@skylabs-digital/react-identity-access 2.3.0 → 2.4.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 +885 -843
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/providers/AuthProvider.d.ts.map +1 -1
- package/dist/utils/crossDomainAuth.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 he, useMemo as X, useState as
|
|
1
|
+
import { jsx as n, Fragment as B, jsxs as c } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as he, useMemo as X, useState as v, useCallback as ne, useEffect as te, useContext as ce, useRef as qe } from "react";
|
|
3
3
|
import { useLocation as be, Navigate as pe } from "react-router-dom";
|
|
4
4
|
class re {
|
|
5
5
|
// SessionManager instance
|
|
@@ -16,27 +16,27 @@ 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
|
|
20
|
-
let
|
|
19
|
+
const g = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, w = (s == null ? void 0 : s.timeout) || this.timeout;
|
|
20
|
+
let x = {
|
|
21
21
|
"Content-Type": "application/json",
|
|
22
22
|
...s == null ? void 0 : s.headers
|
|
23
23
|
};
|
|
24
24
|
if (!(s != null && s.skipAuth) && this.sessionManager)
|
|
25
25
|
try {
|
|
26
26
|
const m = await this.sessionManager.getAuthHeaders();
|
|
27
|
-
|
|
27
|
+
x = { ...x, ...m };
|
|
28
28
|
} catch (m) {
|
|
29
29
|
console.warn("Failed to inject auth headers:", m);
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const b = new AbortController(), A = setTimeout(() => b.abort(), w);
|
|
32
32
|
try {
|
|
33
|
-
const m = await fetch(
|
|
33
|
+
const m = await fetch(g, {
|
|
34
34
|
method: e,
|
|
35
|
-
headers:
|
|
35
|
+
headers: x,
|
|
36
36
|
body: r ? JSON.stringify(r) : void 0,
|
|
37
|
-
signal:
|
|
37
|
+
signal: b.signal
|
|
38
38
|
});
|
|
39
|
-
if (clearTimeout(
|
|
39
|
+
if (clearTimeout(A), m.status === 401 && !(s != null && s.skipRetry) && !o && this.sessionManager)
|
|
40
40
|
try {
|
|
41
41
|
const u = this.sessionManager.getTokens();
|
|
42
42
|
if (u != null && u.refreshToken)
|
|
@@ -49,7 +49,7 @@ class re {
|
|
|
49
49
|
const f = m.headers.get("content-type");
|
|
50
50
|
return !f || !f.includes("application/json") ? {} : await m.json();
|
|
51
51
|
} catch (m) {
|
|
52
|
-
throw clearTimeout(
|
|
52
|
+
throw clearTimeout(A), m instanceof Error && m.name === "AbortError" ? new Error(`Request timeout after ${w}ms`) : m;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
async get(e, t) {
|
|
@@ -125,7 +125,7 @@ class ve {
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
const Pe = he(null);
|
|
128
|
-
function
|
|
128
|
+
function Ct({ config: i, children: e }) {
|
|
129
129
|
const t = X(
|
|
130
130
|
() => {
|
|
131
131
|
var f, u, y;
|
|
@@ -137,7 +137,7 @@ function Et({ config: i, children: e }) {
|
|
|
137
137
|
};
|
|
138
138
|
},
|
|
139
139
|
[i.cache, i.appId]
|
|
140
|
-
), [r, s] =
|
|
140
|
+
), [r, s] = v(() => {
|
|
141
141
|
if (!t.enabled) return null;
|
|
142
142
|
try {
|
|
143
143
|
const f = localStorage.getItem(t.storageKey);
|
|
@@ -147,9 +147,9 @@ function Et({ config: i, children: e }) {
|
|
|
147
147
|
} catch {
|
|
148
148
|
return null;
|
|
149
149
|
}
|
|
150
|
-
}), [o,
|
|
150
|
+
}), [o, g] = v(!r), [w, x] = v(null), b = X(() => {
|
|
151
151
|
const f = () => {
|
|
152
|
-
|
|
152
|
+
A();
|
|
153
153
|
};
|
|
154
154
|
return {
|
|
155
155
|
appId: i.appId,
|
|
@@ -157,19 +157,19 @@ function Et({ config: i, children: e }) {
|
|
|
157
157
|
// App info
|
|
158
158
|
appInfo: r,
|
|
159
159
|
isAppLoading: o,
|
|
160
|
-
appError:
|
|
160
|
+
appError: w,
|
|
161
161
|
retryApp: f
|
|
162
162
|
};
|
|
163
|
-
}, [i, r, o,
|
|
163
|
+
}, [i, r, o, w]), A = ne(
|
|
164
164
|
async (f = !1) => {
|
|
165
165
|
if (!(!f && t.enabled && r))
|
|
166
166
|
try {
|
|
167
|
-
|
|
168
|
-
const u = new re(i.baseUrl),
|
|
169
|
-
if (s(
|
|
167
|
+
g(!0), x(null);
|
|
168
|
+
const u = new re(i.baseUrl), E = await new ve(u, {}).getPublicAppInfo(i.appId);
|
|
169
|
+
if (s(E), t.enabled)
|
|
170
170
|
try {
|
|
171
171
|
const C = {
|
|
172
|
-
data:
|
|
172
|
+
data: E,
|
|
173
173
|
timestamp: Date.now(),
|
|
174
174
|
appId: i.appId
|
|
175
175
|
};
|
|
@@ -179,9 +179,9 @@ function Et({ config: i, children: e }) {
|
|
|
179
179
|
}
|
|
180
180
|
} catch (u) {
|
|
181
181
|
const y = u instanceof Error ? u : new Error("Failed to load app information");
|
|
182
|
-
|
|
182
|
+
x(y), s(null);
|
|
183
183
|
} finally {
|
|
184
|
-
|
|
184
|
+
g(!1);
|
|
185
185
|
}
|
|
186
186
|
},
|
|
187
187
|
[i.baseUrl, i.appId, t, r]
|
|
@@ -192,22 +192,22 @@ function Et({ config: i, children: e }) {
|
|
|
192
192
|
if (!f) return;
|
|
193
193
|
const u = JSON.parse(f);
|
|
194
194
|
if (Date.now() - u.timestamp > t.ttl * 0.5) {
|
|
195
|
-
const
|
|
195
|
+
const E = new re(i.baseUrl), q = await new ve(E, {}).getPublicAppInfo(i.appId);
|
|
196
196
|
s(q);
|
|
197
|
-
const
|
|
197
|
+
const T = {
|
|
198
198
|
data: q,
|
|
199
199
|
timestamp: Date.now(),
|
|
200
200
|
appId: i.appId
|
|
201
201
|
};
|
|
202
|
-
localStorage.setItem(t.storageKey, JSON.stringify(
|
|
202
|
+
localStorage.setItem(t.storageKey, JSON.stringify(T));
|
|
203
203
|
}
|
|
204
204
|
} catch (f) {
|
|
205
205
|
console.warn("Background app refresh failed:", f);
|
|
206
206
|
}
|
|
207
207
|
}, [i, t, r]);
|
|
208
208
|
return te(() => {
|
|
209
|
-
r ? m() :
|
|
210
|
-
}, []), /* @__PURE__ */ n(Pe.Provider, { value:
|
|
209
|
+
r ? m() : A();
|
|
210
|
+
}, []), /* @__PURE__ */ n(Pe.Provider, { value: b, children: e });
|
|
211
211
|
}
|
|
212
212
|
function oe() {
|
|
213
213
|
const i = ce(Pe);
|
|
@@ -215,7 +215,7 @@ function oe() {
|
|
|
215
215
|
throw new Error("useApp must be used within an AppProvider");
|
|
216
216
|
return i;
|
|
217
217
|
}
|
|
218
|
-
const
|
|
218
|
+
const $t = oe;
|
|
219
219
|
class we {
|
|
220
220
|
constructor(e = {}) {
|
|
221
221
|
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);
|
|
@@ -369,7 +369,7 @@ class we {
|
|
|
369
369
|
return e !== null && !this.isTokenExpired(e);
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
|
-
class
|
|
372
|
+
class ze {
|
|
373
373
|
constructor(e) {
|
|
374
374
|
this.httpService = e;
|
|
375
375
|
}
|
|
@@ -481,16 +481,16 @@ class xe {
|
|
|
481
481
|
throw new Error("SessionManager is required for private endpoints");
|
|
482
482
|
const r = await this.sessionManager.getAuthHeaders(), s = new URLSearchParams();
|
|
483
483
|
t != null && t.page && s.append("page", t.page.toString()), t != null && t.limit && s.append("limit", t.limit.toString()), t != null && t.sortBy && s.append("sortBy", t.sortBy), t != null && t.sortOrder && s.append("sortOrder", t.sortOrder);
|
|
484
|
-
const o = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`,
|
|
484
|
+
const o = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, g = await this.httpService.get(o, {
|
|
485
485
|
headers: r
|
|
486
486
|
});
|
|
487
487
|
return {
|
|
488
|
-
roles:
|
|
489
|
-
meta:
|
|
488
|
+
roles: g.data,
|
|
489
|
+
meta: g.meta
|
|
490
490
|
};
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
|
-
class
|
|
493
|
+
class Oe {
|
|
494
494
|
constructor(e, t) {
|
|
495
495
|
this.httpService = e, this.sessionManager = t;
|
|
496
496
|
}
|
|
@@ -608,7 +608,7 @@ class ue {
|
|
|
608
608
|
)).data;
|
|
609
609
|
}
|
|
610
610
|
}
|
|
611
|
-
function
|
|
611
|
+
function We(i, e) {
|
|
612
612
|
if (i === "localhost" || i.startsWith("127.") || i.startsWith("192.168."))
|
|
613
613
|
return null;
|
|
614
614
|
if (e) {
|
|
@@ -616,34 +616,34 @@ function ze(i, e) {
|
|
|
616
616
|
if (o === s || o === `www.${s}`)
|
|
617
617
|
return null;
|
|
618
618
|
if (o.endsWith(`.${s}`)) {
|
|
619
|
-
const
|
|
620
|
-
return
|
|
619
|
+
const g = o.slice(0, -(s.length + 1));
|
|
620
|
+
return g === "www" ? null : g;
|
|
621
621
|
}
|
|
622
622
|
return null;
|
|
623
623
|
}
|
|
624
624
|
const r = i.split(".");
|
|
625
625
|
return r.length >= 3 && r[0] !== "www" ? r[0] : null;
|
|
626
626
|
}
|
|
627
|
-
function
|
|
627
|
+
function Ve(i, e = "tenant", t) {
|
|
628
628
|
const s = new URLSearchParams(i).get(e);
|
|
629
629
|
return s ? (t && t.setItem("tenant", s), s) : t ? t.getItem("tenant") : null;
|
|
630
630
|
}
|
|
631
|
-
function
|
|
631
|
+
function je(i, e, t) {
|
|
632
632
|
const { tenantMode: r, baseDomain: s, selectorParam: o } = i;
|
|
633
|
-
return r === "subdomain" ?
|
|
633
|
+
return r === "subdomain" ? We(e.hostname, s) : r === "selector" ? Ve(e.search, o, t) : null;
|
|
634
634
|
}
|
|
635
|
-
function
|
|
635
|
+
function _e(i, e, t) {
|
|
636
636
|
if (t)
|
|
637
637
|
return `${i}.${t}`;
|
|
638
638
|
const r = e.split(".");
|
|
639
639
|
return r.length === 2 ? `${i}.${e}` : r.length >= 3 ? (r[0] = i, r.join(".")) : null;
|
|
640
640
|
}
|
|
641
641
|
const fe = "_auth";
|
|
642
|
-
function
|
|
642
|
+
function Ge(i) {
|
|
643
643
|
const e = JSON.stringify(i);
|
|
644
644
|
return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
645
645
|
}
|
|
646
|
-
function
|
|
646
|
+
function Ke(i) {
|
|
647
647
|
try {
|
|
648
648
|
let e = i.replace(/-/g, "+").replace(/_/g, "/");
|
|
649
649
|
for (; e.length % 4; )
|
|
@@ -654,19 +654,34 @@ function _e(i) {
|
|
|
654
654
|
return null;
|
|
655
655
|
}
|
|
656
656
|
}
|
|
657
|
-
function
|
|
658
|
-
if (typeof window > "u")
|
|
657
|
+
function Je() {
|
|
658
|
+
if (typeof window > "u")
|
|
659
|
+
return console.log("[CrossDomainAuth] SSR environment, skipping URL token extraction"), null;
|
|
659
660
|
const e = new URLSearchParams(window.location.search).get(fe);
|
|
660
|
-
|
|
661
|
+
if (console.log("[CrossDomainAuth] extractAuthTokensFromUrl called", {
|
|
662
|
+
hasAuthParam: !!e,
|
|
663
|
+
searchParams: window.location.search,
|
|
664
|
+
encodedLength: e == null ? void 0 : e.length
|
|
665
|
+
}), !e) return null;
|
|
666
|
+
const t = Ke(e);
|
|
667
|
+
return console.log("[CrossDomainAuth] Token decode result:", {
|
|
668
|
+
success: !!t,
|
|
669
|
+
hasAccessToken: !!(t != null && t.accessToken),
|
|
670
|
+
hasRefreshToken: !!(t != null && t.refreshToken),
|
|
671
|
+
expiresIn: t == null ? void 0 : t.expiresIn
|
|
672
|
+
}), t;
|
|
661
673
|
}
|
|
662
|
-
function
|
|
674
|
+
function Ye() {
|
|
663
675
|
if (typeof window > "u") return;
|
|
664
676
|
const i = new URL(window.location.href);
|
|
665
|
-
i.searchParams.delete(fe),
|
|
677
|
+
i.searchParams.delete(fe), console.log("[CrossDomainAuth] Clearing auth tokens from URL", {
|
|
678
|
+
oldUrl: window.location.href,
|
|
679
|
+
newUrl: i.toString()
|
|
680
|
+
}), window.history.replaceState({}, "", i.toString());
|
|
666
681
|
}
|
|
667
682
|
const Se = he(null);
|
|
668
|
-
function
|
|
669
|
-
const { baseUrl: t, appInfo: r, appId: s } = oe(), o = ne(() => typeof window > "u" ? null :
|
|
683
|
+
function Dt({ config: i, children: e }) {
|
|
684
|
+
const { baseUrl: t, appInfo: r, appId: s } = oe(), o = ne(() => typeof window > "u" ? null : je(
|
|
670
685
|
{
|
|
671
686
|
tenantMode: i.tenantMode || "selector",
|
|
672
687
|
baseDomain: i.baseDomain,
|
|
@@ -677,118 +692,118 @@ function Ct({ config: i, children: e }) {
|
|
|
677
692
|
search: window.location.search
|
|
678
693
|
},
|
|
679
694
|
window.localStorage
|
|
680
|
-
), [i.tenantMode, i.baseDomain, i.selectorParam]), [
|
|
695
|
+
), [i.tenantMode, i.baseDomain, i.selectorParam]), [g, w] = v(() => o()), x = X(
|
|
681
696
|
() => {
|
|
682
|
-
var
|
|
697
|
+
var l, I, k;
|
|
683
698
|
return {
|
|
684
|
-
enabled: ((
|
|
685
|
-
ttl: ((
|
|
699
|
+
enabled: ((l = i.cache) == null ? void 0 : l.enabled) ?? !0,
|
|
700
|
+
ttl: ((I = i.cache) == null ? void 0 : I.ttl) ?? 5 * 60 * 1e3,
|
|
686
701
|
// 5 minutes default
|
|
687
|
-
storageKey: ((
|
|
702
|
+
storageKey: ((k = i.cache) == null ? void 0 : k.storageKey) ?? `tenant_cache_${g || "default"}`
|
|
688
703
|
};
|
|
689
704
|
},
|
|
690
|
-
[i.cache,
|
|
691
|
-
), [
|
|
705
|
+
[i.cache, g]
|
|
706
|
+
), [b, A] = v(() => {
|
|
692
707
|
if (i.initialTenant) return i.initialTenant;
|
|
693
|
-
if (!
|
|
708
|
+
if (!x.enabled || !g) return null;
|
|
694
709
|
try {
|
|
695
|
-
const
|
|
696
|
-
if (!
|
|
697
|
-
const
|
|
698
|
-
return Date.now() -
|
|
710
|
+
const l = localStorage.getItem(x.storageKey);
|
|
711
|
+
if (!l) return null;
|
|
712
|
+
const I = JSON.parse(l);
|
|
713
|
+
return Date.now() - I.timestamp < x.ttl && I.tenantSlug === g ? I.data : (localStorage.removeItem(x.storageKey), null);
|
|
699
714
|
} catch {
|
|
700
715
|
return null;
|
|
701
716
|
}
|
|
702
|
-
}), [m, f] =
|
|
717
|
+
}), [m, f] = v(!b && !i.initialTenant), [u, y] = v(null), [E, C] = v(null), [q, T] = v(!1), [d, P] = v(null);
|
|
703
718
|
te(() => {
|
|
704
|
-
const
|
|
705
|
-
|
|
719
|
+
const l = o();
|
|
720
|
+
w(l);
|
|
706
721
|
}, [o]);
|
|
707
|
-
const
|
|
708
|
-
async (
|
|
709
|
-
if (!(!
|
|
722
|
+
const R = (r == null ? void 0 : r.settingsSchema) || null, z = ne(
|
|
723
|
+
async (l, I = !1) => {
|
|
724
|
+
if (!(!I && x.enabled && b && b.domain === l))
|
|
710
725
|
try {
|
|
711
726
|
f(!0), y(null);
|
|
712
|
-
const
|
|
713
|
-
if (
|
|
727
|
+
const k = new re(t), a = await new ue(k, s).getPublicTenantInfo(l);
|
|
728
|
+
if (A(a), x.enabled)
|
|
714
729
|
try {
|
|
715
|
-
const
|
|
716
|
-
data:
|
|
730
|
+
const p = {
|
|
731
|
+
data: a,
|
|
717
732
|
timestamp: Date.now(),
|
|
718
|
-
tenantSlug:
|
|
733
|
+
tenantSlug: l
|
|
719
734
|
};
|
|
720
|
-
localStorage.setItem(
|
|
721
|
-
} catch (
|
|
722
|
-
console.warn("Failed to cache tenant info:",
|
|
735
|
+
localStorage.setItem(x.storageKey, JSON.stringify(p));
|
|
736
|
+
} catch (p) {
|
|
737
|
+
console.warn("Failed to cache tenant info:", p);
|
|
723
738
|
}
|
|
724
|
-
} catch (
|
|
725
|
-
const h =
|
|
726
|
-
y(h),
|
|
739
|
+
} catch (k) {
|
|
740
|
+
const h = k instanceof Error ? k : new Error("Failed to load tenant information");
|
|
741
|
+
y(h), A(null);
|
|
727
742
|
} finally {
|
|
728
743
|
f(!1);
|
|
729
744
|
}
|
|
730
745
|
},
|
|
731
|
-
[t, s,
|
|
746
|
+
[t, s, x, b]
|
|
732
747
|
), G = ne(async () => {
|
|
733
|
-
if (!(!
|
|
748
|
+
if (!(!x.enabled || !b || !g))
|
|
734
749
|
try {
|
|
735
|
-
const
|
|
736
|
-
if (!
|
|
737
|
-
const
|
|
738
|
-
if (Date.now() -
|
|
739
|
-
const h = new re(t),
|
|
740
|
-
|
|
741
|
-
const
|
|
742
|
-
data:
|
|
750
|
+
const l = localStorage.getItem(x.storageKey);
|
|
751
|
+
if (!l) return;
|
|
752
|
+
const I = JSON.parse(l);
|
|
753
|
+
if (Date.now() - I.timestamp > x.ttl * 0.5) {
|
|
754
|
+
const h = new re(t), p = await new ue(h, s).getPublicTenantInfo(g);
|
|
755
|
+
A(p);
|
|
756
|
+
const O = {
|
|
757
|
+
data: p,
|
|
743
758
|
timestamp: Date.now(),
|
|
744
|
-
tenantSlug:
|
|
759
|
+
tenantSlug: g
|
|
745
760
|
};
|
|
746
|
-
localStorage.setItem(
|
|
761
|
+
localStorage.setItem(x.storageKey, JSON.stringify(O));
|
|
747
762
|
}
|
|
748
|
-
} catch (
|
|
749
|
-
console.warn("Background tenant refresh failed:",
|
|
763
|
+
} catch (l) {
|
|
764
|
+
console.warn("Background tenant refresh failed:", l);
|
|
750
765
|
}
|
|
751
|
-
}, [t, s,
|
|
752
|
-
if (
|
|
766
|
+
}, [t, s, x, b, g]), $ = ne(async () => {
|
|
767
|
+
if (b != null && b.id)
|
|
753
768
|
try {
|
|
754
|
-
|
|
755
|
-
const
|
|
756
|
-
C(
|
|
757
|
-
} catch (
|
|
758
|
-
const
|
|
759
|
-
P(
|
|
769
|
+
T(!0), P(null);
|
|
770
|
+
const l = new re(t), k = await new ue(l, b.appId).getTenantSettings(b.id);
|
|
771
|
+
C(k);
|
|
772
|
+
} catch (l) {
|
|
773
|
+
const I = l instanceof Error ? l : new Error("Failed to load tenant settings");
|
|
774
|
+
P(I), C(null);
|
|
760
775
|
} finally {
|
|
761
|
-
|
|
776
|
+
T(!1);
|
|
762
777
|
}
|
|
763
|
-
}, [t,
|
|
778
|
+
}, [t, b]), _ = ne(() => {
|
|
764
779
|
$();
|
|
765
|
-
}, [$]),
|
|
766
|
-
(
|
|
767
|
-
if (!
|
|
780
|
+
}, [$]), S = ne(
|
|
781
|
+
(l) => {
|
|
782
|
+
if (!R)
|
|
768
783
|
return { isValid: !0, errors: [] };
|
|
769
|
-
const
|
|
784
|
+
const I = [];
|
|
770
785
|
try {
|
|
771
|
-
return
|
|
772
|
-
var
|
|
773
|
-
const
|
|
774
|
-
if ((
|
|
775
|
-
|
|
786
|
+
return R.properties && Object.entries(R.properties).forEach(([k, h]) => {
|
|
787
|
+
var p;
|
|
788
|
+
const a = l[k];
|
|
789
|
+
if ((p = R.required) != null && p.includes(k) && a == null) {
|
|
790
|
+
I.push(`Field '${k}' is required`);
|
|
776
791
|
return;
|
|
777
792
|
}
|
|
778
|
-
if (
|
|
793
|
+
if (a != null) {
|
|
779
794
|
if (h.type) {
|
|
780
|
-
const
|
|
781
|
-
|
|
795
|
+
const O = h.type, K = typeof a;
|
|
796
|
+
O === "string" && K !== "string" ? I.push(`Field '${k}' must be a string`) : (O === "number" || O === "integer") && K !== "number" ? I.push(`Field '${k}' must be a number`) : O === "boolean" && K !== "boolean" ? I.push(`Field '${k}' must be a boolean`) : O === "array" && !Array.isArray(a) && I.push(`Field '${k}' must be an array`);
|
|
782
797
|
}
|
|
783
|
-
h.minLength !== void 0 && typeof
|
|
784
|
-
`Field '${
|
|
785
|
-
), h.maxLength !== void 0 && typeof
|
|
786
|
-
`Field '${
|
|
787
|
-
), h.minimum !== void 0 && typeof
|
|
798
|
+
h.minLength !== void 0 && typeof a == "string" && a.length < h.minLength && I.push(
|
|
799
|
+
`Field '${k}' must be at least ${h.minLength} characters long`
|
|
800
|
+
), h.maxLength !== void 0 && typeof a == "string" && a.length > h.maxLength && I.push(
|
|
801
|
+
`Field '${k}' must be no more than ${h.maxLength} characters long`
|
|
802
|
+
), h.minimum !== void 0 && typeof a == "number" && a < h.minimum && I.push(`Field '${k}' must be at least ${h.minimum}`), h.maximum !== void 0 && typeof a == "number" && a > h.maximum && I.push(`Field '${k}' must be no more than ${h.maximum}`), h.pattern && typeof a == "string" && (new RegExp(h.pattern).test(a) || I.push(`Field '${k}' does not match the required pattern`)), h.enum && !h.enum.includes(a) && I.push(`Field '${k}' must be one of: ${h.enum.join(", ")}`);
|
|
788
803
|
}
|
|
789
804
|
}), {
|
|
790
|
-
isValid:
|
|
791
|
-
errors:
|
|
805
|
+
isValid: I.length === 0,
|
|
806
|
+
errors: I
|
|
792
807
|
};
|
|
793
808
|
} catch {
|
|
794
809
|
return {
|
|
@@ -797,78 +812,78 @@ function Ct({ config: i, children: e }) {
|
|
|
797
812
|
};
|
|
798
813
|
}
|
|
799
814
|
},
|
|
800
|
-
[
|
|
815
|
+
[R]
|
|
801
816
|
);
|
|
802
817
|
te(() => {
|
|
803
|
-
!i.initialTenant &&
|
|
804
|
-
}, [i.initialTenant,
|
|
805
|
-
|
|
806
|
-
}, [
|
|
818
|
+
!i.initialTenant && g ? b ? G() : z(g) : !i.initialTenant && !g && (A(null), y(null), f(!1));
|
|
819
|
+
}, [i.initialTenant, g, b, z, G]), te(() => {
|
|
820
|
+
b != null && b.id ? $() : (C(null), P(null), T(!1));
|
|
821
|
+
}, [b == null ? void 0 : b.id, $]);
|
|
807
822
|
const M = ne(
|
|
808
|
-
(
|
|
809
|
-
const { mode:
|
|
810
|
-
if (localStorage.setItem("tenant",
|
|
811
|
-
const
|
|
812
|
-
|
|
813
|
-
|
|
823
|
+
(l, I) => {
|
|
824
|
+
const { mode: k = "reload", tokens: h, redirectPath: a } = I || {}, p = i.tenantMode || "selector";
|
|
825
|
+
if (localStorage.setItem("tenant", l), p === "subdomain") {
|
|
826
|
+
const O = window.location.hostname, K = _e(
|
|
827
|
+
l,
|
|
828
|
+
O,
|
|
814
829
|
i.baseDomain
|
|
815
830
|
);
|
|
816
|
-
if (!
|
|
831
|
+
if (!K) {
|
|
817
832
|
console.warn(
|
|
818
833
|
"[TenantProvider] Cannot switch subdomain, invalid hostname:",
|
|
819
|
-
|
|
834
|
+
O
|
|
820
835
|
);
|
|
821
836
|
return;
|
|
822
837
|
}
|
|
823
|
-
const H =
|
|
824
|
-
new URLSearchParams(window.location.search).forEach((
|
|
825
|
-
|
|
826
|
-
}), h && N.searchParams.set(fe,
|
|
827
|
-
} else if (
|
|
828
|
-
const
|
|
829
|
-
if (
|
|
830
|
-
const H = `${
|
|
838
|
+
const H = a || window.location.pathname, N = new URL(`${window.location.protocol}//${K}${H}`);
|
|
839
|
+
new URLSearchParams(window.location.search).forEach((D, J) => {
|
|
840
|
+
J !== fe && N.searchParams.set(J, D);
|
|
841
|
+
}), h && N.searchParams.set(fe, Ge(h)), window.location.href = N.toString();
|
|
842
|
+
} else if (p === "selector") {
|
|
843
|
+
const O = a || window.location.pathname, K = new URLSearchParams(window.location.search);
|
|
844
|
+
if (K.set(i.selectorParam || "tenant", l), k === "reload") {
|
|
845
|
+
const H = `${O}?${K.toString()}${window.location.hash}`;
|
|
831
846
|
window.location.href = H;
|
|
832
847
|
} else {
|
|
833
|
-
const H = `${
|
|
834
|
-
window.history.pushState({}, "", H),
|
|
848
|
+
const H = `${O}?${K.toString()}${window.location.hash}`;
|
|
849
|
+
window.history.pushState({}, "", H), w(l), z(l);
|
|
835
850
|
}
|
|
836
851
|
}
|
|
837
852
|
},
|
|
838
853
|
[i.tenantMode, i.selectorParam, i.baseDomain, z]
|
|
839
|
-
),
|
|
854
|
+
), L = X(() => ({
|
|
840
855
|
// Tenant info
|
|
841
|
-
tenant:
|
|
842
|
-
tenantSlug:
|
|
856
|
+
tenant: b,
|
|
857
|
+
tenantSlug: g,
|
|
843
858
|
isTenantLoading: m,
|
|
844
859
|
tenantError: u,
|
|
845
860
|
retryTenant: () => {
|
|
846
|
-
|
|
861
|
+
g && z(g);
|
|
847
862
|
},
|
|
848
863
|
// Settings
|
|
849
|
-
settings:
|
|
850
|
-
settingsSchema:
|
|
864
|
+
settings: E,
|
|
865
|
+
settingsSchema: R,
|
|
851
866
|
isSettingsLoading: q,
|
|
852
867
|
settingsError: d,
|
|
853
868
|
// Actions
|
|
854
869
|
refreshSettings: _,
|
|
855
870
|
switchTenant: M,
|
|
856
871
|
// Validation
|
|
857
|
-
validateSettings:
|
|
872
|
+
validateSettings: S
|
|
858
873
|
}), [
|
|
859
|
-
|
|
860
|
-
|
|
874
|
+
b,
|
|
875
|
+
g,
|
|
861
876
|
m,
|
|
862
877
|
u,
|
|
863
|
-
R,
|
|
864
878
|
E,
|
|
879
|
+
R,
|
|
865
880
|
q,
|
|
866
881
|
d,
|
|
867
882
|
_,
|
|
868
883
|
M,
|
|
869
|
-
|
|
884
|
+
S
|
|
870
885
|
]);
|
|
871
|
-
return /* @__PURE__ */ n(Se.Provider, { value:
|
|
886
|
+
return /* @__PURE__ */ n(Se.Provider, { value: L, children: e });
|
|
872
887
|
}
|
|
873
888
|
function me() {
|
|
874
889
|
const i = ce(Se);
|
|
@@ -879,8 +894,8 @@ function me() {
|
|
|
879
894
|
function Me() {
|
|
880
895
|
return ce(Se);
|
|
881
896
|
}
|
|
882
|
-
const
|
|
883
|
-
function
|
|
897
|
+
const Ft = me;
|
|
898
|
+
function Ht() {
|
|
884
899
|
const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } = me();
|
|
885
900
|
return {
|
|
886
901
|
settings: i,
|
|
@@ -901,287 +916,314 @@ function se() {
|
|
|
901
916
|
};
|
|
902
917
|
}
|
|
903
918
|
const Ie = he(null);
|
|
904
|
-
function
|
|
905
|
-
const { appId: t, baseUrl: r } = oe(), { tenant: s, tenantSlug: o, switchTenant:
|
|
919
|
+
function Nt({ config: i = {}, children: e }) {
|
|
920
|
+
const { appId: t, baseUrl: r } = oe(), { tenant: s, tenantSlug: o, switchTenant: g } = me(), [w, x] = v(i.initialRoles || []), [b, A] = v(!i.initialRoles), [m, f] = v(null), [u, y] = v(!1), [E, C] = v(null), [q, T] = v(0), d = X(() => new we({
|
|
906
921
|
tenantSlug: o,
|
|
907
922
|
// SessionManager will generate storageKey internally
|
|
908
923
|
onRefreshFailed: i.onRefreshFailed,
|
|
909
924
|
baseUrl: r
|
|
910
925
|
}), [o, r, i.onRefreshFailed]), P = X(() => {
|
|
911
|
-
const
|
|
912
|
-
return
|
|
913
|
-
}, [r, d]),
|
|
914
|
-
const
|
|
926
|
+
const a = new re(r);
|
|
927
|
+
return a.setSessionManager(d), a;
|
|
928
|
+
}, [r, d]), R = X(() => new ze(new re(r)), [r]), z = X(() => new Oe(P, d), [P, d]), G = X(() => new xe(new re(r)), [r]), $ = X(() => m || d.getUser(), [m, d]), _ = X(() => $ != null && $.roleId && w.find((a) => a.id === $.roleId) || null, [$, w]), S = X(() => (_ == null ? void 0 : _.permissions) || [], [_]), M = X(() => d.hasValidSession() && m !== null, [d, m]), L = 5 * 60 * 1e3, l = X(() => {
|
|
929
|
+
const a = async (F = !1) => {
|
|
915
930
|
try {
|
|
916
931
|
if (!d.hasValidSession())
|
|
917
932
|
return;
|
|
918
|
-
const
|
|
919
|
-
if (!
|
|
933
|
+
const U = Date.now();
|
|
934
|
+
if (!F && U - q < L && m)
|
|
920
935
|
return;
|
|
921
|
-
const
|
|
922
|
-
if (!
|
|
936
|
+
const V = d.getUserId();
|
|
937
|
+
if (!V) {
|
|
923
938
|
console.warn("[AuthProvider] No userId available in token or storage");
|
|
924
939
|
return;
|
|
925
940
|
}
|
|
926
941
|
y(!0), C(null);
|
|
927
|
-
const Z = await z.getUserById(
|
|
928
|
-
f(Z), d.setUser(Z),
|
|
929
|
-
} catch (
|
|
930
|
-
const
|
|
931
|
-
C(
|
|
942
|
+
const Z = await z.getUserById(V);
|
|
943
|
+
f(Z), d.setUser(Z), T(Date.now());
|
|
944
|
+
} catch (U) {
|
|
945
|
+
const Y = U instanceof Error ? U : new Error("Failed to load user data");
|
|
946
|
+
C(Y), console.error("[AuthProvider] Failed to load user data:", Y);
|
|
932
947
|
} finally {
|
|
933
948
|
y(!1);
|
|
934
949
|
}
|
|
935
|
-
},
|
|
936
|
-
await
|
|
937
|
-
},
|
|
938
|
-
const { username:
|
|
950
|
+
}, p = async () => {
|
|
951
|
+
await a();
|
|
952
|
+
}, O = async (F) => {
|
|
953
|
+
const { username: U, password: Y, tenantSlug: V } = F;
|
|
939
954
|
let Z = s == null ? void 0 : s.id, Q = o, ee = d;
|
|
940
|
-
|
|
941
|
-
const
|
|
942
|
-
username:
|
|
943
|
-
password:
|
|
955
|
+
V && (Z = (await new ue(P, t).getPublicTenantInfo(V)).id, Q = V);
|
|
956
|
+
const j = await R.login({
|
|
957
|
+
username: U,
|
|
958
|
+
password: Y,
|
|
944
959
|
appId: t,
|
|
945
960
|
tenantId: Z
|
|
946
|
-
}), le =
|
|
961
|
+
}), le = V && V !== o;
|
|
947
962
|
if (le && (ee = new we({
|
|
948
963
|
tenantSlug: Q,
|
|
949
964
|
baseUrl: r
|
|
950
965
|
})), ee.setTokens({
|
|
951
|
-
accessToken:
|
|
952
|
-
refreshToken:
|
|
953
|
-
expiresIn:
|
|
954
|
-
}),
|
|
955
|
-
ee.setUser(
|
|
966
|
+
accessToken: j.accessToken,
|
|
967
|
+
refreshToken: j.refreshToken,
|
|
968
|
+
expiresIn: j.expiresIn
|
|
969
|
+
}), j.user) {
|
|
970
|
+
ee.setUser(j.user), f(j.user);
|
|
956
971
|
try {
|
|
957
|
-
await
|
|
972
|
+
await a();
|
|
958
973
|
} catch (de) {
|
|
959
974
|
console.warn("Failed to load complete user data after login:", de);
|
|
960
975
|
}
|
|
961
976
|
}
|
|
962
|
-
return le && Q && Q !== o &&
|
|
977
|
+
return le && Q && Q !== o && g(Q, {
|
|
963
978
|
tokens: {
|
|
964
|
-
accessToken:
|
|
965
|
-
refreshToken:
|
|
966
|
-
expiresIn:
|
|
979
|
+
accessToken: j.accessToken,
|
|
980
|
+
refreshToken: j.refreshToken,
|
|
981
|
+
expiresIn: j.expiresIn
|
|
967
982
|
}
|
|
968
|
-
}),
|
|
969
|
-
},
|
|
970
|
-
const { email:
|
|
971
|
-
if (!
|
|
983
|
+
}), j;
|
|
984
|
+
}, K = async (F) => {
|
|
985
|
+
const { email: U, phoneNumber: Y, name: V, password: Z, lastName: Q, tenantId: ee } = F;
|
|
986
|
+
if (!U && !Y)
|
|
972
987
|
throw new Error("Either email or phoneNumber is required");
|
|
973
|
-
if (!
|
|
988
|
+
if (!V || !Z)
|
|
974
989
|
throw new Error("Name and password are required");
|
|
975
|
-
const
|
|
976
|
-
return await
|
|
977
|
-
email:
|
|
978
|
-
phoneNumber:
|
|
979
|
-
name:
|
|
990
|
+
const j = ee ?? (s == null ? void 0 : s.id);
|
|
991
|
+
return await R.signup({
|
|
992
|
+
email: U,
|
|
993
|
+
phoneNumber: Y,
|
|
994
|
+
name: V,
|
|
980
995
|
password: Z,
|
|
981
|
-
tenantId:
|
|
996
|
+
tenantId: j,
|
|
982
997
|
lastName: Q,
|
|
983
998
|
appId: t
|
|
984
999
|
});
|
|
985
|
-
},
|
|
986
|
-
const { email:
|
|
987
|
-
if (!
|
|
1000
|
+
}, H = async (F) => {
|
|
1001
|
+
const { email: U, phoneNumber: Y, name: V, password: Z, tenantName: Q, lastName: ee } = F;
|
|
1002
|
+
if (!U && !Y)
|
|
988
1003
|
throw new Error("Either email or phoneNumber is required");
|
|
989
|
-
if (!
|
|
1004
|
+
if (!V || !Z || !Q)
|
|
990
1005
|
throw new Error("Name, password, and tenantName are required");
|
|
991
|
-
return await
|
|
992
|
-
email:
|
|
993
|
-
phoneNumber:
|
|
994
|
-
name:
|
|
1006
|
+
return await R.signupTenantAdmin({
|
|
1007
|
+
email: U,
|
|
1008
|
+
phoneNumber: Y,
|
|
1009
|
+
name: V,
|
|
995
1010
|
password: Z,
|
|
996
1011
|
tenantName: Q,
|
|
997
1012
|
appId: t,
|
|
998
1013
|
lastName: ee
|
|
999
1014
|
});
|
|
1000
|
-
},
|
|
1001
|
-
const { currentPassword:
|
|
1002
|
-
await
|
|
1003
|
-
},
|
|
1004
|
-
const { email:
|
|
1005
|
-
if (!
|
|
1015
|
+
}, N = async (F) => {
|
|
1016
|
+
const { currentPassword: U, newPassword: Y } = F, V = await d.getAuthHeaders();
|
|
1017
|
+
await R.changePassword({ currentPassword: U, newPassword: Y }, V);
|
|
1018
|
+
}, W = async (F) => {
|
|
1019
|
+
const { email: U, tenantId: Y } = F, V = Y ?? (s == null ? void 0 : s.id);
|
|
1020
|
+
if (!V)
|
|
1006
1021
|
throw new Error("tenantId is required for password reset");
|
|
1007
|
-
await
|
|
1008
|
-
},
|
|
1009
|
-
const { token:
|
|
1010
|
-
await
|
|
1011
|
-
},
|
|
1012
|
-
const { email:
|
|
1022
|
+
await R.requestPasswordReset({ email: U, tenantId: V });
|
|
1023
|
+
}, D = async (F) => {
|
|
1024
|
+
const { token: U, newPassword: Y } = F;
|
|
1025
|
+
await R.confirmPasswordReset({ token: U, newPassword: Y });
|
|
1026
|
+
}, J = async (F) => {
|
|
1027
|
+
const { email: U, frontendUrl: Y, name: V, lastName: Z, tenantId: Q } = F, ee = Q ?? (s == null ? void 0 : s.id);
|
|
1013
1028
|
if (!ee)
|
|
1014
1029
|
throw new Error("tenantId is required for magic link authentication");
|
|
1015
|
-
return await
|
|
1016
|
-
email:
|
|
1030
|
+
return await R.sendMagicLink({
|
|
1031
|
+
email: U,
|
|
1017
1032
|
tenantId: ee,
|
|
1018
|
-
frontendUrl:
|
|
1019
|
-
name:
|
|
1033
|
+
frontendUrl: Y,
|
|
1034
|
+
name: V,
|
|
1020
1035
|
lastName: Z,
|
|
1021
1036
|
appId: t
|
|
1022
1037
|
});
|
|
1023
|
-
},
|
|
1024
|
-
const { token:
|
|
1038
|
+
}, ge = async (F) => {
|
|
1039
|
+
const { token: U, email: Y, tenantSlug: V } = F;
|
|
1025
1040
|
let Z = s == null ? void 0 : s.id, Q = o, ee = d;
|
|
1026
|
-
|
|
1027
|
-
const
|
|
1028
|
-
token:
|
|
1029
|
-
email:
|
|
1041
|
+
V && (Z = (await new ue(P, t).getPublicTenantInfo(V)).id, Q = V);
|
|
1042
|
+
const j = await R.verifyMagicLink({
|
|
1043
|
+
token: U,
|
|
1044
|
+
email: Y,
|
|
1030
1045
|
appId: t,
|
|
1031
1046
|
tenantId: Z
|
|
1032
|
-
}), le =
|
|
1047
|
+
}), le = V && V !== o;
|
|
1033
1048
|
if (le && (ee = new we({
|
|
1034
1049
|
tenantSlug: Q,
|
|
1035
1050
|
baseUrl: r
|
|
1036
1051
|
})), ee.setTokens({
|
|
1037
|
-
accessToken:
|
|
1038
|
-
refreshToken:
|
|
1039
|
-
expiresIn:
|
|
1040
|
-
}),
|
|
1041
|
-
ee.setUser(
|
|
1052
|
+
accessToken: j.accessToken,
|
|
1053
|
+
refreshToken: j.refreshToken,
|
|
1054
|
+
expiresIn: j.expiresIn
|
|
1055
|
+
}), j.user) {
|
|
1056
|
+
ee.setUser(j.user), f(j.user);
|
|
1042
1057
|
try {
|
|
1043
|
-
await
|
|
1058
|
+
await a();
|
|
1044
1059
|
} catch (de) {
|
|
1045
1060
|
console.warn("Failed to load complete user data after magic link login:", de);
|
|
1046
1061
|
}
|
|
1047
1062
|
}
|
|
1048
|
-
return le && Q && Q !== o &&
|
|
1063
|
+
return le && Q && Q !== o && g(Q, {
|
|
1049
1064
|
tokens: {
|
|
1050
|
-
accessToken:
|
|
1051
|
-
refreshToken:
|
|
1052
|
-
expiresIn:
|
|
1065
|
+
accessToken: j.accessToken,
|
|
1066
|
+
refreshToken: j.refreshToken,
|
|
1067
|
+
expiresIn: j.expiresIn
|
|
1053
1068
|
}
|
|
1054
|
-
}),
|
|
1055
|
-
},
|
|
1056
|
-
const
|
|
1057
|
-
if (!(
|
|
1069
|
+
}), j;
|
|
1070
|
+
}, Ce = async () => {
|
|
1071
|
+
const F = d.getTokens();
|
|
1072
|
+
if (!(F != null && F.refreshToken))
|
|
1058
1073
|
throw new Error("No refresh token available");
|
|
1059
|
-
const
|
|
1060
|
-
refreshToken:
|
|
1074
|
+
const U = await R.refreshToken({
|
|
1075
|
+
refreshToken: F.refreshToken
|
|
1061
1076
|
});
|
|
1062
1077
|
d.setTokens({
|
|
1063
|
-
accessToken:
|
|
1064
|
-
refreshToken:
|
|
1065
|
-
expiresIn:
|
|
1078
|
+
accessToken: U.accessToken,
|
|
1079
|
+
refreshToken: U.refreshToken || F.refreshToken,
|
|
1080
|
+
expiresIn: U.expiresIn
|
|
1066
1081
|
});
|
|
1067
|
-
},
|
|
1082
|
+
}, $e = () => {
|
|
1068
1083
|
d.clearSession(), f(null), C(null);
|
|
1069
|
-
},
|
|
1070
|
-
d.setTokens(
|
|
1071
|
-
},
|
|
1084
|
+
}, De = (F) => {
|
|
1085
|
+
d.setTokens(F);
|
|
1086
|
+
}, Fe = () => d.hasValidSession(), He = () => {
|
|
1072
1087
|
d.clearSession(), f(null), C(null);
|
|
1073
|
-
},
|
|
1088
|
+
}, Ne = async () => {
|
|
1074
1089
|
if (t)
|
|
1075
1090
|
try {
|
|
1076
|
-
|
|
1077
|
-
const { roles:
|
|
1078
|
-
|
|
1079
|
-
} catch (
|
|
1080
|
-
console.error("Failed to fetch roles:",
|
|
1091
|
+
A(!0);
|
|
1092
|
+
const { roles: F } = await G.getRolesByApp(t);
|
|
1093
|
+
x(F);
|
|
1094
|
+
} catch (F) {
|
|
1095
|
+
console.error("Failed to fetch roles:", F);
|
|
1081
1096
|
} finally {
|
|
1082
|
-
|
|
1097
|
+
A(!1);
|
|
1083
1098
|
}
|
|
1084
|
-
},
|
|
1085
|
-
await
|
|
1086
|
-
}, ye = (
|
|
1087
|
-
if (!
|
|
1099
|
+
}, Ue = async () => {
|
|
1100
|
+
await Ne();
|
|
1101
|
+
}, ye = (F) => {
|
|
1102
|
+
if (!S || S.length === 0)
|
|
1088
1103
|
return !1;
|
|
1089
|
-
if (typeof
|
|
1090
|
-
return
|
|
1091
|
-
const
|
|
1092
|
-
return
|
|
1104
|
+
if (typeof F == "string")
|
|
1105
|
+
return S.includes(F);
|
|
1106
|
+
const U = `${F.resource}.${F.action}`;
|
|
1107
|
+
return S.includes(U);
|
|
1093
1108
|
};
|
|
1094
1109
|
return {
|
|
1095
1110
|
// RFC-003: Authentication state
|
|
1096
1111
|
isAuthenticated: M,
|
|
1097
1112
|
sessionManager: d,
|
|
1098
1113
|
authenticatedHttpService: P,
|
|
1099
|
-
login:
|
|
1100
|
-
signup:
|
|
1101
|
-
signupTenantAdmin:
|
|
1102
|
-
sendMagicLink:
|
|
1103
|
-
verifyMagicLink:
|
|
1104
|
-
changePassword:
|
|
1105
|
-
requestPasswordReset:
|
|
1106
|
-
confirmPasswordReset:
|
|
1107
|
-
refreshToken:
|
|
1108
|
-
logout:
|
|
1109
|
-
setTokens:
|
|
1110
|
-
hasValidSession:
|
|
1111
|
-
clearSession:
|
|
1114
|
+
login: O,
|
|
1115
|
+
signup: K,
|
|
1116
|
+
signupTenantAdmin: H,
|
|
1117
|
+
sendMagicLink: J,
|
|
1118
|
+
verifyMagicLink: ge,
|
|
1119
|
+
changePassword: N,
|
|
1120
|
+
requestPasswordReset: W,
|
|
1121
|
+
confirmPasswordReset: D,
|
|
1122
|
+
refreshToken: Ce,
|
|
1123
|
+
logout: $e,
|
|
1124
|
+
setTokens: De,
|
|
1125
|
+
hasValidSession: Fe,
|
|
1126
|
+
clearSession: He,
|
|
1112
1127
|
currentUser: m,
|
|
1113
1128
|
isUserLoading: u,
|
|
1114
|
-
userError:
|
|
1115
|
-
loadUserData:
|
|
1116
|
-
refreshUser:
|
|
1129
|
+
userError: E,
|
|
1130
|
+
loadUserData: a,
|
|
1131
|
+
refreshUser: p,
|
|
1117
1132
|
userRole: _,
|
|
1118
|
-
userPermissions:
|
|
1119
|
-
availableRoles:
|
|
1120
|
-
rolesLoading:
|
|
1133
|
+
userPermissions: S,
|
|
1134
|
+
availableRoles: w,
|
|
1135
|
+
rolesLoading: b,
|
|
1121
1136
|
hasPermission: ye,
|
|
1122
|
-
hasAnyPermission: (
|
|
1123
|
-
hasAllPermissions: (
|
|
1124
|
-
getUserPermissionStrings: () =>
|
|
1125
|
-
refreshRoles:
|
|
1137
|
+
hasAnyPermission: (F) => F.some((U) => ye(U)),
|
|
1138
|
+
hasAllPermissions: (F) => F.every((U) => ye(U)),
|
|
1139
|
+
getUserPermissionStrings: () => S || [],
|
|
1140
|
+
refreshRoles: Ue
|
|
1126
1141
|
};
|
|
1127
1142
|
}, [
|
|
1128
1143
|
M,
|
|
1129
1144
|
d,
|
|
1130
1145
|
P,
|
|
1131
|
-
|
|
1146
|
+
R,
|
|
1132
1147
|
z,
|
|
1133
1148
|
G,
|
|
1134
1149
|
t,
|
|
1135
1150
|
s,
|
|
1136
1151
|
o,
|
|
1137
|
-
|
|
1138
|
-
|
|
1152
|
+
g,
|
|
1153
|
+
w,
|
|
1139
1154
|
m,
|
|
1140
1155
|
u,
|
|
1141
|
-
|
|
1156
|
+
E,
|
|
1142
1157
|
_,
|
|
1143
|
-
|
|
1158
|
+
S,
|
|
1144
1159
|
q,
|
|
1145
|
-
|
|
1160
|
+
L
|
|
1146
1161
|
]);
|
|
1147
1162
|
te(() => {
|
|
1148
1163
|
!i.initialRoles && t && (async () => {
|
|
1149
1164
|
try {
|
|
1150
|
-
|
|
1151
|
-
const
|
|
1152
|
-
|
|
1153
|
-
} catch (
|
|
1154
|
-
console.error("Failed to fetch roles:",
|
|
1165
|
+
A(!0);
|
|
1166
|
+
const p = new re(r), O = new xe(p), { roles: K } = await O.getRolesByApp(t);
|
|
1167
|
+
x(K);
|
|
1168
|
+
} catch (p) {
|
|
1169
|
+
console.error("Failed to fetch roles:", p);
|
|
1155
1170
|
} finally {
|
|
1156
|
-
|
|
1171
|
+
A(!1);
|
|
1157
1172
|
}
|
|
1158
1173
|
})();
|
|
1159
1174
|
}, [t, r, i.initialRoles]);
|
|
1160
|
-
const
|
|
1175
|
+
const [I, k] = v(!1), h = qe(!1);
|
|
1161
1176
|
return te(() => {
|
|
1162
|
-
if (
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1177
|
+
if (console.log("[AuthProvider] Cross-subdomain auth effect running", {
|
|
1178
|
+
alreadyChecked: I,
|
|
1179
|
+
alreadyProcessed: h.current,
|
|
1180
|
+
currentUrl: typeof window < "u" ? window.location.href : "SSR"
|
|
1181
|
+
}), I) {
|
|
1182
|
+
console.log("[AuthProvider] URL tokens already checked, skipping");
|
|
1183
|
+
return;
|
|
1184
|
+
}
|
|
1185
|
+
k(!0);
|
|
1186
|
+
const a = Je();
|
|
1187
|
+
console.log("[AuthProvider] URL tokens extraction result:", {
|
|
1188
|
+
found: !!a,
|
|
1189
|
+
hasAccessToken: !!(a != null && a.accessToken)
|
|
1190
|
+
}), a && (h.current = !0, console.log("[AuthProvider] Saving URL tokens to session..."), d.setTokens({
|
|
1191
|
+
accessToken: a.accessToken,
|
|
1192
|
+
refreshToken: a.refreshToken,
|
|
1193
|
+
expiresIn: a.expiresIn
|
|
1194
|
+
}), console.log("[AuthProvider] Tokens saved, verifying session validity:", {
|
|
1195
|
+
hasValidSession: d.hasValidSession()
|
|
1196
|
+
}), Ye(), console.log("[AuthProvider] Loading user data after URL token consumption..."), l.loadUserData().catch((p) => {
|
|
1197
|
+
console.error(
|
|
1198
|
+
"[AuthProvider] Failed to load user data after URL token consumption:",
|
|
1199
|
+
p
|
|
1200
|
+
);
|
|
1169
1201
|
}));
|
|
1170
|
-
}, [d,
|
|
1171
|
-
const
|
|
1172
|
-
|
|
1202
|
+
}, [d, l, I]), te(() => {
|
|
1203
|
+
const a = d.getUser();
|
|
1204
|
+
a && d.hasValidSession() && f(a);
|
|
1173
1205
|
}, [d]), te(() => {
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1206
|
+
if (console.log("[AuthProvider] Auto-load effect running", {
|
|
1207
|
+
hasCurrentUser: !!m,
|
|
1208
|
+
isUserLoading: u,
|
|
1209
|
+
hasValidSession: d.hasValidSession(),
|
|
1210
|
+
urlTokensChecked: I,
|
|
1211
|
+
urlTokensProcessed: h.current
|
|
1212
|
+
}), !I) {
|
|
1213
|
+
console.log("[AuthProvider] Waiting for URL tokens check before auto-load");
|
|
1214
|
+
return;
|
|
1215
|
+
}
|
|
1216
|
+
!m && !u && (console.log("[AuthProvider] Auto-loading user data..."), l.loadUserData().catch(() => {
|
|
1217
|
+
}));
|
|
1218
|
+
}, [m, u, l, d, I]), te(() => {
|
|
1177
1219
|
if (!d.hasValidSession() || !m)
|
|
1178
1220
|
return;
|
|
1179
|
-
const
|
|
1180
|
-
|
|
1221
|
+
const a = setInterval(() => {
|
|
1222
|
+
l.loadUserData().catch(() => {
|
|
1181
1223
|
});
|
|
1182
|
-
},
|
|
1183
|
-
return () => clearInterval(
|
|
1184
|
-
}, [d, m,
|
|
1224
|
+
}, L);
|
|
1225
|
+
return () => clearInterval(a);
|
|
1226
|
+
}, [d, m, l, L]), /* @__PURE__ */ n(Ie.Provider, { value: l, children: e });
|
|
1185
1227
|
}
|
|
1186
1228
|
function ae() {
|
|
1187
1229
|
const i = ce(Ie);
|
|
@@ -1189,7 +1231,7 @@ function ae() {
|
|
|
1189
1231
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
1190
1232
|
return i;
|
|
1191
1233
|
}
|
|
1192
|
-
class
|
|
1234
|
+
class Qe {
|
|
1193
1235
|
constructor(e, t) {
|
|
1194
1236
|
this.httpService = e, this.sessionManager = t;
|
|
1195
1237
|
}
|
|
@@ -1270,57 +1312,57 @@ class Je {
|
|
|
1270
1312
|
}
|
|
1271
1313
|
}
|
|
1272
1314
|
const Le = he(null);
|
|
1273
|
-
function
|
|
1274
|
-
const { baseUrl: t, appId: r } = oe(), { tenant: s } = se(), [o,
|
|
1315
|
+
function Ut({ config: i = {}, children: e }) {
|
|
1316
|
+
const { baseUrl: t, appId: r } = oe(), { tenant: s } = se(), [o, g] = v([]), [w, x] = v(!1), [b, A] = v(null), m = X(() => {
|
|
1275
1317
|
const y = new re(t);
|
|
1276
|
-
return new
|
|
1318
|
+
return new Qe(y);
|
|
1277
1319
|
}, [t]), f = async () => {
|
|
1278
1320
|
if (!(s != null && s.id)) {
|
|
1279
|
-
|
|
1321
|
+
g([]);
|
|
1280
1322
|
return;
|
|
1281
1323
|
}
|
|
1282
|
-
|
|
1324
|
+
x(!0), A(null);
|
|
1283
1325
|
try {
|
|
1284
1326
|
const y = await m.getTenantFeatureFlags(s.id, r);
|
|
1285
|
-
|
|
1327
|
+
g(y);
|
|
1286
1328
|
} catch (y) {
|
|
1287
|
-
const
|
|
1288
|
-
|
|
1329
|
+
const E = y instanceof Error ? y.message : "Failed to fetch feature flags";
|
|
1330
|
+
A(E), i.onError && i.onError(y instanceof Error ? y : new Error(E));
|
|
1289
1331
|
} finally {
|
|
1290
|
-
|
|
1332
|
+
x(!1);
|
|
1291
1333
|
}
|
|
1292
1334
|
};
|
|
1293
1335
|
te(() => {
|
|
1294
1336
|
f();
|
|
1295
|
-
const y = i.refreshInterval || 5 * 60 * 1e3,
|
|
1296
|
-
return () => clearInterval(
|
|
1337
|
+
const y = i.refreshInterval || 5 * 60 * 1e3, E = setInterval(f, y);
|
|
1338
|
+
return () => clearInterval(E);
|
|
1297
1339
|
}, [s == null ? void 0 : s.id, i.refreshInterval]);
|
|
1298
1340
|
const u = X(() => ({
|
|
1299
1341
|
featureFlags: o,
|
|
1300
|
-
loading:
|
|
1301
|
-
error:
|
|
1302
|
-
isEnabled: (
|
|
1303
|
-
const d = o.find((P) => P.key ===
|
|
1342
|
+
loading: w,
|
|
1343
|
+
error: b,
|
|
1344
|
+
isEnabled: (T) => {
|
|
1345
|
+
const d = o.find((P) => P.key === T);
|
|
1304
1346
|
return (d == null ? void 0 : d.value) === !0;
|
|
1305
1347
|
},
|
|
1306
|
-
getFlag: (
|
|
1307
|
-
getFlagState: (
|
|
1308
|
-
const d = o.find((P) => P.key ===
|
|
1348
|
+
getFlag: (T) => o.find((d) => d.key === T),
|
|
1349
|
+
getFlagState: (T) => {
|
|
1350
|
+
const d = o.find((P) => P.key === T);
|
|
1309
1351
|
return d ? d.value ? "enabled" : "disabled" : "not_found";
|
|
1310
1352
|
},
|
|
1311
1353
|
refresh: async () => {
|
|
1312
1354
|
await f();
|
|
1313
1355
|
}
|
|
1314
|
-
}), [o,
|
|
1356
|
+
}), [o, w, b]);
|
|
1315
1357
|
return /* @__PURE__ */ n(Le.Provider, { value: u, children: e });
|
|
1316
1358
|
}
|
|
1317
|
-
function
|
|
1359
|
+
function Xe() {
|
|
1318
1360
|
const i = ce(Le);
|
|
1319
1361
|
if (!i)
|
|
1320
1362
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1321
1363
|
return i;
|
|
1322
1364
|
}
|
|
1323
|
-
class
|
|
1365
|
+
class Ze {
|
|
1324
1366
|
constructor(e, t) {
|
|
1325
1367
|
this.httpService = e, this.sessionManager = t;
|
|
1326
1368
|
}
|
|
@@ -1386,25 +1428,25 @@ class Qe {
|
|
|
1386
1428
|
)).data;
|
|
1387
1429
|
}
|
|
1388
1430
|
}
|
|
1389
|
-
const
|
|
1390
|
-
function
|
|
1391
|
-
const { baseUrl: t } = oe(), { tenant: r } = se(), [s, o] =
|
|
1431
|
+
const Re = he(void 0);
|
|
1432
|
+
function Bt({ config: i = {}, children: e }) {
|
|
1433
|
+
const { baseUrl: t } = oe(), { tenant: r } = se(), [s, o] = v(null), [g, w] = v(!1), [x, b] = v(null), A = X(() => {
|
|
1392
1434
|
const u = new re(t);
|
|
1393
|
-
return new
|
|
1435
|
+
return new Ze(u);
|
|
1394
1436
|
}, [t]), m = async () => {
|
|
1395
1437
|
if (!(r != null && r.id)) {
|
|
1396
1438
|
o(null);
|
|
1397
1439
|
return;
|
|
1398
1440
|
}
|
|
1399
|
-
|
|
1441
|
+
w(!0), b(null);
|
|
1400
1442
|
try {
|
|
1401
|
-
const u = await
|
|
1443
|
+
const u = await A.getTenantSubscriptionFeatures(r.id);
|
|
1402
1444
|
o(u);
|
|
1403
1445
|
} catch (u) {
|
|
1404
1446
|
const y = u instanceof Error ? u.message : "Failed to fetch subscription";
|
|
1405
|
-
|
|
1447
|
+
b(y), i.onError && i.onError(u instanceof Error ? u : new Error(y));
|
|
1406
1448
|
} finally {
|
|
1407
|
-
|
|
1449
|
+
w(!1);
|
|
1408
1450
|
}
|
|
1409
1451
|
};
|
|
1410
1452
|
te(() => {
|
|
@@ -1417,33 +1459,33 @@ function Nt({ config: i = {}, children: e }) {
|
|
|
1417
1459
|
return {
|
|
1418
1460
|
subscription: s,
|
|
1419
1461
|
features: u,
|
|
1420
|
-
loading:
|
|
1421
|
-
error:
|
|
1462
|
+
loading: g,
|
|
1463
|
+
error: x,
|
|
1422
1464
|
isFeatureEnabled: (d) => {
|
|
1423
|
-
const P = u.find((
|
|
1465
|
+
const P = u.find((R) => R.key === d);
|
|
1424
1466
|
return P ? P.type === "BOOLEAN" || P.type === "boolean" ? P.value === !0 : !!P.value : !1;
|
|
1425
1467
|
},
|
|
1426
1468
|
getFeature: (d) => u.find((P) => P.key === d),
|
|
1427
1469
|
getFeatureValue: (d, P) => {
|
|
1428
|
-
const
|
|
1429
|
-
return
|
|
1470
|
+
const R = u.find((z) => z.key === d);
|
|
1471
|
+
return R ? R.value : P;
|
|
1430
1472
|
},
|
|
1431
1473
|
hasAllowedPlan: (d) => !s || !s.isActive ? !1 : d.includes(s.planId),
|
|
1432
1474
|
refresh: async () => {
|
|
1433
1475
|
await m();
|
|
1434
1476
|
}
|
|
1435
1477
|
};
|
|
1436
|
-
}, [s,
|
|
1437
|
-
return /* @__PURE__ */ n(
|
|
1478
|
+
}, [s, g, x]);
|
|
1479
|
+
return /* @__PURE__ */ n(Re.Provider, { value: f, children: e });
|
|
1438
1480
|
}
|
|
1439
|
-
function
|
|
1440
|
-
const i = ce(
|
|
1481
|
+
function et() {
|
|
1482
|
+
const i = ce(Re);
|
|
1441
1483
|
if (i === void 0)
|
|
1442
1484
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1443
1485
|
return i;
|
|
1444
1486
|
}
|
|
1445
1487
|
var ie = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(ie || {});
|
|
1446
|
-
const ke = () => /* @__PURE__ */
|
|
1488
|
+
const ke = () => /* @__PURE__ */ c(
|
|
1447
1489
|
"div",
|
|
1448
1490
|
{
|
|
1449
1491
|
style: {
|
|
@@ -1480,11 +1522,11 @@ const ke = () => /* @__PURE__ */ l(
|
|
|
1480
1522
|
)
|
|
1481
1523
|
]
|
|
1482
1524
|
}
|
|
1483
|
-
),
|
|
1525
|
+
), Ae = ({
|
|
1484
1526
|
userType: i,
|
|
1485
1527
|
minUserType: e,
|
|
1486
1528
|
missingPermissions: t
|
|
1487
|
-
}) => /* @__PURE__ */
|
|
1529
|
+
}) => /* @__PURE__ */ c(
|
|
1488
1530
|
"div",
|
|
1489
1531
|
{
|
|
1490
1532
|
style: {
|
|
@@ -1502,26 +1544,26 @@ const ke = () => /* @__PURE__ */ l(
|
|
|
1502
1544
|
children: [
|
|
1503
1545
|
/* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
|
|
1504
1546
|
/* @__PURE__ */ n("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
|
|
1505
|
-
e && i ? /* @__PURE__ */
|
|
1506
|
-
/* @__PURE__ */
|
|
1547
|
+
e && i ? /* @__PURE__ */ c(B, { children: [
|
|
1548
|
+
/* @__PURE__ */ c("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
|
|
1507
1549
|
"This content requires ",
|
|
1508
1550
|
/* @__PURE__ */ n("strong", { children: e }),
|
|
1509
1551
|
" access level or higher."
|
|
1510
1552
|
] }),
|
|
1511
|
-
/* @__PURE__ */
|
|
1553
|
+
/* @__PURE__ */ c("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1512
1554
|
"Your current access level: ",
|
|
1513
1555
|
/* @__PURE__ */ n("strong", { children: i })
|
|
1514
1556
|
] })
|
|
1515
|
-
] }) : /* @__PURE__ */
|
|
1557
|
+
] }) : /* @__PURE__ */ c(B, { children: [
|
|
1516
1558
|
/* @__PURE__ */ n("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
|
|
1517
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1559
|
+
t && t.length > 0 && /* @__PURE__ */ c("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1518
1560
|
"Required permissions: ",
|
|
1519
1561
|
/* @__PURE__ */ n("strong", { children: t.join(", ") })
|
|
1520
1562
|
] })
|
|
1521
1563
|
] })
|
|
1522
1564
|
]
|
|
1523
1565
|
}
|
|
1524
|
-
),
|
|
1566
|
+
), tt = (i, e) => {
|
|
1525
1567
|
const t = {
|
|
1526
1568
|
[ie.USER]: 1,
|
|
1527
1569
|
[ie.TENANT_ADMIN]: 2,
|
|
@@ -1529,28 +1571,28 @@ const ke = () => /* @__PURE__ */ l(
|
|
|
1529
1571
|
};
|
|
1530
1572
|
return t[i] >= t[e];
|
|
1531
1573
|
};
|
|
1532
|
-
function
|
|
1574
|
+
function qt({
|
|
1533
1575
|
children: i,
|
|
1534
1576
|
fallback: e,
|
|
1535
1577
|
minUserType: t,
|
|
1536
1578
|
requiredPermissions: r,
|
|
1537
1579
|
requireAllPermissions: s = !1
|
|
1538
1580
|
}) {
|
|
1539
|
-
const { hasValidSession: o, sessionManager:
|
|
1581
|
+
const { hasValidSession: o, sessionManager: g, hasPermission: w, hasAnyPermission: x, hasAllPermissions: b } = ae();
|
|
1540
1582
|
if (!o())
|
|
1541
|
-
return /* @__PURE__ */ n(
|
|
1542
|
-
const
|
|
1543
|
-
if (!
|
|
1544
|
-
return /* @__PURE__ */ n(
|
|
1545
|
-
if (t && !
|
|
1546
|
-
return /* @__PURE__ */ n(
|
|
1547
|
-
if (r && r.length > 0 && !(s ?
|
|
1548
|
-
const f = r.filter((u) => !
|
|
1549
|
-
return /* @__PURE__ */ n(
|
|
1550
|
-
}
|
|
1551
|
-
return /* @__PURE__ */ n(
|
|
1583
|
+
return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(ke, {}) });
|
|
1584
|
+
const A = g.getUser();
|
|
1585
|
+
if (!A)
|
|
1586
|
+
return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(ke, {}) });
|
|
1587
|
+
if (t && !tt(A.userType, t))
|
|
1588
|
+
return /* @__PURE__ */ n(Ae, { userType: A.userType, minUserType: t });
|
|
1589
|
+
if (r && r.length > 0 && !(s ? b(r) : x(r))) {
|
|
1590
|
+
const f = r.filter((u) => !w(u)).map((u) => typeof u == "string" ? u : u.name);
|
|
1591
|
+
return /* @__PURE__ */ n(Ae, { missingPermissions: f });
|
|
1592
|
+
}
|
|
1593
|
+
return /* @__PURE__ */ n(B, { children: i });
|
|
1552
1594
|
}
|
|
1553
|
-
const
|
|
1595
|
+
const rt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1554
1596
|
"div",
|
|
1555
1597
|
{
|
|
1556
1598
|
style: {
|
|
@@ -1563,7 +1605,7 @@ const et = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1563
1605
|
backgroundColor: "#f9fafb",
|
|
1564
1606
|
textAlign: "center"
|
|
1565
1607
|
},
|
|
1566
|
-
children: /* @__PURE__ */
|
|
1608
|
+
children: /* @__PURE__ */ c(
|
|
1567
1609
|
"div",
|
|
1568
1610
|
{
|
|
1569
1611
|
style: {
|
|
@@ -1577,7 +1619,7 @@ const et = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1577
1619
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
|
|
1578
1620
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
|
|
1579
1621
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
|
|
1580
|
-
/* @__PURE__ */
|
|
1622
|
+
/* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1581
1623
|
"Redirecting to ",
|
|
1582
1624
|
i,
|
|
1583
1625
|
"..."
|
|
@@ -1586,7 +1628,7 @@ const et = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1586
1628
|
}
|
|
1587
1629
|
)
|
|
1588
1630
|
}
|
|
1589
|
-
),
|
|
1631
|
+
), Te = ({
|
|
1590
1632
|
userType: i,
|
|
1591
1633
|
minUserType: e,
|
|
1592
1634
|
missingPermissions: t
|
|
@@ -1603,7 +1645,7 @@ const et = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1603
1645
|
backgroundColor: "#f9fafb",
|
|
1604
1646
|
textAlign: "center"
|
|
1605
1647
|
},
|
|
1606
|
-
children: /* @__PURE__ */
|
|
1648
|
+
children: /* @__PURE__ */ c(
|
|
1607
1649
|
"div",
|
|
1608
1650
|
{
|
|
1609
1651
|
style: {
|
|
@@ -1616,19 +1658,19 @@ const et = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1616
1658
|
children: [
|
|
1617
1659
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
|
|
1618
1660
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
|
|
1619
|
-
e && i ? /* @__PURE__ */
|
|
1620
|
-
/* @__PURE__ */
|
|
1661
|
+
e && i ? /* @__PURE__ */ c(B, { children: [
|
|
1662
|
+
/* @__PURE__ */ c("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
|
|
1621
1663
|
"This page requires ",
|
|
1622
1664
|
/* @__PURE__ */ n("strong", { children: e }),
|
|
1623
1665
|
" access level or higher."
|
|
1624
1666
|
] }),
|
|
1625
|
-
/* @__PURE__ */
|
|
1667
|
+
/* @__PURE__ */ c("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1626
1668
|
"Your current access level: ",
|
|
1627
1669
|
/* @__PURE__ */ n("strong", { children: i })
|
|
1628
1670
|
] })
|
|
1629
|
-
] }) : /* @__PURE__ */
|
|
1671
|
+
] }) : /* @__PURE__ */ c(B, { children: [
|
|
1630
1672
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
|
|
1631
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1673
|
+
t && t.length > 0 && /* @__PURE__ */ c("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1632
1674
|
"Required permissions: ",
|
|
1633
1675
|
/* @__PURE__ */ n("strong", { children: t.join(", ") })
|
|
1634
1676
|
] })
|
|
@@ -1637,7 +1679,7 @@ const et = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1637
1679
|
}
|
|
1638
1680
|
)
|
|
1639
1681
|
}
|
|
1640
|
-
),
|
|
1682
|
+
), nt = (i, e) => {
|
|
1641
1683
|
const t = {
|
|
1642
1684
|
[ie.USER]: 1,
|
|
1643
1685
|
[ie.TENANT_ADMIN]: 2,
|
|
@@ -1645,7 +1687,7 @@ const et = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1645
1687
|
};
|
|
1646
1688
|
return t[i] >= t[e];
|
|
1647
1689
|
};
|
|
1648
|
-
function
|
|
1690
|
+
function zt({
|
|
1649
1691
|
children: i,
|
|
1650
1692
|
redirectTo: e = "/login",
|
|
1651
1693
|
minUserType: t,
|
|
@@ -1653,24 +1695,24 @@ function Ut({
|
|
|
1653
1695
|
requireAllPermissions: s = !1,
|
|
1654
1696
|
fallback: o
|
|
1655
1697
|
}) {
|
|
1656
|
-
const { hasValidSession:
|
|
1657
|
-
if (!
|
|
1658
|
-
return o ? /* @__PURE__ */ n(
|
|
1659
|
-
/* @__PURE__ */ n(
|
|
1698
|
+
const { hasValidSession: g, sessionManager: w, hasPermission: x, hasAnyPermission: b, hasAllPermissions: A } = ae(), m = be();
|
|
1699
|
+
if (!g())
|
|
1700
|
+
return o ? /* @__PURE__ */ n(B, { children: o }) : /* @__PURE__ */ c(B, { children: [
|
|
1701
|
+
/* @__PURE__ */ n(rt, { redirectPath: e }),
|
|
1660
1702
|
/* @__PURE__ */ n(pe, { to: e, state: { from: m.pathname }, replace: !0 })
|
|
1661
1703
|
] });
|
|
1662
|
-
const f =
|
|
1704
|
+
const f = w.getUser();
|
|
1663
1705
|
if (!f)
|
|
1664
1706
|
return /* @__PURE__ */ n(pe, { to: e, state: { from: m.pathname }, replace: !0 });
|
|
1665
|
-
if (t && !
|
|
1666
|
-
return /* @__PURE__ */ n(
|
|
1667
|
-
if (r && r.length > 0 && !(s ?
|
|
1668
|
-
const y = r.filter((
|
|
1669
|
-
return /* @__PURE__ */ n(
|
|
1707
|
+
if (t && !nt(f.userType, t))
|
|
1708
|
+
return /* @__PURE__ */ n(Te, { userType: f.userType, minUserType: t });
|
|
1709
|
+
if (r && r.length > 0 && !(s ? A(r) : b(r))) {
|
|
1710
|
+
const y = r.filter((E) => !x(E)).map((E) => typeof E == "string" ? E : E.name);
|
|
1711
|
+
return /* @__PURE__ */ n(Te, { missingPermissions: y });
|
|
1670
1712
|
}
|
|
1671
|
-
return /* @__PURE__ */ n(
|
|
1713
|
+
return /* @__PURE__ */ n(B, { children: i });
|
|
1672
1714
|
}
|
|
1673
|
-
const
|
|
1715
|
+
const st = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1674
1716
|
"div",
|
|
1675
1717
|
{
|
|
1676
1718
|
style: {
|
|
@@ -1683,7 +1725,7 @@ const rt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1683
1725
|
backgroundColor: "#f9fafb",
|
|
1684
1726
|
textAlign: "center"
|
|
1685
1727
|
},
|
|
1686
|
-
children: /* @__PURE__ */
|
|
1728
|
+
children: /* @__PURE__ */ c(
|
|
1687
1729
|
"div",
|
|
1688
1730
|
{
|
|
1689
1731
|
style: {
|
|
@@ -1697,7 +1739,7 @@ const rt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1697
1739
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
|
|
1698
1740
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
|
|
1699
1741
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
|
|
1700
|
-
/* @__PURE__ */
|
|
1742
|
+
/* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1701
1743
|
"Redirecting to ",
|
|
1702
1744
|
i,
|
|
1703
1745
|
"..."
|
|
@@ -1707,14 +1749,14 @@ const rt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1707
1749
|
)
|
|
1708
1750
|
}
|
|
1709
1751
|
);
|
|
1710
|
-
function
|
|
1711
|
-
const { tenant: r, isLoading: s, error: o } = se(),
|
|
1712
|
-
return s || o ? null : r ? /* @__PURE__ */ n(
|
|
1713
|
-
/* @__PURE__ */ n(
|
|
1714
|
-
/* @__PURE__ */ n(pe, { to: e, state: { from:
|
|
1752
|
+
function Ot({ children: i, redirectTo: e = "/", fallback: t }) {
|
|
1753
|
+
const { tenant: r, isLoading: s, error: o } = se(), g = be();
|
|
1754
|
+
return s || o ? null : r ? /* @__PURE__ */ n(B, { children: i }) : t ? /* @__PURE__ */ n(B, { children: t }) : /* @__PURE__ */ c(B, { children: [
|
|
1755
|
+
/* @__PURE__ */ n(st, { redirectPath: e }),
|
|
1756
|
+
/* @__PURE__ */ n(pe, { to: e, state: { from: g.pathname }, replace: !0 })
|
|
1715
1757
|
] });
|
|
1716
1758
|
}
|
|
1717
|
-
const
|
|
1759
|
+
const it = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1718
1760
|
"div",
|
|
1719
1761
|
{
|
|
1720
1762
|
style: {
|
|
@@ -1727,7 +1769,7 @@ const nt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1727
1769
|
backgroundColor: "#f9fafb",
|
|
1728
1770
|
textAlign: "center"
|
|
1729
1771
|
},
|
|
1730
|
-
children: /* @__PURE__ */
|
|
1772
|
+
children: /* @__PURE__ */ c(
|
|
1731
1773
|
"div",
|
|
1732
1774
|
{
|
|
1733
1775
|
style: {
|
|
@@ -1741,7 +1783,7 @@ const nt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1741
1783
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
|
|
1742
1784
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
|
|
1743
1785
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
|
|
1744
|
-
/* @__PURE__ */
|
|
1786
|
+
/* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1745
1787
|
"Redirecting to ",
|
|
1746
1788
|
i,
|
|
1747
1789
|
"..."
|
|
@@ -1751,14 +1793,14 @@ const nt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1751
1793
|
)
|
|
1752
1794
|
}
|
|
1753
1795
|
);
|
|
1754
|
-
function
|
|
1755
|
-
const { tenant: r, isLoading: s, error: o } = se(),
|
|
1756
|
-
return s || o ? null : r ? t ? /* @__PURE__ */ n(
|
|
1757
|
-
/* @__PURE__ */ n(
|
|
1758
|
-
/* @__PURE__ */ n(pe, { to: e, state: { from:
|
|
1759
|
-
] }) : /* @__PURE__ */ n(
|
|
1796
|
+
function Wt({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
|
|
1797
|
+
const { tenant: r, isLoading: s, error: o } = se(), g = be();
|
|
1798
|
+
return s || o ? null : r ? t ? /* @__PURE__ */ n(B, { children: t }) : /* @__PURE__ */ c(B, { children: [
|
|
1799
|
+
/* @__PURE__ */ n(it, { redirectPath: e }),
|
|
1800
|
+
/* @__PURE__ */ n(pe, { to: e, state: { from: g.pathname }, replace: !0 })
|
|
1801
|
+
] }) : /* @__PURE__ */ n(B, { children: i });
|
|
1760
1802
|
}
|
|
1761
|
-
const
|
|
1803
|
+
const ot = () => /* @__PURE__ */ c(
|
|
1762
1804
|
"div",
|
|
1763
1805
|
{
|
|
1764
1806
|
style: {
|
|
@@ -1775,14 +1817,14 @@ const st = () => /* @__PURE__ */ l(
|
|
|
1775
1817
|
]
|
|
1776
1818
|
}
|
|
1777
1819
|
);
|
|
1778
|
-
function
|
|
1820
|
+
function Vt({
|
|
1779
1821
|
children: i,
|
|
1780
|
-
fallback: e = /* @__PURE__ */ n(
|
|
1822
|
+
fallback: e = /* @__PURE__ */ n(ot, {}),
|
|
1781
1823
|
allowedPlans: t,
|
|
1782
1824
|
requiredFeature: r
|
|
1783
1825
|
}) {
|
|
1784
|
-
const { subscription: s, hasAllowedPlan: o, isFeatureEnabled:
|
|
1785
|
-
return
|
|
1826
|
+
const { subscription: s, hasAllowedPlan: o, isFeatureEnabled: g, loading: w } = et();
|
|
1827
|
+
return w ? /* @__PURE__ */ n(
|
|
1786
1828
|
"div",
|
|
1787
1829
|
{
|
|
1788
1830
|
style: {
|
|
@@ -1792,9 +1834,9 @@ function Ot({
|
|
|
1792
1834
|
},
|
|
1793
1835
|
children: "Loading subscription..."
|
|
1794
1836
|
}
|
|
1795
|
-
) : s ? s.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ n(
|
|
1837
|
+
) : s ? s.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ n(B, { children: e }) : r && !g(r) ? /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: i }) : /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: e });
|
|
1796
1838
|
}
|
|
1797
|
-
const
|
|
1839
|
+
const at = ({ flagName: i }) => /* @__PURE__ */ c(
|
|
1798
1840
|
"div",
|
|
1799
1841
|
{
|
|
1800
1842
|
style: {
|
|
@@ -1813,7 +1855,7 @@ const it = ({ flagName: i }) => /* @__PURE__ */ l(
|
|
|
1813
1855
|
children: [
|
|
1814
1856
|
/* @__PURE__ */ n("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
|
|
1815
1857
|
/* @__PURE__ */ n("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
|
|
1816
|
-
/* @__PURE__ */
|
|
1858
|
+
/* @__PURE__ */ c("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
|
|
1817
1859
|
'Feature flag "',
|
|
1818
1860
|
i,
|
|
1819
1861
|
'" is disabled'
|
|
@@ -1821,8 +1863,8 @@ const it = ({ flagName: i }) => /* @__PURE__ */ l(
|
|
|
1821
1863
|
]
|
|
1822
1864
|
}
|
|
1823
1865
|
);
|
|
1824
|
-
function
|
|
1825
|
-
const { isEnabled: r, loading: s } =
|
|
1866
|
+
function jt({ name: i, children: e, fallback: t }) {
|
|
1867
|
+
const { isEnabled: r, loading: s } = Xe();
|
|
1826
1868
|
return s ? /* @__PURE__ */ n(
|
|
1827
1869
|
"div",
|
|
1828
1870
|
{
|
|
@@ -1836,9 +1878,9 @@ function Wt({ name: i, children: e, fallback: t }) {
|
|
|
1836
1878
|
},
|
|
1837
1879
|
children: "Loading feature flags..."
|
|
1838
1880
|
}
|
|
1839
|
-
) : r(i) ? /* @__PURE__ */ n(
|
|
1881
|
+
) : r(i) ? /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: t || /* @__PURE__ */ n(at, { flagName: i }) });
|
|
1840
1882
|
}
|
|
1841
|
-
const
|
|
1883
|
+
const lt = () => /* @__PURE__ */ c(
|
|
1842
1884
|
"svg",
|
|
1843
1885
|
{
|
|
1844
1886
|
width: "16",
|
|
@@ -1855,7 +1897,7 @@ const ot = () => /* @__PURE__ */ l(
|
|
|
1855
1897
|
/* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "3" })
|
|
1856
1898
|
]
|
|
1857
1899
|
}
|
|
1858
|
-
),
|
|
1900
|
+
), ct = () => /* @__PURE__ */ c(
|
|
1859
1901
|
"svg",
|
|
1860
1902
|
{
|
|
1861
1903
|
width: "16",
|
|
@@ -1872,10 +1914,10 @@ const ot = () => /* @__PURE__ */ l(
|
|
|
1872
1914
|
/* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
1873
1915
|
]
|
|
1874
1916
|
}
|
|
1875
|
-
),
|
|
1876
|
-
showPassword: /* @__PURE__ */ n(
|
|
1877
|
-
hidePassword: /* @__PURE__ */ n(
|
|
1878
|
-
},
|
|
1917
|
+
), dt = {
|
|
1918
|
+
showPassword: /* @__PURE__ */ n(lt, {}),
|
|
1919
|
+
hidePassword: /* @__PURE__ */ n(ct, {})
|
|
1920
|
+
}, ut = {
|
|
1879
1921
|
title: "Sign In",
|
|
1880
1922
|
usernameLabel: "Email or Phone",
|
|
1881
1923
|
usernamePlaceholder: "Enter your email or phone number",
|
|
@@ -1889,7 +1931,7 @@ const ot = () => /* @__PURE__ */ l(
|
|
|
1889
1931
|
magicLinkLink: "Use Magic Link",
|
|
1890
1932
|
errorMessage: "Invalid credentials",
|
|
1891
1933
|
loadingText: "Signing in..."
|
|
1892
|
-
},
|
|
1934
|
+
}, ht = {
|
|
1893
1935
|
container: {
|
|
1894
1936
|
maxWidth: "400px",
|
|
1895
1937
|
width: "100%",
|
|
@@ -1996,57 +2038,57 @@ const ot = () => /* @__PURE__ */ l(
|
|
|
1996
2038
|
fontSize: "0.875rem"
|
|
1997
2039
|
}
|
|
1998
2040
|
};
|
|
1999
|
-
function
|
|
2041
|
+
function _t({
|
|
2000
2042
|
copy: i = {},
|
|
2001
2043
|
styles: e = {},
|
|
2002
2044
|
icons: t = {},
|
|
2003
2045
|
onSuccess: r,
|
|
2004
2046
|
onError: s,
|
|
2005
2047
|
onForgotPassword: o,
|
|
2006
|
-
onSignupClick:
|
|
2007
|
-
onMagicLinkClick:
|
|
2008
|
-
showForgotPassword:
|
|
2009
|
-
showSignupLink:
|
|
2010
|
-
showMagicLinkOption:
|
|
2048
|
+
onSignupClick: g,
|
|
2049
|
+
onMagicLinkClick: w,
|
|
2050
|
+
showForgotPassword: x = !0,
|
|
2051
|
+
showSignupLink: b = !0,
|
|
2052
|
+
showMagicLinkOption: A = !0,
|
|
2011
2053
|
className: m
|
|
2012
2054
|
}) {
|
|
2013
|
-
const [f, u] =
|
|
2014
|
-
const
|
|
2015
|
-
return f.trim() || (
|
|
2016
|
-
},
|
|
2017
|
-
if (
|
|
2055
|
+
const [f, u] = v(""), [y, E] = v(""), [C, q] = v(!1), [T, d] = v(!1), [P, R] = v(""), [z, G] = v({}), { login: $ } = ae(), { tenant: _ } = se(), S = { ...ut, ...i }, M = { ...ht, ...e }, L = { ...dt, ...t }, l = () => {
|
|
2056
|
+
const a = {};
|
|
2057
|
+
return f.trim() || (a.username = !0), y.trim() || (a.password = !0), G(a), Object.keys(a).length === 0;
|
|
2058
|
+
}, I = async (a) => {
|
|
2059
|
+
if (a.preventDefault(), !!l()) {
|
|
2018
2060
|
if (!(_ != null && _.id)) {
|
|
2019
|
-
|
|
2061
|
+
R("Tenant not found");
|
|
2020
2062
|
return;
|
|
2021
2063
|
}
|
|
2022
|
-
d(!0),
|
|
2064
|
+
d(!0), R("");
|
|
2023
2065
|
try {
|
|
2024
|
-
const
|
|
2066
|
+
const p = await $({
|
|
2025
2067
|
username: f,
|
|
2026
2068
|
password: y
|
|
2027
2069
|
// tenantId inferred from context automatically
|
|
2028
2070
|
});
|
|
2029
|
-
r == null || r(
|
|
2030
|
-
} catch (
|
|
2031
|
-
const
|
|
2032
|
-
|
|
2071
|
+
r == null || r(p);
|
|
2072
|
+
} catch (p) {
|
|
2073
|
+
const O = p.message || S.errorMessage;
|
|
2074
|
+
R(O), s == null || s(O);
|
|
2033
2075
|
} finally {
|
|
2034
2076
|
d(!1);
|
|
2035
2077
|
}
|
|
2036
2078
|
}
|
|
2037
|
-
},
|
|
2079
|
+
}, k = (a) => ({
|
|
2038
2080
|
...M.input,
|
|
2039
|
-
...z[
|
|
2081
|
+
...z[a] ? M.inputError : {}
|
|
2040
2082
|
}), h = () => ({
|
|
2041
2083
|
...M.button,
|
|
2042
|
-
...
|
|
2043
|
-
...!f || !y ||
|
|
2084
|
+
...T ? M.buttonLoading : {},
|
|
2085
|
+
...!f || !y || T ? M.buttonDisabled : {}
|
|
2044
2086
|
});
|
|
2045
|
-
return /* @__PURE__ */
|
|
2046
|
-
/* @__PURE__ */ n("h2", { style: M.title, children:
|
|
2047
|
-
/* @__PURE__ */
|
|
2048
|
-
/* @__PURE__ */
|
|
2049
|
-
/* @__PURE__ */ n("label", { style: M.label, children:
|
|
2087
|
+
return /* @__PURE__ */ c("div", { className: m, style: M.container, children: [
|
|
2088
|
+
/* @__PURE__ */ n("h2", { style: M.title, children: S.title }),
|
|
2089
|
+
/* @__PURE__ */ c("form", { onSubmit: I, style: M.form, children: [
|
|
2090
|
+
/* @__PURE__ */ c("div", { style: M.fieldGroup, children: [
|
|
2091
|
+
/* @__PURE__ */ n("label", { style: M.label, children: S.usernameLabel }),
|
|
2050
2092
|
/* @__PURE__ */ n(
|
|
2051
2093
|
"input",
|
|
2052
2094
|
{
|
|
@@ -2054,18 +2096,18 @@ function jt({
|
|
|
2054
2096
|
name: "username",
|
|
2055
2097
|
type: "text",
|
|
2056
2098
|
value: f,
|
|
2057
|
-
onChange: (
|
|
2058
|
-
u(
|
|
2099
|
+
onChange: (a) => {
|
|
2100
|
+
u(a.target.value), z.username && G((p) => ({ ...p, username: !1 }));
|
|
2059
2101
|
},
|
|
2060
|
-
placeholder:
|
|
2061
|
-
style:
|
|
2062
|
-
disabled:
|
|
2102
|
+
placeholder: S.usernamePlaceholder,
|
|
2103
|
+
style: k("username"),
|
|
2104
|
+
disabled: T
|
|
2063
2105
|
}
|
|
2064
2106
|
)
|
|
2065
2107
|
] }),
|
|
2066
|
-
/* @__PURE__ */
|
|
2067
|
-
/* @__PURE__ */ n("label", { style: M.label, children:
|
|
2068
|
-
/* @__PURE__ */
|
|
2108
|
+
/* @__PURE__ */ c("div", { style: M.fieldGroup, children: [
|
|
2109
|
+
/* @__PURE__ */ n("label", { style: M.label, children: S.passwordLabel }),
|
|
2110
|
+
/* @__PURE__ */ c("div", { style: M.inputContainer, children: [
|
|
2069
2111
|
/* @__PURE__ */ n(
|
|
2070
2112
|
"input",
|
|
2071
2113
|
{
|
|
@@ -2073,16 +2115,16 @@ function jt({
|
|
|
2073
2115
|
name: "password",
|
|
2074
2116
|
type: C ? "text" : "password",
|
|
2075
2117
|
value: y,
|
|
2076
|
-
onChange: (
|
|
2077
|
-
|
|
2118
|
+
onChange: (a) => {
|
|
2119
|
+
E(a.target.value), z.password && G((p) => ({ ...p, password: !1 }));
|
|
2078
2120
|
},
|
|
2079
|
-
placeholder:
|
|
2121
|
+
placeholder: S.passwordPlaceholder,
|
|
2080
2122
|
style: {
|
|
2081
|
-
...
|
|
2123
|
+
...k("password"),
|
|
2082
2124
|
paddingRight: "2.5rem"
|
|
2083
2125
|
// Make room for the icon
|
|
2084
2126
|
},
|
|
2085
|
-
disabled:
|
|
2127
|
+
disabled: T
|
|
2086
2128
|
}
|
|
2087
2129
|
),
|
|
2088
2130
|
/* @__PURE__ */ n(
|
|
@@ -2091,38 +2133,38 @@ function jt({
|
|
|
2091
2133
|
type: "button",
|
|
2092
2134
|
onClick: () => q(!C),
|
|
2093
2135
|
style: M.passwordToggle,
|
|
2094
|
-
disabled:
|
|
2136
|
+
disabled: T,
|
|
2095
2137
|
"aria-label": C ? "Hide password" : "Show password",
|
|
2096
|
-
children: C ?
|
|
2138
|
+
children: C ? L.hidePassword : L.showPassword
|
|
2097
2139
|
}
|
|
2098
2140
|
)
|
|
2099
2141
|
] })
|
|
2100
2142
|
] }),
|
|
2101
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !f || !y ||
|
|
2143
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !f || !y || T, style: h(), children: T ? S.loadingText : S.submitButton }),
|
|
2102
2144
|
P && /* @__PURE__ */ n("div", { style: M.errorText, children: P })
|
|
2103
2145
|
] }),
|
|
2104
|
-
(
|
|
2105
|
-
|
|
2106
|
-
/* @__PURE__ */
|
|
2107
|
-
|
|
2146
|
+
(x || b || A) && /* @__PURE__ */ c("div", { style: M.linkContainer, children: [
|
|
2147
|
+
A && /* @__PURE__ */ c("div", { children: [
|
|
2148
|
+
/* @__PURE__ */ c("span", { style: M.divider, children: [
|
|
2149
|
+
S.magicLinkText,
|
|
2108
2150
|
" "
|
|
2109
2151
|
] }),
|
|
2110
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
2152
|
+
/* @__PURE__ */ n("a", { onClick: w, style: M.link, children: S.magicLinkLink })
|
|
2111
2153
|
] }),
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
/* @__PURE__ */
|
|
2117
|
-
|
|
2154
|
+
A && (x || b) && /* @__PURE__ */ n("div", { style: M.divider, children: "•" }),
|
|
2155
|
+
x && /* @__PURE__ */ n("a", { onClick: o, style: M.link, children: S.forgotPasswordLink }),
|
|
2156
|
+
x && b && /* @__PURE__ */ n("div", { style: M.divider, children: "•" }),
|
|
2157
|
+
b && /* @__PURE__ */ c("div", { children: [
|
|
2158
|
+
/* @__PURE__ */ c("span", { style: M.divider, children: [
|
|
2159
|
+
S.signupText,
|
|
2118
2160
|
" "
|
|
2119
2161
|
] }),
|
|
2120
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
2162
|
+
/* @__PURE__ */ n("a", { onClick: g, style: M.link, children: S.signupLink })
|
|
2121
2163
|
] })
|
|
2122
2164
|
] })
|
|
2123
2165
|
] });
|
|
2124
2166
|
}
|
|
2125
|
-
const
|
|
2167
|
+
const gt = {
|
|
2126
2168
|
title: "Create Account",
|
|
2127
2169
|
nameLabel: "First Name",
|
|
2128
2170
|
namePlaceholder: "Enter your first name",
|
|
@@ -2148,7 +2190,7 @@ const ut = {
|
|
|
2148
2190
|
passwordMismatchError: "Passwords do not match",
|
|
2149
2191
|
isAdminLabel: "Create new organization",
|
|
2150
2192
|
isAdminDescription: "Check this if you want to create a new organization"
|
|
2151
|
-
},
|
|
2193
|
+
}, pt = {
|
|
2152
2194
|
container: {
|
|
2153
2195
|
maxWidth: "400px",
|
|
2154
2196
|
width: "100%",
|
|
@@ -2247,25 +2289,25 @@ const ut = {
|
|
|
2247
2289
|
fontSize: "0.875rem"
|
|
2248
2290
|
}
|
|
2249
2291
|
};
|
|
2250
|
-
function
|
|
2292
|
+
function Gt({
|
|
2251
2293
|
copy: i = {},
|
|
2252
2294
|
styles: e = {},
|
|
2253
2295
|
signupType: t = "user",
|
|
2254
2296
|
onSuccess: r,
|
|
2255
2297
|
onError: s,
|
|
2256
2298
|
onLoginClick: o,
|
|
2257
|
-
onMagicLinkClick:
|
|
2258
|
-
showLoginLink:
|
|
2259
|
-
showMagicLinkOption:
|
|
2260
|
-
className:
|
|
2299
|
+
onMagicLinkClick: g,
|
|
2300
|
+
showLoginLink: w = !0,
|
|
2301
|
+
showMagicLinkOption: x = !0,
|
|
2302
|
+
className: b
|
|
2261
2303
|
}) {
|
|
2262
|
-
const [
|
|
2263
|
-
const
|
|
2264
|
-
return
|
|
2265
|
-
},
|
|
2266
|
-
if (
|
|
2267
|
-
if (
|
|
2268
|
-
M(
|
|
2304
|
+
const [A, m] = v(""), [f, u] = v(""), [y, E] = v(""), [C, q] = v(""), [T, d] = v(""), [P, R] = v(""), [z, G] = v(""), [$, _] = v(!1), [S, M] = v(""), [L, l] = v({}), { signup: I, signupTenantAdmin: k } = ae(), { tenant: h } = se(), a = { ...gt, ...i }, p = { ...pt, ...e }, O = () => {
|
|
2305
|
+
const D = {};
|
|
2306
|
+
return A.trim() || (D.name = !0), !y.trim() && !C.trim() && (D.email = !0, D.phoneNumber = !0), T.trim() || (D.password = !0), P.trim() || (D.confirmPassword = !0), t === "tenant" && !z.trim() && (D.tenantName = !0), l(D), Object.keys(D).length === 0;
|
|
2307
|
+
}, K = async (D) => {
|
|
2308
|
+
if (D.preventDefault(), !!O()) {
|
|
2309
|
+
if (T !== P) {
|
|
2310
|
+
M(a.passwordMismatchError), l({ confirmPassword: !0 });
|
|
2269
2311
|
return;
|
|
2270
2312
|
}
|
|
2271
2313
|
if (t === "user" && !(h != null && h.id)) {
|
|
@@ -2274,60 +2316,60 @@ function Vt({
|
|
|
2274
2316
|
}
|
|
2275
2317
|
_(!0), M("");
|
|
2276
2318
|
try {
|
|
2277
|
-
let
|
|
2278
|
-
t === "tenant" ?
|
|
2319
|
+
let J;
|
|
2320
|
+
t === "tenant" ? J = await k({
|
|
2279
2321
|
email: y || void 0,
|
|
2280
2322
|
phoneNumber: C || void 0,
|
|
2281
|
-
name:
|
|
2282
|
-
password:
|
|
2323
|
+
name: A,
|
|
2324
|
+
password: T,
|
|
2283
2325
|
tenantName: z,
|
|
2284
2326
|
lastName: f || void 0
|
|
2285
|
-
}) :
|
|
2327
|
+
}) : J = await I({
|
|
2286
2328
|
email: y || void 0,
|
|
2287
2329
|
phoneNumber: C || void 0,
|
|
2288
|
-
name:
|
|
2289
|
-
password:
|
|
2330
|
+
name: A,
|
|
2331
|
+
password: T,
|
|
2290
2332
|
tenantId: h.id,
|
|
2291
2333
|
lastName: f || void 0
|
|
2292
|
-
}), r == null || r(
|
|
2293
|
-
} catch (
|
|
2294
|
-
const ge =
|
|
2334
|
+
}), r == null || r(J);
|
|
2335
|
+
} catch (J) {
|
|
2336
|
+
const ge = J.message || a.errorMessage;
|
|
2295
2337
|
M(ge), s == null || s(ge);
|
|
2296
2338
|
} finally {
|
|
2297
2339
|
_(!1);
|
|
2298
2340
|
}
|
|
2299
2341
|
}
|
|
2300
|
-
}, H = (
|
|
2301
|
-
...
|
|
2302
|
-
...
|
|
2342
|
+
}, H = (D) => ({
|
|
2343
|
+
...p.input,
|
|
2344
|
+
...L[D] ? p.inputError : {}
|
|
2303
2345
|
}), N = () => ({
|
|
2304
|
-
...
|
|
2305
|
-
...$ ?
|
|
2306
|
-
...!
|
|
2307
|
-
}),
|
|
2308
|
-
return /* @__PURE__ */
|
|
2309
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2310
|
-
/* @__PURE__ */
|
|
2311
|
-
/* @__PURE__ */
|
|
2312
|
-
/* @__PURE__ */ n("label", { style:
|
|
2346
|
+
...p.button,
|
|
2347
|
+
...$ ? p.buttonLoading : {},
|
|
2348
|
+
...!A || !y && !C || !T || !P || $ || t === "tenant" && !z ? p.buttonDisabled : {}
|
|
2349
|
+
}), W = A && (y || C) && T && P && (t === "user" || z);
|
|
2350
|
+
return /* @__PURE__ */ c("div", { className: b, style: p.container, children: [
|
|
2351
|
+
/* @__PURE__ */ n("h2", { style: p.title, children: a.title }),
|
|
2352
|
+
/* @__PURE__ */ c("form", { onSubmit: K, style: p.form, children: [
|
|
2353
|
+
/* @__PURE__ */ c("div", { style: p.fieldGroup, children: [
|
|
2354
|
+
/* @__PURE__ */ n("label", { style: p.label, children: a.nameLabel }),
|
|
2313
2355
|
/* @__PURE__ */ n(
|
|
2314
2356
|
"input",
|
|
2315
2357
|
{
|
|
2316
2358
|
id: "name",
|
|
2317
2359
|
name: "name",
|
|
2318
2360
|
type: "text",
|
|
2319
|
-
value:
|
|
2320
|
-
onChange: (
|
|
2321
|
-
m(
|
|
2361
|
+
value: A,
|
|
2362
|
+
onChange: (D) => {
|
|
2363
|
+
m(D.target.value), L.name && l((J) => ({ ...J, name: !1 }));
|
|
2322
2364
|
},
|
|
2323
|
-
placeholder:
|
|
2365
|
+
placeholder: a.namePlaceholder,
|
|
2324
2366
|
style: H("name"),
|
|
2325
2367
|
disabled: $
|
|
2326
2368
|
}
|
|
2327
2369
|
)
|
|
2328
2370
|
] }),
|
|
2329
|
-
/* @__PURE__ */
|
|
2330
|
-
/* @__PURE__ */ n("label", { style:
|
|
2371
|
+
/* @__PURE__ */ c("div", { style: p.fieldGroup, children: [
|
|
2372
|
+
/* @__PURE__ */ n("label", { style: p.label, children: a.lastNameLabel }),
|
|
2331
2373
|
/* @__PURE__ */ n(
|
|
2332
2374
|
"input",
|
|
2333
2375
|
{
|
|
@@ -2335,15 +2377,15 @@ function Vt({
|
|
|
2335
2377
|
name: "lastName",
|
|
2336
2378
|
type: "text",
|
|
2337
2379
|
value: f,
|
|
2338
|
-
onChange: (
|
|
2339
|
-
placeholder:
|
|
2340
|
-
style:
|
|
2380
|
+
onChange: (D) => u(D.target.value),
|
|
2381
|
+
placeholder: a.lastNamePlaceholder,
|
|
2382
|
+
style: p.input,
|
|
2341
2383
|
disabled: $
|
|
2342
2384
|
}
|
|
2343
2385
|
)
|
|
2344
2386
|
] }),
|
|
2345
|
-
/* @__PURE__ */
|
|
2346
|
-
/* @__PURE__ */ n("label", { style:
|
|
2387
|
+
/* @__PURE__ */ c("div", { style: p.fieldGroup, children: [
|
|
2388
|
+
/* @__PURE__ */ n("label", { style: p.label, children: a.emailLabel }),
|
|
2347
2389
|
/* @__PURE__ */ n(
|
|
2348
2390
|
"input",
|
|
2349
2391
|
{
|
|
@@ -2351,17 +2393,17 @@ function Vt({
|
|
|
2351
2393
|
name: "email",
|
|
2352
2394
|
type: "email",
|
|
2353
2395
|
value: y,
|
|
2354
|
-
onChange: (
|
|
2355
|
-
|
|
2396
|
+
onChange: (D) => {
|
|
2397
|
+
E(D.target.value), L.email && l((J) => ({ ...J, email: !1, phoneNumber: !1 }));
|
|
2356
2398
|
},
|
|
2357
|
-
placeholder:
|
|
2399
|
+
placeholder: a.emailPlaceholder,
|
|
2358
2400
|
style: H("email"),
|
|
2359
2401
|
disabled: $
|
|
2360
2402
|
}
|
|
2361
2403
|
)
|
|
2362
2404
|
] }),
|
|
2363
|
-
/* @__PURE__ */
|
|
2364
|
-
/* @__PURE__ */ n("label", { style:
|
|
2405
|
+
/* @__PURE__ */ c("div", { style: p.fieldGroup, children: [
|
|
2406
|
+
/* @__PURE__ */ n("label", { style: p.label, children: a.phoneNumberLabel }),
|
|
2365
2407
|
/* @__PURE__ */ n(
|
|
2366
2408
|
"input",
|
|
2367
2409
|
{
|
|
@@ -2369,10 +2411,10 @@ function Vt({
|
|
|
2369
2411
|
name: "phoneNumber",
|
|
2370
2412
|
type: "tel",
|
|
2371
2413
|
value: C,
|
|
2372
|
-
onChange: (
|
|
2373
|
-
q(
|
|
2414
|
+
onChange: (D) => {
|
|
2415
|
+
q(D.target.value), L.phoneNumber && l((J) => ({ ...J, email: !1, phoneNumber: !1 }));
|
|
2374
2416
|
},
|
|
2375
|
-
placeholder:
|
|
2417
|
+
placeholder: a.phoneNumberPlaceholder,
|
|
2376
2418
|
style: H("phoneNumber"),
|
|
2377
2419
|
disabled: $
|
|
2378
2420
|
}
|
|
@@ -2390,26 +2432,26 @@ function Vt({
|
|
|
2390
2432
|
children: "At least one contact method (email or phone) is required"
|
|
2391
2433
|
}
|
|
2392
2434
|
),
|
|
2393
|
-
/* @__PURE__ */
|
|
2394
|
-
/* @__PURE__ */ n("label", { style:
|
|
2435
|
+
/* @__PURE__ */ c("div", { style: p.fieldGroup, children: [
|
|
2436
|
+
/* @__PURE__ */ n("label", { style: p.label, children: a.passwordLabel }),
|
|
2395
2437
|
/* @__PURE__ */ n(
|
|
2396
2438
|
"input",
|
|
2397
2439
|
{
|
|
2398
2440
|
id: "password",
|
|
2399
2441
|
name: "password",
|
|
2400
2442
|
type: "password",
|
|
2401
|
-
value:
|
|
2402
|
-
onChange: (
|
|
2403
|
-
d(
|
|
2443
|
+
value: T,
|
|
2444
|
+
onChange: (D) => {
|
|
2445
|
+
d(D.target.value), L.password && l((J) => ({ ...J, password: !1 }));
|
|
2404
2446
|
},
|
|
2405
|
-
placeholder:
|
|
2447
|
+
placeholder: a.passwordPlaceholder,
|
|
2406
2448
|
style: H("password"),
|
|
2407
2449
|
disabled: $
|
|
2408
2450
|
}
|
|
2409
2451
|
)
|
|
2410
2452
|
] }),
|
|
2411
|
-
/* @__PURE__ */
|
|
2412
|
-
/* @__PURE__ */ n("label", { style:
|
|
2453
|
+
/* @__PURE__ */ c("div", { style: p.fieldGroup, children: [
|
|
2454
|
+
/* @__PURE__ */ n("label", { style: p.label, children: a.confirmPasswordLabel }),
|
|
2413
2455
|
/* @__PURE__ */ n(
|
|
2414
2456
|
"input",
|
|
2415
2457
|
{
|
|
@@ -2417,17 +2459,17 @@ function Vt({
|
|
|
2417
2459
|
name: "confirmPassword",
|
|
2418
2460
|
type: "password",
|
|
2419
2461
|
value: P,
|
|
2420
|
-
onChange: (
|
|
2421
|
-
|
|
2462
|
+
onChange: (D) => {
|
|
2463
|
+
R(D.target.value), L.confirmPassword && l((J) => ({ ...J, confirmPassword: !1 })), S === a.passwordMismatchError && M("");
|
|
2422
2464
|
},
|
|
2423
|
-
placeholder:
|
|
2465
|
+
placeholder: a.confirmPasswordPlaceholder,
|
|
2424
2466
|
style: H("confirmPassword"),
|
|
2425
2467
|
disabled: $
|
|
2426
2468
|
}
|
|
2427
2469
|
)
|
|
2428
2470
|
] }),
|
|
2429
|
-
t === "tenant" && /* @__PURE__ */
|
|
2430
|
-
/* @__PURE__ */ n("label", { style:
|
|
2471
|
+
t === "tenant" && /* @__PURE__ */ c("div", { style: p.fieldGroup, children: [
|
|
2472
|
+
/* @__PURE__ */ n("label", { style: p.label, children: a.tenantNameLabel }),
|
|
2431
2473
|
/* @__PURE__ */ n(
|
|
2432
2474
|
"input",
|
|
2433
2475
|
{
|
|
@@ -2435,38 +2477,38 @@ function Vt({
|
|
|
2435
2477
|
name: "tenantName",
|
|
2436
2478
|
type: "text",
|
|
2437
2479
|
value: z,
|
|
2438
|
-
onChange: (
|
|
2439
|
-
G(
|
|
2480
|
+
onChange: (D) => {
|
|
2481
|
+
G(D.target.value), L.tenantName && l((J) => ({ ...J, tenantName: !1 }));
|
|
2440
2482
|
},
|
|
2441
|
-
placeholder:
|
|
2483
|
+
placeholder: a.tenantNamePlaceholder,
|
|
2442
2484
|
style: H("tenantName"),
|
|
2443
2485
|
disabled: $
|
|
2444
2486
|
}
|
|
2445
2487
|
)
|
|
2446
2488
|
] }),
|
|
2447
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !
|
|
2448
|
-
|
|
2489
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !W || $, style: N(), children: $ ? a.loadingText : a.submitButton }),
|
|
2490
|
+
S && /* @__PURE__ */ n("div", { style: p.errorText, children: S })
|
|
2449
2491
|
] }),
|
|
2450
|
-
(
|
|
2451
|
-
|
|
2452
|
-
/* @__PURE__ */
|
|
2453
|
-
|
|
2492
|
+
(w || x) && /* @__PURE__ */ c("div", { style: p.linkContainer, children: [
|
|
2493
|
+
x && /* @__PURE__ */ c("div", { children: [
|
|
2494
|
+
/* @__PURE__ */ c("span", { style: p.divider, children: [
|
|
2495
|
+
a.magicLinkText,
|
|
2454
2496
|
" "
|
|
2455
2497
|
] }),
|
|
2456
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
2498
|
+
/* @__PURE__ */ n("a", { onClick: g, style: p.link, children: a.magicLinkLink })
|
|
2457
2499
|
] }),
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
/* @__PURE__ */
|
|
2461
|
-
|
|
2500
|
+
x && w && /* @__PURE__ */ n("div", { style: p.divider, children: "•" }),
|
|
2501
|
+
w && /* @__PURE__ */ c("div", { children: [
|
|
2502
|
+
/* @__PURE__ */ c("span", { style: p.divider, children: [
|
|
2503
|
+
a.loginText,
|
|
2462
2504
|
" "
|
|
2463
2505
|
] }),
|
|
2464
|
-
/* @__PURE__ */ n("a", { onClick: o, style:
|
|
2506
|
+
/* @__PURE__ */ n("a", { onClick: o, style: p.link, children: a.loginLink })
|
|
2465
2507
|
] })
|
|
2466
2508
|
] })
|
|
2467
2509
|
] });
|
|
2468
2510
|
}
|
|
2469
|
-
const
|
|
2511
|
+
const ft = {
|
|
2470
2512
|
title: "Sign In with Magic Link",
|
|
2471
2513
|
emailLabel: "Email",
|
|
2472
2514
|
emailPlaceholder: "Enter your email",
|
|
@@ -2484,7 +2526,7 @@ const gt = {
|
|
|
2484
2526
|
loadingText: "Sending magic link...",
|
|
2485
2527
|
verifyingText: "Verifying magic link...",
|
|
2486
2528
|
description: "Enter your email to receive a magic link. If you don't have an account, we'll create one for you."
|
|
2487
|
-
},
|
|
2529
|
+
}, mt = {
|
|
2488
2530
|
container: {
|
|
2489
2531
|
maxWidth: "400px",
|
|
2490
2532
|
width: "100%",
|
|
@@ -2587,101 +2629,101 @@ const gt = {
|
|
|
2587
2629
|
fontSize: "0.875rem"
|
|
2588
2630
|
}
|
|
2589
2631
|
};
|
|
2590
|
-
function
|
|
2632
|
+
function Kt({
|
|
2591
2633
|
copy: i = {},
|
|
2592
2634
|
styles: e = {},
|
|
2593
2635
|
onSuccess: t,
|
|
2594
2636
|
onError: r,
|
|
2595
2637
|
onLoginClick: s,
|
|
2596
2638
|
onSignupClick: o,
|
|
2597
|
-
showTraditionalLinks:
|
|
2598
|
-
className:
|
|
2599
|
-
verifyToken:
|
|
2600
|
-
frontendUrl:
|
|
2639
|
+
showTraditionalLinks: g = !0,
|
|
2640
|
+
className: w,
|
|
2641
|
+
verifyToken: x,
|
|
2642
|
+
frontendUrl: b
|
|
2601
2643
|
}) {
|
|
2602
|
-
const [
|
|
2644
|
+
const [A, m] = v(""), [f, u] = v(""), [y, E] = v(""), [C, q] = v(!1), [T, d] = v(!1), [P, R] = v(""), [z, G] = v(""), [$, _] = v({}), [S, M] = v(!1), { sendMagicLink: L, verifyMagicLink: l } = ae(), { tenant: I } = se(), k = { ...ft, ...i }, h = { ...mt, ...e };
|
|
2603
2645
|
te(() => {
|
|
2604
|
-
|
|
2605
|
-
}, [
|
|
2606
|
-
const
|
|
2607
|
-
if (!
|
|
2608
|
-
|
|
2646
|
+
x && a(x);
|
|
2647
|
+
}, [x]);
|
|
2648
|
+
const a = async (N) => {
|
|
2649
|
+
if (!I || !A) {
|
|
2650
|
+
R("Missing tenant or email");
|
|
2609
2651
|
return;
|
|
2610
2652
|
}
|
|
2611
|
-
d(!0),
|
|
2653
|
+
d(!0), R("");
|
|
2612
2654
|
try {
|
|
2613
|
-
const
|
|
2655
|
+
const W = await l({
|
|
2614
2656
|
token: N,
|
|
2615
|
-
email:
|
|
2657
|
+
email: A
|
|
2616
2658
|
// tenantId inferred from context automatically
|
|
2617
2659
|
});
|
|
2618
|
-
t == null || t(
|
|
2619
|
-
} catch (
|
|
2620
|
-
const
|
|
2621
|
-
|
|
2660
|
+
t == null || t(W);
|
|
2661
|
+
} catch (W) {
|
|
2662
|
+
const D = W.message || "Failed to verify magic link";
|
|
2663
|
+
R(D), r == null || r(D);
|
|
2622
2664
|
} finally {
|
|
2623
2665
|
d(!1);
|
|
2624
2666
|
}
|
|
2625
|
-
},
|
|
2667
|
+
}, p = () => {
|
|
2626
2668
|
const N = {};
|
|
2627
|
-
return
|
|
2628
|
-
},
|
|
2629
|
-
if (N.preventDefault(), !!
|
|
2630
|
-
if (!(
|
|
2631
|
-
|
|
2669
|
+
return A.trim() || (N.email = !0), S && !f.trim() && (N.name = !0), _(N), Object.keys(N).length === 0;
|
|
2670
|
+
}, O = async (N) => {
|
|
2671
|
+
if (N.preventDefault(), !!p()) {
|
|
2672
|
+
if (!(I != null && I.id)) {
|
|
2673
|
+
R("Tenant not found");
|
|
2632
2674
|
return;
|
|
2633
2675
|
}
|
|
2634
|
-
q(!0),
|
|
2676
|
+
q(!0), R(""), G("");
|
|
2635
2677
|
try {
|
|
2636
|
-
const
|
|
2637
|
-
email:
|
|
2638
|
-
tenantId:
|
|
2639
|
-
frontendUrl:
|
|
2640
|
-
name:
|
|
2641
|
-
lastName:
|
|
2678
|
+
const W = b || (typeof window < "u" ? window.location.origin : ""), D = await L({
|
|
2679
|
+
email: A,
|
|
2680
|
+
tenantId: I.id,
|
|
2681
|
+
frontendUrl: W,
|
|
2682
|
+
name: S ? f : void 0,
|
|
2683
|
+
lastName: S ? y : void 0
|
|
2642
2684
|
});
|
|
2643
|
-
G(
|
|
2644
|
-
} catch (
|
|
2645
|
-
const
|
|
2646
|
-
|
|
2685
|
+
G(k.successMessage), t == null || t(D);
|
|
2686
|
+
} catch (W) {
|
|
2687
|
+
const D = W.message || k.errorMessage;
|
|
2688
|
+
R(D), r == null || r(D);
|
|
2647
2689
|
} finally {
|
|
2648
2690
|
q(!1);
|
|
2649
2691
|
}
|
|
2650
2692
|
}
|
|
2651
|
-
},
|
|
2693
|
+
}, K = (N) => ({
|
|
2652
2694
|
...h.input,
|
|
2653
2695
|
...$[N] ? h.inputError : {}
|
|
2654
2696
|
}), H = () => ({
|
|
2655
2697
|
...h.button,
|
|
2656
|
-
...C ||
|
|
2657
|
-
...!
|
|
2698
|
+
...C || T ? h.buttonLoading : {},
|
|
2699
|
+
...!A || C || T ? h.buttonDisabled : {}
|
|
2658
2700
|
});
|
|
2659
|
-
return
|
|
2660
|
-
/* @__PURE__ */ n("h2", { style: h.title, children:
|
|
2701
|
+
return T ? /* @__PURE__ */ c("div", { className: w, style: h.container, children: [
|
|
2702
|
+
/* @__PURE__ */ n("h2", { style: h.title, children: k.verifyingText }),
|
|
2661
2703
|
/* @__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..." }) })
|
|
2662
|
-
] }) : /* @__PURE__ */
|
|
2663
|
-
/* @__PURE__ */ n("h2", { style: h.title, children:
|
|
2664
|
-
/* @__PURE__ */ n("p", { style: h.description, children:
|
|
2665
|
-
/* @__PURE__ */
|
|
2666
|
-
/* @__PURE__ */
|
|
2667
|
-
/* @__PURE__ */ n("label", { style: h.label, children:
|
|
2704
|
+
] }) : /* @__PURE__ */ c("div", { className: w, style: h.container, children: [
|
|
2705
|
+
/* @__PURE__ */ n("h2", { style: h.title, children: k.title }),
|
|
2706
|
+
/* @__PURE__ */ n("p", { style: h.description, children: k.description }),
|
|
2707
|
+
/* @__PURE__ */ c("form", { onSubmit: O, style: h.form, children: [
|
|
2708
|
+
/* @__PURE__ */ c("div", { style: h.fieldGroup, children: [
|
|
2709
|
+
/* @__PURE__ */ n("label", { style: h.label, children: k.emailLabel }),
|
|
2668
2710
|
/* @__PURE__ */ n(
|
|
2669
2711
|
"input",
|
|
2670
2712
|
{
|
|
2671
2713
|
id: "email",
|
|
2672
2714
|
name: "email",
|
|
2673
2715
|
type: "email",
|
|
2674
|
-
value:
|
|
2716
|
+
value: A,
|
|
2675
2717
|
onChange: (N) => {
|
|
2676
|
-
m(N.target.value), $.email && _((
|
|
2718
|
+
m(N.target.value), $.email && _((W) => ({ ...W, email: !1 }));
|
|
2677
2719
|
},
|
|
2678
|
-
placeholder:
|
|
2679
|
-
style:
|
|
2680
|
-
disabled: C ||
|
|
2720
|
+
placeholder: k.emailPlaceholder,
|
|
2721
|
+
style: K("email"),
|
|
2722
|
+
disabled: C || T
|
|
2681
2723
|
}
|
|
2682
2724
|
)
|
|
2683
2725
|
] }),
|
|
2684
|
-
!
|
|
2726
|
+
!S && /* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
|
|
2685
2727
|
"button",
|
|
2686
2728
|
{
|
|
2687
2729
|
type: "button",
|
|
@@ -2697,9 +2739,9 @@ function _t({
|
|
|
2697
2739
|
children: "New user? Add your name"
|
|
2698
2740
|
}
|
|
2699
2741
|
) }),
|
|
2700
|
-
|
|
2701
|
-
/* @__PURE__ */
|
|
2702
|
-
/* @__PURE__ */ n("label", { style: h.label, children:
|
|
2742
|
+
S && /* @__PURE__ */ c(B, { children: [
|
|
2743
|
+
/* @__PURE__ */ c("div", { style: h.fieldGroup, children: [
|
|
2744
|
+
/* @__PURE__ */ n("label", { style: h.label, children: k.nameLabel }),
|
|
2703
2745
|
/* @__PURE__ */ n(
|
|
2704
2746
|
"input",
|
|
2705
2747
|
{
|
|
@@ -2708,16 +2750,16 @@ function _t({
|
|
|
2708
2750
|
type: "text",
|
|
2709
2751
|
value: f,
|
|
2710
2752
|
onChange: (N) => {
|
|
2711
|
-
u(N.target.value), $.name && _((
|
|
2753
|
+
u(N.target.value), $.name && _((W) => ({ ...W, name: !1 }));
|
|
2712
2754
|
},
|
|
2713
|
-
placeholder:
|
|
2714
|
-
style:
|
|
2715
|
-
disabled: C ||
|
|
2755
|
+
placeholder: k.namePlaceholder,
|
|
2756
|
+
style: K("name"),
|
|
2757
|
+
disabled: C || T
|
|
2716
2758
|
}
|
|
2717
2759
|
)
|
|
2718
2760
|
] }),
|
|
2719
|
-
/* @__PURE__ */
|
|
2720
|
-
/* @__PURE__ */ n("label", { style: h.label, children:
|
|
2761
|
+
/* @__PURE__ */ c("div", { style: h.fieldGroup, children: [
|
|
2762
|
+
/* @__PURE__ */ n("label", { style: h.label, children: k.lastNameLabel }),
|
|
2721
2763
|
/* @__PURE__ */ n(
|
|
2722
2764
|
"input",
|
|
2723
2765
|
{
|
|
@@ -2725,10 +2767,10 @@ function _t({
|
|
|
2725
2767
|
name: "lastName",
|
|
2726
2768
|
type: "text",
|
|
2727
2769
|
value: y,
|
|
2728
|
-
onChange: (N) =>
|
|
2729
|
-
placeholder:
|
|
2770
|
+
onChange: (N) => E(N.target.value),
|
|
2771
|
+
placeholder: k.lastNamePlaceholder,
|
|
2730
2772
|
style: h.input,
|
|
2731
|
-
disabled: C ||
|
|
2773
|
+
disabled: C || T
|
|
2732
2774
|
}
|
|
2733
2775
|
)
|
|
2734
2776
|
] }),
|
|
@@ -2737,7 +2779,7 @@ function _t({
|
|
|
2737
2779
|
{
|
|
2738
2780
|
type: "button",
|
|
2739
2781
|
onClick: () => {
|
|
2740
|
-
M(!1), u(""),
|
|
2782
|
+
M(!1), u(""), E("");
|
|
2741
2783
|
},
|
|
2742
2784
|
style: {
|
|
2743
2785
|
background: "none",
|
|
@@ -2751,30 +2793,30 @@ function _t({
|
|
|
2751
2793
|
}
|
|
2752
2794
|
) })
|
|
2753
2795
|
] }),
|
|
2754
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !
|
|
2796
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !A || C || T, style: H(), children: C ? k.loadingText : k.submitButton }),
|
|
2755
2797
|
P && /* @__PURE__ */ n("div", { style: h.errorText, children: P }),
|
|
2756
2798
|
z && /* @__PURE__ */ n("div", { style: h.successText, children: z })
|
|
2757
2799
|
] }),
|
|
2758
|
-
|
|
2759
|
-
/* @__PURE__ */
|
|
2760
|
-
/* @__PURE__ */
|
|
2761
|
-
|
|
2800
|
+
g && /* @__PURE__ */ c("div", { style: h.linkContainer, children: [
|
|
2801
|
+
/* @__PURE__ */ c("div", { children: [
|
|
2802
|
+
/* @__PURE__ */ c("span", { style: h.divider, children: [
|
|
2803
|
+
k.loginText,
|
|
2762
2804
|
" "
|
|
2763
2805
|
] }),
|
|
2764
|
-
/* @__PURE__ */ n("a", { onClick: s, style: h.link, children:
|
|
2806
|
+
/* @__PURE__ */ n("a", { onClick: s, style: h.link, children: k.loginLink })
|
|
2765
2807
|
] }),
|
|
2766
2808
|
/* @__PURE__ */ n("div", { style: h.divider, children: "•" }),
|
|
2767
|
-
/* @__PURE__ */
|
|
2768
|
-
/* @__PURE__ */
|
|
2769
|
-
|
|
2809
|
+
/* @__PURE__ */ c("div", { children: [
|
|
2810
|
+
/* @__PURE__ */ c("span", { style: h.divider, children: [
|
|
2811
|
+
k.signupText,
|
|
2770
2812
|
" "
|
|
2771
2813
|
] }),
|
|
2772
|
-
/* @__PURE__ */ n("a", { onClick: o, style: h.link, children:
|
|
2814
|
+
/* @__PURE__ */ n("a", { onClick: o, style: h.link, children: k.signupLink })
|
|
2773
2815
|
] })
|
|
2774
2816
|
] })
|
|
2775
2817
|
] });
|
|
2776
2818
|
}
|
|
2777
|
-
const
|
|
2819
|
+
const yt = {
|
|
2778
2820
|
title: "Verifying Magic Link",
|
|
2779
2821
|
verifyingMessage: "Please wait while we verify your magic link...",
|
|
2780
2822
|
successMessage: "Magic link verified successfully! You are now logged in.",
|
|
@@ -2782,7 +2824,7 @@ const ft = {
|
|
|
2782
2824
|
redirectingMessage: "Redirecting you to the dashboard...",
|
|
2783
2825
|
retryButton: "Try Again",
|
|
2784
2826
|
backToLoginButton: "Back to Login"
|
|
2785
|
-
},
|
|
2827
|
+
}, Ee = {
|
|
2786
2828
|
container: {
|
|
2787
2829
|
maxWidth: "400px",
|
|
2788
2830
|
width: "100%",
|
|
@@ -2869,7 +2911,7 @@ const ft = {
|
|
|
2869
2911
|
cursor: "pointer",
|
|
2870
2912
|
transition: "all 0.15s ease-in-out"
|
|
2871
2913
|
}
|
|
2872
|
-
},
|
|
2914
|
+
}, wt = () => /* @__PURE__ */ n("div", { style: Ee.spinner }), bt = () => /* @__PURE__ */ c(
|
|
2873
2915
|
"svg",
|
|
2874
2916
|
{
|
|
2875
2917
|
width: "48",
|
|
@@ -2886,7 +2928,7 @@ const ft = {
|
|
|
2886
2928
|
/* @__PURE__ */ n("polyline", { points: "22,4 12,14.01 9,11.01" })
|
|
2887
2929
|
]
|
|
2888
2930
|
}
|
|
2889
|
-
),
|
|
2931
|
+
), St = () => /* @__PURE__ */ c(
|
|
2890
2932
|
"svg",
|
|
2891
2933
|
{
|
|
2892
2934
|
width: "48",
|
|
@@ -2904,57 +2946,57 @@ const ft = {
|
|
|
2904
2946
|
/* @__PURE__ */ n("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
|
|
2905
2947
|
]
|
|
2906
2948
|
}
|
|
2907
|
-
),
|
|
2908
|
-
loading: /* @__PURE__ */ n(
|
|
2909
|
-
success: /* @__PURE__ */ n(
|
|
2910
|
-
error: /* @__PURE__ */ n(
|
|
2949
|
+
), vt = {
|
|
2950
|
+
loading: /* @__PURE__ */ n(wt, {}),
|
|
2951
|
+
success: /* @__PURE__ */ n(bt, {}),
|
|
2952
|
+
error: /* @__PURE__ */ n(St, {})
|
|
2911
2953
|
};
|
|
2912
|
-
function
|
|
2954
|
+
function Jt({
|
|
2913
2955
|
copy: i = {},
|
|
2914
2956
|
styles: e = {},
|
|
2915
2957
|
icons: t = {},
|
|
2916
2958
|
onSuccess: r,
|
|
2917
2959
|
onError: s,
|
|
2918
2960
|
onRetry: o,
|
|
2919
|
-
onBackToLogin:
|
|
2920
|
-
className:
|
|
2921
|
-
token:
|
|
2922
|
-
email:
|
|
2923
|
-
appId:
|
|
2961
|
+
onBackToLogin: g,
|
|
2962
|
+
className: w,
|
|
2963
|
+
token: x,
|
|
2964
|
+
email: b,
|
|
2965
|
+
appId: A,
|
|
2924
2966
|
tenantSlug: m,
|
|
2925
2967
|
autoRedirectDelay: f = 3e3
|
|
2926
2968
|
}) {
|
|
2927
|
-
const [u, y] =
|
|
2969
|
+
const [u, y] = v("verifying"), [E, C] = v(""), { verifyMagicLink: q } = ae(), T = { ...yt, ...i }, d = { ...Ee, ...e }, P = { ...vt, ...t }, R = () => {
|
|
2928
2970
|
if (typeof window > "u") return {};
|
|
2929
|
-
const
|
|
2971
|
+
const S = new URLSearchParams(window.location.search);
|
|
2930
2972
|
return {
|
|
2931
|
-
token:
|
|
2932
|
-
email:
|
|
2933
|
-
appId:
|
|
2934
|
-
tenantSlug: m ||
|
|
2973
|
+
token: x || S.get("token") || "",
|
|
2974
|
+
email: b || S.get("email") || "",
|
|
2975
|
+
appId: A || S.get("appId") || "",
|
|
2976
|
+
tenantSlug: m || S.get("tenantSlug") || void 0
|
|
2935
2977
|
};
|
|
2936
2978
|
}, z = async () => {
|
|
2937
2979
|
y("verifying"), C("");
|
|
2938
2980
|
try {
|
|
2939
|
-
const
|
|
2940
|
-
if (!
|
|
2981
|
+
const S = R();
|
|
2982
|
+
if (!S.token || !S.email)
|
|
2941
2983
|
throw new Error("Missing required parameters: token or email");
|
|
2942
2984
|
const M = await q({
|
|
2943
|
-
token:
|
|
2944
|
-
email:
|
|
2945
|
-
tenantSlug:
|
|
2985
|
+
token: S.token,
|
|
2986
|
+
email: S.email,
|
|
2987
|
+
tenantSlug: S.tenantSlug
|
|
2946
2988
|
});
|
|
2947
2989
|
y("success"), r == null || r(M), f > 0 && setTimeout(() => {
|
|
2948
2990
|
y("redirecting");
|
|
2949
2991
|
}, f);
|
|
2950
|
-
} catch (
|
|
2951
|
-
const M =
|
|
2992
|
+
} catch (S) {
|
|
2993
|
+
const M = S.message || T.errorMessage;
|
|
2952
2994
|
C(M), y("error"), s == null || s(M);
|
|
2953
2995
|
}
|
|
2954
2996
|
}, G = () => {
|
|
2955
2997
|
o == null || o(), z();
|
|
2956
2998
|
}, $ = () => {
|
|
2957
|
-
|
|
2999
|
+
g == null || g();
|
|
2958
3000
|
};
|
|
2959
3001
|
te(() => {
|
|
2960
3002
|
z();
|
|
@@ -2962,37 +3004,37 @@ function Gt({
|
|
|
2962
3004
|
const _ = () => {
|
|
2963
3005
|
switch (u) {
|
|
2964
3006
|
case "verifying":
|
|
2965
|
-
return /* @__PURE__ */
|
|
3007
|
+
return /* @__PURE__ */ c("div", { style: d.message, children: [
|
|
2966
3008
|
P.loading,
|
|
2967
|
-
|
|
3009
|
+
T.verifyingMessage
|
|
2968
3010
|
] });
|
|
2969
3011
|
case "success":
|
|
2970
|
-
return /* @__PURE__ */
|
|
3012
|
+
return /* @__PURE__ */ c(B, { children: [
|
|
2971
3013
|
P.success,
|
|
2972
|
-
/* @__PURE__ */ n("div", { style: d.successMessage, children:
|
|
3014
|
+
/* @__PURE__ */ n("div", { style: d.successMessage, children: T.successMessage })
|
|
2973
3015
|
] });
|
|
2974
3016
|
case "redirecting":
|
|
2975
|
-
return /* @__PURE__ */
|
|
3017
|
+
return /* @__PURE__ */ c(B, { children: [
|
|
2976
3018
|
P.loading,
|
|
2977
|
-
/* @__PURE__ */ n("div", { style: d.message, children:
|
|
3019
|
+
/* @__PURE__ */ n("div", { style: d.message, children: T.redirectingMessage })
|
|
2978
3020
|
] });
|
|
2979
3021
|
case "error":
|
|
2980
|
-
return /* @__PURE__ */
|
|
3022
|
+
return /* @__PURE__ */ c(B, { children: [
|
|
2981
3023
|
P.error,
|
|
2982
|
-
/* @__PURE__ */ n("div", { style: d.errorMessage, children:
|
|
2983
|
-
/* @__PURE__ */
|
|
3024
|
+
/* @__PURE__ */ n("div", { style: d.errorMessage, children: E || T.errorMessage }),
|
|
3025
|
+
/* @__PURE__ */ c("div", { style: d.buttonContainer, children: [
|
|
2984
3026
|
/* @__PURE__ */ n(
|
|
2985
3027
|
"button",
|
|
2986
3028
|
{
|
|
2987
3029
|
onClick: G,
|
|
2988
3030
|
style: d.retryButton,
|
|
2989
|
-
onMouseOver: (
|
|
2990
|
-
|
|
3031
|
+
onMouseOver: (S) => {
|
|
3032
|
+
S.currentTarget.style.backgroundColor = "#2563eb";
|
|
2991
3033
|
},
|
|
2992
|
-
onMouseOut: (
|
|
2993
|
-
|
|
3034
|
+
onMouseOut: (S) => {
|
|
3035
|
+
S.currentTarget.style.backgroundColor = "#3b82f6";
|
|
2994
3036
|
},
|
|
2995
|
-
children:
|
|
3037
|
+
children: T.retryButton
|
|
2996
3038
|
}
|
|
2997
3039
|
),
|
|
2998
3040
|
/* @__PURE__ */ n(
|
|
@@ -3000,13 +3042,13 @@ function Gt({
|
|
|
3000
3042
|
{
|
|
3001
3043
|
onClick: $,
|
|
3002
3044
|
style: d.backButton,
|
|
3003
|
-
onMouseOver: (
|
|
3004
|
-
|
|
3045
|
+
onMouseOver: (S) => {
|
|
3046
|
+
S.currentTarget.style.backgroundColor = "#e5e7eb";
|
|
3005
3047
|
},
|
|
3006
|
-
onMouseOut: (
|
|
3007
|
-
|
|
3048
|
+
onMouseOut: (S) => {
|
|
3049
|
+
S.currentTarget.style.backgroundColor = "#f3f4f6";
|
|
3008
3050
|
},
|
|
3009
|
-
children:
|
|
3051
|
+
children: T.backToLoginButton
|
|
3010
3052
|
}
|
|
3011
3053
|
)
|
|
3012
3054
|
] })
|
|
@@ -3015,18 +3057,18 @@ function Gt({
|
|
|
3015
3057
|
return null;
|
|
3016
3058
|
}
|
|
3017
3059
|
};
|
|
3018
|
-
return /* @__PURE__ */
|
|
3060
|
+
return /* @__PURE__ */ c("div", { style: d.container, className: w, children: [
|
|
3019
3061
|
/* @__PURE__ */ n("style", { children: `
|
|
3020
3062
|
@keyframes spin {
|
|
3021
3063
|
0% { transform: rotate(0deg); }
|
|
3022
3064
|
100% { transform: rotate(360deg); }
|
|
3023
3065
|
}
|
|
3024
3066
|
` }),
|
|
3025
|
-
/* @__PURE__ */ n("h1", { style: d.title, children:
|
|
3067
|
+
/* @__PURE__ */ n("h1", { style: d.title, children: T.title }),
|
|
3026
3068
|
_()
|
|
3027
3069
|
] });
|
|
3028
3070
|
}
|
|
3029
|
-
const
|
|
3071
|
+
const xt = {
|
|
3030
3072
|
title: "Reset Password",
|
|
3031
3073
|
subtitle: "Enter your email address and we'll send you a link to reset your password.",
|
|
3032
3074
|
emailLabel: "Email",
|
|
@@ -3048,7 +3090,7 @@ const St = {
|
|
|
3048
3090
|
resetLoadingText: "Resetting...",
|
|
3049
3091
|
resetSuccessMessage: "Password reset successfully!",
|
|
3050
3092
|
passwordMismatchError: "Passwords do not match"
|
|
3051
|
-
},
|
|
3093
|
+
}, kt = {
|
|
3052
3094
|
container: {
|
|
3053
3095
|
maxWidth: "400px",
|
|
3054
3096
|
margin: "0 auto",
|
|
@@ -3140,112 +3182,112 @@ const St = {
|
|
|
3140
3182
|
cursor: "pointer"
|
|
3141
3183
|
}
|
|
3142
3184
|
};
|
|
3143
|
-
function
|
|
3185
|
+
function Yt({
|
|
3144
3186
|
copy: i = {},
|
|
3145
3187
|
styles: e = {},
|
|
3146
3188
|
mode: t = "request",
|
|
3147
3189
|
token: r = "",
|
|
3148
3190
|
onSuccess: s,
|
|
3149
3191
|
onError: o,
|
|
3150
|
-
onBackToLogin:
|
|
3151
|
-
onModeChange:
|
|
3152
|
-
className:
|
|
3192
|
+
onBackToLogin: g,
|
|
3193
|
+
onModeChange: w,
|
|
3194
|
+
className: x
|
|
3153
3195
|
}) {
|
|
3154
|
-
const [
|
|
3196
|
+
const [b, A] = v(""), [m, f] = v(r), [u, y] = v(""), [E, C] = v(""), [q, T] = v(!1), [d, P] = v(""), [R, z] = v(""), [G, $] = v({}), { requestPasswordReset: _, confirmPasswordReset: S } = ae(), { tenant: M } = se(), L = { ...xt, ...i }, l = { ...kt, ...e }, I = () => {
|
|
3155
3197
|
const H = {};
|
|
3156
|
-
return
|
|
3157
|
-
},
|
|
3198
|
+
return b.trim() || (H.email = !0), $(H), Object.keys(H).length === 0;
|
|
3199
|
+
}, k = () => {
|
|
3158
3200
|
const H = {};
|
|
3159
|
-
return m.trim() || (H.token = !0), u.trim() || (H.newPassword = !0),
|
|
3201
|
+
return m.trim() || (H.token = !0), u.trim() || (H.newPassword = !0), E.trim() || (H.confirmPassword = !0), $(H), Object.keys(H).length === 0;
|
|
3160
3202
|
}, h = async (H) => {
|
|
3161
|
-
if (H.preventDefault(), !!
|
|
3203
|
+
if (H.preventDefault(), !!I()) {
|
|
3162
3204
|
if (!(M != null && M.id)) {
|
|
3163
3205
|
P("Tenant not found");
|
|
3164
3206
|
return;
|
|
3165
3207
|
}
|
|
3166
|
-
|
|
3208
|
+
T(!0), P(""), z("");
|
|
3167
3209
|
try {
|
|
3168
|
-
await _({ email:
|
|
3210
|
+
await _({ email: b, tenantId: M.id }), z(L.successMessage), s == null || s();
|
|
3169
3211
|
} catch (N) {
|
|
3170
|
-
const
|
|
3171
|
-
P(
|
|
3212
|
+
const W = N.message || L.errorMessage;
|
|
3213
|
+
P(W), o == null || o(W);
|
|
3172
3214
|
} finally {
|
|
3173
|
-
|
|
3215
|
+
T(!1);
|
|
3174
3216
|
}
|
|
3175
3217
|
}
|
|
3176
|
-
},
|
|
3177
|
-
if (H.preventDefault(), !!
|
|
3178
|
-
if (u !==
|
|
3179
|
-
P(
|
|
3218
|
+
}, a = async (H) => {
|
|
3219
|
+
if (H.preventDefault(), !!k()) {
|
|
3220
|
+
if (u !== E) {
|
|
3221
|
+
P(L.passwordMismatchError), $({ confirmPassword: !0 });
|
|
3180
3222
|
return;
|
|
3181
3223
|
}
|
|
3182
|
-
|
|
3224
|
+
T(!0), P(""), z("");
|
|
3183
3225
|
try {
|
|
3184
|
-
await
|
|
3226
|
+
await S({ token: m, newPassword: u }), z(L.resetSuccessMessage), s == null || s();
|
|
3185
3227
|
} catch (N) {
|
|
3186
|
-
const
|
|
3187
|
-
P(
|
|
3228
|
+
const W = N.message || L.errorMessage;
|
|
3229
|
+
P(W), o == null || o(W);
|
|
3188
3230
|
} finally {
|
|
3189
|
-
|
|
3231
|
+
T(!1);
|
|
3190
3232
|
}
|
|
3191
3233
|
}
|
|
3192
|
-
},
|
|
3193
|
-
...
|
|
3194
|
-
...G[H] ?
|
|
3195
|
-
}),
|
|
3196
|
-
...
|
|
3197
|
-
...q ?
|
|
3234
|
+
}, p = (H) => ({
|
|
3235
|
+
...l.input,
|
|
3236
|
+
...G[H] ? l.inputError : {}
|
|
3237
|
+
}), O = () => ({
|
|
3238
|
+
...l.button,
|
|
3239
|
+
...q ? l.buttonLoading : {}
|
|
3198
3240
|
});
|
|
3199
3241
|
if (t === "reset") {
|
|
3200
|
-
const H = m && u &&
|
|
3201
|
-
return /* @__PURE__ */
|
|
3202
|
-
/* @__PURE__ */ n("h2", { style:
|
|
3203
|
-
/* @__PURE__ */ n("p", { style:
|
|
3204
|
-
/* @__PURE__ */
|
|
3205
|
-
/* @__PURE__ */
|
|
3206
|
-
/* @__PURE__ */ n("label", { style:
|
|
3242
|
+
const H = m && u && E;
|
|
3243
|
+
return /* @__PURE__ */ c("div", { className: x, style: l.container, children: [
|
|
3244
|
+
/* @__PURE__ */ n("h2", { style: l.title, children: L.resetTitle }),
|
|
3245
|
+
/* @__PURE__ */ n("p", { style: l.subtitle, children: L.resetSubtitle }),
|
|
3246
|
+
/* @__PURE__ */ c("form", { onSubmit: a, style: l.form, children: [
|
|
3247
|
+
/* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
|
|
3248
|
+
/* @__PURE__ */ n("label", { style: l.label, children: L.tokenLabel }),
|
|
3207
3249
|
/* @__PURE__ */ n(
|
|
3208
3250
|
"input",
|
|
3209
3251
|
{
|
|
3210
3252
|
type: "text",
|
|
3211
3253
|
value: m,
|
|
3212
3254
|
onChange: (N) => {
|
|
3213
|
-
f(N.target.value), G.token && $((
|
|
3255
|
+
f(N.target.value), G.token && $((W) => ({ ...W, token: !1 }));
|
|
3214
3256
|
},
|
|
3215
|
-
placeholder:
|
|
3216
|
-
style:
|
|
3257
|
+
placeholder: L.tokenPlaceholder,
|
|
3258
|
+
style: p("token"),
|
|
3217
3259
|
disabled: q
|
|
3218
3260
|
}
|
|
3219
3261
|
)
|
|
3220
3262
|
] }),
|
|
3221
|
-
/* @__PURE__ */
|
|
3222
|
-
/* @__PURE__ */ n("label", { style:
|
|
3263
|
+
/* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
|
|
3264
|
+
/* @__PURE__ */ n("label", { style: l.label, children: L.newPasswordLabel }),
|
|
3223
3265
|
/* @__PURE__ */ n(
|
|
3224
3266
|
"input",
|
|
3225
3267
|
{
|
|
3226
3268
|
type: "password",
|
|
3227
3269
|
value: u,
|
|
3228
3270
|
onChange: (N) => {
|
|
3229
|
-
y(N.target.value), G.newPassword && $((
|
|
3271
|
+
y(N.target.value), G.newPassword && $((W) => ({ ...W, newPassword: !1 }));
|
|
3230
3272
|
},
|
|
3231
|
-
placeholder:
|
|
3232
|
-
style:
|
|
3273
|
+
placeholder: L.newPasswordPlaceholder,
|
|
3274
|
+
style: p("newPassword"),
|
|
3233
3275
|
disabled: q
|
|
3234
3276
|
}
|
|
3235
3277
|
)
|
|
3236
3278
|
] }),
|
|
3237
|
-
/* @__PURE__ */
|
|
3238
|
-
/* @__PURE__ */ n("label", { style:
|
|
3279
|
+
/* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
|
|
3280
|
+
/* @__PURE__ */ n("label", { style: l.label, children: L.confirmPasswordLabel }),
|
|
3239
3281
|
/* @__PURE__ */ n(
|
|
3240
3282
|
"input",
|
|
3241
3283
|
{
|
|
3242
3284
|
type: "password",
|
|
3243
|
-
value:
|
|
3285
|
+
value: E,
|
|
3244
3286
|
onChange: (N) => {
|
|
3245
|
-
C(N.target.value), G.confirmPassword && $((
|
|
3287
|
+
C(N.target.value), G.confirmPassword && $((W) => ({ ...W, confirmPassword: !1 })), d === L.passwordMismatchError && P("");
|
|
3246
3288
|
},
|
|
3247
|
-
placeholder:
|
|
3248
|
-
style:
|
|
3289
|
+
placeholder: L.confirmPasswordPlaceholder,
|
|
3290
|
+
style: p("confirmPassword"),
|
|
3249
3291
|
disabled: q
|
|
3250
3292
|
}
|
|
3251
3293
|
)
|
|
@@ -3256,41 +3298,41 @@ function Kt({
|
|
|
3256
3298
|
type: "submit",
|
|
3257
3299
|
disabled: !H || q,
|
|
3258
3300
|
style: {
|
|
3259
|
-
...
|
|
3260
|
-
...!H || q ?
|
|
3301
|
+
...O(),
|
|
3302
|
+
...!H || q ? l.buttonDisabled : {}
|
|
3261
3303
|
},
|
|
3262
|
-
children: q ?
|
|
3304
|
+
children: q ? L.resetLoadingText : L.resetSubmitButton
|
|
3263
3305
|
}
|
|
3264
3306
|
),
|
|
3265
|
-
d && /* @__PURE__ */ n("div", { style:
|
|
3266
|
-
|
|
3307
|
+
d && /* @__PURE__ */ n("div", { style: l.errorText, children: d }),
|
|
3308
|
+
R && /* @__PURE__ */ n("div", { style: l.successText, children: R })
|
|
3267
3309
|
] }),
|
|
3268
|
-
/* @__PURE__ */
|
|
3269
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
3270
|
-
|
|
3310
|
+
/* @__PURE__ */ c("div", { style: l.linkContainer, children: [
|
|
3311
|
+
/* @__PURE__ */ n("a", { onClick: g, style: l.link, children: L.backToLoginLink }),
|
|
3312
|
+
w && /* @__PURE__ */ c(B, { children: [
|
|
3271
3313
|
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3272
|
-
/* @__PURE__ */ n("a", { onClick: () =>
|
|
3314
|
+
/* @__PURE__ */ n("a", { onClick: () => w("request"), style: l.link, children: "Request New Link" })
|
|
3273
3315
|
] })
|
|
3274
3316
|
] })
|
|
3275
3317
|
] });
|
|
3276
3318
|
}
|
|
3277
|
-
const
|
|
3278
|
-
return /* @__PURE__ */
|
|
3279
|
-
/* @__PURE__ */ n("h2", { style:
|
|
3280
|
-
/* @__PURE__ */ n("p", { style:
|
|
3281
|
-
/* @__PURE__ */
|
|
3282
|
-
/* @__PURE__ */
|
|
3283
|
-
/* @__PURE__ */ n("label", { style:
|
|
3319
|
+
const K = b;
|
|
3320
|
+
return /* @__PURE__ */ c("div", { className: x, style: l.container, children: [
|
|
3321
|
+
/* @__PURE__ */ n("h2", { style: l.title, children: L.title }),
|
|
3322
|
+
/* @__PURE__ */ n("p", { style: l.subtitle, children: L.subtitle }),
|
|
3323
|
+
/* @__PURE__ */ c("form", { onSubmit: h, style: l.form, children: [
|
|
3324
|
+
/* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
|
|
3325
|
+
/* @__PURE__ */ n("label", { style: l.label, children: L.emailLabel }),
|
|
3284
3326
|
/* @__PURE__ */ n(
|
|
3285
3327
|
"input",
|
|
3286
3328
|
{
|
|
3287
3329
|
type: "email",
|
|
3288
|
-
value:
|
|
3330
|
+
value: b,
|
|
3289
3331
|
onChange: (H) => {
|
|
3290
|
-
|
|
3332
|
+
A(H.target.value), G.email && $((N) => ({ ...N, email: !1 }));
|
|
3291
3333
|
},
|
|
3292
|
-
placeholder:
|
|
3293
|
-
style:
|
|
3334
|
+
placeholder: L.emailPlaceholder,
|
|
3335
|
+
style: p("email"),
|
|
3294
3336
|
disabled: q
|
|
3295
3337
|
}
|
|
3296
3338
|
)
|
|
@@ -3299,27 +3341,27 @@ function Kt({
|
|
|
3299
3341
|
"button",
|
|
3300
3342
|
{
|
|
3301
3343
|
type: "submit",
|
|
3302
|
-
disabled: !
|
|
3344
|
+
disabled: !K || q,
|
|
3303
3345
|
style: {
|
|
3304
|
-
...
|
|
3305
|
-
...!
|
|
3346
|
+
...O(),
|
|
3347
|
+
...!K || q ? l.buttonDisabled : {}
|
|
3306
3348
|
},
|
|
3307
|
-
children: q ?
|
|
3349
|
+
children: q ? L.loadingText : L.submitButton
|
|
3308
3350
|
}
|
|
3309
3351
|
),
|
|
3310
|
-
d && /* @__PURE__ */ n("div", { style:
|
|
3311
|
-
|
|
3352
|
+
d && /* @__PURE__ */ n("div", { style: l.errorText, children: d }),
|
|
3353
|
+
R && /* @__PURE__ */ n("div", { style: l.successText, children: R })
|
|
3312
3354
|
] }),
|
|
3313
|
-
/* @__PURE__ */
|
|
3314
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
3315
|
-
|
|
3355
|
+
/* @__PURE__ */ c("div", { style: l.linkContainer, children: [
|
|
3356
|
+
/* @__PURE__ */ n("a", { onClick: g, style: l.link, children: L.backToLoginLink }),
|
|
3357
|
+
w && /* @__PURE__ */ c(B, { children: [
|
|
3316
3358
|
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3317
|
-
/* @__PURE__ */ n("a", { onClick: () =>
|
|
3359
|
+
/* @__PURE__ */ n("a", { onClick: () => w("reset"), style: l.link, children: "I have a token" })
|
|
3318
3360
|
] })
|
|
3319
3361
|
] })
|
|
3320
3362
|
] });
|
|
3321
3363
|
}
|
|
3322
|
-
const
|
|
3364
|
+
const At = () => /* @__PURE__ */ n(
|
|
3323
3365
|
"div",
|
|
3324
3366
|
{
|
|
3325
3367
|
style: {
|
|
@@ -3331,7 +3373,7 @@ const xt = () => /* @__PURE__ */ n(
|
|
|
3331
3373
|
},
|
|
3332
3374
|
children: /* @__PURE__ */ n("div", { children: "Loading..." })
|
|
3333
3375
|
}
|
|
3334
|
-
),
|
|
3376
|
+
), Tt = ({ error: i, retry: e }) => /* @__PURE__ */ c(
|
|
3335
3377
|
"div",
|
|
3336
3378
|
{
|
|
3337
3379
|
style: {
|
|
@@ -3365,40 +3407,40 @@ const xt = () => /* @__PURE__ */ n(
|
|
|
3365
3407
|
]
|
|
3366
3408
|
}
|
|
3367
3409
|
);
|
|
3368
|
-
function
|
|
3410
|
+
function Qt({
|
|
3369
3411
|
children: i,
|
|
3370
3412
|
loadingFallback: e,
|
|
3371
3413
|
errorFallback: t,
|
|
3372
3414
|
requireTenant: r = !0
|
|
3373
3415
|
}) {
|
|
3374
|
-
const { isAppLoading: s, appError: o, retryApp:
|
|
3375
|
-
}), f = r &&
|
|
3376
|
-
o &&
|
|
3416
|
+
const { isAppLoading: s, appError: o, retryApp: g } = oe(), w = Me(), x = (w == null ? void 0 : w.isTenantLoading) ?? !1, b = (w == null ? void 0 : w.tenantError) ?? null, A = (w == null ? void 0 : w.tenantSlug) ?? null, m = (w == null ? void 0 : w.retryTenant) ?? (() => {
|
|
3417
|
+
}), f = r && w && A, u = s || f && x, y = o || (f ? b : null), E = () => {
|
|
3418
|
+
o && g(), b && w && m();
|
|
3377
3419
|
};
|
|
3378
3420
|
if (u)
|
|
3379
|
-
return /* @__PURE__ */ n(
|
|
3421
|
+
return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(At, {}) });
|
|
3380
3422
|
if (y) {
|
|
3381
|
-
const C = typeof t == "function" ? t(y,
|
|
3382
|
-
return /* @__PURE__ */ n(
|
|
3423
|
+
const C = typeof t == "function" ? t(y, E) : t || /* @__PURE__ */ n(Tt, { error: y, retry: E });
|
|
3424
|
+
return /* @__PURE__ */ n(B, { children: C });
|
|
3383
3425
|
}
|
|
3384
|
-
return /* @__PURE__ */ n(
|
|
3426
|
+
return /* @__PURE__ */ n(B, { children: i });
|
|
3385
3427
|
}
|
|
3386
|
-
function
|
|
3387
|
-
const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = oe(), o = Me(),
|
|
3388
|
-
}), m = i && o &&
|
|
3428
|
+
function Xt(i = !0) {
|
|
3429
|
+
const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = oe(), o = Me(), g = (o == null ? void 0 : o.isTenantLoading) ?? !1, w = (o == null ? void 0 : o.tenantError) ?? null, x = (o == null ? void 0 : o.tenant) ?? null, b = (o == null ? void 0 : o.tenantSlug) ?? null, A = (o == null ? void 0 : o.retryTenant) ?? (() => {
|
|
3430
|
+
}), m = i && o && b, f = e || m && g, u = t || (m ? w : null);
|
|
3389
3431
|
return {
|
|
3390
3432
|
isLoading: f,
|
|
3391
3433
|
error: u,
|
|
3392
|
-
isReady: !f && !u && s !== null && (!m ||
|
|
3434
|
+
isReady: !f && !u && s !== null && (!m || x !== null),
|
|
3393
3435
|
retry: () => {
|
|
3394
|
-
t && r(),
|
|
3436
|
+
t && r(), w && o && A();
|
|
3395
3437
|
},
|
|
3396
3438
|
// Individual states
|
|
3397
3439
|
app: { isLoading: e, error: t, data: s },
|
|
3398
|
-
tenant: o ? { isLoading:
|
|
3440
|
+
tenant: o ? { isLoading: g, error: w, data: x } : null
|
|
3399
3441
|
};
|
|
3400
3442
|
}
|
|
3401
|
-
class
|
|
3443
|
+
class Zt {
|
|
3402
3444
|
constructor(e, t) {
|
|
3403
3445
|
this.httpService = e, this.sessionManager = t;
|
|
3404
3446
|
}
|
|
@@ -3466,7 +3508,7 @@ class Qt {
|
|
|
3466
3508
|
};
|
|
3467
3509
|
}
|
|
3468
3510
|
}
|
|
3469
|
-
class
|
|
3511
|
+
class er {
|
|
3470
3512
|
constructor(e, t) {
|
|
3471
3513
|
this.httpService = e, this.sessionManager = t;
|
|
3472
3514
|
}
|
|
@@ -3517,7 +3559,7 @@ class Xt {
|
|
|
3517
3559
|
});
|
|
3518
3560
|
}
|
|
3519
3561
|
}
|
|
3520
|
-
class
|
|
3562
|
+
class tr {
|
|
3521
3563
|
constructor(e) {
|
|
3522
3564
|
this.httpService = e;
|
|
3523
3565
|
}
|
|
@@ -3526,7 +3568,7 @@ class Zt {
|
|
|
3526
3568
|
return await this.httpService.get("/health");
|
|
3527
3569
|
}
|
|
3528
3570
|
}
|
|
3529
|
-
class
|
|
3571
|
+
class rr {
|
|
3530
3572
|
// Date string to Date object
|
|
3531
3573
|
static toDate(e) {
|
|
3532
3574
|
return new Date(e);
|
|
@@ -3649,47 +3691,47 @@ class er {
|
|
|
3649
3691
|
}
|
|
3650
3692
|
}
|
|
3651
3693
|
export {
|
|
3652
|
-
|
|
3694
|
+
rr as ApiMappers,
|
|
3653
3695
|
ve as AppApiService,
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3696
|
+
Qt as AppLoader,
|
|
3697
|
+
Ct as AppProvider,
|
|
3698
|
+
ze as AuthApiService,
|
|
3699
|
+
Nt as AuthProvider,
|
|
3700
|
+
jt as FeatureFlag,
|
|
3701
|
+
Qe as FeatureFlagApiService,
|
|
3702
|
+
Ut as FeatureFlagProvider,
|
|
3703
|
+
tr as HealthApiService,
|
|
3662
3704
|
re as HttpService,
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3705
|
+
Wt as LandingRoute,
|
|
3706
|
+
_t as LoginForm,
|
|
3707
|
+
Kt as MagicLinkForm,
|
|
3708
|
+
Jt as MagicLinkVerify,
|
|
3709
|
+
Yt as PasswordRecoveryForm,
|
|
3710
|
+
Zt as PermissionApiService,
|
|
3711
|
+
qt as Protected,
|
|
3712
|
+
zt as ProtectedRoute,
|
|
3671
3713
|
xe as RoleApiService,
|
|
3672
3714
|
we as SessionManager,
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3715
|
+
Gt as SignupForm,
|
|
3716
|
+
Ze as SubscriptionApiService,
|
|
3717
|
+
Vt as SubscriptionGuard,
|
|
3718
|
+
er as SubscriptionPlanApiService,
|
|
3719
|
+
Bt as SubscriptionProvider,
|
|
3678
3720
|
ue as TenantApiService,
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3721
|
+
Dt as TenantProvider,
|
|
3722
|
+
Ot as TenantRoute,
|
|
3723
|
+
Oe as UserApiService,
|
|
3682
3724
|
ie as UserType,
|
|
3683
|
-
|
|
3725
|
+
$t as useApi,
|
|
3684
3726
|
oe as useApp,
|
|
3685
|
-
|
|
3727
|
+
Xt as useAppLoaderState,
|
|
3686
3728
|
ae as useAuth,
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3729
|
+
Xe as useFeatureFlags,
|
|
3730
|
+
Ht as useSettings,
|
|
3731
|
+
et as useSubscription,
|
|
3690
3732
|
me as useTenant,
|
|
3691
3733
|
se as useTenantInfo,
|
|
3692
3734
|
Me as useTenantOptional,
|
|
3693
|
-
|
|
3735
|
+
Ft as useTenantSettings
|
|
3694
3736
|
};
|
|
3695
3737
|
//# sourceMappingURL=index.es.js.map
|