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

@leadrails/sdk

v0.1.2

Published

Server-only SDK to send HMAC-signed lead events to LeadRails. Tested in Node ≥18; portable to Bun, Deno, Cloudflare Workers, Vercel Edge.

Readme

@leadrails/sdk

Server-only SDK to send HMAC-signed lead events to LeadRails. Tested in Node ≥18 (CI runs a pack-and-load smoke against the published artifact); portable to Bun, Deno, Cloudflare Workers, and Vercel Edge — those runtimes will be added to CI as customers adopt them.

Install

pnpm add @leadrails/sdk
npm  install @leadrails/sdk
deno add @leadrails/sdk    # via JSR

Env vars

The SDK auto-reads these from process.env by default:

LEADRAILS_CLIENT_ID=cli_...
LEADRAILS_SOURCE_ID=src_...
LEADRAILS_KEY_ID=key_...
LEADRAILS_SIGNING_SECRET=...          # server-only, NEVER prefix with NEXT_PUBLIC_
LEADRAILS_API_URL=https://intake.leadrails.dev  # optional override

If LEADRAILS_SIGNING_SECRET is detected in a NEXT_PUBLIC_*-prefixed env var, createClient() throws — that prefix inlines the value into the browser bundle and would leak the secret.

Usage

import { createClient, leadEvent } from "@leadrails/sdk";

const client = createClient();  // auto-reads the LEADRAILS_* env vars above

await client.send(
  leadEvent({
    source: { source_system: "world-flags-feedback" },
    lead: {
      full_name: "Jane Doe",
      email: "[email protected]",
      message: "I'd like a quote.",
    },
  }),
);

If you prefer to pass credentials explicitly:

const client = createClient({
  clientId:      "cli_...",
  sourceId:      "src_...",
  keyId:         "key_...",
  signingSecret: "...",        // server-only, never NEXT_PUBLIC_*
  apiUrl:        "https://intake.leadrails.dev", // optional
});

Errors

import { LeadRailsApiError, LeadRailsAuthError } from "@leadrails/sdk";

try {
  await client.send(event);
} catch (err) {
  if (err instanceof LeadRailsAuthError) {
    // 401 — rotate keys
  } else if (err instanceof LeadRailsApiError) {
    // Other non-2xx: err.status, err.errorCode, err.requestId
  } else {
    // Network / fetch error
  }
}

Stable errorCode values: auth_failed, stale_timestamp, replayed_nonce, schema_validation_failed, workflow_paused, idempotency_key_collision, plus HTTP fallbacks like http_500.

Idempotency

By default, the SDK sets X-LR-Idempotency-Key = sha256(body + floor(now / 60s)). Same body within a 60-second window dedupes — covers double-clicks, retries, transient network. Configurable per call:

await client.send(event, { idempotencyKey: "your-stable-key" });

Observability

Optional, off by default:

const client = createClient({
  onRequest({ url, durationMs, status, errorCode }) {
    yourMetrics.increment("leadrails.send", { status });
  },
  onError(err) {
    yourSentry.captureException(err);
  },
});

The SDK never makes a network request the consumer didn't ask for.

License

MIT