Securing your webhooks
When receiving an incoming webhook, it is important to verify that the request came from Finove and was not forged by a third party.
import crypto from 'crypto';
// Should be securely stored in environment variables
const secret = '37b039f76bbe31fd8ed7152031d9fa63';
// From Webhook-Signature header
// Webhook-Signature: sha256=f33e87e8960b16a1541c2fb2219a85c920f3bcf53d90de457ab694aa2392d3a8
const signature = 'f33e87e8960b16a1541c2fb2219a85c920f3bcf53d90de457ab694aa2392d3a8';
// From webhook request
const rawRequestBody = ...;
// Generate signature from webhook body
const generatedSignature = crypto
.createHmac('sha256', secret)
.update(rawRequestBody)
.digest('hex');
const isVerifiedWebhook = crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(generatedSignature));Your secret

Last updated
Was this helpful?