Functions -
jwt
buildHeaderString | Build the header string from the |
buildPayloadString | Build the payload string from the |
decodeJwt | Decode the given JWT string. |
issueJwt | Issue a JWT token based on provided header and payload. JWT will be signed (JWS) if |
validateJwt | Validate the given JWT string. |
Build the header string from the JwtHeader
record.
Parameters
- header JwtHeader
-
JWT header record to be built as a string
Build the payload string from the JwtPayload
record.
Parameters
- payload JwtPayload
-
JWT payload record to be built as a string
Decode the given JWT string.
Parameters
- jwtToken string
-
JWT token that needs to be decoded
-
Return Type
([JwtHeader, JwtPayload] | Error) The JWT header and payload tuple or an
Error
if token decoding fails.
Issue a JWT token based on provided header and payload. JWT will be signed (JWS) if keyStore
information is provided
in the JwtKeyStoreConfig
and the alg
field of JwtHeader
is not NONE
.
Parameters
- header JwtHeader
-
JwtHeader object
- payload JwtPayload
-
JwtPayload object
- config JwtKeyStoreConfig?
-
JWT key store config record
Validate the given JWT string.
Parameters
- jwtToken string
-
JWT token that needs to be validated
- config JwtValidatorConfig
-
JWT validator config record
-
Return Type
(JwtPayload | Error) If the JWT token is valid, return the JWT payload. Else, return an
Error
if token validation fails.