Skip to main content

@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.

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new CapacitorContainer(options?): CapacitorContainer

Parameters

NameType
options?ContainerOptions

Returns

CapacitorContainer

Defined in

packages/authgear-capacitor/index.d.ts:727

Properties

delegate

Optional delegate: CapacitorContainerDelegate

Defined in

packages/authgear-capacitor/index.d.ts:686

Accessors

accessToken

get accessToken(): undefined | string

Returns

undefined | string

Defined in

packages/authgear-capacitor/index.d.ts:726


clientID

get clientID(): undefined | string

OIDC client ID

Returns

undefined | string

Defined in

packages/authgear-capacitor/index.d.ts:701

set clientID(clientID): void

Parameters

NameType
clientIDundefined | string

Returns

void

Defined in

packages/authgear-capacitor/index.d.ts:702


isSSOEnabled

get isSSOEnabled(): boolean

Is SSO enabled

Returns

boolean

Defined in

packages/authgear-capacitor/index.d.ts:708

set isSSOEnabled(isSSOEnabled): void

Parameters

NameType
isSSOEnabledboolean

Returns

void

Defined in

packages/authgear-capacitor/index.d.ts:709


name

get name(): string

Unique ID for this container.

Returns

string

Default Value

"default"

@public

Defined in

packages/authgear-capacitor/index.d.ts:694

set name(name): void

Parameters

NameType
namestring

Returns

void

Defined in

packages/authgear-capacitor/index.d.ts:695


preAuthenticatedURLEnabled

get preAuthenticatedURLEnabled(): boolean

Is Pre Authenticated URL enabled

Returns

boolean

Defined in

packages/authgear-capacitor/index.d.ts:715

set preAuthenticatedURLEnabled(preAuthenticatedURLEnabled): void

Parameters

NameType
preAuthenticatedURLEnabledboolean

Returns

void

Defined in

packages/authgear-capacitor/index.d.ts:716


sessionState

get sessionState(): SessionState

Returns

SessionState

Defined in

packages/authgear-capacitor/index.d.ts:721

Methods

addEmail

addEmail(options): Promise<void>

Parameters

NameType
optionsSettingsActionOptions

Returns

Promise<void>

Defined in

packages/authgear-capacitor/index.d.ts:827


addPhone

addPhone(options): Promise<void>

Parameters

NameType
optionsSettingsActionOptions

Returns

Promise<void>

Defined in

packages/authgear-capacitor/index.d.ts:831


addUsername

addUsername(options): Promise<void>

Parameters

NameType
optionsSettingsActionOptions

Returns

Promise<void>

Defined in

packages/authgear-capacitor/index.d.ts:835


authenticate

authenticate(options): Promise<AuthenticateResult>

Authenticate the end user via the web.

Parameters

NameType
optionsAuthenticateOptions

Returns

Promise<AuthenticateResult>

Defined in

packages/authgear-capacitor/index.d.ts:803


authenticateBiometric

authenticateBiometric(options): Promise<AuthenticateResult>

Parameters

NameType
optionsBiometricOptions

Returns

Promise<AuthenticateResult>

Defined in

packages/authgear-capacitor/index.d.ts:858


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

Defined in

packages/authgear-capacitor/index.d.ts:740


changeEmail

changeEmail(originalEmail, options): Promise<void>

Parameters

NameType
originalEmailstring
optionsSettingsActionOptions

Returns

Promise<void>

Defined in

packages/authgear-capacitor/index.d.ts:839


changePassword

changePassword(options): Promise<void>

Parameters

NameType
optionsSettingsActionOptions

Returns

Promise<void>

Defined in

packages/authgear-capacitor/index.d.ts:819


changePhone

changePhone(originalPhone, options): Promise<void>

Parameters

NameType
originalPhonestring
optionsSettingsActionOptions

Returns

Promise<void>

Defined in

packages/authgear-capacitor/index.d.ts:843


changeUsername

changeUsername(originalUsername, options): Promise<void>

Parameters

NameType
originalUsernamestring
optionsSettingsActionOptions

Returns

Promise<void>

Defined in

packages/authgear-capacitor/index.d.ts:847


checkBiometricSupported

checkBiometricSupported(options): Promise<void>

Parameters

NameType
optionsBiometricOptions

Returns

Promise<void>

Defined in

packages/authgear-capacitor/index.d.ts:851


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

NameType
optionsConfigureOptions

Returns

Promise<void>

Defined in

packages/authgear-capacitor/index.d.ts:761


deleteAccount

deleteAccount(options): Promise<void>

Parameters

NameType
optionsSettingsActionOptions

Returns

Promise<void>

Defined in

packages/authgear-capacitor/index.d.ts:823


disableBiometric

disableBiometric(): Promise<void>

Returns

Promise<void>

Defined in

packages/authgear-capacitor/index.d.ts:856


enableBiometric

enableBiometric(options): Promise<void>

Parameters

NameType
optionsBiometricOptions

Returns

Promise<void>

Defined in

packages/authgear-capacitor/index.d.ts:857


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

NameType
inputRequestInfo | URL
init?RequestInit

Returns

Promise<Response>

Defined in

packages/authgear-capacitor/index.d.ts:785


fetchUserInfo

fetchUserInfo(): Promise<UserInfo>

Fetch user info.

Returns

Promise<UserInfo>

Defined in

packages/authgear-capacitor/index.d.ts:777


getAuthTime

getAuthTime(): undefined | Date

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

Returns

undefined | Date

Defined in

packages/authgear-capacitor/index.d.ts:747


getIDTokenHint

getIDTokenHint(): undefined | string

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

Returns

undefined | string

Defined in

packages/authgear-capacitor/index.d.ts:733


isBiometricEnabled

isBiometricEnabled(): Promise<boolean>

Returns

Promise<boolean>

Defined in

packages/authgear-capacitor/index.d.ts:855


logout

logout(options?): Promise<void>

Logout.

Parameters

NameTypeDescription
options?ObjectLogout options
options.force?boolean-

Returns

Promise<void>

Remarks

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

Defined in

packages/authgear-capacitor/index.d.ts:795


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

NameType
optionsPreAuthenticatedURLOptions

Returns

Promise<string>

Defined in

packages/authgear-capacitor/index.d.ts:866


open

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

Parameters

NameType
pagePage
options?SettingOptions

Returns

Promise<void>

Defined in

packages/authgear-capacitor/index.d.ts:815


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

NameType
optionsReauthenticateOptions
biometricOptions?BiometricOptions

Returns

Promise<ReauthenticateResult>

Defined in

packages/authgear-capacitor/index.d.ts:811


refreshAccessTokenIfNeeded

refreshAccessTokenIfNeeded(): Promise<void>

Returns

Promise<void>

Defined in

packages/authgear-capacitor/index.d.ts:772


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>

Defined in

packages/authgear-capacitor/index.d.ts:768

  • Table of contents
  • Constructors
    • constructor
  • Properties
    • delegate
  • Accessors
    • accessToken
    • clientID
    • isSSOEnabled
    • name
    • preAuthenticatedURLEnabled
    • sessionState
  • Methods
    • addEmail
    • addPhone
    • addUsername
    • authenticate
    • authenticateBiometric
    • canReauthenticate
    • changeEmail
    • changePassword
    • changePhone
    • changeUsername
    • checkBiometricSupported
    • configure
    • deleteAccount
    • disableBiometric
    • enableBiometric
    • fetch
    • fetchUserInfo
    • getAuthTime
    • getIDTokenHint
    • isBiometricEnabled
    • logout
    • makePreAuthenticatedURL
    • open
    • reauthenticate
    • refreshAccessTokenIfNeeded
    • refreshIDToken