Class CryptoStorage

Crypto Storage service used to save and load local encrypted data using IndexedDB.

Hierarchy

  • CryptoStorage

Constructors

  • Base constructor that receive all the configuration as an object.

    Parameters

    Returns CryptoStorage

  • Base constructor.

    Parameters

    • baseKey: CryptoKey | InputData

      Base key used to encrypt the stored data.

    • Optional dbName: string

      Database name used to store the data.

    • Optional storeName: string

      Storage name used to store the data.

    • Optional salt: BufferSource

      Custom salt used to encrypt the stored data.

    • Optional encryptIterations: number

      Custom iteration cycles to encrypt the stored data.

    Returns CryptoStorage

Properties

AuthenticityError: string = 'Integrity/Authenticity check failed!'

Default authenticity error message when the CryptoStorage were not able de decrypt the stored data.

CryptoKeyError: string = 'CryptoStorage needs a base key to work properly'

Default error message when a crypto key were not given.

Methods

  • Erase all key and data stored at the current store and database, but keeping the structure.

    Returns

    Promise to know when the process was complete.

    Returns Promise<void>

  • Completely close the database connection.

    Returns

    Promise to know when the process was complete.

    Returns Promise<void>

  • Delete individual data that match the given key.

    Returns

    Promise to know when the process was complete.

    Parameters

    • key: InputData

      The given key to find the data.

    Returns Promise<void>

  • Fully delete not only all the key and data stored at the current store and database, but also deleting the whole store and database the structure.

    Returns

    Promise to know when the process was complete.

    Returns Promise<void>

  • Loads and decrypt the stored data that match the given key.

    Returns

    Promise with the decrypted data that match the given key, or undefined if nothing was found.

    Parameters

    • key: InputData

      The given key to find the data.

    Returns Promise<undefined | string>

  • Encrypt and save the given data and key.

    Returns

    Promise to know when the encrypt and store process was complete.

    Parameters

    • key: InputData

      The key to be encrypted and find the data in the future.

    • value: InputData

      The value to be encrypted and stored.

    Returns Promise<void>

Generated using TypeDoc