var crypto = require('crypto');
var secret = process.env.SECRET_KEY;
const encoder = new TextEncoder();
// Using Express
app.post("/webhookurl", async function(req, res) {
//validate event
const data = encoder.encode(secret);
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hash = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
if (hash == req.headers['x-dojah-signature-v2']) {
// i.e the hash generated matches with the header signature
}
res.send(200);
});