@bates-solutions/payments-core API Reference - v0.2.0
    Preparing search index...

    Function verifyTimestampedHmac

    • Verify a timestamped HMAC-SHA256 signature header, the scheme Stripe and Clover use: the provider signs ${timestamp}.${payload} and sends t=<timestamp>,v1=<hex signature>.

      Checks, in order: the header parses, one of the listed signatures matches (each compared in constant time), and the timestamp is within the tolerance. The caller checks for a missing payload, header or secret first and maps the failure reason to its own messages; an empty secret makes the promise reject (see hmacSha256).

      Parameters

      Returns Promise<TimestampedHmacResult>

      const result = await verifyTimestampedHmac(rawBody, header, signingSecret);
      if (!result.valid && result.reason === 'timestamp-outside-tolerance') {
      // reject a replayed webhook
      }