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.
package/dist/sdk2.esm.js CHANGED
@@ -203,7 +203,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
203
203
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
204
204
  };
205
205
 
206
- var webSdkVersion = '2.2.147';
206
+ var webSdkVersion = '2.2.149';
207
207
 
208
208
  function getPlatform() {
209
209
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -2269,18 +2269,22 @@ function waitForVideoReady(videoRef, checkEveryMs) {
2269
2269
  if (checkEveryMs === void 0) {
2270
2270
  checkEveryMs = 100;
2271
2271
  }
2272
- return new Promise(function (resolve) {
2272
+ var cancelled = false;
2273
+ var promise = new Promise(function (resolve) {
2273
2274
  var _a, _b, _c;
2274
2275
  if (((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.readyState) !== null && _b !== void 0 ? _b : 0) >= 2) return resolve();
2275
2276
  (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.load();
2276
2277
  var interval = setInterval(function () {
2277
2278
  var _a, _b;
2278
- if (((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.readyState) !== null && _b !== void 0 ? _b : 0) >= 2) {
2279
+ if (((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.readyState) !== null && _b !== void 0 ? _b : 0) >= 2 || cancelled) {
2279
2280
  clearInterval(interval);
2280
2281
  resolve();
2281
2282
  }
2282
2283
  }, checkEveryMs);
2283
2284
  });
2285
+ return [promise, function () {
2286
+ cancelled = true;
2287
+ }];
2284
2288
  }
2285
2289
  function calculateIoU(boxA, boxB) {
2286
2290
  var xA = Math.max(boxA.xMin, boxB.xMin);
@@ -2405,17 +2409,26 @@ function useLoadFocusModel(_a) {
2405
2409
  var modelLoadTimeout = setTimeout(function () {
2406
2410
  setModelError(new Error('Model loading time limit exceeded.'));
2407
2411
  }, modelLoadTimeoutMs);
2412
+ var cancelVideoReady = function cancelVideoReady() {};
2408
2413
  loadFocusModel(modelPath).then(function (loadedModel) {
2409
2414
  return __awaiter(_this, void 0, void 0, function () {
2410
- return __generator(this, function (_a) {
2411
- switch (_a.label) {
2415
+ var _a, videoReady, cancel, cancelled;
2416
+ return __generator(this, function (_b) {
2417
+ switch (_b.label) {
2412
2418
  case 0:
2413
2419
  setModelDownloadProgress(100);
2414
2420
  clearTimeout(modelLoadTimeout);
2415
- return [4 /*yield*/, waitForVideoReady(videoRef)];
2421
+ _a = waitForVideoReady(videoRef), videoReady = _a[0], cancel = _a[1];
2422
+ cancelled = false;
2423
+ cancelVideoReady = function cancelVideoReady() {
2424
+ cancelled = true;
2425
+ cancel();
2426
+ };
2427
+ return [4 /*yield*/, videoReady];
2416
2428
  case 1:
2417
- _a.sent();
2429
+ _b.sent();
2418
2430
  setTimeout(function () {
2431
+ if (cancelled) return;
2419
2432
  loadedModel.classifyForVideo(videoRef.current, performance.now());
2420
2433
  setReady(true);
2421
2434
  }, 500);
@@ -2430,6 +2443,7 @@ function useLoadFocusModel(_a) {
2430
2443
  });
2431
2444
  return function () {
2432
2445
  log('unloading focus model');
2446
+ cancelVideoReady();
2433
2447
  closeFocusModel();
2434
2448
  clearTimeout(modelLoadTimeout);
2435
2449
  document.removeEventListener('idmission.preloadProgress.focus', handleDownloadProgress);
@@ -2553,16 +2567,25 @@ function useLoadFaceDetector(_a) {
2553
2567
  setModelDownloadProgress(progressToPercentage(event.detail));
2554
2568
  }
2555
2569
  document.addEventListener('idmission.preloadProgress.faceDetection', handleDownloadProgress);
2570
+ var cancelVideoReady = function cancelVideoReady() {};
2556
2571
  loadFaceDetector().then(function (model) {
2557
2572
  return __awaiter(_this, void 0, void 0, function () {
2558
- return __generator(this, function (_a) {
2559
- switch (_a.label) {
2573
+ var _a, videoReady, cancel, cancelled;
2574
+ return __generator(this, function (_b) {
2575
+ switch (_b.label) {
2560
2576
  case 0:
2561
2577
  setModelDownloadProgress(100);
2562
2578
  clearTimeout(modelLoadTimeout);
2563
- return [4 /*yield*/, waitForVideoReady(videoRef)];
2579
+ _a = waitForVideoReady(videoRef), videoReady = _a[0], cancel = _a[1];
2580
+ cancelled = false;
2581
+ cancelVideoReady = function cancelVideoReady() {
2582
+ cancelled = true;
2583
+ cancel();
2584
+ };
2585
+ return [4 /*yield*/, videoReady];
2564
2586
  case 1:
2565
- _a.sent();
2587
+ _b.sent();
2588
+ if (cancelled) return [2 /*return*/];
2566
2589
  model.detectForVideo(videoRef.current, performance.now());
2567
2590
  setReady(true);
2568
2591
  return [2 /*return*/];
@@ -2576,6 +2599,7 @@ function useLoadFaceDetector(_a) {
2576
2599
  });
2577
2600
  return function () {
2578
2601
  log('unloading face detection model');
2602
+ cancelVideoReady();
2579
2603
  closeFaceDetector();
2580
2604
  clearTimeout(modelLoadTimeout);
2581
2605
  document.removeEventListener('idmission.preloadProgress.faceDetection', handleDownloadProgress);
@@ -3050,17 +3074,26 @@ function useLoadDocumentDetector(_a) {
3050
3074
  var modelLoadTimeout = setTimeout(function () {
3051
3075
  setModelError(new Error('Model loading time limit exceeded.'));
3052
3076
  }, modelLoadTimeoutMs);
3077
+ var cancelVideoReady = function cancelVideoReady() {};
3053
3078
  loadDocumentDetector(modelPath, scoreThreshold).then(function (model) {
3054
3079
  return __awaiter(_this, void 0, void 0, function () {
3055
- return __generator(this, function (_a) {
3056
- switch (_a.label) {
3080
+ var _a, videoReady, cancel, cancelled;
3081
+ return __generator(this, function (_b) {
3082
+ switch (_b.label) {
3057
3083
  case 0:
3058
3084
  setModelDownloadProgress(100);
3059
3085
  clearTimeout(modelLoadTimeout);
3060
- return [4 /*yield*/, waitForVideoReady(videoRef)];
3086
+ _a = waitForVideoReady(videoRef), videoReady = _a[0], cancel = _a[1];
3087
+ cancelled = false;
3088
+ cancelVideoReady = function cancelVideoReady() {
3089
+ cancelled = true;
3090
+ cancel();
3091
+ };
3092
+ return [4 /*yield*/, videoReady];
3061
3093
  case 1:
3062
- _a.sent();
3094
+ _b.sent();
3063
3095
  setTimeout(function () {
3096
+ if (cancelled) return;
3064
3097
  model.detectForVideo(videoRef.current, performance.now());
3065
3098
  setReady(true);
3066
3099
  }, 500);
@@ -3075,6 +3108,7 @@ function useLoadDocumentDetector(_a) {
3075
3108
  });
3076
3109
  return function () {
3077
3110
  log('unloading document detection model');
3111
+ cancelVideoReady();
3078
3112
  closeDocumentDetector();
3079
3113
  clearTimeout(modelLoadTimeout);
3080
3114
  document.removeEventListener('idmission.preloadProgress.documentDetection', handleDownloadProgress);
@@ -4484,7 +4518,7 @@ var _reducer = function reducer(state, action) {
4484
4518
  }
4485
4519
  }
4486
4520
  }
4487
- if (!allowUploadingDocumentsFromStorage) {
4521
+ if (newState.captureState === 'initializing' && !allowUploadingDocumentsFromStorage) {
4488
4522
  newState.captureState = 'capturing';
4489
4523
  }
4490
4524
  return newState;
@@ -12264,6 +12298,7 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
12264
12298
  onExitCapture = _a.onExitCapture,
12265
12299
  onExitAfterFailure = _a.onExitAfterFailure,
12266
12300
  onUserCancel = _a.onUserCancel,
12301
+ precapturedDocuments = _a.precapturedDocuments,
12267
12302
  _e = _a.loadingOverlayMode,
12268
12303
  loadingOverlayMode = _e === void 0 ? 'default' : _e,
12269
12304
  customOverlayContent = _a.customOverlayContent,
@@ -12329,12 +12364,17 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
12329
12364
  start = _0.start,
12330
12365
  stop = _0.stop;
12331
12366
  useEffect(function () {
12367
+ if (precapturedDocuments === null || precapturedDocuments === void 0 ? void 0 : precapturedDocuments.selfie) {
12368
+ setSelfieImage(precapturedDocuments.selfie.imageData);
12369
+ setCaptureState('SUCCESS');
12370
+ return;
12371
+ }
12332
12372
  if (captureState !== 'CAPTURING') return;
12333
12373
  operationStartedAt.current = new Date();
12334
12374
  captureStartedAt.current = undefined;
12335
12375
  start();
12336
12376
  return stop;
12337
- }, [captureState, start, stop]);
12377
+ }, [captureState, precapturedDocuments === null || precapturedDocuments === void 0 ? void 0 : precapturedDocuments.selfie, setSelfieImage, start, stop]);
12338
12378
  var onCapture = useCallback(function () {
12339
12379
  livenessScore.current = undefined;
12340
12380
  }, []);
@@ -15679,6 +15719,7 @@ var IdAndFaceValidation = function IdAndFaceValidation(_a) {
15679
15719
  initialCaptureDelayMs: faceLivenessInitialCaptureDelayMs,
15680
15720
  timeoutDurationMs: faceLivenessTimeoutDurationMs,
15681
15721
  modelLoadTimeoutMs: selfieCaptureModelLoadTimeoutMs,
15722
+ precapturedDocuments: precapturedDocuments,
15682
15723
  onDenied: onDenied,
15683
15724
  onExitCapture: onExitCapture,
15684
15725
  onExitAfterFailure: onExitAfterFailure,
@@ -15691,7 +15732,7 @@ var IdAndFaceValidation = function IdAndFaceValidation(_a) {
15691
15732
  verbiage: verbiage.faceLiveness,
15692
15733
  debugMode: debugMode
15693
15734
  };
15694
- }, [assets.faceLiveness, classNames.faceLiveness, colors.faceLiveness, debugMode, faceLivenessInitialCaptureDelayMs, faceLivenessLoadingOverlayMode, faceLivenessTimeoutDurationMs, onDenied, onExitAfterFailure, onExitCapture, onSelfieCaptureModelError, onUserCancel, selfieCaptureModelLoadTimeoutMs, skipSuccessScreen, verbiage.faceLiveness]);
15735
+ }, [assets.faceLiveness, classNames.faceLiveness, colors.faceLiveness, debugMode, faceLivenessInitialCaptureDelayMs, faceLivenessLoadingOverlayMode, faceLivenessTimeoutDurationMs, onDenied, onExitAfterFailure, onExitCapture, onSelfieCaptureModelError, onUserCancel, precapturedDocuments, selfieCaptureModelLoadTimeoutMs, skipSuccessScreen, verbiage.faceLiveness]);
15695
15736
  var additionalDocumentCaptureProps = useMemo(function () {
15696
15737
  return {
15697
15738
  documents: captureAdditionalDocuments,
@@ -15822,6 +15863,7 @@ var CustomerIdAndBiometricsEnrollment = function CustomerIdAndBiometricsEnrollme
15822
15863
  sendBase64DocumentsInSwaggerProxy = _a.sendBase64DocumentsInSwaggerProxy,
15823
15864
  customerDataMatchConfig = _a.customerDataMatchConfig,
15824
15865
  useDocumentServiceForLivenessChecks = _a.useDocumentServiceForLivenessChecks,
15866
+ precapturedDocuments = _a.precapturedDocuments,
15825
15867
  _c = _a.idCaptureLoadingOverlayMode,
15826
15868
  idCaptureLoadingOverlayMode = _c === void 0 ? 'default' : _c,
15827
15869
  _d = _a.idCaptureRequirement,
@@ -15912,6 +15954,7 @@ var CustomerIdAndBiometricsEnrollment = function CustomerIdAndBiometricsEnrollme
15912
15954
  classNames: classNames.idCapture,
15913
15955
  colors: colors.idCapture,
15914
15956
  verbiage: verbiage.idCapture,
15957
+ precapturedDocuments: precapturedDocuments,
15915
15958
  captureRequirement: idCaptureRequirement,
15916
15959
  allowSinglePageIdCapture: allowSinglePageIdCapture,
15917
15960
  thresholds: idCaptureThresholds,
@@ -15934,13 +15977,14 @@ var CustomerIdAndBiometricsEnrollment = function CustomerIdAndBiometricsEnrollme
15934
15977
  skipSuccessScreen: skipSuccessScreen,
15935
15978
  debugMode: debugMode
15936
15979
  };
15937
- }, [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]);
15980
+ }, [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]);
15938
15981
  var faceLivenessProps = useMemo(function () {
15939
15982
  return {
15940
15983
  onExitCapture: onExitCapture,
15941
15984
  onExitAfterFailure: onExitAfterFailure,
15942
15985
  onUserCancel: onUserCancel,
15943
15986
  onModelError: onSelfieCaptureModelError,
15987
+ precapturedDocuments: precapturedDocuments,
15944
15988
  loadingOverlayMode: faceLivenessLoadingOverlayMode,
15945
15989
  initialCaptureDelayMs: faceLivenessInitialCaptureDelayMs,
15946
15990
  timeoutDurationMs: faceLivenessTimeoutDurationMs,
@@ -15952,7 +15996,7 @@ var CustomerIdAndBiometricsEnrollment = function CustomerIdAndBiometricsEnrollme
15952
15996
  verbiage: verbiage.faceLiveness,
15953
15997
  debugMode: debugMode
15954
15998
  };
15955
- }, [assets.faceLiveness, classNames.faceLiveness, colors.faceLiveness, debugMode, faceLivenessInitialCaptureDelayMs, faceLivenessLoadingOverlayMode, faceLivenessTimeoutDurationMs, onExitAfterFailure, onExitCapture, onSelfieCaptureModelError, onUserCancel, selfieCaptureModelLoadTimeoutMs, skipSuccessScreen, verbiage.faceLiveness]);
15999
+ }, [assets.faceLiveness, classNames.faceLiveness, colors.faceLiveness, debugMode, faceLivenessInitialCaptureDelayMs, faceLivenessLoadingOverlayMode, faceLivenessTimeoutDurationMs, onExitAfterFailure, onExitCapture, onSelfieCaptureModelError, onUserCancel, precapturedDocuments, selfieCaptureModelLoadTimeoutMs, skipSuccessScreen, verbiage.faceLiveness]);
15956
16000
  var videoIdCaptureProps = useMemo(function () {
15957
16001
  return _assign({
15958
16002
  onExitCapture: onExitCapture,
@@ -16013,6 +16057,7 @@ var CustomerIdAndBiometricsEnrollment = function CustomerIdAndBiometricsEnrollme
16013
16057
  action: SubmissionAction.ENROLL,
16014
16058
  submissionUrl: submissionUrl,
16015
16059
  documentServiceUrl: documentServiceUrl,
16060
+ precapturedDocuments: precapturedDocuments,
16016
16061
  companyId: companyId,
16017
16062
  jobId: jobId,
16018
16063
  taskId: taskId,