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/sdk2.esm.js CHANGED
@@ -203,7 +203,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
203
203
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
204
204
  };
205
205
 
206
- var webSdkVersion = '2.2.57';
206
+ var webSdkVersion = '2.2.59';
207
207
 
208
208
  function getPlatform() {
209
209
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -1358,7 +1358,7 @@ var SubmissionProvider = function SubmissionProvider(_a) {
1358
1358
  }
1359
1359
  }, _d.onSuccess = function () {
1360
1360
  var _a, _b;
1361
- documentId || (documentId = "urn:documentsv1:".concat((_a = upload.url.split('/files/').pop()) === null || _a === void 0 ? void 0 : _a.split('+').shift()));
1361
+ documentId || (documentId = "urn:documentsv1:".concat(getEnvFromUrl(upload.url), ":").concat((_a = upload.url.split('/files/').pop()) === null || _a === void 0 ? void 0 : _a.split('+').shift()));
1362
1362
  (_b = onDocumentUploaded.current) === null || _b === void 0 ? void 0 : _b.call(onDocumentUploaded, documentId, metadata);
1363
1363
  resolve(documentId);
1364
1364
  }, _d.onError = function (error) {
@@ -1913,6 +1913,20 @@ function calculateMd5(blob) {
1913
1913
  };
1914
1914
  });
1915
1915
  }
1916
+ function getEnvFromUrl(url) {
1917
+ if (url.startsWith('https://portal-api.idmission.com')) {
1918
+ return 'prod';
1919
+ } else if (url.startsWith('https://portal-api-uat.idmission.com')) {
1920
+ return 'uat';
1921
+ } else if (url.startsWith('https://portal-api-demo.idmission.com')) {
1922
+ return 'demo';
1923
+ } else if (url.startsWith('https://portal-api-dev.idmission.com')) {
1924
+ return 'dev';
1925
+ } else if (url.startsWith('http://localhost:10000')) {
1926
+ return 'local';
1927
+ }
1928
+ return 'unknown';
1929
+ }
1916
1930
 
1917
1931
  var visionTasksBasePath = "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.7/wasm";
1918
1932
  var visionRuntimePreloading = false;
@@ -2224,7 +2238,7 @@ function average(arr) {
2224
2238
 
2225
2239
  var DEFAULT_CDN_URL = 'https://websdk-cdn-dev.idmission.com/assets';
2226
2240
 
2227
- var defaultDocumentDetectorModelPath = "".concat(DEFAULT_CDN_URL, "/models/DocumentDetector/DocumentDetector-20241018_093000.tflite");
2241
+ var defaultDocumentDetectorModelPath = "".concat(DEFAULT_CDN_URL, "/models/DocumentDetector/DocumentDetector-20241212_131026.tflite");
2228
2242
 
2229
2243
  var defaultFocusModelPath = "".concat(DEFAULT_CDN_URL, "/models/Focus/Focus-20241008_102708.tflite");
2230
2244
 
@@ -2243,6 +2257,10 @@ var defaultFocusThresholds = {
2243
2257
  passport: {
2244
2258
  desktop: 0,
2245
2259
  mobile: 0.3
2260
+ },
2261
+ singlePage: {
2262
+ desktop: 0,
2263
+ mobile: 0.3
2246
2264
  }
2247
2265
  };
2248
2266
  var classifier = null;
@@ -2868,16 +2886,19 @@ var defaultDocumentDetectionThresholds = {
2868
2886
  idCardFront: 0.6,
2869
2887
  idCardBack: 0.6,
2870
2888
  passport: 0.4,
2889
+ singlePage: 0.4,
2871
2890
  stability: {
2872
2891
  idCardFront: 0.85,
2873
2892
  idCardBack: 0.85,
2874
- passport: 0.5
2893
+ passport: 0.5,
2894
+ singlePage: 0.5
2875
2895
  }
2876
2896
  };
2877
2897
  var documentTypeDisplayNames = {
2878
2898
  idCardFront: 'ID card front',
2879
2899
  idCardBack: 'ID card back',
2880
2900
  passport: 'Passport',
2901
+ singlePage: 'Single page',
2881
2902
  none: 'None'
2882
2903
  };
2883
2904
  var detector = null;
@@ -3066,7 +3087,7 @@ var defaultDocumentDetectionBoundaries = {
3066
3087
  right: 20
3067
3088
  };
3068
3089
  function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
3069
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
3090
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
3070
3091
  if (boundaries === void 0) {
3071
3092
  boundaries = defaultDocumentDetectionBoundaries;
3072
3093
  }
@@ -3117,18 +3138,25 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
3117
3138
  var bestPassportPage = detectedObjects.find(function (obj) {
3118
3139
  return obj.label === 'Passport page';
3119
3140
  });
3141
+ var bestSinglePage = detectedObjects.find(function (obj) {
3142
+ return obj.label === 'Single page';
3143
+ });
3120
3144
  var idCardFrontDetectionScore = (_e = bestIdCardFront === null || bestIdCardFront === void 0 ? void 0 : bestIdCardFront.score) !== null && _e !== void 0 ? _e : 0;
3121
3145
  var idCardBackDetectionScore = (_f = bestIdCardBack === null || bestIdCardBack === void 0 ? void 0 : bestIdCardBack.score) !== null && _f !== void 0 ? _f : 0;
3122
3146
  var passportDetectionScore = (_g = bestPassportPage === null || bestPassportPage === void 0 ? void 0 : bestPassportPage.score) !== null && _g !== void 0 ? _g : 0;
3123
- var idCardFrontDetectionThresholdMet = idCardFrontDetectionScore >= ((_h = thresholds.idCardFront) !== null && _h !== void 0 ? _h : 0);
3124
- var idCardBackDetectionThresholdMet = idCardBackDetectionScore >= ((_j = thresholds.idCardBack) !== null && _j !== void 0 ? _j : 0);
3125
- var passportDetectionThresholdMet = passportDetectionScore >= ((_k = thresholds.passport) !== null && _k !== void 0 ? _k : 0);
3126
- var bestDocument = passportDetectionThresholdMet ? bestPassportPage : idCardBackDetectionThresholdMet ? bestIdCardBack : bestIdCardFront;
3127
- var detectionThreshold = passportDetectionThresholdMet ? thresholds.passport : idCardBackDetectionThresholdMet ? thresholds.idCardBack : thresholds.idCardFront;
3128
- var detectionScore = (_l = bestDocument === null || bestDocument === void 0 ? void 0 : bestDocument.score) !== null && _l !== void 0 ? _l : 0;
3147
+ var singlePageDetectionScore = (_h = bestSinglePage === null || bestSinglePage === void 0 ? void 0 : bestSinglePage.score) !== null && _h !== void 0 ? _h : 0;
3148
+ var idCardFrontDetectionThresholdMet = idCardFrontDetectionScore >= ((_j = thresholds.idCardFront) !== null && _j !== void 0 ? _j : 0);
3149
+ var idCardBackDetectionThresholdMet = idCardBackDetectionScore >= ((_k = thresholds.idCardBack) !== null && _k !== void 0 ? _k : 0);
3150
+ var passportDetectionThresholdMet = passportDetectionScore >= ((_l = thresholds.passport) !== null && _l !== void 0 ? _l : 0);
3151
+ var singlePageDetectionThresholdMet = singlePageDetectionScore >= ((_m = thresholds.singlePage) !== null && _m !== void 0 ? _m : 0);
3152
+ var bestDocument = singlePageDetectionThresholdMet ? bestSinglePage : passportDetectionThresholdMet ? bestPassportPage : idCardBackDetectionThresholdMet ? bestIdCardBack : bestIdCardFront;
3153
+ var detectionThreshold = singlePageDetectionThresholdMet ? thresholds.singlePage : passportDetectionThresholdMet ? thresholds.passport : idCardBackDetectionThresholdMet ? thresholds.idCardBack : thresholds.idCardFront;
3154
+ var detectionScore = (_o = bestDocument === null || bestDocument === void 0 ? void 0 : bestDocument.score) !== null && _o !== void 0 ? _o : 0;
3129
3155
  var detectionThresholdMet = detectionScore >= (detectionThreshold !== null && detectionThreshold !== void 0 ? detectionThreshold : 0);
3130
3156
  var detectedDocumentType = 'none';
3131
- if (passportDetectionThresholdMet) {
3157
+ if (singlePageDetectionThresholdMet) {
3158
+ detectedDocumentType = 'singlePage';
3159
+ } else if (passportDetectionThresholdMet) {
3132
3160
  detectedDocumentType = 'passport';
3133
3161
  } else if (idCardBackDetectionThresholdMet) {
3134
3162
  detectedDocumentType = 'idCardBack';
@@ -3142,12 +3170,12 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
3142
3170
  var documentIsStable = false;
3143
3171
  var documentTooClose = false;
3144
3172
  if (bestDocument) {
3145
- var _o = [bestDocument.box.width / frameWidth, bestDocument.box.height / frameHeight],
3146
- docWidth = _o[0],
3147
- docHeight = _o[1];
3173
+ var _q = [bestDocument.box.width / frameWidth, bestDocument.box.height / frameHeight],
3174
+ docWidth = _q[0],
3175
+ docHeight = _q[1];
3148
3176
  documentTooClose = docWidth > 0.85 || docHeight > 0.85;
3149
3177
  if (detectionThresholdMet && documentInBounds && !documentTooClose) {
3150
- var thresholdSet = (_m = thresholds.stability) !== null && _m !== void 0 ? _m : defaultDocumentDetectionThresholds.stability;
3178
+ var thresholdSet = (_p = thresholds.stability) !== null && _p !== void 0 ? _p : defaultDocumentDetectionThresholds.stability;
3151
3179
  var threshold_1 = thresholdSet[detectedDocumentType];
3152
3180
  var framesNeeded = Math.ceil(average(framesNeededSamples));
3153
3181
  trackBox(bestDocument.box, framesNeeded);
@@ -4116,7 +4144,8 @@ function IdCaptureModelsProviderInner(_a) {
4116
4144
  if (!lastPredictionCanvas.current) return [2 /*return*/];
4117
4145
  stopDetectionAtStart = stopDetection.current;
4118
4146
  focusPredictionTime = 0, focusScore = 0, focusThresholdMet = false;
4119
- isRequiredDocumentType = requiredDocumentType === 'none' || prediction.detectedDocumentType === requiredDocumentType || ((_a = requiredDocumentType.includes) === null || _a === void 0 ? void 0 : _a.call(requiredDocumentType, prediction.detectedDocumentType));
4147
+ 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
4148
+ ;
4120
4149
  if (isRequiredDocumentType && prediction.detectedDocumentType !== 'none' && prediction.detectionThresholdMet && prediction.documentInBounds && !prediction.documentTooClose && prediction.documentIsStable) {
4121
4150
  focusPrediction = makeFocusPrediction(lastPredictionCanvas.current, (_b = prediction.bestDocument) === null || _b === void 0 ? void 0 : _b.box);
4122
4151
  if (focusPrediction) {
@@ -4264,6 +4293,8 @@ var initialState$4 = {
4264
4293
  idCardBackDetectionThresholdMet: false,
4265
4294
  passportDetectionScore: 0,
4266
4295
  passportDetectionThresholdMet: false,
4296
+ singlePageDetectionScore: 0,
4297
+ singlePageDetectionThresholdMet: false,
4267
4298
  focusScore: 0,
4268
4299
  focusThresholdMet: false,
4269
4300
  isGoodFrame: false,
@@ -5216,7 +5247,7 @@ var IdCapture = function IdCapture(_a) {
5216
5247
  scaling: debugScalingDetails,
5217
5248
  flipX: !isRearFacing
5218
5249
  });
5219
- }))), debugMode && ( /*#__PURE__*/React__default.createElement(DebugStatsPane, null, camera ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u2705 Camera: ", camera.label, " (", camera.width, "x", camera.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React__default.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__default.createElement("br", null), modelsReady ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, state.detectionThresholdMet ? '✅' : '❌', " Detected Document Type: ", state.detectedDocumentType, /*#__PURE__*/React__default.createElement("br", null), state.idCardFrontDetectionThresholdMet ? '✅' : '❌', " ID Card Front Score: ", state.idCardFrontDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.idCardBackDetectionThresholdMet ? '✅' : '❌', " ID Card Back Score: ", state.idCardBackDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.passportDetectionThresholdMet ? '✅' : '❌', " Passport Score: ", state.passportDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.focusThresholdMet ? '✅' : '❌', " Focus Score:", ' ', state.focusScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.documentInBounds ? '✅' : '❌', " Document In Bounds", /*#__PURE__*/React__default.createElement("br", null), state.documentIsStable ? '✅' : '❌', " Document Is Stable", /*#__PURE__*/React__default.createElement("br", null), state.goodFramesThresholdMet ? '✅' : '❌', " Good Frame Count:", ' ', state.goodFramesCount, "/", state.goodFramesThreshold)) : ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u274C Models not ready")))));
5250
+ }))), debugMode && ( /*#__PURE__*/React__default.createElement(DebugStatsPane, null, camera ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u2705 Camera: ", camera.label, " (", camera.width, "x", camera.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React__default.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__default.createElement("br", null), modelsReady ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, state.detectionThresholdMet ? '✅' : '❌', " Detected Document Type: ", state.detectedDocumentType, /*#__PURE__*/React__default.createElement("br", null), state.idCardFrontDetectionThresholdMet ? '✅' : '❌', " ID Card Front Score: ", state.idCardFrontDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.idCardBackDetectionThresholdMet ? '✅' : '❌', " ID Card Back Score: ", state.idCardBackDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.passportDetectionThresholdMet ? '✅' : '❌', " Passport Score: ", state.passportDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.singlePageDetectionThresholdMet ? '✅' : '❌', " Single Page Score: ", state.singlePageDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.focusThresholdMet ? '✅' : '❌', " Focus Score:", ' ', state.focusScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.documentInBounds ? '✅' : '❌', " Document In Bounds", /*#__PURE__*/React__default.createElement("br", null), state.documentIsStable ? '✅' : '❌', " Document Is Stable", /*#__PURE__*/React__default.createElement("br", null), state.goodFramesThresholdMet ? '✅' : '❌', " Good Frame Count:", ' ', state.goodFramesCount, "/", state.goodFramesThreshold)) : ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u274C Models not ready")))));
5220
5251
  };
5221
5252
  var timeSince = function timeSince(t) {
5222
5253
  if (!t) return 0;