Class: AuthConnect
Methods
buildAuthResult
▸ Static
buildAuthResult(provider
, options
, tokens
): Promise
<AuthResult
>
Builds an AuthResult object.
Usage
_10const newAuthResult = await AuthConnect.buildAuthResult(getProvider(), getProviderOptions(), {refreshToken});
Parameters
Name | Type |
---|---|
provider | AuthProvider |
options | ProviderOptions |
tokens | Object |
tokens.accessToken? | string |
tokens.idToken? | string |
tokens.refreshToken? | string |
Returns
Promise
<AuthResult
>
decodeToken
▸ Static
decodeToken<T
>(tokenType
, auth
, parseHeader?
): Promise
<T
>
Returns decoded token data from the specified TokenType.
Usage
_10const data = await AuthConnect.decodeToken<MyType>(TokenType.id, authResult);
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
tokenType | TokenType |
auth | AuthResult |
parseHeader? | boolean |
Returns
Promise
<T
>
expire
▸ Static
expire(auth
): Promise
<AuthResult
>
Expire the current access token, but keep the refresh token, useful for testing.
Usage
_10const expiredAuthResult = await AuthConnect.expire(authResult);
Parameters
Name | Type |
---|---|
auth | AuthResult |
Returns
Promise
<AuthResult
>
fetchManifest
▸ Static
fetchManifest(discoveryUrl?
): Promise
<Manifest
>
Download the auth provider manifest from the specified discoveryUrl.
Parameters
Name | Type |
---|---|
discoveryUrl? | string |
Returns
Promise
<Manifest
>
Manifest
getAccessTokenExpiration
▸ Static
getAccessTokenExpiration(auth
): Promise
<undefined
| number
>
Get the time until the access token expires, in milliseconds.
Usage
_10const expiresIn = await AuthConnect.getAccessTokenExpiration(authResult);
Parameters
Name | Type |
---|---|
auth | AuthResult |
Returns
Promise
<undefined
| number
>
number
getConfig
▸ Static
getConfig(): Promise
<AuthConnectConfig
>
Get the current configuration object used by AuthConnect
Usage
_10const config = await AuthConnect.getConfig();
Returns
Promise
<AuthConnectConfig
>
AuthConnectConfig
getToken
▸ Static
getToken(tokenType
, auth
): Promise
<undefined
| string
>
Get the raw token string from the specified TokenType.
Usage
_10const tokenString = await AuthConnect.getToken(TokenType.access, authResult);
Parameters
Name | Type |
---|---|
tokenType | TokenType |
auth | AuthResult |
Returns
Promise
<undefined
| string
>
handleLoginCallback
▸ Static
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 uiMode.
This method will parse the callback query parameters and return an AuthResult.
Usage
_10const urlParams = new URLSearchParams(window.location.search);_10const queryEntries = Object.fromEntries(urlParams.entries());_10this.result = await AuthConnect.handleLoginCallback(queryEntries, providerOptions);
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
>
isAccessTokenAvailable
▸ Static
isAccessTokenAvailable(auth
, tokenName?
): Promise
<boolean
>
Checks if access token is available in the provided AuthResult.
Usage
_10const isAvailable = await AuthConnect.isAccessTokenAvailable(authResult);
Parameters
Name | Type |
---|---|
auth | AuthResult |
tokenName? | string |
Returns
Promise
<boolean
>
isAccessTokenExpired
▸ Static
isAccessTokenExpired(auth
): Promise
<boolean
>
Checks if the access token is expired.
Usage
_10const isExpired = await AuthConnect.isAccessTokenExpired(authResult);
Parameters
Name | Type |
---|---|
auth | AuthResult |
Returns
Promise
<boolean
>
isRefreshTokenAvailable
▸ Static
isRefreshTokenAvailable(auth
): Promise
<boolean
>
Checks if refresh token is available in the provided AuthResult.
Usage
_10const isAvailable = await AuthConnect.isRefreshTokenAvailable(authResult);
Parameters
Name | Type |
---|---|
auth | AuthResult |
Returns
Promise
<boolean
>
login
▸ Static
login(provider
, options
): Promise
<AuthResult
>
Display the auth provider's login UI, and begin the login process.
Usage
_10const result = await AuthConnect.login(getProvider(), myProviderConfig);
Parameters
Name | Type |
---|---|
provider | AuthProvider |
options | ProviderOptions |
Returns
Promise
<AuthResult
>
AuthResult
logout
▸ Static
logout(provider
, auth
): Promise
<void
>
Log the user out of the auth provider.
Usage
_10await AuthConnect.logout(getProvider(), authResult);
Parameters
Name | Type |
---|---|
provider | AuthProvider |
auth | AuthResult |
Returns
Promise
<void
>
refreshSession
▸ Static
refreshSession(provider
, auth
, scope?
): Promise
<AuthResult
>
Refresh the AuthResult session, throws if refresh token is invalid or missing.
Usage
_10const newAuthResult = await AuthConnect.refreshSession(getProvider(), authResult);
Parameters
Name | Type |
---|---|
provider | AuthProvider |
auth | AuthResult |
scope? | string |
Returns
Promise
<AuthResult
>
setup
▸ Static
setup(config
): Promise
<void
>
Initialize AuthConnect with platform level configuration.
Usage
_10await AuthConnect.setup(myConfig);
Parameters
Name | Type |
---|---|
config | AuthConnectConfig |
Returns
Promise
<void
>