This class represents an 'Single User API without Credentials' authentication workflow.

Hierarchy (view full)

Constructors

Properties

onLogin: OEvent<((instanceName: string, secret: string, email: string) => void)> = ...

This event will be triggered right AFTER the instance was initialised

onLogout: OEvent<(() => void)> = ...

This event will be triggered right BEFORE the instance was closed

Methods

  • Logins the user. This function will:

    • trigger the 'login' event
    • will check if there are any stored credentials
      • if no, it will throw an error and trigger 'login_failure' event
      • if yes, it will check if the instance exist
        • if no, it will throw an error and trigger 'login_failure' event
        • if yes, it will initialize the instance, import modules, register recipes trigger onLogin and wait for all the listeners to finish and trigger 'login_success' event

    Returns Promise<void>

  • Logouts the user. This function will:

    • trigger the 'logout' event
    • trigger onLogout and wait for all the listeners to finish
    • close the instance
    • trigger the 'logout_done' event if it is successfully

    Returns Promise<void>

  • Registers the user with generated credentials. This function will:

    • will check if there are any stored credentials
      • if no, it will persist the generated email, instance name & secret
      • if yes, continue
    • will trigger the 'login' event
    • will init the instance
    • if successful
      • if yes, it will trigger the 'login_success' event
      • if no, it will throw error and trigger 'login_failure' event

    Parameters

    • OptionalregisterData: {
          email?: string;
          instanceName?: string;
          secret?: string;
      }
      • Optionalemail?: string
      • OptionalinstanceName?: string
      • Optionalsecret?: string

    Returns Promise<void>

  • Parameters

    • secretEncryptionKey: string | Uint8Array
    • secretSignKey: string | Uint8Array
    • OptionalregisterData: {
          email?: string;
          instanceName?: string;
          secret?: string;
      }
      • Optionalemail?: string
      • OptionalinstanceName?: string
      • Optionalsecret?: string

    Returns Promise<void>