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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Frame } from './getFrameDimensions';
|
|
2
2
|
import { DetectedObjectBox } from '../models/DocumentDetection';
|
|
3
3
|
import { Face } from '../models/FaceDetection';
|
|
4
|
-
export declare function cropToShoulders(rawCanvas: HTMLCanvasElement | null, cropCanvas: HTMLCanvasElement | null, frame: ImageData, face: Face): string;
|
|
4
|
+
export declare function cropToShoulders(rawCanvas: HTMLCanvasElement | null, cropCanvas: HTMLCanvasElement | null, resizeCanvas: HTMLCanvasElement | null, frame: ImageData, face: Face, quality?: number, maxHeight?: number): string;
|
|
5
5
|
export declare function cropToDetectedObjectBox(frame: Frame, box: DetectedObjectBox, canvas?: HTMLCanvasElement): HTMLCanvasElement;
|
|
@@ -49,7 +49,7 @@ var LanguageDetector__default = /*#__PURE__*/_interopDefaultLegacy(LanguageDetec
|
|
|
49
49
|
var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
|
|
50
50
|
var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
|
|
51
51
|
|
|
52
|
-
var webSdkVersion = '2.1.
|
|
52
|
+
var webSdkVersion = '2.1.9';
|
|
53
53
|
|
|
54
54
|
function getPlatform() {
|
|
55
55
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -493,7 +493,8 @@ var SessionIdMissingOverlay = function SessionIdMissingOverlay() {
|
|
|
493
493
|
}, "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.")));
|
|
494
494
|
};
|
|
495
495
|
|
|
496
|
-
var SessionValidationFailedOverlay = function SessionValidationFailedOverlay() {
|
|
496
|
+
var SessionValidationFailedOverlay = function SessionValidationFailedOverlay(_a) {
|
|
497
|
+
var message = _a.message;
|
|
497
498
|
return /*#__PURE__*/React__default['default'].createElement(OverlayContainer, null, /*#__PURE__*/React__default['default'].createElement(OverlayInner$2, {
|
|
498
499
|
style: {
|
|
499
500
|
justifyContent: 'center'
|
|
@@ -506,7 +507,7 @@ var SessionValidationFailedOverlay = function SessionValidationFailedOverlay() {
|
|
|
506
507
|
style: {
|
|
507
508
|
marginBottom: 0
|
|
508
509
|
}
|
|
509
|
-
}, "Required property ", /*#__PURE__*/React__default['default'].createElement("code", null, "sessionId"), " is not valid."), /*#__PURE__*/React__default['default'].createElement("p", {
|
|
510
|
+
}, "Required property ", /*#__PURE__*/React__default['default'].createElement("code", null, "sessionId"), " is not valid", message && " (".concat(message, ")"), "."), /*#__PURE__*/React__default['default'].createElement("p", {
|
|
510
511
|
style: {
|
|
511
512
|
lineHeight: '1.5rem'
|
|
512
513
|
}
|
|
@@ -614,7 +615,7 @@ var Spinner = styled__default['default'].div(templateObject_1$D || (templateObje
|
|
|
614
615
|
var templateObject_1$D;
|
|
615
616
|
|
|
616
617
|
var defaultAuthUrl = 'https://portal-api.idmission.com';
|
|
617
|
-
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'];
|
|
618
|
+
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'];
|
|
618
619
|
var initialState$5 = {
|
|
619
620
|
authUrl: defaultAuthUrl,
|
|
620
621
|
sessionCheckState: 'READY'
|
|
@@ -632,6 +633,7 @@ var reducer$5 = function reducer(state, action) {
|
|
|
632
633
|
sessionCheckState: action.payload
|
|
633
634
|
});
|
|
634
635
|
case 'setError':
|
|
636
|
+
console.log('setting error', action.payload);
|
|
635
637
|
return tslib.__assign(tslib.__assign({}, state), {
|
|
636
638
|
sessionCheckState: 'ERROR',
|
|
637
639
|
authError: action.payload
|
|
@@ -696,11 +698,11 @@ function useAuthReducer(authUrl, sessionId) {
|
|
|
696
698
|
});
|
|
697
699
|
(function () {
|
|
698
700
|
return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
699
|
-
var resp, valid, e_1;
|
|
700
|
-
return tslib.__generator(this, function (
|
|
701
|
-
switch (
|
|
701
|
+
var resp, _a, valid, message, e_1;
|
|
702
|
+
return tslib.__generator(this, function (_b) {
|
|
703
|
+
switch (_b.label) {
|
|
702
704
|
case 0:
|
|
703
|
-
|
|
705
|
+
_b.trys.push([0, 3,, 4]);
|
|
704
706
|
return [4 /*yield*/, fetch("".concat(authUrl, "/portal.sessions.v1.SessionsService/ValidateSession"), {
|
|
705
707
|
method: 'POST',
|
|
706
708
|
headers: {
|
|
@@ -711,17 +713,23 @@ function useAuthReducer(authUrl, sessionId) {
|
|
|
711
713
|
})
|
|
712
714
|
})];
|
|
713
715
|
case 1:
|
|
714
|
-
resp =
|
|
716
|
+
resp = _b.sent();
|
|
715
717
|
return [4 /*yield*/, resp.json()];
|
|
716
718
|
case 2:
|
|
717
|
-
|
|
719
|
+
_a = _b.sent(), valid = _a.valid, message = _a.message;
|
|
720
|
+
if (!resp.ok) {
|
|
721
|
+
dispatch({
|
|
722
|
+
type: 'setError',
|
|
723
|
+
payload: new SessionValidationFailedError(new Error(message), authUrl)
|
|
724
|
+
});
|
|
725
|
+
}
|
|
718
726
|
dispatch({
|
|
719
727
|
type: 'setCheckState',
|
|
720
728
|
payload: valid ? 'PASSED' : 'FAILED'
|
|
721
729
|
});
|
|
722
730
|
return [3 /*break*/, 4];
|
|
723
731
|
case 3:
|
|
724
|
-
e_1 =
|
|
732
|
+
e_1 = _b.sent();
|
|
725
733
|
dispatch({
|
|
726
734
|
type: 'setError',
|
|
727
735
|
payload: new SessionValidationFailedError(e_1, authUrl)
|
|
@@ -744,18 +752,21 @@ function useAuthContext() {
|
|
|
744
752
|
return [state, dispatch];
|
|
745
753
|
}
|
|
746
754
|
function AuthProvider(_a) {
|
|
747
|
-
var _b
|
|
748
|
-
|
|
755
|
+
var _b;
|
|
756
|
+
var _c = _a.authUrl,
|
|
757
|
+
authUrl = _c === void 0 ? defaultAuthUrl : _c,
|
|
749
758
|
sessionId = _a.sessionId,
|
|
750
759
|
children = _a.children;
|
|
751
|
-
var
|
|
752
|
-
state =
|
|
753
|
-
dispatch =
|
|
760
|
+
var _d = useAuthReducer(authUrl, sessionId),
|
|
761
|
+
state = _d[0],
|
|
762
|
+
dispatch = _d[1];
|
|
754
763
|
if (state.sessionCheckState === 'MISSING') {
|
|
755
764
|
return /*#__PURE__*/React__default['default'].createElement(SessionIdMissingOverlay, null);
|
|
756
765
|
}
|
|
757
766
|
if (state.sessionCheckState === 'FAILED') {
|
|
758
|
-
return /*#__PURE__*/React__default['default'].createElement(SessionValidationFailedOverlay,
|
|
767
|
+
return /*#__PURE__*/React__default['default'].createElement(SessionValidationFailedOverlay, {
|
|
768
|
+
message: (_b = state.authError) === null || _b === void 0 ? void 0 : _b.message
|
|
769
|
+
});
|
|
759
770
|
}
|
|
760
771
|
if (state.sessionCheckState === 'AUTH_URL_NOT_ALLOWED') {
|
|
761
772
|
return /*#__PURE__*/React__default['default'].createElement(AuthUrlNotAllowedOverlay, null);
|
|
@@ -2278,39 +2289,15 @@ function preloadVisionRuntime() {
|
|
|
2278
2289
|
});
|
|
2279
2290
|
}
|
|
2280
2291
|
|
|
2281
|
-
function
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
function isMobile(nav) {
|
|
2285
|
-
if (nav || _isNavigatorDefined()) {
|
|
2286
|
-
if (!nav) {
|
|
2287
|
-
nav = navigator;
|
|
2288
|
-
}
|
|
2289
|
-
if (nav.product === 'ReactNative') {
|
|
2290
|
-
return true;
|
|
2291
|
-
}
|
|
2292
|
-
var a = nav.userAgent || nav.vendor || (
|
|
2293
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2294
|
-
// @ts-ignore
|
|
2295
|
-
typeof window !== 'undefined' ? window.opera : '');
|
|
2296
|
-
if (!a) {
|
|
2297
|
-
var navAny = nav;
|
|
2298
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2299
|
-
// @ts-ignore
|
|
2300
|
-
return navAny.userAgentData && navAny.userAgentData.mobile;
|
|
2301
|
-
}
|
|
2302
|
-
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) ||
|
|
2303
|
-
// tslint:disable-next-line:max-line-length
|
|
2304
|
-
/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));
|
|
2292
|
+
function cropToShoulders(rawCanvas, cropCanvas, resizeCanvas, frame, face, quality, maxHeight) {
|
|
2293
|
+
if (quality === void 0) {
|
|
2294
|
+
quality = 0.92;
|
|
2305
2295
|
}
|
|
2306
|
-
return
|
|
2307
|
-
}
|
|
2308
|
-
|
|
2309
|
-
function cropToShoulders(rawCanvas, cropCanvas, frame, face) {
|
|
2310
|
-
if (!rawCanvas || !cropCanvas) return '';
|
|
2296
|
+
if (!rawCanvas || !cropCanvas || !resizeCanvas) return '';
|
|
2311
2297
|
var rawCtx = rawCanvas.getContext('2d');
|
|
2312
2298
|
var cropCtx = cropCanvas.getContext('2d');
|
|
2313
|
-
|
|
2299
|
+
var resizeCtx = resizeCanvas.getContext('2d');
|
|
2300
|
+
if (!rawCtx || !cropCtx || !resizeCtx) throw new Error('could not get 2d context');
|
|
2314
2301
|
rawCanvas.width = frame.width;
|
|
2315
2302
|
rawCanvas.height = frame.height;
|
|
2316
2303
|
rawCtx.putImageData(frame, 0, 0);
|
|
@@ -2320,7 +2307,7 @@ function cropToShoulders(rawCanvas, cropCanvas, frame, face) {
|
|
|
2320
2307
|
var frameHeight = frame.height;
|
|
2321
2308
|
var xPadding = frameHeight * 0.6 - width;
|
|
2322
2309
|
var xPos = Math.max(0, xMin - xPadding / 2);
|
|
2323
|
-
if (
|
|
2310
|
+
if (frame.height > frame.width) {
|
|
2324
2311
|
cropCanvas.width = frame.width;
|
|
2325
2312
|
cropCanvas.height = frame.height;
|
|
2326
2313
|
cropCtx.drawImage(rawCanvas, 0, 0, cropCanvas.width, cropCanvas.height);
|
|
@@ -2329,9 +2316,14 @@ function cropToShoulders(rawCanvas, cropCanvas, frame, face) {
|
|
|
2329
2316
|
cropCanvas.height = frame.height;
|
|
2330
2317
|
cropCtx.drawImage(rawCanvas, xPos, 0, cropCanvas.width, cropCanvas.height, 0, 0, cropCanvas.width, cropCanvas.height);
|
|
2331
2318
|
}
|
|
2332
|
-
|
|
2319
|
+
resizeCanvas.height = maxHeight !== null && maxHeight !== void 0 ? maxHeight : cropCanvas.height;
|
|
2320
|
+
resizeCanvas.width = cropCanvas.width * (resizeCanvas.height / cropCanvas.height);
|
|
2321
|
+
resizeCtx === null || resizeCtx === void 0 ? void 0 : resizeCtx.drawImage(cropCanvas, 0, 0, resizeCanvas.width, resizeCanvas.height);
|
|
2322
|
+
var dataURL = resizeCanvas.toDataURL('image/jpeg', quality);
|
|
2323
|
+
log('cropToShoulders size', new TextEncoder().encode(dataURL).length);
|
|
2333
2324
|
clearCanvas(rawCanvas);
|
|
2334
2325
|
clearCanvas(cropCanvas);
|
|
2326
|
+
clearCanvas(resizeCanvas);
|
|
2335
2327
|
return dataURL;
|
|
2336
2328
|
}
|
|
2337
2329
|
function cropToDetectedObjectBox(frame, box, canvas) {
|
|
@@ -3664,6 +3656,34 @@ function FocusModelProvider(_a) {
|
|
|
3664
3656
|
}), children);
|
|
3665
3657
|
}
|
|
3666
3658
|
|
|
3659
|
+
function _isNavigatorDefined() {
|
|
3660
|
+
return typeof navigator !== 'undefined' && navigator != null;
|
|
3661
|
+
}
|
|
3662
|
+
function isMobile(nav) {
|
|
3663
|
+
if (nav || _isNavigatorDefined()) {
|
|
3664
|
+
if (!nav) {
|
|
3665
|
+
nav = navigator;
|
|
3666
|
+
}
|
|
3667
|
+
if (nav.product === 'ReactNative') {
|
|
3668
|
+
return true;
|
|
3669
|
+
}
|
|
3670
|
+
var a = nav.userAgent || nav.vendor || (
|
|
3671
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3672
|
+
// @ts-ignore
|
|
3673
|
+
typeof window !== 'undefined' ? window.opera : '');
|
|
3674
|
+
if (!a) {
|
|
3675
|
+
var navAny = nav;
|
|
3676
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3677
|
+
// @ts-ignore
|
|
3678
|
+
return navAny.userAgentData && navAny.userAgentData.mobile;
|
|
3679
|
+
}
|
|
3680
|
+
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) ||
|
|
3681
|
+
// tslint:disable-next-line:max-line-length
|
|
3682
|
+
/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));
|
|
3683
|
+
}
|
|
3684
|
+
return false;
|
|
3685
|
+
}
|
|
3686
|
+
|
|
3667
3687
|
var onMobile = isMobile();
|
|
3668
3688
|
var defaultIdCaptureThresholds = {
|
|
3669
3689
|
detection: defaultDocumentDetectionThresholds,
|
|
@@ -7943,9 +7963,6 @@ var templateObject_1$j, templateObject_2$d, templateObject_3$c, templateObject_4
|
|
|
7943
7963
|
var initialState$3 = {
|
|
7944
7964
|
videoWidth: 0,
|
|
7945
7965
|
videoHeight: 0,
|
|
7946
|
-
capturing: false,
|
|
7947
|
-
captured: false,
|
|
7948
|
-
captureFailed: false,
|
|
7949
7966
|
frame: null,
|
|
7950
7967
|
faces: [],
|
|
7951
7968
|
faceNotCentered: false,
|
|
@@ -7953,36 +7970,12 @@ var initialState$3 = {
|
|
|
7953
7970
|
faceTooClose: false,
|
|
7954
7971
|
faceTooFar: false,
|
|
7955
7972
|
faceReady: false,
|
|
7956
|
-
faceReadyAt: null
|
|
7957
|
-
goodFramesCount: 0,
|
|
7958
|
-
goodFramesThreshold: 1,
|
|
7959
|
-
goodFramesThresholdMet: false
|
|
7973
|
+
faceReadyAt: null
|
|
7960
7974
|
};
|
|
7961
7975
|
var reducer$3 = function reducer(state, action) {
|
|
7962
7976
|
switch (action.type) {
|
|
7963
7977
|
case 'configure':
|
|
7964
|
-
return tslib.__assign(tslib.__assign({}, state),
|
|
7965
|
-
videoWidth: action.payload.videoWidth,
|
|
7966
|
-
videoHeight: action.payload.videoHeight
|
|
7967
|
-
});
|
|
7968
|
-
case 'capturing':
|
|
7969
|
-
return tslib.__assign(tslib.__assign({}, state), {
|
|
7970
|
-
capturing: true,
|
|
7971
|
-
captured: false,
|
|
7972
|
-
captureFailed: false
|
|
7973
|
-
});
|
|
7974
|
-
case 'captured':
|
|
7975
|
-
return tslib.__assign(tslib.__assign({}, state), {
|
|
7976
|
-
capturing: false,
|
|
7977
|
-
captured: true,
|
|
7978
|
-
captureFailed: false
|
|
7979
|
-
});
|
|
7980
|
-
case 'captureFailed':
|
|
7981
|
-
return tslib.__assign(tslib.__assign({}, state), {
|
|
7982
|
-
capturing: false,
|
|
7983
|
-
captured: false,
|
|
7984
|
-
captureFailed: true
|
|
7985
|
-
});
|
|
7978
|
+
return tslib.__assign(tslib.__assign({}, state), action.payload);
|
|
7986
7979
|
case 'facesDetected':
|
|
7987
7980
|
{
|
|
7988
7981
|
var faces = action.payload.faces;
|
|
@@ -7991,8 +7984,7 @@ var reducer$3 = function reducer(state, action) {
|
|
|
7991
7984
|
faceLookingAway = false,
|
|
7992
7985
|
faceTooClose = false,
|
|
7993
7986
|
faceTooFar = false,
|
|
7994
|
-
faceReadyAt = state.faceReadyAt
|
|
7995
|
-
goodFramesCount = state.goodFramesCount;
|
|
7987
|
+
faceReadyAt = state.faceReadyAt;
|
|
7996
7988
|
if (face) {
|
|
7997
7989
|
// calculate centroids
|
|
7998
7990
|
var vCX = state.videoWidth / 2;
|
|
@@ -8018,7 +8010,6 @@ var reducer$3 = function reducer(state, action) {
|
|
|
8018
8010
|
var faceReady = !faceNotCentered && !faceLookingAway && !faceTooClose && !faceTooFar;
|
|
8019
8011
|
if (!faceReady) {
|
|
8020
8012
|
faceReadyAt = null;
|
|
8021
|
-
goodFramesCount = 0;
|
|
8022
8013
|
} else if (!state.faceReady) {
|
|
8023
8014
|
faceReadyAt = new Date();
|
|
8024
8015
|
}
|
|
@@ -8029,8 +8020,7 @@ var reducer$3 = function reducer(state, action) {
|
|
|
8029
8020
|
faceTooClose: faceTooClose,
|
|
8030
8021
|
faceTooFar: faceTooFar,
|
|
8031
8022
|
faceReady: faceReady,
|
|
8032
|
-
faceReadyAt: faceReadyAt
|
|
8033
|
-
goodFramesCount: goodFramesCount
|
|
8023
|
+
faceReadyAt: faceReadyAt
|
|
8034
8024
|
});
|
|
8035
8025
|
}
|
|
8036
8026
|
}
|
|
@@ -8082,16 +8072,14 @@ var SelfieCapture = function SelfieCapture(_a) {
|
|
|
8082
8072
|
});
|
|
8083
8073
|
}
|
|
8084
8074
|
}, [cameraReady, videoRef]);
|
|
8085
|
-
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
}
|
|
8092
|
-
});
|
|
8075
|
+
onPredictionMade(useDebounce.useThrottledCallback(function (prediction) {
|
|
8076
|
+
dispatch({
|
|
8077
|
+
type: 'facesDetected',
|
|
8078
|
+
payload: {
|
|
8079
|
+
faces: prediction
|
|
8080
|
+
}
|
|
8093
8081
|
});
|
|
8094
|
-
},
|
|
8082
|
+
}, 16));
|
|
8095
8083
|
var _p = React.useState(false),
|
|
8096
8084
|
captureReady = _p[0],
|
|
8097
8085
|
setCaptureReady = _p[1];
|
|
@@ -8110,22 +8098,14 @@ var SelfieCapture = function SelfieCapture(_a) {
|
|
|
8110
8098
|
};
|
|
8111
8099
|
}, [onGuidanceNotSatisfied, onGuidanceSatisfied, state.faceReady]);
|
|
8112
8100
|
React.useEffect(function () {
|
|
8113
|
-
(
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
8117
|
-
|
|
8118
|
-
|
|
8119
|
-
|
|
8120
|
-
|
|
8121
|
-
imageData = ctx.getImageData(0, 0, videoRef.current.videoWidth, videoRef.current.videoHeight);
|
|
8122
|
-
onSelfieCaptured === null || onSelfieCaptured === void 0 ? void 0 : onSelfieCaptured(imageData, state.faces[0]);
|
|
8123
|
-
clearCanvas(lastPredictionCanvas.current);
|
|
8124
|
-
}
|
|
8125
|
-
return [2 /*return*/];
|
|
8126
|
-
});
|
|
8127
|
-
});
|
|
8128
|
-
})();
|
|
8101
|
+
if (captureReady && videoRef.current && lastPredictionCanvas.current && state.faces.length > 0) {
|
|
8102
|
+
drawToCanvas(lastPredictionCanvas.current, videoRef.current);
|
|
8103
|
+
var ctx = lastPredictionCanvas.current.getContext('2d');
|
|
8104
|
+
if (!ctx) return;
|
|
8105
|
+
var imageData = ctx.getImageData(0, 0, videoRef.current.videoWidth, videoRef.current.videoHeight);
|
|
8106
|
+
onSelfieCaptured === null || onSelfieCaptured === void 0 ? void 0 : onSelfieCaptured(imageData, state.faces[0]);
|
|
8107
|
+
clearCanvas(lastPredictionCanvas.current);
|
|
8108
|
+
}
|
|
8129
8109
|
}, [captureReady, onSelfieCaptured, state.faces, videoRef]);
|
|
8130
8110
|
var _q = useTimeout(timeoutDurationMs, onTimeout),
|
|
8131
8111
|
timedOut = _q.timedOut,
|
|
@@ -8174,7 +8154,7 @@ var SelfieCapture = function SelfieCapture(_a) {
|
|
|
8174
8154
|
scaling: debugScalingDetails,
|
|
8175
8155
|
color: satisfied ? 'green' : 'red'
|
|
8176
8156
|
});
|
|
8177
|
-
}))), debugMode && ( /*#__PURE__*/React__default['default'].createElement(DebugStatsPane, null, cameraRef.current ? ( /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, "\u2705 Camera: ", cameraRef.current.label, " (", cameraRef.current.width, "x", cameraRef.current.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React__default['default'].createElement("br", null), !state.faceNotCentered ? '✅' : '❌', " Face Centered", /*#__PURE__*/React__default['default'].createElement("br", null), !state.faceTooClose && !state.faceTooFar ? '✅' : '❌', " Face", ' ', state.faceTooClose ? 'Too Close' : state.faceTooFar ? 'Too Far' : 'Distance Correct', /*#__PURE__*/React__default['default'].createElement("br", null), !state.faceLookingAway ? '✅' : '❌', " Face Looking Forward", /*#__PURE__*/React__default['default'].createElement("br", null),
|
|
8157
|
+
}))), debugMode && ( /*#__PURE__*/React__default['default'].createElement(DebugStatsPane, null, cameraRef.current ? ( /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, "\u2705 Camera: ", cameraRef.current.label, " (", cameraRef.current.width, "x", cameraRef.current.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React__default['default'].createElement("br", null), !state.faceNotCentered ? '✅' : '❌', " Face Centered", /*#__PURE__*/React__default['default'].createElement("br", null), !state.faceTooClose && !state.faceTooFar ? '✅' : '❌', " Face", ' ', state.faceTooClose ? 'Too Close' : state.faceTooFar ? 'Too Far' : 'Distance Correct', /*#__PURE__*/React__default['default'].createElement("br", null), !state.faceLookingAway ? '✅' : '❌', " Face Looking Forward", /*#__PURE__*/React__default['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['default'].createElement(ExitCaptureButton, {
|
|
8178
8158
|
onClick: onExit,
|
|
8179
8159
|
className: classNames.exitCaptureBtn
|
|
8180
8160
|
}));
|
|
@@ -8294,6 +8274,7 @@ var FaceLivenessCapture = function FaceLivenessCapture(_a) {
|
|
|
8294
8274
|
setImageUrl = _m[1];
|
|
8295
8275
|
var rawCanvas = React.useRef(null);
|
|
8296
8276
|
var cropCanvas = React.useRef(null);
|
|
8277
|
+
var resizeCanvas = React.useRef(null);
|
|
8297
8278
|
var theme = styled.useTheme();
|
|
8298
8279
|
var onSelfieCaptured = React.useCallback(function (frame, face) {
|
|
8299
8280
|
onCapture === null || onCapture === void 0 ? void 0 : onCapture();
|
|
@@ -8322,7 +8303,7 @@ var FaceLivenessCapture = function FaceLivenessCapture(_a) {
|
|
|
8322
8303
|
switch (_b.label) {
|
|
8323
8304
|
case 0:
|
|
8324
8305
|
_b.trys.push([0, 3,, 4]);
|
|
8325
|
-
imageUrl_1 = cropToShoulders(rawCanvas.current, cropCanvas.current, frame, face);
|
|
8306
|
+
imageUrl_1 = cropToShoulders(rawCanvas.current, cropCanvas.current, resizeCanvas.current, frame, face, 0.92, 500);
|
|
8326
8307
|
setImageUrl(imageUrl_1);
|
|
8327
8308
|
_a = checkLiveness;
|
|
8328
8309
|
return [4 /*yield*/, dataUrlToBase64(imageUrl_1)];
|
|
@@ -8435,6 +8416,8 @@ var FaceLivenessCapture = function FaceLivenessCapture(_a) {
|
|
|
8435
8416
|
ref: rawCanvas
|
|
8436
8417
|
}), /*#__PURE__*/React__default['default'].createElement(InvisibleCanvas, {
|
|
8437
8418
|
ref: cropCanvas
|
|
8419
|
+
}), /*#__PURE__*/React__default['default'].createElement(InvisibleCanvas, {
|
|
8420
|
+
ref: resizeCanvas
|
|
8438
8421
|
}), /*#__PURE__*/React__default['default'].createElement(SelfieCapture, {
|
|
8439
8422
|
onSelfieCaptured: onSelfieCaptured,
|
|
8440
8423
|
onExit: onExit,
|
|
@@ -12529,6 +12512,7 @@ var CustomerVerificationCapture = function CustomerVerificationCapture(_a) {
|
|
|
12529
12512
|
setImageUrl = _k[1];
|
|
12530
12513
|
var rawCanvas = React.useRef(null);
|
|
12531
12514
|
var cropCanvas = React.useRef(null);
|
|
12515
|
+
var resizeCanvas = React.useRef(null);
|
|
12532
12516
|
var onSelfieCaptured = React.useCallback(function (frame, face) {
|
|
12533
12517
|
dispatch({
|
|
12534
12518
|
type: 'verificationReady',
|
|
@@ -12541,7 +12525,7 @@ var CustomerVerificationCapture = function CustomerVerificationCapture(_a) {
|
|
|
12541
12525
|
var isReady = state.requestState === 'CAPTURED';
|
|
12542
12526
|
React.useEffect(function () {
|
|
12543
12527
|
if (!frame || !face || submissionError) return;
|
|
12544
|
-
var imageUrl = cropToShoulders(rawCanvas.current, cropCanvas.current, frame, face);
|
|
12528
|
+
var imageUrl = cropToShoulders(rawCanvas.current, cropCanvas.current, resizeCanvas.current, frame, face);
|
|
12545
12529
|
setImageUrl(imageUrl);
|
|
12546
12530
|
dataUrlToBase64(imageUrl).then(function (img) {
|
|
12547
12531
|
setSelfieImage(img);
|
|
@@ -12604,6 +12588,8 @@ var CustomerVerificationCapture = function CustomerVerificationCapture(_a) {
|
|
|
12604
12588
|
ref: rawCanvas
|
|
12605
12589
|
}), /*#__PURE__*/React__default['default'].createElement(InvisibleCanvas, {
|
|
12606
12590
|
ref: cropCanvas
|
|
12591
|
+
}), /*#__PURE__*/React__default['default'].createElement(InvisibleCanvas, {
|
|
12592
|
+
ref: resizeCanvas
|
|
12607
12593
|
}), /*#__PURE__*/React__default['default'].createElement(SelfieCapture, {
|
|
12608
12594
|
onSelfieCaptured: onSelfieCaptured,
|
|
12609
12595
|
onExit: onExit,
|
|
@@ -13082,6 +13068,7 @@ var CustomerIdentificationCapture = function CustomerIdentificationCapture(_a) {
|
|
|
13082
13068
|
setImageUrl = _k[1];
|
|
13083
13069
|
var rawCanvas = React.useRef(null);
|
|
13084
13070
|
var cropCanvas = React.useRef(null);
|
|
13071
|
+
var resizeCanvas = React.useRef(null);
|
|
13085
13072
|
var onSelfieCaptured = React.useCallback(function (frame, face) {
|
|
13086
13073
|
dispatch({
|
|
13087
13074
|
type: 'identificationReady',
|
|
@@ -13096,7 +13083,7 @@ var CustomerIdentificationCapture = function CustomerIdentificationCapture(_a) {
|
|
|
13096
13083
|
var isReady = state.requestState === 'CAPTURED';
|
|
13097
13084
|
React.useEffect(function () {
|
|
13098
13085
|
if (!frame || !face || submissionError) return;
|
|
13099
|
-
var imageUrl = cropToShoulders(rawCanvas.current, cropCanvas.current, frame, face);
|
|
13086
|
+
var imageUrl = cropToShoulders(rawCanvas.current, cropCanvas.current, resizeCanvas.current, frame, face);
|
|
13100
13087
|
setImageUrl(imageUrl);
|
|
13101
13088
|
dataUrlToBase64(imageUrl).then(function (img) {
|
|
13102
13089
|
setSelfieImage(img);
|
|
@@ -13159,6 +13146,8 @@ var CustomerIdentificationCapture = function CustomerIdentificationCapture(_a) {
|
|
|
13159
13146
|
ref: rawCanvas
|
|
13160
13147
|
}), /*#__PURE__*/React__default['default'].createElement(InvisibleCanvas, {
|
|
13161
13148
|
ref: cropCanvas
|
|
13149
|
+
}), /*#__PURE__*/React__default['default'].createElement(InvisibleCanvas, {
|
|
13150
|
+
ref: resizeCanvas
|
|
13162
13151
|
}), /*#__PURE__*/React__default['default'].createElement(SelfieCapture, {
|
|
13163
13152
|
onSelfieCaptured: onSelfieCaptured,
|
|
13164
13153
|
onExit: onExit,
|