idmission-web-sdk 2.1.75 → 2.1.77

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
@@ -204,7 +204,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
204
204
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
205
205
  };
206
206
 
207
- var webSdkVersion = '2.1.75';
207
+ var webSdkVersion = '2.1.77';
208
208
 
209
209
  function getPlatform() {
210
210
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -8405,38 +8405,23 @@ function IdCardBorderSvg(_a) {
8405
8405
  _b = _a.borderOpacity,
8406
8406
  borderOpacity = _b === void 0 ? 1 : _b,
8407
8407
  _c = _a.progress,
8408
- progress = _c === void 0 ? 1 : _c,
8408
+ progress = _c === void 0 ? 0 : _c,
8409
8409
  _d = _a.progressPaused,
8410
8410
  progressPaused = _d === void 0 ? false : _d,
8411
8411
  _e = _a.isProgressBar,
8412
8412
  isProgressBar = _e === void 0 ? false : _e,
8413
8413
  props = __rest(_a, ["borderRadius", "borderColor", "borderWidth", "borderOpacity", "progress", "progressPaused", "isProgressBar"]);
8414
- var rectRef = useRef(null);
8415
8414
  var _f = useState(0),
8416
8415
  totalLength = _f[0],
8417
8416
  setTotalLength = _f[1];
8418
8417
  var resolvedProgress = progress * totalLength;
8419
- useLayoutEffect(function () {
8420
- if (totalLength > 0) return;
8421
- var interval;
8422
- var measuredLength = 0;
8423
- function measureTotalLength() {
8424
- var _a, _b;
8425
- try {
8426
- measuredLength = (_b = (_a = rectRef.current) === null || _a === void 0 ? void 0 : _a.getTotalLength()) !== null && _b !== void 0 ? _b : 0;
8427
- if (measuredLength === 0) return;
8428
- setTotalLength(measuredLength);
8429
- if (interval) clearInterval(interval);
8430
- } catch (e) {
8431
- warn('failed to measure SVG length', e);
8432
- }
8418
+ var rectRef = function rectRef(r) {
8419
+ try {
8420
+ if (isProgressBar && r) setTotalLength(r.getTotalLength());
8421
+ } catch (e) {
8422
+ debug('failed to measure SVG length', e);
8433
8423
  }
8434
- measureTotalLength();
8435
- if (measuredLength === 0) interval = setInterval(measureTotalLength, 250);
8436
- return function () {
8437
- if (interval) clearInterval(interval);
8438
- };
8439
- }, [totalLength]);
8424
+ };
8440
8425
  return /*#__PURE__*/React__default.createElement(SvgOverlay, _assign({
8441
8426
  height: "100%",
8442
8427
  fill: "none",
@@ -8469,7 +8454,7 @@ function IdCardBorderSvg(_a) {
8469
8454
  }
8470
8455
  var IdCardBorderContainer = styled.div(templateObject_3$j || (templateObject_3$j = __makeTemplateObject(["\n & > .pulse {\n position: absolute;\n animation: glow-grow 2s ease-out infinite;\n\n &:nth-child(2) {\n animation-delay: 0.66s;\n }\n\n &:nth-child(3) {\n animation-delay: 1.33s;\n }\n }\n\n @keyframes glow-grow {\n 0% {\n opacity: 0;\n transform: scale(1);\n }\n 50% {\n opacity: 1;\n }\n 100% {\n transform: scale(2);\n opacity: 0;\n }\n }\n"], ["\n & > .pulse {\n position: absolute;\n animation: glow-grow 2s ease-out infinite;\n\n &:nth-child(2) {\n animation-delay: 0.66s;\n }\n\n &:nth-child(3) {\n animation-delay: 1.33s;\n }\n }\n\n @keyframes glow-grow {\n 0% {\n opacity: 0;\n transform: scale(1);\n }\n 50% {\n opacity: 1;\n }\n 100% {\n transform: scale(2);\n opacity: 0;\n }\n }\n"])));
8471
8456
  var SvgOverlay = styled.svg(templateObject_4$d || (templateObject_4$d = __makeTemplateObject(["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n"], ["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n"])));
8472
- var IdCardBorderRect = styled.rect(templateObject_5$8 || (templateObject_5$8 = __makeTemplateObject(["\n &.progress {\n width: 100%;\n height: 100%;\n animation: dash ", "\n ", ";\n }\n\n &.paused {\n animation-play-state: paused;\n }\n\n @keyframes dash {\n to {\n stroke-dashoffset: 0;\n }\n }\n"], ["\n &.progress {\n width: 100%;\n height: 100%;\n animation: dash ", "\n ", ";\n }\n\n &.paused {\n animation-play-state: paused;\n }\n\n @keyframes dash {\n to {\n stroke-dashoffset: 0;\n }\n }\n"])), function (props) {
8457
+ var IdCardBorderRect = styled.rect(templateObject_5$8 || (templateObject_5$8 = __makeTemplateObject(["\n &.progress {\n animation: dash ", "\n ", ";\n }\n\n &.paused {\n animation-play-state: paused;\n }\n\n @keyframes dash {\n to {\n stroke-dashoffset: 0;\n }\n }\n"], ["\n &.progress {\n animation: dash ", "\n ", ";\n }\n\n &.paused {\n animation-play-state: paused;\n }\n\n @keyframes dash {\n to {\n stroke-dashoffset: 0;\n }\n }\n"])), function (props) {
8473
8458
  var _a;
8474
8459
  return (_a = props.$speed) !== null && _a !== void 0 ? _a : '3s';
8475
8460
  }, function (props) {
@@ -13696,14 +13681,13 @@ var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
13696
13681
  idCardGuideStatus = _1 === void 0 ? 'ready' : _1,
13697
13682
  idCardGuideBorderWidth = _a.idCardGuideBorderWidth,
13698
13683
  idCardGuideBorderColor = _a.idCardGuideBorderColor,
13699
- _2 = _a.idCardCaptureProgress,
13700
- idCardCaptureProgress = _2 === void 0 ? 0 : _2,
13701
- _3 = _a.idCardCaptureGuideImages,
13702
- userSuppliedImages = _3 === void 0 ? defaultIdCaptureGuideImages : _3,
13703
- _4 = _a.classNames,
13704
- classNames = _4 === void 0 ? {} : _4,
13705
- _5 = _a.verbiage,
13706
- rawVerbiage = _5 === void 0 ? {} : _5;
13684
+ idCardCaptureProgress = _a.idCardCaptureProgress,
13685
+ _2 = _a.idCardCaptureGuideImages,
13686
+ userSuppliedImages = _2 === void 0 ? defaultIdCaptureGuideImages : _2,
13687
+ _3 = _a.classNames,
13688
+ classNames = _3 === void 0 ? {} : _3,
13689
+ _4 = _a.verbiage,
13690
+ rawVerbiage = _4 === void 0 ? {} : _4;
13707
13691
  var cameraRef = useContext(CameraStateContext).cameraRef;
13708
13692
  var verbiage = useTranslations(rawVerbiage, {
13709
13693
  idFrontInstructionText: 'Display the front of your ID card...',
@@ -13717,17 +13701,17 @@ var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
13717
13701
  if (faceGuideBorderColor === undefined) faceGuideBorderColor = (_j = satisfied ? (_f = (_e = theme.idVideoCapture) === null || _e === void 0 ? void 0 : _e.faceGuides) === null || _f === void 0 ? void 0 : _f.satisfiedColor : (_h = (_g = theme.idVideoCapture) === null || _g === void 0 ? void 0 : _g.faceGuides) === null || _h === void 0 ? void 0 : _h.unsatisfiedColor) !== null && _j !== void 0 ? _j : '#D6DCE7';
13718
13702
  if (idCardGuideBorderWidth === undefined) idCardGuideBorderWidth = (_m = (_l = (_k = theme.idVideoCapture) === null || _k === void 0 ? void 0 : _k.idCardGuides) === null || _l === void 0 ? void 0 : _l.borderWidth) !== null && _m !== void 0 ? _m : 20;
13719
13703
  if (idCardGuideBorderColor === undefined) idCardGuideBorderColor = (_s = satisfied ? (_p = (_o = theme.idVideoCapture) === null || _o === void 0 ? void 0 : _o.idCardGuides) === null || _p === void 0 ? void 0 : _p.satisfiedColor : (_r = (_q = theme.idVideoCapture) === null || _q === void 0 ? void 0 : _q.idCardGuides) === null || _r === void 0 ? void 0 : _r.unsatisfiedColor) !== null && _s !== void 0 ? _s : '#D6DCE7';
13720
- var _6 = useResizeObserver(),
13721
- idCardGuideRef = _6.ref,
13722
- _7 = _6.width,
13723
- idCardGuideWidth = _7 === void 0 ? 0 : _7,
13724
- _8 = _6.height,
13725
- idCardGuideHeight = _8 === void 0 ? 0 : _8;
13704
+ var _5 = useResizeObserver(),
13705
+ idCardGuideRef = _5.ref,
13706
+ _6 = _5.width,
13707
+ idCardGuideWidth = _6 === void 0 ? 0 : _6,
13708
+ _7 = _5.height,
13709
+ idCardGuideHeight = _7 === void 0 ? 0 : _7;
13726
13710
  var idCaptureGuideImages = useGuideImages(userSuppliedImages);
13727
13711
  var idCaptureGuideImagesByUrl = useGuideImagesByUrl(idCaptureGuideImages);
13728
- var _9 = useState(undefined),
13729
- aspectRatio = _9[0],
13730
- setAspectRatio = _9[1];
13712
+ var _8 = useState(undefined),
13713
+ aspectRatio = _8[0],
13714
+ setAspectRatio = _8[1];
13731
13715
  var onImageLoaded = useCallback(function (e) {
13732
13716
  var _a, _b, _c, _d;
13733
13717
  var img = e.currentTarget;
@@ -13769,7 +13753,7 @@ var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
13769
13753
  borderColor: idCardGuideBorderColor,
13770
13754
  aspectRatio: aspectRatio,
13771
13755
  "$isVisible": requestedAction !== 'FLIP_ID',
13772
- progress: requestedAction === 'VERIFY_LIVENESS' ? 0 : idCardCaptureProgress
13756
+ progress: requestedAction === 'VERIFY_LIVENESS' ? undefined : idCardCaptureProgress
13773
13757
  }, /*#__PURE__*/React__default.createElement(IdCardGuideImage, {
13774
13758
  alt: "",
13775
13759
  className: classNames.idCardGuideImage,
@@ -13909,7 +13893,7 @@ var edgeBoundary = 0.05;
13909
13893
  var defaultVideoIdCaptureThresholds = {
13910
13894
  detection: {
13911
13895
  idCardFront: 0.4,
13912
- idCardBack: 0.4,
13896
+ idCardBack: 0.5,
13913
13897
  passport: 1
13914
13898
  },
13915
13899
  focus: {
@@ -13929,7 +13913,8 @@ var defaultVideoIdCaptureThresholds = {
13929
13913
  goodFrames: {
13930
13914
  idCardFront: 1,
13931
13915
  idCardBack: 1
13932
- }
13916
+ },
13917
+ flipShortcutThreshold: 0.7
13933
13918
  };
13934
13919
  var IdVideoCapture = function IdVideoCapture(_a) {
13935
13920
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
@@ -14085,14 +14070,15 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14085
14070
  setCurrentFocusScore(prediction.focusScore);
14086
14071
  var detectionThresholdMet = requestedAction === 'SHOW_ID_FRONT' ? prediction.idCardFrontDetectionThresholdMet : prediction.idCardBackDetectionThresholdMet;
14087
14072
  var isGoodFrame = detectionThresholdMet && prediction.focusThresholdMet;
14088
- if (requestedAction === 'FLIP_ID' && isGoodFrame) {
14073
+ var shouldShortcutFlipAnimation = requestedAction === 'FLIP_ID' && isGoodFrame && prediction.idCardBackDetectionScore >= videoIdCaptureThresholds.flipShortcutThreshold;
14074
+ if (shouldShortcutFlipAnimation) {
14089
14075
  return setRequestedAction('SHOW_ID_BACK');
14090
14076
  }
14091
14077
  setGoodFramesCount(isGoodFrame ? function (n) {
14092
14078
  return n + 1;
14093
14079
  } : 0);
14094
14080
  });
14095
- }, [idCaptureModelsEnabled, onIdPredictionMade, idModelError, requestedAction]);
14081
+ }, [idCaptureModelsEnabled, onIdPredictionMade, idModelError, requestedAction, videoIdCaptureThresholds.flipShortcutThreshold]);
14096
14082
  var _29 = useState(null),
14097
14083
  idFrontCaptureStartedAt = _29[0],
14098
14084
  setFirstGoodFrameTime = _29[1];
@@ -14294,7 +14280,7 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14294
14280
  requestedAction: requestedAction,
14295
14281
  satisfied: satisfied,
14296
14282
  idCardGuideStatus: countdownStartedAt ? 'capturing' : 'ready',
14297
- idCardCaptureProgress: countdownStartedAt ? 1 : 0,
14283
+ idCardCaptureProgress: !!countdownStartedAt ? 1 : 0,
14298
14284
  idCardCaptureGuideImages: idCardCaptureGuideImages,
14299
14285
  faceGuideBorderColor: satisfied ? colors.guidesSatisfiedColor : colors.guidesUnsatisfiedColor,
14300
14286
  idCardGuideBorderColor: satisfied ? colors.guidesSatisfiedColor : colors.guidesUnsatisfiedColor