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

@torii-backend/sdk

v0.0.2

Published

Backend SDK for torii — verify JWTs, manage users, react to events from your Node server.

Downloads

285

Readme

@torii-backend/sdk

Backend SDK for torii — verify end-user JWTs without a per-request round trip and manage users from your Node server.

v0.x — API may still change.

Setup

  1. Sign in to app.torii.so and from your dashboard copy:

    • your issuer URL (e.g. https://acme.torii.so)
    • a secret key (sk_test_… for development, sk_live_… for production)
  2. Install the SDK:

    bun add @torii-backend/sdk
    # or: npm install @torii-backend/sdk

    Node 18+ (global fetch). Bun is supported.

  3. Verify an end-user JWT:

    import { verifyToken } from "@torii-backend/sdk";
    
    const auth = await verifyToken(token, {
      issuer: "https://acme.torii.so",
    });
    
    console.log(auth.userId, auth.environmentId, auth.emailVerified);

    The first call fetches the issuer's JWKS; subsequent calls reuse the cache and rotate keys automatically (handled by jose). No round trip per request.

  4. Call the backend REST API:

    import { createToriiClient } from "@torii-backend/sdk";
    
    const torii = createToriiClient({
      secretKey: process.env.TORII_SECRET_KEY!,
    });
    
    const user = await torii.users.get(userId);

    Default base URL is https://api.torii.so. Override with apiUrl for staging or self-hosted.

Express middleware

import express from "express";
import { requireAuth } from "@torii-backend/sdk/express";

const app = express();

app.get(
  "/me",
  requireAuth({ issuer: "https://acme.torii.so" }),
  (req, res) => {
    res.json({ user: req.auth!.userId });
  },
);

Backend API

const page = await torii.users.list({ limit: 50 });
const user = await torii.users.create({ email: "[email protected]" });
await torii.users.ban(user.id);

const sessions = await torii.sessions.listForUser(user.id);
await torii.sessions.revokeAllForUser(user.id);

PATCH semantics

torii.users.update() takes a partial body where each field is tri-state — T | null | undefined:

await torii.users.update(userId, {
  name: "Ada",       // → server updates name
  phone: null,       // → server clears phone
  // address absent  → server leaves address alone
});
  • A value (e.g. "Ada") updates the field.
  • null clears the field.
  • undefined (or omitting the key) leaves the field alone.

This works because JSON.stringify drops undefined keys but emits null — which is exactly the wire contract the server expects for PATCH bodies.

License

MIT