AuthClient
Defined in: index.ts:204
Tool to manage authentication and identity
AuthClient
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”
protected
new AuthClient(_identity
,_key
,_chain
,_storage
,idleManager
,_createOptions
,_idpWindow?
,_eventHandler?
):AuthClient
Defined in: index.ts:338
Parameters
Section titled “Parameters”_identity
Section titled “_identity”SignIdentity
| PartialIdentity
_chain
Section titled “_chain”null
| DelegationChain
_storage
Section titled “_storage”idleManager
Section titled “idleManager”undefined
| IdleManager
_createOptions
Section titled “_createOptions”undefined
| AuthClientCreateOptions
_idpWindow?
Section titled “_idpWindow?”Window
_eventHandler?
Section titled “_eventHandler?”(event
) => void
Returns
Section titled “Returns”AuthClient
Properties
Section titled “Properties”idleManager
Section titled “idleManager”idleManager:
undefined
|IdleManager
Defined in: index.ts:343
Methods
Section titled “Methods”getIdentity()
Section titled “getIdentity()”getIdentity():
Identity
Defined in: index.ts:421
Returns
Section titled “Returns”isAuthenticated()
Section titled “isAuthenticated()”isAuthenticated():
Promise
<boolean
>
Defined in: index.ts:425
Returns
Section titled “Returns”Promise
<boolean
>
login()
Section titled “login()”login(
options?
):Promise
<void
>
Defined in: index.ts:458
AuthClient Login - Opens up a new window to authenticate with Internet Identity
Parameters
Section titled “Parameters”options?
Section titled “options?”Options for logging in, merged with the options set during creation if any. Note: we only perform a shallow merge for the customValues
property.
Returns
Section titled “Returns”Promise
<void
>
Example
Section titled “Example”const authClient = await AuthClient.create();authClient.login({ identityProvider: 'http://<canisterID>.127.0.0.1:8000', maxTimeToLive: BigInt (7) * BigInt(24) * BigInt(3_600_000_000_000), // 1 week windowOpenerFeatures: "toolbar=0,location=0,menubar=0,width=500,height=500,left=100,top=100", onSuccess: () => { console.log('Login Successful!'); }, onError: (error) => { console.error('Login Failed: ', error); }});
logout()
Section titled “logout()”logout(
options
):Promise
<void
>
Defined in: index.ts:561
Parameters
Section titled “Parameters”options
Section titled “options”returnTo?
Section titled “returnTo?”string
Returns
Section titled “Returns”Promise
<void
>
create()
Section titled “create()”
static
create(options
):Promise
<AuthClient
>
Defined in: index.ts:224
Create an AuthClient to manage authentication and identity
Parameters
Section titled “Parameters”options
Section titled “options”Options for creating an AuthClient
Returns
Section titled “Returns”Promise
<AuthClient
>
- AuthClientCreateOptions
- SignIdentity
- AuthClientStorage
- IdleOptions Default behavior is to clear stored identity and reload the page when a user goes idle, unless you set the disableDefaultIdleCallback flag or pass in a custom idle callback.
Example
Section titled “Example”const authClient = await AuthClient.create({ idleOptions: { disableIdle: true }})