idmission-web-sdk 2.3.13 → 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.
- package/dist/components/video_id/IdVideoCapture.d.ts.map +1 -1
- package/dist/components/video_signature_capture/VideoSignatureCapture.d.ts +2 -1
- package/dist/components/video_signature_capture/VideoSignatureCapture.d.ts.map +1 -1
- package/dist/components/video_signature_capture/VideoSignatureContext.d.ts +19 -4
- package/dist/components/video_signature_capture/VideoSignatureContext.d.ts.map +1 -1
- package/dist/components/video_signature_capture/VideoSignatureGuides.d.ts.map +1 -1
- package/dist/components/video_signature_capture/VideoSignatureWizard.d.ts.map +1 -1
- package/dist/lib/camera/useVideoRecorder.d.ts +32 -3
- package/dist/lib/camera/useVideoRecorder.d.ts.map +1 -1
- package/dist/sdk2.cjs.development.js +370 -361
- package/dist/sdk2.cjs.development.js.map +1 -1
- package/dist/sdk2.cjs.production.js +1 -1
- package/dist/sdk2.cjs.production.js.map +1 -1
- package/dist/sdk2.esm.js +370 -361
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +370 -361
- package/dist/sdk2.umd.development.js.map +1 -1
- package/dist/sdk2.umd.production.js +1 -1
- package/dist/sdk2.umd.production.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +3 -3
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.
|
|
207
|
+
var webSdkVersion = '2.3.15';
|
|
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$
|
|
825
|
+
var initialState$7 = {
|
|
826
826
|
authUrl: defaultAuthUrl,
|
|
827
827
|
sessionCheckState: 'READY'
|
|
828
828
|
};
|
|
829
|
-
var AuthStateContext = /*#__PURE__*/createContext(initialState$
|
|
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$
|
|
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$
|
|
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$
|
|
4768
|
+
return _assign(_assign(_assign({}, initialState$6), config), {
|
|
4769
4769
|
reset: function reset() {
|
|
4770
|
-
return set(_assign(_assign({}, initialState$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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
|
|
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
|
-
|
|
13353
|
-
|
|
13354
|
-
|
|
13355
|
-
|
|
13356
|
-
|
|
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
|
-
|
|
13456
|
+
useVideoRecorderStore.setState({
|
|
13457
|
+
videoUrl: URL.createObjectURL(videoBlob),
|
|
13458
|
+
isRecordingVideo: false
|
|
13459
|
+
});
|
|
13388
13460
|
clearVideoChunks();
|
|
13389
|
-
setIsRecordingVideo(false);
|
|
13390
13461
|
setVideoRecorder(null);
|
|
13391
|
-
|
|
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
|
-
|
|
13399
|
-
|
|
13400
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
-
debug('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
|
|
13547
|
-
|
|
13548
|
-
|
|
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
|
-
|
|
13609
|
-
|
|
13610
|
-
|
|
13611
|
-
|
|
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,110 +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 () {
|
|
13583
|
+
log('VideoSignatureContext: onstop');
|
|
13624
13584
|
var blob = new Blob(signatureChunks, {
|
|
13625
13585
|
type: 'video/mp4'
|
|
13626
13586
|
});
|
|
13627
|
-
|
|
13628
|
-
|
|
13587
|
+
useVideoSignatureStore.setState({
|
|
13588
|
+
signatureVideoData: blob,
|
|
13589
|
+
signatureVideoUrl: URL.createObjectURL(blob)
|
|
13590
|
+
});
|
|
13629
13591
|
clearSignatureChunks();
|
|
13630
13592
|
setSignatureRecorder(null);
|
|
13631
|
-
onRecordingStopped.current();
|
|
13632
13593
|
};
|
|
13633
|
-
|
|
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
|
|
13634
13624
|
});
|
|
13635
|
-
}, [
|
|
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])
|
|
13636
13651
|
var animationFrame = useRef(0);
|
|
13637
13652
|
useEffect(function () {
|
|
13638
|
-
if (!
|
|
13653
|
+
if (!videoRef.current || !outputCanvas.current || !camera || !isRecording || !isRecordingVideo) return;
|
|
13639
13654
|
var ctx = outputCanvas.current.getContext('2d');
|
|
13640
13655
|
if (!ctx) return;
|
|
13656
|
+
var signaturePad = useVideoSignatureStore.getState().signaturePad;
|
|
13641
13657
|
animationFrame.current = requestAnimationFrame(function runFrame() {
|
|
13642
|
-
|
|
13643
|
-
|
|
13644
|
-
return
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
|
|
13648
|
-
|
|
13649
|
-
|
|
13650
|
-
|
|
13651
|
-
|
|
13652
|
-
|
|
13653
|
-
|
|
13654
|
-
|
|
13655
|
-
|
|
13656
|
-
|
|
13657
|
-
|
|
13658
|
-
|
|
13659
|
-
|
|
13660
|
-
animationFrame.current = requestAnimationFrame(runFrame);
|
|
13661
|
-
return [2 /*return*/];
|
|
13662
|
-
});
|
|
13663
|
-
});
|
|
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);
|
|
13664
13676
|
});
|
|
13665
13677
|
return function () {
|
|
13666
|
-
cancelAnimationFrame(animationFrame.current);
|
|
13678
|
+
return cancelAnimationFrame(animationFrame.current);
|
|
13667
13679
|
};
|
|
13668
13680
|
}, [camera, isRecording, isRecordingVideo, videoRef]);
|
|
13669
|
-
|
|
13670
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
13671
|
-
var signatureData, imageUrl;
|
|
13672
|
-
var _a;
|
|
13673
|
-
return __generator(this, function (_b) {
|
|
13674
|
-
switch (_b.label) {
|
|
13675
|
-
case 0:
|
|
13676
|
-
debug('VideoSignatureContext: onAcceptClicked');
|
|
13677
|
-
if (!signaturePad.current) return [2 /*return*/];
|
|
13678
|
-
debug('VideoSignatureContext: building signature data...');
|
|
13679
|
-
signatureData = buildSignatureData(signaturePad.current);
|
|
13680
|
-
debug('VideoSignatureContext: exporting signature image...');
|
|
13681
|
-
return [4 /*yield*/, exportSignatureImage(signaturePad.current)];
|
|
13682
|
-
case 1:
|
|
13683
|
-
imageUrl = _b.sent();
|
|
13684
|
-
if (imageUrl) signatureData.fileContent = dataUrlToBase64Sync(imageUrl);
|
|
13685
|
-
debug('VideoSignatureContext: setting signature data url...');
|
|
13686
|
-
setSignatureDataUrl(imageUrl);
|
|
13687
|
-
setSignatureData(signatureData);
|
|
13688
|
-
debug('VideoSignatureContext: stopping recording...');
|
|
13689
|
-
stopRecordingVideo();
|
|
13690
|
-
stopRecordingAudio();
|
|
13691
|
-
debug('VideoSignatureContext: stopping signature recorder...');
|
|
13692
|
-
(_a = getSignatureRecorder()) === null || _a === void 0 ? void 0 : _a.stop();
|
|
13693
|
-
return [2 /*return*/];
|
|
13694
|
-
}
|
|
13695
|
-
});
|
|
13696
|
-
});
|
|
13697
|
-
}, [stopRecordingAudio, stopRecordingVideo]);
|
|
13698
|
-
var value = useMemo(function () {
|
|
13699
|
-
return {
|
|
13700
|
-
isRecording: isRecording,
|
|
13701
|
-
startRecording: startRecording,
|
|
13702
|
-
stopRecording: stopRecording,
|
|
13703
|
-
clearRecordedData: clearRecordedData,
|
|
13704
|
-
signaturePad: signaturePad,
|
|
13705
|
-
signatureData: signatureData,
|
|
13706
|
-
signatureDataUrl: signatureDataUrl,
|
|
13707
|
-
signatureVideoData: signatureVideoData,
|
|
13708
|
-
signatureVideoUrl: signatureVideoUrl,
|
|
13709
|
-
onAcceptClicked: onAcceptClicked
|
|
13710
|
-
};
|
|
13711
|
-
}, [clearRecordedData, isRecording, onAcceptClicked, signatureData, signatureDataUrl, signatureVideoData, signatureVideoUrl, startRecording, stopRecording]);
|
|
13712
|
-
return /*#__PURE__*/React__default.createElement(VideoSignatureContext.Provider, {
|
|
13713
|
-
value: value
|
|
13714
|
-
}, children, /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
|
|
13681
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, children, /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
|
|
13715
13682
|
ref: outputCanvas,
|
|
13716
13683
|
width: (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth,
|
|
13717
13684
|
height: (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.videoHeight
|
|
13718
13685
|
}));
|
|
13719
13686
|
}
|
|
13720
|
-
function useVideoSignatureContext() {
|
|
13721
|
-
var ctx = useContext(VideoSignatureContext);
|
|
13722
|
-
if (!ctx) throw new Error('useVideoSignatureContext cannot be used without ContextProvider');
|
|
13723
|
-
return ctx;
|
|
13724
|
-
}
|
|
13725
13687
|
|
|
13726
13688
|
function VideoSignatureGuides(_a) {
|
|
13689
|
+
var _this = this;
|
|
13727
13690
|
var _b = _a.requestedAction,
|
|
13728
13691
|
requestedAction = _b === void 0 ? 'VERIFY_LIVENESS' : _b,
|
|
13729
13692
|
_c = _a.faceGuideStatus,
|
|
@@ -13743,15 +13706,18 @@ function VideoSignatureGuides(_a) {
|
|
|
13743
13706
|
ref = _h.ref,
|
|
13744
13707
|
width = _h.width,
|
|
13745
13708
|
height = _h.height;
|
|
13746
|
-
var
|
|
13747
|
-
|
|
13748
|
-
|
|
13749
|
-
|
|
13750
|
-
|
|
13751
|
-
|
|
13752
|
-
|
|
13753
|
-
|
|
13754
|
-
|
|
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
|
+
}, []);
|
|
13755
13721
|
var verbiage = useTranslations(rawVerbiage, {
|
|
13756
13722
|
signaturePadEmptyText: '',
|
|
13757
13723
|
headTrackingUnsatisfiedText: '',
|
|
@@ -13768,13 +13734,41 @@ function VideoSignatureGuides(_a) {
|
|
|
13768
13734
|
var isSigning = requestedAction === 'CAPTURE_SIGNATURE';
|
|
13769
13735
|
var canClear = isSigning && !signaturePadEmpty;
|
|
13770
13736
|
var canSubmit = isSigning && signatureValid && headTrackingSatisfied;
|
|
13771
|
-
var
|
|
13772
|
-
emptyContentDismissed =
|
|
13773
|
-
setEmptyContentDismissed =
|
|
13737
|
+
var _l = useState(false),
|
|
13738
|
+
emptyContentDismissed = _l[0],
|
|
13739
|
+
setEmptyContentDismissed = _l[1];
|
|
13774
13740
|
var displayEmptyState = requestedAction === 'CAPTURE_SIGNATURE' && signaturePadEmpty && !emptyContentDismissed;
|
|
13775
13741
|
useEffect(function () {
|
|
13776
13742
|
if (signaturePadEmpty) setEmptyContentDismissed(false);
|
|
13777
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
|
+
}, []);
|
|
13778
13772
|
return /*#__PURE__*/React__default.createElement(Container$3, {
|
|
13779
13773
|
className: classNames.container
|
|
13780
13774
|
}, /*#__PURE__*/React__default.createElement(Inner$1, {
|
|
@@ -13877,40 +13871,45 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
|
|
|
13877
13871
|
minSignaturePadPoints = _c === void 0 ? DEFAULT_MIN_SIGNATURE_PAD_POINTS : _c,
|
|
13878
13872
|
_d = _a.headTrackingBoundaryPercentage,
|
|
13879
13873
|
headTrackingBoundaryPercentage = _d === void 0 ? DEFAULT_HEAD_TRACKING_BOUNDARY_PERCENTAGE : _d,
|
|
13880
|
-
_e = _a.
|
|
13881
|
-
|
|
13882
|
-
_f = _a.
|
|
13883
|
-
|
|
13884
|
-
_g = _a.
|
|
13885
|
-
|
|
13886
|
-
_h = _a.
|
|
13887
|
-
|
|
13888
|
-
|
|
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) {
|
|
13889
13885
|
return {
|
|
13890
13886
|
camera: state.camera,
|
|
13887
|
+
audioStream: state.audioStream,
|
|
13891
13888
|
videoWidth: state.videoWidth,
|
|
13892
13889
|
videoHeight: state.videoHeight
|
|
13893
13890
|
};
|
|
13894
13891
|
})),
|
|
13895
|
-
camera =
|
|
13896
|
-
|
|
13897
|
-
|
|
13898
|
-
|
|
13899
|
-
|
|
13900
|
-
|
|
13901
|
-
|
|
13902
|
-
|
|
13903
|
-
|
|
13904
|
-
|
|
13905
|
-
|
|
13906
|
-
|
|
13907
|
-
|
|
13908
|
-
|
|
13909
|
-
|
|
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;
|
|
13910
13908
|
useEffect(function () {
|
|
13911
|
-
|
|
13909
|
+
if (!camera) return;
|
|
13910
|
+
startRecording(camera, audioStream, captureAudio);
|
|
13912
13911
|
return stopRecording;
|
|
13913
|
-
}, [startRecording, stopRecording]);
|
|
13912
|
+
}, [audioStream, camera, captureAudio, startRecording, stopRecording]);
|
|
13914
13913
|
useEffect(function () {
|
|
13915
13914
|
setTimeout(startHeadTracking, 1);
|
|
13916
13915
|
return stopHeadTracking;
|
|
@@ -13925,15 +13924,15 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
|
|
|
13925
13924
|
onVideoCaptured === null || onVideoCaptured === void 0 ? void 0 : onVideoCaptured(signatureVideoData, signatureData, signatureDataUrl);
|
|
13926
13925
|
}
|
|
13927
13926
|
}, [onVideoCaptured, signatureData, signatureDataUrl, signatureVideoData]);
|
|
13928
|
-
var
|
|
13929
|
-
headTrackingSatisfied =
|
|
13930
|
-
setHeadTrackingSatisfied =
|
|
13931
|
-
var
|
|
13932
|
-
lastFace =
|
|
13933
|
-
setLastFace =
|
|
13934
|
-
var
|
|
13935
|
-
numFramesWithoutFaces =
|
|
13936
|
-
setNumFramesWithoutFaces =
|
|
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];
|
|
13937
13936
|
onPredictionMade(useThrottledCallback(useCallback(function (_a) {
|
|
13938
13937
|
var face = _a.face;
|
|
13939
13938
|
if (!camera) return;
|
|
@@ -13944,12 +13943,12 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
|
|
|
13944
13943
|
return n + 1;
|
|
13945
13944
|
});
|
|
13946
13945
|
}, [camera, headTrackingBoundaryPercentage, videoHeight, videoWidth]), 16));
|
|
13947
|
-
var
|
|
13948
|
-
ref =
|
|
13949
|
-
|
|
13950
|
-
width =
|
|
13951
|
-
|
|
13952
|
-
height =
|
|
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;
|
|
13953
13952
|
var debugScalingDetails = useDebugScalingDetails({
|
|
13954
13953
|
enabled: debugMode,
|
|
13955
13954
|
pageWidth: width,
|
|
@@ -14166,6 +14165,7 @@ var VideoSignatureWizard = function VideoSignatureWizard(_a) {
|
|
|
14166
14165
|
return n + 1;
|
|
14167
14166
|
});
|
|
14168
14167
|
setCaptureState('CHECKING_LIVENESS');
|
|
14168
|
+
useVideoSignatureStore.getState().clearRecordedData();
|
|
14169
14169
|
}, [onRetryClicked]);
|
|
14170
14170
|
var onExitSignatureCapture = useCallback(function () {
|
|
14171
14171
|
setAttempt(function (n) {
|
|
@@ -14187,9 +14187,10 @@ var VideoSignatureWizard = function VideoSignatureWizard(_a) {
|
|
|
14187
14187
|
return /*#__PURE__*/React__default.createElement(VideoSignatureWizardGuides, _assign({}, props, {
|
|
14188
14188
|
classNames: classNames === null || classNames === void 0 ? void 0 : classNames.guides,
|
|
14189
14189
|
verbiage: verbiage === null || verbiage === void 0 ? void 0 : verbiage.guides,
|
|
14190
|
-
restartVideoOnSignaturePadCleared: restartVideoOnSignaturePadCleared
|
|
14190
|
+
restartVideoOnSignaturePadCleared: restartVideoOnSignaturePadCleared,
|
|
14191
|
+
captureAudio: captureAudio
|
|
14191
14192
|
}));
|
|
14192
|
-
}, [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]);
|
|
14193
14194
|
var onExitAfterFailureProp = faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.onExitAfterFailure;
|
|
14194
14195
|
var onExitAfterFailure = useCallback(function (resp, req) {
|
|
14195
14196
|
onExitAfterFailureProp === null || onExitAfterFailureProp === void 0 ? void 0 : onExitAfterFailureProp(resp, req);
|
|
@@ -14241,6 +14242,7 @@ var VideoSignatureWizard = function VideoSignatureWizard(_a) {
|
|
|
14241
14242
|
headTrackingBoundaryPercentage: headTrackingBoundaryPercentage,
|
|
14242
14243
|
restartVideoOnSignaturePadCleared: restartVideoOnSignaturePadCleared,
|
|
14243
14244
|
guidesComponent: guidesComponent,
|
|
14245
|
+
captureAudio: captureAudio,
|
|
14244
14246
|
classNames: classNames,
|
|
14245
14247
|
colors: colors,
|
|
14246
14248
|
verbiage: verbiage,
|
|
@@ -14265,14 +14267,25 @@ function VideoSignatureWizardGuides(_a) {
|
|
|
14265
14267
|
var status = _a.status,
|
|
14266
14268
|
_b = _a.restartVideoOnSignaturePadCleared,
|
|
14267
14269
|
restartVideoOnSignaturePadCleared = _b === void 0 ? true : _b,
|
|
14268
|
-
|
|
14269
|
-
|
|
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
|
+
}
|
|
14270
14285
|
return /*#__PURE__*/React__default.createElement(VideoSignatureGuides, _assign({}, props, {
|
|
14271
14286
|
faceGuideStatus: status,
|
|
14272
|
-
|
|
14273
|
-
|
|
14274
|
-
return setTimeout(clearRecordedData, 100);
|
|
14275
|
-
} : undefined
|
|
14287
|
+
onClearSignaturePadClicked: onClear,
|
|
14288
|
+
requestedAction: status === 'success' ? 'CAPTURE_SIGNATURE' : 'VERIFY_LIVENESS'
|
|
14276
14289
|
}));
|
|
14277
14290
|
}
|
|
14278
14291
|
var VideoSignatureWizardWithProviders = function VideoSignatureWizardWithProviders(props) {
|
|
@@ -14655,12 +14668,8 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
14655
14668
|
stopSelfieGuidance = _16.stop,
|
|
14656
14669
|
onSelfiePredictionMade = _16.onPredictionMade,
|
|
14657
14670
|
selfieModelError = _16.error;
|
|
14658
|
-
var _17 = useVideoRecorder(
|
|
14671
|
+
var _17 = useVideoRecorder(mergeAVStreams),
|
|
14659
14672
|
isRecordingVideo = _17.isRecordingVideo,
|
|
14660
|
-
startRecordingVideo = _17.startRecordingVideo,
|
|
14661
|
-
startRecordingAudio = _17.startRecordingAudio,
|
|
14662
|
-
stopRecordingVideo = _17.stopRecordingVideo,
|
|
14663
|
-
stopRecordingAudio = _17.stopRecordingAudio,
|
|
14664
14673
|
videoRecordingUnintentionallyStopped = _17.videoRecordingUnintentionallyStopped,
|
|
14665
14674
|
audioRecordingUnintentionallyStopped = _17.audioRecordingUnintentionallyStopped,
|
|
14666
14675
|
videoUrl = _17.videoUrl,
|
|
@@ -14670,8 +14679,8 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
14670
14679
|
countdownRemaining = _18[0],
|
|
14671
14680
|
setCountdownRemaining = _18[1];
|
|
14672
14681
|
useEffect(function () {
|
|
14673
|
-
if (!isRecordingVideo && !videoUrl) {
|
|
14674
|
-
startRecordingVideo();
|
|
14682
|
+
if (camera && !isRecordingVideo && !videoUrl) {
|
|
14683
|
+
useVideoRecorderStore.getState().startRecordingVideo(camera, audioStream);
|
|
14675
14684
|
setVideoStartsAt(new Date());
|
|
14676
14685
|
}
|
|
14677
14686
|
// if the mergeAVStreams flag is present, the audio stream is on the video
|
|
@@ -14682,7 +14691,7 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
14682
14691
|
releaseCameraAccess();
|
|
14683
14692
|
onComplete === null || onComplete === void 0 ? void 0 : onComplete(videoUrl, audioUrl);
|
|
14684
14693
|
}
|
|
14685
|
-
}, [audioUrl, isRecordingVideo, mergeAVStreams, onComplete, readTextPrompt, releaseCameraAccess,
|
|
14694
|
+
}, [audioStream, audioUrl, camera, isRecordingVideo, mergeAVStreams, onComplete, readTextPrompt, releaseCameraAccess, videoUrl]);
|
|
14686
14695
|
useEffect(function () {
|
|
14687
14696
|
if (videoRecordingUnintentionallyStopped || audioRecordingUnintentionallyStopped || !!readTextPrompt && !microphoneReady) {
|
|
14688
14697
|
onRecordingFailed === null || onRecordingFailed === void 0 ? void 0 : onRecordingFailed();
|
|
@@ -14777,13 +14786,13 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
14777
14786
|
var _a;
|
|
14778
14787
|
if (translatedText) {
|
|
14779
14788
|
setRequestedAction('READ_TEXT');
|
|
14780
|
-
startRecordingAudio();
|
|
14789
|
+
useVideoRecorderStore.getState().startRecordingAudio(audioStream);
|
|
14781
14790
|
setIdCaptureVideoAudioStartsAt(new Date().getTime() - ((_a = videoStartsAt === null || videoStartsAt === void 0 ? void 0 : videoStartsAt.getTime()) !== null && _a !== void 0 ? _a : 0));
|
|
14782
14791
|
setExpectedAudioText(translatedText);
|
|
14783
14792
|
} else {
|
|
14784
|
-
stopRecordingVideo();
|
|
14793
|
+
useVideoRecorderStore.getState().stopRecordingVideo();
|
|
14785
14794
|
}
|
|
14786
|
-
}, [setExpectedAudioText, setIdCaptureVideoAudioStartsAt,
|
|
14795
|
+
}, [audioStream, setExpectedAudioText, setIdCaptureVideoAudioStartsAt, translatedText, videoStartsAt]);
|
|
14787
14796
|
var frameWidth = (_c = (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth) !== null && _c !== void 0 ? _c : 0;
|
|
14788
14797
|
var frameHeight = (_e = (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) !== null && _e !== void 0 ? _e : 0;
|
|
14789
14798
|
var faceBox = face === null || face === void 0 ? void 0 : face.box;
|
|
@@ -14853,9 +14862,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
14853
14862
|
};
|
|
14854
14863
|
}, [isFlipping]);
|
|
14855
14864
|
var stopRecording = useCallback(function () {
|
|
14856
|
-
stopRecordingVideo();
|
|
14857
|
-
stopRecordingAudio();
|
|
14858
|
-
}, [
|
|
14865
|
+
useVideoRecorderStore.getState().stopRecordingVideo();
|
|
14866
|
+
useVideoRecorderStore.getState().stopRecordingAudio();
|
|
14867
|
+
}, []);
|
|
14859
14868
|
var satisfied = !isFlipping && goodFramesThresholdMet && faceCentered && delaySatisfied;
|
|
14860
14869
|
useEffect(function () {
|
|
14861
14870
|
if (satisfied && !countdownStartedAt) {
|