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

Update to react-native-keychain V6.0.0 breaks hasUserSetPinCode and other methods #137

Closed
greenbue opened this issue Apr 15, 2020 · 5 comments

Comments

@greenbue
Copy link

v6.0.0+ of react-native-keychain breaks the method hasUserSetPinCode because of its reliance to Keychain.getInternetCredentials

Instead of

Keychain.getInternetCredentials('reactNativePinCode')

Authentication Prompt needs to be declared.
https://github.com/oblador/react-native-keychain/releases/tag/v6.0.0

Keychain.getInternetCredentials('reactNativePinCode', { authenticationPrompt: { title: 'prompt' } })

Error returned

PinCodeEnter:  [Error: Title must be set and non-empty]
@efronnyp
Copy link

@greenbue +1 for this issue. I faced exactly the same issue as yours sometimes ago.
From what I got:

  1. It is actually react-native-keychain bugs as the author claims that the default value of the authenticationPrompt.title is Authenticate to retrieve secret (kindly see this section). However, if you dive into KeychainModule.java file, and goto getPromptInfo() function, you will see that there is no setTitle() nor setNegativeButtonText() called (which are required to build the PromptInfo) if the options is null. Thus make the PromptInfo building process throw an exception.
  2. In my case, I just invoke Keychain.getInternetCredentials(...) manually, and pass the
    { authenticationPrompt: { title: "Fingerprint title", cancel: "Cancel" }} options.
  3. It is also good to raise this issue on react-native-keychain repository if it's not raised yet

So in my opinion, the best way to solve this issue is by manually invoke the getInternetCredentials function, and recommend a resolution to react-native-keychain regarding this issue.

I hope it helps you.

@greenbue
Copy link
Author

greenbue commented Apr 15, 2020

@efronnyp - Thanks for the feedback, I will definitely try your suggestions.

Upon further investigation - it does seem to be more of an issue on react-native-keychain - as you have mentioned, the default title seems to be missing after they deprecated the old way of setting up authenticationPrompt.

image

I think this issue can be closed on this side, but would be good to have some kind of note on the README in terms of support for this.

@greenbue
Copy link
Author

https://github.com/jarden-digital/react-native-pincode/blob/2b3e4a33d2af2344f5272a73274c096fd2687a2f/dist/src/PinCodeEnter.js

This method will now throw an error because of...

However, if you dive into KeychainModule.java file, and goto getPromptInfo() function, you will see that there is no setTitle() nor setNegativeButtonText() called (which are required to build the PromptInfo) if the options is null. Thus make the PromptInfo building process throw an exception.

PinCodeEnter is using Keychain.getInternetCredentials(...) without the declaration of authenticationPrompt and title.

@NetPumi2
Copy link
Contributor

NetPumi2 commented Jun 10, 2020

To fix this issue is just needed to update keychain to 6.1.1. check my commit

@jeremy-farnault
Copy link
Contributor

Just merged. Releasing a new version in a few minutes.
Thanks!

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

No branches or pull requests

4 participants