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

Class: SessionManager

DEPRECATION NOTE: We don’t plan on supporting multi session for client-side applications. Please see @inrupt/solid-client-authn-node for server-side multi session. This class will be removed in an upcoming major release.

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

Table of contents

Constructors

Properties

Methods

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

Properties

clientAuthn

Private clientAuthn: default

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


handledIncomingRedirect

Private handledIncomingRedirect: boolean= false

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


isInitialized

Private isInitialized: boolean= false

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


sessionRecords

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

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


captureRejectionSymbol

Static Readonly captureRejectionSymbol: typeof captureRejectionSymbol

Inherited from: EventEmitter.captureRejectionSymbol

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


captureRejections

Static captureRejections: boolean

Sets or gets the default captureRejection value for all emitters.

Inherited from: EventEmitter.captureRejections

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


defaultMaxListeners

Static defaultMaxListeners: number

Inherited from: EventEmitter.defaultMaxListeners

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


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: browser/node_modules/@types/node/events.d.ts:42

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: 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:91


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:196


emit

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

Parameters:

Name

Type

event

string | symbol

...args

any[]

Returns: boolean

Inherited from: EventEmitter.emit

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


eventNames

eventNames(): (string | symbol)[]

Returns: (string | symbol)[]

Inherited from: EventEmitter.eventNames

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


getMaxListeners

getMaxListeners(): number

Returns: number

Inherited from: EventEmitter.getMaxListeners

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

Implementation of: ISessionManager.getSession

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


getSessionFromCurrentSessionInfo

PrivategetSessionFromCurrentSessionInfo(sessionInfo: ISessionInfo): Session

Parameters:

Name

Type

sessionInfo

ISessionInfo

Returns: Session

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


getSessions

getSessions(): Promise<Session[]>

Returns: Promise<Session[]>

all the sessions currently managed by the session manager.

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


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


init

Privateinit(): Promise<void>

Returns: Promise<void>

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


listenerCount

listenerCount(event: string | symbol): number

Parameters:

Name

Type

event

string | symbol

Returns: number

Inherited from: EventEmitter.listenerCount

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[]

Inherited from: EventEmitter.listeners

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

Inherited from: EventEmitter.off

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

Inherited from: EventEmitter.on

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:174


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:183


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: 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

Inherited from: EventEmitter.prependListener

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

Inherited from: EventEmitter.prependOnceListener

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[]

Inherited from: EventEmitter.rawListeners

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

Inherited from: EventEmitter.removeAllListeners

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

Inherited from: EventEmitter.removeListener

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


setMaxListeners

setMaxListeners(n: number): SessionManager

Parameters:

Name

Type

n

number

Returns: SessionManager

Inherited from: EventEmitter.setMaxListeners

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

Inherited from: EventEmitter.listenerCount

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


on

Staticon(emitter: EventEmitter, event: string): AsyncIterableIterator<any>

Parameters:

Name

Type

emitter

EventEmitter

event

string

Returns: AsyncIterableIterator<any>

Inherited from: EventEmitter.on

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


once

Staticonce(emitter: NodeEventTarget, event: string | symbol): Promise<any[]>

Parameters:

Name

Type

emitter

NodeEventTarget

event

string | symbol

Returns: Promise<any[]>

Inherited from: EventEmitter.once

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

Staticonce(emitter: DOMEventTarget, event: string): Promise<any[]>

Parameters:

Name

Type

emitter

DOMEventTarget

event

string

Returns: Promise<any[]>

Inherited from: EventEmitter.once

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