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

@deeblr/auth-jwt

v0.4.0

Published

JWT access tokens, refresh-token rotation with reuse detection, and Personal Access Tokens for Deeblr Auth. Zero runtime dependencies (Node's built-in crypto only).

Readme

@deeblr/auth-jwt

Real RFC 7519 JWT access tokens, refresh-token rotation with reuse detection, and Personal Access Tokens for Deeblr Auth. Zero runtime dependencies — everything is built on Node's crypto module, not jsonwebtoken.

Install

npm install @deeblr/auth-jwt

Most people won't install this directly — configure apiTokens (and optionally sessions: { strategy: "jwt" }) on @deeblr/auth's DeeblrAuth. Install it directly if you're building on @deeblr/auth-core/@deeblr/auth-session yourself.

JWT (JwtSigner)

import { JwtSigner } from "@deeblr/auth-jwt";

const signer = new JwtSigner({
  algorithm: "HS256",       // or "RS256" with { privateKey, publicKey }
  secret: process.env.JWT_SECRET!,
  issuer: "my-app",
  audience: "my-app-api",
});

const token = signer.sign({
  subject: user.id,
  expiresInSeconds: 900,
  claims: { role: "admin", organization: "org_1" }, // custom claims
});

const claims = signer.verify(token); // throws TOKEN_INVALID / TOKEN_EXPIRED
const inspected = signer.decode(token); // NO signature check — inspection only, never for auth decisions

RS256 is for deployments where the service verifying tokens must not be able to mint them — distribute publicKey freely, keep privateKey only where tokens are issued.

Refresh tokens (RefreshTokenService)

Opaque, hashed-at-rest, one-time-use tokens with reuse detection:

import { RefreshTokenService, InMemoryTokenStore } from "@deeblr/auth-jwt";

const service = new RefreshTokenService({ store: new InMemoryTokenStore(), clock, hooks, ttlSeconds: 60 * 60 * 24 * 30 });

const { token } = await service.issue(user.id);
const { token: newToken } = await service.rotate(token); // old token is now dead
await service.revoke(newToken);       // kill one token
await service.revokeFamily(familyId); // kill every token descended from one login ("log out everywhere")

Rotation IS one-time use — every rotate() call revokes the presented token before issuing its replacement. If an already-rotated (dead) token is ever presented again, that's treated as a compromise signal and the entire family is revoked, forcing re-authentication — the same strategy Auth0 and most modern OAuth implementations use.

InMemoryTokenStore is real and functional (fine for dev/single-instance), not a placeholder. For multi-instance production, supply your own TokenStore (4 methods) backed by a database or Redis.

Personal Access Tokens / API keys / service tokens

import { PersonalAccessTokenService } from "@deeblr/auth-jwt";

const pats = new PersonalAccessTokenService({ store, clock, hooks });
const { token } = await pats.create({ userId, name: "CI token", scopes: ["repo:read"], expiresInSeconds: 60 * 60 * 24 * 90 });

const record = await pats.verify(token, "repo:read"); // throws PERMISSION_DENIED if missing the scope
await pats.revoke(record.id);

TokenManager — the combined auth.tokens.* API

import { TokenManager } from "@deeblr/auth-jwt";

const tokens = new TokenManager({
  jwt: { secret: process.env.JWT_SECRET! },
  clock,
  hooks,
  accessTokenTtlSeconds: 900,       // default
  refreshTokenTtlSeconds: 2592000,  // default (30 days)
});

const pair = await tokens.create({ userId: user.id, claims: { role: "admin" } });
tokens.verify(pair.accessToken);
await tokens.refresh(pair.refreshToken);
await tokens.revoke(pair.refreshToken);
await tokens.createPersonalAccessToken({ userId: user.id, scopes: ["read"] });

session: { strategy: "jwt" } — stateless sessions

JwtSessionStrategy implements @deeblr/auth-session's SessionStrategy using signed JWTs — no storage at all. Stated honestly:

  • touch() (sliding expiration) always returns a new session id (a freshly-signed token) — a JWT can't be edited in place.
  • list() / destroyAllForUser() throw AuthConfigError — nothing is persisted to enumerate. Need "list my sessions" or "log out everywhere"? Use the memory/database strategy, or RefreshTokenService (which IS persisted for exactly this reason).
  • destroy() is a documented no-op unless you supply a revocationCache (any CacheAdapter), in which case it adds the token's jti to a denylist for its remaining lifetime.
sessions: {
  strategy: "jwt",
  jwt: { secret: process.env.SESSION_JWT_SECRET! },
  revocationCache: myRedisCacheAdapter, // optional
}

Hooks and events

auth:beforeTokenIssue, auth:afterTokenIssue, plus token.created, token.revoked (includes reason: "reuse_detected" when applicable), token.rotated — declaration-merged onto the shared AuthHookEventMap.

License

MIT