-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created a new package for matching V1 webhook requests. Also change implementation to verify via a hmac signature instead of a header/body property value.
- Loading branch information
1 parent
452ba62
commit 6ee73fb
Showing
6 changed files
with
218 additions
and
107 deletions.
There are no files selected for viewing
This file contains 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
7 changes: 7 additions & 0 deletions
7
packages/webhooked-github-request-matchers/src/isRequestFromGithub.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const { createHmac } = require('crypto'); | ||
|
||
module.exports = (req, hmacKey) => | ||
req.headers['x-hub-signature'] === | ||
`sha1=${createHmac('sha1', hmacKey) | ||
.update(JSON.stringify(req.body)) | ||
.digest('hex')}`; |
25 changes: 21 additions & 4 deletions
25
packages/webhooked-github-request-matchers/tests/matchesActions.test.js
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.