@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 +7 -1
- package/dist/index.js +79 -66
- package/dist/support/aaa.d.ts +4 -6
- package/dist/support/signature.d.ts +2 -3
- package/dist/support/user.d.ts +6 -7
- package/package.json +15 -9
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
|
|
2
|
-
import
|
|
3
|
-
import
|
|
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(
|
|
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 =
|
|
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 =
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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__*/
|
|
1302
|
+
const SecurityContext = /*#__PURE__*/ createContext(null);
|
|
1303
1303
|
const useSecurityContext = ()=>{
|
|
1304
|
-
const sc =
|
|
1305
|
-
if (!sc) throw new Error(
|
|
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 =
|
|
1310
|
-
const provide =
|
|
1309
|
+
const navigate = useNavigate();
|
|
1310
|
+
const provide = useMemo(()=>bundler(new AccessGuarderBuilder().navigate(navigate)), [
|
|
1311
1311
|
bundler,
|
|
1312
1312
|
navigate
|
|
1313
1313
|
]);
|
|
1314
|
-
return /*#__PURE__*/
|
|
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__*/
|
|
1321
|
+
if (manager.isDisabled()) return /*#__PURE__*/ jsx(Fragment, {
|
|
1322
1322
|
children: children
|
|
1323
1323
|
});
|
|
1324
|
-
const blocker =
|
|
1325
|
-
const [guarded, setGuarded] =
|
|
1326
|
-
const [nextPath, setNextPath] =
|
|
1327
|
-
const [firstAccess, setFirstAccess] =
|
|
1328
|
-
const [firstHandle, setFirstHandle] =
|
|
1329
|
-
const [countSignature, setCountSignature] =
|
|
1330
|
-
const [handledDecision, setHandledDecision] =
|
|
1331
|
-
const [beforeDecision, setBeforeDecision] =
|
|
1332
|
-
const [currentDecision, setCurrentDecision] =
|
|
1333
|
-
const [securityBlock, setSecurityBlock] =
|
|
1334
|
-
const [executableBlocked, setExecutableBlocked] =
|
|
1335
|
-
|
|
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__*/
|
|
1430
|
-
return /*#__PURE__*/
|
|
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__*/
|
|
1434
|
+
const withSecurityBlocker = (Component, bundler)=>()=>/*#__PURE__*/ jsx(SecurityProvider, {
|
|
1435
1435
|
bundler: bundler,
|
|
1436
|
-
children: /*#__PURE__*/
|
|
1437
|
-
children: /*#__PURE__*/
|
|
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 = (
|
|
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 (
|
|
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 = (
|
|
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 (
|
|
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 = (
|
|
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 (
|
|
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
|
-
|
|
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 = (
|
|
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 (
|
|
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 (
|
|
1621
|
+
if ("" !== pRedirect) p_navigator.navigate(pRedirect);
|
|
1622
1622
|
}
|
|
1623
1623
|
};
|
|
1624
1624
|
};
|
|
1625
|
-
const useLogin = (
|
|
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
|
-
|
|
1630
|
+
useEffect(()=>{
|
|
1631
1631
|
const isAuthentication = recorder.existAccessAuthentication() || !!storer.loadAuthentication(recorder);
|
|
1632
|
-
if (
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
|
1667
|
-
const [
|
|
1668
|
-
const [
|
|
1669
|
-
const
|
|
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 =
|
|
1696
|
+
const reset = useCallback(()=>{
|
|
1685
1697
|
setPath(void 0);
|
|
1686
1698
|
setJump(false);
|
|
1687
1699
|
setBlocked(false);
|
|
1688
1700
|
}, []);
|
|
1689
|
-
const handler =
|
|
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
|
-
|
|
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__*/
|
|
1718
|
-
return /*#__PURE__*/
|
|
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__*/
|
|
1735
|
+
const withHavePermission = (Component, term)=>()=>/*#__PURE__*/ jsx(HavePermission, {
|
|
1723
1736
|
term: term,
|
|
1724
|
-
children: /*#__PURE__*/
|
|
1737
|
+
children: /*#__PURE__*/ jsx(Component, {})
|
|
1725
1738
|
});
|
|
1726
1739
|
class MicroAppAddon extends AbstractAddon {
|
|
1727
1740
|
static HIERARCHY_JOIN_IGNORE = 'ignore';
|
package/dist/support/aaa.d.ts
CHANGED
|
@@ -17,13 +17,11 @@ export declare const useDeleteAuthentication: () => (() => void);
|
|
|
17
17
|
export declare const useDeleteAuthorization: () => (() => void);
|
|
18
18
|
/**
|
|
19
19
|
* 保存认证钩子
|
|
20
|
-
* @param
|
|
21
|
-
* @param redirect 重定向路径(如果不存在原始路径时使用)
|
|
20
|
+
* @param redirect 重定向路径,当为空字符串时不进行重定向,默认:空(如果不存在原始路径时使用)
|
|
22
21
|
*/
|
|
23
|
-
export declare const useSaveAuthentication: <Datasheet>(
|
|
22
|
+
export declare const useSaveAuthentication: <Datasheet>(redirect?: string) => ((datasheet: AccessDatasheet<AuthenticationDatasheet<Datasheet>>) => void);
|
|
24
23
|
/**
|
|
25
24
|
* 保存授权钩子
|
|
26
|
-
* @param
|
|
27
|
-
* @param redirect 重定向路径(如果不存在原始路径时使用)
|
|
25
|
+
* @param redirect 重定向路径,当为空字符串时不进行重定向,默认:空(如果不存在原始路径时使用)
|
|
28
26
|
*/
|
|
29
|
-
export declare const useSaveAuthorization: <Datasheet>(
|
|
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
|
|
5
|
-
* @param redirect 重定向路径(如果不存在原始路径时使用)
|
|
4
|
+
* @param redirect 重定向路径,当为空字符串时不进行重定向,默认:'/'(如果不存在原始路径时使用)
|
|
6
5
|
*/
|
|
7
|
-
export declare const useSaveSignature: (
|
|
6
|
+
export declare const useSaveSignature: (redirect?: string) => ((path?: AccessPath) => void);
|
|
8
7
|
/**
|
|
9
8
|
* 删除签名钩子
|
|
10
9
|
*/
|
package/dist/support/user.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import type { AccessDatasheet, UserDatasheet } from '../access';
|
|
2
2
|
/**
|
|
3
3
|
* 登出钩子
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
4
|
+
* @param cRedirect 当前重定向路径,当为空字符串时不进行重定向,默认:'/'
|
|
5
|
+
* @param pRedirect 父级重定向路径,当为空字符串时不进行重定向,默认:'/'(如果存在父级时才会生效)
|
|
6
6
|
*/
|
|
7
|
-
export declare const useLogout: (
|
|
7
|
+
export declare const useLogout: (cRedirect?: string, pRedirect?: string) => (() => void);
|
|
8
8
|
/**
|
|
9
9
|
* 登入钩子
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
12
|
-
* @param redirect 重定向路径(如果不存在原始路径时使用)
|
|
10
|
+
* @param cRedirect 当前重定向路径,当为空字符串时不进行重定向,默认:'/'(如果不存在原始路径时使用)
|
|
11
|
+
* @param pRedirect 父级重定向路径,当为空字符串时不进行重定向,默认:'/'(如果存在父级时才会生效)
|
|
13
12
|
*/
|
|
14
|
-
export declare const useLogin: <Datasheet>(
|
|
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.
|
|
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.
|
|
52
|
-
"@rslib/core": "
|
|
53
|
-
"@types/react": "^19.
|
|
54
|
-
"@types/react-dom": "^19.1
|
|
55
|
-
"react": "^19.
|
|
56
|
-
"react-dom": "^19.
|
|
57
|
-
"react-router-dom": "^7.
|
|
58
|
-
"typescript": "^5.
|
|
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",
|