idmission-web-sdk 1.0.196 → 1.0.197
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/IdCaptureStateProvider.d.ts +31 -2
- package/dist/sdk2.cjs.development.js +158 -180
- 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 +158 -180
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +158 -180
- package/dist/sdk2.umd.development.js.map +1 -1
- package/dist/sdk2.umd.production.js +1 -1
- package/dist/sdk2.umd.production.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React, { Dispatch, ReactNode } from 'react';
|
|
2
|
-
import { CapturedDocumentType } from './CapturedDocuments';
|
|
2
|
+
import { CapturedDocument, CapturedDocuments, CapturedDocumentType } from './CapturedDocuments';
|
|
3
3
|
import { IdCapturePrediction } from './IdCaptureModelsProvider';
|
|
4
4
|
import { PDF417DetectionResult } from '../../lib/barcode/Native';
|
|
5
5
|
import { DetectedObject, DocumentType } from '../../lib/models/DocumentDetection';
|
|
6
|
+
import { IdCaptureRequirementOption } from './IdCaptureRequirementOption';
|
|
7
|
+
export type CaptureState = 'capturing' | 'complete' | 'requestingFlip';
|
|
6
8
|
export type IdCaptureState = {
|
|
7
9
|
initialDrawComplete: boolean;
|
|
8
10
|
redrawing: boolean;
|
|
@@ -52,9 +54,21 @@ export type IdCaptureState = {
|
|
|
52
54
|
captured: boolean;
|
|
53
55
|
captureFailed: boolean;
|
|
54
56
|
imageUrl: string | null;
|
|
57
|
+
captureState: CaptureState;
|
|
58
|
+
capturedDocuments: CapturedDocuments;
|
|
59
|
+
captureRequirement: IdCaptureRequirementOption;
|
|
60
|
+
requestedDocumentType: CapturedDocumentType;
|
|
61
|
+
detectedDocumentType: DocumentType;
|
|
62
|
+
differentDocumentTypeDetections: number;
|
|
55
63
|
};
|
|
56
64
|
export type IdCaptureAction = {
|
|
57
|
-
type: '
|
|
65
|
+
type: 'configureWizard';
|
|
66
|
+
payload: {
|
|
67
|
+
captureRequirement: IdCaptureRequirementOption;
|
|
68
|
+
precapturedDocuments?: CapturedDocuments;
|
|
69
|
+
};
|
|
70
|
+
} | {
|
|
71
|
+
type: 'configureCapture';
|
|
58
72
|
payload: {
|
|
59
73
|
requiredDocumentType?: CapturedDocumentType;
|
|
60
74
|
goodFramesThreshold: number;
|
|
@@ -110,6 +124,21 @@ export type IdCaptureAction = {
|
|
|
110
124
|
};
|
|
111
125
|
} | {
|
|
112
126
|
type: 'barcodeScanFailed';
|
|
127
|
+
} | {
|
|
128
|
+
type: 'predictionMade';
|
|
129
|
+
payload: IdCapturePrediction;
|
|
130
|
+
} | {
|
|
131
|
+
type: 'documentCaptured';
|
|
132
|
+
payload: CapturedDocument;
|
|
133
|
+
} | {
|
|
134
|
+
type: 'documentCapturedManually';
|
|
135
|
+
payload: {
|
|
136
|
+
imageData: string;
|
|
137
|
+
};
|
|
138
|
+
} | {
|
|
139
|
+
type: 'flipRequestCompleted';
|
|
140
|
+
} | {
|
|
141
|
+
type: 'resetWizard';
|
|
113
142
|
};
|
|
114
143
|
export type IdCaptureDispatch = Dispatch<IdCaptureAction>;
|
|
115
144
|
export declare const IdCaptureStateContext: React.Context<IdCaptureState>;
|
|
@@ -48,7 +48,7 @@ var LanguageDetector__default = /*#__PURE__*/_interopDefaultLegacy(LanguageDetec
|
|
|
48
48
|
var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
|
|
49
49
|
var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
|
|
50
50
|
|
|
51
|
-
var webSdkVersion = '1.0.
|
|
51
|
+
var webSdkVersion = '1.0.197';
|
|
52
52
|
|
|
53
53
|
function getPlatform() {
|
|
54
54
|
if (typeof window === 'undefined') return;
|
|
@@ -9032,7 +9032,6 @@ function makeDocumentDetectionPredictions(image, logPredictions) {
|
|
|
9032
9032
|
_e.label = 1;
|
|
9033
9033
|
case 1:
|
|
9034
9034
|
_e.trys.push([1, 7, 8, 9]);
|
|
9035
|
-
console.log(' Tensors before:', tf__namespace.memory().numTensors);
|
|
9036
9035
|
tf__namespace.engine().startScope();
|
|
9037
9036
|
tfImg = tf__namespace.browser.fromPixels(image);
|
|
9038
9037
|
if (logPredictions) console.time('resize');
|
|
@@ -9088,8 +9087,6 @@ function makeDocumentDetectionPredictions(image, logPredictions) {
|
|
|
9088
9087
|
}];
|
|
9089
9088
|
case 8:
|
|
9090
9089
|
tf__namespace.engine().endScope();
|
|
9091
|
-
// tf.engine().disposeVariables()
|
|
9092
|
-
console.log('Tensors afters:', tf__namespace.memory().numTensors);
|
|
9093
9090
|
return [7 /*endfinally*/];
|
|
9094
9091
|
case 9:
|
|
9095
9092
|
return [2 /*return*/];
|
|
@@ -9188,7 +9185,20 @@ function disposeTfBackend() {
|
|
|
9188
9185
|
}
|
|
9189
9186
|
}
|
|
9190
9187
|
|
|
9191
|
-
var
|
|
9188
|
+
var CapturedDocumentTypeValues = ['idCardFront', 'idCardBack', 'passport', 'selfie'];
|
|
9189
|
+
|
|
9190
|
+
var requiredDocumentsForOption = {
|
|
9191
|
+
passport: ['passport'],
|
|
9192
|
+
idCard: ['idCardFront', 'idCardBack'],
|
|
9193
|
+
idCardAndPassport: ['idCardFront', 'idCardBack', 'passport'],
|
|
9194
|
+
idCardOrPassport: ['idCardFront', 'idCardBack', 'passport'] // this one is so weird
|
|
9195
|
+
};
|
|
9196
|
+
function requiredImageCountForOption(idCaptureRequirement) {
|
|
9197
|
+
if (idCaptureRequirement === 'idCardOrPassport') return 1;
|
|
9198
|
+
return requiredDocumentsForOption[idCaptureRequirement].length;
|
|
9199
|
+
}
|
|
9200
|
+
|
|
9201
|
+
var initialState$4 = {
|
|
9192
9202
|
initialDrawComplete: false,
|
|
9193
9203
|
redrawing: false,
|
|
9194
9204
|
guideRectX: 0,
|
|
@@ -9235,13 +9245,44 @@ var initialState$5 = {
|
|
|
9235
9245
|
capturing: false,
|
|
9236
9246
|
captured: false,
|
|
9237
9247
|
captureFailed: false,
|
|
9238
|
-
imageUrl: null
|
|
9248
|
+
imageUrl: null,
|
|
9249
|
+
captureState: 'capturing',
|
|
9250
|
+
capturedDocuments: {},
|
|
9251
|
+
captureRequirement: 'idCardOrPassport',
|
|
9252
|
+
requestedDocumentType: 'idCardFront',
|
|
9253
|
+
detectedDocumentType: 'none',
|
|
9254
|
+
differentDocumentTypeDetections: 0
|
|
9239
9255
|
};
|
|
9240
|
-
var IdCaptureStateContext = /*#__PURE__*/React.createContext(initialState$
|
|
9256
|
+
var IdCaptureStateContext = /*#__PURE__*/React.createContext(initialState$4);
|
|
9241
9257
|
var IdCaptureDispatchContext = /*#__PURE__*/React.createContext(function () {});
|
|
9242
|
-
var reducer$
|
|
9258
|
+
var reducer$4 = function reducer(state, action) {
|
|
9259
|
+
var _a;
|
|
9243
9260
|
switch (action.type) {
|
|
9244
|
-
case '
|
|
9261
|
+
case 'configureWizard':
|
|
9262
|
+
{
|
|
9263
|
+
var _b = action.payload,
|
|
9264
|
+
captureRequirement = _b.captureRequirement,
|
|
9265
|
+
precapturedDocuments = _b.precapturedDocuments;
|
|
9266
|
+
var newState = tslib.__assign(tslib.__assign({}, state), {
|
|
9267
|
+
captureRequirement: captureRequirement
|
|
9268
|
+
});
|
|
9269
|
+
if (captureRequirement === 'passport') newState.requestedDocumentType = 'passport';
|
|
9270
|
+
if (precapturedDocuments) {
|
|
9271
|
+
for (var _i = 0, CapturedDocumentTypeValues_1 = CapturedDocumentTypeValues; _i < CapturedDocumentTypeValues_1.length; _i++) {
|
|
9272
|
+
var k = CapturedDocumentTypeValues_1[_i];
|
|
9273
|
+
var payload = precapturedDocuments[k];
|
|
9274
|
+
if (payload) {
|
|
9275
|
+
newState.requestedDocumentType = k;
|
|
9276
|
+
newState = reducer(newState, {
|
|
9277
|
+
type: 'documentCaptured',
|
|
9278
|
+
payload: payload
|
|
9279
|
+
});
|
|
9280
|
+
}
|
|
9281
|
+
}
|
|
9282
|
+
}
|
|
9283
|
+
return newState;
|
|
9284
|
+
}
|
|
9285
|
+
case 'configureCapture':
|
|
9245
9286
|
return tslib.__assign(tslib.__assign(tslib.__assign({}, state), action.payload), {
|
|
9246
9287
|
goodFramesCount: 0,
|
|
9247
9288
|
capturing: false,
|
|
@@ -9278,26 +9319,26 @@ var reducer$5 = function reducer(state, action) {
|
|
|
9278
9319
|
guideImageHeight: action.payload.height
|
|
9279
9320
|
});
|
|
9280
9321
|
case 'objectsDetected':
|
|
9281
|
-
var
|
|
9282
|
-
detectedObjects =
|
|
9283
|
-
detectionScore =
|
|
9284
|
-
detectionThresholdMet =
|
|
9285
|
-
detectedDocumentType =
|
|
9286
|
-
passportDetectionScore =
|
|
9287
|
-
passportDetectionThresholdMet =
|
|
9288
|
-
mrzDetectionScore =
|
|
9289
|
-
mrzDetectionThresholdMet =
|
|
9290
|
-
pdf417DetectionScore =
|
|
9291
|
-
pdf417DetectionThresholdMet =
|
|
9292
|
-
bestDocumentOrPassport =
|
|
9293
|
-
bestMrz =
|
|
9294
|
-
bestPdf417 =
|
|
9295
|
-
documentInBounds =
|
|
9296
|
-
documentTooClose =
|
|
9297
|
-
focusScore =
|
|
9298
|
-
focusThresholdMet =
|
|
9299
|
-
frameWidth =
|
|
9300
|
-
frameHeight =
|
|
9322
|
+
var _c = action.payload.prediction,
|
|
9323
|
+
detectedObjects = _c.detectedObjects,
|
|
9324
|
+
detectionScore = _c.detectionScore,
|
|
9325
|
+
detectionThresholdMet = _c.detectionThresholdMet,
|
|
9326
|
+
detectedDocumentType = _c.detectedDocumentType,
|
|
9327
|
+
passportDetectionScore = _c.passportDetectionScore,
|
|
9328
|
+
passportDetectionThresholdMet = _c.passportDetectionThresholdMet,
|
|
9329
|
+
mrzDetectionScore = _c.mrzDetectionScore,
|
|
9330
|
+
mrzDetectionThresholdMet = _c.mrzDetectionThresholdMet,
|
|
9331
|
+
pdf417DetectionScore = _c.pdf417DetectionScore,
|
|
9332
|
+
pdf417DetectionThresholdMet = _c.pdf417DetectionThresholdMet,
|
|
9333
|
+
bestDocumentOrPassport = _c.bestDocumentOrPassport,
|
|
9334
|
+
bestMrz = _c.bestMrz,
|
|
9335
|
+
bestPdf417 = _c.bestPdf417,
|
|
9336
|
+
documentInBounds = _c.documentInBounds,
|
|
9337
|
+
documentTooClose = _c.documentTooClose,
|
|
9338
|
+
focusScore = _c.focusScore,
|
|
9339
|
+
focusThresholdMet = _c.focusThresholdMet,
|
|
9340
|
+
frameWidth = _c.frameWidth,
|
|
9341
|
+
frameHeight = _c.frameHeight;
|
|
9301
9342
|
var frameCapturedAt = new Date();
|
|
9302
9343
|
var frameCaptureRate = 0;
|
|
9303
9344
|
var goodFramesThreshold = state.goodFramesThreshold;
|
|
@@ -9344,6 +9385,29 @@ var reducer$5 = function reducer(state, action) {
|
|
|
9344
9385
|
lastFrameCapturedAt: frameCapturedAt,
|
|
9345
9386
|
frameCaptureRate: frameCaptureRate
|
|
9346
9387
|
});
|
|
9388
|
+
case 'predictionMade':
|
|
9389
|
+
{
|
|
9390
|
+
var _d = action.payload,
|
|
9391
|
+
detectedDocumentType_1 = _d.detectedDocumentType,
|
|
9392
|
+
passportDetectionScore_1 = _d.passportDetectionScore;
|
|
9393
|
+
var requestedDocumentType = state.requestedDocumentType;
|
|
9394
|
+
var newState = tslib.__assign(tslib.__assign({}, state), {
|
|
9395
|
+
detectedDocumentType: detectedDocumentType_1
|
|
9396
|
+
});
|
|
9397
|
+
if (state.captureRequirement === 'idCardOrPassport') {
|
|
9398
|
+
var predictionIsRequestedType = requestedDocumentType.startsWith(detectedDocumentType_1);
|
|
9399
|
+
if (predictionIsRequestedType) {
|
|
9400
|
+
newState.differentDocumentTypeDetections = 0;
|
|
9401
|
+
}
|
|
9402
|
+
if (detectedDocumentType_1 === 'passport' && requestedDocumentType !== 'passport') {
|
|
9403
|
+
newState.requestedDocumentType = 'passport';
|
|
9404
|
+
}
|
|
9405
|
+
if (requestedDocumentType === 'passport' && passportDetectionScore_1 < 0.3) {
|
|
9406
|
+
newState.requestedDocumentType = 'idCardFront' in state.capturedDocuments ? 'idCardBack' : 'idCardFront';
|
|
9407
|
+
}
|
|
9408
|
+
}
|
|
9409
|
+
return newState;
|
|
9410
|
+
}
|
|
9347
9411
|
case 'barcodeScanned':
|
|
9348
9412
|
return tslib.__assign(tslib.__assign({}, state), {
|
|
9349
9413
|
barcodeResult: action.payload.result,
|
|
@@ -9384,13 +9448,64 @@ var reducer$5 = function reducer(state, action) {
|
|
|
9384
9448
|
captured: false,
|
|
9385
9449
|
captureFailed: true
|
|
9386
9450
|
});
|
|
9451
|
+
case 'documentCaptured':
|
|
9452
|
+
{
|
|
9453
|
+
var newState_1 = tslib.__assign(tslib.__assign({}, state), {
|
|
9454
|
+
capturedDocuments: tslib.__assign(tslib.__assign({}, state.capturedDocuments), (_a = {}, _a[state.requestedDocumentType] = action.payload, _a))
|
|
9455
|
+
});
|
|
9456
|
+
var remainingRequirements = requiredDocumentsForOption[state.captureRequirement].filter(function (v) {
|
|
9457
|
+
return !(v in newState_1.capturedDocuments);
|
|
9458
|
+
});
|
|
9459
|
+
if (state.captureRequirement === 'idCardOrPassport') {
|
|
9460
|
+
if (state.requestedDocumentType === 'passport') {
|
|
9461
|
+
remainingRequirements = [];
|
|
9462
|
+
} else {
|
|
9463
|
+
remainingRequirements = remainingRequirements.filter(function (v) {
|
|
9464
|
+
return v !== 'passport';
|
|
9465
|
+
});
|
|
9466
|
+
}
|
|
9467
|
+
}
|
|
9468
|
+
if (remainingRequirements.length === 0) {
|
|
9469
|
+
newState_1.captureState = 'complete';
|
|
9470
|
+
} else {
|
|
9471
|
+
newState_1.requestedDocumentType = remainingRequirements[0];
|
|
9472
|
+
if (state.requestedDocumentType === 'idCardFront' && newState_1.requestedDocumentType === 'idCardBack') {
|
|
9473
|
+
newState_1.captureState = 'requestingFlip';
|
|
9474
|
+
newState_1.documentDetectionThresholdMet = false;
|
|
9475
|
+
newState_1.passportPageDetectionThresholdMet = false;
|
|
9476
|
+
}
|
|
9477
|
+
}
|
|
9478
|
+
return newState_1;
|
|
9479
|
+
}
|
|
9480
|
+
case 'documentCapturedManually':
|
|
9481
|
+
{
|
|
9482
|
+
var newState = tslib.__assign({}, state);
|
|
9483
|
+
var capturedDocument = tslib.__assign(tslib.__assign({}, action.payload), {
|
|
9484
|
+
width: 0,
|
|
9485
|
+
height: 0
|
|
9486
|
+
});
|
|
9487
|
+
if (Object.keys(state.capturedDocuments).length === 0) {
|
|
9488
|
+
newState.capturedDocuments.passport = capturedDocument;
|
|
9489
|
+
} else {
|
|
9490
|
+
newState.capturedDocuments = {};
|
|
9491
|
+
newState.capturedDocuments.idCardFront = state.capturedDocuments.passport;
|
|
9492
|
+
newState.capturedDocuments.idCardBack = capturedDocument;
|
|
9493
|
+
}
|
|
9494
|
+
return newState;
|
|
9495
|
+
}
|
|
9496
|
+
case 'flipRequestCompleted':
|
|
9497
|
+
return tslib.__assign(tslib.__assign({}, state), {
|
|
9498
|
+
captureState: 'capturing'
|
|
9499
|
+
});
|
|
9500
|
+
case 'resetWizard':
|
|
9501
|
+
return tslib.__assign({}, initialState$4);
|
|
9387
9502
|
default:
|
|
9388
9503
|
return state;
|
|
9389
9504
|
}
|
|
9390
9505
|
};
|
|
9391
9506
|
var IdCaptureStateProvider = function IdCaptureStateProvider(_a) {
|
|
9392
9507
|
var children = _a.children;
|
|
9393
|
-
var _b = React.useReducer(reducer$
|
|
9508
|
+
var _b = React.useReducer(reducer$4, initialState$4),
|
|
9394
9509
|
state = _b[0],
|
|
9395
9510
|
dispatch = _b[1];
|
|
9396
9511
|
var onResize = useDebounce.useDebouncedCallback(function () {
|
|
@@ -9841,7 +9956,7 @@ var IdCapture = function IdCapture(_a) {
|
|
|
9841
9956
|
}, []);
|
|
9842
9957
|
React.useEffect(function () {
|
|
9843
9958
|
dispatch({
|
|
9844
|
-
type: '
|
|
9959
|
+
type: 'configureCapture',
|
|
9845
9960
|
payload: {
|
|
9846
9961
|
requiredDocumentType: requiredDocumentType,
|
|
9847
9962
|
goodFramesThreshold: autoCaptureGoodFramesRequired,
|
|
@@ -10270,8 +10385,6 @@ var IdCaptureLoadingOverlay = function IdCaptureLoadingOverlay(_a) {
|
|
|
10270
10385
|
};
|
|
10271
10386
|
var templateObject_1$s, templateObject_2$i;
|
|
10272
10387
|
|
|
10273
|
-
var CapturedDocumentTypeValues = ['idCardFront', 'idCardBack', 'passport', 'selfie'];
|
|
10274
|
-
|
|
10275
10388
|
var ButtonsRow = styled__default['default'].div(templateObject_1$r || (templateObject_1$r = tslib.__makeTemplateObject(["\n display: flex;\n gap: 0 15px;\n justify-content: center;\n"], ["\n display: flex;\n gap: 0 15px;\n justify-content: center;\n"])));
|
|
10276
10389
|
var templateObject_1$r;
|
|
10277
10390
|
|
|
@@ -10467,17 +10580,6 @@ function useShowSuccessScreen(skipSuccessScreen, successScreenReady, onDoneCallb
|
|
|
10467
10580
|
return !skipSuccessScreen || skipSuccessScreenResolvedFalse;
|
|
10468
10581
|
}
|
|
10469
10582
|
|
|
10470
|
-
var requiredDocumentsForOption = {
|
|
10471
|
-
passport: ['passport'],
|
|
10472
|
-
idCard: ['idCardFront', 'idCardBack'],
|
|
10473
|
-
idCardAndPassport: ['idCardFront', 'idCardBack', 'passport'],
|
|
10474
|
-
idCardOrPassport: ['idCardFront', 'idCardBack', 'passport'] // this one is so weird
|
|
10475
|
-
};
|
|
10476
|
-
function requiredImageCountForOption(idCaptureRequirement) {
|
|
10477
|
-
if (idCaptureRequirement === 'idCardOrPassport') return 1;
|
|
10478
|
-
return requiredDocumentsForOption[idCaptureRequirement].length;
|
|
10479
|
-
}
|
|
10480
|
-
|
|
10481
10583
|
var IdCaptureFallback = function IdCaptureFallback(_a) {
|
|
10482
10584
|
var _b = _a.idCaptureRequirement,
|
|
10483
10585
|
idCaptureRequirement = _b === void 0 ? 'idCardOrPassport' : _b,
|
|
@@ -11186,120 +11288,6 @@ var ImagePreviewText = styled__default['default'].div(templateObject_3$9 || (tem
|
|
|
11186
11288
|
var ImagePreviewImageWrapper = styled__default['default'].div(templateObject_4$5 || (templateObject_4$5 = tslib.__makeTemplateObject(["\n position: relative;\n height: calc(100% - 8px);\n padding: 4px;\n border-radius: 4px;\n background: white;\n\n & > img {\n border-radius: 4px;\n width: auto;\n max-height: 100%;\n }\n"], ["\n position: relative;\n height: calc(100% - 8px);\n padding: 4px;\n border-radius: 4px;\n background: white;\n\n & > img {\n border-radius: 4px;\n width: auto;\n max-height: 100%;\n }\n"])));
|
|
11187
11289
|
var templateObject_1$i, templateObject_2$c, templateObject_3$9, templateObject_4$5;
|
|
11188
11290
|
|
|
11189
|
-
var initialState$4 = {
|
|
11190
|
-
captureState: 'capturing',
|
|
11191
|
-
capturedDocuments: {},
|
|
11192
|
-
captureRequirement: 'idCardOrPassport',
|
|
11193
|
-
requestedDocumentType: 'idCardFront',
|
|
11194
|
-
detectedDocumentType: 'none',
|
|
11195
|
-
differentDocumentTypeDetections: 0,
|
|
11196
|
-
barcodeResult: null
|
|
11197
|
-
};
|
|
11198
|
-
var reducer$4 = function reducer(state, action) {
|
|
11199
|
-
var _a;
|
|
11200
|
-
switch (action.type) {
|
|
11201
|
-
case 'configure':
|
|
11202
|
-
{
|
|
11203
|
-
var _b = action.payload,
|
|
11204
|
-
captureRequirement = _b.captureRequirement,
|
|
11205
|
-
precapturedDocuments = _b.precapturedDocuments;
|
|
11206
|
-
var newState = tslib.__assign(tslib.__assign({}, state), {
|
|
11207
|
-
captureRequirement: captureRequirement
|
|
11208
|
-
});
|
|
11209
|
-
if (captureRequirement === 'passport') newState.requestedDocumentType = 'passport';
|
|
11210
|
-
if (precapturedDocuments) {
|
|
11211
|
-
for (var _i = 0, CapturedDocumentTypeValues_1 = CapturedDocumentTypeValues; _i < CapturedDocumentTypeValues_1.length; _i++) {
|
|
11212
|
-
var k = CapturedDocumentTypeValues_1[_i];
|
|
11213
|
-
var payload = precapturedDocuments[k];
|
|
11214
|
-
if (payload) {
|
|
11215
|
-
newState.requestedDocumentType = k;
|
|
11216
|
-
newState = reducer(newState, {
|
|
11217
|
-
type: 'imageCaptured',
|
|
11218
|
-
payload: payload
|
|
11219
|
-
});
|
|
11220
|
-
}
|
|
11221
|
-
}
|
|
11222
|
-
}
|
|
11223
|
-
return newState;
|
|
11224
|
-
}
|
|
11225
|
-
case 'predictionMade':
|
|
11226
|
-
{
|
|
11227
|
-
var _c = action.payload,
|
|
11228
|
-
detectedDocumentType = _c.detectedDocumentType,
|
|
11229
|
-
passportDetectionScore = _c.passportDetectionScore;
|
|
11230
|
-
var requestedDocumentType = state.requestedDocumentType;
|
|
11231
|
-
var newState = tslib.__assign(tslib.__assign({}, state), {
|
|
11232
|
-
detectedDocumentType: detectedDocumentType
|
|
11233
|
-
});
|
|
11234
|
-
if (state.captureRequirement === 'idCardOrPassport') {
|
|
11235
|
-
var predictionIsRequestedType = requestedDocumentType.startsWith(detectedDocumentType);
|
|
11236
|
-
if (predictionIsRequestedType) {
|
|
11237
|
-
newState.differentDocumentTypeDetections = 0;
|
|
11238
|
-
}
|
|
11239
|
-
if (detectedDocumentType === 'passport' && requestedDocumentType !== 'passport') {
|
|
11240
|
-
newState.requestedDocumentType = 'passport';
|
|
11241
|
-
}
|
|
11242
|
-
if (requestedDocumentType === 'passport' && passportDetectionScore < 0.3) {
|
|
11243
|
-
newState.requestedDocumentType = 'idCardFront' in state.capturedDocuments ? 'idCardBack' : 'idCardFront';
|
|
11244
|
-
}
|
|
11245
|
-
}
|
|
11246
|
-
return newState;
|
|
11247
|
-
}
|
|
11248
|
-
case 'barcodeScanned':
|
|
11249
|
-
return tslib.__assign(tslib.__assign({}, state), {
|
|
11250
|
-
barcodeResult: action.payload.result
|
|
11251
|
-
});
|
|
11252
|
-
case 'imageCaptured':
|
|
11253
|
-
{
|
|
11254
|
-
var newState_1 = tslib.__assign(tslib.__assign({}, state), {
|
|
11255
|
-
capturedDocuments: tslib.__assign(tslib.__assign({}, state.capturedDocuments), (_a = {}, _a[state.requestedDocumentType] = action.payload, _a))
|
|
11256
|
-
});
|
|
11257
|
-
var remainingRequirements = requiredDocumentsForOption[state.captureRequirement].filter(function (v) {
|
|
11258
|
-
return !(v in newState_1.capturedDocuments);
|
|
11259
|
-
});
|
|
11260
|
-
if (state.captureRequirement === 'idCardOrPassport') {
|
|
11261
|
-
if (state.requestedDocumentType === 'passport') {
|
|
11262
|
-
remainingRequirements = [];
|
|
11263
|
-
} else {
|
|
11264
|
-
remainingRequirements = remainingRequirements.filter(function (v) {
|
|
11265
|
-
return v !== 'passport';
|
|
11266
|
-
});
|
|
11267
|
-
}
|
|
11268
|
-
}
|
|
11269
|
-
if (remainingRequirements.length === 0) {
|
|
11270
|
-
newState_1.captureState = 'complete';
|
|
11271
|
-
} else {
|
|
11272
|
-
newState_1.requestedDocumentType = remainingRequirements[0];
|
|
11273
|
-
if (state.requestedDocumentType === 'idCardFront' && newState_1.requestedDocumentType === 'idCardBack') {
|
|
11274
|
-
newState_1.captureState = 'requestingFlip';
|
|
11275
|
-
}
|
|
11276
|
-
}
|
|
11277
|
-
return newState_1;
|
|
11278
|
-
}
|
|
11279
|
-
case 'imageCapturedManually':
|
|
11280
|
-
{
|
|
11281
|
-
var newState = tslib.__assign({}, state);
|
|
11282
|
-
var capturedDocument = tslib.__assign(tslib.__assign({}, action.payload), {
|
|
11283
|
-
width: 0,
|
|
11284
|
-
height: 0
|
|
11285
|
-
});
|
|
11286
|
-
if (Object.keys(state.capturedDocuments).length === 0) {
|
|
11287
|
-
newState.capturedDocuments.passport = capturedDocument;
|
|
11288
|
-
} else {
|
|
11289
|
-
newState.capturedDocuments = {};
|
|
11290
|
-
newState.capturedDocuments.idCardFront = state.capturedDocuments.passport;
|
|
11291
|
-
newState.capturedDocuments.idCardBack = capturedDocument;
|
|
11292
|
-
}
|
|
11293
|
-
return newState;
|
|
11294
|
-
}
|
|
11295
|
-
case 'flipRequestCompleted':
|
|
11296
|
-
return tslib.__assign(tslib.__assign({}, state), {
|
|
11297
|
-
captureState: 'capturing'
|
|
11298
|
-
});
|
|
11299
|
-
case 'reset':
|
|
11300
|
-
return tslib.__assign({}, initialState$4);
|
|
11301
|
-
}
|
|
11302
|
-
};
|
|
11303
11291
|
var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
11304
11292
|
var _b, _c, _d, _e, _f, _g;
|
|
11305
11293
|
var _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
@@ -11346,7 +11334,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
11346
11334
|
verbiage = _10 === void 0 ? {} : _10,
|
|
11347
11335
|
_11 = _a.debugMode,
|
|
11348
11336
|
debugMode = _11 === void 0 ? false : _11;
|
|
11349
|
-
var _12 =
|
|
11337
|
+
var _12 = useIdCaptureState(),
|
|
11350
11338
|
state = _12[0],
|
|
11351
11339
|
dispatch = _12[1];
|
|
11352
11340
|
var releaseCameraAccess = React.useContext(CameraStateContext).releaseCameraAccess;
|
|
@@ -11364,13 +11352,13 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
11364
11352
|
var operationStartedAt = React.useRef();
|
|
11365
11353
|
React.useEffect(function () {
|
|
11366
11354
|
dispatch({
|
|
11367
|
-
type: '
|
|
11355
|
+
type: 'configureWizard',
|
|
11368
11356
|
payload: {
|
|
11369
11357
|
captureRequirement: captureRequirement,
|
|
11370
11358
|
precapturedDocuments: precapturedDocuments
|
|
11371
11359
|
}
|
|
11372
11360
|
});
|
|
11373
|
-
}, [captureRequirement, precapturedDocuments]);
|
|
11361
|
+
}, [captureRequirement, dispatch, precapturedDocuments]);
|
|
11374
11362
|
var documentCount = Object.keys(state.capturedDocuments).length;
|
|
11375
11363
|
React.useEffect(function () {
|
|
11376
11364
|
operationStartedAt.current = new Date();
|
|
@@ -11385,19 +11373,11 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
11385
11373
|
type: 'predictionMade',
|
|
11386
11374
|
payload: prediction
|
|
11387
11375
|
});
|
|
11388
|
-
}, []);
|
|
11389
|
-
var onBarcodeScanned = React.useCallback(function (result) {
|
|
11390
|
-
dispatch({
|
|
11391
|
-
type: 'barcodeScanned',
|
|
11392
|
-
payload: {
|
|
11393
|
-
result: result
|
|
11394
|
-
}
|
|
11395
|
-
});
|
|
11396
|
-
}, []);
|
|
11376
|
+
}, [dispatch]);
|
|
11397
11377
|
var onCapture = React.useCallback(function (imageData, width, height, metadata) {
|
|
11398
11378
|
logCaptureMetadata(metadata);
|
|
11399
11379
|
dispatch({
|
|
11400
|
-
type: '
|
|
11380
|
+
type: 'documentCaptured',
|
|
11401
11381
|
payload: {
|
|
11402
11382
|
imageData: imageData,
|
|
11403
11383
|
width: width,
|
|
@@ -11405,7 +11385,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
11405
11385
|
boundingBox: metadata.boundingBox
|
|
11406
11386
|
}
|
|
11407
11387
|
});
|
|
11408
|
-
}, [logCaptureMetadata]);
|
|
11388
|
+
}, [dispatch, logCaptureMetadata]);
|
|
11409
11389
|
var onSubmitClick = React.useCallback(function () {
|
|
11410
11390
|
var _a = state.capturedDocuments,
|
|
11411
11391
|
idCardFront = _a.idCardFront,
|
|
@@ -11429,9 +11409,9 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
11429
11409
|
var showSuccessScreen = useShowSuccessScreen(skipSuccessScreen, state.captureState === 'complete', onSubmitClick);
|
|
11430
11410
|
var onRetryClick = React.useCallback(function () {
|
|
11431
11411
|
dispatch({
|
|
11432
|
-
type: '
|
|
11412
|
+
type: 'resetWizard'
|
|
11433
11413
|
});
|
|
11434
|
-
}, []);
|
|
11414
|
+
}, [dispatch]);
|
|
11435
11415
|
var _15 = React.useState(0),
|
|
11436
11416
|
attempt = _15[0],
|
|
11437
11417
|
setAttempt = _15[1];
|
|
@@ -11441,10 +11421,10 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
11441
11421
|
return n + 1;
|
|
11442
11422
|
});
|
|
11443
11423
|
dispatch({
|
|
11444
|
-
type: '
|
|
11424
|
+
type: 'resetWizard'
|
|
11445
11425
|
});
|
|
11446
11426
|
onExitCapture === null || onExitCapture === void 0 ? void 0 : onExitCapture();
|
|
11447
|
-
}, [onExitCapture]);
|
|
11427
|
+
}, [dispatch, onExitCapture]);
|
|
11448
11428
|
React.useEffect(function () {
|
|
11449
11429
|
if (submissionStatus !== SubmissionStatus.READY) {
|
|
11450
11430
|
releaseCameraAccessOnExit && releaseCameraAccess();
|
|
@@ -11493,14 +11473,14 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
11493
11473
|
});
|
|
11494
11474
|
}, 3500);
|
|
11495
11475
|
}
|
|
11496
|
-
}, [state.captureState]);
|
|
11476
|
+
}, [dispatch, state.captureState]);
|
|
11497
11477
|
if (modelsError) {
|
|
11498
11478
|
return /*#__PURE__*/React__default['default'].createElement(IdCaptureFallback, {
|
|
11499
11479
|
idCaptureRequirement: captureRequirement,
|
|
11500
11480
|
onFinished: onSubmitClick,
|
|
11501
11481
|
onCapture: function onCapture(imageData) {
|
|
11502
11482
|
dispatch({
|
|
11503
|
-
type: '
|
|
11483
|
+
type: 'documentCapturedManually',
|
|
11504
11484
|
payload: {
|
|
11505
11485
|
imageData: imageData
|
|
11506
11486
|
}
|
|
@@ -11555,7 +11535,6 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
11555
11535
|
mrzDetectionScoreThreshold: mrzDetectionScoreThreshold,
|
|
11556
11536
|
focusScoreThreshold: idCardFocusScoreThreshold,
|
|
11557
11537
|
onPrediction: onPrediction,
|
|
11558
|
-
onBarcodeScanned: onBarcodeScanned,
|
|
11559
11538
|
onCapture: onCapture,
|
|
11560
11539
|
assets: idCaptureAssets,
|
|
11561
11540
|
classNames: classNames === null || classNames === void 0 ? void 0 : classNames.capture,
|
|
@@ -11575,7 +11554,6 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
11575
11554
|
barcodeScanningEnabled: false,
|
|
11576
11555
|
focusScoreThreshold: passportFocusScoreThreshold,
|
|
11577
11556
|
onPrediction: onPrediction,
|
|
11578
|
-
onBarcodeScanned: onBarcodeScanned,
|
|
11579
11557
|
onCapture: onCapture,
|
|
11580
11558
|
assets: idCaptureAssets,
|
|
11581
11559
|
classNames: classNames === null || classNames === void 0 ? void 0 : classNames.capture,
|