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

face-auth-library

v1.0.7

Published

Thư viện xác thực khuôn mặt với TensorFlow.js và AI

Downloads

28

Readme

Face Auth Library

Thư viện xác thực khuôn mặt thông minh, hỗ trợ tiếng Việt.
Dùng để tích hợp xác thực khuôn mặt cho các sản phẩm web (KYC, check-in, chấm công, v.v.).


📦 Cài đặt

1️⃣ CDN

<!-- Face Auth Library (bundle) -->
<script src="https://cdn.jsdelivr.net/npm/face-auth-library@latest/dist/face-auth.min.js"></script>

Sử dụng với HTML thuần:

<button id="openFaceAuth">Mở camera xác thực</button>

<script>
  // Khởi tạo instance
  const faceAuth = new FaceAuth({
    detectionConfidence: 0.8,
    maxFaces: 1
  });

  document.getElementById('openFaceAuth').addEventListener('click', async () => {
    // Khởi tạo model
    await faceAuth.init();

    // Thực hiện xác thực
    const result = await faceAuth.authenticate();

    if (result.isAuthenticated) {
      alert('Xác thực thành công!');
    } else {
      alert('Xác thực thất bại, vui lòng thử lại.');
    }
  });
</script>

2️⃣ NPM

npm install face-auth-library

Sử dụng trong project (React, Vue, Next.js, Vite, Webpack, v.v.):

import { FaceAuth } from 'face-auth-library';

// Khởi tạo
const faceAuth = new FaceAuth({
  detectionConfidence: 0.8,
  maxFaces: 1
});

async function handleFaceAuth() {
  // Khởi tạo model
  await faceAuth.init();

  // Thực hiện xác thực
  const result = await faceAuth.authenticate();

  if (result.isAuthenticated) {
    console.log('Xác thực thành công!');
  } else {
    console.log('Xác thực thất bại!');
  }
}

🚀 Ví dụ tích hợp nhanh (HTML thuần)

<!DOCTYPE html>
<html lang="vi">
<head>
  <meta charset="UTF-8" />
  <title>Demo Face Auth</title>
</head>
<body>
  <button id="openFaceAuth">Mở camera xác thực</button>
  
  <!-- Face Auth Library -->
  <script src="https://cdn.jsdelivr.net/npm/face-auth-library@latest/dist/face-auth.min.js"></script>

  <script>
    const faceAuth = new FaceAuth({
      detectionConfidence: 0.8,
      maxFaces: 1
    });

    document
      .getElementById('openFaceAuth')
      .addEventListener('click', async () => {
        await faceAuth.init();
        const result = await faceAuth.authenticate();

        if (result.isAuthenticated) {
          alert('Xác thực thành công!');
        } else {
          alert('Xác thực thất bại, vui lòng thử lại.');
        }
      });
  </script>
</body>
</html>

🧠 API Reference

FaceAuth(options)

Khởi tạo một đối tượng FaceAuth.

const faceAuth = new FaceAuth(options);

Tham số options (Object, optional):

  • detectionConfidence (number)
    Ngưỡng tin cậy khi phát hiện khuôn mặt (0 → 1, ví dụ 0.8).

  • maxFaces (number)
    Số lượng khuôn mặt tối đa cần xử lý (thường là 1 cho xác thực người dùng).

Ví dụ:

const faceAuth = new FaceAuth({
  detectionConfidence: 0.85,
  maxFaces: 1
});

await faceAuth.init()

Khởi tạo model, camera và các tài nguyên cần thiết.
Bắt buộc phải gọi trước khi authenticate().

await faceAuth.init();

Trả về:
Promise<void>


const result = await faceAuth.authenticate()

Thực hiện quy trình xác thực khuôn mặt:

  1. Mở camera.
  2. Phát hiện khuôn mặt.
  3. Kiểm tra vị trí, điều kiện.
  4. Trả về kết quả xác thực.
const result = await faceAuth.authenticate();

if (result.isAuthenticated) {
  console.log('Xác thực thành công!');
} else {
  console.log('Xác thực thất bại!', result.reason);
}

Trả về:

type FaceAuthResult = {
  isAuthenticated: boolean; // true nếu xác thực thành công
  // Có thể mở rộng thêm:
  // imageBlob?: Blob;    // ảnh khuôn mặt đã chụp
  // reason?: string;     // lý do thất bại (nếu có)
};

✅ Tóm tắt

  • Hỗ trợ:
    • CDN (nhúng trực tiếp vào HTML)
    • NPM (dùng trong các project build bằng bundler)
  • API đơn giản:
    • new FaceAuth(options)
    • await faceAuth.init()
    • await faceAuth.authenticate()
  • Tối ưu cho:
    • Xác thực người dùng (KYC)
    • Check-in, chấm công
    • Kiosk, hệ thống doanh nghiệp