Skip to main content
Version: 6.0

Class: AuthConnect

Methods

buildAuthResult

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

Builds an AuthResult object.

Usage


_10
const newAuthResult = await AuthConnect.buildAuthResult(getProvider(), getProviderOptions(), {refreshToken});

Parameters

NameType
providerAuthProvider
optionsProviderOptions
tokensObject
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


_10
const data = await AuthConnect.decodeToken<MyType>(TokenType.id, authResult);

Type parameters

Name
T

Parameters

NameType
tokenTypeTokenType
authAuthResult
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


_10
const expiredAuthResult = await AuthConnect.expire(authResult);

Parameters

NameType
authAuthResult

Returns

Promise<AuthResult>


fetchManifest

Static fetchManifest(discoveryUrl?): Promise<Manifest>

Download the auth provider manifest from the specified discoveryUrl.

Parameters

NameType
discoveryUrl?string

Returns

Promise<Manifest>

Manifest


getAccessTokenExpiration

Static getAccessTokenExpiration(auth): Promise<undefined | number>

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

Usage


_10
const expiresIn = await AuthConnect.getAccessTokenExpiration(authResult);

Parameters

NameType
authAuthResult

Returns

Promise<undefined | number>

number


getConfig

Static getConfig(): Promise<AuthConnectConfig>

Get the current configuration object used by AuthConnect

Usage


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


_10
const tokenString = await AuthConnect.getToken(TokenType.access, authResult);

Parameters

NameType
tokenTypeTokenType
authAuthResult

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


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

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>


isAccessTokenAvailable

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

Checks if access token is available in the provided AuthResult.

Usage


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

Parameters

NameType
authAuthResult
tokenName?string

Returns

Promise<boolean>


isAccessTokenExpired

Static isAccessTokenExpired(auth): Promise<boolean>

Checks if the access token is expired.

Usage


_10
const isExpired = await AuthConnect.isAccessTokenExpired(authResult);

Parameters

NameType
authAuthResult

Returns

Promise<boolean>


isRefreshTokenAvailable

Static isRefreshTokenAvailable(auth): Promise<boolean>

Checks if refresh token is available in the provided AuthResult.

Usage


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

Parameters

NameType
authAuthResult

Returns

Promise<boolean>


login

Static login(provider, options): Promise<AuthResult>

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

Usage


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

Parameters

NameType
providerAuthProvider
optionsProviderOptions

Returns

Promise<AuthResult>

AuthResult


logout

Static logout(provider, auth): Promise<void>

Log the user out of the auth provider.

Usage


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

Parameters

NameType
providerAuthProvider
authAuthResult

Returns

Promise<void>


refreshSession

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

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

Usage


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

Parameters

NameType
providerAuthProvider
authAuthResult
scope?string

Returns

Promise<AuthResult>


setup

Static setup(config): Promise<void>

Initialize AuthConnect with platform level configuration.

Usage


_10
await AuthConnect.setup(myConfig);

Parameters

NameType
configAuthConnectConfig

Returns

Promise<void>