Add verifyMailGateWebhook HMAC-SHA256 helper to mailgate-sdk

Aperta
#13 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
75/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, typescript

Direzione di ricerca

Start by reading src/lib/crypto.ts and the SDK entry points sdk/index.mjs and sdk/index.d.ts. Add the helper and focused unit tests for valid, tampered, invalid, and expired requests; document a usage snippet in sdk/README.md. Done means the helper is exported with TypeScript declarations, uses no external dependencies, and npm run typecheck and npm test pass.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement good first issue help wanted

Context

cloudflare-bridge/ forwards inbound emails as HMAC-SHA256 signed JSON webhooks (X-MailGate-Signature and X-MailGate-Timestamp), and src/lib/crypto.ts already implements erifyWebhookSignature for the Worker side.

Users consuming cloudflare-bridge/ webhooks in Express, Fastify, Hono, or Next.js routes currently have to re-implement timestamp drift checks and constant-time HMAC verification themselves.

Proposed Scope

  • Export erifyMailGateWebhook({ rawBody, signature, timestamp, secret, maxDriftSeconds }) from sdk/index.mjs (and TypeScript declarations in sdk/index.d.ts).
  • Use Web Crypto (crypto.subtle) or Node built-ins only, with constant-time comparison and configurable replay window (default 300s).
  • Add unit tests covering valid signature, tampered body, invalid signature, and expired timestamp.
  • Document usage with a short snippet in sdk/README.md.

Constraints

  • Zero external dependencies in sdk/.
  • Run
    pm run typecheck and
    pm test before opening a PR.
Lingua principale
JavaScript
Stelle
0
Fork
3
Merge medio
1h 15m
PR unite (30g)
4

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Dicka18/mailgate

Tutte le issue di Dicka18/mailgate

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.