@biopassid/face-sdk

中文文档
1.3.46发布于 2025/12/19ISCTypeScriptESM + CJS近 30 天下载 2048


BioPass ID

原始使用文档
文档目录11 节
  1. Key Features
  2. Customizations
  3. Demo
  4. First Steps
  5. Installing
  6. How To Use
  7. Example
  8. Options
  9. Changelog
  10. 1.3.46
  11. Breaking Changes


BioPass ID

BioPass ID Face SDK JavaScript.

npm version

Key Features • Customizations • Demo • First Steps • Installing • How To Use • Example • Support

Key Features

  • Face Detection
    • We ensure that there will be only one face in the capture
  • Face Positioning
    • Ensure face position in your capture for better enroll and match.
  • Auto Capture
    • When a face is detected the capture will be performed in how many seconds you configure.
  • Resolution Control
    • Configure the image size thinking about the tradeoff between image quality and API's response time.
  • Aspect Ratio Control
  • Fully customizable interface

Customizations

Increase the security of your applications without harming your user experience.

All customization available:

  • Title Text
  • Help Text
  • Loading Text
  • Font Family
  • Face Frame
  • Overlay
  • Default Camera
  • Capture button

Enable or disable components:

  • Tittle text
  • Help Text
  • Capture button
  • Button icons
  • Flip Camera button
  • Flash button

Change all colors:

  • Overlay color and opacity
  • Capture button color
  • Capture button text color
  • Flip Camera color
  • Flash Button color
  • Text colors

Demo

Explore our features that make your apps do more.

Web Demo - of BioPass ID Face SDK JavaScript and API'S

First Steps

First create a folder called models in your application's static files directory. Donwload and add this two files

tiny_face_detector_model-shard1

tiny_face_detector_model-weights_manifest

Your folder structure will look like this:

/assets
/js
/css
/models
    - tiny_face_detector_model-shard1
    - tiny_face_detector_model-weights_manifest.json
/index.html

Installing

Through bundler

Install the dependency:

npm i --save @biopassid/face-sdk

Use in your project:

import { camera } from '@biopassid/face-sdk'

Through CDN

Add the script to the project and the modules will be injected inside an object called faceSdk:

<script src="https://cdn.jsdelivr.net/npm/@biopassid/face-sdk/face-sdk.min.js"></script>
<script>
        const {takePicture} = faceSdk.camera();
        async function handleTakePicture() {
            const resp = await takePicture({
                element: document.querySelector("#elementId"),
            })
        }
        handleTakePicture();


</script>

How To Use

Basic usage

import { camera } from '@biopassid/face-sdk'
<script>
        const {takePicture} = camera();
        async function handleTakePicture() {
            const resp = await takePicture({
                element: document.querySelector("#elementId"),
            })
        }
        handleTakePicture();
</script>

Adding Face Validation

The takePicture function has an argument called "faceDetectionAdapter", which is a function responsible for performing the validation processing, the FaceSDK has a standard adapter for face detection. It is also necessary to run the function responsible for loading the models

import { camera, faceDetectionAdapter, loadFaceDetectorModels } from '@biopassid/face-sdk'

const { takePicture } = camera();

async function handleTakePicture() {
    await loadFaceDetectorModels(); // Carregamento dos modelos

    const resp = await takePicture({
        element: document.querySelector("#elementId"),
        faceDetectionAdapter: faceDetectionAdapter,
    })
}

Adding Auto Capture

To add automatic capture, simply activate the functionality within the options parameter.

import { camera, faceDetectionAdapter, loadFaceDetectorModels } from '@biopassid/face-sdk'

const { takePicture } = camera();

async function handleTakePicture() {
    await loadFaceDetectorModels();

    const resp = await takePicture({
        element: document.querySelector("#elementId"),
        faceDetectionAdapter: faceDetectionAdapter,
        options: {
            faceDetection: {
                autoCapture: true
            }
        },
    })
}

Internationalization

It is possible to define the texts displayed during face detection through parameter i18n.

import { camera, faceDetectionAdapter } from '@biopassid/face-sdk'

const { takePicture } = camera();

async function handleTakePicture() {
    const resp = await takePicture({
        element: document.querySelector("#elementId"),
        faceDetectionAdapter: faceDetectionAdapter,
        i18n: {
            noFacesDetected: "Nenhuma face detectada",
            multipleFacesDetected: "Multiplas faces detectadas",
            moveFaceLeft: "Mova o rosto para a esquerda",
            moveFaceRight: "Mova o rosto para a direita",
            moveFaceUp: "Mova o rosto para cima",
            moveFaceDown: "Mova o rosto para baixo",
            moveFaceBack: "Mova o rosto para trás",
            moveFaceCloser:: "Mova o rosto para frente"
            keepStill: "Mantenha o rosto parado",
        },
        options: {
            faceDetection: {
                autoCapture: true
            }
        },
    })
}

Example

Example with all properties

All elements are optional

const resp = await takePicture({
  element: document.querySelector("#camera"),
  options: {
    mask: {
      enabled: true,
      type: "face",
      backgroundColor: "black",
      backgroundOpacity: 0.6,
      frameColor: "white",
      frameThickness: 3,
    },
    backButton: {
      enabled: true,
      size: "30px",
      backgroundColor: "transparent",
      label: {
        enabled: false,
        content: "",
        fontSize: "1rem",
        fontWeight: "normal",
        color: "white",
      },
      icon: {
        enabled: true,
        source: null,
        color: "white",
        size: "30px",
      },
      padding: "0",
    },
    captureButton: {
      enabled: true,
      size: "30px",
      backgroundColor: "white",
      label: {
        enabled: false,
        content: "",
        fontSize: "1rem",
        fontWeight: "normal",
        color: "black",
      },
      icon: {
        enabled: true,
        source: null,
        color: "black",
        size: "30px",
      },
      padding: string,
    },
    cancelButton: {
      enabled: true,
      size: "30px",
      backgroundColor: "red",
      label: {
        enabled: false,
        content: "",
        fontSize: "1rem",
        fontWeight: "normal",
        color: "white",
      },
      icon: {
        enabled: true,
        source: null,
        color: "white",
        size: "30px",
      },
      padding: "0",
    },
    confirmButton: {
      enabled: true,
      size: "30px",
      backgroundColor: "white",
      label: {
        enabled: false,
        content: "",
        fontSize: "1rem",
        fontWeight: "normal",
        color: "black",
      },
      icon: {
        enabled: true,
        source: null,
        color: "black",
        size: "30px",
      },
      padding: string,
    },
    legend: {
      title: {
        enabled: true,
        content: "Captura Facial",
        fontSize: "1.5rem",
        fontWeight: "600",
        color: "white",
      },
      subtitle: {
        enabled: true,
        content: "",
        fontSize: "1rem",
        fontWeight: "normal",
        color: "white",
      },
    },
    faceDetection: {
      enabled: true,
      autoCapture: false,
      timeToCapture: 3000,
      timeToCaptureFeedbackColor: "#FF0000",
      multipleFacesEnabled: true,
      scoreThreshold: 0.1,
    },
    width: "100%",
    height: "100%",
    modelsDirectory: "/models",
    cameraPresets: {
      aspectRatio: 16 / 9,
      preferredResolution: 480,
      deviceId: null,
      facingMode: "environment",
    },
    fontFamily: "inherit",
    formatImage: "image/jpeg",
  },
});

Options

To know more about all SDK options and methods you can visit our complete documentation

Documentation

Changelog

1.3.46

Breaking Changes

  • When using the plugin via CDN, the functions are stored in an object named faceSdk.
<!-- After -->
<script src="https://cdn.jsdelivr.net/npm/@biopassid/face-sdk/face-sdk.min.js"></script>
<script>
  const { takePicture } = faceSdk.camera();
</script>

<!-- Before -->
<script src="https://cdn.jsdelivr.net/npm/@biopassid/face-sdk/face-sdk.min.js"></script>
<script>
  const { takePicture } = camera();
</script>

版本与发布记录

@biopassid/face-sdk 共发布 78 个版本,首次发布于 2022/04/02;过去 12 个月发布了 3 个版本。

版本发布日期距今
1.3.46latest2025/12/1910 个月前
1.3.46-beta.2test2025/11/2511 个月前
1.3.46-beta.1beta2025/11/1411 个月前
1.3.46-beta.02025/11/051 年前
1.3.45-beta.02025/11/031 年前
1.3.452025/09/231.1 年前

关于 @biopassid/face-sdk 的常见问题

如何安装 @biopassid/face-sdk?

在项目目录运行 npm install @biopassid/face-sdk,或使用 pnpm add / yarn add / bun add。

@biopassid/face-sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@biopassid/face-sdk 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@biopassid/face-sdk 可以商用吗?

@biopassid/face-sdk 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@biopassid/face-sdk 的下载量有多少?

根据 npm 官方下载统计,@biopassid/face-sdk 在 2026/10/08 – 2026/11/06 这 30 天内被下载 2,048 次,日均约 68 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@biopassid/face-sdk 还在维护吗?

最新版本 1.3.46 发布于 2025/12/19(10 个月前);至今共发布 78 个版本,其中过去 12 个月发布了 3 个;首次发布于 2022/04/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。