Gathering detailed insights and metrics for @privateid/small-age-sdk
Gathering detailed insights and metrics for @privateid/small-age-sdk
Gathering detailed insights and metrics for @privateid/small-age-sdk
Gathering detailed insights and metrics for @privateid/small-age-sdk
npm install @privateid/small-age-sdk
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Powered by Private Identity®
https://private.id
Age SDK Lite Implementation is an npm package that uses the W3C WebAssembly to perform 1:N fully homomorphically encrypted (FHE) face recognition.
Please update code accordingly because it might cause issue.
Sign up on the waitlist on https://private.id to obtain your apiKey.
Installation
1npm install @privateid/cryptonets-web-sdk
Copy the necessary dependencies to the public folder of your app
1"prestart": "cp -R ./node_modules/@privateid/cryptonets-web-sdk/wasm public/&& cp -R ./node_modules/@privateid/cryptonets-web-sdk/workers public/", 2"prebuild": "cp -R ./node_modules/@privateid/cryptonets-web-sdk/wasm public/ && cp -R ./node_modules/@privateid/cryptonets-web-sdk/workers public/"
Add the necessary environment variables on the .env file in the root of your project
1SKIP_PREFLIGHT_CHECK=true 2REACT_APP_API_URL= 3REACT_APP_API_KEY= 4REACT_APP_WASM_MODULE= face_mask | face | voice
Optional environment variable
1REACT_APP_API_ORCHESTRATION= 2REACT_APP_SET_CACHE= true | false (Used for predict caching)
The first step is to load and initialize the wasm module and clear the content of the local database.
1import { loadPrivIdModule, clearDB } from '@privateid/cryptonets-web-sdk'; 2 3const isSupported = await loadPrivIdModule(); 4clearDB();
In case of .env file (evironment variable) does not work for you we have added a support to set the variables on load.
1import { loadPrivIdModule } from '@privateid/cryptonets-web-sdk'; 2 3const isSupported =await loadPrivIdModule( 4 api_url, 5 api_key, 6 api_orchestration_url, 7 wasm_url, 8 wasm_module, 9);
Status | Description |
---|---|
api_url | Equivalent to env variable REACT_APP_API_URL |
api_key | Equivalent to env variable REACT_APP_API_KEY |
api_orchestration_url | Equivalent to env variable REACT_APP_API_ORCHESTRATION_URL |
wasm_url | Please set it the same with api_url or REACT_APP_API_URL |
wasm_module | face_mask , face , voice |
The loadPrivIdModule() function returns an object to check if the device is supporting WASM and WebRTC.
1{ 2 support: boolean, 3 message: string, 4}
The first step is to load and initialize the wasm module.
To open user camera use the openCamera function with element id of the video tag in the DOM
1import { openCamera } from '@privateid/cryptonets-web-sdk'; 2 3const { devices, faceMode } = await openCamera(element);
it returns list of the available video devices.
To switch to another media device use the switchCamera function with the ID of the device to be used
1import { switchCamera } from '@privateid/cryptonets-web-sdk'; 2 3switchCamera(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
1import { switchCamera } from '@privateid/cryptonets-web-sdk'; 2 3switchCamera('front');
To close user camera use the closeCamera function with element id of the video tag in the DOM.
1import { closeCamera } from '@privateid/cryptonets-web-sdk'; 2 3closeCamera(element); // Will specifically look for the element id and will close that camera 4closeCamera(); // By default will close opened camera using openCamera
Perform an age estimation using predictAge
function on all detected faces from image or camera.
1import { predictAge } from '@privateid/cryptonets-web-sdk'; 2 3await predictAge(null, predictAgeCallback); 4
The function takes 3 parameters
Property | Description |
---|---|
imageData | If this parameter is provided it will check age of the imageData instead of opened camera. |
callback | The callback function to handle predictAge results. |
Callback
Here are sample returned data to callback from predictAge :
1{ 2 "status": "WASM_RESPONSE", 3 "returnValue": { 4 "error": 0, 5 "faces": [ 6 { 7 "status": 0, 8 "age": 16.912670135498047, 9 "box": { 10 "top_left": { 11 "x": 486, 12 "y": 371 13 }, 14 "bottom_right": { 15 "x": 652, 16 "y": 545 17 } 18 } 19 }, 20 ] 21 } 22}
No vulnerabilities found.
No security vulnerabilities found.