Class: AuthConnect
Methods
handleLogoutCallback
▸ handleLogoutCallback(): Promise<void>
Returns
Promise<void>
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): Promise<AuthResult>
Parameters
| Name | Type |
|---|---|
queryEntries | Object |
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): 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 |
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>