@treye/ts-jwt
Decode and work with JWT in a type-safe way.
It is highly recommended you work with this package from TypeScript.
Installation
This package runs on Node.js and is available as an NPM package.
npm install @treye/ts-jwt
Usage
A single class is exposed to decode JWTs: JwtDecoder
.
The class offers two static methods:
-
simpleDecodeJwt(jwt: string): JwtDecodeResult<SimpleJwtPayload>
- decode a JWT into a structure using a simplified, default payload type. -
decodeJwt<T>(jwt: string, requiredProperties?: (keyof T)[]): JwtDecodeResult<T>
- decode a JWT into a structure with a payload interface of your choosing.
Documentation
Documentation can be found in the docs
folder of the package. If you're working with the source you can generate it with npm docs
.