Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@stpe
Created May 28, 2020 09:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stpe/5f3fffcebf3ecfd931dc5d1e4fec7166 to your computer and use it in GitHub Desktop.
Save stpe/5f3fffcebf3ecfd931dc5d1e4fec7166 to your computer and use it in GitHub Desktop.
How to calculate Clearbit API webhook X-Request-Signature in Node.js / JavaScript / TypeScript
import * as crypto from 'crypto';
export class ClearbitSignatureValidation {
static getSignature(raw_body: string, signature: string): string {
const signature_without_prefix = signature.replace(/^(sk\_)/, '');
return (
'sha1=' +
crypto
.createHmac('sha1', signature_without_prefix)
.update(raw_body)
.digest('hex')
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment