idmission-web-sdk 2.2.58 → 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.58';
206
+ var webSdkVersion = '2.2.59';
207
207
 
208
208
  function getPlatform() {
209
209
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -2238,7 +2238,7 @@ function average(arr) {
2238
2238
 
2239
2239
  var DEFAULT_CDN_URL = 'https://websdk-cdn-dev.idmission.com/assets';
2240
2240
 
2241
- 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");
2242
2242
 
2243
2243
  var defaultFocusModelPath = "".concat(DEFAULT_CDN_URL, "/models/Focus/Focus-20241008_102708.tflite");
2244
2244
 
@@ -2257,6 +2257,10 @@ var defaultFocusThresholds = {
2257
2257
  passport: {
2258
2258
  desktop: 0,
2259
2259
  mobile: 0.3
2260
+ },
2261
+ singlePage: {
2262
+ desktop: 0,
2263
+ mobile: 0.3
2260
2264
  }
2261
2265
  };
2262
2266
  var classifier = null;
@@ -2882,16 +2886,19 @@ var defaultDocumentDetectionThresholds = {
2882
2886
  idCardFront: 0.6,
2883
2887
  idCardBack: 0.6,
2884
2888
  passport: 0.4,
2889
+ singlePage: 0.4,
2885
2890
  stability: {
2886
2891
  idCardFront: 0.85,
2887
2892
  idCardBack: 0.85,
2888
- passport: 0.5
2893
+ passport: 0.5,
2894
+ singlePage: 0.5
2889
2895
  }
2890
2896
  };
2891
2897
  var documentTypeDisplayNames = {
2892
2898
  idCardFront: 'ID card front',
2893
2899
  idCardBack: 'ID card back',
2894
2900
  passport: 'Passport',
2901
+ singlePage: 'Single page',
2895
2902
  none: 'None'
2896
2903
  };
2897
2904
  var detector = null;
@@ -3080,7 +3087,7 @@ var defaultDocumentDetectionBoundaries = {
3080
3087
  right: 20
3081
3088
  };
3082
3089
  function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
3083
- 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;
3084
3091
  if (boundaries === void 0) {
3085
3092
  boundaries = defaultDocumentDetectionBoundaries;
3086
3093
  }
@@ -3131,18 +3138,25 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
3131
3138
  var bestPassportPage = detectedObjects.find(function (obj) {
3132
3139
  return obj.label === 'Passport page';
3133
3140
  });
3141
+ var bestSinglePage = detectedObjects.find(function (obj) {
3142
+ return obj.label === 'Single page';
3143
+ });
3134
3144
  var idCardFrontDetectionScore = (_e = bestIdCardFront === null || bestIdCardFront === void 0 ? void 0 : bestIdCardFront.score) !== null && _e !== void 0 ? _e : 0;
3135
3145
  var idCardBackDetectionScore = (_f = bestIdCardBack === null || bestIdCardBack === void 0 ? void 0 : bestIdCardBack.score) !== null && _f !== void 0 ? _f : 0;
3136
3146
  var passportDetectionScore = (_g = bestPassportPage === null || bestPassportPage === void 0 ? void 0 : bestPassportPage.score) !== null && _g !== void 0 ? _g : 0;
3137
- var idCardFrontDetectionThresholdMet = idCardFrontDetectionScore >= ((_h = thresholds.idCardFront) !== null && _h !== void 0 ? _h : 0);
3138
- var idCardBackDetectionThresholdMet = idCardBackDetectionScore >= ((_j = thresholds.idCardBack) !== null && _j !== void 0 ? _j : 0);
3139
- var passportDetectionThresholdMet = passportDetectionScore >= ((_k = thresholds.passport) !== null && _k !== void 0 ? _k : 0);
3140
- var bestDocument = passportDetectionThresholdMet ? bestPassportPage : idCardBackDetectionThresholdMet ? bestIdCardBack : bestIdCardFront;
3141
- var detectionThreshold = passportDetectionThresholdMet ? thresholds.passport : idCardBackDetectionThresholdMet ? thresholds.idCardBack : thresholds.idCardFront;
3142
- 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;
3143
3155
  var detectionThresholdMet = detectionScore >= (detectionThreshold !== null && detectionThreshold !== void 0 ? detectionThreshold : 0);
3144
3156
  var detectedDocumentType = 'none';
3145
- if (passportDetectionThresholdMet) {
3157
+ if (singlePageDetectionThresholdMet) {
3158
+ detectedDocumentType = 'singlePage';
3159
+ } else if (passportDetectionThresholdMet) {
3146
3160
  detectedDocumentType = 'passport';
3147
3161
  } else if (idCardBackDetectionThresholdMet) {
3148
3162
  detectedDocumentType = 'idCardBack';
@@ -3156,12 +3170,12 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
3156
3170
  var documentIsStable = false;
3157
3171
  var documentTooClose = false;
3158
3172
  if (bestDocument) {
3159
- var _o = [bestDocument.box.width / frameWidth, bestDocument.box.height / frameHeight],
3160
- docWidth = _o[0],
3161
- docHeight = _o[1];
3173
+ var _q = [bestDocument.box.width / frameWidth, bestDocument.box.height / frameHeight],
3174
+ docWidth = _q[0],
3175
+ docHeight = _q[1];
3162
3176
  documentTooClose = docWidth > 0.85 || docHeight > 0.85;
3163
3177
  if (detectionThresholdMet && documentInBounds && !documentTooClose) {
3164
- 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;
3165
3179
  var threshold_1 = thresholdSet[detectedDocumentType];
3166
3180
  var framesNeeded = Math.ceil(average(framesNeededSamples));
3167
3181
  trackBox(bestDocument.box, framesNeeded);
@@ -4130,7 +4144,8 @@ function IdCaptureModelsProviderInner(_a) {
4130
4144
  if (!lastPredictionCanvas.current) return [2 /*return*/];
4131
4145
  stopDetectionAtStart = stopDetection.current;
4132
4146
  focusPredictionTime = 0, focusScore = 0, focusThresholdMet = false;
4133
- 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
+ ;
4134
4149
  if (isRequiredDocumentType && prediction.detectedDocumentType !== 'none' && prediction.detectionThresholdMet && prediction.documentInBounds && !prediction.documentTooClose && prediction.documentIsStable) {
4135
4150
  focusPrediction = makeFocusPrediction(lastPredictionCanvas.current, (_b = prediction.bestDocument) === null || _b === void 0 ? void 0 : _b.box);
4136
4151
  if (focusPrediction) {
@@ -4278,6 +4293,8 @@ var initialState$4 = {
4278
4293
  idCardBackDetectionThresholdMet: false,
4279
4294
  passportDetectionScore: 0,
4280
4295
  passportDetectionThresholdMet: false,
4296
+ singlePageDetectionScore: 0,
4297
+ singlePageDetectionThresholdMet: false,
4281
4298
  focusScore: 0,
4282
4299
  focusThresholdMet: false,
4283
4300
  isGoodFrame: false,
@@ -5230,7 +5247,7 @@ var IdCapture = function IdCapture(_a) {
5230
5247
  scaling: debugScalingDetails,
5231
5248
  flipX: !isRearFacing
5232
5249
  });
5233
- }))), 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")))));
5234
5251
  };
5235
5252
  var timeSince = function timeSince(t) {
5236
5253
  if (!t) return 0;