Astrada TypeScript SDK
    Preparing search index...

    Function verifyWebhook

    • Checks the signature and age of a webhook delivery and returns the parsed body. Throws WebhookVerificationError when the delivery must be rejected.

      Type Parameters

      • T = unknown

      Parameters

      • payload: string | Uint8Array<ArrayBufferLike>

        the raw request body, exactly as received (do not parse and re-serialise it), as a string or as bytes (a Node.js Buffer is a Uint8Array, so it can be passed as is)

      • headers: WebhookHeaders

        the request headers

      • secret: string

        the webhook's secret, as returned when the webhook was created

      • options: VerifyWebhookOptions = {}

      Returns T

      WebhookVerificationError if the signature does not match or the delivery is too old or too new

      RangeError for a configuration mistake: a missing or non-base64 secret, or an invalid toleranceSeconds