@skylabs-digital/react-identity-access 2.8.0 → 2.9.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/dist/index.es.js +259 -258
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/providers/AuthProvider.d.ts.map +1 -1
- package/dist/types/authParams.d.ts +1 -0
- package/dist/types/authParams.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as n, Fragment as j, jsxs as l } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as ue, useMemo as
|
|
3
|
-
import { useLocation as
|
|
4
|
-
class
|
|
2
|
+
import { createContext as ue, useMemo as Q, useState as S, useCallback as ie, useEffect as re, useContext as se, useRef as Ge } from "react";
|
|
3
|
+
import { useLocation as ve, Navigate as pe } from "react-router-dom";
|
|
4
|
+
class ne {
|
|
5
5
|
// SessionManager instance
|
|
6
6
|
constructor(e, t = 1e4) {
|
|
7
7
|
this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
|
|
@@ -65,7 +65,7 @@ class re {
|
|
|
65
65
|
return this.request("DELETE", e, void 0, t);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
class
|
|
68
|
+
class Me {
|
|
69
69
|
constructor(e, t) {
|
|
70
70
|
this.httpService = e, this.sessionManager = t;
|
|
71
71
|
}
|
|
@@ -124,9 +124,9 @@ class Pe {
|
|
|
124
124
|
})).data;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
const
|
|
128
|
-
function
|
|
129
|
-
const t =
|
|
127
|
+
const ke = ue(null);
|
|
128
|
+
function qt({ config: i, children: e }) {
|
|
129
|
+
const t = Q(
|
|
130
130
|
() => {
|
|
131
131
|
var f, A, E;
|
|
132
132
|
return {
|
|
@@ -147,7 +147,7 @@ function Bt({ config: i, children: e }) {
|
|
|
147
147
|
} catch {
|
|
148
148
|
return null;
|
|
149
149
|
}
|
|
150
|
-
}), [o, a] = S(!r), [g, w] = S(null), m =
|
|
150
|
+
}), [o, a] = S(!r), [g, w] = S(null), m = Q(() => {
|
|
151
151
|
const f = () => {
|
|
152
152
|
k();
|
|
153
153
|
};
|
|
@@ -160,12 +160,12 @@ function Bt({ config: i, children: e }) {
|
|
|
160
160
|
appError: g,
|
|
161
161
|
retryApp: f
|
|
162
162
|
};
|
|
163
|
-
}, [i, r, o, g]), k =
|
|
163
|
+
}, [i, r, o, g]), k = ie(
|
|
164
164
|
async (f = !1) => {
|
|
165
165
|
if (!(!f && t.enabled && r))
|
|
166
166
|
try {
|
|
167
167
|
a(!0), w(null);
|
|
168
|
-
const A = new
|
|
168
|
+
const A = new ne(i.baseUrl), $ = await new Me(A, {}).getPublicAppInfo(i.appId);
|
|
169
169
|
if (s($), t.enabled)
|
|
170
170
|
try {
|
|
171
171
|
const L = {
|
|
@@ -185,14 +185,14 @@ function Bt({ config: i, children: e }) {
|
|
|
185
185
|
}
|
|
186
186
|
},
|
|
187
187
|
[i.baseUrl, i.appId, t, r]
|
|
188
|
-
), b =
|
|
188
|
+
), b = ie(async () => {
|
|
189
189
|
if (!(!t.enabled || !r))
|
|
190
190
|
try {
|
|
191
191
|
const f = localStorage.getItem(t.storageKey);
|
|
192
192
|
if (!f) return;
|
|
193
193
|
const A = JSON.parse(f);
|
|
194
194
|
if (Date.now() - A.timestamp > t.ttl * 0.5) {
|
|
195
|
-
const $ = new
|
|
195
|
+
const $ = new ne(i.baseUrl), P = await new Me($, {}).getPublicAppInfo(i.appId);
|
|
196
196
|
s(P);
|
|
197
197
|
const u = {
|
|
198
198
|
data: P,
|
|
@@ -205,21 +205,21 @@ function Bt({ config: i, children: e }) {
|
|
|
205
205
|
console.warn("Background app refresh failed:", f);
|
|
206
206
|
}
|
|
207
207
|
}, [i, t, r]);
|
|
208
|
-
return
|
|
208
|
+
return re(() => {
|
|
209
209
|
r ? b() : k();
|
|
210
|
-
}, []), /* @__PURE__ */ n(
|
|
210
|
+
}, []), /* @__PURE__ */ n(ke.Provider, { value: m, children: e });
|
|
211
211
|
}
|
|
212
212
|
function he() {
|
|
213
|
-
const i =
|
|
213
|
+
const i = se(ke);
|
|
214
214
|
if (!i)
|
|
215
215
|
throw new Error("useApp must be used within an AppProvider");
|
|
216
216
|
return i;
|
|
217
217
|
}
|
|
218
|
-
function
|
|
219
|
-
return
|
|
218
|
+
function Fe() {
|
|
219
|
+
return se(ke);
|
|
220
220
|
}
|
|
221
|
-
const
|
|
222
|
-
class
|
|
221
|
+
const zt = he;
|
|
222
|
+
class Se {
|
|
223
223
|
constructor(e = {}) {
|
|
224
224
|
this.refreshPromise = null, this.refreshQueue = [], e.tenantSlug !== void 0 ? this.storageKey = e.tenantSlug ? `auth_tokens_${e.tenantSlug}` : "auth_tokens" : this.storageKey = e.storageKey || "auth_tokens", this.autoRefresh = e.autoRefresh ?? !0, this.refreshThreshold = e.refreshThreshold || 3e5, this.onRefreshFailed = e.onRefreshFailed, this.baseUrl = e.baseUrl || "", this.tokenStorage = e.tokenStorage || this.createTokenStorage(this.storageKey);
|
|
225
225
|
}
|
|
@@ -417,7 +417,7 @@ class Ke {
|
|
|
417
417
|
});
|
|
418
418
|
}
|
|
419
419
|
}
|
|
420
|
-
class
|
|
420
|
+
class Ie {
|
|
421
421
|
constructor(e, t) {
|
|
422
422
|
this.httpService = e, this.sessionManager = t;
|
|
423
423
|
}
|
|
@@ -682,9 +682,9 @@ function nt() {
|
|
|
682
682
|
newUrl: i.toString()
|
|
683
683
|
}), window.history.replaceState({}, "", i.toString());
|
|
684
684
|
}
|
|
685
|
-
const
|
|
686
|
-
function
|
|
687
|
-
const { baseUrl: t, appInfo: r, appId: s } = he(), o =
|
|
685
|
+
const xe = ue(null);
|
|
686
|
+
function Ot({ config: i, children: e }) {
|
|
687
|
+
const { baseUrl: t, appInfo: r, appId: s } = he(), o = ie(() => typeof window > "u" ? null : Xe(
|
|
688
688
|
{
|
|
689
689
|
tenantMode: i.tenantMode || "selector",
|
|
690
690
|
baseDomain: i.baseDomain,
|
|
@@ -695,7 +695,7 @@ function zt({ config: i, children: e }) {
|
|
|
695
695
|
search: window.location.search
|
|
696
696
|
},
|
|
697
697
|
window.localStorage
|
|
698
|
-
), [i.tenantMode, i.baseDomain, i.selectorParam]), [a, g] = S(() => o()), w =
|
|
698
|
+
), [i.tenantMode, i.baseDomain, i.selectorParam]), [a, g] = S(() => o()), w = Q(
|
|
699
699
|
() => {
|
|
700
700
|
var c, R, T;
|
|
701
701
|
return {
|
|
@@ -718,16 +718,16 @@ function zt({ config: i, children: e }) {
|
|
|
718
718
|
return null;
|
|
719
719
|
}
|
|
720
720
|
}), [b, f] = S(!m && !i.initialTenant), [A, E] = S(null), [$, L] = S(null), [P, u] = S(!1), [M, z] = S(null);
|
|
721
|
-
|
|
721
|
+
re(() => {
|
|
722
722
|
const c = o();
|
|
723
723
|
g(c);
|
|
724
724
|
}, [o]);
|
|
725
|
-
const N = (r == null ? void 0 : r.settingsSchema) || null, p =
|
|
725
|
+
const N = (r == null ? void 0 : r.settingsSchema) || null, p = ie(
|
|
726
726
|
async (c, R = !1) => {
|
|
727
727
|
if (!(!R && w.enabled && m && m.domain === c))
|
|
728
728
|
try {
|
|
729
729
|
f(!0), E(null);
|
|
730
|
-
const T = new
|
|
730
|
+
const T = new ne(t), d = await new de(T, s).getPublicTenantInfo(c);
|
|
731
731
|
if (k(d), w.enabled)
|
|
732
732
|
try {
|
|
733
733
|
const y = {
|
|
@@ -747,14 +747,14 @@ function zt({ config: i, children: e }) {
|
|
|
747
747
|
}
|
|
748
748
|
},
|
|
749
749
|
[t, s, w, m]
|
|
750
|
-
), O =
|
|
750
|
+
), O = ie(async () => {
|
|
751
751
|
if (!(!w.enabled || !m || !a))
|
|
752
752
|
try {
|
|
753
753
|
const c = localStorage.getItem(w.storageKey);
|
|
754
754
|
if (!c) return;
|
|
755
755
|
const R = JSON.parse(c);
|
|
756
756
|
if (Date.now() - R.timestamp > w.ttl * 0.5) {
|
|
757
|
-
const h = new
|
|
757
|
+
const h = new ne(t), y = await new de(h, s).getPublicTenantInfo(a);
|
|
758
758
|
k(y);
|
|
759
759
|
const G = {
|
|
760
760
|
data: y,
|
|
@@ -766,11 +766,11 @@ function zt({ config: i, children: e }) {
|
|
|
766
766
|
} catch (c) {
|
|
767
767
|
console.warn("Background tenant refresh failed:", c);
|
|
768
768
|
}
|
|
769
|
-
}, [t, s, w, m, a]), v =
|
|
769
|
+
}, [t, s, w, m, a]), v = ie(async () => {
|
|
770
770
|
if (m != null && m.id)
|
|
771
771
|
try {
|
|
772
772
|
u(!0), z(null);
|
|
773
|
-
const c = new
|
|
773
|
+
const c = new ne(t), T = await new de(c, m.appId).getTenantSettings(m.id);
|
|
774
774
|
L(T);
|
|
775
775
|
} catch (c) {
|
|
776
776
|
const R = c instanceof Error ? c : new Error("Failed to load tenant settings");
|
|
@@ -778,9 +778,9 @@ function zt({ config: i, children: e }) {
|
|
|
778
778
|
} finally {
|
|
779
779
|
u(!1);
|
|
780
780
|
}
|
|
781
|
-
}, [t, m]), C =
|
|
781
|
+
}, [t, m]), C = ie(() => {
|
|
782
782
|
v();
|
|
783
|
-
}, [v]), x =
|
|
783
|
+
}, [v]), x = ie(
|
|
784
784
|
(c) => {
|
|
785
785
|
if (!N)
|
|
786
786
|
return { isValid: !0, errors: [] };
|
|
@@ -817,12 +817,12 @@ function zt({ config: i, children: e }) {
|
|
|
817
817
|
},
|
|
818
818
|
[N]
|
|
819
819
|
);
|
|
820
|
-
|
|
820
|
+
re(() => {
|
|
821
821
|
!i.initialTenant && a ? m ? O() : p(a) : !i.initialTenant && !a && (k(null), E(null), f(!1));
|
|
822
|
-
}, [i.initialTenant, a, m, p, O]),
|
|
822
|
+
}, [i.initialTenant, a, m, p, O]), re(() => {
|
|
823
823
|
m != null && m.id ? v() : (L(null), z(null), u(!1));
|
|
824
824
|
}, [m == null ? void 0 : m.id, v]);
|
|
825
|
-
const I =
|
|
825
|
+
const I = ie(
|
|
826
826
|
(c, R) => {
|
|
827
827
|
const { mode: T = "reload", tokens: h, redirectPath: d } = R || {}, y = i.tenantMode || "selector";
|
|
828
828
|
if (localStorage.setItem("tenant", c), y === "subdomain") {
|
|
@@ -839,8 +839,8 @@ function zt({ config: i, children: e }) {
|
|
|
839
839
|
return;
|
|
840
840
|
}
|
|
841
841
|
const H = d || window.location.pathname, U = new URL(`${window.location.protocol}//${D}${H}`);
|
|
842
|
-
new URLSearchParams(window.location.search).forEach((B,
|
|
843
|
-
|
|
842
|
+
new URLSearchParams(window.location.search).forEach((B, K) => {
|
|
843
|
+
K !== fe && U.searchParams.set(K, B);
|
|
844
844
|
}), h && U.searchParams.set(fe, et(h)), window.location.href = U.toString();
|
|
845
845
|
} else if (y === "selector") {
|
|
846
846
|
const G = d || window.location.pathname, D = new URLSearchParams(window.location.search);
|
|
@@ -854,7 +854,7 @@ function zt({ config: i, children: e }) {
|
|
|
854
854
|
}
|
|
855
855
|
},
|
|
856
856
|
[i.tenantMode, i.selectorParam, i.baseDomain, p]
|
|
857
|
-
), F =
|
|
857
|
+
), F = Q(() => ({
|
|
858
858
|
// Tenant info
|
|
859
859
|
tenant: m,
|
|
860
860
|
tenantSlug: a,
|
|
@@ -886,19 +886,19 @@ function zt({ config: i, children: e }) {
|
|
|
886
886
|
I,
|
|
887
887
|
x
|
|
888
888
|
]);
|
|
889
|
-
return /* @__PURE__ */ n(
|
|
889
|
+
return /* @__PURE__ */ n(xe.Provider, { value: F, children: e });
|
|
890
890
|
}
|
|
891
891
|
function me() {
|
|
892
|
-
const i =
|
|
892
|
+
const i = se(xe);
|
|
893
893
|
if (!i)
|
|
894
894
|
throw new Error("useTenant must be used within a TenantProvider");
|
|
895
895
|
return i;
|
|
896
896
|
}
|
|
897
897
|
function ye() {
|
|
898
|
-
return
|
|
898
|
+
return se(xe);
|
|
899
899
|
}
|
|
900
|
-
const
|
|
901
|
-
function
|
|
900
|
+
const Wt = me;
|
|
901
|
+
function jt() {
|
|
902
902
|
const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } = me();
|
|
903
903
|
return {
|
|
904
904
|
settings: i,
|
|
@@ -918,8 +918,8 @@ function le() {
|
|
|
918
918
|
retry: s
|
|
919
919
|
};
|
|
920
920
|
}
|
|
921
|
-
const
|
|
922
|
-
function
|
|
921
|
+
const Ae = ue(null);
|
|
922
|
+
function Vt({ config: i = {}, children: e }) {
|
|
923
923
|
const { appId: t, baseUrl: r } = he(), { tenant: s, tenantSlug: o, switchTenant: a } = me(), [g, w] = S(i.initialRoles || []), [m, k] = S(!i.initialRoles), [b, f] = S(null), [A, E] = S(!1), [$, L] = S(null), [P, u] = S(0), M = Ge({ done: !1, urlTokens: null });
|
|
924
924
|
M.current.done || (M.current.done = !0, M.current.urlTokens = rt(), M.current.urlTokens && console.log(
|
|
925
925
|
"[AuthProvider] SYNC: URL tokens found, will block isAuthReady until user loaded"
|
|
@@ -927,8 +927,8 @@ function jt({ config: i = {}, children: e }) {
|
|
|
927
927
|
const [z, N] = S(() => {
|
|
928
928
|
const D = M.current.urlTokens !== null;
|
|
929
929
|
return console.log("[AuthProvider] SYNC: isLoadingAfterUrlTokens initial:", D), D;
|
|
930
|
-
}), p =
|
|
931
|
-
const D = new
|
|
930
|
+
}), p = Q(() => {
|
|
931
|
+
const D = new Se({
|
|
932
932
|
tenantSlug: o,
|
|
933
933
|
onRefreshFailed: i.onRefreshFailed,
|
|
934
934
|
baseUrl: r
|
|
@@ -938,10 +938,10 @@ function jt({ config: i = {}, children: e }) {
|
|
|
938
938
|
refreshToken: M.current.urlTokens.refreshToken,
|
|
939
939
|
expiresIn: M.current.urlTokens.expiresIn
|
|
940
940
|
}), console.log("[AuthProvider] SYNC: Session valid:", D.hasValidSession())), D;
|
|
941
|
-
}, [o, r, i.onRefreshFailed]), O = M.current.done && !z, v =
|
|
942
|
-
const D = new
|
|
941
|
+
}, [o, r, i.onRefreshFailed]), O = M.current.done && !z, v = Q(() => {
|
|
942
|
+
const D = new ne(r);
|
|
943
943
|
return D.setSessionManager(p), D;
|
|
944
|
-
}, [r, p]), C =
|
|
944
|
+
}, [r, p]), C = Q(() => new Ke(new ne(r)), [r]), x = Q(() => new Je(v, p), [v, p]), I = Q(() => new Ie(new ne(r)), [r]), F = Q(() => b || p.getUser(), [b, p]), c = Q(() => F != null && F.roleId && g.find((D) => D.id === F.roleId) || null, [F, g]), R = Q(() => (c == null ? void 0 : c.permissions) || [], [c]), T = Q(() => p.hasValidSession() && b !== null, [p, b]), h = 5 * 60 * 1e3, d = Q(() => {
|
|
945
945
|
const D = async (q = !1) => {
|
|
946
946
|
try {
|
|
947
947
|
if (!p.hasValidSession())
|
|
@@ -958,132 +958,133 @@ function jt({ config: i = {}, children: e }) {
|
|
|
958
958
|
const Z = await x.getUserById(_);
|
|
959
959
|
f(Z), p.setUser(Z), u(Date.now());
|
|
960
960
|
} catch (W) {
|
|
961
|
-
const
|
|
962
|
-
L(
|
|
961
|
+
const J = W instanceof Error ? W : new Error("Failed to load user data");
|
|
962
|
+
L(J), console.error("[AuthProvider] Failed to load user data:", J);
|
|
963
963
|
} finally {
|
|
964
964
|
E(!1);
|
|
965
965
|
}
|
|
966
966
|
}, H = async () => {
|
|
967
967
|
await D();
|
|
968
968
|
}, U = async (q) => {
|
|
969
|
-
const { username: W, password:
|
|
970
|
-
let
|
|
971
|
-
_ && (
|
|
972
|
-
const
|
|
969
|
+
const { username: W, password: J, tenantSlug: _, redirectPath: Z } = q;
|
|
970
|
+
let ee = s == null ? void 0 : s.id, X = o, Y = p;
|
|
971
|
+
_ && (ee = (await new de(v, t).getPublicTenantInfo(_)).id, X = _);
|
|
972
|
+
const te = await C.login({
|
|
973
973
|
username: W,
|
|
974
|
-
password:
|
|
974
|
+
password: J,
|
|
975
975
|
appId: t,
|
|
976
|
-
tenantId:
|
|
977
|
-
}),
|
|
978
|
-
if (
|
|
979
|
-
tenantSlug:
|
|
976
|
+
tenantId: ee
|
|
977
|
+
}), ce = _ && _ !== o;
|
|
978
|
+
if (ce && (Y = new Se({
|
|
979
|
+
tenantSlug: X,
|
|
980
980
|
baseUrl: r
|
|
981
|
-
})),
|
|
982
|
-
accessToken:
|
|
983
|
-
refreshToken:
|
|
984
|
-
expiresIn:
|
|
985
|
-
}),
|
|
986
|
-
|
|
981
|
+
})), Y.setTokens({
|
|
982
|
+
accessToken: te.accessToken,
|
|
983
|
+
refreshToken: te.refreshToken,
|
|
984
|
+
expiresIn: te.expiresIn
|
|
985
|
+
}), te.user) {
|
|
986
|
+
Y.setUser(te.user), f(te.user);
|
|
987
987
|
try {
|
|
988
988
|
await D();
|
|
989
|
-
} catch (
|
|
990
|
-
console.warn("Failed to load complete user data after login:",
|
|
989
|
+
} catch (be) {
|
|
990
|
+
console.warn("Failed to load complete user data after login:", be);
|
|
991
991
|
}
|
|
992
992
|
}
|
|
993
|
-
return
|
|
993
|
+
return ce && X && X !== o && a(X, {
|
|
994
994
|
tokens: {
|
|
995
|
-
accessToken:
|
|
996
|
-
refreshToken:
|
|
997
|
-
expiresIn:
|
|
998
|
-
}
|
|
999
|
-
|
|
995
|
+
accessToken: te.accessToken,
|
|
996
|
+
refreshToken: te.refreshToken,
|
|
997
|
+
expiresIn: te.expiresIn
|
|
998
|
+
},
|
|
999
|
+
redirectPath: Z
|
|
1000
|
+
}), te;
|
|
1000
1001
|
}, V = async (q) => {
|
|
1001
|
-
const { email: W, phoneNumber:
|
|
1002
|
-
if (!W && !
|
|
1002
|
+
const { email: W, phoneNumber: J, name: _, password: Z, lastName: ee, tenantId: X } = q;
|
|
1003
|
+
if (!W && !J)
|
|
1003
1004
|
throw new Error("Either email or phoneNumber is required");
|
|
1004
1005
|
if (!_ || !Z)
|
|
1005
1006
|
throw new Error("Name and password are required");
|
|
1006
|
-
const
|
|
1007
|
+
const Y = X ?? (s == null ? void 0 : s.id);
|
|
1007
1008
|
return await C.signup({
|
|
1008
1009
|
email: W,
|
|
1009
|
-
phoneNumber:
|
|
1010
|
+
phoneNumber: J,
|
|
1010
1011
|
name: _,
|
|
1011
1012
|
password: Z,
|
|
1012
|
-
tenantId:
|
|
1013
|
-
lastName:
|
|
1013
|
+
tenantId: Y,
|
|
1014
|
+
lastName: ee,
|
|
1014
1015
|
appId: t
|
|
1015
1016
|
});
|
|
1016
1017
|
}, B = async (q) => {
|
|
1017
|
-
const { email: W, phoneNumber:
|
|
1018
|
-
if (!W && !
|
|
1018
|
+
const { email: W, phoneNumber: J, name: _, password: Z, tenantName: ee, lastName: X } = q;
|
|
1019
|
+
if (!W && !J)
|
|
1019
1020
|
throw new Error("Either email or phoneNumber is required");
|
|
1020
|
-
if (!_ || !Z || !
|
|
1021
|
+
if (!_ || !Z || !ee)
|
|
1021
1022
|
throw new Error("Name, password, and tenantName are required");
|
|
1022
1023
|
return await C.signupTenantAdmin({
|
|
1023
1024
|
email: W,
|
|
1024
|
-
phoneNumber:
|
|
1025
|
+
phoneNumber: J,
|
|
1025
1026
|
name: _,
|
|
1026
1027
|
password: Z,
|
|
1027
|
-
tenantName:
|
|
1028
|
+
tenantName: ee,
|
|
1028
1029
|
appId: t,
|
|
1029
|
-
lastName:
|
|
1030
|
+
lastName: X
|
|
1030
1031
|
});
|
|
1031
|
-
},
|
|
1032
|
-
const { currentPassword: W, newPassword:
|
|
1033
|
-
await C.changePassword({ currentPassword: W, newPassword:
|
|
1032
|
+
}, K = async (q) => {
|
|
1033
|
+
const { currentPassword: W, newPassword: J } = q, _ = await p.getAuthHeaders();
|
|
1034
|
+
await C.changePassword({ currentPassword: W, newPassword: J }, _);
|
|
1034
1035
|
}, ge = async (q) => {
|
|
1035
|
-
const { email: W, tenantId:
|
|
1036
|
+
const { email: W, tenantId: J } = q, _ = J ?? (s == null ? void 0 : s.id);
|
|
1036
1037
|
if (!_)
|
|
1037
1038
|
throw new Error("tenantId is required for password reset");
|
|
1038
1039
|
await C.requestPasswordReset({ email: W, tenantId: _ });
|
|
1039
|
-
}, He = async (q) => {
|
|
1040
|
-
const { token: W, newPassword: Y } = q;
|
|
1041
|
-
await C.confirmPasswordReset({ token: W, newPassword: Y });
|
|
1042
1040
|
}, Ne = async (q) => {
|
|
1043
|
-
const {
|
|
1044
|
-
|
|
1041
|
+
const { token: W, newPassword: J } = q;
|
|
1042
|
+
await C.confirmPasswordReset({ token: W, newPassword: J });
|
|
1043
|
+
}, Ue = async (q) => {
|
|
1044
|
+
const { email: W, frontendUrl: J, name: _, lastName: Z, tenantId: ee } = q, X = ee ?? (s == null ? void 0 : s.id);
|
|
1045
|
+
if (!X)
|
|
1045
1046
|
throw new Error("tenantId is required for magic link authentication");
|
|
1046
1047
|
return await C.sendMagicLink({
|
|
1047
1048
|
email: W,
|
|
1048
|
-
tenantId:
|
|
1049
|
-
frontendUrl:
|
|
1049
|
+
tenantId: X,
|
|
1050
|
+
frontendUrl: J,
|
|
1050
1051
|
name: _,
|
|
1051
1052
|
lastName: Z,
|
|
1052
1053
|
appId: t
|
|
1053
1054
|
});
|
|
1054
|
-
},
|
|
1055
|
-
const { token: W, email:
|
|
1056
|
-
let Z = s == null ? void 0 : s.id,
|
|
1057
|
-
_ && (Z = (await new de(v, t).getPublicTenantInfo(_)).id,
|
|
1058
|
-
const
|
|
1055
|
+
}, Be = async (q) => {
|
|
1056
|
+
const { token: W, email: J, tenantSlug: _ } = q;
|
|
1057
|
+
let Z = s == null ? void 0 : s.id, ee = o, X = p;
|
|
1058
|
+
_ && (Z = (await new de(v, t).getPublicTenantInfo(_)).id, ee = _);
|
|
1059
|
+
const Y = await C.verifyMagicLink({
|
|
1059
1060
|
token: W,
|
|
1060
|
-
email:
|
|
1061
|
+
email: J,
|
|
1061
1062
|
appId: t,
|
|
1062
1063
|
tenantId: Z
|
|
1063
|
-
}),
|
|
1064
|
-
if (
|
|
1065
|
-
tenantSlug:
|
|
1064
|
+
}), te = _ && _ !== o;
|
|
1065
|
+
if (te && (X = new Se({
|
|
1066
|
+
tenantSlug: ee,
|
|
1066
1067
|
baseUrl: r
|
|
1067
|
-
})),
|
|
1068
|
-
accessToken:
|
|
1069
|
-
refreshToken:
|
|
1070
|
-
expiresIn:
|
|
1071
|
-
}),
|
|
1072
|
-
|
|
1068
|
+
})), X.setTokens({
|
|
1069
|
+
accessToken: Y.accessToken,
|
|
1070
|
+
refreshToken: Y.refreshToken,
|
|
1071
|
+
expiresIn: Y.expiresIn
|
|
1072
|
+
}), Y.user) {
|
|
1073
|
+
X.setUser(Y.user), f(Y.user);
|
|
1073
1074
|
try {
|
|
1074
1075
|
await D();
|
|
1075
1076
|
} catch (ce) {
|
|
1076
1077
|
console.warn("Failed to load complete user data after magic link login:", ce);
|
|
1077
1078
|
}
|
|
1078
1079
|
}
|
|
1079
|
-
return
|
|
1080
|
+
return te && ee && ee !== o && a(ee, {
|
|
1080
1081
|
tokens: {
|
|
1081
|
-
accessToken:
|
|
1082
|
-
refreshToken:
|
|
1083
|
-
expiresIn:
|
|
1082
|
+
accessToken: Y.accessToken,
|
|
1083
|
+
refreshToken: Y.refreshToken,
|
|
1084
|
+
expiresIn: Y.expiresIn
|
|
1084
1085
|
}
|
|
1085
|
-
}),
|
|
1086
|
-
},
|
|
1086
|
+
}), Y;
|
|
1087
|
+
}, qe = async () => {
|
|
1087
1088
|
const q = p.getTokens();
|
|
1088
1089
|
if (!(q != null && q.refreshToken))
|
|
1089
1090
|
throw new Error("No refresh token available");
|
|
@@ -1095,13 +1096,13 @@ function jt({ config: i = {}, children: e }) {
|
|
|
1095
1096
|
refreshToken: W.refreshToken || q.refreshToken,
|
|
1096
1097
|
expiresIn: W.expiresIn
|
|
1097
1098
|
});
|
|
1098
|
-
},
|
|
1099
|
+
}, ze = () => {
|
|
1099
1100
|
p.clearSession(), f(null), L(null);
|
|
1100
|
-
},
|
|
1101
|
+
}, Oe = (q) => {
|
|
1101
1102
|
p.setTokens(q);
|
|
1102
|
-
},
|
|
1103
|
+
}, We = () => p.hasValidSession(), je = () => {
|
|
1103
1104
|
p.clearSession(), f(null), L(null);
|
|
1104
|
-
},
|
|
1105
|
+
}, Ve = async () => {
|
|
1105
1106
|
if (t)
|
|
1106
1107
|
try {
|
|
1107
1108
|
k(!0);
|
|
@@ -1112,8 +1113,8 @@ function jt({ config: i = {}, children: e }) {
|
|
|
1112
1113
|
} finally {
|
|
1113
1114
|
k(!1);
|
|
1114
1115
|
}
|
|
1115
|
-
},
|
|
1116
|
-
await
|
|
1116
|
+
}, _e = async () => {
|
|
1117
|
+
await Ve();
|
|
1117
1118
|
}, we = (q) => {
|
|
1118
1119
|
if (!R || R.length === 0)
|
|
1119
1120
|
return !1;
|
|
@@ -1130,16 +1131,16 @@ function jt({ config: i = {}, children: e }) {
|
|
|
1130
1131
|
login: U,
|
|
1131
1132
|
signup: V,
|
|
1132
1133
|
signupTenantAdmin: B,
|
|
1133
|
-
sendMagicLink:
|
|
1134
|
-
verifyMagicLink:
|
|
1135
|
-
changePassword:
|
|
1134
|
+
sendMagicLink: Ue,
|
|
1135
|
+
verifyMagicLink: Be,
|
|
1136
|
+
changePassword: K,
|
|
1136
1137
|
requestPasswordReset: ge,
|
|
1137
|
-
confirmPasswordReset:
|
|
1138
|
-
refreshToken:
|
|
1139
|
-
logout:
|
|
1140
|
-
setTokens:
|
|
1141
|
-
hasValidSession:
|
|
1142
|
-
clearSession:
|
|
1138
|
+
confirmPasswordReset: Ne,
|
|
1139
|
+
refreshToken: qe,
|
|
1140
|
+
logout: ze,
|
|
1141
|
+
setTokens: Oe,
|
|
1142
|
+
hasValidSession: We,
|
|
1143
|
+
clearSession: je,
|
|
1143
1144
|
currentUser: b,
|
|
1144
1145
|
isUserLoading: A,
|
|
1145
1146
|
userError: $,
|
|
@@ -1155,7 +1156,7 @@ function jt({ config: i = {}, children: e }) {
|
|
|
1155
1156
|
hasAnyPermission: (q) => q.some((W) => we(W)),
|
|
1156
1157
|
hasAllPermissions: (q) => q.every((W) => we(W)),
|
|
1157
1158
|
getUserPermissionStrings: () => R || [],
|
|
1158
|
-
refreshRoles:
|
|
1159
|
+
refreshRoles: _e
|
|
1159
1160
|
};
|
|
1160
1161
|
}, [
|
|
1161
1162
|
T,
|
|
@@ -1178,11 +1179,11 @@ function jt({ config: i = {}, children: e }) {
|
|
|
1178
1179
|
P,
|
|
1179
1180
|
h
|
|
1180
1181
|
]);
|
|
1181
|
-
|
|
1182
|
+
re(() => {
|
|
1182
1183
|
!i.initialRoles && t && (async () => {
|
|
1183
1184
|
try {
|
|
1184
1185
|
k(!0);
|
|
1185
|
-
const H = new
|
|
1186
|
+
const H = new ne(r), U = new Ie(H), { roles: V } = await U.getRolesByApp(t);
|
|
1186
1187
|
w(V);
|
|
1187
1188
|
} catch (H) {
|
|
1188
1189
|
console.error("Failed to fetch roles:", H);
|
|
@@ -1192,19 +1193,19 @@ function jt({ config: i = {}, children: e }) {
|
|
|
1192
1193
|
})();
|
|
1193
1194
|
}, [t, r, i.initialRoles]);
|
|
1194
1195
|
const [y, G] = S(!1);
|
|
1195
|
-
return
|
|
1196
|
+
return re(() => {
|
|
1196
1197
|
y || (G(!0), M.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), nt(), N(!0), console.log("[AuthProvider] EFFECT: Loading user data (blocking isAuthReady)..."), d.loadUserData().catch((D) => {
|
|
1197
1198
|
console.error("[AuthProvider] Failed to load user data:", D);
|
|
1198
1199
|
}).finally(() => {
|
|
1199
1200
|
console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"), N(!1);
|
|
1200
1201
|
})));
|
|
1201
|
-
}, [d, y]),
|
|
1202
|
+
}, [d, y]), re(() => {
|
|
1202
1203
|
const D = p.getUser();
|
|
1203
1204
|
D && p.hasValidSession() && f(D);
|
|
1204
|
-
}, [p]),
|
|
1205
|
+
}, [p]), re(() => {
|
|
1205
1206
|
y && (M.current.urlTokens || !b && !A && p.hasValidSession() && (console.log("[AuthProvider] Auto-loading user data..."), d.loadUserData().catch(() => {
|
|
1206
1207
|
})));
|
|
1207
|
-
}, [b, A, d, p, y]),
|
|
1208
|
+
}, [b, A, d, p, y]), re(() => {
|
|
1208
1209
|
if (!p.hasValidSession() || !b)
|
|
1209
1210
|
return;
|
|
1210
1211
|
const D = setInterval(() => {
|
|
@@ -1212,16 +1213,16 @@ function jt({ config: i = {}, children: e }) {
|
|
|
1212
1213
|
});
|
|
1213
1214
|
}, h);
|
|
1214
1215
|
return () => clearInterval(D);
|
|
1215
|
-
}, [p, b, d, h]), /* @__PURE__ */ n(
|
|
1216
|
+
}, [p, b, d, h]), /* @__PURE__ */ n(Ae.Provider, { value: d, children: e });
|
|
1216
1217
|
}
|
|
1217
|
-
function
|
|
1218
|
-
const i =
|
|
1218
|
+
function ae() {
|
|
1219
|
+
const i = se(Ae);
|
|
1219
1220
|
if (!i)
|
|
1220
1221
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
1221
1222
|
return i;
|
|
1222
1223
|
}
|
|
1223
|
-
function
|
|
1224
|
-
return
|
|
1224
|
+
function Ce() {
|
|
1225
|
+
return se(Ae);
|
|
1225
1226
|
}
|
|
1226
1227
|
class st {
|
|
1227
1228
|
constructor(e, t) {
|
|
@@ -1303,10 +1304,10 @@ class st {
|
|
|
1303
1304
|
})).data;
|
|
1304
1305
|
}
|
|
1305
1306
|
}
|
|
1306
|
-
const
|
|
1307
|
-
function
|
|
1308
|
-
const t =
|
|
1309
|
-
const u = new
|
|
1307
|
+
const Te = ue(null);
|
|
1308
|
+
function _t({ config: i = {}, children: e }) {
|
|
1309
|
+
const t = Fe(), r = ye(), s = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (r == null ? void 0 : r.tenant) ?? null, [g, w] = S([]), [m, k] = S(!1), [b, f] = S(null), [A, E] = S(!1), $ = Q(() => {
|
|
1310
|
+
const u = new ne(s);
|
|
1310
1311
|
return new st(u);
|
|
1311
1312
|
}, [s]), L = async () => {
|
|
1312
1313
|
if (!(a != null && a.id)) {
|
|
@@ -1324,13 +1325,13 @@ function Vt({ config: i = {}, children: e }) {
|
|
|
1324
1325
|
k(!1);
|
|
1325
1326
|
}
|
|
1326
1327
|
};
|
|
1327
|
-
|
|
1328
|
+
re(() => {
|
|
1328
1329
|
if (!s || !o) return;
|
|
1329
1330
|
L().finally(() => E(!0));
|
|
1330
1331
|
const u = i.refreshInterval || 5 * 60 * 1e3, M = setInterval(L, u);
|
|
1331
1332
|
return () => clearInterval(M);
|
|
1332
1333
|
}, [a == null ? void 0 : a.id, s, o, i.refreshInterval]);
|
|
1333
|
-
const P =
|
|
1334
|
+
const P = Q(() => {
|
|
1334
1335
|
const u = (O) => {
|
|
1335
1336
|
const v = g.find((C) => C.key === O);
|
|
1336
1337
|
return (v == null ? void 0 : v.value) === !0;
|
|
@@ -1351,16 +1352,16 @@ function Vt({ config: i = {}, children: e }) {
|
|
|
1351
1352
|
refresh: N
|
|
1352
1353
|
};
|
|
1353
1354
|
}, [g, m, b, s, o, a == null ? void 0 : a.id, A]);
|
|
1354
|
-
return /* @__PURE__ */ n(
|
|
1355
|
+
return /* @__PURE__ */ n(Te.Provider, { value: P, children: e });
|
|
1355
1356
|
}
|
|
1356
1357
|
function it() {
|
|
1357
|
-
const i =
|
|
1358
|
+
const i = se(Te);
|
|
1358
1359
|
if (!i)
|
|
1359
1360
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1360
1361
|
return i;
|
|
1361
1362
|
}
|
|
1362
|
-
function
|
|
1363
|
-
return
|
|
1363
|
+
function De() {
|
|
1364
|
+
return se(Te);
|
|
1364
1365
|
}
|
|
1365
1366
|
class ot {
|
|
1366
1367
|
constructor(e, t) {
|
|
@@ -1428,10 +1429,10 @@ class ot {
|
|
|
1428
1429
|
)).data;
|
|
1429
1430
|
}
|
|
1430
1431
|
}
|
|
1431
|
-
const
|
|
1432
|
-
function
|
|
1433
|
-
const t =
|
|
1434
|
-
const P = new
|
|
1432
|
+
const Pe = ue(void 0);
|
|
1433
|
+
function Gt({ config: i = {}, children: e }) {
|
|
1434
|
+
const t = Fe(), r = ye(), s = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a, g] = S(null), [w, m] = S(!1), [k, b] = S(null), [f, A] = S(!1), E = Q(() => {
|
|
1435
|
+
const P = new ne(s);
|
|
1435
1436
|
return new ot(P);
|
|
1436
1437
|
}, [s]), $ = async () => {
|
|
1437
1438
|
if (!(o != null && o.id)) {
|
|
@@ -1449,12 +1450,12 @@ function _t({ config: i = {}, children: e }) {
|
|
|
1449
1450
|
m(!1);
|
|
1450
1451
|
}
|
|
1451
1452
|
};
|
|
1452
|
-
|
|
1453
|
+
re(() => {
|
|
1453
1454
|
if (!s || ($().finally(() => A(!0)), !i.refreshInterval)) return;
|
|
1454
1455
|
const P = i.refreshInterval || 10 * 60 * 1e3, u = setInterval($, P);
|
|
1455
1456
|
return () => clearInterval(u);
|
|
1456
1457
|
}, [o == null ? void 0 : o.id, s, i.refreshInterval]);
|
|
1457
|
-
const L =
|
|
1458
|
+
const L = Q(() => {
|
|
1458
1459
|
const P = (a == null ? void 0 : a.features) || [], u = (v) => {
|
|
1459
1460
|
const C = P.find((x) => x.key === v);
|
|
1460
1461
|
return C ? C.type === "BOOLEAN" || C.type === "boolean" ? C.value === !0 : !!C.value : !1;
|
|
@@ -1477,19 +1478,19 @@ function _t({ config: i = {}, children: e }) {
|
|
|
1477
1478
|
refresh: p
|
|
1478
1479
|
};
|
|
1479
1480
|
}, [a, w, k, s, o == null ? void 0 : o.id, f]);
|
|
1480
|
-
return /* @__PURE__ */ n(
|
|
1481
|
+
return /* @__PURE__ */ n(Pe.Provider, { value: L, children: e });
|
|
1481
1482
|
}
|
|
1482
1483
|
function at() {
|
|
1483
|
-
const i =
|
|
1484
|
+
const i = se(Pe);
|
|
1484
1485
|
if (i === void 0)
|
|
1485
1486
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1486
1487
|
return i;
|
|
1487
1488
|
}
|
|
1488
|
-
function
|
|
1489
|
-
return
|
|
1489
|
+
function $e() {
|
|
1490
|
+
return se(Pe) ?? null;
|
|
1490
1491
|
}
|
|
1491
|
-
var
|
|
1492
|
-
const
|
|
1492
|
+
var oe = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(oe || {});
|
|
1493
|
+
const Re = () => /* @__PURE__ */ l(
|
|
1493
1494
|
"div",
|
|
1494
1495
|
{
|
|
1495
1496
|
style: {
|
|
@@ -1526,7 +1527,7 @@ const Ie = () => /* @__PURE__ */ l(
|
|
|
1526
1527
|
)
|
|
1527
1528
|
]
|
|
1528
1529
|
}
|
|
1529
|
-
),
|
|
1530
|
+
), Le = ({
|
|
1530
1531
|
userType: i,
|
|
1531
1532
|
minUserType: e,
|
|
1532
1533
|
missingPermissions: t
|
|
@@ -1569,30 +1570,30 @@ const Ie = () => /* @__PURE__ */ l(
|
|
|
1569
1570
|
}
|
|
1570
1571
|
), lt = (i, e) => {
|
|
1571
1572
|
const t = {
|
|
1572
|
-
[
|
|
1573
|
-
[
|
|
1574
|
-
[
|
|
1573
|
+
[oe.USER]: 1,
|
|
1574
|
+
[oe.TENANT_ADMIN]: 2,
|
|
1575
|
+
[oe.SUPERUSER]: 3
|
|
1575
1576
|
};
|
|
1576
1577
|
return t[i] >= t[e];
|
|
1577
1578
|
};
|
|
1578
|
-
function
|
|
1579
|
+
function Kt({
|
|
1579
1580
|
children: i,
|
|
1580
1581
|
fallback: e,
|
|
1581
1582
|
minUserType: t,
|
|
1582
1583
|
requiredPermissions: r,
|
|
1583
1584
|
requireAllPermissions: s = !1
|
|
1584
1585
|
}) {
|
|
1585
|
-
const { hasValidSession: o, sessionManager: a, hasPermission: g, hasAnyPermission: w, hasAllPermissions: m } =
|
|
1586
|
+
const { hasValidSession: o, sessionManager: a, hasPermission: g, hasAnyPermission: w, hasAllPermissions: m } = ae();
|
|
1586
1587
|
if (!o())
|
|
1587
|
-
return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(
|
|
1588
|
+
return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(Re, {}) });
|
|
1588
1589
|
const k = a.getUser();
|
|
1589
1590
|
if (!k)
|
|
1590
|
-
return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(
|
|
1591
|
+
return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(Re, {}) });
|
|
1591
1592
|
if (t && !lt(k.userType, t))
|
|
1592
|
-
return /* @__PURE__ */ n(
|
|
1593
|
+
return /* @__PURE__ */ n(Le, { userType: k.userType, minUserType: t });
|
|
1593
1594
|
if (r && r.length > 0 && !(s ? m(r) : w(r))) {
|
|
1594
1595
|
const f = r.filter((A) => !g(A)).map((A) => typeof A == "string" ? A : A.name);
|
|
1595
|
-
return /* @__PURE__ */ n(
|
|
1596
|
+
return /* @__PURE__ */ n(Le, { missingPermissions: f });
|
|
1596
1597
|
}
|
|
1597
1598
|
return /* @__PURE__ */ n(j, { children: i });
|
|
1598
1599
|
}
|
|
@@ -1632,7 +1633,7 @@ const ct = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1632
1633
|
}
|
|
1633
1634
|
)
|
|
1634
1635
|
}
|
|
1635
|
-
),
|
|
1636
|
+
), Ee = ({
|
|
1636
1637
|
userType: i,
|
|
1637
1638
|
minUserType: e,
|
|
1638
1639
|
missingPermissions: t
|
|
@@ -1685,13 +1686,13 @@ const ct = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1685
1686
|
}
|
|
1686
1687
|
), dt = (i, e) => {
|
|
1687
1688
|
const t = {
|
|
1688
|
-
[
|
|
1689
|
-
[
|
|
1690
|
-
[
|
|
1689
|
+
[oe.USER]: 1,
|
|
1690
|
+
[oe.TENANT_ADMIN]: 2,
|
|
1691
|
+
[oe.SUPERUSER]: 3
|
|
1691
1692
|
};
|
|
1692
1693
|
return t[i] >= t[e];
|
|
1693
1694
|
};
|
|
1694
|
-
function
|
|
1695
|
+
function Jt({
|
|
1695
1696
|
children: i,
|
|
1696
1697
|
redirectTo: e = "/login",
|
|
1697
1698
|
minUserType: t,
|
|
@@ -1699,7 +1700,7 @@ function Kt({
|
|
|
1699
1700
|
requireAllPermissions: s = !1,
|
|
1700
1701
|
fallback: o
|
|
1701
1702
|
}) {
|
|
1702
|
-
const { hasValidSession: a, sessionManager: g, hasPermission: w, hasAnyPermission: m, hasAllPermissions: k } =
|
|
1703
|
+
const { hasValidSession: a, sessionManager: g, hasPermission: w, hasAnyPermission: m, hasAllPermissions: k } = ae(), b = ve();
|
|
1703
1704
|
if (!a())
|
|
1704
1705
|
return o ? /* @__PURE__ */ n(j, { children: o }) : /* @__PURE__ */ l(j, { children: [
|
|
1705
1706
|
/* @__PURE__ */ n(ct, { redirectPath: e }),
|
|
@@ -1709,10 +1710,10 @@ function Kt({
|
|
|
1709
1710
|
if (!f)
|
|
1710
1711
|
return /* @__PURE__ */ n(pe, { to: e, state: { from: b.pathname }, replace: !0 });
|
|
1711
1712
|
if (t && !dt(f.userType, t))
|
|
1712
|
-
return /* @__PURE__ */ n(
|
|
1713
|
+
return /* @__PURE__ */ n(Ee, { userType: f.userType, minUserType: t });
|
|
1713
1714
|
if (r && r.length > 0 && !(s ? k(r) : m(r))) {
|
|
1714
1715
|
const E = r.filter(($) => !w($)).map(($) => typeof $ == "string" ? $ : $.name);
|
|
1715
|
-
return /* @__PURE__ */ n(
|
|
1716
|
+
return /* @__PURE__ */ n(Ee, { missingPermissions: E });
|
|
1716
1717
|
}
|
|
1717
1718
|
return /* @__PURE__ */ n(j, { children: i });
|
|
1718
1719
|
}
|
|
@@ -1753,8 +1754,8 @@ const ut = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1753
1754
|
)
|
|
1754
1755
|
}
|
|
1755
1756
|
);
|
|
1756
|
-
function
|
|
1757
|
-
const { tenant: r, isLoading: s, error: o } = le(), a =
|
|
1757
|
+
function Yt({ children: i, redirectTo: e = "/", fallback: t }) {
|
|
1758
|
+
const { tenant: r, isLoading: s, error: o } = le(), a = ve();
|
|
1758
1759
|
return s || o ? null : r ? /* @__PURE__ */ n(j, { children: i }) : t ? /* @__PURE__ */ n(j, { children: t }) : /* @__PURE__ */ l(j, { children: [
|
|
1759
1760
|
/* @__PURE__ */ n(ut, { redirectPath: e }),
|
|
1760
1761
|
/* @__PURE__ */ n(pe, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
@@ -1797,8 +1798,8 @@ const ht = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1797
1798
|
)
|
|
1798
1799
|
}
|
|
1799
1800
|
);
|
|
1800
|
-
function
|
|
1801
|
-
const { tenant: r, isLoading: s, error: o } = le(), a =
|
|
1801
|
+
function Qt({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
|
|
1802
|
+
const { tenant: r, isLoading: s, error: o } = le(), a = ve();
|
|
1802
1803
|
return s || o ? null : r ? t ? /* @__PURE__ */ n(j, { children: t }) : /* @__PURE__ */ l(j, { children: [
|
|
1803
1804
|
/* @__PURE__ */ n(ht, { redirectPath: e }),
|
|
1804
1805
|
/* @__PURE__ */ n(pe, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
@@ -1821,7 +1822,7 @@ const gt = () => /* @__PURE__ */ l(
|
|
|
1821
1822
|
]
|
|
1822
1823
|
}
|
|
1823
1824
|
);
|
|
1824
|
-
function
|
|
1825
|
+
function Xt({
|
|
1825
1826
|
children: i,
|
|
1826
1827
|
fallback: e = /* @__PURE__ */ n(gt, {}),
|
|
1827
1828
|
allowedPlans: t,
|
|
@@ -1867,7 +1868,7 @@ const pt = ({ flagName: i }) => /* @__PURE__ */ l(
|
|
|
1867
1868
|
]
|
|
1868
1869
|
}
|
|
1869
1870
|
);
|
|
1870
|
-
function
|
|
1871
|
+
function Zt({ name: i, children: e, fallback: t }) {
|
|
1871
1872
|
const { isEnabled: r, loading: s } = it();
|
|
1872
1873
|
return s ? /* @__PURE__ */ n(
|
|
1873
1874
|
"div",
|
|
@@ -2042,7 +2043,7 @@ const ft = () => /* @__PURE__ */ l(
|
|
|
2042
2043
|
fontSize: "0.875rem"
|
|
2043
2044
|
}
|
|
2044
2045
|
};
|
|
2045
|
-
function
|
|
2046
|
+
function er({
|
|
2046
2047
|
copy: i = {},
|
|
2047
2048
|
styles: e = {},
|
|
2048
2049
|
icons: t = {},
|
|
@@ -2056,7 +2057,7 @@ function Zt({
|
|
|
2056
2057
|
showMagicLinkOption: k = !0,
|
|
2057
2058
|
className: b
|
|
2058
2059
|
}) {
|
|
2059
|
-
const [f, A] = S(""), [E, $] = S(""), [L, P] = S(!1), [u, M] = S(!1), [z, N] = S(""), [p, O] = S({}), { login: v } =
|
|
2060
|
+
const [f, A] = S(""), [E, $] = S(""), [L, P] = S(!1), [u, M] = S(!1), [z, N] = S(""), [p, O] = S({}), { login: v } = ae(), { tenant: C } = le(), x = { ...wt, ...i }, I = { ...bt, ...e }, F = { ...yt, ...t }, c = () => {
|
|
2060
2061
|
const d = {};
|
|
2061
2062
|
return f.trim() || (d.username = !0), E.trim() || (d.password = !0), O(d), Object.keys(d).length === 0;
|
|
2062
2063
|
}, R = async (d) => {
|
|
@@ -2293,7 +2294,7 @@ const St = {
|
|
|
2293
2294
|
fontSize: "0.875rem"
|
|
2294
2295
|
}
|
|
2295
2296
|
};
|
|
2296
|
-
function
|
|
2297
|
+
function tr({
|
|
2297
2298
|
copy: i = {},
|
|
2298
2299
|
styles: e = {},
|
|
2299
2300
|
signupType: t = "user",
|
|
@@ -2305,7 +2306,7 @@ function er({
|
|
|
2305
2306
|
showMagicLinkOption: w = !0,
|
|
2306
2307
|
className: m
|
|
2307
2308
|
}) {
|
|
2308
|
-
const [k, b] = S(""), [f, A] = S(""), [E, $] = S(""), [L, P] = S(""), [u, M] = S(""), [z, N] = S(""), [p, O] = S(""), [v, C] = S(!1), [x, I] = S(""), [F, c] = S({}), { signup: R, signupTenantAdmin: T } =
|
|
2309
|
+
const [k, b] = S(""), [f, A] = S(""), [E, $] = S(""), [L, P] = S(""), [u, M] = S(""), [z, N] = S(""), [p, O] = S(""), [v, C] = S(!1), [x, I] = S(""), [F, c] = S({}), { signup: R, signupTenantAdmin: T } = ae(), { tenant: h } = le(), d = { ...St, ...i }, y = { ...vt, ...e }, G = () => {
|
|
2309
2310
|
const B = {};
|
|
2310
2311
|
return k.trim() || (B.name = !0), !E.trim() && !L.trim() && (B.email = !0, B.phoneNumber = !0), u.trim() || (B.password = !0), z.trim() || (B.confirmPassword = !0), t === "tenant" && !p.trim() && (B.tenantName = !0), c(B), Object.keys(B).length === 0;
|
|
2311
2312
|
}, D = async (B) => {
|
|
@@ -2320,24 +2321,24 @@ function er({
|
|
|
2320
2321
|
}
|
|
2321
2322
|
C(!0), I("");
|
|
2322
2323
|
try {
|
|
2323
|
-
let
|
|
2324
|
-
t === "tenant" ?
|
|
2324
|
+
let K;
|
|
2325
|
+
t === "tenant" ? K = await T({
|
|
2325
2326
|
email: E || void 0,
|
|
2326
2327
|
phoneNumber: L || void 0,
|
|
2327
2328
|
name: k,
|
|
2328
2329
|
password: u,
|
|
2329
2330
|
tenantName: p,
|
|
2330
2331
|
lastName: f || void 0
|
|
2331
|
-
}) :
|
|
2332
|
+
}) : K = await R({
|
|
2332
2333
|
email: E || void 0,
|
|
2333
2334
|
phoneNumber: L || void 0,
|
|
2334
2335
|
name: k,
|
|
2335
2336
|
password: u,
|
|
2336
2337
|
tenantId: h.id,
|
|
2337
2338
|
lastName: f || void 0
|
|
2338
|
-
}), r == null || r(
|
|
2339
|
-
} catch (
|
|
2340
|
-
const ge =
|
|
2339
|
+
}), r == null || r(K);
|
|
2340
|
+
} catch (K) {
|
|
2341
|
+
const ge = K.message || d.errorMessage;
|
|
2341
2342
|
I(ge), s == null || s(ge);
|
|
2342
2343
|
} finally {
|
|
2343
2344
|
C(!1);
|
|
@@ -2364,7 +2365,7 @@ function er({
|
|
|
2364
2365
|
type: "text",
|
|
2365
2366
|
value: k,
|
|
2366
2367
|
onChange: (B) => {
|
|
2367
|
-
b(B.target.value), F.name && c((
|
|
2368
|
+
b(B.target.value), F.name && c((K) => ({ ...K, name: !1 }));
|
|
2368
2369
|
},
|
|
2369
2370
|
placeholder: d.namePlaceholder,
|
|
2370
2371
|
style: H("name"),
|
|
@@ -2398,7 +2399,7 @@ function er({
|
|
|
2398
2399
|
type: "email",
|
|
2399
2400
|
value: E,
|
|
2400
2401
|
onChange: (B) => {
|
|
2401
|
-
$(B.target.value), F.email && c((
|
|
2402
|
+
$(B.target.value), F.email && c((K) => ({ ...K, email: !1, phoneNumber: !1 }));
|
|
2402
2403
|
},
|
|
2403
2404
|
placeholder: d.emailPlaceholder,
|
|
2404
2405
|
style: H("email"),
|
|
@@ -2416,7 +2417,7 @@ function er({
|
|
|
2416
2417
|
type: "tel",
|
|
2417
2418
|
value: L,
|
|
2418
2419
|
onChange: (B) => {
|
|
2419
|
-
P(B.target.value), F.phoneNumber && c((
|
|
2420
|
+
P(B.target.value), F.phoneNumber && c((K) => ({ ...K, email: !1, phoneNumber: !1 }));
|
|
2420
2421
|
},
|
|
2421
2422
|
placeholder: d.phoneNumberPlaceholder,
|
|
2422
2423
|
style: H("phoneNumber"),
|
|
@@ -2446,7 +2447,7 @@ function er({
|
|
|
2446
2447
|
type: "password",
|
|
2447
2448
|
value: u,
|
|
2448
2449
|
onChange: (B) => {
|
|
2449
|
-
M(B.target.value), F.password && c((
|
|
2450
|
+
M(B.target.value), F.password && c((K) => ({ ...K, password: !1 }));
|
|
2450
2451
|
},
|
|
2451
2452
|
placeholder: d.passwordPlaceholder,
|
|
2452
2453
|
style: H("password"),
|
|
@@ -2464,7 +2465,7 @@ function er({
|
|
|
2464
2465
|
type: "password",
|
|
2465
2466
|
value: z,
|
|
2466
2467
|
onChange: (B) => {
|
|
2467
|
-
N(B.target.value), F.confirmPassword && c((
|
|
2468
|
+
N(B.target.value), F.confirmPassword && c((K) => ({ ...K, confirmPassword: !1 })), x === d.passwordMismatchError && I("");
|
|
2468
2469
|
},
|
|
2469
2470
|
placeholder: d.confirmPasswordPlaceholder,
|
|
2470
2471
|
style: H("confirmPassword"),
|
|
@@ -2482,7 +2483,7 @@ function er({
|
|
|
2482
2483
|
type: "text",
|
|
2483
2484
|
value: p,
|
|
2484
2485
|
onChange: (B) => {
|
|
2485
|
-
O(B.target.value), F.tenantName && c((
|
|
2486
|
+
O(B.target.value), F.tenantName && c((K) => ({ ...K, tenantName: !1 }));
|
|
2486
2487
|
},
|
|
2487
2488
|
placeholder: d.tenantNamePlaceholder,
|
|
2488
2489
|
style: H("tenantName"),
|
|
@@ -2633,7 +2634,7 @@ const kt = {
|
|
|
2633
2634
|
fontSize: "0.875rem"
|
|
2634
2635
|
}
|
|
2635
2636
|
};
|
|
2636
|
-
function
|
|
2637
|
+
function rr({
|
|
2637
2638
|
copy: i = {},
|
|
2638
2639
|
styles: e = {},
|
|
2639
2640
|
onSuccess: t,
|
|
@@ -2645,8 +2646,8 @@ function tr({
|
|
|
2645
2646
|
verifyToken: w,
|
|
2646
2647
|
frontendUrl: m
|
|
2647
2648
|
}) {
|
|
2648
|
-
const [k, b] = S(""), [f, A] = S(""), [E, $] = S(""), [L, P] = S(!1), [u, M] = S(!1), [z, N] = S(""), [p, O] = S(""), [v, C] = S({}), [x, I] = S(!1), { sendMagicLink: F, verifyMagicLink: c } =
|
|
2649
|
-
|
|
2649
|
+
const [k, b] = S(""), [f, A] = S(""), [E, $] = S(""), [L, P] = S(!1), [u, M] = S(!1), [z, N] = S(""), [p, O] = S(""), [v, C] = S({}), [x, I] = S(!1), { sendMagicLink: F, verifyMagicLink: c } = ae(), { tenant: R } = le(), T = { ...kt, ...i }, h = { ...xt, ...e };
|
|
2650
|
+
re(() => {
|
|
2650
2651
|
w && d(w);
|
|
2651
2652
|
}, [w]);
|
|
2652
2653
|
const d = async (U) => {
|
|
@@ -2828,7 +2829,7 @@ const At = {
|
|
|
2828
2829
|
redirectingMessage: "Redirecting you to the dashboard...",
|
|
2829
2830
|
retryButton: "Try Again",
|
|
2830
2831
|
backToLoginButton: "Back to Login"
|
|
2831
|
-
},
|
|
2832
|
+
}, He = {
|
|
2832
2833
|
container: {
|
|
2833
2834
|
maxWidth: "400px",
|
|
2834
2835
|
width: "100%",
|
|
@@ -2915,7 +2916,7 @@ const At = {
|
|
|
2915
2916
|
cursor: "pointer",
|
|
2916
2917
|
transition: "all 0.15s ease-in-out"
|
|
2917
2918
|
}
|
|
2918
|
-
}, Tt = () => /* @__PURE__ */ n("div", { style:
|
|
2919
|
+
}, Tt = () => /* @__PURE__ */ n("div", { style: He.spinner }), Pt = () => /* @__PURE__ */ l(
|
|
2919
2920
|
"svg",
|
|
2920
2921
|
{
|
|
2921
2922
|
width: "48",
|
|
@@ -2955,7 +2956,7 @@ const At = {
|
|
|
2955
2956
|
success: /* @__PURE__ */ n(Pt, {}),
|
|
2956
2957
|
error: /* @__PURE__ */ n(Mt, {})
|
|
2957
2958
|
};
|
|
2958
|
-
function
|
|
2959
|
+
function nr({
|
|
2959
2960
|
copy: i = {},
|
|
2960
2961
|
styles: e = {},
|
|
2961
2962
|
icons: t = {},
|
|
@@ -2970,7 +2971,7 @@ function rr({
|
|
|
2970
2971
|
tenantSlug: b,
|
|
2971
2972
|
autoRedirectDelay: f = 3e3
|
|
2972
2973
|
}) {
|
|
2973
|
-
const [A, E] = S("verifying"), [$, L] = S(""), { verifyMagicLink: P } =
|
|
2974
|
+
const [A, E] = S("verifying"), [$, L] = S(""), { verifyMagicLink: P } = ae(), u = { ...At, ...i }, M = { ...He, ...e }, z = { ...It, ...t }, N = () => {
|
|
2974
2975
|
if (typeof window > "u") return {};
|
|
2975
2976
|
const x = new URLSearchParams(window.location.search);
|
|
2976
2977
|
return {
|
|
@@ -3002,7 +3003,7 @@ function rr({
|
|
|
3002
3003
|
}, v = () => {
|
|
3003
3004
|
a == null || a();
|
|
3004
3005
|
};
|
|
3005
|
-
|
|
3006
|
+
re(() => {
|
|
3006
3007
|
p();
|
|
3007
3008
|
}, []);
|
|
3008
3009
|
const C = () => {
|
|
@@ -3186,7 +3187,7 @@ const Rt = {
|
|
|
3186
3187
|
cursor: "pointer"
|
|
3187
3188
|
}
|
|
3188
3189
|
};
|
|
3189
|
-
function
|
|
3190
|
+
function sr({
|
|
3190
3191
|
copy: i = {},
|
|
3191
3192
|
styles: e = {},
|
|
3192
3193
|
mode: t = "request",
|
|
@@ -3197,7 +3198,7 @@ function nr({
|
|
|
3197
3198
|
onModeChange: g,
|
|
3198
3199
|
className: w
|
|
3199
3200
|
}) {
|
|
3200
|
-
const [m, k] = S(""), [b, f] = S(r), [A, E] = S(""), [$, L] = S(""), [P, u] = S(!1), [M, z] = S(""), [N, p] = S(""), [O, v] = S({}), { requestPasswordReset: C, confirmPasswordReset: x } =
|
|
3201
|
+
const [m, k] = S(""), [b, f] = S(r), [A, E] = S(""), [$, L] = S(""), [P, u] = S(!1), [M, z] = S(""), [N, p] = S(""), [O, v] = S({}), { requestPasswordReset: C, confirmPasswordReset: x } = ae(), { tenant: I } = le(), F = { ...Rt, ...i }, c = { ...Lt, ...e }, R = () => {
|
|
3201
3202
|
const H = {};
|
|
3202
3203
|
return m.trim() || (H.email = !0), v(H), Object.keys(H).length === 0;
|
|
3203
3204
|
}, T = () => {
|
|
@@ -3411,13 +3412,13 @@ const Et = () => /* @__PURE__ */ n(
|
|
|
3411
3412
|
]
|
|
3412
3413
|
}
|
|
3413
3414
|
);
|
|
3414
|
-
function
|
|
3415
|
+
function ir({
|
|
3415
3416
|
children: i,
|
|
3416
3417
|
loadingFallback: e,
|
|
3417
3418
|
errorFallback: t,
|
|
3418
3419
|
requireTenant: r = !0
|
|
3419
3420
|
}) {
|
|
3420
|
-
const { isAppLoading: s, appError: o, retryApp: a } = he(), g = ye(), w =
|
|
3421
|
+
const { isAppLoading: s, appError: o, retryApp: a } = he(), g = ye(), w = Ce(), m = De(), k = $e(), b = (g == null ? void 0 : g.isTenantLoading) ?? !1, f = (g == null ? void 0 : g.tenantError) ?? null, A = (g == null ? void 0 : g.tenantSlug) ?? null, E = (g == null ? void 0 : g.retryTenant) ?? (() => {
|
|
3421
3422
|
}), $ = (w == null ? void 0 : w.isAuthReady) ?? !0, L = (m == null ? void 0 : m.isReady) ?? !0, P = (k == null ? void 0 : k.isReady) ?? !0, u = r && g && A, p = s || u && b || w && !$ || m && !L || k && !P, O = o || (u ? f : null), v = () => {
|
|
3422
3423
|
o && a(), f && g && E();
|
|
3423
3424
|
};
|
|
@@ -3429,8 +3430,8 @@ function sr({
|
|
|
3429
3430
|
}
|
|
3430
3431
|
return /* @__PURE__ */ n(j, { children: i });
|
|
3431
3432
|
}
|
|
3432
|
-
function
|
|
3433
|
-
const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = he(), o = ye(), a =
|
|
3433
|
+
function or(i = !0) {
|
|
3434
|
+
const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = he(), o = ye(), a = Ce(), g = De(), w = $e(), m = (o == null ? void 0 : o.isTenantLoading) ?? !1, k = (o == null ? void 0 : o.tenantError) ?? null, b = (o == null ? void 0 : o.tenant) ?? null, f = (o == null ? void 0 : o.tenantSlug) ?? null, A = (o == null ? void 0 : o.retryTenant) ?? (() => {
|
|
3434
3435
|
}), E = (a == null ? void 0 : a.isAuthReady) ?? !0, $ = (g == null ? void 0 : g.isReady) ?? !0, L = (w == null ? void 0 : w.isReady) ?? !0, P = i && o && f, N = e || P && m || a && !E || g && !$ || w && !L, p = t || (P ? k : null);
|
|
3435
3436
|
return {
|
|
3436
3437
|
isLoading: N,
|
|
@@ -3447,7 +3448,7 @@ function ir(i = !0) {
|
|
|
3447
3448
|
subscription: w ? { isReady: L } : null
|
|
3448
3449
|
};
|
|
3449
3450
|
}
|
|
3450
|
-
class
|
|
3451
|
+
class ar {
|
|
3451
3452
|
constructor(e, t) {
|
|
3452
3453
|
this.httpService = e, this.sessionManager = t;
|
|
3453
3454
|
}
|
|
@@ -3515,7 +3516,7 @@ class or {
|
|
|
3515
3516
|
};
|
|
3516
3517
|
}
|
|
3517
3518
|
}
|
|
3518
|
-
class
|
|
3519
|
+
class lr {
|
|
3519
3520
|
constructor(e, t) {
|
|
3520
3521
|
this.httpService = e, this.sessionManager = t;
|
|
3521
3522
|
}
|
|
@@ -3566,7 +3567,7 @@ class ar {
|
|
|
3566
3567
|
});
|
|
3567
3568
|
}
|
|
3568
3569
|
}
|
|
3569
|
-
class
|
|
3570
|
+
class cr {
|
|
3570
3571
|
constructor(e) {
|
|
3571
3572
|
this.httpService = e;
|
|
3572
3573
|
}
|
|
@@ -3575,7 +3576,7 @@ class lr {
|
|
|
3575
3576
|
return await this.httpService.get("/health");
|
|
3576
3577
|
}
|
|
3577
3578
|
}
|
|
3578
|
-
class
|
|
3579
|
+
class dr {
|
|
3579
3580
|
// Date string to Date object
|
|
3580
3581
|
static toDate(e) {
|
|
3581
3582
|
return new Date(e);
|
|
@@ -3698,47 +3699,47 @@ class cr {
|
|
|
3698
3699
|
}
|
|
3699
3700
|
}
|
|
3700
3701
|
export {
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3702
|
+
dr as ApiMappers,
|
|
3703
|
+
Me as AppApiService,
|
|
3704
|
+
ir as AppLoader,
|
|
3705
|
+
qt as AppProvider,
|
|
3705
3706
|
Ke as AuthApiService,
|
|
3706
|
-
|
|
3707
|
-
|
|
3707
|
+
Vt as AuthProvider,
|
|
3708
|
+
Zt as FeatureFlag,
|
|
3708
3709
|
st as FeatureFlagApiService,
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3710
|
+
_t as FeatureFlagProvider,
|
|
3711
|
+
cr as HealthApiService,
|
|
3712
|
+
ne as HttpService,
|
|
3713
|
+
Qt as LandingRoute,
|
|
3714
|
+
er as LoginForm,
|
|
3715
|
+
rr as MagicLinkForm,
|
|
3716
|
+
nr as MagicLinkVerify,
|
|
3717
|
+
sr as PasswordRecoveryForm,
|
|
3718
|
+
ar as PermissionApiService,
|
|
3719
|
+
Kt as Protected,
|
|
3720
|
+
Jt as ProtectedRoute,
|
|
3721
|
+
Ie as RoleApiService,
|
|
3722
|
+
Se as SessionManager,
|
|
3723
|
+
tr as SignupForm,
|
|
3723
3724
|
ot as SubscriptionApiService,
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3725
|
+
Xt as SubscriptionGuard,
|
|
3726
|
+
lr as SubscriptionPlanApiService,
|
|
3727
|
+
Gt as SubscriptionProvider,
|
|
3727
3728
|
de as TenantApiService,
|
|
3728
|
-
|
|
3729
|
-
|
|
3729
|
+
Ot as TenantProvider,
|
|
3730
|
+
Yt as TenantRoute,
|
|
3730
3731
|
Je as UserApiService,
|
|
3731
|
-
|
|
3732
|
-
|
|
3732
|
+
oe as UserType,
|
|
3733
|
+
zt as useApi,
|
|
3733
3734
|
he as useApp,
|
|
3734
|
-
|
|
3735
|
-
|
|
3735
|
+
or as useAppLoaderState,
|
|
3736
|
+
ae as useAuth,
|
|
3736
3737
|
it as useFeatureFlags,
|
|
3737
|
-
|
|
3738
|
+
jt as useSettings,
|
|
3738
3739
|
at as useSubscription,
|
|
3739
3740
|
me as useTenant,
|
|
3740
3741
|
le as useTenantInfo,
|
|
3741
3742
|
ye as useTenantOptional,
|
|
3742
|
-
|
|
3743
|
+
Wt as useTenantSettings
|
|
3743
3744
|
};
|
|
3744
3745
|
//# sourceMappingURL=index.es.js.map
|