@inrupt/solid-client-authn-node / SessionManager

Class: SessionManager

A SessionManager instance can be used to manage all the sessions in an application, each session being associated with an individual user.

deprecated

Hierarchy

  • EventEmitter

    SessionManager

Implements

  • ISessionManager

Constructors

constructor

+ new SessionManager(options?: ISessionManagerOptions): SessionManager

Constructor for the SessionManager object. It is typically used as follows:

import { SessionManager } from "@inrupt/solid-client-authn-browser";
import customStorage from "./myCustomStorage";

const sessionManager = new SessionManager({
  secureStorage: customStorage
});

See IStorage for more information on how to define your own storage mechanism.

Parameters

Name

Type

Default value

Description

options

ISessionManagerOptions

{}

Options customizing the behaviour of the SessionManager, namely to store data appropriately.

Returns: SessionManager

Overrides: EventEmitter.constructor

Defined in: node/src/SessionManager.ts:54

Properties

clientAuthn

Private clientAuthn: default

Defined in: node/src/SessionManager.ts:45


handledIncomingRedirect

Private handledIncomingRedirect: boolean= false

Defined in: node/src/SessionManager.ts:54


isInitialized

Private isInitialized: boolean= false

Defined in: node/src/SessionManager.ts:52


sessionRecords

Private sessionRecords: Record<string, { logoutCallback: () => unknown ; session: Session }>= {}

Defined in: node/src/SessionManager.ts:47


captureRejectionSymbol

Static Readonly captureRejectionSymbol: typeof captureRejectionSymbol

Inherited from: EventEmitter.captureRejectionSymbol

Defined in: node/node_modules/@types/node/events.d.ts:42


captureRejections

Static captureRejections: boolean

Sets or gets the default captureRejection value for all emitters.

Inherited from: EventEmitter.captureRejections

Defined in: node/node_modules/@types/node/events.d.ts:48


defaultMaxListeners

Static defaultMaxListeners: number

Inherited from: EventEmitter.defaultMaxListeners

Defined in: node/node_modules/@types/node/events.d.ts:49


errorMonitor

Static Readonly errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted, therefore the process will still crash if no regular 'error' listener is installed.

Inherited from: EventEmitter.errorMonitor

Defined in: node/node_modules/@types/node/events.d.ts:41

Methods

addListener

addListener(event: string | symbol, listener: (…args: any[]) => void): SessionManager

Parameters

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: SessionManager

Inherited from: EventEmitter.addListener

Defined in: node/node_modules/@types/node/events.d.ts:61


addNewSessionRecord

Private addNewSessionRecord(session: Session): Session

Parameters

Name

Type

session

Session

Returns: Session

Defined in: node/src/SessionManager.ts:81


detachSession

detachSession(sessionId: string): void

Removes a session from the pool managed by the manager. This is typically useful when a user logs out of the application, so that the number of managed sessions is not ever-growing.

Note: this specific function does not log out the session, it only removes references to it, so after this call the session will become unreachable.

since 0.2.0

Parameters

Name

Type

Description

sessionId

string

A unique session identifier.

Returns: void

Defined in: node/src/SessionManager.ts:194


emit

emit(event: string | symbol, …args: any[]): boolean

Parameters

Name

Type

event

string | symbol

...args

any[]

Returns: boolean

Inherited from: EventEmitter.emit

Defined in: node/node_modules/@types/node/events.d.ts:71


eventNames

eventNames(): (string | symbol)[]

Returns: (string | symbol)[]

Inherited from: EventEmitter.eventNames

Defined in: node/node_modules/@types/node/events.d.ts:76


getMaxListeners

getMaxListeners(): number

Returns: number

Inherited from: EventEmitter.getMaxListeners

Defined in: node/node_modules/@types/node/events.d.ts:68


getSession

getSession(sessionId?: string): Promise<Session>

Creates a new session and adds it to the session manager. If a session ID is not provided then a random UUID will be assigned as the session ID. If the session of the provided ID already exists then that session will be returned.

Parameters

Name

Type

Description

sessionId?

string

An optional unique session identifier.

Returns: Promise<Session>

A Session associated with the given ID.

Implementation of: ISessionManager.getSession

Defined in: node/src/SessionManager.ts:130


getSessionFromCurrentSessionInfo

Private getSessionFromCurrentSessionInfo(sessionInfo: ISessionInfo): Session

Parameters

Name

Type

sessionInfo

ISessionInfo

Returns: Session

Defined in: node/src/SessionManager.ts:95


getSessions

getSessions(): Promise<Session[]>

Returns: Promise<Session[]>

all the sessions currently managed by the session manager.

Defined in: node/src/SessionManager.ts:114


handleIncomingRedirect

handleIncomingRedirect(url: string): Promise<undefined | Session>

Processes the information sent by the Solid Identity Provider after the user has logged in, in order to return a logged in Session.

Parameters

Name

Type

Description

url

string

The URL to which the user is being redirected.

Returns: Promise<undefined | Session>

The Session that completed login if the process has been successful.

Defined in: node/src/SessionManager.ts:214


hasSession

hasSession(sessionId: string): Promise<boolean>

Parameters

Name

Type

Description

sessionId

string

A unique session identifier.

Returns: Promise<boolean>

A Promise resolving to true if a session associated with the given ID exists, and false if not.

Defined in: node/src/SessionManager.ts:158


listenerCount

listenerCount(event: string | symbol): number

Parameters

Name

Type

event

string | symbol

Returns: number

Inherited from: EventEmitter.listenerCount

Defined in: node/node_modules/@types/node/events.d.ts:72


listeners

listeners(event: string | symbol): Function[]

Parameters

Name

Type

event

string | symbol

Returns: Function[]

Inherited from: EventEmitter.listeners

Defined in: node/node_modules/@types/node/events.d.ts:69


off

off(event: string | symbol, listener: (…args: any[]) => void): SessionManager

Parameters

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: SessionManager

Inherited from: EventEmitter.off

Defined in: node/node_modules/@types/node/events.d.ts:65


on

on(event: string | symbol, listener: (…args: any[]) => void): SessionManager

Parameters

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: SessionManager

Inherited from: EventEmitter.on

Defined in: node/node_modules/@types/node/events.d.ts:62


onSessionLogin

onSessionLogin(callback: (session: Session) => unknown): void

Registers a callback to be called when a session is logged in.

Parameters

Name

Type

Description

callback

(session: Session) => unknown

a function executed when a session logs in, with the session as a parameter.

Returns: void

Defined in: node/src/SessionManager.ts:168


onSessionLogout

onSessionLogout(callback: (session: Session) => unknown): void

Registers a callback to be called when a session is logged out.

Parameters

Name

Type

Description

callback

(session: Session) => unknown

a function executed when a session logs out, with the session as a parameter.

Returns: void

Defined in: node/src/SessionManager.ts:178


once

once(event: string | symbol, listener: (…args: any[]) => void): SessionManager

Parameters

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: SessionManager

Inherited from: EventEmitter.once

Defined in: node/node_modules/@types/node/events.d.ts:63


prependListener

prependListener(event: string | symbol, listener: (…args: any[]) => void): SessionManager

Parameters

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: SessionManager

Inherited from: EventEmitter.prependListener

Defined in: node/node_modules/@types/node/events.d.ts:74


prependOnceListener

prependOnceListener(event: string | symbol, listener: (…args: any[]) => void): SessionManager

Parameters

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: SessionManager

Inherited from: EventEmitter.prependOnceListener

Defined in: node/node_modules/@types/node/events.d.ts:75


rawListeners

rawListeners(event: string | symbol): Function[]

Parameters

Name

Type

event

string | symbol

Returns: Function[]

Inherited from: EventEmitter.rawListeners

Defined in: node/node_modules/@types/node/events.d.ts:70


removeAllListeners

removeAllListeners(event?: string | symbol): SessionManager

Parameters

Name

Type

event?

string | symbol

Returns: SessionManager

Inherited from: EventEmitter.removeAllListeners

Defined in: node/node_modules/@types/node/events.d.ts:66


removeListener

removeListener(event: string | symbol, listener: (…args: any[]) => void): SessionManager

Parameters

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: SessionManager

Inherited from: EventEmitter.removeListener

Defined in: node/node_modules/@types/node/events.d.ts:64


setMaxListeners

setMaxListeners(n: number): SessionManager

Parameters

Name

Type

n

number

Returns: SessionManager

Inherited from: EventEmitter.setMaxListeners

Defined in: node/node_modules/@types/node/events.d.ts:67


listenerCount

Static listenerCount(emitter: EventEmitter, event: string | symbol): number

deprecated since v4.0.0

Parameters

Name

Type

emitter

EventEmitter

event

string | symbol

Returns: number

Inherited from: EventEmitter.listenerCount

Defined in: node/node_modules/@types/node/events.d.ts:30


on

Static on(emitter: EventEmitter, event: string, options?: StaticEventEmitterOptions): AsyncIterableIterator<any>

Parameters

Name

Type

emitter

EventEmitter

event

string

options?

StaticEventEmitterOptions

Returns: AsyncIterableIterator<any>

Inherited from: EventEmitter.on

Defined in: node/node_modules/@types/node/events.d.ts:27


once

Static once(emitter: NodeEventTarget, event: string | symbol, options?: StaticEventEmitterOptions): Promise<any[]>

Parameters

Name

Type

emitter

NodeEventTarget

event

string | symbol

options?

StaticEventEmitterOptions

Returns: Promise<any[]>

Inherited from: EventEmitter.once

Defined in: node/node_modules/@types/node/events.d.ts:25

Static once(emitter: DOMEventTarget, event: string, options?: StaticEventEmitterOptions): Promise<any[]>

Parameters

Name

Type

emitter

DOMEventTarget

event

string

options?

StaticEventEmitterOptions

Returns: Promise<any[]>

Inherited from: EventEmitter.once

Defined in: node/node_modules/@types/node/events.d.ts:26