@rtorcato/api-webhooks-hono v0.1.0
Interfaces
WebhookOptions
Defined in: index.ts:6
Extends
unknown
Properties
secret
secret:
string
Defined in: index.ts:8
Shared secret used to compute the expected HMAC.
header?
optionalheader?:string
Defined in: index.ts:10
Request header carrying the signature. Default: 'x-signature'.
Functions
webhookMiddleware()
webhookMiddleware(
options):MiddlewareHandler
Defined in: index.ts:32
Hono webhook middleware: verifies the HMAC signature over the raw request
body. Responds 401 with the standard @rtorcato/api-errors envelope on a
missing/invalid signature.
Hono buffers the request body, so a downstream handler can still call
c.req.json() after this middleware has read it as text:
app.post('/webhooks/github', webhookMiddleware({
secret: env.WEBHOOK_SECRET,
header: 'x-hub-signature-256',
prefix: 'sha256=',
}), async (c) => {
const payload = await c.req.json()
return c.body(null, 204)
})
Parameters
options
Returns
MiddlewareHandler