Skip to content

Verify Signature

The following is the method for verifying the signature provided in the header x-webhook-signature.

WARNING

For communication security, please verify the signature provided in the header.

Example

js
function verifySignature(payload, signature, clientSecret) {
  const hash = crypto.createHmac('SHA256', clientSecret)
    .update(JSON.stringify(payload))
    .digest('hex')

  return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(hash))
}