Skip to main content
The Web Crypto API ships with every modern runtime — Edge, Node 18+, every modern browser. Single dependency-free implementation. Full source (verbatim): docs/examples/webhook-receivers/typescript-cloudflare-worker/worker.ts

worker.ts

Deploy on Cloudflare Workers

To pin a different key (during a rotation):
The deployed URL becomes https://pegana-hook.<account>.workers.dev — register it in pegana.xyz/account/webhooks.

Deploy on Vercel Edge

Same logic in app/api/pegana-hook/route.ts:

Node 18+ (Express, Fastify)

Same verification. Make sure you read the raw body before any JSON middleware:

Production checklist

  • Persist alert_id in a real store (Cloudflare KV, Redis, your DB)
  • Pin PEGANA_PUB_KEY_B64 via secrets, not in source — easier rotation
  • ACK with 200 (or 202) within ~100ms; queue real work to a background runner
  • Log failed verifications with timestamp + remote IP for audit
  • Poll /v1/me/alerts as a safety net (catch deliveries that exhausted retries)
  • Set Content-Type on your response — some load balancers strip empty bodies

Why Web Crypto and not @noble/ed25519

The Web Crypto API is standardized, audited, and ships with every modern runtime (Workers since 2023 via Secure Curves; Node since 18 via webcrypto). @noble/ed25519 is excellent and you may need it for older Node versions (<18) — but for new code, Web Crypto is one less dependency.

Next

Rust example

axum + ed25519-dalek strict mode.

Retry policy

Failure modes, backoff, replay.