idmission-web-sdk 2.1.7 → 2.1.9
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/submission/SessionValidationFailedOverlay.d.ts +3 -1
- package/dist/lib/utils/cropping.d.ts +1 -1
- package/dist/sdk2.cjs.development.js +101 -112
- 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 +102 -113
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +103 -114
- 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 +1 -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.9';
|
|
18
18
|
|
|
19
19
|
function getPlatform() {
|
|
20
20
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -458,7 +458,8 @@ var SessionIdMissingOverlay = function SessionIdMissingOverlay() {
|
|
|
458
458
|
}, "Getting Started"), ' ', "section of the documentation for information on how to use your credentials to generate a valid session for your IDmission account. Every usage of the IDmission WebSDK must be authorized with a valid session from IDmission's servers.")));
|
|
459
459
|
};
|
|
460
460
|
|
|
461
|
-
var SessionValidationFailedOverlay = function SessionValidationFailedOverlay() {
|
|
461
|
+
var SessionValidationFailedOverlay = function SessionValidationFailedOverlay(_a) {
|
|
462
|
+
var message = _a.message;
|
|
462
463
|
return /*#__PURE__*/React__default.createElement(OverlayContainer, null, /*#__PURE__*/React__default.createElement(OverlayInner$2, {
|
|
463
464
|
style: {
|
|
464
465
|
justifyContent: 'center'
|
|
@@ -471,7 +472,7 @@ var SessionValidationFailedOverlay = function SessionValidationFailedOverlay() {
|
|
|
471
472
|
style: {
|
|
472
473
|
marginBottom: 0
|
|
473
474
|
}
|
|
474
|
-
}, "Required property ", /*#__PURE__*/React__default.createElement("code", null, "sessionId"), " is not valid."), /*#__PURE__*/React__default.createElement("p", {
|
|
475
|
+
}, "Required property ", /*#__PURE__*/React__default.createElement("code", null, "sessionId"), " is not valid", message && " (".concat(message, ")"), "."), /*#__PURE__*/React__default.createElement("p", {
|
|
475
476
|
style: {
|
|
476
477
|
lineHeight: '1.5rem'
|
|
477
478
|
}
|
|
@@ -579,7 +580,7 @@ var Spinner = styled.div(templateObject_1$D || (templateObject_1$D = __makeTempl
|
|
|
579
580
|
var templateObject_1$D;
|
|
580
581
|
|
|
581
582
|
var defaultAuthUrl = 'https://portal-api.idmission.com';
|
|
582
|
-
var allowedAuthUrls = ['https://portal-api.idmission.com', 'https://portal-api-uat.idmission.com', 'https://portal-api-demo.idmission.com', 'https://portal-api-dev.idmission.com', 'http://localhost:10000'];
|
|
583
|
+
var allowedAuthUrls = ['https://portal-2-dev-fargate.idmission.com', 'https://portal-2-demo-fargate.idmission.com', 'https://portal-2-uat-fargate.idmission.com', 'https://portal-2-prod-fargate.idmission.com', 'https://portal2-api.idmission.com', 'https://portal-api.idmission.com', 'https://portal-api-uat.idmission.com', 'https://portal-api-demo.idmission.com', 'https://portal-api-dev.idmission.com', 'http://localhost:10000'];
|
|
583
584
|
var initialState$5 = {
|
|
584
585
|
authUrl: defaultAuthUrl,
|
|
585
586
|
sessionCheckState: 'READY'
|
|
@@ -597,6 +598,7 @@ var reducer$5 = function reducer(state, action) {
|
|
|
597
598
|
sessionCheckState: action.payload
|
|
598
599
|
});
|
|
599
600
|
case 'setError':
|
|
601
|
+
console.log('setting error', action.payload);
|
|
600
602
|
return __assign(__assign({}, state), {
|
|
601
603
|
sessionCheckState: 'ERROR',
|
|
602
604
|
authError: action.payload
|
|
@@ -661,11 +663,11 @@ function useAuthReducer(authUrl, sessionId) {
|
|
|
661
663
|
});
|
|
662
664
|
(function () {
|
|
663
665
|
return __awaiter(_this, void 0, void 0, function () {
|
|
664
|
-
var resp, valid, e_1;
|
|
665
|
-
return __generator(this, function (
|
|
666
|
-
switch (
|
|
666
|
+
var resp, _a, valid, message, e_1;
|
|
667
|
+
return __generator(this, function (_b) {
|
|
668
|
+
switch (_b.label) {
|
|
667
669
|
case 0:
|
|
668
|
-
|
|
670
|
+
_b.trys.push([0, 3,, 4]);
|
|
669
671
|
return [4 /*yield*/, fetch("".concat(authUrl, "/portal.sessions.v1.SessionsService/ValidateSession"), {
|
|
670
672
|
method: 'POST',
|
|
671
673
|
headers: {
|
|
@@ -676,17 +678,23 @@ function useAuthReducer(authUrl, sessionId) {
|
|
|
676
678
|
})
|
|
677
679
|
})];
|
|
678
680
|
case 1:
|
|
679
|
-
resp =
|
|
681
|
+
resp = _b.sent();
|
|
680
682
|
return [4 /*yield*/, resp.json()];
|
|
681
683
|
case 2:
|
|
682
|
-
|
|
684
|
+
_a = _b.sent(), valid = _a.valid, message = _a.message;
|
|
685
|
+
if (!resp.ok) {
|
|
686
|
+
dispatch({
|
|
687
|
+
type: 'setError',
|
|
688
|
+
payload: new SessionValidationFailedError(new Error(message), authUrl)
|
|
689
|
+
});
|
|
690
|
+
}
|
|
683
691
|
dispatch({
|
|
684
692
|
type: 'setCheckState',
|
|
685
693
|
payload: valid ? 'PASSED' : 'FAILED'
|
|
686
694
|
});
|
|
687
695
|
return [3 /*break*/, 4];
|
|
688
696
|
case 3:
|
|
689
|
-
e_1 =
|
|
697
|
+
e_1 = _b.sent();
|
|
690
698
|
dispatch({
|
|
691
699
|
type: 'setError',
|
|
692
700
|
payload: new SessionValidationFailedError(e_1, authUrl)
|
|
@@ -709,18 +717,21 @@ function useAuthContext() {
|
|
|
709
717
|
return [state, dispatch];
|
|
710
718
|
}
|
|
711
719
|
function AuthProvider(_a) {
|
|
712
|
-
var _b
|
|
713
|
-
|
|
720
|
+
var _b;
|
|
721
|
+
var _c = _a.authUrl,
|
|
722
|
+
authUrl = _c === void 0 ? defaultAuthUrl : _c,
|
|
714
723
|
sessionId = _a.sessionId,
|
|
715
724
|
children = _a.children;
|
|
716
|
-
var
|
|
717
|
-
state =
|
|
718
|
-
dispatch =
|
|
725
|
+
var _d = useAuthReducer(authUrl, sessionId),
|
|
726
|
+
state = _d[0],
|
|
727
|
+
dispatch = _d[1];
|
|
719
728
|
if (state.sessionCheckState === 'MISSING') {
|
|
720
729
|
return /*#__PURE__*/React__default.createElement(SessionIdMissingOverlay, null);
|
|
721
730
|
}
|
|
722
731
|
if (state.sessionCheckState === 'FAILED') {
|
|
723
|
-
return /*#__PURE__*/React__default.createElement(SessionValidationFailedOverlay,
|
|
732
|
+
return /*#__PURE__*/React__default.createElement(SessionValidationFailedOverlay, {
|
|
733
|
+
message: (_b = state.authError) === null || _b === void 0 ? void 0 : _b.message
|
|
734
|
+
});
|
|
724
735
|
}
|
|
725
736
|
if (state.sessionCheckState === 'AUTH_URL_NOT_ALLOWED') {
|
|
726
737
|
return /*#__PURE__*/React__default.createElement(AuthUrlNotAllowedOverlay, null);
|
|
@@ -2243,39 +2254,15 @@ function preloadVisionRuntime() {
|
|
|
2243
2254
|
});
|
|
2244
2255
|
}
|
|
2245
2256
|
|
|
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));
|
|
2257
|
+
function cropToShoulders(rawCanvas, cropCanvas, resizeCanvas, frame, face, quality, maxHeight) {
|
|
2258
|
+
if (quality === void 0) {
|
|
2259
|
+
quality = 0.92;
|
|
2270
2260
|
}
|
|
2271
|
-
return
|
|
2272
|
-
}
|
|
2273
|
-
|
|
2274
|
-
function cropToShoulders(rawCanvas, cropCanvas, frame, face) {
|
|
2275
|
-
if (!rawCanvas || !cropCanvas) return '';
|
|
2261
|
+
if (!rawCanvas || !cropCanvas || !resizeCanvas) return '';
|
|
2276
2262
|
var rawCtx = rawCanvas.getContext('2d');
|
|
2277
2263
|
var cropCtx = cropCanvas.getContext('2d');
|
|
2278
|
-
|
|
2264
|
+
var resizeCtx = resizeCanvas.getContext('2d');
|
|
2265
|
+
if (!rawCtx || !cropCtx || !resizeCtx) throw new Error('could not get 2d context');
|
|
2279
2266
|
rawCanvas.width = frame.width;
|
|
2280
2267
|
rawCanvas.height = frame.height;
|
|
2281
2268
|
rawCtx.putImageData(frame, 0, 0);
|
|
@@ -2285,7 +2272,7 @@ function cropToShoulders(rawCanvas, cropCanvas, frame, face) {
|
|
|
2285
2272
|
var frameHeight = frame.height;
|
|
2286
2273
|
var xPadding = frameHeight * 0.6 - width;
|
|
2287
2274
|
var xPos = Math.max(0, xMin - xPadding / 2);
|
|
2288
|
-
if (
|
|
2275
|
+
if (frame.height > frame.width) {
|
|
2289
2276
|
cropCanvas.width = frame.width;
|
|
2290
2277
|
cropCanvas.height = frame.height;
|
|
2291
2278
|
cropCtx.drawImage(rawCanvas, 0, 0, cropCanvas.width, cropCanvas.height);
|
|
@@ -2294,9 +2281,14 @@ function cropToShoulders(rawCanvas, cropCanvas, frame, face) {
|
|
|
2294
2281
|
cropCanvas.height = frame.height;
|
|
2295
2282
|
cropCtx.drawImage(rawCanvas, xPos, 0, cropCanvas.width, cropCanvas.height, 0, 0, cropCanvas.width, cropCanvas.height);
|
|
2296
2283
|
}
|
|
2297
|
-
|
|
2284
|
+
resizeCanvas.height = maxHeight !== null && maxHeight !== void 0 ? maxHeight : cropCanvas.height;
|
|
2285
|
+
resizeCanvas.width = cropCanvas.width * (resizeCanvas.height / cropCanvas.height);
|
|
2286
|
+
resizeCtx === null || resizeCtx === void 0 ? void 0 : resizeCtx.drawImage(cropCanvas, 0, 0, resizeCanvas.width, resizeCanvas.height);
|
|
2287
|
+
var dataURL = resizeCanvas.toDataURL('image/jpeg', quality);
|
|
2288
|
+
log('cropToShoulders size', new TextEncoder().encode(dataURL).length);
|
|
2298
2289
|
clearCanvas(rawCanvas);
|
|
2299
2290
|
clearCanvas(cropCanvas);
|
|
2291
|
+
clearCanvas(resizeCanvas);
|
|
2300
2292
|
return dataURL;
|
|
2301
2293
|
}
|
|
2302
2294
|
function cropToDetectedObjectBox(frame, box, canvas) {
|
|
@@ -3629,6 +3621,34 @@ function FocusModelProvider(_a) {
|
|
|
3629
3621
|
}), children);
|
|
3630
3622
|
}
|
|
3631
3623
|
|
|
3624
|
+
function _isNavigatorDefined() {
|
|
3625
|
+
return typeof navigator !== 'undefined' && navigator != null;
|
|
3626
|
+
}
|
|
3627
|
+
function isMobile(nav) {
|
|
3628
|
+
if (nav || _isNavigatorDefined()) {
|
|
3629
|
+
if (!nav) {
|
|
3630
|
+
nav = navigator;
|
|
3631
|
+
}
|
|
3632
|
+
if (nav.product === 'ReactNative') {
|
|
3633
|
+
return true;
|
|
3634
|
+
}
|
|
3635
|
+
var a = nav.userAgent || nav.vendor || (
|
|
3636
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3637
|
+
// @ts-ignore
|
|
3638
|
+
typeof window !== 'undefined' ? window.opera : '');
|
|
3639
|
+
if (!a) {
|
|
3640
|
+
var navAny = nav;
|
|
3641
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3642
|
+
// @ts-ignore
|
|
3643
|
+
return navAny.userAgentData && navAny.userAgentData.mobile;
|
|
3644
|
+
}
|
|
3645
|
+
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) ||
|
|
3646
|
+
// tslint:disable-next-line:max-line-length
|
|
3647
|
+
/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));
|
|
3648
|
+
}
|
|
3649
|
+
return false;
|
|
3650
|
+
}
|
|
3651
|
+
|
|
3632
3652
|
var onMobile = isMobile();
|
|
3633
3653
|
var defaultIdCaptureThresholds = {
|
|
3634
3654
|
detection: defaultDocumentDetectionThresholds,
|
|
@@ -7908,9 +7928,6 @@ var templateObject_1$j, templateObject_2$d, templateObject_3$c, templateObject_4
|
|
|
7908
7928
|
var initialState$3 = {
|
|
7909
7929
|
videoWidth: 0,
|
|
7910
7930
|
videoHeight: 0,
|
|
7911
|
-
capturing: false,
|
|
7912
|
-
captured: false,
|
|
7913
|
-
captureFailed: false,
|
|
7914
7931
|
frame: null,
|
|
7915
7932
|
faces: [],
|
|
7916
7933
|
faceNotCentered: false,
|
|
@@ -7918,36 +7935,12 @@ var initialState$3 = {
|
|
|
7918
7935
|
faceTooClose: false,
|
|
7919
7936
|
faceTooFar: false,
|
|
7920
7937
|
faceReady: false,
|
|
7921
|
-
faceReadyAt: null
|
|
7922
|
-
goodFramesCount: 0,
|
|
7923
|
-
goodFramesThreshold: 1,
|
|
7924
|
-
goodFramesThresholdMet: false
|
|
7938
|
+
faceReadyAt: null
|
|
7925
7939
|
};
|
|
7926
7940
|
var reducer$3 = function reducer(state, action) {
|
|
7927
7941
|
switch (action.type) {
|
|
7928
7942
|
case 'configure':
|
|
7929
|
-
return __assign(__assign({}, state),
|
|
7930
|
-
videoWidth: action.payload.videoWidth,
|
|
7931
|
-
videoHeight: action.payload.videoHeight
|
|
7932
|
-
});
|
|
7933
|
-
case 'capturing':
|
|
7934
|
-
return __assign(__assign({}, state), {
|
|
7935
|
-
capturing: true,
|
|
7936
|
-
captured: false,
|
|
7937
|
-
captureFailed: false
|
|
7938
|
-
});
|
|
7939
|
-
case 'captured':
|
|
7940
|
-
return __assign(__assign({}, state), {
|
|
7941
|
-
capturing: false,
|
|
7942
|
-
captured: true,
|
|
7943
|
-
captureFailed: false
|
|
7944
|
-
});
|
|
7945
|
-
case 'captureFailed':
|
|
7946
|
-
return __assign(__assign({}, state), {
|
|
7947
|
-
capturing: false,
|
|
7948
|
-
captured: false,
|
|
7949
|
-
captureFailed: true
|
|
7950
|
-
});
|
|
7943
|
+
return __assign(__assign({}, state), action.payload);
|
|
7951
7944
|
case 'facesDetected':
|
|
7952
7945
|
{
|
|
7953
7946
|
var faces = action.payload.faces;
|
|
@@ -7956,8 +7949,7 @@ var reducer$3 = function reducer(state, action) {
|
|
|
7956
7949
|
faceLookingAway = false,
|
|
7957
7950
|
faceTooClose = false,
|
|
7958
7951
|
faceTooFar = false,
|
|
7959
|
-
faceReadyAt = state.faceReadyAt
|
|
7960
|
-
goodFramesCount = state.goodFramesCount;
|
|
7952
|
+
faceReadyAt = state.faceReadyAt;
|
|
7961
7953
|
if (face) {
|
|
7962
7954
|
// calculate centroids
|
|
7963
7955
|
var vCX = state.videoWidth / 2;
|
|
@@ -7983,7 +7975,6 @@ var reducer$3 = function reducer(state, action) {
|
|
|
7983
7975
|
var faceReady = !faceNotCentered && !faceLookingAway && !faceTooClose && !faceTooFar;
|
|
7984
7976
|
if (!faceReady) {
|
|
7985
7977
|
faceReadyAt = null;
|
|
7986
|
-
goodFramesCount = 0;
|
|
7987
7978
|
} else if (!state.faceReady) {
|
|
7988
7979
|
faceReadyAt = new Date();
|
|
7989
7980
|
}
|
|
@@ -7994,8 +7985,7 @@ var reducer$3 = function reducer(state, action) {
|
|
|
7994
7985
|
faceTooClose: faceTooClose,
|
|
7995
7986
|
faceTooFar: faceTooFar,
|
|
7996
7987
|
faceReady: faceReady,
|
|
7997
|
-
faceReadyAt: faceReadyAt
|
|
7998
|
-
goodFramesCount: goodFramesCount
|
|
7988
|
+
faceReadyAt: faceReadyAt
|
|
7999
7989
|
});
|
|
8000
7990
|
}
|
|
8001
7991
|
}
|
|
@@ -8047,16 +8037,14 @@ var SelfieCapture = function SelfieCapture(_a) {
|
|
|
8047
8037
|
});
|
|
8048
8038
|
}
|
|
8049
8039
|
}, [cameraReady, videoRef]);
|
|
8050
|
-
|
|
8051
|
-
|
|
8052
|
-
|
|
8053
|
-
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
}
|
|
8057
|
-
});
|
|
8040
|
+
onPredictionMade(useThrottledCallback(function (prediction) {
|
|
8041
|
+
dispatch({
|
|
8042
|
+
type: 'facesDetected',
|
|
8043
|
+
payload: {
|
|
8044
|
+
faces: prediction
|
|
8045
|
+
}
|
|
8058
8046
|
});
|
|
8059
|
-
},
|
|
8047
|
+
}, 16));
|
|
8060
8048
|
var _p = useState(false),
|
|
8061
8049
|
captureReady = _p[0],
|
|
8062
8050
|
setCaptureReady = _p[1];
|
|
@@ -8075,22 +8063,14 @@ var SelfieCapture = function SelfieCapture(_a) {
|
|
|
8075
8063
|
};
|
|
8076
8064
|
}, [onGuidanceNotSatisfied, onGuidanceSatisfied, state.faceReady]);
|
|
8077
8065
|
useEffect(function () {
|
|
8078
|
-
(
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
|
|
8085
|
-
|
|
8086
|
-
imageData = ctx.getImageData(0, 0, videoRef.current.videoWidth, videoRef.current.videoHeight);
|
|
8087
|
-
onSelfieCaptured === null || onSelfieCaptured === void 0 ? void 0 : onSelfieCaptured(imageData, state.faces[0]);
|
|
8088
|
-
clearCanvas(lastPredictionCanvas.current);
|
|
8089
|
-
}
|
|
8090
|
-
return [2 /*return*/];
|
|
8091
|
-
});
|
|
8092
|
-
});
|
|
8093
|
-
})();
|
|
8066
|
+
if (captureReady && videoRef.current && lastPredictionCanvas.current && state.faces.length > 0) {
|
|
8067
|
+
drawToCanvas(lastPredictionCanvas.current, videoRef.current);
|
|
8068
|
+
var ctx = lastPredictionCanvas.current.getContext('2d');
|
|
8069
|
+
if (!ctx) return;
|
|
8070
|
+
var imageData = ctx.getImageData(0, 0, videoRef.current.videoWidth, videoRef.current.videoHeight);
|
|
8071
|
+
onSelfieCaptured === null || onSelfieCaptured === void 0 ? void 0 : onSelfieCaptured(imageData, state.faces[0]);
|
|
8072
|
+
clearCanvas(lastPredictionCanvas.current);
|
|
8073
|
+
}
|
|
8094
8074
|
}, [captureReady, onSelfieCaptured, state.faces, videoRef]);
|
|
8095
8075
|
var _q = useTimeout(timeoutDurationMs, onTimeout),
|
|
8096
8076
|
timedOut = _q.timedOut,
|
|
@@ -8139,7 +8119,7 @@ var SelfieCapture = function SelfieCapture(_a) {
|
|
|
8139
8119
|
scaling: debugScalingDetails,
|
|
8140
8120
|
color: satisfied ? 'green' : 'red'
|
|
8141
8121
|
});
|
|
8142
|
-
}))), 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),
|
|
8122
|
+
}))), 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, {
|
|
8143
8123
|
onClick: onExit,
|
|
8144
8124
|
className: classNames.exitCaptureBtn
|
|
8145
8125
|
}));
|
|
@@ -8259,6 +8239,7 @@ var FaceLivenessCapture = function FaceLivenessCapture(_a) {
|
|
|
8259
8239
|
setImageUrl = _m[1];
|
|
8260
8240
|
var rawCanvas = useRef(null);
|
|
8261
8241
|
var cropCanvas = useRef(null);
|
|
8242
|
+
var resizeCanvas = useRef(null);
|
|
8262
8243
|
var theme = useTheme();
|
|
8263
8244
|
var onSelfieCaptured = useCallback(function (frame, face) {
|
|
8264
8245
|
onCapture === null || onCapture === void 0 ? void 0 : onCapture();
|
|
@@ -8287,7 +8268,7 @@ var FaceLivenessCapture = function FaceLivenessCapture(_a) {
|
|
|
8287
8268
|
switch (_b.label) {
|
|
8288
8269
|
case 0:
|
|
8289
8270
|
_b.trys.push([0, 3,, 4]);
|
|
8290
|
-
imageUrl_1 = cropToShoulders(rawCanvas.current, cropCanvas.current, frame, face);
|
|
8271
|
+
imageUrl_1 = cropToShoulders(rawCanvas.current, cropCanvas.current, resizeCanvas.current, frame, face, 0.92, 500);
|
|
8291
8272
|
setImageUrl(imageUrl_1);
|
|
8292
8273
|
_a = checkLiveness;
|
|
8293
8274
|
return [4 /*yield*/, dataUrlToBase64(imageUrl_1)];
|
|
@@ -8400,6 +8381,8 @@ var FaceLivenessCapture = function FaceLivenessCapture(_a) {
|
|
|
8400
8381
|
ref: rawCanvas
|
|
8401
8382
|
}), /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
|
|
8402
8383
|
ref: cropCanvas
|
|
8384
|
+
}), /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
|
|
8385
|
+
ref: resizeCanvas
|
|
8403
8386
|
}), /*#__PURE__*/React__default.createElement(SelfieCapture, {
|
|
8404
8387
|
onSelfieCaptured: onSelfieCaptured,
|
|
8405
8388
|
onExit: onExit,
|
|
@@ -12494,6 +12477,7 @@ var CustomerVerificationCapture = function CustomerVerificationCapture(_a) {
|
|
|
12494
12477
|
setImageUrl = _k[1];
|
|
12495
12478
|
var rawCanvas = useRef(null);
|
|
12496
12479
|
var cropCanvas = useRef(null);
|
|
12480
|
+
var resizeCanvas = useRef(null);
|
|
12497
12481
|
var onSelfieCaptured = useCallback(function (frame, face) {
|
|
12498
12482
|
dispatch({
|
|
12499
12483
|
type: 'verificationReady',
|
|
@@ -12506,7 +12490,7 @@ var CustomerVerificationCapture = function CustomerVerificationCapture(_a) {
|
|
|
12506
12490
|
var isReady = state.requestState === 'CAPTURED';
|
|
12507
12491
|
useEffect(function () {
|
|
12508
12492
|
if (!frame || !face || submissionError) return;
|
|
12509
|
-
var imageUrl = cropToShoulders(rawCanvas.current, cropCanvas.current, frame, face);
|
|
12493
|
+
var imageUrl = cropToShoulders(rawCanvas.current, cropCanvas.current, resizeCanvas.current, frame, face);
|
|
12510
12494
|
setImageUrl(imageUrl);
|
|
12511
12495
|
dataUrlToBase64(imageUrl).then(function (img) {
|
|
12512
12496
|
setSelfieImage(img);
|
|
@@ -12569,6 +12553,8 @@ var CustomerVerificationCapture = function CustomerVerificationCapture(_a) {
|
|
|
12569
12553
|
ref: rawCanvas
|
|
12570
12554
|
}), /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
|
|
12571
12555
|
ref: cropCanvas
|
|
12556
|
+
}), /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
|
|
12557
|
+
ref: resizeCanvas
|
|
12572
12558
|
}), /*#__PURE__*/React__default.createElement(SelfieCapture, {
|
|
12573
12559
|
onSelfieCaptured: onSelfieCaptured,
|
|
12574
12560
|
onExit: onExit,
|
|
@@ -13047,6 +13033,7 @@ var CustomerIdentificationCapture = function CustomerIdentificationCapture(_a) {
|
|
|
13047
13033
|
setImageUrl = _k[1];
|
|
13048
13034
|
var rawCanvas = useRef(null);
|
|
13049
13035
|
var cropCanvas = useRef(null);
|
|
13036
|
+
var resizeCanvas = useRef(null);
|
|
13050
13037
|
var onSelfieCaptured = useCallback(function (frame, face) {
|
|
13051
13038
|
dispatch({
|
|
13052
13039
|
type: 'identificationReady',
|
|
@@ -13061,7 +13048,7 @@ var CustomerIdentificationCapture = function CustomerIdentificationCapture(_a) {
|
|
|
13061
13048
|
var isReady = state.requestState === 'CAPTURED';
|
|
13062
13049
|
useEffect(function () {
|
|
13063
13050
|
if (!frame || !face || submissionError) return;
|
|
13064
|
-
var imageUrl = cropToShoulders(rawCanvas.current, cropCanvas.current, frame, face);
|
|
13051
|
+
var imageUrl = cropToShoulders(rawCanvas.current, cropCanvas.current, resizeCanvas.current, frame, face);
|
|
13065
13052
|
setImageUrl(imageUrl);
|
|
13066
13053
|
dataUrlToBase64(imageUrl).then(function (img) {
|
|
13067
13054
|
setSelfieImage(img);
|
|
@@ -13124,6 +13111,8 @@ var CustomerIdentificationCapture = function CustomerIdentificationCapture(_a) {
|
|
|
13124
13111
|
ref: rawCanvas
|
|
13125
13112
|
}), /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
|
|
13126
13113
|
ref: cropCanvas
|
|
13114
|
+
}), /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
|
|
13115
|
+
ref: resizeCanvas
|
|
13127
13116
|
}), /*#__PURE__*/React__default.createElement(SelfieCapture, {
|
|
13128
13117
|
onSelfieCaptured: onSelfieCaptured,
|
|
13129
13118
|
onExit: onExit,
|