Token signing
Besides the common things like token authorization, the middleware comes with handy functions responsible for token signing.
+ generateToken
The middleware wraps auth0 jsonwebtoken API into more RxJS friendly functions that can be partially applied and composed inside Observable streams.
generateToken signs new JWT token with provided payload and configuration object which defines the way how the token is signed.
Importing
Type declaration
Parameters
parameter | definition |
options |
|
payload |
|
Config object which defines a set of parameters that are used for token signing.
parameter | definition |
secret | |
algorithm | <optional> |
keyid | <optional> |
expiresIn | <optional> |
notBefore | <optional> |
audience | <optional> |
subject | <optional> |
issuer | <optional> |
jwtid | <optional> |
noTimestamp | <optional> |
header | <optional> |
encoding | <optional> |
For more details about JWT token signing, please visit jsonwebtoken package docs.
+ generateExpirationInHours
The standard for JWT defines an exp
claim for expiration. The expiration is represented as a NumericDate. This means that the expiration should contain the number of seconds since the epoch.
generateExpiratinoInHours is a small, but handy function that returns an numeric date for given hours as a parameter. If the function is called without any parameter then the date is generated with 1 hour expiration.
Importing
Type declaration
Example
Last updated