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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@wg-npm/face-sdk

v0.3.4-9

Published

## install

Downloads

71

Readme

face-sdk

install

$ npm install @wg-npm/fack-sdk

how to use

import FaceSDK from "@wg-npm/face-sdk";
// 定义传入options
const options = {
  //获取签名的函数,需返回Promise对象
  signHandler: () => {
    return Promise.resolve({
      //调用Face Service后端地址
      serviceUrl: "https://www.baidu.com",

      //分配的AppCode
      appCode: "TC",

      //用户编号
      userNo: "userNo",

      //签名
      signature: "signature",

      //时间戳
      timestamp: 1616039507624,
    });
  },
  //需识别的用户名称
  name: "张三",

  //需识别的用户身份证号
  idCard: "614938471839283941",

  //调用方类型:web, mobile
  sourceType: "web",

  //业务类型:LOGIN, COURSE, ONLINE_VIDEO, GENERAL_ACTIVITY
  targetType: "login",

  //在targetType="course"的情况下需传入课程courseCode, 拍照检测必传
  targetCode: "targetCode",

  //在非登录场景下检测时传入学习活动或课程ID,拍照检测必传
  targetCode: "100001",

  //在非登录场景下检测时传入学习活动或课程名称,拍照检测必传
  targetName: "高等数学",

  //可以自定义传入二维码刷新间隔,单位为毫秒
  interval: 3000,

  //用户工号,拍照检测必传
  userNo: "u00001",

  //学习活动类型,拍照检测必传
  activityType: "",

  //音视频观看进度,拍照检测必传
  businessKey: "",

  //  二维码蒙层显示时的回调函数
  onShowMask: (response) => {},

  /*  调用方自定义人脸检测有效方法
      不传入该函数执行默认方法:
      在sourceType="web"且targetType="course"的情况下,展示下次需要识别的时间,并倒计时;倒计时结束唤醒Face-H5二维码蒙层。
      其余情况均在success回调函数中返回人脸检测有效的结果。
      该方法的response同样为人脸检测有效的结果。
   */
  onCheckSuccess: (response) => {},

  /*  调用方自定义人脸检测失效方法
      不传入该函数执行默认方法:
      在sourceType="web"的情况下,唤醒Face-H5二维码蒙层。
      其余情况均在success回调函数中返回人脸检测失效的结果。
      该方法的response同样为人脸检测失效的结果。
   */
  onCheckFail: (response) => {},

  /*  调用方自定义用户扫描二维码识别成功之后的方法
      可以获取到人脸检测成功的返回数据。
   */
  afterCheckSuccess: (response) => {},

  /*  调用成功时执行的回调函数,response如下:
      Result {
        //SDK接口调用成功标识
        success: true, 
        data: {
          //人脸检测是否有效标识
          status: "SUCCESS"
          //距离下次检测时间间隔,单位为毫秒
          times: 5000
          //face-h5调用地址
          url: "http://api.com"
        }, 
        //提示信息
        message: "success"
      }
   */
  success: (response) => {},

  /*  调用失败时执行的回调函数,response如下:
      Result {
        //SDK接口调用失败标识
        success: false, 
        data: {}, 
        //提示信息
        message: "serviceUrl parameter error"
      }
   */
  fail: (response) => {},

  //调用完成时执行的回调函数,无论成功或失败都会执行
  complete: () => {},
};

//人脸识别接口
FaceSDK.startFaceRecognition(options);

//人脸拍照接口
FaceSDK.startFaceCapture(options);

//success,fail,complete方法支持promise方式使用
FaceSDK.startFaceRecognition(options)
  .then((res) => console.log(res))
  .catch((res) => console.log(res))
  .finally(() => console.log("on finally"));