@freshheads/react-auth 0.0.1-alpha.2 → 0.0.1-alpha.4

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 +10 -8
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -15,6 +15,7 @@ const h = "jwt_hp", f = (t) => {
15
15
  return console.error(e), null;
16
16
  }
17
17
  }, R = async (t) => {
18
+ "use server";
18
19
  const e = await w(), n = h;
19
20
  if (!e.has(n))
20
21
  return console.error("No cookie found with name:", n), null;
@@ -42,35 +43,36 @@ const N = (t, e) => {
42
43
  ...e.open.routes
43
44
  };
44
45
  return !a(r, n)(t);
45
- }, y = (t, e, n) => a(
46
+ }, v = (t, e, n) => a(
46
47
  e.unauthenticated.routes,
47
48
  n
48
- )(t), L = (t, e, n) => a(
49
+ )(t), y = (t, e, n) => a(
49
50
  e.open.routes,
50
51
  n
51
- )(t), O = (t, e) => e[t]?.landing || e.default.landing, J = (t, e) => t.filter(
52
+ )(t), L = (t, e) => e[t]?.landing || e.default.landing, O = (t, e) => t.filter(
52
53
  (n) => e.includes(n)
53
- ), U = async (t, e) => J(t, e).length > 0, W = async (t) => {
54
+ ), J = async (t, e) => O(t, e).length > 0, W = async (t) => {
55
+ "use server";
54
56
  const e = await R();
55
57
  return e === null ? !1 : e.includes(t);
56
58
  };
57
59
  function $(t) {
58
60
  return function(n, r) {
59
61
  const o = n.nextUrl.pathname, { rbac: s, authorizedRoles: d, withLocaleRoutePrefix: i, cookieName: m } = t;
60
- if (L(o, s, i))
62
+ if (y(o, s, i))
61
63
  return r ?? c.next();
62
64
  const u = A(
63
65
  n.cookies,
64
66
  m
65
- ), l = u !== null && u.length > 0, g = u === null || !l ? !1 : U(u, d);
67
+ ), l = u !== null && u.length > 0, g = u === null || !l ? !1 : J(u, d);
66
68
  return (!l || !g) && x(o, s, i) ? c.redirect(
67
69
  new URL(s.default.login, n.url),
68
70
  307
69
- ) : l && y(o, s, i) ? u === null || u.length === 0 || u[0] === void 0 ? c.redirect(
71
+ ) : l && v(o, s, i) ? u === null || u.length === 0 || u[0] === void 0 ? c.redirect(
70
72
  new URL(s.default.login, n.url),
71
73
  307
72
74
  ) : c.redirect(
73
- new URL(O(u[0], s), n.url),
75
+ new URL(L(u[0], s), n.url),
74
76
  307
75
77
  ) : r ?? c.next();
76
78
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@freshheads/react-auth",
3
- "version": "0.0.1-alpha.2",
3
+ "version": "0.0.1-alpha.4",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "tsc -b && vite build",