@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
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 |
|---|---|---|---|
|
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: browser/src/Session.ts:91
Properties¶
info¶
• Readonly info: ISessionInfo
Information regarding the current session.
Defined in: browser/src/Session.ts:87
tokenRequestInProgress¶
• Private tokenRequestInProgress: boolean= false
Defined in: browser/src/Session.ts:91
captureRejectionSymbol¶
▪ Readonly Static captureRejectionSymbol: typeof 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.
Defined in: browser/node_modules/@types/node/events.d.ts:49
defaultMaxListeners¶
▪ Static defaultMaxListeners: number
Defined in: browser/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: browser/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: browser/node_modules/@types/node/events.d.ts:72
eventNames¶
▸ eventNames(): (string | symbol)[]
Returns: (string | symbol)[]
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 |
|---|---|---|
|
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: browser/src/Session.ts:159
getMaxListeners¶
▸ getMaxListeners(): number
Returns: number
Defined in: browser/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 Solid identity provider through redirect.
Parameters:¶
Name |
Type |
Default value |
Description |
|---|---|---|---|
|
string |
… |
The URL of the page handling the redirect, including the query parameters — these contain the information to process the login. Note: as a convenience, if no URL value is specified here, we default to using the browser’s current location. |
Returns: Promise<undefined | ISessionInfo>
Defined in: browser/src/Session.ts:181
listenerCount¶
▸ listenerCount(event: string | symbol): number
Parameters:¶
Name |
Type |
|---|---|
|
string | symbol |
Returns: number
Defined in: browser/node_modules/@types/node/events.d.ts:73
listeners¶
▸ listeners(event: string | symbol): Function[]
Parameters:¶
Name |
Type |
|---|---|
|
string | symbol |
Returns: Function[]
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 |
|---|---|---|
|
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: browser/src/Session.ts:147
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:166
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: browser/src/Session.ts:243
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: browser/src/Session.ts:252
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 |
|---|---|---|
|
( |
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:264
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: browser/node_modules/@types/node/events.d.ts:71
listenerCount¶
▸ StaticlistenerCount(emitter: EventEmitter, event: string | symbol): number
deprecated since v4.0.0
Parameters:¶
Name |
Type |
|---|---|
|
EventEmitter |
|
string | symbol |
Returns: number
Defined in: browser/node_modules/@types/node/events.d.ts:31
on¶
▸ Staticon(emitter: EventEmitter, event: string): AsyncIterableIterator<any>
Parameters:¶
Name |
Type |
|---|---|
|
EventEmitter |
|
string |
Returns: AsyncIterableIterator<any>
Defined in: browser/node_modules/@types/node/events.d.ts:28
once¶
▸ Staticonce(emitter: NodeEventTarget, event: string | symbol): Promise<any[]>
Parameters:¶
Name |
Type |
|---|---|
|
NodeEventTarget |
|
string | symbol |
Returns: Promise<any[]>
Defined in: browser/node_modules/@types/node/events.d.ts:26
▸ Staticonce(emitter: DOMEventTarget, event: string): Promise<any[]>
Parameters:¶
Name |
Type |
|---|---|
|
DOMEventTarget |
|
string |
Returns: Promise<any[]>
Defined in: browser/node_modules/@types/node/events.d.ts:27