Web Hooks
Webhook Signing
const secret = "Api-Secret";
const payload = JSON.stringify(response.body);
console.log(response.body.result);
const devID = response.body.results.devID;
const signature = JSON.parse(response.headers["kaedim-signature"]);
/* {
t : 1235678,
v1:80e62bdd6bddf54905d3cd6e13940626e16aedd....
}*/
const checkSignature = crypto
.createHmac("sha256", secret)
.update(`${signature.t}${payload}`)
.digest("hex");
if (
crypto.timingSafeEqual(
Buffer.from(signature.v1),
Buffer.from(checkSignature)
)
) {
// Authenticity confirmed
console.log("SUCCESS");
} else {
// Reject response
console.log("FAIL");
}Last updated
Was this helpful?