idmission-web-sdk 2.2.99 → 2.2.101
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 +24 -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 -215
- 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 -216
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +544 -292
- 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/dist/version.d.ts.map +1 -1
- package/package.json +3 -3
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.101';
|
|
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;
|
|
@@ -4606,6 +4611,11 @@ var _reducer = function reducer(state, action) {
|
|
|
4606
4611
|
frameCaptureRate: frameCaptureRate
|
|
4607
4612
|
});
|
|
4608
4613
|
}
|
|
4614
|
+
case 'captureInitialized':
|
|
4615
|
+
return _assign(_assign({}, state), {
|
|
4616
|
+
captureState: 'capturing',
|
|
4617
|
+
isUploadingDocumentsFromStorage: false
|
|
4618
|
+
});
|
|
4609
4619
|
case 'captureStarted':
|
|
4610
4620
|
return _assign(_assign({}, state), {
|
|
4611
4621
|
captureStartedAt: new Date(),
|
|
@@ -4648,7 +4658,9 @@ var _reducer = function reducer(state, action) {
|
|
|
4648
4658
|
} else {
|
|
4649
4659
|
newState.requestedDocumentType = remainingRequirements[0];
|
|
4650
4660
|
if (state.requestedDocumentType === 'idCardFront' && newState.requestedDocumentType === 'idCardBack' || state.requestedDocumentType === 'idCardBack' && newState.requestedDocumentType === 'idCardFront') {
|
|
4651
|
-
newState.
|
|
4661
|
+
if (!newState.isUploadingDocumentsFromStorage) {
|
|
4662
|
+
newState.captureState = 'requestingFlip';
|
|
4663
|
+
}
|
|
4652
4664
|
newState.idCardFrontDetectionThresholdMet = false;
|
|
4653
4665
|
newState.idCardBackDetectionThresholdMet = false;
|
|
4654
4666
|
newState.passportDetectionThresholdMet = false;
|
|
@@ -4658,28 +4670,23 @@ var _reducer = function reducer(state, action) {
|
|
|
4658
4670
|
return newState;
|
|
4659
4671
|
}
|
|
4660
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':
|
|
4661
4682
|
{
|
|
4662
|
-
var newState = _assign(
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
var remainingRequirements = remainingIdCaptureRequirements(state.captureRequirement, newState.capturedDocuments, state.requestedDocumentType);
|
|
4670
|
-
if (remainingRequirements.length === 0) {
|
|
4671
|
-
newState.captureState = 'complete';
|
|
4672
|
-
} else {
|
|
4673
|
-
newState.requestedDocumentType = remainingRequirements[0];
|
|
4674
|
-
if (state.requestedDocumentType === 'idCardFront' && newState.requestedDocumentType === 'idCardBack' || state.requestedDocumentType === 'idCardBack' && newState.requestedDocumentType === 'idCardFront') {
|
|
4675
|
-
if (!newState.isUploadingDocumentsFromStorage) {
|
|
4676
|
-
newState.captureState = 'requestingFlip';
|
|
4677
|
-
}
|
|
4678
|
-
newState.idCardFrontDetectionThresholdMet = false;
|
|
4679
|
-
newState.idCardBackDetectionThresholdMet = false;
|
|
4680
|
-
newState.passportDetectionThresholdMet = false;
|
|
4681
|
-
newState.wrongDocumentTypePredictions = 0;
|
|
4682
|
-
}
|
|
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
|
+
});
|
|
4683
4690
|
}
|
|
4684
4691
|
return newState;
|
|
4685
4692
|
}
|
|
@@ -4716,6 +4723,9 @@ var _reducer = function reducer(state, action) {
|
|
|
4716
4723
|
}
|
|
4717
4724
|
case 'resetWizard':
|
|
4718
4725
|
return _assign(_assign({}, initialState$4), {
|
|
4726
|
+
dispatch: state.dispatch,
|
|
4727
|
+
allowUploadingDocumentsFromStorage: state.allowUploadingDocumentsFromStorage,
|
|
4728
|
+
captureState: state.allowUploadingDocumentsFromStorage ? 'initializing' : 'capturing',
|
|
4719
4729
|
captureRequirement: state.captureRequirement,
|
|
4720
4730
|
allowIdCardBackToFrontCapture: state.allowIdCardBackToFrontCapture
|
|
4721
4731
|
});
|
|
@@ -4723,13 +4733,26 @@ var _reducer = function reducer(state, action) {
|
|
|
4723
4733
|
return state;
|
|
4724
4734
|
}
|
|
4725
4735
|
};
|
|
4726
|
-
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) {
|
|
4727
4746
|
var children = _a.children;
|
|
4728
|
-
var
|
|
4729
|
-
state
|
|
4730
|
-
|
|
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]);
|
|
4731
4754
|
var onResize = useDebouncedCallback(function () {
|
|
4732
|
-
|
|
4755
|
+
dispatchIdCaptureAction({
|
|
4733
4756
|
type: 'redrawRequested'
|
|
4734
4757
|
});
|
|
4735
4758
|
}, 500);
|
|
@@ -4737,26 +4760,13 @@ var IdCaptureStateProvider = function IdCaptureStateProvider(_a) {
|
|
|
4737
4760
|
if (typeof window === 'undefined') return;
|
|
4738
4761
|
window.addEventListener('resize', onResize);
|
|
4739
4762
|
return function () {
|
|
4740
|
-
window.removeEventListener('resize', onResize);
|
|
4763
|
+
return window.removeEventListener('resize', onResize);
|
|
4741
4764
|
};
|
|
4742
4765
|
}, [onResize]);
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
}
|
|
4748
|
-
}, [state.overrideWrongDocumentTypeGuidance, setRequiredDocumentType]);
|
|
4749
|
-
return /*#__PURE__*/React__default.createElement(IdCaptureStateContext.Provider, {
|
|
4750
|
-
value: state
|
|
4751
|
-
}, /*#__PURE__*/React__default.createElement(IdCaptureDispatchContext.Provider, {
|
|
4752
|
-
value: dispatch
|
|
4753
|
-
}, children));
|
|
4754
|
-
};
|
|
4755
|
-
var useIdCaptureState = function useIdCaptureState() {
|
|
4756
|
-
var state = useContext(IdCaptureStateContext);
|
|
4757
|
-
var dispatch = useContext(IdCaptureDispatchContext);
|
|
4758
|
-
if (!state || !dispatch) throw new Error('useIdCaptureState cannot be used without IdCaptureStateProvider');
|
|
4759
|
-
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);
|
|
4760
4770
|
};
|
|
4761
4771
|
|
|
4762
4772
|
function DebugStatsPane(_a) {
|
|
@@ -4831,7 +4841,7 @@ var DebugBoundingBoxOverlay = function DebugBoundingBoxOverlay(_a) {
|
|
|
4831
4841
|
var scaling = _a.scaling,
|
|
4832
4842
|
$flipX = _a.$flipX,
|
|
4833
4843
|
children = _a.children;
|
|
4834
|
-
var _b =
|
|
4844
|
+
var _b = useIdCaptureStore(),
|
|
4835
4845
|
guideRectWidth = _b.guideRectWidth,
|
|
4836
4846
|
guideRectHeight = _b.guideRectHeight,
|
|
4837
4847
|
guideRectX = _b.guideRectX,
|
|
@@ -5996,14 +6006,14 @@ function OverrideWrongDocumentTypeGuidanceDialog(_a) {
|
|
|
5996
6006
|
classNames = _b === void 0 ? {} : _b,
|
|
5997
6007
|
_c = _a.verbiage,
|
|
5998
6008
|
rawVerbiage = _c === void 0 ? {} : _c;
|
|
5999
|
-
var _d =
|
|
6000
|
-
|
|
6001
|
-
dispatch = _d
|
|
6009
|
+
var _d = useIdCaptureStore(),
|
|
6010
|
+
allowOverrideWrongDocumentTypeGuidance = _d.allowOverrideWrongDocumentTypeGuidance,
|
|
6011
|
+
dispatch = _d.dispatch;
|
|
6002
6012
|
var verbiage = useTranslations(rawVerbiage, {
|
|
6003
6013
|
messageText: 'We are having trouble identifying the correct side of your id, do you want to continue with capture anyway?',
|
|
6004
6014
|
buttonText: 'OK'
|
|
6005
6015
|
});
|
|
6006
|
-
if (!
|
|
6016
|
+
if (!allowOverrideWrongDocumentTypeGuidance) return null;
|
|
6007
6017
|
return /*#__PURE__*/React__default.createElement(Container$2, {
|
|
6008
6018
|
className: classNames.container
|
|
6009
6019
|
}, /*#__PURE__*/React__default.createElement(InnerContainer, {
|
|
@@ -6057,47 +6067,50 @@ var IdCapture = function IdCapture(_a) {
|
|
|
6057
6067
|
width = _q === void 0 ? 1 : _q,
|
|
6058
6068
|
_r = _p.height,
|
|
6059
6069
|
height = _r === void 0 ? 1 : _r;
|
|
6060
|
-
var
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
|
|
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;
|
|
6080
|
+
useEffect(function () {
|
|
6081
|
+
return dispatchIdCaptureAction({
|
|
6082
|
+
type: 'captureInitialized'
|
|
6083
|
+
});
|
|
6084
|
+
}, []);
|
|
6072
6085
|
useEffect(function () {
|
|
6073
6086
|
setThresholds(thresholds);
|
|
6074
6087
|
}, [thresholds, setThresholds]);
|
|
6075
6088
|
useEffect(function () {
|
|
6076
6089
|
if (!requiredDocumentType) return;
|
|
6077
|
-
|
|
6090
|
+
dispatchIdCaptureAction({
|
|
6078
6091
|
type: 'setRequiredDocumentType',
|
|
6079
6092
|
payload: requiredDocumentType
|
|
6080
6093
|
});
|
|
6081
|
-
}, [
|
|
6094
|
+
}, [requiredDocumentType]);
|
|
6082
6095
|
useEffect(function () {
|
|
6083
|
-
|
|
6096
|
+
dispatchIdCaptureAction({
|
|
6084
6097
|
type: 'pageRendered',
|
|
6085
6098
|
payload: {
|
|
6086
6099
|
pageWidth: width,
|
|
6087
6100
|
pageHeight: height
|
|
6088
6101
|
}
|
|
6089
6102
|
});
|
|
6090
|
-
}, [
|
|
6103
|
+
}, [height, width]);
|
|
6091
6104
|
var shouldCapture = state.goodFramesThresholdMet && !state.capturing && timeSince(state.captureStartedAt) >= 3000;
|
|
6092
6105
|
useEffect(function () {
|
|
6093
6106
|
if (!shouldCapture) return;
|
|
6094
|
-
|
|
6107
|
+
dispatchIdCaptureAction({
|
|
6095
6108
|
type: 'capturing'
|
|
6096
6109
|
});
|
|
6097
6110
|
var bestFrame = getBestFrame();
|
|
6098
6111
|
if (!bestFrame) {
|
|
6099
6112
|
log('uh oh, i did not get a photo');
|
|
6100
|
-
|
|
6113
|
+
dispatchIdCaptureAction({
|
|
6101
6114
|
type: 'captureFailed'
|
|
6102
6115
|
});
|
|
6103
6116
|
return;
|
|
@@ -6110,7 +6123,7 @@ var IdCapture = function IdCapture(_a) {
|
|
|
6110
6123
|
var width = canvas.width,
|
|
6111
6124
|
height = canvas.height;
|
|
6112
6125
|
var imageUrl = canvas.toDataURL('image/jpeg', 0.95);
|
|
6113
|
-
|
|
6126
|
+
dispatchIdCaptureAction({
|
|
6114
6127
|
type: 'frameCaptured',
|
|
6115
6128
|
payload: {
|
|
6116
6129
|
imageUrl: imageUrl
|
|
@@ -6128,11 +6141,11 @@ var IdCapture = function IdCapture(_a) {
|
|
|
6128
6141
|
bestFocusScore: focusScore
|
|
6129
6142
|
};
|
|
6130
6143
|
onCapture === null || onCapture === void 0 ? void 0 : onCapture(imageUrl, width, height, capturedDocumentType, metadata);
|
|
6131
|
-
|
|
6144
|
+
dispatchIdCaptureAction({
|
|
6132
6145
|
type: 'captured'
|
|
6133
6146
|
});
|
|
6134
6147
|
}, 0);
|
|
6135
|
-
}, [
|
|
6148
|
+
}, [getBestFrame, onCapture, shouldCapture, state.captureStartedAt, state.requestedDocumentType]);
|
|
6136
6149
|
var theme = useTheme();
|
|
6137
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');
|
|
6138
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');
|
|
@@ -6858,13 +6871,6 @@ var IdCaptureLoadingOverlayDefault = function IdCaptureLoadingOverlayDefault(_a)
|
|
|
6858
6871
|
var _q = useState(false),
|
|
6859
6872
|
dismissed = _q[0],
|
|
6860
6873
|
setDismissed = _q[1];
|
|
6861
|
-
var dispatch = useIdCaptureState()[1];
|
|
6862
|
-
useEffect(function () {
|
|
6863
|
-
dispatch({
|
|
6864
|
-
type: 'setUploadingDocumentsFromStorage',
|
|
6865
|
-
payload: false
|
|
6866
|
-
});
|
|
6867
|
-
}, [dispatch]);
|
|
6868
6874
|
assets.instructionImageUrl || (assets.instructionImageUrl = legacyInstructionImageUrl$1);
|
|
6869
6875
|
var verbiage = useTranslations(rawVerbiage, {
|
|
6870
6876
|
headingText: 'Use your device camera to capture your ID',
|
|
@@ -7849,9 +7855,7 @@ var IdCaptureGuideOverlay = function IdCaptureGuideOverlay(_a) {
|
|
|
7849
7855
|
wrapperAspectRatio = _1.wrapperAspectRatio,
|
|
7850
7856
|
guideOrientationOnImageLoaded = _1.onImageLoaded,
|
|
7851
7857
|
setDimensions = _1.setDimensions;
|
|
7852
|
-
var
|
|
7853
|
-
state = _2[0],
|
|
7854
|
-
dispatch = _2[1];
|
|
7858
|
+
var state = useIdCaptureStore();
|
|
7855
7859
|
var theme = useTheme();
|
|
7856
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;
|
|
7857
7861
|
useEffect(function () {
|
|
@@ -7877,14 +7881,14 @@ var IdCaptureGuideOverlay = function IdCaptureGuideOverlay(_a) {
|
|
|
7877
7881
|
var imageByUrl = imagesByUrl[img.src];
|
|
7878
7882
|
var width = (_a = imageByUrl === null || imageByUrl === void 0 ? void 0 : imageByUrl.width) !== null && _a !== void 0 ? _a : img.naturalWidth;
|
|
7879
7883
|
var height = (_b = imageByUrl === null || imageByUrl === void 0 ? void 0 : imageByUrl.height) !== null && _b !== void 0 ? _b : img.naturalHeight;
|
|
7880
|
-
|
|
7884
|
+
dispatchIdCaptureAction({
|
|
7881
7885
|
type: 'guideImageLoaded',
|
|
7882
7886
|
payload: {
|
|
7883
7887
|
width: width,
|
|
7884
7888
|
height: height
|
|
7885
7889
|
}
|
|
7886
7890
|
});
|
|
7887
|
-
}, [
|
|
7891
|
+
}, [guideOrientationOnImageLoaded, imagesByUrl]);
|
|
7888
7892
|
return /*#__PURE__*/React__default.createElement(StyledPageContainer, {
|
|
7889
7893
|
ref: wrapperRef,
|
|
7890
7894
|
onClick: onClick,
|
|
@@ -8014,19 +8018,17 @@ var IdCaptureFitGuide = function IdCaptureFitGuide(_a) {
|
|
|
8014
8018
|
images = _w === void 0 ? defaultIdCaptureGuideImages : _w,
|
|
8015
8019
|
_x = _a.classNames,
|
|
8016
8020
|
classNames = _x === void 0 ? {} : _x;
|
|
8017
|
-
var _y =
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
|
|
8021
|
-
guideImageHeight = _z.guideImageHeight,
|
|
8022
|
-
dispatch = _y[1];
|
|
8021
|
+
var _y = useIdCaptureStore(),
|
|
8022
|
+
redrawing = _y.redrawing,
|
|
8023
|
+
guideImageWidth = _y.guideImageWidth,
|
|
8024
|
+
guideImageHeight = _y.guideImageHeight;
|
|
8023
8025
|
var canvasRef = useRef(null);
|
|
8024
|
-
var
|
|
8025
|
-
wrapperRef =
|
|
8026
|
-
|
|
8027
|
-
wrapperWidth =
|
|
8028
|
-
|
|
8029
|
-
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;
|
|
8030
8032
|
var theme = useTheme();
|
|
8031
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;
|
|
8032
8034
|
if (padding === undefined) {
|
|
@@ -8044,7 +8046,7 @@ var IdCaptureFitGuide = function IdCaptureFitGuide(_a) {
|
|
|
8044
8046
|
if (redrawing) {
|
|
8045
8047
|
resetCanvasDimensions(canvas);
|
|
8046
8048
|
var timer_1 = setTimeout(function () {
|
|
8047
|
-
|
|
8049
|
+
dispatchIdCaptureAction({
|
|
8048
8050
|
type: 'redrawInProgress'
|
|
8049
8051
|
});
|
|
8050
8052
|
}, 10);
|
|
@@ -8094,7 +8096,7 @@ var IdCaptureFitGuide = function IdCaptureFitGuide(_a) {
|
|
|
8094
8096
|
// reset composite mode to default
|
|
8095
8097
|
ctx.globalCompositeOperation = 'source-over';
|
|
8096
8098
|
var rectOffsetTop = canvas.offsetTop;
|
|
8097
|
-
|
|
8099
|
+
dispatchIdCaptureAction({
|
|
8098
8100
|
type: 'redrawCompleted',
|
|
8099
8101
|
payload: {
|
|
8100
8102
|
guideRectX: rectX,
|
|
@@ -8105,7 +8107,7 @@ var IdCaptureFitGuide = function IdCaptureFitGuide(_a) {
|
|
|
8105
8107
|
}
|
|
8106
8108
|
});
|
|
8107
8109
|
return function () {};
|
|
8108
|
-
}, [aspectRatio, borderColor, borderRadius, borderWidth,
|
|
8110
|
+
}, [aspectRatio, borderColor, borderRadius, borderWidth, maskColor, padding, redrawing, wrapperHeight, wrapperWidth]);
|
|
8109
8111
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(CanvasWrapper$1, {
|
|
8110
8112
|
ref: wrapperRef,
|
|
8111
8113
|
"$maskColor": maskColor !== null && maskColor !== void 0 ? maskColor : '',
|
|
@@ -8155,7 +8157,7 @@ function IdCaptureGuides(_a) {
|
|
|
8155
8157
|
colors = _k === void 0 ? {} : _k,
|
|
8156
8158
|
_l = _a.verbiage,
|
|
8157
8159
|
rawVerbiage = _l === void 0 ? {} : _l;
|
|
8158
|
-
var state =
|
|
8160
|
+
var state = useIdCaptureStore();
|
|
8159
8161
|
var isRearFacing = useCameraStore(function (state) {
|
|
8160
8162
|
return state.isRearFacing;
|
|
8161
8163
|
});
|
|
@@ -9118,7 +9120,7 @@ var StyledButtonsRow$8 = styled(ButtonsRow)(templateObject_6$5 || (templateObjec
|
|
|
9118
9120
|
var templateObject_1$m, templateObject_2$k, templateObject_3$g, templateObject_4$a, templateObject_5$6, templateObject_6$5;
|
|
9119
9121
|
|
|
9120
9122
|
function ScalingCameraFeed() {
|
|
9121
|
-
var _a =
|
|
9123
|
+
var _a = useIdCaptureStore(),
|
|
9122
9124
|
captureState = _a.captureState,
|
|
9123
9125
|
guideRectX = _a.guideRectX,
|
|
9124
9126
|
guideRectY = _a.guideRectY,
|
|
@@ -9144,14 +9146,12 @@ function IdCaptureOrUploadScreen(_a) {
|
|
|
9144
9146
|
classNames = _b === void 0 ? {} : _b,
|
|
9145
9147
|
_c = _a.verbiage,
|
|
9146
9148
|
rawVerbiage = _c === void 0 ? {} : _c;
|
|
9147
|
-
var
|
|
9148
|
-
state = _d[0],
|
|
9149
|
-
dispatch = _d[1];
|
|
9149
|
+
var state = useIdCaptureStore();
|
|
9150
9150
|
var requestCameraAccess = useCameraStore().requestCameraAccess;
|
|
9151
9151
|
var loadModels = useContext(IdCaptureModelsContext).load;
|
|
9152
|
-
var
|
|
9153
|
-
selectIdTypeModalOpen =
|
|
9154
|
-
setSelectIdTypeModalOpen =
|
|
9152
|
+
var _d = useState(false),
|
|
9153
|
+
selectIdTypeModalOpen = _d[0],
|
|
9154
|
+
setSelectIdTypeModalOpen = _d[1];
|
|
9155
9155
|
var verbiage = useTranslations(rawVerbiage, {
|
|
9156
9156
|
captureWithCameraText: 'Capture with Camera',
|
|
9157
9157
|
orText: 'OR',
|
|
@@ -9183,7 +9183,7 @@ function IdCaptureOrUploadScreen(_a) {
|
|
|
9183
9183
|
onClick: function onClick() {
|
|
9184
9184
|
loadModels();
|
|
9185
9185
|
void requestCameraAccess();
|
|
9186
|
-
dispatch({
|
|
9186
|
+
state.dispatch({
|
|
9187
9187
|
type: 'setUploadingDocumentsFromStorage',
|
|
9188
9188
|
payload: false
|
|
9189
9189
|
});
|
|
@@ -9200,19 +9200,19 @@ function IdCaptureOrUploadScreen(_a) {
|
|
|
9200
9200
|
className: classNames.uploadFromStorageButton,
|
|
9201
9201
|
colors: buttonColors,
|
|
9202
9202
|
onClick: function onClick() {
|
|
9203
|
-
dispatch({
|
|
9203
|
+
state.dispatch({
|
|
9204
9204
|
type: 'setUploadingDocumentsFromStorage',
|
|
9205
9205
|
payload: true
|
|
9206
9206
|
});
|
|
9207
9207
|
if (state.captureRequirement === 'idCardOrPassport') {
|
|
9208
9208
|
setSelectIdTypeModalOpen(true);
|
|
9209
9209
|
} else if (state.captureRequirement === 'passport') {
|
|
9210
|
-
dispatch({
|
|
9210
|
+
state.dispatch({
|
|
9211
9211
|
type: 'setUploadingDocumentsType',
|
|
9212
9212
|
payload: 'passport'
|
|
9213
9213
|
});
|
|
9214
9214
|
} else {
|
|
9215
|
-
dispatch({
|
|
9215
|
+
state.dispatch({
|
|
9216
9216
|
type: 'setUploadingDocumentsType',
|
|
9217
9217
|
payload: 'idCard'
|
|
9218
9218
|
});
|
|
@@ -9232,7 +9232,7 @@ function IdCaptureOrUploadScreen(_a) {
|
|
|
9232
9232
|
className: classNames.selectPassportTypeButton,
|
|
9233
9233
|
colors: buttonColors,
|
|
9234
9234
|
onClick: function onClick() {
|
|
9235
|
-
return dispatch({
|
|
9235
|
+
return state.dispatch({
|
|
9236
9236
|
type: 'setUploadingDocumentsType',
|
|
9237
9237
|
payload: 'passport'
|
|
9238
9238
|
});
|
|
@@ -9245,7 +9245,7 @@ function IdCaptureOrUploadScreen(_a) {
|
|
|
9245
9245
|
className: classNames.selectIdCardTypeButton,
|
|
9246
9246
|
colors: buttonColors,
|
|
9247
9247
|
onClick: function onClick() {
|
|
9248
|
-
return dispatch({
|
|
9248
|
+
return state.dispatch({
|
|
9249
9249
|
type: 'setUploadingDocumentsType',
|
|
9250
9250
|
payload: 'idCard'
|
|
9251
9251
|
});
|
|
@@ -9296,20 +9296,18 @@ function PassportUploadScreen(_a) {
|
|
|
9296
9296
|
}, verbiage.continueText)));
|
|
9297
9297
|
}
|
|
9298
9298
|
function IdDocumentUploadScreen(_a) {
|
|
9299
|
+
var _this = this;
|
|
9299
9300
|
var _b = _a.classNames,
|
|
9300
9301
|
classNames = _b === void 0 ? {} : _b,
|
|
9301
9302
|
_c = _a.verbiage,
|
|
9302
9303
|
rawVerbiage = _c === void 0 ? {} : _c;
|
|
9303
|
-
var
|
|
9304
|
-
|
|
9305
|
-
|
|
9304
|
+
var state = useIdCaptureStore();
|
|
9305
|
+
var _d = useState(null),
|
|
9306
|
+
idFrontFile = _d[0],
|
|
9307
|
+
setIdFrontFile = _d[1];
|
|
9306
9308
|
var _e = useState(null),
|
|
9307
|
-
|
|
9308
|
-
|
|
9309
|
-
var _f = useState(null),
|
|
9310
|
-
idBackFile = _f[0],
|
|
9311
|
-
setIdBackFile = _f[1];
|
|
9312
|
-
var onCapturedManually = useOnCapturedManually();
|
|
9309
|
+
idBackFile = _e[0],
|
|
9310
|
+
setIdBackFile = _e[1];
|
|
9313
9311
|
var verbiage = useTranslations(rawVerbiage, {
|
|
9314
9312
|
uploadIdFrontText: 'Upload ID Front',
|
|
9315
9313
|
uploadIdBackText: 'Upload ID Back',
|
|
@@ -9349,25 +9347,56 @@ function IdDocumentUploadScreen(_a) {
|
|
|
9349
9347
|
disabled: !idFrontFile || !state.allowSinglePageIdCapture && !idBackFile,
|
|
9350
9348
|
colors: buttonColors,
|
|
9351
9349
|
onClick: function onClick() {
|
|
9352
|
-
|
|
9353
|
-
|
|
9354
|
-
|
|
9355
|
-
|
|
9350
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
9351
|
+
var _a, _b, _c, _d, _e;
|
|
9352
|
+
var _f, _g, _h, _j, _k;
|
|
9353
|
+
return __generator(this, function (_l) {
|
|
9354
|
+
switch (_l.label) {
|
|
9355
|
+
case 0:
|
|
9356
|
+
if (!(!idBackFile && state.allowSinglePageIdCapture)) return [3 /*break*/, 2];
|
|
9357
|
+
state.dispatch({
|
|
9358
|
+
type: 'setUploadingDocumentsType',
|
|
9359
|
+
payload: 'singlePage'
|
|
9360
|
+
});
|
|
9361
|
+
_b = (_a = state).dispatch;
|
|
9362
|
+
_f = {
|
|
9363
|
+
type: 'documentCaptured'
|
|
9364
|
+
};
|
|
9365
|
+
_g = {};
|
|
9366
|
+
return [4 /*yield*/, readFile(idFrontFile)];
|
|
9367
|
+
case 1:
|
|
9368
|
+
_b.apply(_a, [(_f.payload = (_g.imageData = _l.sent(), _g.documentType = 'singlePage', _g.width = 0, _g.height = 0, _g), _f)]);
|
|
9369
|
+
return [3 /*break*/, 5];
|
|
9370
|
+
case 2:
|
|
9371
|
+
_d = (_c = state).dispatch;
|
|
9372
|
+
_h = {
|
|
9373
|
+
type: 'documentsCaptured'
|
|
9374
|
+
};
|
|
9375
|
+
_j = {};
|
|
9376
|
+
return [4 /*yield*/, readFile(idFrontFile)];
|
|
9377
|
+
case 3:
|
|
9378
|
+
_e = [(_j.imageData = _l.sent(), _j.documentType = 'idCardFront', _j.width = 0, _j.height = 0, _j)];
|
|
9379
|
+
_k = {};
|
|
9380
|
+
return [4 /*yield*/, readFile(idBackFile)];
|
|
9381
|
+
case 4:
|
|
9382
|
+
_d.apply(_c, [(_h.payload = _e.concat([(_k.imageData = _l.sent(), _k.documentType = 'idCardBack', _k.width = 0, _k.height = 0, _k)]), _h)]);
|
|
9383
|
+
_l.label = 5;
|
|
9384
|
+
case 5:
|
|
9385
|
+
return [2 /*return*/];
|
|
9386
|
+
}
|
|
9356
9387
|
});
|
|
9357
|
-
}
|
|
9358
|
-
void onCapturedManually(idFrontFile, idBackFile);
|
|
9388
|
+
});
|
|
9359
9389
|
}
|
|
9360
9390
|
}, verbiage.continueText)));
|
|
9361
9391
|
}
|
|
9362
9392
|
function CancelUploadTypeButton(_a) {
|
|
9363
9393
|
var children = _a.children,
|
|
9364
9394
|
className = _a.className;
|
|
9365
|
-
var dispatch = useIdCaptureState()[1];
|
|
9366
9395
|
return /*#__PURE__*/React__default.createElement(Button, {
|
|
9367
9396
|
className: className,
|
|
9368
9397
|
colors: buttonColors,
|
|
9369
9398
|
onClick: function onClick() {
|
|
9370
|
-
return
|
|
9399
|
+
return dispatchIdCaptureAction({
|
|
9371
9400
|
type: 'setUploadingDocumentsType',
|
|
9372
9401
|
payload: null
|
|
9373
9402
|
});
|
|
@@ -9375,7 +9404,6 @@ function CancelUploadTypeButton(_a) {
|
|
|
9375
9404
|
}, children);
|
|
9376
9405
|
}
|
|
9377
9406
|
function useOnCapturedManually() {
|
|
9378
|
-
var dispatch = useIdCaptureState()[1];
|
|
9379
9407
|
return useCallback(function () {
|
|
9380
9408
|
var files = [];
|
|
9381
9409
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
@@ -9384,7 +9412,7 @@ function useOnCapturedManually() {
|
|
|
9384
9412
|
return Promise.all(files.filter(Boolean).map(readFile)).then(function (f) {
|
|
9385
9413
|
for (var _i = 0, f_1 = f; _i < f_1.length; _i++) {
|
|
9386
9414
|
var imageData = f_1[_i];
|
|
9387
|
-
|
|
9415
|
+
dispatchIdCaptureAction({
|
|
9388
9416
|
type: 'documentCapturedManually',
|
|
9389
9417
|
payload: {
|
|
9390
9418
|
imageData: imageData
|
|
@@ -9392,7 +9420,7 @@ function useOnCapturedManually() {
|
|
|
9392
9420
|
});
|
|
9393
9421
|
}
|
|
9394
9422
|
});
|
|
9395
|
-
}, [
|
|
9423
|
+
}, []);
|
|
9396
9424
|
}
|
|
9397
9425
|
function readFile(file) {
|
|
9398
9426
|
return new Promise(function (resolve, reject) {
|
|
@@ -9796,32 +9824,30 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
9796
9824
|
verbiage = _3 === void 0 ? {} : _3,
|
|
9797
9825
|
_4 = _a.debugMode,
|
|
9798
9826
|
debugMode = _4 === void 0 ? false : _4;
|
|
9799
|
-
var
|
|
9800
|
-
|
|
9801
|
-
|
|
9802
|
-
|
|
9803
|
-
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
|
|
9807
|
-
|
|
9808
|
-
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
-
|
|
9812
|
-
|
|
9813
|
-
|
|
9814
|
-
|
|
9815
|
-
|
|
9816
|
-
|
|
9817
|
-
|
|
9818
|
-
|
|
9819
|
-
|
|
9820
|
-
|
|
9821
|
-
modelError = _9.modelError,
|
|
9822
|
-
resetBestFrame = _9.resetBestFrame;
|
|
9827
|
+
var state = useIdCaptureStore();
|
|
9828
|
+
var _5 = useCameraStore(),
|
|
9829
|
+
cameraAccessDenied = _5.cameraAccessDenied,
|
|
9830
|
+
requestCameraAccess = _5.requestCameraAccess,
|
|
9831
|
+
releaseCameraAccess = _5.releaseCameraAccess;
|
|
9832
|
+
var _6 = useState(false),
|
|
9833
|
+
overlayDismissed = _6[0],
|
|
9834
|
+
setOverlayDismissed = _6[1];
|
|
9835
|
+
var _7 = useContext(SubmissionContext),
|
|
9836
|
+
submissionStatus = _7.submissionStatus,
|
|
9837
|
+
setIdFrontImage = _7.setIdFrontImage,
|
|
9838
|
+
setIdBackImage = _7.setIdBackImage,
|
|
9839
|
+
setPassportImage = _7.setPassportImage,
|
|
9840
|
+
logIdFrontCaptureAttempt = _7.logIdFrontCaptureAttempt,
|
|
9841
|
+
logIdBackCaptureAttempt = _7.logIdBackCaptureAttempt;
|
|
9842
|
+
var _8 = useContext(IdCaptureModelsContext),
|
|
9843
|
+
start = _8.start,
|
|
9844
|
+
stop = _8.stop,
|
|
9845
|
+
onPredictionMade = _8.onPredictionMade,
|
|
9846
|
+
setRequiredDocumentType = _8.setRequiredDocumentType,
|
|
9847
|
+
modelError = _8.modelError,
|
|
9848
|
+
resetBestFrame = _8.resetBestFrame;
|
|
9823
9849
|
useEffect(function () {
|
|
9824
|
-
|
|
9850
|
+
dispatchIdCaptureAction({
|
|
9825
9851
|
type: 'configureWizard',
|
|
9826
9852
|
payload: {
|
|
9827
9853
|
captureRequirement: captureRequirement,
|
|
@@ -9833,7 +9859,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
9833
9859
|
allowUploadingDocumentsFromStorage: allowUploadingDocumentsFromStorage
|
|
9834
9860
|
}
|
|
9835
9861
|
});
|
|
9836
|
-
}, [allowIdCardBackToFrontCapture, allowOverrideWrongDocumentTypeAfterMs, allowSinglePageIdCapture, allowUploadingDocumentsFromStorage, captureRequirement,
|
|
9862
|
+
}, [allowIdCardBackToFrontCapture, allowOverrideWrongDocumentTypeAfterMs, allowSinglePageIdCapture, allowUploadingDocumentsFromStorage, captureRequirement, enableOverrideWrongDocumentTypeDialog, precapturedDocuments]);
|
|
9837
9863
|
var documentCount = Object.keys(state.capturedDocuments).length;
|
|
9838
9864
|
useEffect(function () {
|
|
9839
9865
|
if (documentCount) resetBestFrame();
|
|
@@ -9849,15 +9875,15 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
9849
9875
|
}, [logIdBackCaptureAttempt, logIdFrontCaptureAttempt, state.operationStartedAt, state.requestedDocumentType]);
|
|
9850
9876
|
useEffect(function startModelsWhenCapturing() {
|
|
9851
9877
|
if (!overlayDismissed || state.captureState !== 'capturing') return;
|
|
9852
|
-
|
|
9878
|
+
dispatchIdCaptureAction({
|
|
9853
9879
|
type: 'captureStarted'
|
|
9854
9880
|
});
|
|
9855
9881
|
start();
|
|
9856
|
-
}, [
|
|
9882
|
+
}, [overlayDismissed, start, state.captureState]);
|
|
9857
9883
|
useEffect(function () {
|
|
9858
9884
|
onPredictionMade(function (prediction) {
|
|
9859
9885
|
if (state.captureState === 'capturing') {
|
|
9860
|
-
|
|
9886
|
+
dispatchIdCaptureAction({
|
|
9861
9887
|
type: 'objectsDetected',
|
|
9862
9888
|
payload: {
|
|
9863
9889
|
prediction: prediction
|
|
@@ -9866,19 +9892,19 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
9866
9892
|
} else if (state.captureState === 'requestingFlip') {
|
|
9867
9893
|
if (state.requestedDocumentType !== 'selfie' && prediction["".concat(state.requestedDocumentType, "DetectionThresholdMet")]) {
|
|
9868
9894
|
resetBestFrame();
|
|
9869
|
-
|
|
9895
|
+
dispatchIdCaptureAction({
|
|
9870
9896
|
type: 'flipRequestCompleted'
|
|
9871
9897
|
});
|
|
9872
9898
|
}
|
|
9873
9899
|
}
|
|
9874
9900
|
});
|
|
9875
|
-
}, [
|
|
9901
|
+
}, [onPredictionMade, resetBestFrame, state.captureState, state.requestedDocumentType]);
|
|
9876
9902
|
useEffect(function () {
|
|
9877
9903
|
if (state.captureState === 'complete') stop();
|
|
9878
9904
|
}, [state.captureState, stop]);
|
|
9879
9905
|
var onCapture = useCallback(function (imageData, width, height, documentType, metadata) {
|
|
9880
9906
|
logCaptureMetadata(metadata);
|
|
9881
|
-
|
|
9907
|
+
dispatchIdCaptureAction({
|
|
9882
9908
|
type: 'documentCaptured',
|
|
9883
9909
|
payload: {
|
|
9884
9910
|
imageData: imageData,
|
|
@@ -9890,7 +9916,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
9890
9916
|
focusScore: metadata.bestFocusScore
|
|
9891
9917
|
}
|
|
9892
9918
|
});
|
|
9893
|
-
}, [
|
|
9919
|
+
}, [logCaptureMetadata]);
|
|
9894
9920
|
var onSubmitClick = useCallback(function () {
|
|
9895
9921
|
var _a = state.capturedDocuments,
|
|
9896
9922
|
idCardFront = _a.idCardFront,
|
|
@@ -9916,25 +9942,25 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
9916
9942
|
}, [onSuccess, releaseCameraAccess, releaseCameraAccessOnExit, setIdBackImage, setIdFrontImage, setPassportImage, state.capturedDocuments]);
|
|
9917
9943
|
var showSuccessScreen = useShowSuccessScreen(skipSuccessScreen, state.captureState === 'complete', onSubmitClick);
|
|
9918
9944
|
var onRetryClick = useCallback(function () {
|
|
9919
|
-
|
|
9945
|
+
return dispatchIdCaptureAction({
|
|
9920
9946
|
type: 'resetWizard'
|
|
9921
9947
|
});
|
|
9922
|
-
}, [
|
|
9923
|
-
var
|
|
9924
|
-
attempt =
|
|
9925
|
-
setAttempt =
|
|
9948
|
+
}, []);
|
|
9949
|
+
var _9 = useState(0),
|
|
9950
|
+
attempt = _9[0],
|
|
9951
|
+
setAttempt = _9[1];
|
|
9926
9952
|
var onExit = useCallback(function () {
|
|
9927
9953
|
releaseCameraAccess();
|
|
9928
9954
|
setOverlayDismissed(false);
|
|
9929
9955
|
setAttempt(function (n) {
|
|
9930
9956
|
return n + 1;
|
|
9931
9957
|
});
|
|
9932
|
-
|
|
9958
|
+
dispatchIdCaptureAction({
|
|
9933
9959
|
type: 'resetWizard'
|
|
9934
9960
|
});
|
|
9935
9961
|
onExitCapture === null || onExitCapture === void 0 ? void 0 : onExitCapture();
|
|
9936
9962
|
void requestCameraAccess();
|
|
9937
|
-
}, [
|
|
9963
|
+
}, [onExitCapture, releaseCameraAccess, requestCameraAccess]);
|
|
9938
9964
|
useEffect(function () {
|
|
9939
9965
|
if (submissionStatus !== SubmissionStatus.READY) {
|
|
9940
9966
|
if (releaseCameraAccessOnExit) releaseCameraAccess();
|
|
@@ -9967,14 +9993,14 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
9967
9993
|
if (state.captureState !== 'requestingFlip') return;
|
|
9968
9994
|
var t = setTimeout(function () {
|
|
9969
9995
|
resetBestFrame();
|
|
9970
|
-
|
|
9996
|
+
dispatchIdCaptureAction({
|
|
9971
9997
|
type: 'flipRequestCompleted'
|
|
9972
9998
|
});
|
|
9973
9999
|
}, 6000);
|
|
9974
10000
|
return function () {
|
|
9975
10001
|
clearTimeout(t);
|
|
9976
10002
|
};
|
|
9977
|
-
}, [
|
|
10003
|
+
}, [resetBestFrame, separateIdCardCaptureSequence, state.captureState]);
|
|
9978
10004
|
useEffect(function () {
|
|
9979
10005
|
if (state.requestedDocumentType === 'idCardFront') {
|
|
9980
10006
|
if (captureRequirement === 'idCardOrPassport') {
|
|
@@ -10002,7 +10028,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
10002
10028
|
return [4 /*yield*/, dataUrlToBase64(imageData)];
|
|
10003
10029
|
case 1:
|
|
10004
10030
|
base64ImageData = _a.sent();
|
|
10005
|
-
|
|
10031
|
+
dispatchIdCaptureAction({
|
|
10006
10032
|
type: 'documentCapturedManually',
|
|
10007
10033
|
payload: {
|
|
10008
10034
|
imageData: base64ImageData
|
|
@@ -10012,10 +10038,10 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
10012
10038
|
}
|
|
10013
10039
|
});
|
|
10014
10040
|
});
|
|
10015
|
-
}, [
|
|
10016
|
-
var
|
|
10017
|
-
progressStarted =
|
|
10018
|
-
setProgressStarted =
|
|
10041
|
+
}, []);
|
|
10042
|
+
var _10 = useState(false),
|
|
10043
|
+
progressStarted = _10[0],
|
|
10044
|
+
setProgressStarted = _10[1];
|
|
10019
10045
|
useEffect(function () {
|
|
10020
10046
|
if (state.captureState === 'capturing') {
|
|
10021
10047
|
setProgressStarted(false);
|
|
@@ -10095,7 +10121,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
10095
10121
|
capturedDocuments: state.capturedDocuments,
|
|
10096
10122
|
classNames: classNames.success,
|
|
10097
10123
|
onSubmitClick: function onSubmitClick() {
|
|
10098
|
-
|
|
10124
|
+
return dispatchIdCaptureAction({
|
|
10099
10125
|
type: 'flipRequestCompleted'
|
|
10100
10126
|
});
|
|
10101
10127
|
},
|