emeraldsanto / react-native-encrypted-storage

React Native wrapper around EncryptedSharedPreferences and Keychain to provide a secure alternative to Async Storage.

Home Page:https://www.npmjs.com/package/react-native-encrypted-storage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

a FATAL EXCEPTION: mqt_native_modules occurs when EncryptedStorage.clear() is used.

khosyk opened this issue · comments

a noob got an error below.
This error is not always happening. It just occurs without reasons(that I don't know).

Error is happening when a user tries to logout,
The process is

  1. delete FCM Tokens by deleteToken() from '@react-native-firebase/messaging'.
  2. clear EncryptedStorages by await EncryptedStorage.clear();
  3. clear AsyncStorage by await AsyncStorage.clear();
  4. then move user to the main page

but the problem is that await EncryptedStorage.clear() when the problematic phone calls the function to clear.
I am attaching error log from logcat of android studio, hopefully it helps to fix this problem.

** at com.emeraldsanto.encryptedstorage.RNEncryptedStorageModule.clear(Unknown Source:22)
// I am guessing this problem cause that clear() occurs by this line

2023-05-18 16:28:50.410 7811-7872/? E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules Process: com.test3app, PID: 7811 java.lang.SecurityException: Could not decrypt key. decryption failed at b1.a.c(Unknown Source:58) at b1.a.getAll(Unknown Source:49) at b1.a$b.a(Unknown Source:11) at b1.a$b.commit(Unknown Source:0) at com.emeraldsanto.encryptedstorage.RNEncryptedStorageModule.clear(Unknown Source:22) at java.lang.reflect.Method.invoke(Native Method) at com.facebook.react.bridge.JavaMethodWrapper.invoke(Unknown Source:148) at com.facebook.react.bridge.JavaModuleWrapper.invoke(Unknown Source:147) at com.facebook.jni.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(Unknown Source:0) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(Unknown Source:37) at java.lang.Thread.run(Thread.java:1012) Caused by: java.security.GeneralSecurityException: decryption failed at ca.c$a.b(Unknown Source:116) at b1.a.c(Unknown Source:13) at b1.a.getAll(Unknown Source:49)  at b1.a$b.a(Unknown Source:11)  at b1.a$b.commit(Unknown Source:0)  at com.emeraldsanto.encryptedstorage.RNEncryptedStorageModule.clear(Unknown Source:22)  at java.lang.reflect.Method.invoke(Native Method)  at com.facebook.react.bridge.JavaMethodWrapper.invoke(Unknown Source:148)  at com.facebook.react.bridge.JavaModuleWrapper.invoke(Unknown Source:147)  at com.facebook.jni.NativeRunnable.run(Native Method)  at android.os.Handler.handleCallback(Handler.java:942)  at android.os.Handler.dispatchMessage(Handler.java:99)  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(Unknown Source:0)  at android.os.Looper.loopOnce(Looper.java:226)  at android.os.Looper.loop(Looper.java:313)  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(Unknown Source:37)  at java.lang.Thread.run(Thread.java:1012)