@inrupt/solid-client-authn-node / 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(
  {
    clientAuthentication: getClientAuthenticationWithDependencies({})
  },
  "mySession"
);

Parameters:

Name

Type

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

Defined in: node/src/Session.ts:89

Properties

clientAuthentication

Private clientAuthentication: default

Defined in: node/src/Session.ts:87


info

Readonly info: ISessionInfo

Information regarding the current session.

Defined in: node/src/Session.ts:85


tokenRequestInProgress

Private tokenRequestInProgress: boolean= false

Defined in: node/src/Session.ts:89


captureRejectionSymbol

Readonly Static captureRejectionSymbol: typeof captureRejectionSymbol

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


captureRejections

Static captureRejections: boolean

Sets or gets the default captureRejection value for all emitters.

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


defaultMaxListeners

Static defaultMaxListeners: number

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


errorMonitor

Readonly Static 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.

Defined in: node/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

Defined in: node/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

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


eventNames

eventNames(): (string | symbol)[]

Returns: (string | symbol)[]

Defined in: node/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: node/src/Session.ts:175


getMaxListeners

getMaxListeners(): number

Returns: number

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


handleIncomingRedirect

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

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

Defined in: node/src/Session.ts:199


listenerCount

listenerCount(event: string | symbol): number

Parameters:

Name

Type

event

string | symbol

Returns: number

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


listeners

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

Parameters:

Name

Type

event

string | symbol

Returns: Function[]

Defined in: node/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: node/src/Session.ts:155


logout

logout(): Promise<void>

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>

Defined in: node/src/Session.ts:188


off

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

Parameters:

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: Session

Defined in: node/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

Defined in: node/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: node/src/Session.ts:242


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: node/src/Session.ts:251


once

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

Parameters:

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns: Session

Defined in: node/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

Defined in: node/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

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


rawListeners

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

Parameters:

Name

Type

event

string | symbol

Returns: Function[]

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


removeAllListeners

removeAllListeners(event?: string | symbol): Session

Parameters:

Name

Type

event?

string | symbol

Returns: Session

Defined in: node/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

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


setMaxListeners

setMaxListeners(n: number): Session

Parameters:

Name

Type

n

number

Returns: Session

Defined in: node/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

Defined in: node/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>

Defined in: node/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[]>

Defined in: node/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[]>

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