Skip to content

Instantly share code, notes, and snippets.

@anchan828
Created June 26, 2018 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anchan828/6be2c099a81b47ea069ab76986f62eaf to your computer and use it in GitHub Desktop.
Save anchan828/6be2c099a81b47ea069ab76986f62eaf to your computer and use it in GitHub Desktop.
Favro webhooks for nodejs
import * as bodyParser from "body-parser";
import * as crypto from "crypto";
import {default as express, Request} from "express";
const app = express();
app.use(bodyParser.json()).post("/", (req: Request, res) => {
const secretKey = "1234";
const str = req.body.payloadId + req.body.hook.url;
const sha1 = crypto.createHmac("sha1", secretKey);
const signature = sha1.update(str).digest("base64");
const valid = (req.headers["x-favro-webhook"] as string) === signature;
});
app.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment