idmission-web-sdk 1.0.102 → 1.0.104
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/customer_flows/DocumentCapture.d.ts +34 -0
- package/dist/components/document_capture/DocumentCaptureGuideOverlay.d.ts +14 -0
- package/dist/components/document_capture/DocumentCaptureWizard.d.ts +14 -0
- package/dist/components/id_capture/IdCapture.d.ts +2 -2
- package/dist/components/id_capture/{DocumentCaptureGuideOverlay.d.ts → IdCaptureGuideOverlay.d.ts} +4 -4
- package/dist/components/id_capture/IdCaptureModelsProvider.d.ts +5 -1
- package/dist/sdk2.cjs.development.js +70 -94
- 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 +70 -94
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +70 -94
- 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/stories/Components/DocumentCaptureGuideOverlay/LicenseBack.stories.d.ts +2 -2
- package/dist/stories/Components/DocumentCaptureGuideOverlay/LicenseFront.stories.d.ts +2 -2
- package/dist/stories/Components/DocumentCaptureGuideOverlay/Passport.stories.d.ts +2 -2
- package/dist/stories/CustomerFlows/DocumentCapture.stories.d.ts +40 -0
- package/dist/themes/index.d.ts +8 -0
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { FC, PropsWithChildren, ReactNode } from 'react';
|
|
2
|
+
import { ThemeInput } from '../../themes';
|
|
3
|
+
import { LangOption } from '../../lib/locales';
|
|
4
|
+
import { SubmissionRequest, SubmissionResponse } from '../../contexts/SubmissionContext';
|
|
5
|
+
import { DocumentCaptureWizardClassNames } from '../document_capture/DocumentCaptureWizard';
|
|
6
|
+
export type DocumentCaptureClassNames = DocumentCaptureWizardClassNames;
|
|
7
|
+
export interface DocumentCaptureProps extends PropsWithChildren {
|
|
8
|
+
/** Language code to use. Supported values: 'auto' (detect based on user's OS), 'en' (English), 'es' (Spanish). Defaults to auto. */
|
|
9
|
+
lang?: LangOption;
|
|
10
|
+
/** A token generated with your IDmission credentials. */
|
|
11
|
+
submissionToken: string;
|
|
12
|
+
/** URL to hit with all API requests. Defaults to the value specified in your decoded `submissionToken`. */
|
|
13
|
+
submissionUrl?: string;
|
|
14
|
+
/** Callback function that fires immediately prior to submission, giving the client application an opportunity to specify custom asynchronous logic that mutates the request before it executes. The submission request is passed in as a parameter and a promise resolving to the updated request should be returned. */
|
|
15
|
+
onBeforeSubmit?: (req: SubmissionRequest) => Promise<SubmissionRequest>;
|
|
16
|
+
/** Callback function that fires when the user has completed the flow instead of making a call to IDmission's servers, allowing customers to specify their own submission logic. Arguments: the request payload that would have been dispatched to IDmission's API, which contains the images/documents/video submitted by the user. Note that when this parameter is supplied, `onComplete` will never fire, and the customer will need to implement their own error handling/retry logic. Use at your own risk! */
|
|
17
|
+
onSubmit?: (req: SubmissionRequest) => void;
|
|
18
|
+
/** Callback function that fires when the user completes the DocumentCapture flow. Arguments: the SubmissionResponse from IDmission's API is passed as an argument to the customer's application for further handling, which indicates whether the user passed the validation check, and the request payload dispatched to IDmission's API, which contains the images submitted by the user. */
|
|
19
|
+
onComplete?: (resp: SubmissionResponse, req: SubmissionRequest) => void;
|
|
20
|
+
/** Callback function that fires when the user clicks the exit button during ID or selfie capture. */
|
|
21
|
+
onExitCapture?: () => void;
|
|
22
|
+
/** Callback function that fires when the user clicks the exit button from the loading overlay, declining to engage with IDmission. Binding this callback results in the cancel button being rendered on the loading overlay. */
|
|
23
|
+
onUserCancel?: () => void;
|
|
24
|
+
aspectRatio?: number;
|
|
25
|
+
instructions?: ReactNode;
|
|
26
|
+
/** Name of an included theme or object containing theme properties. **/
|
|
27
|
+
theme?: ThemeInput;
|
|
28
|
+
/** Object containing any classNames for inner components. **/
|
|
29
|
+
classNames?: DocumentCaptureClassNames;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Render a fullscreen capture component that instructs the user to photograph their document.
|
|
33
|
+
*/
|
|
34
|
+
export declare const DocumentCapture: FC<DocumentCaptureProps>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type DocumentCaptureGuideOverlayClassNames = {
|
|
3
|
+
container?: string;
|
|
4
|
+
};
|
|
5
|
+
export type DocumentCaptureGuideOverlayProps = {
|
|
6
|
+
aspectRatio?: number;
|
|
7
|
+
borderRadius?: number;
|
|
8
|
+
borderColor?: string;
|
|
9
|
+
borderWidth?: number;
|
|
10
|
+
maskColor?: string;
|
|
11
|
+
padding?: number;
|
|
12
|
+
classNames?: DocumentCaptureGuideOverlayClassNames;
|
|
13
|
+
};
|
|
14
|
+
export declare const DocumentCaptureGuideOverlay: ({ aspectRatio, borderRadius, borderColor, borderWidth, maskColor, padding, classNames, }: DocumentCaptureGuideOverlayProps) => React.JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
export type DocumentCaptureWizardClassNames = {
|
|
3
|
+
container?: string;
|
|
4
|
+
cameraFeed?: string;
|
|
5
|
+
};
|
|
6
|
+
export type DocumentCaptureWizardProps = {
|
|
7
|
+
onSuccess?: () => void;
|
|
8
|
+
onExitCapture?: () => void;
|
|
9
|
+
onUserCancel?: () => void;
|
|
10
|
+
aspectRatio?: number;
|
|
11
|
+
instructions?: ReactNode;
|
|
12
|
+
classNames?: DocumentCaptureWizardClassNames;
|
|
13
|
+
};
|
|
14
|
+
export declare const DocumentCaptureWizard: ({ aspectRatio, instructions, classNames, }: DocumentCaptureWizardProps) => React.JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { IdCaptureGuideOverlayClassNames } from './IdCaptureGuideOverlay';
|
|
3
3
|
import { PDF417DetectionResult } from '../../lib/barcode/Native';
|
|
4
4
|
import { CaptureAttemptMetadata } from '../../contexts/SubmissionContext';
|
|
5
5
|
import { IdCapturePrediction } from './IdCaptureModelsProvider';
|
|
@@ -12,7 +12,7 @@ export type IdCaptureAssets = {
|
|
|
12
12
|
};
|
|
13
13
|
export type IdCaptureClassNames = {
|
|
14
14
|
container?: string;
|
|
15
|
-
guides?:
|
|
15
|
+
guides?: IdCaptureGuideOverlayClassNames;
|
|
16
16
|
guidanceMessageContainer?: string;
|
|
17
17
|
guidanceMessage?: string;
|
|
18
18
|
imagePreview?: IdCaptureImagePreviewClassNames;
|
package/dist/components/id_capture/{DocumentCaptureGuideOverlay.d.ts → IdCaptureGuideOverlay.d.ts}
RENAMED
|
@@ -831,7 +831,7 @@ export declare const GuideImage: import("styled-components").IStyledComponent<"w
|
|
|
831
831
|
$height?: number | undefined;
|
|
832
832
|
$padding: number;
|
|
833
833
|
}>>;
|
|
834
|
-
export type
|
|
834
|
+
export type IdCaptureGuideOverlayClassNames = {
|
|
835
835
|
container?: string;
|
|
836
836
|
inner?: string;
|
|
837
837
|
dimmingRegion?: string;
|
|
@@ -845,8 +845,8 @@ export type DocumentCaptureGuideOverlayClassNames = {
|
|
|
845
845
|
image?: string;
|
|
846
846
|
guideText?: string;
|
|
847
847
|
};
|
|
848
|
-
export type
|
|
849
|
-
classNames?:
|
|
848
|
+
export type IdCaptureGuideOverlayProps = {
|
|
849
|
+
classNames?: IdCaptureGuideOverlayClassNames;
|
|
850
850
|
width?: number;
|
|
851
851
|
height?: number;
|
|
852
852
|
padding?: number;
|
|
@@ -859,4 +859,4 @@ export type DocumentCaptureGuideOverlayProps = {
|
|
|
859
859
|
landscapeGuidesImageUrl?: string;
|
|
860
860
|
onClick?: () => void;
|
|
861
861
|
};
|
|
862
|
-
export declare const
|
|
862
|
+
export declare const IdCaptureGuideOverlay: ({ classNames, width, height, padding: userSuppliedPadding, imagePadding: userSuppliedImagePadding, borderWidth, borderColor, isMirrored, instruction, portraitGuidesImageUrl, landscapeGuidesImageUrl, onClick, }: IdCaptureGuideOverlayProps) => ReactElement;
|
|
@@ -16,6 +16,7 @@ export type IdCapturePrediction = {
|
|
|
16
16
|
bestDocumentOrPassport: DetectedObject | undefined;
|
|
17
17
|
bestMrz: DetectedObject | undefined;
|
|
18
18
|
bestPdf417: DetectedObject | undefined;
|
|
19
|
+
documentInBounds: boolean;
|
|
19
20
|
focusScore: number;
|
|
20
21
|
focusThresholdMet: boolean;
|
|
21
22
|
focusPredictionTime: number;
|
|
@@ -28,7 +29,10 @@ export type IdCaptureThresholds = {
|
|
|
28
29
|
passport?: number;
|
|
29
30
|
mrz?: number;
|
|
30
31
|
pdf417?: number;
|
|
31
|
-
focus?:
|
|
32
|
+
focus?: {
|
|
33
|
+
desktop?: number;
|
|
34
|
+
mobile?: number;
|
|
35
|
+
};
|
|
32
36
|
};
|
|
33
37
|
export declare const PREDICTION_POSITIONS: {
|
|
34
38
|
boxes: number;
|
|
@@ -46,7 +46,7 @@ var LanguageDetector__default = /*#__PURE__*/_interopDefaultLegacy(LanguageDetec
|
|
|
46
46
|
var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
|
|
47
47
|
var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
|
|
48
48
|
|
|
49
|
-
var webSdkVersion = '1.0.
|
|
49
|
+
var webSdkVersion = '1.0.104';
|
|
50
50
|
|
|
51
51
|
function getPlatform() {
|
|
52
52
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -1394,9 +1394,10 @@ function isBrowser() {
|
|
|
1394
1394
|
(typeof WorkerGlobalScope !== 'undefined');
|
|
1395
1395
|
}
|
|
1396
1396
|
|
|
1397
|
-
var
|
|
1398
|
-
var
|
|
1399
|
-
var
|
|
1397
|
+
var StyledPageContainer = styled__default['default'](PageContainer)(templateObject_1$t || (templateObject_1$t = tslib.__makeTemplateObject(["\n z-index: 1000;\n"], ["\n z-index: 1000;\n"])));
|
|
1398
|
+
var GuidesContainer = styled__default['default'].div(templateObject_2$h || (templateObject_2$h = tslib.__makeTemplateObject(["\n display: flex;\n flex-flow: column nowrap;\n width: 100%;\n height: 100%;\n"], ["\n display: flex;\n flex-flow: column nowrap;\n width: 100%;\n height: 100%;\n"])));
|
|
1399
|
+
var GuideCenterRow = styled__default['default'].div(templateObject_3$c || (templateObject_3$c = tslib.__makeTemplateObject(["\n position: relative;\n display: flex;\n flex-flow: row nowrap;\n align-items: center;\n justify-items: center;\n box-sizing: border-box;\n max-width: 100%;\n max-height: 100%;\n"], ["\n position: relative;\n display: flex;\n flex-flow: row nowrap;\n align-items: center;\n justify-items: center;\n box-sizing: border-box;\n max-width: 100%;\n max-height: 100%;\n"])));
|
|
1400
|
+
var GuideRegion = styled__default['default'].div(templateObject_4$8 || (templateObject_4$8 = tslib.__makeTemplateObject(["\n display: flex;\n flex-direction: column;\n justify-content: end;\n width: 100%;\n height: 100%;\n flex-grow: 1;\n background: ", ";\n color: ", ";\n text-align: center;\n ", "\n ", "\n"], ["\n display: flex;\n flex-direction: column;\n justify-content: end;\n width: 100%;\n height: 100%;\n flex-grow: 1;\n background: ", ";\n color: ", ";\n text-align: center;\n ", "\n ", "\n"])), function (props) {
|
|
1400
1401
|
var _a, _b, _c, _d;
|
|
1401
1402
|
return (_d = (_c = (_b = (_a = props.theme) === null || _a === void 0 ? void 0 : _a.idCapture) === null || _b === void 0 ? void 0 : _b.guideOverlay) === null || _c === void 0 ? void 0 : _c.backgroundColor) !== null && _d !== void 0 ? _d : 'rgba(0, 0, 0, 0.5)';
|
|
1402
1403
|
}, function (props) {
|
|
@@ -1407,22 +1408,22 @@ var GuideRegion = styled__default['default'].div(templateObject_3$c || (template
|
|
|
1407
1408
|
}, function (props) {
|
|
1408
1409
|
return props.$minHeight ? "min-width: ".concat(props.$minHeight, "px;") : "";
|
|
1409
1410
|
});
|
|
1410
|
-
var GuideCenterRegion = styled__default['default'].div(
|
|
1411
|
+
var GuideCenterRegion = styled__default['default'].div(templateObject_5$3 || (templateObject_5$3 = tslib.__makeTemplateObject(["\n ", "\n box-sizing: border-box;\n"], ["\n ", "\n box-sizing: border-box;\n"])), function (props) {
|
|
1411
1412
|
return props.$isMirrored ? 'transform: scaleX(-1);' : '';
|
|
1412
1413
|
});
|
|
1413
|
-
var GuideCenterBorder = styled__default['default'].div(
|
|
1414
|
+
var GuideCenterBorder = styled__default['default'].div(templateObject_6$2 || (templateObject_6$2 = tslib.__makeTemplateObject(["\n box-sizing: border-box;\n position: relative;\n border: ", ";\n"], ["\n box-sizing: border-box;\n position: relative;\n border: ", ";\n"])), function (props) {
|
|
1414
1415
|
var _a, _b;
|
|
1415
1416
|
return "".concat((_a = props.$borderWidth) !== null && _a !== void 0 ? _a : 4, "px solid ").concat((_b = props.$borderColor) !== null && _b !== void 0 ? _b : 'white');
|
|
1416
1417
|
});
|
|
1417
|
-
var GuideText = styled__default['default'].span(
|
|
1418
|
-
var GuideImage = styled__default['default'].img(
|
|
1418
|
+
var GuideText = styled__default['default'].span(templateObject_7 || (templateObject_7 = tslib.__makeTemplateObject(["\n align-content: center;\n margin-top: 12px;\n margin-bottom: 12px;\n"], ["\n align-content: center;\n margin-top: 12px;\n margin-bottom: 12px;\n"])));
|
|
1419
|
+
var GuideImage = styled__default['default'].img(templateObject_8 || (templateObject_8 = tslib.__makeTemplateObject(["\n display: block;\n padding: ", "px;\n box-sizing: border-box;\n ", "\n ", "\n"], ["\n display: block;\n padding: ", "px;\n box-sizing: border-box;\n ", "\n ", "\n"])), function (props) {
|
|
1419
1420
|
return props.$padding;
|
|
1420
1421
|
}, function (props) {
|
|
1421
1422
|
return props.$width ? "width: ".concat(props.$width, "px;\n max-width: ").concat(props.$width, "px;") : "max-width: none;";
|
|
1422
1423
|
}, function (props) {
|
|
1423
1424
|
return props.$height ? "height: ".concat(props.$height, "px;\n max-height: ").concat(props.$height, "px;") : "max-height: none;";
|
|
1424
1425
|
});
|
|
1425
|
-
var
|
|
1426
|
+
var IdCaptureGuideOverlay = function IdCaptureGuideOverlay(_a) {
|
|
1426
1427
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
1427
1428
|
var _p = _a.classNames,
|
|
1428
1429
|
classNames = _p === void 0 ? {} : _p,
|
|
@@ -1514,7 +1515,6 @@ var DocumentCaptureGuideOverlay = function DocumentCaptureGuideOverlay(_a) {
|
|
|
1514
1515
|
}
|
|
1515
1516
|
}, instruction)))));
|
|
1516
1517
|
};
|
|
1517
|
-
var StyledPageContainer = styled__default['default'](PageContainer)(templateObject_8 || (templateObject_8 = tslib.__makeTemplateObject(["\n z-index: 1000;\n"], ["\n z-index: 1000;\n"])));
|
|
1518
1518
|
var regionClsx$1 = function regionClsx(classNames, which) {
|
|
1519
1519
|
return [classNames.dimmingRegion, classNames["dimmingRegion".concat(which)]].filter(function (v) {
|
|
1520
1520
|
return v;
|
|
@@ -2127,13 +2127,13 @@ function loadFocusModel(url) {
|
|
|
2127
2127
|
case 2:
|
|
2128
2128
|
_e.sent();
|
|
2129
2129
|
zeroes = tf__namespace.zeros([448, 448, 3]);
|
|
2130
|
-
tfInt32 = tf__namespace.cast(zeroes, '
|
|
2130
|
+
tfInt32 = tf__namespace.cast(zeroes, 'float32');
|
|
2131
2131
|
_b = (_a = tf__namespace).tensor4d;
|
|
2132
2132
|
_d = (_c = Array).from;
|
|
2133
2133
|
return [4 /*yield*/, tfInt32.data()];
|
|
2134
2134
|
case 3:
|
|
2135
2135
|
tf4d_ = _b.apply(_a, [_d.apply(_c, [_e.sent()]), [1, 448, 448, 3]]);
|
|
2136
|
-
tf4d = tf__namespace.cast(tf4d_, '
|
|
2136
|
+
tf4d = tf__namespace.cast(tf4d_, 'float32');
|
|
2137
2137
|
return [4 /*yield*/, focusModel.predict(tf4d)];
|
|
2138
2138
|
case 4:
|
|
2139
2139
|
warmupResult = _e.sent();
|
|
@@ -8781,39 +8781,27 @@ var IdCaptureModelsProvider = function IdCaptureModelsProvider(_a) {
|
|
|
8781
8781
|
var _c = React.useState(false),
|
|
8782
8782
|
ready = _c[0],
|
|
8783
8783
|
setReady = _c[1];
|
|
8784
|
-
var _d = React.useState(
|
|
8785
|
-
|
|
8786
|
-
|
|
8787
|
-
var _e = React.useState(0),
|
|
8788
|
-
passportDetectionThreshold = _e[0],
|
|
8789
|
-
setPassportDetectionThreshold = _e[1];
|
|
8790
|
-
var _f = React.useState(0),
|
|
8791
|
-
mrzDetectionThreshold = _f[0],
|
|
8792
|
-
setMrzDetectionThreshold = _f[1];
|
|
8793
|
-
var _g = React.useState(0),
|
|
8794
|
-
pdf417DetectionThreshold = _g[0],
|
|
8795
|
-
setPdf417DetectionThreshold = _g[1];
|
|
8796
|
-
var _h = React.useState(0),
|
|
8797
|
-
focusThreshold = _h[0],
|
|
8798
|
-
setFocusThreshold = _h[1];
|
|
8784
|
+
var _d = React.useState({}),
|
|
8785
|
+
thresholds = _d[0],
|
|
8786
|
+
setThresholds = _d[1];
|
|
8799
8787
|
var working = React.useRef(false);
|
|
8800
8788
|
var onPredictionHandler = React.useRef();
|
|
8801
8789
|
var lastPredictionCanvas = React.useRef(null);
|
|
8790
|
+
var _e = React.useState(0),
|
|
8791
|
+
detectionTime = _e[0],
|
|
8792
|
+
setDetectionTime = _e[1];
|
|
8793
|
+
var _f = React.useState(0),
|
|
8794
|
+
focusPredictionTime = _f[0],
|
|
8795
|
+
setFocusPredictionTime = _f[1];
|
|
8796
|
+
var _g = React.useState(null),
|
|
8797
|
+
loadingError = _g[0],
|
|
8798
|
+
setLoadingError = _g[1];
|
|
8799
|
+
var _h = React.useState(0),
|
|
8800
|
+
bestFrameDetectionScore = _h[0],
|
|
8801
|
+
setBestFrameDetectionScore = _h[1];
|
|
8802
8802
|
var _j = React.useState(0),
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
var _k = React.useState(0),
|
|
8806
|
-
focusPredictionTime = _k[0],
|
|
8807
|
-
setFocusPredictionTime = _k[1];
|
|
8808
|
-
var _l = React.useState(null),
|
|
8809
|
-
loadingError = _l[0],
|
|
8810
|
-
setLoadingError = _l[1];
|
|
8811
|
-
var _m = React.useState(0),
|
|
8812
|
-
bestFrameDetectionScore = _m[0],
|
|
8813
|
-
setBestFrameDetectionScore = _m[1];
|
|
8814
|
-
var _o = React.useState(0),
|
|
8815
|
-
bestFrameFocusScore = _o[0],
|
|
8816
|
-
setBestFrameFocusScore = _o[1];
|
|
8803
|
+
bestFrameFocusScore = _j[0],
|
|
8804
|
+
setBestFrameFocusScore = _j[1];
|
|
8817
8805
|
React.useEffect(function () {
|
|
8818
8806
|
setReady(false);
|
|
8819
8807
|
var ddmUrl = documentDetectionModelUrl || defaultDocumentDetectionModelUrl;
|
|
@@ -8875,25 +8863,9 @@ var IdCaptureModelsProvider = function IdCaptureModelsProvider(_a) {
|
|
|
8875
8863
|
(_a = webGLCanvas.removeEventListener) === null || _a === void 0 ? void 0 : _a.call(webGLCanvas, 'webglcontextlost', reloadModels);
|
|
8876
8864
|
};
|
|
8877
8865
|
}, [documentDetectionModelUrl, focusModelUrl]);
|
|
8878
|
-
var
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
passport: passportDetectionThreshold,
|
|
8882
|
-
mrz: mrzDetectionThreshold,
|
|
8883
|
-
pdf417: pdf417DetectionThreshold,
|
|
8884
|
-
focus: focusThreshold
|
|
8885
|
-
};
|
|
8886
|
-
}, [documentDetectionThreshold, focusThreshold, mrzDetectionThreshold, passportDetectionThreshold, pdf417DetectionThreshold]);
|
|
8887
|
-
var setThresholds = React.useCallback(function (thresholds) {
|
|
8888
|
-
if (thresholds.document) setDocumentDetectionThreshold(thresholds.document);
|
|
8889
|
-
if (thresholds.passport) setPassportDetectionThreshold(thresholds.passport);
|
|
8890
|
-
if (thresholds.mrz) setMrzDetectionThreshold(thresholds.mrz);
|
|
8891
|
-
if (thresholds.pdf417) setPdf417DetectionThreshold(thresholds.pdf417);
|
|
8892
|
-
if (thresholds.focus) setFocusThreshold(thresholds.focus);
|
|
8893
|
-
}, []);
|
|
8894
|
-
var _p = React.useState(0),
|
|
8895
|
-
timesAllZero = _p[0],
|
|
8896
|
-
setTimesAllZero = _p[1];
|
|
8866
|
+
var _k = React.useState(0),
|
|
8867
|
+
timesAllZero = _k[0],
|
|
8868
|
+
setTimesAllZero = _k[1];
|
|
8897
8869
|
var bestPredictionCanvas = React.useRef(null);
|
|
8898
8870
|
var bestFocusScore = React.useRef(0);
|
|
8899
8871
|
var makePrediction = React.useCallback(function (frame) {
|
|
@@ -8977,22 +8949,23 @@ var IdCaptureModelsProvider = function IdCaptureModelsProvider(_a) {
|
|
|
8977
8949
|
ref: bestPredictionCanvas
|
|
8978
8950
|
}));
|
|
8979
8951
|
};
|
|
8952
|
+
var onMobile = isMobile();
|
|
8980
8953
|
function makePredictions(frame, lastPredictionCanvas, thresholds, logPredictions) {
|
|
8981
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
8954
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
8982
8955
|
if (logPredictions === void 0) {
|
|
8983
8956
|
logPredictions = false;
|
|
8984
8957
|
}
|
|
8985
8958
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
8986
|
-
var
|
|
8987
|
-
var
|
|
8988
|
-
return tslib.__generator(this, function (
|
|
8989
|
-
switch (
|
|
8959
|
+
var _o, frameWidth, frameHeight, _q, boxes, scores, labels, time, allZero, detectedObjects, bestDocument, bestPassportPage, bestDocumentScore, passportDetectionScore, passportDetectionThresholdMet, bestDocumentOrPassport, detectionScore, detectionThresholdMet, detectedDocumentType, bestMrz, mrzDetectionScore, mrzDetectionThresholdMet, bestPdf417, pdf417DetectionScore, pdf417DetectionThresholdMet, documentInBounds, boundaryPx, _r, boundaryX, boundaryY, boundaryWidth, boundaryHeight, focusPrediction, focusPredictionTime, focusScore, focusThresholdMet, focusThreshold;
|
|
8960
|
+
var _s;
|
|
8961
|
+
return tslib.__generator(this, function (_t) {
|
|
8962
|
+
switch (_t.label) {
|
|
8990
8963
|
case 0:
|
|
8991
|
-
|
|
8964
|
+
_o = getFrameDimensions(frame), frameWidth = _o[0], frameHeight = _o[1];
|
|
8992
8965
|
drawToCanvas(lastPredictionCanvas, frame);
|
|
8993
8966
|
return [4 /*yield*/, makeDocumentDetectionPredictions(frame, logPredictions)];
|
|
8994
8967
|
case 1:
|
|
8995
|
-
|
|
8968
|
+
_q = _t.sent(), boxes = _q.boxes, scores = _q.scores, labels = _q.labels, time = _q.time;
|
|
8996
8969
|
allZero = boxes.length > 0 && !boxes.some(function (box) {
|
|
8997
8970
|
return box.some(function (n) {
|
|
8998
8971
|
return n > 0;
|
|
@@ -9029,14 +9002,31 @@ function makePredictions(frame, lastPredictionCanvas, thresholds, logPredictions
|
|
|
9029
9002
|
});
|
|
9030
9003
|
pdf417DetectionScore = (_g = bestPdf417 === null || bestPdf417 === void 0 ? void 0 : bestPdf417.score) !== null && _g !== void 0 ? _g : 0;
|
|
9031
9004
|
pdf417DetectionThresholdMet = pdf417DetectionScore >= ((_h = thresholds.pdf417) !== null && _h !== void 0 ? _h : 0);
|
|
9005
|
+
documentInBounds = false;
|
|
9006
|
+
if (bestDocumentOrPassport) {
|
|
9007
|
+
boundaryPx = 20;
|
|
9008
|
+
_r = bestDocumentOrPassport.bbox, boundaryX = _r[0], boundaryY = _r[1], boundaryWidth = _r[2], boundaryHeight = _r[3];
|
|
9009
|
+
boundaryX *= frameWidth;
|
|
9010
|
+
boundaryWidth *= frameWidth;
|
|
9011
|
+
boundaryY *= frameHeight;
|
|
9012
|
+
boundaryHeight *= frameHeight;
|
|
9013
|
+
documentInBounds = boundaryY > boundaryPx &&
|
|
9014
|
+
// Is it valid top edge of ID detected?
|
|
9015
|
+
boundaryY + boundaryHeight + boundaryPx < frameHeight && (
|
|
9016
|
+
// Is it valid bottom edge less than max video height
|
|
9017
|
+
boundaryX > boundaryPx || boundaryX < boundaryPx && boundaryX + boundaryWidth > frameWidth * 0.8) &&
|
|
9018
|
+
// If either the left side visible or if not, right edge of ID should be more than 80% of width.
|
|
9019
|
+
boundaryX + boundaryWidth + boundaryPx < frameWidth; // Valid right edge if it's less than video width.
|
|
9020
|
+
}
|
|
9032
9021
|
focusPrediction = null, focusPredictionTime = 0, focusScore = 0, focusThresholdMet = false;
|
|
9033
|
-
if (!detectionThresholdMet) return [3 /*break*/, 3];
|
|
9022
|
+
if (!(detectionThresholdMet && documentInBounds)) return [3 /*break*/, 3];
|
|
9034
9023
|
return [4 /*yield*/, makeFocusPrediction(frame, bestDocumentOrPassport === null || bestDocumentOrPassport === void 0 ? void 0 : bestDocumentOrPassport.bbox, logPredictions)];
|
|
9035
9024
|
case 2:
|
|
9036
|
-
|
|
9025
|
+
_s = _t.sent(), focusPrediction = _s[0], focusPredictionTime = _s[1];
|
|
9037
9026
|
focusScore = (_j = focusPrediction === null || focusPrediction === void 0 ? void 0 : focusPrediction[1]) !== null && _j !== void 0 ? _j : 0;
|
|
9038
|
-
|
|
9039
|
-
|
|
9027
|
+
focusThreshold = (_m = onMobile ? (_k = thresholds.focus) === null || _k === void 0 ? void 0 : _k.mobile : (_l = thresholds.focus) === null || _l === void 0 ? void 0 : _l.desktop) !== null && _m !== void 0 ? _m : 0;
|
|
9028
|
+
focusThresholdMet = focusScore >= focusThreshold;
|
|
9029
|
+
_t.label = 3;
|
|
9040
9030
|
case 3:
|
|
9041
9031
|
return [2 /*return*/, {
|
|
9042
9032
|
detectedObjects: detectedObjects,
|
|
@@ -9053,6 +9043,7 @@ function makePredictions(frame, lastPredictionCanvas, thresholds, logPredictions
|
|
|
9053
9043
|
bestDocumentOrPassport: bestDocumentOrPassport,
|
|
9054
9044
|
bestMrz: bestMrz,
|
|
9055
9045
|
bestPdf417: bestPdf417,
|
|
9046
|
+
documentInBounds: documentInBounds,
|
|
9056
9047
|
focusScore: focusScore,
|
|
9057
9048
|
focusThresholdMet: focusThresholdMet,
|
|
9058
9049
|
focusPredictionTime: focusPredictionTime,
|
|
@@ -9722,6 +9713,7 @@ var reducer$5 = function reducer(state, action) {
|
|
|
9722
9713
|
bestDocumentOrPassport = _a.bestDocumentOrPassport,
|
|
9723
9714
|
bestMrz = _a.bestMrz,
|
|
9724
9715
|
bestPdf417 = _a.bestPdf417,
|
|
9716
|
+
documentInBounds = _a.documentInBounds,
|
|
9725
9717
|
focusScore = _a.focusScore,
|
|
9726
9718
|
focusThresholdMet = _a.focusThresholdMet,
|
|
9727
9719
|
frameWidth = _a.frameWidth,
|
|
@@ -9735,26 +9727,6 @@ var reducer$5 = function reducer(state, action) {
|
|
|
9735
9727
|
goodFramesThreshold = Math.ceil(3 * frameCaptureRate);
|
|
9736
9728
|
}
|
|
9737
9729
|
}
|
|
9738
|
-
var documentInBounds = false;
|
|
9739
|
-
if (bestDocumentOrPassport) {
|
|
9740
|
-
var boundaryPx = 20;
|
|
9741
|
-
var _b = bestDocumentOrPassport.bbox,
|
|
9742
|
-
boundaryX = _b[0],
|
|
9743
|
-
boundaryY = _b[1],
|
|
9744
|
-
boundaryWidth = _b[2],
|
|
9745
|
-
boundaryHeight = _b[3];
|
|
9746
|
-
boundaryX *= frameWidth;
|
|
9747
|
-
boundaryWidth *= frameWidth;
|
|
9748
|
-
boundaryY *= frameHeight;
|
|
9749
|
-
boundaryHeight *= frameHeight;
|
|
9750
|
-
documentInBounds = boundaryY > boundaryPx &&
|
|
9751
|
-
// Is it valid top edge of ID detected?
|
|
9752
|
-
boundaryY + boundaryHeight + boundaryPx < frameHeight && (
|
|
9753
|
-
// Is it valid bottom edge less than max video height
|
|
9754
|
-
boundaryX > boundaryPx || boundaryX < boundaryPx && boundaryX + boundaryWidth > frameWidth * 0.8) &&
|
|
9755
|
-
// If either the left side visible or if not, right edge of ID should be more than 80% of width.
|
|
9756
|
-
boundaryX + boundaryWidth + boundaryPx < frameWidth; // Valid right edge if it's less than video width.
|
|
9757
|
-
}
|
|
9758
9730
|
var barcodeScanRequired = state.autoCaptureBarcodeRequired === true || state.autoCaptureBarcodeRequired === 'mobile' && isMobile();
|
|
9759
9731
|
var shouldScanBarcode = state.barcodeScanningEnabled && pdf417DetectionThresholdMet && barcodeScanRequired;
|
|
9760
9732
|
var waitingForBarcodeScan = shouldScanBarcode && !state.barcodeResult;
|
|
@@ -9925,7 +9897,9 @@ var IdCapture = function IdCapture(_a) {
|
|
|
9925
9897
|
passport: passportPageDetectionThreshold,
|
|
9926
9898
|
mrz: mrzDetectionScoreThreshold,
|
|
9927
9899
|
pdf417: pdf417DetectionThreshold,
|
|
9928
|
-
focus:
|
|
9900
|
+
focus: {
|
|
9901
|
+
mobile: focusScoreThreshold
|
|
9902
|
+
}
|
|
9929
9903
|
});
|
|
9930
9904
|
}, [requiredDocumentType, autoCaptureScoreThreshold, focusScoreThreshold, mrzDetectionScoreThreshold, autoCaptureGoodFramesRequired, autoCaptureBarcodeRequired, barcodeScanningEnabled, maxBarcodeScanAttempts, passportPageDetectionThreshold, pdf417DetectionThreshold, resetBestFrame, setThresholds]);
|
|
9931
9905
|
var animationFrame = React.useRef(0);
|
|
@@ -10128,7 +10102,7 @@ var IdCapture = function IdCapture(_a) {
|
|
|
10128
10102
|
return /*#__PURE__*/React__default['default'].createElement(PageContainer, {
|
|
10129
10103
|
ref: ref,
|
|
10130
10104
|
className: "flex ".concat((_l = classNames.container) !== null && _l !== void 0 ? _l : '')
|
|
10131
|
-
}, /*#__PURE__*/React__default['default'].createElement(
|
|
10105
|
+
}, /*#__PURE__*/React__default['default'].createElement(IdCaptureGuideOverlay, {
|
|
10132
10106
|
classNames: classNames.guides,
|
|
10133
10107
|
width: width,
|
|
10134
10108
|
height: height,
|
|
@@ -13592,7 +13566,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
13592
13566
|
setThresholds({
|
|
13593
13567
|
document: idCardFrontDetectionThreshold,
|
|
13594
13568
|
passport: 1,
|
|
13595
|
-
focus:
|
|
13569
|
+
focus: {
|
|
13570
|
+
mobile: idCardFrontFocusThreshold
|
|
13571
|
+
}
|
|
13596
13572
|
});
|
|
13597
13573
|
}, [idCardFrontDetectionThreshold, idCardFrontFocusThreshold, setThresholds]);
|
|
13598
13574
|
var _4 = React.useState(0),
|