Skip to content

keylabJWT and JWKS tooling that stays portable

Create, sign, verify, and inspect tokens with PEM, JWK, and JWKS support across Node.js, Cloudflare Workers, browsers, and Bun.

Install ​

bash
bun add keylab
bash
npm install keylab
bash
yarn add keylab

Quick example ​

ts
import {
  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],
})