idmission-web-sdk 2.2.61 → 2.2.63

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.61';
206
+ var webSdkVersion = '2.2.63';
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-20241212_131026.tflite");
2241
+ var defaultDocumentDetectorModelPath = "".concat(DEFAULT_CDN_URL, "/models/DocumentDetector/DocumentDetector-20241018_093000.tflite");
2242
2242
 
2243
2243
  var defaultFocusModelPath = "".concat(DEFAULT_CDN_URL, "/models/Focus/Focus-20241008_102708.tflite");
2244
2244
 
@@ -2257,10 +2257,6 @@ var defaultFocusThresholds = {
2257
2257
  passport: {
2258
2258
  desktop: 0,
2259
2259
  mobile: 0.3
2260
- },
2261
- singlePage: {
2262
- desktop: 0,
2263
- mobile: 0.3
2264
2260
  }
2265
2261
  };
2266
2262
  var classifier = null;
@@ -2582,7 +2578,7 @@ function processFaceDetectorPrediction(_a) {
2582
2578
  _b = _a.requireVerticalFaceCentering,
2583
2579
  requireVerticalFaceCentering = _b === void 0 ? true : _b,
2584
2580
  _c = _a.stabilityThreshold,
2585
- stabilityThreshold = _c === void 0 ? 0.75 : _c;
2581
+ stabilityThreshold = _c === void 0 ? 0.7 : _c;
2586
2582
  var face = faces[0];
2587
2583
  var faceNotDetected = faces.length === 0;
2588
2584
  var faceNotCentered = requireVerticalFaceCentering,
@@ -2886,19 +2882,16 @@ var defaultDocumentDetectionThresholds = {
2886
2882
  idCardFront: 0.6,
2887
2883
  idCardBack: 0.6,
2888
2884
  passport: 0.4,
2889
- singlePage: 0.4,
2890
2885
  stability: {
2891
2886
  idCardFront: 0.85,
2892
2887
  idCardBack: 0.85,
2893
- passport: 0.5,
2894
- singlePage: 0.5
2888
+ passport: 0.5
2895
2889
  }
2896
2890
  };
2897
2891
  var documentTypeDisplayNames = {
2898
2892
  idCardFront: 'ID card front',
2899
2893
  idCardBack: 'ID card back',
2900
2894
  passport: 'Passport',
2901
- singlePage: 'Single page',
2902
2895
  none: 'None'
2903
2896
  };
2904
2897
  var detector = null;
@@ -3087,7 +3080,7 @@ var defaultDocumentDetectionBoundaries = {
3087
3080
  right: 20
3088
3081
  };
3089
3082
  function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
3090
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
3083
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
3091
3084
  if (boundaries === void 0) {
3092
3085
  boundaries = defaultDocumentDetectionBoundaries;
3093
3086
  }
@@ -3138,25 +3131,18 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
3138
3131
  var bestPassportPage = detectedObjects.find(function (obj) {
3139
3132
  return obj.label === 'Passport page';
3140
3133
  });
3141
- var bestSinglePage = detectedObjects.find(function (obj) {
3142
- return obj.label === 'Single page';
3143
- });
3144
3134
  var idCardFrontDetectionScore = (_e = bestIdCardFront === null || bestIdCardFront === void 0 ? void 0 : bestIdCardFront.score) !== null && _e !== void 0 ? _e : 0;
3145
3135
  var idCardBackDetectionScore = (_f = bestIdCardBack === null || bestIdCardBack === void 0 ? void 0 : bestIdCardBack.score) !== null && _f !== void 0 ? _f : 0;
3146
3136
  var passportDetectionScore = (_g = bestPassportPage === null || bestPassportPage === void 0 ? void 0 : bestPassportPage.score) !== null && _g !== void 0 ? _g : 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;
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;
3155
3143
  var detectionThresholdMet = detectionScore >= (detectionThreshold !== null && detectionThreshold !== void 0 ? detectionThreshold : 0);
3156
3144
  var detectedDocumentType = 'none';
3157
- if (singlePageDetectionThresholdMet) {
3158
- detectedDocumentType = 'singlePage';
3159
- } else if (passportDetectionThresholdMet) {
3145
+ if (passportDetectionThresholdMet) {
3160
3146
  detectedDocumentType = 'passport';
3161
3147
  } else if (idCardBackDetectionThresholdMet) {
3162
3148
  detectedDocumentType = 'idCardBack';
@@ -3170,12 +3156,12 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
3170
3156
  var documentIsStable = false;
3171
3157
  var documentTooClose = false;
3172
3158
  if (bestDocument) {
3173
- var _q = [bestDocument.box.width / frameWidth, bestDocument.box.height / frameHeight],
3174
- docWidth = _q[0],
3175
- docHeight = _q[1];
3159
+ var _o = [bestDocument.box.width / frameWidth, bestDocument.box.height / frameHeight],
3160
+ docWidth = _o[0],
3161
+ docHeight = _o[1];
3176
3162
  documentTooClose = docWidth > 0.85 || docHeight > 0.85;
3177
3163
  if (detectionThresholdMet && documentInBounds && !documentTooClose) {
3178
- var thresholdSet = (_p = thresholds.stability) !== null && _p !== void 0 ? _p : defaultDocumentDetectionThresholds.stability;
3164
+ var thresholdSet = (_m = thresholds.stability) !== null && _m !== void 0 ? _m : defaultDocumentDetectionThresholds.stability;
3179
3165
  var threshold_1 = thresholdSet[detectedDocumentType];
3180
3166
  var framesNeeded = Math.ceil(average(framesNeededSamples));
3181
3167
  trackBox(bestDocument.box, framesNeeded);
@@ -3197,8 +3183,6 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
3197
3183
  idCardBackDetectionThresholdMet: idCardBackDetectionThresholdMet,
3198
3184
  passportDetectionScore: passportDetectionScore,
3199
3185
  passportDetectionThresholdMet: passportDetectionThresholdMet,
3200
- singlePageDetectionScore: singlePageDetectionScore,
3201
- singlePageDetectionThresholdMet: singlePageDetectionThresholdMet,
3202
3186
  bestDocument: bestDocument,
3203
3187
  documentInBounds: documentInBounds,
3204
3188
  documentTooClose: documentTooClose,
@@ -4146,8 +4130,7 @@ function IdCaptureModelsProviderInner(_a) {
4146
4130
  if (!lastPredictionCanvas.current) return [2 /*return*/];
4147
4131
  stopDetectionAtStart = stopDetection.current;
4148
4132
  focusPredictionTime = 0, focusScore = 0, focusThresholdMet = false;
4149
- 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
4150
- ;
4133
+ isRequiredDocumentType = requiredDocumentType === 'none' || prediction.detectedDocumentType === requiredDocumentType || ((_a = requiredDocumentType.includes) === null || _a === void 0 ? void 0 : _a.call(requiredDocumentType, prediction.detectedDocumentType));
4151
4134
  if (isRequiredDocumentType && prediction.detectedDocumentType !== 'none' && prediction.detectionThresholdMet && prediction.documentInBounds && !prediction.documentTooClose && prediction.documentIsStable) {
4152
4135
  focusPrediction = makeFocusPrediction(lastPredictionCanvas.current, (_b = prediction.bestDocument) === null || _b === void 0 ? void 0 : _b.box);
4153
4136
  if (focusPrediction) {
@@ -4295,8 +4278,6 @@ var initialState$4 = {
4295
4278
  idCardBackDetectionThresholdMet: false,
4296
4279
  passportDetectionScore: 0,
4297
4280
  passportDetectionThresholdMet: false,
4298
- singlePageDetectionScore: 0,
4299
- singlePageDetectionThresholdMet: false,
4300
4281
  focusScore: 0,
4301
4282
  focusThresholdMet: false,
4302
4283
  isGoodFrame: false,
@@ -4398,8 +4379,6 @@ var _reducer = function reducer(state, action) {
4398
4379
  idCardBackDetectionThresholdMet = _d.idCardBackDetectionThresholdMet,
4399
4380
  passportDetectionScore = _d.passportDetectionScore,
4400
4381
  passportDetectionThresholdMet = _d.passportDetectionThresholdMet,
4401
- singlePageDetectionScore = _d.singlePageDetectionScore,
4402
- singlePageDetectionThresholdMet = _d.singlePageDetectionThresholdMet,
4403
4382
  bestDocument = _d.bestDocument,
4404
4383
  documentInBounds = _d.documentInBounds,
4405
4384
  documentTooClose = _d.documentTooClose,
@@ -4480,8 +4459,6 @@ var _reducer = function reducer(state, action) {
4480
4459
  idCardBackDetectionThresholdMet: idCardBackDetectionThresholdMet,
4481
4460
  passportDetectionScore: passportDetectionScore,
4482
4461
  passportDetectionThresholdMet: passportDetectionThresholdMet,
4483
- singlePageDetectionScore: singlePageDetectionScore,
4484
- singlePageDetectionThresholdMet: singlePageDetectionThresholdMet,
4485
4462
  focusScore: focusScore,
4486
4463
  focusThresholdMet: focusThresholdMet,
4487
4464
  isGoodFrame: isGoodFrame,
@@ -5253,7 +5230,7 @@ var IdCapture = function IdCapture(_a) {
5253
5230
  scaling: debugScalingDetails,
5254
5231
  flipX: !isRearFacing
5255
5232
  });
5256
- }))), 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")))));
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")))));
5257
5234
  };
5258
5235
  var timeSince = function timeSince(t) {
5259
5236
  if (!t) return 0;
@@ -11273,26 +11250,21 @@ function VideoSignatureContextProvider(_a) {
11273
11250
  }, [isRecording, isRecordingVideo, startRecordingVideo, videoUrl]);
11274
11251
  var animationFrame = useRef(0);
11275
11252
  useEffect(function () {
11276
- var _a;
11277
11253
  if (!signaturePad.current || !videoRef.current || !outputCanvas.current || !camera || !isRecording || !isRecordingVideo) return;
11278
- var _b = [camera.width, camera.height],
11279
- w = _b[0],
11280
- h = _b[1];
11281
- var isPortrait = typeof window !== 'undefined' && window.innerWidth < window.innerHeight;
11282
- var cameraIsLandscape = w > h;
11283
- if (isPortrait && cameraIsLandscape) _a = [h, w], w = _a[0], h = _a[1];
11284
- outputCanvas.current.width = w;
11285
- outputCanvas.current.height = h;
11286
11254
  var ctx = outputCanvas.current.getContext('2d');
11287
11255
  if (!ctx) return;
11288
11256
  animationFrame.current = requestAnimationFrame(function runFrame() {
11289
11257
  return __awaiter(this, void 0, void 0, function () {
11290
- var rect;
11291
- return __generator(this, function (_a) {
11258
+ var _a, w, h, isPortrait, rect;
11259
+ return __generator(this, function (_b) {
11292
11260
  if (!signaturePad.current || !videoRef.current || !outputCanvas.current) {
11293
11261
  cancelAnimationFrame(animationFrame.current);
11294
11262
  return [2 /*return*/];
11295
11263
  }
11264
+ _a = [videoRef.current.videoWidth, videoRef.current.videoHeight], w = _a[0], h = _a[1];
11265
+ isPortrait = w < h;
11266
+ outputCanvas.current.width = w;
11267
+ outputCanvas.current.height = h;
11296
11268
  rect = [w * (isPortrait ? 0.02 : 0.15), h * (isPortrait ? 0.15 : 0.25), w * (isPortrait ? 0.96 : 0.7), h * (isPortrait ? 0.7 : 0.5)];
11297
11269
  ctx.drawImage(videoRef.current, 0, 0, w, h);
11298
11270
  ctx.beginPath();