@skylabs-digital/react-identity-access 2.6.0 → 2.7.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 +879 -877
- 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/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as n, Fragment as
|
|
2
|
-
import { createContext as ue, useMemo as X, useState as
|
|
1
|
+
import { jsx as n, Fragment as j, jsxs as l } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as ue, useMemo as X, useState as S, useCallback as se, useEffect as te, useContext as ne, useRef as Ge } from "react";
|
|
3
3
|
import { useLocation as Se, Navigate as pe } from "react-router-dom";
|
|
4
4
|
class re {
|
|
5
5
|
// SessionManager instance
|
|
@@ -16,7 +16,7 @@ class re {
|
|
|
16
16
|
return this.executeRequest(e, t, r, s, !1);
|
|
17
17
|
}
|
|
18
18
|
async executeRequest(e, t, r, s, o = !1) {
|
|
19
|
-
const a = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`,
|
|
19
|
+
const a = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, g = (s == null ? void 0 : s.timeout) || this.timeout;
|
|
20
20
|
let w = {
|
|
21
21
|
"Content-Type": "application/json",
|
|
22
22
|
...s == null ? void 0 : s.headers
|
|
@@ -28,15 +28,15 @@ class re {
|
|
|
28
28
|
} catch (b) {
|
|
29
29
|
console.warn("Failed to inject auth headers:", b);
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const m = new AbortController(), k = setTimeout(() => m.abort(), g);
|
|
32
32
|
try {
|
|
33
33
|
const b = await fetch(a, {
|
|
34
34
|
method: e,
|
|
35
35
|
headers: w,
|
|
36
36
|
body: r ? JSON.stringify(r) : void 0,
|
|
37
|
-
signal:
|
|
37
|
+
signal: m.signal
|
|
38
38
|
});
|
|
39
|
-
if (clearTimeout(
|
|
39
|
+
if (clearTimeout(k), b.status === 401 && !(s != null && s.skipRetry) && !o && this.sessionManager)
|
|
40
40
|
try {
|
|
41
41
|
const A = this.sessionManager.getTokens();
|
|
42
42
|
if (A != null && A.refreshToken)
|
|
@@ -49,7 +49,7 @@ class re {
|
|
|
49
49
|
const f = b.headers.get("content-type");
|
|
50
50
|
return !f || !f.includes("application/json") ? {} : await b.json();
|
|
51
51
|
} catch (b) {
|
|
52
|
-
throw clearTimeout(
|
|
52
|
+
throw clearTimeout(k), b instanceof Error && b.name === "AbortError" ? new Error(`Request timeout after ${g}ms`) : b;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
async get(e, t) {
|
|
@@ -125,7 +125,7 @@ class Pe {
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
const ve = ue(null);
|
|
128
|
-
function
|
|
128
|
+
function Bt({ config: i, children: e }) {
|
|
129
129
|
const t = X(
|
|
130
130
|
() => {
|
|
131
131
|
var f, A, L;
|
|
@@ -137,7 +137,7 @@ function Nt({ config: i, children: e }) {
|
|
|
137
137
|
};
|
|
138
138
|
},
|
|
139
139
|
[i.cache, i.appId]
|
|
140
|
-
), [r, s] =
|
|
140
|
+
), [r, s] = S(() => {
|
|
141
141
|
if (!t.enabled) return null;
|
|
142
142
|
try {
|
|
143
143
|
const f = localStorage.getItem(t.storageKey);
|
|
@@ -147,9 +147,9 @@ function Nt({ config: i, children: e }) {
|
|
|
147
147
|
} catch {
|
|
148
148
|
return null;
|
|
149
149
|
}
|
|
150
|
-
}), [o, a] =
|
|
150
|
+
}), [o, a] = S(!r), [g, w] = S(null), m = X(() => {
|
|
151
151
|
const f = () => {
|
|
152
|
-
|
|
152
|
+
k();
|
|
153
153
|
};
|
|
154
154
|
return {
|
|
155
155
|
appId: i.appId,
|
|
@@ -157,10 +157,10 @@ function Nt({ config: i, children: e }) {
|
|
|
157
157
|
// App info
|
|
158
158
|
appInfo: r,
|
|
159
159
|
isAppLoading: o,
|
|
160
|
-
appError:
|
|
160
|
+
appError: g,
|
|
161
161
|
retryApp: f
|
|
162
162
|
};
|
|
163
|
-
}, [i, r, o,
|
|
163
|
+
}, [i, r, o, g]), k = se(
|
|
164
164
|
async (f = !1) => {
|
|
165
165
|
if (!(!f && t.enabled && r))
|
|
166
166
|
try {
|
|
@@ -168,14 +168,14 @@ function Nt({ config: i, children: e }) {
|
|
|
168
168
|
const A = new re(i.baseUrl), D = await new Pe(A, {}).getPublicAppInfo(i.appId);
|
|
169
169
|
if (s(D), t.enabled)
|
|
170
170
|
try {
|
|
171
|
-
const
|
|
171
|
+
const R = {
|
|
172
172
|
data: D,
|
|
173
173
|
timestamp: Date.now(),
|
|
174
174
|
appId: i.appId
|
|
175
175
|
};
|
|
176
|
-
localStorage.setItem(t.storageKey, JSON.stringify(
|
|
177
|
-
} catch (
|
|
178
|
-
console.warn("Failed to cache app info:",
|
|
176
|
+
localStorage.setItem(t.storageKey, JSON.stringify(R));
|
|
177
|
+
} catch (R) {
|
|
178
|
+
console.warn("Failed to cache app info:", R);
|
|
179
179
|
}
|
|
180
180
|
} catch (A) {
|
|
181
181
|
const L = A instanceof Error ? A : new Error("Failed to load app information");
|
|
@@ -192,10 +192,10 @@ function Nt({ config: i, children: e }) {
|
|
|
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 D = new re(i.baseUrl),
|
|
196
|
-
s(
|
|
195
|
+
const D = new re(i.baseUrl), P = await new Pe(D, {}).getPublicAppInfo(i.appId);
|
|
196
|
+
s(P);
|
|
197
197
|
const u = {
|
|
198
|
-
data:
|
|
198
|
+
data: P,
|
|
199
199
|
timestamp: Date.now(),
|
|
200
200
|
appId: i.appId
|
|
201
201
|
};
|
|
@@ -206,8 +206,8 @@ function Nt({ config: i, children: e }) {
|
|
|
206
206
|
}
|
|
207
207
|
}, [i, t, r]);
|
|
208
208
|
return te(() => {
|
|
209
|
-
r ? b() :
|
|
210
|
-
}, []), /* @__PURE__ */ n(ve.Provider, { value:
|
|
209
|
+
r ? b() : k();
|
|
210
|
+
}, []), /* @__PURE__ */ n(ve.Provider, { value: m, children: e });
|
|
211
211
|
}
|
|
212
212
|
function he() {
|
|
213
213
|
const i = ne(ve);
|
|
@@ -218,7 +218,7 @@ function he() {
|
|
|
218
218
|
function Ee() {
|
|
219
219
|
return ne(ve);
|
|
220
220
|
}
|
|
221
|
-
const
|
|
221
|
+
const qt = he;
|
|
222
222
|
class be {
|
|
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 be {
|
|
|
372
372
|
return e !== null && !this.isTokenExpired(e);
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
|
-
class
|
|
375
|
+
class Ke {
|
|
376
376
|
constructor(e) {
|
|
377
377
|
this.httpService = e;
|
|
378
378
|
}
|
|
@@ -493,7 +493,7 @@ class Me {
|
|
|
493
493
|
};
|
|
494
494
|
}
|
|
495
495
|
}
|
|
496
|
-
class
|
|
496
|
+
class Je {
|
|
497
497
|
constructor(e, t) {
|
|
498
498
|
this.httpService = e, this.sessionManager = t;
|
|
499
499
|
}
|
|
@@ -611,7 +611,7 @@ class de {
|
|
|
611
611
|
)).data;
|
|
612
612
|
}
|
|
613
613
|
}
|
|
614
|
-
function
|
|
614
|
+
function Ye(i, e) {
|
|
615
615
|
if (i === "localhost" || i.startsWith("127.") || i.startsWith("192.168."))
|
|
616
616
|
return null;
|
|
617
617
|
if (e) {
|
|
@@ -627,26 +627,26 @@ function Ke(i, e) {
|
|
|
627
627
|
const r = i.split(".");
|
|
628
628
|
return r.length >= 3 && r[0] !== "www" ? r[0] : null;
|
|
629
629
|
}
|
|
630
|
-
function
|
|
630
|
+
function Qe(i, e = "tenant", t) {
|
|
631
631
|
const s = new URLSearchParams(i).get(e);
|
|
632
632
|
return s ? (t && t.setItem("tenant", s), s) : t ? t.getItem("tenant") : null;
|
|
633
633
|
}
|
|
634
|
-
function
|
|
634
|
+
function Xe(i, e, t) {
|
|
635
635
|
const { tenantMode: r, baseDomain: s, selectorParam: o } = i;
|
|
636
|
-
return r === "subdomain" ?
|
|
636
|
+
return r === "subdomain" ? Ye(e.hostname, s) : r === "selector" ? Qe(e.search, o, t) : null;
|
|
637
637
|
}
|
|
638
|
-
function
|
|
638
|
+
function Ze(i, e, t) {
|
|
639
639
|
if (t)
|
|
640
640
|
return `${i}.${t}`;
|
|
641
641
|
const r = e.split(".");
|
|
642
642
|
return r.length === 2 ? `${i}.${e}` : r.length >= 3 ? (r[0] = i, r.join(".")) : null;
|
|
643
643
|
}
|
|
644
644
|
const fe = "_auth";
|
|
645
|
-
function
|
|
645
|
+
function et(i) {
|
|
646
646
|
const e = JSON.stringify(i);
|
|
647
647
|
return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
648
648
|
}
|
|
649
|
-
function
|
|
649
|
+
function tt(i) {
|
|
650
650
|
try {
|
|
651
651
|
let e = i.replace(/-/g, "+").replace(/_/g, "/");
|
|
652
652
|
for (; e.length % 4; )
|
|
@@ -657,7 +657,7 @@ function Ze(i) {
|
|
|
657
657
|
return null;
|
|
658
658
|
}
|
|
659
659
|
}
|
|
660
|
-
function
|
|
660
|
+
function rt() {
|
|
661
661
|
if (typeof window > "u")
|
|
662
662
|
return console.log("[CrossDomainAuth] SSR environment, skipping URL token extraction"), null;
|
|
663
663
|
const e = new URLSearchParams(window.location.search).get(fe);
|
|
@@ -666,7 +666,7 @@ function et() {
|
|
|
666
666
|
searchParams: window.location.search,
|
|
667
667
|
encodedLength: e == null ? void 0 : e.length
|
|
668
668
|
}), !e) return null;
|
|
669
|
-
const t =
|
|
669
|
+
const t = tt(e);
|
|
670
670
|
return console.log("[CrossDomainAuth] Token decode result:", {
|
|
671
671
|
success: !!t,
|
|
672
672
|
hasAccessToken: !!(t != null && t.accessToken),
|
|
@@ -674,7 +674,7 @@ function et() {
|
|
|
674
674
|
expiresIn: t == null ? void 0 : t.expiresIn
|
|
675
675
|
}), t;
|
|
676
676
|
}
|
|
677
|
-
function
|
|
677
|
+
function nt() {
|
|
678
678
|
if (typeof window > "u") return;
|
|
679
679
|
const i = new URL(window.location.href);
|
|
680
680
|
i.searchParams.delete(fe), console.log("[CrossDomainAuth] Clearing auth tokens from URL", {
|
|
@@ -683,8 +683,8 @@ function tt() {
|
|
|
683
683
|
}), window.history.replaceState({}, "", i.toString());
|
|
684
684
|
}
|
|
685
685
|
const ke = ue(null);
|
|
686
|
-
function
|
|
687
|
-
const { baseUrl: t, appInfo: r, appId: s } = he(), o = se(() => typeof window > "u" ? null :
|
|
686
|
+
function zt({ config: i, children: e }) {
|
|
687
|
+
const { baseUrl: t, appInfo: r, appId: s } = he(), o = se(() => typeof window > "u" ? null : Xe(
|
|
688
688
|
{
|
|
689
689
|
tenantMode: i.tenantMode || "selector",
|
|
690
690
|
baseDomain: i.baseDomain,
|
|
@@ -695,118 +695,118 @@ function Bt({ config: i, children: e }) {
|
|
|
695
695
|
search: window.location.search
|
|
696
696
|
},
|
|
697
697
|
window.localStorage
|
|
698
|
-
), [i.tenantMode, i.baseDomain, i.selectorParam]), [a,
|
|
698
|
+
), [i.tenantMode, i.baseDomain, i.selectorParam]), [a, g] = S(() => o()), w = X(
|
|
699
699
|
() => {
|
|
700
|
-
var
|
|
700
|
+
var c, I, T;
|
|
701
701
|
return {
|
|
702
|
-
enabled: ((
|
|
703
|
-
ttl: ((
|
|
702
|
+
enabled: ((c = i.cache) == null ? void 0 : c.enabled) ?? !0,
|
|
703
|
+
ttl: ((I = i.cache) == null ? void 0 : I.ttl) ?? 5 * 60 * 1e3,
|
|
704
704
|
// 5 minutes default
|
|
705
|
-
storageKey: ((
|
|
705
|
+
storageKey: ((T = i.cache) == null ? void 0 : T.storageKey) ?? `tenant_cache_${a || "default"}`
|
|
706
706
|
};
|
|
707
707
|
},
|
|
708
708
|
[i.cache, a]
|
|
709
|
-
), [
|
|
709
|
+
), [m, k] = S(() => {
|
|
710
710
|
if (i.initialTenant) return i.initialTenant;
|
|
711
711
|
if (!w.enabled || !a) return null;
|
|
712
712
|
try {
|
|
713
|
-
const
|
|
714
|
-
if (!
|
|
715
|
-
const
|
|
716
|
-
return Date.now() -
|
|
713
|
+
const c = localStorage.getItem(w.storageKey);
|
|
714
|
+
if (!c) return null;
|
|
715
|
+
const I = JSON.parse(c);
|
|
716
|
+
return Date.now() - I.timestamp < w.ttl && I.tenantSlug === a ? I.data : (localStorage.removeItem(w.storageKey), null);
|
|
717
717
|
} catch {
|
|
718
718
|
return null;
|
|
719
719
|
}
|
|
720
|
-
}), [b, f] =
|
|
720
|
+
}), [b, f] = S(!m && !i.initialTenant), [A, L] = S(null), [D, R] = S(null), [P, u] = S(!1), [N, z] = S(null);
|
|
721
721
|
te(() => {
|
|
722
|
-
const
|
|
723
|
-
|
|
722
|
+
const c = o();
|
|
723
|
+
g(c);
|
|
724
724
|
}, [o]);
|
|
725
|
-
const
|
|
726
|
-
async (
|
|
727
|
-
if (!(!
|
|
725
|
+
const E = (r == null ? void 0 : r.settingsSchema) || null, p = se(
|
|
726
|
+
async (c, I = !1) => {
|
|
727
|
+
if (!(!I && w.enabled && m && m.domain === c))
|
|
728
728
|
try {
|
|
729
729
|
f(!0), L(null);
|
|
730
|
-
const
|
|
731
|
-
if (
|
|
730
|
+
const T = new re(t), d = await new de(T, s).getPublicTenantInfo(c);
|
|
731
|
+
if (k(d), w.enabled)
|
|
732
732
|
try {
|
|
733
|
-
const
|
|
734
|
-
data:
|
|
733
|
+
const y = {
|
|
734
|
+
data: d,
|
|
735
735
|
timestamp: Date.now(),
|
|
736
|
-
tenantSlug:
|
|
736
|
+
tenantSlug: c
|
|
737
737
|
};
|
|
738
|
-
localStorage.setItem(w.storageKey, JSON.stringify(
|
|
739
|
-
} catch (
|
|
740
|
-
console.warn("Failed to cache tenant info:",
|
|
738
|
+
localStorage.setItem(w.storageKey, JSON.stringify(y));
|
|
739
|
+
} catch (y) {
|
|
740
|
+
console.warn("Failed to cache tenant info:", y);
|
|
741
741
|
}
|
|
742
|
-
} catch (
|
|
743
|
-
const h =
|
|
744
|
-
L(h),
|
|
742
|
+
} catch (T) {
|
|
743
|
+
const h = T instanceof Error ? T : new Error("Failed to load tenant information");
|
|
744
|
+
L(h), k(null);
|
|
745
745
|
} finally {
|
|
746
746
|
f(!1);
|
|
747
747
|
}
|
|
748
748
|
},
|
|
749
|
-
[t, s, w,
|
|
750
|
-
),
|
|
751
|
-
if (!(!w.enabled || !
|
|
749
|
+
[t, s, w, m]
|
|
750
|
+
), O = se(async () => {
|
|
751
|
+
if (!(!w.enabled || !m || !a))
|
|
752
752
|
try {
|
|
753
|
-
const
|
|
754
|
-
if (!
|
|
755
|
-
const
|
|
756
|
-
if (Date.now() -
|
|
757
|
-
const h = new re(t),
|
|
758
|
-
|
|
759
|
-
const
|
|
760
|
-
data:
|
|
753
|
+
const c = localStorage.getItem(w.storageKey);
|
|
754
|
+
if (!c) return;
|
|
755
|
+
const I = JSON.parse(c);
|
|
756
|
+
if (Date.now() - I.timestamp > w.ttl * 0.5) {
|
|
757
|
+
const h = new re(t), y = await new de(h, s).getPublicTenantInfo(a);
|
|
758
|
+
k(y);
|
|
759
|
+
const G = {
|
|
760
|
+
data: y,
|
|
761
761
|
timestamp: Date.now(),
|
|
762
762
|
tenantSlug: a
|
|
763
763
|
};
|
|
764
|
-
localStorage.setItem(w.storageKey, JSON.stringify(
|
|
764
|
+
localStorage.setItem(w.storageKey, JSON.stringify(G));
|
|
765
765
|
}
|
|
766
|
-
} catch (
|
|
767
|
-
console.warn("Background tenant refresh failed:",
|
|
766
|
+
} catch (c) {
|
|
767
|
+
console.warn("Background tenant refresh failed:", c);
|
|
768
768
|
}
|
|
769
|
-
}, [t, s, w,
|
|
770
|
-
if (
|
|
769
|
+
}, [t, s, w, m, a]), v = se(async () => {
|
|
770
|
+
if (m != null && m.id)
|
|
771
771
|
try {
|
|
772
|
-
u(!0),
|
|
773
|
-
const
|
|
774
|
-
|
|
775
|
-
} catch (
|
|
776
|
-
const
|
|
777
|
-
|
|
772
|
+
u(!0), z(null);
|
|
773
|
+
const c = new re(t), T = await new de(c, m.appId).getTenantSettings(m.id);
|
|
774
|
+
R(T);
|
|
775
|
+
} catch (c) {
|
|
776
|
+
const I = c instanceof Error ? c : new Error("Failed to load tenant settings");
|
|
777
|
+
z(I), R(null);
|
|
778
778
|
} finally {
|
|
779
779
|
u(!1);
|
|
780
780
|
}
|
|
781
|
-
}, [t,
|
|
782
|
-
|
|
783
|
-
}, [
|
|
784
|
-
(
|
|
785
|
-
if (!
|
|
781
|
+
}, [t, m]), C = se(() => {
|
|
782
|
+
v();
|
|
783
|
+
}, [v]), x = se(
|
|
784
|
+
(c) => {
|
|
785
|
+
if (!E)
|
|
786
786
|
return { isValid: !0, errors: [] };
|
|
787
|
-
const
|
|
787
|
+
const I = [];
|
|
788
788
|
try {
|
|
789
|
-
return
|
|
790
|
-
var
|
|
791
|
-
const
|
|
792
|
-
if ((
|
|
793
|
-
|
|
789
|
+
return E.properties && Object.entries(E.properties).forEach(([T, h]) => {
|
|
790
|
+
var y;
|
|
791
|
+
const d = c[T];
|
|
792
|
+
if ((y = E.required) != null && y.includes(T) && d == null) {
|
|
793
|
+
I.push(`Field '${T}' is required`);
|
|
794
794
|
return;
|
|
795
795
|
}
|
|
796
|
-
if (
|
|
796
|
+
if (d != null) {
|
|
797
797
|
if (h.type) {
|
|
798
|
-
const
|
|
799
|
-
|
|
798
|
+
const G = h.type, $ = typeof d;
|
|
799
|
+
G === "string" && $ !== "string" ? I.push(`Field '${T}' must be a string`) : (G === "number" || G === "integer") && $ !== "number" ? I.push(`Field '${T}' must be a number`) : G === "boolean" && $ !== "boolean" ? I.push(`Field '${T}' must be a boolean`) : G === "array" && !Array.isArray(d) && I.push(`Field '${T}' must be an array`);
|
|
800
800
|
}
|
|
801
|
-
h.minLength !== void 0 && typeof
|
|
802
|
-
`Field '${
|
|
803
|
-
), h.maxLength !== void 0 && typeof
|
|
804
|
-
`Field '${
|
|
805
|
-
), h.minimum !== void 0 && typeof
|
|
801
|
+
h.minLength !== void 0 && typeof d == "string" && d.length < h.minLength && I.push(
|
|
802
|
+
`Field '${T}' must be at least ${h.minLength} characters long`
|
|
803
|
+
), h.maxLength !== void 0 && typeof d == "string" && d.length > h.maxLength && I.push(
|
|
804
|
+
`Field '${T}' must be no more than ${h.maxLength} characters long`
|
|
805
|
+
), h.minimum !== void 0 && typeof d == "number" && d < h.minimum && I.push(`Field '${T}' must be at least ${h.minimum}`), h.maximum !== void 0 && typeof d == "number" && d > h.maximum && I.push(`Field '${T}' must be no more than ${h.maximum}`), h.pattern && typeof d == "string" && (new RegExp(h.pattern).test(d) || I.push(`Field '${T}' does not match the required pattern`)), h.enum && !h.enum.includes(d) && I.push(`Field '${T}' must be one of: ${h.enum.join(", ")}`);
|
|
806
806
|
}
|
|
807
807
|
}), {
|
|
808
|
-
isValid:
|
|
809
|
-
errors:
|
|
808
|
+
isValid: I.length === 0,
|
|
809
|
+
errors: I
|
|
810
810
|
};
|
|
811
811
|
} catch {
|
|
812
812
|
return {
|
|
@@ -815,78 +815,78 @@ function Bt({ config: i, children: e }) {
|
|
|
815
815
|
};
|
|
816
816
|
}
|
|
817
817
|
},
|
|
818
|
-
[
|
|
818
|
+
[E]
|
|
819
819
|
);
|
|
820
820
|
te(() => {
|
|
821
|
-
!i.initialTenant && a ?
|
|
822
|
-
}, [i.initialTenant, a,
|
|
823
|
-
|
|
824
|
-
}, [
|
|
825
|
-
const
|
|
826
|
-
(
|
|
827
|
-
const { mode:
|
|
828
|
-
if (localStorage.setItem("tenant",
|
|
829
|
-
const
|
|
830
|
-
|
|
831
|
-
|
|
821
|
+
!i.initialTenant && a ? m ? O() : p(a) : !i.initialTenant && !a && (k(null), L(null), f(!1));
|
|
822
|
+
}, [i.initialTenant, a, m, p, O]), te(() => {
|
|
823
|
+
m != null && m.id ? v() : (R(null), z(null), u(!1));
|
|
824
|
+
}, [m == null ? void 0 : m.id, v]);
|
|
825
|
+
const M = se(
|
|
826
|
+
(c, I) => {
|
|
827
|
+
const { mode: T = "reload", tokens: h, redirectPath: d } = I || {}, y = i.tenantMode || "selector";
|
|
828
|
+
if (localStorage.setItem("tenant", c), y === "subdomain") {
|
|
829
|
+
const G = window.location.hostname, $ = Ze(
|
|
830
|
+
c,
|
|
831
|
+
G,
|
|
832
832
|
i.baseDomain
|
|
833
833
|
);
|
|
834
|
-
if (
|
|
834
|
+
if (!$) {
|
|
835
835
|
console.warn(
|
|
836
836
|
"[TenantProvider] Cannot switch subdomain, invalid hostname:",
|
|
837
|
-
|
|
837
|
+
G
|
|
838
838
|
);
|
|
839
839
|
return;
|
|
840
840
|
}
|
|
841
|
-
const
|
|
842
|
-
new URLSearchParams(window.location.search).forEach((
|
|
843
|
-
J !== fe &&
|
|
844
|
-
}), h &&
|
|
845
|
-
} else if (
|
|
846
|
-
const
|
|
847
|
-
if (
|
|
848
|
-
const
|
|
849
|
-
window.location.href =
|
|
841
|
+
const H = d || window.location.pathname, U = new URL(`${window.location.protocol}//${$}${H}`);
|
|
842
|
+
new URLSearchParams(window.location.search).forEach((B, J) => {
|
|
843
|
+
J !== fe && U.searchParams.set(J, B);
|
|
844
|
+
}), h && U.searchParams.set(fe, et(h)), window.location.href = U.toString();
|
|
845
|
+
} else if (y === "selector") {
|
|
846
|
+
const G = d || window.location.pathname, $ = new URLSearchParams(window.location.search);
|
|
847
|
+
if ($.set(i.selectorParam || "tenant", c), T === "reload") {
|
|
848
|
+
const H = `${G}?${$.toString()}${window.location.hash}`;
|
|
849
|
+
window.location.href = H;
|
|
850
850
|
} else {
|
|
851
|
-
const
|
|
852
|
-
window.history.pushState({}, "",
|
|
851
|
+
const H = `${G}?${$.toString()}${window.location.hash}`;
|
|
852
|
+
window.history.pushState({}, "", H), g(c), p(c);
|
|
853
853
|
}
|
|
854
854
|
}
|
|
855
855
|
},
|
|
856
|
-
[i.tenantMode, i.selectorParam, i.baseDomain,
|
|
857
|
-
),
|
|
856
|
+
[i.tenantMode, i.selectorParam, i.baseDomain, p]
|
|
857
|
+
), F = X(() => ({
|
|
858
858
|
// Tenant info
|
|
859
|
-
tenant:
|
|
859
|
+
tenant: m,
|
|
860
860
|
tenantSlug: a,
|
|
861
861
|
isTenantLoading: b,
|
|
862
862
|
tenantError: A,
|
|
863
863
|
retryTenant: () => {
|
|
864
|
-
a &&
|
|
864
|
+
a && p(a);
|
|
865
865
|
},
|
|
866
866
|
// Settings
|
|
867
867
|
settings: D,
|
|
868
|
-
settingsSchema:
|
|
869
|
-
isSettingsLoading:
|
|
870
|
-
settingsError:
|
|
868
|
+
settingsSchema: E,
|
|
869
|
+
isSettingsLoading: P,
|
|
870
|
+
settingsError: N,
|
|
871
871
|
// Actions
|
|
872
|
-
refreshSettings:
|
|
873
|
-
switchTenant:
|
|
872
|
+
refreshSettings: C,
|
|
873
|
+
switchTenant: M,
|
|
874
874
|
// Validation
|
|
875
|
-
validateSettings:
|
|
875
|
+
validateSettings: x
|
|
876
876
|
}), [
|
|
877
|
-
|
|
877
|
+
m,
|
|
878
878
|
a,
|
|
879
879
|
b,
|
|
880
880
|
A,
|
|
881
881
|
D,
|
|
882
|
-
|
|
883
|
-
M,
|
|
884
|
-
R,
|
|
885
|
-
q,
|
|
882
|
+
E,
|
|
886
883
|
P,
|
|
887
|
-
|
|
884
|
+
N,
|
|
885
|
+
C,
|
|
886
|
+
M,
|
|
887
|
+
x
|
|
888
888
|
]);
|
|
889
|
-
return /* @__PURE__ */ n(ke.Provider, { value:
|
|
889
|
+
return /* @__PURE__ */ n(ke.Provider, { value: F, children: e });
|
|
890
890
|
}
|
|
891
891
|
function me() {
|
|
892
892
|
const i = ne(ke);
|
|
@@ -897,8 +897,8 @@ function me() {
|
|
|
897
897
|
function ye() {
|
|
898
898
|
return ne(ke);
|
|
899
899
|
}
|
|
900
|
-
const
|
|
901
|
-
function
|
|
900
|
+
const Ot = me;
|
|
901
|
+
function Wt() {
|
|
902
902
|
const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } = me();
|
|
903
903
|
return {
|
|
904
904
|
settings: i,
|
|
@@ -919,53 +919,53 @@ function le() {
|
|
|
919
919
|
};
|
|
920
920
|
}
|
|
921
921
|
const xe = ue(null);
|
|
922
|
-
function
|
|
923
|
-
const { appId: t, baseUrl: r } = he(), { tenant: s, tenantSlug: o, switchTenant: a } = me(), [
|
|
924
|
-
|
|
925
|
-
const
|
|
926
|
-
const
|
|
922
|
+
function jt({ config: i = {}, children: e }) {
|
|
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, L] = S(!1), [D, R] = S(null), [P, u] = S(0), [N, z] = S(!1), E = Ge({ done: !1, urlTokens: null });
|
|
924
|
+
E.current.done || (E.current.done = !0, E.current.urlTokens = rt(), E.current.urlTokens && console.log("[AuthProvider] SYNC: URL tokens found"));
|
|
925
|
+
const p = X(() => {
|
|
926
|
+
const $ = new be({
|
|
927
927
|
tenantSlug: o,
|
|
928
928
|
onRefreshFailed: i.onRefreshFailed,
|
|
929
929
|
baseUrl: r
|
|
930
930
|
});
|
|
931
|
-
return
|
|
932
|
-
accessToken:
|
|
933
|
-
refreshToken:
|
|
934
|
-
expiresIn:
|
|
935
|
-
}), console.log("[AuthProvider] SYNC: Session valid:",
|
|
936
|
-
}, [o, r, i.onRefreshFailed]),
|
|
937
|
-
const
|
|
938
|
-
return
|
|
939
|
-
}, [r,
|
|
940
|
-
const
|
|
931
|
+
return E.current.urlTokens && (console.log("[AuthProvider] SYNC: Saving URL tokens to session manager"), $.setTokens({
|
|
932
|
+
accessToken: E.current.urlTokens.accessToken,
|
|
933
|
+
refreshToken: E.current.urlTokens.refreshToken,
|
|
934
|
+
expiresIn: E.current.urlTokens.expiresIn
|
|
935
|
+
}), console.log("[AuthProvider] SYNC: Session valid:", $.hasValidSession())), $;
|
|
936
|
+
}, [o, r, i.onRefreshFailed]), O = E.current.done && !N, v = X(() => {
|
|
937
|
+
const $ = new re(r);
|
|
938
|
+
return $.setSessionManager(p), $;
|
|
939
|
+
}, [r, p]), C = X(() => new Ke(new re(r)), [r]), x = X(() => new Je(v, p), [v, p]), M = X(() => new Me(new re(r)), [r]), F = X(() => b || p.getUser(), [b, p]), c = X(() => F != null && F.roleId && g.find(($) => $.id === F.roleId) || null, [F, g]), I = X(() => (c == null ? void 0 : c.permissions) || [], [c]), T = X(() => p.hasValidSession() && b !== null, [p, b]), h = 5 * 60 * 1e3, d = X(() => {
|
|
940
|
+
const $ = async (q = !1) => {
|
|
941
941
|
try {
|
|
942
|
-
if (!
|
|
942
|
+
if (!p.hasValidSession())
|
|
943
943
|
return;
|
|
944
|
-
const
|
|
945
|
-
if (!
|
|
944
|
+
const W = Date.now();
|
|
945
|
+
if (!q && W - P < h && b)
|
|
946
946
|
return;
|
|
947
|
-
const _ =
|
|
947
|
+
const _ = p.getUserId();
|
|
948
948
|
if (!_) {
|
|
949
949
|
console.warn("[AuthProvider] No userId available in token or storage");
|
|
950
950
|
return;
|
|
951
951
|
}
|
|
952
|
-
L(!0),
|
|
953
|
-
const Z = await
|
|
954
|
-
f(Z),
|
|
955
|
-
} catch (
|
|
956
|
-
const Y =
|
|
957
|
-
|
|
952
|
+
L(!0), R(null);
|
|
953
|
+
const Z = await x.getUserById(_);
|
|
954
|
+
f(Z), p.setUser(Z), u(Date.now());
|
|
955
|
+
} catch (W) {
|
|
956
|
+
const Y = W instanceof Error ? W : new Error("Failed to load user data");
|
|
957
|
+
R(Y), console.error("[AuthProvider] Failed to load user data:", Y);
|
|
958
958
|
} finally {
|
|
959
959
|
L(!1);
|
|
960
960
|
}
|
|
961
|
-
},
|
|
962
|
-
await
|
|
963
|
-
},
|
|
964
|
-
const { username:
|
|
965
|
-
let Z = s == null ? void 0 : s.id, Q = o, ee =
|
|
966
|
-
_ && (Z = (await new de(
|
|
967
|
-
const
|
|
968
|
-
username:
|
|
961
|
+
}, H = async () => {
|
|
962
|
+
await $();
|
|
963
|
+
}, U = async (q) => {
|
|
964
|
+
const { username: W, password: Y, tenantSlug: _ } = q;
|
|
965
|
+
let Z = s == null ? void 0 : s.id, Q = o, ee = p;
|
|
966
|
+
_ && (Z = (await new de(v, t).getPublicTenantInfo(_)).id, Q = _);
|
|
967
|
+
const K = await C.login({
|
|
968
|
+
username: W,
|
|
969
969
|
password: Y,
|
|
970
970
|
appId: t,
|
|
971
971
|
tenantId: Z
|
|
@@ -974,48 +974,48 @@ function Ot({ config: i = {}, children: e }) {
|
|
|
974
974
|
tenantSlug: Q,
|
|
975
975
|
baseUrl: r
|
|
976
976
|
})), ee.setTokens({
|
|
977
|
-
accessToken:
|
|
978
|
-
refreshToken:
|
|
979
|
-
expiresIn:
|
|
980
|
-
}),
|
|
981
|
-
ee.setUser(
|
|
977
|
+
accessToken: K.accessToken,
|
|
978
|
+
refreshToken: K.refreshToken,
|
|
979
|
+
expiresIn: K.expiresIn
|
|
980
|
+
}), K.user) {
|
|
981
|
+
ee.setUser(K.user), f(K.user);
|
|
982
982
|
try {
|
|
983
|
-
await
|
|
983
|
+
await $();
|
|
984
984
|
} catch (ce) {
|
|
985
985
|
console.warn("Failed to load complete user data after login:", ce);
|
|
986
986
|
}
|
|
987
987
|
}
|
|
988
988
|
return ae && Q && Q !== o && a(Q, {
|
|
989
989
|
tokens: {
|
|
990
|
-
accessToken:
|
|
991
|
-
refreshToken:
|
|
992
|
-
expiresIn:
|
|
990
|
+
accessToken: K.accessToken,
|
|
991
|
+
refreshToken: K.refreshToken,
|
|
992
|
+
expiresIn: K.expiresIn
|
|
993
993
|
}
|
|
994
|
-
}),
|
|
995
|
-
},
|
|
996
|
-
const { email:
|
|
997
|
-
if (!
|
|
994
|
+
}), K;
|
|
995
|
+
}, V = async (q) => {
|
|
996
|
+
const { email: W, phoneNumber: Y, name: _, password: Z, lastName: Q, tenantId: ee } = q;
|
|
997
|
+
if (!W && !Y)
|
|
998
998
|
throw new Error("Either email or phoneNumber is required");
|
|
999
999
|
if (!_ || !Z)
|
|
1000
1000
|
throw new Error("Name and password are required");
|
|
1001
|
-
const
|
|
1001
|
+
const K = ee ?? (s == null ? void 0 : s.id);
|
|
1002
1002
|
return await C.signup({
|
|
1003
|
-
email:
|
|
1003
|
+
email: W,
|
|
1004
1004
|
phoneNumber: Y,
|
|
1005
1005
|
name: _,
|
|
1006
1006
|
password: Z,
|
|
1007
|
-
tenantId:
|
|
1007
|
+
tenantId: K,
|
|
1008
1008
|
lastName: Q,
|
|
1009
1009
|
appId: t
|
|
1010
1010
|
});
|
|
1011
|
-
},
|
|
1012
|
-
const { email:
|
|
1013
|
-
if (!
|
|
1011
|
+
}, B = async (q) => {
|
|
1012
|
+
const { email: W, phoneNumber: Y, name: _, password: Z, tenantName: Q, lastName: ee } = q;
|
|
1013
|
+
if (!W && !Y)
|
|
1014
1014
|
throw new Error("Either email or phoneNumber is required");
|
|
1015
1015
|
if (!_ || !Z || !Q)
|
|
1016
1016
|
throw new Error("Name, password, and tenantName are required");
|
|
1017
1017
|
return await C.signupTenantAdmin({
|
|
1018
|
-
email:
|
|
1018
|
+
email: W,
|
|
1019
1019
|
phoneNumber: Y,
|
|
1020
1020
|
name: _,
|
|
1021
1021
|
password: Z,
|
|
@@ -1023,35 +1023,35 @@ function Ot({ config: i = {}, children: e }) {
|
|
|
1023
1023
|
appId: t,
|
|
1024
1024
|
lastName: ee
|
|
1025
1025
|
});
|
|
1026
|
-
},
|
|
1027
|
-
const { currentPassword:
|
|
1028
|
-
await C.changePassword({ currentPassword:
|
|
1029
|
-
},
|
|
1030
|
-
const { email:
|
|
1026
|
+
}, J = async (q) => {
|
|
1027
|
+
const { currentPassword: W, newPassword: Y } = q, _ = await p.getAuthHeaders();
|
|
1028
|
+
await C.changePassword({ currentPassword: W, newPassword: Y }, _);
|
|
1029
|
+
}, ge = async (q) => {
|
|
1030
|
+
const { email: W, tenantId: Y } = q, _ = Y ?? (s == null ? void 0 : s.id);
|
|
1031
1031
|
if (!_)
|
|
1032
1032
|
throw new Error("tenantId is required for password reset");
|
|
1033
|
-
await C.requestPasswordReset({ email:
|
|
1034
|
-
},
|
|
1035
|
-
const { token:
|
|
1036
|
-
await C.confirmPasswordReset({ token:
|
|
1037
|
-
},
|
|
1038
|
-
const { email:
|
|
1033
|
+
await C.requestPasswordReset({ email: W, tenantId: _ });
|
|
1034
|
+
}, He = async (q) => {
|
|
1035
|
+
const { token: W, newPassword: Y } = q;
|
|
1036
|
+
await C.confirmPasswordReset({ token: W, newPassword: Y });
|
|
1037
|
+
}, Ne = async (q) => {
|
|
1038
|
+
const { email: W, frontendUrl: Y, name: _, lastName: Z, tenantId: Q } = q, ee = Q ?? (s == null ? void 0 : s.id);
|
|
1039
1039
|
if (!ee)
|
|
1040
1040
|
throw new Error("tenantId is required for magic link authentication");
|
|
1041
1041
|
return await C.sendMagicLink({
|
|
1042
|
-
email:
|
|
1042
|
+
email: W,
|
|
1043
1043
|
tenantId: ee,
|
|
1044
1044
|
frontendUrl: Y,
|
|
1045
1045
|
name: _,
|
|
1046
1046
|
lastName: Z,
|
|
1047
1047
|
appId: t
|
|
1048
1048
|
});
|
|
1049
|
-
},
|
|
1050
|
-
const { token:
|
|
1051
|
-
let Z = s == null ? void 0 : s.id, Q = o, ee =
|
|
1052
|
-
_ && (Z = (await new de(
|
|
1053
|
-
const
|
|
1054
|
-
token:
|
|
1049
|
+
}, Ue = async (q) => {
|
|
1050
|
+
const { token: W, email: Y, tenantSlug: _ } = q;
|
|
1051
|
+
let Z = s == null ? void 0 : s.id, Q = o, ee = p;
|
|
1052
|
+
_ && (Z = (await new de(v, t).getPublicTenantInfo(_)).id, Q = _);
|
|
1053
|
+
const K = await C.verifyMagicLink({
|
|
1054
|
+
token: W,
|
|
1055
1055
|
email: Y,
|
|
1056
1056
|
appId: t,
|
|
1057
1057
|
tenantId: Z
|
|
@@ -1060,152 +1060,154 @@ function Ot({ config: i = {}, children: e }) {
|
|
|
1060
1060
|
tenantSlug: Q,
|
|
1061
1061
|
baseUrl: r
|
|
1062
1062
|
})), ee.setTokens({
|
|
1063
|
-
accessToken:
|
|
1064
|
-
refreshToken:
|
|
1065
|
-
expiresIn:
|
|
1066
|
-
}),
|
|
1067
|
-
ee.setUser(
|
|
1063
|
+
accessToken: K.accessToken,
|
|
1064
|
+
refreshToken: K.refreshToken,
|
|
1065
|
+
expiresIn: K.expiresIn
|
|
1066
|
+
}), K.user) {
|
|
1067
|
+
ee.setUser(K.user), f(K.user);
|
|
1068
1068
|
try {
|
|
1069
|
-
await
|
|
1069
|
+
await $();
|
|
1070
1070
|
} catch (ce) {
|
|
1071
1071
|
console.warn("Failed to load complete user data after magic link login:", ce);
|
|
1072
1072
|
}
|
|
1073
1073
|
}
|
|
1074
1074
|
return ae && Q && Q !== o && a(Q, {
|
|
1075
1075
|
tokens: {
|
|
1076
|
-
accessToken:
|
|
1077
|
-
refreshToken:
|
|
1078
|
-
expiresIn:
|
|
1076
|
+
accessToken: K.accessToken,
|
|
1077
|
+
refreshToken: K.refreshToken,
|
|
1078
|
+
expiresIn: K.expiresIn
|
|
1079
1079
|
}
|
|
1080
|
-
}),
|
|
1081
|
-
},
|
|
1082
|
-
const
|
|
1083
|
-
if (!(
|
|
1080
|
+
}), K;
|
|
1081
|
+
}, Be = async () => {
|
|
1082
|
+
const q = p.getTokens();
|
|
1083
|
+
if (!(q != null && q.refreshToken))
|
|
1084
1084
|
throw new Error("No refresh token available");
|
|
1085
|
-
const
|
|
1086
|
-
refreshToken:
|
|
1085
|
+
const W = await C.refreshToken({
|
|
1086
|
+
refreshToken: q.refreshToken
|
|
1087
1087
|
});
|
|
1088
|
-
|
|
1089
|
-
accessToken:
|
|
1090
|
-
refreshToken:
|
|
1091
|
-
expiresIn:
|
|
1088
|
+
p.setTokens({
|
|
1089
|
+
accessToken: W.accessToken,
|
|
1090
|
+
refreshToken: W.refreshToken || q.refreshToken,
|
|
1091
|
+
expiresIn: W.expiresIn
|
|
1092
1092
|
});
|
|
1093
|
-
},
|
|
1094
|
-
|
|
1095
|
-
},
|
|
1096
|
-
|
|
1097
|
-
},
|
|
1098
|
-
|
|
1099
|
-
},
|
|
1093
|
+
}, qe = () => {
|
|
1094
|
+
p.clearSession(), f(null), R(null);
|
|
1095
|
+
}, ze = (q) => {
|
|
1096
|
+
p.setTokens(q);
|
|
1097
|
+
}, Oe = () => p.hasValidSession(), We = () => {
|
|
1098
|
+
p.clearSession(), f(null), R(null);
|
|
1099
|
+
}, je = async () => {
|
|
1100
1100
|
if (t)
|
|
1101
1101
|
try {
|
|
1102
|
-
|
|
1103
|
-
const { roles:
|
|
1104
|
-
w(
|
|
1105
|
-
} catch (
|
|
1106
|
-
console.error("Failed to fetch roles:",
|
|
1102
|
+
k(!0);
|
|
1103
|
+
const { roles: q } = await M.getRolesByApp(t);
|
|
1104
|
+
w(q);
|
|
1105
|
+
} catch (q) {
|
|
1106
|
+
console.error("Failed to fetch roles:", q);
|
|
1107
1107
|
} finally {
|
|
1108
|
-
|
|
1108
|
+
k(!1);
|
|
1109
1109
|
}
|
|
1110
|
-
},
|
|
1111
|
-
await
|
|
1112
|
-
}, we = (
|
|
1113
|
-
if (!
|
|
1110
|
+
}, Ve = async () => {
|
|
1111
|
+
await je();
|
|
1112
|
+
}, we = (q) => {
|
|
1113
|
+
if (!I || I.length === 0)
|
|
1114
1114
|
return !1;
|
|
1115
|
-
if (typeof
|
|
1116
|
-
return
|
|
1117
|
-
const
|
|
1118
|
-
return
|
|
1115
|
+
if (typeof q == "string")
|
|
1116
|
+
return I.includes(q);
|
|
1117
|
+
const W = `${q.resource}.${q.action}`;
|
|
1118
|
+
return I.includes(W);
|
|
1119
1119
|
};
|
|
1120
1120
|
return {
|
|
1121
1121
|
// RFC-003: Authentication state
|
|
1122
|
-
isAuthenticated:
|
|
1123
|
-
sessionManager:
|
|
1124
|
-
authenticatedHttpService:
|
|
1125
|
-
login:
|
|
1126
|
-
signup:
|
|
1127
|
-
signupTenantAdmin:
|
|
1128
|
-
sendMagicLink:
|
|
1129
|
-
verifyMagicLink:
|
|
1130
|
-
changePassword:
|
|
1131
|
-
requestPasswordReset:
|
|
1132
|
-
confirmPasswordReset:
|
|
1133
|
-
refreshToken:
|
|
1134
|
-
logout:
|
|
1135
|
-
setTokens:
|
|
1136
|
-
hasValidSession:
|
|
1137
|
-
clearSession:
|
|
1122
|
+
isAuthenticated: T,
|
|
1123
|
+
sessionManager: p,
|
|
1124
|
+
authenticatedHttpService: v,
|
|
1125
|
+
login: U,
|
|
1126
|
+
signup: V,
|
|
1127
|
+
signupTenantAdmin: B,
|
|
1128
|
+
sendMagicLink: Ne,
|
|
1129
|
+
verifyMagicLink: Ue,
|
|
1130
|
+
changePassword: J,
|
|
1131
|
+
requestPasswordReset: ge,
|
|
1132
|
+
confirmPasswordReset: He,
|
|
1133
|
+
refreshToken: Be,
|
|
1134
|
+
logout: qe,
|
|
1135
|
+
setTokens: ze,
|
|
1136
|
+
hasValidSession: Oe,
|
|
1137
|
+
clearSession: We,
|
|
1138
1138
|
currentUser: b,
|
|
1139
1139
|
isUserLoading: A,
|
|
1140
1140
|
userError: D,
|
|
1141
|
-
loadUserData:
|
|
1142
|
-
refreshUser:
|
|
1143
|
-
isAuthInitializing: !
|
|
1144
|
-
isAuthReady:
|
|
1145
|
-
userRole:
|
|
1146
|
-
userPermissions:
|
|
1147
|
-
availableRoles:
|
|
1148
|
-
rolesLoading:
|
|
1141
|
+
loadUserData: $,
|
|
1142
|
+
refreshUser: H,
|
|
1143
|
+
isAuthInitializing: !O,
|
|
1144
|
+
isAuthReady: O,
|
|
1145
|
+
userRole: c,
|
|
1146
|
+
userPermissions: I,
|
|
1147
|
+
availableRoles: g,
|
|
1148
|
+
rolesLoading: m,
|
|
1149
1149
|
hasPermission: we,
|
|
1150
|
-
hasAnyPermission: (
|
|
1151
|
-
hasAllPermissions: (
|
|
1152
|
-
getUserPermissionStrings: () =>
|
|
1153
|
-
refreshRoles:
|
|
1150
|
+
hasAnyPermission: (q) => q.some((W) => we(W)),
|
|
1151
|
+
hasAllPermissions: (q) => q.every((W) => we(W)),
|
|
1152
|
+
getUserPermissionStrings: () => I || [],
|
|
1153
|
+
refreshRoles: Ve
|
|
1154
1154
|
};
|
|
1155
1155
|
}, [
|
|
1156
|
-
d,
|
|
1157
|
-
m,
|
|
1158
|
-
$,
|
|
1159
|
-
C,
|
|
1160
1156
|
T,
|
|
1161
|
-
|
|
1157
|
+
p,
|
|
1158
|
+
v,
|
|
1159
|
+
C,
|
|
1160
|
+
x,
|
|
1161
|
+
M,
|
|
1162
1162
|
t,
|
|
1163
1163
|
s,
|
|
1164
1164
|
o,
|
|
1165
1165
|
a,
|
|
1166
|
-
|
|
1166
|
+
g,
|
|
1167
1167
|
b,
|
|
1168
1168
|
A,
|
|
1169
1169
|
D,
|
|
1170
|
-
|
|
1170
|
+
O,
|
|
1171
|
+
c,
|
|
1172
|
+
I,
|
|
1171
1173
|
P,
|
|
1172
|
-
|
|
1173
|
-
M,
|
|
1174
|
-
F
|
|
1174
|
+
h
|
|
1175
1175
|
]);
|
|
1176
1176
|
te(() => {
|
|
1177
1177
|
!i.initialRoles && t && (async () => {
|
|
1178
1178
|
try {
|
|
1179
|
-
|
|
1180
|
-
const
|
|
1181
|
-
w(
|
|
1182
|
-
} catch (
|
|
1183
|
-
console.error("Failed to fetch roles:",
|
|
1179
|
+
k(!0);
|
|
1180
|
+
const H = new re(r), U = new Me(H), { roles: V } = await U.getRolesByApp(t);
|
|
1181
|
+
w(V);
|
|
1182
|
+
} catch (H) {
|
|
1183
|
+
console.error("Failed to fetch roles:", H);
|
|
1184
1184
|
} finally {
|
|
1185
|
-
|
|
1185
|
+
k(!1);
|
|
1186
1186
|
}
|
|
1187
1187
|
})();
|
|
1188
1188
|
}, [t, r, i.initialRoles]);
|
|
1189
|
-
const [
|
|
1189
|
+
const [y, G] = S(!1);
|
|
1190
1190
|
return te(() => {
|
|
1191
|
-
|
|
1192
|
-
console.error("[AuthProvider] Failed to load user data:",
|
|
1191
|
+
y || (G(!0), E.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), nt(), z(!0), console.log("[AuthProvider] EFFECT: Loading user data (blocking isAuthReady)..."), d.loadUserData().catch(($) => {
|
|
1192
|
+
console.error("[AuthProvider] Failed to load user data:", $);
|
|
1193
|
+
}).finally(() => {
|
|
1194
|
+
console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"), z(!1);
|
|
1193
1195
|
})));
|
|
1194
|
-
}, [
|
|
1195
|
-
const
|
|
1196
|
-
|
|
1197
|
-
}, [
|
|
1198
|
-
|
|
1196
|
+
}, [d, y]), te(() => {
|
|
1197
|
+
const $ = p.getUser();
|
|
1198
|
+
$ && p.hasValidSession() && f($);
|
|
1199
|
+
}, [p]), te(() => {
|
|
1200
|
+
y && (E.current.urlTokens || !b && !A && p.hasValidSession() && (console.log("[AuthProvider] Auto-loading user data..."), d.loadUserData().catch(() => {
|
|
1199
1201
|
})));
|
|
1200
|
-
}, [b, A,
|
|
1201
|
-
if (!
|
|
1202
|
+
}, [b, A, d, p, y]), te(() => {
|
|
1203
|
+
if (!p.hasValidSession() || !b)
|
|
1202
1204
|
return;
|
|
1203
|
-
const
|
|
1204
|
-
|
|
1205
|
+
const $ = setInterval(() => {
|
|
1206
|
+
d.loadUserData().catch(() => {
|
|
1205
1207
|
});
|
|
1206
|
-
},
|
|
1207
|
-
return () => clearInterval(
|
|
1208
|
-
}, [
|
|
1208
|
+
}, h);
|
|
1209
|
+
return () => clearInterval($);
|
|
1210
|
+
}, [p, b, d, h]), /* @__PURE__ */ n(xe.Provider, { value: d, children: e });
|
|
1209
1211
|
}
|
|
1210
1212
|
function oe() {
|
|
1211
1213
|
const i = ne(xe);
|
|
@@ -1216,7 +1218,7 @@ function oe() {
|
|
|
1216
1218
|
function Fe() {
|
|
1217
1219
|
return ne(xe);
|
|
1218
1220
|
}
|
|
1219
|
-
class
|
|
1221
|
+
class st {
|
|
1220
1222
|
constructor(e, t) {
|
|
1221
1223
|
this.httpService = e, this.sessionManager = t;
|
|
1222
1224
|
}
|
|
@@ -1297,56 +1299,56 @@ class rt {
|
|
|
1297
1299
|
}
|
|
1298
1300
|
}
|
|
1299
1301
|
const Ae = ue(null);
|
|
1300
|
-
function
|
|
1301
|
-
const t = Ee(), r = ye(), s = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (r == null ? void 0 : r.tenant) ?? null, [
|
|
1302
|
+
function Vt({ config: i = {}, children: e }) {
|
|
1303
|
+
const t = Ee(), 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, L] = S(!1), D = X(() => {
|
|
1302
1304
|
const u = new re(s);
|
|
1303
|
-
return new
|
|
1304
|
-
}, [s]),
|
|
1305
|
+
return new st(u);
|
|
1306
|
+
}, [s]), R = async () => {
|
|
1305
1307
|
if (!(a != null && a.id)) {
|
|
1306
1308
|
w([]);
|
|
1307
1309
|
return;
|
|
1308
1310
|
}
|
|
1309
|
-
|
|
1311
|
+
k(!0), f(null);
|
|
1310
1312
|
try {
|
|
1311
1313
|
const u = await D.getTenantFeatureFlags(a.id, o);
|
|
1312
1314
|
w(u);
|
|
1313
1315
|
} catch (u) {
|
|
1314
|
-
const
|
|
1315
|
-
f(
|
|
1316
|
+
const N = u instanceof Error ? u.message : "Failed to fetch feature flags";
|
|
1317
|
+
f(N), i.onError && i.onError(u instanceof Error ? u : new Error(N));
|
|
1316
1318
|
} finally {
|
|
1317
|
-
|
|
1319
|
+
k(!1);
|
|
1318
1320
|
}
|
|
1319
1321
|
};
|
|
1320
1322
|
te(() => {
|
|
1321
1323
|
if (!s || !o) return;
|
|
1322
|
-
|
|
1323
|
-
const u = i.refreshInterval || 5 * 60 * 1e3,
|
|
1324
|
-
return () => clearInterval(
|
|
1324
|
+
R().finally(() => L(!0));
|
|
1325
|
+
const u = i.refreshInterval || 5 * 60 * 1e3, N = setInterval(R, u);
|
|
1326
|
+
return () => clearInterval(N);
|
|
1325
1327
|
}, [a == null ? void 0 : a.id, s, o, i.refreshInterval]);
|
|
1326
|
-
const
|
|
1327
|
-
const u = (
|
|
1328
|
-
const
|
|
1329
|
-
return (
|
|
1330
|
-
},
|
|
1331
|
-
const
|
|
1332
|
-
return
|
|
1333
|
-
},
|
|
1334
|
-
await
|
|
1335
|
-
},
|
|
1328
|
+
const P = X(() => {
|
|
1329
|
+
const u = (O) => {
|
|
1330
|
+
const v = g.find((C) => C.key === O);
|
|
1331
|
+
return (v == null ? void 0 : v.value) === !0;
|
|
1332
|
+
}, N = (O) => g.find((v) => v.key === O), z = (O) => {
|
|
1333
|
+
const v = g.find((C) => C.key === O);
|
|
1334
|
+
return v ? v.value ? "enabled" : "disabled" : "not_found";
|
|
1335
|
+
}, E = async () => {
|
|
1336
|
+
await R();
|
|
1337
|
+
}, p = !!(s && o) && (A || !(a != null && a.id));
|
|
1336
1338
|
return {
|
|
1337
|
-
featureFlags:
|
|
1338
|
-
loading:
|
|
1339
|
+
featureFlags: g,
|
|
1340
|
+
loading: m,
|
|
1339
1341
|
error: b,
|
|
1340
|
-
isReady:
|
|
1342
|
+
isReady: p,
|
|
1341
1343
|
isEnabled: u,
|
|
1342
|
-
getFlag:
|
|
1343
|
-
getFlagState:
|
|
1344
|
-
refresh:
|
|
1344
|
+
getFlag: N,
|
|
1345
|
+
getFlagState: z,
|
|
1346
|
+
refresh: E
|
|
1345
1347
|
};
|
|
1346
|
-
}, [
|
|
1347
|
-
return /* @__PURE__ */ n(Ae.Provider, { value:
|
|
1348
|
+
}, [g, m, b, s, o, a == null ? void 0 : a.id, A]);
|
|
1349
|
+
return /* @__PURE__ */ n(Ae.Provider, { value: P, children: e });
|
|
1348
1350
|
}
|
|
1349
|
-
function
|
|
1351
|
+
function it() {
|
|
1350
1352
|
const i = ne(Ae);
|
|
1351
1353
|
if (!i)
|
|
1352
1354
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
@@ -1355,7 +1357,7 @@ function nt() {
|
|
|
1355
1357
|
function Ce() {
|
|
1356
1358
|
return ne(Ae);
|
|
1357
1359
|
}
|
|
1358
|
-
class
|
|
1360
|
+
class ot {
|
|
1359
1361
|
constructor(e, t) {
|
|
1360
1362
|
this.httpService = e, this.sessionManager = t;
|
|
1361
1363
|
}
|
|
@@ -1422,57 +1424,57 @@ class st {
|
|
|
1422
1424
|
}
|
|
1423
1425
|
}
|
|
1424
1426
|
const Te = ue(void 0);
|
|
1425
|
-
function
|
|
1426
|
-
const t = Ee(), r = ye(), s = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a,
|
|
1427
|
-
const
|
|
1428
|
-
return new
|
|
1427
|
+
function _t({ config: i = {}, children: e }) {
|
|
1428
|
+
const t = Ee(), 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), L = X(() => {
|
|
1429
|
+
const P = new re(s);
|
|
1430
|
+
return new ot(P);
|
|
1429
1431
|
}, [s]), D = async () => {
|
|
1430
1432
|
if (!(o != null && o.id)) {
|
|
1431
|
-
|
|
1433
|
+
g(null);
|
|
1432
1434
|
return;
|
|
1433
1435
|
}
|
|
1434
|
-
|
|
1436
|
+
m(!0), b(null);
|
|
1435
1437
|
try {
|
|
1436
|
-
const
|
|
1437
|
-
|
|
1438
|
-
} catch (
|
|
1439
|
-
const u =
|
|
1440
|
-
b(u), i.onError && i.onError(
|
|
1438
|
+
const P = await L.getTenantSubscriptionFeatures(o.id);
|
|
1439
|
+
g(P);
|
|
1440
|
+
} catch (P) {
|
|
1441
|
+
const u = P instanceof Error ? P.message : "Failed to fetch subscription";
|
|
1442
|
+
b(u), i.onError && i.onError(P instanceof Error ? P : new Error(u));
|
|
1441
1443
|
} finally {
|
|
1442
|
-
|
|
1444
|
+
m(!1);
|
|
1443
1445
|
}
|
|
1444
1446
|
};
|
|
1445
1447
|
te(() => {
|
|
1446
1448
|
if (!s || (D().finally(() => A(!0)), !i.refreshInterval)) return;
|
|
1447
|
-
const
|
|
1449
|
+
const P = i.refreshInterval || 10 * 60 * 1e3, u = setInterval(D, P);
|
|
1448
1450
|
return () => clearInterval(u);
|
|
1449
1451
|
}, [o == null ? void 0 : o.id, s, i.refreshInterval]);
|
|
1450
|
-
const
|
|
1451
|
-
const
|
|
1452
|
-
const
|
|
1453
|
-
return
|
|
1454
|
-
},
|
|
1455
|
-
const
|
|
1456
|
-
return
|
|
1457
|
-
},
|
|
1452
|
+
const R = X(() => {
|
|
1453
|
+
const P = (a == null ? void 0 : a.features) || [], u = (v) => {
|
|
1454
|
+
const C = P.find((x) => x.key === v);
|
|
1455
|
+
return C ? C.type === "BOOLEAN" || C.type === "boolean" ? C.value === !0 : !!C.value : !1;
|
|
1456
|
+
}, N = (v) => P.find((C) => C.key === v), z = (v, C) => {
|
|
1457
|
+
const x = P.find((M) => M.key === v);
|
|
1458
|
+
return x ? x.value : C;
|
|
1459
|
+
}, E = (v) => !a || !a.isActive ? !1 : v.includes(a.planId), p = async () => {
|
|
1458
1460
|
await D();
|
|
1459
|
-
},
|
|
1461
|
+
}, O = !!s && (f || !(o != null && o.id));
|
|
1460
1462
|
return {
|
|
1461
1463
|
subscription: a,
|
|
1462
|
-
features:
|
|
1464
|
+
features: P,
|
|
1463
1465
|
loading: w,
|
|
1464
|
-
error:
|
|
1465
|
-
isReady:
|
|
1466
|
+
error: k,
|
|
1467
|
+
isReady: O,
|
|
1466
1468
|
isFeatureEnabled: u,
|
|
1467
|
-
getFeature:
|
|
1468
|
-
getFeatureValue:
|
|
1469
|
-
hasAllowedPlan:
|
|
1470
|
-
refresh:
|
|
1469
|
+
getFeature: N,
|
|
1470
|
+
getFeatureValue: z,
|
|
1471
|
+
hasAllowedPlan: E,
|
|
1472
|
+
refresh: p
|
|
1471
1473
|
};
|
|
1472
|
-
}, [a, w,
|
|
1473
|
-
return /* @__PURE__ */ n(Te.Provider, { value:
|
|
1474
|
+
}, [a, w, k, s, o == null ? void 0 : o.id, f]);
|
|
1475
|
+
return /* @__PURE__ */ n(Te.Provider, { value: R, children: e });
|
|
1474
1476
|
}
|
|
1475
|
-
function
|
|
1477
|
+
function at() {
|
|
1476
1478
|
const i = ne(Te);
|
|
1477
1479
|
if (i === void 0)
|
|
1478
1480
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
@@ -1541,7 +1543,7 @@ const Ie = () => /* @__PURE__ */ l(
|
|
|
1541
1543
|
children: [
|
|
1542
1544
|
/* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
|
|
1543
1545
|
/* @__PURE__ */ n("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
|
|
1544
|
-
e && i ? /* @__PURE__ */ l(
|
|
1546
|
+
e && i ? /* @__PURE__ */ l(j, { children: [
|
|
1545
1547
|
/* @__PURE__ */ l("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
|
|
1546
1548
|
"This content requires ",
|
|
1547
1549
|
/* @__PURE__ */ n("strong", { children: e }),
|
|
@@ -1551,7 +1553,7 @@ const Ie = () => /* @__PURE__ */ l(
|
|
|
1551
1553
|
"Your current access level: ",
|
|
1552
1554
|
/* @__PURE__ */ n("strong", { children: i })
|
|
1553
1555
|
] })
|
|
1554
|
-
] }) : /* @__PURE__ */ l(
|
|
1556
|
+
] }) : /* @__PURE__ */ l(j, { children: [
|
|
1555
1557
|
/* @__PURE__ */ n("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
|
|
1556
1558
|
t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1557
1559
|
"Required permissions: ",
|
|
@@ -1560,7 +1562,7 @@ const Ie = () => /* @__PURE__ */ l(
|
|
|
1560
1562
|
] })
|
|
1561
1563
|
]
|
|
1562
1564
|
}
|
|
1563
|
-
),
|
|
1565
|
+
), lt = (i, e) => {
|
|
1564
1566
|
const t = {
|
|
1565
1567
|
[ie.USER]: 1,
|
|
1566
1568
|
[ie.TENANT_ADMIN]: 2,
|
|
@@ -1568,28 +1570,28 @@ const Ie = () => /* @__PURE__ */ l(
|
|
|
1568
1570
|
};
|
|
1569
1571
|
return t[i] >= t[e];
|
|
1570
1572
|
};
|
|
1571
|
-
function
|
|
1573
|
+
function Gt({
|
|
1572
1574
|
children: i,
|
|
1573
1575
|
fallback: e,
|
|
1574
1576
|
minUserType: t,
|
|
1575
1577
|
requiredPermissions: r,
|
|
1576
1578
|
requireAllPermissions: s = !1
|
|
1577
1579
|
}) {
|
|
1578
|
-
const { hasValidSession: o, sessionManager: a, hasPermission:
|
|
1580
|
+
const { hasValidSession: o, sessionManager: a, hasPermission: g, hasAnyPermission: w, hasAllPermissions: m } = oe();
|
|
1579
1581
|
if (!o())
|
|
1580
|
-
return /* @__PURE__ */ n(
|
|
1581
|
-
const
|
|
1582
|
-
if (!
|
|
1583
|
-
return /* @__PURE__ */ n(
|
|
1584
|
-
if (t && !
|
|
1585
|
-
return /* @__PURE__ */ n(Re, { userType:
|
|
1586
|
-
if (r && r.length > 0 && !(s ?
|
|
1587
|
-
const f = r.filter((A) => !
|
|
1582
|
+
return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(Ie, {}) });
|
|
1583
|
+
const k = a.getUser();
|
|
1584
|
+
if (!k)
|
|
1585
|
+
return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(Ie, {}) });
|
|
1586
|
+
if (t && !lt(k.userType, t))
|
|
1587
|
+
return /* @__PURE__ */ n(Re, { userType: k.userType, minUserType: t });
|
|
1588
|
+
if (r && r.length > 0 && !(s ? m(r) : w(r))) {
|
|
1589
|
+
const f = r.filter((A) => !g(A)).map((A) => typeof A == "string" ? A : A.name);
|
|
1588
1590
|
return /* @__PURE__ */ n(Re, { missingPermissions: f });
|
|
1589
1591
|
}
|
|
1590
|
-
return /* @__PURE__ */ n(
|
|
1592
|
+
return /* @__PURE__ */ n(j, { children: i });
|
|
1591
1593
|
}
|
|
1592
|
-
const
|
|
1594
|
+
const ct = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1593
1595
|
"div",
|
|
1594
1596
|
{
|
|
1595
1597
|
style: {
|
|
@@ -1655,7 +1657,7 @@ const at = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1655
1657
|
children: [
|
|
1656
1658
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
|
|
1657
1659
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
|
|
1658
|
-
e && i ? /* @__PURE__ */ l(
|
|
1660
|
+
e && i ? /* @__PURE__ */ l(j, { children: [
|
|
1659
1661
|
/* @__PURE__ */ l("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
|
|
1660
1662
|
"This page requires ",
|
|
1661
1663
|
/* @__PURE__ */ n("strong", { children: e }),
|
|
@@ -1665,7 +1667,7 @@ const at = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1665
1667
|
"Your current access level: ",
|
|
1666
1668
|
/* @__PURE__ */ n("strong", { children: i })
|
|
1667
1669
|
] })
|
|
1668
|
-
] }) : /* @__PURE__ */ l(
|
|
1670
|
+
] }) : /* @__PURE__ */ l(j, { children: [
|
|
1669
1671
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
|
|
1670
1672
|
t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1671
1673
|
"Required permissions: ",
|
|
@@ -1676,7 +1678,7 @@ const at = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1676
1678
|
}
|
|
1677
1679
|
)
|
|
1678
1680
|
}
|
|
1679
|
-
),
|
|
1681
|
+
), dt = (i, e) => {
|
|
1680
1682
|
const t = {
|
|
1681
1683
|
[ie.USER]: 1,
|
|
1682
1684
|
[ie.TENANT_ADMIN]: 2,
|
|
@@ -1684,7 +1686,7 @@ const at = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1684
1686
|
};
|
|
1685
1687
|
return t[i] >= t[e];
|
|
1686
1688
|
};
|
|
1687
|
-
function
|
|
1689
|
+
function Kt({
|
|
1688
1690
|
children: i,
|
|
1689
1691
|
redirectTo: e = "/login",
|
|
1690
1692
|
minUserType: t,
|
|
@@ -1692,24 +1694,24 @@ function _t({
|
|
|
1692
1694
|
requireAllPermissions: s = !1,
|
|
1693
1695
|
fallback: o
|
|
1694
1696
|
}) {
|
|
1695
|
-
const { hasValidSession: a, sessionManager:
|
|
1697
|
+
const { hasValidSession: a, sessionManager: g, hasPermission: w, hasAnyPermission: m, hasAllPermissions: k } = oe(), b = Se();
|
|
1696
1698
|
if (!a())
|
|
1697
|
-
return o ? /* @__PURE__ */ n(
|
|
1698
|
-
/* @__PURE__ */ n(
|
|
1699
|
+
return o ? /* @__PURE__ */ n(j, { children: o }) : /* @__PURE__ */ l(j, { children: [
|
|
1700
|
+
/* @__PURE__ */ n(ct, { redirectPath: e }),
|
|
1699
1701
|
/* @__PURE__ */ n(pe, { to: e, state: { from: b.pathname }, replace: !0 })
|
|
1700
1702
|
] });
|
|
1701
|
-
const f =
|
|
1703
|
+
const f = g.getUser();
|
|
1702
1704
|
if (!f)
|
|
1703
1705
|
return /* @__PURE__ */ n(pe, { to: e, state: { from: b.pathname }, replace: !0 });
|
|
1704
|
-
if (t && !
|
|
1706
|
+
if (t && !dt(f.userType, t))
|
|
1705
1707
|
return /* @__PURE__ */ n(Le, { userType: f.userType, minUserType: t });
|
|
1706
|
-
if (r && r.length > 0 && !(s ?
|
|
1708
|
+
if (r && r.length > 0 && !(s ? k(r) : m(r))) {
|
|
1707
1709
|
const L = r.filter((D) => !w(D)).map((D) => typeof D == "string" ? D : D.name);
|
|
1708
1710
|
return /* @__PURE__ */ n(Le, { missingPermissions: L });
|
|
1709
1711
|
}
|
|
1710
|
-
return /* @__PURE__ */ n(
|
|
1712
|
+
return /* @__PURE__ */ n(j, { children: i });
|
|
1711
1713
|
}
|
|
1712
|
-
const
|
|
1714
|
+
const ut = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1713
1715
|
"div",
|
|
1714
1716
|
{
|
|
1715
1717
|
style: {
|
|
@@ -1746,14 +1748,14 @@ const ct = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1746
1748
|
)
|
|
1747
1749
|
}
|
|
1748
1750
|
);
|
|
1749
|
-
function
|
|
1751
|
+
function Jt({ children: i, redirectTo: e = "/", fallback: t }) {
|
|
1750
1752
|
const { tenant: r, isLoading: s, error: o } = le(), a = Se();
|
|
1751
|
-
return s || o ? null : r ? /* @__PURE__ */ n(
|
|
1752
|
-
/* @__PURE__ */ n(
|
|
1753
|
+
return s || o ? null : r ? /* @__PURE__ */ n(j, { children: i }) : t ? /* @__PURE__ */ n(j, { children: t }) : /* @__PURE__ */ l(j, { children: [
|
|
1754
|
+
/* @__PURE__ */ n(ut, { redirectPath: e }),
|
|
1753
1755
|
/* @__PURE__ */ n(pe, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
1754
1756
|
] });
|
|
1755
1757
|
}
|
|
1756
|
-
const
|
|
1758
|
+
const ht = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1757
1759
|
"div",
|
|
1758
1760
|
{
|
|
1759
1761
|
style: {
|
|
@@ -1790,14 +1792,14 @@ const dt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1790
1792
|
)
|
|
1791
1793
|
}
|
|
1792
1794
|
);
|
|
1793
|
-
function
|
|
1795
|
+
function Yt({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
|
|
1794
1796
|
const { tenant: r, isLoading: s, error: o } = le(), a = Se();
|
|
1795
|
-
return s || o ? null : r ? t ? /* @__PURE__ */ n(
|
|
1796
|
-
/* @__PURE__ */ n(
|
|
1797
|
+
return s || o ? null : r ? t ? /* @__PURE__ */ n(j, { children: t }) : /* @__PURE__ */ l(j, { children: [
|
|
1798
|
+
/* @__PURE__ */ n(ht, { redirectPath: e }),
|
|
1797
1799
|
/* @__PURE__ */ n(pe, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
1798
|
-
] }) : /* @__PURE__ */ n(
|
|
1800
|
+
] }) : /* @__PURE__ */ n(j, { children: i });
|
|
1799
1801
|
}
|
|
1800
|
-
const
|
|
1802
|
+
const gt = () => /* @__PURE__ */ l(
|
|
1801
1803
|
"div",
|
|
1802
1804
|
{
|
|
1803
1805
|
style: {
|
|
@@ -1814,14 +1816,14 @@ const ut = () => /* @__PURE__ */ l(
|
|
|
1814
1816
|
]
|
|
1815
1817
|
}
|
|
1816
1818
|
);
|
|
1817
|
-
function
|
|
1819
|
+
function Qt({
|
|
1818
1820
|
children: i,
|
|
1819
|
-
fallback: e = /* @__PURE__ */ n(
|
|
1821
|
+
fallback: e = /* @__PURE__ */ n(gt, {}),
|
|
1820
1822
|
allowedPlans: t,
|
|
1821
1823
|
requiredFeature: r
|
|
1822
1824
|
}) {
|
|
1823
|
-
const { subscription: s, hasAllowedPlan: o, isFeatureEnabled: a, loading:
|
|
1824
|
-
return
|
|
1825
|
+
const { subscription: s, hasAllowedPlan: o, isFeatureEnabled: a, loading: g } = at();
|
|
1826
|
+
return g ? /* @__PURE__ */ n(
|
|
1825
1827
|
"div",
|
|
1826
1828
|
{
|
|
1827
1829
|
style: {
|
|
@@ -1831,9 +1833,9 @@ function Jt({
|
|
|
1831
1833
|
},
|
|
1832
1834
|
children: "Loading subscription..."
|
|
1833
1835
|
}
|
|
1834
|
-
) : s ? s.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ n(
|
|
1836
|
+
) : s ? s.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ n(j, { children: e }) : r && !a(r) ? /* @__PURE__ */ n(j, { children: e }) : /* @__PURE__ */ n(j, { children: i }) : /* @__PURE__ */ n(j, { children: e }) : /* @__PURE__ */ n(j, { children: e });
|
|
1835
1837
|
}
|
|
1836
|
-
const
|
|
1838
|
+
const pt = ({ flagName: i }) => /* @__PURE__ */ l(
|
|
1837
1839
|
"div",
|
|
1838
1840
|
{
|
|
1839
1841
|
style: {
|
|
@@ -1860,8 +1862,8 @@ const ht = ({ flagName: i }) => /* @__PURE__ */ l(
|
|
|
1860
1862
|
]
|
|
1861
1863
|
}
|
|
1862
1864
|
);
|
|
1863
|
-
function
|
|
1864
|
-
const { isEnabled: r, loading: s } =
|
|
1865
|
+
function Xt({ name: i, children: e, fallback: t }) {
|
|
1866
|
+
const { isEnabled: r, loading: s } = it();
|
|
1865
1867
|
return s ? /* @__PURE__ */ n(
|
|
1866
1868
|
"div",
|
|
1867
1869
|
{
|
|
@@ -1875,9 +1877,9 @@ function Yt({ name: i, children: e, fallback: t }) {
|
|
|
1875
1877
|
},
|
|
1876
1878
|
children: "Loading feature flags..."
|
|
1877
1879
|
}
|
|
1878
|
-
) : r(i) ? /* @__PURE__ */ n(
|
|
1880
|
+
) : r(i) ? /* @__PURE__ */ n(j, { children: e }) : /* @__PURE__ */ n(j, { children: t || /* @__PURE__ */ n(pt, { flagName: i }) });
|
|
1879
1881
|
}
|
|
1880
|
-
const
|
|
1882
|
+
const ft = () => /* @__PURE__ */ l(
|
|
1881
1883
|
"svg",
|
|
1882
1884
|
{
|
|
1883
1885
|
width: "16",
|
|
@@ -1894,7 +1896,7 @@ const gt = () => /* @__PURE__ */ l(
|
|
|
1894
1896
|
/* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "3" })
|
|
1895
1897
|
]
|
|
1896
1898
|
}
|
|
1897
|
-
),
|
|
1899
|
+
), mt = () => /* @__PURE__ */ l(
|
|
1898
1900
|
"svg",
|
|
1899
1901
|
{
|
|
1900
1902
|
width: "16",
|
|
@@ -1911,10 +1913,10 @@ const gt = () => /* @__PURE__ */ l(
|
|
|
1911
1913
|
/* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
1912
1914
|
]
|
|
1913
1915
|
}
|
|
1914
|
-
),
|
|
1915
|
-
showPassword: /* @__PURE__ */ n(
|
|
1916
|
-
hidePassword: /* @__PURE__ */ n(
|
|
1917
|
-
},
|
|
1916
|
+
), yt = {
|
|
1917
|
+
showPassword: /* @__PURE__ */ n(ft, {}),
|
|
1918
|
+
hidePassword: /* @__PURE__ */ n(mt, {})
|
|
1919
|
+
}, wt = {
|
|
1918
1920
|
title: "Sign In",
|
|
1919
1921
|
usernameLabel: "Email or Phone",
|
|
1920
1922
|
usernamePlaceholder: "Enter your email or phone number",
|
|
@@ -1928,7 +1930,7 @@ const gt = () => /* @__PURE__ */ l(
|
|
|
1928
1930
|
magicLinkLink: "Use Magic Link",
|
|
1929
1931
|
errorMessage: "Invalid credentials",
|
|
1930
1932
|
loadingText: "Signing in..."
|
|
1931
|
-
},
|
|
1933
|
+
}, bt = {
|
|
1932
1934
|
container: {
|
|
1933
1935
|
maxWidth: "400px",
|
|
1934
1936
|
width: "100%",
|
|
@@ -2035,7 +2037,7 @@ const gt = () => /* @__PURE__ */ l(
|
|
|
2035
2037
|
fontSize: "0.875rem"
|
|
2036
2038
|
}
|
|
2037
2039
|
};
|
|
2038
|
-
function
|
|
2040
|
+
function Zt({
|
|
2039
2041
|
copy: i = {},
|
|
2040
2042
|
styles: e = {},
|
|
2041
2043
|
icons: t = {},
|
|
@@ -2043,49 +2045,49 @@ function Qt({
|
|
|
2043
2045
|
onError: s,
|
|
2044
2046
|
onForgotPassword: o,
|
|
2045
2047
|
onSignupClick: a,
|
|
2046
|
-
onMagicLinkClick:
|
|
2048
|
+
onMagicLinkClick: g,
|
|
2047
2049
|
showForgotPassword: w = !0,
|
|
2048
|
-
showSignupLink:
|
|
2049
|
-
showMagicLinkOption:
|
|
2050
|
+
showSignupLink: m = !0,
|
|
2051
|
+
showMagicLinkOption: k = !0,
|
|
2050
2052
|
className: b
|
|
2051
2053
|
}) {
|
|
2052
|
-
const [f, A] =
|
|
2053
|
-
const
|
|
2054
|
-
return f.trim() || (
|
|
2055
|
-
},
|
|
2056
|
-
if (
|
|
2057
|
-
if (!(
|
|
2058
|
-
|
|
2054
|
+
const [f, A] = S(""), [L, D] = S(""), [R, P] = S(!1), [u, N] = S(!1), [z, E] = S(""), [p, O] = S({}), { login: v } = oe(), { tenant: C } = le(), x = { ...wt, ...i }, M = { ...bt, ...e }, F = { ...yt, ...t }, c = () => {
|
|
2055
|
+
const d = {};
|
|
2056
|
+
return f.trim() || (d.username = !0), L.trim() || (d.password = !0), O(d), Object.keys(d).length === 0;
|
|
2057
|
+
}, I = async (d) => {
|
|
2058
|
+
if (d.preventDefault(), !!c()) {
|
|
2059
|
+
if (!(C != null && C.id)) {
|
|
2060
|
+
E("Tenant not found");
|
|
2059
2061
|
return;
|
|
2060
2062
|
}
|
|
2061
|
-
|
|
2063
|
+
N(!0), E("");
|
|
2062
2064
|
try {
|
|
2063
|
-
const
|
|
2065
|
+
const y = await v({
|
|
2064
2066
|
username: f,
|
|
2065
2067
|
password: L
|
|
2066
2068
|
// tenantId inferred from context automatically
|
|
2067
2069
|
});
|
|
2068
|
-
r == null || r(
|
|
2069
|
-
} catch (
|
|
2070
|
-
const
|
|
2071
|
-
|
|
2070
|
+
r == null || r(y);
|
|
2071
|
+
} catch (y) {
|
|
2072
|
+
const G = y.message || x.errorMessage;
|
|
2073
|
+
E(G), s == null || s(G);
|
|
2072
2074
|
} finally {
|
|
2073
|
-
|
|
2075
|
+
N(!1);
|
|
2074
2076
|
}
|
|
2075
2077
|
}
|
|
2076
|
-
},
|
|
2077
|
-
...
|
|
2078
|
-
|
|
2078
|
+
}, T = (d) => ({
|
|
2079
|
+
...M.input,
|
|
2080
|
+
...p[d] ? M.inputError : {}
|
|
2079
2081
|
}), h = () => ({
|
|
2080
|
-
...
|
|
2081
|
-
...u ?
|
|
2082
|
-
...!f || !L || u ?
|
|
2082
|
+
...M.button,
|
|
2083
|
+
...u ? M.buttonLoading : {},
|
|
2084
|
+
...!f || !L || u ? M.buttonDisabled : {}
|
|
2083
2085
|
});
|
|
2084
|
-
return /* @__PURE__ */ l("div", { className: b, style:
|
|
2085
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2086
|
-
/* @__PURE__ */ l("form", { onSubmit:
|
|
2087
|
-
/* @__PURE__ */ l("div", { style:
|
|
2088
|
-
/* @__PURE__ */ n("label", { style:
|
|
2086
|
+
return /* @__PURE__ */ l("div", { className: b, style: M.container, children: [
|
|
2087
|
+
/* @__PURE__ */ n("h2", { style: M.title, children: x.title }),
|
|
2088
|
+
/* @__PURE__ */ l("form", { onSubmit: I, style: M.form, children: [
|
|
2089
|
+
/* @__PURE__ */ l("div", { style: M.fieldGroup, children: [
|
|
2090
|
+
/* @__PURE__ */ n("label", { style: M.label, children: x.usernameLabel }),
|
|
2089
2091
|
/* @__PURE__ */ n(
|
|
2090
2092
|
"input",
|
|
2091
2093
|
{
|
|
@@ -2093,31 +2095,31 @@ function Qt({
|
|
|
2093
2095
|
name: "username",
|
|
2094
2096
|
type: "text",
|
|
2095
2097
|
value: f,
|
|
2096
|
-
onChange: (
|
|
2097
|
-
A(
|
|
2098
|
+
onChange: (d) => {
|
|
2099
|
+
A(d.target.value), p.username && O((y) => ({ ...y, username: !1 }));
|
|
2098
2100
|
},
|
|
2099
|
-
placeholder:
|
|
2100
|
-
style:
|
|
2101
|
+
placeholder: x.usernamePlaceholder,
|
|
2102
|
+
style: T("username"),
|
|
2101
2103
|
disabled: u
|
|
2102
2104
|
}
|
|
2103
2105
|
)
|
|
2104
2106
|
] }),
|
|
2105
|
-
/* @__PURE__ */ l("div", { style:
|
|
2106
|
-
/* @__PURE__ */ n("label", { style:
|
|
2107
|
-
/* @__PURE__ */ l("div", { style:
|
|
2107
|
+
/* @__PURE__ */ l("div", { style: M.fieldGroup, children: [
|
|
2108
|
+
/* @__PURE__ */ n("label", { style: M.label, children: x.passwordLabel }),
|
|
2109
|
+
/* @__PURE__ */ l("div", { style: M.inputContainer, children: [
|
|
2108
2110
|
/* @__PURE__ */ n(
|
|
2109
2111
|
"input",
|
|
2110
2112
|
{
|
|
2111
2113
|
id: "password",
|
|
2112
2114
|
name: "password",
|
|
2113
|
-
type:
|
|
2115
|
+
type: R ? "text" : "password",
|
|
2114
2116
|
value: L,
|
|
2115
|
-
onChange: (
|
|
2116
|
-
D(
|
|
2117
|
+
onChange: (d) => {
|
|
2118
|
+
D(d.target.value), p.password && O((y) => ({ ...y, password: !1 }));
|
|
2117
2119
|
},
|
|
2118
|
-
placeholder:
|
|
2120
|
+
placeholder: x.passwordPlaceholder,
|
|
2119
2121
|
style: {
|
|
2120
|
-
...
|
|
2122
|
+
...T("password"),
|
|
2121
2123
|
paddingRight: "2.5rem"
|
|
2122
2124
|
// Make room for the icon
|
|
2123
2125
|
},
|
|
@@ -2128,40 +2130,40 @@ function Qt({
|
|
|
2128
2130
|
"button",
|
|
2129
2131
|
{
|
|
2130
2132
|
type: "button",
|
|
2131
|
-
onClick: () =>
|
|
2132
|
-
style:
|
|
2133
|
+
onClick: () => P(!R),
|
|
2134
|
+
style: M.passwordToggle,
|
|
2133
2135
|
disabled: u,
|
|
2134
|
-
"aria-label":
|
|
2135
|
-
children:
|
|
2136
|
+
"aria-label": R ? "Hide password" : "Show password",
|
|
2137
|
+
children: R ? F.hidePassword : F.showPassword
|
|
2136
2138
|
}
|
|
2137
2139
|
)
|
|
2138
2140
|
] })
|
|
2139
2141
|
] }),
|
|
2140
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !f || !L || u, style: h(), children: u ?
|
|
2141
|
-
|
|
2142
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !f || !L || u, style: h(), children: u ? x.loadingText : x.submitButton }),
|
|
2143
|
+
z && /* @__PURE__ */ n("div", { style: M.errorText, children: z })
|
|
2142
2144
|
] }),
|
|
2143
|
-
(w ||
|
|
2144
|
-
|
|
2145
|
-
/* @__PURE__ */ l("span", { style:
|
|
2146
|
-
|
|
2145
|
+
(w || m || k) && /* @__PURE__ */ l("div", { style: M.linkContainer, children: [
|
|
2146
|
+
k && /* @__PURE__ */ l("div", { children: [
|
|
2147
|
+
/* @__PURE__ */ l("span", { style: M.divider, children: [
|
|
2148
|
+
x.magicLinkText,
|
|
2147
2149
|
" "
|
|
2148
2150
|
] }),
|
|
2149
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
2151
|
+
/* @__PURE__ */ n("a", { onClick: g, style: M.link, children: x.magicLinkLink })
|
|
2150
2152
|
] }),
|
|
2151
|
-
|
|
2152
|
-
w && /* @__PURE__ */ n("a", { onClick: o, style:
|
|
2153
|
-
w &&
|
|
2154
|
-
|
|
2155
|
-
/* @__PURE__ */ l("span", { style:
|
|
2156
|
-
|
|
2153
|
+
k && (w || m) && /* @__PURE__ */ n("div", { style: M.divider, children: "•" }),
|
|
2154
|
+
w && /* @__PURE__ */ n("a", { onClick: o, style: M.link, children: x.forgotPasswordLink }),
|
|
2155
|
+
w && m && /* @__PURE__ */ n("div", { style: M.divider, children: "•" }),
|
|
2156
|
+
m && /* @__PURE__ */ l("div", { children: [
|
|
2157
|
+
/* @__PURE__ */ l("span", { style: M.divider, children: [
|
|
2158
|
+
x.signupText,
|
|
2157
2159
|
" "
|
|
2158
2160
|
] }),
|
|
2159
|
-
/* @__PURE__ */ n("a", { onClick: a, style:
|
|
2161
|
+
/* @__PURE__ */ n("a", { onClick: a, style: M.link, children: x.signupLink })
|
|
2160
2162
|
] })
|
|
2161
2163
|
] })
|
|
2162
2164
|
] });
|
|
2163
2165
|
}
|
|
2164
|
-
const
|
|
2166
|
+
const St = {
|
|
2165
2167
|
title: "Create Account",
|
|
2166
2168
|
nameLabel: "First Name",
|
|
2167
2169
|
namePlaceholder: "Enter your first name",
|
|
@@ -2187,7 +2189,7 @@ const wt = {
|
|
|
2187
2189
|
passwordMismatchError: "Passwords do not match",
|
|
2188
2190
|
isAdminLabel: "Create new organization",
|
|
2189
2191
|
isAdminDescription: "Check this if you want to create a new organization"
|
|
2190
|
-
},
|
|
2192
|
+
}, vt = {
|
|
2191
2193
|
container: {
|
|
2192
2194
|
maxWidth: "400px",
|
|
2193
2195
|
width: "100%",
|
|
@@ -2286,7 +2288,7 @@ const wt = {
|
|
|
2286
2288
|
fontSize: "0.875rem"
|
|
2287
2289
|
}
|
|
2288
2290
|
};
|
|
2289
|
-
function
|
|
2291
|
+
function er({
|
|
2290
2292
|
copy: i = {},
|
|
2291
2293
|
styles: e = {},
|
|
2292
2294
|
signupType: t = "user",
|
|
@@ -2294,79 +2296,79 @@ function Xt({
|
|
|
2294
2296
|
onError: s,
|
|
2295
2297
|
onLoginClick: o,
|
|
2296
2298
|
onMagicLinkClick: a,
|
|
2297
|
-
showLoginLink:
|
|
2299
|
+
showLoginLink: g = !0,
|
|
2298
2300
|
showMagicLinkOption: w = !0,
|
|
2299
|
-
className:
|
|
2301
|
+
className: m
|
|
2300
2302
|
}) {
|
|
2301
|
-
const [
|
|
2302
|
-
const
|
|
2303
|
-
return
|
|
2304
|
-
},
|
|
2305
|
-
if (
|
|
2306
|
-
if (u !==
|
|
2307
|
-
|
|
2303
|
+
const [k, b] = S(""), [f, A] = S(""), [L, D] = S(""), [R, P] = S(""), [u, N] = S(""), [z, E] = S(""), [p, O] = S(""), [v, C] = S(!1), [x, M] = S(""), [F, c] = S({}), { signup: I, signupTenantAdmin: T } = oe(), { tenant: h } = le(), d = { ...St, ...i }, y = { ...vt, ...e }, G = () => {
|
|
2304
|
+
const B = {};
|
|
2305
|
+
return k.trim() || (B.name = !0), !L.trim() && !R.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;
|
|
2306
|
+
}, $ = async (B) => {
|
|
2307
|
+
if (B.preventDefault(), !!G()) {
|
|
2308
|
+
if (u !== z) {
|
|
2309
|
+
M(d.passwordMismatchError), c({ confirmPassword: !0 });
|
|
2308
2310
|
return;
|
|
2309
2311
|
}
|
|
2310
2312
|
if (t === "user" && !(h != null && h.id)) {
|
|
2311
|
-
|
|
2313
|
+
M("Tenant not found");
|
|
2312
2314
|
return;
|
|
2313
2315
|
}
|
|
2314
|
-
|
|
2316
|
+
C(!0), M("");
|
|
2315
2317
|
try {
|
|
2316
2318
|
let J;
|
|
2317
|
-
t === "tenant" ? J = await
|
|
2319
|
+
t === "tenant" ? J = await T({
|
|
2318
2320
|
email: L || void 0,
|
|
2319
|
-
phoneNumber:
|
|
2320
|
-
name:
|
|
2321
|
+
phoneNumber: R || void 0,
|
|
2322
|
+
name: k,
|
|
2321
2323
|
password: u,
|
|
2322
|
-
tenantName:
|
|
2324
|
+
tenantName: p,
|
|
2323
2325
|
lastName: f || void 0
|
|
2324
|
-
}) : J = await
|
|
2326
|
+
}) : J = await I({
|
|
2325
2327
|
email: L || void 0,
|
|
2326
|
-
phoneNumber:
|
|
2327
|
-
name:
|
|
2328
|
+
phoneNumber: R || void 0,
|
|
2329
|
+
name: k,
|
|
2328
2330
|
password: u,
|
|
2329
2331
|
tenantId: h.id,
|
|
2330
2332
|
lastName: f || void 0
|
|
2331
2333
|
}), r == null || r(J);
|
|
2332
2334
|
} catch (J) {
|
|
2333
|
-
const ge = J.message ||
|
|
2334
|
-
|
|
2335
|
+
const ge = J.message || d.errorMessage;
|
|
2336
|
+
M(ge), s == null || s(ge);
|
|
2335
2337
|
} finally {
|
|
2336
|
-
|
|
2338
|
+
C(!1);
|
|
2337
2339
|
}
|
|
2338
2340
|
}
|
|
2339
|
-
},
|
|
2340
|
-
...
|
|
2341
|
-
...
|
|
2342
|
-
}),
|
|
2343
|
-
...
|
|
2344
|
-
...
|
|
2345
|
-
...!
|
|
2346
|
-
}), V =
|
|
2347
|
-
return /* @__PURE__ */ l("div", { className:
|
|
2348
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2349
|
-
/* @__PURE__ */ l("form", { onSubmit:
|
|
2350
|
-
/* @__PURE__ */ l("div", { style:
|
|
2351
|
-
/* @__PURE__ */ n("label", { style:
|
|
2341
|
+
}, H = (B) => ({
|
|
2342
|
+
...y.input,
|
|
2343
|
+
...F[B] ? y.inputError : {}
|
|
2344
|
+
}), U = () => ({
|
|
2345
|
+
...y.button,
|
|
2346
|
+
...v ? y.buttonLoading : {},
|
|
2347
|
+
...!k || !L && !R || !u || !z || v || t === "tenant" && !p ? y.buttonDisabled : {}
|
|
2348
|
+
}), V = k && (L || R) && u && z && (t === "user" || p);
|
|
2349
|
+
return /* @__PURE__ */ l("div", { className: m, style: y.container, children: [
|
|
2350
|
+
/* @__PURE__ */ n("h2", { style: y.title, children: d.title }),
|
|
2351
|
+
/* @__PURE__ */ l("form", { onSubmit: $, style: y.form, children: [
|
|
2352
|
+
/* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
|
|
2353
|
+
/* @__PURE__ */ n("label", { style: y.label, children: d.nameLabel }),
|
|
2352
2354
|
/* @__PURE__ */ n(
|
|
2353
2355
|
"input",
|
|
2354
2356
|
{
|
|
2355
2357
|
id: "name",
|
|
2356
2358
|
name: "name",
|
|
2357
2359
|
type: "text",
|
|
2358
|
-
value:
|
|
2359
|
-
onChange: (
|
|
2360
|
-
b(
|
|
2360
|
+
value: k,
|
|
2361
|
+
onChange: (B) => {
|
|
2362
|
+
b(B.target.value), F.name && c((J) => ({ ...J, name: !1 }));
|
|
2361
2363
|
},
|
|
2362
|
-
placeholder:
|
|
2363
|
-
style:
|
|
2364
|
-
disabled:
|
|
2364
|
+
placeholder: d.namePlaceholder,
|
|
2365
|
+
style: H("name"),
|
|
2366
|
+
disabled: v
|
|
2365
2367
|
}
|
|
2366
2368
|
)
|
|
2367
2369
|
] }),
|
|
2368
|
-
/* @__PURE__ */ l("div", { style:
|
|
2369
|
-
/* @__PURE__ */ n("label", { style:
|
|
2370
|
+
/* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
|
|
2371
|
+
/* @__PURE__ */ n("label", { style: y.label, children: d.lastNameLabel }),
|
|
2370
2372
|
/* @__PURE__ */ n(
|
|
2371
2373
|
"input",
|
|
2372
2374
|
{
|
|
@@ -2374,15 +2376,15 @@ function Xt({
|
|
|
2374
2376
|
name: "lastName",
|
|
2375
2377
|
type: "text",
|
|
2376
2378
|
value: f,
|
|
2377
|
-
onChange: (
|
|
2378
|
-
placeholder:
|
|
2379
|
-
style:
|
|
2380
|
-
disabled:
|
|
2379
|
+
onChange: (B) => A(B.target.value),
|
|
2380
|
+
placeholder: d.lastNamePlaceholder,
|
|
2381
|
+
style: y.input,
|
|
2382
|
+
disabled: v
|
|
2381
2383
|
}
|
|
2382
2384
|
)
|
|
2383
2385
|
] }),
|
|
2384
|
-
/* @__PURE__ */ l("div", { style:
|
|
2385
|
-
/* @__PURE__ */ n("label", { style:
|
|
2386
|
+
/* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
|
|
2387
|
+
/* @__PURE__ */ n("label", { style: y.label, children: d.emailLabel }),
|
|
2386
2388
|
/* @__PURE__ */ n(
|
|
2387
2389
|
"input",
|
|
2388
2390
|
{
|
|
@@ -2390,30 +2392,30 @@ function Xt({
|
|
|
2390
2392
|
name: "email",
|
|
2391
2393
|
type: "email",
|
|
2392
2394
|
value: L,
|
|
2393
|
-
onChange: (
|
|
2394
|
-
D(
|
|
2395
|
+
onChange: (B) => {
|
|
2396
|
+
D(B.target.value), F.email && c((J) => ({ ...J, email: !1, phoneNumber: !1 }));
|
|
2395
2397
|
},
|
|
2396
|
-
placeholder:
|
|
2397
|
-
style:
|
|
2398
|
-
disabled:
|
|
2398
|
+
placeholder: d.emailPlaceholder,
|
|
2399
|
+
style: H("email"),
|
|
2400
|
+
disabled: v
|
|
2399
2401
|
}
|
|
2400
2402
|
)
|
|
2401
2403
|
] }),
|
|
2402
|
-
/* @__PURE__ */ l("div", { style:
|
|
2403
|
-
/* @__PURE__ */ n("label", { style:
|
|
2404
|
+
/* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
|
|
2405
|
+
/* @__PURE__ */ n("label", { style: y.label, children: d.phoneNumberLabel }),
|
|
2404
2406
|
/* @__PURE__ */ n(
|
|
2405
2407
|
"input",
|
|
2406
2408
|
{
|
|
2407
2409
|
id: "phoneNumber",
|
|
2408
2410
|
name: "phoneNumber",
|
|
2409
2411
|
type: "tel",
|
|
2410
|
-
value:
|
|
2411
|
-
onChange: (
|
|
2412
|
-
|
|
2412
|
+
value: R,
|
|
2413
|
+
onChange: (B) => {
|
|
2414
|
+
P(B.target.value), F.phoneNumber && c((J) => ({ ...J, email: !1, phoneNumber: !1 }));
|
|
2413
2415
|
},
|
|
2414
|
-
placeholder:
|
|
2415
|
-
style:
|
|
2416
|
-
disabled:
|
|
2416
|
+
placeholder: d.phoneNumberPlaceholder,
|
|
2417
|
+
style: H("phoneNumber"),
|
|
2418
|
+
disabled: v
|
|
2417
2419
|
}
|
|
2418
2420
|
)
|
|
2419
2421
|
] }),
|
|
@@ -2429,8 +2431,8 @@ function Xt({
|
|
|
2429
2431
|
children: "At least one contact method (email or phone) is required"
|
|
2430
2432
|
}
|
|
2431
2433
|
),
|
|
2432
|
-
/* @__PURE__ */ l("div", { style:
|
|
2433
|
-
/* @__PURE__ */ n("label", { style:
|
|
2434
|
+
/* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
|
|
2435
|
+
/* @__PURE__ */ n("label", { style: y.label, children: d.passwordLabel }),
|
|
2434
2436
|
/* @__PURE__ */ n(
|
|
2435
2437
|
"input",
|
|
2436
2438
|
{
|
|
@@ -2438,74 +2440,74 @@ function Xt({
|
|
|
2438
2440
|
name: "password",
|
|
2439
2441
|
type: "password",
|
|
2440
2442
|
value: u,
|
|
2441
|
-
onChange: (
|
|
2442
|
-
|
|
2443
|
+
onChange: (B) => {
|
|
2444
|
+
N(B.target.value), F.password && c((J) => ({ ...J, password: !1 }));
|
|
2443
2445
|
},
|
|
2444
|
-
placeholder:
|
|
2445
|
-
style:
|
|
2446
|
-
disabled:
|
|
2446
|
+
placeholder: d.passwordPlaceholder,
|
|
2447
|
+
style: H("password"),
|
|
2448
|
+
disabled: v
|
|
2447
2449
|
}
|
|
2448
2450
|
)
|
|
2449
2451
|
] }),
|
|
2450
|
-
/* @__PURE__ */ l("div", { style:
|
|
2451
|
-
/* @__PURE__ */ n("label", { style:
|
|
2452
|
+
/* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
|
|
2453
|
+
/* @__PURE__ */ n("label", { style: y.label, children: d.confirmPasswordLabel }),
|
|
2452
2454
|
/* @__PURE__ */ n(
|
|
2453
2455
|
"input",
|
|
2454
2456
|
{
|
|
2455
2457
|
id: "confirmPassword",
|
|
2456
2458
|
name: "confirmPassword",
|
|
2457
2459
|
type: "password",
|
|
2458
|
-
value:
|
|
2459
|
-
onChange: (
|
|
2460
|
-
|
|
2460
|
+
value: z,
|
|
2461
|
+
onChange: (B) => {
|
|
2462
|
+
E(B.target.value), F.confirmPassword && c((J) => ({ ...J, confirmPassword: !1 })), x === d.passwordMismatchError && M("");
|
|
2461
2463
|
},
|
|
2462
|
-
placeholder:
|
|
2463
|
-
style:
|
|
2464
|
-
disabled:
|
|
2464
|
+
placeholder: d.confirmPasswordPlaceholder,
|
|
2465
|
+
style: H("confirmPassword"),
|
|
2466
|
+
disabled: v
|
|
2465
2467
|
}
|
|
2466
2468
|
)
|
|
2467
2469
|
] }),
|
|
2468
|
-
t === "tenant" && /* @__PURE__ */ l("div", { style:
|
|
2469
|
-
/* @__PURE__ */ n("label", { style:
|
|
2470
|
+
t === "tenant" && /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
|
|
2471
|
+
/* @__PURE__ */ n("label", { style: y.label, children: d.tenantNameLabel }),
|
|
2470
2472
|
/* @__PURE__ */ n(
|
|
2471
2473
|
"input",
|
|
2472
2474
|
{
|
|
2473
2475
|
id: "tenantName",
|
|
2474
2476
|
name: "tenantName",
|
|
2475
2477
|
type: "text",
|
|
2476
|
-
value:
|
|
2477
|
-
onChange: (
|
|
2478
|
-
|
|
2478
|
+
value: p,
|
|
2479
|
+
onChange: (B) => {
|
|
2480
|
+
O(B.target.value), F.tenantName && c((J) => ({ ...J, tenantName: !1 }));
|
|
2479
2481
|
},
|
|
2480
|
-
placeholder:
|
|
2481
|
-
style:
|
|
2482
|
-
disabled:
|
|
2482
|
+
placeholder: d.tenantNamePlaceholder,
|
|
2483
|
+
style: H("tenantName"),
|
|
2484
|
+
disabled: v
|
|
2483
2485
|
}
|
|
2484
2486
|
)
|
|
2485
2487
|
] }),
|
|
2486
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !V ||
|
|
2487
|
-
|
|
2488
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !V || v, style: U(), children: v ? d.loadingText : d.submitButton }),
|
|
2489
|
+
x && /* @__PURE__ */ n("div", { style: y.errorText, children: x })
|
|
2488
2490
|
] }),
|
|
2489
|
-
(
|
|
2491
|
+
(g || w) && /* @__PURE__ */ l("div", { style: y.linkContainer, children: [
|
|
2490
2492
|
w && /* @__PURE__ */ l("div", { children: [
|
|
2491
|
-
/* @__PURE__ */ l("span", { style:
|
|
2492
|
-
|
|
2493
|
+
/* @__PURE__ */ l("span", { style: y.divider, children: [
|
|
2494
|
+
d.magicLinkText,
|
|
2493
2495
|
" "
|
|
2494
2496
|
] }),
|
|
2495
|
-
/* @__PURE__ */ n("a", { onClick: a, style:
|
|
2497
|
+
/* @__PURE__ */ n("a", { onClick: a, style: y.link, children: d.magicLinkLink })
|
|
2496
2498
|
] }),
|
|
2497
|
-
w &&
|
|
2498
|
-
|
|
2499
|
-
/* @__PURE__ */ l("span", { style:
|
|
2500
|
-
|
|
2499
|
+
w && g && /* @__PURE__ */ n("div", { style: y.divider, children: "•" }),
|
|
2500
|
+
g && /* @__PURE__ */ l("div", { children: [
|
|
2501
|
+
/* @__PURE__ */ l("span", { style: y.divider, children: [
|
|
2502
|
+
d.loginText,
|
|
2501
2503
|
" "
|
|
2502
2504
|
] }),
|
|
2503
|
-
/* @__PURE__ */ n("a", { onClick: o, style:
|
|
2505
|
+
/* @__PURE__ */ n("a", { onClick: o, style: y.link, children: d.loginLink })
|
|
2504
2506
|
] })
|
|
2505
2507
|
] })
|
|
2506
2508
|
] });
|
|
2507
2509
|
}
|
|
2508
|
-
const
|
|
2510
|
+
const kt = {
|
|
2509
2511
|
title: "Sign In with Magic Link",
|
|
2510
2512
|
emailLabel: "Email",
|
|
2511
2513
|
emailPlaceholder: "Enter your email",
|
|
@@ -2523,7 +2525,7 @@ const St = {
|
|
|
2523
2525
|
loadingText: "Sending magic link...",
|
|
2524
2526
|
verifyingText: "Verifying magic link...",
|
|
2525
2527
|
description: "Enter your email to receive a magic link. If you don't have an account, we'll create one for you."
|
|
2526
|
-
},
|
|
2528
|
+
}, xt = {
|
|
2527
2529
|
container: {
|
|
2528
2530
|
maxWidth: "400px",
|
|
2529
2531
|
width: "100%",
|
|
@@ -2626,7 +2628,7 @@ const St = {
|
|
|
2626
2628
|
fontSize: "0.875rem"
|
|
2627
2629
|
}
|
|
2628
2630
|
};
|
|
2629
|
-
function
|
|
2631
|
+
function tr({
|
|
2630
2632
|
copy: i = {},
|
|
2631
2633
|
styles: e = {},
|
|
2632
2634
|
onSuccess: t,
|
|
@@ -2634,97 +2636,97 @@ function Zt({
|
|
|
2634
2636
|
onLoginClick: s,
|
|
2635
2637
|
onSignupClick: o,
|
|
2636
2638
|
showTraditionalLinks: a = !0,
|
|
2637
|
-
className:
|
|
2639
|
+
className: g,
|
|
2638
2640
|
verifyToken: w,
|
|
2639
|
-
frontendUrl:
|
|
2641
|
+
frontendUrl: m
|
|
2640
2642
|
}) {
|
|
2641
|
-
const [
|
|
2643
|
+
const [k, b] = S(""), [f, A] = S(""), [L, D] = S(""), [R, P] = S(!1), [u, N] = S(!1), [z, E] = S(""), [p, O] = S(""), [v, C] = S({}), [x, M] = S(!1), { sendMagicLink: F, verifyMagicLink: c } = oe(), { tenant: I } = le(), T = { ...kt, ...i }, h = { ...xt, ...e };
|
|
2642
2644
|
te(() => {
|
|
2643
|
-
w &&
|
|
2645
|
+
w && d(w);
|
|
2644
2646
|
}, [w]);
|
|
2645
|
-
const
|
|
2646
|
-
if (!
|
|
2647
|
-
|
|
2647
|
+
const d = async (U) => {
|
|
2648
|
+
if (!I || !k) {
|
|
2649
|
+
E("Missing tenant or email");
|
|
2648
2650
|
return;
|
|
2649
2651
|
}
|
|
2650
|
-
|
|
2652
|
+
N(!0), E("");
|
|
2651
2653
|
try {
|
|
2652
|
-
const V = await
|
|
2653
|
-
token:
|
|
2654
|
-
email:
|
|
2654
|
+
const V = await c({
|
|
2655
|
+
token: U,
|
|
2656
|
+
email: k
|
|
2655
2657
|
// tenantId inferred from context automatically
|
|
2656
2658
|
});
|
|
2657
2659
|
t == null || t(V);
|
|
2658
2660
|
} catch (V) {
|
|
2659
|
-
const
|
|
2660
|
-
|
|
2661
|
+
const B = V.message || "Failed to verify magic link";
|
|
2662
|
+
E(B), r == null || r(B);
|
|
2661
2663
|
} finally {
|
|
2662
|
-
|
|
2664
|
+
N(!1);
|
|
2663
2665
|
}
|
|
2664
|
-
},
|
|
2665
|
-
const
|
|
2666
|
-
return
|
|
2667
|
-
},
|
|
2668
|
-
if (
|
|
2669
|
-
if (!(
|
|
2670
|
-
|
|
2666
|
+
}, y = () => {
|
|
2667
|
+
const U = {};
|
|
2668
|
+
return k.trim() || (U.email = !0), x && !f.trim() && (U.name = !0), C(U), Object.keys(U).length === 0;
|
|
2669
|
+
}, G = async (U) => {
|
|
2670
|
+
if (U.preventDefault(), !!y()) {
|
|
2671
|
+
if (!(I != null && I.id)) {
|
|
2672
|
+
E("Tenant not found");
|
|
2671
2673
|
return;
|
|
2672
2674
|
}
|
|
2673
|
-
|
|
2675
|
+
P(!0), E(""), O("");
|
|
2674
2676
|
try {
|
|
2675
|
-
const V =
|
|
2676
|
-
email:
|
|
2677
|
-
tenantId:
|
|
2677
|
+
const V = m || (typeof window < "u" ? window.location.origin : ""), B = await F({
|
|
2678
|
+
email: k,
|
|
2679
|
+
tenantId: I.id,
|
|
2678
2680
|
frontendUrl: V,
|
|
2679
|
-
name:
|
|
2680
|
-
lastName:
|
|
2681
|
+
name: x ? f : void 0,
|
|
2682
|
+
lastName: x ? L : void 0
|
|
2681
2683
|
});
|
|
2682
|
-
|
|
2684
|
+
O(T.successMessage), t == null || t(B);
|
|
2683
2685
|
} catch (V) {
|
|
2684
|
-
const
|
|
2685
|
-
|
|
2686
|
+
const B = V.message || T.errorMessage;
|
|
2687
|
+
E(B), r == null || r(B);
|
|
2686
2688
|
} finally {
|
|
2687
|
-
|
|
2689
|
+
P(!1);
|
|
2688
2690
|
}
|
|
2689
2691
|
}
|
|
2690
|
-
},
|
|
2692
|
+
}, $ = (U) => ({
|
|
2691
2693
|
...h.input,
|
|
2692
|
-
...
|
|
2693
|
-
}),
|
|
2694
|
+
...v[U] ? h.inputError : {}
|
|
2695
|
+
}), H = () => ({
|
|
2694
2696
|
...h.button,
|
|
2695
|
-
...
|
|
2696
|
-
...!
|
|
2697
|
+
...R || u ? h.buttonLoading : {},
|
|
2698
|
+
...!k || R || u ? h.buttonDisabled : {}
|
|
2697
2699
|
});
|
|
2698
|
-
return u ? /* @__PURE__ */ l("div", { className:
|
|
2699
|
-
/* @__PURE__ */ n("h2", { style: h.title, children:
|
|
2700
|
+
return u ? /* @__PURE__ */ l("div", { className: g, style: h.container, children: [
|
|
2701
|
+
/* @__PURE__ */ n("h2", { style: h.title, children: T.verifyingText }),
|
|
2700
2702
|
/* @__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..." }) })
|
|
2701
|
-
] }) : /* @__PURE__ */ l("div", { className:
|
|
2702
|
-
/* @__PURE__ */ n("h2", { style: h.title, children:
|
|
2703
|
-
/* @__PURE__ */ n("p", { style: h.description, children:
|
|
2704
|
-
/* @__PURE__ */ l("form", { onSubmit:
|
|
2703
|
+
] }) : /* @__PURE__ */ l("div", { className: g, style: h.container, children: [
|
|
2704
|
+
/* @__PURE__ */ n("h2", { style: h.title, children: T.title }),
|
|
2705
|
+
/* @__PURE__ */ n("p", { style: h.description, children: T.description }),
|
|
2706
|
+
/* @__PURE__ */ l("form", { onSubmit: G, style: h.form, children: [
|
|
2705
2707
|
/* @__PURE__ */ l("div", { style: h.fieldGroup, children: [
|
|
2706
|
-
/* @__PURE__ */ n("label", { style: h.label, children:
|
|
2708
|
+
/* @__PURE__ */ n("label", { style: h.label, children: T.emailLabel }),
|
|
2707
2709
|
/* @__PURE__ */ n(
|
|
2708
2710
|
"input",
|
|
2709
2711
|
{
|
|
2710
2712
|
id: "email",
|
|
2711
2713
|
name: "email",
|
|
2712
2714
|
type: "email",
|
|
2713
|
-
value:
|
|
2714
|
-
onChange: (
|
|
2715
|
-
b(
|
|
2715
|
+
value: k,
|
|
2716
|
+
onChange: (U) => {
|
|
2717
|
+
b(U.target.value), v.email && C((V) => ({ ...V, email: !1 }));
|
|
2716
2718
|
},
|
|
2717
|
-
placeholder:
|
|
2718
|
-
style:
|
|
2719
|
-
disabled:
|
|
2719
|
+
placeholder: T.emailPlaceholder,
|
|
2720
|
+
style: $("email"),
|
|
2721
|
+
disabled: R || u
|
|
2720
2722
|
}
|
|
2721
2723
|
)
|
|
2722
2724
|
] }),
|
|
2723
|
-
!
|
|
2725
|
+
!x && /* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
|
|
2724
2726
|
"button",
|
|
2725
2727
|
{
|
|
2726
2728
|
type: "button",
|
|
2727
|
-
onClick: () =>
|
|
2729
|
+
onClick: () => M(!0),
|
|
2728
2730
|
style: {
|
|
2729
2731
|
background: "none",
|
|
2730
2732
|
border: "none",
|
|
@@ -2736,9 +2738,9 @@ function Zt({
|
|
|
2736
2738
|
children: "New user? Add your name"
|
|
2737
2739
|
}
|
|
2738
2740
|
) }),
|
|
2739
|
-
|
|
2741
|
+
x && /* @__PURE__ */ l(j, { children: [
|
|
2740
2742
|
/* @__PURE__ */ l("div", { style: h.fieldGroup, children: [
|
|
2741
|
-
/* @__PURE__ */ n("label", { style: h.label, children:
|
|
2743
|
+
/* @__PURE__ */ n("label", { style: h.label, children: T.nameLabel }),
|
|
2742
2744
|
/* @__PURE__ */ n(
|
|
2743
2745
|
"input",
|
|
2744
2746
|
{
|
|
@@ -2746,17 +2748,17 @@ function Zt({
|
|
|
2746
2748
|
name: "name",
|
|
2747
2749
|
type: "text",
|
|
2748
2750
|
value: f,
|
|
2749
|
-
onChange: (
|
|
2750
|
-
A(
|
|
2751
|
+
onChange: (U) => {
|
|
2752
|
+
A(U.target.value), v.name && C((V) => ({ ...V, name: !1 }));
|
|
2751
2753
|
},
|
|
2752
|
-
placeholder:
|
|
2753
|
-
style:
|
|
2754
|
-
disabled:
|
|
2754
|
+
placeholder: T.namePlaceholder,
|
|
2755
|
+
style: $("name"),
|
|
2756
|
+
disabled: R || u
|
|
2755
2757
|
}
|
|
2756
2758
|
)
|
|
2757
2759
|
] }),
|
|
2758
2760
|
/* @__PURE__ */ l("div", { style: h.fieldGroup, children: [
|
|
2759
|
-
/* @__PURE__ */ n("label", { style: h.label, children:
|
|
2761
|
+
/* @__PURE__ */ n("label", { style: h.label, children: T.lastNameLabel }),
|
|
2760
2762
|
/* @__PURE__ */ n(
|
|
2761
2763
|
"input",
|
|
2762
2764
|
{
|
|
@@ -2764,10 +2766,10 @@ function Zt({
|
|
|
2764
2766
|
name: "lastName",
|
|
2765
2767
|
type: "text",
|
|
2766
2768
|
value: L,
|
|
2767
|
-
onChange: (
|
|
2768
|
-
placeholder:
|
|
2769
|
+
onChange: (U) => D(U.target.value),
|
|
2770
|
+
placeholder: T.lastNamePlaceholder,
|
|
2769
2771
|
style: h.input,
|
|
2770
|
-
disabled:
|
|
2772
|
+
disabled: R || u
|
|
2771
2773
|
}
|
|
2772
2774
|
)
|
|
2773
2775
|
] }),
|
|
@@ -2776,7 +2778,7 @@ function Zt({
|
|
|
2776
2778
|
{
|
|
2777
2779
|
type: "button",
|
|
2778
2780
|
onClick: () => {
|
|
2779
|
-
|
|
2781
|
+
M(!1), A(""), D("");
|
|
2780
2782
|
},
|
|
2781
2783
|
style: {
|
|
2782
2784
|
background: "none",
|
|
@@ -2790,30 +2792,30 @@ function Zt({
|
|
|
2790
2792
|
}
|
|
2791
2793
|
) })
|
|
2792
2794
|
] }),
|
|
2793
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !
|
|
2794
|
-
|
|
2795
|
-
|
|
2795
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !k || R || u, style: H(), children: R ? T.loadingText : T.submitButton }),
|
|
2796
|
+
z && /* @__PURE__ */ n("div", { style: h.errorText, children: z }),
|
|
2797
|
+
p && /* @__PURE__ */ n("div", { style: h.successText, children: p })
|
|
2796
2798
|
] }),
|
|
2797
2799
|
a && /* @__PURE__ */ l("div", { style: h.linkContainer, children: [
|
|
2798
2800
|
/* @__PURE__ */ l("div", { children: [
|
|
2799
2801
|
/* @__PURE__ */ l("span", { style: h.divider, children: [
|
|
2800
|
-
|
|
2802
|
+
T.loginText,
|
|
2801
2803
|
" "
|
|
2802
2804
|
] }),
|
|
2803
|
-
/* @__PURE__ */ n("a", { onClick: s, style: h.link, children:
|
|
2805
|
+
/* @__PURE__ */ n("a", { onClick: s, style: h.link, children: T.loginLink })
|
|
2804
2806
|
] }),
|
|
2805
2807
|
/* @__PURE__ */ n("div", { style: h.divider, children: "•" }),
|
|
2806
2808
|
/* @__PURE__ */ l("div", { children: [
|
|
2807
2809
|
/* @__PURE__ */ l("span", { style: h.divider, children: [
|
|
2808
|
-
|
|
2810
|
+
T.signupText,
|
|
2809
2811
|
" "
|
|
2810
2812
|
] }),
|
|
2811
|
-
/* @__PURE__ */ n("a", { onClick: o, style: h.link, children:
|
|
2813
|
+
/* @__PURE__ */ n("a", { onClick: o, style: h.link, children: T.signupLink })
|
|
2812
2814
|
] })
|
|
2813
2815
|
] })
|
|
2814
2816
|
] });
|
|
2815
2817
|
}
|
|
2816
|
-
const
|
|
2818
|
+
const At = {
|
|
2817
2819
|
title: "Verifying Magic Link",
|
|
2818
2820
|
verifyingMessage: "Please wait while we verify your magic link...",
|
|
2819
2821
|
successMessage: "Magic link verified successfully! You are now logged in.",
|
|
@@ -2908,7 +2910,7 @@ const kt = {
|
|
|
2908
2910
|
cursor: "pointer",
|
|
2909
2911
|
transition: "all 0.15s ease-in-out"
|
|
2910
2912
|
}
|
|
2911
|
-
},
|
|
2913
|
+
}, Tt = () => /* @__PURE__ */ n("div", { style: $e.spinner }), Pt = () => /* @__PURE__ */ l(
|
|
2912
2914
|
"svg",
|
|
2913
2915
|
{
|
|
2914
2916
|
width: "48",
|
|
@@ -2925,7 +2927,7 @@ const kt = {
|
|
|
2925
2927
|
/* @__PURE__ */ n("polyline", { points: "22,4 12,14.01 9,11.01" })
|
|
2926
2928
|
]
|
|
2927
2929
|
}
|
|
2928
|
-
),
|
|
2930
|
+
), Mt = () => /* @__PURE__ */ l(
|
|
2929
2931
|
"svg",
|
|
2930
2932
|
{
|
|
2931
2933
|
width: "48",
|
|
@@ -2943,12 +2945,12 @@ const kt = {
|
|
|
2943
2945
|
/* @__PURE__ */ n("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
|
|
2944
2946
|
]
|
|
2945
2947
|
}
|
|
2946
|
-
),
|
|
2947
|
-
loading: /* @__PURE__ */ n(
|
|
2948
|
-
success: /* @__PURE__ */ n(
|
|
2949
|
-
error: /* @__PURE__ */ n(
|
|
2948
|
+
), It = {
|
|
2949
|
+
loading: /* @__PURE__ */ n(Tt, {}),
|
|
2950
|
+
success: /* @__PURE__ */ n(Pt, {}),
|
|
2951
|
+
error: /* @__PURE__ */ n(Mt, {})
|
|
2950
2952
|
};
|
|
2951
|
-
function
|
|
2953
|
+
function rr({
|
|
2952
2954
|
copy: i = {},
|
|
2953
2955
|
styles: e = {},
|
|
2954
2956
|
icons: t = {},
|
|
@@ -2956,80 +2958,80 @@ function er({
|
|
|
2956
2958
|
onError: s,
|
|
2957
2959
|
onRetry: o,
|
|
2958
2960
|
onBackToLogin: a,
|
|
2959
|
-
className:
|
|
2961
|
+
className: g,
|
|
2960
2962
|
token: w,
|
|
2961
|
-
email:
|
|
2962
|
-
appId:
|
|
2963
|
+
email: m,
|
|
2964
|
+
appId: k,
|
|
2963
2965
|
tenantSlug: b,
|
|
2964
2966
|
autoRedirectDelay: f = 3e3
|
|
2965
2967
|
}) {
|
|
2966
|
-
const [A, L] =
|
|
2968
|
+
const [A, L] = S("verifying"), [D, R] = S(""), { verifyMagicLink: P } = oe(), u = { ...At, ...i }, N = { ...$e, ...e }, z = { ...It, ...t }, E = () => {
|
|
2967
2969
|
if (typeof window > "u") return {};
|
|
2968
|
-
const
|
|
2970
|
+
const x = new URLSearchParams(window.location.search);
|
|
2969
2971
|
return {
|
|
2970
|
-
token: w ||
|
|
2971
|
-
email:
|
|
2972
|
-
appId:
|
|
2973
|
-
tenantSlug: b ||
|
|
2972
|
+
token: w || x.get("token") || "",
|
|
2973
|
+
email: m || x.get("email") || "",
|
|
2974
|
+
appId: k || x.get("appId") || "",
|
|
2975
|
+
tenantSlug: b || x.get("tenantSlug") || void 0
|
|
2974
2976
|
};
|
|
2975
|
-
},
|
|
2976
|
-
L("verifying"),
|
|
2977
|
+
}, p = async () => {
|
|
2978
|
+
L("verifying"), R("");
|
|
2977
2979
|
try {
|
|
2978
|
-
const
|
|
2979
|
-
if (!
|
|
2980
|
+
const x = E();
|
|
2981
|
+
if (!x.token || !x.email)
|
|
2980
2982
|
throw new Error("Missing required parameters: token or email");
|
|
2981
|
-
const
|
|
2982
|
-
token:
|
|
2983
|
-
email:
|
|
2984
|
-
tenantSlug:
|
|
2983
|
+
const M = await P({
|
|
2984
|
+
token: x.token,
|
|
2985
|
+
email: x.email,
|
|
2986
|
+
tenantSlug: x.tenantSlug
|
|
2985
2987
|
});
|
|
2986
|
-
L("success"), r == null || r(
|
|
2988
|
+
L("success"), r == null || r(M), f > 0 && setTimeout(() => {
|
|
2987
2989
|
L("redirecting");
|
|
2988
2990
|
}, f);
|
|
2989
|
-
} catch (
|
|
2990
|
-
const
|
|
2991
|
-
|
|
2991
|
+
} catch (x) {
|
|
2992
|
+
const M = x.message || u.errorMessage;
|
|
2993
|
+
R(M), L("error"), s == null || s(M);
|
|
2992
2994
|
}
|
|
2993
|
-
},
|
|
2994
|
-
o == null || o(),
|
|
2995
|
-
},
|
|
2995
|
+
}, O = () => {
|
|
2996
|
+
o == null || o(), p();
|
|
2997
|
+
}, v = () => {
|
|
2996
2998
|
a == null || a();
|
|
2997
2999
|
};
|
|
2998
3000
|
te(() => {
|
|
2999
|
-
|
|
3001
|
+
p();
|
|
3000
3002
|
}, []);
|
|
3001
|
-
const
|
|
3003
|
+
const C = () => {
|
|
3002
3004
|
switch (A) {
|
|
3003
3005
|
case "verifying":
|
|
3004
|
-
return /* @__PURE__ */ l("div", { style:
|
|
3005
|
-
|
|
3006
|
+
return /* @__PURE__ */ l("div", { style: N.message, children: [
|
|
3007
|
+
z.loading,
|
|
3006
3008
|
u.verifyingMessage
|
|
3007
3009
|
] });
|
|
3008
3010
|
case "success":
|
|
3009
|
-
return /* @__PURE__ */ l(
|
|
3010
|
-
|
|
3011
|
-
/* @__PURE__ */ n("div", { style:
|
|
3011
|
+
return /* @__PURE__ */ l(j, { children: [
|
|
3012
|
+
z.success,
|
|
3013
|
+
/* @__PURE__ */ n("div", { style: N.successMessage, children: u.successMessage })
|
|
3012
3014
|
] });
|
|
3013
3015
|
case "redirecting":
|
|
3014
|
-
return /* @__PURE__ */ l(
|
|
3015
|
-
|
|
3016
|
-
/* @__PURE__ */ n("div", { style:
|
|
3016
|
+
return /* @__PURE__ */ l(j, { children: [
|
|
3017
|
+
z.loading,
|
|
3018
|
+
/* @__PURE__ */ n("div", { style: N.message, children: u.redirectingMessage })
|
|
3017
3019
|
] });
|
|
3018
3020
|
case "error":
|
|
3019
|
-
return /* @__PURE__ */ l(
|
|
3020
|
-
|
|
3021
|
-
/* @__PURE__ */ n("div", { style:
|
|
3022
|
-
/* @__PURE__ */ l("div", { style:
|
|
3021
|
+
return /* @__PURE__ */ l(j, { children: [
|
|
3022
|
+
z.error,
|
|
3023
|
+
/* @__PURE__ */ n("div", { style: N.errorMessage, children: D || u.errorMessage }),
|
|
3024
|
+
/* @__PURE__ */ l("div", { style: N.buttonContainer, children: [
|
|
3023
3025
|
/* @__PURE__ */ n(
|
|
3024
3026
|
"button",
|
|
3025
3027
|
{
|
|
3026
|
-
onClick:
|
|
3027
|
-
style:
|
|
3028
|
-
onMouseOver: (
|
|
3029
|
-
|
|
3028
|
+
onClick: O,
|
|
3029
|
+
style: N.retryButton,
|
|
3030
|
+
onMouseOver: (x) => {
|
|
3031
|
+
x.currentTarget.style.backgroundColor = "#2563eb";
|
|
3030
3032
|
},
|
|
3031
|
-
onMouseOut: (
|
|
3032
|
-
|
|
3033
|
+
onMouseOut: (x) => {
|
|
3034
|
+
x.currentTarget.style.backgroundColor = "#3b82f6";
|
|
3033
3035
|
},
|
|
3034
3036
|
children: u.retryButton
|
|
3035
3037
|
}
|
|
@@ -3037,13 +3039,13 @@ function er({
|
|
|
3037
3039
|
/* @__PURE__ */ n(
|
|
3038
3040
|
"button",
|
|
3039
3041
|
{
|
|
3040
|
-
onClick:
|
|
3041
|
-
style:
|
|
3042
|
-
onMouseOver: (
|
|
3043
|
-
|
|
3042
|
+
onClick: v,
|
|
3043
|
+
style: N.backButton,
|
|
3044
|
+
onMouseOver: (x) => {
|
|
3045
|
+
x.currentTarget.style.backgroundColor = "#e5e7eb";
|
|
3044
3046
|
},
|
|
3045
|
-
onMouseOut: (
|
|
3046
|
-
|
|
3047
|
+
onMouseOut: (x) => {
|
|
3048
|
+
x.currentTarget.style.backgroundColor = "#f3f4f6";
|
|
3047
3049
|
},
|
|
3048
3050
|
children: u.backToLoginButton
|
|
3049
3051
|
}
|
|
@@ -3054,18 +3056,18 @@ function er({
|
|
|
3054
3056
|
return null;
|
|
3055
3057
|
}
|
|
3056
3058
|
};
|
|
3057
|
-
return /* @__PURE__ */ l("div", { style:
|
|
3059
|
+
return /* @__PURE__ */ l("div", { style: N.container, className: g, children: [
|
|
3058
3060
|
/* @__PURE__ */ n("style", { children: `
|
|
3059
3061
|
@keyframes spin {
|
|
3060
3062
|
0% { transform: rotate(0deg); }
|
|
3061
3063
|
100% { transform: rotate(360deg); }
|
|
3062
3064
|
}
|
|
3063
3065
|
` }),
|
|
3064
|
-
/* @__PURE__ */ n("h1", { style:
|
|
3065
|
-
|
|
3066
|
+
/* @__PURE__ */ n("h1", { style: N.title, children: u.title }),
|
|
3067
|
+
C()
|
|
3066
3068
|
] });
|
|
3067
3069
|
}
|
|
3068
|
-
const
|
|
3070
|
+
const Rt = {
|
|
3069
3071
|
title: "Reset Password",
|
|
3070
3072
|
subtitle: "Enter your email address and we'll send you a link to reset your password.",
|
|
3071
3073
|
emailLabel: "Email",
|
|
@@ -3087,7 +3089,7 @@ const Mt = {
|
|
|
3087
3089
|
resetLoadingText: "Resetting...",
|
|
3088
3090
|
resetSuccessMessage: "Password reset successfully!",
|
|
3089
3091
|
passwordMismatchError: "Passwords do not match"
|
|
3090
|
-
},
|
|
3092
|
+
}, Lt = {
|
|
3091
3093
|
container: {
|
|
3092
3094
|
maxWidth: "400px",
|
|
3093
3095
|
margin: "0 auto",
|
|
@@ -3179,7 +3181,7 @@ const Mt = {
|
|
|
3179
3181
|
cursor: "pointer"
|
|
3180
3182
|
}
|
|
3181
3183
|
};
|
|
3182
|
-
function
|
|
3184
|
+
function nr({
|
|
3183
3185
|
copy: i = {},
|
|
3184
3186
|
styles: e = {},
|
|
3185
3187
|
mode: t = "request",
|
|
@@ -3187,105 +3189,105 @@ function tr({
|
|
|
3187
3189
|
onSuccess: s,
|
|
3188
3190
|
onError: o,
|
|
3189
3191
|
onBackToLogin: a,
|
|
3190
|
-
onModeChange:
|
|
3192
|
+
onModeChange: g,
|
|
3191
3193
|
className: w
|
|
3192
3194
|
}) {
|
|
3193
|
-
const [
|
|
3194
|
-
const
|
|
3195
|
-
return
|
|
3196
|
-
},
|
|
3197
|
-
const
|
|
3198
|
-
return b.trim() || (
|
|
3199
|
-
}, h = async (
|
|
3200
|
-
if (
|
|
3201
|
-
if (!(
|
|
3202
|
-
|
|
3195
|
+
const [m, k] = S(""), [b, f] = S(r), [A, L] = S(""), [D, R] = S(""), [P, u] = S(!1), [N, z] = S(""), [E, p] = S(""), [O, v] = S({}), { requestPasswordReset: C, confirmPasswordReset: x } = oe(), { tenant: M } = le(), F = { ...Rt, ...i }, c = { ...Lt, ...e }, I = () => {
|
|
3196
|
+
const H = {};
|
|
3197
|
+
return m.trim() || (H.email = !0), v(H), Object.keys(H).length === 0;
|
|
3198
|
+
}, T = () => {
|
|
3199
|
+
const H = {};
|
|
3200
|
+
return b.trim() || (H.token = !0), A.trim() || (H.newPassword = !0), D.trim() || (H.confirmPassword = !0), v(H), Object.keys(H).length === 0;
|
|
3201
|
+
}, h = async (H) => {
|
|
3202
|
+
if (H.preventDefault(), !!I()) {
|
|
3203
|
+
if (!(M != null && M.id)) {
|
|
3204
|
+
z("Tenant not found");
|
|
3203
3205
|
return;
|
|
3204
3206
|
}
|
|
3205
|
-
u(!0),
|
|
3207
|
+
u(!0), z(""), p("");
|
|
3206
3208
|
try {
|
|
3207
|
-
await
|
|
3208
|
-
} catch (
|
|
3209
|
-
const V =
|
|
3210
|
-
|
|
3209
|
+
await C({ email: m, tenantId: M.id }), p(F.successMessage), s == null || s();
|
|
3210
|
+
} catch (U) {
|
|
3211
|
+
const V = U.message || F.errorMessage;
|
|
3212
|
+
z(V), o == null || o(V);
|
|
3211
3213
|
} finally {
|
|
3212
3214
|
u(!1);
|
|
3213
3215
|
}
|
|
3214
3216
|
}
|
|
3215
|
-
},
|
|
3216
|
-
if (
|
|
3217
|
+
}, d = async (H) => {
|
|
3218
|
+
if (H.preventDefault(), !!T()) {
|
|
3217
3219
|
if (A !== D) {
|
|
3218
|
-
|
|
3220
|
+
z(F.passwordMismatchError), v({ confirmPassword: !0 });
|
|
3219
3221
|
return;
|
|
3220
3222
|
}
|
|
3221
|
-
u(!0),
|
|
3223
|
+
u(!0), z(""), p("");
|
|
3222
3224
|
try {
|
|
3223
|
-
await
|
|
3224
|
-
} catch (
|
|
3225
|
-
const V =
|
|
3226
|
-
|
|
3225
|
+
await x({ token: b, newPassword: A }), p(F.resetSuccessMessage), s == null || s();
|
|
3226
|
+
} catch (U) {
|
|
3227
|
+
const V = U.message || F.errorMessage;
|
|
3228
|
+
z(V), o == null || o(V);
|
|
3227
3229
|
} finally {
|
|
3228
3230
|
u(!1);
|
|
3229
3231
|
}
|
|
3230
3232
|
}
|
|
3231
|
-
},
|
|
3232
|
-
...
|
|
3233
|
-
...
|
|
3234
|
-
}),
|
|
3235
|
-
...
|
|
3236
|
-
...
|
|
3233
|
+
}, y = (H) => ({
|
|
3234
|
+
...c.input,
|
|
3235
|
+
...O[H] ? c.inputError : {}
|
|
3236
|
+
}), G = () => ({
|
|
3237
|
+
...c.button,
|
|
3238
|
+
...P ? c.buttonLoading : {}
|
|
3237
3239
|
});
|
|
3238
3240
|
if (t === "reset") {
|
|
3239
|
-
const
|
|
3240
|
-
return /* @__PURE__ */ l("div", { className: w, style:
|
|
3241
|
-
/* @__PURE__ */ n("h2", { style:
|
|
3242
|
-
/* @__PURE__ */ n("p", { style:
|
|
3243
|
-
/* @__PURE__ */ l("form", { onSubmit:
|
|
3244
|
-
/* @__PURE__ */ l("div", { style:
|
|
3245
|
-
/* @__PURE__ */ n("label", { style:
|
|
3241
|
+
const H = b && A && D;
|
|
3242
|
+
return /* @__PURE__ */ l("div", { className: w, style: c.container, children: [
|
|
3243
|
+
/* @__PURE__ */ n("h2", { style: c.title, children: F.resetTitle }),
|
|
3244
|
+
/* @__PURE__ */ n("p", { style: c.subtitle, children: F.resetSubtitle }),
|
|
3245
|
+
/* @__PURE__ */ l("form", { onSubmit: d, style: c.form, children: [
|
|
3246
|
+
/* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
|
|
3247
|
+
/* @__PURE__ */ n("label", { style: c.label, children: F.tokenLabel }),
|
|
3246
3248
|
/* @__PURE__ */ n(
|
|
3247
3249
|
"input",
|
|
3248
3250
|
{
|
|
3249
3251
|
type: "text",
|
|
3250
3252
|
value: b,
|
|
3251
|
-
onChange: (
|
|
3252
|
-
f(
|
|
3253
|
+
onChange: (U) => {
|
|
3254
|
+
f(U.target.value), O.token && v((V) => ({ ...V, token: !1 }));
|
|
3253
3255
|
},
|
|
3254
|
-
placeholder:
|
|
3255
|
-
style:
|
|
3256
|
-
disabled:
|
|
3256
|
+
placeholder: F.tokenPlaceholder,
|
|
3257
|
+
style: y("token"),
|
|
3258
|
+
disabled: P
|
|
3257
3259
|
}
|
|
3258
3260
|
)
|
|
3259
3261
|
] }),
|
|
3260
|
-
/* @__PURE__ */ l("div", { style:
|
|
3261
|
-
/* @__PURE__ */ n("label", { style:
|
|
3262
|
+
/* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
|
|
3263
|
+
/* @__PURE__ */ n("label", { style: c.label, children: F.newPasswordLabel }),
|
|
3262
3264
|
/* @__PURE__ */ n(
|
|
3263
3265
|
"input",
|
|
3264
3266
|
{
|
|
3265
3267
|
type: "password",
|
|
3266
3268
|
value: A,
|
|
3267
|
-
onChange: (
|
|
3268
|
-
L(
|
|
3269
|
+
onChange: (U) => {
|
|
3270
|
+
L(U.target.value), O.newPassword && v((V) => ({ ...V, newPassword: !1 }));
|
|
3269
3271
|
},
|
|
3270
|
-
placeholder:
|
|
3271
|
-
style:
|
|
3272
|
-
disabled:
|
|
3272
|
+
placeholder: F.newPasswordPlaceholder,
|
|
3273
|
+
style: y("newPassword"),
|
|
3274
|
+
disabled: P
|
|
3273
3275
|
}
|
|
3274
3276
|
)
|
|
3275
3277
|
] }),
|
|
3276
|
-
/* @__PURE__ */ l("div", { style:
|
|
3277
|
-
/* @__PURE__ */ n("label", { style:
|
|
3278
|
+
/* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
|
|
3279
|
+
/* @__PURE__ */ n("label", { style: c.label, children: F.confirmPasswordLabel }),
|
|
3278
3280
|
/* @__PURE__ */ n(
|
|
3279
3281
|
"input",
|
|
3280
3282
|
{
|
|
3281
3283
|
type: "password",
|
|
3282
3284
|
value: D,
|
|
3283
|
-
onChange: (
|
|
3284
|
-
|
|
3285
|
+
onChange: (U) => {
|
|
3286
|
+
R(U.target.value), O.confirmPassword && v((V) => ({ ...V, confirmPassword: !1 })), N === F.passwordMismatchError && z("");
|
|
3285
3287
|
},
|
|
3286
|
-
placeholder:
|
|
3287
|
-
style:
|
|
3288
|
-
disabled:
|
|
3288
|
+
placeholder: F.confirmPasswordPlaceholder,
|
|
3289
|
+
style: y("confirmPassword"),
|
|
3290
|
+
disabled: P
|
|
3289
3291
|
}
|
|
3290
3292
|
)
|
|
3291
3293
|
] }),
|
|
@@ -3293,44 +3295,44 @@ function tr({
|
|
|
3293
3295
|
"button",
|
|
3294
3296
|
{
|
|
3295
3297
|
type: "submit",
|
|
3296
|
-
disabled: !
|
|
3298
|
+
disabled: !H || P,
|
|
3297
3299
|
style: {
|
|
3298
|
-
...
|
|
3299
|
-
...!
|
|
3300
|
+
...G(),
|
|
3301
|
+
...!H || P ? c.buttonDisabled : {}
|
|
3300
3302
|
},
|
|
3301
|
-
children:
|
|
3303
|
+
children: P ? F.resetLoadingText : F.resetSubmitButton
|
|
3302
3304
|
}
|
|
3303
3305
|
),
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
+
N && /* @__PURE__ */ n("div", { style: c.errorText, children: N }),
|
|
3307
|
+
E && /* @__PURE__ */ n("div", { style: c.successText, children: E })
|
|
3306
3308
|
] }),
|
|
3307
|
-
/* @__PURE__ */ l("div", { style:
|
|
3308
|
-
/* @__PURE__ */ n("a", { onClick: a, style:
|
|
3309
|
-
|
|
3309
|
+
/* @__PURE__ */ l("div", { style: c.linkContainer, children: [
|
|
3310
|
+
/* @__PURE__ */ n("a", { onClick: a, style: c.link, children: F.backToLoginLink }),
|
|
3311
|
+
g && /* @__PURE__ */ l(j, { children: [
|
|
3310
3312
|
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3311
|
-
/* @__PURE__ */ n("a", { onClick: () =>
|
|
3313
|
+
/* @__PURE__ */ n("a", { onClick: () => g("request"), style: c.link, children: "Request New Link" })
|
|
3312
3314
|
] })
|
|
3313
3315
|
] })
|
|
3314
3316
|
] });
|
|
3315
3317
|
}
|
|
3316
|
-
const
|
|
3317
|
-
return /* @__PURE__ */ l("div", { className: w, style:
|
|
3318
|
-
/* @__PURE__ */ n("h2", { style:
|
|
3319
|
-
/* @__PURE__ */ n("p", { style:
|
|
3320
|
-
/* @__PURE__ */ l("form", { onSubmit: h, style:
|
|
3321
|
-
/* @__PURE__ */ l("div", { style:
|
|
3322
|
-
/* @__PURE__ */ n("label", { style:
|
|
3318
|
+
const $ = m;
|
|
3319
|
+
return /* @__PURE__ */ l("div", { className: w, style: c.container, children: [
|
|
3320
|
+
/* @__PURE__ */ n("h2", { style: c.title, children: F.title }),
|
|
3321
|
+
/* @__PURE__ */ n("p", { style: c.subtitle, children: F.subtitle }),
|
|
3322
|
+
/* @__PURE__ */ l("form", { onSubmit: h, style: c.form, children: [
|
|
3323
|
+
/* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
|
|
3324
|
+
/* @__PURE__ */ n("label", { style: c.label, children: F.emailLabel }),
|
|
3323
3325
|
/* @__PURE__ */ n(
|
|
3324
3326
|
"input",
|
|
3325
3327
|
{
|
|
3326
3328
|
type: "email",
|
|
3327
|
-
value:
|
|
3328
|
-
onChange: (
|
|
3329
|
-
|
|
3329
|
+
value: m,
|
|
3330
|
+
onChange: (H) => {
|
|
3331
|
+
k(H.target.value), O.email && v((U) => ({ ...U, email: !1 }));
|
|
3330
3332
|
},
|
|
3331
|
-
placeholder:
|
|
3332
|
-
style:
|
|
3333
|
-
disabled:
|
|
3333
|
+
placeholder: F.emailPlaceholder,
|
|
3334
|
+
style: y("email"),
|
|
3335
|
+
disabled: P
|
|
3334
3336
|
}
|
|
3335
3337
|
)
|
|
3336
3338
|
] }),
|
|
@@ -3338,27 +3340,27 @@ function tr({
|
|
|
3338
3340
|
"button",
|
|
3339
3341
|
{
|
|
3340
3342
|
type: "submit",
|
|
3341
|
-
disabled:
|
|
3343
|
+
disabled: !$ || P,
|
|
3342
3344
|
style: {
|
|
3343
|
-
...
|
|
3344
|
-
|
|
3345
|
+
...G(),
|
|
3346
|
+
...!$ || P ? c.buttonDisabled : {}
|
|
3345
3347
|
},
|
|
3346
|
-
children:
|
|
3348
|
+
children: P ? F.loadingText : F.submitButton
|
|
3347
3349
|
}
|
|
3348
3350
|
),
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
+
N && /* @__PURE__ */ n("div", { style: c.errorText, children: N }),
|
|
3352
|
+
E && /* @__PURE__ */ n("div", { style: c.successText, children: E })
|
|
3351
3353
|
] }),
|
|
3352
|
-
/* @__PURE__ */ l("div", { style:
|
|
3353
|
-
/* @__PURE__ */ n("a", { onClick: a, style:
|
|
3354
|
-
|
|
3354
|
+
/* @__PURE__ */ l("div", { style: c.linkContainer, children: [
|
|
3355
|
+
/* @__PURE__ */ n("a", { onClick: a, style: c.link, children: F.backToLoginLink }),
|
|
3356
|
+
g && /* @__PURE__ */ l(j, { children: [
|
|
3355
3357
|
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3356
|
-
/* @__PURE__ */ n("a", { onClick: () =>
|
|
3358
|
+
/* @__PURE__ */ n("a", { onClick: () => g("reset"), style: c.link, children: "I have a token" })
|
|
3357
3359
|
] })
|
|
3358
3360
|
] })
|
|
3359
3361
|
] });
|
|
3360
3362
|
}
|
|
3361
|
-
const
|
|
3363
|
+
const Et = () => /* @__PURE__ */ n(
|
|
3362
3364
|
"div",
|
|
3363
3365
|
{
|
|
3364
3366
|
style: {
|
|
@@ -3370,7 +3372,7 @@ const Rt = () => /* @__PURE__ */ n(
|
|
|
3370
3372
|
},
|
|
3371
3373
|
children: /* @__PURE__ */ n("div", { children: "Loading..." })
|
|
3372
3374
|
}
|
|
3373
|
-
),
|
|
3375
|
+
), Ft = ({ error: i, retry: e }) => /* @__PURE__ */ l(
|
|
3374
3376
|
"div",
|
|
3375
3377
|
{
|
|
3376
3378
|
style: {
|
|
@@ -3404,43 +3406,43 @@ const Rt = () => /* @__PURE__ */ n(
|
|
|
3404
3406
|
]
|
|
3405
3407
|
}
|
|
3406
3408
|
);
|
|
3407
|
-
function
|
|
3409
|
+
function sr({
|
|
3408
3410
|
children: i,
|
|
3409
3411
|
loadingFallback: e,
|
|
3410
3412
|
errorFallback: t,
|
|
3411
3413
|
requireTenant: r = !0
|
|
3412
3414
|
}) {
|
|
3413
|
-
const { isAppLoading: s, appError: o, retryApp: a } = he(),
|
|
3414
|
-
}), D = (w == null ? void 0 : w.isAuthReady) ?? !0,
|
|
3415
|
-
o && a(), f &&
|
|
3415
|
+
const { isAppLoading: s, appError: o, retryApp: a } = he(), g = ye(), w = Fe(), m = Ce(), k = De(), b = (g == null ? void 0 : g.isTenantLoading) ?? !1, f = (g == null ? void 0 : g.tenantError) ?? null, A = (g == null ? void 0 : g.tenantSlug) ?? null, L = (g == null ? void 0 : g.retryTenant) ?? (() => {
|
|
3416
|
+
}), D = (w == null ? void 0 : w.isAuthReady) ?? !0, R = (m == null ? void 0 : m.isReady) ?? !0, P = (k == null ? void 0 : k.isReady) ?? !0, u = r && g && A, p = s || u && b || w && !D || m && !R || k && !P, O = o || (u ? f : null), v = () => {
|
|
3417
|
+
o && a(), f && g && L();
|
|
3416
3418
|
};
|
|
3417
|
-
if (
|
|
3418
|
-
return /* @__PURE__ */ n(
|
|
3419
|
-
if (
|
|
3420
|
-
const
|
|
3421
|
-
return /* @__PURE__ */ n(
|
|
3419
|
+
if (p)
|
|
3420
|
+
return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(Et, {}) });
|
|
3421
|
+
if (O) {
|
|
3422
|
+
const C = typeof t == "function" ? t(O, v) : t || /* @__PURE__ */ n(Ft, { error: O, retry: v });
|
|
3423
|
+
return /* @__PURE__ */ n(j, { children: C });
|
|
3422
3424
|
}
|
|
3423
|
-
return /* @__PURE__ */ n(
|
|
3425
|
+
return /* @__PURE__ */ n(j, { children: i });
|
|
3424
3426
|
}
|
|
3425
|
-
function
|
|
3426
|
-
const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = he(), o = ye(), a = Fe(),
|
|
3427
|
-
}), L = (a == null ? void 0 : a.isAuthReady) ?? !0, D = (
|
|
3427
|
+
function ir(i = !0) {
|
|
3428
|
+
const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = he(), o = ye(), a = Fe(), g = Ce(), w = De(), 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) ?? (() => {
|
|
3429
|
+
}), L = (a == null ? void 0 : a.isAuthReady) ?? !0, D = (g == null ? void 0 : g.isReady) ?? !0, R = (w == null ? void 0 : w.isReady) ?? !0, P = i && o && f, E = e || P && m || a && !L || g && !D || w && !R, p = t || (P ? k : null);
|
|
3428
3430
|
return {
|
|
3429
|
-
isLoading:
|
|
3430
|
-
error:
|
|
3431
|
-
isReady: !
|
|
3431
|
+
isLoading: E,
|
|
3432
|
+
error: p,
|
|
3433
|
+
isReady: !E && !p && s !== null && (!P || b !== null),
|
|
3432
3434
|
retry: () => {
|
|
3433
|
-
t && r(),
|
|
3435
|
+
t && r(), k && o && A();
|
|
3434
3436
|
},
|
|
3435
3437
|
// Individual states
|
|
3436
3438
|
app: { isLoading: e, error: t, data: s },
|
|
3437
|
-
tenant: o ? { isLoading:
|
|
3439
|
+
tenant: o ? { isLoading: m, error: k, data: b } : null,
|
|
3438
3440
|
auth: a ? { isReady: L } : null,
|
|
3439
|
-
featureFlags:
|
|
3440
|
-
subscription: w ? { isReady:
|
|
3441
|
+
featureFlags: g ? { isReady: D } : null,
|
|
3442
|
+
subscription: w ? { isReady: R } : null
|
|
3441
3443
|
};
|
|
3442
3444
|
}
|
|
3443
|
-
class
|
|
3445
|
+
class or {
|
|
3444
3446
|
constructor(e, t) {
|
|
3445
3447
|
this.httpService = e, this.sessionManager = t;
|
|
3446
3448
|
}
|
|
@@ -3508,7 +3510,7 @@ class sr {
|
|
|
3508
3510
|
};
|
|
3509
3511
|
}
|
|
3510
3512
|
}
|
|
3511
|
-
class
|
|
3513
|
+
class ar {
|
|
3512
3514
|
constructor(e, t) {
|
|
3513
3515
|
this.httpService = e, this.sessionManager = t;
|
|
3514
3516
|
}
|
|
@@ -3559,7 +3561,7 @@ class ir {
|
|
|
3559
3561
|
});
|
|
3560
3562
|
}
|
|
3561
3563
|
}
|
|
3562
|
-
class
|
|
3564
|
+
class lr {
|
|
3563
3565
|
constructor(e) {
|
|
3564
3566
|
this.httpService = e;
|
|
3565
3567
|
}
|
|
@@ -3568,7 +3570,7 @@ class or {
|
|
|
3568
3570
|
return await this.httpService.get("/health");
|
|
3569
3571
|
}
|
|
3570
3572
|
}
|
|
3571
|
-
class
|
|
3573
|
+
class cr {
|
|
3572
3574
|
// Date string to Date object
|
|
3573
3575
|
static toDate(e) {
|
|
3574
3576
|
return new Date(e);
|
|
@@ -3691,47 +3693,47 @@ class ar {
|
|
|
3691
3693
|
}
|
|
3692
3694
|
}
|
|
3693
3695
|
export {
|
|
3694
|
-
|
|
3696
|
+
cr as ApiMappers,
|
|
3695
3697
|
Pe as AppApiService,
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3698
|
+
sr as AppLoader,
|
|
3699
|
+
Bt as AppProvider,
|
|
3700
|
+
Ke as AuthApiService,
|
|
3701
|
+
jt as AuthProvider,
|
|
3702
|
+
Xt as FeatureFlag,
|
|
3703
|
+
st as FeatureFlagApiService,
|
|
3704
|
+
Vt as FeatureFlagProvider,
|
|
3705
|
+
lr as HealthApiService,
|
|
3704
3706
|
re as HttpService,
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3707
|
+
Yt as LandingRoute,
|
|
3708
|
+
Zt as LoginForm,
|
|
3709
|
+
tr as MagicLinkForm,
|
|
3710
|
+
rr as MagicLinkVerify,
|
|
3711
|
+
nr as PasswordRecoveryForm,
|
|
3712
|
+
or as PermissionApiService,
|
|
3713
|
+
Gt as Protected,
|
|
3714
|
+
Kt as ProtectedRoute,
|
|
3713
3715
|
Me as RoleApiService,
|
|
3714
3716
|
be as SessionManager,
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3717
|
+
er as SignupForm,
|
|
3718
|
+
ot as SubscriptionApiService,
|
|
3719
|
+
Qt as SubscriptionGuard,
|
|
3720
|
+
ar as SubscriptionPlanApiService,
|
|
3721
|
+
_t as SubscriptionProvider,
|
|
3720
3722
|
de as TenantApiService,
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3723
|
+
zt as TenantProvider,
|
|
3724
|
+
Jt as TenantRoute,
|
|
3725
|
+
Je as UserApiService,
|
|
3724
3726
|
ie as UserType,
|
|
3725
|
-
|
|
3727
|
+
qt as useApi,
|
|
3726
3728
|
he as useApp,
|
|
3727
|
-
|
|
3729
|
+
ir as useAppLoaderState,
|
|
3728
3730
|
oe as useAuth,
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3731
|
+
it as useFeatureFlags,
|
|
3732
|
+
Wt as useSettings,
|
|
3733
|
+
at as useSubscription,
|
|
3732
3734
|
me as useTenant,
|
|
3733
3735
|
le as useTenantInfo,
|
|
3734
3736
|
ye as useTenantOptional,
|
|
3735
|
-
|
|
3737
|
+
Ot as useTenantSettings
|
|
3736
3738
|
};
|
|
3737
3739
|
//# sourceMappingURL=index.es.js.map
|