idmission-web-sdk 2.1.0 → 2.1.2

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.
@@ -140,7 +140,7 @@
140
140
  return cooked;
141
141
  }
142
142
 
143
- var webSdkVersion = '2.1.0';
143
+ var webSdkVersion = '2.1.2';
144
144
 
145
145
  function getPlatform() {
146
146
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -4302,33 +4302,33 @@
4302
4302
  onDocumentDetected(function (prediction) {
4303
4303
  return __awaiter(_this, void 0, void 0, function () {
4304
4304
  var stopDetectionAtStart, focusPredictionTime, focusScore, focusThresholdMet, isRequiredDocumentType, focusPrediction, focusThresholdSet, focusThreshold;
4305
- var _a, _b, _c, _d, _e;
4306
- return __generator(this, function (_f) {
4305
+ var _a, _b, _c, _d, _e, _f;
4306
+ return __generator(this, function (_g) {
4307
4307
  if (!lastPredictionCanvas.current) return [2 /*return*/];
4308
4308
  stopDetectionAtStart = stopDetection.current;
4309
4309
  focusPredictionTime = 0, focusScore = 0, focusThresholdMet = false;
4310
- isRequiredDocumentType = requiredDocumentType === 'none' || prediction.detectedDocumentType === requiredDocumentType;
4310
+ isRequiredDocumentType = requiredDocumentType === 'none' || prediction.detectedDocumentType === requiredDocumentType || ((_a = requiredDocumentType.includes) === null || _a === void 0 ? void 0 : _a.call(requiredDocumentType, prediction.detectedDocumentType));
4311
4311
  if (isRequiredDocumentType && prediction.detectedDocumentType !== 'none' && prediction.detectionThresholdMet && prediction.documentInBounds && !prediction.documentTooClose) {
4312
- focusPrediction = makeFocusPrediction(lastPredictionCanvas.current, (_a = prediction.bestDocument) === null || _a === void 0 ? void 0 : _a.box);
4312
+ focusPrediction = makeFocusPrediction(lastPredictionCanvas.current, (_b = prediction.bestDocument) === null || _b === void 0 ? void 0 : _b.box);
4313
4313
  if (focusPrediction) {
4314
4314
  focusScore = focusPrediction.score;
4315
4315
  focusPredictionTime = focusPrediction.predictionTime;
4316
4316
  }
4317
- focusThresholdSet = (_b = thresholds.focus) === null || _b === void 0 ? void 0 : _b[prediction.detectedDocumentType];
4318
- focusThreshold = (_c = onMobile ? focusThresholdSet === null || focusThresholdSet === void 0 ? void 0 : focusThresholdSet.mobile : focusThresholdSet === null || focusThresholdSet === void 0 ? void 0 : focusThresholdSet.desktop) !== null && _c !== void 0 ? _c : 0;
4317
+ focusThresholdSet = (_c = thresholds.focus) === null || _c === void 0 ? void 0 : _c[prediction.detectedDocumentType];
4318
+ 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;
4319
4319
  focusThresholdMet = focusScore >= focusThreshold;
4320
4320
  if (bestFocusScore.current <= focusScore && stopDetectionAtStart === stopDetection.current) {
4321
4321
  bestFocusScore.current = focusScore;
4322
4322
  drawToCanvas(bestPredictionCanvas.current, lastPredictionCanvas.current);
4323
4323
  setBestFrameDetails({
4324
- boundingBox: (_d = prediction.bestDocument) === null || _d === void 0 ? void 0 : _d.box,
4324
+ boundingBox: (_e = prediction.bestDocument) === null || _e === void 0 ? void 0 : _e.box,
4325
4325
  documentType: prediction.detectedDocumentType,
4326
4326
  detectionScore: prediction.detectionScore,
4327
4327
  focusScore: focusScore
4328
4328
  });
4329
4329
  }
4330
4330
  }
4331
- (_e = onPredictionHandler.current) === null || _e === void 0 ? void 0 : _e.call(onPredictionHandler, __assign$1(__assign$1({}, prediction), {
4331
+ (_f = onPredictionHandler.current) === null || _f === void 0 ? void 0 : _f.call(onPredictionHandler, __assign$1(__assign$1({}, prediction), {
4332
4332
  focusScore: focusScore,
4333
4333
  focusPredictionTime: focusPredictionTime,
4334
4334
  focusThresholdMet: focusThresholdMet
@@ -4440,6 +4440,7 @@
4440
4440
  documentInBounds: false,
4441
4441
  documentTooClose: false,
4442
4442
  flipRequired: false,
4443
+ backDetectedFirst: false,
4443
4444
  idCardFrontDetectionScore: 0,
4444
4445
  idCardFrontDetectionThresholdMet: false,
4445
4446
  idCardBackDetectionScore: 0,
@@ -4556,7 +4557,8 @@
4556
4557
  }
4557
4558
  }
4558
4559
  var flipRequired = state.requestedDocumentType === 'idCardBack' && detectedDocumentType === 'idCardFront';
4559
- var isGoodFrame = detectionThresholdMet && documentInBounds && !documentTooClose && !flipRequired && focusThresholdMet;
4560
+ var backDetectedFirst = state.requestedDocumentType.includes('idCardFront') && detectedDocumentType === 'idCardBack';
4561
+ var isGoodFrame = detectionThresholdMet && documentInBounds && !documentTooClose && !flipRequired && !backDetectedFirst && focusThresholdMet;
4560
4562
  var goodFramesCount = state.goodFramesCount;
4561
4563
  if (isGoodFrame) {
4562
4564
  goodFramesCount += 1;
@@ -4582,6 +4584,7 @@
4582
4584
  documentInBounds: documentInBounds,
4583
4585
  documentTooClose: documentTooClose,
4584
4586
  flipRequired: flipRequired,
4587
+ backDetectedFirst: backDetectedFirst,
4585
4588
  idCardFrontDetectionScore: idCardFrontDetectionScore,
4586
4589
  idCardFrontDetectionThresholdMet: idCardFrontDetectionThresholdMet,
4587
4590
  idCardBackDetectionScore: idCardBackDetectionScore,
@@ -4971,6 +4974,8 @@
4971
4974
  'Document is not centered': 'Documento no centrado',
4972
4975
  'Document too close, please back up': 'Documento muy cerca, favor de alejarse',
4973
4976
  'Document out of focus – try improving the lighting': 'Documento no enfocado - hay que tratar de mejorar la iluminación',
4977
+ 'ID card front detected - please flip your ID card': 'Anverso detectado, por favor voltea tu identificación',
4978
+ 'ID card back detected - please flip your ID card': 'Reverso detectado, por favor voltea tu identificación',
4974
4979
  'Document detected, hold still...': 'Se ha detectado el documento, no moverse por favor...',
4975
4980
  'Capturing...': 'Capturando...',
4976
4981
  'Capture failed!': 'Falló la captura',
@@ -7920,6 +7925,7 @@
7920
7925
  processingIdCardText: 'ID card front captured.',
7921
7926
  guidanceSatisfiedText: "".concat(documentTypeDisplayNames[state.detectedDocumentType], " detected, hold still..."),
7922
7927
  guidancePleaseFlipText: 'ID card front detected - please flip your ID card',
7928
+ guidanceBackDetectedFirstText: 'ID card back detected - please flip your ID card',
7923
7929
  guidanceTooBlurryText: 'Document out of focus – try improving the lighting',
7924
7930
  guidanceNotCenteredText: 'Document is not centered',
7925
7931
  guidanceTooCloseText: 'Document too close, please back up',
@@ -7934,7 +7940,7 @@
7934
7940
  });
7935
7941
  var satisfied = state.isGoodFrame;
7936
7942
  if (typeof guidanceSatisfied === 'boolean') satisfied = guidanceSatisfied;
7937
- guidanceMessage || (guidanceMessage = satisfied ? verbiage.guidanceSatisfiedText : !state.detectionThresholdMet ? verbiage.guidanceNotDetectedText : state.flipRequired ? verbiage.guidancePleaseFlipText : !state.documentInBounds ? verbiage.guidanceNotCenteredText : state.documentTooClose ? verbiage.guidanceTooCloseText : !state.focusThresholdMet ? verbiage.guidanceTooBlurryText : '');
7943
+ guidanceMessage || (guidanceMessage = satisfied ? verbiage.guidanceSatisfiedText : !state.detectionThresholdMet ? verbiage.guidanceNotDetectedText : state.backDetectedFirst ? verbiage.guidanceBackDetectedFirstText : state.flipRequired ? verbiage.guidancePleaseFlipText : !state.documentInBounds ? verbiage.guidanceNotCenteredText : state.documentTooClose ? verbiage.guidanceTooCloseText : !state.focusThresholdMet ? verbiage.guidanceTooBlurryText : '');
7938
7944
  return /*#__PURE__*/React__default['default'].createElement(PageContainer, {
7939
7945
  ref: ref,
7940
7946
  className: "flex ".concat((_h = classNames.container) !== null && _h !== void 0 ? _h : '')
@@ -10725,13 +10731,23 @@
10725
10731
  };
10726
10732
  }, [dispatch, resetBestFrame, separateIdCardCaptureSequence, state.captureState]);
10727
10733
  React.useEffect(function () {
10734
+ if (state.requestedDocumentType === 'idCardFront') {
10735
+ if (captureRequirement === 'idCardOrPassport') {
10736
+ setRequiredDocumentType(['idCardFront', 'passport']);
10737
+ } else {
10738
+ setRequiredDocumentType('idCardFront');
10739
+ }
10740
+ }
10728
10741
  if (state.requestedDocumentType === 'idCardBack') {
10729
10742
  setRequiredDocumentType('idCardBack');
10730
10743
  }
10744
+ if (state.requestedDocumentType === 'passport') {
10745
+ setRequiredDocumentType('passport');
10746
+ }
10731
10747
  return function () {
10732
10748
  setRequiredDocumentType('none');
10733
10749
  };
10734
- }, [setRequiredDocumentType, state.requestedDocumentType]);
10750
+ }, [captureRequirement, setRequiredDocumentType, state.requestedDocumentType]);
10735
10751
  var handleCapture = React.useCallback(function (imageData) {
10736
10752
  return __awaiter(void 0, void 0, void 0, function () {
10737
10753
  var base64ImageData;
@@ -12635,6 +12651,7 @@
12635
12651
  var fileContent = fileReader.result.toString();
12636
12652
  onComplete === null || onComplete === void 0 ? void 0 : onComplete({
12637
12653
  documentName: document.name,
12654
+ processAsPOA: document.processAsPOA ? 'Y' : 'N',
12638
12655
  additionalDocument: {
12639
12656
  name: file.name,
12640
12657
  fileContent: dataUrlToBase64Sync(fileContent),