@inrupt/solid-client-authn-browser / 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.

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

Defined in: browser/src/SessionManager.ts:53

Properties

clientAuthn

Private clientAuthn: default

Defined in: browser/src/SessionManager.ts:44


handledIncomingRedirect

Private handledIncomingRedirect: boolean= false

Defined in: browser/src/SessionManager.ts:53


isInitialized

Private isInitialized: boolean= false

Defined in: browser/src/SessionManager.ts:51


sessionRecords

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

Defined in: browser/src/SessionManager.ts:46


defaultMaxListeners

Static defaultMaxListeners: number

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


errorMonitor

Readonly Static 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.

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

Methods

addListener

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

Parameters:

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: SessionManager

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


addNewSessionRecord

PrivateaddNewSessionRecord(session: Session): Session

Parameters:

Name

Type

session

Session

Returns: Session

Defined in: browser/src/SessionManager.ts:85


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 session is not ever-growing. Note that 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: browser/src/SessionManager.ts:190


emit

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

Parameters:

Name

Type

event

string | symbol

...args

any[]

Returns: boolean

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


eventNames

eventNames(): (string | symbol)[]

Returns: (string | symbol)[]

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


getMaxListeners

getMaxListeners(): number

Returns: number

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


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 to the given ID.

Defined in: browser/src/SessionManager.ts:132


getSessionFromCurrentSessionInfo

PrivategetSessionFromCurrentSessionInfo(sessionInfo: ISessionInfo): Session

Parameters:

Name

Type

sessionInfo

ISessionInfo

Returns: Session

Defined in: browser/src/SessionManager.ts:97


getSessions

getSessions(): Promise<Session[]>

Returns: Promise<Session[]>

all the sessions currently managed by the session manager.

Defined in: browser/src/SessionManager.ts:115


handleIncomingRedirect

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

Processes the information sent by the 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: browser/src/SessionManager.ts:208


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 to the given ID exists, and false if not.

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


init

Privateinit(): Promise<void>

Returns: Promise<void>

Defined in: browser/src/SessionManager.ts:78


listenerCount

listenerCount(event: string | symbol): number

Parameters:

Name

Type

event

string | symbol

Returns: number

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


listeners

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

Parameters:

Name

Type

event

string | symbol

Returns: Function[]

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


off

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

Parameters:

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: SessionManager

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


on

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

Parameters:

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: SessionManager

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


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: browser/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: browser/src/SessionManager.ts:177


once

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

Parameters:

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: SessionManager

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


prependListener

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

Parameters:

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: SessionManager

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


prependOnceListener

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

Parameters:

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: SessionManager

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


rawListeners

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

Parameters:

Name

Type

event

string | symbol

Returns: Function[]

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


removeAllListeners

removeAllListeners(event?: string | symbol): SessionManager

Parameters:

Name

Type

event?

string | symbol

Returns: SessionManager

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


removeListener

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

Parameters:

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: SessionManager

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


setMaxListeners

setMaxListeners(n: number): SessionManager

Parameters:

Name

Type

n

number

Returns: SessionManager

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


listenerCount

StaticlistenerCount(emitter: EventEmitter, event: string | symbol): number

deprecated since v4.0.0

Parameters:

Name

Type

emitter

EventEmitter

event

string | symbol

Returns: number

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