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

capacitor-plugin-faceantispoofing

v0.0.3

Published

Capacitor plugin for Passive Liveness Detection and Face Anti-Spoofing

Readme

capacitor-plugin-faceantispoofing

Capacitor plugin for Passive Liveness Detection and Face Anti-Spoofing using TensorFlow Lite models.

This plugin has been migrated from cordova-plugin-facespoofing.

Features

  • Face Detection: Uses MTCNN (Multi-task Cascaded Convolutional Networks) for accurate face detection
  • Anti-Spoofing Detection: Passive liveness detection using TensorFlow Lite models
  • Blur Detection: Laplacian variance-based image quality assessment
  • Cross-Platform: Support for both Android and iOS

Install

Using npm

npm install capacitor-plugin-faceantispoofing
npx cap sync

Using yarn

yarn add capacitor-plugin-faceantispoofing
npx cap sync

Usage

import { FaceAntiSpoofing } from 'capacitor-plugin-faceantispoofing';

// Detect face liveness from base64 image
const detectLiveness = async (base64Image: string) => {
  try {
    const result = await FaceAntiSpoofing.detect({
      image: base64Image  // Base64 encoded image (without data:image/...;base64, prefix)
    });

    console.log('Error:', result.error);
    console.log('Liveness:', result.liveness);
    console.log('Score:', result.score);
    console.log('Threshold:', result.threshold);
    console.log('Message:', result.message);

    if (result.liveness) {
      console.log('Real face detected!');
    } else {
      console.log('Spoof detected or no face found!');
    }
  } catch (error) {
    console.error('Detection failed:', error);
  }
};

API

detect(options)

Detects face liveness and performs anti-spoofing detection on the provided image.

| Param | Type | Description | | ------------ | ----------------------------- | -------------------------------------------------- | | options | <DetectOptions> | Options for the detection | | image | <string> | Base64 encoded image data or file URI |

Returns: Promise<DetectionResult>

DetectOptions

| Prop | Type | Description | | ------- | ------------------- | ---------------------------------------- | | image | string | Base64 encoded image (without data:image/...;base64, prefix) or file URI starting with file:// |

DetectionResult

| Prop | Type | Description | | --------- | ------------------- | ---------------------------------------- | | error | boolean | Whether an error occurred | | liveness | boolean | Whether the face is detected as real | | score | string | The liveness score | | threshold | string | The threshold used for classification | | message | string | Additional information message |

Detection Flow

  1. Face Detection: Uses MTCNN (P-Net → R-Net → O-Net) to detect faces in the image
  2. Face Alignment: Aligns the detected face based on facial landmarks
  3. Blur Detection: Checks image clarity using Laplacian variance
  4. Anti-Spoofing: If image is clear enough, runs the anti-spoofing model to classify as real or fake

Response Values

  • No faces detected: error: true, message: "No faces detected"
  • Image too blurry: error: false, liveness: false, score contains Laplacian value
  • Real face detected: error: false, liveness: true, score < threshold
  • Spoof detected: error: false, liveness: false, score >= threshold

Platform Support

| Platform | Supported | | -------- | --------- | | Android | ✅ Yes | | iOS | ✅ Yes | | Web | ❌ No* |

*Web is not supported as native TensorFlow Lite is required.

Dependencies

Android

  • Google AI Edge LITErt (TensorFlow Lite) 1.4.0
  • minSdkVersion: 24
  • compileSdkVersion: 36

iOS

  • TensorFlowLiteSwift ~ 2.17.0
  • TensorFlowLiteC ~ 2.17.0
  • iOS Deployment Target: 15.0

Model Files

This plugin includes the following TensorFlow Lite models:

  • FaceAntiSpoofing.tflite - Anti-spoofing classification model
  • pnet.tflite - MTCNN Proposal Network
  • rnet.tflite - MTCNN Refine Network
  • onet.tflite - MTCNN Output Network

Threshold Values

  • Android: THRESHOLD = 0.5, LAPLACIAN_THRESHOLD = 0
  • iOS: threshold = 0.5, laplacianThreshold = 0

Note: These values have been normalized from the original Cordova plugin.

Example Image Format

The plugin accepts images in the following formats:

  1. Base64 without prefix: iVBORw0KGgoAAAANSUhEUgAA...
  2. Base64 with data URI: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...
  3. File URI: file:///path/to/image.png

Error Handling

try {
  const result = await FaceAntiSpoofing.detect({ image: base64Data });

  if (result.error) {
    console.error('Detection error:', result.message);
    return;
  }

  if (result.liveness) {
    // Real face detected
  } else {
    // Spoof or no face detected
  }
} catch (e) {
  console.error('Plugin error:', e);
}

License

MIT

Credits

Originally based on cordova-plugin-facespoofing by rakaraka029.