idmission-web-sdk 2.2.148 → 2.2.150

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.148';
206
+ var webSdkVersion = '2.2.150';
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
  }, []);
@@ -13044,39 +13084,40 @@ var videoSignatureInitialState = {
13044
13084
  var VideoSignatureContext = /*#__PURE__*/createContext(videoSignatureInitialState);
13045
13085
  function VideoSignatureContextProvider(_a) {
13046
13086
  var _this = this;
13087
+ var _b, _c;
13047
13088
  var children = _a.children,
13048
- _b = _a.captureAudio,
13049
- captureAudio = _b === void 0 ? false : _b;
13089
+ _d = _a.captureAudio,
13090
+ captureAudio = _d === void 0 ? false : _d;
13050
13091
  var signaturePad = useRef(null);
13051
- var _c = useState(null),
13052
- signatureData = _c[0],
13053
- setSignatureData = _c[1];
13054
- var _d = useState(null),
13055
- signatureDataUrl = _d[0],
13056
- setSignatureDataUrl = _d[1];
13057
13092
  var _e = useState(null),
13058
- signatureVideoData = _e[0],
13059
- setSignatureVideoData = _e[1];
13093
+ signatureData = _e[0],
13094
+ setSignatureData = _e[1];
13060
13095
  var _f = useState(null),
13061
- signatureVideoUrl = _f[0],
13062
- setSignatureVideoUrl = _f[1];
13096
+ signatureDataUrl = _f[0],
13097
+ setSignatureDataUrl = _f[1];
13098
+ var _g = useState(null),
13099
+ signatureVideoData = _g[0],
13100
+ setSignatureVideoData = _g[1];
13101
+ var _h = useState(null),
13102
+ signatureVideoUrl = _h[0],
13103
+ setSignatureVideoUrl = _h[1];
13063
13104
  var signatureRecorder = useRef(null);
13064
13105
  var recordedChunks = useRef([]);
13065
- var _g = useCameraStore(),
13066
- camera = _g.camera,
13067
- videoRef = _g.videoRef,
13068
- audioStream = _g.audioStream;
13069
- var _h = useVideoRecorder(camera, audioStream, captureAudio),
13070
- isRecordingVideo = _h.isRecordingVideo,
13071
- startRecordingVideo = _h.startRecordingVideo,
13072
- stopRecordingVideo = _h.stopRecordingVideo,
13073
- startRecordingAudio = _h.startRecordingAudio,
13074
- stopRecordingAudio = _h.stopRecordingAudio;
13106
+ var _j = useCameraStore(),
13107
+ camera = _j.camera,
13108
+ videoRef = _j.videoRef,
13109
+ audioStream = _j.audioStream;
13110
+ var _k = useVideoRecorder(camera, audioStream, captureAudio),
13111
+ isRecordingVideo = _k.isRecordingVideo,
13112
+ startRecordingVideo = _k.startRecordingVideo,
13113
+ stopRecordingVideo = _k.stopRecordingVideo,
13114
+ startRecordingAudio = _k.startRecordingAudio,
13115
+ stopRecordingAudio = _k.stopRecordingAudio;
13075
13116
  var outputCanvas = useRef(null);
13076
13117
  var recordingLock = useRef(false);
13077
- var _j = useState(false),
13078
- isRecording = _j[0],
13079
- setIsRecording = _j[1];
13118
+ var _l = useState(false),
13119
+ isRecording = _l[0],
13120
+ setIsRecording = _l[1];
13080
13121
  var startRecording = useCallback(function () {
13081
13122
  setIsRecording(true);
13082
13123
  }, []);
@@ -13207,7 +13248,9 @@ function VideoSignatureContextProvider(_a) {
13207
13248
  return /*#__PURE__*/React__default.createElement(VideoSignatureContext.Provider, {
13208
13249
  value: value
13209
13250
  }, children, /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
13210
- ref: outputCanvas
13251
+ ref: outputCanvas,
13252
+ width: (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth,
13253
+ height: (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.videoHeight
13211
13254
  }));
13212
13255
  }
13213
13256
  function useVideoSignatureContext() {
@@ -15679,6 +15722,7 @@ var IdAndFaceValidation = function IdAndFaceValidation(_a) {
15679
15722
  initialCaptureDelayMs: faceLivenessInitialCaptureDelayMs,
15680
15723
  timeoutDurationMs: faceLivenessTimeoutDurationMs,
15681
15724
  modelLoadTimeoutMs: selfieCaptureModelLoadTimeoutMs,
15725
+ precapturedDocuments: precapturedDocuments,
15682
15726
  onDenied: onDenied,
15683
15727
  onExitCapture: onExitCapture,
15684
15728
  onExitAfterFailure: onExitAfterFailure,
@@ -15691,7 +15735,7 @@ var IdAndFaceValidation = function IdAndFaceValidation(_a) {
15691
15735
  verbiage: verbiage.faceLiveness,
15692
15736
  debugMode: debugMode
15693
15737
  };
15694
- }, [assets.faceLiveness, classNames.faceLiveness, colors.faceLiveness, debugMode, faceLivenessInitialCaptureDelayMs, faceLivenessLoadingOverlayMode, faceLivenessTimeoutDurationMs, onDenied, onExitAfterFailure, onExitCapture, onSelfieCaptureModelError, onUserCancel, selfieCaptureModelLoadTimeoutMs, skipSuccessScreen, verbiage.faceLiveness]);
15738
+ }, [assets.faceLiveness, classNames.faceLiveness, colors.faceLiveness, debugMode, faceLivenessInitialCaptureDelayMs, faceLivenessLoadingOverlayMode, faceLivenessTimeoutDurationMs, onDenied, onExitAfterFailure, onExitCapture, onSelfieCaptureModelError, onUserCancel, precapturedDocuments, selfieCaptureModelLoadTimeoutMs, skipSuccessScreen, verbiage.faceLiveness]);
15695
15739
  var additionalDocumentCaptureProps = useMemo(function () {
15696
15740
  return {
15697
15741
  documents: captureAdditionalDocuments,
@@ -15943,6 +15987,7 @@ var CustomerIdAndBiometricsEnrollment = function CustomerIdAndBiometricsEnrollme
15943
15987
  onExitAfterFailure: onExitAfterFailure,
15944
15988
  onUserCancel: onUserCancel,
15945
15989
  onModelError: onSelfieCaptureModelError,
15990
+ precapturedDocuments: precapturedDocuments,
15946
15991
  loadingOverlayMode: faceLivenessLoadingOverlayMode,
15947
15992
  initialCaptureDelayMs: faceLivenessInitialCaptureDelayMs,
15948
15993
  timeoutDurationMs: faceLivenessTimeoutDurationMs,
@@ -15954,7 +15999,7 @@ var CustomerIdAndBiometricsEnrollment = function CustomerIdAndBiometricsEnrollme
15954
15999
  verbiage: verbiage.faceLiveness,
15955
16000
  debugMode: debugMode
15956
16001
  };
15957
- }, [assets.faceLiveness, classNames.faceLiveness, colors.faceLiveness, debugMode, faceLivenessInitialCaptureDelayMs, faceLivenessLoadingOverlayMode, faceLivenessTimeoutDurationMs, onExitAfterFailure, onExitCapture, onSelfieCaptureModelError, onUserCancel, selfieCaptureModelLoadTimeoutMs, skipSuccessScreen, verbiage.faceLiveness]);
16002
+ }, [assets.faceLiveness, classNames.faceLiveness, colors.faceLiveness, debugMode, faceLivenessInitialCaptureDelayMs, faceLivenessLoadingOverlayMode, faceLivenessTimeoutDurationMs, onExitAfterFailure, onExitCapture, onSelfieCaptureModelError, onUserCancel, precapturedDocuments, selfieCaptureModelLoadTimeoutMs, skipSuccessScreen, verbiage.faceLiveness]);
15958
16003
  var videoIdCaptureProps = useMemo(function () {
15959
16004
  return _assign({
15960
16005
  onExitCapture: onExitCapture,