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