Open WilliamAlexander opened 3 years ago
The same issue happens on XiaoMi 12 Pro device(Android 13). This happens when the faceId is turned on while the fingerprint is turned off.
Also experiencing this, any workarounds?
We have the same issue. We found out, when switching phones Android 'restores' your apps. Some apps also restore their internal caches, probably coming from the google cloud. And after this restore it gets corrupted... Probably the same after some phone updates as well.
We are starting to see a sudden increase of this error again in one of our apps, on all kinds of android devices (mostly android 14)..
if it's the same as expo's secure-storage issue, then maybe this can help?
https://github.com/expo/expo/issues/23426#issuecomment-2178534351
We found an issue related to SharedPreferences being backed up by automatic backup and being restored when re-installing the app, which would cause decryption errors as after uninstalling the app the KeyStore is cleared, which makes them impossible to decrypt.
HERE IS A SOLUTION
u can simulate this issue on android studio simulator,
first u have to root it (https://medium.com/@lightbulbr/how-to-root-an-android-emulator-with-tiramisu-android-13-f070a756c499)
then after u loged in do
adb shell
su
cd /data/misc/keystore/user_0 and delete ..._USRPKEY_ACCESS_TOKEN
tahts how u can see it and u can handle it in the code like this
`import { SecureStorage } from "./secureStorage";
export async function getAccessToken() {
try {
const key = SecureStorage.keys.ACCESS_TOKEN;
const token = await SecureStorage.getSecureValue(key);
return token;
} catch (e) {
if (e.message == 'Could not decrypt data with alias: ACCESS_TOKEN') {
const key = SecureStorage.keys.ACCESS_TOKEN;
await SecureStorage.removeSecureValue(key);
return null;
} else {
throw e;
}
}
}`
Now and again I get the error: "Could not decrypt data with alias: "
Happens when I call Keychain.getGenericPassword() I don't use a service when calling Keychain.setGenericPassword (it uses the package name as default in Android).
Out of over 5k users, it happens for around 20 users (so far). 99% of the devices are Samsung. Tried myself on a Samsung phone and I cannot recreate.
Not sure if related to the user:
I'll eventually update the react-native-keychain package but holding off as it might cause further issues in this field
"react-native": "0.64.0", "react-native-keychain": "^6.2.0"