idmission-web-sdk 2.3.14 → 2.3.15

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.3.14';
214
+ var webSdkVersion = '2.3.15';
215
215
 
216
216
  function getPlatform() {
217
217
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -1147,11 +1147,11 @@
1147
1147
  if (!allowedAuthUrls.includes(url)) throw new Error('invalid auth url');
1148
1148
  exports.defaultAuthUrl = url;
1149
1149
  }
1150
- var initialState$6 = {
1150
+ var initialState$7 = {
1151
1151
  authUrl: exports.defaultAuthUrl,
1152
1152
  sessionCheckState: 'READY'
1153
1153
  };
1154
- var AuthStateContext = /*#__PURE__*/React.createContext(initialState$6);
1154
+ var AuthStateContext = /*#__PURE__*/React.createContext(initialState$7);
1155
1155
  var AuthDispatchContext = /*#__PURE__*/React.createContext(function () {});
1156
1156
  var reducer$4 = function reducer(state, action) {
1157
1157
  switch (action.type) {
@@ -1270,7 +1270,7 @@
1270
1270
  if (authUrl === void 0) {
1271
1271
  authUrl = exports.defaultAuthUrl;
1272
1272
  }
1273
- var _a = React.useReducer(reducer$4, _assign(_assign({}, initialState$6), {
1273
+ var _a = React.useReducer(reducer$4, _assign(_assign({}, initialState$7), {
1274
1274
  authUrl: authUrl
1275
1275
  })),
1276
1276
  state = _a[0],
@@ -13502,7 +13502,7 @@
13502
13502
  }, [fallbacks, i18n.language, t, verbiage]);
13503
13503
  }
13504
13504
 
13505
- var initialState$5 = {
13505
+ var initialState$6 = {
13506
13506
  videoRef: {
13507
13507
  current: null
13508
13508
  },
@@ -13525,9 +13525,9 @@
13525
13525
  };
13526
13526
  var createCameraStore = function createCameraStore(config) {
13527
13527
  var store = createStore(function (set, get) {
13528
- return _assign(_assign(_assign({}, initialState$5), config), {
13528
+ return _assign(_assign(_assign({}, initialState$6), config), {
13529
13529
  reset: function reset() {
13530
- return set(_assign(_assign({}, initialState$5), config));
13530
+ return set(_assign(_assign({}, initialState$6), config));
13531
13531
  },
13532
13532
  setConfig: function setConfig(config) {
13533
13533
  return set(config);
@@ -14907,7 +14907,7 @@
14907
14907
  };
14908
14908
  }
14909
14909
 
14910
- var initialState$4 = {
14910
+ var initialState$5 = {
14911
14911
  initialDrawComplete: false,
14912
14912
  redrawing: false,
14913
14913
  guideRectX: 0,
@@ -15267,7 +15267,7 @@
15267
15267
  });
15268
15268
  }
15269
15269
  case 'resetWizard':
15270
- return _assign(_assign({}, initialState$4), {
15270
+ return _assign(_assign({}, initialState$5), {
15271
15271
  dispatch: state.dispatch,
15272
15272
  allowUploadingDocumentsFromStorage: state.allowUploadingDocumentsFromStorage,
15273
15273
  captureState: state.allowUploadingDocumentsFromStorage ? 'initializing' : 'capturing',
@@ -15279,7 +15279,7 @@
15279
15279
  }
15280
15280
  };
15281
15281
  var useIdCaptureStore = create$1()(devtools(function (set) {
15282
- return _assign(_assign({}, initialState$4), {
15282
+ return _assign(_assign({}, initialState$5), {
15283
15283
  dispatch: function dispatch(action) {
15284
15284
  return set(function (state) {
15285
15285
  return _reducer(state, action);
@@ -20838,7 +20838,7 @@
20838
20838
  var StyledButtonsRow$6 = styled(ButtonsRow$2)(templateObject_5$5 || (templateObject_5$5 = __makeTemplateObject(["\n margin-top: 32px;\n"], ["\n margin-top: 32px;\n"])));
20839
20839
  var templateObject_1$m, templateObject_2$i, templateObject_3$d, templateObject_4$8, templateObject_5$5;
20840
20840
 
20841
- var initialState$3 = {
20841
+ var initialState$4 = {
20842
20842
  busy: false,
20843
20843
  frame: null,
20844
20844
  prediction: null
@@ -20893,7 +20893,7 @@
20893
20893
  width = _k === void 0 ? 1 : _k,
20894
20894
  _l = _j.height,
20895
20895
  height = _l === void 0 ? 1 : _l;
20896
- var _m = React.useReducer(reducer$3, initialState$3),
20896
+ var _m = React.useReducer(reducer$3, initialState$4),
20897
20897
  _o = _m[0],
20898
20898
  busy = _o.busy,
20899
20899
  prediction = _o.prediction,
@@ -21003,7 +21003,7 @@
21003
21003
  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"])));
21004
21004
  var templateObject_1$l;
21005
21005
 
21006
- var initialState$2 = {
21006
+ var initialState$3 = {
21007
21007
  frame: null,
21008
21008
  face: null,
21009
21009
  requestState: 'CAPTURING',
@@ -21020,7 +21020,7 @@
21020
21020
  var _a, _b;
21021
21021
  switch (action.type) {
21022
21022
  case 'resetLivenessCheck':
21023
- return _assign(_assign({}, initialState$2), {
21023
+ return _assign(_assign({}, initialState$3), {
21024
21024
  timesLivenessCheckFailed: state.timesLivenessCheckFailed
21025
21025
  });
21026
21026
  case 'guidanceUnsatisfied':
@@ -21128,7 +21128,7 @@
21128
21128
  checkLiveness = _m.checkLiveness,
21129
21129
  submissionError = _m.submissionError;
21130
21130
  var modelError = useSelfieGuidanceModelsContext().error;
21131
- var _o = React.useReducer(reducer$2, initialState$2),
21131
+ var _o = React.useReducer(reducer$2, initialState$3),
21132
21132
  state = _o[0],
21133
21133
  dispatch = _o[1];
21134
21134
  var _p = React.useState(null),
@@ -23251,120 +23251,141 @@
23251
23251
  function clearAudioChunks() {
23252
23252
  audioChunks = [];
23253
23253
  }
23254
- var useVideoRecorder = function useVideoRecorder(camera, audioStream, mergeAVStreams) {
23254
+ var initialState$2 = {
23255
+ videoUrl: null,
23256
+ audioUrl: null,
23257
+ isRecordingVideo: false,
23258
+ isRecordingAudio: false,
23259
+ videoRecordingStopped: false,
23260
+ audioRecordingStopped: false,
23261
+ videoRecordingIntentionallyStopped: false,
23262
+ audioRecordingIntentionallyStopped: false,
23263
+ mergeAVStreams: false
23264
+ };
23265
+ var useVideoRecorderStore = create$1()(devtools(function (set, get) {
23266
+ return _assign(_assign({}, initialState$2), {
23267
+ startRecordingVideo: function startRecordingVideo(camera, audioStream) {
23268
+ var _a, _b, _c;
23269
+ 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;
23270
+ if (!videoStream) return;
23271
+ clearVideoChunks();
23272
+ setVideoRecorder(null);
23273
+ set({
23274
+ isRecordingVideo: true,
23275
+ videoRecordingStopped: false,
23276
+ videoRecordingIntentionallyStopped: false
23277
+ });
23278
+ var videoRecorder = new MediaRecorder(videoStream, {
23279
+ videoBitsPerSecond: 270000,
23280
+ audioBitsPerSecond: 32000
23281
+ });
23282
+ setVideoRecorder(videoRecorder);
23283
+ videoRecorder.ondataavailable = function (e) {
23284
+ videoChunks.push(e.data);
23285
+ };
23286
+ videoRecorder.onstop = function () {
23287
+ set({
23288
+ videoRecordingStopped: true
23289
+ });
23290
+ };
23291
+ videoRecorder.start(1000);
23292
+ setTimeout(function () {
23293
+ var videoRecorder = getVideoRecorder();
23294
+ if (!videoRecorder || videoRecorder.state === 'inactive') {
23295
+ log('media recorder is inactive!');
23296
+ // TODO: figure out what to do here
23297
+ }
23298
+ }, 100);
23299
+ },
23300
+ stopRecordingVideo: function stopRecordingVideo() {
23301
+ set({
23302
+ videoRecordingIntentionallyStopped: true
23303
+ });
23304
+ if ((videoRecorder === null || videoRecorder === void 0 ? void 0 : videoRecorder.state) !== 'inactive') {
23305
+ videoRecorder === null || videoRecorder === void 0 ? void 0 : videoRecorder.stop(); // if you call this while state === 'inactive', an exception is thrown.
23306
+ }
23307
+ },
23308
+ startRecordingAudio: function startRecordingAudio(audioStream) {
23309
+ if (get().mergeAVStreams) return;
23310
+ if (!audioStream) return;
23311
+ clearAudioChunks();
23312
+ set({
23313
+ isRecordingAudio: true,
23314
+ audioRecordingStopped: false,
23315
+ audioRecordingIntentionallyStopped: false
23316
+ });
23317
+ var audioRecorder = new MediaRecorder(audioStream, {
23318
+ audioBitsPerSecond: 32000
23319
+ });
23320
+ setAudioRecorder(audioRecorder);
23321
+ audioRecorder.ondataavailable = function (e) {
23322
+ audioChunks.push(e.data);
23323
+ };
23324
+ audioRecorder.onstop = function () {
23325
+ set({
23326
+ audioRecordingStopped: true
23327
+ });
23328
+ };
23329
+ audioRecorder.start(1000);
23330
+ },
23331
+ stopRecordingAudio: function stopRecordingAudio() {
23332
+ set({
23333
+ audioRecordingIntentionallyStopped: true
23334
+ });
23335
+ if ((audioRecorder === null || audioRecorder === void 0 ? void 0 : audioRecorder.state) !== 'inactive') {
23336
+ audioRecorder === null || audioRecorder === void 0 ? void 0 : audioRecorder.stop(); // if you call this while state === 'inactive', an exception is thrown.
23337
+ }
23338
+ },
23339
+ stopRecording: function stopRecording() {
23340
+ get().stopRecordingVideo();
23341
+ get().stopRecordingAudio();
23342
+ },
23343
+ clearRecordedData: function clearRecordedData() {
23344
+ clearVideoChunks();
23345
+ clearAudioChunks();
23346
+ }
23347
+ });
23348
+ }));
23349
+ var useVideoRecorder = function useVideoRecorder(mergeAVStreams) {
23255
23350
  if (mergeAVStreams === void 0) {
23256
23351
  mergeAVStreams = false;
23257
23352
  }
23258
- var _a = React.useState(null),
23259
- videoUrl = _a[0],
23260
- setVideoUrl = _a[1];
23261
- var _b = React.useState(null),
23262
- audioUrl = _b[0],
23263
- setAudioUrl = _b[1];
23264
- var _c = React.useState(false),
23265
- isRecordingVideo = _c[0],
23266
- setIsRecordingVideo = _c[1];
23267
- var _d = React.useState(false),
23268
- isRecordingAudio = _d[0],
23269
- setIsRecordingAudio = _d[1];
23270
- var _e = React.useState(false),
23271
- videoRecordingStopped = _e[0],
23272
- setVideoRecordingStopped = _e[1];
23273
- var _f = React.useState(false),
23274
- audioRecordingStopped = _f[0],
23275
- setAudioRecordingStopped = _f[1];
23276
- var _g = React.useState(false),
23277
- videoRecordingIntentionallyStopped = _g[0],
23278
- setVideoRecordingIntentionallyStopped = _g[1];
23279
- var _h = React.useState(false),
23280
- audioRecordingIntentionallyStopped = _h[0],
23281
- setAudioRecordingIntentionallyStopped = _h[1];
23282
- var getVideoStream = React.useCallback(function () {
23283
- var _a, _b, _c;
23284
- if (!mergeAVStreams) return camera === null || camera === void 0 ? void 0 : camera.stream;
23285
- 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 : [];
23286
- var audioTracks = (_c = audioStream === null || audioStream === void 0 ? void 0 : audioStream.getTracks()) !== null && _c !== void 0 ? _c : [];
23287
- return new MediaStream(__spreadArray(__spreadArray([], videoTracks, true), audioTracks, true));
23288
- }, [audioStream, camera === null || camera === void 0 ? void 0 : camera.stream, mergeAVStreams]);
23353
+ React.useEffect(function () {
23354
+ return useVideoRecorderStore.setState({
23355
+ mergeAVStreams: mergeAVStreams
23356
+ });
23357
+ }, [mergeAVStreams]);
23289
23358
  var processVideo = React.useCallback(function () {
23290
23359
  var videoBlob = new Blob(videoChunks, {
23291
23360
  type: 'video/mp4'
23292
23361
  });
23293
- setVideoUrl(URL.createObjectURL(videoBlob));
23362
+ useVideoRecorderStore.setState({
23363
+ videoUrl: URL.createObjectURL(videoBlob),
23364
+ isRecordingVideo: false
23365
+ });
23294
23366
  clearVideoChunks();
23295
- setIsRecordingVideo(false);
23296
23367
  setVideoRecorder(null);
23297
- camera === null || camera === void 0 ? void 0 : camera.release();
23298
- }, [camera]);
23368
+ }, []);
23299
23369
  var processAudio = React.useCallback(function () {
23300
- var _a;
23301
23370
  var audioBlob = new Blob(audioChunks, {
23302
23371
  type: 'audio/mp4'
23303
23372
  });
23304
- setAudioUrl(URL.createObjectURL(audioBlob));
23305
- clearAudioChunks();
23306
- setIsRecordingAudio(false);
23307
- setAudioRecorder(null);
23308
- (_a = audioStream === null || audioStream === void 0 ? void 0 : audioStream.stop) === null || _a === void 0 ? void 0 : _a.call(audioStream);
23309
- }, [audioStream]);
23310
- var startRecordingVideo = React.useCallback(function () {
23311
- var videoStream = getVideoStream();
23312
- if (!videoStream) return;
23313
- clearVideoChunks();
23314
- setIsRecordingVideo(true);
23315
- setVideoRecordingStopped(false);
23316
- setVideoRecordingIntentionallyStopped(false);
23317
- var videoRecorder = new MediaRecorder(videoStream, {
23318
- videoBitsPerSecond: 270000,
23319
- audioBitsPerSecond: 32000
23373
+ useVideoRecorderStore.setState({
23374
+ audioUrl: URL.createObjectURL(audioBlob),
23375
+ isRecordingAudio: false
23320
23376
  });
23321
- setVideoRecorder(videoRecorder);
23322
- videoRecorder.ondataavailable = function (e) {
23323
- videoChunks.push(e.data);
23324
- };
23325
- videoRecorder.onstop = function () {
23326
- setVideoRecordingStopped(true);
23327
- };
23328
- videoRecorder.start(1000);
23329
- setTimeout(function () {
23330
- var _a;
23331
- if (((_a = getVideoRecorder()) === null || _a === void 0 ? void 0 : _a.state) === 'inactive') {
23332
- log('media recorder is inactive!');
23333
- // TODO: figure out what to do here
23334
- }
23335
- }, 100);
23336
- }, [getVideoStream]);
23337
- var startRecordingAudio = React.useCallback(function () {
23338
- if (mergeAVStreams) return;
23339
- if (!audioStream) return;
23340
23377
  clearAudioChunks();
23341
- setIsRecordingAudio(true);
23342
- setAudioRecordingStopped(false);
23343
- setAudioRecordingIntentionallyStopped(false);
23344
- var audioRecorder = new MediaRecorder(audioStream, {
23345
- audioBitsPerSecond: 32000
23346
- });
23347
- setAudioRecorder(audioRecorder);
23348
- audioRecorder.ondataavailable = function (e) {
23349
- audioChunks.push(e.data);
23350
- };
23351
- audioRecorder.onstop = function () {
23352
- setAudioRecordingStopped(true);
23353
- };
23354
- audioRecorder.start(1000);
23355
- }, [audioStream, mergeAVStreams]);
23356
- var stopRecordingVideo = React.useCallback(function () {
23357
- setVideoRecordingIntentionallyStopped(true);
23358
- if ((videoRecorder === null || videoRecorder === void 0 ? void 0 : videoRecorder.state) !== 'inactive') {
23359
- videoRecorder === null || videoRecorder === void 0 ? void 0 : videoRecorder.stop(); // if you call this while state === 'inactive', an exception is thrown.
23360
- }
23361
- }, []);
23362
- var stopRecordingAudio = React.useCallback(function () {
23363
- setAudioRecordingIntentionallyStopped(true);
23364
- if ((audioRecorder === null || audioRecorder === void 0 ? void 0 : audioRecorder.state) !== 'inactive') {
23365
- audioRecorder === null || audioRecorder === void 0 ? void 0 : audioRecorder.stop(); // if you call this while state === 'inactive', an exception is thrown.
23366
- }
23378
+ setAudioRecorder(null);
23367
23379
  }, []);
23380
+ var _a = useVideoRecorderStore(),
23381
+ videoUrl = _a.videoUrl,
23382
+ audioUrl = _a.audioUrl,
23383
+ isRecordingVideo = _a.isRecordingVideo,
23384
+ isRecordingAudio = _a.isRecordingAudio,
23385
+ videoRecordingStopped = _a.videoRecordingStopped,
23386
+ videoRecordingIntentionallyStopped = _a.videoRecordingIntentionallyStopped,
23387
+ audioRecordingStopped = _a.audioRecordingStopped,
23388
+ audioRecordingIntentionallyStopped = _a.audioRecordingIntentionallyStopped;
23368
23389
  React.useEffect(function () {
23369
23390
  if (videoRecordingStopped && videoRecordingIntentionallyStopped) {
23370
23391
  processVideo();
@@ -23375,25 +23396,16 @@
23375
23396
  processAudio();
23376
23397
  }
23377
23398
  }, [audioRecordingIntentionallyStopped, audioRecordingStopped, processAudio]);
23378
- var clearRecordedData = React.useCallback(function () {
23379
- clearVideoChunks();
23380
- clearAudioChunks();
23381
- }, []);
23382
23399
  return React.useMemo(function () {
23383
23400
  return {
23384
23401
  isRecordingVideo: isRecordingVideo,
23385
23402
  isRecordingAudio: isRecordingAudio,
23386
- startRecordingVideo: startRecordingVideo,
23387
- startRecordingAudio: startRecordingAudio,
23388
- stopRecordingVideo: stopRecordingVideo,
23389
- stopRecordingAudio: stopRecordingAudio,
23390
- clearRecordedData: clearRecordedData,
23391
23403
  videoRecordingUnintentionallyStopped: videoRecordingStopped && !videoRecordingIntentionallyStopped,
23392
23404
  audioRecordingUnintentionallyStopped: audioRecordingStopped && !audioRecordingIntentionallyStopped,
23393
23405
  videoUrl: videoUrl,
23394
23406
  audioUrl: audioUrl
23395
23407
  };
23396
- }, [audioRecordingIntentionallyStopped, audioRecordingStopped, audioUrl, clearRecordedData, isRecordingAudio, isRecordingVideo, startRecordingAudio, startRecordingVideo, stopRecordingAudio, stopRecordingVideo, videoRecordingIntentionallyStopped, videoRecordingStopped, videoUrl]);
23408
+ }, [audioRecordingIntentionallyStopped, audioRecordingStopped, audioUrl, isRecordingAudio, isRecordingVideo, videoRecordingIntentionallyStopped, videoRecordingStopped, videoUrl]);
23397
23409
  };
23398
23410
 
23399
23411
  var signatureRecorder = null;
@@ -23407,25 +23419,6 @@
23407
23419
  var clearSignatureChunks = function clearSignatureChunks() {
23408
23420
  return signatureChunks = [];
23409
23421
  };
23410
- var recordingLock = false;
23411
- var setRecordingLock = function setRecordingLock(lock) {
23412
- return recordingLock = lock;
23413
- };
23414
- var recordingLockEngaged = function recordingLockEngaged() {
23415
- return recordingLock;
23416
- };
23417
- function waitForCanvasAvailable(canvasRef) {
23418
- if (canvasRef.current) return Promise.resolve(null);
23419
- return new Promise(function (resolve) {
23420
- var interval = setInterval(function () {
23421
- log('VideoSignatureContext: waiting for output canvas');
23422
- if (canvasRef.current) {
23423
- clearInterval(interval);
23424
- resolve(null);
23425
- }
23426
- }, 100);
23427
- });
23428
- }
23429
23422
  var videoSignatureInitialState = {
23430
23423
  startRecording: function startRecording() {
23431
23424
  return null;
@@ -23437,10 +23430,16 @@
23437
23430
  return null;
23438
23431
  },
23439
23432
  isRecording: false,
23433
+ signaturePad: {
23434
+ current: null
23435
+ },
23440
23436
  signatureData: null,
23441
23437
  signatureDataUrl: null,
23442
23438
  signatureVideoData: null,
23443
23439
  signatureVideoUrl: null,
23440
+ outputCanvas: {
23441
+ current: null
23442
+ },
23444
23443
  onAcceptClicked: function onAcceptClicked() {
23445
23444
  return __awaiter(void 0, void 0, void 0, function () {
23446
23445
  return __generator(this, function (_a) {
@@ -23449,72 +23448,24 @@
23449
23448
  });
23450
23449
  }
23451
23450
  };
23452
- var VideoSignatureContext = /*#__PURE__*/React.createContext(videoSignatureInitialState);
23453
- function VideoSignatureContextProvider(_a) {
23454
- var _this = this;
23455
- var _b, _c;
23456
- var children = _a.children,
23457
- _d = _a.captureAudio,
23458
- captureAudio = _d === void 0 ? false : _d;
23459
- var signaturePad = React.useRef(null);
23460
- var _e = React.useState(null),
23461
- signatureData = _e[0],
23462
- setSignatureData = _e[1];
23463
- var _f = React.useState(null),
23464
- signatureDataUrl = _f[0],
23465
- setSignatureDataUrl = _f[1];
23466
- var _g = React.useState(null),
23467
- signatureVideoData = _g[0],
23468
- setSignatureVideoData = _g[1];
23469
- var _h = React.useState(null),
23470
- signatureVideoUrl = _h[0],
23471
- setSignatureVideoUrl = _h[1];
23472
- var _j = useCameraStore(),
23473
- camera = _j.camera,
23474
- videoRef = _j.videoRef,
23475
- audioStream = _j.audioStream;
23476
- var _k = useVideoRecorder(camera, audioStream, captureAudio),
23477
- isRecordingVideo = _k.isRecordingVideo,
23478
- startRecordingVideo = _k.startRecordingVideo,
23479
- stopRecordingVideo = _k.stopRecordingVideo,
23480
- startRecordingAudio = _k.startRecordingAudio,
23481
- stopRecordingAudio = _k.stopRecordingAudio,
23482
- clearRecordedVideoData = _k.clearRecordedData;
23483
- var outputCanvas = React.useRef(null);
23484
- var onRecordingStopped = React.useRef(function () {});
23485
- var _l = React.useState(false),
23486
- isRecording = _l[0],
23487
- setIsRecording = _l[1];
23488
- var startRecording = React.useCallback(function () {
23489
- return setIsRecording(true);
23490
- }, []);
23491
- var stopRecording = React.useCallback(function () {
23492
- return setIsRecording(false);
23493
- }, []);
23494
- var clearRecordedData = React.useCallback(function () {
23495
- var _a;
23496
- onRecordingStopped.current = function () {
23497
- setSignatureVideoUrl(null);
23498
- setSignatureVideoData(null);
23499
- setIsRecording(true);
23500
- onRecordingStopped.current = function () {};
23501
- };
23502
- setRecordingLock(false);
23503
- setIsRecording(false);
23504
- (_a = getSignatureRecorder()) === null || _a === void 0 ? void 0 : _a.stop();
23505
- setSignatureRecorder(null);
23506
- }, []);
23507
- React.useEffect(function () {
23508
- if (!isRecording) return;
23509
- if (recordingLockEngaged()) return;
23510
- setRecordingLock(true);
23511
- waitForCanvasAvailable(outputCanvas).then(function () {
23451
+ var useVideoSignatureStore = create$1()(devtools(function (set, get) {
23452
+ return _assign(_assign({}, videoSignatureInitialState), {
23453
+ startRecording: function startRecording(camera, audioStream, captureAudio) {
23512
23454
  var _a;
23455
+ if (captureAudio === void 0) {
23456
+ captureAudio = false;
23457
+ }
23458
+ set({
23459
+ isRecording: true
23460
+ });
23513
23461
  clearSignatureChunks();
23514
- clearRecordedVideoData();
23515
- startRecordingVideo();
23516
- if (captureAudio) startRecordingAudio();
23517
- var stream = outputCanvas.current.captureStream(24 /* fps */);
23462
+ useVideoRecorderStore.getState().clearRecordedData();
23463
+ var _b = useVideoRecorderStore.getState(),
23464
+ startRecordingVideo = _b.startRecordingVideo,
23465
+ startRecordingAudio = _b.startRecordingAudio;
23466
+ startRecordingVideo(camera, audioStream);
23467
+ if (captureAudio) startRecordingAudio(audioStream);
23468
+ var stream = get().outputCanvas.current.captureStream(24 /* fps */);
23518
23469
  var tracks = [stream.getVideoTracks()[0]];
23519
23470
  var audioTrack = (_a = audioStream === null || audioStream === void 0 ? void 0 : audioStream.getAudioTracks()) === null || _a === void 0 ? void 0 : _a[0];
23520
23471
  if (audioTrack) tracks.push(audioTrack);
@@ -23526,111 +23477,122 @@
23526
23477
  signatureRecorder.ondataavailable = function (event) {
23527
23478
  signatureChunks.push(event.data);
23528
23479
  };
23480
+ signatureRecorder.start(1000);
23481
+ },
23482
+ stopRecording: function stopRecording() {
23483
+ set({
23484
+ isRecording: false
23485
+ });
23486
+ if (!signatureRecorder) return;
23487
+ signatureRecorder.stop();
23529
23488
  signatureRecorder.onstop = function () {
23530
23489
  log('VideoSignatureContext: onstop');
23531
23490
  var blob = new Blob(signatureChunks, {
23532
23491
  type: 'video/mp4'
23533
23492
  });
23534
- setSignatureVideoData(blob);
23535
- setSignatureVideoUrl(URL.createObjectURL(blob));
23493
+ useVideoSignatureStore.setState({
23494
+ signatureVideoData: blob,
23495
+ signatureVideoUrl: URL.createObjectURL(blob)
23496
+ });
23536
23497
  clearSignatureChunks();
23537
23498
  setSignatureRecorder(null);
23538
- onRecordingStopped.current();
23539
23499
  };
23540
- signatureRecorder.start(1000);
23500
+ useVideoRecorderStore.getState().stopRecording();
23501
+ },
23502
+ clearRecordedData: function clearRecordedData() {
23503
+ var _a;
23504
+ clearSignatureChunks();
23505
+ useVideoRecorderStore.getState().stopRecordingVideo();
23506
+ useVideoRecorderStore.getState().clearRecordedData();
23507
+ (_a = getSignatureRecorder()) === null || _a === void 0 ? void 0 : _a.stop();
23508
+ setSignatureRecorder(null);
23509
+ set({
23510
+ isRecording: false,
23511
+ signatureVideoData: null,
23512
+ signatureVideoUrl: null
23513
+ });
23514
+ }
23515
+ });
23516
+ }));
23517
+ function VideoSignatureContextProvider(_a) {
23518
+ var _b, _c;
23519
+ var children = _a.children,
23520
+ _d = _a.captureAudio,
23521
+ captureAudio = _d === void 0 ? false : _d;
23522
+ var _e = useCameraStore(),
23523
+ camera = _e.camera,
23524
+ videoRef = _e.videoRef;
23525
+ var isRecordingVideo = useVideoRecorder(captureAudio).isRecordingVideo;
23526
+ var outputCanvas = React.useRef(null);
23527
+ React.useEffect(function () {
23528
+ return useVideoSignatureStore.setState({
23529
+ outputCanvas: outputCanvas
23541
23530
  });
23542
- }, [audioStream, captureAudio, clearRecordedVideoData, isRecording, startRecordingAudio, startRecordingVideo]);
23531
+ }, []);
23532
+ var isRecording = useVideoSignatureStore().isRecording;
23533
+ // useEffect(() => {
23534
+ // if (!isRecording || !camera) return
23535
+ // waitForCanvasAvailable(outputCanvas).then(() => {
23536
+ // log('VideoSignatureContext: starting recording...')
23537
+ // clearSignatureChunks()
23538
+ // const { startRecordingVideo, startRecordingAudio } =
23539
+ // useVideoRecorderStore.getState()
23540
+ // startRecordingVideo(camera, audioStream)
23541
+ // if (captureAudio) startRecordingAudio(audioStream)
23542
+ // const stream = outputCanvas.current!.captureStream(24 /* fps */)
23543
+ // const tracks = [stream.getVideoTracks()[0]]
23544
+ // const audioTrack = audioStream?.getAudioTracks()?.[0]
23545
+ // if (audioTrack) tracks.push(audioTrack)
23546
+ // const signatureRecorder = new MediaRecorder(new MediaStream(tracks), {
23547
+ // videoBitsPerSecond: 270000,
23548
+ // audioBitsPerSecond: 32000,
23549
+ // })
23550
+ // setSignatureRecorder(signatureRecorder)
23551
+ // signatureRecorder.ondataavailable = (event) => {
23552
+ // signatureChunks.push(event.data)
23553
+ // }
23554
+ // signatureRecorder.start(1000)
23555
+ // })
23556
+ // }, [audioStream, captureAudio, isRecording, camera])
23543
23557
  var animationFrame = React.useRef(0);
23544
23558
  React.useEffect(function () {
23545
- if (!signaturePad.current || !videoRef.current || !outputCanvas.current || !camera || !isRecording || !isRecordingVideo) return;
23559
+ if (!videoRef.current || !outputCanvas.current || !camera || !isRecording || !isRecordingVideo) return;
23546
23560
  var ctx = outputCanvas.current.getContext('2d');
23547
23561
  if (!ctx) return;
23562
+ var signaturePad = useVideoSignatureStore.getState().signaturePad;
23548
23563
  animationFrame.current = requestAnimationFrame(function runFrame() {
23549
- return __awaiter(this, void 0, void 0, function () {
23550
- var _a, w, h, isPortrait, rect;
23551
- return __generator(this, function (_b) {
23552
- if (!signaturePad.current || !videoRef.current || !outputCanvas.current) {
23553
- cancelAnimationFrame(animationFrame.current);
23554
- return [2 /*return*/];
23555
- }
23556
- _a = [videoRef.current.videoWidth, videoRef.current.videoHeight], w = _a[0], h = _a[1];
23557
- isPortrait = w < h;
23558
- outputCanvas.current.width = w;
23559
- outputCanvas.current.height = h;
23560
- 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)];
23561
- ctx.drawImage(videoRef.current, 0, 0, w, h);
23562
- ctx.beginPath();
23563
- ctx.fillStyle = 'rgba(255,255,255,0.5)';
23564
- ctx.roundRect.apply(ctx, __spreadArray(__spreadArray([], rect, false), [16], false));
23565
- ctx.fill();
23566
- ctx.drawImage.apply(ctx, __spreadArray([signaturePad.current.getCanvas()], rect, false));
23567
- animationFrame.current = requestAnimationFrame(runFrame);
23568
- return [2 /*return*/];
23569
- });
23570
- });
23564
+ if (!signaturePad.current || !videoRef.current || !outputCanvas.current) {
23565
+ cancelAnimationFrame(animationFrame.current);
23566
+ return;
23567
+ }
23568
+ var _a = [videoRef.current.videoWidth, videoRef.current.videoHeight],
23569
+ w = _a[0],
23570
+ h = _a[1];
23571
+ var isPortrait = w < h;
23572
+ outputCanvas.current.width = w;
23573
+ outputCanvas.current.height = h;
23574
+ 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)];
23575
+ ctx.drawImage(videoRef.current, 0, 0, w, h);
23576
+ ctx.beginPath();
23577
+ ctx.fillStyle = 'rgba(255,255,255,0.5)';
23578
+ ctx.roundRect.apply(ctx, __spreadArray(__spreadArray([], rect, false), [16], false));
23579
+ ctx.fill();
23580
+ ctx.drawImage.apply(ctx, __spreadArray([signaturePad.current.getCanvas()], rect, false));
23581
+ animationFrame.current = requestAnimationFrame(runFrame);
23571
23582
  });
23572
23583
  return function () {
23573
- cancelAnimationFrame(animationFrame.current);
23584
+ return cancelAnimationFrame(animationFrame.current);
23574
23585
  };
23575
23586
  }, [camera, isRecording, isRecordingVideo, videoRef]);
23576
- var onAcceptClicked = React.useCallback(function () {
23577
- return __awaiter(_this, void 0, void 0, function () {
23578
- var signatureData, imageUrl;
23579
- var _a;
23580
- return __generator(this, function (_b) {
23581
- switch (_b.label) {
23582
- case 0:
23583
- log('VideoSignatureContext: onAcceptClicked');
23584
- if (!signaturePad.current) return [2 /*return*/];
23585
- log('VideoSignatureContext: building signature data...');
23586
- signatureData = buildSignatureData(signaturePad.current);
23587
- log('VideoSignatureContext: exporting signature image...');
23588
- return [4 /*yield*/, exportSignatureImage(signaturePad.current)];
23589
- case 1:
23590
- imageUrl = _b.sent();
23591
- if (imageUrl) signatureData.fileContent = dataUrlToBase64Sync(imageUrl);
23592
- log('VideoSignatureContext: setting signature data url...');
23593
- setSignatureDataUrl(imageUrl);
23594
- setSignatureData(signatureData);
23595
- log('VideoSignatureContext: stopping recording...');
23596
- stopRecordingVideo();
23597
- stopRecordingAudio();
23598
- log('VideoSignatureContext: stopping signature recorder...');
23599
- (_a = getSignatureRecorder()) === null || _a === void 0 ? void 0 : _a.stop();
23600
- return [2 /*return*/];
23601
- }
23602
- });
23603
- });
23604
- }, [stopRecordingAudio, stopRecordingVideo]);
23605
- var value = React.useMemo(function () {
23606
- return {
23607
- isRecording: isRecording,
23608
- startRecording: startRecording,
23609
- stopRecording: stopRecording,
23610
- clearRecordedData: clearRecordedData,
23611
- signaturePad: signaturePad,
23612
- signatureData: signatureData,
23613
- signatureDataUrl: signatureDataUrl,
23614
- signatureVideoData: signatureVideoData,
23615
- signatureVideoUrl: signatureVideoUrl,
23616
- onAcceptClicked: onAcceptClicked
23617
- };
23618
- }, [clearRecordedData, isRecording, onAcceptClicked, signatureData, signatureDataUrl, signatureVideoData, signatureVideoUrl, startRecording, stopRecording]);
23619
- return /*#__PURE__*/React.createElement(VideoSignatureContext.Provider, {
23620
- value: value
23621
- }, children, /*#__PURE__*/React.createElement(InvisibleCanvas, {
23587
+ return /*#__PURE__*/React.createElement(React.Fragment, null, children, /*#__PURE__*/React.createElement(InvisibleCanvas, {
23622
23588
  ref: outputCanvas,
23623
23589
  width: (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth,
23624
23590
  height: (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.videoHeight
23625
23591
  }));
23626
23592
  }
23627
- function useVideoSignatureContext() {
23628
- var ctx = React.useContext(VideoSignatureContext);
23629
- if (!ctx) throw new Error('useVideoSignatureContext cannot be used without ContextProvider');
23630
- return ctx;
23631
- }
23632
23593
 
23633
23594
  function VideoSignatureGuides(_a) {
23595
+ var _this = this;
23634
23596
  var _b = _a.requestedAction,
23635
23597
  requestedAction = _b === void 0 ? 'VERIFY_LIVENESS' : _b,
23636
23598
  _c = _a.faceGuideStatus,
@@ -23650,15 +23612,18 @@
23650
23612
  ref = _h.ref,
23651
23613
  width = _h.width,
23652
23614
  height = _h.height;
23653
- var _j = useVideoSignatureContext(),
23654
- signaturePad = _j.signaturePad,
23655
- onAcceptClicked = _j.onAcceptClicked;
23656
- var _k = React.useState(true),
23657
- signaturePadEmpty = _k[0],
23658
- setSignaturePadEmpty = _k[1];
23659
- var _l = React.useState(false),
23660
- signatureValid = _l[0],
23661
- setSignatureValid = _l[1];
23615
+ var signaturePad = React.useRef(null);
23616
+ var _j = React.useState(true),
23617
+ signaturePadEmpty = _j[0],
23618
+ setSignaturePadEmpty = _j[1];
23619
+ var _k = React.useState(false),
23620
+ signatureValid = _k[0],
23621
+ setSignatureValid = _k[1];
23622
+ React.useEffect(function () {
23623
+ return useVideoSignatureStore.setState({
23624
+ signaturePad: signaturePad
23625
+ });
23626
+ }, []);
23662
23627
  var verbiage = useTranslations(rawVerbiage, {
23663
23628
  signaturePadEmptyText: '',
23664
23629
  headTrackingUnsatisfiedText: '',
@@ -23675,13 +23640,41 @@
23675
23640
  var isSigning = requestedAction === 'CAPTURE_SIGNATURE';
23676
23641
  var canClear = isSigning && !signaturePadEmpty;
23677
23642
  var canSubmit = isSigning && signatureValid && headTrackingSatisfied;
23678
- var _m = React.useState(false),
23679
- emptyContentDismissed = _m[0],
23680
- setEmptyContentDismissed = _m[1];
23643
+ var _l = React.useState(false),
23644
+ emptyContentDismissed = _l[0],
23645
+ setEmptyContentDismissed = _l[1];
23681
23646
  var displayEmptyState = requestedAction === 'CAPTURE_SIGNATURE' && signaturePadEmpty && !emptyContentDismissed;
23682
23647
  React.useEffect(function () {
23683
23648
  if (signaturePadEmpty) setEmptyContentDismissed(false);
23684
23649
  }, [signaturePadEmpty]);
23650
+ var onAcceptClicked = React.useCallback(function () {
23651
+ return __awaiter(_this, void 0, void 0, function () {
23652
+ var signatureData, imageUrl;
23653
+ return __generator(this, function (_a) {
23654
+ switch (_a.label) {
23655
+ case 0:
23656
+ log('VideoSignatureContext: onAcceptClicked');
23657
+ if (!signaturePad.current) return [2 /*return*/];
23658
+ log('VideoSignatureContext: building signature data...');
23659
+ signatureData = buildSignatureData(signaturePad.current);
23660
+ log('VideoSignatureContext: exporting signature image...', signatureData);
23661
+ return [4 /*yield*/, exportSignatureImage(signaturePad.current)];
23662
+ case 1:
23663
+ imageUrl = _a.sent();
23664
+ if (imageUrl) signatureData.fileContent = dataUrlToBase64Sync(imageUrl);
23665
+ log('VideoSignatureContext: setting signature data url...', imageUrl);
23666
+ useVideoSignatureStore.setState({
23667
+ signatureData: signatureData,
23668
+ signatureDataUrl: imageUrl
23669
+ });
23670
+ log('VideoSignatureContext: stopping signature recorder...');
23671
+ // getSignatureRecorder()?.stop()
23672
+ useVideoSignatureStore.getState().stopRecording();
23673
+ return [2 /*return*/];
23674
+ }
23675
+ });
23676
+ });
23677
+ }, []);
23685
23678
  return /*#__PURE__*/React.createElement(Container$3, {
23686
23679
  className: classNames.container
23687
23680
  }, /*#__PURE__*/React.createElement(Inner$1, {
@@ -23784,40 +23777,45 @@
23784
23777
  minSignaturePadPoints = _c === void 0 ? DEFAULT_MIN_SIGNATURE_PAD_POINTS : _c,
23785
23778
  _d = _a.headTrackingBoundaryPercentage,
23786
23779
  headTrackingBoundaryPercentage = _d === void 0 ? DEFAULT_HEAD_TRACKING_BOUNDARY_PERCENTAGE : _d,
23787
- _e = _a.classNames,
23788
- classNames = _e === void 0 ? {} : _e,
23789
- _f = _a.colors,
23790
- colors = _f === void 0 ? {} : _f,
23791
- _g = _a.verbiage,
23792
- rawVerbiage = _g === void 0 ? {} : _g,
23793
- _h = _a.debugMode,
23794
- debugMode = _h === void 0 ? false : _h;
23795
- var _j = useCameraStore(useShallow(function (state) {
23780
+ _e = _a.captureAudio,
23781
+ captureAudio = _e === void 0 ? false : _e,
23782
+ _f = _a.classNames,
23783
+ classNames = _f === void 0 ? {} : _f,
23784
+ _g = _a.colors,
23785
+ colors = _g === void 0 ? {} : _g,
23786
+ _h = _a.verbiage,
23787
+ rawVerbiage = _h === void 0 ? {} : _h,
23788
+ _j = _a.debugMode,
23789
+ debugMode = _j === void 0 ? false : _j;
23790
+ var _k = useCameraStore(useShallow(function (state) {
23796
23791
  return {
23797
23792
  camera: state.camera,
23793
+ audioStream: state.audioStream,
23798
23794
  videoWidth: state.videoWidth,
23799
23795
  videoHeight: state.videoHeight
23800
23796
  };
23801
23797
  })),
23802
- camera = _j.camera,
23803
- videoWidth = _j.videoWidth,
23804
- videoHeight = _j.videoHeight;
23805
- var _k = useSelfieGuidanceModelsContext(),
23806
- onPredictionMade = _k.onPredictionMade,
23807
- startHeadTracking = _k.start,
23808
- stopHeadTracking = _k.stop;
23809
- var _l = useVideoSignatureContext(),
23810
- signatureData = _l.signatureData,
23811
- signatureDataUrl = _l.signatureDataUrl,
23812
- signatureVideoData = _l.signatureVideoData,
23813
- startRecording = _l.startRecording,
23814
- stopRecording = _l.stopRecording,
23815
- clearRecordedData = _l.clearRecordedData,
23816
- isRecording = _l.isRecording;
23798
+ camera = _k.camera,
23799
+ audioStream = _k.audioStream,
23800
+ videoWidth = _k.videoWidth,
23801
+ videoHeight = _k.videoHeight;
23802
+ var _l = useSelfieGuidanceModelsContext(),
23803
+ onPredictionMade = _l.onPredictionMade,
23804
+ startHeadTracking = _l.start,
23805
+ stopHeadTracking = _l.stop;
23806
+ var _m = useVideoSignatureStore(),
23807
+ signatureData = _m.signatureData,
23808
+ signatureDataUrl = _m.signatureDataUrl,
23809
+ signatureVideoData = _m.signatureVideoData,
23810
+ startRecording = _m.startRecording,
23811
+ stopRecording = _m.stopRecording,
23812
+ clearRecordedData = _m.clearRecordedData,
23813
+ isRecording = _m.isRecording;
23817
23814
  React.useEffect(function () {
23818
- startRecording();
23815
+ if (!camera) return;
23816
+ startRecording(camera, audioStream, captureAudio);
23819
23817
  return stopRecording;
23820
- }, [startRecording, stopRecording]);
23818
+ }, [audioStream, camera, captureAudio, startRecording, stopRecording]);
23821
23819
  React.useEffect(function () {
23822
23820
  setTimeout(startHeadTracking, 1);
23823
23821
  return stopHeadTracking;
@@ -23832,15 +23830,15 @@
23832
23830
  onVideoCaptured === null || onVideoCaptured === void 0 ? void 0 : onVideoCaptured(signatureVideoData, signatureData, signatureDataUrl);
23833
23831
  }
23834
23832
  }, [onVideoCaptured, signatureData, signatureDataUrl, signatureVideoData]);
23835
- var _m = React.useState(true),
23836
- headTrackingSatisfied = _m[0],
23837
- setHeadTrackingSatisfied = _m[1];
23838
- var _o = React.useState(null),
23839
- lastFace = _o[0],
23840
- setLastFace = _o[1];
23841
- var _p = React.useState(0),
23842
- numFramesWithoutFaces = _p[0],
23843
- setNumFramesWithoutFaces = _p[1];
23833
+ var _o = React.useState(true),
23834
+ headTrackingSatisfied = _o[0],
23835
+ setHeadTrackingSatisfied = _o[1];
23836
+ var _p = React.useState(null),
23837
+ lastFace = _p[0],
23838
+ setLastFace = _p[1];
23839
+ var _q = React.useState(0),
23840
+ numFramesWithoutFaces = _q[0],
23841
+ setNumFramesWithoutFaces = _q[1];
23844
23842
  onPredictionMade(f(React.useCallback(function (_a) {
23845
23843
  var face = _a.face;
23846
23844
  if (!camera) return;
@@ -23851,12 +23849,12 @@
23851
23849
  return n + 1;
23852
23850
  });
23853
23851
  }, [camera, headTrackingBoundaryPercentage, videoHeight, videoWidth]), 16));
23854
- var _q = useResizeObserver(),
23855
- ref = _q.ref,
23856
- _r = _q.width,
23857
- width = _r === void 0 ? 1 : _r,
23858
- _s = _q.height,
23859
- height = _s === void 0 ? 1 : _s;
23852
+ var _r = useResizeObserver(),
23853
+ ref = _r.ref,
23854
+ _s = _r.width,
23855
+ width = _s === void 0 ? 1 : _s,
23856
+ _t = _r.height,
23857
+ height = _t === void 0 ? 1 : _t;
23860
23858
  var debugScalingDetails = useDebugScalingDetails({
23861
23859
  enabled: debugMode,
23862
23860
  pageWidth: width,
@@ -24073,6 +24071,7 @@
24073
24071
  return n + 1;
24074
24072
  });
24075
24073
  setCaptureState('CHECKING_LIVENESS');
24074
+ useVideoSignatureStore.getState().clearRecordedData();
24076
24075
  }, [onRetryClicked]);
24077
24076
  var onExitSignatureCapture = React.useCallback(function () {
24078
24077
  setAttempt(function (n) {
@@ -24094,9 +24093,10 @@
24094
24093
  return /*#__PURE__*/React.createElement(VideoSignatureWizardGuides, _assign({}, props, {
24095
24094
  classNames: classNames === null || classNames === void 0 ? void 0 : classNames.guides,
24096
24095
  verbiage: verbiage === null || verbiage === void 0 ? void 0 : verbiage.guides,
24097
- restartVideoOnSignaturePadCleared: restartVideoOnSignaturePadCleared
24096
+ restartVideoOnSignaturePadCleared: restartVideoOnSignaturePadCleared,
24097
+ captureAudio: captureAudio
24098
24098
  }));
24099
- }, [classNames === null || classNames === void 0 ? void 0 : classNames.guides, restartVideoOnSignaturePadCleared, verbiage === null || verbiage === void 0 ? void 0 : verbiage.guides]);
24099
+ }, [captureAudio, classNames === null || classNames === void 0 ? void 0 : classNames.guides, restartVideoOnSignaturePadCleared, verbiage === null || verbiage === void 0 ? void 0 : verbiage.guides]);
24100
24100
  var onExitAfterFailureProp = faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.onExitAfterFailure;
24101
24101
  var onExitAfterFailure = React.useCallback(function (resp, req) {
24102
24102
  onExitAfterFailureProp === null || onExitAfterFailureProp === void 0 ? void 0 : onExitAfterFailureProp(resp, req);
@@ -24148,6 +24148,7 @@
24148
24148
  headTrackingBoundaryPercentage: headTrackingBoundaryPercentage,
24149
24149
  restartVideoOnSignaturePadCleared: restartVideoOnSignaturePadCleared,
24150
24150
  guidesComponent: guidesComponent,
24151
+ captureAudio: captureAudio,
24151
24152
  classNames: classNames,
24152
24153
  colors: colors,
24153
24154
  verbiage: verbiage,
@@ -24172,14 +24173,25 @@
24172
24173
  var status = _a.status,
24173
24174
  _b = _a.restartVideoOnSignaturePadCleared,
24174
24175
  restartVideoOnSignaturePadCleared = _b === void 0 ? true : _b,
24175
- props = __rest(_a, ["status", "restartVideoOnSignaturePadCleared"]);
24176
- var clearRecordedData = useVideoSignatureContext().clearRecordedData;
24176
+ _c = _a.captureAudio,
24177
+ captureAudio = _c === void 0 ? false : _c,
24178
+ props = __rest(_a, ["status", "restartVideoOnSignaturePadCleared", "captureAudio"]);
24179
+ var _d = useCameraStore(),
24180
+ camera = _d.camera,
24181
+ audioStream = _d.audioStream;
24182
+ function onClear() {
24183
+ if (!restartVideoOnSignaturePadCleared) return;
24184
+ setTimeout(function () {
24185
+ useVideoSignatureStore.getState().clearRecordedData();
24186
+ setTimeout(function () {
24187
+ useVideoSignatureStore.getState().startRecording(camera, audioStream, captureAudio);
24188
+ }, 100);
24189
+ }, 100);
24190
+ }
24177
24191
  return /*#__PURE__*/React.createElement(VideoSignatureGuides, _assign({}, props, {
24178
24192
  faceGuideStatus: status,
24179
- requestedAction: status === 'success' ? 'CAPTURE_SIGNATURE' : 'VERIFY_LIVENESS',
24180
- onClearSignaturePadClicked: restartVideoOnSignaturePadCleared ? function () {
24181
- return setTimeout(clearRecordedData, 100);
24182
- } : undefined
24193
+ onClearSignaturePadClicked: onClear,
24194
+ requestedAction: status === 'success' ? 'CAPTURE_SIGNATURE' : 'VERIFY_LIVENESS'
24183
24195
  }));
24184
24196
  }
24185
24197
  var VideoSignatureWizardWithProviders = function VideoSignatureWizardWithProviders(props) {
@@ -24562,12 +24574,8 @@
24562
24574
  stopSelfieGuidance = _16.stop,
24563
24575
  onSelfiePredictionMade = _16.onPredictionMade,
24564
24576
  selfieModelError = _16.error;
24565
- var _17 = useVideoRecorder(camera, audioStream, mergeAVStreams),
24577
+ var _17 = useVideoRecorder(mergeAVStreams),
24566
24578
  isRecordingVideo = _17.isRecordingVideo,
24567
- startRecordingVideo = _17.startRecordingVideo,
24568
- startRecordingAudio = _17.startRecordingAudio,
24569
- stopRecordingVideo = _17.stopRecordingVideo,
24570
- stopRecordingAudio = _17.stopRecordingAudio,
24571
24579
  videoRecordingUnintentionallyStopped = _17.videoRecordingUnintentionallyStopped,
24572
24580
  audioRecordingUnintentionallyStopped = _17.audioRecordingUnintentionallyStopped,
24573
24581
  videoUrl = _17.videoUrl,
@@ -24577,8 +24585,8 @@
24577
24585
  countdownRemaining = _18[0],
24578
24586
  setCountdownRemaining = _18[1];
24579
24587
  React.useEffect(function () {
24580
- if (!isRecordingVideo && !videoUrl) {
24581
- startRecordingVideo();
24588
+ if (camera && !isRecordingVideo && !videoUrl) {
24589
+ useVideoRecorderStore.getState().startRecordingVideo(camera, audioStream);
24582
24590
  setVideoStartsAt(new Date());
24583
24591
  }
24584
24592
  // if the mergeAVStreams flag is present, the audio stream is on the video
@@ -24589,7 +24597,7 @@
24589
24597
  releaseCameraAccess();
24590
24598
  onComplete === null || onComplete === void 0 ? void 0 : onComplete(videoUrl, audioUrl);
24591
24599
  }
24592
- }, [audioUrl, isRecordingVideo, mergeAVStreams, onComplete, readTextPrompt, releaseCameraAccess, startRecordingVideo, videoUrl]);
24600
+ }, [audioStream, audioUrl, camera, isRecordingVideo, mergeAVStreams, onComplete, readTextPrompt, releaseCameraAccess, videoUrl]);
24593
24601
  React.useEffect(function () {
24594
24602
  if (videoRecordingUnintentionallyStopped || audioRecordingUnintentionallyStopped || !!readTextPrompt && !microphoneReady) {
24595
24603
  onRecordingFailed === null || onRecordingFailed === void 0 ? void 0 : onRecordingFailed();
@@ -24684,13 +24692,13 @@
24684
24692
  var _a;
24685
24693
  if (translatedText) {
24686
24694
  setRequestedAction('READ_TEXT');
24687
- startRecordingAudio();
24695
+ useVideoRecorderStore.getState().startRecordingAudio(audioStream);
24688
24696
  setIdCaptureVideoAudioStartsAt(new Date().getTime() - ((_a = videoStartsAt === null || videoStartsAt === void 0 ? void 0 : videoStartsAt.getTime()) !== null && _a !== void 0 ? _a : 0));
24689
24697
  setExpectedAudioText(translatedText);
24690
24698
  } else {
24691
- stopRecordingVideo();
24699
+ useVideoRecorderStore.getState().stopRecordingVideo();
24692
24700
  }
24693
- }, [setExpectedAudioText, setIdCaptureVideoAudioStartsAt, startRecordingAudio, stopRecordingVideo, translatedText, videoStartsAt]);
24701
+ }, [audioStream, setExpectedAudioText, setIdCaptureVideoAudioStartsAt, translatedText, videoStartsAt]);
24694
24702
  var frameWidth = (_c = (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth) !== null && _c !== void 0 ? _c : 0;
24695
24703
  var frameHeight = (_e = (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) !== null && _e !== void 0 ? _e : 0;
24696
24704
  var faceBox = face === null || face === void 0 ? void 0 : face.box;
@@ -24760,9 +24768,9 @@
24760
24768
  };
24761
24769
  }, [isFlipping]);
24762
24770
  var stopRecording = React.useCallback(function () {
24763
- stopRecordingVideo();
24764
- stopRecordingAudio();
24765
- }, [stopRecordingAudio, stopRecordingVideo]);
24771
+ useVideoRecorderStore.getState().stopRecordingVideo();
24772
+ useVideoRecorderStore.getState().stopRecordingAudio();
24773
+ }, []);
24766
24774
  var satisfied = !isFlipping && goodFramesThresholdMet && faceCentered && delaySatisfied;
24767
24775
  React.useEffect(function () {
24768
24776
  if (satisfied && !countdownStartedAt) {