# jose — card for AI agents

Comprehensive JWT and JWK handling for Node.js and web runtimes.

Category: Auth and security libraries · npm package `jose` · latest version 6.2.14 (checked 2026-11-01)
Install: `npm install jose`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (paste into AGENTS.md or CLAUDE.md)

## jose
- Import as ESM: `import * as jose from 'jose'`. Use `require('jose')` only on Node.js ^20.19.0 || ^22.12.0 || >= 23.0.0.
- Use `jwtVerify` for JWT signature verification and Claims Set validation. The README lists `decodeJwt` as a utility that decodes the JWT Claims Set "prior to its validation".
- To verify against an issuer's published keys, use `createRemoteJWKSet`. For a key set held locally, use `createLocalJWKSet`.
- Sign tokens with the `SignJWT` class. For encrypted tokens, encrypt with `EncryptJWT`, then decrypt and validate with `jwtDecrypt`.
- Import PEM keys with `importSPKI`, `importX509` or `importPKCS8`, and JWKs with `importJWK`. Generate keys with `generateKeyPair` or `generateSecret`.
- Before choosing an algorithm, check the README's per-runtime issue for the target runtime. Some algorithms are not available everywhere.
- The README's Supported Versions table lists only v6.x, so write code against v6.x.

## What it is
- jose is a JavaScript module for JSON Object Signing and Encryption. It signs, verifies, encrypts and decrypts JSON Web Tokens. It also handles arbitrary JWS and JWE payloads in compact, flattened and general JSON forms, and it imports, exports and generates keys. The README's Specifications section lists the RFCs it follows, from JWS (RFC7515) and JWT (RFC7519) to JWK thumbprints, Fully-Specified Algorithms for JOSE and ML-DSA for JOSE.
- The README says the module works on runtimes that support the Web API globals it uses, or on Node.js. Keys can come from PEM (SPKI, X.509, PKCS #8), from JWK, or from a remote or local JSON Web Key Set. It is distributed through npm, jsr.io, jsdelivr and GitHub.
- The repository was created in 2018 and is MIT licensed. The latest listed release, v6.2.12, groups documentation changes, a refactor of the JWS and JWE operation cores, and several performance changes, among them deduplicating pending JWKS key imports and avoiding copies of AES-GCM output.

## Caveats
- Algorithm support depends on the runtime: Some algorithms may be missing on a given runtime. The README links a separate issue for each runtime that lists its available algorithms.
- require() only on recent Node.js: The package is ESM. CommonJS `require('jose')` works only in Node.js versions where `require(esm)` is enabled by default.
- Assumes WebCrypto and Fetch: The README's "Universal" label on v6.x comes with a footnote. It assumes the runtime supports the WebCryptoAPI and the Fetch API.

## Numbers (AgentGid data)
- Gid Score: 75.3 (#199 of all tools, 6 of 141 in its category)
- Used in 108 public projects set up for AI coding agents (1.7%)
- Downloads last week: 244,235,645 (as of 2026-11-24), +53.6% over 4 weeks
- GitHub stars: 7,894 (as of 2026-11-24)
- Last push: 2026-11-18

## Often used with
Next.js 64.8%, Zod 75.0%, Lucide React 65.7%, Tailwind Merge 63.0%, clsx 63.9%, React 80.6%

## Checked alternatives (same job)
- jsonwebtoken: https://agentgid.com/tools/jsonwebtoken/agent.md
- Passport.js: https://agentgid.com/tools/passport/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/jose/
- Homepage: https://github.com/panva/jose
- Repository: https://github.com/panva/jose
- Source: https://github.com/panva/jose#readme
- Source: https://github.com/panva/jose
- Source: https://github.com/panva/jose/releases


## jose: sign and check login tokens (JWT) in JavaScript

jose is a free JavaScript library for login tokens, the signed strings called JWTs that prove who a user is. Your app uses it to issue a token after sign-in and to check every token that comes back, so forged or expired ones are refused. It runs in Node.js, browsers, Cloudflare Workers, Deno and Bun, and has no other packages inside.

### Where to use it
- Keep users signed in: After a user logs in, your server hands out a signed token that expires in two hours; later requests show it instead of the password.
- Refuse forged or expired tokens: Every request to your server is checked; a token someone edited, one that has run out, or one meant for another app is turned away.
- Accept Google or other sign-in tokens: Users sign in with Google or another login service; your server checks their token against the service's public keys, which jose downloads and caches.
- Check tokens at the edge: A Cloudflare Worker or Deno function in front of your site checks the visitor's token before the page is served, with the same code as on the server.
- Hide data inside a token: A token carries an email address or an order number that only your server can read, because the content is encrypted, not only signed.
- Expiring links in emails: A password reset or email confirmation link carries a signed token that works for 30 minutes and only for that one user. (idea, not from the official pages)

### How to start
- Add jose to your project.

```
npm install jose
```

- Import it as an ES module.

```
import * as jose from 'jose'
```

- Sign a token with SignJWT, then check it with jwtVerify and the same secret (or the public key).

```
const secret = new TextEncoder().encode(
  'cc7e0d44fd473002f1c42167459001140ec6389b7353f8088f4d9a95f2f596f2',
)
const alg = 'HS256'

const jwt = await new jose.SignJWT({ 'urn:example:claim': true })
  .setProtectedHeader({ alg })
  .setIssuedAt()
  .setIssuer('urn:example:issuer')
  .setAudience('urn:example:audience')
  .setExpirationTime('2h')
  .sign(secret)
```


### License
Free to use in paid and closed-source products under the MIT license. Keep the copyright and license notice in copies of the library you ship; no credit on screen is needed.

### Good to know
- It only signs, checks and encrypts tokens. Who may log in, sessions, sign-out and permissions are left to your app or a full login library.
- Version 6 needs Node.js 20 or newer; older Node.js versions were dropped.
- It does not stop you from using a short secret. Use one of 32 random bytes or more, or let jose make one with generateSecret.
- Some signing methods are missing in some places, for example in a given browser; the README links a list for each place it runs.
- The project is active; version 6.2.17 came out on 9 November 2026, and only the 6.x line gets fixes.

Checked 2026-11-11 against: https://github.com/panva/jose/blob/main/README.md, https://github.com/panva/jose/blob/main/CHANGELOG.md, https://github.com/panva/jose/blob/main/LICENSE.md, https://github.com/panva/jose/blob/main/SECURITY.md, https://github.com/panva/jose/blob/main/docs/jwt/sign/classes/SignJWT.md, https://github.com/panva/jose/blob/main/docs/jwt/verify/functions/jwtVerify.md, https://github.com/panva/jose/blob/main/docs/jwt/encrypt/classes/EncryptJWT.md, https://github.com/panva/jose/blob/main/docs/jwks/remote/functions/createRemoteJWKSet.md, https://github.com/panva/jose/blob/main/docs/util/decode_jwt/functions/decodeJwt.md, https://github.com/panva/jose/blob/main/docs/util/errors/README.md, https://github.com/panva/jose/blob/main/docs/key/generate_key_pair/functions/generateKeyPair.md, https://github.com/panva/jose/blob/main/docs/key/generate_secret/functions/generateSecret.md, https://registry.npmjs.org/jose/latest

### Mistakes to avoid
- Don't: const user = jose.decodeJwt(req.cookies.token)   // then trust user.role → Do: const { payload } = await jose.jwtVerify(token, key, { issuer, audience, algorithms }) (decodeJwt checks nothing; in our run an edited token decoded as role=admin, while jwtVerify refused it with ERR_JWS_SIGNATURE_VERIFICATION_FAILED.)
- Don't: await jose.jwtVerify(token, key)   // no issuer, audience or algorithms → Do: Pass issuer, audience and algorithms (and requiredClaims if you need them) in the jwtVerify options (jose checks only what you ask for; a token from another app signed with the same key passes otherwise. Our run refused a wrong-audience token only because audience was set.)
- Don't: Code written for jose v4/v5 that expects KeyObject from generateKeyPair or importSPKI, or passes agent to createRemoteJWKSet → Do: In v6 these return CryptoKey; createRemoteJWKSet uses fetch, so drop the agent option and use its fetch-related options (Version 6.0.0 changed key types and removed the Node.js-only agent option.)
- Don't: Installing jose-node-cjs-runtime, jose-node-esm-runtime or jose-browser-runtime → Do: npm install jose (one package for every runtime) (The runtime-specific packages are no longer maintained since v6.)
- Don't: const { privateKey } = await jose.generateKeyPair('ES256'); await jose.exportPKCS8(privateKey) → Do: Pass { extractable: true } to generateKeyPair when you need to save the private key (Generated private keys cannot be exported unless you ask for it.)

### Questions
- Can I read what is inside a token without the key? Yes, decodeJwt reads it, but it checks nothing; anyone can edit a token that is only decoded. Use jwtVerify before you trust it.
- Does it work with require() in older CommonJS code? Only in Node.js versions where loading ES modules with require is on by default (20.19+, 22.12+ or 23+). Otherwise use import.
- Does it check tokens from Google, Auth0 or other login services? Yes. createRemoteJWKSet downloads the service's public keys from its URL, caches them, and jwtVerify uses them.
- Can I use it in a paid app? Yes. It is MIT-licensed and free; keep the license notice with the library files.

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
