Documentation: https://jwt.oslojs.dev
A JavaScript library for parsing and encoding JSON web tokens (JWT) by Oslo. Only signed tokens are supported.
- Runtime-agnostic
- No third-party dependencies
- Fully typed
import{parseJWT,JWSRegisteredHeaders,JWTRegisteredClaims,joseAlgorithmHS256}from"@oslojs/jwt";const[header,payload,signature]=parseJWT(jwt);constheaderParameters=newJWSRegisteredHeaders(header);if(headerParameters.algorithm()!==joseAlgorithmHS256){thrownewError("Unsupported algorithm");}constclaims=newJWTRegisteredClaims(payload);if(!claims.verifyExpiration()){thrownewError("Expired token");}if(claims.hasNotBefore()&&!claims.verifyNotBefore()){thrownewError("Invalid token");}npm i @oslojs/jwt