@inrupt/solid-client-authn-browser

Globals / “Session” / 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?: undefined | string): Session

Overrides void

Defined in browser/src/Session.ts:64

Session object constructor. Typically called as follows:

const session = new Session(
  {
    clientAuthentication: getClientAuthenticationWithDependencies({})
  },
  "mySession"
);

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?

undefined | string

-

A magic string uniquely identifying the session.

Returns: Session

Properties

clientAuthentication

Private clientAuthentication: ClientAuthentication

Defined in browser/src/Session.ts:63


info

Readonly info: ISessionInfo

Defined in browser/src/Session.ts:61

Information regarding the current session.


tokenRequestInProgress

Private tokenRequestInProgress: boolean = false

Defined in browser/src/Session.ts:64


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


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>


fetch

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

Defined in browser/src/Session.ts:134

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>


getMaxListeners

getMaxListeners(): number

Inherited from SessionManager.getMaxListeners

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

Returns: number


handleIncomingRedirect

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

Defined in browser/src/Session.ts:151

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

Parameters:

Name

Type

Description

url

string

The URL of the page handling the redirect, including the query parameters — these contain the information to process the login.

Returns: Promise<ISessionInfo | undefined>


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


login

login(options: ILoginInputOptions): Promise<void>

Defined in browser/src/Session.ts:122

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.


logout

logout(): Promise<void>

Defined in browser/src/Session.ts:141

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

Returns: Promise<void>


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


onLogin

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

Defined in browser/src/Session.ts:185

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


onLogout

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

Defined in browser/src/Session.ts:194

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


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