@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 |
---|---|---|
|
Partial<ISessionOptions> |
The options enabling the correct instantiation of the session. Either both storages or clientAuthentication are required. For more information, see ISessionOptions. |
|
string |
A string uniquely identifying the session. |
Returns: Session
Defined in: node/src/Session.ts:89
Properties¶
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¶
emit¶
▸ emit(event
: string | symbol, …args
: any[]): boolean
Parameters:¶
Name |
Type |
---|---|
|
string | symbol |
|
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 |
---|---|---|
|
RequestInfo |
The URL from which data should be fetched. |
|
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 |
---|---|---|
|
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 |
---|---|
|
string | symbol |
Returns: number
Defined in: node/node_modules/@types/node/events.d.ts:73
listeners¶
▸ listeners(event
: string | symbol): Function[]
Parameters:¶
Name |
Type |
---|---|
|
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 |
---|---|---|
|
Parameter to customize the login behaviour. In particular, two options are mandatory: |
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
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 |
---|---|---|
|
() => 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 |
---|---|---|
|
() => unknown |
The function called when a user completes logout. |
Returns: void
Defined in: node/src/Session.ts:251
prependListener¶
▸ prependListener(event
: string | symbol, listener
: (…args
: any[]) => void): Session
prependOnceListener¶
▸ prependOnceListener(event
: string | symbol, listener
: (…args
: any[]) => void): Session
rawListeners¶
▸ rawListeners(event
: string | symbol): Function[]
Parameters:¶
Name |
Type |
---|---|
|
string | symbol |
Returns: Function[]
Defined in: node/node_modules/@types/node/events.d.ts:71
listenerCount¶
▸ Static
listenerCount(emitter
: EventEmitter, event
: string | symbol): number
deprecated
since v4.0.0
Parameters:¶
Name |
Type |
---|---|
|
EventEmitter |
|
string | symbol |
Returns: number
Defined in: node/node_modules/@types/node/events.d.ts:31
on¶
▸ Static
on(emitter
: EventEmitter, event
: string): AsyncIterableIterator<any>
Parameters:¶
Name |
Type |
---|---|
|
EventEmitter |
|
string |
Returns: AsyncIterableIterator<any>
Defined in: node/node_modules/@types/node/events.d.ts:28
once¶
▸ Static
once(emitter
: NodeEventTarget, event
: string | symbol): Promise<any[]>
Parameters:¶
Name |
Type |
---|---|
|
NodeEventTarget |
|
string | symbol |
Returns: Promise<any[]>
Defined in: node/node_modules/@types/node/events.d.ts:26
▸ Static
once(emitter
: DOMEventTarget, event
: string): Promise<any[]>
Parameters:¶
Name |
Type |
---|---|
|
DOMEventTarget |
|
string |
Returns: Promise<any[]>
Defined in: node/node_modules/@types/node/events.d.ts:27