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

@richard.fadiora/liveness-detection

v2.1.0

Published

A React-based liveness detection component that performs randomized user challenges and verifies real-user presence via a backend anti-spoofing API.

Readme

Liveness Detection Component

A React-based liveness detection component that performs randomized user challenges and verifies real-user presence via a backend anti-spoofing API.


📌 Overview

This component strengthens identity verification by combining:

  • Randomized challenge-response validation
  • Strict timeout enforcement
  • Backend spoof detection
  • Callback-based integration for easy usage

It protects against:

  • Presentation (photo) attacks
  • Screen glare attacks
  • Video replay/injection attacks

⚙️ How It Works

1️⃣ Challenge Initialization

When the user clicks the "Start Challenge" button:

  • The system randomly selects 3 challenges

  • The challenges are chosen from a fixed pool of 4:

    • Smile
    • Blink
    • Turn_Head
    • Thumbs_Up
  • A timer starts immediately. If you do not pass the duration property, it will default to 60 seconds.

If the timer expires before completion:

  • The session is terminated
  • The user must restart the process manually
  • No frames are sent to the backend

2️⃣ Challenge Execution

  • Challenges are validated in real-time using webcam input.
  • The next challenge only begins after the current one is successfully completed.
  • All 3 challenges must be completed within the 60-second window.

If successful, the component proceeds to backend verification.


3️⃣ Backend Liveness Verification

After all challenges are completed:

  • The component captures 5 frames from the webcam.
  • These frames are sent to the backend API defined by the apiUrl prop.
  • The backend performs:
    • Spoof detection
    • Glare detection
    • Video injection detection

✅ Success & Failure Behavior

If verification succeeds:

  • The UI displays: "Verification Passed"
  • The component triggers:
onComplete(true)

If verification fails:

  • The UI displays a failure message
  • The component triggers:
onError(false)

This is because the parameters being passed for both completion and Error are the same: success, result, and skinConfidence.


📦 Props

| Prop Name | Type | Required | Description | |------------|----------------------------|----------|-------------| | apiUrl | string | Yes | Backend endpoint used for liveness verification | | onComplete | (result: boolean) => void | Yes | Callback fired after verification completes | | onError | (result: boolean) => void | Yes | Callback fired after verification flags error | | duration | int | No | Used for setting maximum time for the challenges to be completed |


🧩 Usage Example

import { LivenessSDK } from "@richard.fadiora/liveness-detection";

function App() {
  return (
    <LivenessSDK
      apiUrl="https://your-backend-api.com/liveness-check"
      onComplete={(result) => {
        if (result) {
          console.log("User verified successfully");
        } else {
          console.log("Liveness verification failed");
        }
      }}
    />
  );
}

export default App;

⏳ Timeout Rules

  • Maximum session duration: Set in the duration property, else 60 seconds
  • If time expires:
    • The challenge stops immediately
    • The verification state resets
    • User must click Start Challenge again
    • Backend verification will NOT be triggered

🔐 Security Architecture

This component uses a layered approach:

  1. Client-side active verification

    • Randomized challenge selection
    • Real-time gesture detection
  2. Server-side passive verification

    • Frame-based spoof analysis
    • Glare detection
    • Video injection detection
  3. Strict session control

    • Timeout enforcement
    • Restart requirement on failure

This multi-layer strategy reduces false positives and prevents replay-based attacks.


📊 Verification Criteria

A verification is considered successful only if:

  • 3 randomly selected challenges are completed
  • All 5 frames are successfully sent to the backend
  • Backend confirms:
    • No spoofing detected
    • No glare detected
    • Skin Texture is human
    • No video injection detected

🏗️ Integration Notes

  • The component assumes webcam permissions are granted.
  • The backend must accept 5 frames in the expected format.
  • The apiUrl must be reachable from the client environment.
  • Ensure CORS is properly configured on the backend.

🚀 Ideal Use Cases

  • KYC verification flows
  • Identity onboarding systems
  • Account recovery flows
  • Secure login systems
  • Financial or compliance-based applications

👨‍💻 Maintainer

Maintained by Princeps Credit Systems Limited.