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

@sovereignfs/sdk

v2.1.0

Published

How a JavaScript app's server talks to the Sovereign server it signs people in with: tokens, failure, version support.

Readme

@sovereignfs/sdk

How a JavaScript app's server talks to the Sovereign server it signs people in with. It wraps a client generated from core's API contract (bundled in, so there is nothing else to install) with what is tedious to do by hand: tokens, failure, and version support. What it promises is in docs/specs/sdk.md; the contract it never goes beyond is contracts/core-api/openapi.yaml.

npm install @sovereignfs/sdk

It runs on Node 22.3 or later, and on any server runtime that has fetch and Web Crypto.

import { createSovereign } from '@sovereignfs/sdk';

// Reads NOTES_URL, NOTES_CORE_URL, NOTES_CORE_CLIENT_ID and NOTES_CORE_CLIENT_SECRET (or its _FILE form).
// Makes no network call, so the app starts while core is down.
export const sv = createSovereign({ prefix: 'NOTES', tokenStore });

const { users } = await sv.as(person).directory.searchUsers({ q: 'ada' }); // as a person
const branding = await sv.instance.getBranding(); // public, so no actor
  • Actors. Every call names who it is made as: sv.as(person), sv.app, or sv.instance for public calls. A method exists only on an actor that can use it, and the SDK never falls back from one to another.
  • Tokens. An app never handles an access token. Access tokens are cached in memory until 30 seconds before they expire. A person's refresh token is kept in a token store the app gives (read, and a conditional write); core rotates it on every use and takes one used twice for theft, so refreshes run one at a time for each person, and an app that runs more than one process gives its store a lock.
  • Failure. Every call can fail, as one of CoreApiError, CoreUnavailableError, SessionEndedError, NotSupportedError or ConfigurationError. Requests time out (5 seconds), safe ones are retried, and nothing logs a token or a person's details.
  • Version support. The SDK reads the instance document and raises NotSupportedError for a capability this core lacks, without sending the call.
  • Signing in. sv.auth signs people in through core with openid-client (PKCE S256, state, nonce), keeps the sessions in a session store the app gives, and ends them on sign-out and on core's back-channel logout notice, which it verifies (signature, issuer, audience, age, event, jti, and no nonce). The session cookie is host-only (__Host-, Secure, HttpOnly) over https. getSession makes no call to core.
  • Notices without the SDK's sessions. An app whose sessions are its own (it has other ways in, or uses another auth library) verifies core's logout and account-deleted notices with verifyLogoutToken and verifyAccountDeletedToken, which apply every check and end and delete nothing. They need a seen that records each jti; see Using the SDK.
  • Server only. Importing it in a browser throws.

In Next.js

// app/auth/[action]/route.ts: /auth/login, /auth/callback, /auth/logout (POST) and /auth/backchannel-logout (POST)
import { nextAuth } from '@sovereignfs/sdk/next';
export const { GET, POST } = nextAuth(sv).handlers;

// A Server Component:
const session = await nextAuth(sv).requireSession('/notes'); // sends a person to sign in, and back

Register https://notes.sovereign.local/auth/callback as the app's sign-in address, https://notes.sovereign.local/ as its address after sign-out, and https://notes.sovereign.local/auth/backchannel-logout as its back-channel logout address. next is an optional peer dependency, and nothing outside /next needs it.

Testing an app

@sovereignfs/sdk/testing is a core that needs no server:

import { createFakeCore } from '@sovereignfs/sdk/testing';

const core = createFakeCore();
core.addPerson({ sub: 'u1', name: 'Ada Lovelace' });
const sv = createSovereign({
  appUrl: 'https://notes.sovereign.local',
  coreUrl: core.url,
  ...core.credentials,
  tokenStore,
  fetch: core.fetch,
});
await tokenStore.write('u1', core.signIn('u1'), undefined);

core.fail({ kind: 'down' }); // or 'timeout', 'lost-answer', or { kind: 'status', status: 503 }

// Signing in: the person agrees at core, and core can send a logout notice, wrong in any way you want to test.
const back = core.authorize((await sv.auth.beginSignIn()).url, 'u1');
const notice = await core.logoutToken({ sub: 'u1' }, { wrong: 'expired' });

memorySessionStore() is a session store for tests, and memorySeen() a seen for verifyLogoutToken and verifyAccountDeletedToken.

Core versions

This release supports core >=0.46.0 (sovereign.core in package.json). A core too old to say what it serves is treated as serving the Directory and the instance document, and nothing else. The guide for an app's developer is Using the SDK.

Which exports are stable

createSovereign and the error types are stable and change only in a major version; everything else is experimental and may change in a minor version (src/stability.ts lists both).

Versions

This SDK starts at 2.0.0. Versions up to 1.25.0 of @sovereignfs/sdk are the legacy SDK, which ran inside the old platform and is not an earlier release of this one.

Licence

MPL-2.0, so an app under any licence can use it.