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.
@@ -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.148';
214
+ var webSdkVersion = '2.2.150';
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
  }, []);
@@ -22936,39 +22976,40 @@
22936
22976
  var VideoSignatureContext = /*#__PURE__*/React.createContext(videoSignatureInitialState);
22937
22977
  function VideoSignatureContextProvider(_a) {
22938
22978
  var _this = this;
22979
+ var _b, _c;
22939
22980
  var children = _a.children,
22940
- _b = _a.captureAudio,
22941
- captureAudio = _b === void 0 ? false : _b;
22981
+ _d = _a.captureAudio,
22982
+ captureAudio = _d === void 0 ? false : _d;
22942
22983
  var signaturePad = React.useRef(null);
22943
- var _c = React.useState(null),
22944
- signatureData = _c[0],
22945
- setSignatureData = _c[1];
22946
- var _d = React.useState(null),
22947
- signatureDataUrl = _d[0],
22948
- setSignatureDataUrl = _d[1];
22949
22984
  var _e = React.useState(null),
22950
- signatureVideoData = _e[0],
22951
- setSignatureVideoData = _e[1];
22985
+ signatureData = _e[0],
22986
+ setSignatureData = _e[1];
22952
22987
  var _f = React.useState(null),
22953
- signatureVideoUrl = _f[0],
22954
- setSignatureVideoUrl = _f[1];
22988
+ signatureDataUrl = _f[0],
22989
+ setSignatureDataUrl = _f[1];
22990
+ var _g = React.useState(null),
22991
+ signatureVideoData = _g[0],
22992
+ setSignatureVideoData = _g[1];
22993
+ var _h = React.useState(null),
22994
+ signatureVideoUrl = _h[0],
22995
+ setSignatureVideoUrl = _h[1];
22955
22996
  var signatureRecorder = React.useRef(null);
22956
22997
  var recordedChunks = React.useRef([]);
22957
- var _g = useCameraStore(),
22958
- camera = _g.camera,
22959
- videoRef = _g.videoRef,
22960
- audioStream = _g.audioStream;
22961
- var _h = useVideoRecorder(camera, audioStream, captureAudio),
22962
- isRecordingVideo = _h.isRecordingVideo,
22963
- startRecordingVideo = _h.startRecordingVideo,
22964
- stopRecordingVideo = _h.stopRecordingVideo,
22965
- startRecordingAudio = _h.startRecordingAudio,
22966
- stopRecordingAudio = _h.stopRecordingAudio;
22998
+ var _j = useCameraStore(),
22999
+ camera = _j.camera,
23000
+ videoRef = _j.videoRef,
23001
+ audioStream = _j.audioStream;
23002
+ var _k = useVideoRecorder(camera, audioStream, captureAudio),
23003
+ isRecordingVideo = _k.isRecordingVideo,
23004
+ startRecordingVideo = _k.startRecordingVideo,
23005
+ stopRecordingVideo = _k.stopRecordingVideo,
23006
+ startRecordingAudio = _k.startRecordingAudio,
23007
+ stopRecordingAudio = _k.stopRecordingAudio;
22967
23008
  var outputCanvas = React.useRef(null);
22968
23009
  var recordingLock = React.useRef(false);
22969
- var _j = React.useState(false),
22970
- isRecording = _j[0],
22971
- setIsRecording = _j[1];
23010
+ var _l = React.useState(false),
23011
+ isRecording = _l[0],
23012
+ setIsRecording = _l[1];
22972
23013
  var startRecording = React.useCallback(function () {
22973
23014
  setIsRecording(true);
22974
23015
  }, []);
@@ -23099,7 +23140,9 @@
23099
23140
  return /*#__PURE__*/React.createElement(VideoSignatureContext.Provider, {
23100
23141
  value: value
23101
23142
  }, children, /*#__PURE__*/React.createElement(InvisibleCanvas, {
23102
- ref: outputCanvas
23143
+ ref: outputCanvas,
23144
+ width: (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth,
23145
+ height: (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.videoHeight
23103
23146
  }));
23104
23147
  }
23105
23148
  function useVideoSignatureContext() {
@@ -25571,6 +25614,7 @@
25571
25614
  initialCaptureDelayMs: faceLivenessInitialCaptureDelayMs,
25572
25615
  timeoutDurationMs: faceLivenessTimeoutDurationMs,
25573
25616
  modelLoadTimeoutMs: selfieCaptureModelLoadTimeoutMs,
25617
+ precapturedDocuments: precapturedDocuments,
25574
25618
  onDenied: onDenied,
25575
25619
  onExitCapture: onExitCapture,
25576
25620
  onExitAfterFailure: onExitAfterFailure,
@@ -25583,7 +25627,7 @@
25583
25627
  verbiage: verbiage.faceLiveness,
25584
25628
  debugMode: debugMode
25585
25629
  };
25586
- }, [assets.faceLiveness, classNames.faceLiveness, colors.faceLiveness, debugMode, faceLivenessInitialCaptureDelayMs, faceLivenessLoadingOverlayMode, faceLivenessTimeoutDurationMs, onDenied, onExitAfterFailure, onExitCapture, onSelfieCaptureModelError, onUserCancel, selfieCaptureModelLoadTimeoutMs, skipSuccessScreen, verbiage.faceLiveness]);
25630
+ }, [assets.faceLiveness, classNames.faceLiveness, colors.faceLiveness, debugMode, faceLivenessInitialCaptureDelayMs, faceLivenessLoadingOverlayMode, faceLivenessTimeoutDurationMs, onDenied, onExitAfterFailure, onExitCapture, onSelfieCaptureModelError, onUserCancel, precapturedDocuments, selfieCaptureModelLoadTimeoutMs, skipSuccessScreen, verbiage.faceLiveness]);
25587
25631
  var additionalDocumentCaptureProps = React.useMemo(function () {
25588
25632
  return {
25589
25633
  documents: captureAdditionalDocuments,
@@ -25835,6 +25879,7 @@
25835
25879
  onExitAfterFailure: onExitAfterFailure,
25836
25880
  onUserCancel: onUserCancel,
25837
25881
  onModelError: onSelfieCaptureModelError,
25882
+ precapturedDocuments: precapturedDocuments,
25838
25883
  loadingOverlayMode: faceLivenessLoadingOverlayMode,
25839
25884
  initialCaptureDelayMs: faceLivenessInitialCaptureDelayMs,
25840
25885
  timeoutDurationMs: faceLivenessTimeoutDurationMs,
@@ -25846,7 +25891,7 @@
25846
25891
  verbiage: verbiage.faceLiveness,
25847
25892
  debugMode: debugMode
25848
25893
  };
25849
- }, [assets.faceLiveness, classNames.faceLiveness, colors.faceLiveness, debugMode, faceLivenessInitialCaptureDelayMs, faceLivenessLoadingOverlayMode, faceLivenessTimeoutDurationMs, onExitAfterFailure, onExitCapture, onSelfieCaptureModelError, onUserCancel, selfieCaptureModelLoadTimeoutMs, skipSuccessScreen, verbiage.faceLiveness]);
25894
+ }, [assets.faceLiveness, classNames.faceLiveness, colors.faceLiveness, debugMode, faceLivenessInitialCaptureDelayMs, faceLivenessLoadingOverlayMode, faceLivenessTimeoutDurationMs, onExitAfterFailure, onExitCapture, onSelfieCaptureModelError, onUserCancel, precapturedDocuments, selfieCaptureModelLoadTimeoutMs, skipSuccessScreen, verbiage.faceLiveness]);
25850
25895
  var videoIdCaptureProps = React.useMemo(function () {
25851
25896
  return _assign({
25852
25897
  onExitCapture: onExitCapture,