idmission-web-sdk 2.3.58 → 2.3.59

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.
Files changed (28) hide show
  1. package/dist/components/CompositeWizard.d.ts.map +1 -1
  2. package/dist/components/camera/CameraVideoTag.d.ts.map +1 -1
  3. package/dist/components/face_liveness/FaceLivenessWizard.d.ts +6 -1
  4. package/dist/components/face_liveness/FaceLivenessWizard.d.ts.map +1 -1
  5. package/dist/components/id_capture/IdCaptureWizard.d.ts +7 -1
  6. package/dist/components/id_capture/IdCaptureWizard.d.ts.map +1 -1
  7. package/dist/components/selfie_capture/SelfieCapture.d.ts.map +1 -1
  8. package/dist/components/video_id/IdVideoCapture.d.ts.map +1 -1
  9. package/dist/components/video_signature_capture/VideoSignatureCapture.d.ts.map +1 -1
  10. package/dist/components/video_signature_capture/VideoSignatureContext.d.ts +1 -2
  11. package/dist/components/video_signature_capture/VideoSignatureContext.d.ts.map +1 -1
  12. package/dist/components/video_signature_capture/VideoSignatureWizard.d.ts.map +1 -1
  13. package/dist/lib/camera/cameraStore.d.ts +3 -3
  14. package/dist/lib/camera/cameraStore.d.ts.map +1 -1
  15. package/dist/lib/camera/useVideoRecorder.d.ts +1 -2
  16. package/dist/lib/camera/useVideoRecorder.d.ts.map +1 -1
  17. package/dist/sdk2.cjs.development.js +161 -150
  18. package/dist/sdk2.cjs.development.js.map +1 -1
  19. package/dist/sdk2.cjs.production.js +1 -1
  20. package/dist/sdk2.cjs.production.js.map +1 -1
  21. package/dist/sdk2.esm.js +161 -150
  22. package/dist/sdk2.esm.js.map +1 -1
  23. package/dist/sdk2.umd.development.js +161 -150
  24. package/dist/sdk2.umd.development.js.map +1 -1
  25. package/dist/sdk2.umd.production.js +1 -1
  26. package/dist/sdk2.umd.production.js.map +1 -1
  27. package/dist/version.d.ts +1 -1
  28. package/package.json +1 -1
package/dist/sdk2.esm.js CHANGED
@@ -205,7 +205,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
205
205
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
206
206
  };
207
207
 
208
- var webSdkVersion = '2.3.58';
208
+ var webSdkVersion = '2.3.59';
209
209
 
210
210
  function getPlatform() {
211
211
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -3641,8 +3641,8 @@ function obtainCameraAccess(stream, deviceLabel, video) {
3641
3641
  release: release
3642
3642
  };
3643
3643
  log('camera access granted');
3644
- if (video) video.srcObject = stream;
3645
- log('video source initialized');
3644
+ // if (video) video.srcObject = stream
3645
+ // log('video source initialized')
3646
3646
  return currentCamera;
3647
3647
  }
3648
3648
  function releaseCameraAccess() {
@@ -4775,24 +4775,24 @@ function useTranslations(verbiage, fallbacks) {
4775
4775
  }, [fallbacks, i18n.language, t, verbiage]);
4776
4776
  }
4777
4777
 
4778
+ var camera = null;
4779
+ var videoStream = null;
4780
+ var audioStream = null;
4778
4781
  var initialState$6 = {
4779
4782
  videoRef: {
4780
4783
  current: null
4781
4784
  },
4782
4785
  videoLoaded: false,
4783
- videoStream: null,
4784
4786
  videoDevice: null,
4785
4787
  videoWidth: 0,
4786
4788
  videoHeight: 0,
4787
4789
  isRearFacing: false,
4788
- camera: null,
4789
4790
  cameraReady: false,
4790
4791
  cameraAccessDenied: false,
4791
4792
  iphoneContinuityCameraAvailable: false,
4792
4793
  iphoneContinuityCameraDenied: false,
4793
4794
  preferIphoneContinuityCamera: true,
4794
4795
  cameraTamperingDetected: false,
4795
- audioStream: null,
4796
4796
  microphoneReady: false,
4797
4797
  microphoneAccessDenied: false
4798
4798
  };
@@ -4806,8 +4806,7 @@ var createCameraStore = function createCameraStore(config) {
4806
4806
  return set(config);
4807
4807
  },
4808
4808
  onVideoMounted: function onVideoMounted(e) {
4809
- var _a;
4810
- var selectedVideoStreamId = (_a = get().videoStream) === null || _a === void 0 ? void 0 : _a.id;
4809
+ var selectedVideoStreamId = videoStream === null || videoStream === void 0 ? void 0 : videoStream.id;
4811
4810
  if (!selectedVideoStreamId) return;
4812
4811
  var srcObject = e.currentTarget.srcObject;
4813
4812
  if (srcObject.id === selectedVideoStreamId) {
@@ -4827,19 +4826,19 @@ var createCameraStore = function createCameraStore(config) {
4827
4826
  },
4828
4827
  requestCameraAccess: function requestCameraAccess() {
4829
4828
  return __awaiter(this, void 0, void 0, function () {
4830
- var _a, videoRef, releaseCameraAccess, preferFrontFacingCamera, preferIphoneContinuityCamera, iphoneContinuityCameraDenied, availableCameras, selectedCamera, platform_1, iphoneContinuityCamera, constraints, stream_1, e_1, e_2, handleStreamEnded_1, videoTrack_1, camera_1, e_3;
4831
- var _b, _c, _d;
4832
- return __generator(this, function (_e) {
4833
- switch (_e.label) {
4829
+ var _a, videoRef, releaseCameraAccess, preferFrontFacingCamera, preferIphoneContinuityCamera, iphoneContinuityCameraDenied, availableCameras, selectedCamera, platform_1, iphoneContinuityCamera, constraints, stream_1, e_1, e_2, handleStreamEnded_1, videoTrack_1, e_3;
4830
+ var _b, _c, _d, _e;
4831
+ return __generator(this, function (_f) {
4832
+ switch (_f.label) {
4834
4833
  case 0:
4835
4834
  _a = get(), videoRef = _a.videoRef, releaseCameraAccess = _a.releaseCameraAccess, preferFrontFacingCamera = _a.preferFrontFacingCamera, preferIphoneContinuityCamera = _a.preferIphoneContinuityCamera, iphoneContinuityCameraDenied = _a.iphoneContinuityCameraDenied;
4836
4835
  releaseCameraAccess();
4837
- _e.label = 1;
4836
+ _f.label = 1;
4838
4837
  case 1:
4839
- _e.trys.push([1, 11,, 12]);
4838
+ _f.trys.push([1, 11,, 12]);
4840
4839
  return [4 /*yield*/, listAvailableCameras()];
4841
4840
  case 2:
4842
- availableCameras = _e.sent();
4841
+ availableCameras = _f.sent();
4843
4842
  selectedCamera = void 0;
4844
4843
  debug('availableCameras', availableCameras);
4845
4844
  platform_1 = getPlatform();
@@ -4909,16 +4908,16 @@ var createCameraStore = function createCameraStore(config) {
4909
4908
  };
4910
4909
  }
4911
4910
  stream_1 = null;
4912
- _e.label = 3;
4911
+ _f.label = 3;
4913
4912
  case 3:
4914
- _e.trys.push([3, 5,, 6]);
4913
+ _f.trys.push([3, 5,, 6]);
4915
4914
  debug('obtaining camera access with constraints', constraints);
4916
4915
  return [4 /*yield*/, navigator.mediaDevices.getUserMedia(constraints)];
4917
4916
  case 4:
4918
- stream_1 = _e.sent();
4917
+ stream_1 = _f.sent();
4919
4918
  return [3 /*break*/, 6];
4920
4919
  case 5:
4921
- e_1 = _e.sent();
4920
+ e_1 = _f.sent();
4922
4921
  if (e_1.name === 'NotAllowedError') {
4923
4922
  if (preferIphoneContinuityCamera) {
4924
4923
  set({
@@ -4935,19 +4934,19 @@ var createCameraStore = function createCameraStore(config) {
4935
4934
  return [3 /*break*/, 6];
4936
4935
  case 6:
4937
4936
  if (!!stream_1) return [3 /*break*/, 10];
4938
- _e.label = 7;
4937
+ _f.label = 7;
4939
4938
  case 7:
4940
- _e.trys.push([7, 9,, 10]);
4939
+ _f.trys.push([7, 9,, 10]);
4941
4940
  return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
4942
4941
  audio: false,
4943
4942
  video: true
4944
4943
  })];
4945
4944
  case 8:
4946
- stream_1 = _e.sent();
4945
+ stream_1 = _f.sent();
4947
4946
  debug('opened stream with no width and height constraints');
4948
4947
  return [3 /*break*/, 10];
4949
4948
  case 9:
4950
- e_2 = _e.sent();
4949
+ e_2 = _f.sent();
4951
4950
  debug('cannot open stream at all', e_2);
4952
4951
  return [3 /*break*/, 10];
4953
4952
  case 10:
@@ -4959,8 +4958,8 @@ var createCameraStore = function createCameraStore(config) {
4959
4958
  handleStreamEnded_1 = function handleStreamEnded_1() {
4960
4959
  if (preferIphoneContinuityCamera && get().iphoneContinuityCameraAvailable) {
4961
4960
  debug('someone unplugged the continuity camera');
4961
+ videoStream = null;
4962
4962
  set({
4963
- videoStream: null,
4964
4963
  videoDevice: null,
4965
4964
  cameraReady: false,
4966
4965
  iphoneContinuityCameraAvailable: false,
@@ -4969,9 +4968,9 @@ var createCameraStore = function createCameraStore(config) {
4969
4968
  get().requestCameraAccess();
4970
4969
  } else {
4971
4970
  debug('someone unplugged the webcam');
4972
- releaseCameraAccess();
4971
+ get().releaseCameraAccess();
4972
+ videoStream = null;
4973
4973
  set({
4974
- videoStream: null,
4975
4974
  videoDevice: null,
4976
4975
  videoLoaded: false,
4977
4976
  cameraReady: false,
@@ -4982,25 +4981,26 @@ var createCameraStore = function createCameraStore(config) {
4982
4981
  (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.addEventListener('ended', handleStreamEnded_1);
4983
4982
  videoTrack_1 = stream_1.getVideoTracks()[0];
4984
4983
  videoTrack_1.onended = handleStreamEnded_1;
4985
- camera_1 = obtainCameraAccess(stream_1, selectedCamera.label, videoRef.current);
4984
+ camera = obtainCameraAccess(stream_1, selectedCamera.label, videoRef.current);
4986
4985
  setTimeout(function () {
4986
+ var _a;
4987
4987
  // iOS 17 has a strange behavior where the video track flickers between muted and unmuted
4988
4988
  // when the camera access is being requested. This delay is a workaround for that.
4989
4989
  videoTrack_1.onmute = function () {
4990
4990
  if (videoTrack_1.readyState !== 'live') handleStreamEnded_1();
4991
4991
  };
4992
+ videoStream = stream_1;
4993
+ var isRearFacing = (_a = camera === null || camera === void 0 ? void 0 : camera.isRearFacing) !== null && _a !== void 0 ? _a : false;
4992
4994
  set({
4993
- camera: camera_1,
4994
4995
  cameraReady: true,
4995
4996
  cameraAccessDenied: false,
4996
- isRearFacing: camera_1.isRearFacing,
4997
- videoStream: stream_1
4997
+ isRearFacing: isRearFacing
4998
4998
  });
4999
4999
  }, 500);
5000
5000
  return [3 /*break*/, 12];
5001
5001
  case 11:
5002
- e_3 = _e.sent();
5003
- if (e_3.name === 'NotAllowedError') {
5002
+ e_3 = _f.sent();
5003
+ if (e_3.name === 'NotAllowedError' || ((_e = e_3.message) === null || _e === void 0 ? void 0 : _e.includes('Could not start video source'))) {
5004
5004
  error('camera access has been blocked by the user', e_3);
5005
5005
  set({
5006
5006
  cameraAccessDenied: true
@@ -5018,17 +5018,18 @@ var createCameraStore = function createCameraStore(config) {
5018
5018
  },
5019
5019
  releaseCameraAccess: function releaseCameraAccess() {
5020
5020
  return __awaiter(this, void 0, void 0, function () {
5021
- var camera;
5022
5021
  return __generator(this, function (_a) {
5023
- camera = get().camera;
5024
5022
  if (!camera) return [2 /*return*/];
5025
5023
  camera.release();
5024
+ camera = null;
5025
+ videoStream === null || videoStream === void 0 ? void 0 : videoStream.getTracks().forEach(function (track) {
5026
+ track.stop();
5027
+ });
5028
+ videoStream = null;
5026
5029
  set({
5027
- camera: null,
5028
5030
  cameraReady: false,
5029
5031
  cameraAccessDenied: false,
5030
5032
  videoDevice: null,
5031
- videoStream: null,
5032
5033
  videoLoaded: false
5033
5034
  });
5034
5035
  return [2 /*return*/];
@@ -5057,8 +5058,8 @@ var createCameraStore = function createCameraStore(config) {
5057
5058
  // iOS 17 has a strange behavior where the video track flickers between muted and unmuted
5058
5059
  // when the camera access is being requested. This delay is a workaround for that.
5059
5060
  setTimeout(function () {
5061
+ audioStream = stream_2;
5060
5062
  set({
5061
- audioStream: stream_2,
5062
5063
  microphoneReady: true,
5063
5064
  microphoneAccessDenied: false
5064
5065
  });
@@ -5067,6 +5068,7 @@ var createCameraStore = function createCameraStore(config) {
5067
5068
  microphoneReady: false,
5068
5069
  microphoneAccessDenied: true
5069
5070
  });
5071
+ get().releaseMicrophoneAccess();
5070
5072
  };
5071
5073
  var track = stream_2.getAudioTracks()[0];
5072
5074
  track.onended = handleStreamEnded;
@@ -5090,14 +5092,13 @@ var createCameraStore = function createCameraStore(config) {
5090
5092
  },
5091
5093
  releaseMicrophoneAccess: function releaseMicrophoneAccess() {
5092
5094
  var _a;
5093
- var audioStream = get().audioStream;
5094
5095
  (_a = audioStream === null || audioStream === void 0 ? void 0 : audioStream.stop) === null || _a === void 0 ? void 0 : _a.call(audioStream);
5095
5096
  audioStream === null || audioStream === void 0 ? void 0 : audioStream.getAudioTracks().forEach(function (track) {
5096
5097
  var _a;
5097
5098
  (_a = track.stop) === null || _a === void 0 ? void 0 : _a.call(track);
5098
5099
  });
5100
+ audioStream = null;
5099
5101
  set({
5100
- audioStream: null,
5101
5102
  microphoneReady: false,
5102
5103
  microphoneAccessDenied: false
5103
5104
  });
@@ -6635,15 +6636,13 @@ var IdCapture = function IdCapture(_a) {
6635
6636
  _q = _o.height,
6636
6637
  height = _q === void 0 ? 1 : _q;
6637
6638
  var state = useIdCaptureStore();
6638
- var _r = useCameraStore(),
6639
- camera = _r.camera,
6640
- isRearFacing = _r.isRearFacing;
6641
- var _s = useContext(IdCaptureModelsContext),
6642
- modelsReady = _s.ready,
6643
- setThresholds = _s.setThresholds,
6644
- detectionTime = _s.detectionTime,
6645
- focusPredictionTime = _s.focusPredictionTime,
6646
- getBestFrame = _s.getBestFrame;
6639
+ var isRearFacing = useCameraStore().isRearFacing;
6640
+ var _r = useContext(IdCaptureModelsContext),
6641
+ modelsReady = _r.ready,
6642
+ setThresholds = _r.setThresholds,
6643
+ detectionTime = _r.detectionTime,
6644
+ focusPredictionTime = _r.focusPredictionTime,
6645
+ getBestFrame = _r.getBestFrame;
6647
6646
  useEffect(function () {
6648
6647
  return dispatchIdCaptureAction({
6649
6648
  type: 'captureInitialized'
@@ -9073,9 +9072,7 @@ var DocumentCaptureStateProvider = function DocumentCaptureStateProvider(_a) {
9073
9072
  var _c = useReducer(documentCaptureStateReducer, documentCaptureInitialState),
9074
9073
  state = _c[0],
9075
9074
  dispatch = _c[1];
9076
- var _d = useCameraStore(),
9077
- videoStream = _d.videoStream,
9078
- videoRef = _d.videoRef;
9075
+ var videoRef = useCameraStore().videoRef;
9079
9076
  var uploadDocument = useContext(SubmissionContext).uploadDocument;
9080
9077
  var uploadCapturedDocument = useCallback(function (content, filetype) {
9081
9078
  return __awaiter(void 0, void 0, void 0, function () {
@@ -9169,7 +9166,7 @@ var DocumentCaptureStateProvider = function DocumentCaptureStateProvider(_a) {
9169
9166
  }, [onResize]);
9170
9167
  var videoTag = videoRef.current;
9171
9168
  useEffect(function () {
9172
- if (!state.capturing || !(videoStream === null || videoStream === void 0 ? void 0 : videoStream.active)) return;
9169
+ if (!state.capturing) return;
9173
9170
  function onComplete(content) {
9174
9171
  if (!content) return;
9175
9172
  var contentUrl = URL.createObjectURL(content);
@@ -9186,7 +9183,7 @@ var DocumentCaptureStateProvider = function DocumentCaptureStateProvider(_a) {
9186
9183
  drawToCanvas(canvas, videoTag);
9187
9184
  canvas.toBlob(onComplete);
9188
9185
  }
9189
- }, [state.capturing, videoStream, videoTag]);
9186
+ }, [state.capturing, videoTag]);
9190
9187
  var stateWithActions = useMemo(function () {
9191
9188
  return _assign(_assign({}, state), {
9192
9189
  uploadCapturedDocument: uploadCapturedDocument
@@ -9315,29 +9312,28 @@ var templateObject_1$u;
9315
9312
  var CameraVideoTag = function CameraVideoTag(props) {
9316
9313
  var _a = useCameraStore(useShallow(function (store) {
9317
9314
  return {
9315
+ cameraReady: store.cameraReady,
9318
9316
  videoRef: store.videoRef,
9319
- videoStream: store.videoStream,
9320
9317
  onVideoMounted: store.onVideoMounted,
9321
9318
  isRearFacing: store.isRearFacing
9322
9319
  };
9323
9320
  })),
9321
+ cameraReady = _a.cameraReady,
9324
9322
  videoRef = _a.videoRef,
9325
- videoStream = _a.videoStream,
9326
9323
  onVideoMounted = _a.onVideoMounted,
9327
9324
  isRearFacing = _a.isRearFacing;
9328
- useEffect(function attachCameraStreamToVideoTagWhenReady() {
9329
- if (videoRef.current && videoStream) {
9330
- debug('attaching camera stream to video tag');
9331
- // eslint-disable-next-line react-compiler/react-compiler
9332
- videoRef.current.srcObject = videoStream;
9333
- }
9334
- }, [videoStream, videoRef]);
9325
+ useEffect(function () {
9326
+ if (!cameraReady || !videoRef.current) return;
9327
+ debug('attaching camera stream to video tag');
9328
+ // eslint-disable-next-line react-compiler/react-compiler
9329
+ videoRef.current.srcObject = videoStream;
9330
+ }, [cameraReady, videoRef]);
9335
9331
  return /*#__PURE__*/React__default.createElement(FullscreenVideoTag, _assign({
9336
9332
  autoPlay: true,
9337
9333
  playsInline: true,
9338
9334
  muted: true,
9339
9335
  ref: videoRef,
9340
- onLoadedData: onVideoMounted,
9336
+ onCanPlay: onVideoMounted,
9341
9337
  "$isRearFacing": isRearFacing
9342
9338
  }, props));
9343
9339
  };
@@ -9374,7 +9370,6 @@ var DocumentCaptureScreen = function DocumentCaptureScreen(_a) {
9374
9370
  content = _k.content,
9375
9371
  uploadState = _k.uploadState;
9376
9372
  var _l = useCameraStore(),
9377
- videoStream = _l.videoStream,
9378
9373
  cameraReady = _l.cameraReady,
9379
9374
  cameraAccessDenied = _l.cameraAccessDenied,
9380
9375
  requestCameraAccess = _l.requestCameraAccess;
@@ -9389,7 +9384,7 @@ var DocumentCaptureScreen = function DocumentCaptureScreen(_a) {
9389
9384
  // and the user hasn't passed a media blob for the current document...
9390
9385
  !cameraAccessRequested &&
9391
9386
  // and we haven't already tried to force a camera request...
9392
- !(videoStream === null || videoStream === void 0 ? void 0 : videoStream.active); // and we don't already have camera access.
9387
+ !cameraReady; // and we don't already have camera access.
9393
9388
  useEffect(function requestCameraAccessIfNeeded() {
9394
9389
  if (!cameraAccessNeeded) return;
9395
9390
  setCameraAccessRequested(true);
@@ -10814,6 +10809,30 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
10814
10809
  debugMode: debugMode
10815
10810
  })));
10816
10811
  };
10812
+ function IdCaptureWizardWithProviders(_a) {
10813
+ var _b, _c, _d, _e, _f, _g;
10814
+ var onCameraAccessDenied = _a.onCameraAccessDenied,
10815
+ onCameraTamperingDetected = _a.onCameraTamperingDetected,
10816
+ onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied,
10817
+ shouldLoadIdCaptureModels = _a.shouldLoadIdCaptureModels,
10818
+ idCaptureProps = __rest(_a, ["onCameraAccessDenied", "onCameraTamperingDetected", "onMicrophoneAccessDenied", "shouldLoadIdCaptureModels"]);
10819
+ return /*#__PURE__*/React__default.createElement(CameraStoreProvider, {
10820
+ onCameraAccessDenied: onCameraAccessDenied,
10821
+ onCameraTamperingDetected: onCameraTamperingDetected,
10822
+ onMicrophoneAccessDenied: onMicrophoneAccessDenied,
10823
+ requestAccessAutomatically: shouldLoadIdCaptureModels,
10824
+ classNames: (_b = idCaptureProps.classNames) === null || _b === void 0 ? void 0 : _b.cameraStoreProvider,
10825
+ verbiage: (_c = idCaptureProps.verbiage) === null || _c === void 0 ? void 0 : _c.cameraStoreProvider
10826
+ }, /*#__PURE__*/React__default.createElement(IdCaptureModelsProvider, {
10827
+ autoStart: false,
10828
+ shouldLoadModels: shouldLoadIdCaptureModels,
10829
+ documentDetectionModelUrl: (_e = (_d = idCaptureProps.assets) === null || _d === void 0 ? void 0 : _d.documentDetectionModelUrl) !== null && _e !== void 0 ? _e : '',
10830
+ focusModelUrl: (_g = (_f = idCaptureProps.assets) === null || _f === void 0 ? void 0 : _f.focusModelUrl) !== null && _g !== void 0 ? _g : '',
10831
+ onModelError: idCaptureProps.onModelError,
10832
+ modelLoadTimeoutMs: idCaptureProps.modelLoadTimeoutMs,
10833
+ allowSinglePageIdCapture: idCaptureProps.allowSinglePageIdCapture
10834
+ }, /*#__PURE__*/React__default.createElement(IdCaptureStateProvider, null, /*#__PURE__*/React__default.createElement(GuideOrientationContextProvider, null, /*#__PURE__*/React__default.createElement(IdCaptureWizard, _assign({}, idCaptureProps))))));
10835
+ }
10817
10836
 
10818
10837
  function SelfieCaptureLoadingGraphic(_a) {
10819
10838
  var _b, _c, _d;
@@ -11827,9 +11846,6 @@ var SelfieCapture = function SelfieCapture(_a) {
11827
11846
  prediction = _o.prediction,
11828
11847
  dispatch = _m[1];
11829
11848
  var lastPredictionCanvas = useRef(null);
11830
- var camera = useCameraStore(useShallow(function (state) {
11831
- return state.camera;
11832
- }));
11833
11849
  var _p = useContext(SelfieGuidanceModelsContext),
11834
11850
  onPredictionMade = _p.onPredictionMade,
11835
11851
  canvasRef = _p.canvasRef,
@@ -13005,6 +13021,26 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
13005
13021
  waitForIdCaptureModels: waitForIdCaptureModels
13006
13022
  })));
13007
13023
  };
13024
+ function FaceLivenessWizardWithProviders(_a) {
13025
+ var _b, _c;
13026
+ var onCameraAccessDenied = _a.onCameraAccessDenied,
13027
+ onCameraTamperingDetected = _a.onCameraTamperingDetected,
13028
+ onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied,
13029
+ faceLivenessProps = __rest(_a, ["onCameraAccessDenied", "onCameraTamperingDetected", "onMicrophoneAccessDenied"]);
13030
+ return /*#__PURE__*/React__default.createElement(CameraStoreProvider, {
13031
+ preferFrontFacingCamera: true,
13032
+ preferIphoneContinuityCamera: false,
13033
+ onCameraAccessDenied: onCameraAccessDenied,
13034
+ onCameraTamperingDetected: onCameraTamperingDetected,
13035
+ onMicrophoneAccessDenied: onMicrophoneAccessDenied,
13036
+ classNames: (_b = faceLivenessProps.classNames) === null || _b === void 0 ? void 0 : _b.cameraStoreProvider,
13037
+ verbiage: (_c = faceLivenessProps.verbiage) === null || _c === void 0 ? void 0 : _c.cameraStoreProvider
13038
+ }, /*#__PURE__*/React__default.createElement(SelfieGuidanceModelsProvider, {
13039
+ autoStart: false,
13040
+ onModelError: faceLivenessProps.onModelError,
13041
+ modelLoadTimeoutMs: faceLivenessProps.modelLoadTimeoutMs
13042
+ }, /*#__PURE__*/React__default.createElement(FaceLivenessWizard, _assign({}, faceLivenessProps))));
13043
+ }
13008
13044
 
13009
13045
  var SubmissionSuccess = function SubmissionSuccess() {
13010
13046
  var _a = useContext(SubmissionContext),
@@ -13421,12 +13457,16 @@ var initialState$2 = {
13421
13457
  };
13422
13458
  var useVideoRecorderStore = create()(devtools(function (set, get) {
13423
13459
  return _assign(_assign({}, initialState$2), {
13424
- startRecordingVideo: function startRecordingVideo(camera, audioStream) {
13460
+ startRecordingVideo: function startRecordingVideo(captureAudio) {
13425
13461
  var _a, _b, _c;
13462
+ if (captureAudio === void 0) {
13463
+ captureAudio = false;
13464
+ }
13465
+ if (!camera) throw new Error('Camera not found');
13426
13466
  var _d = get(),
13427
13467
  mergeAVStreams = _d.mergeAVStreams,
13428
13468
  startRecordingAudio = _d.startRecordingAudio;
13429
- var videoStream = mergeAVStreams ? new MediaStream(__spreadArray(__spreadArray([], (_b = (_a = camera === null || camera === void 0 ? void 0 : camera.stream) === null || _a === void 0 ? void 0 : _a.getTracks()) !== null && _b !== void 0 ? _b : [], true), (_c = audioStream === null || audioStream === void 0 ? void 0 : audioStream.getTracks()) !== null && _c !== void 0 ? _c : [], true)) : camera.stream;
13469
+ var videoStream = mergeAVStreams ? new MediaStream(__spreadArray(__spreadArray([], (_b = (_a = camera === null || camera === void 0 ? void 0 : camera.stream) === null || _a === void 0 ? void 0 : _a.getTracks()) !== null && _b !== void 0 ? _b : [], true), captureAudio ? (_c = audioStream === null || audioStream === void 0 ? void 0 : audioStream.getTracks()) !== null && _c !== void 0 ? _c : [] : [], true)) : camera.stream;
13430
13470
  if (!videoStream) return;
13431
13471
  clearVideoChunks();
13432
13472
  videoRecorder = null;
@@ -13454,8 +13494,8 @@ var useVideoRecorderStore = create()(devtools(function (set, get) {
13454
13494
  // TODO: figure out what to do here
13455
13495
  }
13456
13496
  }, 100);
13457
- if (audioStream && !mergeAVStreams) {
13458
- startRecordingAudio(audioStream);
13497
+ if (captureAudio && !mergeAVStreams) {
13498
+ startRecordingAudio();
13459
13499
  }
13460
13500
  },
13461
13501
  stopRecordingVideo: function stopRecordingVideo() {
@@ -13466,7 +13506,7 @@ var useVideoRecorderStore = create()(devtools(function (set, get) {
13466
13506
  videoRecorder === null || videoRecorder === void 0 ? void 0 : videoRecorder.stop(); // if you call this while state === 'inactive', an exception is thrown.
13467
13507
  }
13468
13508
  },
13469
- startRecordingAudio: function startRecordingAudio(audioStream) {
13509
+ startRecordingAudio: function startRecordingAudio() {
13470
13510
  if (get().mergeAVStreams) return;
13471
13511
  if (!audioStream) return;
13472
13512
  clearAudioChunks();
@@ -13600,18 +13640,19 @@ var videoSignatureInitialState = {
13600
13640
  };
13601
13641
  var useVideoSignatureStore = create()(devtools(function (set, get) {
13602
13642
  return _assign(_assign({}, videoSignatureInitialState), {
13603
- startRecording: function startRecording(camera, audioStream, captureAudio) {
13643
+ startRecording: function startRecording(captureAudio) {
13604
13644
  var _a;
13605
13645
  if (captureAudio === void 0) {
13606
13646
  captureAudio = false;
13607
13647
  }
13648
+ if (!camera) throw new Error('Camera not found');
13608
13649
  // set our flag and clear whatever we have recorded so far.
13609
13650
  set({
13610
13651
  isRecording: true
13611
13652
  });
13612
13653
  signatureChunks = [];
13613
13654
  // start recording video and audio
13614
- useVideoRecorderStore.getState().startRecordingVideo(camera, captureAudio ? audioStream : undefined);
13655
+ useVideoRecorderStore.getState().startRecordingVideo(captureAudio);
13615
13656
  // start recording from the output canvas to capture the signature
13616
13657
  var videoStream = get().outputCanvas.current.captureStream(24); // fps
13617
13658
  var tracks = [videoStream.getVideoTracks()[0]];
@@ -13905,14 +13946,10 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
13905
13946
  debugMode = _l === void 0 ? false : _l;
13906
13947
  var _m = useCameraStore(useShallow(function (state) {
13907
13948
  return {
13908
- camera: state.camera,
13909
- audioStream: state.audioStream,
13910
13949
  videoWidth: state.videoWidth,
13911
13950
  videoHeight: state.videoHeight
13912
13951
  };
13913
13952
  })),
13914
- camera = _m.camera,
13915
- audioStream = _m.audioStream,
13916
13953
  videoWidth = _m.videoWidth,
13917
13954
  videoHeight = _m.videoHeight;
13918
13955
  var _o = useSelfieGuidanceModelsContext(),
@@ -13920,8 +13957,6 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
13920
13957
  startHeadTracking = _o.start,
13921
13958
  stopHeadTracking = _o.stop;
13922
13959
  var _p = useVideoSignatureStore(),
13923
- startRecording = _p.startRecording,
13924
- stopRecording = _p.stopRecording,
13925
13960
  clearRecordedData = _p.clearRecordedData,
13926
13961
  isRecording = _p.isRecording;
13927
13962
  useEffect(function () {
@@ -13930,10 +13965,11 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
13930
13965
  });
13931
13966
  }, [onSignatureVideoCaptured]);
13932
13967
  useEffect(function () {
13933
- if (!camera) return;
13934
- startRecording(camera, audioStream, captureAudio);
13935
- return stopRecording;
13936
- }, [audioStream, camera, captureAudio, startRecording, stopRecording]);
13968
+ useVideoSignatureStore.getState().startRecording(captureAudio);
13969
+ return function () {
13970
+ return useVideoSignatureStore.getState().stopRecording();
13971
+ };
13972
+ }, [captureAudio]);
13937
13973
  useEffect(function () {
13938
13974
  setTimeout(startHeadTracking, 1);
13939
13975
  return stopHeadTracking;
@@ -13954,7 +13990,7 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
13954
13990
  setNumFramesWithoutFaces = _s[1];
13955
13991
  onHeadTrackingPredictionMade(useThrottledCallback(useCallback(function (_a) {
13956
13992
  var face = _a.face;
13957
- if (!camera || headTrackingDisabled) return;
13993
+ if (headTrackingDisabled) return;
13958
13994
  var leftEdge = videoWidth * headTrackingBoundaryPercentage;
13959
13995
  var rightEdge = videoWidth * (1 - headTrackingBoundaryPercentage);
13960
13996
  var topEdge = videoHeight * headTrackingBoundaryPercentage;
@@ -13965,7 +14001,7 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
13965
14001
  setNumFramesWithoutFaces(face ? 0 : function (n) {
13966
14002
  return n + 1;
13967
14003
  });
13968
- }, [camera, headTrackingBoundaryPercentage, headTrackingBoundaryType, headTrackingDisabled, videoHeight, videoWidth]), 16));
14004
+ }, [headTrackingBoundaryPercentage, headTrackingBoundaryType, headTrackingDisabled, videoHeight, videoWidth]), 16));
13969
14005
  var _t = useResizeObserver(),
13970
14006
  ref = _t.ref,
13971
14007
  _u = _t.width,
@@ -14008,7 +14044,7 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
14008
14044
  face: lastFace,
14009
14045
  scaling: debugScalingDetails,
14010
14046
  color: headTrackingSatisfied ? 'green' : 'red'
14011
- }))), /*#__PURE__*/React__default.createElement(DebugStatsPane, null, "Video: ", camera === null || camera === void 0 ? void 0 : camera.width, "x", camera === null || camera === void 0 ? void 0 : camera.height, /*#__PURE__*/React__default.createElement("br", null), "Recording: ", isRecording ? 'true' : 'false'))), /*#__PURE__*/React__default.createElement(ExitCaptureButton, {
14047
+ }))), /*#__PURE__*/React__default.createElement(DebugStatsPane, null, "Video: ", videoWidth, "x", videoHeight, /*#__PURE__*/React__default.createElement("br", null), "Recording: ", isRecording ? 'true' : 'false'))), /*#__PURE__*/React__default.createElement(ExitCaptureButton, {
14012
14048
  onClick: onExit,
14013
14049
  className: classNames.exitCaptureBtn
14014
14050
  }));
@@ -14514,9 +14550,6 @@ function VideoSignatureWizardGuides(_a) {
14514
14550
  component = _a.component,
14515
14551
  props = __rest(_a, ["status", "restartVideoOnSignaturePadCleared", "captureAudio", "component"]);
14516
14552
  var Component = component !== null && component !== void 0 ? component : VideoSignatureGuides;
14517
- var _d = useCameraStore(),
14518
- camera = _d.camera,
14519
- audioStream = _d.audioStream;
14520
14553
  var onAcceptBtnClicked = useCallback(function () {
14521
14554
  var signaturePad = useVideoSignatureStore.getState().signaturePad;
14522
14555
  if (!signaturePad.current) throw new Error('Signature pad not found');
@@ -14538,11 +14571,11 @@ function VideoSignatureWizardGuides(_a) {
14538
14571
  setTimeout(function () {
14539
14572
  useVideoSignatureStore.getState().clearRecordedData();
14540
14573
  setTimeout(function () {
14541
- useVideoSignatureStore.getState().startRecording(camera, audioStream, captureAudio);
14574
+ useVideoSignatureStore.getState().startRecording(captureAudio);
14542
14575
  }, 100);
14543
14576
  }, 100);
14544
14577
  }
14545
- }, [audioStream, camera, captureAudio, restartVideoOnSignaturePadCleared]);
14578
+ }, [captureAudio, restartVideoOnSignaturePadCleared]);
14546
14579
  return /*#__PURE__*/React__default.createElement(Component, _assign({}, props, {
14547
14580
  faceGuideStatus: status,
14548
14581
  onAcceptBtnClicked: onAcceptBtnClicked,
@@ -14896,12 +14929,10 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14896
14929
  _9 = _7.height,
14897
14930
  height = _9 === void 0 ? 1 : _9;
14898
14931
  var _10 = useCameraStore(),
14899
- camera = _10.camera,
14900
14932
  videoRef = _10.videoRef,
14901
14933
  videoLoaded = _10.videoLoaded,
14902
14934
  cameraReady = _10.cameraReady,
14903
14935
  microphoneReady = _10.microphoneReady,
14904
- audioStream = _10.audioStream,
14905
14936
  isRearFacing = _10.isRearFacing,
14906
14937
  releaseCameraAccess = _10.releaseCameraAccess;
14907
14938
  var _11 = useState([]),
@@ -14943,8 +14974,8 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14943
14974
  countdownRemaining = _18[0],
14944
14975
  setCountdownRemaining = _18[1];
14945
14976
  useEffect(function () {
14946
- if (camera && !isRecordingVideo && !videoUrl) {
14947
- useVideoRecorderStore.getState().startRecordingVideo(camera, audioStream);
14977
+ if (!isRecordingVideo && !videoUrl) {
14978
+ useVideoRecorderStore.getState().startRecordingVideo();
14948
14979
  setVideoStartsAt(new Date());
14949
14980
  }
14950
14981
  // if the mergeAVStreams flag is present, the audio stream is on the video
@@ -14955,7 +14986,7 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14955
14986
  releaseCameraAccess();
14956
14987
  onComplete === null || onComplete === void 0 ? void 0 : onComplete(videoUrl, audioUrl);
14957
14988
  }
14958
- }, [audioStream, audioUrl, camera, isRecordingVideo, mergeAVStreams, onComplete, readTextPrompt, releaseCameraAccess, videoUrl]);
14989
+ }, [audioUrl, isRecordingVideo, mergeAVStreams, onComplete, readTextPrompt, releaseCameraAccess, videoUrl]);
14959
14990
  useEffect(function () {
14960
14991
  if (videoRecordingUnintentionallyStopped || audioRecordingUnintentionallyStopped || !!readTextPrompt && !microphoneReady) {
14961
14992
  onRecordingFailed === null || onRecordingFailed === void 0 ? void 0 : onRecordingFailed();
@@ -15050,14 +15081,14 @@ var IdVideoCapture = function IdVideoCapture(_a) {
15050
15081
  var _a;
15051
15082
  if (translatedText) {
15052
15083
  setRequestedAction('READ_TEXT');
15053
- useVideoRecorderStore.getState().startRecordingAudio(audioStream);
15084
+ useVideoRecorderStore.getState().startRecordingAudio();
15054
15085
  setIdCaptureVideoAudioStartsAt(new Date().getTime() - ((_a = videoStartsAt === null || videoStartsAt === void 0 ? void 0 : videoStartsAt.getTime()) !== null && _a !== void 0 ? _a : 0));
15055
15086
  var renderedTranslatedText = typeof translatedText === 'string' ? translatedText : renderToString(translatedText);
15056
15087
  setExpectedAudioText(renderedTranslatedText);
15057
15088
  } else {
15058
15089
  useVideoRecorderStore.getState().stopRecordingVideo();
15059
15090
  }
15060
- }, [audioStream, setExpectedAudioText, setIdCaptureVideoAudioStartsAt, translatedText, videoStartsAt]);
15091
+ }, [setExpectedAudioText, setIdCaptureVideoAudioStartsAt, translatedText, videoStartsAt]);
15061
15092
  var frameWidth = (_c = (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth) !== null && _c !== void 0 ? _c : 0;
15062
15093
  var frameHeight = (_e = (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) !== null && _e !== void 0 ? _e : 0;
15063
15094
  var faceBox = face === null || face === void 0 ? void 0 : face.box;
@@ -15689,36 +15720,36 @@ var VideoIdWizard = function VideoIdWizard(_a) {
15689
15720
  };
15690
15721
 
15691
15722
  function CompositeWizard(_a) {
15692
- var _b, _c, _d, _e, _f, _g, _h, _j, _k;
15723
+ var _b;
15693
15724
  var userChecks = _a.checks,
15694
- _l = _a.idCaptureProps,
15695
- idCaptureProps = _l === void 0 ? {} : _l,
15696
- _m = _a.faceLivenessProps,
15697
- faceLivenessProps = _m === void 0 ? {} : _m,
15725
+ _c = _a.idCaptureProps,
15726
+ idCaptureProps = _c === void 0 ? {} : _c,
15727
+ _d = _a.faceLivenessProps,
15728
+ faceLivenessProps = _d === void 0 ? {} : _d,
15698
15729
  additionalDocumentCaptureProps = _a.additionalDocumentCaptureProps,
15699
- _o = _a.signatureCaptureProps,
15700
- signatureCaptureProps = _o === void 0 ? {} : _o,
15701
- _p = _a.videoSignatureCaptureProps,
15702
- videoSignatureCaptureProps = _p === void 0 ? {} : _p,
15703
- _q = _a.videoIdCaptureProps,
15704
- videoIdCaptureProps = _q === void 0 ? {} : _q,
15705
- _r = _a.captureSignature,
15706
- captureSignature = _r === void 0 ? false : _r,
15707
- _s = _a.captureSignatureVideo,
15708
- captureSignatureVideo = _s === void 0 ? false : _s,
15730
+ _e = _a.signatureCaptureProps,
15731
+ signatureCaptureProps = _e === void 0 ? {} : _e,
15732
+ _f = _a.videoSignatureCaptureProps,
15733
+ videoSignatureCaptureProps = _f === void 0 ? {} : _f,
15734
+ _g = _a.videoIdCaptureProps,
15735
+ videoIdCaptureProps = _g === void 0 ? {} : _g,
15736
+ _h = _a.captureSignature,
15737
+ captureSignature = _h === void 0 ? false : _h,
15738
+ _j = _a.captureSignatureVideo,
15739
+ captureSignatureVideo = _j === void 0 ? false : _j,
15709
15740
  onCameraAccessDenied = _a.onCameraAccessDenied,
15710
15741
  onCameraTamperingDetected = _a.onCameraTamperingDetected,
15711
15742
  onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied,
15712
- _t = _a.debugMode,
15713
- debugMode = _t === void 0 ? false : _t;
15714
- var _u = useContext(SubmissionContext),
15715
- submit = _u.submit,
15716
- submissionStatus = _u.submissionStatus,
15717
- setSignatureData = _u.setSignatureData,
15718
- setAdditionalDocuments = _u.setAdditionalDocuments;
15719
- var _v = useState(0),
15720
- checkIndex = _v[0],
15721
- setCheckIndex = _v[1];
15743
+ _k = _a.debugMode,
15744
+ debugMode = _k === void 0 ? false : _k;
15745
+ var _l = useContext(SubmissionContext),
15746
+ submit = _l.submit,
15747
+ submissionStatus = _l.submissionStatus,
15748
+ setSignatureData = _l.setSignatureData,
15749
+ setAdditionalDocuments = _l.setAdditionalDocuments;
15750
+ var _m = useState(0),
15751
+ checkIndex = _m[0],
15752
+ setCheckIndex = _m[1];
15722
15753
  var checks = useMemo(function () {
15723
15754
  var _a, _b;
15724
15755
  var checks = __spreadArray([], userChecks, true);
@@ -15825,24 +15856,13 @@ function CompositeWizard(_a) {
15825
15856
  var shouldLoadIdCaptureModels = !(idCaptureProps === null || idCaptureProps === void 0 ? void 0 : idCaptureProps.forceFallbackMode) && !(idCaptureProps === null || idCaptureProps === void 0 ? void 0 : idCaptureProps.allowUploadingDocumentsFromStorage);
15826
15857
  switch (checks[checkIndex]) {
15827
15858
  case 'IdCapture':
15828
- return /*#__PURE__*/React__default.createElement(CameraStoreProvider, {
15859
+ return /*#__PURE__*/React__default.createElement(IdCaptureWizardWithProviders, _assign({}, idCaptureProps, {
15829
15860
  onCameraAccessDenied: onCameraAccessDenied,
15830
15861
  onCameraTamperingDetected: onCameraTamperingDetected,
15831
15862
  onMicrophoneAccessDenied: onMicrophoneAccessDenied,
15832
- requestAccessAutomatically: shouldLoadIdCaptureModels,
15833
- classNames: (_c = idCaptureProps.classNames) === null || _c === void 0 ? void 0 : _c.cameraStoreProvider,
15834
- verbiage: (_d = idCaptureProps.verbiage) === null || _d === void 0 ? void 0 : _d.cameraStoreProvider
15835
- }, /*#__PURE__*/React__default.createElement(IdCaptureModelsProvider, {
15836
- autoStart: false,
15837
- shouldLoadModels: shouldLoadIdCaptureModels,
15838
- documentDetectionModelUrl: (_f = (_e = idCaptureProps.assets) === null || _e === void 0 ? void 0 : _e.documentDetectionModelUrl) !== null && _f !== void 0 ? _f : '',
15839
- focusModelUrl: (_h = (_g = idCaptureProps.assets) === null || _g === void 0 ? void 0 : _g.focusModelUrl) !== null && _h !== void 0 ? _h : '',
15840
- onModelError: idCaptureProps.onModelError,
15841
- modelLoadTimeoutMs: idCaptureProps.modelLoadTimeoutMs,
15842
- allowSinglePageIdCapture: idCaptureProps.allowSinglePageIdCapture
15843
- }, /*#__PURE__*/React__default.createElement(IdCaptureStateProvider, null, /*#__PURE__*/React__default.createElement(GuideOrientationContextProvider, null, /*#__PURE__*/React__default.createElement(IdCaptureWizard, _assign({}, idCaptureProps, {
15863
+ shouldLoadIdCaptureModels: shouldLoadIdCaptureModels,
15844
15864
  onSuccess: onIdCaptureSuccess
15845
- }))))));
15865
+ }));
15846
15866
  case 'VideoIdCapture':
15847
15867
  return /*#__PURE__*/React__default.createElement(VideoIdWizard, _assign({}, videoIdCaptureProps, {
15848
15868
  onComplete: onVideoIdCaptureComplete,
@@ -15851,21 +15871,12 @@ function CompositeWizard(_a) {
15851
15871
  onMicrophoneAccessDenied: onMicrophoneAccessDenied
15852
15872
  }));
15853
15873
  case 'FaceLiveness':
15854
- return /*#__PURE__*/React__default.createElement(CameraStoreProvider, {
15855
- preferFrontFacingCamera: true,
15856
- preferIphoneContinuityCamera: false,
15874
+ return /*#__PURE__*/React__default.createElement(FaceLivenessWizardWithProviders, _assign({}, faceLivenessProps, {
15857
15875
  onCameraAccessDenied: onCameraAccessDenied,
15858
15876
  onCameraTamperingDetected: onCameraTamperingDetected,
15859
15877
  onMicrophoneAccessDenied: onMicrophoneAccessDenied,
15860
- classNames: (_j = faceLivenessProps.classNames) === null || _j === void 0 ? void 0 : _j.cameraStoreProvider,
15861
- verbiage: (_k = faceLivenessProps.verbiage) === null || _k === void 0 ? void 0 : _k.cameraStoreProvider
15862
- }, /*#__PURE__*/React__default.createElement(SelfieGuidanceModelsProvider, {
15863
- autoStart: false,
15864
- onModelError: faceLivenessProps.onModelError,
15865
- modelLoadTimeoutMs: faceLivenessProps.modelLoadTimeoutMs
15866
- }, /*#__PURE__*/React__default.createElement(FaceLivenessWizard, _assign({}, faceLivenessProps, {
15867
15878
  onComplete: onFaceLivenessComplete
15868
- }))));
15879
+ }));
15869
15880
  case 'SignatureCapture':
15870
15881
  return /*#__PURE__*/React__default.createElement(SignatureCapture, _assign({}, signatureCaptureProps, {
15871
15882
  onAccept: onSignatureCaptureSuccess