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

spoof-detection-package

v0.1.2

Published

On-device face anti-spoofing (printed photo / poster / phone screen detection) for Expo and React Native. Takes a photo uri, returns a spoof verdict.

Readme

spoof-detection-package

On-device face anti-spoofing for Expo and React Native. Give it a photo uri, it tells you whether the face is real or a presentation attack — printed photo, passport photo, poster, or a phone/tablet/laptop screen.

Everything runs natively on-device (ML Kit / Apple Vision for face detection, MiniFASNetV2 for texture analysis — converted from the official Silent-Face-Anti-Spoofing weights and bundled in the package, ~1.9 MB). No network calls, no photo ever leaves the device, no JS dependencies.

Install

npx expo install spoof-detection-package
# bare React Native: also needs expo-modules-core set up (npx install-expo-modules)

Native module — needs a dev build / prebuild, does not work in Expo Go.

Plays nice with other TFLite packages

Safe to install alongside react-native-fast-tflite (or alone):

  • Android uses Google's LiteRT artifact (com.google.ai.edge.litert:litert), the same family fast-tflite v3 uses — Gradle dedupes to a single copy, no duplicate-class or duplicate-.so errors.
  • iOS declares TensorFlowLiteSwift >= 2.14, < 3.0 as a range, so CocoaPods can settle on whatever exact TensorFlowLiteC version other pods pin (e.g. fast-tflite 3.x pins 2.17.0) instead of conflicting.

Usage

import { detectSpoof, isSpoof } from 'spoof-detection-package';

const result = await detectSpoof(photo.uri);
// {
//   live: true,          // safe to proceed
//   spoof: false,        // presentation attack detected
//   realScore: 0.94,     // P(real face) from the model, 0-1
//   reason: null,        // 'no_face' | 'multiple_faces' | 'face_too_small' | 'texture' | null
// }

if (result.spoof) {
  // show "Spoof detected" popup
} else if (!result.live) {
  // quality problem: result.reason === 'no_face' or 'face_too_small'
} else {
  // real face — continue with recognition / attendance
}

// or the one-liner:
if (await isSpoof(photo.uri)) return blockScan();

Options

await detectSpoof(uri, {
  threshold: 0.7,     // min P(real) to accept; raise = stricter
  minFaceRatio: 0.18, // face must be >= 18% of the photo's short side
  cropScale: 2.7,     // context crop around the face (model default)
});

How it decides

  1. Face detection (ML Kit on Android, Apple Vision on iOS)
    • no face -> { live: false, spoof: false, reason: 'no_face' }
    • 2+ faces -> { spoof: true, reason: 'multiple_faces' }
    • tiny face -> { live: false, reason: 'face_too_small' } (ask the user to come closer — also blocks passport photos held at a distance)
  2. MiniFASNetV2 texture analysis on a wide 2.7x crop (sees paper edges, screen bezels, glare, moiré) -> realScore; below threshold -> { spoof: true, reason: 'texture' }

Tips

  • Combine with an object detector (COCO-SSD "cell phone"/"tv"/"laptop") and a motion check across preview frames for defense in depth.
  • Tune threshold with real data: log realScore for genuine users and known fakes, pick the value that separates them.