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

@tolt/webhooks

v0.1.0

Published

Verify and type Tolt webhooks. A dependency-free signature verifier plus typed events.

Readme

@tolt/webhooks

Verify and type Tolt webhooks. A dependency-free signature verifier plus typed events, so you can react to program activity without trusting an unverified payload.

Install

npm install @tolt/webhooks

Verify a webhook

Pass the raw request body, the request headers, and your endpoint's signing secret (whsec_...). You get back a typed event, or a WebhookVerificationError if it can't be trusted.

Next.js (App Router)

import { verifyWebhook } from "@tolt/webhooks";

export async function POST(req: Request) {
  const event = verifyWebhook({
    payload: await req.text(), // raw body
    headers: req.headers,
    secret: process.env.TOLT_WEBHOOK_SECRET!,
  });

  switch (event.type) {
    case "commission.created":
      // event.data is a ToltCommission
      await payPartner(event.data.partner_id, event.data.amount);
      break;
    case "partner.created":
      await onboard(event.data.email);
      break;
  }

  return new Response("ok");
}

Express

import express from "express";
import { verifyWebhook, WebhookVerificationError } from "@tolt/webhooks";

// IMPORTANT: use the raw body, not express.json()
app.post("/tolt/webhook", express.raw({ type: "application/json" }), (req, res) => {
  try {
    const event = verifyWebhook({
      payload: req.body.toString("utf8"),
      headers: req.headers,
      secret: process.env.TOLT_WEBHOOK_SECRET!,
    });
    // handle event...
    res.sendStatus(200);
  } catch (err) {
    if (err instanceof WebhookVerificationError) return res.sendStatus(400);
    throw err;
  }
});

Events

Narrow on event.type and event.data is typed for you.

| Event | data | | --- | --- | | partner.created, partner.updated | ToltPartner | | link.created, link.updated | ToltLink | | customer.created, customer.updated | ToltCustomer | | transaction.created, transaction.updated | ToltTransaction | | commission.created, commission.updated | ToltCommission |

Every event is { type, data, timestamp }.

Notes

  • Always pass the raw body. Re-serializing a parsed JSON object changes the bytes and the signature won't match.
  • Verification includes a timestamp check (default 5 minutes) to guard against replays. Adjust with toleranceInSeconds.

License

Apache-2.0