2.0.5-alpha • Published 2 years ago

@privateid/privid-fhe-modules v2.0.5-alpha

Weekly downloads
-
License
See AWS EULA Temp...
Repository
github
Last release
2 years ago

Powered by Private Identity® https://private.id

BENEFITS

BUILD

Prerequisite

Sign up on the waitlist on https://private.id to obtain your apiKey.

Installation

npm install @privateid/privid-fhe-modules

Copy the necessary dependencies to the public folder of your app

"prestart": "cp -R ./node_modules/@privateid/privid-fhe-modules/wasm public/&& cp -R ./node_modules/@privateid/privid-fhe-modules/workers public/",
"prebuild": "cp -R ./node_modules/@privateid/privid-fhe-modules/wasm public/ && cp -R ./node_modules/@privateid/privid-fhe-modules/workers public/"

Add the necessary environment variables on the .env file in the root of your project

SKIP_PREFLIGHT_CHECK=true
REACT_APP_API_URL= 
REACT_APP_API_KEY=
REACT_APP_WASM_MODULE= face_mask | face | voice

Load the WASM Module

The first step is to load and initialize the wasm module and clear the content of the local database.

import { loadPrivIdModule, clearDB } from '@privateid/privid-fhe-modules';

await loadPrivIdModule();
clearDB();

Open or switch camera

The first step is to load and initialize the wasm module.

Open the camera

To open user camera use the openCamera function with element id of the video tag in the DOM

import { openCamera } from '@privateid/privid-fhe-modules';

const { devices, faceMode } = await openCamera(element);

it returns list of the available video devices.

Switch to another camera

To switch to another media device use the switchCamera function with the ID of the device to be used

import { switchCamera } from '@privateid/privid-fhe-modules';

switchCamera(deviceID);

for the mobile phone we can select whether it's front or back camera for this we pass 'front' or 'back' to the switch function

import { switchCamera } from '@privateid/privid-fhe-modules';

switchCamera('front');

isValid

Live demo: https://age.devel.private.id

isValid only exercises the is_valid() call and does not find identity. The function detects if there is a valid face in the camera view or in an ImageData Array.

isValid accepts two parameters.

  • action: false for prediction (less restrictive), and true for enrollment (more restrictive). We recommend using false as your default.
  • ImageData: array of an image data to perform the face captcha on (optional)
import { isValid  } from '@privateid/privid-fhe-modules';

const {result, imageData} = isValid (false);

Face CAPTCHA returns 17 possible coded results, as follows.

PropertyDescription
-1No Face
0Valid Biometric
1Image Spoof
2Video Spoof
3Too close
4Too far away
5Too far to right
6Too far to left
7Too far up
8Too far down
9Too blurry
10Glasses on
11Mask on
12Chin too far left
13Chin too far right
14Chin too far up
15Chin too far down

Enroll or predict

Perform a new enrollment (register a new user) or predict (authenticate a user) using the enrollPredict function

import { enrollPredict } from '@privateid/privid-fhe-modules';

enrollPredict('userVideo', false, callback)

The function takes 3 parameters

PropertyDescription
videoRefVideo tag
actionTrue (enroll) / false (predict)
callbackThe callback to be executed on each status

Callback

The enrollPredict function provides 5 status updates to allow the developer to take action at different steps of the identification process.

StatusDescription
VALID_FACEA face is detected
INVALID_FACEA valid face is not detected
ENROLLINGEnrollment (registration) starts of a valid face
PREDICTINGPrediction (authentication) starts of a valid face
WASM_RESPONSEThe prediction or enrollment process is complete

Continuous enroll predict

Live demo: https://c.priv.id

Perform continuous user enrollment or prediction (registration or authentication) using the continuousEnrollPredict function. This provides the same status updates as Enroll or Predict.

import { continuousEnrollPredict } from '@privateid/privid-fhe-modules';

continuousEnrollPredict(false, callback)

The continousEnrollPredict function takes 2 parameters

PropertyDescription
actionTrue (enroll) / false (predict)
callbackThe callback to be executed on each status

isValidPhotoID (coming soon)

This function finds, crops, align and validate, front and back of the photoID, and returns back a valid cropped and aligned image of the photoID

The isValidPhotoID function takes 3 parameters

PropertyDescription
docTypeit can be either PHOTO_ID_BACK (back of the photo ID) or PHOTO_ID_FRONT (front of the photo ID)
callbackreturns the uuid of the portrait on the Front of the Photo ID

The function returns

result: status of the validation of the document

StatusDescription
0valid document
1

href: aligned and cropped image of the document returned in case of valid document confScore: confidence score indicates if the image contains the 4 corners of the document, without fingers or objects hidding the document, it goes from 0 to 1.

Licensing Restriction: This product is not licensed for use in regulated gaming. To license in this market, please contact CentralAMS.