Package Exports
- @travetto/jwt
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@travetto/jwt) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
travetto: JWT
Install: primary
$ npm install @travetto/jwtThis module is a simple component to support JWT signing and verification. The framework provides a port of node-jsonwebtoken. The API has been streamlined, and is intended as a lower level component as a basis for other modules.
The API exposes:
Code: Signing typings
sign(payload:object, config:{
key?: string | Buffer | Promise<string | Buffer>; // Signing Key
iatExclude?: boolean; // Do not return or set the issuedAt flag
alg?: string; // Which encoding algorithm
header?: Record<string, string>; // Any additional header information
encoding?: string; // Encoding, defaults to utf8
}):Promise<string>;Code: Decode typings
decode(token: string): Payload;
decodeComplete(token:string): {
header: {},
signature: string,
payload: Payload
}Code: Verify typings
verify(token: string, options: {
clock?: {
timestamp?: number | Date, // Timestamp as basis for expiry checks
tolerance?: number // How many seconds are you willing to tolerate
},
ignore?: {
exp?: boolean, // Ignore expires
nbf?: boolean // Ignore not before
},
maxAgeSec?: number, // Maximum age of token in seconds
header?: Record<string, string>, // Match against specific header fields
key?: string | Buffer | Promise<string | Buffer>, // Use the key for decoding token
encoding?: string, // Defaults to utf8
alg?: string | string[]; // Algorithm for decryption
payload?: {
aud?: string | RegExp | (string | RegExp)[]; // Match the payload aud against a set of audiences
... // Match against any payload value
}
}):Promise<string>