Skip to content
seedfundedPublic

About

Zero-dependency offline webhook signer, multi-provider verifier, chaos simulator, and CI test harness

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

hookspec

Zero-dependency offline webhook signer, multi-provider verifier, chaos simulator, and CI test harness.

Test Stripe, GitHub, Shopify, Slack, Svix/Clerk/Resend, Linear, Twilio, and Discord webhooks locally and in CI with provider-accurate cryptographic signatures and automated chaos scenarios—no tunnels, no accounts, and zero runtime dependencies.

Built purely on the Web Crypto API (crypto.subtle), so the SDK runs identically in Node.js 20+, Bun, Deno, Cloudflare Workers, and Next.js Edge.

Supported Providers

Provider Aliases Signature Scheme Replay Window
Stripe stripe Stripe-Signature: t=...,v1=... (HMAC-SHA256, multi-sig) Yes (300s default)
Paddle Billing paddle Paddle-Signature: ts=...;h1=... (HMAC-SHA256, multi-sig) Yes (300s default)
Lemon Squeezy lemonsqueezy X-Signature (HMAC-SHA256) + X-Event-Name No
GitHub github X-Hub-Signature-256: sha256=... (HMAC-SHA256) No
GitLab gitlab X-Gitlab-Token (constant-time token) No
Shopify shopify X-Shopify-Hmac-Sha256 (Base64 HMAC-SHA256) No
Slack slack X-Slack-Signature: v0=... + X-Slack-Request-Timestamp Yes (300s default)
Svix svix, clerk, resend svix-signature: v1,<base64> + webhook-* fallback Yes (300s default)
Standard Webhooks standard, openai, supabase, polar webhook-signature: v1,<base64> + webhook-id, webhook-timestamp Yes (300s default)
Linear linear Linear-Signature (HMAC-SHA256 + optional webhookTimestamp) Optional
Vercel vercel x-vercel-signature (HMAC-SHA1) No
Twilio twilio X-Twilio-Signature (HMAC-SHA1 over URL + sorted params / bodySHA256) No
Discord discord X-Signature-Ed25519 + X-Signature-Timestamp (Ed25519) Optional

Quickstart (CLI)

# Send a signed Stripe webhook to localhost (zero ngrok)
npx hookspec send stripe payment_intent.succeeded \
  --url http://localhost:3000/api/webhooks/stripe \
  --secret whsec_test_123

# Run the full chaos & security suite against your endpoint
npx hookspec chaos stripe \
  --url http://localhost:3000/api/webhooks/stripe \
  --secret whsec_test_123 \
  --junit ./webhook-chaos.xml

# Record live webhooks into redacted fixtures, then replay them in CI
npx hookspec record --port 4040 --forward http://localhost:3000/api/webhooks --out ./fixtures
npx hookspec replay ./fixtures --url http://localhost:3000/api/webhooks --resign github --secret dev_secret

# List all providers & events, or generate an Ed25519 keypair for Discord
npx hookspec list
npx hookspec keygen

Quickstart (SDK)

npm install hookspec
import { createWebhookHandler } from 'hookspec';

export const POST = createWebhookHandler<{ id: string; type: string }>({
  provider: 'stripe',
  secret: [process.env.STRIPE_WEBHOOK_SECRET!, process.env.STRIPE_WEBHOOK_SECRET_PREV!],
  idempotency: true,
  on: {
    'payment_intent.succeeded': async ({ payload }) => {
      return Response.json({ received: true, id: payload.id });
    },
    '*': async ({ eventName }) => Response.json({ ignored: eventName }),
  },
});

Node.js / Express / Fastify Middleware

Use createNodeWebhookHandler to mount the same raw-body verification, maxBodyBytes (413), POST-only (405), two-phase idempotency, and event routing directly on node:http, Express, Fastify, or Koa:

import http from 'node:http';
import { createNodeWebhookHandler } from 'hookspec';

const stripeHandler = createNodeWebhookHandler<{ id: string; type: string }>({
  provider: 'stripe',
  secret: process.env.STRIPE_WEBHOOK_SECRET!,
  idempotency: true,
  on: {
    'payment_intent.succeeded': async ({ payload }) => Response.json({ ok: true, id: payload.id }),
  },
});

http.createServer((req, res) => {
  if (req.url === '/webhooks/stripe') return void stripeHandler(req, res);
  res.writeHead(404).end();
});

Zero-Socket In-Process Chaos Testing

Test your webhook handler in node:test, Vitest, or Jest in milliseconds without binding a port:

import { testWebhookHandler } from 'hookspec';

const report = await testWebhookHandler(POST, {
  provider: 'stripe',
  secret: 'whsec_test_123',
});
assert.equal(report.passed, true);

Custom Providers (Extensible Registry)

Register internal or niche webhook providers with defineHmacProvider + registerProvider (or an isolated createRegistry()), and they automatically work with verifyWebhook, detectProvider, createWebhookHandler, and runChaosSuite:

import { defineHmacProvider, registerProvider } from 'hookspec';

registerProvider(
  defineHmacProvider({
    id: 'acme',
    displayName: 'Acme Pay',
    signatureHeader: 'X-Acme-Signature',
    algorithm: 'SHA-256',
    encoding: 'hex',
    signaturePrefix: 'sha256=',
  })
);

GitHub Action (CI Gate)

- name: Verify webhook security & idempotency
  uses: seedfunded/hookspec@v1
  with:
    provider: stripe
    url: http://127.0.0.1:3000/api/webhooks/stripe
    secret: ci_test_secret
    junit: hookspec-junit.xml

Two-Phase Lease Idempotency & Auto-Detection

createIdempotencyGuard acquires a short processing lease (leaseSeconds: 30) while your handler runs, then commits the key to done (ttlSeconds: 86_400) on completion. If your process crashes or gets SIGKILLed mid-handler, the 30s lease expires so the provider's retry cleanly recovers the event instead of dropping it for 24 hours.

import { createIdempotencyGuard, detectProvider, verifyWebRequest } from 'hookspec';

const guard = createIdempotencyGuard({ leaseSeconds: 30, ttlSeconds: 86_400 });

export async function POST(request: Request) {
  const provider = detectProvider(request.headers);
  if (!provider) return Response.json({ error: 'Unknown provider' }, { status: 400 });

  const verified = await verifyWebRequest(provider, request, {
    secret: process.env.WEBHOOK_SECRET!,
  });
  if (!verified.valid) return Response.json({ error: verified.code }, { status: 400 });

  const event = JSON.parse(verified.rawBody) as { id: string };
  const outcome = await guard.run(event.id, async () => {
    // Runs at most once even under simultaneous duplicate webhook retries
    return { processed: true };
  });

  return Response.json({ received: true, duplicate: outcome.duplicate });
}

Benchmarks

Measured with node scripts/bench.mjs (2,000 verifications per provider, Node v26.13.1, Apple M5):

Provider Throughput Time (2,000 verifications)
GitLab 1,421,758 ops/sec 1.4ms
Vercel 89,926 ops/sec 22.2ms
Linear 87,638 ops/sec 22.8ms
Shopify 77,071 ops/sec 26.0ms
Paddle Billing 73,413 ops/sec 27.2ms
Slack 71,721 ops/sec 27.9ms
GitHub 68,505 ops/sec 29.2ms
Lemon Squeezy 68,360 ops/sec 29.3ms
Svix / Clerk / Resend / Polar 67,033 ops/sec 29.8ms
Twilio 66,478 ops/sec 30.1ms
Stripe 49,128 ops/sec 40.7ms

License

MIT © 2026 (@seedfunded)

About

Zero-dependency offline webhook signer, multi-provider verifier, chaos simulator, and CI test harness

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages