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

@esrating/node

v0.1.0

Published

ESRating Node.js SDK — typed client for the Distribution Hub API + webhook signature verification.

Readme

@esrating/node

Typed Node.js SDK for the ESRating Distribution Hub API. Mints embed sessions, confirms external payments, and verifies inbound webhook signatures.

Install

npm install @esrating/node

Requires Node 18+ (uses native fetch).

Quick start

import { ESRating } from '@esrating/node';

const esrating = new ESRating({ apiKey: process.env.ESRATING_SK_LIVE });

// Inside your /api/start-insurance-session handler:
const session = await esrating.embed.createSession({
  user_id: req.user.id,
  email: req.user.email,
  metadata: { partnerOrderId: req.user.orderId },
});
res.json(session); // → { session_url, expires_at, embed_session_id }

The browser then loads session_url in an iframe via @esrating/embed-js or @esrating/embed-react.

Webhook verification

import express from 'express';
import { ESRating, WebhookSignatureError } from '@esrating/node';

const esrating = new ESRating();
const app = express();

// IMPORTANT — raw body, not JSON-parsed. The signature is over exact bytes.
app.post('/webhooks/esrating', express.raw({ type: 'application/json' }), (req, res) => {
  try {
    const event = esrating.webhooks.constructEvent(
      req.body,
      req.headers['x-esrating-signature'],
      process.env.ESRATING_WEBHOOK_SECRET!,
    );

    switch (event.event) {
      case 'quote.bound':
        await onQuoteBound(event.data);
        break;
      case 'policy.issued':
        await onPolicyIssued(event.data);
        break;
    }
    res.json({ received: true });
  } catch (err) {
    if (err instanceof WebhookSignatureError) {
      res.status(400).json({ error: err.message });
    } else {
      res.status(500).end();
    }
  }
});

Confirm an external payment

For partners who collect payment in their own checkout (their Stripe, their PSP):

await esrating.embed.confirmExternalPayment({
  quote_id: 'quote_abc123',
  external_payment_id: 'pi_partner_xyz',
  amount_cents: 250_000,
  method: 'card',
});

Idempotent — retrying with the same external_payment_id is safe.

Errors

Every non-2xx HTTP response is mapped to a typed subclass of ESRatingError:

import { ESRating, AuthError, ForbiddenError, RateLimitError } from '@esrating/node';

try {
  await esrating.embed.createSession({ ... });
} catch (err) {
  if (err instanceof AuthError) { /* sk_ key bad */ }
  else if (err instanceof ForbiddenError) { /* paused, KYC required, etc. */ }
  else if (err instanceof RateLimitError) {
    await sleep(err.retryAfterSeconds! * 1000);
    // retry
  }
  else throw err;
}

License

Apache-2.0.