Functions - jwt

buildHeaderString

Build the header string from the JwtHeader record.

buildPayloadString

Build the payload string from the JwtPayload record.

decodeJwt

Decode the given JWT string.

issueJwt

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.

validateJwt

Validate the given JWT string.

buildHeaderString

(JwtHeader header)

returns string | Error

Build the header string from the JwtHeader record.

Parameters

  • header JwtHeader
  • JWT header record to be built as a string

  • Return Type

    (string | Error)
  • The header string or an Error if building the string fails

buildPayloadString

(JwtPayload payload)

returns string | Error

Build the payload string from the JwtPayload record.

Parameters

  • payload JwtPayload
  • JWT payload record to be built as a string

  • Return Type

    (string | Error)
  • The payload string or an Error if building the string fails

decodeJwt

(string jwtToken)

returns [JwtHeader, JwtPayload] | Error

Decode the given JWT string.

Parameters

  • jwtToken string
  • JWT token that needs to be decoded

issueJwt

(JwtHeader header, JwtPayload payload, JwtKeyStoreConfig? config)

returns string | Error

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

  • Return Type

    (string | Error)
  • JWT token string or an Error if token validation fails

validateJwt

(string jwtToken, JwtValidatorConfig config)

returns JwtPayload | Error

Validate the given JWT string.

Parameters

  • jwtToken string
  • JWT token that needs to be validated

  • Return Type

    (JwtPayload | Error)
  • If the JWT token is valid, return the JWT payload. Else, return an Error if token validation fails.