Options
All
  • Public
  • Public/Protected
  • All
Menu

Tool to manage authentication and identity

see

AuthClient

Hierarchy

  • AuthClient

Index

Constructors

  • new AuthClient(_identity: Identity | PartialIdentity, _key: SignIdentity | PartialIdentity, _chain: null | DelegationChain, _storage: AuthClientStorage, idleManager: undefined | IdleManager, _createOptions: undefined | AuthClientCreateOptions, _idpWindow?: Window, _eventHandler?: ((event: MessageEvent<any>) => void)): AuthClient
  • Parameters

    • _identity: Identity | PartialIdentity
    • _key: SignIdentity | PartialIdentity
    • _chain: null | DelegationChain
    • _storage: AuthClientStorage
    • idleManager: undefined | IdleManager
    • _createOptions: undefined | AuthClientCreateOptions
    • Optional _idpWindow: Window
    • Optional _eventHandler: ((event: MessageEvent<any>) => void)
        • (event: MessageEvent<any>): void
        • Parameters

          • event: MessageEvent<any>

          Returns void

    Returns AuthClient

Properties

idleManager: undefined | IdleManager

Methods

  • _getEventHandler(identityProviderUrl: URL, options?: AuthClientLoginOptions): ((event: MessageEvent<any>) => Promise<void>)
  • Parameters

    Returns ((event: MessageEvent<any>) => Promise<void>)

      • (event: MessageEvent<any>): Promise<void>
      • Parameters

        • event: MessageEvent<any>

        Returns Promise<void>

  • _handleFailure(errorMessage?: string, onError?: ((error?: string) => void)): void
  • Parameters

    • Optional errorMessage: string
    • Optional onError: ((error?: string) => void)
        • (error?: string): void
        • Parameters

          • Optional error: string

          Returns void

    Returns void

  • _registerDefaultIdleCallback(): void
  • _removeEventListener(): void
  • getIdentity(): Identity
  • isAuthenticated(): Promise<boolean>
  • AuthClient Login - Opens up a new window to authenticate with Internet Identity

    example

    const authClient = await AuthClient.create(); authClient.login({ identityProvider: 'http://.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); } });

    Parameters

    Returns Promise<void>

  • logout(options?: { returnTo?: string }): Promise<void>
  • Parameters

    • options: { returnTo?: string } = {}
      • Optional returnTo?: string

    Returns Promise<void>

  • Create an AuthClient to manage authentication and identity

    constructs
    see

    AuthClientCreateOptions

    see

    {@link SignIdentity}

    see

    AuthClientStorage

    see

    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

    const authClient = await AuthClient.create({ idleOptions: { disableIdle: true } })

    Parameters

    • options: { identity?: SignIdentity | PartialIdentity; idleOptions?: IdleOptions; keyType?: BaseKeyType; storage?: AuthClientStorage } = {}

      Options for creating an AuthClient

      • Optional identity?: SignIdentity | PartialIdentity

        An {@link SignIdentity} or {@link PartialIdentity} to authenticate via delegation.

      • Optional idleOptions?: IdleOptions

        Options to handle idle timeouts

        default

        after 10 minutes, invalidates the identity

      • Optional keyType?: BaseKeyType

        type to use for the base key

        default

        'ECDSA' If you are using a custom storage provider that does not support CryptoKey storage, you should use 'Ed25519' as the key type, as it can serialize to a string

      • Optional storage?: AuthClientStorage
        description

        Optional storage with get, set, and remove. Uses IdbStorage by default

    Returns Promise<AuthClient>

Generated using TypeDoc