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

Class: Session

A Session object represents a user’s session on an application. The session holds state, as it stores information enabling acces to private resources after login for instance.

Hierarchy

  • EventEmitter

    Session

Constructors

constructor

+ new Session(sessionOptions?: Partial<ISessionOptions>, sessionId?: string): Session

Session object constructor. Typically called as follows:

const session = new Session();

See also getDefaultSession.

Parameters

Name

Type

Default value

Description

sessionOptions

Partial<ISessionOptions>

{}

The options enabling the correct instantiation of the session. Either both storages or clientAuthentication are required. For more information, see ISessionOptions.

sessionId?

string

-

A string uniquely identifying the session.

Returns: Session

Overrides: EventEmitter.constructor

Defined in: browser/src/Session.ts:143

Properties

clientAuthentication

Private clientAuthentication: default

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


info

Readonly info: ISessionInfo

Information regarding the current session.

Defined in: browser/src/Session.ts:136


tmpFetchWithCookies

Private tmpFetchWithCookies: boolean= false

Defined in: browser/src/Session.ts:143


tokenRequestInProgress

Private tokenRequestInProgress: boolean= false

Defined in: browser/src/Session.ts:140


captureRejectionSymbol

Static Readonly captureRejectionSymbol: typeof captureRejectionSymbol

Inherited from: EventEmitter.captureRejectionSymbol

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


defaultMaxListeners

Static defaultMaxListeners: number

Inherited from: EventEmitter.defaultMaxListeners

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

Methods

addListener

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

Parameters

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: Session

Inherited from: EventEmitter.addListener

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


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


eventNames

eventNames(): (string | symbol)[]

Returns: (string | symbol)[]

Inherited from: EventEmitter.eventNames

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


fetch

fetch(url: RequestInfo, init?: RequestInit): Promise<Response>

Fetches data using available login information. If the user is not logged in, this will behave as a regular fetch. The signature of this method is identical to the canonical fetch.

Parameters

Name

Type

Description

url

RequestInfo

The URL from which data should be fetched.

init?

RequestInit

Optional parameters customizing the request, by specifying an HTTP method, headers, a body, etc. Follows the WHATWG Fetch Standard.

Returns: Promise<Response>

Defined in: browser/src/Session.ts:222


getMaxListeners

getMaxListeners(): number

Returns: number

Inherited from: EventEmitter.getMaxListeners

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


handleIncomingRedirect

handleIncomingRedirect(inputOptions?: string | IHandleIncomingRedirectOptions): Promise<undefined | ISessionInfo>

Completes the login process by processing the information provided by the Solid identity provider through redirect.

Parameters

Name

Type

Default value

inputOptions

string | IHandleIncomingRedirectOptions

{}

Returns: Promise<undefined | ISessionInfo>

Defined in: browser/src/Session.ts:249


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


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


login

login(options: ILoginInputOptions): Promise<void>

Triggers the login process. Note that this method will redirect the user away from your app.

Parameters

Name

Type

Description

options

ILoginInputOptions

Parameter to customize the login behaviour. In particular, two options are mandatory: options.oidcIssuer, the user’s identity provider, and options.redirectUrl, the URL to which the user will be redirected after logging in their identity provider.

Returns: Promise<void>

This method should redirect the user away from the app: it does not return anything. The login process is completed by handleIncomingRedirect.

Defined in: browser/src/Session.ts:207


logout

logout(): Promise<void>

Logs the user out of the application. This does not log the user out of their Solid identity provider, and should not redirect the user away.

Returns: Promise<void>

Defined in: browser/src/Session.ts:236


off

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

Parameters

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: Session

Inherited from: EventEmitter.off

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


on

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

Parameters

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: Session

Inherited from: EventEmitter.on

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


onLogin

onLogin(callback: () => unknown): void

Register a callback function to be called when a user completes login.

The callback is called when handleIncomingRedirect completes successfully.

Parameters

Name

Type

Description

callback

() => unknown

The function called when a user completes login.

Returns: void

Defined in: browser/src/Session.ts:403


onLogout

onLogout(callback: () => unknown): void

Register a callback function to be called when a user logs out:

Parameters

Name

Type

Description

callback

() => unknown

The function called when a user completes logout.

Returns: void

Defined in: browser/src/Session.ts:412


onSessionRestore

onSessionRestore(callback: (currentUrl: string) => unknown): void

Register a callback function to be called when a session is restored.

Note: the callback will be called with the saved value of the ‘current URL’ at the time the session was restored.

Parameters

Name

Type

Description

callback

(currentUrl: string) => unknown

The function called when a user’s already logged-in session is restored, e.g., after a silent authentication is completed after a page refresh.

Returns: void

Defined in: browser/src/Session.ts:424


once

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

Parameters

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: Session

Inherited from: EventEmitter.once

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


prependListener

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

Parameters

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: Session

Inherited from: EventEmitter.prependListener

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


prependOnceListener

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

Parameters

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: Session

Inherited from: EventEmitter.prependOnceListener

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


removeAllListeners

removeAllListeners(event?: string | symbol): Session

Parameters

Name

Type

event?

string | symbol

Returns: Session

Inherited from: EventEmitter.removeAllListeners

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


removeListener

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

Parameters

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: Session

Inherited from: EventEmitter.removeListener

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


setMaxListeners

setMaxListeners(n: number): Session

Parameters

Name

Type

n

number

Returns: Session

Inherited from: EventEmitter.setMaxListeners

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