ProtectedconstructorOptional_idpWindow: WindowOptional_eventHandler: (event: MessageEvent) => voidStaticcreateCreate an AuthClient to manage authentication and identity
Optionaloptions: AuthClientCreateOptionsOptions for creating an AuthClient
Optional Identity to use as the base
Storage mechanism for delegation credentials
Type of key to use for the base key
Configures an IdleManager
AuthClient Login - Opens up a new window to authenticate with Internet Identity
Optionaloptions: types.AuthClientLoginOptionsOptions for logging in, merged with the options set during creation if any. Note: we only perform a shallow merge for the customValues property.
OptionalidentityProvider?: string | URLIdentity provider
OptionalmaxTimeToLive?: bigintExpiration of the authentication in nanoseconds
OptionalallowPinAuthentication?: booleanIf present, indicates whether or not the Identity Provider should allow the user to authenticate and/or register using a temporary key/PIN identity. Authenticating dapps may want to prevent users from using Temporary keys/PIN identities because Temporary keys/PIN identities are less secure than Passkeys (webauthn credentials) and because Temporary keys/PIN identities generally only live in a browser database (which may get cleared by the browser/OS).
OptionalderivationOrigin?: string | URLOrigin for Identity Provider to use while generating the delegated identity. For II, the derivation origin must authorize this origin by setting a record at <derivation-origin>/.well-known/ii-alternative-origins.
OptionalwindowOpenerFeatures?: stringAuth Window feature config string
OptionalonSuccess?: OnSuccessFuncCallback once login has completed
OptionalonError?: OnErrorFuncCallback in case authentication fails
OptionalcustomValues?: Record<string, unknown>Extra values to be passed in the login request during the authorize-ready phase
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);
}
});
Optionaloptions: { returnTo?: string }
Tool to manage authentication and identity
See
AuthClient