A collection of low-level JWT utilities based on the Web Crypto API.
Low-level JWT toolkit built on the Web Crypto API. Sign, verify, encrypt, decrypt, and manage keys β JWS, JWE, and JWK in a single zero-dependency package.
π Documentation β unjwt.s94.dev
dir, AES-KW, AES-GCM-KW, RSA-OAEP, PBES2, ECDH-ES. AES-GCM and AES-CBC-HMAC-SHA2 content encryption. Compact + General/Flattened JSON Serialization (multi-recipient).CryptoKey β JWK β PEM conversion. ECDH-ES shared-secret derivation. JWKS fetching, lookup, and rotation.h3, cookie-es, rou3).# Auto-detect package manager (npm, yarn, pnpm, deno, bun)
npx nypm install unjwt
Agent skill for Claude Code (and compatible harnesses):
npx skills add sandros94/unjwt
// Sign and verify a JWT (JWS)
import { sign, verify } from "unjwt/jws";
import { generateJWK } from "unjwt/jwk";
const key = await generateJWK("HS256");
const token = await sign({ sub: "user_1" }, key, { expiresIn: "1h" });
const { payload } = await verify(token, key);
// { sub: "user_1", iat: ..., exp: ... }
// Encrypt and decrypt (JWE)
import { encrypt, decrypt } from "unjwt/jwe";
const jwe = await encrypt({ secret: "data" }, "my-password");
const { payload: p } = await decrypt(jwe, "my-password");
Full walkthroughs, recipes, and the complete API reference live at unjwt.s94.dev:
Originally visioned by Johann Schopplich, heavily inspired by Filip Skokanβs jose internal cryptographic primitives, and initially sponsored by JAMflow β thanks to all three for making this project possible.
Published under the MIT license.
Made by community π
π€ auto updated with automd