Methods to handle GitHub Webhook requests
npm install @octokit/webhooks-methods> Methods to handle GitHub Webhook requests


Table of contents
- usage
- Methods
- sign()
- verify()
- verifyWithFallback()
- Contributing
- License
Browsers | š§ Load `` |
|---|---|
Node | Install with npm install @octokit/core @octokit/webhooks-methods ` |
`js
await sign("mysecret", eventPayloadString);
// resolves with a string like "sha256=4864d2759938a15468b5df9ade20bf161da9b4f737ea61794142f3484236bda3"
await verify("mysecret", eventPayloadString, "sha256=486d27...");
// resolves with true or false
await verifyWithFallback("mysecret", eventPayloadString, "sha256=486d27...", ["oldsecret", ...]);
// resolves with true or false
`
`js`
await sign(secret, eventPayloadString);
(String) | Required. Secret as configured in GitHub Settings. |
(String) | Required. Webhook request payload as received from GitHub. If you have only access to an already parsed object, stringify it with JSON.stringify(payload) |
Resolves with a signature string. Throws an error if an argument is missing.
`js`
await verify(secret, eventPayloadString, signature);
(String) | Required. Secret as configured in GitHub Settings. |
(String) | Required. Webhook request payload as received from GitHub. If you have only access to an already parsed object, stringify it with JSON.stringify(payload) |
(String) | Required. Signature string as calculated by sign(). |
Resolves with true or false. Throws error if an argument is missing.
`js`
await verifyWithFallback(
secret,
eventPayloadString,
signature,
additionalSecrets,
);
(String) | Required. Secret as configured in GitHub Settings. |
(String) | Required. Webhook request payload as received from GitHub. If you have only access to an already parsed object, stringify it with JSON.stringify(payload) |
(String) | Required. Signature string as calculated by sign(). |
(Array of String) | If given, each additional secret will be tried in turn. |
This is a thin wrapper around verify() that is intended to ease callers' support for key rotation.
Resolves with true or false`. Throws error if a required argument is missing.
See CONTRIBUTING.md