npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@useatlas/webhook-publisher

v0.0.1

Published

Framework-free outbound webhook sender for Atlas — HMAC signing strategies + bounded retry

Readme

@useatlas/webhook-publisher

Framework-free outbound webhook sender for Atlas — pluggable HMAC signing strategies + bounded retry with a tagged delivery outcome.

It's the one primitive behind Atlas's outbound senders (the sub-processor change feed, SLA alerts, and the @useatlas/webhook-action plugin), so signing and retry behave identically everywhere and no consumer's on-the-wire format drifts.

No dependencies. No Effect, no logger, no validation library — just fetch and node:crypto. The server wraps the result in its structured logger; the plugin (which has no Effect runtime) awaits it directly.

Install

bun add @useatlas/webhook-publisher

Usage

import {
  deliverWebhook,
  timestamped,
  cappedExponentialDelays,
} from "@useatlas/webhook-publisher";

const outcome = await deliverWebhook({
  url: "https://hooks.example.com/atlas",
  payload: { event: "added", entry },
  sign: timestamped({ secret: process.env.WEBHOOK_SECRET! }),
  retry: { maxAttempts: 3, delaysMs: cappedExponentialDelays({ baseMs: 1000, count: 2 }) },
  timeoutMs: 10_000,
});

switch (outcome.kind) {
  case "ok":
    break; // delivered; outcome.signature is the header value, for audit
  case "http_error":
    console.warn(`rejected: HTTP ${outcome.status} after ${outcome.attempts} attempts`);
    break;
  case "transport_error":
    console.warn(`unreachable: ${outcome.error} after ${outcome.attempts} attempts`);
    break;
}

Signing strategies

Both are pure functions of the serialized body. deliverWebhook signs the body once and reuses the headers across retries, so a timestamp (when present) is stable for the whole delivery.

timestamped({ secret, timestampSeconds? }) — Atlas house standard

X-Webhook-Signature: sha256=<hmac(`${ts}:${body}`)>
X-Webhook-Timestamp: <unix-seconds>

The sha256= prefix is Stripe/GitHub style, and this is byte-identical to Atlas's existing sub-processor sender. The ${ts}:${body} signing input matches the inbound @useatlas/webhook verifier, but that verifier compares against bare hex — so receivers strip the sha256= prefix first, as the verify-helper below (and the one in the sub-processor docs) does.

Verify recipe (receiver):

import crypto from "node:crypto";

function verify(secret: string, header: string, timestamp: string, rawBody: string): boolean {
  // Reject requests older than 5 minutes to block replays.
  if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;
  const expected = crypto.createHmac("sha256", secret).update(`${timestamp}:${rawBody}`).digest("hex");
  const provided = header.replace(/^sha256=/, "");
  const a = Buffer.from(expected);
  const b = Buffer.from(provided);
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

rawBody({ secret }) — Stripe/GitHub style

X-Atlas-Signature: <hmac(rawBody)>

Bare hex over the exact request body, no timestamp.

const expected = crypto.createHmac("sha256", secret).update(rawBody).digest("hex");
// constant-time compare expected against the X-Atlas-Signature header

Retry & failure classification

Retry is supplied explicitly — the package never invents a backoff schedule:

retry: { maxAttempts: 4, delaysMs: [250, 1000, 4000] }
  • 2xxok, stop.
  • 4xxpermanent. The receiver rejected the payload; retrying just spams them. Stops and reads a bounded body excerpt (responseText).
  • 5xx / transport error / timeout → transient. Retried per the policy.

cappedExponentialDelays({ baseMs, count, factor?, maxMs? }) builds a capped exponential schedule. Each attempt has its own timeoutMs (default 30s) via AbortController. Pass onFailedAttempt to emit a breadcrumb per failed attempt, and fetcher / sleep to inject test seams.

License

MIT