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

not-jwt

v1.0.1

Published

Tiny cross-runtime message signer for Node and Web/Edge runtimes.

Readme

not-jwt

A tiny cross-runtime signer for Node and Web/Edge runtimes.

It gives you one simple contract:

  • sign(message) -> signed string
  • verify(signedMessage) -> original message (or throws)

Use it when you want JWT-like tamper protection without full JWT complexity.

Why this exists

JWT is great for standards and interoperability. But many projects only need:

  • signed payloads,
  • fast verification,
  • no external dependencies,
  • same behavior in Node and edge runtimes.

not-jwt focuses on that narrow use case.

Install

npm i not-jwt

Quick start

import notJwt from "not-jwt";

const signer = await notJwt("super-secret-key");

const token = await signer.sign("hello");
const message = await signer.verify(token); // "hello"

Runtime-specific imports

Use these for explicit bundling/runtime control:

import { notJwtNode } from "not-jwt/node";
import { notJwtWeb } from "not-jwt/web";

Or use the default auto-runtime entry:

import notJwt from "not-jwt";

API

notJwt(key: string)

Chooses Node or Web implementation based on runtime.

notJwtNode(key: string)

Node-only implementation.

notJwtWeb(key: string)

Web/Edge-only implementation.

Signer methods

sign(message: string): Promise<string>
verify(signedMessage: string): Promise<string>

key must be non-empty.

Using as a JWT replacement

For many internal apps, this can replace JWT when you do not need RFC JWT features.

Typical pattern:

  1. Put claims into a JSON payload.
  2. Add exp (expiry) yourself.
  3. Sign the serialized payload.
  4. On verify, recover payload from verify(...), then parse and validate claims/expiry.

Example:

import notJwt from "not-jwt";

type Claims = {
  sub: string;
  role: "user" | "admin";
  exp: number; // unix seconds
};

const signer = await notJwt(process.env.AUTH_SECRET!);

export async function createToken(claims: Omit<Claims, "exp">): Promise<string> {
  const payload: Claims = {
    ...claims,
    exp: Math.floor(Date.now() / 1000) + 60 * 60, // 1 hour
  };
  return signer.sign(JSON.stringify(payload));
}

export async function verifyToken(token: string): Promise<Claims | null> {
  try {
    const payload = await signer.verify(token);
    const claims = JSON.parse(payload) as Claims;
    if (claims.exp <= Math.floor(Date.now() / 1000)) return null;
    return claims;
  } catch {
    return null;
  }
}

Important differences vs JWT

  • Not RFC 7519 JWT format (header.payload.signature).
  • No alg/kid headers.
  • No built-in claim parsing (exp, aud, iss) or automatic expiry checks.
  • Not intended for third-party JWT interoperability.

If you need standards-based interoperability, keep using a full JWT library.

Security notes

  • Use a strong random secret key.
  • Rotate keys when needed.
  • Treat verify failures as authentication failures.
  • Treat this as message integrity, not encryption.

Development

pnpm test
pnpm test:coverage
pnpm run build
pnpm run pack:check