AuthClient
Defined in: auth-client.ts:196
Tool to manage authentication and identity
AuthClient
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”
protectednew AuthClient(_identity,_key,_chain,_storage,idleManager,_createOptions,_idpWindow?,_eventHandler?):AuthClient
Defined in: auth-client.ts:331
Parameters
Section titled “Parameters”_identity
Section titled “_identity”PartialIdentity | Identity
SignIdentity | PartialIdentity
_chain
Section titled “_chain”DelegationChain | null
_storage
Section titled “_storage”idleManager
Section titled “idleManager”IdleManager | undefined
_createOptions
Section titled “_createOptions”AuthClientCreateOptions | undefined
_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:
IdleManager|undefined
Defined in: auth-client.ts:336
Methods
Section titled “Methods”getIdentity()
Section titled “getIdentity()”getIdentity():
Identity
Defined in: auth-client.ts:419
Returns
Section titled “Returns”Identity
isAuthenticated()
Section titled “isAuthenticated()”isAuthenticated():
Promise<boolean>
Defined in: auth-client.ts:423
Returns
Section titled “Returns”Promise<boolean>
login()
Section titled “login()”login(
options?):Promise<void>
Defined in: auth-client.ts:456
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); }});loginWithIcrc29()
Section titled “loginWithIcrc29()”loginWithIcrc29(
options?):Promise<void>
Defined in: auth-client.ts:504
Parameters
Section titled “Parameters”options?
Section titled “options?”Returns
Section titled “Returns”Promise<void>
logout()
Section titled “logout()”logout(
options):Promise<void>
Defined in: auth-client.ts:613
Parameters
Section titled “Parameters”options
Section titled “options”returnTo?
Section titled “returnTo?”string
Returns
Section titled “Returns”Promise<void>
create()
Section titled “create()”
staticcreate(options):Promise<AuthClient>
Defined in: auth-client.ts:218
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 }})