Catalog npm
PACKAGE EXPLORERView in registry

@021.is/spine-webhooks

npm

Inbound webhook verifier: HMAC signature + replay/idempotency dedupe. Generalized from DC's Resend/Stripe handlers.

Versions collected2
Direct dependencies1From release 0.4.3
Last observed20 Oct, 22:00 UTC

README

Current package documentation

@021.is/spine-webhooks

Inbound webhook HMAC verifier (4 formats: raw, GitHub sha256=…, Stripe t=…,v1=… with tolerance window, Resend svix-style v1,<b64>) + idempotency-key dedupe store. Timing-safe comparisons throughout.

Use

import { makeHmacVerifier, makeMemoryIdempotencyStore } from "@021.is/spine-webhooks";

const stripe = makeHmacVerifier({
  secret: env.STRIPE_WEBHOOK_SECRET,
  toleranceSec: 5 * 60, // 5min — Stripe's recommended max clock skew
});

export const POST = withErrorHandling(async (req: Request) => {
  const rawBody = await req.text();
  const signature = req.headers.get("stripe-signature");
  if (!signature) throw new BadRequestException("missing signature");

  stripe.verify({ payload: rawBody, signature, headerScheme: "stripe" });

  const event = JSON.parse(rawBody);
  const seen = await store.seen(event.id);
  if (seen) return Response.json(ok({ duplicate: true }));

  await handleStripeEvent(event);
  return Response.json(ok({ processed: true }));
});

Schemes

What
rawPlain HMAC-SHA256 hex of body
githubsha256=<hex> prefix
stripet=<unix>,v1=<sig> — body is ${ts}.${rawBody}; tolerance window enforces freshness
resendsvix-style v1,<base64>

Idempotency

Webhooks retry on network failure. Without dedup you charge twice / send twice / publish twice. store.seen(key, ttlSec) returns true if the key has been seen within TTL — first call returns false + records; subsequent calls return true.

Memory store for tests + tiny apps. Wire to your Prisma idempotency table for production.

Timing-safe comparisons

All signature checks use crypto.timingSafeEqual — string compare is timing-attackable.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 2

Collected releases
VersionPublishedDirect dependenciesOpen version
0.4.3Registry latest28 May 20261
0.4.028 May 20261

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
021is/spine-ts

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:00 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:5c78586cefc97878bd8f59ec0c28a2a5ab651e967e3b40d7d169ef9aa0cf2d6d