@react-protected/react 0.1.1-beta.1 → 0.2.0-beta.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/dist/AccessProvider-DTsMa_Df.mjs +317 -0
- package/dist/AccessProvider-sHL1A3i9.js +22 -0
- package/dist/AccessProvider.d.ts +1 -1
- package/dist/index.cjs +1 -22
- package/dist/index.js +11 -319
- package/dist/testing.cjs +1 -0
- package/dist/testing.d.ts +9 -0
- package/dist/testing.js +34 -0
- package/dist/types.d.ts +2 -0
- package/package.json +7 -2
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import ee, { createContext as re, useMemo as F, useContext as te } from "react";
|
|
2
|
+
import { createGuard as ne } from "@react-protected/core";
|
|
3
|
+
var y = { exports: {} }, _ = {};
|
|
4
|
+
/**
|
|
5
|
+
* @license React
|
|
6
|
+
* react-jsx-runtime.production.js
|
|
7
|
+
*
|
|
8
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the MIT license found in the
|
|
11
|
+
* LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/
|
|
13
|
+
var D;
|
|
14
|
+
function oe() {
|
|
15
|
+
if (D) return _;
|
|
16
|
+
D = 1;
|
|
17
|
+
var u = Symbol.for("react.transitional.element"), m = Symbol.for("react.fragment");
|
|
18
|
+
function c(l, a, s) {
|
|
19
|
+
var i = null;
|
|
20
|
+
if (s !== void 0 && (i = "" + s), a.key !== void 0 && (i = "" + a.key), "key" in a) {
|
|
21
|
+
s = {};
|
|
22
|
+
for (var f in a)
|
|
23
|
+
f !== "key" && (s[f] = a[f]);
|
|
24
|
+
} else s = a;
|
|
25
|
+
return a = s.ref, {
|
|
26
|
+
$$typeof: u,
|
|
27
|
+
type: l,
|
|
28
|
+
key: i,
|
|
29
|
+
ref: a !== void 0 ? a : null,
|
|
30
|
+
props: s
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return _.Fragment = m, _.jsx = c, _.jsxs = c, _;
|
|
34
|
+
}
|
|
35
|
+
var v = {};
|
|
36
|
+
/**
|
|
37
|
+
* @license React
|
|
38
|
+
* react-jsx-runtime.development.js
|
|
39
|
+
*
|
|
40
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
41
|
+
*
|
|
42
|
+
* This source code is licensed under the MIT license found in the
|
|
43
|
+
* LICENSE file in the root directory of this source tree.
|
|
44
|
+
*/
|
|
45
|
+
var M;
|
|
46
|
+
function ae() {
|
|
47
|
+
return M || (M = 1, process.env.NODE_ENV !== "production" && function() {
|
|
48
|
+
function u(e) {
|
|
49
|
+
if (e == null) return null;
|
|
50
|
+
if (typeof e == "function")
|
|
51
|
+
return e.$$typeof === Z ? null : e.displayName || e.name || null;
|
|
52
|
+
if (typeof e == "string") return e;
|
|
53
|
+
switch (e) {
|
|
54
|
+
case A:
|
|
55
|
+
return "Fragment";
|
|
56
|
+
case z:
|
|
57
|
+
return "Profiler";
|
|
58
|
+
case V:
|
|
59
|
+
return "StrictMode";
|
|
60
|
+
case J:
|
|
61
|
+
return "Suspense";
|
|
62
|
+
case X:
|
|
63
|
+
return "SuspenseList";
|
|
64
|
+
case H:
|
|
65
|
+
return "Activity";
|
|
66
|
+
}
|
|
67
|
+
if (typeof e == "object")
|
|
68
|
+
switch (typeof e.tag == "number" && console.error(
|
|
69
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
70
|
+
), e.$$typeof) {
|
|
71
|
+
case W:
|
|
72
|
+
return "Portal";
|
|
73
|
+
case U:
|
|
74
|
+
return e.displayName || "Context";
|
|
75
|
+
case G:
|
|
76
|
+
return (e._context.displayName || "Context") + ".Consumer";
|
|
77
|
+
case q:
|
|
78
|
+
var r = e.render;
|
|
79
|
+
return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
80
|
+
case B:
|
|
81
|
+
return r = e.displayName || null, r !== null ? r : u(e.type) || "Memo";
|
|
82
|
+
case O:
|
|
83
|
+
r = e._payload, e = e._init;
|
|
84
|
+
try {
|
|
85
|
+
return u(e(r));
|
|
86
|
+
} catch {
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
function m(e) {
|
|
92
|
+
return "" + e;
|
|
93
|
+
}
|
|
94
|
+
function c(e) {
|
|
95
|
+
try {
|
|
96
|
+
m(e);
|
|
97
|
+
var r = !1;
|
|
98
|
+
} catch {
|
|
99
|
+
r = !0;
|
|
100
|
+
}
|
|
101
|
+
if (r) {
|
|
102
|
+
r = console;
|
|
103
|
+
var t = r.error, n = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
104
|
+
return t.call(
|
|
105
|
+
r,
|
|
106
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
107
|
+
n
|
|
108
|
+
), m(e);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function l(e) {
|
|
112
|
+
if (e === A) return "<>";
|
|
113
|
+
if (typeof e == "object" && e !== null && e.$$typeof === O)
|
|
114
|
+
return "<...>";
|
|
115
|
+
try {
|
|
116
|
+
var r = u(e);
|
|
117
|
+
return r ? "<" + r + ">" : "<...>";
|
|
118
|
+
} catch {
|
|
119
|
+
return "<...>";
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function a() {
|
|
123
|
+
var e = w.A;
|
|
124
|
+
return e === null ? null : e.getOwner();
|
|
125
|
+
}
|
|
126
|
+
function s() {
|
|
127
|
+
return Error("react-stack-top-frame");
|
|
128
|
+
}
|
|
129
|
+
function i(e) {
|
|
130
|
+
if (N.call(e, "key")) {
|
|
131
|
+
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
132
|
+
if (r && r.isReactWarning) return !1;
|
|
133
|
+
}
|
|
134
|
+
return e.key !== void 0;
|
|
135
|
+
}
|
|
136
|
+
function f(e, r) {
|
|
137
|
+
function t() {
|
|
138
|
+
h || (h = !0, console.error(
|
|
139
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
140
|
+
r
|
|
141
|
+
));
|
|
142
|
+
}
|
|
143
|
+
t.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
144
|
+
get: t,
|
|
145
|
+
configurable: !0
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function R() {
|
|
149
|
+
var e = u(this.type);
|
|
150
|
+
return C[e] || (C[e] = !0, console.error(
|
|
151
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
152
|
+
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
153
|
+
}
|
|
154
|
+
function b(e, r, t, n, k, x) {
|
|
155
|
+
var o = t.ref;
|
|
156
|
+
return e = {
|
|
157
|
+
$$typeof: g,
|
|
158
|
+
type: e,
|
|
159
|
+
key: r,
|
|
160
|
+
props: t,
|
|
161
|
+
_owner: n
|
|
162
|
+
}, (o !== void 0 ? o : null) !== null ? Object.defineProperty(e, "ref", {
|
|
163
|
+
enumerable: !1,
|
|
164
|
+
get: R
|
|
165
|
+
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
166
|
+
configurable: !1,
|
|
167
|
+
enumerable: !1,
|
|
168
|
+
writable: !0,
|
|
169
|
+
value: 0
|
|
170
|
+
}), Object.defineProperty(e, "_debugInfo", {
|
|
171
|
+
configurable: !1,
|
|
172
|
+
enumerable: !1,
|
|
173
|
+
writable: !0,
|
|
174
|
+
value: null
|
|
175
|
+
}), Object.defineProperty(e, "_debugStack", {
|
|
176
|
+
configurable: !1,
|
|
177
|
+
enumerable: !1,
|
|
178
|
+
writable: !0,
|
|
179
|
+
value: k
|
|
180
|
+
}), Object.defineProperty(e, "_debugTask", {
|
|
181
|
+
configurable: !1,
|
|
182
|
+
enumerable: !1,
|
|
183
|
+
writable: !0,
|
|
184
|
+
value: x
|
|
185
|
+
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
186
|
+
}
|
|
187
|
+
function E(e, r, t, n, k, x) {
|
|
188
|
+
var o = r.children;
|
|
189
|
+
if (o !== void 0)
|
|
190
|
+
if (n)
|
|
191
|
+
if (Q(o)) {
|
|
192
|
+
for (n = 0; n < o.length; n++)
|
|
193
|
+
p(o[n]);
|
|
194
|
+
Object.freeze && Object.freeze(o);
|
|
195
|
+
} else
|
|
196
|
+
console.error(
|
|
197
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
198
|
+
);
|
|
199
|
+
else p(o);
|
|
200
|
+
if (N.call(r, "key")) {
|
|
201
|
+
o = u(e);
|
|
202
|
+
var d = Object.keys(r).filter(function(K) {
|
|
203
|
+
return K !== "key";
|
|
204
|
+
});
|
|
205
|
+
n = 0 < d.length ? "{key: someKey, " + d.join(": ..., ") + ": ...}" : "{key: someKey}", I[o + n] || (d = 0 < d.length ? "{" + d.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
206
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
207
|
+
let props = %s;
|
|
208
|
+
<%s {...props} />
|
|
209
|
+
React keys must be passed directly to JSX without using spread:
|
|
210
|
+
let props = %s;
|
|
211
|
+
<%s key={someKey} {...props} />`,
|
|
212
|
+
n,
|
|
213
|
+
o,
|
|
214
|
+
d,
|
|
215
|
+
o
|
|
216
|
+
), I[o + n] = !0);
|
|
217
|
+
}
|
|
218
|
+
if (o = null, t !== void 0 && (c(t), o = "" + t), i(r) && (c(r.key), o = "" + r.key), "key" in r) {
|
|
219
|
+
t = {};
|
|
220
|
+
for (var j in r)
|
|
221
|
+
j !== "key" && (t[j] = r[j]);
|
|
222
|
+
} else t = r;
|
|
223
|
+
return o && f(
|
|
224
|
+
t,
|
|
225
|
+
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
226
|
+
), b(
|
|
227
|
+
e,
|
|
228
|
+
o,
|
|
229
|
+
t,
|
|
230
|
+
a(),
|
|
231
|
+
k,
|
|
232
|
+
x
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
function p(e) {
|
|
236
|
+
P(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === O && (e._payload.status === "fulfilled" ? P(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
237
|
+
}
|
|
238
|
+
function P(e) {
|
|
239
|
+
return typeof e == "object" && e !== null && e.$$typeof === g;
|
|
240
|
+
}
|
|
241
|
+
var T = ee, g = Symbol.for("react.transitional.element"), W = Symbol.for("react.portal"), A = Symbol.for("react.fragment"), V = Symbol.for("react.strict_mode"), z = Symbol.for("react.profiler"), G = Symbol.for("react.consumer"), U = Symbol.for("react.context"), q = Symbol.for("react.forward_ref"), J = Symbol.for("react.suspense"), X = Symbol.for("react.suspense_list"), B = Symbol.for("react.memo"), O = Symbol.for("react.lazy"), H = Symbol.for("react.activity"), Z = Symbol.for("react.client.reference"), w = T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, N = Object.prototype.hasOwnProperty, Q = Array.isArray, S = console.createTask ? console.createTask : function() {
|
|
242
|
+
return null;
|
|
243
|
+
};
|
|
244
|
+
T = {
|
|
245
|
+
react_stack_bottom_frame: function(e) {
|
|
246
|
+
return e();
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
var h, C = {}, Y = T.react_stack_bottom_frame.bind(
|
|
250
|
+
T,
|
|
251
|
+
s
|
|
252
|
+
)(), $ = S(l(s)), I = {};
|
|
253
|
+
v.Fragment = A, v.jsx = function(e, r, t) {
|
|
254
|
+
var n = 1e4 > w.recentlyCreatedOwnerStacks++;
|
|
255
|
+
return E(
|
|
256
|
+
e,
|
|
257
|
+
r,
|
|
258
|
+
t,
|
|
259
|
+
!1,
|
|
260
|
+
n ? Error("react-stack-top-frame") : Y,
|
|
261
|
+
n ? S(l(e)) : $
|
|
262
|
+
);
|
|
263
|
+
}, v.jsxs = function(e, r, t) {
|
|
264
|
+
var n = 1e4 > w.recentlyCreatedOwnerStacks++;
|
|
265
|
+
return E(
|
|
266
|
+
e,
|
|
267
|
+
r,
|
|
268
|
+
t,
|
|
269
|
+
!0,
|
|
270
|
+
n ? Error("react-stack-top-frame") : Y,
|
|
271
|
+
n ? S(l(e)) : $
|
|
272
|
+
);
|
|
273
|
+
};
|
|
274
|
+
}()), v;
|
|
275
|
+
}
|
|
276
|
+
process.env.NODE_ENV === "production" ? y.exports = oe() : y.exports = ae();
|
|
277
|
+
var se = y.exports;
|
|
278
|
+
const L = re(null);
|
|
279
|
+
function le({
|
|
280
|
+
children: u,
|
|
281
|
+
loginPath: m = "/login",
|
|
282
|
+
forbiddenPath: c = "/403",
|
|
283
|
+
defaultPath: l = "/",
|
|
284
|
+
callbackUrlParam: a,
|
|
285
|
+
shouldAddCallbackUrl: s,
|
|
286
|
+
getUser: i,
|
|
287
|
+
isAuthenticated: f,
|
|
288
|
+
hasRole: R,
|
|
289
|
+
hasPermission: b
|
|
290
|
+
}) {
|
|
291
|
+
const E = F(
|
|
292
|
+
() => ne({ getUser: i, isAuthenticated: f, hasRole: R, hasPermission: b }),
|
|
293
|
+
[i, f, R, b]
|
|
294
|
+
), p = F(
|
|
295
|
+
() => ({
|
|
296
|
+
guard: E,
|
|
297
|
+
loginPath: m,
|
|
298
|
+
forbiddenPath: c,
|
|
299
|
+
defaultPath: l,
|
|
300
|
+
callbackUrlParam: a,
|
|
301
|
+
shouldAddCallbackUrl: s
|
|
302
|
+
}),
|
|
303
|
+
[E, m, c, l, a, s]
|
|
304
|
+
);
|
|
305
|
+
return /* @__PURE__ */ se.jsx(L.Provider, { value: p, children: u });
|
|
306
|
+
}
|
|
307
|
+
function ie() {
|
|
308
|
+
const u = te(L);
|
|
309
|
+
if (!u)
|
|
310
|
+
throw new Error("useAccess must be used within <AccessProvider>");
|
|
311
|
+
return u;
|
|
312
|
+
}
|
|
313
|
+
export {
|
|
314
|
+
le as A,
|
|
315
|
+
se as j,
|
|
316
|
+
ie as u
|
|
317
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";const R=require("react"),re=require("@react-protected/core");var y={exports:{}},_={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var D;function te(){if(D)return _;D=1;var u=Symbol.for("react.transitional.element"),d=Symbol.for("react.fragment");function c(l,a,s){var i=null;if(s!==void 0&&(i=""+s),a.key!==void 0&&(i=""+a.key),"key"in a){s={};for(var f in a)f!=="key"&&(s[f]=a[f])}else s=a;return a=s.ref,{$$typeof:u,type:l,key:i,ref:a!==void 0?a:null,props:s}}return _.Fragment=d,_.jsx=c,_.jsxs=c,_}var v={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var M;function ne(){return M||(M=1,process.env.NODE_ENV!=="production"&&function(){function u(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Q?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case O:return"Fragment";case z:return"Profiler";case V:return"StrictMode";case X:return"Suspense";case B:return"SuspenseList";case Z:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case q:return"Portal";case U:return e.displayName||"Context";case G:return(e._context.displayName||"Context")+".Consumer";case J:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case H:return r=e.displayName||null,r!==null?r:u(e.type)||"Memo";case w:r=e._payload,e=e._init;try{return u(e(r))}catch{}}return null}function d(e){return""+e}function c(e){try{d(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,n=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",n),d(e)}}function l(e){if(e===O)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===w)return"<...>";try{var r=u(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function a(){var e=S.A;return e===null?null:e.getOwner()}function s(){return Error("react-stack-top-frame")}function i(e){if(h.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function f(e,r){function t(){C||(C=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function b(){var e=u(this.type);return Y[e]||(Y[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function p(e,r,t,n,k,P){var o=t.ref;return e={$$typeof:N,type:e,key:r,props:t,_owner:n},(o!==void 0?o:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:b}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:k}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:P}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function E(e,r,t,n,k,P){var o=r.children;if(o!==void 0)if(n)if(K(o)){for(n=0;n<o.length;n++)T(o[n]);Object.freeze&&Object.freeze(o)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else T(o);if(h.call(r,"key")){o=u(e);var m=Object.keys(r).filter(function(ee){return ee!=="key"});n=0<m.length?"{key: someKey, "+m.join(": ..., ")+": ...}":"{key: someKey}",F[o+n]||(m=0<m.length?"{"+m.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
|
+
let props = %s;
|
|
19
|
+
<%s {...props} />
|
|
20
|
+
React keys must be passed directly to JSX without using spread:
|
|
21
|
+
let props = %s;
|
|
22
|
+
<%s key={someKey} {...props} />`,n,o,m,o),F[o+n]=!0)}if(o=null,t!==void 0&&(c(t),o=""+t),i(r)&&(c(r.key),o=""+r.key),"key"in r){t={};for(var j in r)j!=="key"&&(t[j]=r[j])}else t=r;return o&&f(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),p(e,o,t,a(),k,P)}function T(e){g(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===w&&(e._payload.status==="fulfilled"?g(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function g(e){return typeof e=="object"&&e!==null&&e.$$typeof===N}var A=R,N=Symbol.for("react.transitional.element"),q=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),V=Symbol.for("react.strict_mode"),z=Symbol.for("react.profiler"),G=Symbol.for("react.consumer"),U=Symbol.for("react.context"),J=Symbol.for("react.forward_ref"),X=Symbol.for("react.suspense"),B=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),w=Symbol.for("react.lazy"),Z=Symbol.for("react.activity"),Q=Symbol.for("react.client.reference"),S=A.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,h=Object.prototype.hasOwnProperty,K=Array.isArray,x=console.createTask?console.createTask:function(){return null};A={react_stack_bottom_frame:function(e){return e()}};var C,Y={},$=A.react_stack_bottom_frame.bind(A,s)(),I=x(l(s)),F={};v.Fragment=O,v.jsx=function(e,r,t){var n=1e4>S.recentlyCreatedOwnerStacks++;return E(e,r,t,!1,n?Error("react-stack-top-frame"):$,n?x(l(e)):I)},v.jsxs=function(e,r,t){var n=1e4>S.recentlyCreatedOwnerStacks++;return E(e,r,t,!0,n?Error("react-stack-top-frame"):$,n?x(l(e)):I)}}()),v}process.env.NODE_ENV==="production"?y.exports=te():y.exports=ne();var L=y.exports;const W=R.createContext(null);function oe({children:u,loginPath:d="/login",forbiddenPath:c="/403",defaultPath:l="/",callbackUrlParam:a,shouldAddCallbackUrl:s,getUser:i,isAuthenticated:f,hasRole:b,hasPermission:p}){const E=R.useMemo(()=>re.createGuard({getUser:i,isAuthenticated:f,hasRole:b,hasPermission:p}),[i,f,b,p]),T=R.useMemo(()=>({guard:E,loginPath:d,forbiddenPath:c,defaultPath:l,callbackUrlParam:a,shouldAddCallbackUrl:s}),[E,d,c,l,a,s]);return L.jsx(W.Provider,{value:T,children:u})}function ae(){const u=R.useContext(W);if(!u)throw new Error("useAccess must be used within <AccessProvider>");return u}exports.AccessProvider=oe;exports.jsxRuntimeExports=L;exports.useAccess=ae;
|
package/dist/AccessProvider.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { AccessContextValue, AccessProviderProps } from './types';
|
|
2
|
-
export declare function AccessProvider<TUser = unknown>({ children, loginPath, forbiddenPath, defaultPath, callbackUrlParam, getUser, isAuthenticated, hasRole, hasPermission, }: AccessProviderProps<TUser>): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function AccessProvider<TUser = unknown>({ children, loginPath, forbiddenPath, defaultPath, callbackUrlParam, shouldAddCallbackUrl, getUser, isAuthenticated, hasRole, hasPermission, }: AccessProviderProps<TUser>): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export declare function useAccess<TUser = unknown>(): AccessContextValue<TUser>;
|
package/dist/index.cjs
CHANGED
|
@@ -1,22 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
* @license React
|
|
3
|
-
* react-jsx-runtime.production.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var M;function ne(){if(M)return E;M=1;var a=Symbol.for("react.transitional.element"),u=Symbol.for("react.fragment");function l(i,s,c){var f=null;if(c!==void 0&&(f=""+c),s.key!==void 0&&(f=""+s.key),"key"in s){c={};for(var d in s)d!=="key"&&(c[d]=s[d])}else c=s;return s=c.ref,{$$typeof:a,type:i,key:f,ref:s!==void 0?s:null,props:c}}return E.Fragment=u,E.jsx=l,E.jsxs=l,E}var _={};/**
|
|
10
|
-
* @license React
|
|
11
|
-
* react-jsx-runtime.development.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var D;function oe(){return D||(D=1,process.env.NODE_ENV!=="production"&&function(){function a(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===K?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case k:return"Fragment";case z:return"Profiler";case V:return"StrictMode";case X:return"Suspense";case B:return"SuspenseList";case Q:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case U:return"Portal";case H:return e.displayName||"Context";case G:return(e._context.displayName||"Context")+".Consumer";case J:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Z:return r=e.displayName||null,r!==null?r:a(e.type)||"Memo";case O:r=e._payload,e=e._init;try{return a(e(r))}catch{}}return null}function u(e){return""+e}function l(e){try{u(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,n=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",n),u(e)}}function i(e){if(e===k)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===O)return"<...>";try{var r=a(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function s(){var e=w.A;return e===null?null:e.getOwner()}function c(){return Error("react-stack-top-frame")}function f(e){if(h.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function d(e,r){function t(){C||(C=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function b(){var e=a(this.type);return Y[e]||(Y[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function R(e,r,t,n,A,y){var o=t.ref;return e={$$typeof:N,type:e,key:r,props:t,_owner:n},(o!==void 0?o:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:b}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:A}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:y}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function T(e,r,t,n,A,y){var o=r.children;if(o!==void 0)if(n)if(ee(o)){for(n=0;n<o.length;n++)j(o[n]);Object.freeze&&Object.freeze(o)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else j(o);if(h.call(r,"key")){o=a(e);var m=Object.keys(r).filter(function(re){return re!=="key"});n=0<m.length?"{key: someKey, "+m.join(": ..., ")+": ...}":"{key: someKey}",F[o+n]||(m=0<m.length?"{"+m.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
|
-
let props = %s;
|
|
19
|
-
<%s {...props} />
|
|
20
|
-
React keys must be passed directly to JSX without using spread:
|
|
21
|
-
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,n,o,m,o),F[o+n]=!0)}if(o=null,t!==void 0&&(l(t),o=""+t),f(r)&&(l(r.key),o=""+r.key),"key"in r){t={};for(var P in r)P!=="key"&&(t[P]=r[P])}else t=r;return o&&d(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),R(e,o,t,s(),A,y)}function j(e){x(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===O&&(e._payload.status==="fulfilled"?x(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function x(e){return typeof e=="object"&&e!==null&&e.$$typeof===N}var p=v,N=Symbol.for("react.transitional.element"),U=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),V=Symbol.for("react.strict_mode"),z=Symbol.for("react.profiler"),G=Symbol.for("react.consumer"),H=Symbol.for("react.context"),J=Symbol.for("react.forward_ref"),X=Symbol.for("react.suspense"),B=Symbol.for("react.suspense_list"),Z=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),Q=Symbol.for("react.activity"),K=Symbol.for("react.client.reference"),w=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,h=Object.prototype.hasOwnProperty,ee=Array.isArray,S=console.createTask?console.createTask:function(){return null};p={react_stack_bottom_frame:function(e){return e()}};var C,Y={},$=p.react_stack_bottom_frame.bind(p,c)(),I=S(i(c)),F={};_.Fragment=k,_.jsx=function(e,r,t){var n=1e4>w.recentlyCreatedOwnerStacks++;return T(e,r,t,!1,n?Error("react-stack-top-frame"):$,n?S(i(e)):I)},_.jsxs=function(e,r,t){var n=1e4>w.recentlyCreatedOwnerStacks++;return T(e,r,t,!0,n?Error("react-stack-top-frame"):$,n?S(i(e)):I)}}()),_}process.env.NODE_ENV==="production"?g.exports=ne():g.exports=oe();var ae=g.exports;const L=v.createContext(null);function se({children:a,loginPath:u="/login",forbiddenPath:l="/403",defaultPath:i="/",callbackUrlParam:s,getUser:c,isAuthenticated:f,hasRole:d,hasPermission:b}){const R=v.useMemo(()=>te.createGuard({getUser:c,isAuthenticated:f,hasRole:d,hasPermission:b}),[c,f,d,b]),T=v.useMemo(()=>({guard:R,loginPath:u,forbiddenPath:l,defaultPath:i,callbackUrlParam:s}),[R,u,l,i,s]);return ae.jsx(L.Provider,{value:T,children:a})}function W(){const a=v.useContext(L);if(!a)throw new Error("useAccess must be used within <AccessProvider>");return a}function q(a){const{guard:u}=W();return u.check(a).allowed}function ce({access:a,roles:u,permissions:l,meta:i,children:s}){return q({access:a,roles:u,permissions:l,meta:i})?s??null:null}exports.AccessProvider=se;exports.HasAccess=ce;exports.useAccess=W;exports.useHasAccess=q;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./AccessProvider-sHL1A3i9.js");function r(s){const{guard:e}=c.useAccess();return e.check(s).allowed}function n({access:s,roles:e,permissions:u,meta:o,children:l}){return r({access:s,roles:e,permissions:u,meta:o})?l??null:null}exports.AccessProvider=c.AccessProvider;exports.useAccess=c.useAccess;exports.HasAccess=n;exports.useHasAccess=r;
|
package/dist/index.js
CHANGED
|
@@ -1,323 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* react-jsx-runtime.production.js
|
|
7
|
-
*
|
|
8
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
9
|
-
*
|
|
10
|
-
* This source code is licensed under the MIT license found in the
|
|
11
|
-
* LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/
|
|
13
|
-
var D;
|
|
14
|
-
function oe() {
|
|
15
|
-
if (D) return E;
|
|
16
|
-
D = 1;
|
|
17
|
-
var a = Symbol.for("react.transitional.element"), c = Symbol.for("react.fragment");
|
|
18
|
-
function l(i, s, u) {
|
|
19
|
-
var f = null;
|
|
20
|
-
if (u !== void 0 && (f = "" + u), s.key !== void 0 && (f = "" + s.key), "key" in s) {
|
|
21
|
-
u = {};
|
|
22
|
-
for (var d in s)
|
|
23
|
-
d !== "key" && (u[d] = s[d]);
|
|
24
|
-
} else u = s;
|
|
25
|
-
return s = u.ref, {
|
|
26
|
-
$$typeof: a,
|
|
27
|
-
type: i,
|
|
28
|
-
key: f,
|
|
29
|
-
ref: s !== void 0 ? s : null,
|
|
30
|
-
props: u
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
return E.Fragment = c, E.jsx = l, E.jsxs = l, E;
|
|
1
|
+
import { u as l } from "./AccessProvider-DTsMa_Df.mjs";
|
|
2
|
+
import { A as f } from "./AccessProvider-DTsMa_Df.mjs";
|
|
3
|
+
function n(s) {
|
|
4
|
+
const { guard: e } = l();
|
|
5
|
+
return e.check(s).allowed;
|
|
34
6
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
* @license React
|
|
38
|
-
* react-jsx-runtime.development.js
|
|
39
|
-
*
|
|
40
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
41
|
-
*
|
|
42
|
-
* This source code is licensed under the MIT license found in the
|
|
43
|
-
* LICENSE file in the root directory of this source tree.
|
|
44
|
-
*/
|
|
45
|
-
var M;
|
|
46
|
-
function ae() {
|
|
47
|
-
return M || (M = 1, process.env.NODE_ENV !== "production" && function() {
|
|
48
|
-
function a(e) {
|
|
49
|
-
if (e == null) return null;
|
|
50
|
-
if (typeof e == "function")
|
|
51
|
-
return e.$$typeof === Z ? null : e.displayName || e.name || null;
|
|
52
|
-
if (typeof e == "string") return e;
|
|
53
|
-
switch (e) {
|
|
54
|
-
case k:
|
|
55
|
-
return "Fragment";
|
|
56
|
-
case V:
|
|
57
|
-
return "Profiler";
|
|
58
|
-
case U:
|
|
59
|
-
return "StrictMode";
|
|
60
|
-
case J:
|
|
61
|
-
return "Suspense";
|
|
62
|
-
case X:
|
|
63
|
-
return "SuspenseList";
|
|
64
|
-
case B:
|
|
65
|
-
return "Activity";
|
|
66
|
-
}
|
|
67
|
-
if (typeof e == "object")
|
|
68
|
-
switch (typeof e.tag == "number" && console.error(
|
|
69
|
-
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
70
|
-
), e.$$typeof) {
|
|
71
|
-
case W:
|
|
72
|
-
return "Portal";
|
|
73
|
-
case G:
|
|
74
|
-
return e.displayName || "Context";
|
|
75
|
-
case z:
|
|
76
|
-
return (e._context.displayName || "Context") + ".Consumer";
|
|
77
|
-
case q:
|
|
78
|
-
var r = e.render;
|
|
79
|
-
return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
80
|
-
case H:
|
|
81
|
-
return r = e.displayName || null, r !== null ? r : a(e.type) || "Memo";
|
|
82
|
-
case A:
|
|
83
|
-
r = e._payload, e = e._init;
|
|
84
|
-
try {
|
|
85
|
-
return a(e(r));
|
|
86
|
-
} catch {
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
function c(e) {
|
|
92
|
-
return "" + e;
|
|
93
|
-
}
|
|
94
|
-
function l(e) {
|
|
95
|
-
try {
|
|
96
|
-
c(e);
|
|
97
|
-
var r = !1;
|
|
98
|
-
} catch {
|
|
99
|
-
r = !0;
|
|
100
|
-
}
|
|
101
|
-
if (r) {
|
|
102
|
-
r = console;
|
|
103
|
-
var t = r.error, n = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
104
|
-
return t.call(
|
|
105
|
-
r,
|
|
106
|
-
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
107
|
-
n
|
|
108
|
-
), c(e);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
function i(e) {
|
|
112
|
-
if (e === k) return "<>";
|
|
113
|
-
if (typeof e == "object" && e !== null && e.$$typeof === A)
|
|
114
|
-
return "<...>";
|
|
115
|
-
try {
|
|
116
|
-
var r = a(e);
|
|
117
|
-
return r ? "<" + r + ">" : "<...>";
|
|
118
|
-
} catch {
|
|
119
|
-
return "<...>";
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
function s() {
|
|
123
|
-
var e = w.A;
|
|
124
|
-
return e === null ? null : e.getOwner();
|
|
125
|
-
}
|
|
126
|
-
function u() {
|
|
127
|
-
return Error("react-stack-top-frame");
|
|
128
|
-
}
|
|
129
|
-
function f(e) {
|
|
130
|
-
if (N.call(e, "key")) {
|
|
131
|
-
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
132
|
-
if (r && r.isReactWarning) return !1;
|
|
133
|
-
}
|
|
134
|
-
return e.key !== void 0;
|
|
135
|
-
}
|
|
136
|
-
function d(e, r) {
|
|
137
|
-
function t() {
|
|
138
|
-
h || (h = !0, console.error(
|
|
139
|
-
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
140
|
-
r
|
|
141
|
-
));
|
|
142
|
-
}
|
|
143
|
-
t.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
144
|
-
get: t,
|
|
145
|
-
configurable: !0
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
function v() {
|
|
149
|
-
var e = a(this.type);
|
|
150
|
-
return C[e] || (C[e] = !0, console.error(
|
|
151
|
-
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
152
|
-
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
153
|
-
}
|
|
154
|
-
function R(e, r, t, n, T, S) {
|
|
155
|
-
var o = t.ref;
|
|
156
|
-
return e = {
|
|
157
|
-
$$typeof: g,
|
|
158
|
-
type: e,
|
|
159
|
-
key: r,
|
|
160
|
-
props: t,
|
|
161
|
-
_owner: n
|
|
162
|
-
}, (o !== void 0 ? o : null) !== null ? Object.defineProperty(e, "ref", {
|
|
163
|
-
enumerable: !1,
|
|
164
|
-
get: v
|
|
165
|
-
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
166
|
-
configurable: !1,
|
|
167
|
-
enumerable: !1,
|
|
168
|
-
writable: !0,
|
|
169
|
-
value: 0
|
|
170
|
-
}), Object.defineProperty(e, "_debugInfo", {
|
|
171
|
-
configurable: !1,
|
|
172
|
-
enumerable: !1,
|
|
173
|
-
writable: !0,
|
|
174
|
-
value: null
|
|
175
|
-
}), Object.defineProperty(e, "_debugStack", {
|
|
176
|
-
configurable: !1,
|
|
177
|
-
enumerable: !1,
|
|
178
|
-
writable: !0,
|
|
179
|
-
value: T
|
|
180
|
-
}), Object.defineProperty(e, "_debugTask", {
|
|
181
|
-
configurable: !1,
|
|
182
|
-
enumerable: !1,
|
|
183
|
-
writable: !0,
|
|
184
|
-
value: S
|
|
185
|
-
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
186
|
-
}
|
|
187
|
-
function b(e, r, t, n, T, S) {
|
|
188
|
-
var o = r.children;
|
|
189
|
-
if (o !== void 0)
|
|
190
|
-
if (n)
|
|
191
|
-
if (Q(o)) {
|
|
192
|
-
for (n = 0; n < o.length; n++)
|
|
193
|
-
P(o[n]);
|
|
194
|
-
Object.freeze && Object.freeze(o);
|
|
195
|
-
} else
|
|
196
|
-
console.error(
|
|
197
|
-
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
198
|
-
);
|
|
199
|
-
else P(o);
|
|
200
|
-
if (N.call(r, "key")) {
|
|
201
|
-
o = a(e);
|
|
202
|
-
var m = Object.keys(r).filter(function(K) {
|
|
203
|
-
return K !== "key";
|
|
204
|
-
});
|
|
205
|
-
n = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", I[o + n] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
206
|
-
`A props object containing a "key" prop is being spread into JSX:
|
|
207
|
-
let props = %s;
|
|
208
|
-
<%s {...props} />
|
|
209
|
-
React keys must be passed directly to JSX without using spread:
|
|
210
|
-
let props = %s;
|
|
211
|
-
<%s key={someKey} {...props} />`,
|
|
212
|
-
n,
|
|
213
|
-
o,
|
|
214
|
-
m,
|
|
215
|
-
o
|
|
216
|
-
), I[o + n] = !0);
|
|
217
|
-
}
|
|
218
|
-
if (o = null, t !== void 0 && (l(t), o = "" + t), f(r) && (l(r.key), o = "" + r.key), "key" in r) {
|
|
219
|
-
t = {};
|
|
220
|
-
for (var x in r)
|
|
221
|
-
x !== "key" && (t[x] = r[x]);
|
|
222
|
-
} else t = r;
|
|
223
|
-
return o && d(
|
|
224
|
-
t,
|
|
225
|
-
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
226
|
-
), R(
|
|
227
|
-
e,
|
|
228
|
-
o,
|
|
229
|
-
t,
|
|
230
|
-
s(),
|
|
231
|
-
T,
|
|
232
|
-
S
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
function P(e) {
|
|
236
|
-
j(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === A && (e._payload.status === "fulfilled" ? j(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
237
|
-
}
|
|
238
|
-
function j(e) {
|
|
239
|
-
return typeof e == "object" && e !== null && e.$$typeof === g;
|
|
240
|
-
}
|
|
241
|
-
var p = ee, g = Symbol.for("react.transitional.element"), W = Symbol.for("react.portal"), k = Symbol.for("react.fragment"), U = Symbol.for("react.strict_mode"), V = Symbol.for("react.profiler"), z = Symbol.for("react.consumer"), G = Symbol.for("react.context"), q = Symbol.for("react.forward_ref"), J = Symbol.for("react.suspense"), X = Symbol.for("react.suspense_list"), H = Symbol.for("react.memo"), A = Symbol.for("react.lazy"), B = Symbol.for("react.activity"), Z = Symbol.for("react.client.reference"), w = p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, N = Object.prototype.hasOwnProperty, Q = Array.isArray, O = console.createTask ? console.createTask : function() {
|
|
242
|
-
return null;
|
|
243
|
-
};
|
|
244
|
-
p = {
|
|
245
|
-
react_stack_bottom_frame: function(e) {
|
|
246
|
-
return e();
|
|
247
|
-
}
|
|
248
|
-
};
|
|
249
|
-
var h, C = {}, Y = p.react_stack_bottom_frame.bind(
|
|
250
|
-
p,
|
|
251
|
-
u
|
|
252
|
-
)(), $ = O(i(u)), I = {};
|
|
253
|
-
_.Fragment = k, _.jsx = function(e, r, t) {
|
|
254
|
-
var n = 1e4 > w.recentlyCreatedOwnerStacks++;
|
|
255
|
-
return b(
|
|
256
|
-
e,
|
|
257
|
-
r,
|
|
258
|
-
t,
|
|
259
|
-
!1,
|
|
260
|
-
n ? Error("react-stack-top-frame") : Y,
|
|
261
|
-
n ? O(i(e)) : $
|
|
262
|
-
);
|
|
263
|
-
}, _.jsxs = function(e, r, t) {
|
|
264
|
-
var n = 1e4 > w.recentlyCreatedOwnerStacks++;
|
|
265
|
-
return b(
|
|
266
|
-
e,
|
|
267
|
-
r,
|
|
268
|
-
t,
|
|
269
|
-
!0,
|
|
270
|
-
n ? Error("react-stack-top-frame") : Y,
|
|
271
|
-
n ? O(i(e)) : $
|
|
272
|
-
);
|
|
273
|
-
};
|
|
274
|
-
}()), _;
|
|
275
|
-
}
|
|
276
|
-
process.env.NODE_ENV === "production" ? y.exports = oe() : y.exports = ae();
|
|
277
|
-
var se = y.exports;
|
|
278
|
-
const L = re(null);
|
|
279
|
-
function fe({
|
|
280
|
-
children: a,
|
|
281
|
-
loginPath: c = "/login",
|
|
282
|
-
forbiddenPath: l = "/403",
|
|
283
|
-
defaultPath: i = "/",
|
|
284
|
-
callbackUrlParam: s,
|
|
285
|
-
getUser: u,
|
|
286
|
-
isAuthenticated: f,
|
|
287
|
-
hasRole: d,
|
|
288
|
-
hasPermission: v
|
|
289
|
-
}) {
|
|
290
|
-
const R = F(
|
|
291
|
-
() => ne({ getUser: u, isAuthenticated: f, hasRole: d, hasPermission: v }),
|
|
292
|
-
[u, f, d, v]
|
|
293
|
-
), b = F(
|
|
294
|
-
() => ({
|
|
295
|
-
guard: R,
|
|
296
|
-
loginPath: c,
|
|
297
|
-
forbiddenPath: l,
|
|
298
|
-
defaultPath: i,
|
|
299
|
-
callbackUrlParam: s
|
|
300
|
-
}),
|
|
301
|
-
[R, c, l, i, s]
|
|
302
|
-
);
|
|
303
|
-
return /* @__PURE__ */ se.jsx(L.Provider, { value: b, children: a });
|
|
304
|
-
}
|
|
305
|
-
function ue() {
|
|
306
|
-
const a = te(L);
|
|
307
|
-
if (!a)
|
|
308
|
-
throw new Error("useAccess must be used within <AccessProvider>");
|
|
309
|
-
return a;
|
|
310
|
-
}
|
|
311
|
-
function ce(a) {
|
|
312
|
-
const { guard: c } = ue();
|
|
313
|
-
return c.check(a).allowed;
|
|
314
|
-
}
|
|
315
|
-
function de({ access: a, roles: c, permissions: l, meta: i, children: s }) {
|
|
316
|
-
return ce({ access: a, roles: c, permissions: l, meta: i }) ? s ?? null : null;
|
|
7
|
+
function a({ access: s, roles: e, permissions: c, meta: o, children: r }) {
|
|
8
|
+
return n({ access: s, roles: e, permissions: c, meta: o }) ? r ?? null : null;
|
|
317
9
|
}
|
|
318
10
|
export {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
11
|
+
f as AccessProvider,
|
|
12
|
+
a as HasAccess,
|
|
13
|
+
l as useAccess,
|
|
14
|
+
n as useHasAccess
|
|
323
15
|
};
|
package/dist/testing.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./AccessProvider-sHL1A3i9.js");function a({user:s=null,allowed:e=!0,children:t,getUser:c,isAuthenticated:i,hasRole:o,hasPermission:n,loginPath:u,forbiddenPath:P,defaultPath:d,callbackUrlParam:v,shouldAddCallbackUrl:A}){return r.jsxRuntimeExports.jsx(r.AccessProvider,{getUser:c??(()=>s),isAuthenticated:i??(()=>e),hasRole:o??(()=>e),hasPermission:n??(()=>e),loginPath:u,forbiddenPath:P,defaultPath:d,callbackUrlParam:v,shouldAddCallbackUrl:A,children:t})}exports.MockAccessProvider=a;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GuardOptions } from '@react-protected/core';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { NavigationConfig } from './types';
|
|
4
|
+
export type MockAccessProviderProps<TUser = unknown> = Partial<GuardOptions<TUser>> & NavigationConfig & {
|
|
5
|
+
user?: TUser | null;
|
|
6
|
+
allowed?: boolean;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
export declare function MockAccessProvider<TUser = unknown>({ user, allowed, children, getUser, isAuthenticated, hasRole, hasPermission, loginPath, forbiddenPath, defaultPath, callbackUrlParam, shouldAddCallbackUrl, }: MockAccessProviderProps<TUser>): import("react/jsx-runtime").JSX.Element;
|
package/dist/testing.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { j as a, A as h } from "./AccessProvider-DTsMa_Df.mjs";
|
|
2
|
+
function p({
|
|
3
|
+
user: r = null,
|
|
4
|
+
allowed: s = !0,
|
|
5
|
+
children: e,
|
|
6
|
+
getUser: t,
|
|
7
|
+
isAuthenticated: i,
|
|
8
|
+
hasRole: o,
|
|
9
|
+
hasPermission: c,
|
|
10
|
+
loginPath: n,
|
|
11
|
+
forbiddenPath: u,
|
|
12
|
+
defaultPath: m,
|
|
13
|
+
callbackUrlParam: x,
|
|
14
|
+
shouldAddCallbackUrl: A
|
|
15
|
+
}) {
|
|
16
|
+
return /* @__PURE__ */ a.jsx(
|
|
17
|
+
h,
|
|
18
|
+
{
|
|
19
|
+
getUser: t ?? (() => r),
|
|
20
|
+
isAuthenticated: i ?? (() => s),
|
|
21
|
+
hasRole: o ?? (() => s),
|
|
22
|
+
hasPermission: c ?? (() => s),
|
|
23
|
+
loginPath: n,
|
|
24
|
+
forbiddenPath: u,
|
|
25
|
+
defaultPath: m,
|
|
26
|
+
callbackUrlParam: x,
|
|
27
|
+
shouldAddCallbackUrl: A,
|
|
28
|
+
children: e
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
p as MockAccessProvider
|
|
34
|
+
};
|
package/dist/types.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export type NavigationConfig = {
|
|
|
6
6
|
forbiddenPath?: string;
|
|
7
7
|
defaultPath?: string;
|
|
8
8
|
callbackUrlParam?: string;
|
|
9
|
+
shouldAddCallbackUrl?: () => boolean;
|
|
9
10
|
};
|
|
10
11
|
export type AccessContextValue<TUser = unknown> = {
|
|
11
12
|
guard: Guard<TUser>;
|
|
@@ -13,6 +14,7 @@ export type AccessContextValue<TUser = unknown> = {
|
|
|
13
14
|
forbiddenPath: string;
|
|
14
15
|
defaultPath: string;
|
|
15
16
|
callbackUrlParam?: string;
|
|
17
|
+
shouldAddCallbackUrl?: () => boolean;
|
|
16
18
|
};
|
|
17
19
|
export type AccessProviderProps<TUser = unknown> = GuardOptions<TUser> & NavigationConfig & {
|
|
18
20
|
children?: ReactNode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-protected/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-beta.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React context and hooks for react-protected",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -19,13 +19,18 @@
|
|
|
19
19
|
"import": "./dist/index.js",
|
|
20
20
|
"require": "./dist/index.cjs",
|
|
21
21
|
"types": "./dist/index.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./testing": {
|
|
24
|
+
"import": "./dist/testing.js",
|
|
25
|
+
"require": "./dist/testing.cjs",
|
|
26
|
+
"types": "./dist/testing.d.ts"
|
|
22
27
|
}
|
|
23
28
|
},
|
|
24
29
|
"files": [
|
|
25
30
|
"dist"
|
|
26
31
|
],
|
|
27
32
|
"dependencies": {
|
|
28
|
-
"@react-protected/core": "0.
|
|
33
|
+
"@react-protected/core": "0.2.0-beta.2"
|
|
29
34
|
},
|
|
30
35
|
"peerDependencies": {
|
|
31
36
|
"react": ">=18.0.0",
|