Module connection
January 9, 2025 · View on GitHub
Class Connection
Provides an encapsulation of the OpenID Connect user connection.
Constructors
Connection(router, configuration, userManager, userPrompt)
Creates an instance of the class with the given parameter.
| Parameters | Type | Description |
|---|---|---|
| router | Router | the aurelia router |
| configuration | PluginConfiguration | the openid plugin configuration |
| userManager | UserManager | the openid user manager |
| userPrompt | UserPrompt | the user prompt to confirm reconnection |
Methods
observeUser(userfunc) ► Promise.<void>

Defines a callback called when user connection changes.
| Parameters | Type | Description |
|---|---|---|
| userfunc | (user: User) => void | a callback called when user connection changes |
| return | Promise.<void> | the promise that retrieves user |
getUser() ► Promise.<User>

Retrieves the connected user.
| Parameters | Type | Description |
|---|---|---|
| return | Promise.<User> | the connected user |
loginUser(route, options) ► Promise.<void>

Initiates the OpenID Connect user connection.
| Parameters | Type | Description |
|---|---|---|
| route | string | the aurelia route name to be redirected after login - if not specified this will be the current route |
| options | ExtraSigninRequestArgs | optional options passed to underlying oidc signin method |
| return | Promise.<void> | ** |
logoutUser(route, options) ► Promise.<void>

Initiates the OpenID Connect user deconnection.
| Parameters | Type | Description |
|---|---|---|
| route | string | the aurelia route name to be redirected after logout - if not specified this will be the current route |
| options | ExtraSignoutRequestArgs | optional options passed to underlying oidc signout method |
| return | Promise.<void> | ** |
trySilentLogin(route) ► Promise.<void>

Initiates the OpenID Connect silent user connection and displays the reconnect prompt if asked by the provider.
| Parameters | Type | Description |
|---|---|---|
| route | string | the aurelia route name to be redirected in case of reconnnect prompt - if not specified this will be the current route |
| return | Promise.<void> | ** |
_setUser(user)

Sets the connected user entity.
| Parameters | Type | Description |
|---|---|---|
| user | User | the OpenID Connect user |
Members
| Name | Type | Description |
|---|---|---|
| inProgress | boolean | Is silent login in progress? |
| userId | string | The user identifier. It may be undefined. |
| isUserLoggedIn | boolean | Is the user currently connected with an eventually expired access token? |
| hasValidAccessToken | boolean | Has the user a valid access token? |
| accessToken | string | The user access token. The token may be expired. Check hasValidAccessToken property before. |
| userName | string | The display name of the user. The 'name' claim is used to provide this information. |
| profile | UserProfile | The profile of the user. It contains the claims provided by the identity provider. |
| expiresIn | number | The number of seconds the access token has remaining. |