@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

Table of contents

Constructors

Properties

Methods

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

Properties

clientAuthentication

Private clientAuthentication: default

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


info

Readonly info: ISessionInfo

Information regarding the current session.

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


tokenRequestInProgress

Private tokenRequestInProgress: boolean= false

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


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


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


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


getMaxListeners

getMaxListeners(): number

Returns: number

Inherited from: EventEmitter.getMaxListeners

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


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


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


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


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


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


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


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


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


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


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


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


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

Parameters:

Name

Type

event?

string | symbol

Returns: Session

Inherited from: EventEmitter.removeAllListeners

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


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


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