Created
June 26, 2018 10:13
-
-
Save anchan828/6be2c099a81b47ea069ab76986f62eaf to your computer and use it in GitHub Desktop.
Favro webhooks for nodejs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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