Skip to main content

Class: JWTUtils

Defined in: core/src/JWTUtils.ts:145

Utility class for working with Json Web Token (JWT) authentication tokens.

Constructors

Constructor

new JWTUtils(): JWTUtils

Returns

JWTUtils

Methods

createToken()

static createToken(config, user, data?): Promise<string>

Defined in: core/src/JWTUtils.ts:192

Parameters

config

JWTUtilsConfig

user

JWTUser

data?

any

Returns

Promise<string>


createTokenSync()

static createTokenSync(config, user, data?): string

Defined in: core/src/JWTUtils.ts:241

Parameters

config

JWTUtilsConfig

user

JWTUser

data?

any

Returns

string


decodeToken()

static decodeToken(config, token): Promise<JWTPayload>

Defined in: core/src/JWTUtils.ts:298

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

JWTUtilsConfig

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()

static decodeTokenSync(config, token): JWTPayload

Defined in: core/src/JWTUtils.ts:349

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

JWTUtilsConfig

The JWT configuration to use when validating the token.

token

string

The JWT token to validate.

Returns

JWTPayload

The data encoded in the token's payload.