Cluster 14 · Webhook SLA, Signature Replay, RateLimit-* & DLQ Kit · Zero Upload

Webhook HMAC-SHA256 Replay Verifier, RFC RateLimit-* Builder & DLQ Retry Calculator

Compute and verify WebCrypto HMAC-SHA256 signatures with strict replay-window clock checks across Stripe, GitHub, Shopify, Linear, Twilio & Creem, generate compliant RFC RateLimit-* + Retry-After headers, and size exponential backoff + DLQ schedules — backed by WebhookSLA Guard ($29) and SpecDiff.

100% Browser-Side · WebCrypto crypto.subtle · Strict CSP

1. Webhook Signature & Replay-Window Inputs

crypto.subtle HMAC-SHA256
Paste an incoming signature header to run constant-time verification.
Replay-Window & Clock-Skew Gate
42s age vs 300s max
PASS: WITHIN REPLAY WINDOW
Event age 42s is within <=300s tolerance window (258s remaining). Pair with Idempotency/Delivery ID cache. (126 UTF-8 bytes · Stripe signs `${t}.${rawBody}` with HMAC-SHA256 hex and enforces a 300-second default replay window.)
Computed HTTP Signature Header
Stripe-Signature: t=1795705200,v1=1c60a68742c053b3f0e262e2023bb7e9259b0db8e053a17857a45e79ff5aea39
HMAC-SHA256 Hex
1c60a68742c053b3f0e262e2023bb7e9259b0db8e053a17857a45e79ff5aea39
HMAC-SHA256 Base64
HGCmh0LAU7Pw4mLiAju36SWbDbjgU6F4V6Reef9a6jk=
Drop-In WebCrypto Verifier + Replay Guard (verifyWebhook.ts)
// Strict WebCrypto Webhook Verifier + Replay Guard (Cloudflare Workers / Node 20+)
const REPLAY_TOLERANCE_SEC = 300;

function timingSafeEqual(a: Uint8Array, b: Uint8Array): boolean {
  if (a.length !== b.length) return false;
  let diff = 0;
  for (let i = 0; i < a.length; i++) diff |= a[i] ^ b[i];
  return diff === 0;
}

export async function verifyWebhookRequest(request: Request, secret: string): Promise<{ ok: boolean; reason: string; rawBody: string }> {
  const rawBody = await request.text();
  const sigHeader = request.headers.get("stripe-signature") || "";
  const parts = Object.fromEntries(sigHeader.split(",").map((p) => p.split("=")));
  const ts = Number(parts.t || 0);
  const nowSec = Math.floor(Date.now() / 1000);
  if (!ts || nowSec - ts > REPLAY_TOLERANCE_SEC || ts - nowSec > 30) return { ok: false, reason: "replay_window_rejected", rawBody };
  const signedInput = `${ts}.${rawBody}`;
  const providedHex = (parts.v1 || "").toLowerCase();
  const enc = new TextEncoder();
  const key = await crypto.subtle.importKey("raw", enc.encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
  const mac = new Uint8Array(await crypto.subtle.sign("HMAC", key, enc.encode(signedInput)));
  const expectedHex = [...mac].map((b) => b.toString(16).padStart(2, "0")).join("");
  const ok = timingSafeEqual(enc.encode(providedHex), enc.encode(expectedHex));
  return { ok, reason: ok ? "verified" : "invalid_signature", rawBody };
}
WebhookSLA Guard · Live Check $29 WebhookSLA Guard Kit

Verify Live Webhook Replay Defense, 429 Retry-After & DLQ SLA Readiness

Run a live webhook endpoint & SLA audit on WebhookSLA Guard (webhook.runglab.dev), grab the turnkey $29 WebhookSLA Guard Kit (WebCrypto HMAC verifiers, replay-window store, RFC RateLimit-* middleware & DLQ runbooks) on Creem, or audit webhook OpenAPI specs on SpecDiff (spec.runglab.dev). Need a PayPal invoice? Email [email protected].

Free $0-Upfront Webhook SLA & Replay Hardening Sample (1 Tailored File in 15 Min)

$0 Upfront · 15-Min Delivery

Not ready to buy upfront? Enter your work email + domain/repo — we'll send 1 tailored fix file free within 15 min.

$0 upfront · 1 tailored file in 15 min · No spam · Pay only if you want the full pack

10 Enterprise Webhook SLA, Signature & DLQ Implementation Guides

Copy-paste verified handlers across Stripe, GitHub, Shopify, Linear, Twilio, Cloudflare Workers, FastAPI, Express, Next.js & SOC 2.

Ecosystem stack: Study 08: N=40 Webhook & API Benchmark → · WebhookSLA Guard ($29 Kit) → · SpecDiff OpenAPI Audit → · Cluster 7B: CORS & HMAC Debugger → · Cluster 9: OpenAPI OWASP Scorer → · Cluster 13: SOC 2 Trust Center →

Frequently Asked Questions

Does this Webhook HMAC & Replay Verifier send my signing secrets to RungLab servers?

Never. Signature generation and verification run 100% locally in your browser using the Web Crypto API (crypto.subtle) under strict CSP — zero user secrets or payloads ever leave your tab.

Why do I need both a replay-window check and a delivery ID idempotency key?

A timestamp window (e.g., 300s) blocks old captured payloads from hours or days ago, while an idempotency cache (e.g., event.id or X-GitHub-Delivery) prevents duplicate execution within that 300s window.

What HTTP headers should my webhook endpoint return under load spikes?

Return HTTP 429 Too Many Requests with RFC 9110 Retry-After plus IETF RateLimit-Policy and RateLimit headers so compliant senders back off instead of triggering retry storms.