@skylabs-digital/react-identity-access 2.8.0 → 2.10.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/components/TenantSelector.d.ts +18 -0
- package/dist/components/TenantSelector.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +1285 -1104
- 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 +9 -1
- package/dist/providers/AuthProvider.d.ts.map +1 -1
- package/dist/services/AuthApiService.d.ts +3 -1
- package/dist/services/AuthApiService.d.ts.map +1 -1
- package/dist/types/api.d.ts +18 -1
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/authParams.d.ts +1 -0
- package/dist/types/authParams.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as n, Fragment as j, jsxs as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { useLocation as
|
|
4
|
-
class
|
|
1
|
+
import { jsx as n, Fragment as j, jsxs as d } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as he, useMemo as te, useState as k, useCallback as ie, useEffect as re, useContext as se, useRef as Ne } from "react";
|
|
3
|
+
import { useLocation as Te, Navigate as fe } from "react-router-dom";
|
|
4
|
+
class ne {
|
|
5
5
|
// SessionManager instance
|
|
6
6
|
constructor(e, t = 1e4) {
|
|
7
7
|
this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
|
|
@@ -16,40 +16,40 @@ class re {
|
|
|
16
16
|
return this.executeRequest(e, t, r, s, !1);
|
|
17
17
|
}
|
|
18
18
|
async executeRequest(e, t, r, s, o = !1) {
|
|
19
|
-
const a = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`,
|
|
20
|
-
let
|
|
19
|
+
const a = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, m = (s == null ? void 0 : s.timeout) || this.timeout;
|
|
20
|
+
let y = {
|
|
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
|
-
const
|
|
27
|
-
|
|
28
|
-
} catch (
|
|
29
|
-
console.warn("Failed to inject auth headers:",
|
|
26
|
+
const S = await this.sessionManager.getAuthHeaders();
|
|
27
|
+
y = { ...y, ...S };
|
|
28
|
+
} catch (S) {
|
|
29
|
+
console.warn("Failed to inject auth headers:", S);
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const b = new AbortController(), g = setTimeout(() => b.abort(), m);
|
|
32
32
|
try {
|
|
33
|
-
const
|
|
33
|
+
const S = await fetch(a, {
|
|
34
34
|
method: e,
|
|
35
|
-
headers:
|
|
35
|
+
headers: y,
|
|
36
36
|
body: r ? JSON.stringify(r) : void 0,
|
|
37
|
-
signal:
|
|
37
|
+
signal: b.signal
|
|
38
38
|
});
|
|
39
|
-
if (clearTimeout(
|
|
39
|
+
if (clearTimeout(g), S.status === 401 && !(s != null && s.skipRetry) && !o && this.sessionManager)
|
|
40
40
|
try {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
41
|
+
const T = this.sessionManager.getTokens();
|
|
42
|
+
if (T != null && T.refreshToken)
|
|
43
43
|
return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, r, s, !0);
|
|
44
44
|
} catch {
|
|
45
|
-
throw new Error(`HTTP ${
|
|
45
|
+
throw new Error(`HTTP ${S.status}: ${S.statusText}`);
|
|
46
46
|
}
|
|
47
|
-
if (!
|
|
48
|
-
throw new Error(`HTTP ${
|
|
49
|
-
const f =
|
|
50
|
-
return !f || !f.includes("application/json") ? {} : await
|
|
51
|
-
} catch (
|
|
52
|
-
throw clearTimeout(
|
|
47
|
+
if (!S.ok)
|
|
48
|
+
throw new Error(`HTTP ${S.status}: ${S.statusText}`);
|
|
49
|
+
const f = S.headers.get("content-type");
|
|
50
|
+
return !f || !f.includes("application/json") ? {} : await S.json();
|
|
51
|
+
} catch (S) {
|
|
52
|
+
throw clearTimeout(g), S instanceof Error && S.name === "AbortError" ? new Error(`Request timeout after ${m}ms`) : S;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
async get(e, t) {
|
|
@@ -65,7 +65,7 @@ class re {
|
|
|
65
65
|
return this.request("DELETE", e, void 0, t);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
class
|
|
68
|
+
class Fe {
|
|
69
69
|
constructor(e, t) {
|
|
70
70
|
this.httpService = e, this.sessionManager = t;
|
|
71
71
|
}
|
|
@@ -124,32 +124,32 @@ class Pe {
|
|
|
124
124
|
})).data;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
const
|
|
128
|
-
function
|
|
129
|
-
const t =
|
|
127
|
+
const xe = he(null);
|
|
128
|
+
function Jt({ config: i, children: e }) {
|
|
129
|
+
const t = te(
|
|
130
130
|
() => {
|
|
131
|
-
var f,
|
|
131
|
+
var f, T, I;
|
|
132
132
|
return {
|
|
133
133
|
enabled: ((f = i.cache) == null ? void 0 : f.enabled) ?? !0,
|
|
134
|
-
ttl: ((
|
|
134
|
+
ttl: ((T = i.cache) == null ? void 0 : T.ttl) ?? 3e5,
|
|
135
135
|
// 5 minutes default
|
|
136
|
-
storageKey: ((
|
|
136
|
+
storageKey: ((I = i.cache) == null ? void 0 : I.storageKey) ?? `app_cache_${i.appId}`
|
|
137
137
|
};
|
|
138
138
|
},
|
|
139
139
|
[i.cache, i.appId]
|
|
140
|
-
), [r, s] =
|
|
140
|
+
), [r, s] = k(() => {
|
|
141
141
|
if (!t.enabled) return null;
|
|
142
142
|
try {
|
|
143
143
|
const f = localStorage.getItem(t.storageKey);
|
|
144
144
|
if (!f) return null;
|
|
145
|
-
const
|
|
146
|
-
return Date.now() -
|
|
145
|
+
const T = JSON.parse(f);
|
|
146
|
+
return Date.now() - T.timestamp < t.ttl && T.appId === i.appId ? T.data : (localStorage.removeItem(t.storageKey), null);
|
|
147
147
|
} catch {
|
|
148
148
|
return null;
|
|
149
149
|
}
|
|
150
|
-
}), [o, a] =
|
|
150
|
+
}), [o, a] = k(!r), [m, y] = k(null), b = te(() => {
|
|
151
151
|
const f = () => {
|
|
152
|
-
|
|
152
|
+
g();
|
|
153
153
|
};
|
|
154
154
|
return {
|
|
155
155
|
appId: i.appId,
|
|
@@ -157,69 +157,69 @@ function Bt({ config: i, children: e }) {
|
|
|
157
157
|
// App info
|
|
158
158
|
appInfo: r,
|
|
159
159
|
isAppLoading: o,
|
|
160
|
-
appError:
|
|
160
|
+
appError: m,
|
|
161
161
|
retryApp: f
|
|
162
162
|
};
|
|
163
|
-
}, [i, r, o,
|
|
163
|
+
}, [i, r, o, m]), g = ie(
|
|
164
164
|
async (f = !1) => {
|
|
165
165
|
if (!(!f && t.enabled && r))
|
|
166
166
|
try {
|
|
167
|
-
a(!0),
|
|
168
|
-
const
|
|
169
|
-
if (s(
|
|
167
|
+
a(!0), y(null);
|
|
168
|
+
const T = new ne(i.baseUrl), C = await new Fe(T, {}).getPublicAppInfo(i.appId);
|
|
169
|
+
if (s(C), t.enabled)
|
|
170
170
|
try {
|
|
171
|
-
const
|
|
172
|
-
data:
|
|
171
|
+
const R = {
|
|
172
|
+
data: C,
|
|
173
173
|
timestamp: Date.now(),
|
|
174
174
|
appId: i.appId
|
|
175
175
|
};
|
|
176
|
-
localStorage.setItem(t.storageKey, JSON.stringify(
|
|
177
|
-
} catch (
|
|
178
|
-
console.warn("Failed to cache app info:",
|
|
176
|
+
localStorage.setItem(t.storageKey, JSON.stringify(R));
|
|
177
|
+
} catch (R) {
|
|
178
|
+
console.warn("Failed to cache app info:", R);
|
|
179
179
|
}
|
|
180
|
-
} catch (
|
|
181
|
-
const
|
|
182
|
-
|
|
180
|
+
} catch (T) {
|
|
181
|
+
const I = T instanceof Error ? T : new Error("Failed to load app information");
|
|
182
|
+
y(I), s(null);
|
|
183
183
|
} finally {
|
|
184
184
|
a(!1);
|
|
185
185
|
}
|
|
186
186
|
},
|
|
187
187
|
[i.baseUrl, i.appId, t, r]
|
|
188
|
-
),
|
|
188
|
+
), S = ie(async () => {
|
|
189
189
|
if (!(!t.enabled || !r))
|
|
190
190
|
try {
|
|
191
191
|
const f = localStorage.getItem(t.storageKey);
|
|
192
192
|
if (!f) return;
|
|
193
|
-
const
|
|
194
|
-
if (Date.now() -
|
|
195
|
-
const
|
|
196
|
-
s(
|
|
197
|
-
const
|
|
198
|
-
data:
|
|
193
|
+
const T = JSON.parse(f);
|
|
194
|
+
if (Date.now() - T.timestamp > t.ttl * 0.5) {
|
|
195
|
+
const C = new ne(i.baseUrl), x = await new Fe(C, {}).getPublicAppInfo(i.appId);
|
|
196
|
+
s(x);
|
|
197
|
+
const h = {
|
|
198
|
+
data: x,
|
|
199
199
|
timestamp: Date.now(),
|
|
200
200
|
appId: i.appId
|
|
201
201
|
};
|
|
202
|
-
localStorage.setItem(t.storageKey, JSON.stringify(
|
|
202
|
+
localStorage.setItem(t.storageKey, JSON.stringify(h));
|
|
203
203
|
}
|
|
204
204
|
} catch (f) {
|
|
205
205
|
console.warn("Background app refresh failed:", f);
|
|
206
206
|
}
|
|
207
207
|
}, [i, t, r]);
|
|
208
|
-
return
|
|
209
|
-
r ?
|
|
210
|
-
}, []), /* @__PURE__ */ n(
|
|
208
|
+
return re(() => {
|
|
209
|
+
r ? S() : g();
|
|
210
|
+
}, []), /* @__PURE__ */ n(xe.Provider, { value: b, children: e });
|
|
211
211
|
}
|
|
212
|
-
function
|
|
213
|
-
const i =
|
|
212
|
+
function ge() {
|
|
213
|
+
const i = se(xe);
|
|
214
214
|
if (!i)
|
|
215
215
|
throw new Error("useApp must be used within an AppProvider");
|
|
216
216
|
return i;
|
|
217
217
|
}
|
|
218
|
-
function
|
|
219
|
-
return
|
|
218
|
+
function Ue() {
|
|
219
|
+
return se(xe);
|
|
220
220
|
}
|
|
221
|
-
const
|
|
222
|
-
class
|
|
221
|
+
const Kt = ge;
|
|
222
|
+
class ke {
|
|
223
223
|
constructor(e = {}) {
|
|
224
224
|
this.refreshPromise = null, this.refreshQueue = [], e.tenantSlug !== void 0 ? this.storageKey = e.tenantSlug ? `auth_tokens_${e.tenantSlug}` : "auth_tokens" : this.storageKey = e.storageKey || "auth_tokens", this.autoRefresh = e.autoRefresh ?? !0, this.refreshThreshold = e.refreshThreshold || 3e5, this.onRefreshFailed = e.onRefreshFailed, this.baseUrl = e.baseUrl || "", this.tokenStorage = e.tokenStorage || this.createTokenStorage(this.storageKey);
|
|
225
225
|
}
|
|
@@ -372,7 +372,7 @@ class be {
|
|
|
372
372
|
return e !== null && !this.isTokenExpired(e);
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
|
-
class
|
|
375
|
+
class tt {
|
|
376
376
|
constructor(e) {
|
|
377
377
|
this.httpService = e;
|
|
378
378
|
}
|
|
@@ -392,6 +392,17 @@ class Ke {
|
|
|
392
392
|
async refreshToken(e) {
|
|
393
393
|
return await this.httpService.post("/auth/refresh", e);
|
|
394
394
|
}
|
|
395
|
+
async switchTenant(e) {
|
|
396
|
+
return await this.httpService.post(
|
|
397
|
+
"/auth/switch-tenant",
|
|
398
|
+
e
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
async getUserTenants(e) {
|
|
402
|
+
return await this.httpService.get("/auth/tenants", {
|
|
403
|
+
headers: e
|
|
404
|
+
});
|
|
405
|
+
}
|
|
395
406
|
async requestPasswordReset(e) {
|
|
396
407
|
await this.httpService.post("/auth/password-reset/request", e);
|
|
397
408
|
}
|
|
@@ -417,7 +428,7 @@ class Ke {
|
|
|
417
428
|
});
|
|
418
429
|
}
|
|
419
430
|
}
|
|
420
|
-
class
|
|
431
|
+
class Ce {
|
|
421
432
|
constructor(e, t) {
|
|
422
433
|
this.httpService = e, this.sessionManager = t;
|
|
423
434
|
}
|
|
@@ -493,7 +504,7 @@ class Me {
|
|
|
493
504
|
};
|
|
494
505
|
}
|
|
495
506
|
}
|
|
496
|
-
class
|
|
507
|
+
class rt {
|
|
497
508
|
constructor(e, t) {
|
|
498
509
|
this.httpService = e, this.sessionManager = t;
|
|
499
510
|
}
|
|
@@ -533,7 +544,7 @@ class Je {
|
|
|
533
544
|
});
|
|
534
545
|
}
|
|
535
546
|
}
|
|
536
|
-
class
|
|
547
|
+
class ue {
|
|
537
548
|
constructor(e, t, r) {
|
|
538
549
|
this.httpService = e, this.appId = t, this.sessionManager = r;
|
|
539
550
|
}
|
|
@@ -611,7 +622,7 @@ class de {
|
|
|
611
622
|
)).data;
|
|
612
623
|
}
|
|
613
624
|
}
|
|
614
|
-
function
|
|
625
|
+
function nt(i, e) {
|
|
615
626
|
if (i === "localhost" || i.startsWith("127.") || i.startsWith("192.168."))
|
|
616
627
|
return null;
|
|
617
628
|
if (e) {
|
|
@@ -627,26 +638,26 @@ function Ye(i, e) {
|
|
|
627
638
|
const r = i.split(".");
|
|
628
639
|
return r.length >= 3 && r[0] !== "www" ? r[0] : null;
|
|
629
640
|
}
|
|
630
|
-
function
|
|
641
|
+
function st(i, e = "tenant", t) {
|
|
631
642
|
const s = new URLSearchParams(i).get(e);
|
|
632
643
|
return s ? (t && t.setItem("tenant", s), s) : t ? t.getItem("tenant") : null;
|
|
633
644
|
}
|
|
634
|
-
function
|
|
645
|
+
function it(i, e, t) {
|
|
635
646
|
const { tenantMode: r, baseDomain: s, selectorParam: o } = i;
|
|
636
|
-
return r === "subdomain" ?
|
|
647
|
+
return r === "subdomain" ? nt(e.hostname, s) : r === "selector" ? st(e.search, o, t) : null;
|
|
637
648
|
}
|
|
638
|
-
function
|
|
649
|
+
function ot(i, e, t) {
|
|
639
650
|
if (t)
|
|
640
651
|
return `${i}.${t}`;
|
|
641
652
|
const r = e.split(".");
|
|
642
653
|
return r.length === 2 ? `${i}.${e}` : r.length >= 3 ? (r[0] = i, r.join(".")) : null;
|
|
643
654
|
}
|
|
644
|
-
const
|
|
645
|
-
function
|
|
655
|
+
const me = "_auth";
|
|
656
|
+
function at(i) {
|
|
646
657
|
const e = JSON.stringify(i);
|
|
647
658
|
return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
648
659
|
}
|
|
649
|
-
function
|
|
660
|
+
function lt(i) {
|
|
650
661
|
try {
|
|
651
662
|
let e = i.replace(/-/g, "+").replace(/_/g, "/");
|
|
652
663
|
for (; e.length % 4; )
|
|
@@ -657,16 +668,16 @@ function tt(i) {
|
|
|
657
668
|
return null;
|
|
658
669
|
}
|
|
659
670
|
}
|
|
660
|
-
function
|
|
671
|
+
function ct() {
|
|
661
672
|
if (typeof window > "u")
|
|
662
673
|
return console.log("[CrossDomainAuth] SSR environment, skipping URL token extraction"), null;
|
|
663
|
-
const e = new URLSearchParams(window.location.search).get(
|
|
674
|
+
const e = new URLSearchParams(window.location.search).get(me);
|
|
664
675
|
if (console.log("[CrossDomainAuth] extractAuthTokensFromUrl called", {
|
|
665
676
|
hasAuthParam: !!e,
|
|
666
677
|
searchParams: window.location.search,
|
|
667
678
|
encodedLength: e == null ? void 0 : e.length
|
|
668
679
|
}), !e) return null;
|
|
669
|
-
const t =
|
|
680
|
+
const t = lt(e);
|
|
670
681
|
return console.log("[CrossDomainAuth] Token decode result:", {
|
|
671
682
|
success: !!t,
|
|
672
683
|
hasAccessToken: !!(t != null && t.accessToken),
|
|
@@ -674,17 +685,17 @@ function rt() {
|
|
|
674
685
|
expiresIn: t == null ? void 0 : t.expiresIn
|
|
675
686
|
}), t;
|
|
676
687
|
}
|
|
677
|
-
function
|
|
688
|
+
function dt() {
|
|
678
689
|
if (typeof window > "u") return;
|
|
679
690
|
const i = new URL(window.location.href);
|
|
680
|
-
i.searchParams.delete(
|
|
691
|
+
i.searchParams.delete(me), console.log("[CrossDomainAuth] Clearing auth tokens from URL", {
|
|
681
692
|
oldUrl: window.location.href,
|
|
682
693
|
newUrl: i.toString()
|
|
683
694
|
}), window.history.replaceState({}, "", i.toString());
|
|
684
695
|
}
|
|
685
|
-
const
|
|
686
|
-
function
|
|
687
|
-
const { baseUrl: t, appInfo: r, appId: s } =
|
|
696
|
+
const Ae = he(null);
|
|
697
|
+
function Yt({ config: i, children: e }) {
|
|
698
|
+
const { baseUrl: t, appInfo: r, appId: s } = ge(), o = ie(() => typeof window > "u" ? null : it(
|
|
688
699
|
{
|
|
689
700
|
tenantMode: i.tenantMode || "selector",
|
|
690
701
|
baseDomain: i.baseDomain,
|
|
@@ -695,118 +706,118 @@ function zt({ config: i, children: e }) {
|
|
|
695
706
|
search: window.location.search
|
|
696
707
|
},
|
|
697
708
|
window.localStorage
|
|
698
|
-
), [i.tenantMode, i.baseDomain, i.selectorParam]), [a,
|
|
709
|
+
), [i.tenantMode, i.baseDomain, i.selectorParam]), [a, m] = k(() => o()), y = te(
|
|
699
710
|
() => {
|
|
700
|
-
var
|
|
711
|
+
var l, H, M;
|
|
701
712
|
return {
|
|
702
|
-
enabled: ((
|
|
703
|
-
ttl: ((
|
|
713
|
+
enabled: ((l = i.cache) == null ? void 0 : l.enabled) ?? !0,
|
|
714
|
+
ttl: ((H = i.cache) == null ? void 0 : H.ttl) ?? 5 * 60 * 1e3,
|
|
704
715
|
// 5 minutes default
|
|
705
|
-
storageKey: ((
|
|
716
|
+
storageKey: ((M = i.cache) == null ? void 0 : M.storageKey) ?? `tenant_cache_${a || "default"}`
|
|
706
717
|
};
|
|
707
718
|
},
|
|
708
719
|
[i.cache, a]
|
|
709
|
-
), [
|
|
720
|
+
), [b, g] = k(() => {
|
|
710
721
|
if (i.initialTenant) return i.initialTenant;
|
|
711
|
-
if (!
|
|
722
|
+
if (!y.enabled || !a) return null;
|
|
712
723
|
try {
|
|
713
|
-
const
|
|
714
|
-
if (!
|
|
715
|
-
const
|
|
716
|
-
return Date.now() -
|
|
724
|
+
const l = localStorage.getItem(y.storageKey);
|
|
725
|
+
if (!l) return null;
|
|
726
|
+
const H = JSON.parse(l);
|
|
727
|
+
return Date.now() - H.timestamp < y.ttl && H.tenantSlug === a ? H.data : (localStorage.removeItem(y.storageKey), null);
|
|
717
728
|
} catch {
|
|
718
729
|
return null;
|
|
719
730
|
}
|
|
720
|
-
}), [
|
|
721
|
-
|
|
722
|
-
const
|
|
723
|
-
|
|
731
|
+
}), [S, f] = k(!b && !i.initialTenant), [T, I] = k(null), [C, R] = k(null), [x, h] = k(!1), [$, A] = k(null);
|
|
732
|
+
re(() => {
|
|
733
|
+
const l = o();
|
|
734
|
+
m(l);
|
|
724
735
|
}, [o]);
|
|
725
|
-
const
|
|
726
|
-
async (
|
|
727
|
-
if (!(!
|
|
736
|
+
const E = (r == null ? void 0 : r.settingsSchema) || null, N = ie(
|
|
737
|
+
async (l, H = !1) => {
|
|
738
|
+
if (!(!H && y.enabled && b && b.domain === l))
|
|
728
739
|
try {
|
|
729
|
-
f(!0),
|
|
730
|
-
const
|
|
731
|
-
if (
|
|
740
|
+
f(!0), I(null);
|
|
741
|
+
const M = new ne(t), u = await new ue(M, s).getPublicTenantInfo(l);
|
|
742
|
+
if (g(u), y.enabled)
|
|
732
743
|
try {
|
|
733
|
-
const
|
|
734
|
-
data:
|
|
744
|
+
const w = {
|
|
745
|
+
data: u,
|
|
735
746
|
timestamp: Date.now(),
|
|
736
|
-
tenantSlug:
|
|
747
|
+
tenantSlug: l
|
|
737
748
|
};
|
|
738
|
-
localStorage.setItem(
|
|
739
|
-
} catch (
|
|
740
|
-
console.warn("Failed to cache tenant info:",
|
|
749
|
+
localStorage.setItem(y.storageKey, JSON.stringify(w));
|
|
750
|
+
} catch (w) {
|
|
751
|
+
console.warn("Failed to cache tenant info:", w);
|
|
741
752
|
}
|
|
742
|
-
} catch (
|
|
743
|
-
const
|
|
744
|
-
|
|
753
|
+
} catch (M) {
|
|
754
|
+
const p = M instanceof Error ? M : new Error("Failed to load tenant information");
|
|
755
|
+
I(p), g(null);
|
|
745
756
|
} finally {
|
|
746
757
|
f(!1);
|
|
747
758
|
}
|
|
748
759
|
},
|
|
749
|
-
[t, s,
|
|
750
|
-
),
|
|
751
|
-
if (!(!
|
|
760
|
+
[t, s, y, b]
|
|
761
|
+
), D = ie(async () => {
|
|
762
|
+
if (!(!y.enabled || !b || !a))
|
|
752
763
|
try {
|
|
753
|
-
const
|
|
754
|
-
if (!
|
|
755
|
-
const
|
|
756
|
-
if (Date.now() -
|
|
757
|
-
const
|
|
758
|
-
|
|
764
|
+
const l = localStorage.getItem(y.storageKey);
|
|
765
|
+
if (!l) return;
|
|
766
|
+
const H = JSON.parse(l);
|
|
767
|
+
if (Date.now() - H.timestamp > y.ttl * 0.5) {
|
|
768
|
+
const p = new ne(t), w = await new ue(p, s).getPublicTenantInfo(a);
|
|
769
|
+
g(w);
|
|
759
770
|
const G = {
|
|
760
|
-
data:
|
|
771
|
+
data: w,
|
|
761
772
|
timestamp: Date.now(),
|
|
762
773
|
tenantSlug: a
|
|
763
774
|
};
|
|
764
|
-
localStorage.setItem(
|
|
775
|
+
localStorage.setItem(y.storageKey, JSON.stringify(G));
|
|
765
776
|
}
|
|
766
|
-
} catch (
|
|
767
|
-
console.warn("Background tenant refresh failed:",
|
|
777
|
+
} catch (l) {
|
|
778
|
+
console.warn("Background tenant refresh failed:", l);
|
|
768
779
|
}
|
|
769
|
-
}, [t, s,
|
|
770
|
-
if (
|
|
780
|
+
}, [t, s, y, b, a]), P = ie(async () => {
|
|
781
|
+
if (b != null && b.id)
|
|
771
782
|
try {
|
|
772
|
-
|
|
773
|
-
const
|
|
774
|
-
|
|
775
|
-
} catch (
|
|
776
|
-
const
|
|
777
|
-
|
|
783
|
+
h(!0), A(null);
|
|
784
|
+
const l = new ne(t), M = await new ue(l, b.appId).getTenantSettings(b.id);
|
|
785
|
+
R(M);
|
|
786
|
+
} catch (l) {
|
|
787
|
+
const H = l instanceof Error ? l : new Error("Failed to load tenant settings");
|
|
788
|
+
A(H), R(null);
|
|
778
789
|
} finally {
|
|
779
|
-
|
|
790
|
+
h(!1);
|
|
780
791
|
}
|
|
781
|
-
}, [t,
|
|
782
|
-
|
|
783
|
-
}, [
|
|
784
|
-
(
|
|
785
|
-
if (!
|
|
792
|
+
}, [t, b]), O = ie(() => {
|
|
793
|
+
P();
|
|
794
|
+
}, [P]), c = ie(
|
|
795
|
+
(l) => {
|
|
796
|
+
if (!E)
|
|
786
797
|
return { isValid: !0, errors: [] };
|
|
787
|
-
const
|
|
798
|
+
const H = [];
|
|
788
799
|
try {
|
|
789
|
-
return
|
|
790
|
-
var
|
|
791
|
-
const
|
|
792
|
-
if ((
|
|
793
|
-
|
|
800
|
+
return E.properties && Object.entries(E.properties).forEach(([M, p]) => {
|
|
801
|
+
var w;
|
|
802
|
+
const u = l[M];
|
|
803
|
+
if ((w = E.required) != null && w.includes(M) && u == null) {
|
|
804
|
+
H.push(`Field '${M}' is required`);
|
|
794
805
|
return;
|
|
795
806
|
}
|
|
796
|
-
if (
|
|
797
|
-
if (
|
|
798
|
-
const G =
|
|
799
|
-
G === "string" &&
|
|
807
|
+
if (u != null) {
|
|
808
|
+
if (p.type) {
|
|
809
|
+
const G = p.type, K = typeof u;
|
|
810
|
+
G === "string" && K !== "string" ? H.push(`Field '${M}' must be a string`) : (G === "number" || G === "integer") && K !== "number" ? H.push(`Field '${M}' must be a number`) : G === "boolean" && K !== "boolean" ? H.push(`Field '${M}' must be a boolean`) : G === "array" && !Array.isArray(u) && H.push(`Field '${M}' must be an array`);
|
|
800
811
|
}
|
|
801
|
-
|
|
802
|
-
`Field '${
|
|
803
|
-
),
|
|
804
|
-
`Field '${
|
|
805
|
-
),
|
|
812
|
+
p.minLength !== void 0 && typeof u == "string" && u.length < p.minLength && H.push(
|
|
813
|
+
`Field '${M}' must be at least ${p.minLength} characters long`
|
|
814
|
+
), p.maxLength !== void 0 && typeof u == "string" && u.length > p.maxLength && H.push(
|
|
815
|
+
`Field '${M}' must be no more than ${p.maxLength} characters long`
|
|
816
|
+
), p.minimum !== void 0 && typeof u == "number" && u < p.minimum && H.push(`Field '${M}' must be at least ${p.minimum}`), p.maximum !== void 0 && typeof u == "number" && u > p.maximum && H.push(`Field '${M}' must be no more than ${p.maximum}`), p.pattern && typeof u == "string" && (new RegExp(p.pattern).test(u) || H.push(`Field '${M}' does not match the required pattern`)), p.enum && !p.enum.includes(u) && H.push(`Field '${M}' must be one of: ${p.enum.join(", ")}`);
|
|
806
817
|
}
|
|
807
818
|
}), {
|
|
808
|
-
isValid:
|
|
809
|
-
errors:
|
|
819
|
+
isValid: H.length === 0,
|
|
820
|
+
errors: H
|
|
810
821
|
};
|
|
811
822
|
} catch {
|
|
812
823
|
return {
|
|
@@ -815,91 +826,91 @@ function zt({ config: i, children: e }) {
|
|
|
815
826
|
};
|
|
816
827
|
}
|
|
817
828
|
},
|
|
818
|
-
[
|
|
829
|
+
[E]
|
|
819
830
|
);
|
|
820
|
-
|
|
821
|
-
!i.initialTenant && a ?
|
|
822
|
-
}, [i.initialTenant, a,
|
|
823
|
-
|
|
824
|
-
}, [
|
|
825
|
-
const
|
|
826
|
-
(
|
|
827
|
-
const { mode:
|
|
828
|
-
if (localStorage.setItem("tenant",
|
|
829
|
-
const G = window.location.hostname,
|
|
830
|
-
|
|
831
|
+
re(() => {
|
|
832
|
+
!i.initialTenant && a ? b ? D() : N(a) : !i.initialTenant && !a && (g(null), I(null), f(!1));
|
|
833
|
+
}, [i.initialTenant, a, b, N, D]), re(() => {
|
|
834
|
+
b != null && b.id ? P() : (R(null), A(null), h(!1));
|
|
835
|
+
}, [b == null ? void 0 : b.id, P]);
|
|
836
|
+
const L = ie(
|
|
837
|
+
(l, H) => {
|
|
838
|
+
const { mode: M = "reload", tokens: p, redirectPath: u } = H || {}, w = i.tenantMode || "selector";
|
|
839
|
+
if (localStorage.setItem("tenant", l), w === "subdomain") {
|
|
840
|
+
const G = window.location.hostname, K = ot(
|
|
841
|
+
l,
|
|
831
842
|
G,
|
|
832
843
|
i.baseDomain
|
|
833
844
|
);
|
|
834
|
-
if (!
|
|
845
|
+
if (!K) {
|
|
835
846
|
console.warn(
|
|
836
847
|
"[TenantProvider] Cannot switch subdomain, invalid hostname:",
|
|
837
848
|
G
|
|
838
849
|
);
|
|
839
850
|
return;
|
|
840
851
|
}
|
|
841
|
-
const
|
|
842
|
-
new URLSearchParams(window.location.search).forEach((
|
|
843
|
-
J !==
|
|
844
|
-
}),
|
|
845
|
-
} else if (
|
|
846
|
-
const G =
|
|
847
|
-
if (
|
|
848
|
-
const
|
|
849
|
-
window.location.href =
|
|
852
|
+
const U = u || window.location.pathname, q = new URL(`${window.location.protocol}//${K}${U}`);
|
|
853
|
+
new URLSearchParams(window.location.search).forEach((v, J) => {
|
|
854
|
+
J !== me && q.searchParams.set(J, v);
|
|
855
|
+
}), p && q.searchParams.set(me, at(p)), window.location.href = q.toString();
|
|
856
|
+
} else if (w === "selector") {
|
|
857
|
+
const G = u || window.location.pathname, K = new URLSearchParams(window.location.search);
|
|
858
|
+
if (K.set(i.selectorParam || "tenant", l), M === "reload") {
|
|
859
|
+
const U = `${G}?${K.toString()}${window.location.hash}`;
|
|
860
|
+
window.location.href = U;
|
|
850
861
|
} else {
|
|
851
|
-
const
|
|
852
|
-
window.history.pushState({}, "",
|
|
862
|
+
const U = `${G}?${K.toString()}${window.location.hash}`;
|
|
863
|
+
window.history.pushState({}, "", U), m(l), N(l);
|
|
853
864
|
}
|
|
854
865
|
}
|
|
855
866
|
},
|
|
856
|
-
[i.tenantMode, i.selectorParam, i.baseDomain,
|
|
857
|
-
), F =
|
|
867
|
+
[i.tenantMode, i.selectorParam, i.baseDomain, N]
|
|
868
|
+
), F = te(() => ({
|
|
858
869
|
// Tenant info
|
|
859
|
-
tenant:
|
|
870
|
+
tenant: b,
|
|
860
871
|
tenantSlug: a,
|
|
861
|
-
isTenantLoading:
|
|
862
|
-
tenantError:
|
|
872
|
+
isTenantLoading: S,
|
|
873
|
+
tenantError: T,
|
|
863
874
|
retryTenant: () => {
|
|
864
|
-
a &&
|
|
875
|
+
a && N(a);
|
|
865
876
|
},
|
|
866
877
|
// Settings
|
|
867
|
-
settings:
|
|
868
|
-
settingsSchema:
|
|
869
|
-
isSettingsLoading:
|
|
870
|
-
settingsError:
|
|
878
|
+
settings: C,
|
|
879
|
+
settingsSchema: E,
|
|
880
|
+
isSettingsLoading: x,
|
|
881
|
+
settingsError: $,
|
|
871
882
|
// Actions
|
|
872
|
-
refreshSettings:
|
|
873
|
-
switchTenant:
|
|
883
|
+
refreshSettings: O,
|
|
884
|
+
switchTenant: L,
|
|
874
885
|
// Validation
|
|
875
|
-
validateSettings:
|
|
886
|
+
validateSettings: c
|
|
876
887
|
}), [
|
|
877
|
-
m,
|
|
878
|
-
a,
|
|
879
888
|
b,
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
P,
|
|
884
|
-
M,
|
|
889
|
+
a,
|
|
890
|
+
S,
|
|
891
|
+
T,
|
|
885
892
|
C,
|
|
886
|
-
|
|
887
|
-
x
|
|
893
|
+
E,
|
|
894
|
+
x,
|
|
895
|
+
$,
|
|
896
|
+
O,
|
|
897
|
+
L,
|
|
898
|
+
c
|
|
888
899
|
]);
|
|
889
|
-
return /* @__PURE__ */ n(
|
|
900
|
+
return /* @__PURE__ */ n(Ae.Provider, { value: F, children: e });
|
|
890
901
|
}
|
|
891
|
-
function
|
|
892
|
-
const i =
|
|
902
|
+
function ye() {
|
|
903
|
+
const i = se(Ae);
|
|
893
904
|
if (!i)
|
|
894
905
|
throw new Error("useTenant must be used within a TenantProvider");
|
|
895
906
|
return i;
|
|
896
907
|
}
|
|
897
|
-
function
|
|
898
|
-
return
|
|
908
|
+
function we() {
|
|
909
|
+
return se(Ae);
|
|
899
910
|
}
|
|
900
|
-
const
|
|
901
|
-
function
|
|
902
|
-
const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } =
|
|
911
|
+
const Qt = ye;
|
|
912
|
+
function Xt() {
|
|
913
|
+
const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } = ye();
|
|
903
914
|
return {
|
|
904
915
|
settings: i,
|
|
905
916
|
settingsSchema: e,
|
|
@@ -908,8 +919,8 @@ function Wt() {
|
|
|
908
919
|
validateSettings: s
|
|
909
920
|
};
|
|
910
921
|
}
|
|
911
|
-
function
|
|
912
|
-
const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } =
|
|
922
|
+
function ce() {
|
|
923
|
+
const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } = ye();
|
|
913
924
|
return {
|
|
914
925
|
tenant: i,
|
|
915
926
|
tenantSlug: e,
|
|
@@ -918,312 +929,385 @@ function le() {
|
|
|
918
929
|
retry: s
|
|
919
930
|
};
|
|
920
931
|
}
|
|
921
|
-
const
|
|
922
|
-
function
|
|
923
|
-
const { appId: t, baseUrl: r } =
|
|
924
|
-
|
|
932
|
+
const Pe = he(null);
|
|
933
|
+
function Zt({ config: i = {}, children: e }) {
|
|
934
|
+
const { appId: t, baseUrl: r } = ge(), { tenant: s, tenantSlug: o, switchTenant: a } = ye(), [m, y] = k(i.initialRoles || []), [b, g] = k(!i.initialRoles), [S, f] = k(null), [T, I] = k(!1), [C, R] = k(null), [x, h] = k(0), [$, A] = k(() => {
|
|
935
|
+
try {
|
|
936
|
+
const v = localStorage.getItem("userTenants");
|
|
937
|
+
return v ? JSON.parse(v) : [];
|
|
938
|
+
} catch {
|
|
939
|
+
return [];
|
|
940
|
+
}
|
|
941
|
+
}), [E, N] = k(!1), D = Ne({ done: !1, urlTokens: null });
|
|
942
|
+
D.current.done || (D.current.done = !0, D.current.urlTokens = ct(), D.current.urlTokens && console.log(
|
|
925
943
|
"[AuthProvider] SYNC: URL tokens found, will block isAuthReady until user loaded"
|
|
926
944
|
));
|
|
927
|
-
const [
|
|
928
|
-
const
|
|
929
|
-
return console.log("[AuthProvider] SYNC: isLoadingAfterUrlTokens initial:",
|
|
930
|
-
}),
|
|
931
|
-
const
|
|
945
|
+
const [P, O] = k(() => {
|
|
946
|
+
const v = D.current.urlTokens !== null;
|
|
947
|
+
return console.log("[AuthProvider] SYNC: isLoadingAfterUrlTokens initial:", v), v;
|
|
948
|
+
}), c = te(() => {
|
|
949
|
+
const v = new ke({
|
|
932
950
|
tenantSlug: o,
|
|
933
951
|
onRefreshFailed: i.onRefreshFailed,
|
|
934
952
|
baseUrl: r
|
|
935
953
|
});
|
|
936
|
-
return
|
|
937
|
-
accessToken:
|
|
938
|
-
refreshToken:
|
|
939
|
-
expiresIn:
|
|
940
|
-
}), console.log("[AuthProvider] SYNC: Session valid:",
|
|
941
|
-
}, [o, r, i.onRefreshFailed]),
|
|
942
|
-
const
|
|
943
|
-
return
|
|
944
|
-
}, [r,
|
|
945
|
-
const
|
|
954
|
+
return D.current.urlTokens && (console.log("[AuthProvider] SYNC: Saving URL tokens to session manager"), v.setTokens({
|
|
955
|
+
accessToken: D.current.urlTokens.accessToken,
|
|
956
|
+
refreshToken: D.current.urlTokens.refreshToken,
|
|
957
|
+
expiresIn: D.current.urlTokens.expiresIn
|
|
958
|
+
}), console.log("[AuthProvider] SYNC: Session valid:", v.hasValidSession())), v;
|
|
959
|
+
}, [o, r, i.onRefreshFailed]), L = D.current.done && !P, F = te(() => {
|
|
960
|
+
const v = new ne(r);
|
|
961
|
+
return v.setSessionManager(c), v;
|
|
962
|
+
}, [r, c]), l = te(() => new tt(new ne(r)), [r]), H = te(() => new rt(F, c), [F, c]), M = te(() => new Ce(new ne(r)), [r]), p = te(() => S || c.getUser(), [S, c]), u = te(() => p != null && p.roleId && m.find((v) => v.id === p.roleId) || null, [p, m]), w = te(() => (u == null ? void 0 : u.permissions) || [], [u]), G = te(() => c.hasValidSession() && S !== null, [c, S]), K = 5 * 60 * 1e3, U = te(() => {
|
|
963
|
+
const v = async (B = !1) => {
|
|
946
964
|
try {
|
|
947
|
-
if (!
|
|
965
|
+
if (!c.hasValidSession())
|
|
948
966
|
return;
|
|
949
|
-
const
|
|
950
|
-
if (!
|
|
967
|
+
const z = Date.now();
|
|
968
|
+
if (!B && z - x < K && S)
|
|
951
969
|
return;
|
|
952
|
-
const
|
|
953
|
-
if (!
|
|
970
|
+
const W = c.getUserId();
|
|
971
|
+
if (!W) {
|
|
954
972
|
console.warn("[AuthProvider] No userId available in token or storage");
|
|
955
973
|
return;
|
|
956
974
|
}
|
|
957
|
-
|
|
958
|
-
const
|
|
959
|
-
f(
|
|
960
|
-
} catch (
|
|
961
|
-
const Y =
|
|
962
|
-
|
|
975
|
+
I(!0), R(null);
|
|
976
|
+
const Q = await H.getUserById(W);
|
|
977
|
+
f(Q), c.setUser(Q), h(Date.now());
|
|
978
|
+
} catch (z) {
|
|
979
|
+
const Y = z instanceof Error ? z : new Error("Failed to load user data");
|
|
980
|
+
R(Y), console.error("[AuthProvider] Failed to load user data:", Y);
|
|
963
981
|
} finally {
|
|
964
|
-
|
|
982
|
+
I(!1);
|
|
965
983
|
}
|
|
966
|
-
},
|
|
967
|
-
await
|
|
968
|
-
},
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
984
|
+
}, J = async () => {
|
|
985
|
+
await v();
|
|
986
|
+
}, le = async (B) => {
|
|
987
|
+
var Le;
|
|
988
|
+
const { username: z, password: Y, tenantSlug: W, redirectPath: Q } = B;
|
|
989
|
+
let X = s == null ? void 0 : s.id, Z = o, ee = c;
|
|
990
|
+
W && (X = (await new ue(F, t).getPublicTenantInfo(W)).id, Z = W);
|
|
991
|
+
const _ = await l.login({
|
|
992
|
+
username: z,
|
|
974
993
|
password: Y,
|
|
975
994
|
appId: t,
|
|
976
|
-
tenantId:
|
|
977
|
-
}),
|
|
978
|
-
if (
|
|
979
|
-
tenantSlug:
|
|
995
|
+
tenantId: X
|
|
996
|
+
}), de = W && W !== o;
|
|
997
|
+
if (de && (ee = new ke({
|
|
998
|
+
tenantSlug: Z,
|
|
980
999
|
baseUrl: r
|
|
981
1000
|
})), ee.setTokens({
|
|
982
|
-
accessToken:
|
|
983
|
-
refreshToken:
|
|
984
|
-
expiresIn:
|
|
985
|
-
}),
|
|
986
|
-
ee.setUser(
|
|
1001
|
+
accessToken: _.accessToken,
|
|
1002
|
+
refreshToken: _.refreshToken,
|
|
1003
|
+
expiresIn: _.expiresIn
|
|
1004
|
+
}), _.user) {
|
|
1005
|
+
ee.setUser(_.user), f(_.user);
|
|
987
1006
|
try {
|
|
988
|
-
await
|
|
989
|
-
} catch (
|
|
990
|
-
console.warn("Failed to load complete user data after login:",
|
|
1007
|
+
await v();
|
|
1008
|
+
} catch (pe) {
|
|
1009
|
+
console.warn("Failed to load complete user data after login:", pe);
|
|
991
1010
|
}
|
|
992
1011
|
}
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
1012
|
+
if (_.tenants && _.tenants.length > 0) {
|
|
1013
|
+
A(_.tenants);
|
|
1014
|
+
try {
|
|
1015
|
+
localStorage.setItem("userTenants", JSON.stringify(_.tenants));
|
|
1016
|
+
} catch {
|
|
998
1017
|
}
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1018
|
+
}
|
|
1019
|
+
const ve = ((Le = _.user) == null ? void 0 : Le.tenantId) !== null;
|
|
1020
|
+
if (N(ve), de && Z && Z !== o && a(Z, {
|
|
1021
|
+
tokens: {
|
|
1022
|
+
accessToken: _.accessToken,
|
|
1023
|
+
refreshToken: _.refreshToken,
|
|
1024
|
+
expiresIn: _.expiresIn
|
|
1025
|
+
},
|
|
1026
|
+
redirectPath: Q
|
|
1027
|
+
}), !ve && _.tenants && _.tenants.length > 0) {
|
|
1028
|
+
const pe = i.autoSwitchSingleTenant !== !1;
|
|
1029
|
+
if (_.tenants.length === 1 && pe) {
|
|
1030
|
+
const Ee = _.tenants[0];
|
|
1031
|
+
a(Ee.subdomain, {
|
|
1032
|
+
tokens: {
|
|
1033
|
+
accessToken: _.accessToken,
|
|
1034
|
+
refreshToken: _.refreshToken,
|
|
1035
|
+
expiresIn: _.expiresIn
|
|
1036
|
+
},
|
|
1037
|
+
redirectPath: Q
|
|
1038
|
+
});
|
|
1039
|
+
} else _.tenants.length > 1 && i.onTenantSelectionRequired && i.onTenantSelectionRequired(_.tenants);
|
|
1040
|
+
}
|
|
1041
|
+
return _;
|
|
1042
|
+
}, be = async (B) => {
|
|
1043
|
+
const { email: z, phoneNumber: Y, name: W, password: Q, lastName: X, tenantId: Z } = B;
|
|
1044
|
+
if (!z && !Y)
|
|
1003
1045
|
throw new Error("Either email or phoneNumber is required");
|
|
1004
|
-
if (!
|
|
1046
|
+
if (!W || !Q)
|
|
1005
1047
|
throw new Error("Name and password are required");
|
|
1006
|
-
const
|
|
1007
|
-
return await
|
|
1008
|
-
email:
|
|
1048
|
+
const ee = Z ?? (s == null ? void 0 : s.id);
|
|
1049
|
+
return await l.signup({
|
|
1050
|
+
email: z,
|
|
1009
1051
|
phoneNumber: Y,
|
|
1010
|
-
name:
|
|
1011
|
-
password:
|
|
1012
|
-
tenantId:
|
|
1013
|
-
lastName:
|
|
1052
|
+
name: W,
|
|
1053
|
+
password: Q,
|
|
1054
|
+
tenantId: ee,
|
|
1055
|
+
lastName: X,
|
|
1014
1056
|
appId: t
|
|
1015
1057
|
});
|
|
1016
|
-
},
|
|
1017
|
-
const { email:
|
|
1018
|
-
if (!
|
|
1058
|
+
}, Oe = async (B) => {
|
|
1059
|
+
const { email: z, phoneNumber: Y, name: W, password: Q, tenantName: X, lastName: Z } = B;
|
|
1060
|
+
if (!z && !Y)
|
|
1019
1061
|
throw new Error("Either email or phoneNumber is required");
|
|
1020
|
-
if (!
|
|
1062
|
+
if (!W || !Q || !X)
|
|
1021
1063
|
throw new Error("Name, password, and tenantName are required");
|
|
1022
|
-
return await
|
|
1023
|
-
email:
|
|
1064
|
+
return await l.signupTenantAdmin({
|
|
1065
|
+
email: z,
|
|
1024
1066
|
phoneNumber: Y,
|
|
1025
|
-
name:
|
|
1026
|
-
password:
|
|
1027
|
-
tenantName:
|
|
1067
|
+
name: W,
|
|
1068
|
+
password: Q,
|
|
1069
|
+
tenantName: X,
|
|
1028
1070
|
appId: t,
|
|
1029
|
-
lastName:
|
|
1071
|
+
lastName: Z
|
|
1030
1072
|
});
|
|
1031
|
-
},
|
|
1032
|
-
const { currentPassword:
|
|
1033
|
-
await
|
|
1034
|
-
},
|
|
1035
|
-
const { email:
|
|
1036
|
-
if (!
|
|
1073
|
+
}, We = async (B) => {
|
|
1074
|
+
const { currentPassword: z, newPassword: Y } = B, W = await c.getAuthHeaders();
|
|
1075
|
+
await l.changePassword({ currentPassword: z, newPassword: Y }, W);
|
|
1076
|
+
}, je = async (B) => {
|
|
1077
|
+
const { email: z, tenantId: Y } = B, W = Y ?? (s == null ? void 0 : s.id);
|
|
1078
|
+
if (!W)
|
|
1037
1079
|
throw new Error("tenantId is required for password reset");
|
|
1038
|
-
await
|
|
1039
|
-
},
|
|
1040
|
-
const { token:
|
|
1041
|
-
await
|
|
1042
|
-
},
|
|
1043
|
-
const { email:
|
|
1044
|
-
if (!
|
|
1080
|
+
await l.requestPasswordReset({ email: z, tenantId: W });
|
|
1081
|
+
}, Ve = async (B) => {
|
|
1082
|
+
const { token: z, newPassword: Y } = B;
|
|
1083
|
+
await l.confirmPasswordReset({ token: z, newPassword: Y });
|
|
1084
|
+
}, _e = async (B) => {
|
|
1085
|
+
const { email: z, frontendUrl: Y, name: W, lastName: Q, tenantId: X } = B, Z = X ?? (s == null ? void 0 : s.id);
|
|
1086
|
+
if (!Z)
|
|
1045
1087
|
throw new Error("tenantId is required for magic link authentication");
|
|
1046
|
-
return await
|
|
1047
|
-
email:
|
|
1048
|
-
tenantId:
|
|
1088
|
+
return await l.sendMagicLink({
|
|
1089
|
+
email: z,
|
|
1090
|
+
tenantId: Z,
|
|
1049
1091
|
frontendUrl: Y,
|
|
1050
|
-
name:
|
|
1051
|
-
lastName:
|
|
1092
|
+
name: W,
|
|
1093
|
+
lastName: Q,
|
|
1052
1094
|
appId: t
|
|
1053
1095
|
});
|
|
1054
|
-
},
|
|
1055
|
-
const { token:
|
|
1056
|
-
let
|
|
1057
|
-
|
|
1058
|
-
const
|
|
1059
|
-
token:
|
|
1096
|
+
}, Ge = async (B) => {
|
|
1097
|
+
const { token: z, email: Y, tenantSlug: W } = B;
|
|
1098
|
+
let Q = s == null ? void 0 : s.id, X = o, Z = c;
|
|
1099
|
+
W && (Q = (await new ue(F, t).getPublicTenantInfo(W)).id, X = W);
|
|
1100
|
+
const ee = await l.verifyMagicLink({
|
|
1101
|
+
token: z,
|
|
1060
1102
|
email: Y,
|
|
1061
1103
|
appId: t,
|
|
1062
|
-
tenantId:
|
|
1063
|
-
}),
|
|
1064
|
-
if (
|
|
1065
|
-
tenantSlug:
|
|
1104
|
+
tenantId: Q
|
|
1105
|
+
}), _ = W && W !== o;
|
|
1106
|
+
if (_ && (Z = new ke({
|
|
1107
|
+
tenantSlug: X,
|
|
1066
1108
|
baseUrl: r
|
|
1067
|
-
})),
|
|
1068
|
-
accessToken:
|
|
1069
|
-
refreshToken:
|
|
1070
|
-
expiresIn:
|
|
1071
|
-
}),
|
|
1072
|
-
|
|
1109
|
+
})), Z.setTokens({
|
|
1110
|
+
accessToken: ee.accessToken,
|
|
1111
|
+
refreshToken: ee.refreshToken,
|
|
1112
|
+
expiresIn: ee.expiresIn
|
|
1113
|
+
}), ee.user) {
|
|
1114
|
+
Z.setUser(ee.user), f(ee.user);
|
|
1073
1115
|
try {
|
|
1074
|
-
await
|
|
1075
|
-
} catch (
|
|
1076
|
-
console.warn("Failed to load complete user data after magic link login:",
|
|
1116
|
+
await v();
|
|
1117
|
+
} catch (de) {
|
|
1118
|
+
console.warn("Failed to load complete user data after magic link login:", de);
|
|
1077
1119
|
}
|
|
1078
1120
|
}
|
|
1079
|
-
return
|
|
1121
|
+
return _ && X && X !== o && a(X, {
|
|
1080
1122
|
tokens: {
|
|
1081
|
-
accessToken:
|
|
1082
|
-
refreshToken:
|
|
1083
|
-
expiresIn:
|
|
1123
|
+
accessToken: ee.accessToken,
|
|
1124
|
+
refreshToken: ee.refreshToken,
|
|
1125
|
+
expiresIn: ee.expiresIn
|
|
1084
1126
|
}
|
|
1085
|
-
}),
|
|
1086
|
-
},
|
|
1087
|
-
const
|
|
1088
|
-
if (!(
|
|
1127
|
+
}), ee;
|
|
1128
|
+
}, Je = async () => {
|
|
1129
|
+
const B = c.getTokens();
|
|
1130
|
+
if (!(B != null && B.refreshToken))
|
|
1089
1131
|
throw new Error("No refresh token available");
|
|
1090
|
-
const
|
|
1091
|
-
refreshToken:
|
|
1132
|
+
const z = await l.refreshToken({
|
|
1133
|
+
refreshToken: B.refreshToken
|
|
1092
1134
|
});
|
|
1093
|
-
|
|
1094
|
-
accessToken:
|
|
1095
|
-
refreshToken:
|
|
1096
|
-
expiresIn:
|
|
1135
|
+
c.setTokens({
|
|
1136
|
+
accessToken: z.accessToken,
|
|
1137
|
+
refreshToken: z.refreshToken || B.refreshToken,
|
|
1138
|
+
expiresIn: z.expiresIn
|
|
1097
1139
|
});
|
|
1098
|
-
},
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
},
|
|
1140
|
+
}, Ke = () => {
|
|
1141
|
+
c.clearSession(), f(null), R(null), A([]), N(!1);
|
|
1142
|
+
try {
|
|
1143
|
+
localStorage.removeItem("userTenants");
|
|
1144
|
+
} catch {
|
|
1145
|
+
}
|
|
1146
|
+
}, Ye = (B) => {
|
|
1147
|
+
c.setTokens(B);
|
|
1148
|
+
}, Qe = () => c.hasValidSession(), Xe = () => {
|
|
1149
|
+
c.clearSession(), f(null), R(null);
|
|
1150
|
+
}, Ze = async () => {
|
|
1105
1151
|
if (t)
|
|
1106
1152
|
try {
|
|
1107
|
-
|
|
1108
|
-
const { roles:
|
|
1109
|
-
|
|
1110
|
-
} catch (
|
|
1111
|
-
console.error("Failed to fetch roles:",
|
|
1153
|
+
g(!0);
|
|
1154
|
+
const { roles: B } = await M.getRolesByApp(t);
|
|
1155
|
+
y(B);
|
|
1156
|
+
} catch (B) {
|
|
1157
|
+
console.error("Failed to fetch roles:", B);
|
|
1112
1158
|
} finally {
|
|
1113
|
-
|
|
1159
|
+
g(!1);
|
|
1114
1160
|
}
|
|
1115
|
-
},
|
|
1116
|
-
await
|
|
1117
|
-
},
|
|
1118
|
-
if (!
|
|
1161
|
+
}, et = async () => {
|
|
1162
|
+
await Ze();
|
|
1163
|
+
}, Se = (B) => {
|
|
1164
|
+
if (!w || w.length === 0)
|
|
1119
1165
|
return !1;
|
|
1120
|
-
if (typeof
|
|
1121
|
-
return
|
|
1122
|
-
const
|
|
1123
|
-
return
|
|
1166
|
+
if (typeof B == "string")
|
|
1167
|
+
return w.includes(B);
|
|
1168
|
+
const z = `${B.resource}.${B.action}`;
|
|
1169
|
+
return w.includes(z);
|
|
1124
1170
|
};
|
|
1125
1171
|
return {
|
|
1126
1172
|
// RFC-003: Authentication state
|
|
1127
|
-
isAuthenticated:
|
|
1128
|
-
sessionManager:
|
|
1129
|
-
authenticatedHttpService:
|
|
1130
|
-
login:
|
|
1131
|
-
signup:
|
|
1132
|
-
signupTenantAdmin:
|
|
1133
|
-
sendMagicLink:
|
|
1134
|
-
verifyMagicLink:
|
|
1135
|
-
changePassword:
|
|
1136
|
-
requestPasswordReset:
|
|
1137
|
-
confirmPasswordReset:
|
|
1138
|
-
refreshToken:
|
|
1139
|
-
logout:
|
|
1140
|
-
setTokens:
|
|
1141
|
-
hasValidSession:
|
|
1142
|
-
clearSession:
|
|
1143
|
-
currentUser:
|
|
1144
|
-
isUserLoading:
|
|
1145
|
-
userError:
|
|
1146
|
-
loadUserData:
|
|
1147
|
-
refreshUser:
|
|
1148
|
-
isAuthInitializing: !
|
|
1149
|
-
isAuthReady:
|
|
1150
|
-
userRole:
|
|
1151
|
-
userPermissions:
|
|
1152
|
-
availableRoles:
|
|
1153
|
-
rolesLoading:
|
|
1154
|
-
hasPermission:
|
|
1155
|
-
hasAnyPermission: (
|
|
1156
|
-
hasAllPermissions: (
|
|
1157
|
-
getUserPermissionStrings: () =>
|
|
1158
|
-
refreshRoles:
|
|
1173
|
+
isAuthenticated: G,
|
|
1174
|
+
sessionManager: c,
|
|
1175
|
+
authenticatedHttpService: F,
|
|
1176
|
+
login: le,
|
|
1177
|
+
signup: be,
|
|
1178
|
+
signupTenantAdmin: Oe,
|
|
1179
|
+
sendMagicLink: _e,
|
|
1180
|
+
verifyMagicLink: Ge,
|
|
1181
|
+
changePassword: We,
|
|
1182
|
+
requestPasswordReset: je,
|
|
1183
|
+
confirmPasswordReset: Ve,
|
|
1184
|
+
refreshToken: Je,
|
|
1185
|
+
logout: Ke,
|
|
1186
|
+
setTokens: Ye,
|
|
1187
|
+
hasValidSession: Qe,
|
|
1188
|
+
clearSession: Xe,
|
|
1189
|
+
currentUser: S,
|
|
1190
|
+
isUserLoading: T,
|
|
1191
|
+
userError: C,
|
|
1192
|
+
loadUserData: v,
|
|
1193
|
+
refreshUser: J,
|
|
1194
|
+
isAuthInitializing: !L,
|
|
1195
|
+
isAuthReady: L,
|
|
1196
|
+
userRole: u,
|
|
1197
|
+
userPermissions: w,
|
|
1198
|
+
availableRoles: m,
|
|
1199
|
+
rolesLoading: b,
|
|
1200
|
+
hasPermission: Se,
|
|
1201
|
+
hasAnyPermission: (B) => B.some((z) => Se(z)),
|
|
1202
|
+
hasAllPermissions: (B) => B.every((z) => Se(z)),
|
|
1203
|
+
getUserPermissionStrings: () => w || [],
|
|
1204
|
+
refreshRoles: et,
|
|
1205
|
+
// RFC-004: Multi-tenant user membership
|
|
1206
|
+
userTenants: $,
|
|
1207
|
+
hasTenantContext: E,
|
|
1208
|
+
switchToTenant: async (B, z) => {
|
|
1209
|
+
const { redirectPath: Y } = z || {}, W = c.getTokens();
|
|
1210
|
+
if (!(W != null && W.refreshToken))
|
|
1211
|
+
throw new Error("No refresh token available for tenant switch");
|
|
1212
|
+
const Q = await l.switchTenant({
|
|
1213
|
+
refreshToken: W.refreshToken,
|
|
1214
|
+
tenantId: B
|
|
1215
|
+
});
|
|
1216
|
+
c.setTokens({
|
|
1217
|
+
accessToken: Q.accessToken,
|
|
1218
|
+
refreshToken: W.refreshToken,
|
|
1219
|
+
// Keep the same refresh token
|
|
1220
|
+
expiresIn: Q.expiresIn
|
|
1221
|
+
}), f(Q.user), c.setUser(Q.user), N(!0);
|
|
1222
|
+
const X = $.find((Z) => Z.id === B);
|
|
1223
|
+
X && a(X.subdomain, {
|
|
1224
|
+
tokens: {
|
|
1225
|
+
accessToken: Q.accessToken,
|
|
1226
|
+
refreshToken: W.refreshToken,
|
|
1227
|
+
expiresIn: Q.expiresIn
|
|
1228
|
+
},
|
|
1229
|
+
redirectPath: Y
|
|
1230
|
+
});
|
|
1231
|
+
},
|
|
1232
|
+
refreshUserTenants: async () => {
|
|
1233
|
+
const B = await c.getAuthHeaders(), z = await l.getUserTenants(B);
|
|
1234
|
+
A(z);
|
|
1235
|
+
try {
|
|
1236
|
+
localStorage.setItem("userTenants", JSON.stringify(z));
|
|
1237
|
+
} catch {
|
|
1238
|
+
}
|
|
1239
|
+
return z;
|
|
1240
|
+
}
|
|
1159
1241
|
};
|
|
1160
1242
|
}, [
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1243
|
+
G,
|
|
1244
|
+
c,
|
|
1245
|
+
F,
|
|
1246
|
+
l,
|
|
1247
|
+
H,
|
|
1248
|
+
M,
|
|
1167
1249
|
t,
|
|
1168
1250
|
s,
|
|
1169
1251
|
o,
|
|
1170
1252
|
a,
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1253
|
+
m,
|
|
1254
|
+
S,
|
|
1255
|
+
T,
|
|
1256
|
+
C,
|
|
1174
1257
|
$,
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1258
|
+
E,
|
|
1259
|
+
L,
|
|
1260
|
+
u,
|
|
1261
|
+
w,
|
|
1262
|
+
x,
|
|
1263
|
+
K
|
|
1180
1264
|
]);
|
|
1181
|
-
|
|
1265
|
+
re(() => {
|
|
1182
1266
|
!i.initialRoles && t && (async () => {
|
|
1183
1267
|
try {
|
|
1184
|
-
|
|
1185
|
-
const
|
|
1186
|
-
|
|
1187
|
-
} catch (
|
|
1188
|
-
console.error("Failed to fetch roles:",
|
|
1268
|
+
g(!0);
|
|
1269
|
+
const J = new ne(r), le = new Ce(J), { roles: be } = await le.getRolesByApp(t);
|
|
1270
|
+
y(be);
|
|
1271
|
+
} catch (J) {
|
|
1272
|
+
console.error("Failed to fetch roles:", J);
|
|
1189
1273
|
} finally {
|
|
1190
|
-
|
|
1274
|
+
g(!1);
|
|
1191
1275
|
}
|
|
1192
1276
|
})();
|
|
1193
1277
|
}, [t, r, i.initialRoles]);
|
|
1194
|
-
const [
|
|
1195
|
-
return
|
|
1196
|
-
|
|
1197
|
-
console.error("[AuthProvider] Failed to load user data:",
|
|
1278
|
+
const [q, V] = k(!1);
|
|
1279
|
+
return re(() => {
|
|
1280
|
+
q || (V(!0), D.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), dt(), O(!0), console.log("[AuthProvider] EFFECT: Loading user data (blocking isAuthReady)..."), U.loadUserData().catch((v) => {
|
|
1281
|
+
console.error("[AuthProvider] Failed to load user data:", v);
|
|
1198
1282
|
}).finally(() => {
|
|
1199
|
-
console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"),
|
|
1283
|
+
console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"), O(!1);
|
|
1200
1284
|
})));
|
|
1201
|
-
}, [
|
|
1202
|
-
const
|
|
1203
|
-
|
|
1204
|
-
}, [
|
|
1205
|
-
|
|
1285
|
+
}, [U, q]), re(() => {
|
|
1286
|
+
const v = c.getUser();
|
|
1287
|
+
v && c.hasValidSession() && f(v);
|
|
1288
|
+
}, [c]), re(() => {
|
|
1289
|
+
q && (D.current.urlTokens || !S && !T && c.hasValidSession() && (console.log("[AuthProvider] Auto-loading user data..."), U.loadUserData().catch(() => {
|
|
1206
1290
|
})));
|
|
1207
|
-
}, [
|
|
1208
|
-
if (!
|
|
1291
|
+
}, [S, T, U, c, q]), re(() => {
|
|
1292
|
+
if (!c.hasValidSession() || !S)
|
|
1209
1293
|
return;
|
|
1210
|
-
const
|
|
1211
|
-
|
|
1294
|
+
const v = setInterval(() => {
|
|
1295
|
+
U.loadUserData().catch(() => {
|
|
1212
1296
|
});
|
|
1213
|
-
},
|
|
1214
|
-
return () => clearInterval(
|
|
1215
|
-
}, [
|
|
1297
|
+
}, K);
|
|
1298
|
+
return () => clearInterval(v);
|
|
1299
|
+
}, [c, S, U, K]), /* @__PURE__ */ n(Pe.Provider, { value: U, children: e });
|
|
1216
1300
|
}
|
|
1217
|
-
function
|
|
1218
|
-
const i =
|
|
1301
|
+
function ae() {
|
|
1302
|
+
const i = se(Pe);
|
|
1219
1303
|
if (!i)
|
|
1220
1304
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
1221
1305
|
return i;
|
|
1222
1306
|
}
|
|
1223
|
-
function
|
|
1224
|
-
return
|
|
1307
|
+
function Me() {
|
|
1308
|
+
return se(Pe);
|
|
1225
1309
|
}
|
|
1226
|
-
class
|
|
1310
|
+
class ut {
|
|
1227
1311
|
constructor(e, t) {
|
|
1228
1312
|
this.httpService = e, this.sessionManager = t;
|
|
1229
1313
|
}
|
|
@@ -1303,66 +1387,66 @@ class st {
|
|
|
1303
1387
|
})).data;
|
|
1304
1388
|
}
|
|
1305
1389
|
}
|
|
1306
|
-
const
|
|
1307
|
-
function
|
|
1308
|
-
const t =
|
|
1309
|
-
const
|
|
1310
|
-
return new
|
|
1311
|
-
}, [s]),
|
|
1390
|
+
const Ie = he(null);
|
|
1391
|
+
function er({ config: i = {}, children: e }) {
|
|
1392
|
+
const t = Ue(), r = we(), s = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (r == null ? void 0 : r.tenant) ?? null, [m, y] = k([]), [b, g] = k(!1), [S, f] = k(null), [T, I] = k(!1), C = te(() => {
|
|
1393
|
+
const h = new ne(s);
|
|
1394
|
+
return new ut(h);
|
|
1395
|
+
}, [s]), R = async () => {
|
|
1312
1396
|
if (!(a != null && a.id)) {
|
|
1313
|
-
|
|
1397
|
+
y([]);
|
|
1314
1398
|
return;
|
|
1315
1399
|
}
|
|
1316
|
-
|
|
1400
|
+
g(!0), f(null);
|
|
1317
1401
|
try {
|
|
1318
|
-
const
|
|
1319
|
-
|
|
1320
|
-
} catch (
|
|
1321
|
-
const
|
|
1322
|
-
f(
|
|
1402
|
+
const h = await C.getTenantFeatureFlags(a.id, o);
|
|
1403
|
+
y(h);
|
|
1404
|
+
} catch (h) {
|
|
1405
|
+
const $ = h instanceof Error ? h.message : "Failed to fetch feature flags";
|
|
1406
|
+
f($), i.onError && i.onError(h instanceof Error ? h : new Error($));
|
|
1323
1407
|
} finally {
|
|
1324
|
-
|
|
1408
|
+
g(!1);
|
|
1325
1409
|
}
|
|
1326
1410
|
};
|
|
1327
|
-
|
|
1411
|
+
re(() => {
|
|
1328
1412
|
if (!s || !o) return;
|
|
1329
|
-
|
|
1330
|
-
const
|
|
1331
|
-
return () => clearInterval(
|
|
1413
|
+
R().finally(() => I(!0));
|
|
1414
|
+
const h = i.refreshInterval || 5 * 60 * 1e3, $ = setInterval(R, h);
|
|
1415
|
+
return () => clearInterval($);
|
|
1332
1416
|
}, [a == null ? void 0 : a.id, s, o, i.refreshInterval]);
|
|
1333
|
-
const
|
|
1334
|
-
const
|
|
1335
|
-
const
|
|
1336
|
-
return (
|
|
1337
|
-
},
|
|
1338
|
-
const
|
|
1339
|
-
return
|
|
1340
|
-
},
|
|
1341
|
-
await
|
|
1342
|
-
},
|
|
1417
|
+
const x = te(() => {
|
|
1418
|
+
const h = (D) => {
|
|
1419
|
+
const P = m.find((O) => O.key === D);
|
|
1420
|
+
return (P == null ? void 0 : P.value) === !0;
|
|
1421
|
+
}, $ = (D) => m.find((P) => P.key === D), A = (D) => {
|
|
1422
|
+
const P = m.find((O) => O.key === D);
|
|
1423
|
+
return P ? P.value ? "enabled" : "disabled" : "not_found";
|
|
1424
|
+
}, E = async () => {
|
|
1425
|
+
await R();
|
|
1426
|
+
}, N = !!(s && o) && (T || !(a != null && a.id));
|
|
1343
1427
|
return {
|
|
1344
|
-
featureFlags:
|
|
1345
|
-
loading:
|
|
1346
|
-
error:
|
|
1347
|
-
isReady:
|
|
1348
|
-
isEnabled:
|
|
1349
|
-
getFlag:
|
|
1350
|
-
getFlagState:
|
|
1351
|
-
refresh:
|
|
1428
|
+
featureFlags: m,
|
|
1429
|
+
loading: b,
|
|
1430
|
+
error: S,
|
|
1431
|
+
isReady: N,
|
|
1432
|
+
isEnabled: h,
|
|
1433
|
+
getFlag: $,
|
|
1434
|
+
getFlagState: A,
|
|
1435
|
+
refresh: E
|
|
1352
1436
|
};
|
|
1353
|
-
}, [
|
|
1354
|
-
return /* @__PURE__ */ n(
|
|
1437
|
+
}, [m, b, S, s, o, a == null ? void 0 : a.id, T]);
|
|
1438
|
+
return /* @__PURE__ */ n(Ie.Provider, { value: x, children: e });
|
|
1355
1439
|
}
|
|
1356
|
-
function
|
|
1357
|
-
const i =
|
|
1440
|
+
function ht() {
|
|
1441
|
+
const i = se(Ie);
|
|
1358
1442
|
if (!i)
|
|
1359
1443
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1360
1444
|
return i;
|
|
1361
1445
|
}
|
|
1362
|
-
function
|
|
1363
|
-
return
|
|
1446
|
+
function Be() {
|
|
1447
|
+
return se(Ie);
|
|
1364
1448
|
}
|
|
1365
|
-
class
|
|
1449
|
+
class gt {
|
|
1366
1450
|
constructor(e, t) {
|
|
1367
1451
|
this.httpService = e, this.sessionManager = t;
|
|
1368
1452
|
}
|
|
@@ -1428,68 +1512,68 @@ class ot {
|
|
|
1428
1512
|
)).data;
|
|
1429
1513
|
}
|
|
1430
1514
|
}
|
|
1431
|
-
const
|
|
1432
|
-
function
|
|
1433
|
-
const t =
|
|
1434
|
-
const
|
|
1435
|
-
return new
|
|
1436
|
-
}, [s]),
|
|
1515
|
+
const Re = he(void 0);
|
|
1516
|
+
function tr({ config: i = {}, children: e }) {
|
|
1517
|
+
const t = Ue(), r = we(), s = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a, m] = k(null), [y, b] = k(!1), [g, S] = k(null), [f, T] = k(!1), I = te(() => {
|
|
1518
|
+
const x = new ne(s);
|
|
1519
|
+
return new gt(x);
|
|
1520
|
+
}, [s]), C = async () => {
|
|
1437
1521
|
if (!(o != null && o.id)) {
|
|
1438
|
-
|
|
1522
|
+
m(null);
|
|
1439
1523
|
return;
|
|
1440
1524
|
}
|
|
1441
|
-
|
|
1525
|
+
b(!0), S(null);
|
|
1442
1526
|
try {
|
|
1443
|
-
const
|
|
1444
|
-
|
|
1445
|
-
} catch (
|
|
1446
|
-
const
|
|
1447
|
-
|
|
1527
|
+
const x = await I.getTenantSubscriptionFeatures(o.id);
|
|
1528
|
+
m(x);
|
|
1529
|
+
} catch (x) {
|
|
1530
|
+
const h = x instanceof Error ? x.message : "Failed to fetch subscription";
|
|
1531
|
+
S(h), i.onError && i.onError(x instanceof Error ? x : new Error(h));
|
|
1448
1532
|
} finally {
|
|
1449
|
-
|
|
1533
|
+
b(!1);
|
|
1450
1534
|
}
|
|
1451
1535
|
};
|
|
1452
|
-
|
|
1453
|
-
if (!s || (
|
|
1454
|
-
const
|
|
1455
|
-
return () => clearInterval(
|
|
1536
|
+
re(() => {
|
|
1537
|
+
if (!s || (C().finally(() => T(!0)), !i.refreshInterval)) return;
|
|
1538
|
+
const x = i.refreshInterval || 10 * 60 * 1e3, h = setInterval(C, x);
|
|
1539
|
+
return () => clearInterval(h);
|
|
1456
1540
|
}, [o == null ? void 0 : o.id, s, i.refreshInterval]);
|
|
1457
|
-
const
|
|
1458
|
-
const
|
|
1459
|
-
const
|
|
1460
|
-
return
|
|
1461
|
-
},
|
|
1462
|
-
const
|
|
1463
|
-
return
|
|
1464
|
-
},
|
|
1465
|
-
await
|
|
1466
|
-
},
|
|
1541
|
+
const R = te(() => {
|
|
1542
|
+
const x = (a == null ? void 0 : a.features) || [], h = (P) => {
|
|
1543
|
+
const O = x.find((c) => c.key === P);
|
|
1544
|
+
return O ? O.type === "BOOLEAN" || O.type === "boolean" ? O.value === !0 : !!O.value : !1;
|
|
1545
|
+
}, $ = (P) => x.find((O) => O.key === P), A = (P, O) => {
|
|
1546
|
+
const c = x.find((L) => L.key === P);
|
|
1547
|
+
return c ? c.value : O;
|
|
1548
|
+
}, E = (P) => !a || !a.isActive ? !1 : P.includes(a.planId), N = async () => {
|
|
1549
|
+
await C();
|
|
1550
|
+
}, D = !!s && (f || !(o != null && o.id));
|
|
1467
1551
|
return {
|
|
1468
1552
|
subscription: a,
|
|
1469
|
-
features:
|
|
1470
|
-
loading:
|
|
1471
|
-
error:
|
|
1472
|
-
isReady:
|
|
1473
|
-
isFeatureEnabled:
|
|
1474
|
-
getFeature:
|
|
1475
|
-
getFeatureValue:
|
|
1476
|
-
hasAllowedPlan:
|
|
1477
|
-
refresh:
|
|
1553
|
+
features: x,
|
|
1554
|
+
loading: y,
|
|
1555
|
+
error: g,
|
|
1556
|
+
isReady: D,
|
|
1557
|
+
isFeatureEnabled: h,
|
|
1558
|
+
getFeature: $,
|
|
1559
|
+
getFeatureValue: A,
|
|
1560
|
+
hasAllowedPlan: E,
|
|
1561
|
+
refresh: N
|
|
1478
1562
|
};
|
|
1479
|
-
}, [a,
|
|
1480
|
-
return /* @__PURE__ */ n(
|
|
1563
|
+
}, [a, y, g, s, o == null ? void 0 : o.id, f]);
|
|
1564
|
+
return /* @__PURE__ */ n(Re.Provider, { value: R, children: e });
|
|
1481
1565
|
}
|
|
1482
|
-
function
|
|
1483
|
-
const i =
|
|
1566
|
+
function pt() {
|
|
1567
|
+
const i = se(Re);
|
|
1484
1568
|
if (i === void 0)
|
|
1485
1569
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1486
1570
|
return i;
|
|
1487
1571
|
}
|
|
1488
|
-
function
|
|
1489
|
-
return
|
|
1572
|
+
function qe() {
|
|
1573
|
+
return se(Re) ?? null;
|
|
1490
1574
|
}
|
|
1491
|
-
var
|
|
1492
|
-
const
|
|
1575
|
+
var oe = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(oe || {});
|
|
1576
|
+
const De = () => /* @__PURE__ */ d(
|
|
1493
1577
|
"div",
|
|
1494
1578
|
{
|
|
1495
1579
|
style: {
|
|
@@ -1526,11 +1610,11 @@ const Ie = () => /* @__PURE__ */ l(
|
|
|
1526
1610
|
)
|
|
1527
1611
|
]
|
|
1528
1612
|
}
|
|
1529
|
-
),
|
|
1613
|
+
), $e = ({
|
|
1530
1614
|
userType: i,
|
|
1531
1615
|
minUserType: e,
|
|
1532
1616
|
missingPermissions: t
|
|
1533
|
-
}) => /* @__PURE__ */
|
|
1617
|
+
}) => /* @__PURE__ */ d(
|
|
1534
1618
|
"div",
|
|
1535
1619
|
{
|
|
1536
1620
|
style: {
|
|
@@ -1548,55 +1632,55 @@ const Ie = () => /* @__PURE__ */ l(
|
|
|
1548
1632
|
children: [
|
|
1549
1633
|
/* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
|
|
1550
1634
|
/* @__PURE__ */ n("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
|
|
1551
|
-
e && i ? /* @__PURE__ */
|
|
1552
|
-
/* @__PURE__ */
|
|
1635
|
+
e && i ? /* @__PURE__ */ d(j, { children: [
|
|
1636
|
+
/* @__PURE__ */ d("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
|
|
1553
1637
|
"This content requires ",
|
|
1554
1638
|
/* @__PURE__ */ n("strong", { children: e }),
|
|
1555
1639
|
" access level or higher."
|
|
1556
1640
|
] }),
|
|
1557
|
-
/* @__PURE__ */
|
|
1641
|
+
/* @__PURE__ */ d("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1558
1642
|
"Your current access level: ",
|
|
1559
1643
|
/* @__PURE__ */ n("strong", { children: i })
|
|
1560
1644
|
] })
|
|
1561
|
-
] }) : /* @__PURE__ */
|
|
1645
|
+
] }) : /* @__PURE__ */ d(j, { children: [
|
|
1562
1646
|
/* @__PURE__ */ n("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
|
|
1563
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1647
|
+
t && t.length > 0 && /* @__PURE__ */ d("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1564
1648
|
"Required permissions: ",
|
|
1565
1649
|
/* @__PURE__ */ n("strong", { children: t.join(", ") })
|
|
1566
1650
|
] })
|
|
1567
1651
|
] })
|
|
1568
1652
|
]
|
|
1569
1653
|
}
|
|
1570
|
-
),
|
|
1654
|
+
), ft = (i, e) => {
|
|
1571
1655
|
const t = {
|
|
1572
|
-
[
|
|
1573
|
-
[
|
|
1574
|
-
[
|
|
1656
|
+
[oe.USER]: 1,
|
|
1657
|
+
[oe.TENANT_ADMIN]: 2,
|
|
1658
|
+
[oe.SUPERUSER]: 3
|
|
1575
1659
|
};
|
|
1576
1660
|
return t[i] >= t[e];
|
|
1577
1661
|
};
|
|
1578
|
-
function
|
|
1662
|
+
function rr({
|
|
1579
1663
|
children: i,
|
|
1580
1664
|
fallback: e,
|
|
1581
1665
|
minUserType: t,
|
|
1582
1666
|
requiredPermissions: r,
|
|
1583
1667
|
requireAllPermissions: s = !1
|
|
1584
1668
|
}) {
|
|
1585
|
-
const { hasValidSession: o, sessionManager: a, hasPermission:
|
|
1669
|
+
const { hasValidSession: o, sessionManager: a, hasPermission: m, hasAnyPermission: y, hasAllPermissions: b } = ae();
|
|
1586
1670
|
if (!o())
|
|
1587
|
-
return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(
|
|
1588
|
-
const
|
|
1589
|
-
if (!
|
|
1590
|
-
return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(
|
|
1591
|
-
if (t && !
|
|
1592
|
-
return /* @__PURE__ */ n(
|
|
1593
|
-
if (r && r.length > 0 && !(s ?
|
|
1594
|
-
const f = r.filter((
|
|
1595
|
-
return /* @__PURE__ */ n(
|
|
1671
|
+
return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(De, {}) });
|
|
1672
|
+
const g = a.getUser();
|
|
1673
|
+
if (!g)
|
|
1674
|
+
return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(De, {}) });
|
|
1675
|
+
if (t && !ft(g.userType, t))
|
|
1676
|
+
return /* @__PURE__ */ n($e, { userType: g.userType, minUserType: t });
|
|
1677
|
+
if (r && r.length > 0 && !(s ? b(r) : y(r))) {
|
|
1678
|
+
const f = r.filter((T) => !m(T)).map((T) => typeof T == "string" ? T : T.name);
|
|
1679
|
+
return /* @__PURE__ */ n($e, { missingPermissions: f });
|
|
1596
1680
|
}
|
|
1597
1681
|
return /* @__PURE__ */ n(j, { children: i });
|
|
1598
1682
|
}
|
|
1599
|
-
const
|
|
1683
|
+
const mt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1600
1684
|
"div",
|
|
1601
1685
|
{
|
|
1602
1686
|
style: {
|
|
@@ -1609,7 +1693,7 @@ const ct = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1609
1693
|
backgroundColor: "#f9fafb",
|
|
1610
1694
|
textAlign: "center"
|
|
1611
1695
|
},
|
|
1612
|
-
children: /* @__PURE__ */
|
|
1696
|
+
children: /* @__PURE__ */ d(
|
|
1613
1697
|
"div",
|
|
1614
1698
|
{
|
|
1615
1699
|
style: {
|
|
@@ -1623,7 +1707,7 @@ const ct = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1623
1707
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
|
|
1624
1708
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
|
|
1625
1709
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
|
|
1626
|
-
/* @__PURE__ */
|
|
1710
|
+
/* @__PURE__ */ d("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1627
1711
|
"Redirecting to ",
|
|
1628
1712
|
i,
|
|
1629
1713
|
"..."
|
|
@@ -1632,7 +1716,7 @@ const ct = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1632
1716
|
}
|
|
1633
1717
|
)
|
|
1634
1718
|
}
|
|
1635
|
-
),
|
|
1719
|
+
), He = ({
|
|
1636
1720
|
userType: i,
|
|
1637
1721
|
minUserType: e,
|
|
1638
1722
|
missingPermissions: t
|
|
@@ -1649,7 +1733,7 @@ const ct = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1649
1733
|
backgroundColor: "#f9fafb",
|
|
1650
1734
|
textAlign: "center"
|
|
1651
1735
|
},
|
|
1652
|
-
children: /* @__PURE__ */
|
|
1736
|
+
children: /* @__PURE__ */ d(
|
|
1653
1737
|
"div",
|
|
1654
1738
|
{
|
|
1655
1739
|
style: {
|
|
@@ -1662,19 +1746,19 @@ const ct = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1662
1746
|
children: [
|
|
1663
1747
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
|
|
1664
1748
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
|
|
1665
|
-
e && i ? /* @__PURE__ */
|
|
1666
|
-
/* @__PURE__ */
|
|
1749
|
+
e && i ? /* @__PURE__ */ d(j, { children: [
|
|
1750
|
+
/* @__PURE__ */ d("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
|
|
1667
1751
|
"This page requires ",
|
|
1668
1752
|
/* @__PURE__ */ n("strong", { children: e }),
|
|
1669
1753
|
" access level or higher."
|
|
1670
1754
|
] }),
|
|
1671
|
-
/* @__PURE__ */
|
|
1755
|
+
/* @__PURE__ */ d("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1672
1756
|
"Your current access level: ",
|
|
1673
1757
|
/* @__PURE__ */ n("strong", { children: i })
|
|
1674
1758
|
] })
|
|
1675
|
-
] }) : /* @__PURE__ */
|
|
1759
|
+
] }) : /* @__PURE__ */ d(j, { children: [
|
|
1676
1760
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
|
|
1677
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1761
|
+
t && t.length > 0 && /* @__PURE__ */ d("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1678
1762
|
"Required permissions: ",
|
|
1679
1763
|
/* @__PURE__ */ n("strong", { children: t.join(", ") })
|
|
1680
1764
|
] })
|
|
@@ -1683,15 +1767,15 @@ const ct = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1683
1767
|
}
|
|
1684
1768
|
)
|
|
1685
1769
|
}
|
|
1686
|
-
),
|
|
1770
|
+
), yt = (i, e) => {
|
|
1687
1771
|
const t = {
|
|
1688
|
-
[
|
|
1689
|
-
[
|
|
1690
|
-
[
|
|
1772
|
+
[oe.USER]: 1,
|
|
1773
|
+
[oe.TENANT_ADMIN]: 2,
|
|
1774
|
+
[oe.SUPERUSER]: 3
|
|
1691
1775
|
};
|
|
1692
1776
|
return t[i] >= t[e];
|
|
1693
1777
|
};
|
|
1694
|
-
function
|
|
1778
|
+
function nr({
|
|
1695
1779
|
children: i,
|
|
1696
1780
|
redirectTo: e = "/login",
|
|
1697
1781
|
minUserType: t,
|
|
@@ -1699,24 +1783,24 @@ function Kt({
|
|
|
1699
1783
|
requireAllPermissions: s = !1,
|
|
1700
1784
|
fallback: o
|
|
1701
1785
|
}) {
|
|
1702
|
-
const { hasValidSession: a, sessionManager:
|
|
1786
|
+
const { hasValidSession: a, sessionManager: m, hasPermission: y, hasAnyPermission: b, hasAllPermissions: g } = ae(), S = Te();
|
|
1703
1787
|
if (!a())
|
|
1704
|
-
return o ? /* @__PURE__ */ n(j, { children: o }) : /* @__PURE__ */
|
|
1705
|
-
/* @__PURE__ */ n(
|
|
1706
|
-
/* @__PURE__ */ n(
|
|
1788
|
+
return o ? /* @__PURE__ */ n(j, { children: o }) : /* @__PURE__ */ d(j, { children: [
|
|
1789
|
+
/* @__PURE__ */ n(mt, { redirectPath: e }),
|
|
1790
|
+
/* @__PURE__ */ n(fe, { to: e, state: { from: S.pathname }, replace: !0 })
|
|
1707
1791
|
] });
|
|
1708
|
-
const f =
|
|
1792
|
+
const f = m.getUser();
|
|
1709
1793
|
if (!f)
|
|
1710
|
-
return /* @__PURE__ */ n(
|
|
1711
|
-
if (t && !
|
|
1712
|
-
return /* @__PURE__ */ n(
|
|
1713
|
-
if (r && r.length > 0 && !(s ?
|
|
1714
|
-
const
|
|
1715
|
-
return /* @__PURE__ */ n(
|
|
1794
|
+
return /* @__PURE__ */ n(fe, { to: e, state: { from: S.pathname }, replace: !0 });
|
|
1795
|
+
if (t && !yt(f.userType, t))
|
|
1796
|
+
return /* @__PURE__ */ n(He, { userType: f.userType, minUserType: t });
|
|
1797
|
+
if (r && r.length > 0 && !(s ? g(r) : b(r))) {
|
|
1798
|
+
const I = r.filter((C) => !y(C)).map((C) => typeof C == "string" ? C : C.name);
|
|
1799
|
+
return /* @__PURE__ */ n(He, { missingPermissions: I });
|
|
1716
1800
|
}
|
|
1717
1801
|
return /* @__PURE__ */ n(j, { children: i });
|
|
1718
1802
|
}
|
|
1719
|
-
const
|
|
1803
|
+
const wt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1720
1804
|
"div",
|
|
1721
1805
|
{
|
|
1722
1806
|
style: {
|
|
@@ -1729,7 +1813,7 @@ const ut = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1729
1813
|
backgroundColor: "#f9fafb",
|
|
1730
1814
|
textAlign: "center"
|
|
1731
1815
|
},
|
|
1732
|
-
children: /* @__PURE__ */
|
|
1816
|
+
children: /* @__PURE__ */ d(
|
|
1733
1817
|
"div",
|
|
1734
1818
|
{
|
|
1735
1819
|
style: {
|
|
@@ -1743,7 +1827,7 @@ const ut = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1743
1827
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
|
|
1744
1828
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
|
|
1745
1829
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
|
|
1746
|
-
/* @__PURE__ */
|
|
1830
|
+
/* @__PURE__ */ d("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1747
1831
|
"Redirecting to ",
|
|
1748
1832
|
i,
|
|
1749
1833
|
"..."
|
|
@@ -1753,14 +1837,14 @@ const ut = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1753
1837
|
)
|
|
1754
1838
|
}
|
|
1755
1839
|
);
|
|
1756
|
-
function
|
|
1757
|
-
const { tenant: r, isLoading: s, error: o } =
|
|
1758
|
-
return s || o ? null : r ? /* @__PURE__ */ n(j, { children: i }) : t ? /* @__PURE__ */ n(j, { children: t }) : /* @__PURE__ */
|
|
1759
|
-
/* @__PURE__ */ n(
|
|
1760
|
-
/* @__PURE__ */ n(
|
|
1840
|
+
function sr({ children: i, redirectTo: e = "/", fallback: t }) {
|
|
1841
|
+
const { tenant: r, isLoading: s, error: o } = ce(), a = Te();
|
|
1842
|
+
return s || o ? null : r ? /* @__PURE__ */ n(j, { children: i }) : t ? /* @__PURE__ */ n(j, { children: t }) : /* @__PURE__ */ d(j, { children: [
|
|
1843
|
+
/* @__PURE__ */ n(wt, { redirectPath: e }),
|
|
1844
|
+
/* @__PURE__ */ n(fe, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
1761
1845
|
] });
|
|
1762
1846
|
}
|
|
1763
|
-
const
|
|
1847
|
+
const bt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1764
1848
|
"div",
|
|
1765
1849
|
{
|
|
1766
1850
|
style: {
|
|
@@ -1773,7 +1857,7 @@ const ht = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1773
1857
|
backgroundColor: "#f9fafb",
|
|
1774
1858
|
textAlign: "center"
|
|
1775
1859
|
},
|
|
1776
|
-
children: /* @__PURE__ */
|
|
1860
|
+
children: /* @__PURE__ */ d(
|
|
1777
1861
|
"div",
|
|
1778
1862
|
{
|
|
1779
1863
|
style: {
|
|
@@ -1787,7 +1871,7 @@ const ht = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1787
1871
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
|
|
1788
1872
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
|
|
1789
1873
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
|
|
1790
|
-
/* @__PURE__ */
|
|
1874
|
+
/* @__PURE__ */ d("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1791
1875
|
"Redirecting to ",
|
|
1792
1876
|
i,
|
|
1793
1877
|
"..."
|
|
@@ -1797,14 +1881,14 @@ const ht = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1797
1881
|
)
|
|
1798
1882
|
}
|
|
1799
1883
|
);
|
|
1800
|
-
function
|
|
1801
|
-
const { tenant: r, isLoading: s, error: o } =
|
|
1802
|
-
return s || o ? null : r ? t ? /* @__PURE__ */ n(j, { children: t }) : /* @__PURE__ */
|
|
1803
|
-
/* @__PURE__ */ n(
|
|
1804
|
-
/* @__PURE__ */ n(
|
|
1884
|
+
function ir({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
|
|
1885
|
+
const { tenant: r, isLoading: s, error: o } = ce(), a = Te();
|
|
1886
|
+
return s || o ? null : r ? t ? /* @__PURE__ */ n(j, { children: t }) : /* @__PURE__ */ d(j, { children: [
|
|
1887
|
+
/* @__PURE__ */ n(bt, { redirectPath: e }),
|
|
1888
|
+
/* @__PURE__ */ n(fe, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
1805
1889
|
] }) : /* @__PURE__ */ n(j, { children: i });
|
|
1806
1890
|
}
|
|
1807
|
-
const
|
|
1891
|
+
const St = () => /* @__PURE__ */ d(
|
|
1808
1892
|
"div",
|
|
1809
1893
|
{
|
|
1810
1894
|
style: {
|
|
@@ -1821,14 +1905,14 @@ const gt = () => /* @__PURE__ */ l(
|
|
|
1821
1905
|
]
|
|
1822
1906
|
}
|
|
1823
1907
|
);
|
|
1824
|
-
function
|
|
1908
|
+
function or({
|
|
1825
1909
|
children: i,
|
|
1826
|
-
fallback: e = /* @__PURE__ */ n(
|
|
1910
|
+
fallback: e = /* @__PURE__ */ n(St, {}),
|
|
1827
1911
|
allowedPlans: t,
|
|
1828
1912
|
requiredFeature: r
|
|
1829
1913
|
}) {
|
|
1830
|
-
const { subscription: s, hasAllowedPlan: o, isFeatureEnabled: a, loading:
|
|
1831
|
-
return
|
|
1914
|
+
const { subscription: s, hasAllowedPlan: o, isFeatureEnabled: a, loading: m } = pt();
|
|
1915
|
+
return m ? /* @__PURE__ */ n(
|
|
1832
1916
|
"div",
|
|
1833
1917
|
{
|
|
1834
1918
|
style: {
|
|
@@ -1840,7 +1924,7 @@ function Qt({
|
|
|
1840
1924
|
}
|
|
1841
1925
|
) : s ? s.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ n(j, { children: e }) : r && !a(r) ? /* @__PURE__ */ n(j, { children: e }) : /* @__PURE__ */ n(j, { children: i }) : /* @__PURE__ */ n(j, { children: e }) : /* @__PURE__ */ n(j, { children: e });
|
|
1842
1926
|
}
|
|
1843
|
-
const
|
|
1927
|
+
const vt = ({ flagName: i }) => /* @__PURE__ */ d(
|
|
1844
1928
|
"div",
|
|
1845
1929
|
{
|
|
1846
1930
|
style: {
|
|
@@ -1859,7 +1943,7 @@ const pt = ({ flagName: i }) => /* @__PURE__ */ l(
|
|
|
1859
1943
|
children: [
|
|
1860
1944
|
/* @__PURE__ */ n("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
|
|
1861
1945
|
/* @__PURE__ */ n("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
|
|
1862
|
-
/* @__PURE__ */
|
|
1946
|
+
/* @__PURE__ */ d("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
|
|
1863
1947
|
'Feature flag "',
|
|
1864
1948
|
i,
|
|
1865
1949
|
'" is disabled'
|
|
@@ -1867,8 +1951,8 @@ const pt = ({ flagName: i }) => /* @__PURE__ */ l(
|
|
|
1867
1951
|
]
|
|
1868
1952
|
}
|
|
1869
1953
|
);
|
|
1870
|
-
function
|
|
1871
|
-
const { isEnabled: r, loading: s } =
|
|
1954
|
+
function ar({ name: i, children: e, fallback: t }) {
|
|
1955
|
+
const { isEnabled: r, loading: s } = ht();
|
|
1872
1956
|
return s ? /* @__PURE__ */ n(
|
|
1873
1957
|
"div",
|
|
1874
1958
|
{
|
|
@@ -1882,9 +1966,9 @@ function Xt({ name: i, children: e, fallback: t }) {
|
|
|
1882
1966
|
},
|
|
1883
1967
|
children: "Loading feature flags..."
|
|
1884
1968
|
}
|
|
1885
|
-
) : r(i) ? /* @__PURE__ */ n(j, { children: e }) : /* @__PURE__ */ n(j, { children: t || /* @__PURE__ */ n(
|
|
1969
|
+
) : r(i) ? /* @__PURE__ */ n(j, { children: e }) : /* @__PURE__ */ n(j, { children: t || /* @__PURE__ */ n(vt, { flagName: i }) });
|
|
1886
1970
|
}
|
|
1887
|
-
const
|
|
1971
|
+
const kt = () => /* @__PURE__ */ d(
|
|
1888
1972
|
"svg",
|
|
1889
1973
|
{
|
|
1890
1974
|
width: "16",
|
|
@@ -1901,7 +1985,7 @@ const ft = () => /* @__PURE__ */ l(
|
|
|
1901
1985
|
/* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "3" })
|
|
1902
1986
|
]
|
|
1903
1987
|
}
|
|
1904
|
-
),
|
|
1988
|
+
), Tt = () => /* @__PURE__ */ d(
|
|
1905
1989
|
"svg",
|
|
1906
1990
|
{
|
|
1907
1991
|
width: "16",
|
|
@@ -1918,10 +2002,10 @@ const ft = () => /* @__PURE__ */ l(
|
|
|
1918
2002
|
/* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
1919
2003
|
]
|
|
1920
2004
|
}
|
|
1921
|
-
),
|
|
1922
|
-
showPassword: /* @__PURE__ */ n(
|
|
1923
|
-
hidePassword: /* @__PURE__ */ n(
|
|
1924
|
-
},
|
|
2005
|
+
), xt = {
|
|
2006
|
+
showPassword: /* @__PURE__ */ n(kt, {}),
|
|
2007
|
+
hidePassword: /* @__PURE__ */ n(Tt, {})
|
|
2008
|
+
}, At = {
|
|
1925
2009
|
title: "Sign In",
|
|
1926
2010
|
usernameLabel: "Email or Phone",
|
|
1927
2011
|
usernamePlaceholder: "Enter your email or phone number",
|
|
@@ -1935,7 +2019,7 @@ const ft = () => /* @__PURE__ */ l(
|
|
|
1935
2019
|
magicLinkLink: "Use Magic Link",
|
|
1936
2020
|
errorMessage: "Invalid credentials",
|
|
1937
2021
|
loadingText: "Signing in..."
|
|
1938
|
-
},
|
|
2022
|
+
}, Pt = {
|
|
1939
2023
|
container: {
|
|
1940
2024
|
maxWidth: "400px",
|
|
1941
2025
|
width: "100%",
|
|
@@ -2042,7 +2126,7 @@ const ft = () => /* @__PURE__ */ l(
|
|
|
2042
2126
|
fontSize: "0.875rem"
|
|
2043
2127
|
}
|
|
2044
2128
|
};
|
|
2045
|
-
function
|
|
2129
|
+
function lr({
|
|
2046
2130
|
copy: i = {},
|
|
2047
2131
|
styles: e = {},
|
|
2048
2132
|
icons: t = {},
|
|
@@ -2050,49 +2134,49 @@ function Zt({
|
|
|
2050
2134
|
onError: s,
|
|
2051
2135
|
onForgotPassword: o,
|
|
2052
2136
|
onSignupClick: a,
|
|
2053
|
-
onMagicLinkClick:
|
|
2054
|
-
showForgotPassword:
|
|
2055
|
-
showSignupLink:
|
|
2056
|
-
showMagicLinkOption:
|
|
2057
|
-
className:
|
|
2137
|
+
onMagicLinkClick: m,
|
|
2138
|
+
showForgotPassword: y = !0,
|
|
2139
|
+
showSignupLink: b = !0,
|
|
2140
|
+
showMagicLinkOption: g = !0,
|
|
2141
|
+
className: S
|
|
2058
2142
|
}) {
|
|
2059
|
-
const [f,
|
|
2060
|
-
const
|
|
2061
|
-
return f.trim() || (
|
|
2062
|
-
},
|
|
2063
|
-
if (
|
|
2064
|
-
if (!(
|
|
2065
|
-
|
|
2143
|
+
const [f, T] = k(""), [I, C] = k(""), [R, x] = k(!1), [h, $] = k(!1), [A, E] = k(""), [N, D] = k({}), { login: P } = ae(), { tenant: O } = ce(), c = { ...At, ...i }, L = { ...Pt, ...e }, F = { ...xt, ...t }, l = () => {
|
|
2144
|
+
const u = {};
|
|
2145
|
+
return f.trim() || (u.username = !0), I.trim() || (u.password = !0), D(u), Object.keys(u).length === 0;
|
|
2146
|
+
}, H = async (u) => {
|
|
2147
|
+
if (u.preventDefault(), !!l()) {
|
|
2148
|
+
if (!(O != null && O.id)) {
|
|
2149
|
+
E("Tenant not found");
|
|
2066
2150
|
return;
|
|
2067
2151
|
}
|
|
2068
|
-
|
|
2152
|
+
$(!0), E("");
|
|
2069
2153
|
try {
|
|
2070
|
-
const
|
|
2154
|
+
const w = await P({
|
|
2071
2155
|
username: f,
|
|
2072
|
-
password:
|
|
2156
|
+
password: I
|
|
2073
2157
|
// tenantId inferred from context automatically
|
|
2074
2158
|
});
|
|
2075
|
-
r == null || r(
|
|
2076
|
-
} catch (
|
|
2077
|
-
const G =
|
|
2078
|
-
|
|
2159
|
+
r == null || r(w);
|
|
2160
|
+
} catch (w) {
|
|
2161
|
+
const G = w.message || c.errorMessage;
|
|
2162
|
+
E(G), s == null || s(G);
|
|
2079
2163
|
} finally {
|
|
2080
|
-
|
|
2164
|
+
$(!1);
|
|
2081
2165
|
}
|
|
2082
2166
|
}
|
|
2083
|
-
},
|
|
2084
|
-
...
|
|
2085
|
-
...
|
|
2086
|
-
}),
|
|
2087
|
-
...
|
|
2088
|
-
...
|
|
2089
|
-
...!f || !
|
|
2167
|
+
}, M = (u) => ({
|
|
2168
|
+
...L.input,
|
|
2169
|
+
...N[u] ? L.inputError : {}
|
|
2170
|
+
}), p = () => ({
|
|
2171
|
+
...L.button,
|
|
2172
|
+
...h ? L.buttonLoading : {},
|
|
2173
|
+
...!f || !I || h ? L.buttonDisabled : {}
|
|
2090
2174
|
});
|
|
2091
|
-
return /* @__PURE__ */
|
|
2092
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2093
|
-
/* @__PURE__ */
|
|
2094
|
-
/* @__PURE__ */
|
|
2095
|
-
/* @__PURE__ */ n("label", { style:
|
|
2175
|
+
return /* @__PURE__ */ d("div", { className: S, style: L.container, children: [
|
|
2176
|
+
/* @__PURE__ */ n("h2", { style: L.title, children: c.title }),
|
|
2177
|
+
/* @__PURE__ */ d("form", { onSubmit: H, style: L.form, children: [
|
|
2178
|
+
/* @__PURE__ */ d("div", { style: L.fieldGroup, children: [
|
|
2179
|
+
/* @__PURE__ */ n("label", { style: L.label, children: c.usernameLabel }),
|
|
2096
2180
|
/* @__PURE__ */ n(
|
|
2097
2181
|
"input",
|
|
2098
2182
|
{
|
|
@@ -2100,75 +2184,75 @@ function Zt({
|
|
|
2100
2184
|
name: "username",
|
|
2101
2185
|
type: "text",
|
|
2102
2186
|
value: f,
|
|
2103
|
-
onChange: (
|
|
2104
|
-
|
|
2187
|
+
onChange: (u) => {
|
|
2188
|
+
T(u.target.value), N.username && D((w) => ({ ...w, username: !1 }));
|
|
2105
2189
|
},
|
|
2106
|
-
placeholder:
|
|
2107
|
-
style:
|
|
2108
|
-
disabled:
|
|
2190
|
+
placeholder: c.usernamePlaceholder,
|
|
2191
|
+
style: M("username"),
|
|
2192
|
+
disabled: h
|
|
2109
2193
|
}
|
|
2110
2194
|
)
|
|
2111
2195
|
] }),
|
|
2112
|
-
/* @__PURE__ */
|
|
2113
|
-
/* @__PURE__ */ n("label", { style:
|
|
2114
|
-
/* @__PURE__ */
|
|
2196
|
+
/* @__PURE__ */ d("div", { style: L.fieldGroup, children: [
|
|
2197
|
+
/* @__PURE__ */ n("label", { style: L.label, children: c.passwordLabel }),
|
|
2198
|
+
/* @__PURE__ */ d("div", { style: L.inputContainer, children: [
|
|
2115
2199
|
/* @__PURE__ */ n(
|
|
2116
2200
|
"input",
|
|
2117
2201
|
{
|
|
2118
2202
|
id: "password",
|
|
2119
2203
|
name: "password",
|
|
2120
|
-
type:
|
|
2121
|
-
value:
|
|
2122
|
-
onChange: (
|
|
2123
|
-
|
|
2204
|
+
type: R ? "text" : "password",
|
|
2205
|
+
value: I,
|
|
2206
|
+
onChange: (u) => {
|
|
2207
|
+
C(u.target.value), N.password && D((w) => ({ ...w, password: !1 }));
|
|
2124
2208
|
},
|
|
2125
|
-
placeholder:
|
|
2209
|
+
placeholder: c.passwordPlaceholder,
|
|
2126
2210
|
style: {
|
|
2127
|
-
...
|
|
2211
|
+
...M("password"),
|
|
2128
2212
|
paddingRight: "2.5rem"
|
|
2129
2213
|
// Make room for the icon
|
|
2130
2214
|
},
|
|
2131
|
-
disabled:
|
|
2215
|
+
disabled: h
|
|
2132
2216
|
}
|
|
2133
2217
|
),
|
|
2134
2218
|
/* @__PURE__ */ n(
|
|
2135
2219
|
"button",
|
|
2136
2220
|
{
|
|
2137
2221
|
type: "button",
|
|
2138
|
-
onClick: () =>
|
|
2139
|
-
style:
|
|
2140
|
-
disabled:
|
|
2141
|
-
"aria-label":
|
|
2142
|
-
children:
|
|
2222
|
+
onClick: () => x(!R),
|
|
2223
|
+
style: L.passwordToggle,
|
|
2224
|
+
disabled: h,
|
|
2225
|
+
"aria-label": R ? "Hide password" : "Show password",
|
|
2226
|
+
children: R ? F.hidePassword : F.showPassword
|
|
2143
2227
|
}
|
|
2144
2228
|
)
|
|
2145
2229
|
] })
|
|
2146
2230
|
] }),
|
|
2147
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !f || !
|
|
2148
|
-
|
|
2231
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !f || !I || h, style: p(), children: h ? c.loadingText : c.submitButton }),
|
|
2232
|
+
A && /* @__PURE__ */ n("div", { style: L.errorText, children: A })
|
|
2149
2233
|
] }),
|
|
2150
|
-
(
|
|
2151
|
-
|
|
2152
|
-
/* @__PURE__ */
|
|
2153
|
-
|
|
2234
|
+
(y || b || g) && /* @__PURE__ */ d("div", { style: L.linkContainer, children: [
|
|
2235
|
+
g && /* @__PURE__ */ d("div", { children: [
|
|
2236
|
+
/* @__PURE__ */ d("span", { style: L.divider, children: [
|
|
2237
|
+
c.magicLinkText,
|
|
2154
2238
|
" "
|
|
2155
2239
|
] }),
|
|
2156
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
2240
|
+
/* @__PURE__ */ n("a", { onClick: m, style: L.link, children: c.magicLinkLink })
|
|
2157
2241
|
] }),
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
/* @__PURE__ */
|
|
2163
|
-
|
|
2242
|
+
g && (y || b) && /* @__PURE__ */ n("div", { style: L.divider, children: "•" }),
|
|
2243
|
+
y && /* @__PURE__ */ n("a", { onClick: o, style: L.link, children: c.forgotPasswordLink }),
|
|
2244
|
+
y && b && /* @__PURE__ */ n("div", { style: L.divider, children: "•" }),
|
|
2245
|
+
b && /* @__PURE__ */ d("div", { children: [
|
|
2246
|
+
/* @__PURE__ */ d("span", { style: L.divider, children: [
|
|
2247
|
+
c.signupText,
|
|
2164
2248
|
" "
|
|
2165
2249
|
] }),
|
|
2166
|
-
/* @__PURE__ */ n("a", { onClick: a, style:
|
|
2250
|
+
/* @__PURE__ */ n("a", { onClick: a, style: L.link, children: c.signupLink })
|
|
2167
2251
|
] })
|
|
2168
2252
|
] })
|
|
2169
2253
|
] });
|
|
2170
2254
|
}
|
|
2171
|
-
const
|
|
2255
|
+
const Mt = {
|
|
2172
2256
|
title: "Create Account",
|
|
2173
2257
|
nameLabel: "First Name",
|
|
2174
2258
|
namePlaceholder: "Enter your first name",
|
|
@@ -2194,7 +2278,7 @@ const St = {
|
|
|
2194
2278
|
passwordMismatchError: "Passwords do not match",
|
|
2195
2279
|
isAdminLabel: "Create new organization",
|
|
2196
2280
|
isAdminDescription: "Check this if you want to create a new organization"
|
|
2197
|
-
},
|
|
2281
|
+
}, It = {
|
|
2198
2282
|
container: {
|
|
2199
2283
|
maxWidth: "400px",
|
|
2200
2284
|
width: "100%",
|
|
@@ -2293,7 +2377,7 @@ const St = {
|
|
|
2293
2377
|
fontSize: "0.875rem"
|
|
2294
2378
|
}
|
|
2295
2379
|
};
|
|
2296
|
-
function
|
|
2380
|
+
function cr({
|
|
2297
2381
|
copy: i = {},
|
|
2298
2382
|
styles: e = {},
|
|
2299
2383
|
signupType: t = "user",
|
|
@@ -2301,79 +2385,79 @@ function er({
|
|
|
2301
2385
|
onError: s,
|
|
2302
2386
|
onLoginClick: o,
|
|
2303
2387
|
onMagicLinkClick: a,
|
|
2304
|
-
showLoginLink:
|
|
2305
|
-
showMagicLinkOption:
|
|
2306
|
-
className:
|
|
2388
|
+
showLoginLink: m = !0,
|
|
2389
|
+
showMagicLinkOption: y = !0,
|
|
2390
|
+
className: b
|
|
2307
2391
|
}) {
|
|
2308
|
-
const [
|
|
2309
|
-
const
|
|
2310
|
-
return
|
|
2311
|
-
},
|
|
2312
|
-
if (
|
|
2313
|
-
if (
|
|
2314
|
-
|
|
2392
|
+
const [g, S] = k(""), [f, T] = k(""), [I, C] = k(""), [R, x] = k(""), [h, $] = k(""), [A, E] = k(""), [N, D] = k(""), [P, O] = k(!1), [c, L] = k(""), [F, l] = k({}), { signup: H, signupTenantAdmin: M } = ae(), { tenant: p } = ce(), u = { ...Mt, ...i }, w = { ...It, ...e }, G = () => {
|
|
2393
|
+
const v = {};
|
|
2394
|
+
return g.trim() || (v.name = !0), !I.trim() && !R.trim() && (v.email = !0, v.phoneNumber = !0), h.trim() || (v.password = !0), A.trim() || (v.confirmPassword = !0), t === "tenant" && !N.trim() && (v.tenantName = !0), l(v), Object.keys(v).length === 0;
|
|
2395
|
+
}, K = async (v) => {
|
|
2396
|
+
if (v.preventDefault(), !!G()) {
|
|
2397
|
+
if (h !== A) {
|
|
2398
|
+
L(u.passwordMismatchError), l({ confirmPassword: !0 });
|
|
2315
2399
|
return;
|
|
2316
2400
|
}
|
|
2317
|
-
if (t === "user" && !(
|
|
2318
|
-
|
|
2401
|
+
if (t === "user" && !(p != null && p.id)) {
|
|
2402
|
+
L("Tenant not found");
|
|
2319
2403
|
return;
|
|
2320
2404
|
}
|
|
2321
|
-
|
|
2405
|
+
O(!0), L("");
|
|
2322
2406
|
try {
|
|
2323
2407
|
let J;
|
|
2324
|
-
t === "tenant" ? J = await
|
|
2325
|
-
email:
|
|
2326
|
-
phoneNumber:
|
|
2327
|
-
name:
|
|
2328
|
-
password:
|
|
2329
|
-
tenantName:
|
|
2408
|
+
t === "tenant" ? J = await M({
|
|
2409
|
+
email: I || void 0,
|
|
2410
|
+
phoneNumber: R || void 0,
|
|
2411
|
+
name: g,
|
|
2412
|
+
password: h,
|
|
2413
|
+
tenantName: N,
|
|
2330
2414
|
lastName: f || void 0
|
|
2331
|
-
}) : J = await
|
|
2332
|
-
email:
|
|
2333
|
-
phoneNumber:
|
|
2334
|
-
name:
|
|
2335
|
-
password:
|
|
2336
|
-
tenantId:
|
|
2415
|
+
}) : J = await H({
|
|
2416
|
+
email: I || void 0,
|
|
2417
|
+
phoneNumber: R || void 0,
|
|
2418
|
+
name: g,
|
|
2419
|
+
password: h,
|
|
2420
|
+
tenantId: p.id,
|
|
2337
2421
|
lastName: f || void 0
|
|
2338
2422
|
}), r == null || r(J);
|
|
2339
2423
|
} catch (J) {
|
|
2340
|
-
const
|
|
2341
|
-
|
|
2424
|
+
const le = J.message || u.errorMessage;
|
|
2425
|
+
L(le), s == null || s(le);
|
|
2342
2426
|
} finally {
|
|
2343
|
-
|
|
2427
|
+
O(!1);
|
|
2344
2428
|
}
|
|
2345
2429
|
}
|
|
2346
|
-
},
|
|
2347
|
-
...
|
|
2348
|
-
...F[
|
|
2349
|
-
}),
|
|
2350
|
-
...
|
|
2351
|
-
...
|
|
2352
|
-
...!
|
|
2353
|
-
}), V =
|
|
2354
|
-
return /* @__PURE__ */
|
|
2355
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2356
|
-
/* @__PURE__ */
|
|
2357
|
-
/* @__PURE__ */
|
|
2358
|
-
/* @__PURE__ */ n("label", { style:
|
|
2430
|
+
}, U = (v) => ({
|
|
2431
|
+
...w.input,
|
|
2432
|
+
...F[v] ? w.inputError : {}
|
|
2433
|
+
}), q = () => ({
|
|
2434
|
+
...w.button,
|
|
2435
|
+
...P ? w.buttonLoading : {},
|
|
2436
|
+
...!g || !I && !R || !h || !A || P || t === "tenant" && !N ? w.buttonDisabled : {}
|
|
2437
|
+
}), V = g && (I || R) && h && A && (t === "user" || N);
|
|
2438
|
+
return /* @__PURE__ */ d("div", { className: b, style: w.container, children: [
|
|
2439
|
+
/* @__PURE__ */ n("h2", { style: w.title, children: u.title }),
|
|
2440
|
+
/* @__PURE__ */ d("form", { onSubmit: K, style: w.form, children: [
|
|
2441
|
+
/* @__PURE__ */ d("div", { style: w.fieldGroup, children: [
|
|
2442
|
+
/* @__PURE__ */ n("label", { style: w.label, children: u.nameLabel }),
|
|
2359
2443
|
/* @__PURE__ */ n(
|
|
2360
2444
|
"input",
|
|
2361
2445
|
{
|
|
2362
2446
|
id: "name",
|
|
2363
2447
|
name: "name",
|
|
2364
2448
|
type: "text",
|
|
2365
|
-
value:
|
|
2366
|
-
onChange: (
|
|
2367
|
-
|
|
2449
|
+
value: g,
|
|
2450
|
+
onChange: (v) => {
|
|
2451
|
+
S(v.target.value), F.name && l((J) => ({ ...J, name: !1 }));
|
|
2368
2452
|
},
|
|
2369
|
-
placeholder:
|
|
2370
|
-
style:
|
|
2371
|
-
disabled:
|
|
2453
|
+
placeholder: u.namePlaceholder,
|
|
2454
|
+
style: U("name"),
|
|
2455
|
+
disabled: P
|
|
2372
2456
|
}
|
|
2373
2457
|
)
|
|
2374
2458
|
] }),
|
|
2375
|
-
/* @__PURE__ */
|
|
2376
|
-
/* @__PURE__ */ n("label", { style:
|
|
2459
|
+
/* @__PURE__ */ d("div", { style: w.fieldGroup, children: [
|
|
2460
|
+
/* @__PURE__ */ n("label", { style: w.label, children: u.lastNameLabel }),
|
|
2377
2461
|
/* @__PURE__ */ n(
|
|
2378
2462
|
"input",
|
|
2379
2463
|
{
|
|
@@ -2381,46 +2465,46 @@ function er({
|
|
|
2381
2465
|
name: "lastName",
|
|
2382
2466
|
type: "text",
|
|
2383
2467
|
value: f,
|
|
2384
|
-
onChange: (
|
|
2385
|
-
placeholder:
|
|
2386
|
-
style:
|
|
2387
|
-
disabled:
|
|
2468
|
+
onChange: (v) => T(v.target.value),
|
|
2469
|
+
placeholder: u.lastNamePlaceholder,
|
|
2470
|
+
style: w.input,
|
|
2471
|
+
disabled: P
|
|
2388
2472
|
}
|
|
2389
2473
|
)
|
|
2390
2474
|
] }),
|
|
2391
|
-
/* @__PURE__ */
|
|
2392
|
-
/* @__PURE__ */ n("label", { style:
|
|
2475
|
+
/* @__PURE__ */ d("div", { style: w.fieldGroup, children: [
|
|
2476
|
+
/* @__PURE__ */ n("label", { style: w.label, children: u.emailLabel }),
|
|
2393
2477
|
/* @__PURE__ */ n(
|
|
2394
2478
|
"input",
|
|
2395
2479
|
{
|
|
2396
2480
|
id: "email",
|
|
2397
2481
|
name: "email",
|
|
2398
2482
|
type: "email",
|
|
2399
|
-
value:
|
|
2400
|
-
onChange: (
|
|
2401
|
-
|
|
2483
|
+
value: I,
|
|
2484
|
+
onChange: (v) => {
|
|
2485
|
+
C(v.target.value), F.email && l((J) => ({ ...J, email: !1, phoneNumber: !1 }));
|
|
2402
2486
|
},
|
|
2403
|
-
placeholder:
|
|
2404
|
-
style:
|
|
2405
|
-
disabled:
|
|
2487
|
+
placeholder: u.emailPlaceholder,
|
|
2488
|
+
style: U("email"),
|
|
2489
|
+
disabled: P
|
|
2406
2490
|
}
|
|
2407
2491
|
)
|
|
2408
2492
|
] }),
|
|
2409
|
-
/* @__PURE__ */
|
|
2410
|
-
/* @__PURE__ */ n("label", { style:
|
|
2493
|
+
/* @__PURE__ */ d("div", { style: w.fieldGroup, children: [
|
|
2494
|
+
/* @__PURE__ */ n("label", { style: w.label, children: u.phoneNumberLabel }),
|
|
2411
2495
|
/* @__PURE__ */ n(
|
|
2412
2496
|
"input",
|
|
2413
2497
|
{
|
|
2414
2498
|
id: "phoneNumber",
|
|
2415
2499
|
name: "phoneNumber",
|
|
2416
2500
|
type: "tel",
|
|
2417
|
-
value:
|
|
2418
|
-
onChange: (
|
|
2419
|
-
|
|
2501
|
+
value: R,
|
|
2502
|
+
onChange: (v) => {
|
|
2503
|
+
x(v.target.value), F.phoneNumber && l((J) => ({ ...J, email: !1, phoneNumber: !1 }));
|
|
2420
2504
|
},
|
|
2421
|
-
placeholder:
|
|
2422
|
-
style:
|
|
2423
|
-
disabled:
|
|
2505
|
+
placeholder: u.phoneNumberPlaceholder,
|
|
2506
|
+
style: U("phoneNumber"),
|
|
2507
|
+
disabled: P
|
|
2424
2508
|
}
|
|
2425
2509
|
)
|
|
2426
2510
|
] }),
|
|
@@ -2436,83 +2520,83 @@ function er({
|
|
|
2436
2520
|
children: "At least one contact method (email or phone) is required"
|
|
2437
2521
|
}
|
|
2438
2522
|
),
|
|
2439
|
-
/* @__PURE__ */
|
|
2440
|
-
/* @__PURE__ */ n("label", { style:
|
|
2523
|
+
/* @__PURE__ */ d("div", { style: w.fieldGroup, children: [
|
|
2524
|
+
/* @__PURE__ */ n("label", { style: w.label, children: u.passwordLabel }),
|
|
2441
2525
|
/* @__PURE__ */ n(
|
|
2442
2526
|
"input",
|
|
2443
2527
|
{
|
|
2444
2528
|
id: "password",
|
|
2445
2529
|
name: "password",
|
|
2446
2530
|
type: "password",
|
|
2447
|
-
value:
|
|
2448
|
-
onChange: (
|
|
2449
|
-
|
|
2531
|
+
value: h,
|
|
2532
|
+
onChange: (v) => {
|
|
2533
|
+
$(v.target.value), F.password && l((J) => ({ ...J, password: !1 }));
|
|
2450
2534
|
},
|
|
2451
|
-
placeholder:
|
|
2452
|
-
style:
|
|
2453
|
-
disabled:
|
|
2535
|
+
placeholder: u.passwordPlaceholder,
|
|
2536
|
+
style: U("password"),
|
|
2537
|
+
disabled: P
|
|
2454
2538
|
}
|
|
2455
2539
|
)
|
|
2456
2540
|
] }),
|
|
2457
|
-
/* @__PURE__ */
|
|
2458
|
-
/* @__PURE__ */ n("label", { style:
|
|
2541
|
+
/* @__PURE__ */ d("div", { style: w.fieldGroup, children: [
|
|
2542
|
+
/* @__PURE__ */ n("label", { style: w.label, children: u.confirmPasswordLabel }),
|
|
2459
2543
|
/* @__PURE__ */ n(
|
|
2460
2544
|
"input",
|
|
2461
2545
|
{
|
|
2462
2546
|
id: "confirmPassword",
|
|
2463
2547
|
name: "confirmPassword",
|
|
2464
2548
|
type: "password",
|
|
2465
|
-
value:
|
|
2466
|
-
onChange: (
|
|
2467
|
-
|
|
2549
|
+
value: A,
|
|
2550
|
+
onChange: (v) => {
|
|
2551
|
+
E(v.target.value), F.confirmPassword && l((J) => ({ ...J, confirmPassword: !1 })), c === u.passwordMismatchError && L("");
|
|
2468
2552
|
},
|
|
2469
|
-
placeholder:
|
|
2470
|
-
style:
|
|
2471
|
-
disabled:
|
|
2553
|
+
placeholder: u.confirmPasswordPlaceholder,
|
|
2554
|
+
style: U("confirmPassword"),
|
|
2555
|
+
disabled: P
|
|
2472
2556
|
}
|
|
2473
2557
|
)
|
|
2474
2558
|
] }),
|
|
2475
|
-
t === "tenant" && /* @__PURE__ */
|
|
2476
|
-
/* @__PURE__ */ n("label", { style:
|
|
2559
|
+
t === "tenant" && /* @__PURE__ */ d("div", { style: w.fieldGroup, children: [
|
|
2560
|
+
/* @__PURE__ */ n("label", { style: w.label, children: u.tenantNameLabel }),
|
|
2477
2561
|
/* @__PURE__ */ n(
|
|
2478
2562
|
"input",
|
|
2479
2563
|
{
|
|
2480
2564
|
id: "tenantName",
|
|
2481
2565
|
name: "tenantName",
|
|
2482
2566
|
type: "text",
|
|
2483
|
-
value:
|
|
2484
|
-
onChange: (
|
|
2485
|
-
|
|
2567
|
+
value: N,
|
|
2568
|
+
onChange: (v) => {
|
|
2569
|
+
D(v.target.value), F.tenantName && l((J) => ({ ...J, tenantName: !1 }));
|
|
2486
2570
|
},
|
|
2487
|
-
placeholder:
|
|
2488
|
-
style:
|
|
2489
|
-
disabled:
|
|
2571
|
+
placeholder: u.tenantNamePlaceholder,
|
|
2572
|
+
style: U("tenantName"),
|
|
2573
|
+
disabled: P
|
|
2490
2574
|
}
|
|
2491
2575
|
)
|
|
2492
2576
|
] }),
|
|
2493
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !V ||
|
|
2494
|
-
|
|
2577
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !V || P, style: q(), children: P ? u.loadingText : u.submitButton }),
|
|
2578
|
+
c && /* @__PURE__ */ n("div", { style: w.errorText, children: c })
|
|
2495
2579
|
] }),
|
|
2496
|
-
(
|
|
2497
|
-
|
|
2498
|
-
/* @__PURE__ */
|
|
2499
|
-
|
|
2580
|
+
(m || y) && /* @__PURE__ */ d("div", { style: w.linkContainer, children: [
|
|
2581
|
+
y && /* @__PURE__ */ d("div", { children: [
|
|
2582
|
+
/* @__PURE__ */ d("span", { style: w.divider, children: [
|
|
2583
|
+
u.magicLinkText,
|
|
2500
2584
|
" "
|
|
2501
2585
|
] }),
|
|
2502
|
-
/* @__PURE__ */ n("a", { onClick: a, style:
|
|
2586
|
+
/* @__PURE__ */ n("a", { onClick: a, style: w.link, children: u.magicLinkLink })
|
|
2503
2587
|
] }),
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
/* @__PURE__ */
|
|
2507
|
-
|
|
2588
|
+
y && m && /* @__PURE__ */ n("div", { style: w.divider, children: "•" }),
|
|
2589
|
+
m && /* @__PURE__ */ d("div", { children: [
|
|
2590
|
+
/* @__PURE__ */ d("span", { style: w.divider, children: [
|
|
2591
|
+
u.loginText,
|
|
2508
2592
|
" "
|
|
2509
2593
|
] }),
|
|
2510
|
-
/* @__PURE__ */ n("a", { onClick: o, style:
|
|
2594
|
+
/* @__PURE__ */ n("a", { onClick: o, style: w.link, children: u.loginLink })
|
|
2511
2595
|
] })
|
|
2512
2596
|
] })
|
|
2513
2597
|
] });
|
|
2514
2598
|
}
|
|
2515
|
-
const
|
|
2599
|
+
const Rt = {
|
|
2516
2600
|
title: "Sign In with Magic Link",
|
|
2517
2601
|
emailLabel: "Email",
|
|
2518
2602
|
emailPlaceholder: "Enter your email",
|
|
@@ -2530,7 +2614,7 @@ const kt = {
|
|
|
2530
2614
|
loadingText: "Sending magic link...",
|
|
2531
2615
|
verifyingText: "Verifying magic link...",
|
|
2532
2616
|
description: "Enter your email to receive a magic link. If you don't have an account, we'll create one for you."
|
|
2533
|
-
},
|
|
2617
|
+
}, Lt = {
|
|
2534
2618
|
container: {
|
|
2535
2619
|
maxWidth: "400px",
|
|
2536
2620
|
width: "100%",
|
|
@@ -2633,7 +2717,7 @@ const kt = {
|
|
|
2633
2717
|
fontSize: "0.875rem"
|
|
2634
2718
|
}
|
|
2635
2719
|
};
|
|
2636
|
-
function
|
|
2720
|
+
function dr({
|
|
2637
2721
|
copy: i = {},
|
|
2638
2722
|
styles: e = {},
|
|
2639
2723
|
onSuccess: t,
|
|
@@ -2641,97 +2725,97 @@ function tr({
|
|
|
2641
2725
|
onLoginClick: s,
|
|
2642
2726
|
onSignupClick: o,
|
|
2643
2727
|
showTraditionalLinks: a = !0,
|
|
2644
|
-
className:
|
|
2645
|
-
verifyToken:
|
|
2646
|
-
frontendUrl:
|
|
2728
|
+
className: m,
|
|
2729
|
+
verifyToken: y,
|
|
2730
|
+
frontendUrl: b
|
|
2647
2731
|
}) {
|
|
2648
|
-
const [
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
}, [
|
|
2652
|
-
const
|
|
2653
|
-
if (!
|
|
2654
|
-
|
|
2732
|
+
const [g, S] = k(""), [f, T] = k(""), [I, C] = k(""), [R, x] = k(!1), [h, $] = k(!1), [A, E] = k(""), [N, D] = k(""), [P, O] = k({}), [c, L] = k(!1), { sendMagicLink: F, verifyMagicLink: l } = ae(), { tenant: H } = ce(), M = { ...Rt, ...i }, p = { ...Lt, ...e };
|
|
2733
|
+
re(() => {
|
|
2734
|
+
y && u(y);
|
|
2735
|
+
}, [y]);
|
|
2736
|
+
const u = async (q) => {
|
|
2737
|
+
if (!H || !g) {
|
|
2738
|
+
E("Missing tenant or email");
|
|
2655
2739
|
return;
|
|
2656
2740
|
}
|
|
2657
|
-
|
|
2741
|
+
$(!0), E("");
|
|
2658
2742
|
try {
|
|
2659
|
-
const V = await
|
|
2660
|
-
token:
|
|
2661
|
-
email:
|
|
2743
|
+
const V = await l({
|
|
2744
|
+
token: q,
|
|
2745
|
+
email: g
|
|
2662
2746
|
// tenantId inferred from context automatically
|
|
2663
2747
|
});
|
|
2664
2748
|
t == null || t(V);
|
|
2665
2749
|
} catch (V) {
|
|
2666
|
-
const
|
|
2667
|
-
|
|
2750
|
+
const v = V.message || "Failed to verify magic link";
|
|
2751
|
+
E(v), r == null || r(v);
|
|
2668
2752
|
} finally {
|
|
2669
|
-
|
|
2753
|
+
$(!1);
|
|
2670
2754
|
}
|
|
2671
|
-
},
|
|
2672
|
-
const
|
|
2673
|
-
return
|
|
2674
|
-
}, G = async (
|
|
2675
|
-
if (
|
|
2676
|
-
if (!(
|
|
2677
|
-
|
|
2755
|
+
}, w = () => {
|
|
2756
|
+
const q = {};
|
|
2757
|
+
return g.trim() || (q.email = !0), c && !f.trim() && (q.name = !0), O(q), Object.keys(q).length === 0;
|
|
2758
|
+
}, G = async (q) => {
|
|
2759
|
+
if (q.preventDefault(), !!w()) {
|
|
2760
|
+
if (!(H != null && H.id)) {
|
|
2761
|
+
E("Tenant not found");
|
|
2678
2762
|
return;
|
|
2679
2763
|
}
|
|
2680
|
-
|
|
2764
|
+
x(!0), E(""), D("");
|
|
2681
2765
|
try {
|
|
2682
|
-
const V =
|
|
2683
|
-
email:
|
|
2684
|
-
tenantId:
|
|
2766
|
+
const V = b || (typeof window < "u" ? window.location.origin : ""), v = await F({
|
|
2767
|
+
email: g,
|
|
2768
|
+
tenantId: H.id,
|
|
2685
2769
|
frontendUrl: V,
|
|
2686
|
-
name:
|
|
2687
|
-
lastName:
|
|
2770
|
+
name: c ? f : void 0,
|
|
2771
|
+
lastName: c ? I : void 0
|
|
2688
2772
|
});
|
|
2689
|
-
|
|
2773
|
+
D(M.successMessage), t == null || t(v);
|
|
2690
2774
|
} catch (V) {
|
|
2691
|
-
const
|
|
2692
|
-
|
|
2775
|
+
const v = V.message || M.errorMessage;
|
|
2776
|
+
E(v), r == null || r(v);
|
|
2693
2777
|
} finally {
|
|
2694
|
-
|
|
2778
|
+
x(!1);
|
|
2695
2779
|
}
|
|
2696
2780
|
}
|
|
2697
|
-
},
|
|
2698
|
-
...
|
|
2699
|
-
...
|
|
2700
|
-
}),
|
|
2701
|
-
...
|
|
2702
|
-
...
|
|
2703
|
-
...!
|
|
2781
|
+
}, K = (q) => ({
|
|
2782
|
+
...p.input,
|
|
2783
|
+
...P[q] ? p.inputError : {}
|
|
2784
|
+
}), U = () => ({
|
|
2785
|
+
...p.button,
|
|
2786
|
+
...R || h ? p.buttonLoading : {},
|
|
2787
|
+
...!g || R || h ? p.buttonDisabled : {}
|
|
2704
2788
|
});
|
|
2705
|
-
return
|
|
2706
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2789
|
+
return h ? /* @__PURE__ */ d("div", { className: m, style: p.container, children: [
|
|
2790
|
+
/* @__PURE__ */ n("h2", { style: p.title, children: M.verifyingText }),
|
|
2707
2791
|
/* @__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..." }) })
|
|
2708
|
-
] }) : /* @__PURE__ */
|
|
2709
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2710
|
-
/* @__PURE__ */ n("p", { style:
|
|
2711
|
-
/* @__PURE__ */
|
|
2712
|
-
/* @__PURE__ */
|
|
2713
|
-
/* @__PURE__ */ n("label", { style:
|
|
2792
|
+
] }) : /* @__PURE__ */ d("div", { className: m, style: p.container, children: [
|
|
2793
|
+
/* @__PURE__ */ n("h2", { style: p.title, children: M.title }),
|
|
2794
|
+
/* @__PURE__ */ n("p", { style: p.description, children: M.description }),
|
|
2795
|
+
/* @__PURE__ */ d("form", { onSubmit: G, style: p.form, children: [
|
|
2796
|
+
/* @__PURE__ */ d("div", { style: p.fieldGroup, children: [
|
|
2797
|
+
/* @__PURE__ */ n("label", { style: p.label, children: M.emailLabel }),
|
|
2714
2798
|
/* @__PURE__ */ n(
|
|
2715
2799
|
"input",
|
|
2716
2800
|
{
|
|
2717
2801
|
id: "email",
|
|
2718
2802
|
name: "email",
|
|
2719
2803
|
type: "email",
|
|
2720
|
-
value:
|
|
2721
|
-
onChange: (
|
|
2722
|
-
|
|
2804
|
+
value: g,
|
|
2805
|
+
onChange: (q) => {
|
|
2806
|
+
S(q.target.value), P.email && O((V) => ({ ...V, email: !1 }));
|
|
2723
2807
|
},
|
|
2724
|
-
placeholder:
|
|
2725
|
-
style:
|
|
2726
|
-
disabled:
|
|
2808
|
+
placeholder: M.emailPlaceholder,
|
|
2809
|
+
style: K("email"),
|
|
2810
|
+
disabled: R || h
|
|
2727
2811
|
}
|
|
2728
2812
|
)
|
|
2729
2813
|
] }),
|
|
2730
|
-
!
|
|
2814
|
+
!c && /* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
|
|
2731
2815
|
"button",
|
|
2732
2816
|
{
|
|
2733
2817
|
type: "button",
|
|
2734
|
-
onClick: () =>
|
|
2818
|
+
onClick: () => L(!0),
|
|
2735
2819
|
style: {
|
|
2736
2820
|
background: "none",
|
|
2737
2821
|
border: "none",
|
|
@@ -2743,9 +2827,9 @@ function tr({
|
|
|
2743
2827
|
children: "New user? Add your name"
|
|
2744
2828
|
}
|
|
2745
2829
|
) }),
|
|
2746
|
-
|
|
2747
|
-
/* @__PURE__ */
|
|
2748
|
-
/* @__PURE__ */ n("label", { style:
|
|
2830
|
+
c && /* @__PURE__ */ d(j, { children: [
|
|
2831
|
+
/* @__PURE__ */ d("div", { style: p.fieldGroup, children: [
|
|
2832
|
+
/* @__PURE__ */ n("label", { style: p.label, children: M.nameLabel }),
|
|
2749
2833
|
/* @__PURE__ */ n(
|
|
2750
2834
|
"input",
|
|
2751
2835
|
{
|
|
@@ -2753,28 +2837,28 @@ function tr({
|
|
|
2753
2837
|
name: "name",
|
|
2754
2838
|
type: "text",
|
|
2755
2839
|
value: f,
|
|
2756
|
-
onChange: (
|
|
2757
|
-
|
|
2840
|
+
onChange: (q) => {
|
|
2841
|
+
T(q.target.value), P.name && O((V) => ({ ...V, name: !1 }));
|
|
2758
2842
|
},
|
|
2759
|
-
placeholder:
|
|
2760
|
-
style:
|
|
2761
|
-
disabled:
|
|
2843
|
+
placeholder: M.namePlaceholder,
|
|
2844
|
+
style: K("name"),
|
|
2845
|
+
disabled: R || h
|
|
2762
2846
|
}
|
|
2763
2847
|
)
|
|
2764
2848
|
] }),
|
|
2765
|
-
/* @__PURE__ */
|
|
2766
|
-
/* @__PURE__ */ n("label", { style:
|
|
2849
|
+
/* @__PURE__ */ d("div", { style: p.fieldGroup, children: [
|
|
2850
|
+
/* @__PURE__ */ n("label", { style: p.label, children: M.lastNameLabel }),
|
|
2767
2851
|
/* @__PURE__ */ n(
|
|
2768
2852
|
"input",
|
|
2769
2853
|
{
|
|
2770
2854
|
id: "lastName",
|
|
2771
2855
|
name: "lastName",
|
|
2772
2856
|
type: "text",
|
|
2773
|
-
value:
|
|
2774
|
-
onChange: (
|
|
2775
|
-
placeholder:
|
|
2776
|
-
style:
|
|
2777
|
-
disabled:
|
|
2857
|
+
value: I,
|
|
2858
|
+
onChange: (q) => C(q.target.value),
|
|
2859
|
+
placeholder: M.lastNamePlaceholder,
|
|
2860
|
+
style: p.input,
|
|
2861
|
+
disabled: R || h
|
|
2778
2862
|
}
|
|
2779
2863
|
)
|
|
2780
2864
|
] }),
|
|
@@ -2783,7 +2867,7 @@ function tr({
|
|
|
2783
2867
|
{
|
|
2784
2868
|
type: "button",
|
|
2785
2869
|
onClick: () => {
|
|
2786
|
-
|
|
2870
|
+
L(!1), T(""), C("");
|
|
2787
2871
|
},
|
|
2788
2872
|
style: {
|
|
2789
2873
|
background: "none",
|
|
@@ -2797,30 +2881,30 @@ function tr({
|
|
|
2797
2881
|
}
|
|
2798
2882
|
) })
|
|
2799
2883
|
] }),
|
|
2800
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !
|
|
2801
|
-
|
|
2802
|
-
|
|
2884
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !g || R || h, style: U(), children: R ? M.loadingText : M.submitButton }),
|
|
2885
|
+
A && /* @__PURE__ */ n("div", { style: p.errorText, children: A }),
|
|
2886
|
+
N && /* @__PURE__ */ n("div", { style: p.successText, children: N })
|
|
2803
2887
|
] }),
|
|
2804
|
-
a && /* @__PURE__ */
|
|
2805
|
-
/* @__PURE__ */
|
|
2806
|
-
/* @__PURE__ */
|
|
2807
|
-
|
|
2888
|
+
a && /* @__PURE__ */ d("div", { style: p.linkContainer, children: [
|
|
2889
|
+
/* @__PURE__ */ d("div", { children: [
|
|
2890
|
+
/* @__PURE__ */ d("span", { style: p.divider, children: [
|
|
2891
|
+
M.loginText,
|
|
2808
2892
|
" "
|
|
2809
2893
|
] }),
|
|
2810
|
-
/* @__PURE__ */ n("a", { onClick: s, style:
|
|
2894
|
+
/* @__PURE__ */ n("a", { onClick: s, style: p.link, children: M.loginLink })
|
|
2811
2895
|
] }),
|
|
2812
|
-
/* @__PURE__ */ n("div", { style:
|
|
2813
|
-
/* @__PURE__ */
|
|
2814
|
-
/* @__PURE__ */
|
|
2815
|
-
|
|
2896
|
+
/* @__PURE__ */ n("div", { style: p.divider, children: "•" }),
|
|
2897
|
+
/* @__PURE__ */ d("div", { children: [
|
|
2898
|
+
/* @__PURE__ */ d("span", { style: p.divider, children: [
|
|
2899
|
+
M.signupText,
|
|
2816
2900
|
" "
|
|
2817
2901
|
] }),
|
|
2818
|
-
/* @__PURE__ */ n("a", { onClick: o, style:
|
|
2902
|
+
/* @__PURE__ */ n("a", { onClick: o, style: p.link, children: M.signupLink })
|
|
2819
2903
|
] })
|
|
2820
2904
|
] })
|
|
2821
2905
|
] });
|
|
2822
2906
|
}
|
|
2823
|
-
const
|
|
2907
|
+
const Et = {
|
|
2824
2908
|
title: "Verifying Magic Link",
|
|
2825
2909
|
verifyingMessage: "Please wait while we verify your magic link...",
|
|
2826
2910
|
successMessage: "Magic link verified successfully! You are now logged in.",
|
|
@@ -2828,7 +2912,7 @@ const At = {
|
|
|
2828
2912
|
redirectingMessage: "Redirecting you to the dashboard...",
|
|
2829
2913
|
retryButton: "Try Again",
|
|
2830
2914
|
backToLoginButton: "Back to Login"
|
|
2831
|
-
},
|
|
2915
|
+
}, ze = {
|
|
2832
2916
|
container: {
|
|
2833
2917
|
maxWidth: "400px",
|
|
2834
2918
|
width: "100%",
|
|
@@ -2915,7 +2999,7 @@ const At = {
|
|
|
2915
2999
|
cursor: "pointer",
|
|
2916
3000
|
transition: "all 0.15s ease-in-out"
|
|
2917
3001
|
}
|
|
2918
|
-
},
|
|
3002
|
+
}, Ft = () => /* @__PURE__ */ n("div", { style: ze.spinner }), Ct = () => /* @__PURE__ */ d(
|
|
2919
3003
|
"svg",
|
|
2920
3004
|
{
|
|
2921
3005
|
width: "48",
|
|
@@ -2932,7 +3016,7 @@ const At = {
|
|
|
2932
3016
|
/* @__PURE__ */ n("polyline", { points: "22,4 12,14.01 9,11.01" })
|
|
2933
3017
|
]
|
|
2934
3018
|
}
|
|
2935
|
-
),
|
|
3019
|
+
), Dt = () => /* @__PURE__ */ d(
|
|
2936
3020
|
"svg",
|
|
2937
3021
|
{
|
|
2938
3022
|
width: "48",
|
|
@@ -2950,12 +3034,12 @@ const At = {
|
|
|
2950
3034
|
/* @__PURE__ */ n("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
|
|
2951
3035
|
]
|
|
2952
3036
|
}
|
|
2953
|
-
),
|
|
2954
|
-
loading: /* @__PURE__ */ n(
|
|
2955
|
-
success: /* @__PURE__ */ n(
|
|
2956
|
-
error: /* @__PURE__ */ n(
|
|
3037
|
+
), $t = {
|
|
3038
|
+
loading: /* @__PURE__ */ n(Ft, {}),
|
|
3039
|
+
success: /* @__PURE__ */ n(Ct, {}),
|
|
3040
|
+
error: /* @__PURE__ */ n(Dt, {})
|
|
2957
3041
|
};
|
|
2958
|
-
function
|
|
3042
|
+
function ur({
|
|
2959
3043
|
copy: i = {},
|
|
2960
3044
|
styles: e = {},
|
|
2961
3045
|
icons: t = {},
|
|
@@ -2963,96 +3047,96 @@ function rr({
|
|
|
2963
3047
|
onError: s,
|
|
2964
3048
|
onRetry: o,
|
|
2965
3049
|
onBackToLogin: a,
|
|
2966
|
-
className:
|
|
2967
|
-
token:
|
|
2968
|
-
email:
|
|
2969
|
-
appId:
|
|
2970
|
-
tenantSlug:
|
|
3050
|
+
className: m,
|
|
3051
|
+
token: y,
|
|
3052
|
+
email: b,
|
|
3053
|
+
appId: g,
|
|
3054
|
+
tenantSlug: S,
|
|
2971
3055
|
autoRedirectDelay: f = 3e3
|
|
2972
3056
|
}) {
|
|
2973
|
-
const [
|
|
3057
|
+
const [T, I] = k("verifying"), [C, R] = k(""), { verifyMagicLink: x } = ae(), h = { ...Et, ...i }, $ = { ...ze, ...e }, A = { ...$t, ...t }, E = () => {
|
|
2974
3058
|
if (typeof window > "u") return {};
|
|
2975
|
-
const
|
|
3059
|
+
const c = new URLSearchParams(window.location.search);
|
|
2976
3060
|
return {
|
|
2977
|
-
token:
|
|
2978
|
-
email:
|
|
2979
|
-
appId:
|
|
2980
|
-
tenantSlug:
|
|
3061
|
+
token: y || c.get("token") || "",
|
|
3062
|
+
email: b || c.get("email") || "",
|
|
3063
|
+
appId: g || c.get("appId") || "",
|
|
3064
|
+
tenantSlug: S || c.get("tenantSlug") || void 0
|
|
2981
3065
|
};
|
|
2982
|
-
},
|
|
2983
|
-
|
|
3066
|
+
}, N = async () => {
|
|
3067
|
+
I("verifying"), R("");
|
|
2984
3068
|
try {
|
|
2985
|
-
const
|
|
2986
|
-
if (!
|
|
3069
|
+
const c = E();
|
|
3070
|
+
if (!c.token || !c.email)
|
|
2987
3071
|
throw new Error("Missing required parameters: token or email");
|
|
2988
|
-
const
|
|
2989
|
-
token:
|
|
2990
|
-
email:
|
|
2991
|
-
tenantSlug:
|
|
3072
|
+
const L = await x({
|
|
3073
|
+
token: c.token,
|
|
3074
|
+
email: c.email,
|
|
3075
|
+
tenantSlug: c.tenantSlug
|
|
2992
3076
|
});
|
|
2993
|
-
|
|
2994
|
-
|
|
3077
|
+
I("success"), r == null || r(L), f > 0 && setTimeout(() => {
|
|
3078
|
+
I("redirecting");
|
|
2995
3079
|
}, f);
|
|
2996
|
-
} catch (
|
|
2997
|
-
const
|
|
2998
|
-
L
|
|
3080
|
+
} catch (c) {
|
|
3081
|
+
const L = c.message || h.errorMessage;
|
|
3082
|
+
R(L), I("error"), s == null || s(L);
|
|
2999
3083
|
}
|
|
3000
|
-
},
|
|
3001
|
-
o == null || o(),
|
|
3002
|
-
},
|
|
3084
|
+
}, D = () => {
|
|
3085
|
+
o == null || o(), N();
|
|
3086
|
+
}, P = () => {
|
|
3003
3087
|
a == null || a();
|
|
3004
3088
|
};
|
|
3005
|
-
|
|
3006
|
-
|
|
3089
|
+
re(() => {
|
|
3090
|
+
N();
|
|
3007
3091
|
}, []);
|
|
3008
|
-
const
|
|
3009
|
-
switch (
|
|
3092
|
+
const O = () => {
|
|
3093
|
+
switch (T) {
|
|
3010
3094
|
case "verifying":
|
|
3011
|
-
return /* @__PURE__ */
|
|
3012
|
-
|
|
3013
|
-
|
|
3095
|
+
return /* @__PURE__ */ d("div", { style: $.message, children: [
|
|
3096
|
+
A.loading,
|
|
3097
|
+
h.verifyingMessage
|
|
3014
3098
|
] });
|
|
3015
3099
|
case "success":
|
|
3016
|
-
return /* @__PURE__ */
|
|
3017
|
-
|
|
3018
|
-
/* @__PURE__ */ n("div", { style:
|
|
3100
|
+
return /* @__PURE__ */ d(j, { children: [
|
|
3101
|
+
A.success,
|
|
3102
|
+
/* @__PURE__ */ n("div", { style: $.successMessage, children: h.successMessage })
|
|
3019
3103
|
] });
|
|
3020
3104
|
case "redirecting":
|
|
3021
|
-
return /* @__PURE__ */
|
|
3022
|
-
|
|
3023
|
-
/* @__PURE__ */ n("div", { style:
|
|
3105
|
+
return /* @__PURE__ */ d(j, { children: [
|
|
3106
|
+
A.loading,
|
|
3107
|
+
/* @__PURE__ */ n("div", { style: $.message, children: h.redirectingMessage })
|
|
3024
3108
|
] });
|
|
3025
3109
|
case "error":
|
|
3026
|
-
return /* @__PURE__ */
|
|
3027
|
-
|
|
3028
|
-
/* @__PURE__ */ n("div", { style:
|
|
3029
|
-
/* @__PURE__ */
|
|
3110
|
+
return /* @__PURE__ */ d(j, { children: [
|
|
3111
|
+
A.error,
|
|
3112
|
+
/* @__PURE__ */ n("div", { style: $.errorMessage, children: C || h.errorMessage }),
|
|
3113
|
+
/* @__PURE__ */ d("div", { style: $.buttonContainer, children: [
|
|
3030
3114
|
/* @__PURE__ */ n(
|
|
3031
3115
|
"button",
|
|
3032
3116
|
{
|
|
3033
|
-
onClick:
|
|
3034
|
-
style:
|
|
3035
|
-
onMouseOver: (
|
|
3036
|
-
|
|
3117
|
+
onClick: D,
|
|
3118
|
+
style: $.retryButton,
|
|
3119
|
+
onMouseOver: (c) => {
|
|
3120
|
+
c.currentTarget.style.backgroundColor = "#2563eb";
|
|
3037
3121
|
},
|
|
3038
|
-
onMouseOut: (
|
|
3039
|
-
|
|
3122
|
+
onMouseOut: (c) => {
|
|
3123
|
+
c.currentTarget.style.backgroundColor = "#3b82f6";
|
|
3040
3124
|
},
|
|
3041
|
-
children:
|
|
3125
|
+
children: h.retryButton
|
|
3042
3126
|
}
|
|
3043
3127
|
),
|
|
3044
3128
|
/* @__PURE__ */ n(
|
|
3045
3129
|
"button",
|
|
3046
3130
|
{
|
|
3047
|
-
onClick:
|
|
3048
|
-
style:
|
|
3049
|
-
onMouseOver: (
|
|
3050
|
-
|
|
3131
|
+
onClick: P,
|
|
3132
|
+
style: $.backButton,
|
|
3133
|
+
onMouseOver: (c) => {
|
|
3134
|
+
c.currentTarget.style.backgroundColor = "#e5e7eb";
|
|
3051
3135
|
},
|
|
3052
|
-
onMouseOut: (
|
|
3053
|
-
|
|
3136
|
+
onMouseOut: (c) => {
|
|
3137
|
+
c.currentTarget.style.backgroundColor = "#f3f4f6";
|
|
3054
3138
|
},
|
|
3055
|
-
children:
|
|
3139
|
+
children: h.backToLoginButton
|
|
3056
3140
|
}
|
|
3057
3141
|
)
|
|
3058
3142
|
] })
|
|
@@ -3061,18 +3145,18 @@ function rr({
|
|
|
3061
3145
|
return null;
|
|
3062
3146
|
}
|
|
3063
3147
|
};
|
|
3064
|
-
return /* @__PURE__ */
|
|
3148
|
+
return /* @__PURE__ */ d("div", { style: $.container, className: m, children: [
|
|
3065
3149
|
/* @__PURE__ */ n("style", { children: `
|
|
3066
3150
|
@keyframes spin {
|
|
3067
3151
|
0% { transform: rotate(0deg); }
|
|
3068
3152
|
100% { transform: rotate(360deg); }
|
|
3069
3153
|
}
|
|
3070
3154
|
` }),
|
|
3071
|
-
/* @__PURE__ */ n("h1", { style:
|
|
3072
|
-
|
|
3155
|
+
/* @__PURE__ */ n("h1", { style: $.title, children: h.title }),
|
|
3156
|
+
O()
|
|
3073
3157
|
] });
|
|
3074
3158
|
}
|
|
3075
|
-
const
|
|
3159
|
+
const Ht = {
|
|
3076
3160
|
title: "Reset Password",
|
|
3077
3161
|
subtitle: "Enter your email address and we'll send you a link to reset your password.",
|
|
3078
3162
|
emailLabel: "Email",
|
|
@@ -3094,7 +3178,7 @@ const Rt = {
|
|
|
3094
3178
|
resetLoadingText: "Resetting...",
|
|
3095
3179
|
resetSuccessMessage: "Password reset successfully!",
|
|
3096
3180
|
passwordMismatchError: "Passwords do not match"
|
|
3097
|
-
},
|
|
3181
|
+
}, Nt = {
|
|
3098
3182
|
container: {
|
|
3099
3183
|
maxWidth: "400px",
|
|
3100
3184
|
margin: "0 auto",
|
|
@@ -3186,7 +3270,7 @@ const Rt = {
|
|
|
3186
3270
|
cursor: "pointer"
|
|
3187
3271
|
}
|
|
3188
3272
|
};
|
|
3189
|
-
function
|
|
3273
|
+
function hr({
|
|
3190
3274
|
copy: i = {},
|
|
3191
3275
|
styles: e = {},
|
|
3192
3276
|
mode: t = "request",
|
|
@@ -3194,105 +3278,105 @@ function nr({
|
|
|
3194
3278
|
onSuccess: s,
|
|
3195
3279
|
onError: o,
|
|
3196
3280
|
onBackToLogin: a,
|
|
3197
|
-
onModeChange:
|
|
3198
|
-
className:
|
|
3281
|
+
onModeChange: m,
|
|
3282
|
+
className: y
|
|
3199
3283
|
}) {
|
|
3200
|
-
const [
|
|
3201
|
-
const
|
|
3202
|
-
return
|
|
3203
|
-
},
|
|
3204
|
-
const
|
|
3205
|
-
return
|
|
3206
|
-
},
|
|
3207
|
-
if (
|
|
3208
|
-
if (!(
|
|
3209
|
-
|
|
3284
|
+
const [b, g] = k(""), [S, f] = k(r), [T, I] = k(""), [C, R] = k(""), [x, h] = k(!1), [$, A] = k(""), [E, N] = k(""), [D, P] = k({}), { requestPasswordReset: O, confirmPasswordReset: c } = ae(), { tenant: L } = ce(), F = { ...Ht, ...i }, l = { ...Nt, ...e }, H = () => {
|
|
3285
|
+
const U = {};
|
|
3286
|
+
return b.trim() || (U.email = !0), P(U), Object.keys(U).length === 0;
|
|
3287
|
+
}, M = () => {
|
|
3288
|
+
const U = {};
|
|
3289
|
+
return S.trim() || (U.token = !0), T.trim() || (U.newPassword = !0), C.trim() || (U.confirmPassword = !0), P(U), Object.keys(U).length === 0;
|
|
3290
|
+
}, p = async (U) => {
|
|
3291
|
+
if (U.preventDefault(), !!H()) {
|
|
3292
|
+
if (!(L != null && L.id)) {
|
|
3293
|
+
A("Tenant not found");
|
|
3210
3294
|
return;
|
|
3211
3295
|
}
|
|
3212
|
-
|
|
3296
|
+
h(!0), A(""), N("");
|
|
3213
3297
|
try {
|
|
3214
|
-
await
|
|
3215
|
-
} catch (
|
|
3216
|
-
const V =
|
|
3217
|
-
|
|
3298
|
+
await O({ email: b, tenantId: L.id }), N(F.successMessage), s == null || s();
|
|
3299
|
+
} catch (q) {
|
|
3300
|
+
const V = q.message || F.errorMessage;
|
|
3301
|
+
A(V), o == null || o(V);
|
|
3218
3302
|
} finally {
|
|
3219
|
-
|
|
3303
|
+
h(!1);
|
|
3220
3304
|
}
|
|
3221
3305
|
}
|
|
3222
|
-
},
|
|
3223
|
-
if (
|
|
3224
|
-
if (
|
|
3225
|
-
|
|
3306
|
+
}, u = async (U) => {
|
|
3307
|
+
if (U.preventDefault(), !!M()) {
|
|
3308
|
+
if (T !== C) {
|
|
3309
|
+
A(F.passwordMismatchError), P({ confirmPassword: !0 });
|
|
3226
3310
|
return;
|
|
3227
3311
|
}
|
|
3228
|
-
|
|
3312
|
+
h(!0), A(""), N("");
|
|
3229
3313
|
try {
|
|
3230
|
-
await
|
|
3231
|
-
} catch (
|
|
3232
|
-
const V =
|
|
3233
|
-
|
|
3314
|
+
await c({ token: S, newPassword: T }), N(F.resetSuccessMessage), s == null || s();
|
|
3315
|
+
} catch (q) {
|
|
3316
|
+
const V = q.message || F.errorMessage;
|
|
3317
|
+
A(V), o == null || o(V);
|
|
3234
3318
|
} finally {
|
|
3235
|
-
|
|
3319
|
+
h(!1);
|
|
3236
3320
|
}
|
|
3237
3321
|
}
|
|
3238
|
-
},
|
|
3239
|
-
...
|
|
3240
|
-
...
|
|
3322
|
+
}, w = (U) => ({
|
|
3323
|
+
...l.input,
|
|
3324
|
+
...D[U] ? l.inputError : {}
|
|
3241
3325
|
}), G = () => ({
|
|
3242
|
-
...
|
|
3243
|
-
...
|
|
3326
|
+
...l.button,
|
|
3327
|
+
...x ? l.buttonLoading : {}
|
|
3244
3328
|
});
|
|
3245
3329
|
if (t === "reset") {
|
|
3246
|
-
const
|
|
3247
|
-
return /* @__PURE__ */
|
|
3248
|
-
/* @__PURE__ */ n("h2", { style:
|
|
3249
|
-
/* @__PURE__ */ n("p", { style:
|
|
3250
|
-
/* @__PURE__ */
|
|
3251
|
-
/* @__PURE__ */
|
|
3252
|
-
/* @__PURE__ */ n("label", { style:
|
|
3330
|
+
const U = S && T && C;
|
|
3331
|
+
return /* @__PURE__ */ d("div", { className: y, style: l.container, children: [
|
|
3332
|
+
/* @__PURE__ */ n("h2", { style: l.title, children: F.resetTitle }),
|
|
3333
|
+
/* @__PURE__ */ n("p", { style: l.subtitle, children: F.resetSubtitle }),
|
|
3334
|
+
/* @__PURE__ */ d("form", { onSubmit: u, style: l.form, children: [
|
|
3335
|
+
/* @__PURE__ */ d("div", { style: l.fieldGroup, children: [
|
|
3336
|
+
/* @__PURE__ */ n("label", { style: l.label, children: F.tokenLabel }),
|
|
3253
3337
|
/* @__PURE__ */ n(
|
|
3254
3338
|
"input",
|
|
3255
3339
|
{
|
|
3256
3340
|
type: "text",
|
|
3257
|
-
value:
|
|
3258
|
-
onChange: (
|
|
3259
|
-
f(
|
|
3341
|
+
value: S,
|
|
3342
|
+
onChange: (q) => {
|
|
3343
|
+
f(q.target.value), D.token && P((V) => ({ ...V, token: !1 }));
|
|
3260
3344
|
},
|
|
3261
3345
|
placeholder: F.tokenPlaceholder,
|
|
3262
|
-
style:
|
|
3263
|
-
disabled:
|
|
3346
|
+
style: w("token"),
|
|
3347
|
+
disabled: x
|
|
3264
3348
|
}
|
|
3265
3349
|
)
|
|
3266
3350
|
] }),
|
|
3267
|
-
/* @__PURE__ */
|
|
3268
|
-
/* @__PURE__ */ n("label", { style:
|
|
3351
|
+
/* @__PURE__ */ d("div", { style: l.fieldGroup, children: [
|
|
3352
|
+
/* @__PURE__ */ n("label", { style: l.label, children: F.newPasswordLabel }),
|
|
3269
3353
|
/* @__PURE__ */ n(
|
|
3270
3354
|
"input",
|
|
3271
3355
|
{
|
|
3272
3356
|
type: "password",
|
|
3273
|
-
value:
|
|
3274
|
-
onChange: (
|
|
3275
|
-
|
|
3357
|
+
value: T,
|
|
3358
|
+
onChange: (q) => {
|
|
3359
|
+
I(q.target.value), D.newPassword && P((V) => ({ ...V, newPassword: !1 }));
|
|
3276
3360
|
},
|
|
3277
3361
|
placeholder: F.newPasswordPlaceholder,
|
|
3278
|
-
style:
|
|
3279
|
-
disabled:
|
|
3362
|
+
style: w("newPassword"),
|
|
3363
|
+
disabled: x
|
|
3280
3364
|
}
|
|
3281
3365
|
)
|
|
3282
3366
|
] }),
|
|
3283
|
-
/* @__PURE__ */
|
|
3284
|
-
/* @__PURE__ */ n("label", { style:
|
|
3367
|
+
/* @__PURE__ */ d("div", { style: l.fieldGroup, children: [
|
|
3368
|
+
/* @__PURE__ */ n("label", { style: l.label, children: F.confirmPasswordLabel }),
|
|
3285
3369
|
/* @__PURE__ */ n(
|
|
3286
3370
|
"input",
|
|
3287
3371
|
{
|
|
3288
3372
|
type: "password",
|
|
3289
|
-
value:
|
|
3290
|
-
onChange: (
|
|
3291
|
-
|
|
3373
|
+
value: C,
|
|
3374
|
+
onChange: (q) => {
|
|
3375
|
+
R(q.target.value), D.confirmPassword && P((V) => ({ ...V, confirmPassword: !1 })), $ === F.passwordMismatchError && A("");
|
|
3292
3376
|
},
|
|
3293
3377
|
placeholder: F.confirmPasswordPlaceholder,
|
|
3294
|
-
style:
|
|
3295
|
-
disabled:
|
|
3378
|
+
style: w("confirmPassword"),
|
|
3379
|
+
disabled: x
|
|
3296
3380
|
}
|
|
3297
3381
|
)
|
|
3298
3382
|
] }),
|
|
@@ -3300,44 +3384,44 @@ function nr({
|
|
|
3300
3384
|
"button",
|
|
3301
3385
|
{
|
|
3302
3386
|
type: "submit",
|
|
3303
|
-
disabled: !
|
|
3387
|
+
disabled: !U || x,
|
|
3304
3388
|
style: {
|
|
3305
3389
|
...G(),
|
|
3306
|
-
...!
|
|
3390
|
+
...!U || x ? l.buttonDisabled : {}
|
|
3307
3391
|
},
|
|
3308
|
-
children:
|
|
3392
|
+
children: x ? F.resetLoadingText : F.resetSubmitButton
|
|
3309
3393
|
}
|
|
3310
3394
|
),
|
|
3311
|
-
|
|
3312
|
-
|
|
3395
|
+
$ && /* @__PURE__ */ n("div", { style: l.errorText, children: $ }),
|
|
3396
|
+
E && /* @__PURE__ */ n("div", { style: l.successText, children: E })
|
|
3313
3397
|
] }),
|
|
3314
|
-
/* @__PURE__ */
|
|
3315
|
-
/* @__PURE__ */ n("a", { onClick: a, style:
|
|
3316
|
-
|
|
3398
|
+
/* @__PURE__ */ d("div", { style: l.linkContainer, children: [
|
|
3399
|
+
/* @__PURE__ */ n("a", { onClick: a, style: l.link, children: F.backToLoginLink }),
|
|
3400
|
+
m && /* @__PURE__ */ d(j, { children: [
|
|
3317
3401
|
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3318
|
-
/* @__PURE__ */ n("a", { onClick: () =>
|
|
3402
|
+
/* @__PURE__ */ n("a", { onClick: () => m("request"), style: l.link, children: "Request New Link" })
|
|
3319
3403
|
] })
|
|
3320
3404
|
] })
|
|
3321
3405
|
] });
|
|
3322
3406
|
}
|
|
3323
|
-
const
|
|
3324
|
-
return /* @__PURE__ */
|
|
3325
|
-
/* @__PURE__ */ n("h2", { style:
|
|
3326
|
-
/* @__PURE__ */ n("p", { style:
|
|
3327
|
-
/* @__PURE__ */
|
|
3328
|
-
/* @__PURE__ */
|
|
3329
|
-
/* @__PURE__ */ n("label", { style:
|
|
3407
|
+
const K = b;
|
|
3408
|
+
return /* @__PURE__ */ d("div", { className: y, style: l.container, children: [
|
|
3409
|
+
/* @__PURE__ */ n("h2", { style: l.title, children: F.title }),
|
|
3410
|
+
/* @__PURE__ */ n("p", { style: l.subtitle, children: F.subtitle }),
|
|
3411
|
+
/* @__PURE__ */ d("form", { onSubmit: p, style: l.form, children: [
|
|
3412
|
+
/* @__PURE__ */ d("div", { style: l.fieldGroup, children: [
|
|
3413
|
+
/* @__PURE__ */ n("label", { style: l.label, children: F.emailLabel }),
|
|
3330
3414
|
/* @__PURE__ */ n(
|
|
3331
3415
|
"input",
|
|
3332
3416
|
{
|
|
3333
3417
|
type: "email",
|
|
3334
|
-
value:
|
|
3335
|
-
onChange: (
|
|
3336
|
-
|
|
3418
|
+
value: b,
|
|
3419
|
+
onChange: (U) => {
|
|
3420
|
+
g(U.target.value), D.email && P((q) => ({ ...q, email: !1 }));
|
|
3337
3421
|
},
|
|
3338
3422
|
placeholder: F.emailPlaceholder,
|
|
3339
|
-
style:
|
|
3340
|
-
disabled:
|
|
3423
|
+
style: w("email"),
|
|
3424
|
+
disabled: x
|
|
3341
3425
|
}
|
|
3342
3426
|
)
|
|
3343
3427
|
] }),
|
|
@@ -3345,27 +3429,27 @@ function nr({
|
|
|
3345
3429
|
"button",
|
|
3346
3430
|
{
|
|
3347
3431
|
type: "submit",
|
|
3348
|
-
disabled: !
|
|
3432
|
+
disabled: !K || x,
|
|
3349
3433
|
style: {
|
|
3350
3434
|
...G(),
|
|
3351
|
-
...!
|
|
3435
|
+
...!K || x ? l.buttonDisabled : {}
|
|
3352
3436
|
},
|
|
3353
|
-
children:
|
|
3437
|
+
children: x ? F.loadingText : F.submitButton
|
|
3354
3438
|
}
|
|
3355
3439
|
),
|
|
3356
|
-
|
|
3357
|
-
|
|
3440
|
+
$ && /* @__PURE__ */ n("div", { style: l.errorText, children: $ }),
|
|
3441
|
+
E && /* @__PURE__ */ n("div", { style: l.successText, children: E })
|
|
3358
3442
|
] }),
|
|
3359
|
-
/* @__PURE__ */
|
|
3360
|
-
/* @__PURE__ */ n("a", { onClick: a, style:
|
|
3361
|
-
|
|
3443
|
+
/* @__PURE__ */ d("div", { style: l.linkContainer, children: [
|
|
3444
|
+
/* @__PURE__ */ n("a", { onClick: a, style: l.link, children: F.backToLoginLink }),
|
|
3445
|
+
m && /* @__PURE__ */ d(j, { children: [
|
|
3362
3446
|
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3363
|
-
/* @__PURE__ */ n("a", { onClick: () =>
|
|
3447
|
+
/* @__PURE__ */ n("a", { onClick: () => m("reset"), style: l.link, children: "I have a token" })
|
|
3364
3448
|
] })
|
|
3365
3449
|
] })
|
|
3366
3450
|
] });
|
|
3367
3451
|
}
|
|
3368
|
-
const
|
|
3452
|
+
const Ut = () => /* @__PURE__ */ n(
|
|
3369
3453
|
"div",
|
|
3370
3454
|
{
|
|
3371
3455
|
style: {
|
|
@@ -3377,7 +3461,7 @@ const Et = () => /* @__PURE__ */ n(
|
|
|
3377
3461
|
},
|
|
3378
3462
|
children: /* @__PURE__ */ n("div", { children: "Loading..." })
|
|
3379
3463
|
}
|
|
3380
|
-
),
|
|
3464
|
+
), Bt = ({ error: i, retry: e }) => /* @__PURE__ */ d(
|
|
3381
3465
|
"div",
|
|
3382
3466
|
{
|
|
3383
3467
|
style: {
|
|
@@ -3411,43 +3495,139 @@ const Et = () => /* @__PURE__ */ n(
|
|
|
3411
3495
|
]
|
|
3412
3496
|
}
|
|
3413
3497
|
);
|
|
3414
|
-
function
|
|
3498
|
+
function gr({
|
|
3415
3499
|
children: i,
|
|
3416
3500
|
loadingFallback: e,
|
|
3417
3501
|
errorFallback: t,
|
|
3418
3502
|
requireTenant: r = !0
|
|
3419
3503
|
}) {
|
|
3420
|
-
const { isAppLoading: s, appError: o, retryApp: a } =
|
|
3421
|
-
}),
|
|
3422
|
-
o && a(), f &&
|
|
3504
|
+
const { isAppLoading: s, appError: o, retryApp: a } = ge(), m = we(), y = Me(), b = Be(), g = qe(), S = (m == null ? void 0 : m.isTenantLoading) ?? !1, f = (m == null ? void 0 : m.tenantError) ?? null, T = (m == null ? void 0 : m.tenantSlug) ?? null, I = (m == null ? void 0 : m.retryTenant) ?? (() => {
|
|
3505
|
+
}), C = (y == null ? void 0 : y.isAuthReady) ?? !0, R = (b == null ? void 0 : b.isReady) ?? !0, x = (g == null ? void 0 : g.isReady) ?? !0, h = r && m && T, N = s || h && S || y && !C || b && !R || g && !x, D = o || (h ? f : null), P = () => {
|
|
3506
|
+
o && a(), f && m && I();
|
|
3423
3507
|
};
|
|
3424
|
-
if (
|
|
3425
|
-
return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(
|
|
3426
|
-
if (
|
|
3427
|
-
const
|
|
3428
|
-
return /* @__PURE__ */ n(j, { children:
|
|
3508
|
+
if (N)
|
|
3509
|
+
return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(Ut, {}) });
|
|
3510
|
+
if (D) {
|
|
3511
|
+
const O = typeof t == "function" ? t(D, P) : t || /* @__PURE__ */ n(Bt, { error: D, retry: P });
|
|
3512
|
+
return /* @__PURE__ */ n(j, { children: O });
|
|
3429
3513
|
}
|
|
3430
3514
|
return /* @__PURE__ */ n(j, { children: i });
|
|
3431
3515
|
}
|
|
3432
|
-
function
|
|
3433
|
-
const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } =
|
|
3434
|
-
}),
|
|
3516
|
+
function pr(i = !0) {
|
|
3517
|
+
const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = ge(), o = we(), a = Me(), m = Be(), y = qe(), b = (o == null ? void 0 : o.isTenantLoading) ?? !1, g = (o == null ? void 0 : o.tenantError) ?? null, S = (o == null ? void 0 : o.tenant) ?? null, f = (o == null ? void 0 : o.tenantSlug) ?? null, T = (o == null ? void 0 : o.retryTenant) ?? (() => {
|
|
3518
|
+
}), I = (a == null ? void 0 : a.isAuthReady) ?? !0, C = (m == null ? void 0 : m.isReady) ?? !0, R = (y == null ? void 0 : y.isReady) ?? !0, x = i && o && f, E = e || x && b || a && !I || m && !C || y && !R, N = t || (x ? g : null);
|
|
3435
3519
|
return {
|
|
3436
|
-
isLoading:
|
|
3437
|
-
error:
|
|
3438
|
-
isReady: !
|
|
3520
|
+
isLoading: E,
|
|
3521
|
+
error: N,
|
|
3522
|
+
isReady: !E && !N && s !== null && (!x || S !== null),
|
|
3439
3523
|
retry: () => {
|
|
3440
|
-
t && r(),
|
|
3524
|
+
t && r(), g && o && T();
|
|
3441
3525
|
},
|
|
3442
3526
|
// Individual states
|
|
3443
3527
|
app: { isLoading: e, error: t, data: s },
|
|
3444
|
-
tenant: o ? { isLoading:
|
|
3445
|
-
auth: a ? { isReady:
|
|
3446
|
-
featureFlags:
|
|
3447
|
-
subscription:
|
|
3528
|
+
tenant: o ? { isLoading: b, error: g, data: S } : null,
|
|
3529
|
+
auth: a ? { isReady: I } : null,
|
|
3530
|
+
featureFlags: m ? { isReady: C } : null,
|
|
3531
|
+
subscription: y ? { isReady: R } : null
|
|
3532
|
+
};
|
|
3533
|
+
}
|
|
3534
|
+
function fr({
|
|
3535
|
+
tenants: i,
|
|
3536
|
+
currentTenantId: e,
|
|
3537
|
+
onSelect: t,
|
|
3538
|
+
className: r = "",
|
|
3539
|
+
dropdownClassName: s = "",
|
|
3540
|
+
itemClassName: o = "",
|
|
3541
|
+
renderItem: a,
|
|
3542
|
+
placeholder: m = "Select tenant",
|
|
3543
|
+
disabled: y = !1,
|
|
3544
|
+
showCurrentTenant: b = !0
|
|
3545
|
+
}) {
|
|
3546
|
+
var $;
|
|
3547
|
+
const g = Me(), [S, f] = k(!1), T = Ne(null), I = i ?? (g == null ? void 0 : g.userTenants) ?? [], C = e ?? (($ = g == null ? void 0 : g.currentUser) == null ? void 0 : $.tenantId) ?? null, R = async (A) => {
|
|
3548
|
+
f(!1), t ? t(A) : g != null && g.switchToTenant && await g.switchToTenant(A);
|
|
3448
3549
|
};
|
|
3550
|
+
re(() => {
|
|
3551
|
+
const A = (E) => {
|
|
3552
|
+
T.current && !T.current.contains(E.target) && f(!1);
|
|
3553
|
+
};
|
|
3554
|
+
return document.addEventListener("mousedown", A), () => document.removeEventListener("mousedown", A);
|
|
3555
|
+
}, []);
|
|
3556
|
+
const x = I.find((A) => A.id === C);
|
|
3557
|
+
if (I.length === 0)
|
|
3558
|
+
return null;
|
|
3559
|
+
if (I.length === 1 && b)
|
|
3560
|
+
return /* @__PURE__ */ n("div", { className: r, children: /* @__PURE__ */ n("span", { children: I[0].name }) });
|
|
3561
|
+
const h = (A, E) => /* @__PURE__ */ d("span", { style: { fontWeight: E ? "bold" : "normal" }, children: [
|
|
3562
|
+
A.name,
|
|
3563
|
+
A.role && /* @__PURE__ */ d("span", { style: { opacity: 0.7, marginLeft: 8 }, children: [
|
|
3564
|
+
"(",
|
|
3565
|
+
A.role,
|
|
3566
|
+
")"
|
|
3567
|
+
] })
|
|
3568
|
+
] });
|
|
3569
|
+
return /* @__PURE__ */ d("div", { ref: T, className: r, style: { position: "relative" }, children: [
|
|
3570
|
+
/* @__PURE__ */ d(
|
|
3571
|
+
"button",
|
|
3572
|
+
{
|
|
3573
|
+
type: "button",
|
|
3574
|
+
onClick: () => !y && f(!S),
|
|
3575
|
+
disabled: y,
|
|
3576
|
+
style: {
|
|
3577
|
+
cursor: y ? "not-allowed" : "pointer",
|
|
3578
|
+
opacity: y ? 0.6 : 1
|
|
3579
|
+
},
|
|
3580
|
+
children: [
|
|
3581
|
+
x ? x.name : m,
|
|
3582
|
+
/* @__PURE__ */ n("span", { style: { marginLeft: 8 }, children: S ? "▲" : "▼" })
|
|
3583
|
+
]
|
|
3584
|
+
}
|
|
3585
|
+
),
|
|
3586
|
+
S && /* @__PURE__ */ n(
|
|
3587
|
+
"div",
|
|
3588
|
+
{
|
|
3589
|
+
className: s,
|
|
3590
|
+
style: {
|
|
3591
|
+
position: "absolute",
|
|
3592
|
+
top: "100%",
|
|
3593
|
+
left: 0,
|
|
3594
|
+
right: 0,
|
|
3595
|
+
zIndex: 1e3,
|
|
3596
|
+
backgroundColor: "white",
|
|
3597
|
+
border: "1px solid #ccc",
|
|
3598
|
+
borderRadius: 4,
|
|
3599
|
+
boxShadow: "0 2px 8px rgba(0,0,0,0.15)",
|
|
3600
|
+
maxHeight: 300,
|
|
3601
|
+
overflowY: "auto"
|
|
3602
|
+
},
|
|
3603
|
+
children: I.map((A) => {
|
|
3604
|
+
const E = A.id === C;
|
|
3605
|
+
return /* @__PURE__ */ n(
|
|
3606
|
+
"div",
|
|
3607
|
+
{
|
|
3608
|
+
className: o,
|
|
3609
|
+
onClick: () => R(A.id),
|
|
3610
|
+
style: {
|
|
3611
|
+
padding: "8px 12px",
|
|
3612
|
+
cursor: "pointer",
|
|
3613
|
+
backgroundColor: E ? "#f0f0f0" : "transparent"
|
|
3614
|
+
},
|
|
3615
|
+
onMouseEnter: (N) => {
|
|
3616
|
+
E || (N.target.style.backgroundColor = "#f5f5f5");
|
|
3617
|
+
},
|
|
3618
|
+
onMouseLeave: (N) => {
|
|
3619
|
+
E || (N.target.style.backgroundColor = "transparent");
|
|
3620
|
+
},
|
|
3621
|
+
children: a ? a(A, E) : h(A, E)
|
|
3622
|
+
},
|
|
3623
|
+
A.id
|
|
3624
|
+
);
|
|
3625
|
+
})
|
|
3626
|
+
}
|
|
3627
|
+
)
|
|
3628
|
+
] });
|
|
3449
3629
|
}
|
|
3450
|
-
class
|
|
3630
|
+
class mr {
|
|
3451
3631
|
constructor(e, t) {
|
|
3452
3632
|
this.httpService = e, this.sessionManager = t;
|
|
3453
3633
|
}
|
|
@@ -3515,7 +3695,7 @@ class or {
|
|
|
3515
3695
|
};
|
|
3516
3696
|
}
|
|
3517
3697
|
}
|
|
3518
|
-
class
|
|
3698
|
+
class yr {
|
|
3519
3699
|
constructor(e, t) {
|
|
3520
3700
|
this.httpService = e, this.sessionManager = t;
|
|
3521
3701
|
}
|
|
@@ -3566,7 +3746,7 @@ class ar {
|
|
|
3566
3746
|
});
|
|
3567
3747
|
}
|
|
3568
3748
|
}
|
|
3569
|
-
class
|
|
3749
|
+
class wr {
|
|
3570
3750
|
constructor(e) {
|
|
3571
3751
|
this.httpService = e;
|
|
3572
3752
|
}
|
|
@@ -3575,7 +3755,7 @@ class lr {
|
|
|
3575
3755
|
return await this.httpService.get("/health");
|
|
3576
3756
|
}
|
|
3577
3757
|
}
|
|
3578
|
-
class
|
|
3758
|
+
class br {
|
|
3579
3759
|
// Date string to Date object
|
|
3580
3760
|
static toDate(e) {
|
|
3581
3761
|
return new Date(e);
|
|
@@ -3698,47 +3878,48 @@ class cr {
|
|
|
3698
3878
|
}
|
|
3699
3879
|
}
|
|
3700
3880
|
export {
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3881
|
+
br as ApiMappers,
|
|
3882
|
+
Fe as AppApiService,
|
|
3883
|
+
gr as AppLoader,
|
|
3884
|
+
Jt as AppProvider,
|
|
3885
|
+
tt as AuthApiService,
|
|
3886
|
+
Zt as AuthProvider,
|
|
3887
|
+
ar as FeatureFlag,
|
|
3888
|
+
ut as FeatureFlagApiService,
|
|
3889
|
+
er as FeatureFlagProvider,
|
|
3890
|
+
wr as HealthApiService,
|
|
3891
|
+
ne as HttpService,
|
|
3892
|
+
ir as LandingRoute,
|
|
3893
|
+
lr as LoginForm,
|
|
3894
|
+
dr as MagicLinkForm,
|
|
3895
|
+
ur as MagicLinkVerify,
|
|
3896
|
+
hr as PasswordRecoveryForm,
|
|
3897
|
+
mr as PermissionApiService,
|
|
3898
|
+
rr as Protected,
|
|
3899
|
+
nr as ProtectedRoute,
|
|
3900
|
+
Ce as RoleApiService,
|
|
3901
|
+
ke as SessionManager,
|
|
3902
|
+
cr as SignupForm,
|
|
3903
|
+
gt as SubscriptionApiService,
|
|
3904
|
+
or as SubscriptionGuard,
|
|
3905
|
+
yr as SubscriptionPlanApiService,
|
|
3906
|
+
tr as SubscriptionProvider,
|
|
3907
|
+
ue as TenantApiService,
|
|
3908
|
+
Yt as TenantProvider,
|
|
3909
|
+
sr as TenantRoute,
|
|
3910
|
+
fr as TenantSelector,
|
|
3911
|
+
rt as UserApiService,
|
|
3912
|
+
oe as UserType,
|
|
3913
|
+
Kt as useApi,
|
|
3914
|
+
ge as useApp,
|
|
3915
|
+
pr as useAppLoaderState,
|
|
3916
|
+
ae as useAuth,
|
|
3917
|
+
ht as useFeatureFlags,
|
|
3918
|
+
Xt as useSettings,
|
|
3919
|
+
pt as useSubscription,
|
|
3920
|
+
ye as useTenant,
|
|
3921
|
+
ce as useTenantInfo,
|
|
3922
|
+
we as useTenantOptional,
|
|
3923
|
+
Qt as useTenantSettings
|
|
3743
3924
|
};
|
|
3744
3925
|
//# sourceMappingURL=index.es.js.map
|