jarden-digital/react-native-pincode

callbackErrorTouchId doesn't catch all possible errors.

Opened this issue · 0 comments

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?