The `express-x-hub` package provides an Express.js middleware for validating X-Hub-Signature requests. It was designed to ensure the integrity of incoming webhooks, particularly useful for platforms like Facebook real-time updates and GitHub webhooks, by verifying the request body against a secret using the `X-Hub-Signature` header. The current and only stable version is 1.0.4, last published in October 2015. This package is no longer actively maintained or updated, making it effectively abandoned. Its primary differentiation was its specific focus on adding validation methods directly to the `req` object (`req.isXHub`, `req.isXHubValid()`) within the Express middleware flow, requiring placement *before* any body parsing middleware. It does not provide official TypeScript types.
npm install express-x-hubVerified import paths — ran on the pinned version, not inferred.
This quickstart sets up a basic Express server with the `express-x-hub` middleware to validate incoming webhooks. It demonstrates the critical middleware order (before `body-parser`) and how to use `req.isXHub` and `req.isXHubValid()` to handle and verify signed requests.
Ensure `app.use(xhub(...))` is called *before* `app.use(bodyParser.json())` or `app.use(bodyParser.urlencoded())`.
Evaluate newer, actively maintained alternatives like `x-hub-signature` and its dedicated Express middleware. Be aware of potential API differences when migrating.
Manually extend the `express.Request` interface in your project to include `isXHub: boolean` and `isXHubValid: () => boolean`. Create a declaration file (e.g., `src/types/express-x-hub.d.ts`) with content like: `declare namespace Express { interface Request { isXHub?: boolean; isXHubValid(): boolean; } }`.Add a TypeScript declaration file (e.g., `src/types/express-x-hub.d.ts`) to your project to augment the `express.Request` interface. Example content: `declare namespace Express { interface Request { isXHub?: boolean; isXHubValid(): boolean; } }`. Ensure this file is included in your `tsconfig.json`.1. Verify the `secret` configured in the middleware matches the secret used by the webhook sender. 2. Ensure the `X-Hub-Signature` header is present and correctly formatted in the incoming request. 3. Crucially, confirm that `express-x-hub` is mounted *before* any `body-parser` or other middleware that consumes the raw request body.
No dependency data recorded yet.