Class: AuthConnect
Methods
buildAuthResult
▸ buildAuthResult(provider, options, tokens): Promise<AuthResult>
Builds an AuthResult object.
Parameters
| Name | Type |
|---|---|
provider | AuthProvider |
options | ProviderOptions |
tokens | Object |
tokens.accessToken? | string |
tokens.idToken? | string |
tokens.refreshToken? | string |
Returns
Promise<AuthResult>
Usage
_10const newAuthResult = await AuthConnect.buildAuthResult(getProvider(), getProviderOptions(), {refreshToken});
decodeToken
▸ decodeToken<T>(tokenType, auth, parseHeader?): Promise<T>
Returns decoded token data from the specified TokenType.
Type parameters
| Name |
|---|
T |
Parameters
| Name | Type |
|---|---|
tokenType | TokenType |
auth | AuthResult |
parseHeader? | boolean |
Returns
Promise<T>
Usage
_10const data = await AuthConnect.decodeToken<MyType>(TokenType.id, authResult);
Remarks
This method does not support encrypted tokens (e.g., tokens using A256GCM encryption). Attempting to use this method with an encrypted token will result in an error. Encrypted tokens are supported for login and logout operations, but cannot be used for token inspection or manipulation methods.
expire
▸ expire(auth): Promise<AuthResult>
Expire the current access token, but keep the refresh token, useful for testing.
Parameters
| Name | Type |
|---|---|
auth | AuthResult |
Returns
Promise<AuthResult>
Usage
_10const expiredAuthResult = await AuthConnect.expire(authResult);
Remarks
This method does not support encrypted tokens (e.g., tokens using A256GCM encryption). Attempting to use this method with an encrypted token will result in an error. Encrypted tokens are supported for login and logout operations, but cannot be used for token inspection or manipulation methods.
fetchManifest
▸ fetchManifest(discoveryUrl?): Promise<Manifest>
Download the auth provider manifest from the specified discoveryUrl.
Parameters
| Name | Type |
|---|---|
discoveryUrl? | string |
Returns
Promise<Manifest>
Manifest
getAccessTokenExpiration
▸ getAccessTokenExpiration(auth): Promise<undefined | number>
Get the time until the access token expires, in milliseconds.
Parameters
| Name | Type |
|---|---|
auth | AuthResult |
Returns
Promise<undefined | number>
number
Usage
_10const expiresIn = await AuthConnect.getAccessTokenExpiration(authResult);
Remarks
This method does not support encrypted tokens (e.g., tokens using A256GCM encryption). Attempting to use this method with an encrypted token will result in an error. Encrypted tokens are supported for login and logout operations, but cannot be used for token inspection or manipulation methods.
getConfig
▸ getConfig(): Promise<AuthConnectConfig>
Get the current configuration object used by AuthConnect
Returns
Promise<AuthConnectConfig>
AuthConnectConfig
Usage
_10const config = await AuthConnect.getConfig();
getToken
▸ getToken(tokenType, auth): Promise<undefined | string>
Get the raw token string from the specified TokenType.
Parameters
| Name | Type |
|---|---|
tokenType | TokenType |
auth | AuthResult |
Returns
Promise<undefined | string>
Usage
_10const tokenString = await AuthConnect.getToken(TokenType.access, authResult);
handleLoginCallback
▸ handleLoginCallback(queryEntries, providerOptions): Promise<AuthResult>
Manually called by the hosting app to handle the login callback on web.
This is only needed if the hosting app is using current for the WebOptions#uiMode.
This method will parse the callback query parameters and return an AuthResult.
Parameters
| Name | Type | Description |
|---|---|---|
queryEntries | Object | The key/value pairs (as strings) for the query parameters in the callback url. |
providerOptions | ProviderOptions | The provider options used during the initial login. |
Returns
Promise<AuthResult>
Usage
_10const urlParams = new URLSearchParams(window.location.search);_10const queryEntries = Object.fromEntries(urlParams.entries());_10this.result = await AuthConnect.handleLoginCallback(queryEntries, providerOptions);
isAccessTokenAvailable
▸ isAccessTokenAvailable(auth, tokenName?): Promise<boolean>
Checks if access token is available in the provided AuthResult.
Parameters
| Name | Type |
|---|---|
auth | AuthResult |
tokenName? | string |
Returns
Promise<boolean>
Usage
_10const isAvailable = await AuthConnect.isAccessTokenAvailable(authResult);
Remarks
This method does not support encrypted tokens (e.g., tokens using A256GCM encryption). Attempting to use this method with an encrypted token will result in an error. Encrypted tokens are supported for login and logout operations, but cannot be used for token inspection or manipulation methods.
isAccessTokenExpired
▸ isAccessTokenExpired(auth): Promise<boolean>
Checks if the access token is expired.
Parameters
| Name | Type |
|---|---|
auth | AuthResult |
Returns
Promise<boolean>
Usage
_10const isExpired = await AuthConnect.isAccessTokenExpired(authResult);
Remarks
This method does not support encrypted tokens (e.g., tokens using A256GCM encryption). Attempting to use this method with an encrypted token will result in an error. Encrypted tokens are supported for login and logout operations, but cannot be used for token inspection or manipulation methods.
isRefreshTokenAvailable
▸ isRefreshTokenAvailable(auth): Promise<boolean>
Checks if refresh token is available in the provided AuthResult.
Parameters
| Name | Type |
|---|---|
auth | AuthResult |
Returns
Promise<boolean>
Usage
_10const isAvailable = await AuthConnect.isRefreshTokenAvailable(authResult);
login
▸ login(provider, options): Promise<AuthResult>
Display the auth provider's login UI, and begin the login process.
Parameters
| Name | Type |
|---|---|
provider | AuthProvider |
options | ProviderOptions |
Returns
Promise<AuthResult>
AuthResult
Usage
_10const result = await AuthConnect.login(getProvider(), myProviderConfig);
logout
▸ logout(provider, auth): Promise<void>
Log the user out of the auth provider.
Parameters
| Name | Type |
|---|---|
provider | AuthProvider |
auth | AuthResult |
Returns
Promise<void>
Usage
_10await AuthConnect.logout(getProvider(), authResult);
refreshSession
▸ refreshSession(provider, auth, scope?): Promise<AuthResult>
Refresh the AuthResult session, throws if refresh token is invalid or missing.
Parameters
| Name | Type |
|---|---|
provider | AuthProvider |
auth | AuthResult |
scope? | string |
Returns
Promise<AuthResult>
Usage
_10const newAuthResult = await AuthConnect.refreshSession(getProvider(), authResult);
setup
▸ setup(config): Promise<void>
Initialize AuthConnect with platform level configuration.
Parameters
| Name | Type |
|---|---|
config | AuthConnectConfig |
Returns
Promise<void>
Usage
_10await AuthConnect.setup(myConfig);