@react-protected/react 0.1.1-beta.0

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/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 react-protected contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,3 @@
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;
3
+ export declare function useAccess<TUser = unknown>(): AccessContextValue<TUser>;
@@ -0,0 +1,8 @@
1
+ import { ReactNode } from 'react';
2
+ import { RouteProtection } from './types';
3
+ type HasAccessProps = RouteProtection & {
4
+ children?: ReactNode;
5
+ };
6
+ export declare function useHasAccess(config: RouteProtection): boolean;
7
+ export declare function HasAccess({ access, roles, permissions, meta, children }: HasAccessProps): string | number | boolean | import('react').ReactElement<any, string | import('react').JSXElementConstructor<any>> | Iterable<ReactNode> | null;
8
+ export {};
package/dist/index.cjs ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react"),te=require("@react-protected/core");var g={exports:{}},E={};/**
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;
@@ -0,0 +1,3 @@
1
+ export { AccessProvider, useAccess } from './AccessProvider';
2
+ export { HasAccess, useHasAccess } from './HasAccess';
3
+ export type { AccessContextValue, AccessProviderProps, AccessRouteProps, NavigationConfig, RouteProtection, } from './types';
package/dist/index.js ADDED
@@ -0,0 +1,323 @@
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: {} }, E = {};
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 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;
34
+ }
35
+ var _ = {};
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;
317
+ }
318
+ export {
319
+ fe as AccessProvider,
320
+ de as HasAccess,
321
+ ue as useAccess,
322
+ ce as useHasAccess
323
+ };
@@ -0,0 +1,22 @@
1
+ import { AccessConfig, Guard, GuardOptions } from '@react-protected/core';
2
+ import { ReactNode } from 'react';
3
+ export type { AccessConfig as RouteProtection } from '@react-protected/core';
4
+ export type NavigationConfig = {
5
+ loginPath?: string;
6
+ forbiddenPath?: string;
7
+ defaultPath?: string;
8
+ callbackUrlParam?: string;
9
+ };
10
+ export type AccessContextValue<TUser = unknown> = {
11
+ guard: Guard<TUser>;
12
+ loginPath: string;
13
+ forbiddenPath: string;
14
+ defaultPath: string;
15
+ callbackUrlParam?: string;
16
+ };
17
+ export type AccessProviderProps<TUser = unknown> = GuardOptions<TUser> & NavigationConfig & {
18
+ children?: ReactNode;
19
+ };
20
+ export type AccessRouteProps = AccessConfig & {
21
+ children?: ReactNode;
22
+ };
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@react-protected/react",
3
+ "version": "0.1.1-beta.0",
4
+ "license": "MIT",
5
+ "description": "React context and hooks for react-protected",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/astakhovaskold/react-protected",
12
+ "directory": "packages/react"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "exports": {
18
+ ".": {
19
+ "import": "./dist/index.js",
20
+ "require": "./dist/index.cjs",
21
+ "types": "./dist/index.d.ts"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "dependencies": {
28
+ "@react-protected/core": "0.1.1-beta.0"
29
+ },
30
+ "peerDependencies": {
31
+ "react": ">=18.0.0",
32
+ "react-dom": ">=18.0.0"
33
+ },
34
+ "devDependencies": {
35
+ "@testing-library/react": "^16.3.2",
36
+ "@vitejs/plugin-react": "^4.0.0",
37
+ "jsdom": "^29.1.1",
38
+ "react": "^19.2.0",
39
+ "react-dom": "^19.2.0",
40
+ "vite": "^5.0.0",
41
+ "vite-plugin-dts": "^4.0.0"
42
+ },
43
+ "scripts": {
44
+ "build": "vite build",
45
+ "test": "vitest run"
46
+ }
47
+ }