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

@lookworld4/edge-jwt-lite

v1.0.0

Published

JWT decode and verify using Web Crypto only — no Node.js crypto — for Cloudflare Workers, Vercel Edge, browsers, and other Edge runtimes.

Readme

@lookworld4/edge-jwt-lite

Decode and verify JWTs using Web Crypto only (globalThis.crypto.subtle). There are no imports from Node’s crypto, buffer, or other Node-only primitives, so the same code runs in Cloudflare Workers, Vercel Edge Functions, browsers, Deno with Web Crypto, and other constrained runtimes.

Why use this?

Many JWT libraries rely on Node’s cryptographic APIs. Edge platforms often disallow those entirely. This library keeps the surface small — compact JWS verification for HS256, RS256, and ES256 — and stays inside the cryptographic APIs your Edge runtime already provides.

Installation

npm install @lookworld4/edge-jwt-lite

Requires a runtime where globalThis.crypto.subtle and atob are available (standard on Workers and modern browsers).

Quick start

Verify (recommended for authorization decisions):

import { verifyJwt } from '@lookworld4/edge-jwt-lite';

// HS256 shared secret (UTF-8 string or Uint8Array)
const { header, payload } = await verifyJwt(token, {
  algorithm: 'HS256',
  secret: process.env.JWT_SECRET!, // Workers: env binding
});

// RS256 PEM public key (SPKI, -----BEGIN PUBLIC KEY-----)
await verifyJwt(token, {
  algorithm: 'RS256',
  publicKeyPem: PEM,
});

// Optional standard claim checks (after signature verifies)
await verifyJwt(
  token,
  { algorithm: 'HS256', secret },
  {
    issuer: 'https://idp.example.com',
    audience: 'my-api',
    clockToleranceSeconds: 60,
  }
);

Decode only (inspection — never trust the payload without verifying first):

import { decodeJwt } from '@lookworld4/edge-jwt-lite';

const { header, payload } = decodeJwt(token);

API

| Export | Purpose | |------------------|---------| | verifyJwt() | Verifies signature via Web Crypto, then validates exp / nbf when present. iss / aud are checked only when you pass them in options. | | decodeJwt() | Parses header and payload JSON; no cryptographic verification. | | decodeJwtSegments() | Lower-level access to base64url parts and header.payload signing string. |

Key objects are typed as JwtHs256Secret, JwtRs256PublicKey, or JwtEs256PublicKey (see exported types).

Algorithms and security notes

  • HS256: HMAC-SHA256 using your secret interpreted as UTF-8 when given a string.
  • RS256 / ES256: Public key must be PEM SubjectPublicKeyInfo (BEGIN PUBLIC KEY). ES256 signatures in JWT are ASN.1 DER ECDSA signatures; internally they are converted to the IEEE P1363 form Web Crypto expects.
  • The JWT alg header must match your key (HS256, RS256, or ES256). Passing allowedAlgorithms can further tighten which algorithms you accept.

This is intentionally lite: no JWKS fetching, no JWE, no none algorithm. Prefer a full-featured library on Node servers when you need those.

Scripts

npm run build   # tsup → dist (CJS + ESM + types)
npm test        # node --test (uses Web Crypto in Node 18+)

License

MIT — see LICENSE.