Skip to content

@terminaldz/zrexpress-sdk / webhooks / WebhookVerifier

Class: WebhookVerifier ​

Defined in: webhooks/verifier.ts:17

Constructors ​

Constructor ​

ts
new WebhookVerifier(secret): WebhookVerifier;

Defined in: webhooks/verifier.ts:25

Parameters ​

ParameterTypeDescription
secretstringthe endpoint signing secret (whsec_…) from zr.webhookEndpoints.getSecret().

Returns ​

WebhookVerifier

Throws ​

ZrExpressWebhookVerificationError when the secret is empty/invalid.

Methods ​

verify() ​

ts
verify(rawBody, headers): ParcelWebhookEvent;

Defined in: webhooks/verifier.ts:45

Verify a delivery and return the typed event. Pass the raw body (string or Buffer) exactly as received — not a re-serialized object.

Parameters ​

ParameterType
rawBodystring | Buffer<ArrayBufferLike>
headersRecord<string, string>

Returns ​

ParcelWebhookEvent

Throws ​

ZrExpressWebhookVerificationError on a bad signature, a stale timestamp, a tampered body, or an unrecognized payload shape.

Released under the MIT License. Not affiliated with ZR Express.