Class: JWTUtils
Defined in: core/src/JWTUtils.ts:151
Utility class for working with Json Web Token (JWT) authentication tokens.
Constructors
Constructor
new JWTUtils():
JWTUtils
Returns
JWTUtils
Methods
createToken()
staticcreateToken(config,user,data?):Promise<string>
Defined in: core/src/JWTUtils.ts:400
Parameters
config
user
data?
any
Returns
Promise<string>
createTokenSync()
staticcreateTokenSync(config,user,data?):string
Defined in: core/src/JWTUtils.ts:417
Synchronous counterpart to createToken(). Blocks the event loop while deriving the encryption key
when password-based payload encryption is configured (see deriveKeySync) - prefer createToken() on a
request-handling path in that case.
Parameters
config
user
data?
any
Returns
string
decodeToken()
staticdecodeToken(config,token):Promise<JWTPayload>
Defined in: core/src/JWTUtils.ts:529
Decodes the given JWT authentication token using the provided configuration. If the token is not valid an error is thrown with the reason. Returns the encoded user object payload upon success.
Parameters
config
The JWT configuration to use when validating the token.
token
string
The JWT token to validate.
Returns
Promise<JWTPayload>
The data encoded in the token's payload.
decodeTokenSync()
staticdecodeTokenSync(config,token):JWTPayload
Defined in: core/src/JWTUtils.ts:547
Synchronous counterpart to decodeToken(). Blocks the event loop while deriving the decryption key
when password-based payload encryption is configured (see deriveKeySync) - prefer decodeToken() on a
request-handling path in that case.
Parameters
config
The JWT configuration to use when validating the token.
token
string
The JWT token to validate.
Returns
The data encoded in the token's payload.