Skip to content

WebhookEndpoint

Popii


Popii / WebhookEndpoint

Defined in: plugins/webhook.ts:14

handle(payload, meta): void | Promise<void>

Defined in: plugins/webhook.ts:45

Called with the parsed JSON payload after successful verification.

any

WebhookEndpointMeta

void | Promise<void>

path: string

Defined in: plugins/webhook.ts:16

URL path this endpoint listens on.


optional method?: "GET" | "POST" | "PUT" | "PATCH"

Defined in: plugins/webhook.ts:18

HTTP method to accept. Defaults to “POST”.


optional rateLimit?: object

Defined in: plugins/webhook.ts:23

Per-IP rate limit for this endpoint.

max: number

windowMs: number

rateLimit: { max: 10, windowMs: 60_000 } // 10 req/min

optional secret?: string

Defined in: plugins/webhook.ts:25

Shared secret used for HMAC verification.


optional algorithm?: "sha256" | "sha1" | "md5"

Defined in: plugins/webhook.ts:34

HMAC algorithm preset. Automatically reads the signature from the appropriate header and strips the common prefix:

  • “sha256” → x-hub-signature-256, prefix “sha256=” (GitHub, Stripe, etc.)
  • “sha1” → x-hub-signature, prefix “sha1=”
  • “md5” → x-patreon-signature, no prefix (Patreon) Ignored if verify is provided.

optional signatureHeader?: string

Defined in: plugins/webhook.ts:36

Override which header carries the signature.


optional signaturePrefix?: string

Defined in: plugins/webhook.ts:38

Prefix to strip from the signature header value before comparing.


optional verify?: (body, headers, secret) => boolean | Promise<boolean>

Defined in: plugins/webhook.ts:43

Custom verify function. Return false to reject with 401. Overrides algorithm/signatureHeader/signaturePrefix when provided.

string

Record<string, string>

string

boolean | Promise<boolean>