idmission-web-sdk 2.3.32 → 2.3.33

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.3.32';
207
+ var webSdkVersion = '2.3.33';
208
208
 
209
209
  function getPlatform() {
210
210
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -7916,12 +7916,10 @@ function resetCanvasDimensions(canvas) {
7916
7916
  canvas.style.height = '0';
7917
7917
  }
7918
7918
 
7919
- var IdCardGuideImageContainer = styled(IdCardBorder)(templateObject_1$A || (templateObject_1$A = __makeTemplateObject(["\n position: relative;\n ", "\n box-sizing: border-box;\n aspect-ratio: ", ";\n display: flex;\n"], ["\n position: relative;\n ", "\n box-sizing: border-box;\n aspect-ratio: ", ";\n display: flex;\n"])), function (props) {
7919
+ var IdCardGuideImageContainer = styled(IdCardBorder)(templateObject_1$A || (templateObject_1$A = __makeTemplateObject(["\n position: relative;\n ", "\n box-sizing: border-box;\n"], ["\n position: relative;\n ", "\n box-sizing: border-box;\n"])), function (props) {
7920
7920
  return props.$isVisible ? '' : 'opacity: 0;';
7921
- }, function (props) {
7922
- return props.$aspectRatio;
7923
7921
  });
7924
- var IdCardGuideImage = styled.img(templateObject_2$t || (templateObject_2$t = __makeTemplateObject(["\n transform-style: preserve-3d;\n ", "\n ", "\n max-width: 100%;\n max-height: 100%;\n"], ["\n transform-style: preserve-3d;\n ", "\n ", "\n max-width: 100%;\n max-height: 100%;\n"])), function (props) {
7922
+ var IdCardGuideImage = styled.img(templateObject_2$t || (templateObject_2$t = __makeTemplateObject(["\n max-height: 100%;\n transform-style: preserve-3d;\n ", "\n ", "\n"], ["\n max-height: 100%;\n transform-style: preserve-3d;\n ", "\n ", "\n"])), function (props) {
7925
7923
  return props.$isMirrored ? 'transform: scaleX(-1);' : '';
7926
7924
  }, function (props) {
7927
7925
  return props.$isInvisible ? 'opacity: 0;' : '';
@@ -7937,19 +7935,20 @@ function IdCardBorder(_a) {
7937
7935
  borderRadius = _u === void 0 ? 25 : _u,
7938
7936
  _v = _a.borderColor,
7939
7937
  borderColor = _v === void 0 ? 'white' : _v,
7940
- aspectRatio = _a.aspectRatio,
7941
- _w = _a.progress,
7942
- progress = _w === void 0 ? 0 : _w,
7938
+ _w = _a.aspectRatio,
7939
+ aspectRatio = _w === void 0 ? 1 : _w,
7940
+ _x = _a.progress,
7941
+ progress = _x === void 0 ? 0 : _x,
7943
7942
  props = __rest(_a, ["children", "status", "borderWidth", "borderRadius", "borderColor", "aspectRatio", "progress"]);
7944
- var _x = useResizeObserver(),
7945
- ref = _x.ref,
7946
- _y = _x.width,
7947
- width = _y === void 0 ? 0 : _y,
7948
- _z = _x.height,
7949
- height = _z === void 0 ? 0 : _z;
7950
- var _0 = useState(0),
7951
- progressResets = _0[0],
7952
- setProgressResets = _0[1];
7943
+ var _y = useResizeObserver(),
7944
+ ref = _y.ref,
7945
+ _z = _y.width,
7946
+ width = _z === void 0 ? 0 : _z,
7947
+ _0 = _y.height,
7948
+ height = _0 === void 0 ? 0 : _0;
7949
+ var _1 = useState(0),
7950
+ progressResets = _1[0],
7951
+ setProgressResets = _1[1];
7953
7952
  useEffect(function () {
7954
7953
  if (progress === 0 && status === 'capturing') {
7955
7954
  setProgressResets(function (n) {
@@ -7966,8 +7965,10 @@ function IdCardBorder(_a) {
7966
7965
  return /*#__PURE__*/React__default.createElement(IdCardBorderContainer, _assign({}, props), /*#__PURE__*/React__default.createElement("div", {
7967
7966
  ref: ref,
7968
7967
  style: {
7969
- aspectRatio: aspectRatio,
7970
- flex: 1
7968
+ maxHeight: '100%',
7969
+ maxWidth: '100%',
7970
+ display: 'flex',
7971
+ aspectRatio: aspectRatio
7971
7972
  }
7972
7973
  }, children), status === 'ready' && !wavesDisabled && ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(IdCardBorderSvg, {
7973
7974
  width: width,
@@ -8066,7 +8067,7 @@ function IdCardBorderSvg(_a) {
8066
8067
  className: isProgressBar ? "idmSdkProgressBorder ".concat(progressPaused ? 'idmSdkProgressPaused' : '') : ''
8067
8068
  }));
8068
8069
  }
8069
- var IdCardBorderContainer = styled.div(templateObject_3$k || (templateObject_3$k = __makeTemplateObject(["\n & > .idmSdkWaves {\n position: absolute;\n animation: ", " 2s ease-out infinite;\n transform-style: preserve-3d;\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 & > .idmSdkWaves {\n position: absolute;\n animation: ", " 2s ease-out infinite;\n transform-style: preserve-3d;\n\n &:nth-child(2) {\n animation-delay: 0.66s;\n }\n\n &:nth-child(3) {\n animation-delay: 1.33s;\n }\n }\n"])), wavesAnimation);
8070
+ var IdCardBorderContainer = styled.div(templateObject_3$k || (templateObject_3$k = __makeTemplateObject(["\n max-width: 100%;\n & > .idmSdkWaves {\n position: absolute;\n animation: ", " 2s ease-out infinite;\n transform-style: preserve-3d;\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 max-width: 100%;\n & > .idmSdkWaves {\n position: absolute;\n animation: ", " 2s ease-out infinite;\n transform-style: preserve-3d;\n\n &:nth-child(2) {\n animation-delay: 0.66s;\n }\n\n &:nth-child(3) {\n animation-delay: 1.33s;\n }\n }\n"])), wavesAnimation);
8070
8071
  var SvgOverlay = styled.svg(templateObject_4$e || (templateObject_4$e = __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"])));
8071
8072
  var IdCardBorderRect = styled.rect(templateObject_5$a || (templateObject_5$a = __makeTemplateObject(["\n &.idmSdkProgressBorder {\n animation: ", " ", "\n ", ";\n }\n\n &.idmSdkProgressPaused {\n animation-play-state: paused;\n }\n"], ["\n &.idmSdkProgressBorder {\n animation: ", " ", "\n ", ";\n }\n\n &.idmSdkProgressPaused {\n animation-play-state: paused;\n }\n"])), progressBorderAnimation, function (props) {
8072
8073
  var _a;
@@ -8398,46 +8399,58 @@ var FlipIdPrompt = function FlipIdPrompt(_a) {
8398
8399
  };
8399
8400
 
8400
8401
  var IdCaptureGuideOverlay = function IdCaptureGuideOverlay(_a) {
8401
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
8402
- var _p = _a.classNames,
8403
- classNames = _p === void 0 ? {} : _p,
8404
- _q = _a.images,
8405
- userSuppliedImages = _q === void 0 ? defaultIdCaptureGuideImages : _q,
8402
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
8403
+ var _u = _a.classNames,
8404
+ classNames = _u === void 0 ? {} : _u,
8405
+ _v = _a.images,
8406
+ userSuppliedImages = _v === void 0 ? defaultIdCaptureGuideImages : _v,
8406
8407
  userSuppliedPadding = _a.padding,
8407
8408
  userSuppliedImagePadding = _a.imagePadding,
8408
- _r = _a.imageVisible,
8409
- imageVisible = _r === void 0 ? true : _r,
8409
+ _w = _a.imageVisible,
8410
+ imageVisible = _w === void 0 ? true : _w,
8410
8411
  borderWidth = _a.borderWidth,
8411
8412
  borderColor = _a.borderColor,
8412
- _s = _a.idCardBorderWidth,
8413
- idCardBorderWidth = _s === void 0 ? '2.5%' : _s,
8414
- _t = _a.idCardBorderColor,
8415
- idCardBorderColor = _t === void 0 ? 'white' : _t,
8413
+ _x = _a.idCardBorderWidth,
8414
+ idCardBorderWidth = _x === void 0 ? '2.5%' : _x,
8415
+ _y = _a.idCardBorderColor,
8416
+ idCardBorderColor = _y === void 0 ? 'white' : _y,
8416
8417
  maskColor = _a.maskColor,
8417
- _u = _a.isMirrored,
8418
- isMirrored = _u === void 0 ? false : _u,
8419
- _v = _a.isBackToFront,
8420
- isBackToFront = _v === void 0 ? false : _v,
8421
- _w = _a.portraitGuidesOnMobile,
8422
- portraitGuidesOnMobile = _w === void 0 ? true : _w,
8423
- _x = _a.instruction,
8424
- instruction = _x === void 0 ? '' : _x,
8425
- _y = _a.requestedAction,
8426
- requestedAction = _y === void 0 ? 'SHOW_ID_FRONT' : _y,
8427
- _z = _a.progress,
8428
- progress = _z === void 0 ? 0 : _z,
8429
- _0 = _a.status,
8430
- status = _0 === void 0 ? 'ready' : _0,
8418
+ _z = _a.isMirrored,
8419
+ isMirrored = _z === void 0 ? false : _z,
8420
+ _0 = _a.isBackToFront,
8421
+ isBackToFront = _0 === void 0 ? false : _0,
8422
+ _1 = _a.portraitGuidesOnMobile,
8423
+ portraitGuidesOnMobile = _1 === void 0 ? true : _1,
8424
+ _2 = _a.instruction,
8425
+ instruction = _2 === void 0 ? '' : _2,
8426
+ _3 = _a.requestedAction,
8427
+ requestedAction = _3 === void 0 ? 'SHOW_ID_FRONT' : _3,
8428
+ _4 = _a.progress,
8429
+ progress = _4 === void 0 ? 0 : _4,
8430
+ _5 = _a.status,
8431
+ status = _5 === void 0 ? 'ready' : _5,
8431
8432
  onClick = _a.onClick;
8432
- var _1 = useGuideOrientationContext(),
8433
- wrapperRef = _1.wrapperRef,
8434
- wrapperWidth = _1.wrapperWidth,
8435
- wrapperHeight = _1.wrapperHeight,
8436
- imageAspectRatio = _1.imageAspectRatio,
8437
- wrapperAspectRatio = _1.wrapperAspectRatio,
8438
- guideOrientationOnImageLoaded = _1.onImageLoaded,
8439
- setDimensions = _1.setDimensions;
8440
- var state = useIdCaptureStore();
8433
+ var _6 = useGuideOrientationContext(),
8434
+ wrapperRef = _6.wrapperRef,
8435
+ wrapperWidth = _6.wrapperWidth,
8436
+ wrapperHeight = _6.wrapperHeight,
8437
+ imageAspectRatio = _6.imageAspectRatio,
8438
+ wrapperAspectRatio = _6.wrapperAspectRatio,
8439
+ guideOrientationOnImageLoaded = _6.onImageLoaded,
8440
+ setDimensions = _6.setDimensions;
8441
+ var containerRef = useRef(null);
8442
+ var _7 = useState({
8443
+ width: 0,
8444
+ height: 0
8445
+ }),
8446
+ imageDimensions = _7[0],
8447
+ setImageDimensions = _7[1];
8448
+ var _8 = useState({
8449
+ width: 0,
8450
+ height: 0
8451
+ }),
8452
+ containerDimensions = _8[0],
8453
+ setContainerDimensions = _8[1];
8441
8454
  var theme = useTheme();
8442
8455
  if (borderWidth === undefined) borderWidth = (_d = (_c = (_b = theme.idCapture) === null || _b === void 0 ? void 0 : _b.guideBox) === null || _c === void 0 ? void 0 : _c.borderWidth) !== null && _d !== void 0 ? _d : 4;
8443
8456
  useEffect(function () {
@@ -8449,34 +8462,32 @@ var IdCaptureGuideOverlay = function IdCaptureGuideOverlay(_a) {
8449
8462
  var padding = userSuppliedPadding !== null && userSuppliedPadding !== void 0 ? userSuppliedPadding : isMobile() ? (_g = (_f = (_e = theme.idCapture) === null || _e === void 0 ? void 0 : _e.guideBox) === null || _f === void 0 ? void 0 : _f.mobilePadding) !== null && _g !== void 0 ? _g : 0 : (_k = (_j = (_h = theme.idCapture) === null || _h === void 0 ? void 0 : _h.guideBox) === null || _j === void 0 ? void 0 : _j.desktopPadding) !== null && _k !== void 0 ? _k : 50;
8450
8463
  var paddingAndBorderPx = padding * 2 + (borderWidth !== null && borderWidth !== void 0 ? borderWidth : 0) * 2;
8451
8464
  var images = useImagesWithBackToFront(userSuppliedImages, isBackToFront);
8452
- var imagesByUrl = useGuideImagesByUrl(images);
8453
8465
  var orientation = getOrientation(portraitGuidesOnMobile);
8454
8466
  var currentImage = images[orientation][requestedAction === 'FLIP_ID' ? 'SHOW_ID_FRONT' : requestedAction];
8455
- var imagePadding = (_o = userSuppliedImagePadding !== null && userSuppliedImagePadding !== void 0 ? userSuppliedImagePadding : (_m = (_l = theme.idCapture) === null || _l === void 0 ? void 0 : _l.guideBox) === null || _m === void 0 ? void 0 : _m.imagePadding) !== null && _o !== void 0 ? _o : '0 50px';
8456
- if (typeof imagePadding === 'number') {
8457
- imagePadding = "".concat(imagePadding, "px");
8458
- }
8459
- var paddingForMath = imagePadding.replace(/[^0-9\s]/g, '').split(' ').map(Number);
8460
- var paddingForMathMax = Math.max.apply(Math, paddingForMath);
8461
- var imageWidth = state.guideRectWidth - paddingForMathMax * 2;
8462
- var imageHeight = state.guideRectHeight - paddingForMathMax * 2;
8467
+ var imagePadding = userSuppliedImagePadding !== null && userSuppliedImagePadding !== void 0 ? userSuppliedImagePadding : isMobile() ? (_o = (_m = (_l = theme.idCapture) === null || _l === void 0 ? void 0 : _l.guideBox) === null || _m === void 0 ? void 0 : _m.mobileImagePadding) !== null && _o !== void 0 ? _o : 0 : (_r = (_q = (_p = theme.idCapture) === null || _p === void 0 ? void 0 : _p.guideBox) === null || _q === void 0 ? void 0 : _q.imagePadding) !== null && _r !== void 0 ? _r : 50;
8463
8468
  var centerRegionMinWidth = imageAspectRatio >= wrapperAspectRatio ? wrapperWidth - paddingAndBorderPx : undefined;
8464
- var cardAspectRatio = imageAspectRatio > 1 ? '1.6' : '0.625';
8465
8469
  var onImageLoaded = useCallback(function (e) {
8466
- var _a, _b;
8467
8470
  guideOrientationOnImageLoaded(e);
8468
- var img = e.currentTarget;
8469
- var imageByUrl = imagesByUrl[img.src];
8470
- var width = (_a = imageByUrl === null || imageByUrl === void 0 ? void 0 : imageByUrl.width) !== null && _a !== void 0 ? _a : img.naturalWidth;
8471
- var height = (_b = imageByUrl === null || imageByUrl === void 0 ? void 0 : imageByUrl.height) !== null && _b !== void 0 ? _b : img.naturalHeight;
8472
- dispatchIdCaptureAction({
8473
- type: 'guideImageLoaded',
8474
- payload: {
8475
- width: width,
8476
- height: height
8477
- }
8471
+ setImageDimensions({
8472
+ width: (currentImage === null || currentImage === void 0 ? void 0 : currentImage.width) || imageDimensions.width,
8473
+ height: (currentImage === null || currentImage === void 0 ? void 0 : currentImage.height) || imageDimensions.height
8478
8474
  });
8479
- }, [guideOrientationOnImageLoaded, imagesByUrl]);
8475
+ }, [guideOrientationOnImageLoaded, currentImage, imageDimensions.height, imageDimensions.width]);
8476
+ useEffect(function () {
8477
+ if (containerRef.current && containerRef.current.clientWidth && containerRef.current.clientHeight) {
8478
+ setContainerDimensions({
8479
+ width: containerRef.current.clientWidth,
8480
+ height: containerRef.current.clientHeight
8481
+ });
8482
+ dispatchIdCaptureAction({
8483
+ type: 'guideImageLoaded',
8484
+ payload: {
8485
+ width: imageDimensions.width,
8486
+ height: imageDimensions.height
8487
+ }
8488
+ });
8489
+ }
8490
+ }, [setDimensions, setContainerDimensions, imageDimensions.height, imageDimensions.width]);
8480
8491
  return /*#__PURE__*/React__default.createElement(StyledPageContainer, {
8481
8492
  ref: wrapperRef,
8482
8493
  onClick: onClick,
@@ -8505,14 +8516,19 @@ var IdCaptureGuideOverlay = function IdCaptureGuideOverlay(_a) {
8505
8516
  "$padding": imagePadding,
8506
8517
  className: classNames.centerRegionBorder
8507
8518
  }, /*#__PURE__*/React__default.createElement(GuideCenterInner, {
8508
- className: classNames.centerRegionInner
8519
+ "$isLandscape": orientation === 'landscape',
8520
+ ref: containerRef,
8521
+ className: classNames.centerRegionInner,
8522
+ style: {
8523
+ aspectRatio: imageDimensions.width && imageDimensions.height ? imageDimensions.width / imageDimensions.height : 1
8524
+ }
8509
8525
  }, /*#__PURE__*/React__default.createElement(IdCardGuideImageContainer, {
8510
8526
  status: status,
8511
8527
  progress: progress,
8512
8528
  borderWidth: idCardBorderWidth,
8513
8529
  borderColor: idCardBorderColor,
8514
8530
  "$isVisible": requestedAction !== 'FLIP_ID',
8515
- "$aspectRatio": cardAspectRatio
8531
+ aspectRatio: imageDimensions.width && imageDimensions.height ? imageDimensions.width / imageDimensions.height : 1
8516
8532
  }, /*#__PURE__*/React__default.createElement(IdCardGuideImage, {
8517
8533
  alt: "",
8518
8534
  src: currentImage.url,
@@ -8520,8 +8536,8 @@ var IdCaptureGuideOverlay = function IdCaptureGuideOverlay(_a) {
8520
8536
  className: classNames.image,
8521
8537
  "$isInvisible": !imageVisible,
8522
8538
  "$isMirrored": isMirrored,
8523
- width: imageWidth,
8524
- height: imageHeight
8539
+ width: containerDimensions.width ? containerDimensions.width : imageDimensions.width,
8540
+ height: containerDimensions.height ? containerDimensions.height : imageDimensions.height
8525
8541
  })), requestedAction === 'FLIP_ID' && ( /*#__PURE__*/React__default.createElement(FlipIdPrompt, {
8526
8542
  images: images,
8527
8543
  borderWidth: idCardBorderWidth,
@@ -8529,8 +8545,8 @@ var IdCaptureGuideOverlay = function IdCaptureGuideOverlay(_a) {
8529
8545
  portraitGuidesOnMobile: portraitGuidesOnMobile,
8530
8546
  isMirrored: isMirrored,
8531
8547
  classNames: classNames.flipIdPrompt,
8532
- width: imageWidth,
8533
- height: imageHeight
8548
+ width: (_s = currentImage === null || currentImage === void 0 ? void 0 : currentImage.width) !== null && _s !== void 0 ? _s : imageDimensions.width,
8549
+ height: (_t = currentImage === null || currentImage === void 0 ? void 0 : currentImage.width) !== null && _t !== void 0 ? _t : imageDimensions.height
8534
8550
  }))))), /*#__PURE__*/React__default.createElement(Spacer, {
8535
8551
  "$maskColor": maskColor,
8536
8552
  "$minWidth": padding,
@@ -8574,10 +8590,12 @@ var GuideCenterBorder = styled.div(templateObject_7$4 || (templateObject_7$4 = _
8574
8590
  var _a, _b;
8575
8591
  return "".concat((_a = props.$borderWidth) !== null && _a !== void 0 ? _a : 4, "px solid ").concat((_b = props.$borderColor) !== null && _b !== void 0 ? _b : 'white');
8576
8592
  }, function (props) {
8577
- return props.$padding ? "padding: ".concat(props.$padding, ";") : '';
8593
+ return props.$padding ? "padding: ".concat(props.$padding, "px;") : '';
8578
8594
  });
8579
8595
  var GuideText = styled.span(templateObject_8$2 || (templateObject_8$2 = __makeTemplateObject(["\n align-content: center;\n margin-top: 12px;\n margin-bottom: 12px;\n"], ["\n align-content: center;\n margin-top: 12px;\n margin-bottom: 12px;\n"])));
8580
- var GuideCenterInner = styled.div(templateObject_9$2 || (templateObject_9$2 = __makeTemplateObject(["\n position: relative;\n margin: auto;\n"], ["\n position: relative;\n margin: auto;\n"])));
8596
+ var GuideCenterInner = styled.div(templateObject_9$2 || (templateObject_9$2 = __makeTemplateObject(["\n position: relative;\n margin: auto;\n ", "\n max-height: 100%;\n max-width: 100%;\n display: flex;\n"], ["\n position: relative;\n margin: auto;\n ", "\n max-height: 100%;\n max-width: 100%;\n display: flex;\n"])), function (props) {
8597
+ return props.$isLandscape ? 'height: 100%;' : 'width: 90%;';
8598
+ });
8581
8599
  var templateObject_1$y, templateObject_2$s, templateObject_3$j, templateObject_4$d, templateObject_5$9, templateObject_6$6, templateObject_7$4, templateObject_8$2, templateObject_9$2;
8582
8600
 
8583
8601
  var IdCaptureFitGuide = function IdCaptureFitGuide(_a) {
@@ -15710,7 +15728,8 @@ var defaultTheme = {
15710
15728
  borderWidth: 4,
15711
15729
  desktopPadding: 50,
15712
15730
  mobilePadding: 0,
15713
- imagePadding: '0 50px',
15731
+ imagePadding: 50,
15732
+ mobileImagePadding: 0,
15714
15733
  wavesDisabled: false,
15715
15734
  wavesColor: '#287ec6',
15716
15735
  progressBarColor: 'white',