← Back to archive

Repo of the Day

panva/jose

Published: Aug 24, 2022

Open repository ↗

Summary

jose is a zero-dependency TypeScript module that implements the JOSE specifications—JSON Web Tokens (JWT), JSON Web Signature (JWS), JSON Web Encryption (JWE), JSON Web Key (JWK), and JSON Web Key Sets (JWKS)—for Node.js, browsers, Cloudflare Workers, Deno, Bun, Electron, and other Web-interoperable runtimes. It ships as tree-shakeable ESM with no third-party dependencies and exposes APIs for signing, verifying, encrypting, decrypting, and managing keys.

What it is useful for

This library fits when a JavaScript application needs the full JOSE stack without a runtime-specific crypto wrapper. Concrete use cases from the README include signing tokens with the SignJWT class, verifying tokens with jwtVerify against either a local JWKS or a remote one fetched via createRemoteJWKSet, encrypting JWTs with EncryptJWT and decrypting them with jwtDecrypt, and signing or verifying arbitrary payloads using JWS Compact, Flattened JSON, or General JSON serializations. The key utilities cover PEM and JWK conversion (importSPKI, importPKCS8, importJWK, exportJWK), asymmetric key pair generation (generateKeyPair), and symmetric secret generation (generateSecret). It also calculates JWK thumbprints and thumbprint URIs per RFC 7638 and RFC 9278, and exposes a dedicated JOSE errors module for handling failures. The README also references JWK thumbprint URIs (RFC 9278), JWS unencoded payloads (RFC 7797), ML-DSA for JOSE (RFC 9964), and fully-specified algorithms (RFC 9864).

How engineers can use it

jose is distributed through npmjs.com, jsr.io, jsdelivr.com, and GitHub. The README shows a single ESM import that exposes every helper: import * as jose from 'jose'. A typical sign-and-verify flow uses the SignJWT class to mint a token and the jwtVerify function on the consumer side, where the verification key can be a local JWKS built with createLocalJWKSet or a remote one created with createRemoteJWKSet. For encryption-only flows, EncryptJWT and jwtDecrypt cover JWTs, while CompactEncrypt, FlattenedEncrypt, and GeneralEncrypt (with their decrypt counterparts) handle arbitrary payloads.

The library assumes the runtime exposes the WebCrypto API and Fetch API; certain algorithms may not be available depending on the runtime, so engineers should consult the per-runtime algorithm matrix linked in the README issues. CJS require('jose') only works on Node.js ^20.19.0, ^22.12.0, or >=23.0.0, where require(esm) is enabled by default. Detailed API references for each function live under the linked docs/ paths in the README.