idmission-web-sdk 2.2.57 → 2.2.59
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.map +1 -1
- package/dist/components/id_capture/IdCaptureModelsProvider.d.ts.map +1 -1
- package/dist/components/id_capture/IdCaptureStateProvider.d.ts +2 -0
- package/dist/components/id_capture/IdCaptureStateProvider.d.ts.map +1 -1
- package/dist/lib/models/DocumentDetection.d.ts +4 -2
- package/dist/lib/models/DocumentDetection.d.ts.map +1 -1
- package/dist/lib/models/Focus.d.ts +4 -0
- package/dist/lib/models/Focus.d.ts.map +1 -1
- package/dist/lib/models/defaults/DocumentDetector.d.ts +1 -1
- package/dist/sdk2.cjs.development.js +49 -18
- 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 +49 -18
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +49 -18
- 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
|
@@ -211,7 +211,7 @@
|
|
|
211
211
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
212
212
|
};
|
|
213
213
|
|
|
214
|
-
var webSdkVersion = '2.2.
|
|
214
|
+
var webSdkVersion = '2.2.59';
|
|
215
215
|
|
|
216
216
|
function getPlatform() {
|
|
217
217
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -2330,7 +2330,7 @@
|
|
|
2330
2330
|
}
|
|
2331
2331
|
}, _d.onSuccess = function () {
|
|
2332
2332
|
var _a, _b;
|
|
2333
|
-
documentId || (documentId = "urn:documentsv1:".concat((_a = upload.url.split('/files/').pop()) === null || _a === void 0 ? void 0 : _a.split('+').shift()));
|
|
2333
|
+
documentId || (documentId = "urn:documentsv1:".concat(getEnvFromUrl(upload.url), ":").concat((_a = upload.url.split('/files/').pop()) === null || _a === void 0 ? void 0 : _a.split('+').shift()));
|
|
2334
2334
|
(_b = onDocumentUploaded.current) === null || _b === void 0 ? void 0 : _b.call(onDocumentUploaded, documentId, metadata);
|
|
2335
2335
|
resolve(documentId);
|
|
2336
2336
|
}, _d.onError = function (error) {
|
|
@@ -2885,6 +2885,20 @@
|
|
|
2885
2885
|
};
|
|
2886
2886
|
});
|
|
2887
2887
|
}
|
|
2888
|
+
function getEnvFromUrl(url) {
|
|
2889
|
+
if (url.startsWith('https://portal-api.idmission.com')) {
|
|
2890
|
+
return 'prod';
|
|
2891
|
+
} else if (url.startsWith('https://portal-api-uat.idmission.com')) {
|
|
2892
|
+
return 'uat';
|
|
2893
|
+
} else if (url.startsWith('https://portal-api-demo.idmission.com')) {
|
|
2894
|
+
return 'demo';
|
|
2895
|
+
} else if (url.startsWith('https://portal-api-dev.idmission.com')) {
|
|
2896
|
+
return 'dev';
|
|
2897
|
+
} else if (url.startsWith('http://localhost:10000')) {
|
|
2898
|
+
return 'local';
|
|
2899
|
+
}
|
|
2900
|
+
return 'unknown';
|
|
2901
|
+
}
|
|
2888
2902
|
|
|
2889
2903
|
// This could've been more streamlined with internal state instead of abusing
|
|
2890
2904
|
// refs to such extent, but then composing hooks and components could not opt out of unnecessary renders.
|
|
@@ -8297,7 +8311,7 @@
|
|
|
8297
8311
|
|
|
8298
8312
|
var DEFAULT_CDN_URL = 'https://websdk-cdn-dev.idmission.com/assets';
|
|
8299
8313
|
|
|
8300
|
-
var defaultDocumentDetectorModelPath = "".concat(DEFAULT_CDN_URL, "/models/DocumentDetector/DocumentDetector-
|
|
8314
|
+
var defaultDocumentDetectorModelPath = "".concat(DEFAULT_CDN_URL, "/models/DocumentDetector/DocumentDetector-20241212_131026.tflite");
|
|
8301
8315
|
|
|
8302
8316
|
var defaultFocusModelPath = "".concat(DEFAULT_CDN_URL, "/models/Focus/Focus-20241008_102708.tflite");
|
|
8303
8317
|
|
|
@@ -8316,6 +8330,10 @@
|
|
|
8316
8330
|
passport: {
|
|
8317
8331
|
desktop: 0,
|
|
8318
8332
|
mobile: 0.3
|
|
8333
|
+
},
|
|
8334
|
+
singlePage: {
|
|
8335
|
+
desktop: 0,
|
|
8336
|
+
mobile: 0.3
|
|
8319
8337
|
}
|
|
8320
8338
|
};
|
|
8321
8339
|
var classifier = null;
|
|
@@ -8941,16 +8959,19 @@
|
|
|
8941
8959
|
idCardFront: 0.6,
|
|
8942
8960
|
idCardBack: 0.6,
|
|
8943
8961
|
passport: 0.4,
|
|
8962
|
+
singlePage: 0.4,
|
|
8944
8963
|
stability: {
|
|
8945
8964
|
idCardFront: 0.85,
|
|
8946
8965
|
idCardBack: 0.85,
|
|
8947
|
-
passport: 0.5
|
|
8966
|
+
passport: 0.5,
|
|
8967
|
+
singlePage: 0.5
|
|
8948
8968
|
}
|
|
8949
8969
|
};
|
|
8950
8970
|
var documentTypeDisplayNames = {
|
|
8951
8971
|
idCardFront: 'ID card front',
|
|
8952
8972
|
idCardBack: 'ID card back',
|
|
8953
8973
|
passport: 'Passport',
|
|
8974
|
+
singlePage: 'Single page',
|
|
8954
8975
|
none: 'None'
|
|
8955
8976
|
};
|
|
8956
8977
|
var detector = null;
|
|
@@ -9139,7 +9160,7 @@
|
|
|
9139
9160
|
right: 20
|
|
9140
9161
|
};
|
|
9141
9162
|
function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
|
|
9142
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
9163
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
9143
9164
|
if (boundaries === void 0) {
|
|
9144
9165
|
boundaries = defaultDocumentDetectionBoundaries;
|
|
9145
9166
|
}
|
|
@@ -9190,18 +9211,25 @@
|
|
|
9190
9211
|
var bestPassportPage = detectedObjects.find(function (obj) {
|
|
9191
9212
|
return obj.label === 'Passport page';
|
|
9192
9213
|
});
|
|
9214
|
+
var bestSinglePage = detectedObjects.find(function (obj) {
|
|
9215
|
+
return obj.label === 'Single page';
|
|
9216
|
+
});
|
|
9193
9217
|
var idCardFrontDetectionScore = (_e = bestIdCardFront === null || bestIdCardFront === void 0 ? void 0 : bestIdCardFront.score) !== null && _e !== void 0 ? _e : 0;
|
|
9194
9218
|
var idCardBackDetectionScore = (_f = bestIdCardBack === null || bestIdCardBack === void 0 ? void 0 : bestIdCardBack.score) !== null && _f !== void 0 ? _f : 0;
|
|
9195
9219
|
var passportDetectionScore = (_g = bestPassportPage === null || bestPassportPage === void 0 ? void 0 : bestPassportPage.score) !== null && _g !== void 0 ? _g : 0;
|
|
9196
|
-
var
|
|
9197
|
-
var
|
|
9198
|
-
var
|
|
9199
|
-
var
|
|
9200
|
-
var
|
|
9201
|
-
var
|
|
9220
|
+
var singlePageDetectionScore = (_h = bestSinglePage === null || bestSinglePage === void 0 ? void 0 : bestSinglePage.score) !== null && _h !== void 0 ? _h : 0;
|
|
9221
|
+
var idCardFrontDetectionThresholdMet = idCardFrontDetectionScore >= ((_j = thresholds.idCardFront) !== null && _j !== void 0 ? _j : 0);
|
|
9222
|
+
var idCardBackDetectionThresholdMet = idCardBackDetectionScore >= ((_k = thresholds.idCardBack) !== null && _k !== void 0 ? _k : 0);
|
|
9223
|
+
var passportDetectionThresholdMet = passportDetectionScore >= ((_l = thresholds.passport) !== null && _l !== void 0 ? _l : 0);
|
|
9224
|
+
var singlePageDetectionThresholdMet = singlePageDetectionScore >= ((_m = thresholds.singlePage) !== null && _m !== void 0 ? _m : 0);
|
|
9225
|
+
var bestDocument = singlePageDetectionThresholdMet ? bestSinglePage : passportDetectionThresholdMet ? bestPassportPage : idCardBackDetectionThresholdMet ? bestIdCardBack : bestIdCardFront;
|
|
9226
|
+
var detectionThreshold = singlePageDetectionThresholdMet ? thresholds.singlePage : passportDetectionThresholdMet ? thresholds.passport : idCardBackDetectionThresholdMet ? thresholds.idCardBack : thresholds.idCardFront;
|
|
9227
|
+
var detectionScore = (_o = bestDocument === null || bestDocument === void 0 ? void 0 : bestDocument.score) !== null && _o !== void 0 ? _o : 0;
|
|
9202
9228
|
var detectionThresholdMet = detectionScore >= (detectionThreshold !== null && detectionThreshold !== void 0 ? detectionThreshold : 0);
|
|
9203
9229
|
var detectedDocumentType = 'none';
|
|
9204
|
-
if (
|
|
9230
|
+
if (singlePageDetectionThresholdMet) {
|
|
9231
|
+
detectedDocumentType = 'singlePage';
|
|
9232
|
+
} else if (passportDetectionThresholdMet) {
|
|
9205
9233
|
detectedDocumentType = 'passport';
|
|
9206
9234
|
} else if (idCardBackDetectionThresholdMet) {
|
|
9207
9235
|
detectedDocumentType = 'idCardBack';
|
|
@@ -9215,12 +9243,12 @@
|
|
|
9215
9243
|
var documentIsStable = false;
|
|
9216
9244
|
var documentTooClose = false;
|
|
9217
9245
|
if (bestDocument) {
|
|
9218
|
-
var
|
|
9219
|
-
docWidth =
|
|
9220
|
-
docHeight =
|
|
9246
|
+
var _q = [bestDocument.box.width / frameWidth, bestDocument.box.height / frameHeight],
|
|
9247
|
+
docWidth = _q[0],
|
|
9248
|
+
docHeight = _q[1];
|
|
9221
9249
|
documentTooClose = docWidth > 0.85 || docHeight > 0.85;
|
|
9222
9250
|
if (detectionThresholdMet && documentInBounds && !documentTooClose) {
|
|
9223
|
-
var thresholdSet = (
|
|
9251
|
+
var thresholdSet = (_p = thresholds.stability) !== null && _p !== void 0 ? _p : defaultDocumentDetectionThresholds.stability;
|
|
9224
9252
|
var threshold_1 = thresholdSet[detectedDocumentType];
|
|
9225
9253
|
var framesNeeded = Math.ceil(average(framesNeededSamples));
|
|
9226
9254
|
trackBox(bestDocument.box, framesNeeded);
|
|
@@ -10243,7 +10271,8 @@
|
|
|
10243
10271
|
if (!lastPredictionCanvas.current) return [2 /*return*/];
|
|
10244
10272
|
stopDetectionAtStart = stopDetection.current;
|
|
10245
10273
|
focusPredictionTime = 0, focusScore = 0, focusThresholdMet = false;
|
|
10246
|
-
isRequiredDocumentType = requiredDocumentType === 'none' || prediction.detectedDocumentType === requiredDocumentType || ((_a = requiredDocumentType.includes) === null || _a === void 0 ? void 0 : _a.call(requiredDocumentType, prediction.detectedDocumentType))
|
|
10274
|
+
isRequiredDocumentType = requiredDocumentType === 'none' || prediction.detectedDocumentType === requiredDocumentType || ((_a = requiredDocumentType.includes) === null || _a === void 0 ? void 0 : _a.call(requiredDocumentType, prediction.detectedDocumentType)) || prediction.detectedDocumentType === 'singlePage' // TODO: remove this later
|
|
10275
|
+
;
|
|
10247
10276
|
if (isRequiredDocumentType && prediction.detectedDocumentType !== 'none' && prediction.detectionThresholdMet && prediction.documentInBounds && !prediction.documentTooClose && prediction.documentIsStable) {
|
|
10248
10277
|
focusPrediction = makeFocusPrediction(lastPredictionCanvas.current, (_b = prediction.bestDocument) === null || _b === void 0 ? void 0 : _b.box);
|
|
10249
10278
|
if (focusPrediction) {
|
|
@@ -10474,6 +10503,8 @@
|
|
|
10474
10503
|
idCardBackDetectionThresholdMet: false,
|
|
10475
10504
|
passportDetectionScore: 0,
|
|
10476
10505
|
passportDetectionThresholdMet: false,
|
|
10506
|
+
singlePageDetectionScore: 0,
|
|
10507
|
+
singlePageDetectionThresholdMet: false,
|
|
10477
10508
|
focusScore: 0,
|
|
10478
10509
|
focusThresholdMet: false,
|
|
10479
10510
|
isGoodFrame: false,
|
|
@@ -14216,7 +14247,7 @@
|
|
|
14216
14247
|
scaling: debugScalingDetails,
|
|
14217
14248
|
flipX: !isRearFacing
|
|
14218
14249
|
});
|
|
14219
|
-
}))), debugMode && ( /*#__PURE__*/React.createElement(DebugStatsPane, null, camera ? ( /*#__PURE__*/React.createElement(React.Fragment, null, "\u2705 Camera: ", camera.label, " (", camera.width, "x", camera.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React.createElement("br", null), state.frameCaptureRate > 0.75 ? '✅' : '👎', " Frame Rate:", ' ', Math.round((state.frameCaptureRate + Number.EPSILON) * 1000) / 1000, ' ', "fps (", detectionTime, "ms doc detect, ", focusPredictionTime, "ms focus)", /*#__PURE__*/React.createElement("br", null), modelsReady ? ( /*#__PURE__*/React.createElement(React.Fragment, null, state.detectionThresholdMet ? '✅' : '❌', " Detected Document Type: ", state.detectedDocumentType, /*#__PURE__*/React.createElement("br", null), state.idCardFrontDetectionThresholdMet ? '✅' : '❌', " ID Card Front Score: ", state.idCardFrontDetectionScore.toFixed(3), /*#__PURE__*/React.createElement("br", null), state.idCardBackDetectionThresholdMet ? '✅' : '❌', " ID Card Back Score: ", state.idCardBackDetectionScore.toFixed(3), /*#__PURE__*/React.createElement("br", null), state.passportDetectionThresholdMet ? '✅' : '❌', " Passport Score: ", state.passportDetectionScore.toFixed(3), /*#__PURE__*/React.createElement("br", null), state.focusThresholdMet ? '✅' : '❌', " Focus Score:", ' ', state.focusScore.toFixed(3), /*#__PURE__*/React.createElement("br", null), state.documentInBounds ? '✅' : '❌', " Document In Bounds", /*#__PURE__*/React.createElement("br", null), state.documentIsStable ? '✅' : '❌', " Document Is Stable", /*#__PURE__*/React.createElement("br", null), state.goodFramesThresholdMet ? '✅' : '❌', " Good Frame Count:", ' ', state.goodFramesCount, "/", state.goodFramesThreshold)) : ( /*#__PURE__*/React.createElement(React.Fragment, null, "\u274C Models not ready")))));
|
|
14250
|
+
}))), debugMode && ( /*#__PURE__*/React.createElement(DebugStatsPane, null, camera ? ( /*#__PURE__*/React.createElement(React.Fragment, null, "\u2705 Camera: ", camera.label, " (", camera.width, "x", camera.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React.createElement("br", null), state.frameCaptureRate > 0.75 ? '✅' : '👎', " Frame Rate:", ' ', Math.round((state.frameCaptureRate + Number.EPSILON) * 1000) / 1000, ' ', "fps (", detectionTime, "ms doc detect, ", focusPredictionTime, "ms focus)", /*#__PURE__*/React.createElement("br", null), modelsReady ? ( /*#__PURE__*/React.createElement(React.Fragment, null, state.detectionThresholdMet ? '✅' : '❌', " Detected Document Type: ", state.detectedDocumentType, /*#__PURE__*/React.createElement("br", null), state.idCardFrontDetectionThresholdMet ? '✅' : '❌', " ID Card Front Score: ", state.idCardFrontDetectionScore.toFixed(3), /*#__PURE__*/React.createElement("br", null), state.idCardBackDetectionThresholdMet ? '✅' : '❌', " ID Card Back Score: ", state.idCardBackDetectionScore.toFixed(3), /*#__PURE__*/React.createElement("br", null), state.passportDetectionThresholdMet ? '✅' : '❌', " Passport Score: ", state.passportDetectionScore.toFixed(3), /*#__PURE__*/React.createElement("br", null), state.singlePageDetectionThresholdMet ? '✅' : '❌', " Single Page Score: ", state.singlePageDetectionScore.toFixed(3), /*#__PURE__*/React.createElement("br", null), state.focusThresholdMet ? '✅' : '❌', " Focus Score:", ' ', state.focusScore.toFixed(3), /*#__PURE__*/React.createElement("br", null), state.documentInBounds ? '✅' : '❌', " Document In Bounds", /*#__PURE__*/React.createElement("br", null), state.documentIsStable ? '✅' : '❌', " Document Is Stable", /*#__PURE__*/React.createElement("br", null), state.goodFramesThresholdMet ? '✅' : '❌', " Good Frame Count:", ' ', state.goodFramesCount, "/", state.goodFramesThreshold)) : ( /*#__PURE__*/React.createElement(React.Fragment, null, "\u274C Models not ready")))));
|
|
14220
14251
|
};
|
|
14221
14252
|
var timeSince = function timeSince(t) {
|
|
14222
14253
|
if (!t) return 0;
|