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

@enface/sdk

v1.1.7

Published

Enface biometric services

Downloads

873

Readme

Enface SDK JS library

This package works both in Node.js and Browser environment. Supported browsers:

  • Chrome
  • Opera
  • FireFox
  • Internet Explorer (Edge)
  • Safari

Installation

NPM

npm i --save @enface/sdk

Yarn

yarn add @enface/sdk

Usage

// ES2015 module import:
import { createEnfaceApi } from "@enface/sdk";

// CommonJS module require:
const { createEnfaceApi } = require("@enface/sdk");

// Initialization:
const enfaceApi = createEnfaceApi({
  apiKey: 'YOUR_API_KEY'
});

Face recognition:

// Request:
const result = await enfaceApi.recognize({
  images: [image]
});

Liveness detection:

// Request:
const result = await enfaceApi.liveness({
  images: [image1, image2, image3]
});

Both face recognition & liveness detection in one request:

// Request:
const result = await enfaceApi.recognizeLiveness({
  images: [image1, image2, image3]
});

Images should be in JPEG format with minimal resolution of 800x600 pixels (1280x720 is recommended for better performance). For liveness and complex requests 3 images are required. They should be taken from a camera with strict time frames - 160-200 milliseconds between each other. Supported images inputs:

  • ArrayBuffer (node.js or browser environment)
  • Uint8Array (node.js or browser environment)
  • Blob (browser environment)
  • File, taken from <input type="file"> (browser environment)

Tests

To completely pass the tests fill the values of the corresponding variables below with your own API keys in "__tests__/api.js".

  • const recognitionApiKey = 'YOUR_RECOGNITION_API_KEY';
  • const livenessApiKey = 'YOUR_LIVENESS_API_KEY';
  • const recognizeLivenessApiKey = 'YOUR_RECOGNIZE_LIVENESS_API_KEY';
// Running the tests
npm test

Browser usage

Get the minified "enface.web.js" script from "dist/" folder and link to your web page. Enface library constructor will become available in the global scope:

<script src="set_correct_path/enface.web.js"></script>
<script>

  const enfaceApi = createEnfaceApi({
    apiKey: 'YOUR_API_KEY'
  });

  enfaceApi.recognize({ images: [image] }).then(function(result){
    console.log(result);
  });

</script>

Enface REST API

Enface supports 2 types of API requests - GraphQL & REST. Full GraphQL documentstion can be found here: http://docs.enface.io. REST API accepts data in multipart/form-data format with following fields:

  • apiKey
  • array of images in binary form

JavaScript examples:

Face recognition:

  const formData  = new FormData();
  formData.append('apiKey', 'YOUR_RECOGNITION_API_KEY');
  formData.append('image', image, `image1.jpg`);
  const result = await fetch('https://enface-api-server.herokuapp.com/rest/recognize', {
    method: 'post',
    body: formData,
  });

Liveness detection:

  const formData  = new FormData();
  formData.append('apiKey', 'YOUR_LIVENESS_API_KEY');
  images.forEach((image, index) => formData.append('image', image, `${index}.jpg`));
  const result = await fetch('https://enface-api-server.herokuapp.com/rest/liveness', {
    method: 'post',
    body: formData,
  });

Both face recognition & liveness detection in one request:

  const formData  = new FormData();
  formData.append('apiKey', 'YOUR_RECOGNITION_LIVENESS_API_KEY');
  images.forEach((image, index) => formData.append('image', image, `${index}.jpg`));
  const result = await fetch('https://enface-api-server.herokuapp.com/rest/recognizeLiveness', {
    method: 'post',
    body: formData,
  });

Raw REST API post request with header:

POST https://enface-api-server.herokuapp.com/rest/recognizeLiveness HTTP/1.1
Host: enface-api-server.herokuapp.com
Content-Type: multipart/form-data; boundary=----------------------------794180515515914733140144

----------------------------794180515515914733140144
Content-Disposition: form-data; name="apiKey"
9e9d58b2-d0c9-4465-a4a0-c96db3ebc3b4

----------------------------794180515515914733140144
Content-Disposition: form-data; name="image";
filename="0.jpg"
Content-Type: image/jpeg

binary image1
----------------------------794180515515914733140144
Content-Disposition: form-data; name="image";
filename="1.jpg"
Content-Type: image/jpeg

binary image2
----------------------------794180515515914733140144
Content-Disposition: form-data; name="image";
filename="2.jpg"
Content-Type: image/jpeg

binary image3