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.
@@ -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.61';
214
+ var webSdkVersion = '2.2.63';
215
215
 
216
216
  function getPlatform() {
217
217
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -8311,7 +8311,7 @@
8311
8311
 
8312
8312
  var DEFAULT_CDN_URL = 'https://websdk-cdn-dev.idmission.com/assets';
8313
8313
 
8314
- var defaultDocumentDetectorModelPath = "".concat(DEFAULT_CDN_URL, "/models/DocumentDetector/DocumentDetector-20241212_131026.tflite");
8314
+ var defaultDocumentDetectorModelPath = "".concat(DEFAULT_CDN_URL, "/models/DocumentDetector/DocumentDetector-20241018_093000.tflite");
8315
8315
 
8316
8316
  var defaultFocusModelPath = "".concat(DEFAULT_CDN_URL, "/models/Focus/Focus-20241008_102708.tflite");
8317
8317
 
@@ -8330,10 +8330,6 @@
8330
8330
  passport: {
8331
8331
  desktop: 0,
8332
8332
  mobile: 0.3
8333
- },
8334
- singlePage: {
8335
- desktop: 0,
8336
- mobile: 0.3
8337
8333
  }
8338
8334
  };
8339
8335
  var classifier = null;
@@ -8655,7 +8651,7 @@
8655
8651
  _b = _a.requireVerticalFaceCentering,
8656
8652
  requireVerticalFaceCentering = _b === void 0 ? true : _b,
8657
8653
  _c = _a.stabilityThreshold,
8658
- stabilityThreshold = _c === void 0 ? 0.75 : _c;
8654
+ stabilityThreshold = _c === void 0 ? 0.7 : _c;
8659
8655
  var face = faces[0];
8660
8656
  var faceNotDetected = faces.length === 0;
8661
8657
  var faceNotCentered = requireVerticalFaceCentering,
@@ -8959,19 +8955,16 @@
8959
8955
  idCardFront: 0.6,
8960
8956
  idCardBack: 0.6,
8961
8957
  passport: 0.4,
8962
- singlePage: 0.4,
8963
8958
  stability: {
8964
8959
  idCardFront: 0.85,
8965
8960
  idCardBack: 0.85,
8966
- passport: 0.5,
8967
- singlePage: 0.5
8961
+ passport: 0.5
8968
8962
  }
8969
8963
  };
8970
8964
  var documentTypeDisplayNames = {
8971
8965
  idCardFront: 'ID card front',
8972
8966
  idCardBack: 'ID card back',
8973
8967
  passport: 'Passport',
8974
- singlePage: 'Single page',
8975
8968
  none: 'None'
8976
8969
  };
8977
8970
  var detector = null;
@@ -9160,7 +9153,7 @@
9160
9153
  right: 20
9161
9154
  };
9162
9155
  function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
9163
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
9156
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
9164
9157
  if (boundaries === void 0) {
9165
9158
  boundaries = defaultDocumentDetectionBoundaries;
9166
9159
  }
@@ -9211,25 +9204,18 @@
9211
9204
  var bestPassportPage = detectedObjects.find(function (obj) {
9212
9205
  return obj.label === 'Passport page';
9213
9206
  });
9214
- var bestSinglePage = detectedObjects.find(function (obj) {
9215
- return obj.label === 'Single page';
9216
- });
9217
9207
  var idCardFrontDetectionScore = (_e = bestIdCardFront === null || bestIdCardFront === void 0 ? void 0 : bestIdCardFront.score) !== null && _e !== void 0 ? _e : 0;
9218
9208
  var idCardBackDetectionScore = (_f = bestIdCardBack === null || bestIdCardBack === void 0 ? void 0 : bestIdCardBack.score) !== null && _f !== void 0 ? _f : 0;
9219
9209
  var passportDetectionScore = (_g = bestPassportPage === null || bestPassportPage === void 0 ? void 0 : bestPassportPage.score) !== null && _g !== void 0 ? _g : 0;
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;
9210
+ var idCardFrontDetectionThresholdMet = idCardFrontDetectionScore >= ((_h = thresholds.idCardFront) !== null && _h !== void 0 ? _h : 0);
9211
+ var idCardBackDetectionThresholdMet = idCardBackDetectionScore >= ((_j = thresholds.idCardBack) !== null && _j !== void 0 ? _j : 0);
9212
+ var passportDetectionThresholdMet = passportDetectionScore >= ((_k = thresholds.passport) !== null && _k !== void 0 ? _k : 0);
9213
+ var bestDocument = passportDetectionThresholdMet ? bestPassportPage : idCardBackDetectionThresholdMet ? bestIdCardBack : bestIdCardFront;
9214
+ var detectionThreshold = passportDetectionThresholdMet ? thresholds.passport : idCardBackDetectionThresholdMet ? thresholds.idCardBack : thresholds.idCardFront;
9215
+ var detectionScore = (_l = bestDocument === null || bestDocument === void 0 ? void 0 : bestDocument.score) !== null && _l !== void 0 ? _l : 0;
9228
9216
  var detectionThresholdMet = detectionScore >= (detectionThreshold !== null && detectionThreshold !== void 0 ? detectionThreshold : 0);
9229
9217
  var detectedDocumentType = 'none';
9230
- if (singlePageDetectionThresholdMet) {
9231
- detectedDocumentType = 'singlePage';
9232
- } else if (passportDetectionThresholdMet) {
9218
+ if (passportDetectionThresholdMet) {
9233
9219
  detectedDocumentType = 'passport';
9234
9220
  } else if (idCardBackDetectionThresholdMet) {
9235
9221
  detectedDocumentType = 'idCardBack';
@@ -9243,12 +9229,12 @@
9243
9229
  var documentIsStable = false;
9244
9230
  var documentTooClose = false;
9245
9231
  if (bestDocument) {
9246
- var _q = [bestDocument.box.width / frameWidth, bestDocument.box.height / frameHeight],
9247
- docWidth = _q[0],
9248
- docHeight = _q[1];
9232
+ var _o = [bestDocument.box.width / frameWidth, bestDocument.box.height / frameHeight],
9233
+ docWidth = _o[0],
9234
+ docHeight = _o[1];
9249
9235
  documentTooClose = docWidth > 0.85 || docHeight > 0.85;
9250
9236
  if (detectionThresholdMet && documentInBounds && !documentTooClose) {
9251
- var thresholdSet = (_p = thresholds.stability) !== null && _p !== void 0 ? _p : defaultDocumentDetectionThresholds.stability;
9237
+ var thresholdSet = (_m = thresholds.stability) !== null && _m !== void 0 ? _m : defaultDocumentDetectionThresholds.stability;
9252
9238
  var threshold_1 = thresholdSet[detectedDocumentType];
9253
9239
  var framesNeeded = Math.ceil(average(framesNeededSamples));
9254
9240
  trackBox(bestDocument.box, framesNeeded);
@@ -9270,8 +9256,6 @@
9270
9256
  idCardBackDetectionThresholdMet: idCardBackDetectionThresholdMet,
9271
9257
  passportDetectionScore: passportDetectionScore,
9272
9258
  passportDetectionThresholdMet: passportDetectionThresholdMet,
9273
- singlePageDetectionScore: singlePageDetectionScore,
9274
- singlePageDetectionThresholdMet: singlePageDetectionThresholdMet,
9275
9259
  bestDocument: bestDocument,
9276
9260
  documentInBounds: documentInBounds,
9277
9261
  documentTooClose: documentTooClose,
@@ -10273,8 +10257,7 @@
10273
10257
  if (!lastPredictionCanvas.current) return [2 /*return*/];
10274
10258
  stopDetectionAtStart = stopDetection.current;
10275
10259
  focusPredictionTime = 0, focusScore = 0, focusThresholdMet = false;
10276
- 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
10277
- ;
10260
+ isRequiredDocumentType = requiredDocumentType === 'none' || prediction.detectedDocumentType === requiredDocumentType || ((_a = requiredDocumentType.includes) === null || _a === void 0 ? void 0 : _a.call(requiredDocumentType, prediction.detectedDocumentType));
10278
10261
  if (isRequiredDocumentType && prediction.detectedDocumentType !== 'none' && prediction.detectionThresholdMet && prediction.documentInBounds && !prediction.documentTooClose && prediction.documentIsStable) {
10279
10262
  focusPrediction = makeFocusPrediction(lastPredictionCanvas.current, (_b = prediction.bestDocument) === null || _b === void 0 ? void 0 : _b.box);
10280
10263
  if (focusPrediction) {
@@ -10505,8 +10488,6 @@
10505
10488
  idCardBackDetectionThresholdMet: false,
10506
10489
  passportDetectionScore: 0,
10507
10490
  passportDetectionThresholdMet: false,
10508
- singlePageDetectionScore: 0,
10509
- singlePageDetectionThresholdMet: false,
10510
10491
  focusScore: 0,
10511
10492
  focusThresholdMet: false,
10512
10493
  isGoodFrame: false,
@@ -10608,8 +10589,6 @@
10608
10589
  idCardBackDetectionThresholdMet = _d.idCardBackDetectionThresholdMet,
10609
10590
  passportDetectionScore = _d.passportDetectionScore,
10610
10591
  passportDetectionThresholdMet = _d.passportDetectionThresholdMet,
10611
- singlePageDetectionScore = _d.singlePageDetectionScore,
10612
- singlePageDetectionThresholdMet = _d.singlePageDetectionThresholdMet,
10613
10592
  bestDocument = _d.bestDocument,
10614
10593
  documentInBounds = _d.documentInBounds,
10615
10594
  documentTooClose = _d.documentTooClose,
@@ -10690,8 +10669,6 @@
10690
10669
  idCardBackDetectionThresholdMet: idCardBackDetectionThresholdMet,
10691
10670
  passportDetectionScore: passportDetectionScore,
10692
10671
  passportDetectionThresholdMet: passportDetectionThresholdMet,
10693
- singlePageDetectionScore: singlePageDetectionScore,
10694
- singlePageDetectionThresholdMet: singlePageDetectionThresholdMet,
10695
10672
  focusScore: focusScore,
10696
10673
  focusThresholdMet: focusThresholdMet,
10697
10674
  isGoodFrame: isGoodFrame,
@@ -14253,7 +14230,7 @@
14253
14230
  scaling: debugScalingDetails,
14254
14231
  flipX: !isRearFacing
14255
14232
  });
14256
- }))), 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")))));
14233
+ }))), 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")))));
14257
14234
  };
14258
14235
  var timeSince = function timeSince(t) {
14259
14236
  if (!t) return 0;
@@ -21115,26 +21092,21 @@
21115
21092
  }, [isRecording, isRecordingVideo, startRecordingVideo, videoUrl]);
21116
21093
  var animationFrame = React.useRef(0);
21117
21094
  React.useEffect(function () {
21118
- var _a;
21119
21095
  if (!signaturePad.current || !videoRef.current || !outputCanvas.current || !camera || !isRecording || !isRecordingVideo) return;
21120
- var _b = [camera.width, camera.height],
21121
- w = _b[0],
21122
- h = _b[1];
21123
- var isPortrait = typeof window !== 'undefined' && window.innerWidth < window.innerHeight;
21124
- var cameraIsLandscape = w > h;
21125
- if (isPortrait && cameraIsLandscape) _a = [h, w], w = _a[0], h = _a[1];
21126
- outputCanvas.current.width = w;
21127
- outputCanvas.current.height = h;
21128
21096
  var ctx = outputCanvas.current.getContext('2d');
21129
21097
  if (!ctx) return;
21130
21098
  animationFrame.current = requestAnimationFrame(function runFrame() {
21131
21099
  return __awaiter(this, void 0, void 0, function () {
21132
- var rect;
21133
- return __generator(this, function (_a) {
21100
+ var _a, w, h, isPortrait, rect;
21101
+ return __generator(this, function (_b) {
21134
21102
  if (!signaturePad.current || !videoRef.current || !outputCanvas.current) {
21135
21103
  cancelAnimationFrame(animationFrame.current);
21136
21104
  return [2 /*return*/];
21137
21105
  }
21106
+ _a = [videoRef.current.videoWidth, videoRef.current.videoHeight], w = _a[0], h = _a[1];
21107
+ isPortrait = w < h;
21108
+ outputCanvas.current.width = w;
21109
+ outputCanvas.current.height = h;
21138
21110
  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)];
21139
21111
  ctx.drawImage(videoRef.current, 0, 0, w, h);
21140
21112
  ctx.beginPath();