Cross-runtime by default
Use the same library in Node.js, Workers, browsers, and Bun without pulling Node-only crypto at module load time.
Create, sign, verify, and inspect tokens with PEM, JWK, and JWKS support across Node.js, Cloudflare Workers, browsers, and Bun.
bun add keylabnpm install keylabyarn add keylabimport {
getKeyPair,
signJwtWithPrivateKey,
checkTokenValidness,
JwtAlgorithmsEnum as Algs,
} from "keylab"
const keyPair = await getKeyPair({
keyFormat: "jwk",
algorithmIdentifier: Algs.ES256,
keySize: 2048,
})
const token = await signJwtWithPrivateKey(
{ sub: "user-123", iss: "https://issuer.example" },
Algs.ES256,
keyPair.privateKey,
{ kid: keyPair.kid },
)
const verified = await checkTokenValidness(token, {
adhoc: [keyPair.publicKey],
})