{"_id":"@burslf/react-native-fingerprint-scanner","_rev":"1-891536fe15b245c9c6ea0323ecdffbad","name":"@burslf/react-native-fingerprint-scanner","dist-tags":{"latest":"6.0.1"},"versions":{"6.0.0":{"name":"@burslf/react-native-fingerprint-scanner","version":"6.0.0","description":"React Native Biometrics Scanner for Android and iOS","main":"index.js","keywords":["react-native","react-native-component","react-component","react","native","touch","touchid","touch-id","fingerprint","fingerprint-scanner","authentication","authenticate","auth","face-id","faceid","biometrics"],"peerDependencies":{"react-native":">=0.60 <1.0.0"},"homepage":"https://github.com/hieuvp/react-native-fingerprint-scanner#readme","repository":{"type":"git","url":"git+https://github.com/hieuvp/react-native-fingerprint-scanner.git"},"author":{"name":"Hieu Van","url":"https://github.com/hieuvp"},"license":"MIT","types":"index.d.ts","scripts":{"android":"cd examples && react-native run-android","ios":"cd examples && react-native run-ios","cleanup":"rm -rf android/build ios/build yarn.lock node_modules && cd examples && rm -rf android/build android/app/build ios/build yarn.lock node_modules","cleanup:android":"cd examples/android && ./gradlew clean","cleanup:install":"yarn cleanup && yarn && cd examples && yarn && cd .. && yarn symlink && yarn cleanup:android"},"gitHead":"a04a84051b77152875bbc25c6592f57e31ec1973","bugs":{"url":"https://github.com/hieuvp/react-native-fingerprint-scanner/issues"},"_id":"@burslf/react-native-fingerprint-scanner@6.0.0","_nodeVersion":"18.12.0","_npmVersion":"8.19.2","dist":{"integrity":"sha512-5R0E5HfKYWuaLJZbeHSC+dB6zC906O1V9vdlYGCVYbaMLt08WXwBYRdkYhXTWBIsQwHllU5rLXjXucez5wsq2Q==","shasum":"d24e1a4276f0511716f008f83426af80ea64f21e","tarball":"https://registry.npmjs.org/@burslf/react-native-fingerprint-scanner/-/react-native-fingerprint-scanner-6.0.0.tgz","fileCount":26,"unpackedSize":67648,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGcact8H3ajQPuYq8rEnbBES6rH4pXxvZOkpIndZ5xsuAiB8aA9NN/ClV7bTq3pUrDCr7JX+BpNlIp6wslV0eQSVIw=="}]},"_npmUser":{"name":"burslf","email":"yoel.developer@gmail.com"},"directories":{},"maintainers":[{"name":"burslf","email":"yoel.developer@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-native-fingerprint-scanner_6.0.0_1699185033127_0.7755633577795993"},"_hasShrinkwrap":false},"6.0.1":{"name":"@burslf/react-native-fingerprint-scanner","version":"6.0.1","description":"React Native Biometrics Scanner for Android and iOS","main":"index.js","keywords":["react-native","react-native-component","react-component","react","native","touch","touchid","touch-id","fingerprint","fingerprint-scanner","authentication","authenticate","auth","face-id","faceid","biometrics"],"peerDependencies":{"react-native":">=0.60 <1.0.0"},"homepage":"https://github.com/burslf/react-native-fingerprint-scanner#readme","repository":{"type":"git","url":"git+https://github.com/burslf/react-native-fingerprint-scanner.git"},"author":{"name":"Hieu Van","url":"https://github.com/burslf"},"license":"MIT","types":"index.d.ts","scripts":{"android":"cd examples && react-native run-android","ios":"cd examples && react-native run-ios","cleanup":"rm -rf android/build ios/build yarn.lock node_modules && cd examples && rm -rf android/build android/app/build ios/build yarn.lock node_modules","cleanup:android":"cd examples/android && ./gradlew clean","cleanup:install":"yarn cleanup && yarn && cd examples && yarn && cd .. && yarn symlink && yarn cleanup:android"},"gitHead":"a04a84051b77152875bbc25c6592f57e31ec1973","bugs":{"url":"https://github.com/burslf/react-native-fingerprint-scanner/issues"},"_id":"@burslf/react-native-fingerprint-scanner@6.0.1","_nodeVersion":"18.12.0","_npmVersion":"8.19.2","dist":{"integrity":"sha512-qAqD7UhaMd0wjuVPknJI3vtlQw3tP8T0w/Nk/aPXvb7YhwAR1N0YLraTTmnhxbhgM+hi+lYMqJ6vf3zR05cK0g==","shasum":"cc27590c7b155b51da50e2a8aaca94cef6cce20b","tarball":"https://registry.npmjs.org/@burslf/react-native-fingerprint-scanner/-/react-native-fingerprint-scanner-6.0.1.tgz","fileCount":26,"unpackedSize":67664,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFBCpPXXAw9m49GZ1K81AOmWV/D/y8l8fUxNN+yM8RJdAiA0wKV2aiEQ3FHqzZ0f1mTb1ssRedc9/wv3QqT19nTYeA=="}]},"_npmUser":{"name":"burslf","email":"yoel.developer@gmail.com"},"directories":{},"maintainers":[{"name":"burslf","email":"yoel.developer@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-native-fingerprint-scanner_6.0.1_1699359698146_0.14725504907571074"},"_hasShrinkwrap":false}},"time":{"created":"2023-11-05T11:50:33.049Z","6.0.0":"2023-11-05T11:50:33.346Z","modified":"2023-11-07T12:21:38.596Z","6.0.1":"2023-11-07T12:21:38.448Z"},"maintainers":[{"name":"burslf","email":"yoel.developer@gmail.com"}],"description":"React Native Biometrics Scanner for Android and iOS","homepage":"https://github.com/burslf/react-native-fingerprint-scanner#readme","keywords":["react-native","react-native-component","react-component","react","native","touch","touchid","touch-id","fingerprint","fingerprint-scanner","authentication","authenticate","auth","face-id","faceid","biometrics"],"repository":{"type":"git","url":"git+https://github.com/burslf/react-native-fingerprint-scanner.git"},"author":{"name":"Hieu Van","url":"https://github.com/burslf"},"bugs":{"url":"https://github.com/burslf/react-native-fingerprint-scanner/issues"},"license":"MIT","readme":"# React Native Fingerprint Scanner\n\n# Looking for Maintainers\n\nThis project is no longer actively maintained by the previous maintainers.\nIf you would like to propose a PR we can merge it though, it needs your effort to continue!\n\n----\n\n\n[![React Native Version](https://img.shields.io/badge/react--native-latest-blue.svg?style=flat-square)](http://facebook.github.io/react-native/releases)\n[![Version](https://img.shields.io/npm/v/react-native-fingerprint-scanner.svg)](https://www.npmjs.com/package/react-native-fingerprint-scanner)\n[![NPM](https://img.shields.io/npm/dm/react-native-fingerprint-scanner.svg)](https://www.npmjs.com/package/react-native-fingerprint-scanner)\n\nReact Native Fingerprint Scanner is a [React Native](http://facebook.github.io/react-native/) library for authenticating users with Fingerprint (TouchID).\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Compatibility](#compatibility)\n- [Example](#example)\n- [API](#api)\n- [License](#license)\n\n### iOS Version\nThe usage of the TouchID is based on a framework, named **Local Authentication**.\n\nIt provides a **Default View** that prompts the user to place a finger to the iPhone’s button for scanning.\n\n<div>\n<img src=\"https://github.com/hieuvp/react-native-fingerprint-scanner/raw/master/screenshots/ios-availability.png\" height=\"600\">\n<img src=\"https://github.com/hieuvp/react-native-fingerprint-scanner/raw/master/screenshots/ios-authentication.gif\" height=\"600\">\n</div>\n\n### Android Version\n4.0.0 Prefers the new native Android BiometricPrompt lib on any Android >= v23 (M)\n4.0.0 also DEPRECATES support for the legacy library that provides support for Samsung & MeiZu phones\n\n3.0.2 and below: \nUsing an expandable Android Fingerprint API library, which combines [Samsung](http://developer.samsung.com/galaxy/pass#) and [MeiZu](http://open-wiki.flyme.cn/index.php?title=%E6%8C%87%E7%BA%B9%E8%AF%86%E5%88%ABAPI)'s official Fingerprint API.\n\nSamsung and MeiZu's Fingerprint SDK supports most devices which system versions less than Android 6.0.\n\n<div>\n<img src=\"https://github.com/hieuvp/react-native-fingerprint-scanner/raw/master/screenshots/android-availability.png\" height=\"600\">\n<img src=\"https://github.com/hieuvp/react-native-fingerprint-scanner/raw/master/screenshots/android-authentication.gif\" height=\"600\">\n</div>\n\n## Installation\n\n```sh\n$ npm install react-native-fingerprint-scanner --save\n```\nor\n```sh\n$ yarn add react-native-fingerprint-scanner\n```\n\n### Automatic Configuration\nFor RN >= 0.60\n```sh\n$ cd ios && pod install\n```\n\nFor RN < 0.60, use react-native link to add the library to your project:\n```sh\n$ react-native link react-native-fingerprint-scanner\n```\n\n### Manual Configuration\n\n#### iOS\n\n1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`\n2. Go to `node_modules` ➜ `react-native-fingerprint-scanner` and add `ReactNativeFingerprintScanner.xcodeproj`\n3. To add the library \"libReactNativeFingerprintScanner.a\" to your project in XCode:\n    - In the project navigator, select your project.\n    - Click on the \"Build Phases\" tab.\n    - Under \"Link Binary With Libraries\", click the \"+\" button to add a new library.\n    - Search for \"libReactNativeFingerprintScanner.a\" and select it.\n    - Click \"Add\" to add the library to your project.\n4. Run your project (`Cmd+R`)\n\n#### Android\n\n1. Open up `android/app/src/main/java/[...]/MainApplication.java`\n  - Add `import com.hieuvp.fingerprint.ReactNativeFingerprintScannerPackage;` to the imports at the top of the file\n  - Add `new ReactNativeFingerprintScannerPackage()` to the list returned by the `getPackages()` method\n2. Append the following lines to `android/settings.gradle`:\n  \t```\n  \tinclude ':react-native-fingerprint-scanner'\n  \tproject(':react-native-fingerprint-scanner').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fingerprint-scanner/android')\n  \t```\n3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:\n  \t```\n    implementation project(':react-native-fingerprint-scanner')\n  \t```\n\n### App Permissions\n\nAdd the following permissions to their respective files:\n\n#### Android\nIn your `AndroidManifest.xml`:\n\nAPI level 28+ (Uses Android native BiometricPrompt) ([Reference](https://developer.android.com/reference/android/Manifest.permission#USE_BIOMETRIC))\n```xml\n<uses-permission android:name=\"android.permission.USE_BIOMETRIC\" />\n```\n\nAPI level 23-28 (Uses Android native FingerprintCompat) [Reference](https://developer.android.com/reference/android/Manifest.permission#USE_FINGERPRINT)) \n```xml\n<uses-permission android:name=\"android.permission.USE_FINGERPRINT\" />\n```\n\n// DEPRECATED in 4.0.0\nAPI level <23 (Uses device-specific native fingerprinting, if available - Samsung & MeiZu only) [Reference](https://developer.android.com/reference/android/Manifest.permission#USE_FINGERPRINT)) \n```xml\n<uses-permission android:name=\"android.permission.USE_FINGERPRINT\" />\n```\n#### iOS\nIn your `Info.plist`:\n\n```xml\n<key>NSFaceIDUsageDescription</key>\n<string>$(PRODUCT_NAME) requires FaceID access to allows you quick and secure access.</string>\n```\n\n### Extra Configuration\n\n1. Make sure the following versions are all correct in `android/app/build.gradle`\n    ```\n    // API v29 enables FaceId\n    android {\n        compileSdkVersion 29\n        buildToolsVersion \"29.0.2\"\n    ...\n        defaultConfig {\n          targetSdkVersion 29\n    ```\n\n2. Add necessary rules to `android/app/proguard-rules.pro` if you are using proguard:\n    ```\n    # MeiZu Fingerprint\n\n    // DEPRECATED in 4.0.0\n    -keep class com.fingerprints.service.** { *; }\n    -dontwarn com.fingerprints.service.**\n\n    # Samsung Fingerprint\n\n    // DEPRECATED in 4.0.0\n    -keep class com.samsung.android.sdk.** { *; }\n    -dontwarn com.samsung.android.sdk.**\n    ```\n\n## Compatibility\n\n* For Gradle < 3 you MUST install react-native-fingerprint-scanner at version <= 2.5.0\n* For RN >= 0.57 and/or Gradle >= 3 you MUST install react-native-fingerprint-scanner at version >= 2.6.0\n* For RN >= 0.60 you MUST install react-native-fingerprint-scanner at version >= 3.0.0\n* For Android native Face Unlock, MUST use >= 4.0.0\n\n## Example\n\n[Example Source Code](https://github.com/hieuvp/react-native-fingerprint-scanner/tree/master/examples)\n\n**iOS Implementation**\n```javascript\nimport React, { Component } from 'react';\nimport PropTypes from 'prop-types';\nimport { AlertIOS } from 'react-native';\nimport FingerprintScanner from 'react-native-fingerprint-scanner';\n\nclass FingerprintPopup extends Component {\n\n  componentDidMount() {\n    FingerprintScanner\n      .authenticate({ description: 'Scan your fingerprint on the device scanner to continue' })\n      .then(() => {\n        this.props.handlePopupDismissed();\n        AlertIOS.alert('Authenticated successfully');\n      })\n      .catch((error) => {\n        this.props.handlePopupDismissed();\n        AlertIOS.alert(error.message);\n      });\n  }\n\n  render() {\n    return false;\n  }\n}\n\nFingerprintPopup.propTypes = {\n  handlePopupDismissed: PropTypes.func.isRequired,\n};\n\nexport default FingerprintPopup;\n```\n\n**Android Implementation**\n```javascript\n\nimport React, { Component } from 'react';\nimport PropTypes from 'prop-types';\nimport {\n  Alert,\n  Image,\n  Text,\n  TouchableOpacity,\n  View,\n  ViewPropTypes,\n  Platform,\n} from 'react-native';\n\nimport FingerprintScanner from 'react-native-fingerprint-scanner';\nimport styles from './FingerprintPopup.component.styles';\nimport ShakingText from './ShakingText.component';\n\n\n// - this example component supports both the\n//   legacy device-specific (Android < v23) and\n//   current (Android >= 23) biometric APIs\n// - your lib and implementation may not need both\nclass BiometricPopup extends Component {\n  constructor(props) {\n    super(props);\n    this.state = {\n      errorMessageLegacy: undefined,\n      biometricLegacy: undefined\n    };\n\n    this.description = null;\n  }\n\n  componentDidMount() {\n    if (this.requiresLegacyAuthentication()) {\n      this.authLegacy();\n    } else {\n      this.authCurrent();\n    }\n  }\n\n  componentWillUnmount = () => {\n    FingerprintScanner.release();\n  }\n\n  requiresLegacyAuthentication() {\n    return Platform.Version < 23;\n  }\n\n  authCurrent() {\n    FingerprintScanner\n      .authenticate({ title: 'Log in with Biometrics' })\n      .then(() => {\n        this.props.onAuthenticate();\n      });\n  }\n\n  authLegacy() {\n    FingerprintScanner\n      .authenticate({ onAttempt: this.handleAuthenticationAttemptedLegacy })\n      .then(() => {\n        this.props.handlePopupDismissedLegacy();\n        Alert.alert('Fingerprint Authentication', 'Authenticated successfully');\n      })\n      .catch((error) => {\n        this.setState({ errorMessageLegacy: error.message, biometricLegacy: error.biometric });\n        this.description.shake();\n      });\n  }\n\n  handleAuthenticationAttemptedLegacy = (error) => {\n    this.setState({ errorMessageLegacy: error.message });\n    this.description.shake();\n  };\n\n  renderLegacy() {\n    const { errorMessageLegacy, biometricLegacy } = this.state;\n    const { style, handlePopupDismissedLegacy } = this.props;\n\n    return (\n      <View style={styles.container}>\n        <View style={[styles.contentContainer, style]}>\n\n          <Image\n            style={styles.logo}\n            source={require('./assets/finger_print.png')}\n          />\n\n          <Text style={styles.heading}>\n            Biometric{'\\n'}Authentication\n          </Text>\n          <ShakingText\n            ref={(instance) => { this.description = instance; }}\n            style={styles.description(!!errorMessageLegacy)}>\n            {errorMessageLegacy || `Scan your ${biometricLegacy} on the\\ndevice scanner to continue`}\n          </ShakingText>\n\n          <TouchableOpacity\n            style={styles.buttonContainer}\n            onPress={handlePopupDismissedLegacy}\n          >\n            <Text style={styles.buttonText}>\n              BACK TO MAIN\n            </Text>\n          </TouchableOpacity>\n\n        </View>\n      </View>\n    );\n  }\n\n\n  render = () => {\n    if (this.requiresLegacyAuthentication()) {\n      return this.renderLegacy();\n    }\n\n    // current API UI provided by native BiometricPrompt\n    return null;\n  }\n}\n\nBiometricPopup.propTypes = {\n  onAuthenticate: PropTypes.func.isRequired,\n  handlePopupDismissedLegacy: PropTypes.func,\n  style: ViewPropTypes.style,\n};\n\nexport default BiometricPopup;\n```\n\n## API\n\n### `isSensorAvailable()`: (Android, iOS)\nChecks if Fingerprint Scanner is able to be used by now.\n\n- Returns a `Promise<string>`\n- `biometryType: String` - The type of biometric authentication supported by the device.\n  - iOS: biometryType = 'Touch ID', 'Face ID'\n  - Android: biometryType = 'Biometrics'\n- `error: FingerprintScannerError { name, message, biometric }` - The name and message of failure and the biometric type in use.\n\n```javascript\ncomponentDidMount() {\n  FingerprintScanner\n    .isSensorAvailable()\n    .then(biometryType => this.setState({ biometryType }))\n    .catch(error => this.setState({ errorMessage: error.message }));\n}\n```\n\n### `authenticate({ description, fallbackEnabled })`: (iOS)\nStarts Fingerprint authentication on iOS.\n\n- Returns a `Promise`\n- `description: String` - the string to explain the request for user authentication.\n- `fallbackEnabled: Boolean` - default to `true`, whether to display fallback button (e.g. Enter Password).\n\n```javascript\ncomponentDidMount() {\n  FingerprintScanner\n    .authenticate({ description: 'Scan your fingerprint on the device scanner to continue' })\n    .then(() => {\n      this.props.handlePopupDismissed();\n      AlertIOS.alert('Authenticated successfully');\n    })\n    .catch((error) => {\n      this.props.handlePopupDismissed();\n      AlertIOS.alert(error.message);\n    });\n}\n```\n\n### `authenticate({ title=\"Log In\", subTitle, description, cancelButton=\"Cancel\", onAttempt=() => (null) })`: (Android)\nStarts Fingerprint authentication on Android.\n\n- Returns a `Promise`\n- `title: String` the title text to display in the native Android popup\n- `subTitle: String` the sub title text to display in the native Android popup\n- `description: String` the description text to display in the native Android popup\n- `cancelButton: String` the cancel button text to display in the native Android popup\n- `onAttempt: Function` - a callback function when users are trying to scan their fingerprint but failed.\n\n```javascript\ncomponentDidMount() {\n  if (requiresLegacyAuthentication()) {\n    authLegacy();\n  } else {\n    authCurrent();\n  }\n}\n\ncomponentWillUnmount = () => {\n  FingerprintScanner.release();\n}\n\nrequiresLegacyAuthentication() {\n  return Platform.Version < 23;\n}\n\nauthCurrent() {\n  FingerprintScanner\n    .authenticate({ title: 'Log in with Biometrics' })\n    .then(() => {\n      this.props.onAuthenticate();\n    });\n}\n\nauthLegacy() {\n  FingerprintScanner\n    .authenticate({ onAttempt: this.handleAuthenticationAttemptedLegacy })\n    .then(() => {\n      this.props.handlePopupDismissedLegacy();\n      Alert.alert('Fingerprint Authentication', 'Authenticated successfully');\n    })\n    .catch((error) => {\n      this.setState({ errorMessageLegacy: error.message, biometricLegacy: error.biometric });\n      this.description.shake();\n    });\n}\n\nhandleAuthenticationAttemptedLegacy = (error) => {\n  this.setState({ errorMessageLegacy: error.message });\n  this.description.shake();\n};\n```\n\n### `release()`: (Android)\nStops fingerprint scanner listener, releases cache of internal state in native code, and cancels native prompt if visible.\n\n- Returns a `Void`\n\n```javascript\ncomponentWillUnmount() {\n  FingerprintScanner.release();\n}\n```\n\n### `Types of Biometrics`\n\n| Value | OS | Description|\n|---|---|---|\n| Touch ID | iOS | |\n| Face ID | iOS | |\n| Biometrics | Android | Refers to the biometric set as preferred on the device |\n\n### `Errors`\n\n| Name | Message |\n|---|---|\n| AuthenticationNotMatch | No match |\n| AuthenticationFailed | Authentication was not successful because the user failed to provide valid credentials |\n| AuthenticationTimeout | Authentication was not successful because the operation timed out |\n| AuthenticationProcessFailed | 'Sensor was unable to process the image. Please try again |\n| UserCancel | Authentication was canceled by the user - e.g. the user tapped Cancel in the dialog |\n| UserFallback | Authentication was canceled because the user tapped the fallback button (Enter Password) |\n| SystemCancel | Authentication was canceled by system - e.g. if another application came to foreground while the authentication dialog was up |\n| PasscodeNotSet | Authentication could not start because the passcode is not set on the device |\n| DeviceLocked | Authentication was not successful, the device currently in a lockout of 30 seconds |\n| DeviceLockedPermanent | Authentication was not successful, device must be unlocked via password |\n| DeviceOutOfMemory | Authentication could not proceed because there is not enough free memory on the device |\n| HardwareError | A hardware error occurred |\n| FingerprintScannerUnknownError | Could not authenticate for an unknown reason |\n| FingerprintScannerNotSupported | Device does not support Fingerprint Scanner |\n| FingerprintScannerNotEnrolled  | Authentication could not start because Fingerprint Scanner has no enrolled fingers |\n| FingerprintScannerNotAvailable | Authentication could not start because Fingerprint Scanner is not available on the device |\n\n## License\n\nMIT\n","readmeFilename":"README.md"}