Skip to main content

Class: VrameworkSessionService<UserSession>

The VrameworkSessionService class provides session management capabilities, including handling JWT-based sessions, cookie-based sessions, and API key-based sessions. It allows for retrieving and transforming user sessions based on different authentication mechanisms.

Type Parameters

UserSession

The type representing a user session.

Implements

Constructors

new VrameworkSessionService()

new VrameworkSessionService<UserSession>(jwtService, options): VrameworkSessionService<UserSession>

Constructs a new instance of the VrameworkSessionService class.

Parameters

jwtService: JWTService<UserSession>

The service for handling JWT operations.

options

Options for configuring the session service.

options.cookieNames?: string[]

options.getSessionForAPIKey?

options.getSessionForCookieValue?

options.transformSession?

Returns

VrameworkSessionService<UserSession>

Defined in

packages/core/src/services/vramework-session-service.ts:22

Methods

getUserSession()

getUserSession(
credentialsRequired,
request,
debugJWTDecode?): Promise<undefined | UserSession>

Retrieves the user session.

Parameters

credentialsRequired: boolean

Whether credentials are required to proceed.

request: VrameworkRequest<any>

The request object containing headers and cookies.

debugJWTDecode?: boolean

Whether to enable debugging for JWT decoding.

Returns

Promise<undefined | UserSession>

A promise that resolves to the user session, or undefined if no session is found and credentials are not required.

Throws

  • Throws an error if credentials are required but no session is found.

Implementation of

SessionService.getUserSession

Defined in

packages/core/src/services/vramework-session-service.ts:83