idmission-web-sdk 2.2.100 → 2.2.102
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/id_capture/IdCapture.d.ts.map +1 -1
- package/dist/components/id_capture/IdCaptureFitGuide.d.ts.map +1 -1
- package/dist/components/id_capture/IdCaptureGuideOverlay.d.ts.map +1 -1
- package/dist/components/id_capture/IdCaptureGuides.d.ts +1 -1
- package/dist/components/id_capture/IdCaptureGuides.d.ts.map +1 -1
- package/dist/components/id_capture/IdCaptureLoadingOverlayDefault.d.ts.map +1 -1
- package/dist/components/id_capture/IdCaptureOrUploadScreen.d.ts.map +1 -1
- package/dist/components/id_capture/IdCaptureStateProvider.d.ts +22 -5
- package/dist/components/id_capture/IdCaptureStateProvider.d.ts.map +1 -1
- package/dist/components/id_capture/IdCaptureWizard.d.ts.map +1 -1
- package/dist/components/id_capture/OverrideWrongDocumentTypeGuidanceDialog.d.ts.map +1 -1
- package/dist/components/id_capture/ScalingCameraFeed.d.ts.map +1 -1
- package/dist/sdk2.cjs.development.js +241 -235
- 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 +242 -236
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +544 -312
- 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,12 +8,13 @@ import { Upload } from 'tus-js-client';
|
|
|
8
8
|
import SparkMD5 from 'spark-md5';
|
|
9
9
|
import useResizeObserver from 'use-resize-observer';
|
|
10
10
|
import { ImageSegmenter, FilesetResolver, ImageClassifier, FaceDetector, ObjectDetector } from '@mediapipe/tasks-vision';
|
|
11
|
-
import { createStore, useStore } from 'zustand';
|
|
11
|
+
import { createStore, useStore, create } from 'zustand';
|
|
12
12
|
import { useDebouncedCallback, useThrottledCallback } from 'use-debounce';
|
|
13
|
+
import { devtools } from 'zustand/middleware';
|
|
14
|
+
import { useShallow } from 'zustand/react/shallow';
|
|
13
15
|
import { createPortal } from 'react-dom';
|
|
14
16
|
import LanguageDetector from 'i18next-browser-languagedetector';
|
|
15
17
|
import i18n from 'i18next';
|
|
16
|
-
import { useShallow } from 'zustand/react/shallow';
|
|
17
18
|
import SignatureCanvas from 'react-signature-canvas';
|
|
18
19
|
|
|
19
20
|
/******************************************************************************
|
|
@@ -203,7 +204,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
203
204
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
204
205
|
};
|
|
205
206
|
|
|
206
|
-
var webSdkVersion = '2.2.
|
|
207
|
+
var webSdkVersion = '2.2.102';
|
|
207
208
|
|
|
208
209
|
function getPlatform() {
|
|
209
210
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -4419,31 +4420,35 @@ var initialState$4 = {
|
|
|
4419
4420
|
requestedDocumentType: 'idCardFront',
|
|
4420
4421
|
allowSinglePageIdCapture: false,
|
|
4421
4422
|
allowIdCardBackToFrontCapture: false,
|
|
4423
|
+
allowUploadingDocumentsFromStorage: false,
|
|
4422
4424
|
isUploadingDocumentsFromStorage: false,
|
|
4423
4425
|
uploadingDocumentsType: null,
|
|
4424
4426
|
operationStartedAt: null,
|
|
4425
|
-
captureStartedAt: null
|
|
4427
|
+
captureStartedAt: null,
|
|
4428
|
+
dispatch: function dispatch() {
|
|
4429
|
+
return null;
|
|
4430
|
+
}
|
|
4426
4431
|
};
|
|
4427
|
-
var IdCaptureStateContext = /*#__PURE__*/createContext(initialState$4);
|
|
4428
|
-
var IdCaptureDispatchContext = /*#__PURE__*/createContext(function () {});
|
|
4429
4432
|
var _reducer = function reducer(state, action) {
|
|
4430
|
-
var _a
|
|
4433
|
+
var _a;
|
|
4431
4434
|
switch (action.type) {
|
|
4432
4435
|
case 'configureWizard':
|
|
4433
4436
|
{
|
|
4434
|
-
var
|
|
4435
|
-
captureRequirement =
|
|
4436
|
-
precapturedDocuments =
|
|
4437
|
-
allowSinglePageIdCapture =
|
|
4438
|
-
allowIdCardBackToFrontCapture =
|
|
4439
|
-
enableOverrideWrongDocumentTypeDialog =
|
|
4440
|
-
allowOverrideWrongDocumentTypeAfterMs =
|
|
4437
|
+
var _b = action.payload,
|
|
4438
|
+
captureRequirement = _b.captureRequirement,
|
|
4439
|
+
precapturedDocuments = _b.precapturedDocuments,
|
|
4440
|
+
allowSinglePageIdCapture = _b.allowSinglePageIdCapture,
|
|
4441
|
+
allowIdCardBackToFrontCapture = _b.allowIdCardBackToFrontCapture,
|
|
4442
|
+
enableOverrideWrongDocumentTypeDialog = _b.enableOverrideWrongDocumentTypeDialog,
|
|
4443
|
+
allowOverrideWrongDocumentTypeAfterMs = _b.allowOverrideWrongDocumentTypeAfterMs,
|
|
4444
|
+
allowUploadingDocumentsFromStorage = _b.allowUploadingDocumentsFromStorage;
|
|
4441
4445
|
var newState = _assign(_assign({}, state), {
|
|
4442
4446
|
captureRequirement: captureRequirement,
|
|
4443
4447
|
allowSinglePageIdCapture: allowSinglePageIdCapture !== null && allowSinglePageIdCapture !== void 0 ? allowSinglePageIdCapture : false,
|
|
4444
4448
|
allowIdCardBackToFrontCapture: allowIdCardBackToFrontCapture !== null && allowIdCardBackToFrontCapture !== void 0 ? allowIdCardBackToFrontCapture : false,
|
|
4445
4449
|
enableOverrideWrongDocumentTypeDialog: enableOverrideWrongDocumentTypeDialog,
|
|
4446
|
-
allowOverrideWrongDocumentTypeAfterMs: allowOverrideWrongDocumentTypeAfterMs
|
|
4450
|
+
allowOverrideWrongDocumentTypeAfterMs: allowOverrideWrongDocumentTypeAfterMs,
|
|
4451
|
+
allowUploadingDocumentsFromStorage: allowUploadingDocumentsFromStorage
|
|
4447
4452
|
});
|
|
4448
4453
|
if (captureRequirement === 'idCardBack') newState.requestedDocumentType = 'idCardBack';
|
|
4449
4454
|
if (captureRequirement === 'passport') newState.requestedDocumentType = 'passport';
|
|
@@ -4461,7 +4466,7 @@ var _reducer = function reducer(state, action) {
|
|
|
4461
4466
|
}
|
|
4462
4467
|
}
|
|
4463
4468
|
newState.operationStartedAt = new Date();
|
|
4464
|
-
if (!
|
|
4469
|
+
if (!allowUploadingDocumentsFromStorage) {
|
|
4465
4470
|
newState.captureState = 'capturing';
|
|
4466
4471
|
}
|
|
4467
4472
|
return newState;
|
|
@@ -4501,26 +4506,26 @@ var _reducer = function reducer(state, action) {
|
|
|
4501
4506
|
});
|
|
4502
4507
|
case 'objectsDetected':
|
|
4503
4508
|
{
|
|
4504
|
-
var
|
|
4505
|
-
detectedObjects =
|
|
4506
|
-
detectionThresholdMet =
|
|
4507
|
-
detectedDocumentType =
|
|
4508
|
-
idCardFrontDetectionScore =
|
|
4509
|
-
idCardFrontDetectionThresholdMet =
|
|
4510
|
-
idCardBackDetectionScore =
|
|
4511
|
-
idCardBackDetectionThresholdMet =
|
|
4512
|
-
passportDetectionScore =
|
|
4513
|
-
passportDetectionThresholdMet =
|
|
4514
|
-
singlePageDetectionScore =
|
|
4515
|
-
singlePageDetectionThresholdMet =
|
|
4516
|
-
bestDocument =
|
|
4517
|
-
documentInBounds =
|
|
4518
|
-
documentTooClose =
|
|
4519
|
-
documentIsStable =
|
|
4520
|
-
focusScore =
|
|
4521
|
-
focusThresholdMet =
|
|
4522
|
-
frameWidth =
|
|
4523
|
-
frameHeight =
|
|
4509
|
+
var _c = action.payload.prediction,
|
|
4510
|
+
detectedObjects = _c.detectedObjects,
|
|
4511
|
+
detectionThresholdMet = _c.detectionThresholdMet,
|
|
4512
|
+
detectedDocumentType = _c.detectedDocumentType,
|
|
4513
|
+
idCardFrontDetectionScore = _c.idCardFrontDetectionScore,
|
|
4514
|
+
idCardFrontDetectionThresholdMet = _c.idCardFrontDetectionThresholdMet,
|
|
4515
|
+
idCardBackDetectionScore = _c.idCardBackDetectionScore,
|
|
4516
|
+
idCardBackDetectionThresholdMet = _c.idCardBackDetectionThresholdMet,
|
|
4517
|
+
passportDetectionScore = _c.passportDetectionScore,
|
|
4518
|
+
passportDetectionThresholdMet = _c.passportDetectionThresholdMet,
|
|
4519
|
+
singlePageDetectionScore = _c.singlePageDetectionScore,
|
|
4520
|
+
singlePageDetectionThresholdMet = _c.singlePageDetectionThresholdMet,
|
|
4521
|
+
bestDocument = _c.bestDocument,
|
|
4522
|
+
documentInBounds = _c.documentInBounds,
|
|
4523
|
+
documentTooClose = _c.documentTooClose,
|
|
4524
|
+
documentIsStable = _c.documentIsStable,
|
|
4525
|
+
focusScore = _c.focusScore,
|
|
4526
|
+
focusThresholdMet = _c.focusThresholdMet,
|
|
4527
|
+
frameWidth = _c.frameWidth,
|
|
4528
|
+
frameHeight = _c.frameHeight;
|
|
4524
4529
|
var frameCapturedAt = new Date();
|
|
4525
4530
|
var frameCaptureRate = 0;
|
|
4526
4531
|
var goodFramesThreshold = state.goodFramesThreshold;
|
|
@@ -4653,7 +4658,9 @@ var _reducer = function reducer(state, action) {
|
|
|
4653
4658
|
} else {
|
|
4654
4659
|
newState.requestedDocumentType = remainingRequirements[0];
|
|
4655
4660
|
if (state.requestedDocumentType === 'idCardFront' && newState.requestedDocumentType === 'idCardBack' || state.requestedDocumentType === 'idCardBack' && newState.requestedDocumentType === 'idCardFront') {
|
|
4656
|
-
newState.
|
|
4661
|
+
if (!newState.isUploadingDocumentsFromStorage) {
|
|
4662
|
+
newState.captureState = 'requestingFlip';
|
|
4663
|
+
}
|
|
4657
4664
|
newState.idCardFrontDetectionThresholdMet = false;
|
|
4658
4665
|
newState.idCardBackDetectionThresholdMet = false;
|
|
4659
4666
|
newState.passportDetectionThresholdMet = false;
|
|
@@ -4663,28 +4670,23 @@ var _reducer = function reducer(state, action) {
|
|
|
4663
4670
|
return newState;
|
|
4664
4671
|
}
|
|
4665
4672
|
case 'documentCapturedManually':
|
|
4673
|
+
return _reducer(state, {
|
|
4674
|
+
type: 'documentCaptured',
|
|
4675
|
+
payload: _assign(_assign({}, action.payload), {
|
|
4676
|
+
documentType: state.requestedDocumentType,
|
|
4677
|
+
width: 0,
|
|
4678
|
+
height: 0
|
|
4679
|
+
})
|
|
4680
|
+
});
|
|
4681
|
+
case 'documentsCaptured':
|
|
4666
4682
|
{
|
|
4667
|
-
var newState = _assign(
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
var remainingRequirements = remainingIdCaptureRequirements(state.captureRequirement, newState.capturedDocuments, state.requestedDocumentType);
|
|
4675
|
-
if (remainingRequirements.length === 0) {
|
|
4676
|
-
newState.captureState = 'complete';
|
|
4677
|
-
} else {
|
|
4678
|
-
newState.requestedDocumentType = remainingRequirements[0];
|
|
4679
|
-
if (state.requestedDocumentType === 'idCardFront' && newState.requestedDocumentType === 'idCardBack' || state.requestedDocumentType === 'idCardBack' && newState.requestedDocumentType === 'idCardFront') {
|
|
4680
|
-
if (!newState.isUploadingDocumentsFromStorage) {
|
|
4681
|
-
newState.captureState = 'requestingFlip';
|
|
4682
|
-
}
|
|
4683
|
-
newState.idCardFrontDetectionThresholdMet = false;
|
|
4684
|
-
newState.idCardBackDetectionThresholdMet = false;
|
|
4685
|
-
newState.passportDetectionThresholdMet = false;
|
|
4686
|
-
newState.wrongDocumentTypePredictions = 0;
|
|
4687
|
-
}
|
|
4683
|
+
var newState = _assign({}, state);
|
|
4684
|
+
for (var _d = 0, _e = action.payload; _d < _e.length; _d++) {
|
|
4685
|
+
var doc = _e[_d];
|
|
4686
|
+
newState = _reducer(newState, {
|
|
4687
|
+
type: 'documentCaptured',
|
|
4688
|
+
payload: doc
|
|
4689
|
+
});
|
|
4688
4690
|
}
|
|
4689
4691
|
return newState;
|
|
4690
4692
|
}
|
|
@@ -4721,6 +4723,9 @@ var _reducer = function reducer(state, action) {
|
|
|
4721
4723
|
}
|
|
4722
4724
|
case 'resetWizard':
|
|
4723
4725
|
return _assign(_assign({}, initialState$4), {
|
|
4726
|
+
dispatch: state.dispatch,
|
|
4727
|
+
allowUploadingDocumentsFromStorage: state.allowUploadingDocumentsFromStorage,
|
|
4728
|
+
captureState: state.allowUploadingDocumentsFromStorage ? 'initializing' : 'capturing',
|
|
4724
4729
|
captureRequirement: state.captureRequirement,
|
|
4725
4730
|
allowIdCardBackToFrontCapture: state.allowIdCardBackToFrontCapture
|
|
4726
4731
|
});
|
|
@@ -4728,13 +4733,26 @@ var _reducer = function reducer(state, action) {
|
|
|
4728
4733
|
return state;
|
|
4729
4734
|
}
|
|
4730
4735
|
};
|
|
4731
|
-
var
|
|
4736
|
+
var useIdCaptureStore = create()(devtools(function (set) {
|
|
4737
|
+
return _assign(_assign({}, initialState$4), {
|
|
4738
|
+
dispatch: function dispatch(action) {
|
|
4739
|
+
return set(function (state) {
|
|
4740
|
+
return _reducer(state, action);
|
|
4741
|
+
}, undefined, action);
|
|
4742
|
+
}
|
|
4743
|
+
});
|
|
4744
|
+
}));
|
|
4745
|
+
function IdCaptureStateProvider(_a) {
|
|
4732
4746
|
var children = _a.children;
|
|
4733
|
-
var
|
|
4734
|
-
state
|
|
4735
|
-
|
|
4747
|
+
var overrideWrongDocumentTypeGuidance = useIdCaptureStore(useShallow(function (state) {
|
|
4748
|
+
return state.overrideWrongDocumentTypeGuidance;
|
|
4749
|
+
}));
|
|
4750
|
+
var setRequiredDocumentType = useContext(IdCaptureModelsContext).setRequiredDocumentType;
|
|
4751
|
+
useEffect(function () {
|
|
4752
|
+
if (overrideWrongDocumentTypeGuidance) setRequiredDocumentType('none');
|
|
4753
|
+
}, [overrideWrongDocumentTypeGuidance, setRequiredDocumentType]);
|
|
4736
4754
|
var onResize = useDebouncedCallback(function () {
|
|
4737
|
-
|
|
4755
|
+
dispatchIdCaptureAction({
|
|
4738
4756
|
type: 'redrawRequested'
|
|
4739
4757
|
});
|
|
4740
4758
|
}, 500);
|
|
@@ -4742,26 +4760,13 @@ var IdCaptureStateProvider = function IdCaptureStateProvider(_a) {
|
|
|
4742
4760
|
if (typeof window === 'undefined') return;
|
|
4743
4761
|
window.addEventListener('resize', onResize);
|
|
4744
4762
|
return function () {
|
|
4745
|
-
window.removeEventListener('resize', onResize);
|
|
4763
|
+
return window.removeEventListener('resize', onResize);
|
|
4746
4764
|
};
|
|
4747
4765
|
}, [onResize]);
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
}
|
|
4753
|
-
}, [state.overrideWrongDocumentTypeGuidance, setRequiredDocumentType]);
|
|
4754
|
-
return /*#__PURE__*/React__default.createElement(IdCaptureStateContext.Provider, {
|
|
4755
|
-
value: state
|
|
4756
|
-
}, /*#__PURE__*/React__default.createElement(IdCaptureDispatchContext.Provider, {
|
|
4757
|
-
value: dispatch
|
|
4758
|
-
}, children));
|
|
4759
|
-
};
|
|
4760
|
-
var useIdCaptureState = function useIdCaptureState() {
|
|
4761
|
-
var state = useContext(IdCaptureStateContext);
|
|
4762
|
-
var dispatch = useContext(IdCaptureDispatchContext);
|
|
4763
|
-
if (!state || !dispatch) throw new Error('useIdCaptureState cannot be used without IdCaptureStateProvider');
|
|
4764
|
-
return [state, dispatch];
|
|
4766
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, children);
|
|
4767
|
+
}
|
|
4768
|
+
var dispatchIdCaptureAction = function dispatchIdCaptureAction(action) {
|
|
4769
|
+
return useIdCaptureStore.getState().dispatch(action);
|
|
4765
4770
|
};
|
|
4766
4771
|
|
|
4767
4772
|
function DebugStatsPane(_a) {
|
|
@@ -4836,7 +4841,7 @@ var DebugBoundingBoxOverlay = function DebugBoundingBoxOverlay(_a) {
|
|
|
4836
4841
|
var scaling = _a.scaling,
|
|
4837
4842
|
$flipX = _a.$flipX,
|
|
4838
4843
|
children = _a.children;
|
|
4839
|
-
var _b =
|
|
4844
|
+
var _b = useIdCaptureStore(),
|
|
4840
4845
|
guideRectWidth = _b.guideRectWidth,
|
|
4841
4846
|
guideRectHeight = _b.guideRectHeight,
|
|
4842
4847
|
guideRectX = _b.guideRectX,
|
|
@@ -6001,14 +6006,14 @@ function OverrideWrongDocumentTypeGuidanceDialog(_a) {
|
|
|
6001
6006
|
classNames = _b === void 0 ? {} : _b,
|
|
6002
6007
|
_c = _a.verbiage,
|
|
6003
6008
|
rawVerbiage = _c === void 0 ? {} : _c;
|
|
6004
|
-
var _d =
|
|
6005
|
-
|
|
6006
|
-
dispatch = _d
|
|
6009
|
+
var _d = useIdCaptureStore(),
|
|
6010
|
+
allowOverrideWrongDocumentTypeGuidance = _d.allowOverrideWrongDocumentTypeGuidance,
|
|
6011
|
+
dispatch = _d.dispatch;
|
|
6007
6012
|
var verbiage = useTranslations(rawVerbiage, {
|
|
6008
6013
|
messageText: 'We are having trouble identifying the correct side of your id, do you want to continue with capture anyway?',
|
|
6009
6014
|
buttonText: 'OK'
|
|
6010
6015
|
});
|
|
6011
|
-
if (!
|
|
6016
|
+
if (!allowOverrideWrongDocumentTypeGuidance) return null;
|
|
6012
6017
|
return /*#__PURE__*/React__default.createElement(Container$2, {
|
|
6013
6018
|
className: classNames.container
|
|
6014
6019
|
}, /*#__PURE__*/React__default.createElement(InnerContainer, {
|
|
@@ -6062,52 +6067,50 @@ var IdCapture = function IdCapture(_a) {
|
|
|
6062
6067
|
width = _q === void 0 ? 1 : _q,
|
|
6063
6068
|
_r = _p.height,
|
|
6064
6069
|
height = _r === void 0 ? 1 : _r;
|
|
6065
|
-
var
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
focusPredictionTime = _u.focusPredictionTime,
|
|
6076
|
-
getBestFrame = _u.getBestFrame;
|
|
6070
|
+
var state = useIdCaptureStore();
|
|
6071
|
+
var _s = useCameraStore(),
|
|
6072
|
+
camera = _s.camera,
|
|
6073
|
+
isRearFacing = _s.isRearFacing;
|
|
6074
|
+
var _t = useContext(IdCaptureModelsContext),
|
|
6075
|
+
modelsReady = _t.ready,
|
|
6076
|
+
setThresholds = _t.setThresholds,
|
|
6077
|
+
detectionTime = _t.detectionTime,
|
|
6078
|
+
focusPredictionTime = _t.focusPredictionTime,
|
|
6079
|
+
getBestFrame = _t.getBestFrame;
|
|
6077
6080
|
useEffect(function () {
|
|
6078
|
-
return
|
|
6081
|
+
return dispatchIdCaptureAction({
|
|
6079
6082
|
type: 'captureInitialized'
|
|
6080
6083
|
});
|
|
6081
|
-
}, [
|
|
6084
|
+
}, []);
|
|
6082
6085
|
useEffect(function () {
|
|
6083
6086
|
setThresholds(thresholds);
|
|
6084
6087
|
}, [thresholds, setThresholds]);
|
|
6085
6088
|
useEffect(function () {
|
|
6086
6089
|
if (!requiredDocumentType) return;
|
|
6087
|
-
|
|
6090
|
+
dispatchIdCaptureAction({
|
|
6088
6091
|
type: 'setRequiredDocumentType',
|
|
6089
6092
|
payload: requiredDocumentType
|
|
6090
6093
|
});
|
|
6091
|
-
}, [
|
|
6094
|
+
}, [requiredDocumentType]);
|
|
6092
6095
|
useEffect(function () {
|
|
6093
|
-
|
|
6096
|
+
dispatchIdCaptureAction({
|
|
6094
6097
|
type: 'pageRendered',
|
|
6095
6098
|
payload: {
|
|
6096
6099
|
pageWidth: width,
|
|
6097
6100
|
pageHeight: height
|
|
6098
6101
|
}
|
|
6099
6102
|
});
|
|
6100
|
-
}, [
|
|
6103
|
+
}, [height, width]);
|
|
6101
6104
|
var shouldCapture = state.goodFramesThresholdMet && !state.capturing && timeSince(state.captureStartedAt) >= 3000;
|
|
6102
6105
|
useEffect(function () {
|
|
6103
6106
|
if (!shouldCapture) return;
|
|
6104
|
-
|
|
6107
|
+
dispatchIdCaptureAction({
|
|
6105
6108
|
type: 'capturing'
|
|
6106
6109
|
});
|
|
6107
6110
|
var bestFrame = getBestFrame();
|
|
6108
6111
|
if (!bestFrame) {
|
|
6109
6112
|
log('uh oh, i did not get a photo');
|
|
6110
|
-
|
|
6113
|
+
dispatchIdCaptureAction({
|
|
6111
6114
|
type: 'captureFailed'
|
|
6112
6115
|
});
|
|
6113
6116
|
return;
|
|
@@ -6120,7 +6123,7 @@ var IdCapture = function IdCapture(_a) {
|
|
|
6120
6123
|
var width = canvas.width,
|
|
6121
6124
|
height = canvas.height;
|
|
6122
6125
|
var imageUrl = canvas.toDataURL('image/jpeg', 0.95);
|
|
6123
|
-
|
|
6126
|
+
dispatchIdCaptureAction({
|
|
6124
6127
|
type: 'frameCaptured',
|
|
6125
6128
|
payload: {
|
|
6126
6129
|
imageUrl: imageUrl
|
|
@@ -6138,11 +6141,11 @@ var IdCapture = function IdCapture(_a) {
|
|
|
6138
6141
|
bestFocusScore: focusScore
|
|
6139
6142
|
};
|
|
6140
6143
|
onCapture === null || onCapture === void 0 ? void 0 : onCapture(imageUrl, width, height, capturedDocumentType, metadata);
|
|
6141
|
-
|
|
6144
|
+
dispatchIdCaptureAction({
|
|
6142
6145
|
type: 'captured'
|
|
6143
6146
|
});
|
|
6144
6147
|
}, 0);
|
|
6145
|
-
}, [
|
|
6148
|
+
}, [getBestFrame, onCapture, shouldCapture, state.captureStartedAt, state.requestedDocumentType]);
|
|
6146
6149
|
var theme = useTheme();
|
|
6147
6150
|
colors.guideBoxUnsatisfiedColor || (colors.guideBoxUnsatisfiedColor = (_d = (_c = (_b = theme.idCapture) === null || _b === void 0 ? void 0 : _b.guideBox) === null || _c === void 0 ? void 0 : _c.unsatisfiedColor) !== null && _d !== void 0 ? _d : 'white');
|
|
6148
6151
|
colors.guideBoxSatisfiedColor || (colors.guideBoxSatisfiedColor = (_g = (_f = (_e = theme.idCapture) === null || _e === void 0 ? void 0 : _e.guideBox) === null || _f === void 0 ? void 0 : _f.satisfiedColor) !== null && _g !== void 0 ? _g : 'green');
|
|
@@ -6868,12 +6871,6 @@ var IdCaptureLoadingOverlayDefault = function IdCaptureLoadingOverlayDefault(_a)
|
|
|
6868
6871
|
var _q = useState(false),
|
|
6869
6872
|
dismissed = _q[0],
|
|
6870
6873
|
setDismissed = _q[1];
|
|
6871
|
-
var dispatch = useIdCaptureState()[1];
|
|
6872
|
-
useEffect(function () {
|
|
6873
|
-
return dispatch({
|
|
6874
|
-
type: 'captureInitialized'
|
|
6875
|
-
});
|
|
6876
|
-
}, [dispatch]);
|
|
6877
6874
|
assets.instructionImageUrl || (assets.instructionImageUrl = legacyInstructionImageUrl$1);
|
|
6878
6875
|
var verbiage = useTranslations(rawVerbiage, {
|
|
6879
6876
|
headingText: 'Use your device camera to capture your ID',
|
|
@@ -7858,9 +7855,7 @@ var IdCaptureGuideOverlay = function IdCaptureGuideOverlay(_a) {
|
|
|
7858
7855
|
wrapperAspectRatio = _1.wrapperAspectRatio,
|
|
7859
7856
|
guideOrientationOnImageLoaded = _1.onImageLoaded,
|
|
7860
7857
|
setDimensions = _1.setDimensions;
|
|
7861
|
-
var
|
|
7862
|
-
state = _2[0],
|
|
7863
|
-
dispatch = _2[1];
|
|
7858
|
+
var state = useIdCaptureStore();
|
|
7864
7859
|
var theme = useTheme();
|
|
7865
7860
|
if (borderWidth === undefined) borderWidth = (_d = (_c = (_b = theme.idCapture) === null || _b === void 0 ? void 0 : _b.guideBox) === null || _c === void 0 ? void 0 : _c.borderWidth) !== null && _d !== void 0 ? _d : 4;
|
|
7866
7861
|
useEffect(function () {
|
|
@@ -7886,14 +7881,14 @@ var IdCaptureGuideOverlay = function IdCaptureGuideOverlay(_a) {
|
|
|
7886
7881
|
var imageByUrl = imagesByUrl[img.src];
|
|
7887
7882
|
var width = (_a = imageByUrl === null || imageByUrl === void 0 ? void 0 : imageByUrl.width) !== null && _a !== void 0 ? _a : img.naturalWidth;
|
|
7888
7883
|
var height = (_b = imageByUrl === null || imageByUrl === void 0 ? void 0 : imageByUrl.height) !== null && _b !== void 0 ? _b : img.naturalHeight;
|
|
7889
|
-
|
|
7884
|
+
dispatchIdCaptureAction({
|
|
7890
7885
|
type: 'guideImageLoaded',
|
|
7891
7886
|
payload: {
|
|
7892
7887
|
width: width,
|
|
7893
7888
|
height: height
|
|
7894
7889
|
}
|
|
7895
7890
|
});
|
|
7896
|
-
}, [
|
|
7891
|
+
}, [guideOrientationOnImageLoaded, imagesByUrl]);
|
|
7897
7892
|
return /*#__PURE__*/React__default.createElement(StyledPageContainer, {
|
|
7898
7893
|
ref: wrapperRef,
|
|
7899
7894
|
onClick: onClick,
|
|
@@ -8023,19 +8018,17 @@ var IdCaptureFitGuide = function IdCaptureFitGuide(_a) {
|
|
|
8023
8018
|
images = _w === void 0 ? defaultIdCaptureGuideImages : _w,
|
|
8024
8019
|
_x = _a.classNames,
|
|
8025
8020
|
classNames = _x === void 0 ? {} : _x;
|
|
8026
|
-
var _y =
|
|
8027
|
-
|
|
8028
|
-
|
|
8029
|
-
|
|
8030
|
-
guideImageHeight = _z.guideImageHeight,
|
|
8031
|
-
dispatch = _y[1];
|
|
8021
|
+
var _y = useIdCaptureStore(),
|
|
8022
|
+
redrawing = _y.redrawing,
|
|
8023
|
+
guideImageWidth = _y.guideImageWidth,
|
|
8024
|
+
guideImageHeight = _y.guideImageHeight;
|
|
8032
8025
|
var canvasRef = useRef(null);
|
|
8033
|
-
var
|
|
8034
|
-
wrapperRef =
|
|
8035
|
-
|
|
8036
|
-
wrapperWidth =
|
|
8037
|
-
|
|
8038
|
-
wrapperHeight =
|
|
8026
|
+
var _z = useResizeObserver(),
|
|
8027
|
+
wrapperRef = _z.ref,
|
|
8028
|
+
_0 = _z.width,
|
|
8029
|
+
wrapperWidth = _0 === void 0 ? 1 : _0,
|
|
8030
|
+
_1 = _z.height,
|
|
8031
|
+
wrapperHeight = _1 === void 0 ? 1 : _1;
|
|
8039
8032
|
var theme = useTheme();
|
|
8040
8033
|
if (borderWidth === undefined) borderWidth = (_d = (_c = (_b = theme.idCapture) === null || _b === void 0 ? void 0 : _b.guideBox) === null || _c === void 0 ? void 0 : _c.borderWidth) !== null && _d !== void 0 ? _d : 4;
|
|
8041
8034
|
if (padding === undefined) {
|
|
@@ -8053,7 +8046,7 @@ var IdCaptureFitGuide = function IdCaptureFitGuide(_a) {
|
|
|
8053
8046
|
if (redrawing) {
|
|
8054
8047
|
resetCanvasDimensions(canvas);
|
|
8055
8048
|
var timer_1 = setTimeout(function () {
|
|
8056
|
-
|
|
8049
|
+
dispatchIdCaptureAction({
|
|
8057
8050
|
type: 'redrawInProgress'
|
|
8058
8051
|
});
|
|
8059
8052
|
}, 10);
|
|
@@ -8103,7 +8096,7 @@ var IdCaptureFitGuide = function IdCaptureFitGuide(_a) {
|
|
|
8103
8096
|
// reset composite mode to default
|
|
8104
8097
|
ctx.globalCompositeOperation = 'source-over';
|
|
8105
8098
|
var rectOffsetTop = canvas.offsetTop;
|
|
8106
|
-
|
|
8099
|
+
dispatchIdCaptureAction({
|
|
8107
8100
|
type: 'redrawCompleted',
|
|
8108
8101
|
payload: {
|
|
8109
8102
|
guideRectX: rectX,
|
|
@@ -8114,7 +8107,7 @@ var IdCaptureFitGuide = function IdCaptureFitGuide(_a) {
|
|
|
8114
8107
|
}
|
|
8115
8108
|
});
|
|
8116
8109
|
return function () {};
|
|
8117
|
-
}, [aspectRatio, borderColor, borderRadius, borderWidth,
|
|
8110
|
+
}, [aspectRatio, borderColor, borderRadius, borderWidth, maskColor, padding, redrawing, wrapperHeight, wrapperWidth]);
|
|
8118
8111
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(CanvasWrapper$1, {
|
|
8119
8112
|
ref: wrapperRef,
|
|
8120
8113
|
"$maskColor": maskColor !== null && maskColor !== void 0 ? maskColor : '',
|
|
@@ -8164,7 +8157,7 @@ function IdCaptureGuides(_a) {
|
|
|
8164
8157
|
colors = _k === void 0 ? {} : _k,
|
|
8165
8158
|
_l = _a.verbiage,
|
|
8166
8159
|
rawVerbiage = _l === void 0 ? {} : _l;
|
|
8167
|
-
var state =
|
|
8160
|
+
var state = useIdCaptureStore();
|
|
8168
8161
|
var isRearFacing = useCameraStore(function (state) {
|
|
8169
8162
|
return state.isRearFacing;
|
|
8170
8163
|
});
|
|
@@ -9127,7 +9120,7 @@ var StyledButtonsRow$8 = styled(ButtonsRow)(templateObject_6$5 || (templateObjec
|
|
|
9127
9120
|
var templateObject_1$m, templateObject_2$k, templateObject_3$g, templateObject_4$a, templateObject_5$6, templateObject_6$5;
|
|
9128
9121
|
|
|
9129
9122
|
function ScalingCameraFeed() {
|
|
9130
|
-
var _a =
|
|
9123
|
+
var _a = useIdCaptureStore(),
|
|
9131
9124
|
captureState = _a.captureState,
|
|
9132
9125
|
guideRectX = _a.guideRectX,
|
|
9133
9126
|
guideRectY = _a.guideRectY,
|
|
@@ -9153,14 +9146,12 @@ function IdCaptureOrUploadScreen(_a) {
|
|
|
9153
9146
|
classNames = _b === void 0 ? {} : _b,
|
|
9154
9147
|
_c = _a.verbiage,
|
|
9155
9148
|
rawVerbiage = _c === void 0 ? {} : _c;
|
|
9156
|
-
var
|
|
9157
|
-
state = _d[0],
|
|
9158
|
-
dispatch = _d[1];
|
|
9149
|
+
var state = useIdCaptureStore();
|
|
9159
9150
|
var requestCameraAccess = useCameraStore().requestCameraAccess;
|
|
9160
9151
|
var loadModels = useContext(IdCaptureModelsContext).load;
|
|
9161
|
-
var
|
|
9162
|
-
selectIdTypeModalOpen =
|
|
9163
|
-
setSelectIdTypeModalOpen =
|
|
9152
|
+
var _d = useState(false),
|
|
9153
|
+
selectIdTypeModalOpen = _d[0],
|
|
9154
|
+
setSelectIdTypeModalOpen = _d[1];
|
|
9164
9155
|
var verbiage = useTranslations(rawVerbiage, {
|
|
9165
9156
|
captureWithCameraText: 'Capture with Camera',
|
|
9166
9157
|
orText: 'OR',
|
|
@@ -9192,7 +9183,7 @@ function IdCaptureOrUploadScreen(_a) {
|
|
|
9192
9183
|
onClick: function onClick() {
|
|
9193
9184
|
loadModels();
|
|
9194
9185
|
void requestCameraAccess();
|
|
9195
|
-
dispatch({
|
|
9186
|
+
state.dispatch({
|
|
9196
9187
|
type: 'setUploadingDocumentsFromStorage',
|
|
9197
9188
|
payload: false
|
|
9198
9189
|
});
|
|
@@ -9209,19 +9200,19 @@ function IdCaptureOrUploadScreen(_a) {
|
|
|
9209
9200
|
className: classNames.uploadFromStorageButton,
|
|
9210
9201
|
colors: buttonColors,
|
|
9211
9202
|
onClick: function onClick() {
|
|
9212
|
-
dispatch({
|
|
9203
|
+
state.dispatch({
|
|
9213
9204
|
type: 'setUploadingDocumentsFromStorage',
|
|
9214
9205
|
payload: true
|
|
9215
9206
|
});
|
|
9216
9207
|
if (state.captureRequirement === 'idCardOrPassport') {
|
|
9217
9208
|
setSelectIdTypeModalOpen(true);
|
|
9218
9209
|
} else if (state.captureRequirement === 'passport') {
|
|
9219
|
-
dispatch({
|
|
9210
|
+
state.dispatch({
|
|
9220
9211
|
type: 'setUploadingDocumentsType',
|
|
9221
9212
|
payload: 'passport'
|
|
9222
9213
|
});
|
|
9223
9214
|
} else {
|
|
9224
|
-
dispatch({
|
|
9215
|
+
state.dispatch({
|
|
9225
9216
|
type: 'setUploadingDocumentsType',
|
|
9226
9217
|
payload: 'idCard'
|
|
9227
9218
|
});
|
|
@@ -9241,7 +9232,7 @@ function IdCaptureOrUploadScreen(_a) {
|
|
|
9241
9232
|
className: classNames.selectPassportTypeButton,
|
|
9242
9233
|
colors: buttonColors,
|
|
9243
9234
|
onClick: function onClick() {
|
|
9244
|
-
return dispatch({
|
|
9235
|
+
return state.dispatch({
|
|
9245
9236
|
type: 'setUploadingDocumentsType',
|
|
9246
9237
|
payload: 'passport'
|
|
9247
9238
|
});
|
|
@@ -9254,7 +9245,7 @@ function IdCaptureOrUploadScreen(_a) {
|
|
|
9254
9245
|
className: classNames.selectIdCardTypeButton,
|
|
9255
9246
|
colors: buttonColors,
|
|
9256
9247
|
onClick: function onClick() {
|
|
9257
|
-
return dispatch({
|
|
9248
|
+
return state.dispatch({
|
|
9258
9249
|
type: 'setUploadingDocumentsType',
|
|
9259
9250
|
payload: 'idCard'
|
|
9260
9251
|
});
|
|
@@ -9267,6 +9258,7 @@ function IdCaptureOrUploadScreen(_a) {
|
|
|
9267
9258
|
}, /*#__PURE__*/React__default.createElement(XIcon, null)))));
|
|
9268
9259
|
}
|
|
9269
9260
|
function PassportUploadScreen(_a) {
|
|
9261
|
+
var _this = this;
|
|
9270
9262
|
var _b = _a.classNames,
|
|
9271
9263
|
classNames = _b === void 0 ? {} : _b,
|
|
9272
9264
|
_c = _a.verbiage,
|
|
@@ -9274,7 +9266,6 @@ function PassportUploadScreen(_a) {
|
|
|
9274
9266
|
var _d = useState(null),
|
|
9275
9267
|
file = _d[0],
|
|
9276
9268
|
setFile = _d[1];
|
|
9277
|
-
var onCapturedManually = useOnCapturedManually();
|
|
9278
9269
|
var verbiage = useTranslations(rawVerbiage, {
|
|
9279
9270
|
uploadPassportText: 'Upload Passport',
|
|
9280
9271
|
loadingText: 'Loading...',
|
|
@@ -9300,25 +9291,39 @@ function PassportUploadScreen(_a) {
|
|
|
9300
9291
|
disabled: !file,
|
|
9301
9292
|
colors: buttonColors,
|
|
9302
9293
|
onClick: function onClick() {
|
|
9303
|
-
return
|
|
9294
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
9295
|
+
var _a;
|
|
9296
|
+
var _b, _c;
|
|
9297
|
+
return __generator(this, function (_d) {
|
|
9298
|
+
switch (_d.label) {
|
|
9299
|
+
case 0:
|
|
9300
|
+
_a = dispatchIdCaptureAction;
|
|
9301
|
+
_b = {
|
|
9302
|
+
type: 'documentCaptured'
|
|
9303
|
+
};
|
|
9304
|
+
_c = {};
|
|
9305
|
+
return [4 /*yield*/, readFile(file)];
|
|
9306
|
+
case 1:
|
|
9307
|
+
return [2 /*return*/, _a.apply(void 0, [(_b.payload = (_c.imageData = _d.sent(), _c.documentType = 'passport', _c.width = 0, _c.height = 0, _c), _b)])];
|
|
9308
|
+
}
|
|
9309
|
+
});
|
|
9310
|
+
});
|
|
9304
9311
|
}
|
|
9305
9312
|
}, verbiage.continueText)));
|
|
9306
9313
|
}
|
|
9307
9314
|
function IdDocumentUploadScreen(_a) {
|
|
9315
|
+
var _this = this;
|
|
9308
9316
|
var _b = _a.classNames,
|
|
9309
9317
|
classNames = _b === void 0 ? {} : _b,
|
|
9310
9318
|
_c = _a.verbiage,
|
|
9311
9319
|
rawVerbiage = _c === void 0 ? {} : _c;
|
|
9312
|
-
var
|
|
9313
|
-
|
|
9314
|
-
|
|
9320
|
+
var state = useIdCaptureStore();
|
|
9321
|
+
var _d = useState(null),
|
|
9322
|
+
idFrontFile = _d[0],
|
|
9323
|
+
setIdFrontFile = _d[1];
|
|
9315
9324
|
var _e = useState(null),
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
var _f = useState(null),
|
|
9319
|
-
idBackFile = _f[0],
|
|
9320
|
-
setIdBackFile = _f[1];
|
|
9321
|
-
var onCapturedManually = useOnCapturedManually();
|
|
9325
|
+
idBackFile = _e[0],
|
|
9326
|
+
setIdBackFile = _e[1];
|
|
9322
9327
|
var verbiage = useTranslations(rawVerbiage, {
|
|
9323
9328
|
uploadIdFrontText: 'Upload ID Front',
|
|
9324
9329
|
uploadIdBackText: 'Upload ID Back',
|
|
@@ -9358,51 +9363,54 @@ function IdDocumentUploadScreen(_a) {
|
|
|
9358
9363
|
disabled: !idFrontFile || !state.allowSinglePageIdCapture && !idBackFile,
|
|
9359
9364
|
colors: buttonColors,
|
|
9360
9365
|
onClick: function onClick() {
|
|
9361
|
-
|
|
9362
|
-
|
|
9363
|
-
|
|
9364
|
-
|
|
9366
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
9367
|
+
var _a, _b, _c, _d;
|
|
9368
|
+
var _e, _f, _g, _h;
|
|
9369
|
+
return __generator(this, function (_j) {
|
|
9370
|
+
switch (_j.label) {
|
|
9371
|
+
case 0:
|
|
9372
|
+
_b = (_a = state).dispatch;
|
|
9373
|
+
_e = {
|
|
9374
|
+
type: 'documentsCaptured'
|
|
9375
|
+
};
|
|
9376
|
+
if (!(!idBackFile && state.allowSinglePageIdCapture)) return [3 /*break*/, 2];
|
|
9377
|
+
_f = {};
|
|
9378
|
+
return [4 /*yield*/, readFile(idFrontFile)];
|
|
9379
|
+
case 1:
|
|
9380
|
+
_c = [(_f.imageData = _j.sent(), _f.documentType = 'singlePage', _f.width = 0, _f.height = 0, _f)];
|
|
9381
|
+
return [3 /*break*/, 5];
|
|
9382
|
+
case 2:
|
|
9383
|
+
_g = {};
|
|
9384
|
+
return [4 /*yield*/, readFile(idFrontFile)];
|
|
9385
|
+
case 3:
|
|
9386
|
+
_d = [(_g.imageData = _j.sent(), _g.documentType = 'idCardFront', _g.width = 0, _g.height = 0, _g)];
|
|
9387
|
+
_h = {};
|
|
9388
|
+
return [4 /*yield*/, readFile(idBackFile)];
|
|
9389
|
+
case 4:
|
|
9390
|
+
_c = _d.concat([(_h.imageData = _j.sent(), _h.documentType = 'idCardBack', _h.width = 0, _h.height = 0, _h)]);
|
|
9391
|
+
_j.label = 5;
|
|
9392
|
+
case 5:
|
|
9393
|
+
return [2 /*return*/, _b.apply(_a, [(_e.payload = _c, _e)])];
|
|
9394
|
+
}
|
|
9365
9395
|
});
|
|
9366
|
-
}
|
|
9367
|
-
void onCapturedManually(idFrontFile, idBackFile);
|
|
9396
|
+
});
|
|
9368
9397
|
}
|
|
9369
9398
|
}, verbiage.continueText)));
|
|
9370
9399
|
}
|
|
9371
9400
|
function CancelUploadTypeButton(_a) {
|
|
9372
9401
|
var children = _a.children,
|
|
9373
9402
|
className = _a.className;
|
|
9374
|
-
var dispatch = useIdCaptureState()[1];
|
|
9375
9403
|
return /*#__PURE__*/React__default.createElement(Button, {
|
|
9376
9404
|
className: className,
|
|
9377
9405
|
colors: buttonColors,
|
|
9378
9406
|
onClick: function onClick() {
|
|
9379
|
-
return
|
|
9407
|
+
return dispatchIdCaptureAction({
|
|
9380
9408
|
type: 'setUploadingDocumentsType',
|
|
9381
9409
|
payload: null
|
|
9382
9410
|
});
|
|
9383
9411
|
}
|
|
9384
9412
|
}, children);
|
|
9385
9413
|
}
|
|
9386
|
-
function useOnCapturedManually() {
|
|
9387
|
-
var dispatch = useIdCaptureState()[1];
|
|
9388
|
-
return useCallback(function () {
|
|
9389
|
-
var files = [];
|
|
9390
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
9391
|
-
files[_i] = arguments[_i];
|
|
9392
|
-
}
|
|
9393
|
-
return Promise.all(files.filter(Boolean).map(readFile)).then(function (f) {
|
|
9394
|
-
for (var _i = 0, f_1 = f; _i < f_1.length; _i++) {
|
|
9395
|
-
var imageData = f_1[_i];
|
|
9396
|
-
dispatch({
|
|
9397
|
-
type: 'documentCapturedManually',
|
|
9398
|
-
payload: {
|
|
9399
|
-
imageData: imageData
|
|
9400
|
-
}
|
|
9401
|
-
});
|
|
9402
|
-
}
|
|
9403
|
-
});
|
|
9404
|
-
}, [dispatch]);
|
|
9405
|
-
}
|
|
9406
9414
|
function readFile(file) {
|
|
9407
9415
|
return new Promise(function (resolve, reject) {
|
|
9408
9416
|
if (!file) return reject(new Error('File is undefined'));
|
|
@@ -9805,32 +9813,30 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
9805
9813
|
verbiage = _3 === void 0 ? {} : _3,
|
|
9806
9814
|
_4 = _a.debugMode,
|
|
9807
9815
|
debugMode = _4 === void 0 ? false : _4;
|
|
9808
|
-
var
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
-
|
|
9812
|
-
|
|
9813
|
-
|
|
9814
|
-
|
|
9815
|
-
|
|
9816
|
-
|
|
9817
|
-
|
|
9818
|
-
|
|
9819
|
-
|
|
9820
|
-
|
|
9821
|
-
|
|
9822
|
-
|
|
9823
|
-
|
|
9824
|
-
|
|
9825
|
-
|
|
9826
|
-
|
|
9827
|
-
|
|
9828
|
-
|
|
9829
|
-
|
|
9830
|
-
modelError = _9.modelError,
|
|
9831
|
-
resetBestFrame = _9.resetBestFrame;
|
|
9816
|
+
var state = useIdCaptureStore();
|
|
9817
|
+
var _5 = useCameraStore(),
|
|
9818
|
+
cameraAccessDenied = _5.cameraAccessDenied,
|
|
9819
|
+
requestCameraAccess = _5.requestCameraAccess,
|
|
9820
|
+
releaseCameraAccess = _5.releaseCameraAccess;
|
|
9821
|
+
var _6 = useState(false),
|
|
9822
|
+
overlayDismissed = _6[0],
|
|
9823
|
+
setOverlayDismissed = _6[1];
|
|
9824
|
+
var _7 = useContext(SubmissionContext),
|
|
9825
|
+
submissionStatus = _7.submissionStatus,
|
|
9826
|
+
setIdFrontImage = _7.setIdFrontImage,
|
|
9827
|
+
setIdBackImage = _7.setIdBackImage,
|
|
9828
|
+
setPassportImage = _7.setPassportImage,
|
|
9829
|
+
logIdFrontCaptureAttempt = _7.logIdFrontCaptureAttempt,
|
|
9830
|
+
logIdBackCaptureAttempt = _7.logIdBackCaptureAttempt;
|
|
9831
|
+
var _8 = useContext(IdCaptureModelsContext),
|
|
9832
|
+
start = _8.start,
|
|
9833
|
+
stop = _8.stop,
|
|
9834
|
+
onPredictionMade = _8.onPredictionMade,
|
|
9835
|
+
setRequiredDocumentType = _8.setRequiredDocumentType,
|
|
9836
|
+
modelError = _8.modelError,
|
|
9837
|
+
resetBestFrame = _8.resetBestFrame;
|
|
9832
9838
|
useEffect(function () {
|
|
9833
|
-
|
|
9839
|
+
dispatchIdCaptureAction({
|
|
9834
9840
|
type: 'configureWizard',
|
|
9835
9841
|
payload: {
|
|
9836
9842
|
captureRequirement: captureRequirement,
|
|
@@ -9842,7 +9848,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
9842
9848
|
allowUploadingDocumentsFromStorage: allowUploadingDocumentsFromStorage
|
|
9843
9849
|
}
|
|
9844
9850
|
});
|
|
9845
|
-
}, [allowIdCardBackToFrontCapture, allowOverrideWrongDocumentTypeAfterMs, allowSinglePageIdCapture, allowUploadingDocumentsFromStorage, captureRequirement,
|
|
9851
|
+
}, [allowIdCardBackToFrontCapture, allowOverrideWrongDocumentTypeAfterMs, allowSinglePageIdCapture, allowUploadingDocumentsFromStorage, captureRequirement, enableOverrideWrongDocumentTypeDialog, precapturedDocuments]);
|
|
9846
9852
|
var documentCount = Object.keys(state.capturedDocuments).length;
|
|
9847
9853
|
useEffect(function () {
|
|
9848
9854
|
if (documentCount) resetBestFrame();
|
|
@@ -9858,15 +9864,15 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
9858
9864
|
}, [logIdBackCaptureAttempt, logIdFrontCaptureAttempt, state.operationStartedAt, state.requestedDocumentType]);
|
|
9859
9865
|
useEffect(function startModelsWhenCapturing() {
|
|
9860
9866
|
if (!overlayDismissed || state.captureState !== 'capturing') return;
|
|
9861
|
-
|
|
9867
|
+
dispatchIdCaptureAction({
|
|
9862
9868
|
type: 'captureStarted'
|
|
9863
9869
|
});
|
|
9864
9870
|
start();
|
|
9865
|
-
}, [
|
|
9871
|
+
}, [overlayDismissed, start, state.captureState]);
|
|
9866
9872
|
useEffect(function () {
|
|
9867
9873
|
onPredictionMade(function (prediction) {
|
|
9868
9874
|
if (state.captureState === 'capturing') {
|
|
9869
|
-
|
|
9875
|
+
dispatchIdCaptureAction({
|
|
9870
9876
|
type: 'objectsDetected',
|
|
9871
9877
|
payload: {
|
|
9872
9878
|
prediction: prediction
|
|
@@ -9875,19 +9881,19 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
9875
9881
|
} else if (state.captureState === 'requestingFlip') {
|
|
9876
9882
|
if (state.requestedDocumentType !== 'selfie' && prediction["".concat(state.requestedDocumentType, "DetectionThresholdMet")]) {
|
|
9877
9883
|
resetBestFrame();
|
|
9878
|
-
|
|
9884
|
+
dispatchIdCaptureAction({
|
|
9879
9885
|
type: 'flipRequestCompleted'
|
|
9880
9886
|
});
|
|
9881
9887
|
}
|
|
9882
9888
|
}
|
|
9883
9889
|
});
|
|
9884
|
-
}, [
|
|
9890
|
+
}, [onPredictionMade, resetBestFrame, state.captureState, state.requestedDocumentType]);
|
|
9885
9891
|
useEffect(function () {
|
|
9886
9892
|
if (state.captureState === 'complete') stop();
|
|
9887
9893
|
}, [state.captureState, stop]);
|
|
9888
9894
|
var onCapture = useCallback(function (imageData, width, height, documentType, metadata) {
|
|
9889
9895
|
logCaptureMetadata(metadata);
|
|
9890
|
-
|
|
9896
|
+
dispatchIdCaptureAction({
|
|
9891
9897
|
type: 'documentCaptured',
|
|
9892
9898
|
payload: {
|
|
9893
9899
|
imageData: imageData,
|
|
@@ -9899,7 +9905,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
9899
9905
|
focusScore: metadata.bestFocusScore
|
|
9900
9906
|
}
|
|
9901
9907
|
});
|
|
9902
|
-
}, [
|
|
9908
|
+
}, [logCaptureMetadata]);
|
|
9903
9909
|
var onSubmitClick = useCallback(function () {
|
|
9904
9910
|
var _a = state.capturedDocuments,
|
|
9905
9911
|
idCardFront = _a.idCardFront,
|
|
@@ -9925,25 +9931,25 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
9925
9931
|
}, [onSuccess, releaseCameraAccess, releaseCameraAccessOnExit, setIdBackImage, setIdFrontImage, setPassportImage, state.capturedDocuments]);
|
|
9926
9932
|
var showSuccessScreen = useShowSuccessScreen(skipSuccessScreen, state.captureState === 'complete', onSubmitClick);
|
|
9927
9933
|
var onRetryClick = useCallback(function () {
|
|
9928
|
-
|
|
9934
|
+
return dispatchIdCaptureAction({
|
|
9929
9935
|
type: 'resetWizard'
|
|
9930
9936
|
});
|
|
9931
|
-
}, [
|
|
9932
|
-
var
|
|
9933
|
-
attempt =
|
|
9934
|
-
setAttempt =
|
|
9937
|
+
}, []);
|
|
9938
|
+
var _9 = useState(0),
|
|
9939
|
+
attempt = _9[0],
|
|
9940
|
+
setAttempt = _9[1];
|
|
9935
9941
|
var onExit = useCallback(function () {
|
|
9936
9942
|
releaseCameraAccess();
|
|
9937
9943
|
setOverlayDismissed(false);
|
|
9938
9944
|
setAttempt(function (n) {
|
|
9939
9945
|
return n + 1;
|
|
9940
9946
|
});
|
|
9941
|
-
|
|
9947
|
+
dispatchIdCaptureAction({
|
|
9942
9948
|
type: 'resetWizard'
|
|
9943
9949
|
});
|
|
9944
9950
|
onExitCapture === null || onExitCapture === void 0 ? void 0 : onExitCapture();
|
|
9945
9951
|
void requestCameraAccess();
|
|
9946
|
-
}, [
|
|
9952
|
+
}, [onExitCapture, releaseCameraAccess, requestCameraAccess]);
|
|
9947
9953
|
useEffect(function () {
|
|
9948
9954
|
if (submissionStatus !== SubmissionStatus.READY) {
|
|
9949
9955
|
if (releaseCameraAccessOnExit) releaseCameraAccess();
|
|
@@ -9976,14 +9982,14 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
9976
9982
|
if (state.captureState !== 'requestingFlip') return;
|
|
9977
9983
|
var t = setTimeout(function () {
|
|
9978
9984
|
resetBestFrame();
|
|
9979
|
-
|
|
9985
|
+
dispatchIdCaptureAction({
|
|
9980
9986
|
type: 'flipRequestCompleted'
|
|
9981
9987
|
});
|
|
9982
9988
|
}, 6000);
|
|
9983
9989
|
return function () {
|
|
9984
9990
|
clearTimeout(t);
|
|
9985
9991
|
};
|
|
9986
|
-
}, [
|
|
9992
|
+
}, [resetBestFrame, separateIdCardCaptureSequence, state.captureState]);
|
|
9987
9993
|
useEffect(function () {
|
|
9988
9994
|
if (state.requestedDocumentType === 'idCardFront') {
|
|
9989
9995
|
if (captureRequirement === 'idCardOrPassport') {
|
|
@@ -10011,7 +10017,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
10011
10017
|
return [4 /*yield*/, dataUrlToBase64(imageData)];
|
|
10012
10018
|
case 1:
|
|
10013
10019
|
base64ImageData = _a.sent();
|
|
10014
|
-
|
|
10020
|
+
dispatchIdCaptureAction({
|
|
10015
10021
|
type: 'documentCapturedManually',
|
|
10016
10022
|
payload: {
|
|
10017
10023
|
imageData: base64ImageData
|
|
@@ -10021,10 +10027,10 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
10021
10027
|
}
|
|
10022
10028
|
});
|
|
10023
10029
|
});
|
|
10024
|
-
}, [
|
|
10025
|
-
var
|
|
10026
|
-
progressStarted =
|
|
10027
|
-
setProgressStarted =
|
|
10030
|
+
}, []);
|
|
10031
|
+
var _10 = useState(false),
|
|
10032
|
+
progressStarted = _10[0],
|
|
10033
|
+
setProgressStarted = _10[1];
|
|
10028
10034
|
useEffect(function () {
|
|
10029
10035
|
if (state.captureState === 'capturing') {
|
|
10030
10036
|
setProgressStarted(false);
|
|
@@ -10104,7 +10110,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
10104
10110
|
capturedDocuments: state.capturedDocuments,
|
|
10105
10111
|
classNames: classNames.success,
|
|
10106
10112
|
onSubmitClick: function onSubmitClick() {
|
|
10107
|
-
|
|
10113
|
+
return dispatchIdCaptureAction({
|
|
10108
10114
|
type: 'flipRequestCompleted'
|
|
10109
10115
|
});
|
|
10110
10116
|
},
|