Module jwt aims to provide an implementation of the JSON Web Token. Only compact serializtion is supported.
▸ decode(token
: string): object
Decode JSON Web Token payload without signature validation.
Name | Type | Description |
---|---|---|
token |
string | The JWT to decode |
Returns: object
The decoded payload
▸ sign(key
: Key, payload
: object, header?
: object): string
Create JSON Web Token from payload and optional header.
Name | Type | Description |
---|---|---|
key |
Key | The signing key |
payload |
object | The payload claims |
header? |
object | The header fields |
Returns: string
The signed JWT in compact serialization form
▸ verify(token
: string, ...key
: Key[]): object
Verify JSON Web Token signature and decode payload on success.
Name | Type | Description |
---|---|---|
token |
string | The JWT to verify |
...key |
Key[] | The signature validation key (or keys) |
Returns: object
The payload of the verified token