idmission-web-sdk 2.2.147 → 2.2.149

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.
@@ -211,7 +211,7 @@
211
211
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
212
212
  };
213
213
 
214
- var webSdkVersion = '2.2.147';
214
+ var webSdkVersion = '2.2.149';
215
215
 
216
216
  function getPlatform() {
217
217
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -8175,18 +8175,22 @@
8175
8175
  if (checkEveryMs === void 0) {
8176
8176
  checkEveryMs = 100;
8177
8177
  }
8178
- return new Promise(function (resolve) {
8178
+ var cancelled = false;
8179
+ var promise = new Promise(function (resolve) {
8179
8180
  var _a, _b, _c;
8180
8181
  if (((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.readyState) !== null && _b !== void 0 ? _b : 0) >= 2) return resolve();
8181
8182
  (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.load();
8182
8183
  var interval = setInterval(function () {
8183
8184
  var _a, _b;
8184
- if (((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.readyState) !== null && _b !== void 0 ? _b : 0) >= 2) {
8185
+ if (((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.readyState) !== null && _b !== void 0 ? _b : 0) >= 2 || cancelled) {
8185
8186
  clearInterval(interval);
8186
8187
  resolve();
8187
8188
  }
8188
8189
  }, checkEveryMs);
8189
8190
  });
8191
+ return [promise, function () {
8192
+ cancelled = true;
8193
+ }];
8190
8194
  }
8191
8195
  function calculateIoU(boxA, boxB) {
8192
8196
  var xA = Math.max(boxA.xMin, boxB.xMin);
@@ -8311,17 +8315,26 @@
8311
8315
  var modelLoadTimeout = setTimeout(function () {
8312
8316
  setModelError(new Error('Model loading time limit exceeded.'));
8313
8317
  }, modelLoadTimeoutMs);
8318
+ var cancelVideoReady = function cancelVideoReady() {};
8314
8319
  loadFocusModel(modelPath).then(function (loadedModel) {
8315
8320
  return __awaiter(_this, void 0, void 0, function () {
8316
- return __generator(this, function (_a) {
8317
- switch (_a.label) {
8321
+ var _a, videoReady, cancel, cancelled;
8322
+ return __generator(this, function (_b) {
8323
+ switch (_b.label) {
8318
8324
  case 0:
8319
8325
  setModelDownloadProgress(100);
8320
8326
  clearTimeout(modelLoadTimeout);
8321
- return [4 /*yield*/, waitForVideoReady(videoRef)];
8327
+ _a = waitForVideoReady(videoRef), videoReady = _a[0], cancel = _a[1];
8328
+ cancelled = false;
8329
+ cancelVideoReady = function cancelVideoReady() {
8330
+ cancelled = true;
8331
+ cancel();
8332
+ };
8333
+ return [4 /*yield*/, videoReady];
8322
8334
  case 1:
8323
- _a.sent();
8335
+ _b.sent();
8324
8336
  setTimeout(function () {
8337
+ if (cancelled) return;
8325
8338
  loadedModel.classifyForVideo(videoRef.current, performance.now());
8326
8339
  setReady(true);
8327
8340
  }, 500);
@@ -8336,6 +8349,7 @@
8336
8349
  });
8337
8350
  return function () {
8338
8351
  log('unloading focus model');
8352
+ cancelVideoReady();
8339
8353
  closeFocusModel();
8340
8354
  clearTimeout(modelLoadTimeout);
8341
8355
  document.removeEventListener('idmission.preloadProgress.focus', handleDownloadProgress);
@@ -8459,16 +8473,25 @@
8459
8473
  setModelDownloadProgress(progressToPercentage(event.detail));
8460
8474
  }
8461
8475
  document.addEventListener('idmission.preloadProgress.faceDetection', handleDownloadProgress);
8476
+ var cancelVideoReady = function cancelVideoReady() {};
8462
8477
  loadFaceDetector().then(function (model) {
8463
8478
  return __awaiter(_this, void 0, void 0, function () {
8464
- return __generator(this, function (_a) {
8465
- switch (_a.label) {
8479
+ var _a, videoReady, cancel, cancelled;
8480
+ return __generator(this, function (_b) {
8481
+ switch (_b.label) {
8466
8482
  case 0:
8467
8483
  setModelDownloadProgress(100);
8468
8484
  clearTimeout(modelLoadTimeout);
8469
- return [4 /*yield*/, waitForVideoReady(videoRef)];
8485
+ _a = waitForVideoReady(videoRef), videoReady = _a[0], cancel = _a[1];
8486
+ cancelled = false;
8487
+ cancelVideoReady = function cancelVideoReady() {
8488
+ cancelled = true;
8489
+ cancel();
8490
+ };
8491
+ return [4 /*yield*/, videoReady];
8470
8492
  case 1:
8471
- _a.sent();
8493
+ _b.sent();
8494
+ if (cancelled) return [2 /*return*/];
8472
8495
  model.detectForVideo(videoRef.current, performance.now());
8473
8496
  setReady(true);
8474
8497
  return [2 /*return*/];
@@ -8482,6 +8505,7 @@
8482
8505
  });
8483
8506
  return function () {
8484
8507
  log('unloading face detection model');
8508
+ cancelVideoReady();
8485
8509
  closeFaceDetector();
8486
8510
  clearTimeout(modelLoadTimeout);
8487
8511
  document.removeEventListener('idmission.preloadProgress.faceDetection', handleDownloadProgress);
@@ -8956,17 +8980,26 @@
8956
8980
  var modelLoadTimeout = setTimeout(function () {
8957
8981
  setModelError(new Error('Model loading time limit exceeded.'));
8958
8982
  }, modelLoadTimeoutMs);
8983
+ var cancelVideoReady = function cancelVideoReady() {};
8959
8984
  loadDocumentDetector(modelPath, scoreThreshold).then(function (model) {
8960
8985
  return __awaiter(_this, void 0, void 0, function () {
8961
- return __generator(this, function (_a) {
8962
- switch (_a.label) {
8986
+ var _a, videoReady, cancel, cancelled;
8987
+ return __generator(this, function (_b) {
8988
+ switch (_b.label) {
8963
8989
  case 0:
8964
8990
  setModelDownloadProgress(100);
8965
8991
  clearTimeout(modelLoadTimeout);
8966
- return [4 /*yield*/, waitForVideoReady(videoRef)];
8992
+ _a = waitForVideoReady(videoRef), videoReady = _a[0], cancel = _a[1];
8993
+ cancelled = false;
8994
+ cancelVideoReady = function cancelVideoReady() {
8995
+ cancelled = true;
8996
+ cancel();
8997
+ };
8998
+ return [4 /*yield*/, videoReady];
8967
8999
  case 1:
8968
- _a.sent();
9000
+ _b.sent();
8969
9001
  setTimeout(function () {
9002
+ if (cancelled) return;
8970
9003
  model.detectForVideo(videoRef.current, performance.now());
8971
9004
  setReady(true);
8972
9005
  }, 500);
@@ -8981,6 +9014,7 @@
8981
9014
  });
8982
9015
  return function () {
8983
9016
  log('unloading document detection model');
9017
+ cancelVideoReady();
8984
9018
  closeDocumentDetector();
8985
9019
  clearTimeout(modelLoadTimeout);
8986
9020
  document.removeEventListener('idmission.preloadProgress.documentDetection', handleDownloadProgress);
@@ -10818,7 +10852,7 @@
10818
10852
  }
10819
10853
  }
10820
10854
  }
10821
- if (!allowUploadingDocumentsFromStorage) {
10855
+ if (newState.captureState === 'initializing' && !allowUploadingDocumentsFromStorage) {
10822
10856
  newState.captureState = 'capturing';
10823
10857
  }
10824
10858
  return newState;
@@ -21388,6 +21422,7 @@
21388
21422
  onExitCapture = _a.onExitCapture,
21389
21423
  onExitAfterFailure = _a.onExitAfterFailure,
21390
21424
  onUserCancel = _a.onUserCancel,
21425
+ precapturedDocuments = _a.precapturedDocuments,
21391
21426
  _e = _a.loadingOverlayMode,
21392
21427
  loadingOverlayMode = _e === void 0 ? 'default' : _e,
21393
21428
  customOverlayContent = _a.customOverlayContent,
@@ -21453,12 +21488,17 @@
21453
21488
  start = _0.start,
21454
21489
  stop = _0.stop;
21455
21490
  React.useEffect(function () {
21491
+ if (precapturedDocuments === null || precapturedDocuments === void 0 ? void 0 : precapturedDocuments.selfie) {
21492
+ setSelfieImage(precapturedDocuments.selfie.imageData);
21493
+ setCaptureState('SUCCESS');
21494
+ return;
21495
+ }
21456
21496
  if (captureState !== 'CAPTURING') return;
21457
21497
  operationStartedAt.current = new Date();
21458
21498
  captureStartedAt.current = undefined;
21459
21499
  start();
21460
21500
  return stop;
21461
- }, [captureState, start, stop]);
21501
+ }, [captureState, precapturedDocuments === null || precapturedDocuments === void 0 ? void 0 : precapturedDocuments.selfie, setSelfieImage, start, stop]);
21462
21502
  var onCapture = React.useCallback(function () {
21463
21503
  livenessScore.current = undefined;
21464
21504
  }, []);
@@ -25571,6 +25611,7 @@
25571
25611
  initialCaptureDelayMs: faceLivenessInitialCaptureDelayMs,
25572
25612
  timeoutDurationMs: faceLivenessTimeoutDurationMs,
25573
25613
  modelLoadTimeoutMs: selfieCaptureModelLoadTimeoutMs,
25614
+ precapturedDocuments: precapturedDocuments,
25574
25615
  onDenied: onDenied,
25575
25616
  onExitCapture: onExitCapture,
25576
25617
  onExitAfterFailure: onExitAfterFailure,
@@ -25583,7 +25624,7 @@
25583
25624
  verbiage: verbiage.faceLiveness,
25584
25625
  debugMode: debugMode
25585
25626
  };
25586
- }, [assets.faceLiveness, classNames.faceLiveness, colors.faceLiveness, debugMode, faceLivenessInitialCaptureDelayMs, faceLivenessLoadingOverlayMode, faceLivenessTimeoutDurationMs, onDenied, onExitAfterFailure, onExitCapture, onSelfieCaptureModelError, onUserCancel, selfieCaptureModelLoadTimeoutMs, skipSuccessScreen, verbiage.faceLiveness]);
25627
+ }, [assets.faceLiveness, classNames.faceLiveness, colors.faceLiveness, debugMode, faceLivenessInitialCaptureDelayMs, faceLivenessLoadingOverlayMode, faceLivenessTimeoutDurationMs, onDenied, onExitAfterFailure, onExitCapture, onSelfieCaptureModelError, onUserCancel, precapturedDocuments, selfieCaptureModelLoadTimeoutMs, skipSuccessScreen, verbiage.faceLiveness]);
25587
25628
  var additionalDocumentCaptureProps = React.useMemo(function () {
25588
25629
  return {
25589
25630
  documents: captureAdditionalDocuments,
@@ -25714,6 +25755,7 @@
25714
25755
  sendBase64DocumentsInSwaggerProxy = _a.sendBase64DocumentsInSwaggerProxy,
25715
25756
  customerDataMatchConfig = _a.customerDataMatchConfig,
25716
25757
  useDocumentServiceForLivenessChecks = _a.useDocumentServiceForLivenessChecks,
25758
+ precapturedDocuments = _a.precapturedDocuments,
25717
25759
  _c = _a.idCaptureLoadingOverlayMode,
25718
25760
  idCaptureLoadingOverlayMode = _c === void 0 ? 'default' : _c,
25719
25761
  _d = _a.idCaptureRequirement,
@@ -25804,6 +25846,7 @@
25804
25846
  classNames: classNames.idCapture,
25805
25847
  colors: colors.idCapture,
25806
25848
  verbiage: verbiage.idCapture,
25849
+ precapturedDocuments: precapturedDocuments,
25807
25850
  captureRequirement: idCaptureRequirement,
25808
25851
  allowSinglePageIdCapture: allowSinglePageIdCapture,
25809
25852
  thresholds: idCaptureThresholds,
@@ -25826,13 +25869,14 @@
25826
25869
  skipSuccessScreen: skipSuccessScreen,
25827
25870
  debugMode: debugMode
25828
25871
  };
25829
- }, [assets.idCapture, classNames.idCapture, colors.idCapture, verbiage.idCapture, idCaptureRequirement, allowSinglePageIdCapture, idCaptureThresholds, idCaptureLoadingOverlayMode, idCaptureInstructions, idCaptureGuideType, idCaptureGuideImages, idCapturePortraitGuidesOnMobile, idCaptureRotateLoadingOverlayImageWhenPortrait, idCaptureModelLoadTimeoutMs, allowIdCardBackToFrontCapture, idCaptureForceFallbackMode, enableOverrideWrongDocumentTypeDialog, allowOverrideWrongDocumentTypeAfterMs, allowUploadingDocumentsFromStorage, separateIdCardCaptureSequence, onExitCapture, onUserCancel, onIdCaptureModelError, skipSuccessScreen, debugMode]);
25872
+ }, [assets.idCapture, classNames.idCapture, colors.idCapture, verbiage.idCapture, precapturedDocuments, idCaptureRequirement, allowSinglePageIdCapture, idCaptureThresholds, idCaptureLoadingOverlayMode, idCaptureInstructions, idCaptureGuideType, idCaptureGuideImages, idCapturePortraitGuidesOnMobile, idCaptureRotateLoadingOverlayImageWhenPortrait, idCaptureModelLoadTimeoutMs, allowIdCardBackToFrontCapture, idCaptureForceFallbackMode, enableOverrideWrongDocumentTypeDialog, allowOverrideWrongDocumentTypeAfterMs, allowUploadingDocumentsFromStorage, separateIdCardCaptureSequence, onExitCapture, onUserCancel, onIdCaptureModelError, skipSuccessScreen, debugMode]);
25830
25873
  var faceLivenessProps = React.useMemo(function () {
25831
25874
  return {
25832
25875
  onExitCapture: onExitCapture,
25833
25876
  onExitAfterFailure: onExitAfterFailure,
25834
25877
  onUserCancel: onUserCancel,
25835
25878
  onModelError: onSelfieCaptureModelError,
25879
+ precapturedDocuments: precapturedDocuments,
25836
25880
  loadingOverlayMode: faceLivenessLoadingOverlayMode,
25837
25881
  initialCaptureDelayMs: faceLivenessInitialCaptureDelayMs,
25838
25882
  timeoutDurationMs: faceLivenessTimeoutDurationMs,
@@ -25844,7 +25888,7 @@
25844
25888
  verbiage: verbiage.faceLiveness,
25845
25889
  debugMode: debugMode
25846
25890
  };
25847
- }, [assets.faceLiveness, classNames.faceLiveness, colors.faceLiveness, debugMode, faceLivenessInitialCaptureDelayMs, faceLivenessLoadingOverlayMode, faceLivenessTimeoutDurationMs, onExitAfterFailure, onExitCapture, onSelfieCaptureModelError, onUserCancel, selfieCaptureModelLoadTimeoutMs, skipSuccessScreen, verbiage.faceLiveness]);
25891
+ }, [assets.faceLiveness, classNames.faceLiveness, colors.faceLiveness, debugMode, faceLivenessInitialCaptureDelayMs, faceLivenessLoadingOverlayMode, faceLivenessTimeoutDurationMs, onExitAfterFailure, onExitCapture, onSelfieCaptureModelError, onUserCancel, precapturedDocuments, selfieCaptureModelLoadTimeoutMs, skipSuccessScreen, verbiage.faceLiveness]);
25848
25892
  var videoIdCaptureProps = React.useMemo(function () {
25849
25893
  return _assign({
25850
25894
  onExitCapture: onExitCapture,
@@ -25905,6 +25949,7 @@
25905
25949
  action: SubmissionAction.ENROLL,
25906
25950
  submissionUrl: submissionUrl,
25907
25951
  documentServiceUrl: documentServiceUrl,
25952
+ precapturedDocuments: precapturedDocuments,
25908
25953
  companyId: companyId,
25909
25954
  jobId: jobId,
25910
25955
  taskId: taskId,