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
|
@@ -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.
|
|
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$
|
|
1150
|
+
var initialState$7 = {
|
|
1151
1151
|
authUrl: exports.defaultAuthUrl,
|
|
1152
1152
|
sessionCheckState: 'READY'
|
|
1153
1153
|
};
|
|
1154
|
-
var AuthStateContext = /*#__PURE__*/React.createContext(initialState$
|
|
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$
|
|
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$
|
|
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$
|
|
13528
|
+
return _assign(_assign(_assign({}, initialState$6), config), {
|
|
13529
13529
|
reset: function reset() {
|
|
13530
|
-
return set(_assign(_assign({}, initialState$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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
|
|
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
|
-
|
|
23259
|
-
|
|
23260
|
-
|
|
23261
|
-
|
|
23262
|
-
|
|
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
|
-
|
|
23362
|
+
useVideoRecorderStore.setState({
|
|
23363
|
+
videoUrl: URL.createObjectURL(videoBlob),
|
|
23364
|
+
isRecordingVideo: false
|
|
23365
|
+
});
|
|
23294
23366
|
clearVideoChunks();
|
|
23295
|
-
setIsRecordingVideo(false);
|
|
23296
23367
|
setVideoRecorder(null);
|
|
23297
|
-
|
|
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
|
-
|
|
23305
|
-
|
|
23306
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
-
debug('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
|
|
23453
|
-
|
|
23454
|
-
|
|
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
|
-
|
|
23515
|
-
|
|
23516
|
-
|
|
23517
|
-
|
|
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,110 +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 () {
|
|
23489
|
+
log('VideoSignatureContext: onstop');
|
|
23530
23490
|
var blob = new Blob(signatureChunks, {
|
|
23531
23491
|
type: 'video/mp4'
|
|
23532
23492
|
});
|
|
23533
|
-
|
|
23534
|
-
|
|
23493
|
+
useVideoSignatureStore.setState({
|
|
23494
|
+
signatureVideoData: blob,
|
|
23495
|
+
signatureVideoUrl: URL.createObjectURL(blob)
|
|
23496
|
+
});
|
|
23535
23497
|
clearSignatureChunks();
|
|
23536
23498
|
setSignatureRecorder(null);
|
|
23537
|
-
onRecordingStopped.current();
|
|
23538
23499
|
};
|
|
23539
|
-
|
|
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
|
|
23540
23530
|
});
|
|
23541
|
-
}, [
|
|
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])
|
|
23542
23557
|
var animationFrame = React.useRef(0);
|
|
23543
23558
|
React.useEffect(function () {
|
|
23544
|
-
if (!
|
|
23559
|
+
if (!videoRef.current || !outputCanvas.current || !camera || !isRecording || !isRecordingVideo) return;
|
|
23545
23560
|
var ctx = outputCanvas.current.getContext('2d');
|
|
23546
23561
|
if (!ctx) return;
|
|
23562
|
+
var signaturePad = useVideoSignatureStore.getState().signaturePad;
|
|
23547
23563
|
animationFrame.current = requestAnimationFrame(function runFrame() {
|
|
23548
|
-
|
|
23549
|
-
|
|
23550
|
-
return
|
|
23551
|
-
|
|
23552
|
-
|
|
23553
|
-
|
|
23554
|
-
|
|
23555
|
-
|
|
23556
|
-
|
|
23557
|
-
|
|
23558
|
-
|
|
23559
|
-
|
|
23560
|
-
|
|
23561
|
-
|
|
23562
|
-
|
|
23563
|
-
|
|
23564
|
-
|
|
23565
|
-
|
|
23566
|
-
animationFrame.current = requestAnimationFrame(runFrame);
|
|
23567
|
-
return [2 /*return*/];
|
|
23568
|
-
});
|
|
23569
|
-
});
|
|
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);
|
|
23570
23582
|
});
|
|
23571
23583
|
return function () {
|
|
23572
|
-
cancelAnimationFrame(animationFrame.current);
|
|
23584
|
+
return cancelAnimationFrame(animationFrame.current);
|
|
23573
23585
|
};
|
|
23574
23586
|
}, [camera, isRecording, isRecordingVideo, videoRef]);
|
|
23575
|
-
|
|
23576
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
23577
|
-
var signatureData, imageUrl;
|
|
23578
|
-
var _a;
|
|
23579
|
-
return __generator(this, function (_b) {
|
|
23580
|
-
switch (_b.label) {
|
|
23581
|
-
case 0:
|
|
23582
|
-
debug('VideoSignatureContext: onAcceptClicked');
|
|
23583
|
-
if (!signaturePad.current) return [2 /*return*/];
|
|
23584
|
-
debug('VideoSignatureContext: building signature data...');
|
|
23585
|
-
signatureData = buildSignatureData(signaturePad.current);
|
|
23586
|
-
debug('VideoSignatureContext: exporting signature image...');
|
|
23587
|
-
return [4 /*yield*/, exportSignatureImage(signaturePad.current)];
|
|
23588
|
-
case 1:
|
|
23589
|
-
imageUrl = _b.sent();
|
|
23590
|
-
if (imageUrl) signatureData.fileContent = dataUrlToBase64Sync(imageUrl);
|
|
23591
|
-
debug('VideoSignatureContext: setting signature data url...');
|
|
23592
|
-
setSignatureDataUrl(imageUrl);
|
|
23593
|
-
setSignatureData(signatureData);
|
|
23594
|
-
debug('VideoSignatureContext: stopping recording...');
|
|
23595
|
-
stopRecordingVideo();
|
|
23596
|
-
stopRecordingAudio();
|
|
23597
|
-
debug('VideoSignatureContext: stopping signature recorder...');
|
|
23598
|
-
(_a = getSignatureRecorder()) === null || _a === void 0 ? void 0 : _a.stop();
|
|
23599
|
-
return [2 /*return*/];
|
|
23600
|
-
}
|
|
23601
|
-
});
|
|
23602
|
-
});
|
|
23603
|
-
}, [stopRecordingAudio, stopRecordingVideo]);
|
|
23604
|
-
var value = React.useMemo(function () {
|
|
23605
|
-
return {
|
|
23606
|
-
isRecording: isRecording,
|
|
23607
|
-
startRecording: startRecording,
|
|
23608
|
-
stopRecording: stopRecording,
|
|
23609
|
-
clearRecordedData: clearRecordedData,
|
|
23610
|
-
signaturePad: signaturePad,
|
|
23611
|
-
signatureData: signatureData,
|
|
23612
|
-
signatureDataUrl: signatureDataUrl,
|
|
23613
|
-
signatureVideoData: signatureVideoData,
|
|
23614
|
-
signatureVideoUrl: signatureVideoUrl,
|
|
23615
|
-
onAcceptClicked: onAcceptClicked
|
|
23616
|
-
};
|
|
23617
|
-
}, [clearRecordedData, isRecording, onAcceptClicked, signatureData, signatureDataUrl, signatureVideoData, signatureVideoUrl, startRecording, stopRecording]);
|
|
23618
|
-
return /*#__PURE__*/React.createElement(VideoSignatureContext.Provider, {
|
|
23619
|
-
value: value
|
|
23620
|
-
}, children, /*#__PURE__*/React.createElement(InvisibleCanvas, {
|
|
23587
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children, /*#__PURE__*/React.createElement(InvisibleCanvas, {
|
|
23621
23588
|
ref: outputCanvas,
|
|
23622
23589
|
width: (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth,
|
|
23623
23590
|
height: (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.videoHeight
|
|
23624
23591
|
}));
|
|
23625
23592
|
}
|
|
23626
|
-
function useVideoSignatureContext() {
|
|
23627
|
-
var ctx = React.useContext(VideoSignatureContext);
|
|
23628
|
-
if (!ctx) throw new Error('useVideoSignatureContext cannot be used without ContextProvider');
|
|
23629
|
-
return ctx;
|
|
23630
|
-
}
|
|
23631
23593
|
|
|
23632
23594
|
function VideoSignatureGuides(_a) {
|
|
23595
|
+
var _this = this;
|
|
23633
23596
|
var _b = _a.requestedAction,
|
|
23634
23597
|
requestedAction = _b === void 0 ? 'VERIFY_LIVENESS' : _b,
|
|
23635
23598
|
_c = _a.faceGuideStatus,
|
|
@@ -23649,15 +23612,18 @@
|
|
|
23649
23612
|
ref = _h.ref,
|
|
23650
23613
|
width = _h.width,
|
|
23651
23614
|
height = _h.height;
|
|
23652
|
-
var
|
|
23653
|
-
|
|
23654
|
-
|
|
23655
|
-
|
|
23656
|
-
|
|
23657
|
-
|
|
23658
|
-
|
|
23659
|
-
|
|
23660
|
-
|
|
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
|
+
}, []);
|
|
23661
23627
|
var verbiage = useTranslations(rawVerbiage, {
|
|
23662
23628
|
signaturePadEmptyText: '',
|
|
23663
23629
|
headTrackingUnsatisfiedText: '',
|
|
@@ -23674,13 +23640,41 @@
|
|
|
23674
23640
|
var isSigning = requestedAction === 'CAPTURE_SIGNATURE';
|
|
23675
23641
|
var canClear = isSigning && !signaturePadEmpty;
|
|
23676
23642
|
var canSubmit = isSigning && signatureValid && headTrackingSatisfied;
|
|
23677
|
-
var
|
|
23678
|
-
emptyContentDismissed =
|
|
23679
|
-
setEmptyContentDismissed =
|
|
23643
|
+
var _l = React.useState(false),
|
|
23644
|
+
emptyContentDismissed = _l[0],
|
|
23645
|
+
setEmptyContentDismissed = _l[1];
|
|
23680
23646
|
var displayEmptyState = requestedAction === 'CAPTURE_SIGNATURE' && signaturePadEmpty && !emptyContentDismissed;
|
|
23681
23647
|
React.useEffect(function () {
|
|
23682
23648
|
if (signaturePadEmpty) setEmptyContentDismissed(false);
|
|
23683
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
|
+
}, []);
|
|
23684
23678
|
return /*#__PURE__*/React.createElement(Container$3, {
|
|
23685
23679
|
className: classNames.container
|
|
23686
23680
|
}, /*#__PURE__*/React.createElement(Inner$1, {
|
|
@@ -23783,40 +23777,45 @@
|
|
|
23783
23777
|
minSignaturePadPoints = _c === void 0 ? DEFAULT_MIN_SIGNATURE_PAD_POINTS : _c,
|
|
23784
23778
|
_d = _a.headTrackingBoundaryPercentage,
|
|
23785
23779
|
headTrackingBoundaryPercentage = _d === void 0 ? DEFAULT_HEAD_TRACKING_BOUNDARY_PERCENTAGE : _d,
|
|
23786
|
-
_e = _a.
|
|
23787
|
-
|
|
23788
|
-
_f = _a.
|
|
23789
|
-
|
|
23790
|
-
_g = _a.
|
|
23791
|
-
|
|
23792
|
-
_h = _a.
|
|
23793
|
-
|
|
23794
|
-
|
|
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) {
|
|
23795
23791
|
return {
|
|
23796
23792
|
camera: state.camera,
|
|
23793
|
+
audioStream: state.audioStream,
|
|
23797
23794
|
videoWidth: state.videoWidth,
|
|
23798
23795
|
videoHeight: state.videoHeight
|
|
23799
23796
|
};
|
|
23800
23797
|
})),
|
|
23801
|
-
camera =
|
|
23802
|
-
|
|
23803
|
-
|
|
23804
|
-
|
|
23805
|
-
|
|
23806
|
-
|
|
23807
|
-
|
|
23808
|
-
|
|
23809
|
-
|
|
23810
|
-
|
|
23811
|
-
|
|
23812
|
-
|
|
23813
|
-
|
|
23814
|
-
|
|
23815
|
-
|
|
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;
|
|
23816
23814
|
React.useEffect(function () {
|
|
23817
|
-
|
|
23815
|
+
if (!camera) return;
|
|
23816
|
+
startRecording(camera, audioStream, captureAudio);
|
|
23818
23817
|
return stopRecording;
|
|
23819
|
-
}, [startRecording, stopRecording]);
|
|
23818
|
+
}, [audioStream, camera, captureAudio, startRecording, stopRecording]);
|
|
23820
23819
|
React.useEffect(function () {
|
|
23821
23820
|
setTimeout(startHeadTracking, 1);
|
|
23822
23821
|
return stopHeadTracking;
|
|
@@ -23831,15 +23830,15 @@
|
|
|
23831
23830
|
onVideoCaptured === null || onVideoCaptured === void 0 ? void 0 : onVideoCaptured(signatureVideoData, signatureData, signatureDataUrl);
|
|
23832
23831
|
}
|
|
23833
23832
|
}, [onVideoCaptured, signatureData, signatureDataUrl, signatureVideoData]);
|
|
23834
|
-
var
|
|
23835
|
-
headTrackingSatisfied =
|
|
23836
|
-
setHeadTrackingSatisfied =
|
|
23837
|
-
var
|
|
23838
|
-
lastFace =
|
|
23839
|
-
setLastFace =
|
|
23840
|
-
var
|
|
23841
|
-
numFramesWithoutFaces =
|
|
23842
|
-
setNumFramesWithoutFaces =
|
|
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];
|
|
23843
23842
|
onPredictionMade(f(React.useCallback(function (_a) {
|
|
23844
23843
|
var face = _a.face;
|
|
23845
23844
|
if (!camera) return;
|
|
@@ -23850,12 +23849,12 @@
|
|
|
23850
23849
|
return n + 1;
|
|
23851
23850
|
});
|
|
23852
23851
|
}, [camera, headTrackingBoundaryPercentage, videoHeight, videoWidth]), 16));
|
|
23853
|
-
var
|
|
23854
|
-
ref =
|
|
23855
|
-
|
|
23856
|
-
width =
|
|
23857
|
-
|
|
23858
|
-
height =
|
|
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;
|
|
23859
23858
|
var debugScalingDetails = useDebugScalingDetails({
|
|
23860
23859
|
enabled: debugMode,
|
|
23861
23860
|
pageWidth: width,
|
|
@@ -24072,6 +24071,7 @@
|
|
|
24072
24071
|
return n + 1;
|
|
24073
24072
|
});
|
|
24074
24073
|
setCaptureState('CHECKING_LIVENESS');
|
|
24074
|
+
useVideoSignatureStore.getState().clearRecordedData();
|
|
24075
24075
|
}, [onRetryClicked]);
|
|
24076
24076
|
var onExitSignatureCapture = React.useCallback(function () {
|
|
24077
24077
|
setAttempt(function (n) {
|
|
@@ -24093,9 +24093,10 @@
|
|
|
24093
24093
|
return /*#__PURE__*/React.createElement(VideoSignatureWizardGuides, _assign({}, props, {
|
|
24094
24094
|
classNames: classNames === null || classNames === void 0 ? void 0 : classNames.guides,
|
|
24095
24095
|
verbiage: verbiage === null || verbiage === void 0 ? void 0 : verbiage.guides,
|
|
24096
|
-
restartVideoOnSignaturePadCleared: restartVideoOnSignaturePadCleared
|
|
24096
|
+
restartVideoOnSignaturePadCleared: restartVideoOnSignaturePadCleared,
|
|
24097
|
+
captureAudio: captureAudio
|
|
24097
24098
|
}));
|
|
24098
|
-
}, [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]);
|
|
24099
24100
|
var onExitAfterFailureProp = faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.onExitAfterFailure;
|
|
24100
24101
|
var onExitAfterFailure = React.useCallback(function (resp, req) {
|
|
24101
24102
|
onExitAfterFailureProp === null || onExitAfterFailureProp === void 0 ? void 0 : onExitAfterFailureProp(resp, req);
|
|
@@ -24147,6 +24148,7 @@
|
|
|
24147
24148
|
headTrackingBoundaryPercentage: headTrackingBoundaryPercentage,
|
|
24148
24149
|
restartVideoOnSignaturePadCleared: restartVideoOnSignaturePadCleared,
|
|
24149
24150
|
guidesComponent: guidesComponent,
|
|
24151
|
+
captureAudio: captureAudio,
|
|
24150
24152
|
classNames: classNames,
|
|
24151
24153
|
colors: colors,
|
|
24152
24154
|
verbiage: verbiage,
|
|
@@ -24171,14 +24173,25 @@
|
|
|
24171
24173
|
var status = _a.status,
|
|
24172
24174
|
_b = _a.restartVideoOnSignaturePadCleared,
|
|
24173
24175
|
restartVideoOnSignaturePadCleared = _b === void 0 ? true : _b,
|
|
24174
|
-
|
|
24175
|
-
|
|
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
|
+
}
|
|
24176
24191
|
return /*#__PURE__*/React.createElement(VideoSignatureGuides, _assign({}, props, {
|
|
24177
24192
|
faceGuideStatus: status,
|
|
24178
|
-
|
|
24179
|
-
|
|
24180
|
-
return setTimeout(clearRecordedData, 100);
|
|
24181
|
-
} : undefined
|
|
24193
|
+
onClearSignaturePadClicked: onClear,
|
|
24194
|
+
requestedAction: status === 'success' ? 'CAPTURE_SIGNATURE' : 'VERIFY_LIVENESS'
|
|
24182
24195
|
}));
|
|
24183
24196
|
}
|
|
24184
24197
|
var VideoSignatureWizardWithProviders = function VideoSignatureWizardWithProviders(props) {
|
|
@@ -24561,12 +24574,8 @@
|
|
|
24561
24574
|
stopSelfieGuidance = _16.stop,
|
|
24562
24575
|
onSelfiePredictionMade = _16.onPredictionMade,
|
|
24563
24576
|
selfieModelError = _16.error;
|
|
24564
|
-
var _17 = useVideoRecorder(
|
|
24577
|
+
var _17 = useVideoRecorder(mergeAVStreams),
|
|
24565
24578
|
isRecordingVideo = _17.isRecordingVideo,
|
|
24566
|
-
startRecordingVideo = _17.startRecordingVideo,
|
|
24567
|
-
startRecordingAudio = _17.startRecordingAudio,
|
|
24568
|
-
stopRecordingVideo = _17.stopRecordingVideo,
|
|
24569
|
-
stopRecordingAudio = _17.stopRecordingAudio,
|
|
24570
24579
|
videoRecordingUnintentionallyStopped = _17.videoRecordingUnintentionallyStopped,
|
|
24571
24580
|
audioRecordingUnintentionallyStopped = _17.audioRecordingUnintentionallyStopped,
|
|
24572
24581
|
videoUrl = _17.videoUrl,
|
|
@@ -24576,8 +24585,8 @@
|
|
|
24576
24585
|
countdownRemaining = _18[0],
|
|
24577
24586
|
setCountdownRemaining = _18[1];
|
|
24578
24587
|
React.useEffect(function () {
|
|
24579
|
-
if (!isRecordingVideo && !videoUrl) {
|
|
24580
|
-
startRecordingVideo();
|
|
24588
|
+
if (camera && !isRecordingVideo && !videoUrl) {
|
|
24589
|
+
useVideoRecorderStore.getState().startRecordingVideo(camera, audioStream);
|
|
24581
24590
|
setVideoStartsAt(new Date());
|
|
24582
24591
|
}
|
|
24583
24592
|
// if the mergeAVStreams flag is present, the audio stream is on the video
|
|
@@ -24588,7 +24597,7 @@
|
|
|
24588
24597
|
releaseCameraAccess();
|
|
24589
24598
|
onComplete === null || onComplete === void 0 ? void 0 : onComplete(videoUrl, audioUrl);
|
|
24590
24599
|
}
|
|
24591
|
-
}, [audioUrl, isRecordingVideo, mergeAVStreams, onComplete, readTextPrompt, releaseCameraAccess,
|
|
24600
|
+
}, [audioStream, audioUrl, camera, isRecordingVideo, mergeAVStreams, onComplete, readTextPrompt, releaseCameraAccess, videoUrl]);
|
|
24592
24601
|
React.useEffect(function () {
|
|
24593
24602
|
if (videoRecordingUnintentionallyStopped || audioRecordingUnintentionallyStopped || !!readTextPrompt && !microphoneReady) {
|
|
24594
24603
|
onRecordingFailed === null || onRecordingFailed === void 0 ? void 0 : onRecordingFailed();
|
|
@@ -24683,13 +24692,13 @@
|
|
|
24683
24692
|
var _a;
|
|
24684
24693
|
if (translatedText) {
|
|
24685
24694
|
setRequestedAction('READ_TEXT');
|
|
24686
|
-
startRecordingAudio();
|
|
24695
|
+
useVideoRecorderStore.getState().startRecordingAudio(audioStream);
|
|
24687
24696
|
setIdCaptureVideoAudioStartsAt(new Date().getTime() - ((_a = videoStartsAt === null || videoStartsAt === void 0 ? void 0 : videoStartsAt.getTime()) !== null && _a !== void 0 ? _a : 0));
|
|
24688
24697
|
setExpectedAudioText(translatedText);
|
|
24689
24698
|
} else {
|
|
24690
|
-
stopRecordingVideo();
|
|
24699
|
+
useVideoRecorderStore.getState().stopRecordingVideo();
|
|
24691
24700
|
}
|
|
24692
|
-
}, [setExpectedAudioText, setIdCaptureVideoAudioStartsAt,
|
|
24701
|
+
}, [audioStream, setExpectedAudioText, setIdCaptureVideoAudioStartsAt, translatedText, videoStartsAt]);
|
|
24693
24702
|
var frameWidth = (_c = (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth) !== null && _c !== void 0 ? _c : 0;
|
|
24694
24703
|
var frameHeight = (_e = (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) !== null && _e !== void 0 ? _e : 0;
|
|
24695
24704
|
var faceBox = face === null || face === void 0 ? void 0 : face.box;
|
|
@@ -24759,9 +24768,9 @@
|
|
|
24759
24768
|
};
|
|
24760
24769
|
}, [isFlipping]);
|
|
24761
24770
|
var stopRecording = React.useCallback(function () {
|
|
24762
|
-
stopRecordingVideo();
|
|
24763
|
-
stopRecordingAudio();
|
|
24764
|
-
}, [
|
|
24771
|
+
useVideoRecorderStore.getState().stopRecordingVideo();
|
|
24772
|
+
useVideoRecorderStore.getState().stopRecordingAudio();
|
|
24773
|
+
}, []);
|
|
24765
24774
|
var satisfied = !isFlipping && goodFramesThresholdMet && faceCentered && delaySatisfied;
|
|
24766
24775
|
React.useEffect(function () {
|
|
24767
24776
|
if (satisfied && !countdownStartedAt) {
|