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