API Reference

jose

Web Crypto compatible JWT and JOSE library for signing, verification, key management, and encryption in Node.js, browsers, and edge runtimes.

Official Documentation ↗
CompatibilityThis documentation covers version v6.2.15. Check the official docs for the latest API surface.

Installation

npmnpm install jose
pnpmpnpm add jose
yarnyarn add jose

Methods

jose implements JSON Object Signing and Encryption using Web Crypto. It works in Node.js, browsers, and edge runtimes. The library gives you primitives; the security decisions—key management, algorithm allowlists, issuer and audience—remain yours.

Verify, do not decode

decodeJwt only parses claims. It is useful for reading a key id or issuer before verification, never for authorization. Always call jwtVerify with the allowed algorithms and expected issuer and audience. Accepting the algorithm named in the token header enables algorithm-confusion attacks.

Key management

Keep secrets out of source control and use a secret manager. For asymmetric keys, publish the public key with a kid and rotate it while old tokens remain valid. Remove the old key only after the maximum token lifetime has passed.

Errors

The official API reference declares the following error types:

API reference evidence

Fetched from official sources on 2026-11-08T16:01:12.9137723+08:00 via WebFetch 官方仓库 README 与 docs/*.md(raw.githubusercontent.com/panva/jose/main),Grep/Read 提取.

FAQ

Is jose safe to use in edge runtimes?
Yes. jose uses Web Crypto and does not depend on Node-only crypto APIs, which makes it suitable for Edge middleware and browsers as well as Node.js.
Should I use HS256 or RS256?
Use HS256 when one service signs and verifies with a shared secret. Use RS256 or EdDSA when multiple services must verify without holding the signing key.
Can I trust decodeJwt for authorization?
No. It does not verify the signature or claims. Use jwtVerify with an explicit algorithm allowlist, issuer, and audience for any security decision.