@veripass/react-sdk 1.0.14 → 1.0.16
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/react-sdk.cjs.js +17 -10
- package/dist/react-sdk.cjs.js.map +1 -1
- package/dist/react-sdk.esm.js +17 -10
- package/dist/react-sdk.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/react-sdk.cjs.js
CHANGED
|
@@ -563,7 +563,7 @@ var useLocalStorage = function useLocalStorage(keyName, defaultValue) {
|
|
|
563
563
|
return [storedValue, setValue];
|
|
564
564
|
};
|
|
565
565
|
|
|
566
|
-
var
|
|
566
|
+
var defaultPublicUrlList = ['/auth/login', '/auth/signup'];
|
|
567
567
|
|
|
568
568
|
/**
|
|
569
569
|
* Authentication context used to provide user authentication data and functions.
|
|
@@ -582,7 +582,7 @@ var AuthProvider = function AuthProvider(_ref) {
|
|
|
582
582
|
var children = _ref.children,
|
|
583
583
|
_ref$publicUrls = _ref.publicUrls,
|
|
584
584
|
publicUrls = _ref$publicUrls === void 0 ? [] : _ref$publicUrls;
|
|
585
|
-
var _useState = React.useState(
|
|
585
|
+
var _useState = React.useState(defaultPublicUrlList),
|
|
586
586
|
_useState2 = _slicedToArray(_useState, 2),
|
|
587
587
|
publicUrlsList = _useState2[0],
|
|
588
588
|
setPublicUrlsList = _useState2[1];
|
|
@@ -594,14 +594,21 @@ var AuthProvider = function AuthProvider(_ref) {
|
|
|
594
594
|
setUser = _useLocalStorage2[1];
|
|
595
595
|
React.useEffect(function () {
|
|
596
596
|
console.log(children);
|
|
597
|
+
var publicPaths = new Set(defaultPublicUrlList);
|
|
598
|
+
var extractPublicPaths = function extractPublicPaths(child) {
|
|
599
|
+
if (/*#__PURE__*/React.isValidElement(child)) {
|
|
600
|
+
if (child.props.isPublic && child.props.path) {
|
|
601
|
+
publicPaths.add(child.props.path);
|
|
602
|
+
}
|
|
603
|
+
if (child.props.children) {
|
|
604
|
+
React.Children.forEach(child.props.children, extractPublicPaths);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
React.Children.forEach(children, extractPublicPaths);
|
|
609
|
+
debugger;
|
|
610
|
+
setPublicPathSet(publicPaths);
|
|
597
611
|
}, [children]);
|
|
598
|
-
React.Children.forEach(children, function (child) {
|
|
599
|
-
// Check if child is a valid React element
|
|
600
|
-
if (/*#__PURE__*/React.isValidElement(child) && child.props.isPublic) {
|
|
601
|
-
debugger;
|
|
602
|
-
publicPaths.add(child.props.path); // Assumes `path` is passed as prop
|
|
603
|
-
}
|
|
604
|
-
});
|
|
605
612
|
|
|
606
613
|
/**
|
|
607
614
|
* Logs in the user by saving their data to local storage and navigating to the admin page.
|
|
@@ -649,7 +656,7 @@ var AuthProvider = function AuthProvider(_ref) {
|
|
|
649
656
|
|
|
650
657
|
// Effect to update public URLs whenever publicUrls prop changes
|
|
651
658
|
React.useEffect(function () {
|
|
652
|
-
setPublicUrlsList([].concat(
|
|
659
|
+
setPublicUrlsList([].concat(defaultPublicUrlList, _toConsumableArray(publicUrls)));
|
|
653
660
|
}, [publicUrls]);
|
|
654
661
|
|
|
655
662
|
// Effect to redirect if user is null
|