· 7 years ago · Jun 26, 2018, 10:10 PM
1import * as bodyParser from "body-parser";
2import * as crypto from "crypto";
3import {default as express, Request} from "express";
4
5const app = express();
6
7app.use(bodyParser.json()).post("/", (req: Request, res) => {
8 const secretKey = "1234";
9 const str = req.body.payloadId + req.body.hook.url;
10 const sha1 = crypto.createHmac("sha1", secretKey);
11 const signature = sha1.update(str).digest("base64");
12
13 const valid = (req.headers["x-favro-webhook"] as string) === signature;
14});
15
16app.listen(3000);