idmission-web-sdk 2.1.0 → 2.1.1

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.
@@ -4,9 +4,11 @@ export type AdditionalDocument = {
4
4
  name: string;
5
5
  description?: string;
6
6
  skip?: () => Promise<boolean>;
7
+ processAsPOA?: boolean;
7
8
  };
8
9
  export type UploadedDocument = {
9
10
  documentName: string;
11
+ processAsPOA: 'Y' | 'N';
10
12
  additionalDocument: string | Record<string, string>;
11
13
  };
12
14
  export type AdditionalDocumentCaptureClassNames = {
@@ -8,6 +8,7 @@ export type CapturedDocument = {
8
8
  aspectRatio?: number;
9
9
  cameraFeedMode?: CameraFeedMode;
10
10
  instructions?: ReactNode;
11
+ processAsPOA?: boolean;
11
12
  documentId?: string;
12
13
  content?: Blob;
13
14
  contentUrl?: string;
@@ -32,6 +32,7 @@ export type IdCaptureVerbiage = {
32
32
  captureFailedText?: CustomerSuppliedVerbiage;
33
33
  guidanceSatisfiedText?: CustomerSuppliedVerbiage;
34
34
  guidancePleaseFlipText?: CustomerSuppliedVerbiage;
35
+ guidanceBackDetectedFirstText?: CustomerSuppliedVerbiage;
35
36
  guidanceTooBlurryText?: CustomerSuppliedVerbiage;
36
37
  guidanceNotCenteredText?: CustomerSuppliedVerbiage;
37
38
  guidanceTooCloseText?: CustomerSuppliedVerbiage;
@@ -36,8 +36,8 @@ export type IdCaptureModelsState = {
36
36
  bestFrameDetails: BestFrameDetails | null;
37
37
  getBestFrame: () => BestFrame | null;
38
38
  resetBestFrame: () => void;
39
- requiredDocumentType: DocumentType;
40
- setRequiredDocumentType: (value: DocumentType) => void;
39
+ requiredDocumentType: DocumentType | DocumentType[];
40
+ setRequiredDocumentType: (value: DocumentType | DocumentType[]) => void;
41
41
  };
42
42
  export declare const IdCaptureModelsContext: React.Context<IdCaptureModelsState>;
43
43
  export type IdCaptureModelsProviderProps = {
@@ -26,6 +26,7 @@ export type IdCaptureState = {
26
26
  documentInBounds: boolean;
27
27
  documentTooClose: boolean;
28
28
  flipRequired: boolean;
29
+ backDetectedFirst: boolean;
29
30
  idCardFrontDetectionScore: number;
30
31
  idCardFrontDetectionThresholdMet: boolean;
31
32
  idCardBackDetectionScore: number;
@@ -49,7 +49,7 @@ var LanguageDetector__default = /*#__PURE__*/_interopDefaultLegacy(LanguageDetec
49
49
  var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
50
50
  var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
51
51
 
52
- var webSdkVersion = '2.1.0';
52
+ var webSdkVersion = '2.1.1';
53
53
 
54
54
  function getPlatform() {
55
55
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -3751,33 +3751,33 @@ function IdCaptureModelsProviderInner(_a) {
3751
3751
  onDocumentDetected(function (prediction) {
3752
3752
  return tslib.__awaiter(_this, void 0, void 0, function () {
3753
3753
  var stopDetectionAtStart, focusPredictionTime, focusScore, focusThresholdMet, isRequiredDocumentType, focusPrediction, focusThresholdSet, focusThreshold;
3754
- var _a, _b, _c, _d, _e;
3755
- return tslib.__generator(this, function (_f) {
3754
+ var _a, _b, _c, _d, _e, _f;
3755
+ return tslib.__generator(this, function (_g) {
3756
3756
  if (!lastPredictionCanvas.current) return [2 /*return*/];
3757
3757
  stopDetectionAtStart = stopDetection.current;
3758
3758
  focusPredictionTime = 0, focusScore = 0, focusThresholdMet = false;
3759
- isRequiredDocumentType = requiredDocumentType === 'none' || prediction.detectedDocumentType === requiredDocumentType;
3759
+ isRequiredDocumentType = requiredDocumentType === 'none' || prediction.detectedDocumentType === requiredDocumentType || ((_a = requiredDocumentType.includes) === null || _a === void 0 ? void 0 : _a.call(requiredDocumentType, prediction.detectedDocumentType));
3760
3760
  if (isRequiredDocumentType && prediction.detectedDocumentType !== 'none' && prediction.detectionThresholdMet && prediction.documentInBounds && !prediction.documentTooClose) {
3761
- focusPrediction = makeFocusPrediction(lastPredictionCanvas.current, (_a = prediction.bestDocument) === null || _a === void 0 ? void 0 : _a.box);
3761
+ focusPrediction = makeFocusPrediction(lastPredictionCanvas.current, (_b = prediction.bestDocument) === null || _b === void 0 ? void 0 : _b.box);
3762
3762
  if (focusPrediction) {
3763
3763
  focusScore = focusPrediction.score;
3764
3764
  focusPredictionTime = focusPrediction.predictionTime;
3765
3765
  }
3766
- focusThresholdSet = (_b = thresholds.focus) === null || _b === void 0 ? void 0 : _b[prediction.detectedDocumentType];
3767
- 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;
3766
+ focusThresholdSet = (_c = thresholds.focus) === null || _c === void 0 ? void 0 : _c[prediction.detectedDocumentType];
3767
+ 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;
3768
3768
  focusThresholdMet = focusScore >= focusThreshold;
3769
3769
  if (bestFocusScore.current <= focusScore && stopDetectionAtStart === stopDetection.current) {
3770
3770
  bestFocusScore.current = focusScore;
3771
3771
  drawToCanvas(bestPredictionCanvas.current, lastPredictionCanvas.current);
3772
3772
  setBestFrameDetails({
3773
- boundingBox: (_d = prediction.bestDocument) === null || _d === void 0 ? void 0 : _d.box,
3773
+ boundingBox: (_e = prediction.bestDocument) === null || _e === void 0 ? void 0 : _e.box,
3774
3774
  documentType: prediction.detectedDocumentType,
3775
3775
  detectionScore: prediction.detectionScore,
3776
3776
  focusScore: focusScore
3777
3777
  });
3778
3778
  }
3779
3779
  }
3780
- (_e = onPredictionHandler.current) === null || _e === void 0 ? void 0 : _e.call(onPredictionHandler, tslib.__assign(tslib.__assign({}, prediction), {
3780
+ (_f = onPredictionHandler.current) === null || _f === void 0 ? void 0 : _f.call(onPredictionHandler, tslib.__assign(tslib.__assign({}, prediction), {
3781
3781
  focusScore: focusScore,
3782
3782
  focusPredictionTime: focusPredictionTime,
3783
3783
  focusThresholdMet: focusThresholdMet
@@ -3887,6 +3887,7 @@ var initialState$4 = {
3887
3887
  documentInBounds: false,
3888
3888
  documentTooClose: false,
3889
3889
  flipRequired: false,
3890
+ backDetectedFirst: false,
3890
3891
  idCardFrontDetectionScore: 0,
3891
3892
  idCardFrontDetectionThresholdMet: false,
3892
3893
  idCardBackDetectionScore: 0,
@@ -4003,7 +4004,8 @@ var reducer$4 = function reducer(state, action) {
4003
4004
  }
4004
4005
  }
4005
4006
  var flipRequired = state.requestedDocumentType === 'idCardBack' && detectedDocumentType === 'idCardFront';
4006
- var isGoodFrame = detectionThresholdMet && documentInBounds && !documentTooClose && !flipRequired && focusThresholdMet;
4007
+ var backDetectedFirst = state.requestedDocumentType.includes('idCardFront') && detectedDocumentType === 'idCardBack';
4008
+ var isGoodFrame = detectionThresholdMet && documentInBounds && !documentTooClose && !flipRequired && !backDetectedFirst && focusThresholdMet;
4007
4009
  var goodFramesCount = state.goodFramesCount;
4008
4010
  if (isGoodFrame) {
4009
4011
  goodFramesCount += 1;
@@ -4029,6 +4031,7 @@ var reducer$4 = function reducer(state, action) {
4029
4031
  documentInBounds: documentInBounds,
4030
4032
  documentTooClose: documentTooClose,
4031
4033
  flipRequired: flipRequired,
4034
+ backDetectedFirst: backDetectedFirst,
4032
4035
  idCardFrontDetectionScore: idCardFrontDetectionScore,
4033
4036
  idCardFrontDetectionThresholdMet: idCardFrontDetectionThresholdMet,
4034
4037
  idCardBackDetectionScore: idCardBackDetectionScore,
@@ -4682,6 +4685,7 @@ var IdCapture = function IdCapture(_a) {
4682
4685
  processingIdCardText: 'ID card front captured.',
4683
4686
  guidanceSatisfiedText: "".concat(documentTypeDisplayNames[state.detectedDocumentType], " detected, hold still..."),
4684
4687
  guidancePleaseFlipText: 'ID card front detected - please flip your ID card',
4688
+ guidanceBackDetectedFirstText: 'ID card back detected - please flip your ID card',
4685
4689
  guidanceTooBlurryText: 'Document out of focus – try improving the lighting',
4686
4690
  guidanceNotCenteredText: 'Document is not centered',
4687
4691
  guidanceTooCloseText: 'Document too close, please back up',
@@ -4696,7 +4700,7 @@ var IdCapture = function IdCapture(_a) {
4696
4700
  });
4697
4701
  var satisfied = state.isGoodFrame;
4698
4702
  if (typeof guidanceSatisfied === 'boolean') satisfied = guidanceSatisfied;
4699
- 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 : '');
4703
+ 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 : '');
4700
4704
  return /*#__PURE__*/React__default['default'].createElement(PageContainer, {
4701
4705
  ref: ref,
4702
4706
  className: "flex ".concat((_h = classNames.container) !== null && _h !== void 0 ? _h : '')
@@ -7487,13 +7491,23 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
7487
7491
  };
7488
7492
  }, [dispatch, resetBestFrame, separateIdCardCaptureSequence, state.captureState]);
7489
7493
  React.useEffect(function () {
7494
+ if (state.requestedDocumentType === 'idCardFront') {
7495
+ if (captureRequirement === 'idCardOrPassport') {
7496
+ setRequiredDocumentType(['idCardFront', 'passport']);
7497
+ } else {
7498
+ setRequiredDocumentType('idCardFront');
7499
+ }
7500
+ }
7490
7501
  if (state.requestedDocumentType === 'idCardBack') {
7491
7502
  setRequiredDocumentType('idCardBack');
7492
7503
  }
7504
+ if (state.requestedDocumentType === 'passport') {
7505
+ setRequiredDocumentType('passport');
7506
+ }
7493
7507
  return function () {
7494
7508
  setRequiredDocumentType('none');
7495
7509
  };
7496
- }, [setRequiredDocumentType, state.requestedDocumentType]);
7510
+ }, [captureRequirement, setRequiredDocumentType, state.requestedDocumentType]);
7497
7511
  var handleCapture = React.useCallback(function (imageData) {
7498
7512
  return tslib.__awaiter(void 0, void 0, void 0, function () {
7499
7513
  var base64ImageData;
@@ -9397,6 +9411,7 @@ var AdditionalDocumentCapture = function AdditionalDocumentCapture(_a) {
9397
9411
  var fileContent = fileReader.result.toString();
9398
9412
  onComplete === null || onComplete === void 0 ? void 0 : onComplete({
9399
9413
  documentName: document.name,
9414
+ processAsPOA: document.processAsPOA ? 'Y' : 'N',
9400
9415
  additionalDocument: {
9401
9416
  name: file.name,
9402
9417
  fileContent: dataUrlToBase64Sync(fileContent),