Skip to content

tys.webhooks.verifySignature()

Method@tryyoursize/node

Checks the signature only (throws when it does not verify). Use constructEvent() unless you parse the body yourself.

verifySignature(
rawBody: RawBody,
signatureHeader: string | string[] | null | undefined,
secret: string,
opts?: ConstructEventOptions,
): void
rawBodyRawBodyRequired

The raw request body.

signatureHeaderstring | string[] | null | undefinedRequired

The TYS-Signature header.

secretstringRequired

The signing secret (whsec_…).

optsConstructEventOptionsOptional
Properties
toleranceSecondsnumber | undefinedOptional

Maximum |now − t| in seconds (default 300). 0 or less disables the check.

nownumber | Date | undefinedOptional

The current time (unix seconds or a Date); for tests.

tys.webhooks.verifySignature(rawBody, req.headers["tys-signature"], secret); // throws SignatureVerificationError

Was this page helpful?