npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rn-biometric-authentication

v1.0.2

Published

React Native library biometric authentication.

Downloads

330

Readme

React Native Biometric Auth

React native biometric Auth is a bridge to Android/iOS for biometric authentication.

Feature List

  1. Check if Biometric authentication enabled on the device.
  2. Authenticate user using Biometric with a fallback mechanism to passcode or device password.
  3. Supported on both Android and iOS.

How to use

Installation

npm i rn-biometric-authentication

Link / AutoLinking

On React Native 0.60+ the CLI autolink feature links the module while building the app.

Additional configuration

iOS

This package requires an iOS target SDK version of iOS 10 or higher

Ensure that you have the NSFaceIDUsageDescription entry set in your react native iOS project, or Face ID will not work properly. This description will be will be presented to the user the first time a biometrics action is taken, and the user will be asked if they want to allow the app to use Face ID. If the user declines the usage of face id for the app, the isSensorAvailable function will indicate biometrics is unavailable until the face id permission is specifically allowed for the app by the user.

Android

This package requires a compiled SDK version of 29 (Android 10.0) or higher

Methods

isSensorAvailable()

Detects what type of biometric sensor is available. Returns a Promise that resolves to an object with details about biometrics availability

Result Object

| Property | Type | Description | | --- | --- | --- | | available | bool | A boolean indicating if biometrics is available or not | | biometryType | string | A string indicating what type of biometrics is available. TouchID(iOS), FaceID(iOS), Biometrics(Android), or undefined if biometrics is not available. | | error | string | An error message indicating why biometrics may not be available. undefined if there is no error. |

Example

import ReactNativeBiometricAuth from 'rn-biometric-authentication'

ReactNativeBiometricAuth.isSensorAvailable()
  .then((resultObject) => {
    const { available, biometryType } = resultObject

    if (available && biometryType === ReactNativeBiometrics.TouchID) {
      console.log('ReactNativeBiometricAuth', 'TouchID is supported')
    } else if (available && biometryType === ReactNativeBiometrics.FaceID) {
      console.log('ReactNativeBiometricAuth', 'FaceID is supported')
    } else if (available && biometryType === ReactNativeBiometrics.Biometrics) {
      console.log('ReactNativeBiometricAuth', 'Biometrics is supported')
    } else {
      console.log('ReactNativeBiometricAuth', 'Biometrics not supported')
    }
  })

simplePrompt(options)

Prompts the user for their fingerprint or face id. Returns a Promise that resolves if the user provides a valid biometrics or cancel the prompt, otherwise the promise rejects.

Options Object

| Parameter | Type | Description | iOS | Android | | --- | --- | --- | --- | --- | | promptMessage | string | Message that will be displayed in the biometrics prompt | ✔ | ✔ | | cancelButtonText | string | Text to be displayed for the cancel button on biometric prompts, defaults to Cancel | ✖ | ✔ | | isDeviceAuthEnabled | boolean | Enable fallback to device credential for authentication. | ✖ | ✔ | | fallbackText | string | Fallback text to be displayed for passcode if TouchID or FaceID authentication failed. | ✔ | ✖ |

Result Object

| Property | Type | Description | | --- | --- | --- | | success | bool | A boolean indicating if the biometric prompt succeeded, false if the users cancels the biometrics prompt | | error | string | An error message indicating why the biometric prompt failed. undefined if there is no error. |

Example

import ReactNativeBiometricAuth from 'rn-biometric-authentication'

ReactNativeBiometricAuth.simplePrompt({promptMessage: 'Authenticate'})
  .then((resultObject) => {
    const { success } = resultObject

    if (success) {
      console.log('ReactNativeBiometricAuth', 'Success')
    } else {
      console.log('ReactNativeBiometricAuth', 'Cancelled')
    }
  })
  .catch(() => {
    console.log('ReactNativeBiometricAuth', 'Failed')
  })

Inspiration

This library uses some code from react-native-biometrics. Added options to fallback to the device credentials for authentication. Removed some feature to make it simple to use for authentication purpose only.