idmission-web-sdk 0.0.26 → 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 +16 -24
- 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 +16 -24
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +16 -24
- 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,15 +9299,15 @@ 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
|
}
|
|
9318
|
-
if (
|
|
9310
|
+
if (state.requestedDocumentType === 'PASSPORT' && prediction.passportDetectionScore < 0.3) {
|
|
9319
9311
|
newState.requestedDocumentType = DocumentType.ID_CARD_FRONT;
|
|
9320
9312
|
}
|
|
9321
9313
|
return newState;
|