+ throw AuthenticationException("No hardware available for biometric authentication. Use expo-local-authentication to check if the device supports it")
+ Log.w(TAG, "The requested key has been permanently invalidated. Returning null")
+ return null
+ } catch (e: BadPaddingException) {
+ // The key from the KeyStore is unable to decode the entry. This is because a new key was generated, but the entries are encrypted using the old one.
+ // This usually means that the user has reinstalled the app. We can safely remove the old value and return null as it's impossible to decrypt it.
+ Log.w(
+ TAG,
+ "Failed to decrypt the entry for $key under keychain ${options.keychainService}. " +
+ "The entry in shared preferences is out of sync with the keystore. It will be removed, returning null."
+ Log.w(TAG, "Key has been invalidated, retrying with the key deleted")
+ return setItemImpl(key, value, options, true)
+ }
+ throw EncryptException("Encryption Failed. The key $key has been permanently invalidated and cannot be reinitialized", key, options.keychainService, e)
+ val encryptedItemString = encryptedItem.toString()
+ if (encryptedItemString.isNullOrEmpty()) { // JSONObject#toString() may return null
+ throw WriteException("Could not JSON-encode the encrypted item for SecureStore - the string $encryptedItemString is null or empty", key, keychainService)