Class User

A user instance to manage HD wallet and legacy wallets with detailed information. A user serialized value is secured by a secured password which is given by user. We should never store user's password but its encrypted one to do extra actions.

Hierarchy

  • User

Implements

Constructors

  • Initialize a new user instnace

    Parameters

    • password: string

      a secure password to encrypt/decrypt user's data

    • Optional options: Partial<IUserOptions>

      Options to work with user's instance

    • Optional hdWalletPathTemplate: string

      Option to define a custom derivation path of HD wallet (default is m/PURPOSE'/COINT_TYPE'/INDEX')

    Returns User

Properties

_hdWalletInfo: HDWalletInfo
_hdWalletPathTemplate: string
_legacyWallets: WalletInfo[]
_passwordValidator: IPasswordValidator
_pwdOptions: PasswordOptions

Secret password (encrypted from user's password). To serialize/deserialize the wallet information

_underlyingHDWallet: IHDWallet<Wallet>

Methods

  • Decrypt the given value by user's password

    Parameters

    • value: string

    Returns Promise<string>

  • Deserializes the serialized and encrypted user information to merge back the current user instance.

    Parameters

    • value: string

      serialized user information

    Returns Promise<void>

  • Encrypt the given value by user's password. Everytime we call this method, a new salt will be generated and update directly to the current user instance. The caller must also store it in order to re-use later.

    Parameters

    • value: string

    Returns Promise<string>

  • Check if the given id belongs to a HD wallet. The id of a HD wallet should be a path

    Parameters

    • id: string

    Returns boolean

  • Remove a wallet from user

    Parameters

    • id: string

      could be id or uid of from wallet info

    Returns void

  • Serializes the wallet and encrypts it with the password.

    Returns Promise<string>

    The encrypted wallet.

  • Set the HD wallet information

    Parameters

    • keyEntropy: Uint8Array

      the master key, either keyPhrase (12-24 words) or seed of keyPhrase

    • encryptionType: EncryptionType

      the encryption type

    Returns Promise<void>

  • Set wallet information

    Parameters

    • id: string

      coule be id or uid from wallet info in case of updating, otherwise it must be an id (private key of legacy wallet or path of hd wallet)

    • info: string | WalletDescriptor

    Returns void

  • Update password to serialize user's information. A new salt will be generated regardless the given options.

    Parameters

    • password: string

    Returns Promise<void>

  • Confirms the given password matches requirements

    Parameters

    • password: string

    Returns void

  • Deserialize user information to an instance of user

    Parameters

    • password: string
    • userEncryptedInfo: string
    • Optional options: Partial<IUserOptions>

      Options to work with user's instance

    Returns Promise<User>

Generated using TypeDoc