regulaforensics / FaceSDK-web-js-client

Regula Face SDK web API js client for the browser and node.js based on axios
https://regulaforensics.com
5 stars 3 forks source link

cjs FaceSdk cannot read property 'encode' of undefined #21

Closed oxidia closed 2 years ago

oxidia commented 2 years ago

Expected behavior

Current behavior

NB

Code sample

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);
  }
}

Stack trace

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)

Trying to figure out the issue

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);
ivan-gil commented 2 years ago

https://github.com/regulaforensics/FaceSDK-web-js-client/pull/28 fixed in scope of this PR with your changes