idmission-web-sdk 2.3.14 → 2.3.16

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
@@ -204,7 +204,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
204
204
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
205
205
  };
206
206
 
207
- var webSdkVersion = '2.3.14';
207
+ var webSdkVersion = '2.3.16';
208
208
 
209
209
  function getPlatform() {
210
210
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -822,11 +822,11 @@ function setDefaultAuthUrl(url) {
822
822
  if (!allowedAuthUrls.includes(url)) throw new Error('invalid auth url');
823
823
  defaultAuthUrl = url;
824
824
  }
825
- var initialState$6 = {
825
+ var initialState$7 = {
826
826
  authUrl: defaultAuthUrl,
827
827
  sessionCheckState: 'READY'
828
828
  };
829
- var AuthStateContext = /*#__PURE__*/createContext(initialState$6);
829
+ var AuthStateContext = /*#__PURE__*/createContext(initialState$7);
830
830
  var AuthDispatchContext = /*#__PURE__*/createContext(function () {});
831
831
  var reducer$4 = function reducer(state, action) {
832
832
  switch (action.type) {
@@ -945,7 +945,7 @@ function useAuthReducer(authUrl, sessionId) {
945
945
  if (authUrl === void 0) {
946
946
  authUrl = defaultAuthUrl;
947
947
  }
948
- var _a = useReducer(reducer$4, _assign(_assign({}, initialState$6), {
948
+ var _a = useReducer(reducer$4, _assign(_assign({}, initialState$7), {
949
949
  authUrl: authUrl
950
950
  })),
951
951
  state = _a[0],
@@ -4742,7 +4742,7 @@ function useTranslations(verbiage, fallbacks) {
4742
4742
  }, [fallbacks, i18n.language, t, verbiage]);
4743
4743
  }
4744
4744
 
4745
- var initialState$5 = {
4745
+ var initialState$6 = {
4746
4746
  videoRef: {
4747
4747
  current: null
4748
4748
  },
@@ -4765,9 +4765,9 @@ var initialState$5 = {
4765
4765
  };
4766
4766
  var createCameraStore = function createCameraStore(config) {
4767
4767
  var store = createStore(function (set, get) {
4768
- return _assign(_assign(_assign({}, initialState$5), config), {
4768
+ return _assign(_assign(_assign({}, initialState$6), config), {
4769
4769
  reset: function reset() {
4770
- return set(_assign(_assign({}, initialState$5), config));
4770
+ return set(_assign(_assign({}, initialState$6), config));
4771
4771
  },
4772
4772
  setConfig: function setConfig(config) {
4773
4773
  return set(config);
@@ -5784,7 +5784,7 @@ function remainingIdCaptureRequirements(captureRequirement, capturedDocuments, r
5784
5784
  });
5785
5785
  }
5786
5786
 
5787
- var initialState$4 = {
5787
+ var initialState$5 = {
5788
5788
  initialDrawComplete: false,
5789
5789
  redrawing: false,
5790
5790
  guideRectX: 0,
@@ -6144,7 +6144,7 @@ var _reducer = function reducer(state, action) {
6144
6144
  });
6145
6145
  }
6146
6146
  case 'resetWizard':
6147
- return _assign(_assign({}, initialState$4), {
6147
+ return _assign(_assign({}, initialState$5), {
6148
6148
  dispatch: state.dispatch,
6149
6149
  allowUploadingDocumentsFromStorage: state.allowUploadingDocumentsFromStorage,
6150
6150
  captureState: state.allowUploadingDocumentsFromStorage ? 'initializing' : 'capturing',
@@ -6156,7 +6156,7 @@ var _reducer = function reducer(state, action) {
6156
6156
  }
6157
6157
  };
6158
6158
  var useIdCaptureStore = create()(devtools(function (set) {
6159
- return _assign(_assign({}, initialState$4), {
6159
+ return _assign(_assign({}, initialState$5), {
6160
6160
  dispatch: function dispatch(action) {
6161
6161
  return set(function (state) {
6162
6162
  return _reducer(state, action);
@@ -11700,7 +11700,7 @@ var ImageContainer$6 = styled(OverlayImageContainer)(templateObject_4$8 || (temp
11700
11700
  var StyledButtonsRow$6 = styled(ButtonsRow$2)(templateObject_5$5 || (templateObject_5$5 = __makeTemplateObject(["\n margin-top: 32px;\n"], ["\n margin-top: 32px;\n"])));
11701
11701
  var templateObject_1$m, templateObject_2$i, templateObject_3$d, templateObject_4$8, templateObject_5$5;
11702
11702
 
11703
- var initialState$3 = {
11703
+ var initialState$4 = {
11704
11704
  busy: false,
11705
11705
  frame: null,
11706
11706
  prediction: null
@@ -11755,7 +11755,7 @@ var SelfieCapture = function SelfieCapture(_a) {
11755
11755
  width = _k === void 0 ? 1 : _k,
11756
11756
  _l = _j.height,
11757
11757
  height = _l === void 0 ? 1 : _l;
11758
- var _m = useReducer(reducer$3, initialState$3),
11758
+ var _m = useReducer(reducer$3, initialState$4),
11759
11759
  _o = _m[0],
11760
11760
  busy = _o.busy,
11761
11761
  prediction = _o.prediction,
@@ -11865,7 +11865,7 @@ var SelfieCapture = function SelfieCapture(_a) {
11865
11865
  var Container$6 = styled.div(templateObject_1$l || (templateObject_1$l = __makeTemplateObject(["\n width: 100%;\n height: 100%;\n"], ["\n width: 100%;\n height: 100%;\n"])));
11866
11866
  var templateObject_1$l;
11867
11867
 
11868
- var initialState$2 = {
11868
+ var initialState$3 = {
11869
11869
  frame: null,
11870
11870
  face: null,
11871
11871
  requestState: 'CAPTURING',
@@ -11882,7 +11882,7 @@ var reducer$2 = function reducer(state, action) {
11882
11882
  var _a, _b;
11883
11883
  switch (action.type) {
11884
11884
  case 'resetLivenessCheck':
11885
- return _assign(_assign({}, initialState$2), {
11885
+ return _assign(_assign({}, initialState$3), {
11886
11886
  timesLivenessCheckFailed: state.timesLivenessCheckFailed
11887
11887
  });
11888
11888
  case 'guidanceUnsatisfied':
@@ -11990,7 +11990,7 @@ var FaceLivenessCapture = function FaceLivenessCapture(_a) {
11990
11990
  checkLiveness = _m.checkLiveness,
11991
11991
  submissionError = _m.submissionError;
11992
11992
  var modelError = useSelfieGuidanceModelsContext().error;
11993
- var _o = useReducer(reducer$2, initialState$2),
11993
+ var _o = useReducer(reducer$2, initialState$3),
11994
11994
  state = _o[0],
11995
11995
  dispatch = _o[1];
11996
11996
  var _p = useState(null),
@@ -13345,120 +13345,141 @@ function clearVideoChunks() {
13345
13345
  function clearAudioChunks() {
13346
13346
  audioChunks = [];
13347
13347
  }
13348
- var useVideoRecorder = function useVideoRecorder(camera, audioStream, mergeAVStreams) {
13348
+ var initialState$2 = {
13349
+ videoUrl: null,
13350
+ audioUrl: null,
13351
+ isRecordingVideo: false,
13352
+ isRecordingAudio: false,
13353
+ videoRecordingStopped: false,
13354
+ audioRecordingStopped: false,
13355
+ videoRecordingIntentionallyStopped: false,
13356
+ audioRecordingIntentionallyStopped: false,
13357
+ mergeAVStreams: false
13358
+ };
13359
+ var useVideoRecorderStore = create()(devtools(function (set, get) {
13360
+ return _assign(_assign({}, initialState$2), {
13361
+ startRecordingVideo: function startRecordingVideo(camera, audioStream) {
13362
+ var _a, _b, _c;
13363
+ var videoStream = get().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;
13364
+ if (!videoStream) return;
13365
+ clearVideoChunks();
13366
+ setVideoRecorder(null);
13367
+ set({
13368
+ isRecordingVideo: true,
13369
+ videoRecordingStopped: false,
13370
+ videoRecordingIntentionallyStopped: false
13371
+ });
13372
+ var videoRecorder = new MediaRecorder(videoStream, {
13373
+ videoBitsPerSecond: 270000,
13374
+ audioBitsPerSecond: 32000
13375
+ });
13376
+ setVideoRecorder(videoRecorder);
13377
+ videoRecorder.ondataavailable = function (e) {
13378
+ videoChunks.push(e.data);
13379
+ };
13380
+ videoRecorder.onstop = function () {
13381
+ set({
13382
+ videoRecordingStopped: true
13383
+ });
13384
+ };
13385
+ videoRecorder.start(1000);
13386
+ setTimeout(function () {
13387
+ var videoRecorder = getVideoRecorder();
13388
+ if (!videoRecorder || videoRecorder.state === 'inactive') {
13389
+ log('media recorder is inactive!');
13390
+ // TODO: figure out what to do here
13391
+ }
13392
+ }, 100);
13393
+ },
13394
+ stopRecordingVideo: function stopRecordingVideo() {
13395
+ set({
13396
+ videoRecordingIntentionallyStopped: true
13397
+ });
13398
+ if ((videoRecorder === null || videoRecorder === void 0 ? void 0 : videoRecorder.state) !== 'inactive') {
13399
+ videoRecorder === null || videoRecorder === void 0 ? void 0 : videoRecorder.stop(); // if you call this while state === 'inactive', an exception is thrown.
13400
+ }
13401
+ },
13402
+ startRecordingAudio: function startRecordingAudio(audioStream) {
13403
+ if (get().mergeAVStreams) return;
13404
+ if (!audioStream) return;
13405
+ clearAudioChunks();
13406
+ set({
13407
+ isRecordingAudio: true,
13408
+ audioRecordingStopped: false,
13409
+ audioRecordingIntentionallyStopped: false
13410
+ });
13411
+ var audioRecorder = new MediaRecorder(audioStream, {
13412
+ audioBitsPerSecond: 32000
13413
+ });
13414
+ setAudioRecorder(audioRecorder);
13415
+ audioRecorder.ondataavailable = function (e) {
13416
+ audioChunks.push(e.data);
13417
+ };
13418
+ audioRecorder.onstop = function () {
13419
+ set({
13420
+ audioRecordingStopped: true
13421
+ });
13422
+ };
13423
+ audioRecorder.start(1000);
13424
+ },
13425
+ stopRecordingAudio: function stopRecordingAudio() {
13426
+ set({
13427
+ audioRecordingIntentionallyStopped: true
13428
+ });
13429
+ if ((audioRecorder === null || audioRecorder === void 0 ? void 0 : audioRecorder.state) !== 'inactive') {
13430
+ audioRecorder === null || audioRecorder === void 0 ? void 0 : audioRecorder.stop(); // if you call this while state === 'inactive', an exception is thrown.
13431
+ }
13432
+ },
13433
+ stopRecording: function stopRecording() {
13434
+ get().stopRecordingVideo();
13435
+ get().stopRecordingAudio();
13436
+ },
13437
+ clearRecordedData: function clearRecordedData() {
13438
+ clearVideoChunks();
13439
+ clearAudioChunks();
13440
+ }
13441
+ });
13442
+ }));
13443
+ var useVideoRecorder = function useVideoRecorder(mergeAVStreams) {
13349
13444
  if (mergeAVStreams === void 0) {
13350
13445
  mergeAVStreams = false;
13351
13446
  }
13352
- var _a = useState(null),
13353
- videoUrl = _a[0],
13354
- setVideoUrl = _a[1];
13355
- var _b = useState(null),
13356
- audioUrl = _b[0],
13357
- setAudioUrl = _b[1];
13358
- var _c = useState(false),
13359
- isRecordingVideo = _c[0],
13360
- setIsRecordingVideo = _c[1];
13361
- var _d = useState(false),
13362
- isRecordingAudio = _d[0],
13363
- setIsRecordingAudio = _d[1];
13364
- var _e = useState(false),
13365
- videoRecordingStopped = _e[0],
13366
- setVideoRecordingStopped = _e[1];
13367
- var _f = useState(false),
13368
- audioRecordingStopped = _f[0],
13369
- setAudioRecordingStopped = _f[1];
13370
- var _g = useState(false),
13371
- videoRecordingIntentionallyStopped = _g[0],
13372
- setVideoRecordingIntentionallyStopped = _g[1];
13373
- var _h = useState(false),
13374
- audioRecordingIntentionallyStopped = _h[0],
13375
- setAudioRecordingIntentionallyStopped = _h[1];
13376
- var getVideoStream = useCallback(function () {
13377
- var _a, _b, _c;
13378
- if (!mergeAVStreams) return camera === null || camera === void 0 ? void 0 : camera.stream;
13379
- var videoTracks = (_b = (_a = camera === null || camera === void 0 ? void 0 : camera.stream) === null || _a === void 0 ? void 0 : _a.getTracks()) !== null && _b !== void 0 ? _b : [];
13380
- var audioTracks = (_c = audioStream === null || audioStream === void 0 ? void 0 : audioStream.getTracks()) !== null && _c !== void 0 ? _c : [];
13381
- return new MediaStream(__spreadArray(__spreadArray([], videoTracks, true), audioTracks, true));
13382
- }, [audioStream, camera === null || camera === void 0 ? void 0 : camera.stream, mergeAVStreams]);
13447
+ useEffect(function () {
13448
+ return useVideoRecorderStore.setState({
13449
+ mergeAVStreams: mergeAVStreams
13450
+ });
13451
+ }, [mergeAVStreams]);
13383
13452
  var processVideo = useCallback(function () {
13384
13453
  var videoBlob = new Blob(videoChunks, {
13385
13454
  type: 'video/mp4'
13386
13455
  });
13387
- setVideoUrl(URL.createObjectURL(videoBlob));
13456
+ useVideoRecorderStore.setState({
13457
+ videoUrl: URL.createObjectURL(videoBlob),
13458
+ isRecordingVideo: false
13459
+ });
13388
13460
  clearVideoChunks();
13389
- setIsRecordingVideo(false);
13390
13461
  setVideoRecorder(null);
13391
- camera === null || camera === void 0 ? void 0 : camera.release();
13392
- }, [camera]);
13462
+ }, []);
13393
13463
  var processAudio = useCallback(function () {
13394
- var _a;
13395
13464
  var audioBlob = new Blob(audioChunks, {
13396
13465
  type: 'audio/mp4'
13397
13466
  });
13398
- setAudioUrl(URL.createObjectURL(audioBlob));
13399
- clearAudioChunks();
13400
- setIsRecordingAudio(false);
13401
- setAudioRecorder(null);
13402
- (_a = audioStream === null || audioStream === void 0 ? void 0 : audioStream.stop) === null || _a === void 0 ? void 0 : _a.call(audioStream);
13403
- }, [audioStream]);
13404
- var startRecordingVideo = useCallback(function () {
13405
- var videoStream = getVideoStream();
13406
- if (!videoStream) return;
13407
- clearVideoChunks();
13408
- setIsRecordingVideo(true);
13409
- setVideoRecordingStopped(false);
13410
- setVideoRecordingIntentionallyStopped(false);
13411
- var videoRecorder = new MediaRecorder(videoStream, {
13412
- videoBitsPerSecond: 270000,
13413
- audioBitsPerSecond: 32000
13467
+ useVideoRecorderStore.setState({
13468
+ audioUrl: URL.createObjectURL(audioBlob),
13469
+ isRecordingAudio: false
13414
13470
  });
13415
- setVideoRecorder(videoRecorder);
13416
- videoRecorder.ondataavailable = function (e) {
13417
- videoChunks.push(e.data);
13418
- };
13419
- videoRecorder.onstop = function () {
13420
- setVideoRecordingStopped(true);
13421
- };
13422
- videoRecorder.start(1000);
13423
- setTimeout(function () {
13424
- var _a;
13425
- if (((_a = getVideoRecorder()) === null || _a === void 0 ? void 0 : _a.state) === 'inactive') {
13426
- log('media recorder is inactive!');
13427
- // TODO: figure out what to do here
13428
- }
13429
- }, 100);
13430
- }, [getVideoStream]);
13431
- var startRecordingAudio = useCallback(function () {
13432
- if (mergeAVStreams) return;
13433
- if (!audioStream) return;
13434
13471
  clearAudioChunks();
13435
- setIsRecordingAudio(true);
13436
- setAudioRecordingStopped(false);
13437
- setAudioRecordingIntentionallyStopped(false);
13438
- var audioRecorder = new MediaRecorder(audioStream, {
13439
- audioBitsPerSecond: 32000
13440
- });
13441
- setAudioRecorder(audioRecorder);
13442
- audioRecorder.ondataavailable = function (e) {
13443
- audioChunks.push(e.data);
13444
- };
13445
- audioRecorder.onstop = function () {
13446
- setAudioRecordingStopped(true);
13447
- };
13448
- audioRecorder.start(1000);
13449
- }, [audioStream, mergeAVStreams]);
13450
- var stopRecordingVideo = useCallback(function () {
13451
- setVideoRecordingIntentionallyStopped(true);
13452
- if ((videoRecorder === null || videoRecorder === void 0 ? void 0 : videoRecorder.state) !== 'inactive') {
13453
- videoRecorder === null || videoRecorder === void 0 ? void 0 : videoRecorder.stop(); // if you call this while state === 'inactive', an exception is thrown.
13454
- }
13455
- }, []);
13456
- var stopRecordingAudio = useCallback(function () {
13457
- setAudioRecordingIntentionallyStopped(true);
13458
- if ((audioRecorder === null || audioRecorder === void 0 ? void 0 : audioRecorder.state) !== 'inactive') {
13459
- audioRecorder === null || audioRecorder === void 0 ? void 0 : audioRecorder.stop(); // if you call this while state === 'inactive', an exception is thrown.
13460
- }
13472
+ setAudioRecorder(null);
13461
13473
  }, []);
13474
+ var _a = useVideoRecorderStore(),
13475
+ videoUrl = _a.videoUrl,
13476
+ audioUrl = _a.audioUrl,
13477
+ isRecordingVideo = _a.isRecordingVideo,
13478
+ isRecordingAudio = _a.isRecordingAudio,
13479
+ videoRecordingStopped = _a.videoRecordingStopped,
13480
+ videoRecordingIntentionallyStopped = _a.videoRecordingIntentionallyStopped,
13481
+ audioRecordingStopped = _a.audioRecordingStopped,
13482
+ audioRecordingIntentionallyStopped = _a.audioRecordingIntentionallyStopped;
13462
13483
  useEffect(function () {
13463
13484
  if (videoRecordingStopped && videoRecordingIntentionallyStopped) {
13464
13485
  processVideo();
@@ -13469,25 +13490,16 @@ var useVideoRecorder = function useVideoRecorder(camera, audioStream, mergeAVStr
13469
13490
  processAudio();
13470
13491
  }
13471
13492
  }, [audioRecordingIntentionallyStopped, audioRecordingStopped, processAudio]);
13472
- var clearRecordedData = useCallback(function () {
13473
- clearVideoChunks();
13474
- clearAudioChunks();
13475
- }, []);
13476
13493
  return useMemo(function () {
13477
13494
  return {
13478
13495
  isRecordingVideo: isRecordingVideo,
13479
13496
  isRecordingAudio: isRecordingAudio,
13480
- startRecordingVideo: startRecordingVideo,
13481
- startRecordingAudio: startRecordingAudio,
13482
- stopRecordingVideo: stopRecordingVideo,
13483
- stopRecordingAudio: stopRecordingAudio,
13484
- clearRecordedData: clearRecordedData,
13485
13497
  videoRecordingUnintentionallyStopped: videoRecordingStopped && !videoRecordingIntentionallyStopped,
13486
13498
  audioRecordingUnintentionallyStopped: audioRecordingStopped && !audioRecordingIntentionallyStopped,
13487
13499
  videoUrl: videoUrl,
13488
13500
  audioUrl: audioUrl
13489
13501
  };
13490
- }, [audioRecordingIntentionallyStopped, audioRecordingStopped, audioUrl, clearRecordedData, isRecordingAudio, isRecordingVideo, startRecordingAudio, startRecordingVideo, stopRecordingAudio, stopRecordingVideo, videoRecordingIntentionallyStopped, videoRecordingStopped, videoUrl]);
13502
+ }, [audioRecordingIntentionallyStopped, audioRecordingStopped, audioUrl, isRecordingAudio, isRecordingVideo, videoRecordingIntentionallyStopped, videoRecordingStopped, videoUrl]);
13491
13503
  };
13492
13504
 
13493
13505
  var signatureRecorder = null;
@@ -13501,25 +13513,6 @@ var signatureChunks = [];
13501
13513
  var clearSignatureChunks = function clearSignatureChunks() {
13502
13514
  return signatureChunks = [];
13503
13515
  };
13504
- var recordingLock = false;
13505
- var setRecordingLock = function setRecordingLock(lock) {
13506
- return recordingLock = lock;
13507
- };
13508
- var recordingLockEngaged = function recordingLockEngaged() {
13509
- return recordingLock;
13510
- };
13511
- function waitForCanvasAvailable(canvasRef) {
13512
- if (canvasRef.current) return Promise.resolve(null);
13513
- return new Promise(function (resolve) {
13514
- var interval = setInterval(function () {
13515
- log('VideoSignatureContext: waiting for output canvas');
13516
- if (canvasRef.current) {
13517
- clearInterval(interval);
13518
- resolve(null);
13519
- }
13520
- }, 100);
13521
- });
13522
- }
13523
13516
  var videoSignatureInitialState = {
13524
13517
  startRecording: function startRecording() {
13525
13518
  return null;
@@ -13531,10 +13524,16 @@ var videoSignatureInitialState = {
13531
13524
  return null;
13532
13525
  },
13533
13526
  isRecording: false,
13527
+ signaturePad: {
13528
+ current: null
13529
+ },
13534
13530
  signatureData: null,
13535
13531
  signatureDataUrl: null,
13536
13532
  signatureVideoData: null,
13537
13533
  signatureVideoUrl: null,
13534
+ outputCanvas: {
13535
+ current: null
13536
+ },
13538
13537
  onAcceptClicked: function onAcceptClicked() {
13539
13538
  return __awaiter(void 0, void 0, void 0, function () {
13540
13539
  return __generator(this, function (_a) {
@@ -13543,72 +13542,24 @@ var videoSignatureInitialState = {
13543
13542
  });
13544
13543
  }
13545
13544
  };
13546
- var VideoSignatureContext = /*#__PURE__*/createContext(videoSignatureInitialState);
13547
- function VideoSignatureContextProvider(_a) {
13548
- var _this = this;
13549
- var _b, _c;
13550
- var children = _a.children,
13551
- _d = _a.captureAudio,
13552
- captureAudio = _d === void 0 ? false : _d;
13553
- var signaturePad = useRef(null);
13554
- var _e = useState(null),
13555
- signatureData = _e[0],
13556
- setSignatureData = _e[1];
13557
- var _f = useState(null),
13558
- signatureDataUrl = _f[0],
13559
- setSignatureDataUrl = _f[1];
13560
- var _g = useState(null),
13561
- signatureVideoData = _g[0],
13562
- setSignatureVideoData = _g[1];
13563
- var _h = useState(null),
13564
- signatureVideoUrl = _h[0],
13565
- setSignatureVideoUrl = _h[1];
13566
- var _j = useCameraStore(),
13567
- camera = _j.camera,
13568
- videoRef = _j.videoRef,
13569
- audioStream = _j.audioStream;
13570
- var _k = useVideoRecorder(camera, audioStream, captureAudio),
13571
- isRecordingVideo = _k.isRecordingVideo,
13572
- startRecordingVideo = _k.startRecordingVideo,
13573
- stopRecordingVideo = _k.stopRecordingVideo,
13574
- startRecordingAudio = _k.startRecordingAudio,
13575
- stopRecordingAudio = _k.stopRecordingAudio,
13576
- clearRecordedVideoData = _k.clearRecordedData;
13577
- var outputCanvas = useRef(null);
13578
- var onRecordingStopped = useRef(function () {});
13579
- var _l = useState(false),
13580
- isRecording = _l[0],
13581
- setIsRecording = _l[1];
13582
- var startRecording = useCallback(function () {
13583
- return setIsRecording(true);
13584
- }, []);
13585
- var stopRecording = useCallback(function () {
13586
- return setIsRecording(false);
13587
- }, []);
13588
- var clearRecordedData = useCallback(function () {
13589
- var _a;
13590
- onRecordingStopped.current = function () {
13591
- setSignatureVideoUrl(null);
13592
- setSignatureVideoData(null);
13593
- setIsRecording(true);
13594
- onRecordingStopped.current = function () {};
13595
- };
13596
- setRecordingLock(false);
13597
- setIsRecording(false);
13598
- (_a = getSignatureRecorder()) === null || _a === void 0 ? void 0 : _a.stop();
13599
- setSignatureRecorder(null);
13600
- }, []);
13601
- useEffect(function () {
13602
- if (!isRecording) return;
13603
- if (recordingLockEngaged()) return;
13604
- setRecordingLock(true);
13605
- waitForCanvasAvailable(outputCanvas).then(function () {
13545
+ var useVideoSignatureStore = create()(devtools(function (set, get) {
13546
+ return _assign(_assign({}, videoSignatureInitialState), {
13547
+ startRecording: function startRecording(camera, audioStream, captureAudio) {
13606
13548
  var _a;
13549
+ if (captureAudio === void 0) {
13550
+ captureAudio = false;
13551
+ }
13552
+ set({
13553
+ isRecording: true
13554
+ });
13607
13555
  clearSignatureChunks();
13608
- clearRecordedVideoData();
13609
- startRecordingVideo();
13610
- if (captureAudio) startRecordingAudio();
13611
- var stream = outputCanvas.current.captureStream(24 /* fps */);
13556
+ useVideoRecorderStore.getState().clearRecordedData();
13557
+ var _b = useVideoRecorderStore.getState(),
13558
+ startRecordingVideo = _b.startRecordingVideo,
13559
+ startRecordingAudio = _b.startRecordingAudio;
13560
+ startRecordingVideo(camera, audioStream);
13561
+ if (captureAudio) startRecordingAudio(audioStream);
13562
+ var stream = get().outputCanvas.current.captureStream(24 /* fps */);
13612
13563
  var tracks = [stream.getVideoTracks()[0]];
13613
13564
  var audioTrack = (_a = audioStream === null || audioStream === void 0 ? void 0 : audioStream.getAudioTracks()) === null || _a === void 0 ? void 0 : _a[0];
13614
13565
  if (audioTrack) tracks.push(audioTrack);
@@ -13620,111 +13571,122 @@ function VideoSignatureContextProvider(_a) {
13620
13571
  signatureRecorder.ondataavailable = function (event) {
13621
13572
  signatureChunks.push(event.data);
13622
13573
  };
13574
+ signatureRecorder.start(1000);
13575
+ },
13576
+ stopRecording: function stopRecording() {
13577
+ set({
13578
+ isRecording: false
13579
+ });
13580
+ if (!signatureRecorder) return;
13581
+ signatureRecorder.stop();
13623
13582
  signatureRecorder.onstop = function () {
13624
13583
  log('VideoSignatureContext: onstop');
13625
13584
  var blob = new Blob(signatureChunks, {
13626
13585
  type: 'video/mp4'
13627
13586
  });
13628
- setSignatureVideoData(blob);
13629
- setSignatureVideoUrl(URL.createObjectURL(blob));
13587
+ useVideoSignatureStore.setState({
13588
+ signatureVideoData: blob,
13589
+ signatureVideoUrl: URL.createObjectURL(blob)
13590
+ });
13630
13591
  clearSignatureChunks();
13631
13592
  setSignatureRecorder(null);
13632
- onRecordingStopped.current();
13633
13593
  };
13634
- signatureRecorder.start(1000);
13594
+ useVideoRecorderStore.getState().stopRecording();
13595
+ },
13596
+ clearRecordedData: function clearRecordedData() {
13597
+ var _a;
13598
+ clearSignatureChunks();
13599
+ useVideoRecorderStore.getState().stopRecordingVideo();
13600
+ useVideoRecorderStore.getState().clearRecordedData();
13601
+ (_a = getSignatureRecorder()) === null || _a === void 0 ? void 0 : _a.stop();
13602
+ setSignatureRecorder(null);
13603
+ set({
13604
+ isRecording: false,
13605
+ signatureVideoData: null,
13606
+ signatureVideoUrl: null
13607
+ });
13608
+ }
13609
+ });
13610
+ }));
13611
+ function VideoSignatureContextProvider(_a) {
13612
+ var _b, _c;
13613
+ var children = _a.children,
13614
+ _d = _a.captureAudio,
13615
+ captureAudio = _d === void 0 ? false : _d;
13616
+ var _e = useCameraStore(),
13617
+ camera = _e.camera,
13618
+ videoRef = _e.videoRef;
13619
+ var isRecordingVideo = useVideoRecorder(captureAudio).isRecordingVideo;
13620
+ var outputCanvas = useRef(null);
13621
+ useEffect(function () {
13622
+ return useVideoSignatureStore.setState({
13623
+ outputCanvas: outputCanvas
13635
13624
  });
13636
- }, [audioStream, captureAudio, clearRecordedVideoData, isRecording, startRecordingAudio, startRecordingVideo]);
13625
+ }, []);
13626
+ var isRecording = useVideoSignatureStore().isRecording;
13627
+ // useEffect(() => {
13628
+ // if (!isRecording || !camera) return
13629
+ // waitForCanvasAvailable(outputCanvas).then(() => {
13630
+ // log('VideoSignatureContext: starting recording...')
13631
+ // clearSignatureChunks()
13632
+ // const { startRecordingVideo, startRecordingAudio } =
13633
+ // useVideoRecorderStore.getState()
13634
+ // startRecordingVideo(camera, audioStream)
13635
+ // if (captureAudio) startRecordingAudio(audioStream)
13636
+ // const stream = outputCanvas.current!.captureStream(24 /* fps */)
13637
+ // const tracks = [stream.getVideoTracks()[0]]
13638
+ // const audioTrack = audioStream?.getAudioTracks()?.[0]
13639
+ // if (audioTrack) tracks.push(audioTrack)
13640
+ // const signatureRecorder = new MediaRecorder(new MediaStream(tracks), {
13641
+ // videoBitsPerSecond: 270000,
13642
+ // audioBitsPerSecond: 32000,
13643
+ // })
13644
+ // setSignatureRecorder(signatureRecorder)
13645
+ // signatureRecorder.ondataavailable = (event) => {
13646
+ // signatureChunks.push(event.data)
13647
+ // }
13648
+ // signatureRecorder.start(1000)
13649
+ // })
13650
+ // }, [audioStream, captureAudio, isRecording, camera])
13637
13651
  var animationFrame = useRef(0);
13638
13652
  useEffect(function () {
13639
- if (!signaturePad.current || !videoRef.current || !outputCanvas.current || !camera || !isRecording || !isRecordingVideo) return;
13653
+ if (!videoRef.current || !outputCanvas.current || !camera || !isRecording || !isRecordingVideo) return;
13640
13654
  var ctx = outputCanvas.current.getContext('2d');
13641
13655
  if (!ctx) return;
13656
+ var signaturePad = useVideoSignatureStore.getState().signaturePad;
13642
13657
  animationFrame.current = requestAnimationFrame(function runFrame() {
13643
- return __awaiter(this, void 0, void 0, function () {
13644
- var _a, w, h, isPortrait, rect;
13645
- return __generator(this, function (_b) {
13646
- if (!signaturePad.current || !videoRef.current || !outputCanvas.current) {
13647
- cancelAnimationFrame(animationFrame.current);
13648
- return [2 /*return*/];
13649
- }
13650
- _a = [videoRef.current.videoWidth, videoRef.current.videoHeight], w = _a[0], h = _a[1];
13651
- isPortrait = w < h;
13652
- outputCanvas.current.width = w;
13653
- outputCanvas.current.height = h;
13654
- rect = [w * (isPortrait ? 0.02 : 0.15), h * (isPortrait ? 0.15 : 0.25), w * (isPortrait ? 0.96 : 0.7), h * (isPortrait ? 0.7 : 0.5)];
13655
- ctx.drawImage(videoRef.current, 0, 0, w, h);
13656
- ctx.beginPath();
13657
- ctx.fillStyle = 'rgba(255,255,255,0.5)';
13658
- ctx.roundRect.apply(ctx, __spreadArray(__spreadArray([], rect, false), [16], false));
13659
- ctx.fill();
13660
- ctx.drawImage.apply(ctx, __spreadArray([signaturePad.current.getCanvas()], rect, false));
13661
- animationFrame.current = requestAnimationFrame(runFrame);
13662
- return [2 /*return*/];
13663
- });
13664
- });
13658
+ if (!signaturePad.current || !videoRef.current || !outputCanvas.current) {
13659
+ cancelAnimationFrame(animationFrame.current);
13660
+ return;
13661
+ }
13662
+ var _a = [videoRef.current.videoWidth, videoRef.current.videoHeight],
13663
+ w = _a[0],
13664
+ h = _a[1];
13665
+ var isPortrait = w < h;
13666
+ outputCanvas.current.width = w;
13667
+ outputCanvas.current.height = h;
13668
+ var rect = [w * (isPortrait ? 0.02 : 0.15), h * (isPortrait ? 0.15 : 0.25), w * (isPortrait ? 0.96 : 0.7), h * (isPortrait ? 0.7 : 0.5)];
13669
+ ctx.drawImage(videoRef.current, 0, 0, w, h);
13670
+ ctx.beginPath();
13671
+ ctx.fillStyle = 'rgba(255,255,255,0.5)';
13672
+ ctx.roundRect.apply(ctx, __spreadArray(__spreadArray([], rect, false), [16], false));
13673
+ ctx.fill();
13674
+ ctx.drawImage.apply(ctx, __spreadArray([signaturePad.current.getCanvas()], rect, false));
13675
+ animationFrame.current = requestAnimationFrame(runFrame);
13665
13676
  });
13666
13677
  return function () {
13667
- cancelAnimationFrame(animationFrame.current);
13678
+ return cancelAnimationFrame(animationFrame.current);
13668
13679
  };
13669
13680
  }, [camera, isRecording, isRecordingVideo, videoRef]);
13670
- var onAcceptClicked = useCallback(function () {
13671
- return __awaiter(_this, void 0, void 0, function () {
13672
- var signatureData, imageUrl;
13673
- var _a;
13674
- return __generator(this, function (_b) {
13675
- switch (_b.label) {
13676
- case 0:
13677
- log('VideoSignatureContext: onAcceptClicked');
13678
- if (!signaturePad.current) return [2 /*return*/];
13679
- log('VideoSignatureContext: building signature data...');
13680
- signatureData = buildSignatureData(signaturePad.current);
13681
- log('VideoSignatureContext: exporting signature image...');
13682
- return [4 /*yield*/, exportSignatureImage(signaturePad.current)];
13683
- case 1:
13684
- imageUrl = _b.sent();
13685
- if (imageUrl) signatureData.fileContent = dataUrlToBase64Sync(imageUrl);
13686
- log('VideoSignatureContext: setting signature data url...');
13687
- setSignatureDataUrl(imageUrl);
13688
- setSignatureData(signatureData);
13689
- log('VideoSignatureContext: stopping recording...');
13690
- stopRecordingVideo();
13691
- stopRecordingAudio();
13692
- log('VideoSignatureContext: stopping signature recorder...');
13693
- (_a = getSignatureRecorder()) === null || _a === void 0 ? void 0 : _a.stop();
13694
- return [2 /*return*/];
13695
- }
13696
- });
13697
- });
13698
- }, [stopRecordingAudio, stopRecordingVideo]);
13699
- var value = useMemo(function () {
13700
- return {
13701
- isRecording: isRecording,
13702
- startRecording: startRecording,
13703
- stopRecording: stopRecording,
13704
- clearRecordedData: clearRecordedData,
13705
- signaturePad: signaturePad,
13706
- signatureData: signatureData,
13707
- signatureDataUrl: signatureDataUrl,
13708
- signatureVideoData: signatureVideoData,
13709
- signatureVideoUrl: signatureVideoUrl,
13710
- onAcceptClicked: onAcceptClicked
13711
- };
13712
- }, [clearRecordedData, isRecording, onAcceptClicked, signatureData, signatureDataUrl, signatureVideoData, signatureVideoUrl, startRecording, stopRecording]);
13713
- return /*#__PURE__*/React__default.createElement(VideoSignatureContext.Provider, {
13714
- value: value
13715
- }, children, /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
13681
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, children, /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
13716
13682
  ref: outputCanvas,
13717
13683
  width: (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth,
13718
13684
  height: (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.videoHeight
13719
13685
  }));
13720
13686
  }
13721
- function useVideoSignatureContext() {
13722
- var ctx = useContext(VideoSignatureContext);
13723
- if (!ctx) throw new Error('useVideoSignatureContext cannot be used without ContextProvider');
13724
- return ctx;
13725
- }
13726
13687
 
13727
13688
  function VideoSignatureGuides(_a) {
13689
+ var _this = this;
13728
13690
  var _b = _a.requestedAction,
13729
13691
  requestedAction = _b === void 0 ? 'VERIFY_LIVENESS' : _b,
13730
13692
  _c = _a.faceGuideStatus,
@@ -13744,15 +13706,18 @@ function VideoSignatureGuides(_a) {
13744
13706
  ref = _h.ref,
13745
13707
  width = _h.width,
13746
13708
  height = _h.height;
13747
- var _j = useVideoSignatureContext(),
13748
- signaturePad = _j.signaturePad,
13749
- onAcceptClicked = _j.onAcceptClicked;
13750
- var _k = useState(true),
13751
- signaturePadEmpty = _k[0],
13752
- setSignaturePadEmpty = _k[1];
13753
- var _l = useState(false),
13754
- signatureValid = _l[0],
13755
- setSignatureValid = _l[1];
13709
+ var signaturePad = useRef(null);
13710
+ var _j = useState(true),
13711
+ signaturePadEmpty = _j[0],
13712
+ setSignaturePadEmpty = _j[1];
13713
+ var _k = useState(false),
13714
+ signatureValid = _k[0],
13715
+ setSignatureValid = _k[1];
13716
+ useEffect(function () {
13717
+ return useVideoSignatureStore.setState({
13718
+ signaturePad: signaturePad
13719
+ });
13720
+ }, []);
13756
13721
  var verbiage = useTranslations(rawVerbiage, {
13757
13722
  signaturePadEmptyText: '',
13758
13723
  headTrackingUnsatisfiedText: '',
@@ -13769,13 +13734,41 @@ function VideoSignatureGuides(_a) {
13769
13734
  var isSigning = requestedAction === 'CAPTURE_SIGNATURE';
13770
13735
  var canClear = isSigning && !signaturePadEmpty;
13771
13736
  var canSubmit = isSigning && signatureValid && headTrackingSatisfied;
13772
- var _m = useState(false),
13773
- emptyContentDismissed = _m[0],
13774
- setEmptyContentDismissed = _m[1];
13737
+ var _l = useState(false),
13738
+ emptyContentDismissed = _l[0],
13739
+ setEmptyContentDismissed = _l[1];
13775
13740
  var displayEmptyState = requestedAction === 'CAPTURE_SIGNATURE' && signaturePadEmpty && !emptyContentDismissed;
13776
13741
  useEffect(function () {
13777
13742
  if (signaturePadEmpty) setEmptyContentDismissed(false);
13778
13743
  }, [signaturePadEmpty]);
13744
+ var onAcceptClicked = useCallback(function () {
13745
+ return __awaiter(_this, void 0, void 0, function () {
13746
+ var signatureData, imageUrl;
13747
+ return __generator(this, function (_a) {
13748
+ switch (_a.label) {
13749
+ case 0:
13750
+ log('VideoSignatureContext: onAcceptClicked');
13751
+ if (!signaturePad.current) return [2 /*return*/];
13752
+ log('VideoSignatureContext: building signature data...');
13753
+ signatureData = buildSignatureData(signaturePad.current);
13754
+ log('VideoSignatureContext: exporting signature image...', signatureData);
13755
+ return [4 /*yield*/, exportSignatureImage(signaturePad.current)];
13756
+ case 1:
13757
+ imageUrl = _a.sent();
13758
+ if (imageUrl) signatureData.fileContent = dataUrlToBase64Sync(imageUrl);
13759
+ log('VideoSignatureContext: setting signature data url...', imageUrl);
13760
+ useVideoSignatureStore.setState({
13761
+ signatureData: signatureData,
13762
+ signatureDataUrl: imageUrl
13763
+ });
13764
+ log('VideoSignatureContext: stopping signature recorder...');
13765
+ // getSignatureRecorder()?.stop()
13766
+ useVideoSignatureStore.getState().stopRecording();
13767
+ return [2 /*return*/];
13768
+ }
13769
+ });
13770
+ });
13771
+ }, []);
13779
13772
  return /*#__PURE__*/React__default.createElement(Container$3, {
13780
13773
  className: classNames.container
13781
13774
  }, /*#__PURE__*/React__default.createElement(Inner$1, {
@@ -13878,40 +13871,45 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
13878
13871
  minSignaturePadPoints = _c === void 0 ? DEFAULT_MIN_SIGNATURE_PAD_POINTS : _c,
13879
13872
  _d = _a.headTrackingBoundaryPercentage,
13880
13873
  headTrackingBoundaryPercentage = _d === void 0 ? DEFAULT_HEAD_TRACKING_BOUNDARY_PERCENTAGE : _d,
13881
- _e = _a.classNames,
13882
- classNames = _e === void 0 ? {} : _e,
13883
- _f = _a.colors,
13884
- colors = _f === void 0 ? {} : _f,
13885
- _g = _a.verbiage,
13886
- rawVerbiage = _g === void 0 ? {} : _g,
13887
- _h = _a.debugMode,
13888
- debugMode = _h === void 0 ? false : _h;
13889
- var _j = useCameraStore(useShallow(function (state) {
13874
+ _e = _a.captureAudio,
13875
+ captureAudio = _e === void 0 ? false : _e,
13876
+ _f = _a.classNames,
13877
+ classNames = _f === void 0 ? {} : _f,
13878
+ _g = _a.colors,
13879
+ colors = _g === void 0 ? {} : _g,
13880
+ _h = _a.verbiage,
13881
+ rawVerbiage = _h === void 0 ? {} : _h,
13882
+ _j = _a.debugMode,
13883
+ debugMode = _j === void 0 ? false : _j;
13884
+ var _k = useCameraStore(useShallow(function (state) {
13890
13885
  return {
13891
13886
  camera: state.camera,
13887
+ audioStream: state.audioStream,
13892
13888
  videoWidth: state.videoWidth,
13893
13889
  videoHeight: state.videoHeight
13894
13890
  };
13895
13891
  })),
13896
- camera = _j.camera,
13897
- videoWidth = _j.videoWidth,
13898
- videoHeight = _j.videoHeight;
13899
- var _k = useSelfieGuidanceModelsContext(),
13900
- onPredictionMade = _k.onPredictionMade,
13901
- startHeadTracking = _k.start,
13902
- stopHeadTracking = _k.stop;
13903
- var _l = useVideoSignatureContext(),
13904
- signatureData = _l.signatureData,
13905
- signatureDataUrl = _l.signatureDataUrl,
13906
- signatureVideoData = _l.signatureVideoData,
13907
- startRecording = _l.startRecording,
13908
- stopRecording = _l.stopRecording,
13909
- clearRecordedData = _l.clearRecordedData,
13910
- isRecording = _l.isRecording;
13892
+ camera = _k.camera,
13893
+ audioStream = _k.audioStream,
13894
+ videoWidth = _k.videoWidth,
13895
+ videoHeight = _k.videoHeight;
13896
+ var _l = useSelfieGuidanceModelsContext(),
13897
+ onPredictionMade = _l.onPredictionMade,
13898
+ startHeadTracking = _l.start,
13899
+ stopHeadTracking = _l.stop;
13900
+ var _m = useVideoSignatureStore(),
13901
+ signatureData = _m.signatureData,
13902
+ signatureDataUrl = _m.signatureDataUrl,
13903
+ signatureVideoData = _m.signatureVideoData,
13904
+ startRecording = _m.startRecording,
13905
+ stopRecording = _m.stopRecording,
13906
+ clearRecordedData = _m.clearRecordedData,
13907
+ isRecording = _m.isRecording;
13911
13908
  useEffect(function () {
13912
- startRecording();
13909
+ if (!camera) return;
13910
+ startRecording(camera, audioStream, captureAudio);
13913
13911
  return stopRecording;
13914
- }, [startRecording, stopRecording]);
13912
+ }, [audioStream, camera, captureAudio, startRecording, stopRecording]);
13915
13913
  useEffect(function () {
13916
13914
  setTimeout(startHeadTracking, 1);
13917
13915
  return stopHeadTracking;
@@ -13926,15 +13924,15 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
13926
13924
  onVideoCaptured === null || onVideoCaptured === void 0 ? void 0 : onVideoCaptured(signatureVideoData, signatureData, signatureDataUrl);
13927
13925
  }
13928
13926
  }, [onVideoCaptured, signatureData, signatureDataUrl, signatureVideoData]);
13929
- var _m = useState(true),
13930
- headTrackingSatisfied = _m[0],
13931
- setHeadTrackingSatisfied = _m[1];
13932
- var _o = useState(null),
13933
- lastFace = _o[0],
13934
- setLastFace = _o[1];
13935
- var _p = useState(0),
13936
- numFramesWithoutFaces = _p[0],
13937
- setNumFramesWithoutFaces = _p[1];
13927
+ var _o = useState(true),
13928
+ headTrackingSatisfied = _o[0],
13929
+ setHeadTrackingSatisfied = _o[1];
13930
+ var _p = useState(null),
13931
+ lastFace = _p[0],
13932
+ setLastFace = _p[1];
13933
+ var _q = useState(0),
13934
+ numFramesWithoutFaces = _q[0],
13935
+ setNumFramesWithoutFaces = _q[1];
13938
13936
  onPredictionMade(useThrottledCallback(useCallback(function (_a) {
13939
13937
  var face = _a.face;
13940
13938
  if (!camera) return;
@@ -13945,12 +13943,12 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
13945
13943
  return n + 1;
13946
13944
  });
13947
13945
  }, [camera, headTrackingBoundaryPercentage, videoHeight, videoWidth]), 16));
13948
- var _q = useResizeObserver(),
13949
- ref = _q.ref,
13950
- _r = _q.width,
13951
- width = _r === void 0 ? 1 : _r,
13952
- _s = _q.height,
13953
- height = _s === void 0 ? 1 : _s;
13946
+ var _r = useResizeObserver(),
13947
+ ref = _r.ref,
13948
+ _s = _r.width,
13949
+ width = _s === void 0 ? 1 : _s,
13950
+ _t = _r.height,
13951
+ height = _t === void 0 ? 1 : _t;
13954
13952
  var debugScalingDetails = useDebugScalingDetails({
13955
13953
  enabled: debugMode,
13956
13954
  pageWidth: width,
@@ -14167,6 +14165,7 @@ var VideoSignatureWizard = function VideoSignatureWizard(_a) {
14167
14165
  return n + 1;
14168
14166
  });
14169
14167
  setCaptureState('CHECKING_LIVENESS');
14168
+ useVideoSignatureStore.getState().clearRecordedData();
14170
14169
  }, [onRetryClicked]);
14171
14170
  var onExitSignatureCapture = useCallback(function () {
14172
14171
  setAttempt(function (n) {
@@ -14188,9 +14187,10 @@ var VideoSignatureWizard = function VideoSignatureWizard(_a) {
14188
14187
  return /*#__PURE__*/React__default.createElement(VideoSignatureWizardGuides, _assign({}, props, {
14189
14188
  classNames: classNames === null || classNames === void 0 ? void 0 : classNames.guides,
14190
14189
  verbiage: verbiage === null || verbiage === void 0 ? void 0 : verbiage.guides,
14191
- restartVideoOnSignaturePadCleared: restartVideoOnSignaturePadCleared
14190
+ restartVideoOnSignaturePadCleared: restartVideoOnSignaturePadCleared,
14191
+ captureAudio: captureAudio
14192
14192
  }));
14193
- }, [classNames === null || classNames === void 0 ? void 0 : classNames.guides, restartVideoOnSignaturePadCleared, verbiage === null || verbiage === void 0 ? void 0 : verbiage.guides]);
14193
+ }, [captureAudio, classNames === null || classNames === void 0 ? void 0 : classNames.guides, restartVideoOnSignaturePadCleared, verbiage === null || verbiage === void 0 ? void 0 : verbiage.guides]);
14194
14194
  var onExitAfterFailureProp = faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.onExitAfterFailure;
14195
14195
  var onExitAfterFailure = useCallback(function (resp, req) {
14196
14196
  onExitAfterFailureProp === null || onExitAfterFailureProp === void 0 ? void 0 : onExitAfterFailureProp(resp, req);
@@ -14242,6 +14242,7 @@ var VideoSignatureWizard = function VideoSignatureWizard(_a) {
14242
14242
  headTrackingBoundaryPercentage: headTrackingBoundaryPercentage,
14243
14243
  restartVideoOnSignaturePadCleared: restartVideoOnSignaturePadCleared,
14244
14244
  guidesComponent: guidesComponent,
14245
+ captureAudio: captureAudio,
14245
14246
  classNames: classNames,
14246
14247
  colors: colors,
14247
14248
  verbiage: verbiage,
@@ -14266,14 +14267,25 @@ function VideoSignatureWizardGuides(_a) {
14266
14267
  var status = _a.status,
14267
14268
  _b = _a.restartVideoOnSignaturePadCleared,
14268
14269
  restartVideoOnSignaturePadCleared = _b === void 0 ? true : _b,
14269
- props = __rest(_a, ["status", "restartVideoOnSignaturePadCleared"]);
14270
- var clearRecordedData = useVideoSignatureContext().clearRecordedData;
14270
+ _c = _a.captureAudio,
14271
+ captureAudio = _c === void 0 ? false : _c,
14272
+ props = __rest(_a, ["status", "restartVideoOnSignaturePadCleared", "captureAudio"]);
14273
+ var _d = useCameraStore(),
14274
+ camera = _d.camera,
14275
+ audioStream = _d.audioStream;
14276
+ function onClear() {
14277
+ if (!restartVideoOnSignaturePadCleared) return;
14278
+ setTimeout(function () {
14279
+ useVideoSignatureStore.getState().clearRecordedData();
14280
+ setTimeout(function () {
14281
+ useVideoSignatureStore.getState().startRecording(camera, audioStream, captureAudio);
14282
+ }, 100);
14283
+ }, 100);
14284
+ }
14271
14285
  return /*#__PURE__*/React__default.createElement(VideoSignatureGuides, _assign({}, props, {
14272
14286
  faceGuideStatus: status,
14273
- requestedAction: status === 'success' ? 'CAPTURE_SIGNATURE' : 'VERIFY_LIVENESS',
14274
- onClearSignaturePadClicked: restartVideoOnSignaturePadCleared ? function () {
14275
- return setTimeout(clearRecordedData, 100);
14276
- } : undefined
14287
+ onClearSignaturePadClicked: onClear,
14288
+ requestedAction: status === 'success' ? 'CAPTURE_SIGNATURE' : 'VERIFY_LIVENESS'
14277
14289
  }));
14278
14290
  }
14279
14291
  var VideoSignatureWizardWithProviders = function VideoSignatureWizardWithProviders(props) {
@@ -14656,12 +14668,8 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14656
14668
  stopSelfieGuidance = _16.stop,
14657
14669
  onSelfiePredictionMade = _16.onPredictionMade,
14658
14670
  selfieModelError = _16.error;
14659
- var _17 = useVideoRecorder(camera, audioStream, mergeAVStreams),
14671
+ var _17 = useVideoRecorder(mergeAVStreams),
14660
14672
  isRecordingVideo = _17.isRecordingVideo,
14661
- startRecordingVideo = _17.startRecordingVideo,
14662
- startRecordingAudio = _17.startRecordingAudio,
14663
- stopRecordingVideo = _17.stopRecordingVideo,
14664
- stopRecordingAudio = _17.stopRecordingAudio,
14665
14673
  videoRecordingUnintentionallyStopped = _17.videoRecordingUnintentionallyStopped,
14666
14674
  audioRecordingUnintentionallyStopped = _17.audioRecordingUnintentionallyStopped,
14667
14675
  videoUrl = _17.videoUrl,
@@ -14671,8 +14679,8 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14671
14679
  countdownRemaining = _18[0],
14672
14680
  setCountdownRemaining = _18[1];
14673
14681
  useEffect(function () {
14674
- if (!isRecordingVideo && !videoUrl) {
14675
- startRecordingVideo();
14682
+ if (camera && !isRecordingVideo && !videoUrl) {
14683
+ useVideoRecorderStore.getState().startRecordingVideo(camera, audioStream);
14676
14684
  setVideoStartsAt(new Date());
14677
14685
  }
14678
14686
  // if the mergeAVStreams flag is present, the audio stream is on the video
@@ -14683,7 +14691,7 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14683
14691
  releaseCameraAccess();
14684
14692
  onComplete === null || onComplete === void 0 ? void 0 : onComplete(videoUrl, audioUrl);
14685
14693
  }
14686
- }, [audioUrl, isRecordingVideo, mergeAVStreams, onComplete, readTextPrompt, releaseCameraAccess, startRecordingVideo, videoUrl]);
14694
+ }, [audioStream, audioUrl, camera, isRecordingVideo, mergeAVStreams, onComplete, readTextPrompt, releaseCameraAccess, videoUrl]);
14687
14695
  useEffect(function () {
14688
14696
  if (videoRecordingUnintentionallyStopped || audioRecordingUnintentionallyStopped || !!readTextPrompt && !microphoneReady) {
14689
14697
  onRecordingFailed === null || onRecordingFailed === void 0 ? void 0 : onRecordingFailed();
@@ -14778,13 +14786,13 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14778
14786
  var _a;
14779
14787
  if (translatedText) {
14780
14788
  setRequestedAction('READ_TEXT');
14781
- startRecordingAudio();
14789
+ useVideoRecorderStore.getState().startRecordingAudio(audioStream);
14782
14790
  setIdCaptureVideoAudioStartsAt(new Date().getTime() - ((_a = videoStartsAt === null || videoStartsAt === void 0 ? void 0 : videoStartsAt.getTime()) !== null && _a !== void 0 ? _a : 0));
14783
14791
  setExpectedAudioText(translatedText);
14784
14792
  } else {
14785
- stopRecordingVideo();
14793
+ useVideoRecorderStore.getState().stopRecordingVideo();
14786
14794
  }
14787
- }, [setExpectedAudioText, setIdCaptureVideoAudioStartsAt, startRecordingAudio, stopRecordingVideo, translatedText, videoStartsAt]);
14795
+ }, [audioStream, setExpectedAudioText, setIdCaptureVideoAudioStartsAt, translatedText, videoStartsAt]);
14788
14796
  var frameWidth = (_c = (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth) !== null && _c !== void 0 ? _c : 0;
14789
14797
  var frameHeight = (_e = (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) !== null && _e !== void 0 ? _e : 0;
14790
14798
  var faceBox = face === null || face === void 0 ? void 0 : face.box;
@@ -14854,9 +14862,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14854
14862
  };
14855
14863
  }, [isFlipping]);
14856
14864
  var stopRecording = useCallback(function () {
14857
- stopRecordingVideo();
14858
- stopRecordingAudio();
14859
- }, [stopRecordingAudio, stopRecordingVideo]);
14865
+ useVideoRecorderStore.getState().stopRecordingVideo();
14866
+ useVideoRecorderStore.getState().stopRecordingAudio();
14867
+ }, []);
14860
14868
  var satisfied = !isFlipping && goodFramesThresholdMet && faceCentered && delaySatisfied;
14861
14869
  useEffect(function () {
14862
14870
  if (satisfied && !countdownStartedAt) {
@@ -15258,6 +15266,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
15258
15266
  return n + 1;
15259
15267
  });
15260
15268
  setCaptureState('CAPTURING_ID');
15269
+ useVideoRecorderStore.getState().clearRecordedData();
15261
15270
  }, []);
15262
15271
  var isCapturingId = !skipIdCapture && ['LOADING', 'CAPTURING_ID'].includes(captureState);
15263
15272
  useEffect(function () {