
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
koa-github-webhook-secure
Advanced tools
Koa v2 middleware for processing GitHub Webhooks Securely
This library is a middleware for Koa v2 web servers that handles all the logic of receiving and verifying webhook requests from GitHub. It's based on the awesome work by @TinOo512, available here.
import koa from 'koa';
import GithubWebhook from 'koa-github-webhook-secure';
const app = koa();
const githubWebhook = new GithubWebhook({
path: '/webhook',
secret: 'myhashsecret',
});
githubWebhook.on('push', ({ payload }) => {
console.log('Received a push event for repo', payload.repository.name, '-', payload.ref);
});
app.use(githubWebhook.middleware());
app.listen(3000);
koa-github-webhook-secure exports a class, you must instantiate it with an options object. Your options object should contain:
"path"
: the complete case sensitive path/route to match when looking at req.url
for incoming requests.
Any request not matching this path will yield
to the "downstream" middleware."secret"
: this is a hash key used for creating the SHA-1 HMAC signature of the JSON blob sent by GitHub.
You should register the same secret key with GitHub.
Any request not delivering a X-Hub-Signature
that matches the signature generated using this key against the blob will throw an HTTP 400
error code.The class inherits form EventEmitter
.
All Github events are emitted.
See the GitHub Webhooks documentation for more details on the events you can receive.
Additionally, there is a special '*'
event you can listen to in order to receive everything.
koa-github-webhook-secure is licensed under the MIT License. See the included LICENSE.md file for more details.
FAQs
Koa.js middleware for processing GitHub Webhooks
We found that koa-github-webhook-secure demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.