@veripass/react-sdk 1.0.21 → 1.0.23

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.
@@ -30,9 +30,6 @@ function _arrayLikeToArray(r, a) {
30
30
  function _arrayWithHoles(r) {
31
31
  if (Array.isArray(r)) return r;
32
32
  }
33
- function _arrayWithoutHoles(r) {
34
- if (Array.isArray(r)) return _arrayLikeToArray(r);
35
- }
36
33
  function _assertThisInitialized$1(e) {
37
34
  if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
38
35
  return e;
@@ -121,9 +118,6 @@ function _isNativeReflectConstruct() {
121
118
  return !!t;
122
119
  })();
123
120
  }
124
- function _iterableToArray(r) {
125
- if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
126
- }
127
121
  function _iterableToArrayLimit(r, l) {
128
122
  var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
129
123
  if (null != t) {
@@ -154,9 +148,6 @@ function _iterableToArrayLimit(r, l) {
154
148
  function _nonIterableRest() {
155
149
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
156
150
  }
157
- function _nonIterableSpread() {
158
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
159
- }
160
151
  function ownKeys(e, r) {
161
152
  var t = Object.keys(e);
162
153
  if (Object.getOwnPropertySymbols) {
@@ -503,9 +494,6 @@ function _taggedTemplateLiteral(e, t) {
503
494
  }
504
495
  }));
505
496
  }
506
- function _toConsumableArray(r) {
507
- return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
508
- }
509
497
  function _toPrimitive(t, r) {
510
498
  if ("object" != typeof t || !t) return t;
511
499
  var e = t[Symbol.toPrimitive];
@@ -579,17 +567,12 @@ var AuthContext = /*#__PURE__*/React.createContext();
579
567
  * @returns {JSX.Element} The provider component for AuthContext.
580
568
  */
581
569
  var AuthProvider = function AuthProvider(_ref) {
582
- var children = _ref.children,
583
- _ref$publicUrls = _ref.publicUrls,
584
- publicUrls = _ref$publicUrls === void 0 ? [] : _ref$publicUrls;
585
- var _useState = React.useState(defaultPublicUrlList),
570
+ var children = _ref.children;
571
+ var publicUrlsList = defaultPublicUrlList;
572
+ var _useState = React.useState(false),
586
573
  _useState2 = _slicedToArray(_useState, 2),
587
- publicUrlsList = _useState2[0],
588
- setPublicUrlsList = _useState2[1];
589
- var _useState3 = React.useState(false),
590
- _useState4 = _slicedToArray(_useState3, 2),
591
- isInitialized = _useState4[0],
592
- setIsInitialized = _useState4[1];
574
+ isInitialized = _useState2[0],
575
+ setIsInitialized = _useState2[1];
593
576
 
594
577
  // State to manage user data, persisted in local storage
595
578
  var _useLocalStorage = useLocalStorage('veripass-user-data', null),
@@ -597,13 +580,12 @@ var AuthProvider = function AuthProvider(_ref) {
597
580
  user = _useLocalStorage2[0],
598
581
  setUser = _useLocalStorage2[1];
599
582
  React.useEffect(function () {
600
- var publicPaths = new Set(defaultPublicUrlList);
601
583
  var extractPublicPaths = function extractPublicPaths(child) {
602
584
  var parentPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
603
585
  if (/*#__PURE__*/React.isValidElement(child)) {
604
586
  var currentPath = "".concat(parentPath).concat(child.props.path ? "/".concat(child.props.path) : '').replace(/\/+/g, '/');
605
- if (child.props.isPublic) {
606
- publicPaths.add(currentPath);
587
+ if (child.props.isPublic && !publicUrlsList.includes(currentPath)) {
588
+ publicUrlsList.push(currentPath);
607
589
  }
608
590
  if (child.props.children) {
609
591
  React.Children.forEach(child.props.children, function (grandchild) {
@@ -615,7 +597,6 @@ var AuthProvider = function AuthProvider(_ref) {
615
597
  React.Children.forEach(children, function (child) {
616
598
  return extractPublicPaths(child);
617
599
  });
618
- setPublicUrlsList(publicPaths);
619
600
  setIsInitialized(true);
620
601
  }, [children]);
621
602
 
@@ -663,22 +644,19 @@ var AuthProvider = function AuthProvider(_ref) {
663
644
  return JSON.parse(value);
664
645
  };
665
646
 
666
- // Effect to update public URLs whenever publicUrls prop changes
667
- React.useEffect(function () {
668
- setPublicUrlsList([].concat(defaultPublicUrlList, _toConsumableArray(publicUrls)));
669
- }, [publicUrls]);
670
-
671
647
  // Effect to redirect if user is null
672
648
  React.useEffect(function () {
673
649
  if (isInitialized) {
674
650
  var currentPath = window.location.pathname;
675
651
  var isWhitelisted = publicUrlsList.includes(currentPath);
676
652
  if (user === null && !isWhitelisted) {
653
+ console.log(publicUrlsList);
654
+ console.log(currentPath);
677
655
  debugger;
678
656
  //window.location.replace('/auth/login');
679
657
  }
680
658
  }
681
- }, [user, publicUrlsList, isInitialized]);
659
+ }, [user, isInitialized]);
682
660
 
683
661
  /**
684
662
  * Memoized value containing the user data and authentication functions.