idmission-web-sdk 0.0.25 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/id_capture/IdCapture.d.ts +2 -10
- package/dist/components/id_capture/IdCaptureModelsProvider.d.ts +2 -1
- package/dist/sdk2.cjs.development.js +70 -57
- package/dist/sdk2.cjs.development.js.map +1 -1
- package/dist/sdk2.cjs.production.js +1 -1
- package/dist/sdk2.cjs.production.js.map +1 -1
- package/dist/sdk2.esm.js +70 -57
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +70 -57
- package/dist/sdk2.umd.development.js.map +1 -1
- package/dist/sdk2.umd.production.js +1 -1
- package/dist/sdk2.umd.production.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,15 +3,7 @@ import '../../lib/utils/OffscreenCanvasPolyfill';
|
|
|
3
3
|
import { DocumentType } from '../../lib/models/DocumentDetection';
|
|
4
4
|
import { PDF417DetectionResult } from '../../lib/barcode/Native';
|
|
5
5
|
import { CaptureAttemptMetadata } from '../../contexts/SubmissionContext';
|
|
6
|
-
|
|
7
|
-
documentDetected: boolean;
|
|
8
|
-
documentType: DocumentType;
|
|
9
|
-
documentScore: number;
|
|
10
|
-
mrzDetected: boolean;
|
|
11
|
-
mrzScore: number;
|
|
12
|
-
focusThresholdMet: boolean;
|
|
13
|
-
focusScore: number;
|
|
14
|
-
};
|
|
6
|
+
import { IdCapturePrediction } from './IdCaptureModelsProvider';
|
|
15
7
|
export type IdCaptureAssets = {
|
|
16
8
|
portraitGuidesImageUrl?: string;
|
|
17
9
|
landscapeGuidesImageUrl?: string;
|
|
@@ -33,7 +25,7 @@ export type IdCaptureProps = {
|
|
|
33
25
|
barcodeScanningEnabled?: boolean;
|
|
34
26
|
maxBarcodeScanAttempts?: number;
|
|
35
27
|
focusScoreThreshold?: number;
|
|
36
|
-
onPrediction?: (prediction:
|
|
28
|
+
onPrediction?: (prediction: IdCapturePrediction) => void;
|
|
37
29
|
onBarcodeScanned?: (result: PDF417DetectionResult) => void;
|
|
38
30
|
onCapture?: (frame: string, width: number, height: number, metadata: CaptureAttemptMetadata) => void;
|
|
39
31
|
processingScreen?: React.ReactElement;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React, { MutableRefObject, ReactElement, ReactNode } from 'react';
|
|
2
|
-
import { DetectedObject } from '../../lib/models/DocumentDetection';
|
|
2
|
+
import { DetectedObject, DocumentType } from '../../lib/models/DocumentDetection';
|
|
3
3
|
import { Frame } from '../../lib/utils/getFrameDimensions';
|
|
4
4
|
export type IdCapturePrediction = {
|
|
5
5
|
detectedObjects: DetectedObject[];
|
|
6
6
|
detectionTime: number;
|
|
7
7
|
detectionScore: number;
|
|
8
8
|
detectionThresholdMet: boolean;
|
|
9
|
+
detectedDocumentType: DocumentType;
|
|
9
10
|
passportDetectionScore: number;
|
|
10
11
|
passportDetectionThresholdMet: boolean;
|
|
11
12
|
mrzDetectionScore: number;
|
|
@@ -7907,7 +7907,7 @@ function clearCanvas(canvas) {
|
|
|
7907
7907
|
function makePredictions(frame, lastPredictionCanvas, thresholds) {
|
|
7908
7908
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
7909
7909
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
7910
|
-
var _l, frameWidth, frameHeight, _o, boxes, scores, labels, time, detectedObjects, bestDocument, bestPassportPage, bestDocumentScore, passportDetectionScore, passportDetectionThresholdMet, bestDocumentOrPassport, detectionScore, detectionThresholdMet, bestMrz, mrzDetectionScore, mrzDetectionThresholdMet, bestPdf417, pdf417DetectionScore, pdf417DetectionThresholdMet, focusPrediction, focusPredictionTime, focusScore, focusThresholdMet;
|
|
7910
|
+
var _l, frameWidth, frameHeight, _o, boxes, scores, labels, time, detectedObjects, bestDocument, bestPassportPage, bestDocumentScore, passportDetectionScore, passportDetectionThresholdMet, bestDocumentOrPassport, detectionScore, detectionThresholdMet, detectedDocumentType, bestMrz, mrzDetectionScore, mrzDetectionThresholdMet, bestPdf417, pdf417DetectionScore, pdf417DetectionThresholdMet, focusPrediction, focusPredictionTime, focusScore, focusThresholdMet;
|
|
7911
7911
|
var _p;
|
|
7912
7912
|
return tslib.__generator(this, function (_q) {
|
|
7913
7913
|
switch (_q.label) {
|
|
@@ -7932,6 +7932,12 @@ function makePredictions(frame, lastPredictionCanvas, thresholds) {
|
|
|
7932
7932
|
bestDocumentOrPassport = bestDocumentScore > passportDetectionScore ? bestDocument : bestPassportPage;
|
|
7933
7933
|
detectionScore = passportDetectionThresholdMet ? passportDetectionScore : bestDocumentScore;
|
|
7934
7934
|
detectionThresholdMet = detectionScore >= ((_d = thresholds.document) !== null && _d !== void 0 ? _d : 0);
|
|
7935
|
+
detectedDocumentType = DocumentType.NONE;
|
|
7936
|
+
if (passportDetectionThresholdMet) {
|
|
7937
|
+
detectedDocumentType = DocumentType.PASSPORT;
|
|
7938
|
+
} else if (detectionThresholdMet) {
|
|
7939
|
+
detectedDocumentType = DocumentType.ID_CARD;
|
|
7940
|
+
}
|
|
7935
7941
|
bestMrz = detectedObjects.find(function (obj) {
|
|
7936
7942
|
return obj.label === 'MRZ';
|
|
7937
7943
|
});
|
|
@@ -7954,14 +7960,15 @@ function makePredictions(frame, lastPredictionCanvas, thresholds) {
|
|
|
7954
7960
|
return [2, {
|
|
7955
7961
|
detectedObjects: detectedObjects,
|
|
7956
7962
|
detectionScore: detectionScore,
|
|
7963
|
+
detectionTime: time,
|
|
7957
7964
|
detectionThresholdMet: detectionThresholdMet,
|
|
7965
|
+
detectedDocumentType: detectedDocumentType,
|
|
7958
7966
|
passportDetectionScore: passportDetectionScore,
|
|
7959
7967
|
passportDetectionThresholdMet: passportDetectionThresholdMet,
|
|
7960
7968
|
mrzDetectionScore: mrzDetectionScore,
|
|
7961
7969
|
mrzDetectionThresholdMet: mrzDetectionThresholdMet,
|
|
7962
7970
|
pdf417DetectionScore: pdf417DetectionScore,
|
|
7963
7971
|
pdf417DetectionThresholdMet: pdf417DetectionThresholdMet,
|
|
7964
|
-
detectionTime: time,
|
|
7965
7972
|
bestDocumentOrPassport: bestDocumentOrPassport,
|
|
7966
7973
|
bestMrz: bestMrz,
|
|
7967
7974
|
bestPdf417: bestPdf417,
|
|
@@ -8360,6 +8367,7 @@ var reducer$5 = function reducer(state, action) {
|
|
|
8360
8367
|
detectedObjects = _a.detectedObjects,
|
|
8361
8368
|
detectionScore = _a.detectionScore,
|
|
8362
8369
|
detectionThresholdMet = _a.detectionThresholdMet,
|
|
8370
|
+
detectedDocumentType = _a.detectedDocumentType,
|
|
8363
8371
|
passportDetectionScore = _a.passportDetectionScore,
|
|
8364
8372
|
passportDetectionThresholdMet = _a.passportDetectionThresholdMet,
|
|
8365
8373
|
mrzDetectionScore = _a.mrzDetectionScore,
|
|
@@ -8382,12 +8390,6 @@ var reducer$5 = function reducer(state, action) {
|
|
|
8382
8390
|
goodFramesThreshold = Math.ceil(3 * frameCaptureRate);
|
|
8383
8391
|
}
|
|
8384
8392
|
}
|
|
8385
|
-
var documentType = DocumentType.NONE;
|
|
8386
|
-
if (passportDetectionThresholdMet) {
|
|
8387
|
-
documentType = DocumentType.PASSPORT;
|
|
8388
|
-
} else if (detectionThresholdMet) {
|
|
8389
|
-
documentType = DocumentType.ID_CARD;
|
|
8390
|
-
}
|
|
8391
8393
|
var documentInBounds = false;
|
|
8392
8394
|
if (bestDocumentOrPassport) {
|
|
8393
8395
|
var _b = bestDocumentOrPassport.bbox,
|
|
@@ -8416,7 +8418,7 @@ var reducer$5 = function reducer(state, action) {
|
|
|
8416
8418
|
bestDocument: bestDocumentOrPassport,
|
|
8417
8419
|
bestMrz: bestMrz,
|
|
8418
8420
|
bestPdf417: bestPdf417,
|
|
8419
|
-
documentType:
|
|
8421
|
+
documentType: detectedDocumentType,
|
|
8420
8422
|
documentInBounds: documentInBounds,
|
|
8421
8423
|
documentDetectionScore: detectionScore,
|
|
8422
8424
|
documentDetectionThresholdMet: detectionThresholdMet,
|
|
@@ -8624,19 +8626,9 @@ var IdCapture = function IdCapture(_a) {
|
|
|
8624
8626
|
prediction: prediction
|
|
8625
8627
|
}
|
|
8626
8628
|
});
|
|
8629
|
+
onPrediction === null || onPrediction === void 0 ? void 0 : onPrediction(prediction);
|
|
8627
8630
|
});
|
|
8628
|
-
}, [onPredictionMade]);
|
|
8629
|
-
React.useEffect(function () {
|
|
8630
|
-
onPrediction === null || onPrediction === void 0 ? void 0 : onPrediction({
|
|
8631
|
-
focusScore: state.focusScore,
|
|
8632
|
-
focusThresholdMet: state.focusThresholdMet,
|
|
8633
|
-
documentDetected: state.documentDetectionThresholdMet,
|
|
8634
|
-
documentType: state.documentType,
|
|
8635
|
-
documentScore: state.documentDetectionScore,
|
|
8636
|
-
mrzDetected: state.mrzDetectionThresholdMet,
|
|
8637
|
-
mrzScore: state.mrzDetectionScore
|
|
8638
|
-
});
|
|
8639
|
-
}, [onPrediction, state.bestPdf417, state.documentDetectionScore, state.documentDetectionThresholdMet, state.documentType, state.focusScore, state.focusThresholdMet, state.mrzDetectionScore, state.mrzDetectionThresholdMet]);
|
|
8631
|
+
}, [onPrediction, onPredictionMade]);
|
|
8640
8632
|
React.useEffect(function () {
|
|
8641
8633
|
(function () {
|
|
8642
8634
|
return tslib.__awaiter(void 0, void 0, void 0, function () {
|
|
@@ -9307,14 +9299,17 @@ var reducer$4 = function reducer(state, action) {
|
|
|
9307
9299
|
{
|
|
9308
9300
|
var prediction = action.payload.prediction;
|
|
9309
9301
|
var newState = tslib.__assign(tslib.__assign({}, state), {
|
|
9310
|
-
currentDocumentType: prediction.
|
|
9302
|
+
currentDocumentType: prediction.detectedDocumentType
|
|
9311
9303
|
});
|
|
9312
9304
|
if (newState.currentDocumentType === state.requestedDocumentType) {
|
|
9313
9305
|
newState.differentDocumentTypeDetections = 0;
|
|
9314
9306
|
}
|
|
9315
|
-
if (prediction.
|
|
9307
|
+
if (prediction.detectedDocumentType === 'PASSPORT' && state.requestedDocumentType !== 'PASSPORT') {
|
|
9316
9308
|
newState.requestedDocumentType = DocumentType.PASSPORT;
|
|
9317
9309
|
}
|
|
9310
|
+
if (state.requestedDocumentType === 'PASSPORT' && prediction.passportDetectionScore < 0.3) {
|
|
9311
|
+
newState.requestedDocumentType = DocumentType.ID_CARD_FRONT;
|
|
9312
|
+
}
|
|
9318
9313
|
return newState;
|
|
9319
9314
|
}
|
|
9320
9315
|
case 'barcodeScanned':
|
|
@@ -9478,9 +9473,6 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
9478
9473
|
releaseCameraAccess();
|
|
9479
9474
|
}
|
|
9480
9475
|
}, [releaseCameraAccess, submissionStatus]);
|
|
9481
|
-
if (submissionResponse) {
|
|
9482
|
-
return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement("h1", null, "Submission completed!"), /*#__PURE__*/React__default['default'].createElement("pre", null, JSON.stringify(submissionResponse, null, 2)));
|
|
9483
|
-
}
|
|
9484
9476
|
assets.idCardFrontPortraitGuidesImageUrl = assets.idCardFrontPortraitGuidesImageUrl || "".concat(DEFAULT_CDN_URL, "/Shieldout-IDCard-Front-SVG-Portrait-2.svg");
|
|
9485
9477
|
assets.idCardFrontLandscapeGuidesImageUrl = assets.idCardFrontLandscapeGuidesImageUrl || "".concat(DEFAULT_CDN_URL, "/Shieldout-IDCard-Front-SVG-Landscape-2.svg");
|
|
9486
9478
|
assets.idCardBackPortraitGuidesImageUrl = assets.idCardBackPortraitGuidesImageUrl || "".concat(DEFAULT_CDN_URL, "/Shieldout-IDCard-Back-SVG-Portrait-2.svg");
|
|
@@ -9491,6 +9483,48 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
9491
9483
|
verbiage.idCardFrontInstructionText = verbiage.idCardFrontInstructionText || t('Scan the front of ID');
|
|
9492
9484
|
verbiage.idCardBackInstructionText = verbiage.idCardBackInstructionText || t('Scan the back of ID');
|
|
9493
9485
|
verbiage.passportInstructionText = verbiage.passportInstructionText || t('Scan the ID page of passport');
|
|
9486
|
+
var idCardFrontAssets = React.useMemo(function () {
|
|
9487
|
+
return {
|
|
9488
|
+
portraitGuidesImageUrl: assets.idCardFrontPortraitGuidesImageUrl,
|
|
9489
|
+
landscapeGuidesImageUrl: assets.idCardFrontLandscapeGuidesImageUrl
|
|
9490
|
+
};
|
|
9491
|
+
}, [assets.idCardFrontLandscapeGuidesImageUrl, assets.idCardFrontPortraitGuidesImageUrl]);
|
|
9492
|
+
var idCardFrontVerbiage = React.useMemo(function () {
|
|
9493
|
+
return {
|
|
9494
|
+
instructionText: verbiage.idCardFrontInstructionText,
|
|
9495
|
+
capturingText: verbiage.capturingText,
|
|
9496
|
+
captureFailedText: verbiage.captureFailedText
|
|
9497
|
+
};
|
|
9498
|
+
}, [verbiage.captureFailedText, verbiage.capturingText, verbiage.idCardFrontInstructionText]);
|
|
9499
|
+
var idCardBackAssets = React.useMemo(function () {
|
|
9500
|
+
return {
|
|
9501
|
+
portraitGuidesImageUrl: assets.idCardBackPortraitGuidesImageUrl,
|
|
9502
|
+
landscapeGuidesImageUrl: assets.idCardBackLandscapeGuidesImageUrl
|
|
9503
|
+
};
|
|
9504
|
+
}, [assets.idCardBackLandscapeGuidesImageUrl, assets.idCardBackPortraitGuidesImageUrl]);
|
|
9505
|
+
var idCardBackVerbiage = React.useMemo(function () {
|
|
9506
|
+
return {
|
|
9507
|
+
instructionText: verbiage.idCardBackInstructionText,
|
|
9508
|
+
capturingText: verbiage.capturingText,
|
|
9509
|
+
captureFailedText: verbiage.captureFailedText
|
|
9510
|
+
};
|
|
9511
|
+
}, [verbiage.captureFailedText, verbiage.capturingText, verbiage.idCardBackInstructionText]);
|
|
9512
|
+
var passportAssets = React.useMemo(function () {
|
|
9513
|
+
return {
|
|
9514
|
+
portraitGuidesImageUrl: assets.passportPortraitGuidesImageUrl,
|
|
9515
|
+
landscapeGuidesImageUrl: assets.passportLandscapeGuidesImageUrl
|
|
9516
|
+
};
|
|
9517
|
+
}, [assets.passportLandscapeGuidesImageUrl, assets.passportPortraitGuidesImageUrl]);
|
|
9518
|
+
var passportVerbiage = React.useMemo(function () {
|
|
9519
|
+
return {
|
|
9520
|
+
instructionText: verbiage.passportInstructionText,
|
|
9521
|
+
capturingText: verbiage.capturingText,
|
|
9522
|
+
captureFailedText: verbiage.captureFailedText
|
|
9523
|
+
};
|
|
9524
|
+
}, [verbiage.captureFailedText, verbiage.capturingText, verbiage.passportInstructionText]);
|
|
9525
|
+
if (submissionResponse) {
|
|
9526
|
+
return /*#__PURE__*/React__default['default'].createElement(PageContainer, null, /*#__PURE__*/React__default['default'].createElement("h1", null, "Submission completed!"), /*#__PURE__*/React__default['default'].createElement("pre", null, JSON.stringify(submissionResponse, null, 2)));
|
|
9527
|
+
}
|
|
9494
9528
|
var flipIdPrompt = /*#__PURE__*/React__default['default'].createElement(FlipIdPrompt, {
|
|
9495
9529
|
instructionText: verbiage.flipIdInstructionText,
|
|
9496
9530
|
frontPortraitGuidesImage: assets.idCardFrontPortraitGuidesImageUrl,
|
|
@@ -9517,15 +9551,8 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
9517
9551
|
onCapture: onCapture,
|
|
9518
9552
|
processingScreen: flipIdPrompt,
|
|
9519
9553
|
processingDelay: 3500,
|
|
9520
|
-
assets:
|
|
9521
|
-
|
|
9522
|
-
landscapeGuidesImageUrl: assets.idCardFrontLandscapeGuidesImageUrl
|
|
9523
|
-
},
|
|
9524
|
-
verbiage: {
|
|
9525
|
-
instructionText: verbiage.idCardFrontInstructionText,
|
|
9526
|
-
capturingText: verbiage.capturingText,
|
|
9527
|
-
captureFailedText: verbiage.captureFailedText
|
|
9528
|
-
},
|
|
9554
|
+
assets: idCardFrontAssets,
|
|
9555
|
+
verbiage: idCardFrontVerbiage,
|
|
9529
9556
|
debugMode: debugMode
|
|
9530
9557
|
});
|
|
9531
9558
|
case DocumentType.ID_CARD_BACK:
|
|
@@ -9542,15 +9569,8 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
9542
9569
|
onPrediction: onPrediction,
|
|
9543
9570
|
onBarcodeScanned: onBarcodeScanned,
|
|
9544
9571
|
onCapture: onCapture,
|
|
9545
|
-
assets:
|
|
9546
|
-
|
|
9547
|
-
landscapeGuidesImageUrl: assets.idCardBackLandscapeGuidesImageUrl
|
|
9548
|
-
},
|
|
9549
|
-
verbiage: {
|
|
9550
|
-
instructionText: verbiage.idCardBackInstructionText,
|
|
9551
|
-
capturingText: verbiage.capturingText,
|
|
9552
|
-
captureFailedText: verbiage.captureFailedText
|
|
9553
|
-
},
|
|
9572
|
+
assets: idCardBackAssets,
|
|
9573
|
+
verbiage: idCardBackVerbiage,
|
|
9554
9574
|
debugMode: debugMode
|
|
9555
9575
|
});
|
|
9556
9576
|
case DocumentType.PASSPORT:
|
|
@@ -9567,15 +9587,8 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
9567
9587
|
onPrediction: onPrediction,
|
|
9568
9588
|
onBarcodeScanned: onBarcodeScanned,
|
|
9569
9589
|
onCapture: onCapture,
|
|
9570
|
-
assets:
|
|
9571
|
-
|
|
9572
|
-
landscapeGuidesImageUrl: assets.passportLandscapeGuidesImageUrl
|
|
9573
|
-
},
|
|
9574
|
-
verbiage: {
|
|
9575
|
-
instructionText: verbiage.passportInstructionText,
|
|
9576
|
-
capturingText: verbiage.capturingText,
|
|
9577
|
-
captureFailedText: verbiage.captureFailedText
|
|
9578
|
-
},
|
|
9590
|
+
assets: passportAssets,
|
|
9591
|
+
verbiage: passportVerbiage,
|
|
9579
9592
|
debugMode: debugMode
|
|
9580
9593
|
});
|
|
9581
9594
|
default:
|
|
@@ -10796,11 +10809,10 @@ var useHighestResCaptureDevice = function useHighestResCaptureDevice(_a) {
|
|
|
10796
10809
|
if (!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) return cleanup;
|
|
10797
10810
|
(function () {
|
|
10798
10811
|
return tslib.__awaiter(void 0, void 0, void 0, function () {
|
|
10799
|
-
var
|
|
10812
|
+
var stream, e_1;
|
|
10800
10813
|
return tslib.__generator(this, function (_a) {
|
|
10801
10814
|
switch (_a.label) {
|
|
10802
10815
|
case 0:
|
|
10803
|
-
isPortrait = window.innerWidth < window.innerHeight;
|
|
10804
10816
|
stream = null;
|
|
10805
10817
|
_a.label = 1;
|
|
10806
10818
|
case 1:
|
|
@@ -10812,8 +10824,9 @@ var useHighestResCaptureDevice = function useHighestResCaptureDevice(_a) {
|
|
|
10812
10824
|
exact: videoDevice.deviceId
|
|
10813
10825
|
},
|
|
10814
10826
|
width: {
|
|
10815
|
-
ideal:
|
|
10816
|
-
}
|
|
10827
|
+
ideal: 1920
|
|
10828
|
+
},
|
|
10829
|
+
aspectRatio: 1.777777778
|
|
10817
10830
|
}
|
|
10818
10831
|
})];
|
|
10819
10832
|
case 2:
|