@lanaqi/rsr 0.0.1 → 0.0.2

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/README.md CHANGED
@@ -4,7 +4,7 @@ React 安全路由器
4
4
 
5
5
  # 框架说明
6
6
 
7
- rsr 是 react security router 的简写,一个基于 react router 实现路由级别控制的安全框架。
7
+ rsr 是 react security router 的简写,一个基于 react router 实现纯前端路由级别控制的安全框架。
8
8
 
9
9
  功能简介:
10
10
 
@@ -47,3 +47,9 @@ export default withSecurityBlocker(Root, bundler => {
47
47
  });
48
48
 
49
49
  ```
50
+
51
+ # 其它例子
52
+
53
+ 基于 Modern.js 的例子:https://github.com/lanaqi-opensource/rsr-demo
54
+
55
+ 基于 react-router-dom 的例子:https://github.com/lanaqi-opensource/rsr6-demo
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import * as __WEBPACK_EXTERNAL_MODULE_react_router_dom_5358f3fe__ from "react-router-dom";
2
- import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
3
- import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
1
+ import { matchPath, useBlocker, useLocation, useNavigate } from "react-router-dom";
2
+ import { Fragment, jsx } from "react/jsx-runtime";
3
+ import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
4
4
  var common_AccessDecision = /*#__PURE__*/ function(AccessDecision) {
5
5
  AccessDecision["notResource"] = "notResource";
6
6
  AccessDecision["notAuthentication"] = "notAuthentication";
@@ -97,7 +97,7 @@ class SimpleResource {
97
97
  this.patterns = new Set(patterns);
98
98
  this.permissions = new Set(permissions);
99
99
  this.labels = new Set(labels);
100
- if (0 === this.patterns.size) throw new Error("\u8BBF\u95EE\u8D44\u6E90\u6A21\u5F0F\u96C6\u5408\u4E0D\u80FD\u4E3A\u7A7A\uFF0C\u8BF7\u68C0\u67E5\uFF01");
100
+ if (0 === this.patterns.size) throw new Error('访问资源模式集合不能为空,请检查!');
101
101
  if (0 === this.permissions.size) {
102
102
  this.anonymous = true;
103
103
  this.authenticated = false;
@@ -521,11 +521,11 @@ class SimpleMatcher {
521
521
  ...pattern,
522
522
  path: basename + pattern.path
523
523
  };
524
- const pm = (0, __WEBPACK_EXTERNAL_MODULE_react_router_dom_5358f3fe__.matchPath)(matchPattern, path.pathname);
524
+ const pm = matchPath(matchPattern, path.pathname);
525
525
  if (pm) return true;
526
526
  }
527
527
  else for (const pattern of patterns){
528
- const pm = (0, __WEBPACK_EXTERNAL_MODULE_react_router_dom_5358f3fe__.matchPath)(pattern, path.pathname);
528
+ const pm = matchPath(pattern, path.pathname);
529
529
  if (pm) return true;
530
530
  }
531
531
  return false;
@@ -637,7 +637,7 @@ class BehaveHandler {
637
637
  return common_AccessBehave.goNavigate;
638
638
  }
639
639
  if (this._config.notAuthenticationFunc) return this._config.notAuthenticationFunc(context);
640
- throw new Error("\u6CA1\u6709\u8BA4\u8BC1\u7684\u884C\u4E3A\u662F\u5FC5\u987B\u914D\u7F6E\u7684\uFF0C\u8BF7\u68C0\u67E5\uFF01");
640
+ throw new Error('没有认证的行为是必须配置的,请检查!');
641
641
  }
642
642
  invalidAuthentication(context) {
643
643
  if (this._config.invalidAuthenticationPath) {
@@ -669,7 +669,7 @@ class BehaveHandler {
669
669
  return common_AccessBehave.goNavigate;
670
670
  }
671
671
  if (this._config.accessDeniedFunc) return this._config.accessDeniedFunc(context);
672
- throw new Error("\u62D2\u7EDD\u8BBF\u95EE\u7684\u884C\u4E3A\u662F\u5FC5\u987B\u914D\u7F6E\u7684\uFF0C\u8BF7\u68C0\u67E5\uFF01");
672
+ throw new Error('拒绝访问的行为是必须配置的,请检查!');
673
673
  }
674
674
  allowAccess(context) {
675
675
  if (this._config.allowAccessFunc) this._config.allowAccessFunc(context);
@@ -683,7 +683,7 @@ class BehaveHandler {
683
683
  this.accessDenied(context);
684
684
  break;
685
685
  case common_AccessDecision.notAuthentication:
686
- throw new Error("\u6CA1\u6709\u8BA4\u8BC1\u7684\u9519\u8BEF\u51B3\u7B56\uFF0C\u8BF7\u68C0\u67E5\uFF01");
686
+ throw new Error('没有认证的错误决策,请检查!');
687
687
  case common_AccessDecision.invalidAuthentication:
688
688
  this.notAuthentication(context);
689
689
  break;
@@ -692,7 +692,7 @@ class BehaveHandler {
692
692
  break;
693
693
  case common_AccessDecision.accessDenied:
694
694
  default:
695
- throw new Error("\u62D2\u7EDD\u8BBF\u95EE\u7684\u9519\u8BEF\u51B3\u7B56\uFF0C\u8BF7\u68C0\u67E5\uFF01");
695
+ throw new Error('拒绝访问的错误决策,请检查!');
696
696
  }
697
697
  }
698
698
  }
@@ -1116,7 +1116,7 @@ class AccessNavigatorBuilder {
1116
1116
  return this;
1117
1117
  }
1118
1118
  build() {
1119
- if (!this._navigate) throw new Error("\u5BFC\u822A\u51FD\u6570\u662F\u5FC5\u987B\u8BBE\u7F6E\u7684\uFF0C\u8BF7\u68C0\u67E5\uFF01");
1119
+ if (!this._navigate) throw new Error('导航函数是必须设置的,请检查!');
1120
1120
  return new SimpleNavigator(this._navigate);
1121
1121
  }
1122
1122
  }
@@ -1205,7 +1205,7 @@ class AccessHandlerBuilder {
1205
1205
  return this;
1206
1206
  }
1207
1207
  build() {
1208
- if (!this._config) throw new Error("\u884C\u4E3A\u914D\u7F6E\u662F\u5FC5\u987B\u8BBE\u7F6E\uFF0C\u8BF7\u68C0\u67E5\uFF01");
1208
+ if (!this._config) throw new Error('行为配置是必须设置,请检查!');
1209
1209
  return new BehaveHandler(this._config);
1210
1210
  }
1211
1211
  }
@@ -1299,40 +1299,40 @@ class AccessGuarderBuilder {
1299
1299
  };
1300
1300
  }
1301
1301
  }
1302
- const SecurityContext = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.createContext)(null);
1302
+ const SecurityContext = /*#__PURE__*/ createContext(null);
1303
1303
  const useSecurityContext = ()=>{
1304
- const sc = (0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(SecurityContext);
1305
- if (!sc) throw new Error("\u5B89\u5168\u4E0A\u4E0B\u6587\u4E3A\u7A7A\uFF0C\u5FC5\u987B\u4F7F\u7528\u5B89\u5168\u63D0\u4F9B\u8005\u5305\u88F9\u7EC4\u4EF6\u6765\u8BBE\u7F6E\u5B89\u5168\u4E0A\u4E0B\u6587");
1304
+ const sc = useContext(SecurityContext);
1305
+ if (!sc) throw new Error('安全上下文为空,必须使用安全提供者包裹组件来设置安全上下文');
1306
1306
  return sc;
1307
1307
  };
1308
1308
  function SecurityProvider({ children, bundler }) {
1309
- const navigate = (0, __WEBPACK_EXTERNAL_MODULE_react_router_dom_5358f3fe__.useNavigate)();
1310
- const provide = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>bundler(new AccessGuarderBuilder().navigate(navigate)), [
1309
+ const navigate = useNavigate();
1310
+ const provide = useMemo(()=>bundler(new AccessGuarderBuilder().navigate(navigate)), [
1311
1311
  bundler,
1312
1312
  navigate
1313
1313
  ]);
1314
- return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(SecurityContext.Provider, {
1314
+ return /*#__PURE__*/ jsx(SecurityContext.Provider, {
1315
1315
  value: provide,
1316
1316
  children: children
1317
1317
  });
1318
1318
  }
1319
1319
  function SecurityBlocker({ children }) {
1320
1320
  const { context, manager, guarder } = useSecurityContext();
1321
- if (manager.isDisabled()) return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, {
1321
+ if (manager.isDisabled()) return /*#__PURE__*/ jsx(Fragment, {
1322
1322
  children: children
1323
1323
  });
1324
- const blocker = (0, __WEBPACK_EXTERNAL_MODULE_react_router_dom_5358f3fe__.useBlocker)(({ currentLocation, nextLocation })=>currentLocation.pathname !== nextLocation.pathname);
1325
- const [guarded, setGuarded] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false);
1326
- const [nextPath, setNextPath] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)((0, __WEBPACK_EXTERNAL_MODULE_react_router_dom_5358f3fe__.useLocation)());
1327
- const [firstAccess, setFirstAccess] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(true);
1328
- const [firstHandle, setFirstHandle] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(true);
1329
- const [countSignature, setCountSignature] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(1);
1330
- const [handledDecision, setHandledDecision] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false);
1331
- const [beforeDecision, setBeforeDecision] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(void 0);
1332
- const [currentDecision, setCurrentDecision] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(void 0);
1333
- const [securityBlock, setSecurityBlock] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false);
1334
- const [executableBlocked, setExecutableBlocked] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(true);
1335
- (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
1324
+ const blocker = useBlocker(({ currentLocation, nextLocation })=>currentLocation.pathname !== nextLocation.pathname);
1325
+ const [guarded, setGuarded] = useState(false);
1326
+ const [nextPath, setNextPath] = useState(useLocation());
1327
+ const [firstAccess, setFirstAccess] = useState(true);
1328
+ const [firstHandle, setFirstHandle] = useState(true);
1329
+ const [countSignature, setCountSignature] = useState(1);
1330
+ const [handledDecision, setHandledDecision] = useState(false);
1331
+ const [beforeDecision, setBeforeDecision] = useState(void 0);
1332
+ const [currentDecision, setCurrentDecision] = useState(void 0);
1333
+ const [securityBlock, setSecurityBlock] = useState(false);
1334
+ const [executableBlocked, setExecutableBlocked] = useState(true);
1335
+ useEffect(()=>{
1336
1336
  if ('blocked' === blocker.state && executableBlocked) {
1337
1337
  let isProceed;
1338
1338
  const recorder = context.getRecorder();
@@ -1426,15 +1426,15 @@ function SecurityBlocker({ children }) {
1426
1426
  securityBlock,
1427
1427
  executableBlocked
1428
1428
  ]);
1429
- if (!guarded) return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, {});
1430
- return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, {
1429
+ if (!guarded) return /*#__PURE__*/ jsx(Fragment, {});
1430
+ return /*#__PURE__*/ jsx(Fragment, {
1431
1431
  children: children
1432
1432
  });
1433
1433
  }
1434
- const withSecurityBlocker = (Component, bundler)=>()=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(SecurityProvider, {
1434
+ const withSecurityBlocker = (Component, bundler)=>()=>/*#__PURE__*/ jsx(SecurityProvider, {
1435
1435
  bundler: bundler,
1436
- children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(SecurityBlocker, {
1437
- children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(Component, {})
1436
+ children: /*#__PURE__*/ jsx(SecurityBlocker, {
1437
+ children: /*#__PURE__*/ jsx(Component, {})
1438
1438
  })
1439
1439
  });
1440
1440
  const useObtainAuthentication = ()=>{
@@ -1501,7 +1501,7 @@ const useDeleteAuthorization = ()=>{
1501
1501
  }
1502
1502
  };
1503
1503
  };
1504
- const useSaveAuthentication = (navigate = false, redirect = '/')=>{
1504
+ const useSaveAuthentication = (redirect = '')=>{
1505
1505
  const { context } = useSecurityContext();
1506
1506
  const recorder = context.getRecorder();
1507
1507
  const storer = context.getStorer();
@@ -1510,14 +1510,14 @@ const useSaveAuthentication = (navigate = false, redirect = '/')=>{
1510
1510
  storer.saveAuthentication(recorder, datasheet);
1511
1511
  recorder.clearAccessAuthentication();
1512
1512
  recorder.clearAccessAuthorization();
1513
- if (navigate) {
1513
+ if ('' !== redirect) {
1514
1514
  const path = recorder.getOriginPath();
1515
1515
  if (path) navigator.navigate(path);
1516
1516
  else navigator.navigate(redirect);
1517
1517
  }
1518
1518
  };
1519
1519
  };
1520
- const useSaveAuthorization = (navigate = false, redirect = '/')=>{
1520
+ const useSaveAuthorization = (redirect = '')=>{
1521
1521
  const { context } = useSecurityContext();
1522
1522
  const recorder = context.getRecorder();
1523
1523
  const storer = context.getStorer();
@@ -1525,7 +1525,7 @@ const useSaveAuthorization = (navigate = false, redirect = '/')=>{
1525
1525
  return (datasheet)=>{
1526
1526
  storer.saveAuthorization(recorder, datasheet);
1527
1527
  recorder.clearAccessAuthorization();
1528
- if (navigate) {
1528
+ if ('' !== redirect) {
1529
1529
  const path = recorder.getOriginPath();
1530
1530
  if (path) navigator.navigate(path);
1531
1531
  else navigator.navigate(redirect);
@@ -1549,7 +1549,7 @@ const useHavePermission = ()=>{
1549
1549
  return have;
1550
1550
  };
1551
1551
  };
1552
- const useSaveSignature = (navigate = true, redirect = '/')=>{
1552
+ const useSaveSignature = (redirect = '/')=>{
1553
1553
  const { context } = useSecurityContext();
1554
1554
  const recorder = context.getRecorder();
1555
1555
  const storer = context.getStorer();
@@ -1558,7 +1558,7 @@ const useSaveSignature = (navigate = true, redirect = '/')=>{
1558
1558
  let target;
1559
1559
  target = path ? path : recorder.getOriginPath();
1560
1560
  if (target) storer.saveSignature(recorder, target);
1561
- if (navigate) if (target) navigator.navigate(target);
1561
+ if ('' !== redirect) if (target) navigator.navigate(target);
1562
1562
  else navigator.navigate(redirect);
1563
1563
  };
1564
1564
  };
@@ -1588,7 +1588,7 @@ const usePurgeSignature = ()=>{
1588
1588
  const recorder = context.getRecorder();
1589
1589
  const storer = context.getStorer();
1590
1590
  const path = recorder.getCurrentPath();
1591
- (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>()=>{
1591
+ useEffect(()=>()=>{
1592
1592
  if (path) storer.removeSignature(recorder, path);
1593
1593
  }, [
1594
1594
  recorder,
@@ -1596,7 +1596,7 @@ const usePurgeSignature = ()=>{
1596
1596
  path
1597
1597
  ]);
1598
1598
  };
1599
- const useLogout = (navigate = true, redirect = '/')=>{
1599
+ const useLogout = (cRedirect = '/', pRedirect = '/')=>{
1600
1600
  const { context } = useSecurityContext();
1601
1601
  const recorder = context.getRecorder();
1602
1602
  const storer = context.getStorer();
@@ -1607,7 +1607,7 @@ const useLogout = (navigate = true, redirect = '/')=>{
1607
1607
  storer.deleteSignature(recorder);
1608
1608
  recorder.clearAccessAuthentication();
1609
1609
  recorder.clearAccessAuthorization();
1610
- if (navigate) navigator.navigate(redirect);
1610
+ if ("" !== cRedirect) navigator.navigate(cRedirect);
1611
1611
  const parent = context.getParent();
1612
1612
  if (parent) {
1613
1613
  const p_recorder = parent.getRecorder();
@@ -1618,21 +1618,30 @@ const useLogout = (navigate = true, redirect = '/')=>{
1618
1618
  p_storer.deleteSignature(p_recorder);
1619
1619
  p_recorder.clearAccessAuthentication();
1620
1620
  p_recorder.clearAccessAuthorization();
1621
- if (navigate) p_navigator.navigate(redirect);
1621
+ if ("" !== pRedirect) p_navigator.navigate(pRedirect);
1622
1622
  }
1623
1623
  };
1624
1624
  };
1625
- const useLogin = (logined = false, navigate = true, redirect = '/')=>{
1625
+ const useLogin = (cRedirect = '/', pRedirect = '/')=>{
1626
1626
  const { context } = useSecurityContext();
1627
1627
  const recorder = context.getRecorder();
1628
1628
  const storer = context.getStorer();
1629
1629
  const navigator = context.getNavigator();
1630
- (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
1630
+ useEffect(()=>{
1631
1631
  const isAuthentication = recorder.existAccessAuthentication() || !!storer.loadAuthentication(recorder);
1632
- if (logined && isAuthentication) navigator.navigate(redirect);
1632
+ if (isAuthentication) {
1633
+ const e_parent = context.getParent();
1634
+ if (e_parent && "" !== pRedirect) {
1635
+ const p_navigator = e_parent.getNavigator();
1636
+ p_navigator.navigate(pRedirect);
1637
+ } else if ("" !== cRedirect) {
1638
+ const path = recorder.getOriginPath();
1639
+ if (path) navigator.navigate(path);
1640
+ else navigator.navigate(cRedirect);
1641
+ }
1642
+ }
1633
1643
  }, [
1634
- logined,
1635
- redirect,
1644
+ cRedirect,
1636
1645
  recorder,
1637
1646
  storer,
1638
1647
  navigator
@@ -1641,17 +1650,21 @@ const useLogin = (logined = false, navigate = true, redirect = '/')=>{
1641
1650
  storer.saveAuthentication(recorder, datasheet);
1642
1651
  recorder.clearAccessAuthentication();
1643
1652
  recorder.clearAccessAuthorization();
1644
- if (navigate) {
1653
+ const r_parent = context.getParent();
1654
+ if (r_parent && "" !== pRedirect) {
1655
+ const p_navigator = r_parent.getNavigator();
1656
+ p_navigator.navigate(pRedirect);
1657
+ } else if ("" !== cRedirect) {
1645
1658
  const path = recorder.getOriginPath();
1646
1659
  if (path) navigator.navigate(path);
1647
- else navigator.navigate(redirect);
1660
+ else navigator.navigate(cRedirect);
1648
1661
  }
1649
1662
  };
1650
1663
  };
1651
1664
  const useCustomBlocker = (handler)=>{
1652
1665
  const { manager } = useSecurityContext();
1653
1666
  const blocker = manager.getBlocker();
1654
- (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
1667
+ useEffect(()=>{
1655
1668
  blocker.register(handler);
1656
1669
  return ()=>{
1657
1670
  blocker.unregister(handler);
@@ -1663,11 +1676,10 @@ const useCustomBlocker = (handler)=>{
1663
1676
  };
1664
1677
  const useSecurityBlocker = (recover = true)=>{
1665
1678
  const { context, manager } = useSecurityContext();
1666
- const blocker = manager.getBlocker();
1667
- const [path, setPath] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)();
1668
- const [jump, setJump] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false);
1669
- const [blocked, setBlocked] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false);
1670
- const proceed = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)(()=>{
1679
+ const [path, setPath] = useState();
1680
+ const [jump, setJump] = useState(false);
1681
+ const [blocked, setBlocked] = useState(false);
1682
+ const proceed = useCallback(()=>{
1671
1683
  if (path) {
1672
1684
  setJump(true);
1673
1685
  if (recover) {
@@ -1681,12 +1693,12 @@ const useSecurityBlocker = (recover = true)=>{
1681
1693
  path,
1682
1694
  recover
1683
1695
  ]);
1684
- const reset = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)(()=>{
1696
+ const reset = useCallback(()=>{
1685
1697
  setPath(void 0);
1686
1698
  setJump(false);
1687
1699
  setBlocked(false);
1688
1700
  }, []);
1689
- const handler = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((context, currentPath, currentResource)=>{
1701
+ const handler = useCallback((context, currentPath, currentResource)=>{
1690
1702
  setJump(false);
1691
1703
  if (jump) return false;
1692
1704
  setPath(currentPath);
@@ -1695,7 +1707,8 @@ const useSecurityBlocker = (recover = true)=>{
1695
1707
  }, [
1696
1708
  jump
1697
1709
  ]);
1698
- (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
1710
+ const blocker = manager.getBlocker();
1711
+ useEffect(()=>{
1699
1712
  blocker.register(handler);
1700
1713
  return ()=>{
1701
1714
  blocker.unregister(handler);
@@ -1714,14 +1727,14 @@ const useSecurityBlocker = (recover = true)=>{
1714
1727
  function HavePermission({ children, term }) {
1715
1728
  const havePermission = useHavePermission();
1716
1729
  const have = havePermission(term);
1717
- if (!have) return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, {});
1718
- return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, {
1730
+ if (!have) return /*#__PURE__*/ jsx(Fragment, {});
1731
+ return /*#__PURE__*/ jsx(Fragment, {
1719
1732
  children: children
1720
1733
  });
1721
1734
  }
1722
- const withHavePermission = (Component, term)=>()=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(HavePermission, {
1735
+ const withHavePermission = (Component, term)=>()=>/*#__PURE__*/ jsx(HavePermission, {
1723
1736
  term: term,
1724
- children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(Component, {})
1737
+ children: /*#__PURE__*/ jsx(Component, {})
1725
1738
  });
1726
1739
  class MicroAppAddon extends AbstractAddon {
1727
1740
  static HIERARCHY_JOIN_IGNORE = 'ignore';
@@ -17,13 +17,11 @@ export declare const useDeleteAuthentication: () => (() => void);
17
17
  export declare const useDeleteAuthorization: () => (() => void);
18
18
  /**
19
19
  * 保存认证钩子
20
- * @param navigate 是否导航
21
- * @param redirect 重定向路径(如果不存在原始路径时使用)
20
+ * @param redirect 重定向路径,当为空字符串时不进行重定向,默认:空(如果不存在原始路径时使用)
22
21
  */
23
- export declare const useSaveAuthentication: <Datasheet>(navigate?: boolean, redirect?: string) => ((datasheet: AccessDatasheet<AuthenticationDatasheet<Datasheet>>) => void);
22
+ export declare const useSaveAuthentication: <Datasheet>(redirect?: string) => ((datasheet: AccessDatasheet<AuthenticationDatasheet<Datasheet>>) => void);
24
23
  /**
25
24
  * 保存授权钩子
26
- * @param navigate 是否导航
27
- * @param redirect 重定向路径(如果不存在原始路径时使用)
25
+ * @param redirect 重定向路径,当为空字符串时不进行重定向,默认:空(如果不存在原始路径时使用)
28
26
  */
29
- export declare const useSaveAuthorization: <Datasheet>(navigate?: boolean, redirect?: string) => ((datasheet: AccessDatasheet<AuthorizationDatasheet<Datasheet>>) => void);
27
+ export declare const useSaveAuthorization: <Datasheet>(redirect?: string) => ((datasheet: AccessDatasheet<AuthorizationDatasheet<Datasheet>>) => void);
@@ -1,10 +1,9 @@
1
1
  import type { AccessPath } from '../access';
2
2
  /**
3
3
  * 保存签名钩子
4
- * @param navigate 是否导航(默认:true)
5
- * @param redirect 重定向路径(如果不存在原始路径时使用)
4
+ * @param redirect 重定向路径,当为空字符串时不进行重定向,默认:'/'(如果不存在原始路径时使用)
6
5
  */
7
- export declare const useSaveSignature: (navigate?: boolean, redirect?: string) => ((path?: AccessPath) => void);
6
+ export declare const useSaveSignature: (redirect?: string) => ((path?: AccessPath) => void);
8
7
  /**
9
8
  * 删除签名钩子
10
9
  */
@@ -1,14 +1,13 @@
1
1
  import type { AccessDatasheet, UserDatasheet } from '../access';
2
2
  /**
3
3
  * 登出钩子
4
- * @param navigate 是否导航(默认:true)
5
- * @param redirect 重定向路径(如果不存在原始路径时使用)
4
+ * @param cRedirect 当前重定向路径,当为空字符串时不进行重定向,默认:'/'
5
+ * @param pRedirect 父级重定向路径,当为空字符串时不进行重定向,默认:'/'(如果存在父级时才会生效)
6
6
  */
7
- export declare const useLogout: (navigate?: boolean, redirect?: string) => (() => void);
7
+ export declare const useLogout: (cRedirect?: string, pRedirect?: string) => (() => void);
8
8
  /**
9
9
  * 登入钩子
10
- * @param logined 已登录跳转
11
- * @param navigate 是否导航(默认:true)
12
- * @param redirect 重定向路径(如果不存在原始路径时使用)
10
+ * @param cRedirect 当前重定向路径,当为空字符串时不进行重定向,默认:'/'(如果不存在原始路径时使用)
11
+ * @param pRedirect 父级重定向路径,当为空字符串时不进行重定向,默认:'/'(如果存在父级时才会生效)
13
12
  */
14
- export declare const useLogin: <Datasheet>(logined?: boolean, navigate?: boolean, redirect?: string) => ((datasheet: AccessDatasheet<UserDatasheet<Datasheet>>) => void);
13
+ export declare const useLogin: <Datasheet>(cRedirect?: string, pRedirect?: string) => ((datasheet: AccessDatasheet<UserDatasheet<Datasheet>>) => void);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lanaqi/rsr",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -27,6 +27,12 @@
27
27
  "react-router-dom",
28
28
  "modern-js",
29
29
  "modernjs",
30
+ "auth",
31
+ "authentication",
32
+ "authorization",
33
+ "csr",
34
+ "rsr",
35
+ "纯前端",
30
36
  "安全",
31
37
  "鉴权",
32
38
  "守护",
@@ -48,14 +54,14 @@
48
54
  },
49
55
  "devDependencies": {
50
56
  "@biomejs/biome": "^1.9.4",
51
- "@rsbuild/plugin-react": "^1.1.1",
52
- "@rslib/core": "^0.6.8",
53
- "@types/react": "^19.1.3",
54
- "@types/react-dom": "^19.1.3",
55
- "react": "^19.1.0",
56
- "react-dom": "^19.1.0",
57
- "react-router-dom": "^7.5.3",
58
- "typescript": "^5.8.2"
57
+ "@rsbuild/plugin-react": "^1.4.1",
58
+ "@rslib/core": "0.15.0",
59
+ "@types/react": "^19.2.2",
60
+ "@types/react-dom": "^19.2.1",
61
+ "react": "^19.2.0",
62
+ "react-dom": "^19.2.0",
63
+ "react-router-dom": "^7.9.4",
64
+ "typescript": "^5.9.3"
59
65
  },
60
66
  "peerDependencies": {
61
67
  "react": ">=17.0.0",