idmission-web-sdk 2.1.6 → 2.1.8
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/README.md +648 -655
- package/README.mdx +1012 -0
- package/dist/components/video_id/IdVideoCapture.d.ts +3 -1
- package/dist/lib/utils/cropping.d.ts +1 -1
- package/dist/sdk2.cjs.development.js +131 -128
- 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 +132 -129
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +133 -130
- 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 +2 -1
package/dist/sdk2.esm.js
CHANGED
|
@@ -8,13 +8,13 @@ import { useTranslation, initReactI18next } from 'react-i18next';
|
|
|
8
8
|
import { Upload } from 'tus-js-client';
|
|
9
9
|
import useResizeObserver from 'use-resize-observer';
|
|
10
10
|
import { ImageSegmenter, FilesetResolver, ImageClassifier, FaceDetector, ObjectDetector } from '@mediapipe/tasks-vision';
|
|
11
|
-
import { useDebouncedCallback } from 'use-debounce';
|
|
11
|
+
import { useDebouncedCallback, useThrottledCallback } from 'use-debounce';
|
|
12
12
|
import { createPortal } from 'react-dom';
|
|
13
13
|
import LanguageDetector from 'i18next-browser-languagedetector';
|
|
14
14
|
import i18n from 'i18next';
|
|
15
15
|
import SignatureCanvas from 'react-signature-canvas';
|
|
16
16
|
|
|
17
|
-
var webSdkVersion = '2.1.
|
|
17
|
+
var webSdkVersion = '2.1.8';
|
|
18
18
|
|
|
19
19
|
function getPlatform() {
|
|
20
20
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -2243,39 +2243,15 @@ function preloadVisionRuntime() {
|
|
|
2243
2243
|
});
|
|
2244
2244
|
}
|
|
2245
2245
|
|
|
2246
|
-
function
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
function isMobile(nav) {
|
|
2250
|
-
if (nav || _isNavigatorDefined()) {
|
|
2251
|
-
if (!nav) {
|
|
2252
|
-
nav = navigator;
|
|
2253
|
-
}
|
|
2254
|
-
if (nav.product === 'ReactNative') {
|
|
2255
|
-
return true;
|
|
2256
|
-
}
|
|
2257
|
-
var a = nav.userAgent || nav.vendor || (
|
|
2258
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2259
|
-
// @ts-ignore
|
|
2260
|
-
typeof window !== 'undefined' ? window.opera : '');
|
|
2261
|
-
if (!a) {
|
|
2262
|
-
var navAny = nav;
|
|
2263
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2264
|
-
// @ts-ignore
|
|
2265
|
-
return navAny.userAgentData && navAny.userAgentData.mobile;
|
|
2266
|
-
}
|
|
2267
|
-
return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) ||
|
|
2268
|
-
// tslint:disable-next-line:max-line-length
|
|
2269
|
-
/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4));
|
|
2246
|
+
function cropToShoulders(rawCanvas, cropCanvas, resizeCanvas, frame, face, quality, maxHeight) {
|
|
2247
|
+
if (quality === void 0) {
|
|
2248
|
+
quality = 0.92;
|
|
2270
2249
|
}
|
|
2271
|
-
return
|
|
2272
|
-
}
|
|
2273
|
-
|
|
2274
|
-
function cropToShoulders(rawCanvas, cropCanvas, frame, face) {
|
|
2275
|
-
if (!rawCanvas || !cropCanvas) return '';
|
|
2250
|
+
if (!rawCanvas || !cropCanvas || !resizeCanvas) return '';
|
|
2276
2251
|
var rawCtx = rawCanvas.getContext('2d');
|
|
2277
2252
|
var cropCtx = cropCanvas.getContext('2d');
|
|
2278
|
-
|
|
2253
|
+
var resizeCtx = resizeCanvas.getContext('2d');
|
|
2254
|
+
if (!rawCtx || !cropCtx || !resizeCtx) throw new Error('could not get 2d context');
|
|
2279
2255
|
rawCanvas.width = frame.width;
|
|
2280
2256
|
rawCanvas.height = frame.height;
|
|
2281
2257
|
rawCtx.putImageData(frame, 0, 0);
|
|
@@ -2285,7 +2261,7 @@ function cropToShoulders(rawCanvas, cropCanvas, frame, face) {
|
|
|
2285
2261
|
var frameHeight = frame.height;
|
|
2286
2262
|
var xPadding = frameHeight * 0.6 - width;
|
|
2287
2263
|
var xPos = Math.max(0, xMin - xPadding / 2);
|
|
2288
|
-
if (
|
|
2264
|
+
if (frame.height > frame.width) {
|
|
2289
2265
|
cropCanvas.width = frame.width;
|
|
2290
2266
|
cropCanvas.height = frame.height;
|
|
2291
2267
|
cropCtx.drawImage(rawCanvas, 0, 0, cropCanvas.width, cropCanvas.height);
|
|
@@ -2294,9 +2270,14 @@ function cropToShoulders(rawCanvas, cropCanvas, frame, face) {
|
|
|
2294
2270
|
cropCanvas.height = frame.height;
|
|
2295
2271
|
cropCtx.drawImage(rawCanvas, xPos, 0, cropCanvas.width, cropCanvas.height, 0, 0, cropCanvas.width, cropCanvas.height);
|
|
2296
2272
|
}
|
|
2297
|
-
|
|
2273
|
+
resizeCanvas.height = maxHeight !== null && maxHeight !== void 0 ? maxHeight : cropCanvas.height;
|
|
2274
|
+
resizeCanvas.width = cropCanvas.width * (resizeCanvas.height / cropCanvas.height);
|
|
2275
|
+
resizeCtx === null || resizeCtx === void 0 ? void 0 : resizeCtx.drawImage(cropCanvas, 0, 0, resizeCanvas.width, resizeCanvas.height);
|
|
2276
|
+
var dataURL = resizeCanvas.toDataURL('image/jpeg', quality);
|
|
2277
|
+
log('cropToShoulders size', new TextEncoder().encode(dataURL).length);
|
|
2298
2278
|
clearCanvas(rawCanvas);
|
|
2299
2279
|
clearCanvas(cropCanvas);
|
|
2280
|
+
clearCanvas(resizeCanvas);
|
|
2300
2281
|
return dataURL;
|
|
2301
2282
|
}
|
|
2302
2283
|
function cropToDetectedObjectBox(frame, box, canvas) {
|
|
@@ -2458,11 +2439,11 @@ function waitForVideoReady(videoRef, checkEveryMs) {
|
|
|
2458
2439
|
checkEveryMs = 100;
|
|
2459
2440
|
}
|
|
2460
2441
|
return new Promise(function (resolve) {
|
|
2461
|
-
var _a;
|
|
2462
|
-
if (((_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.readyState)
|
|
2442
|
+
var _a, _b;
|
|
2443
|
+
if (((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.readyState) !== null && _b !== void 0 ? _b : 0) >= 2) return resolve();
|
|
2463
2444
|
var interval = setInterval(function () {
|
|
2464
|
-
var _a;
|
|
2465
|
-
if (((_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.readyState)
|
|
2445
|
+
var _a, _b;
|
|
2446
|
+
if (((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.readyState) !== null && _b !== void 0 ? _b : 0) >= 2) {
|
|
2466
2447
|
clearInterval(interval);
|
|
2467
2448
|
resolve();
|
|
2468
2449
|
}
|
|
@@ -3629,6 +3610,34 @@ function FocusModelProvider(_a) {
|
|
|
3629
3610
|
}), children);
|
|
3630
3611
|
}
|
|
3631
3612
|
|
|
3613
|
+
function _isNavigatorDefined() {
|
|
3614
|
+
return typeof navigator !== 'undefined' && navigator != null;
|
|
3615
|
+
}
|
|
3616
|
+
function isMobile(nav) {
|
|
3617
|
+
if (nav || _isNavigatorDefined()) {
|
|
3618
|
+
if (!nav) {
|
|
3619
|
+
nav = navigator;
|
|
3620
|
+
}
|
|
3621
|
+
if (nav.product === 'ReactNative') {
|
|
3622
|
+
return true;
|
|
3623
|
+
}
|
|
3624
|
+
var a = nav.userAgent || nav.vendor || (
|
|
3625
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3626
|
+
// @ts-ignore
|
|
3627
|
+
typeof window !== 'undefined' ? window.opera : '');
|
|
3628
|
+
if (!a) {
|
|
3629
|
+
var navAny = nav;
|
|
3630
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3631
|
+
// @ts-ignore
|
|
3632
|
+
return navAny.userAgentData && navAny.userAgentData.mobile;
|
|
3633
|
+
}
|
|
3634
|
+
return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) ||
|
|
3635
|
+
// tslint:disable-next-line:max-line-length
|
|
3636
|
+
/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4));
|
|
3637
|
+
}
|
|
3638
|
+
return false;
|
|
3639
|
+
}
|
|
3640
|
+
|
|
3632
3641
|
var onMobile = isMobile();
|
|
3633
3642
|
var defaultIdCaptureThresholds = {
|
|
3634
3643
|
detection: defaultDocumentDetectionThresholds,
|
|
@@ -7280,6 +7289,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
7280
7289
|
dispatch = _8[1];
|
|
7281
7290
|
var _9 = useContext(CameraStateContext),
|
|
7282
7291
|
cameraAccessDenied = _9.cameraAccessDenied,
|
|
7292
|
+
requestCameraAccess = _9.requestCameraAccess,
|
|
7283
7293
|
releaseCameraAccess = _9.releaseCameraAccess;
|
|
7284
7294
|
var _10 = useState(false),
|
|
7285
7295
|
overlayDismissed = _10[0],
|
|
@@ -7390,6 +7400,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
7390
7400
|
attempt = _13[0],
|
|
7391
7401
|
setAttempt = _13[1];
|
|
7392
7402
|
var onExit = useCallback(function () {
|
|
7403
|
+
releaseCameraAccess();
|
|
7393
7404
|
setOverlayDismissed(false);
|
|
7394
7405
|
setAttempt(function (n) {
|
|
7395
7406
|
return n + 1;
|
|
@@ -7398,7 +7409,8 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
7398
7409
|
type: 'resetWizard'
|
|
7399
7410
|
});
|
|
7400
7411
|
onExitCapture === null || onExitCapture === void 0 ? void 0 : onExitCapture();
|
|
7401
|
-
|
|
7412
|
+
requestCameraAccess();
|
|
7413
|
+
}, [dispatch, onExitCapture, releaseCameraAccess]);
|
|
7402
7414
|
useEffect(function () {
|
|
7403
7415
|
if (submissionStatus !== SubmissionStatus.READY) {
|
|
7404
7416
|
releaseCameraAccessOnExit && releaseCameraAccess();
|
|
@@ -7905,9 +7917,6 @@ var templateObject_1$j, templateObject_2$d, templateObject_3$c, templateObject_4
|
|
|
7905
7917
|
var initialState$3 = {
|
|
7906
7918
|
videoWidth: 0,
|
|
7907
7919
|
videoHeight: 0,
|
|
7908
|
-
capturing: false,
|
|
7909
|
-
captured: false,
|
|
7910
|
-
captureFailed: false,
|
|
7911
7920
|
frame: null,
|
|
7912
7921
|
faces: [],
|
|
7913
7922
|
faceNotCentered: false,
|
|
@@ -7915,36 +7924,12 @@ var initialState$3 = {
|
|
|
7915
7924
|
faceTooClose: false,
|
|
7916
7925
|
faceTooFar: false,
|
|
7917
7926
|
faceReady: false,
|
|
7918
|
-
faceReadyAt: null
|
|
7919
|
-
goodFramesCount: 0,
|
|
7920
|
-
goodFramesThreshold: 1,
|
|
7921
|
-
goodFramesThresholdMet: false
|
|
7927
|
+
faceReadyAt: null
|
|
7922
7928
|
};
|
|
7923
7929
|
var reducer$3 = function reducer(state, action) {
|
|
7924
7930
|
switch (action.type) {
|
|
7925
7931
|
case 'configure':
|
|
7926
|
-
return __assign(__assign({}, state),
|
|
7927
|
-
videoWidth: action.payload.videoWidth,
|
|
7928
|
-
videoHeight: action.payload.videoHeight
|
|
7929
|
-
});
|
|
7930
|
-
case 'capturing':
|
|
7931
|
-
return __assign(__assign({}, state), {
|
|
7932
|
-
capturing: true,
|
|
7933
|
-
captured: false,
|
|
7934
|
-
captureFailed: false
|
|
7935
|
-
});
|
|
7936
|
-
case 'captured':
|
|
7937
|
-
return __assign(__assign({}, state), {
|
|
7938
|
-
capturing: false,
|
|
7939
|
-
captured: true,
|
|
7940
|
-
captureFailed: false
|
|
7941
|
-
});
|
|
7942
|
-
case 'captureFailed':
|
|
7943
|
-
return __assign(__assign({}, state), {
|
|
7944
|
-
capturing: false,
|
|
7945
|
-
captured: false,
|
|
7946
|
-
captureFailed: true
|
|
7947
|
-
});
|
|
7932
|
+
return __assign(__assign({}, state), action.payload);
|
|
7948
7933
|
case 'facesDetected':
|
|
7949
7934
|
{
|
|
7950
7935
|
var faces = action.payload.faces;
|
|
@@ -7953,8 +7938,7 @@ var reducer$3 = function reducer(state, action) {
|
|
|
7953
7938
|
faceLookingAway = false,
|
|
7954
7939
|
faceTooClose = false,
|
|
7955
7940
|
faceTooFar = false,
|
|
7956
|
-
faceReadyAt = state.faceReadyAt
|
|
7957
|
-
goodFramesCount = state.goodFramesCount;
|
|
7941
|
+
faceReadyAt = state.faceReadyAt;
|
|
7958
7942
|
if (face) {
|
|
7959
7943
|
// calculate centroids
|
|
7960
7944
|
var vCX = state.videoWidth / 2;
|
|
@@ -7980,7 +7964,6 @@ var reducer$3 = function reducer(state, action) {
|
|
|
7980
7964
|
var faceReady = !faceNotCentered && !faceLookingAway && !faceTooClose && !faceTooFar;
|
|
7981
7965
|
if (!faceReady) {
|
|
7982
7966
|
faceReadyAt = null;
|
|
7983
|
-
goodFramesCount = 0;
|
|
7984
7967
|
} else if (!state.faceReady) {
|
|
7985
7968
|
faceReadyAt = new Date();
|
|
7986
7969
|
}
|
|
@@ -7991,8 +7974,7 @@ var reducer$3 = function reducer(state, action) {
|
|
|
7991
7974
|
faceTooClose: faceTooClose,
|
|
7992
7975
|
faceTooFar: faceTooFar,
|
|
7993
7976
|
faceReady: faceReady,
|
|
7994
|
-
faceReadyAt: faceReadyAt
|
|
7995
|
-
goodFramesCount: goodFramesCount
|
|
7977
|
+
faceReadyAt: faceReadyAt
|
|
7996
7978
|
});
|
|
7997
7979
|
}
|
|
7998
7980
|
}
|
|
@@ -8044,16 +8026,14 @@ var SelfieCapture = function SelfieCapture(_a) {
|
|
|
8044
8026
|
});
|
|
8045
8027
|
}
|
|
8046
8028
|
}, [cameraReady, videoRef]);
|
|
8047
|
-
|
|
8048
|
-
|
|
8049
|
-
|
|
8050
|
-
|
|
8051
|
-
|
|
8052
|
-
|
|
8053
|
-
}
|
|
8054
|
-
});
|
|
8029
|
+
onPredictionMade(useThrottledCallback(function (prediction) {
|
|
8030
|
+
dispatch({
|
|
8031
|
+
type: 'facesDetected',
|
|
8032
|
+
payload: {
|
|
8033
|
+
faces: prediction
|
|
8034
|
+
}
|
|
8055
8035
|
});
|
|
8056
|
-
},
|
|
8036
|
+
}, 16));
|
|
8057
8037
|
var _p = useState(false),
|
|
8058
8038
|
captureReady = _p[0],
|
|
8059
8039
|
setCaptureReady = _p[1];
|
|
@@ -8072,22 +8052,14 @@ var SelfieCapture = function SelfieCapture(_a) {
|
|
|
8072
8052
|
};
|
|
8073
8053
|
}, [onGuidanceNotSatisfied, onGuidanceSatisfied, state.faceReady]);
|
|
8074
8054
|
useEffect(function () {
|
|
8075
|
-
(
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
|
|
8082
|
-
|
|
8083
|
-
imageData = ctx.getImageData(0, 0, videoRef.current.videoWidth, videoRef.current.videoHeight);
|
|
8084
|
-
onSelfieCaptured === null || onSelfieCaptured === void 0 ? void 0 : onSelfieCaptured(imageData, state.faces[0]);
|
|
8085
|
-
clearCanvas(lastPredictionCanvas.current);
|
|
8086
|
-
}
|
|
8087
|
-
return [2 /*return*/];
|
|
8088
|
-
});
|
|
8089
|
-
});
|
|
8090
|
-
})();
|
|
8055
|
+
if (captureReady && videoRef.current && lastPredictionCanvas.current && state.faces.length > 0) {
|
|
8056
|
+
drawToCanvas(lastPredictionCanvas.current, videoRef.current);
|
|
8057
|
+
var ctx = lastPredictionCanvas.current.getContext('2d');
|
|
8058
|
+
if (!ctx) return;
|
|
8059
|
+
var imageData = ctx.getImageData(0, 0, videoRef.current.videoWidth, videoRef.current.videoHeight);
|
|
8060
|
+
onSelfieCaptured === null || onSelfieCaptured === void 0 ? void 0 : onSelfieCaptured(imageData, state.faces[0]);
|
|
8061
|
+
clearCanvas(lastPredictionCanvas.current);
|
|
8062
|
+
}
|
|
8091
8063
|
}, [captureReady, onSelfieCaptured, state.faces, videoRef]);
|
|
8092
8064
|
var _q = useTimeout(timeoutDurationMs, onTimeout),
|
|
8093
8065
|
timedOut = _q.timedOut,
|
|
@@ -8136,7 +8108,7 @@ var SelfieCapture = function SelfieCapture(_a) {
|
|
|
8136
8108
|
scaling: debugScalingDetails,
|
|
8137
8109
|
color: satisfied ? 'green' : 'red'
|
|
8138
8110
|
});
|
|
8139
|
-
}))), debugMode && ( /*#__PURE__*/React__default.createElement(DebugStatsPane, null, cameraRef.current ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u2705 Camera: ", cameraRef.current.label, " (", cameraRef.current.width, "x", cameraRef.current.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React__default.createElement("br", null), !state.faceNotCentered ? '✅' : '❌', " Face Centered", /*#__PURE__*/React__default.createElement("br", null), !state.faceTooClose && !state.faceTooFar ? '✅' : '❌', " Face", ' ', state.faceTooClose ? 'Too Close' : state.faceTooFar ? 'Too Far' : 'Distance Correct', /*#__PURE__*/React__default.createElement("br", null), !state.faceLookingAway ? '✅' : '❌', " Face Looking Forward", /*#__PURE__*/React__default.createElement("br", null),
|
|
8111
|
+
}))), debugMode && ( /*#__PURE__*/React__default.createElement(DebugStatsPane, null, cameraRef.current ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u2705 Camera: ", cameraRef.current.label, " (", cameraRef.current.width, "x", cameraRef.current.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React__default.createElement("br", null), !state.faceNotCentered ? '✅' : '❌', " Face Centered", /*#__PURE__*/React__default.createElement("br", null), !state.faceTooClose && !state.faceTooFar ? '✅' : '❌', " Face", ' ', state.faceTooClose ? 'Too Close' : state.faceTooFar ? 'Too Far' : 'Distance Correct', /*#__PURE__*/React__default.createElement("br", null), !state.faceLookingAway ? '✅' : '❌', " Face Looking Forward", /*#__PURE__*/React__default.createElement("br", null), !timedOut ? '✅' : '❌', " Time Remaining:", ' ', Math.max(0, timeoutDurationMs - (new Date().getTime() - (timeoutStartedAt !== null && timeoutStartedAt !== void 0 ? timeoutStartedAt : new Date()).getTime())), "ms")), /*#__PURE__*/React__default.createElement(ExitCaptureButton, {
|
|
8140
8112
|
onClick: onExit,
|
|
8141
8113
|
className: classNames.exitCaptureBtn
|
|
8142
8114
|
}));
|
|
@@ -8256,6 +8228,7 @@ var FaceLivenessCapture = function FaceLivenessCapture(_a) {
|
|
|
8256
8228
|
setImageUrl = _m[1];
|
|
8257
8229
|
var rawCanvas = useRef(null);
|
|
8258
8230
|
var cropCanvas = useRef(null);
|
|
8231
|
+
var resizeCanvas = useRef(null);
|
|
8259
8232
|
var theme = useTheme();
|
|
8260
8233
|
var onSelfieCaptured = useCallback(function (frame, face) {
|
|
8261
8234
|
onCapture === null || onCapture === void 0 ? void 0 : onCapture();
|
|
@@ -8284,7 +8257,7 @@ var FaceLivenessCapture = function FaceLivenessCapture(_a) {
|
|
|
8284
8257
|
switch (_b.label) {
|
|
8285
8258
|
case 0:
|
|
8286
8259
|
_b.trys.push([0, 3,, 4]);
|
|
8287
|
-
imageUrl_1 = cropToShoulders(rawCanvas.current, cropCanvas.current, frame, face);
|
|
8260
|
+
imageUrl_1 = cropToShoulders(rawCanvas.current, cropCanvas.current, resizeCanvas.current, frame, face, 0.92, 500);
|
|
8288
8261
|
setImageUrl(imageUrl_1);
|
|
8289
8262
|
_a = checkLiveness;
|
|
8290
8263
|
return [4 /*yield*/, dataUrlToBase64(imageUrl_1)];
|
|
@@ -8397,6 +8370,8 @@ var FaceLivenessCapture = function FaceLivenessCapture(_a) {
|
|
|
8397
8370
|
ref: rawCanvas
|
|
8398
8371
|
}), /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
|
|
8399
8372
|
ref: cropCanvas
|
|
8373
|
+
}), /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
|
|
8374
|
+
ref: resizeCanvas
|
|
8400
8375
|
}), /*#__PURE__*/React__default.createElement(SelfieCapture, {
|
|
8401
8376
|
onSelfieCaptured: onSelfieCaptured,
|
|
8402
8377
|
onExit: onExit,
|
|
@@ -9115,6 +9090,7 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
|
|
|
9115
9090
|
logSelfieCaptureAttempt = _s.logSelfieCaptureAttempt;
|
|
9116
9091
|
var _t = useContext(CameraStateContext),
|
|
9117
9092
|
cameraAccessDenied = _t.cameraAccessDenied,
|
|
9093
|
+
requestCameraAccess = _t.requestCameraAccess,
|
|
9118
9094
|
releaseCameraAccess = _t.releaseCameraAccess;
|
|
9119
9095
|
var _u = useState(''),
|
|
9120
9096
|
faceCropImageUrl = _u[0],
|
|
@@ -9186,8 +9162,22 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
|
|
|
9186
9162
|
return n + 1;
|
|
9187
9163
|
});
|
|
9188
9164
|
setCaptureState('LOADING');
|
|
9165
|
+
releaseCameraAccess();
|
|
9189
9166
|
onExitCapture === null || onExitCapture === void 0 ? void 0 : onExitCapture();
|
|
9190
|
-
|
|
9167
|
+
requestCameraAccess();
|
|
9168
|
+
}, [onExitCapture, releaseCameraAccess, requestCameraAccess]);
|
|
9169
|
+
var onRetryCallback = useCallback(function () {
|
|
9170
|
+
logCaptureMetadata();
|
|
9171
|
+
setAttempt(function (n) {
|
|
9172
|
+
return n + 1;
|
|
9173
|
+
});
|
|
9174
|
+
setRetryCount(function (n) {
|
|
9175
|
+
return n + 1;
|
|
9176
|
+
});
|
|
9177
|
+
setCaptureState('LOADING');
|
|
9178
|
+
releaseCameraAccess();
|
|
9179
|
+
requestCameraAccess();
|
|
9180
|
+
}, [logCaptureMetadata, releaseCameraAccess, requestCameraAccess]);
|
|
9191
9181
|
var onDoneCallback = useCallback(function () {
|
|
9192
9182
|
logCaptureMetadata();
|
|
9193
9183
|
releaseCameraAccessOnExit && releaseCameraAccess();
|
|
@@ -9233,10 +9223,7 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
|
|
|
9233
9223
|
colors: colors.success,
|
|
9234
9224
|
verbiage: verbiage.success,
|
|
9235
9225
|
onDoneClick: onDoneCallback,
|
|
9236
|
-
onRetryClick:
|
|
9237
|
-
logCaptureMetadata();
|
|
9238
|
-
setCaptureState('CAPTURING');
|
|
9239
|
-
}
|
|
9226
|
+
onRetryClick: onRetryCallback
|
|
9240
9227
|
});
|
|
9241
9228
|
case 'FAILED':
|
|
9242
9229
|
return /*#__PURE__*/React__default.createElement(FaceLivenessFailure, {
|
|
@@ -9246,13 +9233,7 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
|
|
|
9246
9233
|
colors: colors.failure,
|
|
9247
9234
|
verbiage: verbiage.failure,
|
|
9248
9235
|
canRetry: maxRetries > -1 && retryCount < maxRetries,
|
|
9249
|
-
onRetryClick:
|
|
9250
|
-
logCaptureMetadata();
|
|
9251
|
-
setRetryCount(function (c) {
|
|
9252
|
-
return c + 1;
|
|
9253
|
-
});
|
|
9254
|
-
setCaptureState('CAPTURING');
|
|
9255
|
-
},
|
|
9236
|
+
onRetryClick: onRetryCallback,
|
|
9256
9237
|
onExitClick: function onExitClick() {
|
|
9257
9238
|
releaseCameraAccessOnExit && releaseCameraAccess();
|
|
9258
9239
|
setTimeout(function () {
|
|
@@ -10021,16 +10002,19 @@ var VideoSignatureWizard = function VideoSignatureWizard(_a) {
|
|
|
10021
10002
|
setSignatureData = _k.setSignatureData,
|
|
10022
10003
|
setSignatureVideoUrl = _k.setSignatureVideoUrl,
|
|
10023
10004
|
logSelfieCaptureAttempt = _k.logSelfieCaptureAttempt;
|
|
10024
|
-
var
|
|
10025
|
-
|
|
10026
|
-
|
|
10027
|
-
|
|
10005
|
+
var _l = useContext(CameraStateContext),
|
|
10006
|
+
cameraAccessDenied = _l.cameraAccessDenied,
|
|
10007
|
+
requestCameraAccess = _l.requestCameraAccess,
|
|
10008
|
+
releaseCameraAccess = _l.releaseCameraAccess;
|
|
10009
|
+
var _m = useState('LOADING'),
|
|
10010
|
+
captureState = _m[0],
|
|
10011
|
+
setCaptureState = _m[1];
|
|
10028
10012
|
var operationStartedAt = useRef();
|
|
10029
10013
|
var captureStartedAt = useRef();
|
|
10030
10014
|
var captureEndedAt = useRef();
|
|
10031
|
-
var
|
|
10032
|
-
start =
|
|
10033
|
-
stop =
|
|
10015
|
+
var _o = useContext(SelfieGuidanceModelsContext),
|
|
10016
|
+
start = _o.start,
|
|
10017
|
+
stop = _o.stop;
|
|
10034
10018
|
useEffect(function () {
|
|
10035
10019
|
operationStartedAt.current = new Date();
|
|
10036
10020
|
}, []);
|
|
@@ -10087,16 +10071,18 @@ var VideoSignatureWizard = function VideoSignatureWizard(_a) {
|
|
|
10087
10071
|
var onSignatureCaptureFacesNotDetected = useCallback(function () {
|
|
10088
10072
|
setCaptureState('CHECKING_LIVENESS');
|
|
10089
10073
|
}, []);
|
|
10090
|
-
var
|
|
10091
|
-
attempt =
|
|
10092
|
-
setAttempt =
|
|
10074
|
+
var _p = useState(0),
|
|
10075
|
+
attempt = _p[0],
|
|
10076
|
+
setAttempt = _p[1];
|
|
10093
10077
|
var onExit = useCallback(function () {
|
|
10078
|
+
releaseCameraAccess();
|
|
10094
10079
|
setAttempt(function (n) {
|
|
10095
10080
|
return n + 1;
|
|
10096
10081
|
});
|
|
10097
10082
|
setCaptureState('LOADING');
|
|
10098
10083
|
onExitCapture === null || onExitCapture === void 0 ? void 0 : onExitCapture();
|
|
10099
|
-
|
|
10084
|
+
requestCameraAccess();
|
|
10085
|
+
}, [onExitCapture, releaseCameraAccess, requestCameraAccess]);
|
|
10100
10086
|
var onRetry = useCallback(function () {
|
|
10101
10087
|
onRetryClicked === null || onRetryClicked === void 0 ? void 0 : onRetryClicked();
|
|
10102
10088
|
onExit();
|
|
@@ -10471,6 +10457,7 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
10471
10457
|
onIdBackImageCaptured = _a.onIdBackImageCaptured,
|
|
10472
10458
|
onFaceNotDetected = _a.onFaceNotDetected,
|
|
10473
10459
|
onRecordingFailed = _a.onRecordingFailed,
|
|
10460
|
+
onExitCapture = _a.onExitCapture,
|
|
10474
10461
|
_w = _a.idCaptureModelsEnabled,
|
|
10475
10462
|
idCaptureModelsEnabled = _w === void 0 ? true : _w,
|
|
10476
10463
|
_x = _a.idCardFrontDelay,
|
|
@@ -10851,7 +10838,10 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
10851
10838
|
},
|
|
10852
10839
|
disabled: !!countdownStartedAt || frameLock.current,
|
|
10853
10840
|
className: classNames.captureBtn
|
|
10854
|
-
}, captureBtnText)))
|
|
10841
|
+
}, captureBtnText))), /*#__PURE__*/React__default.createElement(ExitCaptureButton, {
|
|
10842
|
+
onClick: onExitCapture,
|
|
10843
|
+
className: classNames.exitCaptureBtn
|
|
10844
|
+
}));
|
|
10855
10845
|
};
|
|
10856
10846
|
var CountdownContainer = styled.div(templateObject_1$5 || (templateObject_1$5 = __makeTemplateObject(["\n position: fixed;\n top: 0;\n left: 0;\n width: 100dvw;\n height: 100dvh;\n z-index: 99999;\n display: flex;\n"], ["\n position: fixed;\n top: 0;\n left: 0;\n width: 100dvw;\n height: 100dvh;\n z-index: 99999;\n display: flex;\n"])));
|
|
10857
10847
|
var Countdown = styled.div(templateObject_2$5 || (templateObject_2$5 = __makeTemplateObject(["\n color: white;\n font-size: 64px;\n font-weight: bold;\n margin: auto;\n"], ["\n color: white;\n font-size: 64px;\n font-weight: bold;\n margin: auto;\n"])));
|
|
@@ -11104,13 +11094,19 @@ var VideoIdWizard = function VideoIdWizard(_a) {
|
|
|
11104
11094
|
});
|
|
11105
11095
|
setCaptureState('CHECKING_LIVENESS');
|
|
11106
11096
|
}, []);
|
|
11097
|
+
var handleExitCapture = useCallback(function () {
|
|
11098
|
+
setAttempt(function (n) {
|
|
11099
|
+
return n + 1;
|
|
11100
|
+
});
|
|
11101
|
+
onExitCapture === null || onExitCapture === void 0 ? void 0 : onExitCapture();
|
|
11102
|
+
}, [onExitCapture]);
|
|
11107
11103
|
if (submissionStatus === SubmissionStatus.SUBMITTING) {
|
|
11108
11104
|
return /*#__PURE__*/React__default.createElement(PageContainer, {
|
|
11109
11105
|
className: "flex"
|
|
11110
11106
|
}, /*#__PURE__*/React__default.createElement(Spinner, null));
|
|
11111
11107
|
}
|
|
11112
11108
|
return /*#__PURE__*/React__default.createElement(CameraProvider, {
|
|
11113
|
-
key: isCapturingId ? 'id
|
|
11109
|
+
key: "".concat(isCapturingId ? 'id' : 'selfie', "-camera-").concat(attempt),
|
|
11114
11110
|
preferContinuityCamera: isCapturingId,
|
|
11115
11111
|
preferFrontFacingCamera: !isCapturingId,
|
|
11116
11112
|
requireMicrophoneAccess: !isCapturingId && !!readTextPrompt,
|
|
@@ -11146,7 +11142,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
|
|
|
11146
11142
|
colors: colors.idCapture,
|
|
11147
11143
|
verbiage: verbiage.idCapture,
|
|
11148
11144
|
onSuccess: onIdCaptureSuccess,
|
|
11149
|
-
onExitCapture:
|
|
11145
|
+
onExitCapture: handleExitCapture,
|
|
11150
11146
|
onUserCancel: onUserCancel,
|
|
11151
11147
|
skipSuccessScreen: true,
|
|
11152
11148
|
releaseCameraAccessOnExit: false,
|
|
@@ -11162,7 +11158,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
|
|
|
11162
11158
|
silentFallback: silentFallback
|
|
11163
11159
|
}, faceLivenessProps, {
|
|
11164
11160
|
onComplete: onFaceCaptureSuccess,
|
|
11165
|
-
onExitCapture:
|
|
11161
|
+
onExitCapture: handleExitCapture,
|
|
11166
11162
|
onExitAfterFailure: onFaceCaptureExitAfterFailure,
|
|
11167
11163
|
onUserCancel: onUserCancel,
|
|
11168
11164
|
skipSuccessScreen: true,
|
|
@@ -11182,6 +11178,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
|
|
|
11182
11178
|
onIdBackImageCaptured: setIdCaptureVideoIdBackImage,
|
|
11183
11179
|
onFaceNotDetected: onVideoCaptureFaceNotDetected,
|
|
11184
11180
|
onRecordingFailed: onRecordingFailed,
|
|
11181
|
+
onExitCapture: handleExitCapture,
|
|
11185
11182
|
idCaptureModelsEnabled: idCaptureModelsEnabled,
|
|
11186
11183
|
videoIdCaptureThresholds: videoIdCaptureThresholds,
|
|
11187
11184
|
skipShowIdCardBack: skipShowIdCardBack,
|
|
@@ -12469,6 +12466,7 @@ var CustomerVerificationCapture = function CustomerVerificationCapture(_a) {
|
|
|
12469
12466
|
setImageUrl = _k[1];
|
|
12470
12467
|
var rawCanvas = useRef(null);
|
|
12471
12468
|
var cropCanvas = useRef(null);
|
|
12469
|
+
var resizeCanvas = useRef(null);
|
|
12472
12470
|
var onSelfieCaptured = useCallback(function (frame, face) {
|
|
12473
12471
|
dispatch({
|
|
12474
12472
|
type: 'verificationReady',
|
|
@@ -12481,7 +12479,7 @@ var CustomerVerificationCapture = function CustomerVerificationCapture(_a) {
|
|
|
12481
12479
|
var isReady = state.requestState === 'CAPTURED';
|
|
12482
12480
|
useEffect(function () {
|
|
12483
12481
|
if (!frame || !face || submissionError) return;
|
|
12484
|
-
var imageUrl = cropToShoulders(rawCanvas.current, cropCanvas.current, frame, face);
|
|
12482
|
+
var imageUrl = cropToShoulders(rawCanvas.current, cropCanvas.current, resizeCanvas.current, frame, face);
|
|
12485
12483
|
setImageUrl(imageUrl);
|
|
12486
12484
|
dataUrlToBase64(imageUrl).then(function (img) {
|
|
12487
12485
|
setSelfieImage(img);
|
|
@@ -12544,6 +12542,8 @@ var CustomerVerificationCapture = function CustomerVerificationCapture(_a) {
|
|
|
12544
12542
|
ref: rawCanvas
|
|
12545
12543
|
}), /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
|
|
12546
12544
|
ref: cropCanvas
|
|
12545
|
+
}), /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
|
|
12546
|
+
ref: resizeCanvas
|
|
12547
12547
|
}), /*#__PURE__*/React__default.createElement(SelfieCapture, {
|
|
12548
12548
|
onSelfieCaptured: onSelfieCaptured,
|
|
12549
12549
|
onExit: onExit,
|
|
@@ -13022,6 +13022,7 @@ var CustomerIdentificationCapture = function CustomerIdentificationCapture(_a) {
|
|
|
13022
13022
|
setImageUrl = _k[1];
|
|
13023
13023
|
var rawCanvas = useRef(null);
|
|
13024
13024
|
var cropCanvas = useRef(null);
|
|
13025
|
+
var resizeCanvas = useRef(null);
|
|
13025
13026
|
var onSelfieCaptured = useCallback(function (frame, face) {
|
|
13026
13027
|
dispatch({
|
|
13027
13028
|
type: 'identificationReady',
|
|
@@ -13036,7 +13037,7 @@ var CustomerIdentificationCapture = function CustomerIdentificationCapture(_a) {
|
|
|
13036
13037
|
var isReady = state.requestState === 'CAPTURED';
|
|
13037
13038
|
useEffect(function () {
|
|
13038
13039
|
if (!frame || !face || submissionError) return;
|
|
13039
|
-
var imageUrl = cropToShoulders(rawCanvas.current, cropCanvas.current, frame, face);
|
|
13040
|
+
var imageUrl = cropToShoulders(rawCanvas.current, cropCanvas.current, resizeCanvas.current, frame, face);
|
|
13040
13041
|
setImageUrl(imageUrl);
|
|
13041
13042
|
dataUrlToBase64(imageUrl).then(function (img) {
|
|
13042
13043
|
setSelfieImage(img);
|
|
@@ -13099,6 +13100,8 @@ var CustomerIdentificationCapture = function CustomerIdentificationCapture(_a) {
|
|
|
13099
13100
|
ref: rawCanvas
|
|
13100
13101
|
}), /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
|
|
13101
13102
|
ref: cropCanvas
|
|
13103
|
+
}), /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
|
|
13104
|
+
ref: resizeCanvas
|
|
13102
13105
|
}), /*#__PURE__*/React__default.createElement(SelfieCapture, {
|
|
13103
13106
|
onSelfieCaptured: onSelfieCaptured,
|
|
13104
13107
|
onExit: onExit,
|