@inrupt/solid-client-authn-browser

Globals / “SessionManager” / 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

Constructors

constructor

+ new SessionManager(options?: ISessionManagerOptions): SessionManager

Overrides void

Defined in browser/src/SessionManager.ts:51

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

Properties

clientAuthn

Private clientAuthn: ClientAuthentication

Defined in browser/src/SessionManager.ts:45


handledIncomingRedirect

Private handledIncomingRedirect: boolean = false

Defined in browser/src/SessionManager.ts:51


isInitialized

Private isInitialized: boolean = false

Defined in browser/src/SessionManager.ts:50


sessionRecords

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

Defined in browser/src/SessionManager.ts:46


defaultMaxListeners

Static defaultMaxListeners: number

Inherited from SessionManager.defaultMaxListeners

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


errorMonitor

Static Readonly errorMonitor: unique symbol

Inherited from SessionManager.errorMonitor

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

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.

Methods

addListener

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

Inherited from SessionManager.addListener

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

Parameters:

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: this


addNewSessionRecord

PrivateaddNewSessionRecord(session: Session): Session

Defined in browser/src/SessionManager.ts:86

Parameters:

Name

Type

session

Session

Returns: Session


detachSession

detachSession(sessionId: string): void

Defined in browser/src/SessionManager.ts:192

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


emit

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

Inherited from SessionManager.emit

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

Parameters:

Name

Type

event

string | symbol

...args

any[]

Returns: boolean


eventNames

eventNames(): Array<string | symbol>

Inherited from SessionManager.eventNames

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

Returns: Array<string | symbol>


getMaxListeners

getMaxListeners(): number

Inherited from SessionManager.getMaxListeners

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

Returns: number


getSession

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

Implementation of ISessionManager

Defined in browser/src/SessionManager.ts:134

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?

undefined | string

An optional unique session identifier.

Returns: Promise<Session>

A Session associated to the given ID.


getSessionFromCurrentSessionInfo

PrivategetSessionFromCurrentSessionInfo(sessionInfo: ISessionInfo): Session

Defined in browser/src/SessionManager.ts:98

Parameters:

Name

Type

sessionInfo

ISessionInfo

Returns: Session


getSessions

getSessions(): Promise<Session[]>

Defined in browser/src/SessionManager.ts:117

Returns: Promise<Session[]>

all the sessions currently managed by the session manager.


handleIncomingRedirect

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

Defined in browser/src/SessionManager.ts:210

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<Session | undefined>

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


hasSession

hasSession(sessionId: string): Promise<boolean>

Defined in browser/src/SessionManager.ts:160

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.


init

Privateinit(): Promise<void>

Defined in browser/src/SessionManager.ts:76

Returns: Promise<void>


listenerCount

listenerCount(event: string | symbol): number

Inherited from SessionManager.listenerCount

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

Parameters:

Name

Type

event

string | symbol

Returns: number


listeners

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

Inherited from SessionManager.listeners

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

Parameters:

Name

Type

event

string | symbol

Returns: Function[]


off

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

Inherited from SessionManager.off

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

Parameters:

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: this


on

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

Inherited from SessionManager.on

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

Parameters:

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: this


onSessionLogin

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

Defined in browser/src/SessionManager.ts:170

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


onSessionLogout

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

Defined in browser/src/SessionManager.ts:179

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


once

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

Inherited from SessionManager.once

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

Parameters:

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: this


prependListener

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

Inherited from SessionManager.prependListener

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

Parameters:

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: this


prependOnceListener

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

Inherited from SessionManager.prependOnceListener

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

Parameters:

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: this


rawListeners

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

Inherited from SessionManager.rawListeners

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

Parameters:

Name

Type

event

string | symbol

Returns: Function[]


removeAllListeners

removeAllListeners(event?: string | symbol): this

Inherited from SessionManager.removeAllListeners

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

Parameters:

Name

Type

event?

string | symbol

Returns: this


removeListener

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

Inherited from SessionManager.removeListener

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

Parameters:

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: this


setMaxListeners

setMaxListeners(n: number): this

Inherited from SessionManager.setMaxListeners

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

Parameters:

Name

Type

n

number

Returns: this


listenerCount

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

Inherited from SessionManager.listenerCount

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

deprecated since v4.0.0

Parameters:

Name

Type

emitter

EventEmitter

event

string | symbol

Returns: number