Created
November 16, 2022 08:50
-
-
Save robjmills/5729bfa318532b0ae7da45154602be3a to your computer and use it in GitHub Desktop.
Run Javascript in Code by Zapier for validating a HMAC signature in a webhook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let crypto = require('crypto'); | |
let secret = inputData.secret; | |
let webhookBody = inputData.body; | |
let hmacSignature = inputData.hmacSignature; | |
let signature = crypto.createHmac('sha256', secret).update(webhookBody).digest("base64"); | |
const validSignature = (signature === hmacSignature); | |
output = [{isHmacValid: validSignature}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment