smartcomply-web-sdk 1.0.77 → 1.0.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4531,35 +4531,69 @@ var SmartComplySDK = (() => {
4531
4531
  }, nh.POSE_CONNECTIONS = Dc;
4532
4532
 
4533
4533
  // src/camera/FaceDetector.ts
4534
- var WASM_CDN = "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm";
4535
- var MODEL_URL = "https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/latest/face_landmarker.task";
4536
- var _cachedVision = null;
4537
- var _cachedModelBuffer = null;
4534
+ var MEDIAPIPE_VERSION = "0.10.32";
4535
+ var WASM_CDN = `https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@${MEDIAPIPE_VERSION}/wasm`;
4536
+ var MODEL_URL = "https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/1/face_landmarker.task";
4537
+ var _visionPromise = null;
4538
+ var _modelBufferPromise = null;
4539
+ var INIT_TIMEOUT_MS = 2e4;
4540
+ function withTimeout(promise, ms2, label) {
4541
+ return new Promise((resolve, reject) => {
4542
+ const timer = setTimeout(
4543
+ () => reject(new Error(`${label} timed out. Please check your connection and try again.`)),
4544
+ ms2
4545
+ );
4546
+ promise.then(
4547
+ (value) => {
4548
+ clearTimeout(timer);
4549
+ resolve(value);
4550
+ },
4551
+ (err) => {
4552
+ clearTimeout(timer);
4553
+ reject(err);
4554
+ }
4555
+ );
4556
+ });
4557
+ }
4538
4558
  var FaceDetectorEngine = class {
4539
4559
  constructor() {
4540
4560
  this.landmarker = null;
4541
4561
  }
4542
4562
  async init() {
4543
- if (!_cachedVision) {
4544
- _cachedVision = await na.forVisionTasks(WASM_CDN);
4563
+ if (!_visionPromise) {
4564
+ _visionPromise = na.forVisionTasks(WASM_CDN);
4565
+ _visionPromise.catch(() => {
4566
+ _visionPromise = null;
4567
+ });
4545
4568
  }
4546
- if (!_cachedModelBuffer) {
4547
- const res = await fetch(MODEL_URL);
4548
- if (!res.ok) {
4549
- throw new Error(`Failed to download face model (${res.status})`);
4550
- }
4551
- _cachedModelBuffer = await res.arrayBuffer();
4569
+ if (!_modelBufferPromise) {
4570
+ _modelBufferPromise = fetch(MODEL_URL).then((res) => {
4571
+ if (!res.ok) throw new Error(`Failed to download face model (${res.status})`);
4572
+ return res.arrayBuffer();
4573
+ });
4574
+ _modelBufferPromise.catch(() => {
4575
+ _modelBufferPromise = null;
4576
+ });
4552
4577
  }
4553
- this.landmarker = await Ic.createFromOptions(_cachedVision, {
4554
- baseOptions: {
4555
- // Pass a copy — MediaPipe takes ownership of the buffer
4556
- modelAssetBuffer: new Uint8Array(_cachedModelBuffer.slice(0))
4557
- },
4558
- runningMode: "VIDEO",
4559
- outputFaceBlendshapes: true,
4560
- outputFacialTransformationMatrixes: true,
4561
- numFaces: 1
4562
- });
4578
+ const [vision, modelBuffer] = await withTimeout(
4579
+ Promise.all([_visionPromise, _modelBufferPromise]),
4580
+ INIT_TIMEOUT_MS,
4581
+ "Face detection setup"
4582
+ );
4583
+ this.landmarker = await withTimeout(
4584
+ Ic.createFromOptions(vision, {
4585
+ baseOptions: {
4586
+ // Pass a copy — MediaPipe takes ownership of the buffer
4587
+ modelAssetBuffer: new Uint8Array(modelBuffer.slice(0))
4588
+ },
4589
+ runningMode: "VIDEO",
4590
+ outputFaceBlendshapes: true,
4591
+ outputFacialTransformationMatrixes: true,
4592
+ numFaces: 1
4593
+ }),
4594
+ INIT_TIMEOUT_MS,
4595
+ "Face detection setup"
4596
+ );
4563
4597
  }
4564
4598
  detect(video, timestamp) {
4565
4599
  if (!this.landmarker) {
@@ -5362,6 +5396,9 @@ var SmartComplySDK = (() => {
5362
5396
  interrupted.catch(() => {
5363
5397
  });
5364
5398
  try {
5399
+ const faceInitPromise = faceEngine.init();
5400
+ faceInitPromise.catch(() => {
5401
+ });
5365
5402
  let stream;
5366
5403
  if (params.prewarmedStream && params.prewarmedStream.active) {
5367
5404
  stream = params.prewarmedStream;
@@ -5387,7 +5424,7 @@ var SmartComplySDK = (() => {
5387
5424
  tempVideo.style.cssText = "width:100%;border-radius:12px;transform:scaleX(-1);";
5388
5425
  container.appendChild(tempVideo);
5389
5426
  }
5390
- await faceEngine.init();
5427
+ await faceInitPromise;
5391
5428
  ui2.updateInstruction("Fit your face inside the oval outline");
5392
5429
  const videoForDetection = uiVideo || tempVideo;
5393
5430
  await new Promise((resolve) => {
@@ -6984,7 +7021,12 @@ var SmartComplySDK = (() => {
6984
7021
  "failed after all retries",
6985
7022
  "camera access is not supported",
6986
7023
  "camera access failed",
6987
- "recording failed unexpectedly"
7024
+ "recording failed unexpectedly",
7025
+ // FaceDetectorEngine.init() failures (FaceDetector.ts) — a slow/blocked
7026
+ // CDN or model download is a connectivity issue, not a failed face scan,
7027
+ // and must not burn one of the user's limited liveness retry attempts.
7028
+ "face detection setup timed out",
7029
+ "failed to download face model"
6988
7030
  ];
6989
7031
  function _isInfrastructureError(err) {
6990
7032
  const msg = String(err?.message || "").toLowerCase();