{"id":15097832,"url":"https://github.com/mudkipme/koa-x-hub","last_synced_at":"2025-10-08T02:31:54.912Z","repository":{"id":70709876,"uuid":"116015308","full_name":"mudkipme/koa-x-hub","owner":"mudkipme","description":"X-Hub-Signature Koa Middleware","archived":true,"fork":false,"pushed_at":"2018-01-02T14:28:22.000Z","size":4,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-16T16:30:15.599Z","etag":null,"topics":["koa","koa-middleware","x-hub-signature"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mudkipme.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-02T12:58:08.000Z","updated_at":"2024-05-08T05:59:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"f49fb31e-0641-4f28-9947-bd52779ea2f7","html_url":"https://github.com/mudkipme/koa-x-hub","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"69aa31c529a80d4b8c4523653e0bf31645277bca"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mudkipme%2Fkoa-x-hub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mudkipme%2Fkoa-x-hub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mudkipme%2Fkoa-x-hub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mudkipme%2Fkoa-x-hub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mudkipme","download_url":"https://codeload.github.com/mudkipme/koa-x-hub/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235674061,"owners_count":19027515,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["koa","koa-middleware","x-hub-signature"],"created_at":"2024-09-25T16:40:46.849Z","updated_at":"2025-10-08T02:31:49.612Z","avatar_url":"https://github.com/mudkipme.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"koa-x-hub\n=========\n\n[![NPM version](https://img.shields.io/npm/v/koa-x-hub.svg)](https://npmjs.org/package/koa-x-hub)\n[![build status](https://img.shields.io/travis/mudkipme/koa-x-hub.svg)](https://travis-ci.org/mudkipme/koa-x-hub)\n[![node version](https://img.shields.io/badge/node.js-%3E=_7.6-green.svg)](https://nodejs.org/en/download/)\n\nX-Hub-Signature Koa Middleware.\n\n## Install\n\n[![NPM](https://nodei.co/npm/koa-x-hub.png?downloads=true)](https://nodei.co/npm/koa-x-hub/)\n\n## Usage\n\nAdd the middleware to Koa. It needs to be *after* `bodyParser()`.\n\n```js\nconst Koa = require('koa');\nconst bodyParser = require('koa-bodyparser');\nconst xHub = require('koa-x-hub');\n\nconst app = new Koa();\napp.use(bodyParser());\napp.use(xHub({algorithm: 'sha1', secret: XHUB_SECRET_HERE}));\n```\n\nWhere `XHUB_SECRET_HERE` is your platform's (facebook, github, etc) secret.\n\nThis will add some special sauce to your `ctx.request` object:\n\n### isXHub ```boolean```\n\nIs the request X-Hub. Allows you to early reject any messages without XHub content.\n\n```js\nif (!ctx.request.isXHub) { ctx.throw(403, 'No X-Hub Signature'); }\n```\n\n### isXHubValid ```ctx.request.isXHubValid()```\n\nReturns a boolean value. Validates the request body against the X-Hub signature using your secret.\n\n```js\nif (!ctx.request.isXhub || !ctx.request.isXHubValid()) { ctx.throw(403, 'Invalid X-Hub Request'); }\n```\n\nIf it's valid, then the request has not been tampered with and you are safe to process it.\n\n## Options\n\n* **secret**: X-Hub secret that is used to validate the request body against the signed X-HUB signature on the header. **Required.**\n* **algorithm**: Encryption algorithm used to generate the signature. Default is `sha1`.\n\n## License\n\n[MIT](LICENSE)\n\n## Acknowledgements\n\nThis project is inspired by [express-x-hub](https://github.com/alexcurtis/express-x-hub).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmudkipme%2Fkoa-x-hub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmudkipme%2Fkoa-x-hub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmudkipme%2Fkoa-x-hub/lists"}