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

callbackErrorTouchId doesn't catch all possible errors. #213

Open
findiel opened this issue Oct 5, 2022 · 0 comments
Open

callbackErrorTouchId doesn't catch all possible errors. #213

findiel opened this issue Oct 5, 2022 · 0 comments

Comments

@findiel
Copy link

findiel commented Oct 5, 2022

As we can see in react-native-touch-id library documentation (Errors section), errors could come from TouchID.isSupported or TouchID.authenticate methods.
In this lib we have such code:
https://github.com/jarden-digital/react-native-pincode/blob/master/src/PinCodeEnter.tsx

  triggerTouchID() {
    !!TouchID && TouchID.isSupported()
      .then(() => {
        setTimeout(() => {
          this.launchTouchID()
        })
      })
      .catch((error: any) => {
        console.warn('TouchID error', error)
      })
  }

and

  async launchTouchID() {
    const optionalConfigObject = {
      imageColor: '#e00606',
      imageErrorColor: '#ff0000',
      sensorDescription: 'Touch sensor',
      sensorErrorDescription: 'Failed',
      cancelText: this.props.textCancelButtonTouchID || 'Cancel',
      fallbackLabel: 'Show Passcode',
      unifiedErrors: false,
      passcodeFallback: this.props.passcodeFallback
    }
    try {
      await TouchID.authenticate(
        this.props.touchIDSentence,
        Object.assign({}, optionalConfigObject, {
          title: this.props.touchIDTitle
        })
      ).then((success: any) => {
        this.endProcess(this.props.storedPin || this.keyChainResult)
      })
    } catch (e) {
      if (!!this.props.callbackErrorTouchId) {
        this.props.callbackErrorTouchId(e)
      } else {
        console.log('TouchID error', e)
      }
    }
  }

So it seems that we can't handle with errors from TouchID.isSupported, because callbackErrorTouchId callback is triggering only if TouchID.authenticate fails.
Could you fix that please?

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

1 participant