idmission-web-sdk 1.0.13 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/fallback_flows/SelfieCapture.d.ts +21 -0
- package/dist/components/id_capture/IdCapture.d.ts +11 -1
- package/dist/components/id_capture/IdCaptureWizard.d.ts +3 -0
- package/dist/components/selfie_capture/HighPerformanceSelfieGuidanceModelsProvider.d.ts +1 -0
- package/dist/sdk2.cjs.development.js +201 -65
- 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 +201 -65
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +201 -65
- 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/FallbackFlows/SelfieCapture.stories.d.ts +8 -0
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/components/common/ModelLoadingErrorOverlay.d.ts +0 -5
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { CustomerSuppliedVerbiage } from '../../lib/locales';
|
|
3
|
+
import { LoaderButtonColors } from '../common/LoaderButton';
|
|
4
|
+
export type SelfieCaptureFallbackColors = {
|
|
5
|
+
captureBtn?: LoaderButtonColors;
|
|
6
|
+
doneBtn?: LoaderButtonColors;
|
|
7
|
+
};
|
|
8
|
+
export type SelfieCaptureFallbackVerbiage = {
|
|
9
|
+
headingText?: CustomerSuppliedVerbiage;
|
|
10
|
+
descriptionText?: CustomerSuppliedVerbiage;
|
|
11
|
+
captureBtnText?: CustomerSuppliedVerbiage;
|
|
12
|
+
doneBtnText?: CustomerSuppliedVerbiage;
|
|
13
|
+
doneBtnLoadingText?: CustomerSuppliedVerbiage;
|
|
14
|
+
};
|
|
15
|
+
export type SelfieCaptureFallbackProps = {
|
|
16
|
+
onFinished?: (imageData: string) => void;
|
|
17
|
+
onCapture?: (imageData: string) => void;
|
|
18
|
+
colors?: SelfieCaptureFallbackColors;
|
|
19
|
+
verbiage?: SelfieCaptureFallbackVerbiage;
|
|
20
|
+
};
|
|
21
|
+
export declare const SelfieCaptureFallback: ({ onFinished, onCapture, colors, verbiage: rawVerbiage, }: SelfieCaptureFallbackProps) => ReactElement;
|
|
@@ -12,12 +12,20 @@ export type IdCaptureAssets = {
|
|
|
12
12
|
export type IdCaptureColors = {
|
|
13
13
|
guideBoxUnsatisfiedColor?: string;
|
|
14
14
|
guideBoxSatisfiedColor?: string;
|
|
15
|
+
guidanceMessagesSatisfiedBackgroundColor?: string;
|
|
16
|
+
guidanceMessagesUnsatisfiedBackgroundColor?: string;
|
|
17
|
+
guidanceMessagesSatisfiedTextColor?: string;
|
|
18
|
+
guidanceMessagesUnsatisfiedTextColor?: string;
|
|
15
19
|
};
|
|
16
20
|
export type IdCaptureVerbiage = {
|
|
17
21
|
instructionText?: CustomerSuppliedVerbiage;
|
|
18
22
|
processingIdCardText?: CustomerSuppliedVerbiage;
|
|
19
23
|
capturingText?: CustomerSuppliedVerbiage;
|
|
20
24
|
captureFailedText?: CustomerSuppliedVerbiage;
|
|
25
|
+
guidanceSatisfiedText?: CustomerSuppliedVerbiage;
|
|
26
|
+
guidanceTooBlurryText?: CustomerSuppliedVerbiage;
|
|
27
|
+
guidanceNotCenteredText?: CustomerSuppliedVerbiage;
|
|
28
|
+
guidanceNotDetectedText?: CustomerSuppliedVerbiage;
|
|
21
29
|
};
|
|
22
30
|
export type IdCaptureProps = {
|
|
23
31
|
requiredDocumentType?: DocumentType;
|
|
@@ -31,6 +39,8 @@ export type IdCaptureProps = {
|
|
|
31
39
|
barcodeScanningEnabled?: boolean;
|
|
32
40
|
maxBarcodeScanAttempts?: number;
|
|
33
41
|
focusScoreThreshold?: number;
|
|
42
|
+
guidanceMessage?: string;
|
|
43
|
+
guidanceSatisfied?: boolean;
|
|
34
44
|
onPrediction?: (prediction: IdCapturePrediction) => void;
|
|
35
45
|
onBarcodeScanned?: (result: PDF417DetectionResult) => void;
|
|
36
46
|
onCapture?: (frame: string, width: number, height: number, metadata: CaptureAttemptMetadata) => void;
|
|
@@ -42,4 +52,4 @@ export type IdCaptureProps = {
|
|
|
42
52
|
verbiage?: IdCaptureVerbiage;
|
|
43
53
|
debugMode?: boolean;
|
|
44
54
|
};
|
|
45
|
-
export declare const IdCapture: ({ requiredDocumentType, autoCaptureEnabled, autoCaptureScoreThreshold, autoCaptureGoodFramesRequired, autoCaptureBarcodeRequired, mrzDetectionScoreThreshold, passportPageDetectionThreshold, pdf417DetectionThreshold, focusScoreThreshold, barcodeScanningEnabled, maxBarcodeScanAttempts, onPrediction, onBarcodeScanned, onCapture, onExit, processingScreen, processingDelay, assets, colors, verbiage: rawVerbiage, debugMode, }: IdCaptureProps) => React.ReactElement;
|
|
55
|
+
export declare const IdCapture: ({ requiredDocumentType, autoCaptureEnabled, autoCaptureScoreThreshold, autoCaptureGoodFramesRequired, autoCaptureBarcodeRequired, mrzDetectionScoreThreshold, passportPageDetectionThreshold, pdf417DetectionThreshold, focusScoreThreshold, barcodeScanningEnabled, maxBarcodeScanAttempts, guidanceMessage, guidanceSatisfied, onPrediction, onBarcodeScanned, onCapture, onExit, processingScreen, processingDelay, assets, colors, verbiage: rawVerbiage, debugMode, }: IdCaptureProps) => React.ReactElement;
|
|
@@ -3,6 +3,7 @@ import { IdCaptureAssets, IdCaptureColors, IdCaptureVerbiage } from './IdCapture
|
|
|
3
3
|
import { IdCaptureLoadingOverlayAssets, IdCaptureLoadingOverlayColors, IdCaptureLoadingOverlayVerbiage } from './IdCaptureLoadingOverlay';
|
|
4
4
|
import { FlipIdPromptAssets, FlipIdPromptVerbiage } from './FlipIdPrompt';
|
|
5
5
|
import { IdCaptureSuccessColors, IdCaptureSuccessVerbiage } from './IdCaptureSuccess';
|
|
6
|
+
import { IdCaptureFallbackColors, IdCaptureFallbackVerbiage } from '../fallback_flows/IdCapture';
|
|
6
7
|
export type IdCaptureWizardAssets = {
|
|
7
8
|
documentDetectionModelUrl?: string;
|
|
8
9
|
focusModelUrl?: string;
|
|
@@ -15,6 +16,7 @@ export type IdCaptureWizardAssets = {
|
|
|
15
16
|
export type IdCaptureWizardColors = IdCaptureColors & {
|
|
16
17
|
loadingOverlay?: IdCaptureLoadingOverlayColors;
|
|
17
18
|
success?: IdCaptureSuccessColors;
|
|
19
|
+
fallback?: IdCaptureFallbackColors;
|
|
18
20
|
};
|
|
19
21
|
export type IdCaptureWizardVerbiage = {
|
|
20
22
|
loadingOverlay?: IdCaptureLoadingOverlayVerbiage;
|
|
@@ -23,6 +25,7 @@ export type IdCaptureWizardVerbiage = {
|
|
|
23
25
|
passport?: IdCaptureVerbiage;
|
|
24
26
|
flipIdPrompt?: FlipIdPromptVerbiage;
|
|
25
27
|
success?: IdCaptureSuccessVerbiage;
|
|
28
|
+
fallback?: IdCaptureFallbackVerbiage;
|
|
26
29
|
};
|
|
27
30
|
export type IdCaptureSubmission = {
|
|
28
31
|
idFrontImage: string | null;
|
|
@@ -25,6 +25,7 @@ type HighPerformanceSelfieGuidanceModelsState = {
|
|
|
25
25
|
onPredictionMade: (handler: PredictionHandler) => void;
|
|
26
26
|
canvasRef: MutableRefObject<HTMLCanvasElement | null>;
|
|
27
27
|
ready: boolean;
|
|
28
|
+
error: Error | null;
|
|
28
29
|
};
|
|
29
30
|
export declare const HighPerformanceSelfieGuidanceModelsContext: React.Context<HighPerformanceSelfieGuidanceModelsState>;
|
|
30
31
|
export declare const HighPerformanceSelfieGuidanceModelsProvider: ({ autoStart, children, throttleMs, }: {
|
|
@@ -50,7 +50,7 @@ var useResizeObserver__default = /*#__PURE__*/_interopDefaultLegacy(useResizeObs
|
|
|
50
50
|
var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
|
|
51
51
|
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
|
52
52
|
|
|
53
|
-
var webSdkVersion = '1.0.
|
|
53
|
+
var webSdkVersion = '1.0.15';
|
|
54
54
|
|
|
55
55
|
function getPlatform() {
|
|
56
56
|
return window.platform;
|
|
@@ -9181,6 +9181,19 @@ function useTranslations(verbiage, fallbacks) {
|
|
|
9181
9181
|
}, [fallbacks, i18n.language, t, verbiage]);
|
|
9182
9182
|
}
|
|
9183
9183
|
|
|
9184
|
+
var GuidanceMessageContainer = styled__default['default'].div(templateObject_1$3 || (templateObject_1$3 = tslib.__makeTemplateObject(["\n position: absolute;\n top: calc(", ");\n font-weight: bold;\n width: 100%;\n display: flex;\n"], ["\n position: absolute;\n top: calc(", ");\n font-weight: bold;\n width: 100%;\n display: flex;\n"])), function (_a) {
|
|
9185
|
+
var $top = _a.$top;
|
|
9186
|
+
return $top !== null && $top !== void 0 ? $top : '10vh';
|
|
9187
|
+
});
|
|
9188
|
+
var GuidanceMessage = styled__default['default'].div(templateObject_2$1 || (templateObject_2$1 = tslib.__makeTemplateObject(["\n margin-left: auto;\n margin-right: auto;\n background: ", ";\n color: ", ";\n padding: 10px 12px 8px;\n border-radius: 8px;\n"], ["\n margin-left: auto;\n margin-right: auto;\n background: ", ";\n color: ", ";\n padding: 10px 12px 8px;\n border-radius: 8px;\n"])), function (_a) {
|
|
9189
|
+
var $background = _a.$background;
|
|
9190
|
+
return $background !== null && $background !== void 0 ? $background : '#ccc';
|
|
9191
|
+
}, function (_a) {
|
|
9192
|
+
var $textColor = _a.$textColor;
|
|
9193
|
+
return $textColor !== null && $textColor !== void 0 ? $textColor : 'black';
|
|
9194
|
+
});
|
|
9195
|
+
var templateObject_1$3, templateObject_2$1;
|
|
9196
|
+
|
|
9184
9197
|
var initialState$5 = {
|
|
9185
9198
|
videoWidth: 0,
|
|
9186
9199
|
videoHeight: 0,
|
|
@@ -9258,6 +9271,7 @@ var reducer$5 = function reducer(state, action) {
|
|
|
9258
9271
|
}
|
|
9259
9272
|
var documentInBounds = false;
|
|
9260
9273
|
if (bestDocumentOrPassport) {
|
|
9274
|
+
var boundaryPx = 20;
|
|
9261
9275
|
var _b = bestDocumentOrPassport.bbox,
|
|
9262
9276
|
boundaryX = _b[0],
|
|
9263
9277
|
boundaryY = _b[1],
|
|
@@ -9267,7 +9281,7 @@ var reducer$5 = function reducer(state, action) {
|
|
|
9267
9281
|
boundaryWidth *= frameWidth;
|
|
9268
9282
|
boundaryY *= frameHeight;
|
|
9269
9283
|
boundaryHeight *= frameHeight;
|
|
9270
|
-
documentInBounds = boundaryY >
|
|
9284
|
+
documentInBounds = boundaryY > boundaryPx && boundaryY + boundaryHeight + boundaryPx < frameHeight && (boundaryX > boundaryPx || boundaryX < boundaryPx && boundaryX + boundaryWidth > frameWidth * 0.8) && boundaryX + boundaryWidth + boundaryPx < frameWidth;
|
|
9271
9285
|
}
|
|
9272
9286
|
var barcodeScanRequired = state.autoCaptureBarcodeRequired === true || state.autoCaptureBarcodeRequired === 'mobile' && isMobile();
|
|
9273
9287
|
var shouldScanBarcode = state.barcodeScanningEnabled && pdf417DetectionThresholdMet && barcodeScanRequired;
|
|
@@ -9368,6 +9382,8 @@ var IdCapture = function IdCapture(_a) {
|
|
|
9368
9382
|
barcodeScanningEnabled = _o === void 0 ? true : _o,
|
|
9369
9383
|
_p = _a.maxBarcodeScanAttempts,
|
|
9370
9384
|
maxBarcodeScanAttempts = _p === void 0 ? 10 : _p,
|
|
9385
|
+
guidanceMessage = _a.guidanceMessage,
|
|
9386
|
+
guidanceSatisfied = _a.guidanceSatisfied,
|
|
9371
9387
|
onPrediction = _a.onPrediction,
|
|
9372
9388
|
onBarcodeScanned = _a.onBarcodeScanned,
|
|
9373
9389
|
onCapture = _a.onCapture,
|
|
@@ -9602,11 +9618,17 @@ var IdCapture = function IdCapture(_a) {
|
|
|
9602
9618
|
}, [getBestFrame, onCapture, processingDelay, shouldCapture, state.barcodeResult]);
|
|
9603
9619
|
colors.guideBoxUnsatisfiedColor || (colors.guideBoxUnsatisfiedColor = 'white');
|
|
9604
9620
|
colors.guideBoxSatisfiedColor || (colors.guideBoxSatisfiedColor = 'green');
|
|
9621
|
+
colors.guidanceMessagesSatisfiedBackgroundColor || (colors.guidanceMessagesSatisfiedBackgroundColor = 'green');
|
|
9622
|
+
colors.guidanceMessagesSatisfiedTextColor || (colors.guidanceMessagesSatisfiedTextColor = 'white');
|
|
9605
9623
|
var verbiage = useTranslations(rawVerbiage, {
|
|
9606
9624
|
instructionText: 'Scan the front of ID',
|
|
9607
9625
|
processingIdCardText: 'ID card front captured.',
|
|
9608
9626
|
capturingText: 'Capturing...',
|
|
9609
|
-
captureFailedText: 'Capture failed!'
|
|
9627
|
+
captureFailedText: 'Capture failed!',
|
|
9628
|
+
guidanceSatisfiedText: 'Document detected, hold still...',
|
|
9629
|
+
guidanceTooBlurryText: 'Document out of focus – try improving the lighting',
|
|
9630
|
+
guidanceNotCenteredText: 'Document is not centered',
|
|
9631
|
+
guidanceNotDetectedText: 'Document not detected'
|
|
9610
9632
|
});
|
|
9611
9633
|
var debugScalingDetails = useDebugScalingDetails({
|
|
9612
9634
|
enabled: debugMode,
|
|
@@ -9615,6 +9637,9 @@ var IdCapture = function IdCapture(_a) {
|
|
|
9615
9637
|
videoWidth: state.videoWidth,
|
|
9616
9638
|
videoHeight: state.videoHeight
|
|
9617
9639
|
});
|
|
9640
|
+
var satisfied = state.isGoodFrame;
|
|
9641
|
+
if (typeof guidanceSatisfied === 'boolean') satisfied = guidanceSatisfied;
|
|
9642
|
+
guidanceMessage || (guidanceMessage = satisfied ? verbiage.guidanceSatisfiedText : !state.documentDetectionThresholdMet ? verbiage.guidanceNotDetectedText : !state.documentInBounds ? verbiage.guidanceNotCenteredText : !state.focusThresholdMet ? verbiage.guidanceTooBlurryText : '');
|
|
9618
9643
|
if (processingFrame) {
|
|
9619
9644
|
return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, processingScreen, imageURL && /*#__PURE__*/React__default['default'].createElement(IdCaptureImagePreview, {
|
|
9620
9645
|
text: verbiage.processingIdCardText,
|
|
@@ -9642,7 +9667,12 @@ var IdCapture = function IdCapture(_a) {
|
|
|
9642
9667
|
landscapeGuidesImageUrl: assets.landscapeGuidesImageUrl,
|
|
9643
9668
|
isMirrored: !((_c = cameraRef.current) === null || _c === void 0 ? void 0 : _c.isRearFacing),
|
|
9644
9669
|
borderColor: state.isGoodFrame ? colors.guideBoxSatisfiedColor : colors.guideBoxUnsatisfiedColor
|
|
9645
|
-
}),
|
|
9670
|
+
}), guidanceMessage !== '' && /*#__PURE__*/React__default['default'].createElement(GuidanceMessageContainer, {
|
|
9671
|
+
"$top": "82.5vh"
|
|
9672
|
+
}, /*#__PURE__*/React__default['default'].createElement(GuidanceMessage, {
|
|
9673
|
+
"$background": satisfied ? colors.guidanceMessagesSatisfiedBackgroundColor : colors.guidanceMessagesUnsatisfiedBackgroundColor,
|
|
9674
|
+
"$textColor": satisfied ? colors.guidanceMessagesSatisfiedTextColor : colors.guidanceMessagesUnsatisfiedTextColor
|
|
9675
|
+
}, guidanceMessage)), debugMode && state.detectedObjects.length > 0 && /*#__PURE__*/React__default['default'].createElement(ObjectDetectionDebugOverlay, {
|
|
9646
9676
|
"$flipX": !((_d = cameraRef.current) === null || _d === void 0 ? void 0 : _d.isRearFacing)
|
|
9647
9677
|
}, state.detectedObjects.map(function (obj, i) {
|
|
9648
9678
|
var _a;
|
|
@@ -10083,10 +10113,10 @@ var CameraVideoTag = function CameraVideoTag() {
|
|
|
10083
10113
|
"$isRearFacing": (_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.isRearFacing
|
|
10084
10114
|
});
|
|
10085
10115
|
};
|
|
10086
|
-
var FullscreenVideoTag = styled__default['default'].video(templateObject_1$
|
|
10116
|
+
var FullscreenVideoTag = styled__default['default'].video(templateObject_1$2 || (templateObject_1$2 = tslib.__makeTemplateObject(["\n transform: ", ";\n min-width: 100%;\n min-height: 100%;\n width: auto;\n height: auto;\n object-fit: cover;\n"], ["\n transform: ", ";\n min-width: 100%;\n min-height: 100%;\n width: auto;\n height: auto;\n object-fit: cover;\n"])), function (props) {
|
|
10087
10117
|
return props.$isRearFacing ? '' : 'scaleX(-1)';
|
|
10088
10118
|
});
|
|
10089
|
-
var templateObject_1$
|
|
10119
|
+
var templateObject_1$2;
|
|
10090
10120
|
|
|
10091
10121
|
function useShowSuccessScreen(skipSuccessScreen, successScreenReady, onDoneCallback) {
|
|
10092
10122
|
var _this = this;
|
|
@@ -10451,7 +10481,9 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
10451
10481
|
imageData: imageData
|
|
10452
10482
|
}
|
|
10453
10483
|
});
|
|
10454
|
-
}
|
|
10484
|
+
},
|
|
10485
|
+
colors: colors.fallback,
|
|
10486
|
+
verbiage: verbiage.fallback
|
|
10455
10487
|
});
|
|
10456
10488
|
}
|
|
10457
10489
|
return /*#__PURE__*/React__default['default'].createElement(PageContainer, {
|
|
@@ -10570,23 +10602,6 @@ var FaceCaptureGuideOverlay = function FaceCaptureGuideOverlay(_a) {
|
|
|
10570
10602
|
}));
|
|
10571
10603
|
};
|
|
10572
10604
|
|
|
10573
|
-
var ModelLoadingErrorOverlay = function ModelLoadingErrorOverlay(_a) {
|
|
10574
|
-
var error = _a.error;
|
|
10575
|
-
return /*#__PURE__*/React__default['default'].createElement(OverlayContainer, null, /*#__PURE__*/React__default['default'].createElement(OverlayInner, {
|
|
10576
|
-
style: {
|
|
10577
|
-
justifyContent: 'center'
|
|
10578
|
-
}
|
|
10579
|
-
}, /*#__PURE__*/React__default['default'].createElement("h3", {
|
|
10580
|
-
style: {
|
|
10581
|
-
marginBottom: 8
|
|
10582
|
-
}
|
|
10583
|
-
}, "We're sorry, an unexpected error has occurred."), /*#__PURE__*/React__default['default'].createElement("p", {
|
|
10584
|
-
style: {
|
|
10585
|
-
marginBottom: 0
|
|
10586
|
-
}
|
|
10587
|
-
}, /*#__PURE__*/React__default['default'].createElement("code", null, error.message))));
|
|
10588
|
-
};
|
|
10589
|
-
|
|
10590
10605
|
var NUM_KEYPOINTS = 6;
|
|
10591
10606
|
var GREEN = '#32EEDB';
|
|
10592
10607
|
var RED = '#FF2C35';
|
|
@@ -10663,7 +10678,8 @@ var HighPerformanceSelfieGuidanceModelsContext = /*#__PURE__*/React.createContex
|
|
|
10663
10678
|
canvasRef: {
|
|
10664
10679
|
current: null
|
|
10665
10680
|
},
|
|
10666
|
-
ready: false
|
|
10681
|
+
ready: false,
|
|
10682
|
+
error: null
|
|
10667
10683
|
});
|
|
10668
10684
|
var HighPerformanceSelfieGuidanceModelsProvider = function HighPerformanceSelfieGuidanceModelsProvider(_a) {
|
|
10669
10685
|
var _b = _a.autoStart,
|
|
@@ -10686,8 +10702,8 @@ var HighPerformanceSelfieGuidanceModelsProvider = function HighPerformanceSelfie
|
|
|
10686
10702
|
var rafId = React.useRef(0);
|
|
10687
10703
|
var loopId = React.useRef(0);
|
|
10688
10704
|
var _f = React.useState(null),
|
|
10689
|
-
|
|
10690
|
-
|
|
10705
|
+
error = _f[0],
|
|
10706
|
+
setError = _f[1];
|
|
10691
10707
|
React.useEffect(function () {
|
|
10692
10708
|
(function () {
|
|
10693
10709
|
return tslib.__awaiter(void 0, void 0, void 0, function () {
|
|
@@ -10706,7 +10722,7 @@ var HighPerformanceSelfieGuidanceModelsProvider = function HighPerformanceSelfie
|
|
|
10706
10722
|
return [3, 4];
|
|
10707
10723
|
case 3:
|
|
10708
10724
|
e_1 = _b.sent();
|
|
10709
|
-
|
|
10725
|
+
setError(e_1);
|
|
10710
10726
|
return [3, 4];
|
|
10711
10727
|
case 4:
|
|
10712
10728
|
setReady(true);
|
|
@@ -10839,29 +10855,15 @@ var HighPerformanceSelfieGuidanceModelsProvider = function HighPerformanceSelfie
|
|
|
10839
10855
|
stop: stop,
|
|
10840
10856
|
ready: ready,
|
|
10841
10857
|
canvasRef: canvasRef,
|
|
10842
|
-
onPredictionMade: onPredictionMade
|
|
10858
|
+
onPredictionMade: onPredictionMade,
|
|
10859
|
+
error: error
|
|
10843
10860
|
};
|
|
10844
|
-
}, [onPredictionMade, ready, start, stop]);
|
|
10861
|
+
}, [error, onPredictionMade, ready, start, stop]);
|
|
10845
10862
|
return /*#__PURE__*/React__namespace.createElement(HighPerformanceSelfieGuidanceModelsContext.Provider, {
|
|
10846
10863
|
value: value
|
|
10847
|
-
},
|
|
10848
|
-
error: loadingError
|
|
10849
|
-
}) : children);
|
|
10864
|
+
}, children);
|
|
10850
10865
|
};
|
|
10851
10866
|
|
|
10852
|
-
var GuidanceMessageContainer = styled__default['default'].div(templateObject_1$2 || (templateObject_1$2 = tslib.__makeTemplateObject(["\n position: absolute;\n top: calc(", ");\n font-weight: bold;\n width: 100%;\n display: flex;\n"], ["\n position: absolute;\n top: calc(", ");\n font-weight: bold;\n width: 100%;\n display: flex;\n"])), function (_a) {
|
|
10853
|
-
var $top = _a.$top;
|
|
10854
|
-
return $top !== null && $top !== void 0 ? $top : '10vh';
|
|
10855
|
-
});
|
|
10856
|
-
var GuidanceMessage = styled__default['default'].div(templateObject_2$1 || (templateObject_2$1 = tslib.__makeTemplateObject(["\n margin-left: auto;\n margin-right: auto;\n background: ", ";\n color: ", ";\n padding: 10px 12px 8px;\n border-radius: 8px;\n"], ["\n margin-left: auto;\n margin-right: auto;\n background: ", ";\n color: ", ";\n padding: 10px 12px 8px;\n border-radius: 8px;\n"])), function (_a) {
|
|
10857
|
-
var $background = _a.$background;
|
|
10858
|
-
return $background !== null && $background !== void 0 ? $background : '#ccc';
|
|
10859
|
-
}, function (_a) {
|
|
10860
|
-
var $textColor = _a.$textColor;
|
|
10861
|
-
return $textColor !== null && $textColor !== void 0 ? $textColor : 'black';
|
|
10862
|
-
});
|
|
10863
|
-
var templateObject_1$2, templateObject_2$1;
|
|
10864
|
-
|
|
10865
10867
|
var useTimeout = function useTimeout(durationMs, onTimeout, timeoutAverted, shouldWaitLonger) {
|
|
10866
10868
|
var _a = React.useState(false),
|
|
10867
10869
|
timedOut = _a[0],
|
|
@@ -10898,6 +10900,86 @@ var useTimeout = function useTimeout(durationMs, onTimeout, timeoutAverted, shou
|
|
|
10898
10900
|
};
|
|
10899
10901
|
};
|
|
10900
10902
|
|
|
10903
|
+
var SelfieCaptureFallback = function SelfieCaptureFallback(_a) {
|
|
10904
|
+
var onFinished = _a.onFinished,
|
|
10905
|
+
onCapture = _a.onCapture,
|
|
10906
|
+
_b = _a.colors,
|
|
10907
|
+
colors = _b === void 0 ? {} : _b,
|
|
10908
|
+
_c = _a.verbiage,
|
|
10909
|
+
rawVerbiage = _c === void 0 ? {} : _c;
|
|
10910
|
+
var _d = React.useState(null),
|
|
10911
|
+
image = _d[0],
|
|
10912
|
+
setImage = _d[1];
|
|
10913
|
+
var fileInput = React.useRef(null);
|
|
10914
|
+
var _e = React.useState(false),
|
|
10915
|
+
loading = _e[0],
|
|
10916
|
+
setLoading = _e[1];
|
|
10917
|
+
var verbiage = useTranslations(rawVerbiage, {
|
|
10918
|
+
headingText: "We're having some trouble.",
|
|
10919
|
+
descriptionText: 'On-device capture guidance failed, please capture a selfie manually.',
|
|
10920
|
+
captureBtnText: 'Capture',
|
|
10921
|
+
doneBtnText: 'Done',
|
|
10922
|
+
doneBtnLoadingText: 'Verifying...'
|
|
10923
|
+
});
|
|
10924
|
+
return /*#__PURE__*/React__default['default'].createElement(OverlayContainer, null, /*#__PURE__*/React__default['default'].createElement(OverlayInner, {
|
|
10925
|
+
style: {
|
|
10926
|
+
justifyContent: 'center'
|
|
10927
|
+
}
|
|
10928
|
+
}, /*#__PURE__*/React__default['default'].createElement("h3", {
|
|
10929
|
+
style: {
|
|
10930
|
+
marginBottom: 8
|
|
10931
|
+
}
|
|
10932
|
+
}, verbiage.headingText), /*#__PURE__*/React__default['default'].createElement("p", {
|
|
10933
|
+
style: {
|
|
10934
|
+
marginBottom: 8
|
|
10935
|
+
}
|
|
10936
|
+
}, verbiage.descriptionText), image && /*#__PURE__*/React__default['default'].createElement(OverlayImageWrapper, {
|
|
10937
|
+
style: {
|
|
10938
|
+
marginTop: 32
|
|
10939
|
+
}
|
|
10940
|
+
}, /*#__PURE__*/React__default['default'].createElement("img", {
|
|
10941
|
+
src: image,
|
|
10942
|
+
alt: ""
|
|
10943
|
+
})), /*#__PURE__*/React__default['default'].createElement("input", {
|
|
10944
|
+
ref: fileInput,
|
|
10945
|
+
type: "file",
|
|
10946
|
+
accept: "image/*",
|
|
10947
|
+
hidden: true,
|
|
10948
|
+
onChange: function onChange(e) {
|
|
10949
|
+
var _a;
|
|
10950
|
+
var file = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
10951
|
+
if (!file) return;
|
|
10952
|
+
var reader = new FileReader();
|
|
10953
|
+
reader.addEventListener('load', function (e) {
|
|
10954
|
+
var _a;
|
|
10955
|
+
var imageData = (_a = e.target) === null || _a === void 0 ? void 0 : _a.result;
|
|
10956
|
+
setImage(imageData);
|
|
10957
|
+
onCapture === null || onCapture === void 0 ? void 0 : onCapture(imageData);
|
|
10958
|
+
});
|
|
10959
|
+
reader.readAsDataURL(file);
|
|
10960
|
+
}
|
|
10961
|
+
}), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
10962
|
+
style: {
|
|
10963
|
+
marginTop: 32
|
|
10964
|
+
}
|
|
10965
|
+
}, !image && /*#__PURE__*/React__default['default'].createElement(LoaderButton, {
|
|
10966
|
+
colors: colors.captureBtn,
|
|
10967
|
+
finished: true,
|
|
10968
|
+
onClick: function onClick() {
|
|
10969
|
+
var _a;
|
|
10970
|
+
(_a = fileInput.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
10971
|
+
}
|
|
10972
|
+
}, verbiage.captureBtnText), image && /*#__PURE__*/React__default['default'].createElement(LoaderButton, {
|
|
10973
|
+
key: loading ? 'loading-btn' : 'ready-btn',
|
|
10974
|
+
colors: colors.doneBtn,
|
|
10975
|
+
finished: !loading,
|
|
10976
|
+
onClick: function onClick() {
|
|
10977
|
+
setLoading(true);
|
|
10978
|
+
onFinished === null || onFinished === void 0 ? void 0 : onFinished(image);
|
|
10979
|
+
}
|
|
10980
|
+
}, loading ? verbiage.doneBtnLoadingText : verbiage.doneBtnText))));
|
|
10981
|
+
};
|
|
10982
|
+
|
|
10901
10983
|
var initialState$3 = {
|
|
10902
10984
|
videoWidth: 0,
|
|
10903
10985
|
videoHeight: 0,
|
|
@@ -11022,7 +11104,9 @@ var SelfieCapture = function SelfieCapture(_a) {
|
|
|
11022
11104
|
cameraRef = _l.cameraRef,
|
|
11023
11105
|
cameraReady = _l.cameraReady,
|
|
11024
11106
|
videoRef = _l.videoRef;
|
|
11025
|
-
var
|
|
11107
|
+
var _m = React.useContext(HighPerformanceSelfieGuidanceModelsContext),
|
|
11108
|
+
onPredictionMade = _m.onPredictionMade,
|
|
11109
|
+
guidanceError = _m.error;
|
|
11026
11110
|
React.useEffect(function () {
|
|
11027
11111
|
if (cameraReady && videoRef.current && videoRef.current.videoWidth !== 0) {
|
|
11028
11112
|
dispatch({
|
|
@@ -11044,9 +11128,9 @@ var SelfieCapture = function SelfieCapture(_a) {
|
|
|
11044
11128
|
});
|
|
11045
11129
|
});
|
|
11046
11130
|
}, [onPredictionMade]);
|
|
11047
|
-
var
|
|
11048
|
-
captureReady =
|
|
11049
|
-
setCaptureReady =
|
|
11131
|
+
var _o = React.useState(false),
|
|
11132
|
+
captureReady = _o[0],
|
|
11133
|
+
setCaptureReady = _o[1];
|
|
11050
11134
|
React.useEffect(function () {
|
|
11051
11135
|
var timer;
|
|
11052
11136
|
if (state.faceReady) {
|
|
@@ -11079,9 +11163,9 @@ var SelfieCapture = function SelfieCapture(_a) {
|
|
|
11079
11163
|
});
|
|
11080
11164
|
})();
|
|
11081
11165
|
}, [captureReady, onSelfieCaptured, state.faces, videoRef]);
|
|
11082
|
-
var
|
|
11083
|
-
timedOut =
|
|
11084
|
-
timeoutStartedAt =
|
|
11166
|
+
var _p = useTimeout(timeoutDurationMs, onTimeout),
|
|
11167
|
+
timedOut = _p.timedOut,
|
|
11168
|
+
timeoutStartedAt = _p.timeoutStartedAt;
|
|
11085
11169
|
var debugScalingDetails = useDebugScalingDetails({
|
|
11086
11170
|
enabled: debugMode,
|
|
11087
11171
|
pageWidth: width,
|
|
@@ -11102,9 +11186,12 @@ var SelfieCapture = function SelfieCapture(_a) {
|
|
|
11102
11186
|
guidanceMoveForwardText: 'Move forward...',
|
|
11103
11187
|
guidanceMoveToCenterText: 'Move to the center...'
|
|
11104
11188
|
});
|
|
11105
|
-
guidanceMessage || (guidanceMessage = state.faceReady ? verbiage.guidanceHoldStillText : state.faceLookingAway ? verbiage.guidanceLookStraightText : state.faceTooClose ? verbiage.guidanceMoveBackText : state.faceTooFar ? verbiage.guidanceMoveForwardText : state.faceNotCentered ? verbiage.guidanceMoveToCenterText : '');
|
|
11106
11189
|
var satisfied = state.faceReady;
|
|
11107
11190
|
if (typeof guidanceSatisfied === 'boolean') satisfied = guidanceSatisfied;
|
|
11191
|
+
guidanceMessage || (guidanceMessage = satisfied ? verbiage.guidanceHoldStillText : state.faceLookingAway ? verbiage.guidanceLookStraightText : state.faceTooClose ? verbiage.guidanceMoveBackText : state.faceTooFar ? verbiage.guidanceMoveForwardText : state.faceNotCentered ? verbiage.guidanceMoveToCenterText : '');
|
|
11192
|
+
if (guidanceError) {
|
|
11193
|
+
return /*#__PURE__*/React__default['default'].createElement(SelfieCaptureFallback, null);
|
|
11194
|
+
}
|
|
11108
11195
|
return /*#__PURE__*/React__default['default'].createElement(PageContainer, {
|
|
11109
11196
|
ref: ref,
|
|
11110
11197
|
className: "flex"
|
|
@@ -11145,6 +11232,7 @@ var initialState$2 = {
|
|
|
11145
11232
|
timesLivenessCheckFailed: 0
|
|
11146
11233
|
};
|
|
11147
11234
|
var reducer$2 = function reducer(state, action) {
|
|
11235
|
+
var _a, _b;
|
|
11148
11236
|
switch (action.type) {
|
|
11149
11237
|
case 'livenessReady':
|
|
11150
11238
|
{
|
|
@@ -11165,12 +11253,12 @@ var reducer$2 = function reducer(state, action) {
|
|
|
11165
11253
|
});
|
|
11166
11254
|
case 'livenessChecked':
|
|
11167
11255
|
{
|
|
11168
|
-
var
|
|
11169
|
-
|
|
11170
|
-
statusCode =
|
|
11171
|
-
statusMessage =
|
|
11172
|
-
errorData =
|
|
11173
|
-
resultData =
|
|
11256
|
+
var _c = action.payload.response,
|
|
11257
|
+
_d = _c.status,
|
|
11258
|
+
statusCode = _d.statusCode,
|
|
11259
|
+
statusMessage = _d.statusMessage,
|
|
11260
|
+
errorData = _d.errorData,
|
|
11261
|
+
resultData = _c.resultData;
|
|
11174
11262
|
if (statusCode !== '000') {
|
|
11175
11263
|
return tslib.__assign(tslib.__assign({}, state), {
|
|
11176
11264
|
requestState: 'ERROR',
|
|
@@ -11191,8 +11279,8 @@ var reducer$2 = function reducer(state, action) {
|
|
|
11191
11279
|
timesLivenessCheckFailed += 1;
|
|
11192
11280
|
}
|
|
11193
11281
|
return tslib.__assign(tslib.__assign({}, state), {
|
|
11194
|
-
frame: action.payload.frame,
|
|
11195
|
-
face: action.payload.face,
|
|
11282
|
+
frame: (_a = action.payload.frame) !== null && _a !== void 0 ? _a : null,
|
|
11283
|
+
face: (_b = action.payload.face) !== null && _b !== void 0 ? _b : null,
|
|
11196
11284
|
imageUrl: action.payload.imageUrl,
|
|
11197
11285
|
requestState: requestState,
|
|
11198
11286
|
faceLive: faceLive,
|
|
@@ -11227,6 +11315,7 @@ var FaceLivenessCapture = function FaceLivenessCapture(_a) {
|
|
|
11227
11315
|
var _e = React.useContext(SubmissionContext),
|
|
11228
11316
|
checkLiveness = _e.checkLiveness,
|
|
11229
11317
|
submissionError = _e.submissionError;
|
|
11318
|
+
var modelsError = React.useContext(HighPerformanceSelfieGuidanceModelsContext).error;
|
|
11230
11319
|
var _f = React.useReducer(reducer$2, initialState$2),
|
|
11231
11320
|
state = _f[0],
|
|
11232
11321
|
dispatch = _f[1];
|
|
@@ -11295,21 +11384,68 @@ var FaceLivenessCapture = function FaceLivenessCapture(_a) {
|
|
|
11295
11384
|
});
|
|
11296
11385
|
})();
|
|
11297
11386
|
}, [checkLiveness, face, frame, isReady, submissionError]);
|
|
11387
|
+
var onFallbackImageCaptured = React.useCallback(function (imageUrl) {
|
|
11388
|
+
return tslib.__awaiter(void 0, void 0, void 0, function () {
|
|
11389
|
+
var response, _a, e_2;
|
|
11390
|
+
return tslib.__generator(this, function (_b) {
|
|
11391
|
+
switch (_b.label) {
|
|
11392
|
+
case 0:
|
|
11393
|
+
dispatch({
|
|
11394
|
+
type: 'livenessChecking'
|
|
11395
|
+
});
|
|
11396
|
+
_b.label = 1;
|
|
11397
|
+
case 1:
|
|
11398
|
+
_b.trys.push([1, 4,, 5]);
|
|
11399
|
+
_a = checkLiveness;
|
|
11400
|
+
return [4, dataUrlToBase64(imageUrl)];
|
|
11401
|
+
case 2:
|
|
11402
|
+
return [4, _a.apply(void 0, [_b.sent()])];
|
|
11403
|
+
case 3:
|
|
11404
|
+
response = _b.sent();
|
|
11405
|
+
dispatch({
|
|
11406
|
+
type: 'livenessChecked',
|
|
11407
|
+
payload: {
|
|
11408
|
+
imageUrl: imageUrl,
|
|
11409
|
+
response: response
|
|
11410
|
+
}
|
|
11411
|
+
});
|
|
11412
|
+
return [3, 5];
|
|
11413
|
+
case 4:
|
|
11414
|
+
e_2 = _b.sent();
|
|
11415
|
+
dispatch({
|
|
11416
|
+
type: 'livenessCheckFailed',
|
|
11417
|
+
payload: {
|
|
11418
|
+
error: e_2
|
|
11419
|
+
}
|
|
11420
|
+
});
|
|
11421
|
+
return [3, 5];
|
|
11422
|
+
case 5:
|
|
11423
|
+
return [2];
|
|
11424
|
+
}
|
|
11425
|
+
});
|
|
11426
|
+
});
|
|
11427
|
+
}, [checkLiveness]);
|
|
11298
11428
|
React.useEffect(function () {
|
|
11299
11429
|
if (isPassed && state.imageUrl) onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(state.imageUrl);
|
|
11300
11430
|
}, [onSuccess, state.imageUrl, isPassed]);
|
|
11301
11431
|
React.useEffect(function () {
|
|
11302
|
-
|
|
11432
|
+
var allowedFailures = modelsError ? 1 : 2;
|
|
11433
|
+
if (state.timesLivenessCheckFailed >= allowedFailures) {
|
|
11303
11434
|
onTimeout === null || onTimeout === void 0 ? void 0 : onTimeout();
|
|
11304
11435
|
}
|
|
11305
|
-
}, [onTimeout, state.timesLivenessCheckFailed]);
|
|
11306
|
-
useTimeout(timeoutDurationMs, onTimeout, state.requestState === 'PASSED', state.requestState === 'IN_PROGRESS');
|
|
11436
|
+
}, [modelsError, onTimeout, state.timesLivenessCheckFailed]);
|
|
11437
|
+
useTimeout(timeoutDurationMs, onTimeout, state.requestState === 'PASSED' || !!modelsError, state.requestState === 'IN_PROGRESS');
|
|
11307
11438
|
var verbiage = useTranslations(rawVerbiage, {
|
|
11308
11439
|
guidanceRemoveEyeCoveringsText: 'Please remove your eye coverings (sunglasses, eye patch, etc.)...',
|
|
11309
11440
|
guidanceRemoveHeadCoveringsText: 'Please remove your head coverings (hat, scarf, etc.)...',
|
|
11310
11441
|
guidanceRemoveMaskText: 'Please remove your mask...'
|
|
11311
11442
|
});
|
|
11312
11443
|
var guidanceMessage = state.eyeCoveringDetected ? verbiage.guidanceRemoveEyeCoveringsText : state.headCoveringDetected ? verbiage.guidanceRemoveHeadCoveringsText : state.maskDetected ? verbiage.guidanceRemoveMaskText : undefined;
|
|
11444
|
+
if (modelsError) {
|
|
11445
|
+
return /*#__PURE__*/React__default['default'].createElement(SelfieCaptureFallback, {
|
|
11446
|
+
onFinished: onFallbackImageCaptured
|
|
11447
|
+
});
|
|
11448
|
+
}
|
|
11313
11449
|
return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(InvisibleCanvas, {
|
|
11314
11450
|
ref: rawCanvas
|
|
11315
11451
|
}), /*#__PURE__*/React__default['default'].createElement(InvisibleCanvas, {
|