Class: JoseJWTService<UserSession>
Service for handling JSON Web Tokens (JWT) using the jose library.
Type Parameters
• UserSession extends CoreUserSession
The type of the user session.
Implements
JWTService
Constructors
new JoseJWTService()
new JoseJWTService<UserSession>(getSecrets, logger?): JoseJWTService<UserSession>
Parameters
• getSecrets
A function that retrieves an array of secrets.
• logger?: Logger
An optional logger for logging information.
Returns
JoseJWTService
<UserSession
>
Defined in
packages/services/jose/src/jose-jwt-service.ts:28
Methods
decode()
decode<T>(token): Promise<T>
Decodes a JWT into its payload.
Type Parameters
• T
Parameters
• token: string
The JWT to decode.
Returns
Promise
<T
>
A promise that resolves to the decoded payload.
Implementation of
JWTService.decode
Defined in
packages/services/jose/src/jose-jwt-service.ts:76
decodeSession()
decodeSession(session?): Promise<UserSession>
Decodes a user session from a JWT.
Parameters
• session?: string
The JWT representing the user session.
Returns
Promise
<UserSession
>
A promise that resolves to the decoded user session.
Throws
If the session is not provided.
Implementation of
JWTService.decodeSession
Defined in
packages/services/jose/src/jose-jwt-service.ts:97
encode()
encode<T>(expiresIn, payload): Promise<string>
Encodes a payload into a JWT.
Type Parameters
• T
Parameters
• expiresIn: string
The expiration time of the token.
• payload: T
The payload to encode.
Returns
Promise
<string
>
A promise that resolves to the encoded JWT.
Implementation of
JWTService.encode
Defined in
packages/services/jose/src/jose-jwt-service.ts:57
init()
init(): Promise<void>
Initializes the service by retrieving and setting the secrets.
Returns
Promise
<void
>
Defined in
packages/services/jose/src/jose-jwt-service.ts:36
verify()
verify(token): Promise<void>
Verifies the validity of a JWT.
Parameters
• token: string
The JWT to verify.
Returns
Promise
<void
>
A promise that resolves if the token is valid.