Interface BiometricEncryptedStorageManager

interface BiometricEncryptedStorageManager {
    delete(key: string): boolean;
    get(key: string, config?: BiometricConfig): Promise<null | string>;
    has(key: string): boolean;
    set(key: string, value: string, config?: BiometricConfig): Promise<boolean>;
}

Methods

Methods

  • Deletes the key and the associated encrypted value.

    Parameters

    • key: string

    Returns boolean

    true if the key was deleted, or false if the key didn't exist.

  • Retrieves an encrypted value associated with the key.

    Note: This operation requires the user interaction, consider using ActivityManager.runUserInteraction to ensure that consequent UI-related operations are suspended until this one is completed.

    Parameters

    Returns Promise<null | string>

    The deciphered value, or null if key wasn't found, or authentication has failed.

    InvalidAlgorithmParameterException At least one biometric must be enrolled to create keys requiring user authentication for every use. Check BiometricManager.getBiometricStatus before reading the key.

    KeyPermanentlyInvalidatedException Indicates that the key can no longer be read because it has been permanently invalidated (for example, because of the biometric enrollment). Set a new value or delete the key to recover from this error.

    UnrecoverableKeyException User changed or deleted their auth credentials.

    IllegalArgumentException Device credential is not supported on API 28 and below.

    IllegalArgumentException Crypto-based authentication is not supported for Class 2 (Weak) biometrics.

    IllegalStateException Unable to start authentication if the app is in the background.

  • Returns true if the key exists in the storage, or false otherwise.

    Parameters

    • key: string

    Returns boolean

  • Associates a value with a key in an encrypted storage.

    Note: This operation requires the user interaction, consider using ActivityManager.runUserInteraction to ensure that consequent UI-related operations are suspended until this one is completed.

    Parameters

    • key: string

      A key to set.

    • value: string

      A value to write.

    • Optionalconfig: BiometricConfig

      The options of the biometric prompt.

    Returns Promise<boolean>

    true if the value was written to the storage, or false if authentication has failed.

    InvalidAlgorithmParameterException At least one biometric must be enrolled to create keys requiring user authentication for every use. Check BiometricManager.getBiometricStatus before setting the key.

    IllegalArgumentException Device credential is not supported on API 28 and below.

    IllegalArgumentException Crypto-based authentication is not supported for Class 2 (Weak) biometrics.

    IllegalStateException Unable to start authentication if the app is in the background.