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 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-neural-face-auth

v0.1.0

Published

A React Native library for secure, biometric identity verification. It bridges native machine learning frameworks (like TensorFlow Lite or ML Kit) to perform real-time face detection and neural-embedding matching directly on the device, ensuring fast perf

Readme

react-native-neural-face-auth 🛡️

A secure, 100% Offline & On-Premise biometric verification library for React Native.

This library bridges native machine learning frameworks (Google ML Kit & TensorFlow Lite) to perform real-time face detection, liveness checks, and neural-embedding matching directly on the device. No data is ever sent to a server.


🚀 Key Features

  • 100% Offline & On-Premise: All processing happens on the device. No API keys, no cloud costs, and zero latency issues. Perfect for GDPR/privacy-compliant apps.
  • Neural Face Matching: Uses MobileFaceNet models to generate high-accuracy embeddings for 1:1 identity verification.
  • Liveness Detection: Built-in UI (LivenessCameraView) that prompts users to Blink or Smile to ensure they are real.
  • 🕵️ Multi-Frame Anti-Spoofing: Optional integrity check that captures a "secret" early frame and compares it against the final capture to prevent photo-swapping attacks.
  • Dynamic Geofencing: Strict location-based access control with configurable radius logic.

📦 Installation

npm install react-native-neural-face-auth
# or
yarn add react-native-neural-face-auth

🍎 iOS Setup (Important)

Install Pods

cd ios && pod install

Apple Silicon (M1/M2/M3) Users

If you encounter symbol not found or architecture errors, add this to your Podfile inside the post_install block:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      # Force Simulator to use Rosetta mode for ML compatibility
      config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
    end
  end
end

🤖 Android Setup

Ensure you have camera and location permissions in AndroidManifest.xml:

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

📖 How It Works

1) Offline & On-Premise Architecture

Unlike generic face APIs (like AWS Rekognition), this library bundles the TFLite models inside your app binary.

  • Input: Image is passed from React Native to Native (ObjC/Java).
  • Processing: ML Kit detects the face -> TFLite crops and generates a 192-float vector embedding.
  • Comparison: Euclidean distance is calculated between the Source ID and the Camera Capture.
  • Output: A Match/No-Match result is returned instantly.

2) Multi-Frame Integrity (Anti-Spoofing)

When enableMultiFrameLiveness is set to true:

  • The camera silently captures a "Secret Snap" while the user is positioning their face.
  • It captures the "Final Blink" when the liveness challenge is complete.
  • The verifyFaces function compares Secret Snap vs. Final Blink.
  • If the user tried to swap a photo or move a phone screen in front of the camera between these milliseconds, the check fails.

3) Geofencing with Dynamic Radius

You can enforce that a user must be within X meters of a specific location (e.g., an office building) to authenticate.

  • The native module fetches the GPS coordinates securely.
  • It calculates the Haversine distance between the Device Location and the Allowed Center.
  • If Distance > Radius, the verification is rejected immediately (Status 403), even if the face matches.

💻 Usage

1) The Liveness Camera

Import the view to handle the UI interaction (Blink detection).

import { LivenessCameraView } from 'react-native-neural-face-auth';

<LivenessCameraView
  style={{ flex: 1 }}
  livenessMode="BLINK" // Options: "BLINK", "SMILE", "NONE"
  enableMultiFrameLiveness={true} // Enables the secret anti-spoofing frame
  onCapture={(event) => {
    const finalUri = event.nativeEvent.uri;
    const earlyUri = event.nativeEvent.earlyUri; // The secret frame
    console.log("Captured:", finalUri, earlyUri);
  }}
  onStatusChange={(event) => {
    console.log("Instruction:", event.nativeEvent.message); // e.g. "Move Closer"
  }}
/>

2) Verifying the Face (Identity + Geo + Integrity)

Once you have the images, run the verification.

import { verifyFaces, getCurrentLocation } from 'react-native-neural-face-auth';

const handleVerification = async () => {
  // 1. Get GPS (Optional)
  const location = await getCurrentLocation();

  // 2. Configure Verification
  const config = {
    livenessMode: 'NONE', // Already checked liveness in camera

    // Geofencing Config
    enableLocation: true,
    sourceLat: 40.7580,  // Allowed Center (e.g. Office)
    sourceLng: -73.9855,
    targetLat: location.latitude, // Current Device GPS
    targetLng: location.longitude,
    radius: 100 // Allow 100 meter radius
  };

  // 3. Run Verify
  // To check Integrity: Compare Secret Frame vs Final Frame first
  // To check Identity: Compare ID Card vs Final Frame
  const response = await verifyFaces(referenceImageUri, cameraImageUri, config);

  if (response.statusCode === 200) {
    if (response.result.isMatch) {
       console.log(`Matched! Accuracy: ${response.result.accuracy}%`);
    } else {
       console.log("Face did not match.");
    }
  } else if (response.statusCode === 403) {
    console.log("Geofence Violation! You are too far away.");
  }
};

📚 API Reference

verifyFaces(sourceUri, targetUri, config)

Performs the mathematical embedding comparison.

| Config Key | Type | Description | |-----------|------|-------------| | livenessMode | String | "BLINK", "SMILE", or "NONE". Enforces logic on static images. | | enableLocation | Boolean | If true, validates lat/lng distance. | | sourceLat | Number | The latitude of the ALLOWED location. | | sourceLng | Number | The longitude of the ALLOWED location. | | targetLat | Number | The latitude of the DEVICE. | | targetLng | Number | The longitude of the DEVICE. | | radius | Number | Allowed distance in meters. |


📷 LivenessCameraView Props

| Prop | Type | Description | |------|------|-------------| | livenessMode | String | "BLINK" (default) or "NONE". Determines the trigger to take photo. | | enableMultiFrameLiveness | Boolean | If true, captures an early frame before the final trigger. | | onCapture | Event | Returns { uri, earlyUri }. | | onStatusChange | Event | Returns { message, isCorrect } for UI feedback. |


📄 License

MIT © Vasanth