Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Custom Encryption Crashes if no Secure Storage #265

Open
georgeflug opened this issue Jul 6, 2022 · 0 comments
Open

[Bug] Custom Encryption Crashes if no Secure Storage #265

georgeflug opened this issue Jul 6, 2022 · 0 comments

Comments

@georgeflug
Copy link

georgeflug commented Jul 6, 2022

Describe the bug
Loading an existing storage instance using a custom encryption key causes the app to crash if secure storage is not used.

To Reproduce
Use the following code:

const myStorage = new MMKVLoader()
        .withInstanceID('myInstanceId')
        .withEncryption()
        .encryptWithCustomKey(`myEncryptionKey`, false)
        .initialize();

Expected behavior
The storage is initialized the first time it is run. However, if you restart the app and initialize the storage again, the app exits immediately. I expect the storage to load without crashing.

Platform Information:

  • OS: Android (did not try iOS)
  • React Native Version: 0.67.3
  • Library Version: 0.7.6

Additional context
I did some troubleshooting and found that this line of code in initializer.js is the last line that runs before the crash: var key = mmkvJsiModule.getSecureKey(options.alias); (inside initWithEncryptionUsingOldKey). It seems it's trying to load the key from secure storage even though the secure storage boolean was set to false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant