@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?, sessionId?)

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.

Overrides

EventEmitter.constructor

Properties

clientAuthentication

Private clientAuthentication: default


info

Readonly info: ISessionInfo

Information regarding the current session.


onNewRefreshToken

Private Optional onNewRefreshToken: (newToken: string) => unknown

Type declaration

▸ (newToken): unknown

Parameters

Name

Type

newToken

string

Returns

unknown


tokenRequestInProgress

Private tokenRequestInProgress: boolean = false


captureRejectionSymbol

Static Readonly captureRejectionSymbol: typeof captureRejectionSymbol

Inherited from

EventEmitter.captureRejectionSymbol

Defined in

node/node_modules/@types/node/events.d.ts:46


captureRejections

Static captureRejections: boolean

Sets or gets the default captureRejection value for all emitters.

Inherited from

EventEmitter.captureRejections

Defined in

node/node_modules/@types/node/events.d.ts:52


defaultMaxListeners

Static defaultMaxListeners: number

Inherited from

EventEmitter.defaultMaxListeners

Defined in

node/node_modules/@types/node/events.d.ts:53


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

node/node_modules/@types/node/events.d.ts:45

Methods

addListener

addListener(event, listener): Session

Parameters

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns

Session

Inherited from

EventEmitter.addListener

Defined in

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


emit

emit(event, …args): boolean

Parameters

Name

Type

event

string | symbol

...args

any[]

Returns

boolean

Inherited from

EventEmitter.emit

Defined in

node/node_modules/@types/node/events.d.ts:82


eventNames

eventNames(): (string | symbol)[]

Returns

(string | symbol)[]

Inherited from

EventEmitter.eventNames

Defined in

node/node_modules/@types/node/events.d.ts:87


fetch

fetch(url, init?): 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>


getMaxListeners

getMaxListeners(): number

Returns

number

Inherited from

EventEmitter.getMaxListeners

Defined in

node/node_modules/@types/node/events.d.ts:79


handleIncomingRedirect

handleIncomingRedirect(url): 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>


listenerCount

listenerCount(event): number

Parameters

Name

Type

event

string | symbol

Returns

number

Inherited from

EventEmitter.listenerCount

Defined in

node/node_modules/@types/node/events.d.ts:83


listeners

listeners(event): Function[]

Parameters

Name

Type

event

string | symbol

Returns

Function[]

Inherited from

EventEmitter.listeners

Defined in

node/node_modules/@types/node/events.d.ts:80


login

login(options): 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.


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>


off

off(event, listener): Session

Parameters

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns

Session

Inherited from

EventEmitter.off

Defined in

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


on

on(event, listener): Session

Parameters

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns

Session

Inherited from

EventEmitter.on

Defined in

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


onLogin

onLogin(callback): 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


onLogout

onLogout(callback): 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


once

once(event, listener): Session

Parameters

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns

Session

Inherited from

EventEmitter.once

Defined in

node/node_modules/@types/node/events.d.ts:74


prependListener

prependListener(event, listener): Session

Parameters

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns

Session

Inherited from

EventEmitter.prependListener

Defined in

node/node_modules/@types/node/events.d.ts:85


prependOnceListener

prependOnceListener(event, listener): Session

Parameters

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns

Session

Inherited from

EventEmitter.prependOnceListener

Defined in

node/node_modules/@types/node/events.d.ts:86


rawListeners

rawListeners(event): Function[]

Parameters

Name

Type

event

string | symbol

Returns

Function[]

Inherited from

EventEmitter.rawListeners

Defined in

node/node_modules/@types/node/events.d.ts:81


removeAllListeners

removeAllListeners(event?): Session

Parameters

Name

Type

event?

string | symbol

Returns

Session

Inherited from

EventEmitter.removeAllListeners

Defined in

node/node_modules/@types/node/events.d.ts:77


removeListener

removeListener(event, listener): Session

Parameters

Name

Type

event

string | symbol

listener

(…args: any[]) => void

Returns

Session

Inherited from

EventEmitter.removeListener

Defined in

node/node_modules/@types/node/events.d.ts:75


setMaxListeners

setMaxListeners(n): Session

Parameters

Name

Type

n

number

Returns

Session

Inherited from

EventEmitter.setMaxListeners

Defined in

node/node_modules/@types/node/events.d.ts:78


getEventListener

Static getEventListener(emitter, name): Function[]

Returns a list listener for a specific emitter event name.

Parameters

Name

Type

emitter

DOMEventTarget | EventEmitter

name

string | symbol

Returns

Function[]

Inherited from

EventEmitter.getEventListener

Defined in

node/node_modules/@types/node/events.d.ts:34


listenerCount

Static listenerCount(emitter, event): number

deprecated since v4.0.0

Parameters

Name

Type

emitter

EventEmitter

event

string | symbol

Returns

number

Inherited from

EventEmitter.listenerCount

Defined in

node/node_modules/@types/node/events.d.ts:30


on

Static on(emitter, event, options?): AsyncIterableIterator<any>

Parameters

Name

Type

emitter

EventEmitter

event

string

options?

StaticEventEmitterOptions

Returns

AsyncIterableIterator<any>

Inherited from

EventEmitter.on

Defined in

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


once

Static once(emitter, event, options?): Promise<any[]>

Parameters

Name

Type

emitter

NodeEventTarget

event

string | symbol

options?

StaticEventEmitterOptions

Returns

Promise<any[]>

Inherited from

EventEmitter.once

Defined in

node/node_modules/@types/node/events.d.ts:25

Static once(emitter, event, options?): Promise<any[]>

Parameters

Name

Type

emitter

DOMEventTarget

event

string

options?

StaticEventEmitterOptions

Returns

Promise<any[]>

Inherited from

EventEmitter.once

Defined in

node/node_modules/@types/node/events.d.ts:26