@mxraven/mail - v0.2.0
    Preparing search index...

    Class Verifier

    Verifies the signature of an mxRaven webhook request.

    A verifier is safe for concurrent use once constructed. Configure it with a signing secret or with per-key secrets for rotation.

    const secret = process.env.MXRAVEN_WEBHOOK_SECRET;
    if (secret === undefined || secret === "") {
    throw new Error("MXRAVEN_WEBHOOK_SECRET is required");
    }

    const verifier = new Verifier({ secret });
    const event = await verifier.verifyAndDecode(request);
    Index
    • Verifies a request's signature.

      The body is read from a clone, so the caller can still read the original request body afterwards.

      Parameters

      • request: Request

        The incoming request.

      • options: VerifyOptions = {}

        An optional cancellation signal.

      Returns Promise<void>

      InvalidSignatureError When the signature does not match.

      Error When required headers are missing, the timestamp is stale, or the body exceeds the configured limit.

    • Verifies a request and decodes its payload.

      Parameters

      • request: Request

        The incoming request.

      • options: VerifyOptions = {}

        An optional cancellation signal.

      Returns Promise<Event>

      The decoded event.

      InvalidSignatureError When the signature does not match.

      Error When verification or decoding fails.