Skip to main content

@authgear/web / WebContainer

Class: WebContainer

WebContainer 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 WebContainer(options?): WebContainer

Parameters

NameType
options?ContainerOptions

Returns

WebContainer

Defined in

packages/authgear-web/index.d.ts:707

Properties

delegate

Optional delegate: WebContainerDelegate

Defined in

packages/authgear-web/index.d.ts:671


sessionType

sessionType: "cookie" | "refresh_token"

Defined in

packages/authgear-web/index.d.ts:667

Accessors

accessToken

get accessToken(): undefined | string

Returns

undefined | string

Defined in

packages/authgear-web/index.d.ts:705

set accessToken(accessToken): void

Parameters

NameType
accessTokenundefined | string

Returns

void

Defined in

packages/authgear-web/index.d.ts:706


clientID

get clientID(): undefined | string

OIDC client ID

Returns

undefined | string

Defined in

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

set clientID(clientID): void

Parameters

NameType
clientIDundefined | string

Returns

void

Defined in

packages/authgear-web/index.d.ts:687


isSSOEnabled

get isSSOEnabled(): boolean

Is SSO enabled

Returns

boolean

Defined in

packages/authgear-web/index.d.ts:693

set isSSOEnabled(isSSOEnabled): void

Parameters

NameType
isSSOEnabledboolean

Returns

void

Defined in

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


name

get name(): string

Unique ID for this container.

Returns

string

Default Value

"default"

@public

Defined in

packages/authgear-web/index.d.ts:679

set name(name): void

Parameters

NameType
namestring

Returns

void

Defined in

packages/authgear-web/index.d.ts:680


sessionState

get sessionState(): SessionState

Returns

SessionState

Defined in

packages/authgear-web/index.d.ts:699

set sessionState(sessionState): void

Parameters

NameType
sessionStateSessionState

Returns

void

Defined in

packages/authgear-web/index.d.ts:700

Methods

authenticateAnonymously

authenticateAnonymously(): Promise<AuthenticateResult>

Authenticate as an anonymous user.

Returns

Promise<AuthenticateResult>

Defined in

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


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-web/index.d.ts:720


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-web/index.d.ts:748


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-web/index.d.ts:853


fetchUserInfo

fetchUserInfo(): Promise<UserInfo>

Fetch user info.

Returns

Promise<UserInfo>

Defined in

packages/authgear-web/index.d.ts:841


finishAuthentication

finishAuthentication(): Promise<AuthenticateResult>

Finish authentication.

It may reject with OAuthError.

Returns

Promise<AuthenticateResult>

Defined in

packages/authgear-web/index.d.ts:778


finishChangePassword

finishChangePassword(): Promise<void>

Finish settings action "change_password".

It may reject with OAuthError.

Returns

Promise<void>

Defined in

packages/authgear-web/index.d.ts:792


finishDeleteAccount

finishDeleteAccount(): Promise<void>

Finish settings action "delete_account".

It may reject with OAuthError.

Returns

Promise<void>

Defined in

packages/authgear-web/index.d.ts:800


finishPromoteAnonymousUser

finishPromoteAnonymousUser(): Promise<ReauthenticateResult>

Finish promote anonymous user.

It may reject with OAuthError.

Returns

Promise<ReauthenticateResult>

Defined in

packages/authgear-web/index.d.ts:806


finishReauthentication

finishReauthentication(): Promise<ReauthenticateResult>

Finish reauthentication.

It may reject with OAuthError.

Returns

Promise<ReauthenticateResult>

Defined in

packages/authgear-web/index.d.ts:784


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-web/index.d.ts:727


getIDTokenHint

getIDTokenHint(): undefined | string

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

Returns

undefined | string

Defined in

packages/authgear-web/index.d.ts:713


logout

logout(options?): Promise<void>

Logout.

Parameters

NameTypeDescription
options?ObjectLogout options
options.force?boolean-
options.redirectURIstring-

Returns

Promise<void>

Remarks

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

redirectURI is required. User will be redirected to the uri after they have logged out.

Defined in

packages/authgear-web/index.d.ts:820


makeAuthorizeURL

makeAuthorizeURL(options): Promise<string>

Make authorize URL makes authorize URL based on options.

This function will be used if developer wants to redirection in their own code.

Parameters

NameType
optionsAuthenticateOptions

Returns

Promise<string>

Defined in

packages/authgear-web/index.d.ts:837


open

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

Parameters

NameType
pagePage
options?SettingOptions

Returns

Promise<void>

Defined in

packages/authgear-web/index.d.ts:807


refreshAccessTokenIfNeeded

refreshAccessTokenIfNeeded(): Promise<void>

Returns

Promise<void>

Defined in

packages/authgear-web/index.d.ts:845


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-web/index.d.ts:734


startAuthentication

startAuthentication(options): Promise<void>

Start authentication by redirecting to the authorization endpoint.

Parameters

NameType
optionsAuthenticateOptions

Returns

Promise<void>

Defined in

packages/authgear-web/index.d.ts:752


startChangePassword

startChangePassword(options): Promise<void>

Start settings action "change_password" by redirecting to the authorization endpoint.

Parameters

NameType
optionsSettingsActionOptions

Returns

Promise<void>

Defined in

packages/authgear-web/index.d.ts:758


startDeleteAccount

startDeleteAccount(options): Promise<void>

Start settings action "delete_account" by redirecting to the authorization endpoint.

Parameters

NameType
optionsSettingsActionOptions

Returns

Promise<void>

Defined in

packages/authgear-web/index.d.ts:764


startPromoteAnonymousUser

startPromoteAnonymousUser(options): Promise<void>

Start promote anonymous user by redirecting to the authorization endpoint.

Parameters

NameType
optionsPromoteOptions

Returns

Promise<void>

Defined in

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


startReauthentication

startReauthentication(options): Promise<void>

Start reauthentication by redirecting to the authorization endpoint.

Parameters

NameType
optionsReauthenticateOptions

Returns

Promise<void>

Defined in

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

  • Table of contents
  • Constructors
    • constructor
  • Properties
    • delegate
    • sessionType
  • Accessors
    • accessToken
    • clientID
    • isSSOEnabled
    • name
    • sessionState
  • Methods
    • authenticateAnonymously
    • canReauthenticate
    • configure
    • fetch
    • fetchUserInfo
    • finishAuthentication
    • finishChangePassword
    • finishDeleteAccount
    • finishPromoteAnonymousUser
    • finishReauthentication
    • getAuthTime
    • getIDTokenHint
    • logout
    • makeAuthorizeURL
    • open
    • refreshAccessTokenIfNeeded
    • refreshIDToken
    • startAuthentication
    • startChangePassword
    • startDeleteAccount
    • startPromoteAnonymousUser
    • startReauthentication