Skip to main content

CapacitorContainer

@authgear/capacitor


@authgear/capacitor / CapacitorContainer

Class: CapacitorContainer

CapacitorContainer is the entrypoint of the SDK. An instance of a container allows the user to authenticate, reauthenticate, etc.

Every container has a name. The default name of a container is default. If your app supports multi login sessions, you can use multiple containers with different names. You are responsible for managing the list of names in this case.

Constructors

Constructor

new CapacitorContainer(options?): CapacitorContainer

Parameters

options?

ContainerOptions

Returns

CapacitorContainer

Properties

delegate?

optional delegate: CapacitorContainerDelegate

Accessors

accessToken

Get Signature

get accessToken(): string | undefined

Returns

string | undefined


clientID

Get Signature

get clientID(): string | undefined

OIDC client ID

Returns

string | undefined

Set Signature

set clientID(clientID): void

Parameters
clientID

string | undefined

Returns

void


isSSOEnabled

Get Signature

get isSSOEnabled(): boolean

Is SSO enabled

Returns

boolean

Set Signature

set isSSOEnabled(isSSOEnabled): void

Parameters
isSSOEnabled

boolean

Returns

void


name

Get Signature

get name(): string

Unique ID for this container.

Default Value
"default"

@public
Returns

string

Set Signature

set name(name): void

Parameters
name

string

Returns

void


preAuthenticatedURLEnabled

Get Signature

get preAuthenticatedURLEnabled(): boolean

Is Pre Authenticated URL enabled

Returns

boolean

Set Signature

set preAuthenticatedURLEnabled(preAuthenticatedURLEnabled): void

Parameters
preAuthenticatedURLEnabled

boolean

Returns

void


sessionState

Get Signature

get sessionState(): SessionState

Returns

SessionState

Methods

addEmail()

addEmail(options): Promise<void>

Parameters

options

SettingsActionOptions

Returns

Promise<void>


addPhone()

addPhone(options): Promise<void>

Parameters

options

SettingsActionOptions

Returns

Promise<void>


addUsername()

addUsername(options): Promise<void>

Parameters

options

SettingsActionOptions

Returns

Promise<void>


authenticate()

authenticate(options): Promise<AuthenticateResult>

Authenticate the end user via the web.

Parameters

options

AuthenticateOptions

Returns

Promise<AuthenticateResult>


authenticateBiometric()

authenticateBiometric(options): Promise<AuthenticateResult>

Parameters

options

BiometricOptions

Returns

Promise<AuthenticateResult>


canReauthenticate()

canReauthenticate(): boolean

canReauthenticate() reports whether the current user can reauthenticate. The information comes from the ID token and the ID token is NOT verified.

Returns

boolean


changeEmail()

changeEmail(originalEmail, options): Promise<void>

Parameters

originalEmail

string

options

SettingsActionOptions

Returns

Promise<void>


changePassword()

changePassword(options): Promise<void>

Parameters

options

SettingsActionOptions

Returns

Promise<void>


changePhone()

changePhone(originalPhone, options): Promise<void>

Parameters

originalPhone

string

options

SettingsActionOptions

Returns

Promise<void>


changeUsername()

changeUsername(originalUsername, options): Promise<void>

Parameters

originalUsername

string

options

SettingsActionOptions

Returns

Promise<void>


checkBiometricSupported()

checkBiometricSupported(options): Promise<void>

Parameters

options

BiometricOptions

Returns

Promise<void>


configure()

configure(options): Promise<void>

configure() configures the container with the client ID and the endpoint. It also does local IO to retrieve the refresh token. It only obtains the refresh token locally and no network call will be triggered. So the session state maybe outdated for some reason, e.g. user session is revoked. fetchUserInfo should be called to obtain the latest user session state.

configure() can be called more than once if it failed. Otherwise, it is NOT recommended to call it more than once.

Parameters

options

ConfigureOptions

Returns

Promise<void>


deleteAccount()

deleteAccount(options): Promise<void>

Parameters

options

SettingsActionOptions

Returns

Promise<void>


disableBiometric()

disableBiometric(): Promise<void>

Returns

Promise<void>


enableBiometric()

enableBiometric(options): Promise<void>

Parameters

options

BiometricOptions

Returns

Promise<void>


fetch()

fetch(input, init?): Promise<Response>

Fetch function for you to call your application server. The fetch function will include Authorization header in your application request, and handle refresh access token automatically.

Parameters

input

RequestInfo | URL

init?

RequestInit

Returns

Promise<Response>


fetchUserInfo()

fetchUserInfo(): Promise<UserInfo>

Fetch user info.

Returns

Promise<UserInfo>


getAuthTime()

getAuthTime(): Date | undefined

getAuthTime() reports the last time the user was authenticated. The information comes from the ID token and the ID token is NOT verified.

Returns

Date | undefined


getIDTokenHint()

getIDTokenHint(): string | undefined

getIDTokenHint() returns the ID token for the OIDC id_token_hint parameter.

Returns

string | undefined


isBiometricEnabled()

isBiometricEnabled(): Promise<boolean>

Returns

Promise<boolean>


logout()

logout(options?): Promise<void>

Logout.

Parameters

options?

Logout options

force?

boolean

Returns

Promise<void>

Remarks

If force parameter is set to true, all potential errors (e.g. network error) would be ignored.


makePreAuthenticatedURL()

makePreAuthenticatedURL(options): Promise<string>

Share the current authenticated session to a web browser.

preAuthenticatedURLEnabled must be set to true to use this method.

Parameters

options

PreAuthenticatedURLOptions

Returns

Promise<string>


open()

open(page, options?): Promise<void>

Parameters

page

Page

options?

SettingOptions

Returns

Promise<void>


reauthenticate()

reauthenticate(options, biometricOptions?): Promise<ReauthenticateResult>

Reauthenticate the end user via biometric or the web.

If biometricOptions is given, biometric is used when possible.

Parameters

options

ReauthenticateOptions

biometricOptions?

BiometricOptions

Returns

Promise<ReauthenticateResult>


refreshAccessTokenIfNeeded()

refreshAccessTokenIfNeeded(): Promise<void>

Returns

Promise<void>


refreshIDToken()

refreshIDToken(): Promise<void>

refreshIDToken() asks the server to issue an ID token with latest claims. After refreshing, getIDTokenHint() and canReauthenticate() may return up-to-date value.

Returns

Promise<void>