jarden-digital/react-native-pincode

Avoid using RNKeychainManager

Opened this issue ยท 11 comments

Hi. Tried to install this widget, but it requires RNKeyhainManager. It fails with "SECURITY_KEY_ANY". The known issue. After many attempts to fix it, following multiple issues and guides, after attempting manually installing it I decided to not use it.
The readme of this project states that if you decide to not use keychain manager then you have to provide your own, by setting storePin prop. I did that, but it still uses RNKeychainManager and it still fails with SECURITY_KEY_ANY == "Null" error.
How to avoid using keychain manager?
Or alternatively how to make KeyChain to not fail? And btw - I don't have it in my package.json. Previously I had, and it was of 6.1.1 version.

My example of pincode widget:

        <PINCode
          status={"choose"}
          handleResultEnterPin={(pinCode) => this.handleResultEnterPin(pinCode)}
          storePin={(pin) => {
            this.handleResultEnterPin(pin);
          }}
        />

The additional information on the issue. I use expo, and it bring problems of it's own. So the problem actually in expo, and here is an additional info: oblador/react-native-keychain#319
Currently in attempts to solve the issue.

Yes. The question still stands. How to avoid using keychain manager in favor of alternate solutions, including provided by expo.

Hi,

Sorry for the delay.
We won't have time to invest into solving this issue atm so please feel free to open a PR if you find a good solution :)

Was this your error?: null is not an object (evaluating 'RNKeychainManager.SECURITY_LEVEL_ANY')

I got this error and fixed it per oblador/react-native-keychain#388

You need to change a line within react-native-keychain, but it's within the node_modules directory of react-native-pincode which is itself within your own app's node_modules. So it took me a bit of poking around to find it.

change directories into node_modules/\@haskkor/react-native-pincode/node_modules/react-native-keychain/
open index.js with your favorite editor

Replace the follow line, which is contained within export const SECURITY_LEVEL = Object.freeze({...}); :
ANY: RNKeychainManager.SECURITY_LEVEL_ANY,

with

ANY: RNKeychainManager && RNKeychainManager.SECURITY_LEVEL_ANY,

and don't change anything else.

It looks like this needs to be PR'd into react-native-keychain so that it becomes a permanent fix. (I believe reinstalling node_modules will undo your local changes).

For development purposes, this short-term fix worked for me.

Thank you for the answer. I fixed it moving from expo to react-native.
The problem is occurring with expo, since it has a "special way" handling native java components.
Not sure will I try your suggestion, but it is useful anyway to have it for anybody else facing it.

@Xeizzeth have you fixed it just moving from expo to react-native and with out applying @omorkved solution.? If so, Can you please let me know how could you do that?

@Yandamuri yes, I just moved from expo to react-native, and in order to do that you need to eject. I.e. expo eject.

@Xeizzeth I didn't use expo. I just installed react-native-pin and react-native-keychain. But still facing the issue. Can you please tell me what should I do to avid this error?

@Yandamuri
If only I knew what I did back then.
I remember doing something in java package, tweaking some settings and what not but it was like in august. A lot of water moved since then so sorry I cannot help with that in any way. I don't work on this project since september as well.
But one thing I do remember - it used specific version of keymanager, or keymanager used specific version of dependency.
So take a closer look at keymanager and it's dependencies. The only I can suggest.

@omorkved I have installed both react-native-pin and react-native-keychain. But I didn't find the path node_modules/\@haskkor/react-native-pincode/node_modules/react-native-keychain. in fact there is no node_modules folder inside react-native-pincode. Can you please guide me on how to reach the mentioned path?

react-native-keychain has fixed this issue. But unfortunately react-native-pincode is still using the old version. so to overcome this issue, you have to add the new version in the resolutions of your package.json file to force all packages to use only this version or create a patch file. (a patch file stores your node_module changes)

"resolutions": {
   "react-native-keychain": "^8.1.1"
},