JWT
The JWT class provides synchronous APIs to sign, verify, and decode JSON Web Tokens.
Constructor
Parameters
Supported Algorithms
- HMAC:
HS256,HS384,HS512 - RSA PKCS#1 v1.5:
RS256,RS384,RS512 - RSA-PSS:
PS256,PS384,PS512 - ECDSA:
ES256,ES384,ES512 - EdDSA:
EdDSA(Ed25519)
Methods
sign(payload, options?): string
Creates a JWT string synchronously.
verify(token, options?): { header; payload }
Verifies signature and standard claims synchronously. Throws on failure.
decode(token): { header; payload; signature; signingInput }
Decodes JWT without signature verification.
Example
Error Handling
All methods are synchronous. If validation or cryptographic operations fail, JWT throws an Error.
