Community
Samsara Webhook Signature Not Verified
about 1 year ago by Hope Kelly
Hi - For some reason, I am unable to retrieve the expected signature when using webhooks.
Here is the code input:
function(input) {
const webhookSecret = input.secret;
const secret = Buffer.from(webhookSecret, 'base64');
let message = `v1:${input.timestamp}:${JSON.stringify(input.body)}`;
let hmac = crypto.createHmac('sha256', secret).update(message);
let expectedSignature = hmac.digest('hex');
let expectedHeader = 'v1=' + expectedSignature;
return { signature: expectedSignature, header: expectedHeader };
}