@skylabs-digital/react-identity-access 2.10.1 → 2.12.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 +338 -338
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/providers/TenantProvider.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,6 +1,6 @@
|
|
|
1
1
|
import { jsx as n, Fragment as j, jsxs as d } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { useLocation as Te, Navigate as
|
|
2
|
+
import { createContext as he, useMemo as te, useState as k, useCallback as ie, useEffect as re, useContext as se, useRef as Ue } from "react";
|
|
3
|
+
import { useLocation as Te, Navigate as me } from "react-router-dom";
|
|
4
4
|
class ne {
|
|
5
5
|
// SessionManager instance
|
|
6
6
|
constructor(e, t = 1e4) {
|
|
@@ -28,7 +28,7 @@ class ne {
|
|
|
28
28
|
} catch (S) {
|
|
29
29
|
console.warn("Failed to inject auth headers:", S);
|
|
30
30
|
}
|
|
31
|
-
const b = new AbortController(),
|
|
31
|
+
const b = new AbortController(), p = setTimeout(() => b.abort(), m);
|
|
32
32
|
try {
|
|
33
33
|
const S = await fetch(a, {
|
|
34
34
|
method: e,
|
|
@@ -36,7 +36,7 @@ class ne {
|
|
|
36
36
|
body: r ? JSON.stringify(r) : void 0,
|
|
37
37
|
signal: b.signal
|
|
38
38
|
});
|
|
39
|
-
if (clearTimeout(
|
|
39
|
+
if (clearTimeout(p), S.status === 401 && !(s != null && s.skipRetry) && !o && this.sessionManager)
|
|
40
40
|
try {
|
|
41
41
|
const T = this.sessionManager.getTokens();
|
|
42
42
|
if (T != null && T.refreshToken)
|
|
@@ -49,7 +49,7 @@ class ne {
|
|
|
49
49
|
const f = S.headers.get("content-type");
|
|
50
50
|
return !f || !f.includes("application/json") ? {} : await S.json();
|
|
51
51
|
} catch (S) {
|
|
52
|
-
throw clearTimeout(
|
|
52
|
+
throw clearTimeout(p), S instanceof Error && S.name === "AbortError" ? new Error(`Request timeout after ${m}ms`) : S;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
async get(e, t) {
|
|
@@ -124,7 +124,7 @@ class Fe {
|
|
|
124
124
|
})).data;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
const xe =
|
|
127
|
+
const xe = he(null);
|
|
128
128
|
function Jt({ config: i, children: e }) {
|
|
129
129
|
const t = te(
|
|
130
130
|
() => {
|
|
@@ -149,7 +149,7 @@ function Jt({ config: i, children: e }) {
|
|
|
149
149
|
}
|
|
150
150
|
}), [o, a] = k(!r), [m, y] = k(null), b = te(() => {
|
|
151
151
|
const f = () => {
|
|
152
|
-
|
|
152
|
+
p();
|
|
153
153
|
};
|
|
154
154
|
return {
|
|
155
155
|
appId: i.appId,
|
|
@@ -160,7 +160,7 @@ function Jt({ config: i, children: e }) {
|
|
|
160
160
|
appError: m,
|
|
161
161
|
retryApp: f
|
|
162
162
|
};
|
|
163
|
-
}, [i, r, o, m]),
|
|
163
|
+
}, [i, r, o, m]), p = ie(
|
|
164
164
|
async (f = !1) => {
|
|
165
165
|
if (!(!f && t.enabled && r))
|
|
166
166
|
try {
|
|
@@ -194,31 +194,31 @@ function Jt({ config: i, children: e }) {
|
|
|
194
194
|
if (Date.now() - T.timestamp > t.ttl * 0.5) {
|
|
195
195
|
const C = new ne(i.baseUrl), x = await new Fe(C, {}).getPublicAppInfo(i.appId);
|
|
196
196
|
s(x);
|
|
197
|
-
const
|
|
197
|
+
const g = {
|
|
198
198
|
data: x,
|
|
199
199
|
timestamp: Date.now(),
|
|
200
200
|
appId: i.appId
|
|
201
201
|
};
|
|
202
|
-
localStorage.setItem(t.storageKey, JSON.stringify(
|
|
202
|
+
localStorage.setItem(t.storageKey, JSON.stringify(g));
|
|
203
203
|
}
|
|
204
204
|
} catch (f) {
|
|
205
205
|
console.warn("Background app refresh failed:", f);
|
|
206
206
|
}
|
|
207
207
|
}, [i, t, r]);
|
|
208
208
|
return re(() => {
|
|
209
|
-
r ? S() :
|
|
209
|
+
r ? S() : p();
|
|
210
210
|
}, []), /* @__PURE__ */ n(xe.Provider, { value: b, children: e });
|
|
211
211
|
}
|
|
212
|
-
function
|
|
212
|
+
function ge() {
|
|
213
213
|
const i = se(xe);
|
|
214
214
|
if (!i)
|
|
215
215
|
throw new Error("useApp must be used within an AppProvider");
|
|
216
216
|
return i;
|
|
217
217
|
}
|
|
218
|
-
function
|
|
218
|
+
function Be() {
|
|
219
219
|
return se(xe);
|
|
220
220
|
}
|
|
221
|
-
const Kt =
|
|
221
|
+
const Kt = ge;
|
|
222
222
|
class ke {
|
|
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);
|
|
@@ -372,7 +372,7 @@ class ke {
|
|
|
372
372
|
return e !== null && !this.isTokenExpired(e);
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
|
-
class
|
|
375
|
+
class rt {
|
|
376
376
|
constructor(e) {
|
|
377
377
|
this.httpService = e;
|
|
378
378
|
}
|
|
@@ -504,7 +504,7 @@ class Ce {
|
|
|
504
504
|
};
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
|
-
class
|
|
507
|
+
class nt {
|
|
508
508
|
constructor(e, t) {
|
|
509
509
|
this.httpService = e, this.sessionManager = t;
|
|
510
510
|
}
|
|
@@ -544,7 +544,7 @@ class rt {
|
|
|
544
544
|
});
|
|
545
545
|
}
|
|
546
546
|
}
|
|
547
|
-
class
|
|
547
|
+
class ue {
|
|
548
548
|
constructor(e, t, r) {
|
|
549
549
|
this.httpService = e, this.appId = t, this.sessionManager = r;
|
|
550
550
|
}
|
|
@@ -622,7 +622,7 @@ class de {
|
|
|
622
622
|
)).data;
|
|
623
623
|
}
|
|
624
624
|
}
|
|
625
|
-
function
|
|
625
|
+
function st(i, e) {
|
|
626
626
|
if (i === "localhost" || i.startsWith("127.") || i.startsWith("192.168."))
|
|
627
627
|
return null;
|
|
628
628
|
if (e) {
|
|
@@ -638,22 +638,22 @@ function nt(i, e) {
|
|
|
638
638
|
const r = i.split(".");
|
|
639
639
|
return r.length >= 3 && r[0] !== "www" ? r[0] : null;
|
|
640
640
|
}
|
|
641
|
-
function
|
|
641
|
+
function it(i, e = "tenant", t) {
|
|
642
642
|
const s = new URLSearchParams(i).get(e);
|
|
643
643
|
return s ? (t && t.setItem("tenant", s), s) : t ? t.getItem("tenant") : null;
|
|
644
644
|
}
|
|
645
|
-
function
|
|
645
|
+
function ot(i, e, t) {
|
|
646
646
|
const { tenantMode: r, baseDomain: s, selectorParam: o } = i;
|
|
647
|
-
return r === "subdomain" ?
|
|
647
|
+
return r === "subdomain" ? st(e.hostname, s) : r === "selector" ? it(e.search, o, t) : null;
|
|
648
648
|
}
|
|
649
|
-
function
|
|
649
|
+
function at(i, e, t) {
|
|
650
650
|
if (t)
|
|
651
651
|
return `${i}.${t}`;
|
|
652
652
|
const r = e.split(".");
|
|
653
653
|
return r.length === 2 ? `${i}.${e}` : r.length >= 3 ? (r[0] = i, r.join(".")) : null;
|
|
654
654
|
}
|
|
655
|
-
const
|
|
656
|
-
function
|
|
655
|
+
const le = "_auth";
|
|
656
|
+
function De(i) {
|
|
657
657
|
const e = JSON.stringify(i);
|
|
658
658
|
return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
659
659
|
}
|
|
@@ -671,7 +671,7 @@ function lt(i) {
|
|
|
671
671
|
function ct() {
|
|
672
672
|
if (typeof window > "u")
|
|
673
673
|
return console.log("[CrossDomainAuth] SSR environment, skipping URL token extraction"), null;
|
|
674
|
-
const e = new URLSearchParams(window.location.search).get(
|
|
674
|
+
const e = new URLSearchParams(window.location.search).get(le);
|
|
675
675
|
if (console.log("[CrossDomainAuth] extractAuthTokensFromUrl called", {
|
|
676
676
|
hasAuthParam: !!e,
|
|
677
677
|
searchParams: window.location.search,
|
|
@@ -688,14 +688,14 @@ function ct() {
|
|
|
688
688
|
function dt() {
|
|
689
689
|
if (typeof window > "u") return;
|
|
690
690
|
const i = new URL(window.location.href);
|
|
691
|
-
i.searchParams.delete(
|
|
691
|
+
i.searchParams.delete(le), console.log("[CrossDomainAuth] Clearing auth tokens from URL", {
|
|
692
692
|
oldUrl: window.location.href,
|
|
693
693
|
newUrl: i.toString()
|
|
694
694
|
}), window.history.replaceState({}, "", i.toString());
|
|
695
695
|
}
|
|
696
|
-
const Ae =
|
|
696
|
+
const Ae = he(null);
|
|
697
697
|
function Yt({ config: i, children: e }) {
|
|
698
|
-
const { baseUrl: t, appInfo: r, appId: s } =
|
|
698
|
+
const { baseUrl: t, appInfo: r, appId: s } = ge(), o = ie(() => typeof window > "u" ? null : ot(
|
|
699
699
|
{
|
|
700
700
|
tenantMode: i.tenantMode || "selector",
|
|
701
701
|
baseDomain: i.baseDomain,
|
|
@@ -717,7 +717,7 @@ function Yt({ config: i, children: e }) {
|
|
|
717
717
|
};
|
|
718
718
|
},
|
|
719
719
|
[i.cache, a]
|
|
720
|
-
), [b,
|
|
720
|
+
), [b, p] = k(() => {
|
|
721
721
|
if (i.initialTenant) return i.initialTenant;
|
|
722
722
|
if (!y.enabled || !a) return null;
|
|
723
723
|
try {
|
|
@@ -728,18 +728,18 @@ function Yt({ config: i, children: e }) {
|
|
|
728
728
|
} catch {
|
|
729
729
|
return null;
|
|
730
730
|
}
|
|
731
|
-
}), [S, f] = k(!b && !i.initialTenant), [T, I] = k(null), [C, R] = k(null), [x,
|
|
731
|
+
}), [S, f] = k(!b && !i.initialTenant), [T, I] = k(null), [C, R] = k(null), [x, g] = k(!1), [$, A] = k(null);
|
|
732
732
|
re(() => {
|
|
733
733
|
const l = o();
|
|
734
734
|
m(l);
|
|
735
735
|
}, [o]);
|
|
736
|
-
const E = (r == null ? void 0 : r.settingsSchema) || null,
|
|
736
|
+
const E = (r == null ? void 0 : r.settingsSchema) || null, U = ie(
|
|
737
737
|
async (l, H = !1) => {
|
|
738
738
|
if (!(!H && y.enabled && b && b.domain === l))
|
|
739
739
|
try {
|
|
740
740
|
f(!0), I(null);
|
|
741
|
-
const M = new ne(t), u = await new
|
|
742
|
-
if (
|
|
741
|
+
const M = new ne(t), u = await new ue(M, s).getPublicTenantInfo(l);
|
|
742
|
+
if (p(u), y.enabled)
|
|
743
743
|
try {
|
|
744
744
|
const w = {
|
|
745
745
|
data: u,
|
|
@@ -751,8 +751,8 @@ function Yt({ config: i, children: e }) {
|
|
|
751
751
|
console.warn("Failed to cache tenant info:", w);
|
|
752
752
|
}
|
|
753
753
|
} catch (M) {
|
|
754
|
-
const
|
|
755
|
-
I(
|
|
754
|
+
const h = M instanceof Error ? M : new Error("Failed to load tenant information");
|
|
755
|
+
I(h), p(null);
|
|
756
756
|
} finally {
|
|
757
757
|
f(!1);
|
|
758
758
|
}
|
|
@@ -765,8 +765,8 @@ function Yt({ config: i, children: e }) {
|
|
|
765
765
|
if (!l) return;
|
|
766
766
|
const H = JSON.parse(l);
|
|
767
767
|
if (Date.now() - H.timestamp > y.ttl * 0.5) {
|
|
768
|
-
const
|
|
769
|
-
|
|
768
|
+
const h = new ne(t), w = await new ue(h, s).getPublicTenantInfo(a);
|
|
769
|
+
p(w);
|
|
770
770
|
const _ = {
|
|
771
771
|
data: w,
|
|
772
772
|
timestamp: Date.now(),
|
|
@@ -780,14 +780,14 @@ function Yt({ config: i, children: e }) {
|
|
|
780
780
|
}, [t, s, y, b, a]), P = ie(async () => {
|
|
781
781
|
if (b != null && b.id)
|
|
782
782
|
try {
|
|
783
|
-
|
|
784
|
-
const l = new ne(t), M = await new
|
|
783
|
+
g(!0), A(null);
|
|
784
|
+
const l = new ne(t), M = await new ue(l, b.appId).getTenantSettings(b.id);
|
|
785
785
|
R(M);
|
|
786
786
|
} catch (l) {
|
|
787
787
|
const H = l instanceof Error ? l : new Error("Failed to load tenant settings");
|
|
788
788
|
A(H), R(null);
|
|
789
789
|
} finally {
|
|
790
|
-
|
|
790
|
+
g(!1);
|
|
791
791
|
}
|
|
792
792
|
}, [t, b]), O = ie(() => {
|
|
793
793
|
P();
|
|
@@ -797,7 +797,7 @@ function Yt({ config: i, children: e }) {
|
|
|
797
797
|
return { isValid: !0, errors: [] };
|
|
798
798
|
const H = [];
|
|
799
799
|
try {
|
|
800
|
-
return E.properties && Object.entries(E.properties).forEach(([M,
|
|
800
|
+
return E.properties && Object.entries(E.properties).forEach(([M, h]) => {
|
|
801
801
|
var w;
|
|
802
802
|
const u = l[M];
|
|
803
803
|
if ((w = E.required) != null && w.includes(M) && u == null) {
|
|
@@ -805,15 +805,15 @@ function Yt({ config: i, children: e }) {
|
|
|
805
805
|
return;
|
|
806
806
|
}
|
|
807
807
|
if (u != null) {
|
|
808
|
-
if (
|
|
809
|
-
const _ =
|
|
808
|
+
if (h.type) {
|
|
809
|
+
const _ = h.type, K = typeof u;
|
|
810
810
|
_ === "string" && K !== "string" ? H.push(`Field '${M}' must be a string`) : (_ === "number" || _ === "integer") && K !== "number" ? H.push(`Field '${M}' must be a number`) : _ === "boolean" && K !== "boolean" ? H.push(`Field '${M}' must be a boolean`) : _ === "array" && !Array.isArray(u) && H.push(`Field '${M}' must be an array`);
|
|
811
811
|
}
|
|
812
|
-
|
|
813
|
-
`Field '${M}' must be at least ${
|
|
814
|
-
),
|
|
815
|
-
`Field '${M}' must be no more than ${
|
|
816
|
-
),
|
|
812
|
+
h.minLength !== void 0 && typeof u == "string" && u.length < h.minLength && H.push(
|
|
813
|
+
`Field '${M}' must be at least ${h.minLength} characters long`
|
|
814
|
+
), h.maxLength !== void 0 && typeof u == "string" && u.length > h.maxLength && H.push(
|
|
815
|
+
`Field '${M}' must be no more than ${h.maxLength} characters long`
|
|
816
|
+
), h.minimum !== void 0 && typeof u == "number" && u < h.minimum && H.push(`Field '${M}' must be at least ${h.minimum}`), h.maximum !== void 0 && typeof u == "number" && u > h.maximum && H.push(`Field '${M}' must be no more than ${h.maximum}`), h.pattern && typeof u == "string" && (new RegExp(h.pattern).test(u) || H.push(`Field '${M}' does not match the required pattern`)), h.enum && !h.enum.includes(u) && H.push(`Field '${M}' must be one of: ${h.enum.join(", ")}`);
|
|
817
817
|
}
|
|
818
818
|
}), {
|
|
819
819
|
isValid: H.length === 0,
|
|
@@ -829,15 +829,15 @@ function Yt({ config: i, children: e }) {
|
|
|
829
829
|
[E]
|
|
830
830
|
);
|
|
831
831
|
re(() => {
|
|
832
|
-
!i.initialTenant && a ? b ? D() :
|
|
833
|
-
}, [i.initialTenant, a, b,
|
|
834
|
-
b != null && b.id ? P() : (R(null), A(null),
|
|
832
|
+
!i.initialTenant && a ? b ? D() : U(a) : !i.initialTenant && !a && (p(null), I(null), f(!1));
|
|
833
|
+
}, [i.initialTenant, a, b, U, D]), re(() => {
|
|
834
|
+
b != null && b.id ? P() : (R(null), A(null), g(!1));
|
|
835
835
|
}, [b == null ? void 0 : b.id, P]);
|
|
836
836
|
const L = ie(
|
|
837
837
|
(l, H) => {
|
|
838
|
-
const { mode: M = "reload", tokens:
|
|
838
|
+
const { mode: M = "reload", tokens: h, redirectPath: u } = H || {}, w = i.tenantMode || "selector";
|
|
839
839
|
if (localStorage.setItem("tenant", l), w === "subdomain") {
|
|
840
|
-
const _ = window.location.hostname, K =
|
|
840
|
+
const _ = window.location.hostname, K = at(
|
|
841
841
|
l,
|
|
842
842
|
_,
|
|
843
843
|
i.baseDomain
|
|
@@ -849,22 +849,22 @@ function Yt({ config: i, children: e }) {
|
|
|
849
849
|
);
|
|
850
850
|
return;
|
|
851
851
|
}
|
|
852
|
-
const
|
|
852
|
+
const B = u || window.location.pathname, q = new URL(`${window.location.protocol}//${K}${B}`);
|
|
853
853
|
new URLSearchParams(window.location.search).forEach((v, J) => {
|
|
854
|
-
J !==
|
|
855
|
-
}),
|
|
854
|
+
J !== le && q.searchParams.set(J, v);
|
|
855
|
+
}), h && q.searchParams.set(le, De(h)), window.location.href = q.toString();
|
|
856
856
|
} else if (w === "selector") {
|
|
857
857
|
const _ = u || window.location.pathname, K = new URLSearchParams(window.location.search);
|
|
858
|
-
if (K.set(i.selectorParam || "tenant", l), M === "reload") {
|
|
859
|
-
const
|
|
860
|
-
window.location.href =
|
|
858
|
+
if (K.set(i.selectorParam || "tenant", l), K.delete(le), h && K.set(le, De(h)), M === "reload") {
|
|
859
|
+
const B = `${_}?${K.toString()}${window.location.hash}`;
|
|
860
|
+
window.location.href = B;
|
|
861
861
|
} else {
|
|
862
|
-
const
|
|
863
|
-
window.history.pushState({}, "",
|
|
862
|
+
const B = `${_}?${K.toString()}${window.location.hash}`;
|
|
863
|
+
window.history.pushState({}, "", B), m(l), U(l);
|
|
864
864
|
}
|
|
865
865
|
}
|
|
866
866
|
},
|
|
867
|
-
[i.tenantMode, i.selectorParam, i.baseDomain,
|
|
867
|
+
[i.tenantMode, i.selectorParam, i.baseDomain, U]
|
|
868
868
|
), F = te(() => ({
|
|
869
869
|
// Tenant info
|
|
870
870
|
tenant: b,
|
|
@@ -872,7 +872,7 @@ function Yt({ config: i, children: e }) {
|
|
|
872
872
|
isTenantLoading: S,
|
|
873
873
|
tenantError: T,
|
|
874
874
|
retryTenant: () => {
|
|
875
|
-
a &&
|
|
875
|
+
a && U(a);
|
|
876
876
|
},
|
|
877
877
|
// Settings
|
|
878
878
|
settings: C,
|
|
@@ -919,7 +919,7 @@ function Xt() {
|
|
|
919
919
|
validateSettings: s
|
|
920
920
|
};
|
|
921
921
|
}
|
|
922
|
-
function
|
|
922
|
+
function ce() {
|
|
923
923
|
const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } = ye();
|
|
924
924
|
return {
|
|
925
925
|
tenant: i,
|
|
@@ -929,16 +929,16 @@ function le() {
|
|
|
929
929
|
retry: s
|
|
930
930
|
};
|
|
931
931
|
}
|
|
932
|
-
const Pe =
|
|
932
|
+
const Pe = he(null);
|
|
933
933
|
function Zt({ config: i = {}, children: e }) {
|
|
934
|
-
const { appId: t, baseUrl: r } =
|
|
934
|
+
const { appId: t, baseUrl: r } = ge(), { tenant: s, tenantSlug: o, switchTenant: a } = ye(), [m, y] = k(i.initialRoles || []), [b, p] = k(!i.initialRoles), [S, f] = k(null), [T, I] = k(!1), [C, R] = k(null), [x, g] = k(0), [$, A] = k(() => {
|
|
935
935
|
try {
|
|
936
936
|
const v = localStorage.getItem("userTenants");
|
|
937
937
|
return v ? JSON.parse(v) : [];
|
|
938
938
|
} catch {
|
|
939
939
|
return [];
|
|
940
940
|
}
|
|
941
|
-
}), [E,
|
|
941
|
+
}), [E, U] = k(!1), D = Ue({ done: !1, urlTokens: null });
|
|
942
942
|
D.current.done || (D.current.done = !0, D.current.urlTokens = ct(), D.current.urlTokens && console.log(
|
|
943
943
|
"[AuthProvider] SYNC: URL tokens found, will block isAuthReady until user loaded"
|
|
944
944
|
));
|
|
@@ -959,13 +959,13 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
959
959
|
}, [o, r, i.onRefreshFailed]), L = D.current.done && !P, F = te(() => {
|
|
960
960
|
const v = new ne(r);
|
|
961
961
|
return v.setSessionManager(c), v;
|
|
962
|
-
}, [r, c]), l = te(() => new
|
|
963
|
-
const v = async (
|
|
962
|
+
}, [r, c]), l = te(() => new rt(new ne(r)), [r]), H = te(() => new nt(F, c), [F, c]), M = te(() => new Ce(new ne(r)), [r]), h = te(() => S || c.getUser(), [S, c]), u = te(() => h != null && h.roleId && m.find((v) => v.id === h.roleId) || null, [h, m]), w = te(() => (u == null ? void 0 : u.permissions) || [], [u]), _ = te(() => c.hasValidSession() && S !== null, [c, S]), K = 5 * 60 * 1e3, B = te(() => {
|
|
963
|
+
const v = async (N = !1) => {
|
|
964
964
|
try {
|
|
965
965
|
if (!c.hasValidSession())
|
|
966
966
|
return;
|
|
967
967
|
const z = Date.now();
|
|
968
|
-
if (!
|
|
968
|
+
if (!N && z - x < K && S)
|
|
969
969
|
return;
|
|
970
970
|
const W = c.getUserId();
|
|
971
971
|
if (!W) {
|
|
@@ -974,7 +974,7 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
974
974
|
}
|
|
975
975
|
I(!0), R(null);
|
|
976
976
|
const Q = await H.getUserById(W);
|
|
977
|
-
f(Q), c.setUser(Q),
|
|
977
|
+
f(Q), c.setUser(Q), g(Date.now());
|
|
978
978
|
} catch (z) {
|
|
979
979
|
const Y = z instanceof Error ? z : new Error("Failed to load user data");
|
|
980
980
|
R(Y), console.error("[AuthProvider] Failed to load user data:", Y);
|
|
@@ -983,18 +983,18 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
983
983
|
}
|
|
984
984
|
}, J = async () => {
|
|
985
985
|
await v();
|
|
986
|
-
}, ae = async (
|
|
986
|
+
}, ae = async (N) => {
|
|
987
987
|
var Le;
|
|
988
|
-
const { username: z, password: Y, tenantSlug: W, redirectPath: Q } =
|
|
988
|
+
const { username: z, password: Y, tenantSlug: W, redirectPath: Q } = N;
|
|
989
989
|
let X = s == null ? void 0 : s.id, Z = o, ee = c;
|
|
990
|
-
W && (X = (await new
|
|
990
|
+
W && (X = (await new ue(F, t).getPublicTenantInfo(W)).id, Z = W);
|
|
991
991
|
const G = await l.login({
|
|
992
992
|
username: z,
|
|
993
993
|
password: Y,
|
|
994
994
|
appId: t,
|
|
995
995
|
tenantId: X
|
|
996
|
-
}),
|
|
997
|
-
if (
|
|
996
|
+
}), de = W && W !== o;
|
|
997
|
+
if (de && (ee = new ke({
|
|
998
998
|
tenantSlug: Z,
|
|
999
999
|
baseUrl: r
|
|
1000
1000
|
})), ee.setTokens({
|
|
@@ -1005,8 +1005,8 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1005
1005
|
ee.setUser(G.user), f(G.user);
|
|
1006
1006
|
try {
|
|
1007
1007
|
await v();
|
|
1008
|
-
} catch (
|
|
1009
|
-
console.warn("Failed to load complete user data after login:",
|
|
1008
|
+
} catch (pe) {
|
|
1009
|
+
console.warn("Failed to load complete user data after login:", pe);
|
|
1010
1010
|
}
|
|
1011
1011
|
}
|
|
1012
1012
|
if (G.tenants && G.tenants.length > 0) {
|
|
@@ -1017,7 +1017,7 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1017
1017
|
}
|
|
1018
1018
|
}
|
|
1019
1019
|
const ve = ((Le = G.user) == null ? void 0 : Le.tenantId) !== null;
|
|
1020
|
-
if (
|
|
1020
|
+
if (U(ve), de && Z && Z !== o && a(Z, {
|
|
1021
1021
|
tokens: {
|
|
1022
1022
|
accessToken: G.accessToken,
|
|
1023
1023
|
refreshToken: G.refreshToken,
|
|
@@ -1025,8 +1025,8 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1025
1025
|
},
|
|
1026
1026
|
redirectPath: Q
|
|
1027
1027
|
}), !ve && G.tenants && G.tenants.length > 0) {
|
|
1028
|
-
const
|
|
1029
|
-
if (G.tenants.length === 1 &&
|
|
1028
|
+
const pe = N.autoSwitch !== !1 && i.autoSwitchSingleTenant !== !1;
|
|
1029
|
+
if (G.tenants.length === 1 && pe) {
|
|
1030
1030
|
const Ee = G.tenants[0];
|
|
1031
1031
|
a(Ee.subdomain, {
|
|
1032
1032
|
tokens: {
|
|
@@ -1039,8 +1039,8 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1039
1039
|
} else G.tenants.length > 1 && i.onTenantSelectionRequired && i.onTenantSelectionRequired(G.tenants);
|
|
1040
1040
|
}
|
|
1041
1041
|
return G;
|
|
1042
|
-
}, be = async (
|
|
1043
|
-
const { email: z, phoneNumber: Y, name: W, password: Q, lastName: X, tenantId: Z } =
|
|
1042
|
+
}, be = async (N) => {
|
|
1043
|
+
const { email: z, phoneNumber: Y, name: W, password: Q, lastName: X, tenantId: Z } = N;
|
|
1044
1044
|
if (!z && !Y)
|
|
1045
1045
|
throw new Error("Either email or phoneNumber is required");
|
|
1046
1046
|
if (!W || !Q)
|
|
@@ -1055,8 +1055,8 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1055
1055
|
lastName: X,
|
|
1056
1056
|
appId: t
|
|
1057
1057
|
});
|
|
1058
|
-
},
|
|
1059
|
-
const { email: z, phoneNumber: Y, name: W, password: Q, tenantName: X, lastName: Z } =
|
|
1058
|
+
}, We = async (N) => {
|
|
1059
|
+
const { email: z, phoneNumber: Y, name: W, password: Q, tenantName: X, lastName: Z } = N;
|
|
1060
1060
|
if (!z && !Y)
|
|
1061
1061
|
throw new Error("Either email or phoneNumber is required");
|
|
1062
1062
|
if (!W || !Q || !X)
|
|
@@ -1070,19 +1070,19 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1070
1070
|
appId: t,
|
|
1071
1071
|
lastName: Z
|
|
1072
1072
|
});
|
|
1073
|
-
},
|
|
1074
|
-
const { currentPassword: z, newPassword: Y } =
|
|
1073
|
+
}, je = async (N) => {
|
|
1074
|
+
const { currentPassword: z, newPassword: Y } = N, W = await c.getAuthHeaders();
|
|
1075
1075
|
await l.changePassword({ currentPassword: z, newPassword: Y }, W);
|
|
1076
|
-
},
|
|
1077
|
-
const { email: z, tenantId: Y } =
|
|
1076
|
+
}, Ve = async (N) => {
|
|
1077
|
+
const { email: z, tenantId: Y } = N, W = Y ?? (s == null ? void 0 : s.id);
|
|
1078
1078
|
if (!W)
|
|
1079
1079
|
throw new Error("tenantId is required for password reset");
|
|
1080
1080
|
await l.requestPasswordReset({ email: z, tenantId: W });
|
|
1081
|
-
},
|
|
1082
|
-
const { token: z, newPassword: Y } =
|
|
1081
|
+
}, Ge = async (N) => {
|
|
1082
|
+
const { token: z, newPassword: Y } = N;
|
|
1083
1083
|
await l.confirmPasswordReset({ token: z, newPassword: Y });
|
|
1084
|
-
},
|
|
1085
|
-
const { email: z, frontendUrl: Y, name: W, lastName: Q, tenantId: X } =
|
|
1084
|
+
}, _e = async (N) => {
|
|
1085
|
+
const { email: z, frontendUrl: Y, name: W, lastName: Q, tenantId: X } = N, Z = X ?? (s == null ? void 0 : s.id);
|
|
1086
1086
|
if (!Z)
|
|
1087
1087
|
throw new Error("tenantId is required for magic link authentication");
|
|
1088
1088
|
return await l.sendMagicLink({
|
|
@@ -1093,10 +1093,10 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1093
1093
|
lastName: Q,
|
|
1094
1094
|
appId: t
|
|
1095
1095
|
});
|
|
1096
|
-
},
|
|
1097
|
-
const { token: z, email: Y, tenantSlug: W } =
|
|
1096
|
+
}, Je = async (N) => {
|
|
1097
|
+
const { token: z, email: Y, tenantSlug: W } = N;
|
|
1098
1098
|
let Q = s == null ? void 0 : s.id, X = o, Z = c;
|
|
1099
|
-
W && (Q = (await new
|
|
1099
|
+
W && (Q = (await new ue(F, t).getPublicTenantInfo(W)).id, X = W);
|
|
1100
1100
|
const ee = await l.verifyMagicLink({
|
|
1101
1101
|
token: z,
|
|
1102
1102
|
email: Y,
|
|
@@ -1114,8 +1114,8 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1114
1114
|
Z.setUser(ee.user), f(ee.user);
|
|
1115
1115
|
try {
|
|
1116
1116
|
await v();
|
|
1117
|
-
} catch (
|
|
1118
|
-
console.warn("Failed to load complete user data after magic link login:",
|
|
1117
|
+
} catch (de) {
|
|
1118
|
+
console.warn("Failed to load complete user data after magic link login:", de);
|
|
1119
1119
|
}
|
|
1120
1120
|
}
|
|
1121
1121
|
return G && X && X !== o && a(X, {
|
|
@@ -1125,47 +1125,47 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1125
1125
|
expiresIn: ee.expiresIn
|
|
1126
1126
|
}
|
|
1127
1127
|
}), ee;
|
|
1128
|
-
},
|
|
1129
|
-
const
|
|
1130
|
-
if (!(
|
|
1128
|
+
}, Ke = async () => {
|
|
1129
|
+
const N = c.getTokens();
|
|
1130
|
+
if (!(N != null && N.refreshToken))
|
|
1131
1131
|
throw new Error("No refresh token available");
|
|
1132
1132
|
const z = await l.refreshToken({
|
|
1133
|
-
refreshToken:
|
|
1133
|
+
refreshToken: N.refreshToken
|
|
1134
1134
|
});
|
|
1135
1135
|
c.setTokens({
|
|
1136
1136
|
accessToken: z.accessToken,
|
|
1137
|
-
refreshToken: z.refreshToken ||
|
|
1137
|
+
refreshToken: z.refreshToken || N.refreshToken,
|
|
1138
1138
|
expiresIn: z.expiresIn
|
|
1139
1139
|
});
|
|
1140
|
-
},
|
|
1141
|
-
c.clearSession(), f(null), R(null), A([]),
|
|
1140
|
+
}, Ye = () => {
|
|
1141
|
+
c.clearSession(), f(null), R(null), A([]), U(!1);
|
|
1142
1142
|
try {
|
|
1143
1143
|
localStorage.removeItem("userTenants");
|
|
1144
1144
|
} catch {
|
|
1145
1145
|
}
|
|
1146
|
-
},
|
|
1147
|
-
c.setTokens(
|
|
1148
|
-
},
|
|
1146
|
+
}, Qe = (N) => {
|
|
1147
|
+
c.setTokens(N);
|
|
1148
|
+
}, Xe = () => c.hasValidSession(), Ze = () => {
|
|
1149
1149
|
c.clearSession(), f(null), R(null);
|
|
1150
|
-
},
|
|
1150
|
+
}, et = async () => {
|
|
1151
1151
|
if (t)
|
|
1152
1152
|
try {
|
|
1153
|
-
|
|
1154
|
-
const { roles:
|
|
1155
|
-
y(
|
|
1156
|
-
} catch (
|
|
1157
|
-
console.error("Failed to fetch roles:",
|
|
1153
|
+
p(!0);
|
|
1154
|
+
const { roles: N } = await M.getRolesByApp(t);
|
|
1155
|
+
y(N);
|
|
1156
|
+
} catch (N) {
|
|
1157
|
+
console.error("Failed to fetch roles:", N);
|
|
1158
1158
|
} finally {
|
|
1159
|
-
|
|
1159
|
+
p(!1);
|
|
1160
1160
|
}
|
|
1161
|
-
},
|
|
1162
|
-
await
|
|
1163
|
-
}, Se = (
|
|
1161
|
+
}, tt = async () => {
|
|
1162
|
+
await et();
|
|
1163
|
+
}, Se = (N) => {
|
|
1164
1164
|
if (!w || w.length === 0)
|
|
1165
1165
|
return !1;
|
|
1166
|
-
if (typeof
|
|
1167
|
-
return w.includes(
|
|
1168
|
-
const z = `${
|
|
1166
|
+
if (typeof N == "string")
|
|
1167
|
+
return w.includes(N);
|
|
1168
|
+
const z = `${N.resource}.${N.action}`;
|
|
1169
1169
|
return w.includes(z);
|
|
1170
1170
|
};
|
|
1171
1171
|
return {
|
|
@@ -1175,17 +1175,17 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1175
1175
|
authenticatedHttpService: F,
|
|
1176
1176
|
login: ae,
|
|
1177
1177
|
signup: be,
|
|
1178
|
-
signupTenantAdmin:
|
|
1179
|
-
sendMagicLink:
|
|
1180
|
-
verifyMagicLink:
|
|
1181
|
-
changePassword:
|
|
1182
|
-
requestPasswordReset:
|
|
1183
|
-
confirmPasswordReset:
|
|
1184
|
-
refreshToken:
|
|
1185
|
-
logout:
|
|
1186
|
-
setTokens:
|
|
1187
|
-
hasValidSession:
|
|
1188
|
-
clearSession:
|
|
1178
|
+
signupTenantAdmin: We,
|
|
1179
|
+
sendMagicLink: _e,
|
|
1180
|
+
verifyMagicLink: Je,
|
|
1181
|
+
changePassword: je,
|
|
1182
|
+
requestPasswordReset: Ve,
|
|
1183
|
+
confirmPasswordReset: Ge,
|
|
1184
|
+
refreshToken: Ke,
|
|
1185
|
+
logout: Ye,
|
|
1186
|
+
setTokens: Qe,
|
|
1187
|
+
hasValidSession: Xe,
|
|
1188
|
+
clearSession: Ze,
|
|
1189
1189
|
currentUser: S,
|
|
1190
1190
|
isUserLoading: T,
|
|
1191
1191
|
userError: C,
|
|
@@ -1198,28 +1198,28 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1198
1198
|
availableRoles: m,
|
|
1199
1199
|
rolesLoading: b,
|
|
1200
1200
|
hasPermission: Se,
|
|
1201
|
-
hasAnyPermission: (
|
|
1202
|
-
hasAllPermissions: (
|
|
1201
|
+
hasAnyPermission: (N) => N.some((z) => Se(z)),
|
|
1202
|
+
hasAllPermissions: (N) => N.every((z) => Se(z)),
|
|
1203
1203
|
getUserPermissionStrings: () => w || [],
|
|
1204
|
-
refreshRoles:
|
|
1204
|
+
refreshRoles: tt,
|
|
1205
1205
|
// RFC-004: Multi-tenant user membership
|
|
1206
1206
|
userTenants: $,
|
|
1207
1207
|
hasTenantContext: E,
|
|
1208
|
-
switchToTenant: async (
|
|
1208
|
+
switchToTenant: async (N, z) => {
|
|
1209
1209
|
const { redirectPath: Y } = z || {}, W = c.getTokens();
|
|
1210
1210
|
if (!(W != null && W.refreshToken))
|
|
1211
1211
|
throw new Error("No refresh token available for tenant switch");
|
|
1212
1212
|
const Q = await l.switchTenant({
|
|
1213
1213
|
refreshToken: W.refreshToken,
|
|
1214
|
-
tenantId:
|
|
1214
|
+
tenantId: N
|
|
1215
1215
|
});
|
|
1216
1216
|
c.setTokens({
|
|
1217
1217
|
accessToken: Q.accessToken,
|
|
1218
1218
|
refreshToken: W.refreshToken,
|
|
1219
1219
|
// Keep the same refresh token
|
|
1220
1220
|
expiresIn: Q.expiresIn
|
|
1221
|
-
}), f(Q.user), c.setUser(Q.user),
|
|
1222
|
-
const X = $.find((Z) => Z.id ===
|
|
1221
|
+
}), f(Q.user), c.setUser(Q.user), U(!0);
|
|
1222
|
+
const X = $.find((Z) => Z.id === N);
|
|
1223
1223
|
X && a(X.subdomain, {
|
|
1224
1224
|
tokens: {
|
|
1225
1225
|
accessToken: Q.accessToken,
|
|
@@ -1230,7 +1230,7 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1230
1230
|
});
|
|
1231
1231
|
},
|
|
1232
1232
|
refreshUserTenants: async () => {
|
|
1233
|
-
const
|
|
1233
|
+
const N = await c.getAuthHeaders(), z = await l.getUserTenants(N);
|
|
1234
1234
|
A(z);
|
|
1235
1235
|
try {
|
|
1236
1236
|
localStorage.setItem("userTenants", JSON.stringify(z));
|
|
@@ -1265,38 +1265,38 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1265
1265
|
re(() => {
|
|
1266
1266
|
!i.initialRoles && t && (async () => {
|
|
1267
1267
|
try {
|
|
1268
|
-
|
|
1268
|
+
p(!0);
|
|
1269
1269
|
const J = new ne(r), ae = new Ce(J), { roles: be } = await ae.getRolesByApp(t);
|
|
1270
1270
|
y(be);
|
|
1271
1271
|
} catch (J) {
|
|
1272
1272
|
console.error("Failed to fetch roles:", J);
|
|
1273
1273
|
} finally {
|
|
1274
|
-
|
|
1274
|
+
p(!1);
|
|
1275
1275
|
}
|
|
1276
1276
|
})();
|
|
1277
1277
|
}, [t, r, i.initialRoles]);
|
|
1278
1278
|
const [q, V] = k(!1);
|
|
1279
1279
|
return re(() => {
|
|
1280
|
-
q || (V(!0), D.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), dt(), O(!0), console.log("[AuthProvider] EFFECT: Loading user data (blocking isAuthReady)..."),
|
|
1280
|
+
q || (V(!0), D.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), dt(), O(!0), console.log("[AuthProvider] EFFECT: Loading user data (blocking isAuthReady)..."), B.loadUserData().catch((v) => {
|
|
1281
1281
|
console.error("[AuthProvider] Failed to load user data:", v);
|
|
1282
1282
|
}).finally(() => {
|
|
1283
1283
|
console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"), O(!1);
|
|
1284
1284
|
})));
|
|
1285
|
-
}, [
|
|
1285
|
+
}, [B, q]), re(() => {
|
|
1286
1286
|
const v = c.getUser();
|
|
1287
1287
|
v && c.hasValidSession() && f(v);
|
|
1288
1288
|
}, [c]), re(() => {
|
|
1289
|
-
q && (D.current.urlTokens || !S && !T && c.hasValidSession() && (console.log("[AuthProvider] Auto-loading user data..."),
|
|
1289
|
+
q && (D.current.urlTokens || !S && !T && c.hasValidSession() && (console.log("[AuthProvider] Auto-loading user data..."), B.loadUserData().catch(() => {
|
|
1290
1290
|
})));
|
|
1291
|
-
}, [S, T,
|
|
1291
|
+
}, [S, T, B, c, q]), re(() => {
|
|
1292
1292
|
if (!c.hasValidSession() || !S)
|
|
1293
1293
|
return;
|
|
1294
1294
|
const v = setInterval(() => {
|
|
1295
|
-
|
|
1295
|
+
B.loadUserData().catch(() => {
|
|
1296
1296
|
});
|
|
1297
1297
|
}, K);
|
|
1298
1298
|
return () => clearInterval(v);
|
|
1299
|
-
}, [c, S,
|
|
1299
|
+
}, [c, S, B, K]), /* @__PURE__ */ n(Pe.Provider, { value: B, children: e });
|
|
1300
1300
|
}
|
|
1301
1301
|
function oe() {
|
|
1302
1302
|
const i = se(Pe);
|
|
@@ -1387,35 +1387,35 @@ class ut {
|
|
|
1387
1387
|
})).data;
|
|
1388
1388
|
}
|
|
1389
1389
|
}
|
|
1390
|
-
const Ie =
|
|
1390
|
+
const Ie = he(null);
|
|
1391
1391
|
function er({ config: i = {}, children: e }) {
|
|
1392
|
-
const t =
|
|
1393
|
-
const
|
|
1394
|
-
return new ut(
|
|
1392
|
+
const t = Be(), r = we(), s = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (r == null ? void 0 : r.tenant) ?? null, [m, y] = k([]), [b, p] = k(!1), [S, f] = k(null), [T, I] = k(!1), C = te(() => {
|
|
1393
|
+
const g = new ne(s);
|
|
1394
|
+
return new ut(g);
|
|
1395
1395
|
}, [s]), R = async () => {
|
|
1396
1396
|
if (!(a != null && a.id)) {
|
|
1397
1397
|
y([]);
|
|
1398
1398
|
return;
|
|
1399
1399
|
}
|
|
1400
|
-
|
|
1400
|
+
p(!0), f(null);
|
|
1401
1401
|
try {
|
|
1402
|
-
const
|
|
1403
|
-
y(
|
|
1404
|
-
} catch (
|
|
1405
|
-
const $ =
|
|
1406
|
-
f($), i.onError && i.onError(
|
|
1402
|
+
const g = await C.getTenantFeatureFlags(a.id, o);
|
|
1403
|
+
y(g);
|
|
1404
|
+
} catch (g) {
|
|
1405
|
+
const $ = g instanceof Error ? g.message : "Failed to fetch feature flags";
|
|
1406
|
+
f($), i.onError && i.onError(g instanceof Error ? g : new Error($));
|
|
1407
1407
|
} finally {
|
|
1408
|
-
|
|
1408
|
+
p(!1);
|
|
1409
1409
|
}
|
|
1410
1410
|
};
|
|
1411
1411
|
re(() => {
|
|
1412
1412
|
if (!s || !o) return;
|
|
1413
1413
|
R().finally(() => I(!0));
|
|
1414
|
-
const
|
|
1414
|
+
const g = i.refreshInterval || 5 * 60 * 1e3, $ = setInterval(R, g);
|
|
1415
1415
|
return () => clearInterval($);
|
|
1416
1416
|
}, [a == null ? void 0 : a.id, s, o, i.refreshInterval]);
|
|
1417
1417
|
const x = te(() => {
|
|
1418
|
-
const
|
|
1418
|
+
const g = (D) => {
|
|
1419
1419
|
const P = m.find((O) => O.key === D);
|
|
1420
1420
|
return (P == null ? void 0 : P.value) === !0;
|
|
1421
1421
|
}, $ = (D) => m.find((P) => P.key === D), A = (D) => {
|
|
@@ -1423,13 +1423,13 @@ function er({ config: i = {}, children: e }) {
|
|
|
1423
1423
|
return P ? P.value ? "enabled" : "disabled" : "not_found";
|
|
1424
1424
|
}, E = async () => {
|
|
1425
1425
|
await R();
|
|
1426
|
-
},
|
|
1426
|
+
}, U = !!(s && o) && (T || !(a != null && a.id));
|
|
1427
1427
|
return {
|
|
1428
1428
|
featureFlags: m,
|
|
1429
1429
|
loading: b,
|
|
1430
1430
|
error: S,
|
|
1431
|
-
isReady:
|
|
1432
|
-
isEnabled:
|
|
1431
|
+
isReady: U,
|
|
1432
|
+
isEnabled: g,
|
|
1433
1433
|
getFlag: $,
|
|
1434
1434
|
getFlagState: A,
|
|
1435
1435
|
refresh: E
|
|
@@ -1443,7 +1443,7 @@ function ht() {
|
|
|
1443
1443
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1444
1444
|
return i;
|
|
1445
1445
|
}
|
|
1446
|
-
function
|
|
1446
|
+
function qe() {
|
|
1447
1447
|
return se(Ie);
|
|
1448
1448
|
}
|
|
1449
1449
|
class gt {
|
|
@@ -1512,9 +1512,9 @@ class gt {
|
|
|
1512
1512
|
)).data;
|
|
1513
1513
|
}
|
|
1514
1514
|
}
|
|
1515
|
-
const Re =
|
|
1515
|
+
const Re = he(void 0);
|
|
1516
1516
|
function tr({ config: i = {}, children: e }) {
|
|
1517
|
-
const t =
|
|
1517
|
+
const t = Be(), r = we(), s = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a, m] = k(null), [y, b] = k(!1), [p, S] = k(null), [f, T] = k(!1), I = te(() => {
|
|
1518
1518
|
const x = new ne(s);
|
|
1519
1519
|
return new gt(x);
|
|
1520
1520
|
}, [s]), C = async () => {
|
|
@@ -1527,40 +1527,40 @@ function tr({ config: i = {}, children: e }) {
|
|
|
1527
1527
|
const x = await I.getTenantSubscriptionFeatures(o.id);
|
|
1528
1528
|
m(x);
|
|
1529
1529
|
} catch (x) {
|
|
1530
|
-
const
|
|
1531
|
-
S(
|
|
1530
|
+
const g = x instanceof Error ? x.message : "Failed to fetch subscription";
|
|
1531
|
+
S(g), i.onError && i.onError(x instanceof Error ? x : new Error(g));
|
|
1532
1532
|
} finally {
|
|
1533
1533
|
b(!1);
|
|
1534
1534
|
}
|
|
1535
1535
|
};
|
|
1536
1536
|
re(() => {
|
|
1537
1537
|
if (!s || (C().finally(() => T(!0)), !i.refreshInterval)) return;
|
|
1538
|
-
const x = i.refreshInterval || 10 * 60 * 1e3,
|
|
1539
|
-
return () => clearInterval(
|
|
1538
|
+
const x = i.refreshInterval || 10 * 60 * 1e3, g = setInterval(C, x);
|
|
1539
|
+
return () => clearInterval(g);
|
|
1540
1540
|
}, [o == null ? void 0 : o.id, s, i.refreshInterval]);
|
|
1541
1541
|
const R = te(() => {
|
|
1542
|
-
const x = (a == null ? void 0 : a.features) || [],
|
|
1542
|
+
const x = (a == null ? void 0 : a.features) || [], g = (P) => {
|
|
1543
1543
|
const O = x.find((c) => c.key === P);
|
|
1544
1544
|
return O ? O.type === "BOOLEAN" || O.type === "boolean" ? O.value === !0 : !!O.value : !1;
|
|
1545
1545
|
}, $ = (P) => x.find((O) => O.key === P), A = (P, O) => {
|
|
1546
1546
|
const c = x.find((L) => L.key === P);
|
|
1547
1547
|
return c ? c.value : O;
|
|
1548
|
-
}, E = (P) => !a || !a.isActive ? !1 : P.includes(a.planId),
|
|
1548
|
+
}, E = (P) => !a || !a.isActive ? !1 : P.includes(a.planId), U = async () => {
|
|
1549
1549
|
await C();
|
|
1550
1550
|
}, D = !!s && (f || !(o != null && o.id));
|
|
1551
1551
|
return {
|
|
1552
1552
|
subscription: a,
|
|
1553
1553
|
features: x,
|
|
1554
1554
|
loading: y,
|
|
1555
|
-
error:
|
|
1555
|
+
error: p,
|
|
1556
1556
|
isReady: D,
|
|
1557
|
-
isFeatureEnabled:
|
|
1557
|
+
isFeatureEnabled: g,
|
|
1558
1558
|
getFeature: $,
|
|
1559
1559
|
getFeatureValue: A,
|
|
1560
1560
|
hasAllowedPlan: E,
|
|
1561
|
-
refresh:
|
|
1561
|
+
refresh: U
|
|
1562
1562
|
};
|
|
1563
|
-
}, [a, y,
|
|
1563
|
+
}, [a, y, p, s, o == null ? void 0 : o.id, f]);
|
|
1564
1564
|
return /* @__PURE__ */ n(Re.Provider, { value: R, children: e });
|
|
1565
1565
|
}
|
|
1566
1566
|
function pt() {
|
|
@@ -1569,11 +1569,11 @@ function pt() {
|
|
|
1569
1569
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1570
1570
|
return i;
|
|
1571
1571
|
}
|
|
1572
|
-
function
|
|
1572
|
+
function ze() {
|
|
1573
1573
|
return se(Re) ?? null;
|
|
1574
1574
|
}
|
|
1575
|
-
var
|
|
1576
|
-
const
|
|
1575
|
+
var fe = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(fe || {});
|
|
1576
|
+
const $e = () => /* @__PURE__ */ d(
|
|
1577
1577
|
"div",
|
|
1578
1578
|
{
|
|
1579
1579
|
style: {
|
|
@@ -1610,7 +1610,7 @@ const De = () => /* @__PURE__ */ d(
|
|
|
1610
1610
|
)
|
|
1611
1611
|
]
|
|
1612
1612
|
}
|
|
1613
|
-
),
|
|
1613
|
+
), He = ({
|
|
1614
1614
|
userType: i,
|
|
1615
1615
|
minUserType: e,
|
|
1616
1616
|
missingPermissions: t
|
|
@@ -1653,9 +1653,9 @@ const De = () => /* @__PURE__ */ d(
|
|
|
1653
1653
|
}
|
|
1654
1654
|
), ft = (i, e) => {
|
|
1655
1655
|
const t = {
|
|
1656
|
-
[
|
|
1657
|
-
[
|
|
1658
|
-
[
|
|
1656
|
+
[fe.USER]: 1,
|
|
1657
|
+
[fe.TENANT_ADMIN]: 2,
|
|
1658
|
+
[fe.SUPERUSER]: 3
|
|
1659
1659
|
};
|
|
1660
1660
|
return t[i] >= t[e];
|
|
1661
1661
|
};
|
|
@@ -1668,15 +1668,15 @@ function rr({
|
|
|
1668
1668
|
}) {
|
|
1669
1669
|
const { hasValidSession: o, sessionManager: a, hasPermission: m, hasAnyPermission: y, hasAllPermissions: b } = oe();
|
|
1670
1670
|
if (!o())
|
|
1671
|
-
return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(
|
|
1672
|
-
const
|
|
1673
|
-
if (!
|
|
1674
|
-
return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(
|
|
1675
|
-
if (t && !ft(
|
|
1676
|
-
return /* @__PURE__ */ n(
|
|
1671
|
+
return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n($e, {}) });
|
|
1672
|
+
const p = a.getUser();
|
|
1673
|
+
if (!p)
|
|
1674
|
+
return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n($e, {}) });
|
|
1675
|
+
if (t && !ft(p.userType, t))
|
|
1676
|
+
return /* @__PURE__ */ n(He, { userType: p.userType, minUserType: t });
|
|
1677
1677
|
if (r && r.length > 0 && !(s ? b(r) : y(r))) {
|
|
1678
1678
|
const f = r.filter((T) => !m(T)).map((T) => typeof T == "string" ? T : T.name);
|
|
1679
|
-
return /* @__PURE__ */ n(
|
|
1679
|
+
return /* @__PURE__ */ n(He, { missingPermissions: f });
|
|
1680
1680
|
}
|
|
1681
1681
|
return /* @__PURE__ */ n(j, { children: i });
|
|
1682
1682
|
}
|
|
@@ -1716,7 +1716,7 @@ const mt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1716
1716
|
}
|
|
1717
1717
|
)
|
|
1718
1718
|
}
|
|
1719
|
-
),
|
|
1719
|
+
), Ne = ({
|
|
1720
1720
|
userType: i,
|
|
1721
1721
|
requiredUserType: e,
|
|
1722
1722
|
missingPermissions: t
|
|
@@ -1776,26 +1776,26 @@ function nr({
|
|
|
1776
1776
|
requireAllPermissions: s = !1,
|
|
1777
1777
|
fallback: o
|
|
1778
1778
|
}) {
|
|
1779
|
-
const { hasValidSession: a, sessionManager: m, hasPermission: y, hasAnyPermission: b, hasAllPermissions:
|
|
1779
|
+
const { hasValidSession: a, sessionManager: m, hasPermission: y, hasAnyPermission: b, hasAllPermissions: p } = oe(), S = Te();
|
|
1780
1780
|
if (!a())
|
|
1781
1781
|
return o ? /* @__PURE__ */ n(j, { children: o }) : /* @__PURE__ */ d(j, { children: [
|
|
1782
1782
|
/* @__PURE__ */ n(mt, { redirectPath: e }),
|
|
1783
|
-
/* @__PURE__ */ n(
|
|
1783
|
+
/* @__PURE__ */ n(me, { to: e, state: { from: S.pathname }, replace: !0 })
|
|
1784
1784
|
] });
|
|
1785
1785
|
const f = m.getUser();
|
|
1786
1786
|
if (!f)
|
|
1787
|
-
return /* @__PURE__ */ n(
|
|
1787
|
+
return /* @__PURE__ */ n(me, { to: e, state: { from: S.pathname }, replace: !0 });
|
|
1788
1788
|
if (t && !yt(f.userType, t))
|
|
1789
1789
|
return /* @__PURE__ */ n(
|
|
1790
|
-
|
|
1790
|
+
Ne,
|
|
1791
1791
|
{
|
|
1792
1792
|
userType: f.userType,
|
|
1793
1793
|
requiredUserType: t
|
|
1794
1794
|
}
|
|
1795
1795
|
);
|
|
1796
|
-
if (r && r.length > 0 && !(s ?
|
|
1796
|
+
if (r && r.length > 0 && !(s ? p(r) : b(r))) {
|
|
1797
1797
|
const I = r.filter((C) => !y(C)).map((C) => typeof C == "string" ? C : C.name);
|
|
1798
|
-
return /* @__PURE__ */ n(
|
|
1798
|
+
return /* @__PURE__ */ n(Ne, { missingPermissions: I });
|
|
1799
1799
|
}
|
|
1800
1800
|
return /* @__PURE__ */ n(j, { children: i });
|
|
1801
1801
|
}
|
|
@@ -1837,10 +1837,10 @@ const wt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1837
1837
|
}
|
|
1838
1838
|
);
|
|
1839
1839
|
function sr({ children: i, redirectTo: e = "/", fallback: t }) {
|
|
1840
|
-
const { tenant: r, isLoading: s, error: o } =
|
|
1840
|
+
const { tenant: r, isLoading: s, error: o } = ce(), a = Te();
|
|
1841
1841
|
return s || o ? null : r ? /* @__PURE__ */ n(j, { children: i }) : t ? /* @__PURE__ */ n(j, { children: t }) : /* @__PURE__ */ d(j, { children: [
|
|
1842
1842
|
/* @__PURE__ */ n(wt, { redirectPath: e }),
|
|
1843
|
-
/* @__PURE__ */ n(
|
|
1843
|
+
/* @__PURE__ */ n(me, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
1844
1844
|
] });
|
|
1845
1845
|
}
|
|
1846
1846
|
const bt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
@@ -1881,10 +1881,10 @@ const bt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1881
1881
|
}
|
|
1882
1882
|
);
|
|
1883
1883
|
function ir({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
|
|
1884
|
-
const { tenant: r, isLoading: s, error: o } =
|
|
1884
|
+
const { tenant: r, isLoading: s, error: o } = ce(), a = Te();
|
|
1885
1885
|
return s || o ? null : r ? t ? /* @__PURE__ */ n(j, { children: t }) : /* @__PURE__ */ d(j, { children: [
|
|
1886
1886
|
/* @__PURE__ */ n(bt, { redirectPath: e }),
|
|
1887
|
-
/* @__PURE__ */ n(
|
|
1887
|
+
/* @__PURE__ */ n(me, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
1888
1888
|
] }) : /* @__PURE__ */ n(j, { children: i });
|
|
1889
1889
|
}
|
|
1890
1890
|
const St = () => /* @__PURE__ */ d(
|
|
@@ -2136,10 +2136,10 @@ function lr({
|
|
|
2136
2136
|
onMagicLinkClick: m,
|
|
2137
2137
|
showForgotPassword: y = !0,
|
|
2138
2138
|
showSignupLink: b = !0,
|
|
2139
|
-
showMagicLinkOption:
|
|
2139
|
+
showMagicLinkOption: p = !0,
|
|
2140
2140
|
className: S
|
|
2141
2141
|
}) {
|
|
2142
|
-
const [f, T] = k(""), [I, C] = k(""), [R, x] = k(!1), [
|
|
2142
|
+
const [f, T] = k(""), [I, C] = k(""), [R, x] = k(!1), [g, $] = k(!1), [A, E] = k(""), [U, D] = k({}), { login: P } = oe(), { tenant: O } = ce(), c = { ...At, ...i }, L = { ...Pt, ...e }, F = { ...xt, ...t }, l = () => {
|
|
2143
2143
|
const u = {};
|
|
2144
2144
|
return f.trim() || (u.username = !0), I.trim() || (u.password = !0), D(u), Object.keys(u).length === 0;
|
|
2145
2145
|
}, H = async (u) => {
|
|
@@ -2165,11 +2165,11 @@ function lr({
|
|
|
2165
2165
|
}
|
|
2166
2166
|
}, M = (u) => ({
|
|
2167
2167
|
...L.input,
|
|
2168
|
-
...
|
|
2169
|
-
}),
|
|
2168
|
+
...U[u] ? L.inputError : {}
|
|
2169
|
+
}), h = () => ({
|
|
2170
2170
|
...L.button,
|
|
2171
|
-
...
|
|
2172
|
-
...!f || !I ||
|
|
2171
|
+
...g ? L.buttonLoading : {},
|
|
2172
|
+
...!f || !I || g ? L.buttonDisabled : {}
|
|
2173
2173
|
});
|
|
2174
2174
|
return /* @__PURE__ */ d("div", { className: S, style: L.container, children: [
|
|
2175
2175
|
/* @__PURE__ */ n("h2", { style: L.title, children: c.title }),
|
|
@@ -2184,11 +2184,11 @@ function lr({
|
|
|
2184
2184
|
type: "text",
|
|
2185
2185
|
value: f,
|
|
2186
2186
|
onChange: (u) => {
|
|
2187
|
-
T(u.target.value),
|
|
2187
|
+
T(u.target.value), U.username && D((w) => ({ ...w, username: !1 }));
|
|
2188
2188
|
},
|
|
2189
2189
|
placeholder: c.usernamePlaceholder,
|
|
2190
2190
|
style: M("username"),
|
|
2191
|
-
disabled:
|
|
2191
|
+
disabled: g
|
|
2192
2192
|
}
|
|
2193
2193
|
)
|
|
2194
2194
|
] }),
|
|
@@ -2203,7 +2203,7 @@ function lr({
|
|
|
2203
2203
|
type: R ? "text" : "password",
|
|
2204
2204
|
value: I,
|
|
2205
2205
|
onChange: (u) => {
|
|
2206
|
-
C(u.target.value),
|
|
2206
|
+
C(u.target.value), U.password && D((w) => ({ ...w, password: !1 }));
|
|
2207
2207
|
},
|
|
2208
2208
|
placeholder: c.passwordPlaceholder,
|
|
2209
2209
|
style: {
|
|
@@ -2211,7 +2211,7 @@ function lr({
|
|
|
2211
2211
|
paddingRight: "2.5rem"
|
|
2212
2212
|
// Make room for the icon
|
|
2213
2213
|
},
|
|
2214
|
-
disabled:
|
|
2214
|
+
disabled: g
|
|
2215
2215
|
}
|
|
2216
2216
|
),
|
|
2217
2217
|
/* @__PURE__ */ n(
|
|
@@ -2220,25 +2220,25 @@ function lr({
|
|
|
2220
2220
|
type: "button",
|
|
2221
2221
|
onClick: () => x(!R),
|
|
2222
2222
|
style: L.passwordToggle,
|
|
2223
|
-
disabled:
|
|
2223
|
+
disabled: g,
|
|
2224
2224
|
"aria-label": R ? "Hide password" : "Show password",
|
|
2225
2225
|
children: R ? F.hidePassword : F.showPassword
|
|
2226
2226
|
}
|
|
2227
2227
|
)
|
|
2228
2228
|
] })
|
|
2229
2229
|
] }),
|
|
2230
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !f || !I ||
|
|
2230
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !f || !I || g, style: h(), children: g ? c.loadingText : c.submitButton }),
|
|
2231
2231
|
A && /* @__PURE__ */ n("div", { style: L.errorText, children: A })
|
|
2232
2232
|
] }),
|
|
2233
|
-
(y || b ||
|
|
2234
|
-
|
|
2233
|
+
(y || b || p) && /* @__PURE__ */ d("div", { style: L.linkContainer, children: [
|
|
2234
|
+
p && /* @__PURE__ */ d("div", { children: [
|
|
2235
2235
|
/* @__PURE__ */ d("span", { style: L.divider, children: [
|
|
2236
2236
|
c.magicLinkText,
|
|
2237
2237
|
" "
|
|
2238
2238
|
] }),
|
|
2239
2239
|
/* @__PURE__ */ n("a", { onClick: m, style: L.link, children: c.magicLinkLink })
|
|
2240
2240
|
] }),
|
|
2241
|
-
|
|
2241
|
+
p && (y || b) && /* @__PURE__ */ n("div", { style: L.divider, children: "•" }),
|
|
2242
2242
|
y && /* @__PURE__ */ n("a", { onClick: o, style: L.link, children: c.forgotPasswordLink }),
|
|
2243
2243
|
y && b && /* @__PURE__ */ n("div", { style: L.divider, children: "•" }),
|
|
2244
2244
|
b && /* @__PURE__ */ d("div", { children: [
|
|
@@ -2388,16 +2388,16 @@ function cr({
|
|
|
2388
2388
|
showMagicLinkOption: y = !0,
|
|
2389
2389
|
className: b
|
|
2390
2390
|
}) {
|
|
2391
|
-
const [
|
|
2391
|
+
const [p, S] = k(""), [f, T] = k(""), [I, C] = k(""), [R, x] = k(""), [g, $] = k(""), [A, E] = k(""), [U, D] = k(""), [P, O] = k(!1), [c, L] = k(""), [F, l] = k({}), { signup: H, signupTenantAdmin: M } = oe(), { tenant: h } = ce(), u = { ...Mt, ...i }, w = { ...It, ...e }, _ = () => {
|
|
2392
2392
|
const v = {};
|
|
2393
|
-
return
|
|
2393
|
+
return p.trim() || (v.name = !0), !I.trim() && !R.trim() && (v.email = !0, v.phoneNumber = !0), g.trim() || (v.password = !0), A.trim() || (v.confirmPassword = !0), t === "tenant" && !U.trim() && (v.tenantName = !0), l(v), Object.keys(v).length === 0;
|
|
2394
2394
|
}, K = async (v) => {
|
|
2395
2395
|
if (v.preventDefault(), !!_()) {
|
|
2396
|
-
if (
|
|
2396
|
+
if (g !== A) {
|
|
2397
2397
|
L(u.passwordMismatchError), l({ confirmPassword: !0 });
|
|
2398
2398
|
return;
|
|
2399
2399
|
}
|
|
2400
|
-
if (t === "user" && !(
|
|
2400
|
+
if (t === "user" && !(h != null && h.id)) {
|
|
2401
2401
|
L("Tenant not found");
|
|
2402
2402
|
return;
|
|
2403
2403
|
}
|
|
@@ -2407,16 +2407,16 @@ function cr({
|
|
|
2407
2407
|
t === "tenant" ? J = await M({
|
|
2408
2408
|
email: I || void 0,
|
|
2409
2409
|
phoneNumber: R || void 0,
|
|
2410
|
-
name:
|
|
2411
|
-
password:
|
|
2412
|
-
tenantName:
|
|
2410
|
+
name: p,
|
|
2411
|
+
password: g,
|
|
2412
|
+
tenantName: U,
|
|
2413
2413
|
lastName: f || void 0
|
|
2414
2414
|
}) : J = await H({
|
|
2415
2415
|
email: I || void 0,
|
|
2416
2416
|
phoneNumber: R || void 0,
|
|
2417
|
-
name:
|
|
2418
|
-
password:
|
|
2419
|
-
tenantId:
|
|
2417
|
+
name: p,
|
|
2418
|
+
password: g,
|
|
2419
|
+
tenantId: h.id,
|
|
2420
2420
|
lastName: f || void 0
|
|
2421
2421
|
}), r == null || r(J);
|
|
2422
2422
|
} catch (J) {
|
|
@@ -2426,14 +2426,14 @@ function cr({
|
|
|
2426
2426
|
O(!1);
|
|
2427
2427
|
}
|
|
2428
2428
|
}
|
|
2429
|
-
},
|
|
2429
|
+
}, B = (v) => ({
|
|
2430
2430
|
...w.input,
|
|
2431
2431
|
...F[v] ? w.inputError : {}
|
|
2432
2432
|
}), q = () => ({
|
|
2433
2433
|
...w.button,
|
|
2434
2434
|
...P ? w.buttonLoading : {},
|
|
2435
|
-
...!
|
|
2436
|
-
}), V =
|
|
2435
|
+
...!p || !I && !R || !g || !A || P || t === "tenant" && !U ? w.buttonDisabled : {}
|
|
2436
|
+
}), V = p && (I || R) && g && A && (t === "user" || U);
|
|
2437
2437
|
return /* @__PURE__ */ d("div", { className: b, style: w.container, children: [
|
|
2438
2438
|
/* @__PURE__ */ n("h2", { style: w.title, children: u.title }),
|
|
2439
2439
|
/* @__PURE__ */ d("form", { onSubmit: K, style: w.form, children: [
|
|
@@ -2445,12 +2445,12 @@ function cr({
|
|
|
2445
2445
|
id: "name",
|
|
2446
2446
|
name: "name",
|
|
2447
2447
|
type: "text",
|
|
2448
|
-
value:
|
|
2448
|
+
value: p,
|
|
2449
2449
|
onChange: (v) => {
|
|
2450
2450
|
S(v.target.value), F.name && l((J) => ({ ...J, name: !1 }));
|
|
2451
2451
|
},
|
|
2452
2452
|
placeholder: u.namePlaceholder,
|
|
2453
|
-
style:
|
|
2453
|
+
style: B("name"),
|
|
2454
2454
|
disabled: P
|
|
2455
2455
|
}
|
|
2456
2456
|
)
|
|
@@ -2484,7 +2484,7 @@ function cr({
|
|
|
2484
2484
|
C(v.target.value), F.email && l((J) => ({ ...J, email: !1, phoneNumber: !1 }));
|
|
2485
2485
|
},
|
|
2486
2486
|
placeholder: u.emailPlaceholder,
|
|
2487
|
-
style:
|
|
2487
|
+
style: B("email"),
|
|
2488
2488
|
disabled: P
|
|
2489
2489
|
}
|
|
2490
2490
|
)
|
|
@@ -2502,7 +2502,7 @@ function cr({
|
|
|
2502
2502
|
x(v.target.value), F.phoneNumber && l((J) => ({ ...J, email: !1, phoneNumber: !1 }));
|
|
2503
2503
|
},
|
|
2504
2504
|
placeholder: u.phoneNumberPlaceholder,
|
|
2505
|
-
style:
|
|
2505
|
+
style: B("phoneNumber"),
|
|
2506
2506
|
disabled: P
|
|
2507
2507
|
}
|
|
2508
2508
|
)
|
|
@@ -2527,12 +2527,12 @@ function cr({
|
|
|
2527
2527
|
id: "password",
|
|
2528
2528
|
name: "password",
|
|
2529
2529
|
type: "password",
|
|
2530
|
-
value:
|
|
2530
|
+
value: g,
|
|
2531
2531
|
onChange: (v) => {
|
|
2532
2532
|
$(v.target.value), F.password && l((J) => ({ ...J, password: !1 }));
|
|
2533
2533
|
},
|
|
2534
2534
|
placeholder: u.passwordPlaceholder,
|
|
2535
|
-
style:
|
|
2535
|
+
style: B("password"),
|
|
2536
2536
|
disabled: P
|
|
2537
2537
|
}
|
|
2538
2538
|
)
|
|
@@ -2550,7 +2550,7 @@ function cr({
|
|
|
2550
2550
|
E(v.target.value), F.confirmPassword && l((J) => ({ ...J, confirmPassword: !1 })), c === u.passwordMismatchError && L("");
|
|
2551
2551
|
},
|
|
2552
2552
|
placeholder: u.confirmPasswordPlaceholder,
|
|
2553
|
-
style:
|
|
2553
|
+
style: B("confirmPassword"),
|
|
2554
2554
|
disabled: P
|
|
2555
2555
|
}
|
|
2556
2556
|
)
|
|
@@ -2563,12 +2563,12 @@ function cr({
|
|
|
2563
2563
|
id: "tenantName",
|
|
2564
2564
|
name: "tenantName",
|
|
2565
2565
|
type: "text",
|
|
2566
|
-
value:
|
|
2566
|
+
value: U,
|
|
2567
2567
|
onChange: (v) => {
|
|
2568
2568
|
D(v.target.value), F.tenantName && l((J) => ({ ...J, tenantName: !1 }));
|
|
2569
2569
|
},
|
|
2570
2570
|
placeholder: u.tenantNamePlaceholder,
|
|
2571
|
-
style:
|
|
2571
|
+
style: B("tenantName"),
|
|
2572
2572
|
disabled: P
|
|
2573
2573
|
}
|
|
2574
2574
|
)
|
|
@@ -2728,12 +2728,12 @@ function dr({
|
|
|
2728
2728
|
verifyToken: y,
|
|
2729
2729
|
frontendUrl: b
|
|
2730
2730
|
}) {
|
|
2731
|
-
const [
|
|
2731
|
+
const [p, S] = k(""), [f, T] = k(""), [I, C] = k(""), [R, x] = k(!1), [g, $] = k(!1), [A, E] = k(""), [U, D] = k(""), [P, O] = k({}), [c, L] = k(!1), { sendMagicLink: F, verifyMagicLink: l } = oe(), { tenant: H } = ce(), M = { ...Rt, ...i }, h = { ...Lt, ...e };
|
|
2732
2732
|
re(() => {
|
|
2733
2733
|
y && u(y);
|
|
2734
2734
|
}, [y]);
|
|
2735
2735
|
const u = async (q) => {
|
|
2736
|
-
if (!H || !
|
|
2736
|
+
if (!H || !p) {
|
|
2737
2737
|
E("Missing tenant or email");
|
|
2738
2738
|
return;
|
|
2739
2739
|
}
|
|
@@ -2741,7 +2741,7 @@ function dr({
|
|
|
2741
2741
|
try {
|
|
2742
2742
|
const V = await l({
|
|
2743
2743
|
token: q,
|
|
2744
|
-
email:
|
|
2744
|
+
email: p
|
|
2745
2745
|
// tenantId inferred from context automatically
|
|
2746
2746
|
});
|
|
2747
2747
|
t == null || t(V);
|
|
@@ -2753,7 +2753,7 @@ function dr({
|
|
|
2753
2753
|
}
|
|
2754
2754
|
}, w = () => {
|
|
2755
2755
|
const q = {};
|
|
2756
|
-
return
|
|
2756
|
+
return p.trim() || (q.email = !0), c && !f.trim() && (q.name = !0), O(q), Object.keys(q).length === 0;
|
|
2757
2757
|
}, _ = async (q) => {
|
|
2758
2758
|
if (q.preventDefault(), !!w()) {
|
|
2759
2759
|
if (!(H != null && H.id)) {
|
|
@@ -2763,7 +2763,7 @@ function dr({
|
|
|
2763
2763
|
x(!0), E(""), D("");
|
|
2764
2764
|
try {
|
|
2765
2765
|
const V = b || (typeof window < "u" ? window.location.origin : ""), v = await F({
|
|
2766
|
-
email:
|
|
2766
|
+
email: p,
|
|
2767
2767
|
tenantId: H.id,
|
|
2768
2768
|
frontendUrl: V,
|
|
2769
2769
|
name: c ? f : void 0,
|
|
@@ -2778,35 +2778,35 @@ function dr({
|
|
|
2778
2778
|
}
|
|
2779
2779
|
}
|
|
2780
2780
|
}, K = (q) => ({
|
|
2781
|
-
...
|
|
2782
|
-
...P[q] ?
|
|
2783
|
-
}),
|
|
2784
|
-
...
|
|
2785
|
-
...R ||
|
|
2786
|
-
...!
|
|
2781
|
+
...h.input,
|
|
2782
|
+
...P[q] ? h.inputError : {}
|
|
2783
|
+
}), B = () => ({
|
|
2784
|
+
...h.button,
|
|
2785
|
+
...R || g ? h.buttonLoading : {},
|
|
2786
|
+
...!p || R || g ? h.buttonDisabled : {}
|
|
2787
2787
|
});
|
|
2788
|
-
return
|
|
2789
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2788
|
+
return g ? /* @__PURE__ */ d("div", { className: m, style: h.container, children: [
|
|
2789
|
+
/* @__PURE__ */ n("h2", { style: h.title, children: M.verifyingText }),
|
|
2790
2790
|
/* @__PURE__ */ n("div", { style: { textAlign: "center", padding: "2rem" }, children: /* @__PURE__ */ n("div", { style: { fontSize: "1rem", color: "#6b7280" }, children: "Please wait while we verify your magic link..." }) })
|
|
2791
|
-
] }) : /* @__PURE__ */ d("div", { className: m, style:
|
|
2792
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2793
|
-
/* @__PURE__ */ n("p", { style:
|
|
2794
|
-
/* @__PURE__ */ d("form", { onSubmit: _, style:
|
|
2795
|
-
/* @__PURE__ */ d("div", { style:
|
|
2796
|
-
/* @__PURE__ */ n("label", { style:
|
|
2791
|
+
] }) : /* @__PURE__ */ d("div", { className: m, style: h.container, children: [
|
|
2792
|
+
/* @__PURE__ */ n("h2", { style: h.title, children: M.title }),
|
|
2793
|
+
/* @__PURE__ */ n("p", { style: h.description, children: M.description }),
|
|
2794
|
+
/* @__PURE__ */ d("form", { onSubmit: _, style: h.form, children: [
|
|
2795
|
+
/* @__PURE__ */ d("div", { style: h.fieldGroup, children: [
|
|
2796
|
+
/* @__PURE__ */ n("label", { style: h.label, children: M.emailLabel }),
|
|
2797
2797
|
/* @__PURE__ */ n(
|
|
2798
2798
|
"input",
|
|
2799
2799
|
{
|
|
2800
2800
|
id: "email",
|
|
2801
2801
|
name: "email",
|
|
2802
2802
|
type: "email",
|
|
2803
|
-
value:
|
|
2803
|
+
value: p,
|
|
2804
2804
|
onChange: (q) => {
|
|
2805
2805
|
S(q.target.value), P.email && O((V) => ({ ...V, email: !1 }));
|
|
2806
2806
|
},
|
|
2807
2807
|
placeholder: M.emailPlaceholder,
|
|
2808
2808
|
style: K("email"),
|
|
2809
|
-
disabled: R ||
|
|
2809
|
+
disabled: R || g
|
|
2810
2810
|
}
|
|
2811
2811
|
)
|
|
2812
2812
|
] }),
|
|
@@ -2827,8 +2827,8 @@ function dr({
|
|
|
2827
2827
|
}
|
|
2828
2828
|
) }),
|
|
2829
2829
|
c && /* @__PURE__ */ d(j, { children: [
|
|
2830
|
-
/* @__PURE__ */ d("div", { style:
|
|
2831
|
-
/* @__PURE__ */ n("label", { style:
|
|
2830
|
+
/* @__PURE__ */ d("div", { style: h.fieldGroup, children: [
|
|
2831
|
+
/* @__PURE__ */ n("label", { style: h.label, children: M.nameLabel }),
|
|
2832
2832
|
/* @__PURE__ */ n(
|
|
2833
2833
|
"input",
|
|
2834
2834
|
{
|
|
@@ -2841,12 +2841,12 @@ function dr({
|
|
|
2841
2841
|
},
|
|
2842
2842
|
placeholder: M.namePlaceholder,
|
|
2843
2843
|
style: K("name"),
|
|
2844
|
-
disabled: R ||
|
|
2844
|
+
disabled: R || g
|
|
2845
2845
|
}
|
|
2846
2846
|
)
|
|
2847
2847
|
] }),
|
|
2848
|
-
/* @__PURE__ */ d("div", { style:
|
|
2849
|
-
/* @__PURE__ */ n("label", { style:
|
|
2848
|
+
/* @__PURE__ */ d("div", { style: h.fieldGroup, children: [
|
|
2849
|
+
/* @__PURE__ */ n("label", { style: h.label, children: M.lastNameLabel }),
|
|
2850
2850
|
/* @__PURE__ */ n(
|
|
2851
2851
|
"input",
|
|
2852
2852
|
{
|
|
@@ -2856,8 +2856,8 @@ function dr({
|
|
|
2856
2856
|
value: I,
|
|
2857
2857
|
onChange: (q) => C(q.target.value),
|
|
2858
2858
|
placeholder: M.lastNamePlaceholder,
|
|
2859
|
-
style:
|
|
2860
|
-
disabled: R ||
|
|
2859
|
+
style: h.input,
|
|
2860
|
+
disabled: R || g
|
|
2861
2861
|
}
|
|
2862
2862
|
)
|
|
2863
2863
|
] }),
|
|
@@ -2880,25 +2880,25 @@ function dr({
|
|
|
2880
2880
|
}
|
|
2881
2881
|
) })
|
|
2882
2882
|
] }),
|
|
2883
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !
|
|
2884
|
-
A && /* @__PURE__ */ n("div", { style:
|
|
2885
|
-
|
|
2883
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !p || R || g, style: B(), children: R ? M.loadingText : M.submitButton }),
|
|
2884
|
+
A && /* @__PURE__ */ n("div", { style: h.errorText, children: A }),
|
|
2885
|
+
U && /* @__PURE__ */ n("div", { style: h.successText, children: U })
|
|
2886
2886
|
] }),
|
|
2887
|
-
a && /* @__PURE__ */ d("div", { style:
|
|
2887
|
+
a && /* @__PURE__ */ d("div", { style: h.linkContainer, children: [
|
|
2888
2888
|
/* @__PURE__ */ d("div", { children: [
|
|
2889
|
-
/* @__PURE__ */ d("span", { style:
|
|
2889
|
+
/* @__PURE__ */ d("span", { style: h.divider, children: [
|
|
2890
2890
|
M.loginText,
|
|
2891
2891
|
" "
|
|
2892
2892
|
] }),
|
|
2893
|
-
/* @__PURE__ */ n("a", { onClick: s, style:
|
|
2893
|
+
/* @__PURE__ */ n("a", { onClick: s, style: h.link, children: M.loginLink })
|
|
2894
2894
|
] }),
|
|
2895
|
-
/* @__PURE__ */ n("div", { style:
|
|
2895
|
+
/* @__PURE__ */ n("div", { style: h.divider, children: "•" }),
|
|
2896
2896
|
/* @__PURE__ */ d("div", { children: [
|
|
2897
|
-
/* @__PURE__ */ d("span", { style:
|
|
2897
|
+
/* @__PURE__ */ d("span", { style: h.divider, children: [
|
|
2898
2898
|
M.signupText,
|
|
2899
2899
|
" "
|
|
2900
2900
|
] }),
|
|
2901
|
-
/* @__PURE__ */ n("a", { onClick: o, style:
|
|
2901
|
+
/* @__PURE__ */ n("a", { onClick: o, style: h.link, children: M.signupLink })
|
|
2902
2902
|
] })
|
|
2903
2903
|
] })
|
|
2904
2904
|
] });
|
|
@@ -2911,7 +2911,7 @@ const Et = {
|
|
|
2911
2911
|
redirectingMessage: "Redirecting you to the dashboard...",
|
|
2912
2912
|
retryButton: "Try Again",
|
|
2913
2913
|
backToLoginButton: "Back to Login"
|
|
2914
|
-
},
|
|
2914
|
+
}, Oe = {
|
|
2915
2915
|
container: {
|
|
2916
2916
|
maxWidth: "400px",
|
|
2917
2917
|
width: "100%",
|
|
@@ -2998,7 +2998,7 @@ const Et = {
|
|
|
2998
2998
|
cursor: "pointer",
|
|
2999
2999
|
transition: "all 0.15s ease-in-out"
|
|
3000
3000
|
}
|
|
3001
|
-
}, Ft = () => /* @__PURE__ */ n("div", { style:
|
|
3001
|
+
}, Ft = () => /* @__PURE__ */ n("div", { style: Oe.spinner }), Ct = () => /* @__PURE__ */ d(
|
|
3002
3002
|
"svg",
|
|
3003
3003
|
{
|
|
3004
3004
|
width: "48",
|
|
@@ -3049,20 +3049,20 @@ function ur({
|
|
|
3049
3049
|
className: m,
|
|
3050
3050
|
token: y,
|
|
3051
3051
|
email: b,
|
|
3052
|
-
appId:
|
|
3052
|
+
appId: p,
|
|
3053
3053
|
tenantSlug: S,
|
|
3054
3054
|
autoRedirectDelay: f = 3e3
|
|
3055
3055
|
}) {
|
|
3056
|
-
const [T, I] = k("verifying"), [C, R] = k(""), { verifyMagicLink: x } = oe(),
|
|
3056
|
+
const [T, I] = k("verifying"), [C, R] = k(""), { verifyMagicLink: x } = oe(), g = { ...Et, ...i }, $ = { ...Oe, ...e }, A = { ...$t, ...t }, E = () => {
|
|
3057
3057
|
if (typeof window > "u") return {};
|
|
3058
3058
|
const c = new URLSearchParams(window.location.search);
|
|
3059
3059
|
return {
|
|
3060
3060
|
token: y || c.get("token") || "",
|
|
3061
3061
|
email: b || c.get("email") || "",
|
|
3062
|
-
appId:
|
|
3062
|
+
appId: p || c.get("appId") || "",
|
|
3063
3063
|
tenantSlug: S || c.get("tenantSlug") || void 0
|
|
3064
3064
|
};
|
|
3065
|
-
},
|
|
3065
|
+
}, U = async () => {
|
|
3066
3066
|
I("verifying"), R("");
|
|
3067
3067
|
try {
|
|
3068
3068
|
const c = E();
|
|
@@ -3077,38 +3077,38 @@ function ur({
|
|
|
3077
3077
|
I("redirecting");
|
|
3078
3078
|
}, f);
|
|
3079
3079
|
} catch (c) {
|
|
3080
|
-
const L = c.message ||
|
|
3080
|
+
const L = c.message || g.errorMessage;
|
|
3081
3081
|
R(L), I("error"), s == null || s(L);
|
|
3082
3082
|
}
|
|
3083
3083
|
}, D = () => {
|
|
3084
|
-
o == null || o(),
|
|
3084
|
+
o == null || o(), U();
|
|
3085
3085
|
}, P = () => {
|
|
3086
3086
|
a == null || a();
|
|
3087
3087
|
};
|
|
3088
3088
|
re(() => {
|
|
3089
|
-
|
|
3089
|
+
U();
|
|
3090
3090
|
}, []);
|
|
3091
3091
|
const O = () => {
|
|
3092
3092
|
switch (T) {
|
|
3093
3093
|
case "verifying":
|
|
3094
3094
|
return /* @__PURE__ */ d("div", { style: $.message, children: [
|
|
3095
3095
|
A.loading,
|
|
3096
|
-
|
|
3096
|
+
g.verifyingMessage
|
|
3097
3097
|
] });
|
|
3098
3098
|
case "success":
|
|
3099
3099
|
return /* @__PURE__ */ d(j, { children: [
|
|
3100
3100
|
A.success,
|
|
3101
|
-
/* @__PURE__ */ n("div", { style: $.successMessage, children:
|
|
3101
|
+
/* @__PURE__ */ n("div", { style: $.successMessage, children: g.successMessage })
|
|
3102
3102
|
] });
|
|
3103
3103
|
case "redirecting":
|
|
3104
3104
|
return /* @__PURE__ */ d(j, { children: [
|
|
3105
3105
|
A.loading,
|
|
3106
|
-
/* @__PURE__ */ n("div", { style: $.message, children:
|
|
3106
|
+
/* @__PURE__ */ n("div", { style: $.message, children: g.redirectingMessage })
|
|
3107
3107
|
] });
|
|
3108
3108
|
case "error":
|
|
3109
3109
|
return /* @__PURE__ */ d(j, { children: [
|
|
3110
3110
|
A.error,
|
|
3111
|
-
/* @__PURE__ */ n("div", { style: $.errorMessage, children: C ||
|
|
3111
|
+
/* @__PURE__ */ n("div", { style: $.errorMessage, children: C || g.errorMessage }),
|
|
3112
3112
|
/* @__PURE__ */ d("div", { style: $.buttonContainer, children: [
|
|
3113
3113
|
/* @__PURE__ */ n(
|
|
3114
3114
|
"button",
|
|
@@ -3121,7 +3121,7 @@ function ur({
|
|
|
3121
3121
|
onMouseOut: (c) => {
|
|
3122
3122
|
c.currentTarget.style.backgroundColor = "#3b82f6";
|
|
3123
3123
|
},
|
|
3124
|
-
children:
|
|
3124
|
+
children: g.retryButton
|
|
3125
3125
|
}
|
|
3126
3126
|
),
|
|
3127
3127
|
/* @__PURE__ */ n(
|
|
@@ -3135,7 +3135,7 @@ function ur({
|
|
|
3135
3135
|
onMouseOut: (c) => {
|
|
3136
3136
|
c.currentTarget.style.backgroundColor = "#f3f4f6";
|
|
3137
3137
|
},
|
|
3138
|
-
children:
|
|
3138
|
+
children: g.backToLoginButton
|
|
3139
3139
|
}
|
|
3140
3140
|
)
|
|
3141
3141
|
] })
|
|
@@ -3151,7 +3151,7 @@ function ur({
|
|
|
3151
3151
|
100% { transform: rotate(360deg); }
|
|
3152
3152
|
}
|
|
3153
3153
|
` }),
|
|
3154
|
-
/* @__PURE__ */ n("h1", { style: $.title, children:
|
|
3154
|
+
/* @__PURE__ */ n("h1", { style: $.title, children: g.title }),
|
|
3155
3155
|
O()
|
|
3156
3156
|
] });
|
|
3157
3157
|
}
|
|
@@ -3280,53 +3280,53 @@ function hr({
|
|
|
3280
3280
|
onModeChange: m,
|
|
3281
3281
|
className: y
|
|
3282
3282
|
}) {
|
|
3283
|
-
const [b,
|
|
3284
|
-
const
|
|
3285
|
-
return b.trim() || (
|
|
3283
|
+
const [b, p] = k(""), [S, f] = k(r), [T, I] = k(""), [C, R] = k(""), [x, g] = k(!1), [$, A] = k(""), [E, U] = k(""), [D, P] = k({}), { requestPasswordReset: O, confirmPasswordReset: c } = oe(), { tenant: L } = ce(), F = { ...Ht, ...i }, l = { ...Nt, ...e }, H = () => {
|
|
3284
|
+
const B = {};
|
|
3285
|
+
return b.trim() || (B.email = !0), P(B), Object.keys(B).length === 0;
|
|
3286
3286
|
}, M = () => {
|
|
3287
|
-
const
|
|
3288
|
-
return S.trim() || (
|
|
3289
|
-
},
|
|
3290
|
-
if (
|
|
3287
|
+
const B = {};
|
|
3288
|
+
return S.trim() || (B.token = !0), T.trim() || (B.newPassword = !0), C.trim() || (B.confirmPassword = !0), P(B), Object.keys(B).length === 0;
|
|
3289
|
+
}, h = async (B) => {
|
|
3290
|
+
if (B.preventDefault(), !!H()) {
|
|
3291
3291
|
if (!(L != null && L.id)) {
|
|
3292
3292
|
A("Tenant not found");
|
|
3293
3293
|
return;
|
|
3294
3294
|
}
|
|
3295
|
-
|
|
3295
|
+
g(!0), A(""), U("");
|
|
3296
3296
|
try {
|
|
3297
|
-
await O({ email: b, tenantId: L.id }),
|
|
3297
|
+
await O({ email: b, tenantId: L.id }), U(F.successMessage), s == null || s();
|
|
3298
3298
|
} catch (q) {
|
|
3299
3299
|
const V = q.message || F.errorMessage;
|
|
3300
3300
|
A(V), o == null || o(V);
|
|
3301
3301
|
} finally {
|
|
3302
|
-
|
|
3302
|
+
g(!1);
|
|
3303
3303
|
}
|
|
3304
3304
|
}
|
|
3305
|
-
}, u = async (
|
|
3306
|
-
if (
|
|
3305
|
+
}, u = async (B) => {
|
|
3306
|
+
if (B.preventDefault(), !!M()) {
|
|
3307
3307
|
if (T !== C) {
|
|
3308
3308
|
A(F.passwordMismatchError), P({ confirmPassword: !0 });
|
|
3309
3309
|
return;
|
|
3310
3310
|
}
|
|
3311
|
-
|
|
3311
|
+
g(!0), A(""), U("");
|
|
3312
3312
|
try {
|
|
3313
|
-
await c({ token: S, newPassword: T }),
|
|
3313
|
+
await c({ token: S, newPassword: T }), U(F.resetSuccessMessage), s == null || s();
|
|
3314
3314
|
} catch (q) {
|
|
3315
3315
|
const V = q.message || F.errorMessage;
|
|
3316
3316
|
A(V), o == null || o(V);
|
|
3317
3317
|
} finally {
|
|
3318
|
-
|
|
3318
|
+
g(!1);
|
|
3319
3319
|
}
|
|
3320
3320
|
}
|
|
3321
|
-
}, w = (
|
|
3321
|
+
}, w = (B) => ({
|
|
3322
3322
|
...l.input,
|
|
3323
|
-
...D[
|
|
3323
|
+
...D[B] ? l.inputError : {}
|
|
3324
3324
|
}), _ = () => ({
|
|
3325
3325
|
...l.button,
|
|
3326
3326
|
...x ? l.buttonLoading : {}
|
|
3327
3327
|
});
|
|
3328
3328
|
if (t === "reset") {
|
|
3329
|
-
const
|
|
3329
|
+
const B = S && T && C;
|
|
3330
3330
|
return /* @__PURE__ */ d("div", { className: y, style: l.container, children: [
|
|
3331
3331
|
/* @__PURE__ */ n("h2", { style: l.title, children: F.resetTitle }),
|
|
3332
3332
|
/* @__PURE__ */ n("p", { style: l.subtitle, children: F.resetSubtitle }),
|
|
@@ -3383,10 +3383,10 @@ function hr({
|
|
|
3383
3383
|
"button",
|
|
3384
3384
|
{
|
|
3385
3385
|
type: "submit",
|
|
3386
|
-
disabled: !
|
|
3386
|
+
disabled: !B || x,
|
|
3387
3387
|
style: {
|
|
3388
3388
|
..._(),
|
|
3389
|
-
...!
|
|
3389
|
+
...!B || x ? l.buttonDisabled : {}
|
|
3390
3390
|
},
|
|
3391
3391
|
children: x ? F.resetLoadingText : F.resetSubmitButton
|
|
3392
3392
|
}
|
|
@@ -3407,7 +3407,7 @@ function hr({
|
|
|
3407
3407
|
return /* @__PURE__ */ d("div", { className: y, style: l.container, children: [
|
|
3408
3408
|
/* @__PURE__ */ n("h2", { style: l.title, children: F.title }),
|
|
3409
3409
|
/* @__PURE__ */ n("p", { style: l.subtitle, children: F.subtitle }),
|
|
3410
|
-
/* @__PURE__ */ d("form", { onSubmit:
|
|
3410
|
+
/* @__PURE__ */ d("form", { onSubmit: h, style: l.form, children: [
|
|
3411
3411
|
/* @__PURE__ */ d("div", { style: l.fieldGroup, children: [
|
|
3412
3412
|
/* @__PURE__ */ n("label", { style: l.label, children: F.emailLabel }),
|
|
3413
3413
|
/* @__PURE__ */ n(
|
|
@@ -3415,8 +3415,8 @@ function hr({
|
|
|
3415
3415
|
{
|
|
3416
3416
|
type: "email",
|
|
3417
3417
|
value: b,
|
|
3418
|
-
onChange: (
|
|
3419
|
-
|
|
3418
|
+
onChange: (B) => {
|
|
3419
|
+
p(B.target.value), D.email && P((q) => ({ ...q, email: !1 }));
|
|
3420
3420
|
},
|
|
3421
3421
|
placeholder: F.emailPlaceholder,
|
|
3422
3422
|
style: w("email"),
|
|
@@ -3500,11 +3500,11 @@ function gr({
|
|
|
3500
3500
|
errorFallback: t,
|
|
3501
3501
|
requireTenant: r = !0
|
|
3502
3502
|
}) {
|
|
3503
|
-
const { isAppLoading: s, appError: o, retryApp: a } =
|
|
3504
|
-
}), C = (y == null ? void 0 : y.isAuthReady) ?? !0, R = (b == null ? void 0 : b.isReady) ?? !0, x = (
|
|
3503
|
+
const { isAppLoading: s, appError: o, retryApp: a } = ge(), m = we(), y = Me(), b = qe(), p = ze(), S = (m == null ? void 0 : m.isTenantLoading) ?? !1, f = (m == null ? void 0 : m.tenantError) ?? null, T = (m == null ? void 0 : m.tenantSlug) ?? null, I = (m == null ? void 0 : m.retryTenant) ?? (() => {
|
|
3504
|
+
}), C = (y == null ? void 0 : y.isAuthReady) ?? !0, R = (b == null ? void 0 : b.isReady) ?? !0, x = (p == null ? void 0 : p.isReady) ?? !0, g = r && m && T, U = s || g && S || y && !C || b && !R || p && !x, D = o || (g ? f : null), P = () => {
|
|
3505
3505
|
o && a(), f && m && I();
|
|
3506
3506
|
};
|
|
3507
|
-
if (
|
|
3507
|
+
if (U)
|
|
3508
3508
|
return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(Ut, {}) });
|
|
3509
3509
|
if (D) {
|
|
3510
3510
|
const O = typeof t == "function" ? t(D, P) : t || /* @__PURE__ */ n(Bt, { error: D, retry: P });
|
|
@@ -3513,18 +3513,18 @@ function gr({
|
|
|
3513
3513
|
return /* @__PURE__ */ n(j, { children: i });
|
|
3514
3514
|
}
|
|
3515
3515
|
function pr(i = !0) {
|
|
3516
|
-
const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } =
|
|
3517
|
-
}), I = (a == null ? void 0 : a.isAuthReady) ?? !0, C = (m == null ? void 0 : m.isReady) ?? !0, R = (y == null ? void 0 : y.isReady) ?? !0, x = i && o && f, E = e || x && b || a && !I || m && !C || y && !R,
|
|
3516
|
+
const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = ge(), o = we(), a = Me(), m = qe(), y = ze(), b = (o == null ? void 0 : o.isTenantLoading) ?? !1, p = (o == null ? void 0 : o.tenantError) ?? null, S = (o == null ? void 0 : o.tenant) ?? null, f = (o == null ? void 0 : o.tenantSlug) ?? null, T = (o == null ? void 0 : o.retryTenant) ?? (() => {
|
|
3517
|
+
}), I = (a == null ? void 0 : a.isAuthReady) ?? !0, C = (m == null ? void 0 : m.isReady) ?? !0, R = (y == null ? void 0 : y.isReady) ?? !0, x = i && o && f, E = e || x && b || a && !I || m && !C || y && !R, U = t || (x ? p : null);
|
|
3518
3518
|
return {
|
|
3519
3519
|
isLoading: E,
|
|
3520
|
-
error:
|
|
3521
|
-
isReady: !E && !
|
|
3520
|
+
error: U,
|
|
3521
|
+
isReady: !E && !U && s !== null && (!x || S !== null),
|
|
3522
3522
|
retry: () => {
|
|
3523
|
-
t && r(),
|
|
3523
|
+
t && r(), p && o && T();
|
|
3524
3524
|
},
|
|
3525
3525
|
// Individual states
|
|
3526
3526
|
app: { isLoading: e, error: t, data: s },
|
|
3527
|
-
tenant: o ? { isLoading: b, error:
|
|
3527
|
+
tenant: o ? { isLoading: b, error: p, data: S } : null,
|
|
3528
3528
|
auth: a ? { isReady: I } : null,
|
|
3529
3529
|
featureFlags: m ? { isReady: C } : null,
|
|
3530
3530
|
subscription: y ? { isReady: R } : null
|
|
@@ -3543,8 +3543,8 @@ function fr({
|
|
|
3543
3543
|
showCurrentTenant: b = !0
|
|
3544
3544
|
}) {
|
|
3545
3545
|
var $;
|
|
3546
|
-
const
|
|
3547
|
-
f(!1), t ? t(A) :
|
|
3546
|
+
const p = Me(), [S, f] = k(!1), T = Ue(null), I = i ?? (p == null ? void 0 : p.userTenants) ?? [], C = e ?? (($ = p == null ? void 0 : p.currentUser) == null ? void 0 : $.tenantId) ?? null, R = async (A) => {
|
|
3547
|
+
f(!1), t ? t(A) : p != null && p.switchToTenant && await p.switchToTenant(A);
|
|
3548
3548
|
};
|
|
3549
3549
|
re(() => {
|
|
3550
3550
|
const A = (E) => {
|
|
@@ -3557,7 +3557,7 @@ function fr({
|
|
|
3557
3557
|
return null;
|
|
3558
3558
|
if (I.length === 1 && b)
|
|
3559
3559
|
return /* @__PURE__ */ n("div", { className: r, children: /* @__PURE__ */ n("span", { children: I[0].name }) });
|
|
3560
|
-
const
|
|
3560
|
+
const g = (A, E) => /* @__PURE__ */ d("span", { style: { fontWeight: E ? "bold" : "normal" }, children: [
|
|
3561
3561
|
A.name,
|
|
3562
3562
|
A.role && /* @__PURE__ */ d("span", { style: { opacity: 0.7, marginLeft: 8 }, children: [
|
|
3563
3563
|
"(",
|
|
@@ -3611,13 +3611,13 @@ function fr({
|
|
|
3611
3611
|
cursor: "pointer",
|
|
3612
3612
|
backgroundColor: E ? "#f0f0f0" : "transparent"
|
|
3613
3613
|
},
|
|
3614
|
-
onMouseEnter: (
|
|
3615
|
-
E || (
|
|
3614
|
+
onMouseEnter: (U) => {
|
|
3615
|
+
E || (U.target.style.backgroundColor = "#f5f5f5");
|
|
3616
3616
|
},
|
|
3617
|
-
onMouseLeave: (
|
|
3618
|
-
E || (
|
|
3617
|
+
onMouseLeave: (U) => {
|
|
3618
|
+
E || (U.target.style.backgroundColor = "transparent");
|
|
3619
3619
|
},
|
|
3620
|
-
children: a ? a(A, E) :
|
|
3620
|
+
children: a ? a(A, E) : g(A, E)
|
|
3621
3621
|
},
|
|
3622
3622
|
A.id
|
|
3623
3623
|
);
|
|
@@ -3881,7 +3881,7 @@ export {
|
|
|
3881
3881
|
Fe as AppApiService,
|
|
3882
3882
|
gr as AppLoader,
|
|
3883
3883
|
Jt as AppProvider,
|
|
3884
|
-
|
|
3884
|
+
rt as AuthApiService,
|
|
3885
3885
|
Zt as AuthProvider,
|
|
3886
3886
|
ar as FeatureFlag,
|
|
3887
3887
|
ut as FeatureFlagApiService,
|
|
@@ -3903,21 +3903,21 @@ export {
|
|
|
3903
3903
|
or as SubscriptionGuard,
|
|
3904
3904
|
yr as SubscriptionPlanApiService,
|
|
3905
3905
|
tr as SubscriptionProvider,
|
|
3906
|
-
|
|
3906
|
+
ue as TenantApiService,
|
|
3907
3907
|
Yt as TenantProvider,
|
|
3908
3908
|
sr as TenantRoute,
|
|
3909
3909
|
fr as TenantSelector,
|
|
3910
|
-
|
|
3911
|
-
|
|
3910
|
+
nt as UserApiService,
|
|
3911
|
+
fe as UserType,
|
|
3912
3912
|
Kt as useApi,
|
|
3913
|
-
|
|
3913
|
+
ge as useApp,
|
|
3914
3914
|
pr as useAppLoaderState,
|
|
3915
3915
|
oe as useAuth,
|
|
3916
3916
|
ht as useFeatureFlags,
|
|
3917
3917
|
Xt as useSettings,
|
|
3918
3918
|
pt as useSubscription,
|
|
3919
3919
|
ye as useTenant,
|
|
3920
|
-
|
|
3920
|
+
ce as useTenantInfo,
|
|
3921
3921
|
we as useTenantOptional,
|
|
3922
3922
|
Qt as useTenantSettings
|
|
3923
3923
|
};
|