Skip to main content
Version: 8.0

Class: AuthConnect

Methods

buildAuthResult

buildAuthResult(provider, options, tokens): Promise<AuthResult>

Builds an AuthResult object.

Parameters

NameType
providerAuthProvider
optionsProviderOptions
tokensObject
tokens.accessToken?string
tokens.idToken?string
tokens.refreshToken?string

Returns

Promise<AuthResult>

Usage


_10
const 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

NameType
tokenTypeTokenType
authAuthResult
parseHeader?boolean

Returns

Promise<T>

Usage


_10
const 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

NameType
authAuthResult

Returns

Promise<AuthResult>

Usage


_10
const 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

NameType
discoveryUrl?string

Returns

Promise<Manifest>

Manifest


getAccessTokenExpiration

getAccessTokenExpiration(auth): Promise<undefined | number>

Get the time until the access token expires, in milliseconds.

Parameters

NameType
authAuthResult

Returns

Promise<undefined | number>

number

Usage


_10
const 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


_10
const config = await AuthConnect.getConfig();


getToken

getToken(tokenType, auth): Promise<undefined | string>

Get the raw token string from the specified TokenType.

Parameters

NameType
tokenTypeTokenType
authAuthResult

Returns

Promise<undefined | string>

Usage


_10
const 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

NameTypeDescription
queryEntriesObjectThe key/value pairs (as strings) for the query parameters in the callback url.
providerOptionsProviderOptionsThe provider options used during the initial login.

Returns

Promise<AuthResult>

Usage


_10
const urlParams = new URLSearchParams(window.location.search);
_10
const queryEntries = Object.fromEntries(urlParams.entries());
_10
this.result = await AuthConnect.handleLoginCallback(queryEntries, providerOptions);


isAccessTokenAvailable

isAccessTokenAvailable(auth, tokenName?): Promise<boolean>

Checks if access token is available in the provided AuthResult.

Parameters

NameType
authAuthResult
tokenName?string

Returns

Promise<boolean>

Usage


_10
const 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

NameType
authAuthResult

Returns

Promise<boolean>

Usage


_10
const 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

NameType
authAuthResult

Returns

Promise<boolean>

Usage


_10
const isAvailable = await AuthConnect.isRefreshTokenAvailable(authResult);


login

login(provider, options): Promise<AuthResult>

Display the auth provider's login UI, and begin the login process.

Parameters

NameType
providerAuthProvider
optionsProviderOptions

Returns

Promise<AuthResult>

AuthResult

Usage


_10
const result = await AuthConnect.login(getProvider(), myProviderConfig);


logout

logout(provider, auth): Promise<void>

Log the user out of the auth provider.

Parameters

NameType
providerAuthProvider
authAuthResult

Returns

Promise<void>

Usage


_10
await AuthConnect.logout(getProvider(), authResult);


refreshSession

refreshSession(provider, auth, scope?): Promise<AuthResult>

Refresh the AuthResult session, throws if refresh token is invalid or missing.

Parameters

NameType
providerAuthProvider
authAuthResult
scope?string

Returns

Promise<AuthResult>

Usage


_10
const newAuthResult = await AuthConnect.refreshSession(getProvider(), authResult);


setup

setup(config): Promise<void>

Initialize AuthConnect with platform level configuration.

Parameters

NameType
configAuthConnectConfig

Returns

Promise<void>

Usage


_10
await AuthConnect.setup(myConfig);