I am using Bold Commerce Webhooks to subscribe to subscription events in my store. They give documentation about how their request signatures are generated in PHP:
$now = time(); // current unix timestamp $json = json_encode($payload, JSON_FORCE_OBJECT); $signature = hash_hmac('sha256', $now.'.'.$json, $signingKey); I'm trying to recreate the hash on my side in node.js. From my research I've figured out the following so far, which I believe is pretty close, but doesn't match yet:
const hash = request.header("X-Bold-Signature")!; const SECRET = "my-secret-api-key"; const body = request.body; const time = request.header("timestamp")!; const mySignature = crypto.createHmac('sha256', SECRET).update(time + '.' + body).digest("hex"); if (mySignature !== request.header("X-Bold-Signature")!) { //... } I've also tried using JSON.stringify(body) which changes the hash but still doesn't match.