@freshheads/react-auth 0.0.1-alpha.5 → 0.0.1-alpha.6

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.
Files changed (2) hide show
  1. package/dist/main.js +12 -14
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -16,7 +16,6 @@ const f = "jwt_hp", h = (t) => {
16
16
  return console.error(e), null;
17
17
  }
18
18
  }, d = async (t) => {
19
- "use server";
20
19
  const e = await A(), n = t || f;
21
20
  if (!e.has(n))
22
21
  return console.error("No cookie found with name:", n), null;
@@ -41,50 +40,49 @@ const z = (t) => {
41
40
  roles: e,
42
41
  hasRole: (o) => e === null ? !1 : e.includes(o)
43
42
  };
44
- }, v = (t, e) => {
43
+ }, L = (t, e) => {
45
44
  const n = `{/:locale}${t}`;
46
45
  return e ? n : t.replace(/\/\[\[\.\.\.([^\]]+)\]\]/g, "{/*$1}").replace(/\/\[\.\.\.([^\]]+)\]/g, "/*$1").replace(/\[([^\]]+)\]/g, ":$1");
47
46
  }, a = (t, e) => {
48
47
  const n = Object.values(t).map(
49
- (r) => x(v(r, e))
48
+ (r) => x(L(r, e))
50
49
  );
51
50
  return (r) => n.some((o) => o(r) !== !1);
52
- }, L = (t, e, n) => {
51
+ }, N = (t, e, n) => {
53
52
  const r = {
54
53
  ...e.unauthenticated.routes,
55
54
  ...e.open.routes
56
55
  };
57
56
  return !a(r, n)(t);
58
- }, N = (t, e, n) => a(
57
+ }, O = (t, e, n) => a(
59
58
  e.unauthenticated.routes,
60
59
  n
61
- )(t), O = (t, e, n) => a(
60
+ )(t), U = (t, e, n) => a(
62
61
  e.open.routes,
63
62
  n
64
- )(t), U = (t, e) => e[t]?.landing || e.default.landing, E = (t, e) => t.filter(
63
+ )(t), E = (t, e) => e[t]?.landing || e.default.landing, J = (t, e) => t.filter(
65
64
  (n) => e.includes(n)
66
- ), J = async (t, e) => E(t, e).length > 0, F = async (t) => {
67
- "use server";
65
+ ), S = async (t, e) => J(t, e).length > 0, F = async (t) => {
68
66
  const e = await d();
69
67
  return e === null ? !1 : e.includes(t);
70
68
  };
71
69
  function _(t) {
72
70
  return function(n, r) {
73
71
  const o = n.nextUrl.pathname, { rbac: s, authorizedRoles: m, withLocaleRoutePrefix: l, cookieName: g } = t;
74
- if (O(o, s, l))
72
+ if (U(o, s, l))
75
73
  return r ?? c.next();
76
74
  const u = y(
77
75
  n.cookies,
78
76
  g
79
- ), i = u !== null && u.length > 0, p = u === null || !i ? !1 : J(u, m);
80
- return (!i || !p) && L(o, s, l) ? c.redirect(
77
+ ), i = u !== null && u.length > 0, p = u === null || !i ? !1 : S(u, m);
78
+ return (!i || !p) && N(o, s, l) ? c.redirect(
81
79
  new URL(s.default.login, n.url),
82
80
  307
83
- ) : i && N(o, s, l) ? u === null || u.length === 0 || u[0] === void 0 ? c.redirect(
81
+ ) : i && O(o, s, l) ? u === null || u.length === 0 || u[0] === void 0 ? c.redirect(
84
82
  new URL(s.default.login, n.url),
85
83
  307
86
84
  ) : c.redirect(
87
- new URL(U(u[0], s), n.url),
85
+ new URL(E(u[0], s), n.url),
88
86
  307
89
87
  ) : r ?? c.next();
90
88
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@freshheads/react-auth",
3
- "version": "0.0.1-alpha.5",
3
+ "version": "0.0.1-alpha.6",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "tsc -b && vite build",