idmission-web-sdk 2.2.67 → 2.2.68

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.
Files changed (38) hide show
  1. package/dist/components/CompositeWizard.d.ts.map +1 -1
  2. package/dist/components/customer_flows/IdValidation.d.ts +3 -1
  3. package/dist/components/customer_flows/IdValidation.d.ts.map +1 -1
  4. package/dist/components/fallback_flows/IdCapture.d.ts.map +1 -1
  5. package/dist/components/id_capture/CapturedDocuments.d.ts +1 -1
  6. package/dist/components/id_capture/CapturedDocuments.d.ts.map +1 -1
  7. package/dist/components/id_capture/IdCapture.d.ts +2 -2
  8. package/dist/components/id_capture/IdCapture.d.ts.map +1 -1
  9. package/dist/components/id_capture/IdCaptureModelsProvider.d.ts +2 -1
  10. package/dist/components/id_capture/IdCaptureModelsProvider.d.ts.map +1 -1
  11. package/dist/components/id_capture/IdCaptureRequirementOption.d.ts +7 -5
  12. package/dist/components/id_capture/IdCaptureRequirementOption.d.ts.map +1 -1
  13. package/dist/components/id_capture/IdCaptureStateProvider.d.ts +4 -0
  14. package/dist/components/id_capture/IdCaptureStateProvider.d.ts.map +1 -1
  15. package/dist/components/id_capture/IdCaptureSuccess.d.ts +0 -4
  16. package/dist/components/id_capture/IdCaptureSuccess.d.ts.map +1 -1
  17. package/dist/components/id_capture/IdCaptureWizard.d.ts +2 -1
  18. package/dist/components/id_capture/IdCaptureWizard.d.ts.map +1 -1
  19. package/dist/components/video_id/IdVideoCapture.d.ts +2 -0
  20. package/dist/components/video_id/IdVideoCapture.d.ts.map +1 -1
  21. package/dist/components/video_id/IdVideoCaptureWizard.d.ts.map +1 -1
  22. package/dist/lib/models/DocumentDetection.d.ts +6 -2
  23. package/dist/lib/models/DocumentDetection.d.ts.map +1 -1
  24. package/dist/lib/models/Focus.d.ts +4 -0
  25. package/dist/lib/models/Focus.d.ts.map +1 -1
  26. package/dist/lib/models/defaults/DocumentDetector.d.ts +1 -1
  27. package/dist/sdk2.cjs.development.js +353 -327
  28. package/dist/sdk2.cjs.development.js.map +1 -1
  29. package/dist/sdk2.cjs.production.js +1 -1
  30. package/dist/sdk2.cjs.production.js.map +1 -1
  31. package/dist/sdk2.esm.js +353 -327
  32. package/dist/sdk2.esm.js.map +1 -1
  33. package/dist/sdk2.umd.development.js +353 -327
  34. package/dist/sdk2.umd.development.js.map +1 -1
  35. package/dist/sdk2.umd.production.js +1 -1
  36. package/dist/sdk2.umd.production.js.map +1 -1
  37. package/dist/version.d.ts +1 -1
  38. package/package.json +3 -3
package/dist/sdk2.esm.js CHANGED
@@ -203,7 +203,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
203
203
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
204
204
  };
205
205
 
206
- var webSdkVersion = '2.2.67';
206
+ var webSdkVersion = '2.2.68';
207
207
 
208
208
  function getPlatform() {
209
209
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -2266,7 +2266,7 @@ function average(arr) {
2266
2266
 
2267
2267
  var DEFAULT_CDN_URL = 'https://websdk-cdn-dev.idmission.com/assets';
2268
2268
 
2269
- var defaultDocumentDetectorModelPath = "".concat(DEFAULT_CDN_URL, "/models/DocumentDetector/DocumentDetector-20241018_093000.tflite");
2269
+ var defaultDocumentDetectorModelPath = "".concat(DEFAULT_CDN_URL, "/models/DocumentDetector/DocumentDetector-20241212_131026.tflite");
2270
2270
 
2271
2271
  var defaultFocusModelPath = "".concat(DEFAULT_CDN_URL, "/models/Focus/Focus-20241008_102708.tflite");
2272
2272
 
@@ -2285,6 +2285,10 @@ var defaultFocusThresholds = {
2285
2285
  passport: {
2286
2286
  desktop: 0,
2287
2287
  mobile: 0.3
2288
+ },
2289
+ singlePage: {
2290
+ desktop: 0,
2291
+ mobile: 0.3
2288
2292
  }
2289
2293
  };
2290
2294
  var classifier = null;
@@ -2910,16 +2914,19 @@ var defaultDocumentDetectionThresholds = {
2910
2914
  idCardFront: 0.6,
2911
2915
  idCardBack: 0.6,
2912
2916
  passport: 0.4,
2917
+ singlePage: 0.4,
2913
2918
  stability: {
2914
2919
  idCardFront: 0.85,
2915
2920
  idCardBack: 0.85,
2916
- passport: 0.5
2921
+ passport: 0.5,
2922
+ singlePage: 0.5
2917
2923
  }
2918
2924
  };
2919
2925
  var documentTypeDisplayNames = {
2920
2926
  idCardFront: 'ID card front',
2921
2927
  idCardBack: 'ID card back',
2922
2928
  passport: 'Passport',
2929
+ singlePage: 'Single page',
2923
2930
  none: 'None'
2924
2931
  };
2925
2932
  var detector = null;
@@ -3108,7 +3115,7 @@ var defaultDocumentDetectionBoundaries = {
3108
3115
  right: 20
3109
3116
  };
3110
3117
  function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
3111
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
3118
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
3112
3119
  if (boundaries === void 0) {
3113
3120
  boundaries = defaultDocumentDetectionBoundaries;
3114
3121
  }
@@ -3159,18 +3166,25 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
3159
3166
  var bestPassportPage = detectedObjects.find(function (obj) {
3160
3167
  return obj.label === 'Passport page';
3161
3168
  });
3169
+ var bestSinglePage = detectedObjects.find(function (obj) {
3170
+ return obj.label === 'Single page';
3171
+ });
3162
3172
  var idCardFrontDetectionScore = (_e = bestIdCardFront === null || bestIdCardFront === void 0 ? void 0 : bestIdCardFront.score) !== null && _e !== void 0 ? _e : 0;
3163
3173
  var idCardBackDetectionScore = (_f = bestIdCardBack === null || bestIdCardBack === void 0 ? void 0 : bestIdCardBack.score) !== null && _f !== void 0 ? _f : 0;
3164
3174
  var passportDetectionScore = (_g = bestPassportPage === null || bestPassportPage === void 0 ? void 0 : bestPassportPage.score) !== null && _g !== void 0 ? _g : 0;
3165
- var idCardFrontDetectionThresholdMet = idCardFrontDetectionScore >= ((_h = thresholds.idCardFront) !== null && _h !== void 0 ? _h : 0);
3166
- var idCardBackDetectionThresholdMet = idCardBackDetectionScore >= ((_j = thresholds.idCardBack) !== null && _j !== void 0 ? _j : 0);
3167
- var passportDetectionThresholdMet = passportDetectionScore >= ((_k = thresholds.passport) !== null && _k !== void 0 ? _k : 0);
3168
- var bestDocument = passportDetectionThresholdMet ? bestPassportPage : idCardBackDetectionThresholdMet ? bestIdCardBack : bestIdCardFront;
3169
- var detectionThreshold = passportDetectionThresholdMet ? thresholds.passport : idCardBackDetectionThresholdMet ? thresholds.idCardBack : thresholds.idCardFront;
3170
- var detectionScore = (_l = bestDocument === null || bestDocument === void 0 ? void 0 : bestDocument.score) !== null && _l !== void 0 ? _l : 0;
3175
+ var singlePageDetectionScore = (_h = bestSinglePage === null || bestSinglePage === void 0 ? void 0 : bestSinglePage.score) !== null && _h !== void 0 ? _h : 0;
3176
+ var idCardFrontDetectionThresholdMet = idCardFrontDetectionScore >= ((_j = thresholds.idCardFront) !== null && _j !== void 0 ? _j : 0);
3177
+ var idCardBackDetectionThresholdMet = idCardBackDetectionScore >= ((_k = thresholds.idCardBack) !== null && _k !== void 0 ? _k : 0);
3178
+ var passportDetectionThresholdMet = passportDetectionScore >= ((_l = thresholds.passport) !== null && _l !== void 0 ? _l : 0);
3179
+ var singlePageDetectionThresholdMet = singlePageDetectionScore >= ((_m = thresholds.singlePage) !== null && _m !== void 0 ? _m : 0);
3180
+ var bestDocument = singlePageDetectionThresholdMet ? bestSinglePage : passportDetectionThresholdMet ? bestPassportPage : idCardBackDetectionThresholdMet ? bestIdCardBack : bestIdCardFront;
3181
+ var detectionThreshold = singlePageDetectionThresholdMet ? thresholds.singlePage : passportDetectionThresholdMet ? thresholds.passport : idCardBackDetectionThresholdMet ? thresholds.idCardBack : thresholds.idCardFront;
3182
+ var detectionScore = (_o = bestDocument === null || bestDocument === void 0 ? void 0 : bestDocument.score) !== null && _o !== void 0 ? _o : 0;
3171
3183
  var detectionThresholdMet = detectionScore >= (detectionThreshold !== null && detectionThreshold !== void 0 ? detectionThreshold : 0);
3172
3184
  var detectedDocumentType = 'none';
3173
- if (passportDetectionThresholdMet) {
3185
+ if (singlePageDetectionThresholdMet) {
3186
+ detectedDocumentType = 'singlePage';
3187
+ } else if (passportDetectionThresholdMet) {
3174
3188
  detectedDocumentType = 'passport';
3175
3189
  } else if (idCardBackDetectionThresholdMet) {
3176
3190
  detectedDocumentType = 'idCardBack';
@@ -3184,12 +3198,12 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
3184
3198
  var documentIsStable = false;
3185
3199
  var documentTooClose = false;
3186
3200
  if (bestDocument) {
3187
- var _o = [bestDocument.box.width / frameWidth, bestDocument.box.height / frameHeight],
3188
- docWidth = _o[0],
3189
- docHeight = _o[1];
3201
+ var _q = [bestDocument.box.width / frameWidth, bestDocument.box.height / frameHeight],
3202
+ docWidth = _q[0],
3203
+ docHeight = _q[1];
3190
3204
  documentTooClose = docWidth > 0.85 || docHeight > 0.85;
3191
3205
  if (detectionThresholdMet && documentInBounds && !documentTooClose) {
3192
- var thresholdSet = (_m = thresholds.stability) !== null && _m !== void 0 ? _m : defaultDocumentDetectionThresholds.stability;
3206
+ var thresholdSet = (_p = thresholds.stability) !== null && _p !== void 0 ? _p : defaultDocumentDetectionThresholds.stability;
3193
3207
  var threshold_1 = thresholdSet[detectedDocumentType];
3194
3208
  var framesNeeded = Math.ceil(average(framesNeededSamples));
3195
3209
  trackBox(bestDocument.box, framesNeeded);
@@ -3211,6 +3225,8 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
3211
3225
  idCardBackDetectionThresholdMet: idCardBackDetectionThresholdMet,
3212
3226
  passportDetectionScore: passportDetectionScore,
3213
3227
  passportDetectionThresholdMet: passportDetectionThresholdMet,
3228
+ singlePageDetectionScore: singlePageDetectionScore,
3229
+ singlePageDetectionThresholdMet: singlePageDetectionThresholdMet,
3214
3230
  bestDocument: bestDocument,
3215
3231
  documentInBounds: documentInBounds,
3216
3232
  documentTooClose: documentTooClose,
@@ -4103,37 +4119,39 @@ var IdCaptureModelsContext = /*#__PURE__*/createContext({
4103
4119
  });
4104
4120
  function IdCaptureModelsProviderInner(_a) {
4105
4121
  var children = _a.children,
4106
- onModelError = _a.onModelError;
4107
- var _b = useContext(DocumentDetectionModelContext),
4108
- documentDetectionModelReady = _b.documentDetectionModelReady,
4109
- documentDetectionModelDownloadProgress = _b.documentDetectionModelDownloadProgress,
4110
- startDocumentDetection = _b.startDocumentDetection,
4111
- stopDocumentDetection = _b.stopDocumentDetection,
4112
- lastPredictionCanvas = _b.documentDetectionLastPredictionCanvas,
4113
- clearDocumentDetectionLastPredictionCanvas = _b.clearDocumentDetectionLastPredictionCanvas,
4114
- onDocumentDetected = _b.onDocumentDetected,
4115
- detectionTime = _b.detectionTime,
4116
- documentDetectionThresholds = _b.documentDetectionThresholds,
4117
- setDocumentDetectionThresholds = _b.setDocumentDetectionThresholds,
4118
- documentDetectionBoundaries = _b.documentDetectionBoundaries,
4119
- setDocumentDetectionBoundaries = _b.setDocumentDetectionBoundaries,
4120
- documentDetectionModelError = _b.documentDetectionModelError;
4121
- var _c = useContext(FocusModelContext),
4122
- focusModelReady = _c.focusModelReady,
4123
- focusModelDownloadProgress = _c.focusModelDownloadProgress,
4124
- makeFocusPrediction = _c.makeFocusPrediction,
4125
- focusThresholds = _c.focusThresholds,
4126
- setFocusThresholds = _c.setFocusThresholds,
4127
- focusPredictionTime = _c.focusPredictionTime,
4128
- focusModelError = _c.focusModelError;
4122
+ onModelError = _a.onModelError,
4123
+ _b = _a.allowSinglePageIdCapture,
4124
+ allowSinglePageIdCapture = _b === void 0 ? false : _b;
4125
+ var _c = useContext(DocumentDetectionModelContext),
4126
+ documentDetectionModelReady = _c.documentDetectionModelReady,
4127
+ documentDetectionModelDownloadProgress = _c.documentDetectionModelDownloadProgress,
4128
+ startDocumentDetection = _c.startDocumentDetection,
4129
+ stopDocumentDetection = _c.stopDocumentDetection,
4130
+ lastPredictionCanvas = _c.documentDetectionLastPredictionCanvas,
4131
+ clearDocumentDetectionLastPredictionCanvas = _c.clearDocumentDetectionLastPredictionCanvas,
4132
+ onDocumentDetected = _c.onDocumentDetected,
4133
+ detectionTime = _c.detectionTime,
4134
+ documentDetectionThresholds = _c.documentDetectionThresholds,
4135
+ setDocumentDetectionThresholds = _c.setDocumentDetectionThresholds,
4136
+ documentDetectionBoundaries = _c.documentDetectionBoundaries,
4137
+ setDocumentDetectionBoundaries = _c.setDocumentDetectionBoundaries,
4138
+ documentDetectionModelError = _c.documentDetectionModelError;
4139
+ var _d = useContext(FocusModelContext),
4140
+ focusModelReady = _d.focusModelReady,
4141
+ focusModelDownloadProgress = _d.focusModelDownloadProgress,
4142
+ makeFocusPrediction = _d.makeFocusPrediction,
4143
+ focusThresholds = _d.focusThresholds,
4144
+ setFocusThresholds = _d.setFocusThresholds,
4145
+ focusPredictionTime = _d.focusPredictionTime,
4146
+ focusModelError = _d.focusModelError;
4129
4147
  var onPredictionHandler = useRef();
4130
4148
  var bestFrameDetails = useRef(null);
4131
4149
  var bestPredictionCanvas = useRef(null);
4132
4150
  var bestFocusScore = useRef(0);
4133
4151
  var stopDetection = useRef(0);
4134
- var _d = useState('none'),
4135
- requiredDocumentType = _d[0],
4136
- setRequiredDocumentType = _d[1];
4152
+ var _e = useState('none'),
4153
+ requiredDocumentType = _e[0],
4154
+ setRequiredDocumentType = _e[1];
4137
4155
  var thresholds = useMemo(function () {
4138
4156
  return _assign(_assign({}, documentDetectionThresholds), {
4139
4157
  focus: focusThresholds
@@ -4151,34 +4169,42 @@ function IdCaptureModelsProviderInner(_a) {
4151
4169
  var _this = this;
4152
4170
  onDocumentDetected(function (prediction) {
4153
4171
  return __awaiter(_this, void 0, void 0, function () {
4154
- var stopDetectionAtStart, focusPredictionTime, focusScore, focusThresholdMet, isRequiredDocumentType, focusPrediction, focusThresholdSet, focusThreshold;
4155
- var _a, _b, _c, _d, _e, _f;
4156
- return __generator(this, function (_g) {
4172
+ var stopDetectionAtStart, focusPredictionTime, focusScore, focusThresholdMet, isSinglePage, isRequiredDocumentType, focusPrediction, focusThresholdSet, focusThreshold;
4173
+ var _a, _b, _c, _d, _e, _f, _g;
4174
+ return __generator(this, function (_h) {
4157
4175
  if (!lastPredictionCanvas.current) return [2 /*return*/];
4158
4176
  stopDetectionAtStart = stopDetection.current;
4159
4177
  focusPredictionTime = 0, focusScore = 0, focusThresholdMet = false;
4160
- isRequiredDocumentType = requiredDocumentType === 'none' || prediction.detectedDocumentType === requiredDocumentType || ((_a = requiredDocumentType.includes) === null || _a === void 0 ? void 0 : _a.call(requiredDocumentType, prediction.detectedDocumentType));
4178
+ isSinglePage = prediction.detectedDocumentType === 'singlePage';
4179
+ if (!allowSinglePageIdCapture && isSinglePage) {
4180
+ prediction.detectedDocumentType = 'passport';
4181
+ prediction.passportDetectionScore = prediction.singlePageDetectionScore;
4182
+ prediction.passportDetectionThresholdMet = prediction.singlePageDetectionThresholdMet;
4183
+ prediction.singlePageDetectionScore = 0;
4184
+ prediction.singlePageDetectionThresholdMet = false;
4185
+ }
4186
+ isRequiredDocumentType = requiredDocumentType === 'none' || prediction.detectedDocumentType === requiredDocumentType || ((_a = requiredDocumentType.includes) === null || _a === void 0 ? void 0 : _a.call(requiredDocumentType, prediction.detectedDocumentType)) || allowSinglePageIdCapture && isSinglePage && ((_b = requiredDocumentType.includes) === null || _b === void 0 ? void 0 : _b.call(requiredDocumentType, 'idCardFront'));
4161
4187
  if (isRequiredDocumentType && prediction.detectedDocumentType !== 'none' && prediction.detectionThresholdMet && prediction.documentInBounds && !prediction.documentTooClose && prediction.documentIsStable) {
4162
- focusPrediction = makeFocusPrediction(lastPredictionCanvas.current, (_b = prediction.bestDocument) === null || _b === void 0 ? void 0 : _b.box);
4188
+ focusPrediction = makeFocusPrediction(lastPredictionCanvas.current, (_c = prediction.bestDocument) === null || _c === void 0 ? void 0 : _c.box);
4163
4189
  if (focusPrediction) {
4164
4190
  focusScore = focusPrediction.score;
4165
4191
  focusPredictionTime = focusPrediction.predictionTime;
4166
4192
  }
4167
- focusThresholdSet = (_c = thresholds.focus) === null || _c === void 0 ? void 0 : _c[prediction.detectedDocumentType];
4168
- focusThreshold = (_d = onMobile ? focusThresholdSet === null || focusThresholdSet === void 0 ? void 0 : focusThresholdSet.mobile : focusThresholdSet === null || focusThresholdSet === void 0 ? void 0 : focusThresholdSet.desktop) !== null && _d !== void 0 ? _d : 0;
4193
+ focusThresholdSet = (_d = thresholds.focus) === null || _d === void 0 ? void 0 : _d[prediction.detectedDocumentType];
4194
+ focusThreshold = (_e = onMobile ? focusThresholdSet === null || focusThresholdSet === void 0 ? void 0 : focusThresholdSet.mobile : focusThresholdSet === null || focusThresholdSet === void 0 ? void 0 : focusThresholdSet.desktop) !== null && _e !== void 0 ? _e : 0;
4169
4195
  focusThresholdMet = focusScore >= focusThreshold;
4170
4196
  if (bestFocusScore.current <= focusScore && stopDetectionAtStart === stopDetection.current) {
4171
4197
  bestFocusScore.current = focusScore;
4172
4198
  drawToCanvas(bestPredictionCanvas.current, lastPredictionCanvas.current);
4173
4199
  bestFrameDetails.current = {
4174
- boundingBox: (_e = prediction.bestDocument) === null || _e === void 0 ? void 0 : _e.box,
4200
+ boundingBox: (_f = prediction.bestDocument) === null || _f === void 0 ? void 0 : _f.box,
4175
4201
  documentType: prediction.detectedDocumentType,
4176
4202
  detectionScore: prediction.detectionScore,
4177
4203
  focusScore: focusScore
4178
4204
  };
4179
4205
  }
4180
4206
  }
4181
- (_f = onPredictionHandler.current) === null || _f === void 0 ? void 0 : _f.call(onPredictionHandler, _assign(_assign({}, prediction), {
4207
+ (_g = onPredictionHandler.current) === null || _g === void 0 ? void 0 : _g.call(onPredictionHandler, _assign(_assign({}, prediction), {
4182
4208
  focusScore: focusScore,
4183
4209
  focusPredictionTime: focusPredictionTime,
4184
4210
  focusThresholdMet: focusThresholdMet
@@ -4187,7 +4213,7 @@ function IdCaptureModelsProviderInner(_a) {
4187
4213
  });
4188
4214
  });
4189
4215
  });
4190
- }, [lastPredictionCanvas, makeFocusPrediction, onDocumentDetected, requiredDocumentType, thresholds.focus]);
4216
+ }, [allowSinglePageIdCapture, lastPredictionCanvas, makeFocusPrediction, onDocumentDetected, requiredDocumentType, thresholds.focus]);
4191
4217
  var modelError = documentDetectionModelError !== null && documentDetectionModelError !== void 0 ? documentDetectionModelError : focusModelError;
4192
4218
  useEffect(function handleModelErrors() {
4193
4219
  if (modelError) onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError);
@@ -4201,9 +4227,9 @@ function IdCaptureModelsProviderInner(_a) {
4201
4227
  canvas: bestPredictionCanvas.current
4202
4228
  });
4203
4229
  }, []);
4204
- var _e = useState(0),
4205
- canvasKey = _e[0],
4206
- setCanvasKey = _e[1];
4230
+ var _f = useState(0),
4231
+ canvasKey = _f[0],
4232
+ setCanvasKey = _f[1];
4207
4233
  var resetBestFrame = useCallback(function () {
4208
4234
  stopDetection.current += 1;
4209
4235
  setCanvasKey(function (n) {
@@ -4250,9 +4276,9 @@ function IdCaptureModelsProvider(_a) {
4250
4276
  return /*#__PURE__*/React__default.createElement(DocumentDetectionModelProvider, _assign({}, props), /*#__PURE__*/React__default.createElement(FocusModelProvider, _assign({}, props), /*#__PURE__*/React__default.createElement(IdCaptureModelsProviderInner, _assign({}, props), children)));
4251
4277
  }
4252
4278
 
4253
- var CapturedDocumentTypeValues = ['idCardFront', 'idCardBack', 'passport', 'selfie'];
4279
+ var CapturedDocumentTypeValues = ['idCardFront', 'idCardBack', 'passport', 'singlePage', 'selfie'];
4254
4280
 
4255
- var requiredDocumentsForOption = {
4281
+ var acceptedDocumentTypesForIdCaptureRequirementOption = {
4256
4282
  idCardFront: ['idCardFront'],
4257
4283
  idCardBack: ['idCardBack'],
4258
4284
  passport: ['passport'],
@@ -4260,13 +4286,31 @@ var requiredDocumentsForOption = {
4260
4286
  idCardAndPassport: ['idCardFront', 'idCardBack', 'passport'],
4261
4287
  idCardOrPassport: ['idCardFront', 'idCardBack', 'passport'] // this one is so weird
4262
4288
  };
4263
- function requiredImageCountForOption(idCaptureRequirement) {
4289
+ function minImageCountForIdCaptureRequirementOption(idCaptureRequirement) {
4264
4290
  if (idCaptureRequirement === 'idCardOrPassport') return 1;
4265
- return requiredDocumentsForOption[idCaptureRequirement].length;
4291
+ return acceptedDocumentTypesForIdCaptureRequirementOption[idCaptureRequirement].length;
4266
4292
  }
4267
- function allowedImageCountForOption(idCaptureRequirement) {
4293
+ function maxImageCountForIdCaptureRequirementOption(idCaptureRequirement) {
4268
4294
  if (idCaptureRequirement === 'idCardOrPassport') return 2;
4269
- return requiredImageCountForOption(idCaptureRequirement);
4295
+ return minImageCountForIdCaptureRequirementOption(idCaptureRequirement);
4296
+ }
4297
+ function remainingIdCaptureRequirements(captureRequirement, capturedDocuments, requestedDocumentType) {
4298
+ var isIdCardOrPassport = captureRequirement === 'idCardOrPassport';
4299
+ if (isIdCardOrPassport && requestedDocumentType === 'passport') return [];
4300
+ var acceptedTypes = acceptedDocumentTypesForIdCaptureRequirementOption[captureRequirement];
4301
+ if (captureRequirement.includes('idCard') && 'singlePage' in capturedDocuments) {
4302
+ acceptedTypes = acceptedTypes.filter(function (v) {
4303
+ return !v.includes('idCard');
4304
+ });
4305
+ }
4306
+ if (isIdCardOrPassport) {
4307
+ acceptedTypes = acceptedTypes.filter(function (v) {
4308
+ return v !== 'passport';
4309
+ });
4310
+ }
4311
+ return acceptedTypes.filter(function (v) {
4312
+ return !(v in capturedDocuments);
4313
+ });
4270
4314
  }
4271
4315
 
4272
4316
  var initialState$4 = {
@@ -4305,6 +4349,8 @@ var initialState$4 = {
4305
4349
  idCardBackDetectionThresholdMet: false,
4306
4350
  passportDetectionScore: 0,
4307
4351
  passportDetectionThresholdMet: false,
4352
+ singlePageDetectionScore: 0,
4353
+ singlePageDetectionThresholdMet: false,
4308
4354
  focusScore: 0,
4309
4355
  focusThresholdMet: false,
4310
4356
  isGoodFrame: false,
@@ -4320,6 +4366,7 @@ var initialState$4 = {
4320
4366
  capturedDocuments: {},
4321
4367
  captureRequirement: 'idCardOrPassport',
4322
4368
  requestedDocumentType: 'idCardFront',
4369
+ allowSinglePageIdCapture: false,
4323
4370
  allowIdCardBackToFrontCapture: false,
4324
4371
  operationStartedAt: null,
4325
4372
  captureStartedAt: null
@@ -4334,11 +4381,13 @@ var _reducer = function reducer(state, action) {
4334
4381
  var _c = action.payload,
4335
4382
  captureRequirement = _c.captureRequirement,
4336
4383
  precapturedDocuments = _c.precapturedDocuments,
4384
+ allowSinglePageIdCapture = _c.allowSinglePageIdCapture,
4337
4385
  allowIdCardBackToFrontCapture = _c.allowIdCardBackToFrontCapture,
4338
4386
  enableOverrideWrongDocumentTypeDialog = _c.enableOverrideWrongDocumentTypeDialog,
4339
4387
  allowOverrideWrongDocumentTypeAfterMs = _c.allowOverrideWrongDocumentTypeAfterMs;
4340
4388
  var newState = _assign(_assign({}, state), {
4341
4389
  captureRequirement: captureRequirement,
4390
+ allowSinglePageIdCapture: allowSinglePageIdCapture !== null && allowSinglePageIdCapture !== void 0 ? allowSinglePageIdCapture : false,
4342
4391
  allowIdCardBackToFrontCapture: allowIdCardBackToFrontCapture !== null && allowIdCardBackToFrontCapture !== void 0 ? allowIdCardBackToFrontCapture : false,
4343
4392
  enableOverrideWrongDocumentTypeDialog: enableOverrideWrongDocumentTypeDialog,
4344
4393
  allowOverrideWrongDocumentTypeAfterMs: allowOverrideWrongDocumentTypeAfterMs
@@ -4406,6 +4455,8 @@ var _reducer = function reducer(state, action) {
4406
4455
  idCardBackDetectionThresholdMet = _d.idCardBackDetectionThresholdMet,
4407
4456
  passportDetectionScore = _d.passportDetectionScore,
4408
4457
  passportDetectionThresholdMet = _d.passportDetectionThresholdMet,
4458
+ singlePageDetectionScore = _d.singlePageDetectionScore,
4459
+ singlePageDetectionThresholdMet = _d.singlePageDetectionThresholdMet,
4409
4460
  bestDocument = _d.bestDocument,
4410
4461
  documentInBounds = _d.documentInBounds,
4411
4462
  documentTooClose = _d.documentTooClose,
@@ -4426,7 +4477,8 @@ var _reducer = function reducer(state, action) {
4426
4477
  }
4427
4478
  }
4428
4479
  }
4429
- var idCardDetectedButNotAllowed = detectedDocumentType.includes('idCard') && !state.captureRequirement.includes('idCard');
4480
+ var idCardDetected = detectedDocumentType.includes('idCard') || detectedDocumentType === 'singlePage';
4481
+ var idCardDetectedButNotAllowed = idCardDetected && !state.captureRequirement.includes('idCard');
4430
4482
  var passportNotAllowed = !state.captureRequirement.toLowerCase().includes('passport');
4431
4483
  var idCardFrontWasCaptured = 'idCardFront' in state.capturedDocuments;
4432
4484
  var idCardBackWasCaptured = 'idCardBack' in state.capturedDocuments;
@@ -4486,6 +4538,8 @@ var _reducer = function reducer(state, action) {
4486
4538
  idCardBackDetectionThresholdMet: idCardBackDetectionThresholdMet,
4487
4539
  passportDetectionScore: passportDetectionScore,
4488
4540
  passportDetectionThresholdMet: passportDetectionThresholdMet,
4541
+ singlePageDetectionScore: singlePageDetectionScore,
4542
+ singlePageDetectionThresholdMet: singlePageDetectionThresholdMet,
4489
4543
  focusScore: focusScore,
4490
4544
  focusThresholdMet: focusThresholdMet,
4491
4545
  isGoodFrame: isGoodFrame,
@@ -4523,7 +4577,7 @@ var _reducer = function reducer(state, action) {
4523
4577
  });
4524
4578
  case 'documentCaptured':
4525
4579
  {
4526
- var newState_1 = _assign(_assign({}, state), {
4580
+ var newState = _assign(_assign({}, state), {
4527
4581
  capturing: false,
4528
4582
  captureFailed: false,
4529
4583
  allowOverrideFlipRequirement: false,
@@ -4532,64 +4586,42 @@ var _reducer = function reducer(state, action) {
4532
4586
  wrongDocumentTypePredictions: 0,
4533
4587
  capturedDocuments: _assign(_assign({}, state.capturedDocuments), (_a = {}, _a[action.payload.documentType] = action.payload, _a))
4534
4588
  });
4535
- var remainingRequirements = requiredDocumentsForOption[state.captureRequirement].filter(function (v) {
4536
- return !(v in newState_1.capturedDocuments);
4537
- });
4538
- if (state.captureRequirement === 'idCardOrPassport') {
4539
- if (state.requestedDocumentType === 'passport') {
4540
- remainingRequirements = [];
4541
- } else {
4542
- remainingRequirements = remainingRequirements.filter(function (v) {
4543
- return v !== 'passport';
4544
- });
4545
- }
4546
- }
4589
+ var remainingRequirements = remainingIdCaptureRequirements(state.captureRequirement, newState.capturedDocuments, state.requestedDocumentType);
4547
4590
  if (remainingRequirements.length === 0) {
4548
- newState_1.captureState = 'complete';
4591
+ newState.captureState = 'complete';
4549
4592
  } else {
4550
- newState_1.requestedDocumentType = remainingRequirements[0];
4551
- if (state.requestedDocumentType === 'idCardFront' && newState_1.requestedDocumentType === 'idCardBack' || state.requestedDocumentType === 'idCardBack' && newState_1.requestedDocumentType === 'idCardFront') {
4552
- newState_1.captureState = 'requestingFlip';
4553
- newState_1.idCardFrontDetectionThresholdMet = false;
4554
- newState_1.idCardBackDetectionThresholdMet = false;
4555
- newState_1.passportDetectionThresholdMet = false;
4556
- newState_1.wrongDocumentTypePredictions = 0;
4593
+ newState.requestedDocumentType = remainingRequirements[0];
4594
+ if (state.requestedDocumentType === 'idCardFront' && newState.requestedDocumentType === 'idCardBack' || state.requestedDocumentType === 'idCardBack' && newState.requestedDocumentType === 'idCardFront') {
4595
+ newState.captureState = 'requestingFlip';
4596
+ newState.idCardFrontDetectionThresholdMet = false;
4597
+ newState.idCardBackDetectionThresholdMet = false;
4598
+ newState.passportDetectionThresholdMet = false;
4599
+ newState.wrongDocumentTypePredictions = 0;
4557
4600
  }
4558
4601
  }
4559
- return newState_1;
4602
+ return newState;
4560
4603
  }
4561
4604
  case 'documentCapturedManually':
4562
4605
  {
4563
- var newState_2 = _assign(_assign({}, state), {
4606
+ var newState = _assign(_assign({}, state), {
4564
4607
  capturedDocuments: _assign(_assign({}, state.capturedDocuments), (_b = {}, _b[state.requestedDocumentType] = _assign(_assign({}, action.payload), {
4565
4608
  width: 0,
4566
4609
  height: 0
4567
4610
  }), _b))
4568
4611
  });
4569
- var remainingRequirements = requiredDocumentsForOption[state.captureRequirement].filter(function (v) {
4570
- return !(v in newState_2.capturedDocuments);
4571
- });
4572
- if (state.captureRequirement === 'idCardOrPassport') {
4573
- if (state.requestedDocumentType === 'passport') {
4574
- remainingRequirements = [];
4575
- } else {
4576
- remainingRequirements = remainingRequirements.filter(function (v) {
4577
- return v !== 'passport';
4578
- });
4579
- }
4580
- }
4612
+ var remainingRequirements = remainingIdCaptureRequirements(state.captureRequirement, newState.capturedDocuments, state.requestedDocumentType);
4581
4613
  if (remainingRequirements.length === 0) {
4582
- newState_2.captureState = 'complete';
4614
+ newState.captureState = 'complete';
4583
4615
  } else {
4584
- newState_2.requestedDocumentType = remainingRequirements[0];
4585
- if (state.requestedDocumentType === 'idCardFront' && newState_2.requestedDocumentType === 'idCardBack' || state.requestedDocumentType === 'idCardBack' && newState_2.requestedDocumentType === 'idCardFront') {
4586
- newState_2.captureState = 'requestingFlip';
4587
- newState_2.idCardFrontDetectionThresholdMet = false;
4588
- newState_2.idCardBackDetectionThresholdMet = false;
4589
- newState_2.passportDetectionThresholdMet = false;
4616
+ newState.requestedDocumentType = remainingRequirements[0];
4617
+ if (state.requestedDocumentType === 'idCardFront' && newState.requestedDocumentType === 'idCardBack' || state.requestedDocumentType === 'idCardBack' && newState.requestedDocumentType === 'idCardFront') {
4618
+ newState.captureState = 'requestingFlip';
4619
+ newState.idCardFrontDetectionThresholdMet = false;
4620
+ newState.idCardBackDetectionThresholdMet = false;
4621
+ newState.passportDetectionThresholdMet = false;
4590
4622
  }
4591
4623
  }
4592
- return newState_2;
4624
+ return newState;
4593
4625
  }
4594
4626
  case 'flipRequestCompleted':
4595
4627
  return _assign(_assign({}, state), {
@@ -5190,7 +5222,7 @@ var IdCapture = function IdCapture(_a) {
5190
5222
  imageUrl: imageUrl
5191
5223
  }
5192
5224
  });
5193
- var capturedDocumentType = documentType === 'passport' ? 'passport' : state.requestedDocumentType;
5225
+ var capturedDocumentType = documentType;
5194
5226
  setTimeout(function () {
5195
5227
  var _a;
5196
5228
  var captureTime = new Date().getTime() - ((_a = state.captureStartedAt) !== null && _a !== void 0 ? _a : new Date()).getTime();
@@ -5257,7 +5289,7 @@ var IdCapture = function IdCapture(_a) {
5257
5289
  scaling: debugScalingDetails,
5258
5290
  flipX: !isRearFacing
5259
5291
  });
5260
- }))), debugMode && ( /*#__PURE__*/React__default.createElement(DebugStatsPane, null, camera ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u2705 Camera: ", camera.label, " (", camera.width, "x", camera.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React__default.createElement("br", null), state.frameCaptureRate > 0.75 ? '✅' : '👎', " Frame Rate:", ' ', Math.round((state.frameCaptureRate + Number.EPSILON) * 1000) / 1000, ' ', "fps (", detectionTime, "ms doc detect, ", focusPredictionTime, "ms focus)", /*#__PURE__*/React__default.createElement("br", null), modelsReady ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, state.detectionThresholdMet ? '✅' : '❌', " Detected Document Type: ", state.detectedDocumentType, /*#__PURE__*/React__default.createElement("br", null), state.idCardFrontDetectionThresholdMet ? '✅' : '❌', " ID Card Front Score: ", state.idCardFrontDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.idCardBackDetectionThresholdMet ? '✅' : '❌', " ID Card Back Score: ", state.idCardBackDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.passportDetectionThresholdMet ? '✅' : '❌', " Passport Score: ", state.passportDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.focusThresholdMet ? '✅' : '❌', " Focus Score:", ' ', state.focusScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.documentInBounds ? '✅' : '❌', " Document In Bounds", /*#__PURE__*/React__default.createElement("br", null), state.documentIsStable ? '✅' : '❌', " Document Is Stable", /*#__PURE__*/React__default.createElement("br", null), state.goodFramesThresholdMet ? '✅' : '❌', " Good Frame Count:", ' ', state.goodFramesCount, "/", state.goodFramesThreshold)) : ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u274C Models not ready")))));
5292
+ }))), debugMode && ( /*#__PURE__*/React__default.createElement(DebugStatsPane, null, camera ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u2705 Camera: ", camera.label, " (", camera.width, "x", camera.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React__default.createElement("br", null), state.frameCaptureRate > 0.75 ? '✅' : '👎', " Frame Rate:", ' ', Math.round((state.frameCaptureRate + Number.EPSILON) * 1000) / 1000, ' ', "fps (", detectionTime, "ms doc detect, ", focusPredictionTime, "ms focus)", /*#__PURE__*/React__default.createElement("br", null), modelsReady ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, state.detectionThresholdMet ? '✅' : '❌', " Detected Document Type: ", state.detectedDocumentType, /*#__PURE__*/React__default.createElement("br", null), state.idCardFrontDetectionThresholdMet ? '✅' : '❌', " ID Card Front Score: ", state.idCardFrontDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.idCardBackDetectionThresholdMet ? '✅' : '❌', " ID Card Back Score: ", state.idCardBackDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.passportDetectionThresholdMet ? '✅' : '❌', " Passport Score: ", state.passportDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.singlePageDetectionThresholdMet ? '✅' : '❌', " Single Page Score: ", state.singlePageDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.focusThresholdMet ? '✅' : '❌', " Focus Score:", ' ', state.focusScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.documentInBounds ? '✅' : '❌', " Document In Bounds", /*#__PURE__*/React__default.createElement("br", null), state.documentIsStable ? '✅' : '❌', " Document Is Stable", /*#__PURE__*/React__default.createElement("br", null), state.goodFramesThresholdMet ? '✅' : '❌', " Good Frame Count:", ' ', state.goodFramesCount, "/", state.goodFramesThreshold)) : ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u274C Models not ready")))));
5261
5293
  };
5262
5294
  var timeSince = function timeSince(t) {
5263
5295
  if (!t) return 0;
@@ -6296,15 +6328,8 @@ var IdCaptureSuccess = function IdCaptureSuccess(_a) {
6296
6328
  _e = _a.debugMode,
6297
6329
  debugMode = _e === void 0 ? false : _e;
6298
6330
  var submissionStatus = useContext(SubmissionContext).submissionStatus;
6299
- var idCardFront = capturedDocuments.idCardFront,
6300
- idCardBack = capturedDocuments.idCardBack,
6301
- passport = capturedDocuments.passport;
6302
6331
  var verbiage = useTranslations(rawVerbiage, {
6303
6332
  headingText: 'ID Capture Successful',
6304
- idCardFrontText: 'ID Card Front',
6305
- idCardBackText: 'ID Card Back',
6306
- passportText: 'Passport',
6307
- instructionText: 'Verify the entire ID was captured clearly with no glare.',
6308
6333
  retryText: 'Retry',
6309
6334
  submittingText: 'Submitting...',
6310
6335
  submitText: 'Done'
@@ -6321,25 +6346,16 @@ var IdCaptureSuccess = function IdCaptureSuccess(_a) {
6321
6346
  className: classNames.imageContainer
6322
6347
  }, /*#__PURE__*/React__default.createElement(ImageRow, {
6323
6348
  className: classNames.imageRow
6324
- }, idCardFront && ( /*#__PURE__*/React__default.createElement(ImageCol$1, {
6325
- className: classNames.imageCol
6326
- }, /*#__PURE__*/React__default.createElement(StyledImage, {
6327
- image: idCardFront,
6328
- className: classNames.image,
6329
- alt: verbiage.idCardFrontText
6330
- }), debugMode && ( /*#__PURE__*/React__default.createElement(DebugPre, null, "Detection Score: ".concat(idCardFront.detectionScore, "\nFocus Score: ").concat(idCardFront.focusScore, "\nBounding Box: ").concat(JSON.stringify(idCardFront.boundingBox)))))), idCardBack && ( /*#__PURE__*/React__default.createElement(ImageCol$1, {
6331
- className: classNames.imageCol
6332
- }, /*#__PURE__*/React__default.createElement(StyledImage, {
6333
- image: idCardBack,
6334
- className: classNames.image,
6335
- alt: verbiage.idCardBackText
6336
- }), debugMode && ( /*#__PURE__*/React__default.createElement(DebugPre, null, "Detection Score: ".concat(idCardBack.detectionScore, "\nFocus Score: ").concat(idCardBack.focusScore, "\nBounding Box: ").concat(JSON.stringify(idCardBack.boundingBox)))))), passport && ( /*#__PURE__*/React__default.createElement(ImageCol$1, {
6337
- className: classNames.imageCol
6338
- }, /*#__PURE__*/React__default.createElement(StyledImage, {
6339
- image: passport,
6340
- className: classNames.image,
6341
- alt: verbiage.passportText
6342
- }), debugMode && ( /*#__PURE__*/React__default.createElement(DebugPre, null, "Detection Score: ".concat(passport.detectionScore, "\nFocus Score: ").concat(passport.focusScore, "\nBounding Box: ").concat(JSON.stringify(passport.boundingBox)))))))), /*#__PURE__*/React__default.createElement(ButtonsColumn, {
6349
+ }, Object.values(capturedDocuments).map(function (doc) {
6350
+ return /*#__PURE__*/React__default.createElement(ImageCol$1, {
6351
+ className: classNames.imageCol,
6352
+ key: doc.imageData
6353
+ }, /*#__PURE__*/React__default.createElement(StyledImage, {
6354
+ image: doc,
6355
+ className: classNames.image,
6356
+ alt: doc.documentType
6357
+ }), debugMode && ( /*#__PURE__*/React__default.createElement(DebugPre, null, "Document Type: ".concat(doc.documentType, "\nDetection Score: ").concat(doc.detectionScore, "\nFocus Score: ").concat(doc.focusScore, "\nBounding Box: ").concat(JSON.stringify(doc.boundingBox)))));
6358
+ }))), /*#__PURE__*/React__default.createElement(ButtonsColumn, {
6343
6359
  className: classNames.buttonsRow
6344
6360
  }, /*#__PURE__*/React__default.createElement(WideButton, {
6345
6361
  className: classNames.submitBtn,
@@ -6358,7 +6374,7 @@ var IdCaptureSuccess = function IdCaptureSuccess(_a) {
6358
6374
  };
6359
6375
  var Heading$a = styled.h1(templateObject_1$v || (templateObject_1$v = __makeTemplateObject(["\n font-size: 1.5rem;\n margin-top: 0;\n margin-bottom: 1.5rem;\n"], ["\n font-size: 1.5rem;\n margin-top: 0;\n margin-bottom: 1.5rem;\n"])));
6360
6376
  var ImagesContainer = styled(OverlayImageContainer)(templateObject_2$q || (templateObject_2$q = __makeTemplateObject(["\n flex-grow: 1;\n overflow-y: auto;\n padding-bottom: 0;\n max-width: 100%;\n"], ["\n flex-grow: 1;\n overflow-y: auto;\n padding-bottom: 0;\n max-width: 100%;\n"])));
6361
- var ImageRow = styled(OverlayImageRow)(templateObject_3$k || (templateObject_3$k = __makeTemplateObject(["\n max-width: 100%;\n flex-direction: column;\n display: grid;\n grid-gap: 12px;\n //grid-template-columns: 1fr 1fr;\n"], ["\n max-width: 100%;\n flex-direction: column;\n display: grid;\n grid-gap: 12px;\n //grid-template-columns: 1fr 1fr;\n"])));
6377
+ var ImageRow = styled(OverlayImageRow)(templateObject_3$k || (templateObject_3$k = __makeTemplateObject(["\n max-width: 100%;\n flex-direction: column;\n display: grid;\n grid-gap: 12px;\n"], ["\n max-width: 100%;\n flex-direction: column;\n display: grid;\n grid-gap: 12px;\n"])));
6362
6378
  var ImageCol$1 = styled.div(templateObject_4$e || (templateObject_4$e = __makeTemplateObject(["\n width: 100%;\n max-height: none !important;\n"], ["\n width: 100%;\n max-height: none !important;\n"])));
6363
6379
  var StyledImage = styled(CapturedDocumentImg)(templateObject_5$9 || (templateObject_5$9 = __makeTemplateObject(["\n width: 100%;\n border-radius: 12px;\n"], ["\n width: 100%;\n border-radius: 12px;\n"])));
6364
6380
  var DebugPre = styled.pre(templateObject_6$7 || (templateObject_6$7 = __makeTemplateObject(["\n text-align: left;\n max-width: min(450px, 100dvw - 100px);\n overflow-x: auto;\n"], ["\n text-align: left;\n max-width: min(450px, 100dvw - 100px);\n overflow-x: auto;\n"])));
@@ -8068,8 +8084,8 @@ var IdCaptureFallback = function IdCaptureFallback(_a) {
8068
8084
  var _j = useState(silentFallback),
8069
8085
  useFallback = _j[0],
8070
8086
  setUseFallback = _j[1];
8071
- var allowedImageCount = allowedImageCountForOption(idCaptureRequirement);
8072
- var requiredImageCount = requiredImageCountForOption(idCaptureRequirement);
8087
+ var minImageCount = minImageCountForIdCaptureRequirementOption(idCaptureRequirement);
8088
+ var maxImageCount = maxImageCountForIdCaptureRequirementOption(idCaptureRequirement);
8073
8089
  var _k = useFileState(),
8074
8090
  rawFile = _k.rawFile,
8075
8091
  fileInputOnChange = _k.fileInputOnChange;
@@ -8082,7 +8098,7 @@ var IdCaptureFallback = function IdCaptureFallback(_a) {
8082
8098
  var whatToCapture = idCaptureRequirement === 'idCard' ? 'ID card' : idCaptureRequirement === 'passport' ? 'passport' : idCaptureRequirement === 'idCardOrPassport' ? 'ID card or passport' : 'ID card and passport';
8083
8099
  var firstInstructionText = idCaptureRequirement === 'idCard' || idCaptureRequirement === 'idCardAndPassport' ? 'Please capture the front of your ID card.' : idCaptureRequirement === 'passport' ? 'Please capture the ID page of your passport.' : 'Please capture the front of your ID card, or the ID page of your passport.';
8084
8100
  var secondInstructionText = idCaptureRequirement === 'idCardOrPassport' ? 'Please capture the back of your ID card, or click Done if submitting a passport.' : 'Please capture the back of your ID card.';
8085
- var descriptionText = "On-device capture guidance failed, please capture ".concat(requiredImageCount > 1 ? 'photos' : ' a photo', " of your ").concat(whatToCapture, " manually.");
8101
+ var descriptionText = "On-device capture guidance failed, please capture ".concat(minImageCount > 1 ? 'photos' : ' a photo', " of your ").concat(whatToCapture, " manually.");
8086
8102
  var verbiage = useTranslations(rawVerbiage, {
8087
8103
  headingText: "We're having some trouble.",
8088
8104
  descriptionText: descriptionText,
@@ -8156,7 +8172,7 @@ var IdCaptureFallback = function IdCaptureFallback(_a) {
8156
8172
  alt: "",
8157
8173
  className: classNames.image
8158
8174
  }));
8159
- }))), images.length < requiredImageCount && ( /*#__PURE__*/React__default.createElement(Instruction, {
8175
+ }))), images.length < minImageCount && ( /*#__PURE__*/React__default.createElement(Instruction, {
8160
8176
  className: classNames.instruction
8161
8177
  }, instructionText)), /*#__PURE__*/React__default.createElement("input", {
8162
8178
  ref: fileInput,
@@ -8167,7 +8183,7 @@ var IdCaptureFallback = function IdCaptureFallback(_a) {
8167
8183
  hidden: true
8168
8184
  }), /*#__PURE__*/React__default.createElement(StyledButtonsRow$8, {
8169
8185
  className: classNames.buttonsRow
8170
- }, images.length < allowedImageCount && ( /*#__PURE__*/React__default.createElement(LoaderButton, {
8186
+ }, images.length < maxImageCount && ( /*#__PURE__*/React__default.createElement(LoaderButton, {
8171
8187
  variant: images.length > 0 ? 'secondary' : 'positive',
8172
8188
  className: images.length > 0 ? classNames.captureMoreBtn : classNames.captureBtn,
8173
8189
  colors: images.length > 0 ? colors.captureMoreBtn : colors.captureBtn,
@@ -8180,7 +8196,7 @@ var IdCaptureFallback = function IdCaptureFallback(_a) {
8180
8196
  setDocumentToCapture(instructionText);
8181
8197
  }
8182
8198
  }
8183
- }, images.length > 0 ? verbiage.captureMoreBtnText : verbiage.captureBtnText)), images.length >= requiredImageCount && ( /*#__PURE__*/React__default.createElement(LoaderButton, {
8199
+ }, images.length > 0 ? verbiage.captureMoreBtnText : verbiage.captureBtnText)), images.length >= minImageCount && ( /*#__PURE__*/React__default.createElement(LoaderButton, {
8184
8200
  variant: "positive",
8185
8201
  className: classNames.doneBtn,
8186
8202
  colors: colors.doneBtn,
@@ -8227,79 +8243,82 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
8227
8243
  precapturedDocuments = _a.precapturedDocuments,
8228
8244
  _j = _a.captureRequirement,
8229
8245
  captureRequirement = _j === void 0 ? 'idCardOrPassport' : _j,
8230
- _k = _a.separateIdCardCaptureSequence,
8231
- separateIdCardCaptureSequence = _k === void 0 ? false : _k,
8232
- _l = _a.thresholds,
8233
- thresholds = _l === void 0 ? defaultIdCaptureThresholds : _l,
8234
- _m = _a.skipSuccessScreen,
8235
- skipSuccessScreen = _m === void 0 ? false : _m,
8246
+ _k = _a.allowSinglePageIdCapture,
8247
+ allowSinglePageIdCapture = _k === void 0 ? false : _k,
8248
+ _l = _a.separateIdCardCaptureSequence,
8249
+ separateIdCardCaptureSequence = _l === void 0 ? false : _l,
8250
+ _m = _a.thresholds,
8251
+ thresholds = _m === void 0 ? defaultIdCaptureThresholds : _m,
8252
+ _o = _a.skipSuccessScreen,
8253
+ skipSuccessScreen = _o === void 0 ? false : _o,
8236
8254
  instructions = _a.instructions,
8237
- _o = _a.releaseCameraAccessOnExit,
8238
- releaseCameraAccessOnExit = _o === void 0 ? true : _o,
8239
- _p = _a.guideType,
8240
- guideType = _p === void 0 ? 'fit' : _p,
8241
- _q = _a.portraitGuidesOnMobile,
8242
- portraitGuidesOnMobile = _q === void 0 ? true : _q,
8243
- _r = _a.rotateLoadingOverlayImageWhenPortrait,
8244
- rotateLoadingOverlayImageWhenPortrait = _r === void 0 ? true : _r,
8245
- _s = _a.silentFallback,
8246
- silentFallback = _s === void 0 ? false : _s,
8247
- _t = _a.forceFallbackMode,
8248
- forceFallbackMode = _t === void 0 ? false : _t,
8249
- _u = _a.allowIdCardBackToFrontCapture,
8250
- allowIdCardBackToFrontCapture = _u === void 0 ? false : _u,
8251
- _v = _a.enableOverrideWrongDocumentTypeDialog,
8252
- enableOverrideWrongDocumentTypeDialog = _v === void 0 ? false : _v,
8253
- _w = _a.allowOverrideWrongDocumentTypeAfterMs,
8254
- allowOverrideWrongDocumentTypeAfterMs = _w === void 0 ? 8000 : _w,
8255
- _x = _a.guideImages,
8256
- guideImages = _x === void 0 ? defaultIdCaptureGuideImages : _x,
8257
- _y = _a.assets,
8258
- assets = _y === void 0 ? {} : _y,
8259
- _z = _a.classNames,
8260
- classNames = _z === void 0 ? {} : _z,
8261
- _0 = _a.colors,
8262
- colors = _0 === void 0 ? {} : _0,
8263
- _1 = _a.verbiage,
8264
- verbiage = _1 === void 0 ? {} : _1,
8265
- _2 = _a.debugMode,
8266
- debugMode = _2 === void 0 ? false : _2;
8267
- var _3 = useIdCaptureState(),
8268
- state = _3[0],
8269
- dispatch = _3[1];
8270
- var _4 = useCameraStore(),
8271
- cameraAccessDenied = _4.cameraAccessDenied,
8272
- requestCameraAccess = _4.requestCameraAccess,
8273
- releaseCameraAccess = _4.releaseCameraAccess;
8274
- var _5 = useState(false),
8275
- overlayDismissed = _5[0],
8276
- setOverlayDismissed = _5[1];
8277
- var _6 = useContext(SubmissionContext),
8278
- submissionStatus = _6.submissionStatus,
8279
- setIdFrontImage = _6.setIdFrontImage,
8280
- setIdBackImage = _6.setIdBackImage,
8281
- setPassportImage = _6.setPassportImage,
8282
- logIdFrontCaptureAttempt = _6.logIdFrontCaptureAttempt,
8283
- logIdBackCaptureAttempt = _6.logIdBackCaptureAttempt;
8284
- var _7 = useContext(IdCaptureModelsContext),
8285
- start = _7.start,
8286
- stop = _7.stop,
8287
- onPredictionMade = _7.onPredictionMade,
8288
- setRequiredDocumentType = _7.setRequiredDocumentType,
8289
- modelError = _7.modelError,
8290
- resetBestFrame = _7.resetBestFrame;
8255
+ _p = _a.releaseCameraAccessOnExit,
8256
+ releaseCameraAccessOnExit = _p === void 0 ? true : _p,
8257
+ _q = _a.guideType,
8258
+ guideType = _q === void 0 ? 'fit' : _q,
8259
+ _r = _a.portraitGuidesOnMobile,
8260
+ portraitGuidesOnMobile = _r === void 0 ? true : _r,
8261
+ _s = _a.rotateLoadingOverlayImageWhenPortrait,
8262
+ rotateLoadingOverlayImageWhenPortrait = _s === void 0 ? true : _s,
8263
+ _t = _a.silentFallback,
8264
+ silentFallback = _t === void 0 ? false : _t,
8265
+ _u = _a.forceFallbackMode,
8266
+ forceFallbackMode = _u === void 0 ? false : _u,
8267
+ _v = _a.allowIdCardBackToFrontCapture,
8268
+ allowIdCardBackToFrontCapture = _v === void 0 ? false : _v,
8269
+ _w = _a.enableOverrideWrongDocumentTypeDialog,
8270
+ enableOverrideWrongDocumentTypeDialog = _w === void 0 ? false : _w,
8271
+ _x = _a.allowOverrideWrongDocumentTypeAfterMs,
8272
+ allowOverrideWrongDocumentTypeAfterMs = _x === void 0 ? 8000 : _x,
8273
+ _y = _a.guideImages,
8274
+ guideImages = _y === void 0 ? defaultIdCaptureGuideImages : _y,
8275
+ _z = _a.assets,
8276
+ assets = _z === void 0 ? {} : _z,
8277
+ _0 = _a.classNames,
8278
+ classNames = _0 === void 0 ? {} : _0,
8279
+ _1 = _a.colors,
8280
+ colors = _1 === void 0 ? {} : _1,
8281
+ _2 = _a.verbiage,
8282
+ verbiage = _2 === void 0 ? {} : _2,
8283
+ _3 = _a.debugMode,
8284
+ debugMode = _3 === void 0 ? false : _3;
8285
+ var _4 = useIdCaptureState(),
8286
+ state = _4[0],
8287
+ dispatch = _4[1];
8288
+ var _5 = useCameraStore(),
8289
+ cameraAccessDenied = _5.cameraAccessDenied,
8290
+ requestCameraAccess = _5.requestCameraAccess,
8291
+ releaseCameraAccess = _5.releaseCameraAccess;
8292
+ var _6 = useState(false),
8293
+ overlayDismissed = _6[0],
8294
+ setOverlayDismissed = _6[1];
8295
+ var _7 = useContext(SubmissionContext),
8296
+ submissionStatus = _7.submissionStatus,
8297
+ setIdFrontImage = _7.setIdFrontImage,
8298
+ setIdBackImage = _7.setIdBackImage,
8299
+ setPassportImage = _7.setPassportImage,
8300
+ logIdFrontCaptureAttempt = _7.logIdFrontCaptureAttempt,
8301
+ logIdBackCaptureAttempt = _7.logIdBackCaptureAttempt;
8302
+ var _8 = useContext(IdCaptureModelsContext),
8303
+ start = _8.start,
8304
+ stop = _8.stop,
8305
+ onPredictionMade = _8.onPredictionMade,
8306
+ setRequiredDocumentType = _8.setRequiredDocumentType,
8307
+ modelError = _8.modelError,
8308
+ resetBestFrame = _8.resetBestFrame;
8291
8309
  useEffect(function () {
8292
8310
  dispatch({
8293
8311
  type: 'configureWizard',
8294
8312
  payload: {
8295
8313
  captureRequirement: captureRequirement,
8296
8314
  precapturedDocuments: precapturedDocuments,
8315
+ allowSinglePageIdCapture: allowSinglePageIdCapture,
8297
8316
  allowIdCardBackToFrontCapture: allowIdCardBackToFrontCapture,
8298
8317
  enableOverrideWrongDocumentTypeDialog: enableOverrideWrongDocumentTypeDialog,
8299
8318
  allowOverrideWrongDocumentTypeAfterMs: allowOverrideWrongDocumentTypeAfterMs
8300
8319
  }
8301
8320
  });
8302
- }, [allowIdCardBackToFrontCapture, allowOverrideWrongDocumentTypeAfterMs, captureRequirement, dispatch, enableOverrideWrongDocumentTypeDialog, precapturedDocuments]);
8321
+ }, [allowIdCardBackToFrontCapture, allowOverrideWrongDocumentTypeAfterMs, allowSinglePageIdCapture, captureRequirement, dispatch, enableOverrideWrongDocumentTypeDialog, precapturedDocuments]);
8303
8322
  var documentCount = Object.keys(state.capturedDocuments).length;
8304
8323
  useEffect(function () {
8305
8324
  if (documentCount) resetBestFrame();
@@ -8361,13 +8380,16 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
8361
8380
  var _a = state.capturedDocuments,
8362
8381
  idCardFront = _a.idCardFront,
8363
8382
  idCardBack = _a.idCardBack,
8364
- passport = _a.passport;
8383
+ passport = _a.passport,
8384
+ singlePage = _a.singlePage;
8365
8385
  var idFrontImage = idCardFront && dataUrlToBase64Sync(idCardFront.imageData);
8366
8386
  var idBackImage = idCardBack && dataUrlToBase64Sync(idCardBack.imageData);
8367
8387
  var passportImage = passport && dataUrlToBase64Sync(passport.imageData);
8388
+ var singlePageImage = singlePage && dataUrlToBase64Sync(singlePage.imageData);
8368
8389
  if (idFrontImage) setIdFrontImage(idFrontImage);
8369
8390
  if (idBackImage) setIdBackImage(idBackImage);
8370
8391
  if (passportImage) setPassportImage(passportImage);
8392
+ if (singlePageImage) setIdFrontImage(singlePageImage);
8371
8393
  if (releaseCameraAccessOnExit) releaseCameraAccess();
8372
8394
  setTimeout(function () {
8373
8395
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess({
@@ -8383,9 +8405,9 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
8383
8405
  type: 'resetWizard'
8384
8406
  });
8385
8407
  }, [dispatch]);
8386
- var _8 = useState(0),
8387
- attempt = _8[0],
8388
- setAttempt = _8[1];
8408
+ var _9 = useState(0),
8409
+ attempt = _9[0],
8410
+ setAttempt = _9[1];
8389
8411
  var onExit = useCallback(function () {
8390
8412
  releaseCameraAccess();
8391
8413
  setOverlayDismissed(false);
@@ -8476,9 +8498,9 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
8476
8498
  });
8477
8499
  });
8478
8500
  }, [dispatch]);
8479
- var _9 = useState(false),
8480
- progressStarted = _9[0],
8481
- setProgressStarted = _9[1];
8501
+ var _10 = useState(false),
8502
+ progressStarted = _10[0],
8503
+ setProgressStarted = _10[1];
8482
8504
  useEffect(function () {
8483
8505
  if (state.captureState === 'capturing') {
8484
8506
  setProgressStarted(false);
@@ -12010,7 +12032,8 @@ var defaultVideoIdCaptureThresholds = {
12010
12032
  detection: {
12011
12033
  idCardFront: 0.4,
12012
12034
  idCardBack: 0.5,
12013
- passport: 0.3
12035
+ passport: 0.3,
12036
+ singlePage: 0.3
12014
12037
  },
12015
12038
  focus: {
12016
12039
  idCardFront: {
@@ -12024,12 +12047,17 @@ var defaultVideoIdCaptureThresholds = {
12024
12047
  passport: {
12025
12048
  desktop: 0,
12026
12049
  mobile: 0
12050
+ },
12051
+ singlePage: {
12052
+ desktop: 0,
12053
+ mobile: 0
12027
12054
  }
12028
12055
  },
12029
12056
  goodFrames: {
12030
12057
  idCardFront: 1,
12031
12058
  idCardBack: 1,
12032
- passport: 1
12059
+ passport: 1,
12060
+ singlePage: 1
12033
12061
  },
12034
12062
  flipShortcutThreshold: 0.7
12035
12063
  };
@@ -12101,6 +12129,7 @@ var IdVideoCapture = function IdVideoCapture(_a) {
12101
12129
  stopIdModels = _18.stop,
12102
12130
  onIdPredictionMade = _18.onPredictionMade,
12103
12131
  setThresholds = _18.setThresholds,
12132
+ setRequiredDocumentType = _18.setRequiredDocumentType,
12104
12133
  setDocumentDetectionBoundaries = _18.setDocumentDetectionBoundaries,
12105
12134
  bestFrameDetails = _18.bestFrameDetails,
12106
12135
  resetBestFrame = _18.resetBestFrame,
@@ -12179,6 +12208,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
12179
12208
  useEffect(function () {
12180
12209
  setThresholds(adjustedThresholds);
12181
12210
  }, [requestedAction, setThresholds, adjustedThresholds]);
12211
+ useEffect(function () {
12212
+ setRequiredDocumentType(requestedAction === 'SHOW_PASSPORT' ? 'passport' : requestedAction === 'SHOW_ID_BACK' ? 'idCardBack' : 'idCardFront');
12213
+ }, [requestedAction, setRequiredDocumentType]);
12182
12214
  useEffect(function () {
12183
12215
  setDocumentDetectionBoundaries({
12184
12216
  top: 20,
@@ -12201,6 +12233,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
12201
12233
  setGoodFramesCount = _28[1];
12202
12234
  var goodFramesThreshold = requestedAction === 'SHOW_PASSPORT' ? adjustedThresholds.goodFrames.passport : requestedAction === 'SHOW_ID_FRONT' ? adjustedThresholds.goodFrames.idCardFront : adjustedThresholds.goodFrames.idCardBack;
12203
12235
  var goodFramesThresholdMet = goodFramesCount >= goodFramesThreshold;
12236
+ var _29 = useState(false),
12237
+ isSinglePage = _29[0],
12238
+ setIsSinglePage = _29[1];
12204
12239
  useEffect(function () {
12205
12240
  if (!idCaptureModelsEnabled || idModelError) return;
12206
12241
  onIdPredictionMade(function (prediction) {
@@ -12208,7 +12243,8 @@ var IdVideoCapture = function IdVideoCapture(_a) {
12208
12243
  setCurrentDetectionScore(prediction.detectionScore);
12209
12244
  setCurrentDetectedDocumentType(prediction.detectedDocumentType);
12210
12245
  setCurrentFocusScore(prediction.focusScore);
12211
- var detectionThresholdMet = requestedAction === 'SHOW_PASSPORT' ? prediction.passportDetectionThresholdMet : requestedAction === 'SHOW_ID_FRONT' ? prediction.idCardFrontDetectionThresholdMet : prediction.idCardBackDetectionThresholdMet;
12246
+ setIsSinglePage(prediction.singlePageDetectionThresholdMet);
12247
+ var detectionThresholdMet = requestedAction === 'SHOW_PASSPORT' ? prediction.passportDetectionThresholdMet : requestedAction === 'SHOW_ID_BACK' ? prediction.idCardBackDetectionThresholdMet : prediction.idCardFrontDetectionThresholdMet || prediction.singlePageDetectionThresholdMet;
12212
12248
  var isGoodFrame = detectionThresholdMet && prediction.focusThresholdMet;
12213
12249
  var shouldShortcutFlipAnimation = requestedAction === 'FLIP_ID' && isGoodFrame && prediction.idCardBackDetectionScore >= adjustedThresholds.flipShortcutThreshold;
12214
12250
  if (shouldShortcutFlipAnimation) {
@@ -12219,9 +12255,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
12219
12255
  } : 0);
12220
12256
  });
12221
12257
  }, [idCaptureModelsEnabled, onIdPredictionMade, idModelError, requestedAction, adjustedThresholds.flipShortcutThreshold]);
12222
- var _29 = useState(null),
12223
- idFrontCaptureStartedAt = _29[0],
12224
- setFirstGoodFrameTime = _29[1];
12258
+ var _30 = useState(null),
12259
+ idFrontCaptureStartedAt = _30[0],
12260
+ setFirstGoodFrameTime = _30[1];
12225
12261
  useEffect(function () {
12226
12262
  if (goodFramesCount === 1) setFirstGoodFrameTime(new Date().getTime());
12227
12263
  }, [goodFramesCount]);
@@ -12242,80 +12278,60 @@ var IdVideoCapture = function IdVideoCapture(_a) {
12242
12278
  var frameHeight = (_e = (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) !== null && _e !== void 0 ? _e : 0;
12243
12279
  var faceBox = face === null || face === void 0 ? void 0 : face.box;
12244
12280
  var faceCentered = !faceBox || !frameWidth || faceBox.xMin > frameWidth * edgeBoundary && faceBox.yMin > frameHeight * edgeBoundary && faceBox.xMax < frameWidth * (1 - edgeBoundary) && faceBox.yMax < frameHeight * (1 - edgeBoundary);
12245
- var _30 = useState(),
12246
- countdownStartedAt = _30[0],
12247
- setCountdownStartedAt = _30[1];
12281
+ var _31 = useState(),
12282
+ countdownStartedAt = _31[0],
12283
+ setCountdownStartedAt = _31[1];
12248
12284
  var photoCanvas = useRef(null);
12249
12285
  var frameLock = useRef(false);
12250
12286
  var captureFrame = useCallback(function () {
12251
12287
  return __awaiter(void 0, void 0, void 0, function () {
12252
- var frameBase64, _a;
12253
- return __generator(this, function (_b) {
12254
- switch (_b.label) {
12255
- case 0:
12256
- if (frameLock.current) return [2 /*return*/];
12257
- frameLock.current = true;
12258
- drawToCanvas(photoCanvas.current, videoRef.current);
12259
- frameBase64 = photoCanvas.current.toDataURL('image/jpeg');
12260
- if (!frameBase64) {
12261
- frameLock.current = false;
12262
- return [2 /*return*/];
12263
- }
12264
- _b.label = 1;
12265
- case 1:
12266
- _b.trys.push([1,, 7, 8]);
12267
- if (!(requestedAction == 'SHOW_ID_FRONT')) return [3 /*break*/, 5];
12288
+ var frameBase64;
12289
+ return __generator(this, function (_a) {
12290
+ if (frameLock.current) return [2 /*return*/];
12291
+ frameLock.current = true;
12292
+ drawToCanvas(photoCanvas.current, videoRef.current);
12293
+ frameBase64 = photoCanvas.current.toDataURL('image/jpeg');
12294
+ if (!frameBase64) {
12295
+ frameLock.current = false;
12296
+ return [2 /*return*/];
12297
+ }
12298
+ try {
12299
+ if (requestedAction == 'SHOW_ID_FRONT') {
12268
12300
  if (onIdFrontImageCaptured) {
12269
12301
  onIdFrontImageCaptured(frameBase64);
12270
12302
  }
12271
- if (!skipShowIdCardBack) return [3 /*break*/, 4];
12272
- _a = skipShowIdCardBack === true;
12273
- if (_a) return [3 /*break*/, 3];
12274
- return [4 /*yield*/, skipShowIdCardBack()];
12275
- case 2:
12276
- _a = _b.sent();
12277
- _b.label = 3;
12278
- case 3:
12279
- if (_a) {
12303
+ if (isSinglePage || evaluateShouldSkip(skipShowIdCardBack)) {
12280
12304
  return [2 /*return*/, onIdCaptureComplete()];
12281
12305
  }
12282
- _b.label = 4;
12283
- case 4:
12284
12306
  setRequestedAction('FLIP_ID');
12285
- return [3 /*break*/, 6];
12286
- case 5:
12287
- if (requestedAction == 'SHOW_ID_BACK') {
12288
- if (onIdBackImageCaptured) {
12289
- onIdBackImageCaptured(frameBase64);
12290
- }
12291
- onIdCaptureComplete();
12292
- } else if (requestedAction == 'SHOW_PASSPORT') {
12293
- if (onIdFrontImageCaptured) {
12294
- onIdFrontImageCaptured(frameBase64);
12295
- }
12296
- onIdCaptureComplete();
12307
+ } else if (requestedAction == 'SHOW_ID_BACK') {
12308
+ if (onIdBackImageCaptured) {
12309
+ onIdBackImageCaptured(frameBase64);
12297
12310
  }
12298
- _b.label = 6;
12299
- case 6:
12300
- return [3 /*break*/, 8];
12301
- case 7:
12302
- setDetectedObjects([]);
12303
- setCurrentDetectionScore(0);
12304
- setCurrentFocusScore(0);
12305
- setGoodFramesCount(0);
12306
- setCountdownStartedAt(undefined);
12307
- resetBestFrame();
12308
- frameLock.current = false;
12309
- if (countdownTimeoutRef.current) {
12310
- clearTimeout(countdownTimeoutRef.current);
12311
+ onIdCaptureComplete();
12312
+ } else if (requestedAction == 'SHOW_PASSPORT') {
12313
+ if (onIdFrontImageCaptured) {
12314
+ onIdFrontImageCaptured(frameBase64);
12311
12315
  }
12312
- return [7 /*endfinally*/];
12313
- case 8:
12314
- return [2 /*return*/];
12316
+ onIdCaptureComplete();
12317
+ }
12318
+ } finally {
12319
+ setDetectedObjects([]);
12320
+ setCurrentDetectionScore(0);
12321
+ setCurrentFocusScore(0);
12322
+ setGoodFramesCount(0);
12323
+ setCountdownStartedAt(undefined);
12324
+ setIsSinglePage(false);
12325
+ resetBestFrame();
12326
+ frameLock.current = false;
12327
+ if (countdownTimeoutRef.current) {
12328
+ clearTimeout(countdownTimeoutRef.current);
12329
+ }
12315
12330
  }
12331
+ return [2 /*return*/];
12316
12332
  });
12317
12333
  });
12318
- }, [onIdCaptureComplete, onIdBackImageCaptured, onIdFrontImageCaptured, requestedAction, resetBestFrame, skipShowIdCardBack, videoRef]);
12334
+ }, [videoRef, requestedAction, onIdFrontImageCaptured, isSinglePage, skipShowIdCardBack, onIdCaptureComplete, onIdBackImageCaptured, resetBestFrame]);
12319
12335
  var isFlipping = requestedAction === 'FLIP_ID';
12320
12336
  useEffect(function () {
12321
12337
  if (!isFlipping) return;
@@ -12374,9 +12390,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
12374
12390
  stopSelfieGuidance();
12375
12391
  };
12376
12392
  }, [startSelfieGuidance, stopSelfieGuidance]);
12377
- var _31 = useState(0),
12378
- numFramesWithoutFaces = _31[0],
12379
- setNumFramesWithoutFaces = _31[1];
12393
+ var _32 = useState(0),
12394
+ numFramesWithoutFaces = _32[0],
12395
+ setNumFramesWithoutFaces = _32[1];
12380
12396
  onSelfiePredictionMade(useThrottledCallback(useCallback(function (_a) {
12381
12397
  var face = _a.face;
12382
12398
  if (selfieModelError) return;
@@ -12392,12 +12408,12 @@ var IdVideoCapture = function IdVideoCapture(_a) {
12392
12408
  }
12393
12409
  }, [disableFaceDetectionWhileAudioCapture, disableFaceDetectionWhileAudioCaptureMsDelay, numFramesWithoutFaces, onFaceNotDetected, timeoutStartedAt]);
12394
12410
  var theme = useTheme();
12395
- var _32 = useTranslations(rawVerbiage, {
12411
+ var _33 = useTranslations(rawVerbiage, {
12396
12412
  faceNotCenteredText: 'Please move your face to the center...',
12397
12413
  captureBtnText: 'Capture'
12398
12414
  }),
12399
- captureBtnText = _32.captureBtnText,
12400
- faceNotCenteredText = _32.faceNotCenteredText;
12415
+ captureBtnText = _33.captureBtnText,
12416
+ faceNotCenteredText = _33.faceNotCenteredText;
12401
12417
  var debugScalingDetails = useDebugScalingDetails({
12402
12418
  enabled: debugMode,
12403
12419
  pageWidth: width,
@@ -12472,6 +12488,11 @@ var CountdownContainer = styled.div(templateObject_1$5 || (templateObject_1$5 =
12472
12488
  var Countdown = styled.div(templateObject_2$5 || (templateObject_2$5 = __makeTemplateObject(["\n color: white;\n font-size: 64px;\n font-weight: bold;\n margin: auto;\n"], ["\n color: white;\n font-size: 64px;\n font-weight: bold;\n margin: auto;\n"])));
12473
12489
  var CaptureButtonContainer = styled.div(templateObject_3$5 || (templateObject_3$5 = __makeTemplateObject(["\n position: fixed;\n bottom: 0;\n width: 100dvw;\n display: flex;\n z-index: 100000;\n"], ["\n position: fixed;\n bottom: 0;\n width: 100dvw;\n display: flex;\n z-index: 100000;\n"])));
12474
12490
  var CaptureButton = styled(LoaderButton)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n margin: 0 auto 25px;\n"], ["\n margin: 0 auto 25px;\n"])));
12491
+ function evaluateShouldSkip(value) {
12492
+ if (value === true) return true;
12493
+ if (typeof value === 'function') return value();
12494
+ return false;
12495
+ }
12475
12496
  var templateObject_1$5, templateObject_2$5, templateObject_3$5, templateObject_4;
12476
12497
 
12477
12498
  var IdVideoCaptureSuccess = function IdVideoCaptureSuccess(_a) {
@@ -12765,7 +12786,8 @@ var VideoIdWizard = function VideoIdWizard(_a) {
12765
12786
  documentDetectionModelUrl: (_g = (_f = idCaptureProps.assets) === null || _f === void 0 ? void 0 : _f.documentDetectionModelUrl) !== null && _g !== void 0 ? _g : '',
12766
12787
  focusModelUrl: (_j = (_h = idCaptureProps.assets) === null || _h === void 0 ? void 0 : _h.focusModelUrl) !== null && _j !== void 0 ? _j : '',
12767
12788
  onModelError: onIdCaptureModelError,
12768
- modelLoadTimeoutMs: idCaptureModelLoadTimeoutMs
12789
+ modelLoadTimeoutMs: idCaptureModelLoadTimeoutMs,
12790
+ allowSinglePageIdCapture: idCaptureProps.allowSinglePageIdCapture
12769
12791
  }, /*#__PURE__*/React__default.createElement(SelfieGuidanceModelsProvider, {
12770
12792
  autoStart: false,
12771
12793
  onModelError: faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.onModelError,
@@ -13015,7 +13037,8 @@ function CompositeWizard(_a) {
13015
13037
  documentDetectionModelUrl: (_d = (_c = idCaptureProps.assets) === null || _c === void 0 ? void 0 : _c.documentDetectionModelUrl) !== null && _d !== void 0 ? _d : '',
13016
13038
  focusModelUrl: (_f = (_e = idCaptureProps.assets) === null || _e === void 0 ? void 0 : _e.focusModelUrl) !== null && _f !== void 0 ? _f : '',
13017
13039
  onModelError: idCaptureProps.onModelError,
13018
- modelLoadTimeoutMs: idCaptureProps.modelLoadTimeoutMs
13040
+ modelLoadTimeoutMs: idCaptureProps.modelLoadTimeoutMs,
13041
+ allowSinglePageIdCapture: idCaptureProps.allowSinglePageIdCapture
13019
13042
  }, /*#__PURE__*/React__default.createElement(IdCaptureStateProvider, null, /*#__PURE__*/React__default.createElement(GuideOrientationContextProvider, null, /*#__PURE__*/React__default.createElement(IdCaptureWizard, _assign({}, idCaptureProps, {
13020
13043
  onSuccess: onIdCaptureSuccess
13021
13044
  }))))));
@@ -13337,31 +13360,33 @@ var IdValidation = function IdValidation(_a) {
13337
13360
  onLoadingOverlayDismissed = _a.onLoadingOverlayDismissed,
13338
13361
  _d = _a.idCaptureRequirement,
13339
13362
  idCaptureRequirement = _d === void 0 ? 'idCardOrPassport' : _d,
13340
- _e = _a.separateIdCardCaptureSequence,
13341
- separateIdCardCaptureSequence = _e === void 0 ? false : _e,
13342
- _f = _a.idCaptureThresholds,
13343
- idCaptureThresholds = _f === void 0 ? defaultIdCaptureThresholds : _f,
13344
- _g = _a.skipSuccessScreen,
13345
- skipSuccessScreen = _g === void 0 ? false : _g,
13363
+ _e = _a.allowSinglePageIdCapture,
13364
+ allowSinglePageIdCapture = _e === void 0 ? false : _e,
13365
+ _f = _a.separateIdCardCaptureSequence,
13366
+ separateIdCardCaptureSequence = _f === void 0 ? false : _f,
13367
+ _g = _a.idCaptureThresholds,
13368
+ idCaptureThresholds = _g === void 0 ? defaultIdCaptureThresholds : _g,
13369
+ _h = _a.skipSuccessScreen,
13370
+ skipSuccessScreen = _h === void 0 ? false : _h,
13346
13371
  instructions = _a.instructions,
13347
- _h = _a.guideType,
13348
- guideType = _h === void 0 ? 'fit' : _h,
13349
- _j = _a.guideImages,
13350
- guideImages = _j === void 0 ? defaultIdCaptureGuideImages : _j,
13351
- _k = _a.portraitGuidesOnMobile,
13352
- portraitGuidesOnMobile = _k === void 0 ? true : _k,
13353
- _l = _a.rotateLoadingOverlayImageWhenPortrait,
13354
- rotateLoadingOverlayImageWhenPortrait = _l === void 0 ? true : _l,
13355
- _m = _a.modelLoadTimeoutMs,
13356
- modelLoadTimeoutMs = _m === void 0 ? defaultDocumentDetectionModelLoadTimeoutMs : _m,
13357
- _o = _a.forceFallbackMode,
13358
- forceFallbackMode = _o === void 0 ? false : _o,
13359
- _p = _a.allowIdCardBackToFrontCapture,
13360
- allowIdCardBackToFrontCapture = _p === void 0 ? false : _p,
13361
- _q = _a.enableOverrideWrongDocumentTypeDialog,
13362
- enableOverrideWrongDocumentTypeDialog = _q === void 0 ? false : _q,
13363
- _r = _a.allowOverrideWrongDocumentTypeAfterMs,
13364
- allowOverrideWrongDocumentTypeAfterMs = _r === void 0 ? 8000 : _r,
13372
+ _j = _a.guideType,
13373
+ guideType = _j === void 0 ? 'fit' : _j,
13374
+ _k = _a.guideImages,
13375
+ guideImages = _k === void 0 ? defaultIdCaptureGuideImages : _k,
13376
+ _l = _a.portraitGuidesOnMobile,
13377
+ portraitGuidesOnMobile = _l === void 0 ? true : _l,
13378
+ _m = _a.rotateLoadingOverlayImageWhenPortrait,
13379
+ rotateLoadingOverlayImageWhenPortrait = _m === void 0 ? true : _m,
13380
+ _o = _a.modelLoadTimeoutMs,
13381
+ modelLoadTimeoutMs = _o === void 0 ? defaultDocumentDetectionModelLoadTimeoutMs : _o,
13382
+ _p = _a.forceFallbackMode,
13383
+ forceFallbackMode = _p === void 0 ? false : _p,
13384
+ _q = _a.allowIdCardBackToFrontCapture,
13385
+ allowIdCardBackToFrontCapture = _q === void 0 ? false : _q,
13386
+ _r = _a.enableOverrideWrongDocumentTypeDialog,
13387
+ enableOverrideWrongDocumentTypeDialog = _r === void 0 ? false : _r,
13388
+ _s = _a.allowOverrideWrongDocumentTypeAfterMs,
13389
+ allowOverrideWrongDocumentTypeAfterMs = _s === void 0 ? 8000 : _s,
13365
13390
  onBeforeSubmit = _a.onBeforeSubmit,
13366
13391
  onBeforeDocumentUpload = _a.onBeforeDocumentUpload,
13367
13392
  onDocumentUploadProgress = _a.onDocumentUploadProgress,
@@ -13375,28 +13400,28 @@ var IdValidation = function IdValidation(_a) {
13375
13400
  onUserCancel = _a.onUserCancel,
13376
13401
  onModelError = _a.onModelError,
13377
13402
  onCameraAccessDenied = _a.onCameraAccessDenied,
13378
- _s = _a.theme,
13379
- theme = _s === void 0 ? 'default' : _s,
13380
- _t = _a.assets,
13381
- assets = _t === void 0 ? {} : _t,
13382
- _u = _a.classNames,
13383
- classNames = _u === void 0 ? {} : _u,
13384
- _v = _a.colors,
13385
- colors = _v === void 0 ? {} : _v,
13386
- _w = _a.verbiage,
13387
- verbiage = _w === void 0 ? {} : _w,
13388
- _x = _a.captureSignature,
13389
- captureSignature = _x === void 0 ? false : _x,
13390
- _y = _a.captureSignatureVideo,
13391
- captureSignatureVideo = _y === void 0 ? false : _y,
13392
- _z = _a.captureAdditionalDocuments,
13393
- captureAdditionalDocuments = _z === void 0 ? [] : _z,
13394
- _0 = _a.geolocationEnabled,
13395
- geolocationEnabled = _0 === void 0 ? true : _0,
13396
- _1 = _a.geolocationRequired,
13397
- geolocationRequired = _1 === void 0 ? false : _1,
13398
- _2 = _a.debugMode,
13399
- debugMode = _2 === void 0 ? false : _2;
13403
+ _t = _a.theme,
13404
+ theme = _t === void 0 ? 'default' : _t,
13405
+ _u = _a.assets,
13406
+ assets = _u === void 0 ? {} : _u,
13407
+ _v = _a.classNames,
13408
+ classNames = _v === void 0 ? {} : _v,
13409
+ _w = _a.colors,
13410
+ colors = _w === void 0 ? {} : _w,
13411
+ _x = _a.verbiage,
13412
+ verbiage = _x === void 0 ? {} : _x,
13413
+ _y = _a.captureSignature,
13414
+ captureSignature = _y === void 0 ? false : _y,
13415
+ _z = _a.captureSignatureVideo,
13416
+ captureSignatureVideo = _z === void 0 ? false : _z,
13417
+ _0 = _a.captureAdditionalDocuments,
13418
+ captureAdditionalDocuments = _0 === void 0 ? [] : _0,
13419
+ _1 = _a.geolocationEnabled,
13420
+ geolocationEnabled = _1 === void 0 ? true : _1,
13421
+ _2 = _a.geolocationRequired,
13422
+ geolocationRequired = _2 === void 0 ? false : _2,
13423
+ _3 = _a.debugMode,
13424
+ debugMode = _3 === void 0 ? false : _3;
13400
13425
  useLanguage(lang);
13401
13426
  useDebugLogging(debugMode);
13402
13427
  var idCaptureProps = useMemo(function () {
@@ -13406,6 +13431,7 @@ var IdValidation = function IdValidation(_a) {
13406
13431
  onModelError: onModelError,
13407
13432
  precapturedDocuments: precapturedDocuments,
13408
13433
  captureRequirement: idCaptureRequirement,
13434
+ allowSinglePageIdCapture: allowSinglePageIdCapture,
13409
13435
  separateIdCardCaptureSequence: separateIdCardCaptureSequence,
13410
13436
  thresholds: idCaptureThresholds,
13411
13437
  skipSuccessScreen: skipSuccessScreen,
@@ -13428,7 +13454,7 @@ var IdValidation = function IdValidation(_a) {
13428
13454
  verbiage: verbiage,
13429
13455
  debugMode: debugMode
13430
13456
  };
13431
- }, [onExitCapture, onUserCancel, onModelError, precapturedDocuments, idCaptureRequirement, separateIdCardCaptureSequence, idCaptureThresholds, skipSuccessScreen, loadingOverlayMode, customOverlayContent, onLoadingOverlayDismissed, forceFallbackMode, allowIdCardBackToFrontCapture, instructions, guideType, guideImages, portraitGuidesOnMobile, rotateLoadingOverlayImageWhenPortrait, modelLoadTimeoutMs, enableOverrideWrongDocumentTypeDialog, allowOverrideWrongDocumentTypeAfterMs, assets, classNames, colors, verbiage, debugMode]);
13457
+ }, [onExitCapture, onUserCancel, onModelError, precapturedDocuments, idCaptureRequirement, allowSinglePageIdCapture, separateIdCardCaptureSequence, idCaptureThresholds, skipSuccessScreen, loadingOverlayMode, customOverlayContent, onLoadingOverlayDismissed, forceFallbackMode, allowIdCardBackToFrontCapture, instructions, guideType, guideImages, portraitGuidesOnMobile, rotateLoadingOverlayImageWhenPortrait, modelLoadTimeoutMs, enableOverrideWrongDocumentTypeDialog, allowOverrideWrongDocumentTypeAfterMs, assets, classNames, colors, verbiage, debugMode]);
13432
13458
  var additionalDocumentCaptureProps = useMemo(function () {
13433
13459
  return {
13434
13460
  documents: captureAdditionalDocuments,