regulaforensics / facesdk-web-js-client Goto Github PK
View Code? Open in Web Editor NEWRegula Face SDK web API js client for the browser and node.js based on axios
Home Page: https://regulaforensics.com
Regula Face SDK web API js client for the browser and node.js based on axios
Home Page: https://regulaforensics.com
I'm using @regulaforensics/facesdk-webclient module in the nestJS application.
Recently I faced a compile-time issue in my dependency.
Version used - "@regulaforensics/facesdk-webclient": "^5.1.1",
Command - npm run build
Expected - It should be successfully executed
Actual - node_modules/@regulaforensics/facesdk-webclient/src/ext/person-api.ts:14:13 - error TS2532: Object is possibly 'undefined'.
14 if (imageFields.image.content && typeof imageFields.image.content !== "string") {
~~~~~~~~~~~~~~~~~
node_modules/@regulaforensics/facesdk-webclient/src/ext/person-api.ts:14:49 - error TS2532: Object is possibly 'undefined'.
14 if (imageFields.image.content && typeof imageFields.image.content !== "string") {
~~~~~~~~~~~~~~~~~
node_modules/@regulaforensics/facesdk-webclient/src/ext/person-api.ts:15:13 - error TS2532: Object is possibly 'undefined'.
15 imageFields.image.content = converter.encode(imageFields.image.content)
~~~~~~~~~~~~~~~~~
node_modules/@regulaforensics/facesdk-webclient/src/ext/person-api.ts:15:58 - error TS2532: Object is possibly 'undefined'.
15 imageFields.image.content = converter.encode(imageFields.image.content)
~~~~~~~~~~~~~~~~~
node_modules/@regulaforensics/facesdk-webclient/src/ext/search-api.ts:9:13 - error TS2532: Object is possibly 'undefined'.
9 if (searchRequest.image.content && typeof searchRequest.image.content !== "string") {
~~~~~~~~~~~~~~~~~~~
node_modules/@regulaforensics/facesdk-webclient/src/ext/search-api.ts:9:51 - error TS2532: Object is possibly 'undefined'.
9 if (searchRequest.image.content && typeof searchRequest.image.content !== "string") {
~~~~~~~~~~~~~~~~~~~
node_modules/@regulaforensics/facesdk-webclient/src/ext/search-api.ts:10:13 - error TS2532: Object is possibly 'undefined'.
10 searchRequest.image.content = converter.encode(searchRequest.image.content)
~~~~~~~~~~~~~~~~~~~
node_modules/@regulaforensics/facesdk-webclient/src/ext/search-api.ts:10:60 - error TS2532: Object is possibly 'undefined'.
10 searchRequest.image.content = converter.encode(searchRequest.image.content)
~~~~~~~~~~~~~~~~~~~
Found 8 error(s).
When I skip NullChecks in my tsconfig.json it works. But it should not be needed for this library.
There doesn't seem to be any example to perform a liveness check using an uploaded image. I also looked through the code and couldn't find any reference either.
(node:2325) UnhandledPromiseRejectionWarning: Error: Request failed with status code 404
at createError (/mnt/d/OCR/Regula/FaceSDK-web-js-client-master/node_modules/axios/lib/core/createError.js:16:15)
at settle (/mnt/d/OCR/Regula/FaceSDK-web-js-client-master/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/mnt/d/OCR/Regula/FaceSDK-web-js-client-master/node_modules/axios/lib/adapters/http.js:260:11)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (_stream_readable.js:1327:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
(Use node --trace-warnings ...
to show where the warning was created)
(node:2325) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:2325) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
cjs
, but with esm
it works just fine!const { FaceSdk } = require("@regulaforensics/facesdk-webclient");
async function match() {
try {
const sdk = new FaceSdk({ basePath: process.env.REGULA_FACE_API_BASE_URL });
const face1 = fs.readFileSync("face1.jpg").buffer;
const face2 = fs.readFileSync("face2.jpg").buffer;
const response = await sdk.matchingApi.match({
images: [{ data: face1 }, { data: face2 }]
});
console.log(response);
} catch (error) {
console.log(error);
}
}
TypeError: Cannot read property 'encode' of undefined
at MatchingApi.match (/home/node/app/node_modules/@regulaforensics/facesdk-webclient/dist/cjs-es5/ext/matching-api.js:33:59)
It works with this change!!
filename: node_modules/@regulaforensics/facesdk-webclient/dist/cjs-es5/ext/matching-api.js
line: 33
- image.data = base64_arraybuffer_1.default.encode(image.data);
+ image.data = base64_arraybuffer_1.encode(image.data);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.