idmission-web-sdk 1.0.171 → 1.0.173
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 +1 -0
- package/dist/components/id_capture/IdCaptureModelsProvider.d.ts +1 -0
- package/dist/components/id_capture/IdCaptureStateProvider.d.ts +1 -0
- package/dist/lib/locales/es/translation.d.ts +1 -0
- package/dist/lib/locales/index.d.ts +1 -0
- package/dist/sdk2.cjs.development.js +50 -23
- 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 +50 -23
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +50 -23
- 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/dist/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -34,6 +34,7 @@ export type IdCaptureVerbiage = {
|
|
|
34
34
|
guidanceSatisfiedText?: CustomerSuppliedVerbiage;
|
|
35
35
|
guidanceTooBlurryText?: CustomerSuppliedVerbiage;
|
|
36
36
|
guidanceNotCenteredText?: CustomerSuppliedVerbiage;
|
|
37
|
+
guidanceTooCloseText?: CustomerSuppliedVerbiage;
|
|
37
38
|
guidanceNotDetectedText?: CustomerSuppliedVerbiage;
|
|
38
39
|
};
|
|
39
40
|
export type IdCaptureProps = {
|
|
@@ -17,6 +17,7 @@ export type IdCapturePrediction = {
|
|
|
17
17
|
bestMrz: DetectedObject | undefined;
|
|
18
18
|
bestPdf417: DetectedObject | undefined;
|
|
19
19
|
documentInBounds: boolean;
|
|
20
|
+
documentTooClose: boolean;
|
|
20
21
|
focusScore: number;
|
|
21
22
|
focusThresholdMet: boolean;
|
|
22
23
|
focusPredictionTime: number;
|
|
@@ -24,6 +24,7 @@ export type IdCaptureState = {
|
|
|
24
24
|
documentType: DocumentType;
|
|
25
25
|
requiredDocumentType?: CapturedDocumentType;
|
|
26
26
|
documentInBounds: boolean;
|
|
27
|
+
documentTooClose: boolean;
|
|
27
28
|
documentDetectionScore: number;
|
|
28
29
|
documentDetectionThresholdMet: boolean;
|
|
29
30
|
mrzDetectionScore: number;
|
|
@@ -20,6 +20,7 @@ declare const _default: {
|
|
|
20
20
|
Passport: string;
|
|
21
21
|
'Document not detected': string;
|
|
22
22
|
'Document is not centered': string;
|
|
23
|
+
'Document too close, please back up': string;
|
|
23
24
|
'Document out of focus \u2013 try improving the lighting': string;
|
|
24
25
|
'Document detected, hold still...': string;
|
|
25
26
|
'Capturing...': string;
|
|
@@ -28,6 +28,7 @@ export declare const resources: {
|
|
|
28
28
|
Passport: string;
|
|
29
29
|
'Document not detected': string;
|
|
30
30
|
'Document is not centered': string;
|
|
31
|
+
'Document too close, please back up': string;
|
|
31
32
|
'Document out of focus \u2013 try improving the lighting': string;
|
|
32
33
|
'Document detected, hold still...': string;
|
|
33
34
|
'Capturing...': string;
|
|
@@ -48,7 +48,7 @@ var LanguageDetector__default = /*#__PURE__*/_interopDefaultLegacy(LanguageDetec
|
|
|
48
48
|
var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
|
|
49
49
|
var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
|
|
50
50
|
|
|
51
|
-
var webSdkVersion = '1.0.
|
|
51
|
+
var webSdkVersion = '1.0.173';
|
|
52
52
|
|
|
53
53
|
function getPlatform() {
|
|
54
54
|
if (typeof window === 'undefined') return;
|
|
@@ -8873,16 +8873,16 @@ function makePredictions(frame, lastPredictionCanvas, thresholds, logPredictions
|
|
|
8873
8873
|
logPredictions = false;
|
|
8874
8874
|
}
|
|
8875
8875
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
8876
|
-
var _o, frameWidth, frameHeight, _q, boxes, scores, labels, time, allZero, detectedObjects, bestDocument, bestPassportPage, bestDocumentScore, passportDetectionScore, passportDetectionThresholdMet, bestDocumentOrPassport, detectionScore, detectionThresholdMet, detectedDocumentType, bestMrz, mrzDetectionScore, mrzDetectionThresholdMet, bestPdf417, pdf417DetectionScore, pdf417DetectionThresholdMet, documentInBounds, boundaryPx, _r, boundaryX, boundaryY, boundaryWidth, boundaryHeight, focusPrediction, focusPredictionTime, focusScore, focusThresholdMet, focusThreshold;
|
|
8877
|
-
var
|
|
8878
|
-
return tslib.__generator(this, function (
|
|
8879
|
-
switch (
|
|
8876
|
+
var _o, frameWidth, frameHeight, _q, boxes, scores, labels, time, allZero, detectedObjects, bestDocument, bestPassportPage, bestDocumentScore, passportDetectionScore, passportDetectionThresholdMet, bestDocumentOrPassport, detectionScore, detectionThresholdMet, detectedDocumentType, bestMrz, mrzDetectionScore, mrzDetectionThresholdMet, bestPdf417, pdf417DetectionScore, pdf417DetectionThresholdMet, documentInBounds, boundaryPx, _r, boundaryX, boundaryY, boundaryWidth, boundaryHeight, documentTooClose, _s, docWidth, docHeight, focusPrediction, focusPredictionTime, focusScore, focusThresholdMet, focusThreshold;
|
|
8877
|
+
var _t;
|
|
8878
|
+
return tslib.__generator(this, function (_u) {
|
|
8879
|
+
switch (_u.label) {
|
|
8880
8880
|
case 0:
|
|
8881
8881
|
_o = getFrameDimensions(frame), frameWidth = _o[0], frameHeight = _o[1];
|
|
8882
8882
|
drawToCanvas(lastPredictionCanvas, frame);
|
|
8883
8883
|
return [4 /*yield*/, makeDocumentDetectionPredictions(frame, logPredictions)];
|
|
8884
8884
|
case 1:
|
|
8885
|
-
_q =
|
|
8885
|
+
_q = _u.sent(), boxes = _q.boxes, scores = _q.scores, labels = _q.labels, time = _q.time;
|
|
8886
8886
|
allZero = boxes.length > 0 && !boxes.some(function (box) {
|
|
8887
8887
|
return box.some(function (n) {
|
|
8888
8888
|
return n > 0;
|
|
@@ -8935,15 +8935,20 @@ function makePredictions(frame, lastPredictionCanvas, thresholds, logPredictions
|
|
|
8935
8935
|
// If either the left side visible or if not, right edge of ID should be more than 80% of width.
|
|
8936
8936
|
boundaryX + boundaryWidth + boundaryPx < frameWidth; // Valid right edge if it's less than video width.
|
|
8937
8937
|
}
|
|
8938
|
+
documentTooClose = false;
|
|
8939
|
+
if (bestDocumentOrPassport) {
|
|
8940
|
+
_s = [bestDocumentOrPassport.bbox[2], bestDocumentOrPassport.bbox[3]], docWidth = _s[0], docHeight = _s[1];
|
|
8941
|
+
documentTooClose = docWidth > 0.8 || docHeight > 0.8;
|
|
8942
|
+
}
|
|
8938
8943
|
focusPrediction = null, focusPredictionTime = 0, focusScore = 0, focusThresholdMet = false;
|
|
8939
|
-
if (!(detectionThresholdMet && documentInBounds)) return [3 /*break*/, 3];
|
|
8944
|
+
if (!(detectionThresholdMet && documentInBounds && !documentTooClose)) return [3 /*break*/, 3];
|
|
8940
8945
|
return [4 /*yield*/, makeFocusPrediction(frame, bestDocumentOrPassport === null || bestDocumentOrPassport === void 0 ? void 0 : bestDocumentOrPassport.bbox, logPredictions)];
|
|
8941
8946
|
case 2:
|
|
8942
|
-
|
|
8947
|
+
_t = _u.sent(), focusPrediction = _t[0], focusPredictionTime = _t[1];
|
|
8943
8948
|
focusScore = (_j = focusPrediction === null || focusPrediction === void 0 ? void 0 : focusPrediction[1]) !== null && _j !== void 0 ? _j : 0;
|
|
8944
8949
|
focusThreshold = (_m = onMobile ? (_k = thresholds.focus) === null || _k === void 0 ? void 0 : _k.mobile : (_l = thresholds.focus) === null || _l === void 0 ? void 0 : _l.desktop) !== null && _m !== void 0 ? _m : 0;
|
|
8945
8950
|
focusThresholdMet = focusScore >= focusThreshold;
|
|
8946
|
-
|
|
8951
|
+
_u.label = 3;
|
|
8947
8952
|
case 3:
|
|
8948
8953
|
return [2 /*return*/, {
|
|
8949
8954
|
detectedObjects: detectedObjects,
|
|
@@ -8961,6 +8966,7 @@ function makePredictions(frame, lastPredictionCanvas, thresholds, logPredictions
|
|
|
8961
8966
|
bestMrz: bestMrz,
|
|
8962
8967
|
bestPdf417: bestPdf417,
|
|
8963
8968
|
documentInBounds: documentInBounds,
|
|
8969
|
+
documentTooClose: documentTooClose,
|
|
8964
8970
|
focusScore: focusScore,
|
|
8965
8971
|
focusThresholdMet: focusThresholdMet,
|
|
8966
8972
|
focusPredictionTime: focusPredictionTime,
|
|
@@ -9057,20 +9063,36 @@ function makeFocusPrediction(imageData, bbox, logPredictions) {
|
|
|
9057
9063
|
logPredictions = false;
|
|
9058
9064
|
}
|
|
9059
9065
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
9060
|
-
var startedAt, tfImg,
|
|
9061
|
-
return tslib.__generator(this, function (
|
|
9062
|
-
switch (
|
|
9066
|
+
var startedAt, tfImg, cropped, _a, fw, fh, _b, bw, bh, rotated, ctx, tfResize, tfInt32, tf4d_, _c, _d, _e, _f, tf4d, predictions, focusPrediction, predictionTime;
|
|
9067
|
+
return tslib.__generator(this, function (_g) {
|
|
9068
|
+
switch (_g.label) {
|
|
9063
9069
|
case 0:
|
|
9064
9070
|
if (!focusModel) {
|
|
9065
9071
|
throw new Error('focus model is not loaded');
|
|
9066
9072
|
}
|
|
9067
9073
|
startedAt = new Date();
|
|
9068
|
-
|
|
9074
|
+
_g.label = 1;
|
|
9069
9075
|
case 1:
|
|
9070
|
-
|
|
9076
|
+
_g.trys.push([1, 5,, 6]);
|
|
9071
9077
|
tfImg = void 0;
|
|
9072
9078
|
if (bbox) {
|
|
9073
|
-
|
|
9079
|
+
cropped = cropToBoundingBox(imageData, bbox);
|
|
9080
|
+
_a = getFrameDimensions(imageData), fw = _a[0], fh = _a[1];
|
|
9081
|
+
_b = [bbox[2] * fw, bbox[3] * fh], bw = _b[0], bh = _b[1];
|
|
9082
|
+
if (bh > bw) {
|
|
9083
|
+
rotated = document.createElement('canvas');
|
|
9084
|
+
ctx = rotated.getContext('2d');
|
|
9085
|
+
if (ctx) {
|
|
9086
|
+
rotated.width = bh;
|
|
9087
|
+
rotated.height = bw;
|
|
9088
|
+
ctx.clearRect(0, 0, rotated.width, rotated.height);
|
|
9089
|
+
ctx.translate(rotated.height / 2, rotated.width / 2);
|
|
9090
|
+
ctx.rotate(1.5708); // 90 deg in radians
|
|
9091
|
+
ctx.drawImage(cropped, -rotated.width / 2, -rotated.height / 2);
|
|
9092
|
+
cropped = rotated;
|
|
9093
|
+
}
|
|
9094
|
+
}
|
|
9095
|
+
tfImg = tf__namespace.browser.fromPixels(cropped);
|
|
9074
9096
|
} else {
|
|
9075
9097
|
tfImg = tf__namespace.browser.fromPixels(imageData);
|
|
9076
9098
|
}
|
|
@@ -9078,28 +9100,28 @@ function makeFocusPrediction(imageData, bbox, logPredictions) {
|
|
|
9078
9100
|
tfImg.dispose();
|
|
9079
9101
|
tfInt32 = tf__namespace.cast(tfResize, 'float32');
|
|
9080
9102
|
tfResize.dispose();
|
|
9081
|
-
|
|
9082
|
-
|
|
9103
|
+
_d = (_c = tf__namespace).tensor4d;
|
|
9104
|
+
_f = (_e = Array).from;
|
|
9083
9105
|
return [4 /*yield*/, tfInt32.data()];
|
|
9084
9106
|
case 2:
|
|
9085
|
-
tf4d_ =
|
|
9107
|
+
tf4d_ = _d.apply(_c, [_f.apply(_e, [_g.sent()]), [1, 448, 448, 3]]);
|
|
9086
9108
|
tfInt32.dispose();
|
|
9087
9109
|
tf4d = tf__namespace.cast(tf4d_, 'float32');
|
|
9088
9110
|
tf4d_.dispose();
|
|
9089
9111
|
if (logPredictions) console.time('focus prediction');
|
|
9090
9112
|
return [4 /*yield*/, focusModel.predict(tf4d)];
|
|
9091
9113
|
case 3:
|
|
9092
|
-
predictions =
|
|
9114
|
+
predictions = _g.sent();
|
|
9093
9115
|
tf4d.dispose();
|
|
9094
9116
|
return [4 /*yield*/, predictions.array()];
|
|
9095
9117
|
case 4:
|
|
9096
|
-
focusPrediction =
|
|
9118
|
+
focusPrediction = _g.sent()[0];
|
|
9097
9119
|
if (logPredictions) console.timeEnd('focus prediction');
|
|
9098
9120
|
tf__namespace.dispose(predictions);
|
|
9099
9121
|
predictionTime = new Date().getTime() - startedAt.getTime();
|
|
9100
9122
|
return [2 /*return*/, [focusPrediction, predictionTime]];
|
|
9101
9123
|
case 5:
|
|
9102
|
-
|
|
9124
|
+
_g.sent();
|
|
9103
9125
|
return [2 /*return*/, [[0, 0], 0]];
|
|
9104
9126
|
case 6:
|
|
9105
9127
|
return [2 /*return*/];
|
|
@@ -9149,6 +9171,7 @@ var initialState$5 = {
|
|
|
9149
9171
|
bestPdf417: undefined,
|
|
9150
9172
|
documentType: 'none',
|
|
9151
9173
|
documentInBounds: false,
|
|
9174
|
+
documentTooClose: false,
|
|
9152
9175
|
documentDetectionScore: 0,
|
|
9153
9176
|
documentDetectionThresholdMet: false,
|
|
9154
9177
|
passportPageDetectionScore: 0,
|
|
@@ -9233,6 +9256,7 @@ var reducer$5 = function reducer(state, action) {
|
|
|
9233
9256
|
bestMrz = _a.bestMrz,
|
|
9234
9257
|
bestPdf417 = _a.bestPdf417,
|
|
9235
9258
|
documentInBounds = _a.documentInBounds,
|
|
9259
|
+
documentTooClose = _a.documentTooClose,
|
|
9236
9260
|
focusScore = _a.focusScore,
|
|
9237
9261
|
focusThresholdMet = _a.focusThresholdMet,
|
|
9238
9262
|
frameWidth = _a.frameWidth,
|
|
@@ -9249,7 +9273,7 @@ var reducer$5 = function reducer(state, action) {
|
|
|
9249
9273
|
var barcodeScanRequired = state.autoCaptureBarcodeRequired === true || state.autoCaptureBarcodeRequired === 'mobile' && isMobile();
|
|
9250
9274
|
var shouldScanBarcode = state.barcodeScanningEnabled && pdf417DetectionThresholdMet && barcodeScanRequired;
|
|
9251
9275
|
var waitingForBarcodeScan = shouldScanBarcode && !state.barcodeResult;
|
|
9252
|
-
var isGoodFrame = detectionThresholdMet && documentInBounds && focusThresholdMet;
|
|
9276
|
+
var isGoodFrame = detectionThresholdMet && documentInBounds && !documentTooClose && focusThresholdMet;
|
|
9253
9277
|
var goodFramesCount = state.goodFramesCount;
|
|
9254
9278
|
if (isGoodFrame) {
|
|
9255
9279
|
goodFramesCount += 1;
|
|
@@ -9263,6 +9287,7 @@ var reducer$5 = function reducer(state, action) {
|
|
|
9263
9287
|
bestPdf417: bestPdf417,
|
|
9264
9288
|
documentType: detectedDocumentType,
|
|
9265
9289
|
documentInBounds: documentInBounds,
|
|
9290
|
+
documentTooClose: documentTooClose,
|
|
9266
9291
|
documentDetectionScore: detectionScore,
|
|
9267
9292
|
documentDetectionThresholdMet: detectionThresholdMet,
|
|
9268
9293
|
mrzDetectionScore: mrzDetectionScore,
|
|
@@ -9576,6 +9601,7 @@ var esTranslation = {
|
|
|
9576
9601
|
Passport: 'Pasaporte',
|
|
9577
9602
|
'Document not detected': 'No se ha detectado el documento',
|
|
9578
9603
|
'Document is not centered': 'Documento no centrado',
|
|
9604
|
+
'Document too close, please back up': 'Documento muy cerca, favor de alejarse',
|
|
9579
9605
|
'Document out of focus – try improving the lighting': 'Documento no enfocado - hay que tratar de mejorar la iluminación',
|
|
9580
9606
|
'Document detected, hold still...': 'Se ha detectado el documento, no moverse por favor...',
|
|
9581
9607
|
'Capturing...': 'Capturando...',
|
|
@@ -9977,6 +10003,7 @@ var IdCapture = function IdCapture(_a) {
|
|
|
9977
10003
|
guidanceSatisfiedText: 'Document detected, hold still...',
|
|
9978
10004
|
guidanceTooBlurryText: 'Document out of focus – try improving the lighting',
|
|
9979
10005
|
guidanceNotCenteredText: 'Document is not centered',
|
|
10006
|
+
guidanceTooCloseText: 'Document too close, please back up',
|
|
9980
10007
|
guidanceNotDetectedText: 'Document not detected'
|
|
9981
10008
|
});
|
|
9982
10009
|
var debugScalingDetails = useDebugScalingDetails({
|
|
@@ -9988,7 +10015,7 @@ var IdCapture = function IdCapture(_a) {
|
|
|
9988
10015
|
});
|
|
9989
10016
|
var satisfied = state.isGoodFrame;
|
|
9990
10017
|
if (typeof guidanceSatisfied === 'boolean') satisfied = guidanceSatisfied;
|
|
9991
|
-
guidanceMessage || (guidanceMessage = satisfied ? verbiage.guidanceSatisfiedText : !state.documentDetectionThresholdMet ? verbiage.guidanceNotDetectedText : !state.documentInBounds ? verbiage.guidanceNotCenteredText : !state.focusThresholdMet ? verbiage.guidanceTooBlurryText : '');
|
|
10018
|
+
guidanceMessage || (guidanceMessage = satisfied ? verbiage.guidanceSatisfiedText : !state.documentDetectionThresholdMet ? verbiage.guidanceNotDetectedText : !state.documentInBounds ? verbiage.guidanceNotCenteredText : state.documentTooClose ? verbiage.guidanceTooCloseText : !state.focusThresholdMet ? verbiage.guidanceTooBlurryText : '');
|
|
9992
10019
|
return /*#__PURE__*/React__default['default'].createElement(PageContainer, {
|
|
9993
10020
|
ref: ref,
|
|
9994
10021
|
className: "flex ".concat((_j = classNames.container) !== null && _j !== void 0 ? _j : '')
|