jose
Web Crypto compatible JWT and JOSE library for signing, verification, key management, and encryption in Node.js, browsers, and edge runtimes.
Official Documentation ↗v6.2.15. Check the official docs for the latest API surface.Installation
npm install josepnpm add joseyarn add joseMethods
No methods match this filter.
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:
JOSEError(class(所有 JOSE 错误的基类)) — official text: “Base class for JOSE errors. ## Properties ### code • code:string='ERR_JOSE_GENERIC'Stable code identifying the error class.” (source: https://github.com/panva/jose/blob/main/docs/util/errors/classes/JOSEError.md, fetched 2026-11-08T16:01:12.9137723+08:00)
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 提取.
SignJWT→ signature from https://github.com/panva/jose/blob/main/docs/jwt/sign/classes/SignJWT.md; official text: “## Constructors ### Constructor ▸ new SignJWT(payload?):SignJWT#### Parameters | Parameter | Type | Description | | —— | —— | —— | |payload?| [JWTPayload](../../../types/interfaces/JWTPayload.”jwtVerify→ signature from https://github.com/panva/jose/blob/main/docs/jwt/verify/functions/jwtVerify.md; official text: “▸ jwtVerify<PayloadType>(jwt,key,options?):Promise<JWTVerifyResult<”generateKeyPair→ signature from https://github.com/panva/jose/blob/main/docs/key/generate_key_pair/functions/generateKeyPair.md; official text: “▸ generateKeyPair(alg,options?):Promise<GenerateKeyPairResult> Generates an as”decodeJwt→ signature from https://github.com/panva/jose/blob/main/docs/util/decode_jwt/functions/decodeJwt.md; official text: “▸ decodeJwt<PayloadType>(jwt):PayloadType&JWTPayload& ([PayloadType] extends [object] ?unknown:unknownextendsPayloadType?unknown:never”
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.
Report a problem with this API docOpens a pre-filled issue on GitHub.