@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.
@@ -10,9 +10,6 @@ function _arrayLikeToArray(r, a) {
10
10
  function _arrayWithHoles(r) {
11
11
  if (Array.isArray(r)) return r;
12
12
  }
13
- function _arrayWithoutHoles(r) {
14
- if (Array.isArray(r)) return _arrayLikeToArray(r);
15
- }
16
13
  function _assertThisInitialized$1(e) {
17
14
  if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
18
15
  return e;
@@ -101,9 +98,6 @@ function _isNativeReflectConstruct() {
101
98
  return !!t;
102
99
  })();
103
100
  }
104
- function _iterableToArray(r) {
105
- if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
106
- }
107
101
  function _iterableToArrayLimit(r, l) {
108
102
  var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
109
103
  if (null != t) {
@@ -134,9 +128,6 @@ function _iterableToArrayLimit(r, l) {
134
128
  function _nonIterableRest() {
135
129
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
136
130
  }
137
- function _nonIterableSpread() {
138
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
139
- }
140
131
  function ownKeys(e, r) {
141
132
  var t = Object.keys(e);
142
133
  if (Object.getOwnPropertySymbols) {
@@ -483,9 +474,6 @@ function _taggedTemplateLiteral(e, t) {
483
474
  }
484
475
  }));
485
476
  }
486
- function _toConsumableArray(r) {
487
- return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
488
- }
489
477
  function _toPrimitive(t, r) {
490
478
  if ("object" != typeof t || !t) return t;
491
479
  var e = t[Symbol.toPrimitive];
@@ -559,17 +547,12 @@ var AuthContext = /*#__PURE__*/createContext();
559
547
  * @returns {JSX.Element} The provider component for AuthContext.
560
548
  */
561
549
  var AuthProvider = function AuthProvider(_ref) {
562
- var children = _ref.children,
563
- _ref$publicUrls = _ref.publicUrls,
564
- publicUrls = _ref$publicUrls === void 0 ? [] : _ref$publicUrls;
565
- var _useState = useState(defaultPublicUrlList),
550
+ var children = _ref.children;
551
+ var publicUrlsList = defaultPublicUrlList;
552
+ var _useState = useState(false),
566
553
  _useState2 = _slicedToArray(_useState, 2),
567
- publicUrlsList = _useState2[0],
568
- setPublicUrlsList = _useState2[1];
569
- var _useState3 = useState(false),
570
- _useState4 = _slicedToArray(_useState3, 2),
571
- isInitialized = _useState4[0],
572
- setIsInitialized = _useState4[1];
554
+ isInitialized = _useState2[0],
555
+ setIsInitialized = _useState2[1];
573
556
 
574
557
  // State to manage user data, persisted in local storage
575
558
  var _useLocalStorage = useLocalStorage('veripass-user-data', null),
@@ -577,13 +560,12 @@ var AuthProvider = function AuthProvider(_ref) {
577
560
  user = _useLocalStorage2[0],
578
561
  setUser = _useLocalStorage2[1];
579
562
  useEffect(function () {
580
- var publicPaths = new Set(defaultPublicUrlList);
581
563
  var extractPublicPaths = function extractPublicPaths(child) {
582
564
  var parentPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
583
565
  if (/*#__PURE__*/React__default.isValidElement(child)) {
584
566
  var currentPath = "".concat(parentPath).concat(child.props.path ? "/".concat(child.props.path) : '').replace(/\/+/g, '/');
585
- if (child.props.isPublic) {
586
- publicPaths.add(currentPath);
567
+ if (child.props.isPublic && !publicUrlsList.includes(currentPath)) {
568
+ publicUrlsList.push(currentPath);
587
569
  }
588
570
  if (child.props.children) {
589
571
  React__default.Children.forEach(child.props.children, function (grandchild) {
@@ -595,7 +577,6 @@ var AuthProvider = function AuthProvider(_ref) {
595
577
  React__default.Children.forEach(children, function (child) {
596
578
  return extractPublicPaths(child);
597
579
  });
598
- setPublicUrlsList(publicPaths);
599
580
  setIsInitialized(true);
600
581
  }, [children]);
601
582
 
@@ -643,22 +624,19 @@ var AuthProvider = function AuthProvider(_ref) {
643
624
  return JSON.parse(value);
644
625
  };
645
626
 
646
- // Effect to update public URLs whenever publicUrls prop changes
647
- useEffect(function () {
648
- setPublicUrlsList([].concat(defaultPublicUrlList, _toConsumableArray(publicUrls)));
649
- }, [publicUrls]);
650
-
651
627
  // Effect to redirect if user is null
652
628
  useEffect(function () {
653
629
  if (isInitialized) {
654
630
  var currentPath = window.location.pathname;
655
631
  var isWhitelisted = publicUrlsList.includes(currentPath);
656
632
  if (user === null && !isWhitelisted) {
633
+ console.log(publicUrlsList);
634
+ console.log(currentPath);
657
635
  debugger;
658
636
  //window.location.replace('/auth/login');
659
637
  }
660
638
  }
661
- }, [user, publicUrlsList, isInitialized]);
639
+ }, [user, isInitialized]);
662
640
 
663
641
  /**
664
642
  * Memoized value containing the user data and authentication functions.