@skylabs-digital/react-identity-access 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AppLoader.d.ts +56 -0
- package/dist/components/AppLoader.d.ts.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +1011 -1008
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/providers/AppProvider.d.ts +0 -2
- package/dist/providers/AppProvider.d.ts.map +1 -1
- package/dist/providers/TenantProvider.d.ts +2 -2
- package/dist/providers/TenantProvider.d.ts.map +1 -1
- package/dist/utils/tenantDetection.d.ts +26 -0
- package/dist/utils/tenantDetection.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as n, Fragment as
|
|
2
|
-
import { createContext as
|
|
1
|
+
import { jsx as n, Fragment as B, jsxs as a } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as he, useMemo as Q, useState as k, useCallback as ne, useEffect as te, useContext as ce } from "react";
|
|
3
3
|
import { useLocation as we, Navigate as pe } from "react-router-dom";
|
|
4
4
|
class re {
|
|
5
5
|
// SessionManager instance
|
|
@@ -16,40 +16,40 @@ class re {
|
|
|
16
16
|
return this.executeRequest(e, t, r, s, !1);
|
|
17
17
|
}
|
|
18
18
|
async executeRequest(e, t, r, s, o = !1) {
|
|
19
|
-
const
|
|
19
|
+
const g = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, y = (s == null ? void 0 : s.timeout) || this.timeout;
|
|
20
20
|
let A = {
|
|
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
|
-
A = { ...A, ...
|
|
28
|
-
} catch (
|
|
29
|
-
console.warn("Failed to inject auth headers:",
|
|
26
|
+
const f = await this.sessionManager.getAuthHeaders();
|
|
27
|
+
A = { ...A, ...f };
|
|
28
|
+
} catch (f) {
|
|
29
|
+
console.warn("Failed to inject auth headers:", f);
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const w = new AbortController(), T = setTimeout(() => w.abort(), y);
|
|
32
32
|
try {
|
|
33
|
-
const
|
|
33
|
+
const f = await fetch(g, {
|
|
34
34
|
method: e,
|
|
35
35
|
headers: A,
|
|
36
36
|
body: r ? JSON.stringify(r) : void 0,
|
|
37
|
-
signal:
|
|
37
|
+
signal: w.signal
|
|
38
38
|
});
|
|
39
|
-
if (clearTimeout(T),
|
|
39
|
+
if (clearTimeout(T), f.status === 401 && !(s != null && s.skipRetry) && !o && this.sessionManager)
|
|
40
40
|
try {
|
|
41
41
|
const h = this.sessionManager.getTokens();
|
|
42
42
|
if (h != null && h.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 ${f.status}: ${f.statusText}`);
|
|
46
46
|
}
|
|
47
|
-
if (!
|
|
48
|
-
throw new Error(`HTTP ${
|
|
49
|
-
const
|
|
50
|
-
return !
|
|
51
|
-
} catch (
|
|
52
|
-
throw clearTimeout(T),
|
|
47
|
+
if (!f.ok)
|
|
48
|
+
throw new Error(`HTTP ${f.status}: ${f.statusText}`);
|
|
49
|
+
const p = f.headers.get("content-type");
|
|
50
|
+
return !p || !p.includes("application/json") ? {} : await f.json();
|
|
51
|
+
} catch (f) {
|
|
52
|
+
throw clearTimeout(T), f instanceof Error && f.name === "AbortError" ? new Error(`Request timeout after ${y}ms`) : f;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
async get(e, t) {
|
|
@@ -65,7 +65,7 @@ class re {
|
|
|
65
65
|
return this.request("DELETE", e, void 0, t);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
class
|
|
68
|
+
class Se {
|
|
69
69
|
constructor(e, t) {
|
|
70
70
|
this.httpService = e, this.sessionManager = t;
|
|
71
71
|
}
|
|
@@ -124,76 +124,31 @@ class be {
|
|
|
124
124
|
})).data;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
{
|
|
130
|
-
style: {
|
|
131
|
-
display: "flex",
|
|
132
|
-
justifyContent: "center",
|
|
133
|
-
alignItems: "center",
|
|
134
|
-
height: "100vh",
|
|
135
|
-
fontFamily: "system-ui, sans-serif"
|
|
136
|
-
},
|
|
137
|
-
children: /* @__PURE__ */ n("div", { children: "Loading application..." })
|
|
138
|
-
}
|
|
139
|
-
), He = ({ error: i, retry: e }) => /* @__PURE__ */ l(
|
|
140
|
-
"div",
|
|
141
|
-
{
|
|
142
|
-
style: {
|
|
143
|
-
display: "flex",
|
|
144
|
-
flexDirection: "column",
|
|
145
|
-
justifyContent: "center",
|
|
146
|
-
alignItems: "center",
|
|
147
|
-
height: "100vh",
|
|
148
|
-
fontFamily: "system-ui, sans-serif",
|
|
149
|
-
textAlign: "center",
|
|
150
|
-
padding: "20px"
|
|
151
|
-
},
|
|
152
|
-
children: [
|
|
153
|
-
/* @__PURE__ */ n("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Application Error" }),
|
|
154
|
-
/* @__PURE__ */ n("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load application" }),
|
|
155
|
-
/* @__PURE__ */ n(
|
|
156
|
-
"button",
|
|
157
|
-
{
|
|
158
|
-
onClick: e,
|
|
159
|
-
style: {
|
|
160
|
-
padding: "8px 16px",
|
|
161
|
-
backgroundColor: "#007bff",
|
|
162
|
-
color: "white",
|
|
163
|
-
border: "none",
|
|
164
|
-
borderRadius: "4px",
|
|
165
|
-
cursor: "pointer"
|
|
166
|
-
},
|
|
167
|
-
children: "Retry"
|
|
168
|
-
}
|
|
169
|
-
)
|
|
170
|
-
]
|
|
171
|
-
}
|
|
172
|
-
);
|
|
173
|
-
function St({ config: i, children: e }) {
|
|
127
|
+
const Te = he(null);
|
|
128
|
+
function xt({ config: i, children: e }) {
|
|
174
129
|
const t = Q(
|
|
175
130
|
() => {
|
|
176
|
-
var
|
|
131
|
+
var p, h, m;
|
|
177
132
|
return {
|
|
178
|
-
enabled: ((
|
|
133
|
+
enabled: ((p = i.cache) == null ? void 0 : p.enabled) ?? !0,
|
|
179
134
|
ttl: ((h = i.cache) == null ? void 0 : h.ttl) ?? 3e5,
|
|
180
135
|
// 5 minutes default
|
|
181
|
-
storageKey: ((
|
|
136
|
+
storageKey: ((m = i.cache) == null ? void 0 : m.storageKey) ?? `app_cache_${i.appId}`
|
|
182
137
|
};
|
|
183
138
|
},
|
|
184
139
|
[i.cache, i.appId]
|
|
185
|
-
), [r, s] =
|
|
140
|
+
), [r, s] = k(() => {
|
|
186
141
|
if (!t.enabled) return null;
|
|
187
142
|
try {
|
|
188
|
-
const
|
|
189
|
-
if (!
|
|
190
|
-
const h = JSON.parse(
|
|
143
|
+
const p = localStorage.getItem(t.storageKey);
|
|
144
|
+
if (!p) return null;
|
|
145
|
+
const h = JSON.parse(p);
|
|
191
146
|
return Date.now() - h.timestamp < t.ttl && h.appId === i.appId ? h.data : (localStorage.removeItem(t.storageKey), null);
|
|
192
147
|
} catch {
|
|
193
148
|
return null;
|
|
194
149
|
}
|
|
195
|
-
}), [o,
|
|
196
|
-
const
|
|
150
|
+
}), [o, g] = k(!r), [y, A] = k(null), w = Q(() => {
|
|
151
|
+
const p = () => {
|
|
197
152
|
T();
|
|
198
153
|
};
|
|
199
154
|
return {
|
|
@@ -202,71 +157,65 @@ function St({ config: i, children: e }) {
|
|
|
202
157
|
// App info
|
|
203
158
|
appInfo: r,
|
|
204
159
|
isAppLoading: o,
|
|
205
|
-
appError:
|
|
206
|
-
retryApp:
|
|
160
|
+
appError: y,
|
|
161
|
+
retryApp: p
|
|
207
162
|
};
|
|
208
|
-
}, [i, r, o,
|
|
209
|
-
async (
|
|
210
|
-
if (!(!
|
|
163
|
+
}, [i, r, o, y]), T = ne(
|
|
164
|
+
async (p = !1) => {
|
|
165
|
+
if (!(!p && t.enabled && r))
|
|
211
166
|
try {
|
|
212
|
-
|
|
213
|
-
const h = new re(i.baseUrl),
|
|
214
|
-
if (s(
|
|
167
|
+
g(!0), A(null);
|
|
168
|
+
const h = new re(i.baseUrl), R = await new Se(h, {}).getPublicAppInfo(i.appId);
|
|
169
|
+
if (s(R), t.enabled)
|
|
215
170
|
try {
|
|
216
|
-
const
|
|
217
|
-
data:
|
|
171
|
+
const C = {
|
|
172
|
+
data: R,
|
|
218
173
|
timestamp: Date.now(),
|
|
219
174
|
appId: i.appId
|
|
220
175
|
};
|
|
221
|
-
localStorage.setItem(t.storageKey, JSON.stringify(
|
|
222
|
-
} catch (
|
|
223
|
-
console.warn("Failed to cache app info:",
|
|
176
|
+
localStorage.setItem(t.storageKey, JSON.stringify(C));
|
|
177
|
+
} catch (C) {
|
|
178
|
+
console.warn("Failed to cache app info:", C);
|
|
224
179
|
}
|
|
225
180
|
} catch (h) {
|
|
226
|
-
const
|
|
227
|
-
A(
|
|
181
|
+
const m = h instanceof Error ? h : new Error("Failed to load app information");
|
|
182
|
+
A(m), s(null);
|
|
228
183
|
} finally {
|
|
229
|
-
|
|
184
|
+
g(!1);
|
|
230
185
|
}
|
|
231
186
|
},
|
|
232
187
|
[i.baseUrl, i.appId, t, r]
|
|
233
|
-
),
|
|
188
|
+
), f = ne(async () => {
|
|
234
189
|
if (!(!t.enabled || !r))
|
|
235
190
|
try {
|
|
236
|
-
const
|
|
237
|
-
if (!
|
|
238
|
-
const h = JSON.parse(
|
|
191
|
+
const p = localStorage.getItem(t.storageKey);
|
|
192
|
+
if (!p) return;
|
|
193
|
+
const h = JSON.parse(p);
|
|
239
194
|
if (Date.now() - h.timestamp > t.ttl * 0.5) {
|
|
240
|
-
const
|
|
241
|
-
s(
|
|
242
|
-
const
|
|
243
|
-
data:
|
|
195
|
+
const R = new re(i.baseUrl), U = await new Se(R, {}).getPublicAppInfo(i.appId);
|
|
196
|
+
s(U);
|
|
197
|
+
const P = {
|
|
198
|
+
data: U,
|
|
244
199
|
timestamp: Date.now(),
|
|
245
200
|
appId: i.appId
|
|
246
201
|
};
|
|
247
|
-
localStorage.setItem(t.storageKey, JSON.stringify(
|
|
202
|
+
localStorage.setItem(t.storageKey, JSON.stringify(P));
|
|
248
203
|
}
|
|
249
|
-
} catch (
|
|
250
|
-
console.warn("Background app refresh failed:",
|
|
204
|
+
} catch (p) {
|
|
205
|
+
console.warn("Background app refresh failed:", p);
|
|
251
206
|
}
|
|
252
207
|
}, [i, t, r]);
|
|
253
|
-
|
|
254
|
-
r ?
|
|
255
|
-
}, []),
|
|
256
|
-
return /* @__PURE__ */ n(N, { children: i.loadingFallback || /* @__PURE__ */ n(De, {}) });
|
|
257
|
-
if (I) {
|
|
258
|
-
const f = typeof i.errorFallback == "function" ? i.errorFallback(I, () => T()) : i.errorFallback || /* @__PURE__ */ n(He, { error: I, retry: () => T() });
|
|
259
|
-
return /* @__PURE__ */ n(N, { children: f });
|
|
260
|
-
}
|
|
261
|
-
return /* @__PURE__ */ n(Ae.Provider, { value: x, children: e });
|
|
208
|
+
return te(() => {
|
|
209
|
+
r ? f() : T();
|
|
210
|
+
}, []), /* @__PURE__ */ n(Te.Provider, { value: w, children: e });
|
|
262
211
|
}
|
|
263
|
-
function
|
|
264
|
-
const i =
|
|
212
|
+
function oe() {
|
|
213
|
+
const i = ce(Te);
|
|
265
214
|
if (!i)
|
|
266
215
|
throw new Error("useApp must be used within an AppProvider");
|
|
267
216
|
return i;
|
|
268
217
|
}
|
|
269
|
-
const
|
|
218
|
+
const kt = oe;
|
|
270
219
|
class ye {
|
|
271
220
|
constructor(e = {}) {
|
|
272
221
|
this.refreshPromise = null, this.refreshQueue = [], e.tenantSlug !== void 0 ? this.storageKey = e.tenantSlug ? `auth_tokens_${e.tenantSlug}` : "auth_tokens" : this.storageKey = e.storageKey || "auth_tokens", this.autoRefresh = e.autoRefresh ?? !0, this.refreshThreshold = e.refreshThreshold || 3e5, this.onRefreshFailed = e.onRefreshFailed, this.baseUrl = e.baseUrl || "", this.tokenStorage = e.tokenStorage || this.createTokenStorage(this.storageKey);
|
|
@@ -420,7 +369,7 @@ class ye {
|
|
|
420
369
|
return e !== null && !this.isTokenExpired(e);
|
|
421
370
|
}
|
|
422
371
|
}
|
|
423
|
-
class
|
|
372
|
+
class He {
|
|
424
373
|
constructor(e) {
|
|
425
374
|
this.httpService = e;
|
|
426
375
|
}
|
|
@@ -465,7 +414,7 @@ class Ne {
|
|
|
465
414
|
});
|
|
466
415
|
}
|
|
467
416
|
}
|
|
468
|
-
class
|
|
417
|
+
class ve {
|
|
469
418
|
constructor(e, t) {
|
|
470
419
|
this.httpService = e, this.sessionManager = t;
|
|
471
420
|
}
|
|
@@ -532,16 +481,16 @@ class Se {
|
|
|
532
481
|
throw new Error("SessionManager is required for private endpoints");
|
|
533
482
|
const r = await this.sessionManager.getAuthHeaders(), s = new URLSearchParams();
|
|
534
483
|
t != null && t.page && s.append("page", t.page.toString()), t != null && t.limit && s.append("limit", t.limit.toString()), t != null && t.sortBy && s.append("sortBy", t.sortBy), t != null && t.sortOrder && s.append("sortOrder", t.sortOrder);
|
|
535
|
-
const o = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`,
|
|
484
|
+
const o = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, g = await this.httpService.get(o, {
|
|
536
485
|
headers: r
|
|
537
486
|
});
|
|
538
487
|
return {
|
|
539
|
-
roles:
|
|
540
|
-
meta:
|
|
488
|
+
roles: g.data,
|
|
489
|
+
meta: g.meta
|
|
541
490
|
};
|
|
542
491
|
}
|
|
543
492
|
}
|
|
544
|
-
class
|
|
493
|
+
class Ne {
|
|
545
494
|
constructor(e, t) {
|
|
546
495
|
this.httpService = e, this.sessionManager = t;
|
|
547
496
|
}
|
|
@@ -581,7 +530,7 @@ class Be {
|
|
|
581
530
|
});
|
|
582
531
|
}
|
|
583
532
|
}
|
|
584
|
-
class
|
|
533
|
+
class ue {
|
|
585
534
|
constructor(e, t, r) {
|
|
586
535
|
this.httpService = e, this.appId = t, this.sessionManager = r;
|
|
587
536
|
}
|
|
@@ -659,180 +608,155 @@ class ce {
|
|
|
659
608
|
)).data;
|
|
660
609
|
}
|
|
661
610
|
}
|
|
662
|
-
|
|
663
|
-
"
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
children: /* @__PURE__ */ n("div", { children: "Loading tenant..." })
|
|
673
|
-
}
|
|
674
|
-
), qe = ({ error: i, retry: e }) => /* @__PURE__ */ l(
|
|
675
|
-
"div",
|
|
676
|
-
{
|
|
677
|
-
style: {
|
|
678
|
-
display: "flex",
|
|
679
|
-
flexDirection: "column",
|
|
680
|
-
justifyContent: "center",
|
|
681
|
-
alignItems: "center",
|
|
682
|
-
height: "100vh",
|
|
683
|
-
fontFamily: "system-ui, sans-serif",
|
|
684
|
-
textAlign: "center",
|
|
685
|
-
padding: "20px"
|
|
686
|
-
},
|
|
687
|
-
children: [
|
|
688
|
-
/* @__PURE__ */ n("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Tenant Error" }),
|
|
689
|
-
/* @__PURE__ */ n("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load tenant" }),
|
|
690
|
-
/* @__PURE__ */ n(
|
|
691
|
-
"button",
|
|
692
|
-
{
|
|
693
|
-
onClick: e,
|
|
694
|
-
style: {
|
|
695
|
-
padding: "8px 16px",
|
|
696
|
-
backgroundColor: "#007bff",
|
|
697
|
-
color: "white",
|
|
698
|
-
border: "none",
|
|
699
|
-
borderRadius: "4px",
|
|
700
|
-
cursor: "pointer"
|
|
701
|
-
},
|
|
702
|
-
children: "Retry"
|
|
703
|
-
}
|
|
704
|
-
)
|
|
705
|
-
]
|
|
706
|
-
}
|
|
707
|
-
);
|
|
708
|
-
function xt({ config: i, children: e }) {
|
|
709
|
-
const { baseUrl: t, appInfo: r, appId: s } = he(), o = ne(() => {
|
|
710
|
-
const a = i.tenantMode || "selector", g = "tenant";
|
|
711
|
-
if (typeof window > "u") return null;
|
|
712
|
-
if (a === "subdomain") {
|
|
713
|
-
const c = window.location.hostname.split(".");
|
|
714
|
-
if (c.length >= 3) {
|
|
715
|
-
const d = c[0];
|
|
716
|
-
return localStorage.setItem(g, d), d;
|
|
717
|
-
}
|
|
718
|
-
return localStorage.getItem(g);
|
|
719
|
-
} else if (a === "selector") {
|
|
720
|
-
const c = new URLSearchParams(window.location.search).get(i.selectorParam || "tenant");
|
|
721
|
-
return c ? (localStorage.setItem(g, c), c) : localStorage.getItem(g);
|
|
611
|
+
function Be(i, e) {
|
|
612
|
+
if (i === "localhost" || i.startsWith("127.") || i.startsWith("192.168."))
|
|
613
|
+
return null;
|
|
614
|
+
if (e) {
|
|
615
|
+
const s = e.toLowerCase(), o = i.toLowerCase();
|
|
616
|
+
if (o === s || o === `www.${s}`)
|
|
617
|
+
return null;
|
|
618
|
+
if (o.endsWith(`.${s}`)) {
|
|
619
|
+
const g = o.slice(0, -(s.length + 1));
|
|
620
|
+
return g === "www" ? null : g;
|
|
722
621
|
}
|
|
723
622
|
return null;
|
|
724
|
-
}
|
|
623
|
+
}
|
|
624
|
+
const r = i.split(".");
|
|
625
|
+
return r.length >= 3 && r[0] !== "www" ? r[0] : null;
|
|
626
|
+
}
|
|
627
|
+
function Ue(i, e = "tenant", t) {
|
|
628
|
+
const s = new URLSearchParams(i).get(e);
|
|
629
|
+
return s ? (t && t.setItem("tenant", s), s) : t ? t.getItem("tenant") : null;
|
|
630
|
+
}
|
|
631
|
+
function qe(i, e, t) {
|
|
632
|
+
const { tenantMode: r, baseDomain: s, selectorParam: o } = i;
|
|
633
|
+
return r === "subdomain" ? Be(e.hostname, s) : r === "selector" ? Ue(e.search, o, t) : null;
|
|
634
|
+
}
|
|
635
|
+
const be = he(null);
|
|
636
|
+
function At({ config: i, children: e }) {
|
|
637
|
+
const { baseUrl: t, appInfo: r, appId: s } = oe(), o = ne(() => typeof window > "u" ? null : qe(
|
|
638
|
+
{
|
|
639
|
+
tenantMode: i.tenantMode || "selector",
|
|
640
|
+
baseDomain: i.baseDomain,
|
|
641
|
+
selectorParam: i.selectorParam
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
hostname: window.location.hostname,
|
|
645
|
+
search: window.location.search
|
|
646
|
+
},
|
|
647
|
+
window.localStorage
|
|
648
|
+
), [i.tenantMode, i.baseDomain, i.selectorParam]), [g, y] = k(() => o()), A = Q(
|
|
725
649
|
() => {
|
|
726
|
-
var
|
|
650
|
+
var l, x, b;
|
|
727
651
|
return {
|
|
728
|
-
enabled: ((
|
|
729
|
-
ttl: ((
|
|
652
|
+
enabled: ((l = i.cache) == null ? void 0 : l.enabled) ?? !0,
|
|
653
|
+
ttl: ((x = i.cache) == null ? void 0 : x.ttl) ?? 5 * 60 * 1e3,
|
|
730
654
|
// 5 minutes default
|
|
731
|
-
storageKey: ((
|
|
655
|
+
storageKey: ((b = i.cache) == null ? void 0 : b.storageKey) ?? `tenant_cache_${g || "default"}`
|
|
732
656
|
};
|
|
733
657
|
},
|
|
734
|
-
[i.cache,
|
|
735
|
-
), [
|
|
658
|
+
[i.cache, g]
|
|
659
|
+
), [w, T] = k(() => {
|
|
736
660
|
if (i.initialTenant) return i.initialTenant;
|
|
737
|
-
if (!A.enabled || !
|
|
661
|
+
if (!A.enabled || !g) return null;
|
|
738
662
|
try {
|
|
739
|
-
const
|
|
740
|
-
if (!
|
|
741
|
-
const
|
|
742
|
-
return Date.now() -
|
|
663
|
+
const l = localStorage.getItem(A.storageKey);
|
|
664
|
+
if (!l) return null;
|
|
665
|
+
const x = JSON.parse(l);
|
|
666
|
+
return Date.now() - x.timestamp < A.ttl && x.tenantSlug === g ? x.data : (localStorage.removeItem(A.storageKey), null);
|
|
743
667
|
} catch {
|
|
744
668
|
return null;
|
|
745
669
|
}
|
|
746
|
-
}), [
|
|
670
|
+
}), [f, p] = k(!w && !i.initialTenant), [h, m] = k(null), [R, C] = k(null), [U, P] = k(!1), [u, M] = k(null);
|
|
747
671
|
te(() => {
|
|
748
|
-
const
|
|
749
|
-
|
|
672
|
+
const l = o();
|
|
673
|
+
y(l);
|
|
750
674
|
}, [o]);
|
|
751
|
-
const
|
|
752
|
-
async (
|
|
753
|
-
if (!(!
|
|
675
|
+
const E = (r == null ? void 0 : r.settingsSchema) || null, q = ne(
|
|
676
|
+
async (l, x = !1) => {
|
|
677
|
+
if (!(!x && A.enabled && w && w.domain === l))
|
|
754
678
|
try {
|
|
755
|
-
|
|
756
|
-
const
|
|
757
|
-
if (T(
|
|
679
|
+
p(!0), m(null);
|
|
680
|
+
const b = new re(t), c = await new ue(b, s).getPublicTenantInfo(l);
|
|
681
|
+
if (T(c), A.enabled)
|
|
758
682
|
try {
|
|
759
|
-
const
|
|
760
|
-
data:
|
|
683
|
+
const S = {
|
|
684
|
+
data: c,
|
|
761
685
|
timestamp: Date.now(),
|
|
762
|
-
tenantSlug:
|
|
686
|
+
tenantSlug: l
|
|
763
687
|
};
|
|
764
|
-
localStorage.setItem(A.storageKey, JSON.stringify(
|
|
765
|
-
} catch (
|
|
766
|
-
console.warn("Failed to cache tenant info:",
|
|
688
|
+
localStorage.setItem(A.storageKey, JSON.stringify(S));
|
|
689
|
+
} catch (S) {
|
|
690
|
+
console.warn("Failed to cache tenant info:", S);
|
|
767
691
|
}
|
|
768
|
-
} catch (
|
|
769
|
-
const
|
|
770
|
-
|
|
692
|
+
} catch (b) {
|
|
693
|
+
const d = b instanceof Error ? b : new Error("Failed to load tenant information");
|
|
694
|
+
m(d), T(null);
|
|
771
695
|
} finally {
|
|
772
|
-
|
|
696
|
+
p(!1);
|
|
773
697
|
}
|
|
774
698
|
},
|
|
775
|
-
[t, s, A,
|
|
776
|
-
),
|
|
777
|
-
if (!(!A.enabled || !
|
|
699
|
+
[t, s, A, w]
|
|
700
|
+
), V = ne(async () => {
|
|
701
|
+
if (!(!A.enabled || !w || !g))
|
|
778
702
|
try {
|
|
779
|
-
const
|
|
780
|
-
if (!
|
|
781
|
-
const
|
|
782
|
-
if (Date.now() -
|
|
783
|
-
const
|
|
784
|
-
T(
|
|
703
|
+
const l = localStorage.getItem(A.storageKey);
|
|
704
|
+
if (!l) return;
|
|
705
|
+
const x = JSON.parse(l);
|
|
706
|
+
if (Date.now() - x.timestamp > A.ttl * 0.5) {
|
|
707
|
+
const d = new re(t), S = await new ue(d, s).getPublicTenantInfo(g);
|
|
708
|
+
T(S);
|
|
785
709
|
const G = {
|
|
786
|
-
data:
|
|
710
|
+
data: S,
|
|
787
711
|
timestamp: Date.now(),
|
|
788
|
-
tenantSlug:
|
|
712
|
+
tenantSlug: g
|
|
789
713
|
};
|
|
790
714
|
localStorage.setItem(A.storageKey, JSON.stringify(G));
|
|
791
715
|
}
|
|
792
|
-
} catch (
|
|
793
|
-
console.warn("Background tenant refresh failed:",
|
|
716
|
+
} catch (l) {
|
|
717
|
+
console.warn("Background tenant refresh failed:", l);
|
|
794
718
|
}
|
|
795
|
-
}, [t, s, A,
|
|
796
|
-
if (
|
|
719
|
+
}, [t, s, A, w, g]), $ = ne(async () => {
|
|
720
|
+
if (w != null && w.id)
|
|
797
721
|
try {
|
|
798
|
-
|
|
799
|
-
const
|
|
800
|
-
|
|
801
|
-
} catch (
|
|
802
|
-
const
|
|
803
|
-
|
|
722
|
+
P(!0), M(null);
|
|
723
|
+
const l = new re(t), b = await new ue(l, w.appId).getTenantSettings(w.id);
|
|
724
|
+
C(b);
|
|
725
|
+
} catch (l) {
|
|
726
|
+
const x = l instanceof Error ? l : new Error("Failed to load tenant settings");
|
|
727
|
+
M(x), C(null);
|
|
804
728
|
} finally {
|
|
805
|
-
|
|
729
|
+
P(!1);
|
|
806
730
|
}
|
|
807
|
-
}, [t,
|
|
808
|
-
|
|
809
|
-
}, [
|
|
810
|
-
(
|
|
811
|
-
if (!
|
|
731
|
+
}, [t, w]), j = ne(() => {
|
|
732
|
+
$();
|
|
733
|
+
}, [$]), v = ne(
|
|
734
|
+
(l) => {
|
|
735
|
+
if (!E)
|
|
812
736
|
return { isValid: !0, errors: [] };
|
|
813
|
-
const
|
|
737
|
+
const x = [];
|
|
814
738
|
try {
|
|
815
|
-
return
|
|
816
|
-
var
|
|
817
|
-
const
|
|
818
|
-
if ((
|
|
819
|
-
|
|
739
|
+
return E.properties && Object.entries(E.properties).forEach(([b, d]) => {
|
|
740
|
+
var S;
|
|
741
|
+
const c = l[b];
|
|
742
|
+
if ((S = E.required) != null && S.includes(b) && c == null) {
|
|
743
|
+
x.push(`Field '${b}' is required`);
|
|
820
744
|
return;
|
|
821
745
|
}
|
|
822
|
-
if (
|
|
823
|
-
if (
|
|
824
|
-
const G =
|
|
825
|
-
G === "string" && ee !== "string" ?
|
|
746
|
+
if (c != null) {
|
|
747
|
+
if (d.type) {
|
|
748
|
+
const G = d.type, ee = typeof c;
|
|
749
|
+
G === "string" && ee !== "string" ? x.push(`Field '${b}' must be a string`) : (G === "number" || G === "integer") && ee !== "number" ? x.push(`Field '${b}' must be a number`) : G === "boolean" && ee !== "boolean" ? x.push(`Field '${b}' must be a boolean`) : G === "array" && !Array.isArray(c) && x.push(`Field '${b}' must be an array`);
|
|
826
750
|
}
|
|
827
|
-
|
|
828
|
-
`Field '${
|
|
829
|
-
),
|
|
830
|
-
`Field '${
|
|
831
|
-
),
|
|
751
|
+
d.minLength !== void 0 && typeof c == "string" && c.length < d.minLength && x.push(
|
|
752
|
+
`Field '${b}' must be at least ${d.minLength} characters long`
|
|
753
|
+
), d.maxLength !== void 0 && typeof c == "string" && c.length > d.maxLength && x.push(
|
|
754
|
+
`Field '${b}' must be no more than ${d.maxLength} characters long`
|
|
755
|
+
), d.minimum !== void 0 && typeof c == "number" && c < d.minimum && x.push(`Field '${b}' must be at least ${d.minimum}`), d.maximum !== void 0 && typeof c == "number" && c > d.maximum && x.push(`Field '${b}' must be no more than ${d.maximum}`), d.pattern && typeof c == "string" && (new RegExp(d.pattern).test(c) || x.push(`Field '${b}' does not match the required pattern`)), d.enum && !d.enum.includes(c) && x.push(`Field '${b}' must be one of: ${d.enum.join(", ")}`);
|
|
832
756
|
}
|
|
833
757
|
}), {
|
|
834
|
-
isValid:
|
|
835
|
-
errors:
|
|
758
|
+
isValid: x.length === 0,
|
|
759
|
+
errors: x
|
|
836
760
|
};
|
|
837
761
|
} catch {
|
|
838
762
|
return {
|
|
@@ -841,87 +765,84 @@ function xt({ config: i, children: e }) {
|
|
|
841
765
|
};
|
|
842
766
|
}
|
|
843
767
|
},
|
|
844
|
-
[
|
|
768
|
+
[E]
|
|
845
769
|
);
|
|
846
770
|
te(() => {
|
|
847
|
-
!i.initialTenant &&
|
|
848
|
-
}, [i.initialTenant,
|
|
849
|
-
|
|
850
|
-
}, [
|
|
851
|
-
const
|
|
852
|
-
(
|
|
853
|
-
const
|
|
854
|
-
if (localStorage.setItem("tenant",
|
|
855
|
-
const
|
|
856
|
-
if (
|
|
857
|
-
|
|
858
|
-
const
|
|
771
|
+
!i.initialTenant && g ? w ? V() : q(g) : !i.initialTenant && !g && (T(null), m(null), p(!1));
|
|
772
|
+
}, [i.initialTenant, g, w, q, V]), te(() => {
|
|
773
|
+
w != null && w.id ? $() : (C(null), M(null), P(!1));
|
|
774
|
+
}, [w == null ? void 0 : w.id, $]);
|
|
775
|
+
const I = ne(
|
|
776
|
+
(l, x = "reload") => {
|
|
777
|
+
const b = i.tenantMode || "selector";
|
|
778
|
+
if (localStorage.setItem("tenant", l), b === "subdomain") {
|
|
779
|
+
const d = window.location.hostname, c = d.split(".");
|
|
780
|
+
if (c.length >= 2) {
|
|
781
|
+
c[0] = l;
|
|
782
|
+
const S = c.join("."), G = `${window.location.protocol}//${S}${window.location.pathname}${window.location.search}`;
|
|
859
783
|
window.location.href = G;
|
|
860
784
|
} else
|
|
861
785
|
console.warn(
|
|
862
786
|
"[TenantProvider] Cannot switch subdomain, invalid hostname:",
|
|
863
|
-
|
|
787
|
+
d
|
|
864
788
|
);
|
|
865
|
-
} else if (
|
|
866
|
-
const
|
|
867
|
-
if (
|
|
868
|
-
const
|
|
869
|
-
window.location.href =
|
|
789
|
+
} else if (b === "selector") {
|
|
790
|
+
const d = new URLSearchParams(window.location.search);
|
|
791
|
+
if (d.set(i.selectorParam || "tenant", l), x === "reload") {
|
|
792
|
+
const c = `${window.location.pathname}?${d.toString()}${window.location.hash}`;
|
|
793
|
+
window.location.href = c;
|
|
870
794
|
} else {
|
|
871
|
-
const
|
|
872
|
-
window.history.pushState({}, "",
|
|
795
|
+
const c = `${window.location.pathname}?${d.toString()}${window.location.hash}`;
|
|
796
|
+
window.history.pushState({}, "", c), y(l), q(l);
|
|
873
797
|
}
|
|
874
798
|
}
|
|
875
799
|
},
|
|
876
|
-
[i.tenantMode, i.selectorParam,
|
|
877
|
-
),
|
|
800
|
+
[i.tenantMode, i.selectorParam, q, g]
|
|
801
|
+
), L = Q(() => ({
|
|
878
802
|
// Tenant info
|
|
879
|
-
tenant:
|
|
880
|
-
tenantSlug:
|
|
881
|
-
isTenantLoading:
|
|
803
|
+
tenant: w,
|
|
804
|
+
tenantSlug: g,
|
|
805
|
+
isTenantLoading: f,
|
|
882
806
|
tenantError: h,
|
|
883
807
|
retryTenant: () => {
|
|
884
|
-
|
|
808
|
+
g && q(g);
|
|
885
809
|
},
|
|
886
810
|
// Settings
|
|
887
|
-
settings:
|
|
888
|
-
settingsSchema:
|
|
889
|
-
isSettingsLoading:
|
|
811
|
+
settings: R,
|
|
812
|
+
settingsSchema: E,
|
|
813
|
+
isSettingsLoading: U,
|
|
890
814
|
settingsError: u,
|
|
891
815
|
// Actions
|
|
892
|
-
refreshSettings:
|
|
893
|
-
switchTenant:
|
|
816
|
+
refreshSettings: j,
|
|
817
|
+
switchTenant: I,
|
|
894
818
|
// Validation
|
|
895
|
-
validateSettings:
|
|
819
|
+
validateSettings: v
|
|
896
820
|
}), [
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
821
|
+
w,
|
|
822
|
+
g,
|
|
823
|
+
f,
|
|
900
824
|
h,
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
825
|
+
R,
|
|
826
|
+
E,
|
|
827
|
+
U,
|
|
904
828
|
u,
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
829
|
+
j,
|
|
830
|
+
I,
|
|
831
|
+
v
|
|
908
832
|
]);
|
|
909
|
-
|
|
910
|
-
return /* @__PURE__ */ n(N, { children: i.loadingFallback || /* @__PURE__ */ n(Ue, {}) });
|
|
911
|
-
if (h) {
|
|
912
|
-
const a = typeof i.errorFallback == "function" ? i.errorFallback(h, () => H(p || "")) : i.errorFallback || /* @__PURE__ */ n(qe, { error: h, retry: () => H(p || "") });
|
|
913
|
-
return /* @__PURE__ */ n(N, { children: a });
|
|
914
|
-
}
|
|
915
|
-
return /* @__PURE__ */ n(Te.Provider, { value: E, children: e });
|
|
833
|
+
return /* @__PURE__ */ n(be.Provider, { value: L, children: e });
|
|
916
834
|
}
|
|
917
835
|
function fe() {
|
|
918
|
-
const i =
|
|
836
|
+
const i = ce(be);
|
|
919
837
|
if (!i)
|
|
920
838
|
throw new Error("useTenant must be used within a TenantProvider");
|
|
921
839
|
return i;
|
|
922
840
|
}
|
|
923
|
-
|
|
924
|
-
|
|
841
|
+
function Pe() {
|
|
842
|
+
return ce(be);
|
|
843
|
+
}
|
|
844
|
+
const Tt = fe;
|
|
845
|
+
function Pt() {
|
|
925
846
|
const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } = fe();
|
|
926
847
|
return {
|
|
927
848
|
settings: i,
|
|
@@ -941,51 +862,51 @@ function se() {
|
|
|
941
862
|
retry: s
|
|
942
863
|
};
|
|
943
864
|
}
|
|
944
|
-
const
|
|
945
|
-
function
|
|
946
|
-
const { appId: t, baseUrl: r } =
|
|
865
|
+
const Me = he(null);
|
|
866
|
+
function Mt({ config: i = {}, children: e }) {
|
|
867
|
+
const { appId: t, baseUrl: r } = oe(), { tenant: s, tenantSlug: o, switchTenant: g } = fe(), [y, A] = k(i.initialRoles || []), [w, T] = k(!i.initialRoles), [f, p] = k(null), [h, m] = k(!1), [R, C] = k(null), [U, P] = k(0), u = Q(() => new ye({
|
|
947
868
|
tenantSlug: o,
|
|
948
869
|
// SessionManager will generate storageKey internally
|
|
949
870
|
onRefreshFailed: i.onRefreshFailed,
|
|
950
871
|
baseUrl: r
|
|
951
|
-
}), [o, r, i.onRefreshFailed]),
|
|
952
|
-
const
|
|
953
|
-
return
|
|
954
|
-
}, [r, u]),
|
|
955
|
-
const
|
|
872
|
+
}), [o, r, i.onRefreshFailed]), M = Q(() => {
|
|
873
|
+
const x = new re(r);
|
|
874
|
+
return x.setSessionManager(u), x;
|
|
875
|
+
}, [r, u]), E = Q(() => new He(new re(r)), [r]), q = Q(() => new Ne(M, u), [M, u]), V = Q(() => new ve(new re(r)), [r]), $ = Q(() => f || u.getUser(), [f, u]), j = Q(() => $ != null && $.roleId && y.find((x) => x.id === $.roleId) || null, [$, y]), v = Q(() => (j == null ? void 0 : j.permissions) || [], [j]), I = Q(() => u.hasValidSession() && f !== null, [u, f]), L = 5 * 60 * 1e3, l = Q(() => {
|
|
876
|
+
const x = async (F = !1) => {
|
|
956
877
|
try {
|
|
957
878
|
if (!u.hasValidSession())
|
|
958
879
|
return;
|
|
959
|
-
const
|
|
960
|
-
if (
|
|
880
|
+
const N = Date.now();
|
|
881
|
+
if (!F && N - U < L && f)
|
|
961
882
|
return;
|
|
962
|
-
const
|
|
963
|
-
if (!
|
|
883
|
+
const W = u.getUserId();
|
|
884
|
+
if (!W) {
|
|
964
885
|
console.warn("[AuthProvider] No userId available in token or storage");
|
|
965
886
|
return;
|
|
966
887
|
}
|
|
967
|
-
|
|
968
|
-
const X = await
|
|
969
|
-
|
|
970
|
-
} catch (
|
|
971
|
-
const
|
|
972
|
-
|
|
888
|
+
m(!0), C(null);
|
|
889
|
+
const X = await q.getUserById(W);
|
|
890
|
+
p(X), u.setUser(X), P(Date.now());
|
|
891
|
+
} catch (N) {
|
|
892
|
+
const _ = N instanceof Error ? N : new Error("Failed to load user data");
|
|
893
|
+
C(_), console.error("[AuthProvider] Failed to load user data:", _);
|
|
973
894
|
} finally {
|
|
974
|
-
|
|
895
|
+
m(!1);
|
|
975
896
|
}
|
|
976
|
-
},
|
|
977
|
-
await
|
|
978
|
-
},
|
|
979
|
-
const { username:
|
|
897
|
+
}, b = async () => {
|
|
898
|
+
await x();
|
|
899
|
+
}, d = async (F) => {
|
|
900
|
+
const { username: N, password: _, tenantSlug: W } = F;
|
|
980
901
|
let X = s == null ? void 0 : s.id, Y = o, Z = u;
|
|
981
|
-
|
|
982
|
-
const J = await
|
|
983
|
-
username:
|
|
984
|
-
password:
|
|
902
|
+
W && (X = (await new ue(M, t).getPublicTenantInfo(W)).id, Y = W);
|
|
903
|
+
const J = await E.login({
|
|
904
|
+
username: N,
|
|
905
|
+
password: _,
|
|
985
906
|
appId: t,
|
|
986
907
|
tenantId: X
|
|
987
|
-
}),
|
|
988
|
-
if (
|
|
908
|
+
}), le = W && W !== o;
|
|
909
|
+
if (le && (Z = new ye({
|
|
989
910
|
tenantSlug: Y,
|
|
990
911
|
baseUrl: r
|
|
991
912
|
})), Z.setTokens({
|
|
@@ -993,79 +914,79 @@ function Tt({ config: i = {}, children: e }) {
|
|
|
993
914
|
refreshToken: J.refreshToken,
|
|
994
915
|
expiresIn: J.expiresIn
|
|
995
916
|
}), J.user) {
|
|
996
|
-
Z.setUser(J.user),
|
|
917
|
+
Z.setUser(J.user), p(J.user);
|
|
997
918
|
try {
|
|
998
|
-
await
|
|
999
|
-
} catch (
|
|
1000
|
-
console.warn("Failed to load complete user data after login:",
|
|
919
|
+
await x();
|
|
920
|
+
} catch (de) {
|
|
921
|
+
console.warn("Failed to load complete user data after login:", de);
|
|
1001
922
|
}
|
|
1002
923
|
}
|
|
1003
|
-
return
|
|
1004
|
-
},
|
|
1005
|
-
const { email:
|
|
1006
|
-
if (!
|
|
924
|
+
return le && Y && Y !== o && g(Y), J;
|
|
925
|
+
}, c = async (F) => {
|
|
926
|
+
const { email: N, phoneNumber: _, name: W, password: X, lastName: Y, tenantId: Z } = F;
|
|
927
|
+
if (!N && !_)
|
|
1007
928
|
throw new Error("Either email or phoneNumber is required");
|
|
1008
|
-
if (!
|
|
929
|
+
if (!W || !X)
|
|
1009
930
|
throw new Error("Name and password are required");
|
|
1010
931
|
const J = Z ?? (s == null ? void 0 : s.id);
|
|
1011
|
-
return await
|
|
1012
|
-
email:
|
|
1013
|
-
phoneNumber:
|
|
1014
|
-
name:
|
|
932
|
+
return await E.signup({
|
|
933
|
+
email: N,
|
|
934
|
+
phoneNumber: _,
|
|
935
|
+
name: W,
|
|
1015
936
|
password: X,
|
|
1016
937
|
tenantId: J,
|
|
1017
938
|
lastName: Y,
|
|
1018
939
|
appId: t
|
|
1019
940
|
});
|
|
1020
|
-
},
|
|
1021
|
-
const { email:
|
|
1022
|
-
if (!
|
|
941
|
+
}, S = async (F) => {
|
|
942
|
+
const { email: N, phoneNumber: _, name: W, password: X, tenantName: Y, lastName: Z } = F;
|
|
943
|
+
if (!N && !_)
|
|
1023
944
|
throw new Error("Either email or phoneNumber is required");
|
|
1024
|
-
if (!
|
|
945
|
+
if (!W || !X || !Y)
|
|
1025
946
|
throw new Error("Name, password, and tenantName are required");
|
|
1026
|
-
return await
|
|
1027
|
-
email:
|
|
1028
|
-
phoneNumber:
|
|
1029
|
-
name:
|
|
947
|
+
return await E.signupTenantAdmin({
|
|
948
|
+
email: N,
|
|
949
|
+
phoneNumber: _,
|
|
950
|
+
name: W,
|
|
1030
951
|
password: X,
|
|
1031
952
|
tenantName: Y,
|
|
1032
953
|
appId: t,
|
|
1033
954
|
lastName: Z
|
|
1034
955
|
});
|
|
1035
|
-
}, G = async (
|
|
1036
|
-
const { currentPassword:
|
|
1037
|
-
await
|
|
1038
|
-
}, ee = async (
|
|
1039
|
-
const { email:
|
|
1040
|
-
if (!
|
|
956
|
+
}, G = async (F) => {
|
|
957
|
+
const { currentPassword: N, newPassword: _ } = F, W = await u.getAuthHeaders();
|
|
958
|
+
await E.changePassword({ currentPassword: N, newPassword: _ }, W);
|
|
959
|
+
}, ee = async (F) => {
|
|
960
|
+
const { email: N, tenantId: _ } = F, W = _ ?? (s == null ? void 0 : s.id);
|
|
961
|
+
if (!W)
|
|
1041
962
|
throw new Error("tenantId is required for password reset");
|
|
1042
|
-
await
|
|
1043
|
-
}, z = async (
|
|
1044
|
-
const { token:
|
|
1045
|
-
await
|
|
1046
|
-
},
|
|
1047
|
-
const { email:
|
|
963
|
+
await E.requestPasswordReset({ email: N, tenantId: W });
|
|
964
|
+
}, z = async (F) => {
|
|
965
|
+
const { token: N, newPassword: _ } = F;
|
|
966
|
+
await E.confirmPasswordReset({ token: N, newPassword: _ });
|
|
967
|
+
}, H = async (F) => {
|
|
968
|
+
const { email: N, frontendUrl: _, name: W, lastName: X, tenantId: Y } = F, Z = Y ?? (s == null ? void 0 : s.id);
|
|
1048
969
|
if (!Z)
|
|
1049
970
|
throw new Error("tenantId is required for magic link authentication");
|
|
1050
|
-
return await
|
|
1051
|
-
email:
|
|
971
|
+
return await E.sendMagicLink({
|
|
972
|
+
email: N,
|
|
1052
973
|
tenantId: Z,
|
|
1053
|
-
frontendUrl:
|
|
1054
|
-
name:
|
|
974
|
+
frontendUrl: _,
|
|
975
|
+
name: W,
|
|
1055
976
|
lastName: X,
|
|
1056
977
|
appId: t
|
|
1057
978
|
});
|
|
1058
|
-
}, O = async (
|
|
1059
|
-
const { token:
|
|
979
|
+
}, O = async (F) => {
|
|
980
|
+
const { token: N, email: _, tenantSlug: W } = F;
|
|
1060
981
|
let X = s == null ? void 0 : s.id, Y = o, Z = u;
|
|
1061
|
-
|
|
1062
|
-
const J = await
|
|
1063
|
-
token:
|
|
1064
|
-
email:
|
|
982
|
+
W && (X = (await new ue(M, t).getPublicTenantInfo(W)).id, Y = W);
|
|
983
|
+
const J = await E.verifyMagicLink({
|
|
984
|
+
token: N,
|
|
985
|
+
email: _,
|
|
1065
986
|
appId: t,
|
|
1066
987
|
tenantId: X
|
|
1067
|
-
}),
|
|
1068
|
-
if (
|
|
988
|
+
}), le = W && W !== o;
|
|
989
|
+
if (le && (Z = new ye({
|
|
1069
990
|
tenantSlug: Y,
|
|
1070
991
|
baseUrl: r
|
|
1071
992
|
})), Z.setTokens({
|
|
@@ -1073,136 +994,136 @@ function Tt({ config: i = {}, children: e }) {
|
|
|
1073
994
|
refreshToken: J.refreshToken,
|
|
1074
995
|
expiresIn: J.expiresIn
|
|
1075
996
|
}), J.user) {
|
|
1076
|
-
Z.setUser(J.user),
|
|
997
|
+
Z.setUser(J.user), p(J.user);
|
|
1077
998
|
try {
|
|
1078
|
-
await
|
|
1079
|
-
} catch (
|
|
1080
|
-
console.warn("Failed to load complete user data after magic link login:",
|
|
999
|
+
await x();
|
|
1000
|
+
} catch (de) {
|
|
1001
|
+
console.warn("Failed to load complete user data after magic link login:", de);
|
|
1081
1002
|
}
|
|
1082
1003
|
}
|
|
1083
|
-
return
|
|
1004
|
+
return le && Y && Y !== o && g(Y), J;
|
|
1084
1005
|
}, D = async () => {
|
|
1085
|
-
const
|
|
1086
|
-
if (!(
|
|
1006
|
+
const F = u.getTokens();
|
|
1007
|
+
if (!(F != null && F.refreshToken))
|
|
1087
1008
|
throw new Error("No refresh token available");
|
|
1088
|
-
const
|
|
1089
|
-
refreshToken:
|
|
1009
|
+
const N = await E.refreshToken({
|
|
1010
|
+
refreshToken: F.refreshToken
|
|
1090
1011
|
});
|
|
1091
1012
|
u.setTokens({
|
|
1092
|
-
accessToken:
|
|
1093
|
-
refreshToken:
|
|
1094
|
-
expiresIn:
|
|
1013
|
+
accessToken: N.accessToken,
|
|
1014
|
+
refreshToken: N.refreshToken || F.refreshToken,
|
|
1015
|
+
expiresIn: N.expiresIn
|
|
1095
1016
|
});
|
|
1096
|
-
},
|
|
1097
|
-
u.clearSession(),
|
|
1098
|
-
}, ge = (
|
|
1099
|
-
u.setTokens(
|
|
1100
|
-
},
|
|
1101
|
-
u.clearSession(),
|
|
1102
|
-
},
|
|
1017
|
+
}, K = () => {
|
|
1018
|
+
u.clearSession(), p(null), C(null);
|
|
1019
|
+
}, ge = (F) => {
|
|
1020
|
+
u.setTokens(F);
|
|
1021
|
+
}, Re = () => u.hasValidSession(), Ce = () => {
|
|
1022
|
+
u.clearSession(), p(null), C(null);
|
|
1023
|
+
}, $e = async () => {
|
|
1103
1024
|
if (t)
|
|
1104
1025
|
try {
|
|
1105
1026
|
T(!0);
|
|
1106
|
-
const { roles:
|
|
1107
|
-
A(
|
|
1108
|
-
} catch (
|
|
1109
|
-
console.error("Failed to fetch roles:",
|
|
1027
|
+
const { roles: F } = await V.getRolesByApp(t);
|
|
1028
|
+
A(F);
|
|
1029
|
+
} catch (F) {
|
|
1030
|
+
console.error("Failed to fetch roles:", F);
|
|
1110
1031
|
} finally {
|
|
1111
1032
|
T(!1);
|
|
1112
1033
|
}
|
|
1113
1034
|
}, Fe = async () => {
|
|
1114
|
-
await
|
|
1115
|
-
}, me = (
|
|
1116
|
-
if (!
|
|
1035
|
+
await $e();
|
|
1036
|
+
}, me = (F) => {
|
|
1037
|
+
if (!v || v.length === 0)
|
|
1117
1038
|
return !1;
|
|
1118
|
-
if (typeof
|
|
1119
|
-
return
|
|
1120
|
-
const
|
|
1121
|
-
return
|
|
1039
|
+
if (typeof F == "string")
|
|
1040
|
+
return v.includes(F);
|
|
1041
|
+
const N = `${F.resource}.${F.action}`;
|
|
1042
|
+
return v.includes(N);
|
|
1122
1043
|
};
|
|
1123
1044
|
return {
|
|
1124
1045
|
// RFC-003: Authentication state
|
|
1125
|
-
isAuthenticated:
|
|
1046
|
+
isAuthenticated: I,
|
|
1126
1047
|
sessionManager: u,
|
|
1127
|
-
authenticatedHttpService:
|
|
1128
|
-
login:
|
|
1129
|
-
signup:
|
|
1130
|
-
signupTenantAdmin:
|
|
1131
|
-
sendMagicLink:
|
|
1048
|
+
authenticatedHttpService: M,
|
|
1049
|
+
login: d,
|
|
1050
|
+
signup: c,
|
|
1051
|
+
signupTenantAdmin: S,
|
|
1052
|
+
sendMagicLink: H,
|
|
1132
1053
|
verifyMagicLink: O,
|
|
1133
1054
|
changePassword: G,
|
|
1134
1055
|
requestPasswordReset: ee,
|
|
1135
1056
|
confirmPasswordReset: z,
|
|
1136
1057
|
refreshToken: D,
|
|
1137
|
-
logout:
|
|
1058
|
+
logout: K,
|
|
1138
1059
|
setTokens: ge,
|
|
1139
|
-
hasValidSession:
|
|
1140
|
-
clearSession:
|
|
1141
|
-
currentUser:
|
|
1060
|
+
hasValidSession: Re,
|
|
1061
|
+
clearSession: Ce,
|
|
1062
|
+
currentUser: f,
|
|
1142
1063
|
isUserLoading: h,
|
|
1143
|
-
userError:
|
|
1144
|
-
loadUserData:
|
|
1145
|
-
refreshUser:
|
|
1146
|
-
userRole:
|
|
1147
|
-
userPermissions:
|
|
1148
|
-
availableRoles:
|
|
1149
|
-
rolesLoading:
|
|
1064
|
+
userError: R,
|
|
1065
|
+
loadUserData: x,
|
|
1066
|
+
refreshUser: b,
|
|
1067
|
+
userRole: j,
|
|
1068
|
+
userPermissions: v,
|
|
1069
|
+
availableRoles: y,
|
|
1070
|
+
rolesLoading: w,
|
|
1150
1071
|
hasPermission: me,
|
|
1151
|
-
hasAnyPermission: (
|
|
1152
|
-
hasAllPermissions: (
|
|
1153
|
-
getUserPermissionStrings: () =>
|
|
1072
|
+
hasAnyPermission: (F) => F.some((N) => me(N)),
|
|
1073
|
+
hasAllPermissions: (F) => F.every((N) => me(N)),
|
|
1074
|
+
getUserPermissionStrings: () => v || [],
|
|
1154
1075
|
refreshRoles: Fe
|
|
1155
1076
|
};
|
|
1156
1077
|
}, [
|
|
1157
|
-
|
|
1078
|
+
I,
|
|
1158
1079
|
u,
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1080
|
+
M,
|
|
1081
|
+
E,
|
|
1082
|
+
q,
|
|
1083
|
+
V,
|
|
1163
1084
|
t,
|
|
1164
1085
|
s,
|
|
1165
1086
|
o,
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1087
|
+
g,
|
|
1088
|
+
y,
|
|
1089
|
+
f,
|
|
1169
1090
|
h,
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1091
|
+
R,
|
|
1092
|
+
j,
|
|
1093
|
+
v,
|
|
1094
|
+
U,
|
|
1095
|
+
L
|
|
1175
1096
|
]);
|
|
1176
1097
|
return te(() => {
|
|
1177
1098
|
!i.initialRoles && t && (async () => {
|
|
1178
1099
|
try {
|
|
1179
1100
|
T(!0);
|
|
1180
|
-
const
|
|
1181
|
-
A(
|
|
1182
|
-
} catch (
|
|
1183
|
-
console.error("Failed to fetch roles:",
|
|
1101
|
+
const b = new re(r), d = new ve(b), { roles: c } = await d.getRolesByApp(t);
|
|
1102
|
+
A(c);
|
|
1103
|
+
} catch (b) {
|
|
1104
|
+
console.error("Failed to fetch roles:", b);
|
|
1184
1105
|
} finally {
|
|
1185
1106
|
T(!1);
|
|
1186
1107
|
}
|
|
1187
1108
|
})();
|
|
1188
1109
|
}, [t, r, i.initialRoles]), te(() => {
|
|
1189
|
-
const
|
|
1190
|
-
|
|
1110
|
+
const x = u.getUser();
|
|
1111
|
+
x && u.hasValidSession() && p(x);
|
|
1191
1112
|
}, [u]), te(() => {
|
|
1192
|
-
!
|
|
1113
|
+
!f && !h && l.loadUserData().catch(() => {
|
|
1193
1114
|
});
|
|
1194
|
-
}, [
|
|
1195
|
-
if (!u.hasValidSession() || !
|
|
1115
|
+
}, [f, h, l]), te(() => {
|
|
1116
|
+
if (!u.hasValidSession() || !f)
|
|
1196
1117
|
return;
|
|
1197
|
-
const
|
|
1198
|
-
|
|
1118
|
+
const x = setInterval(() => {
|
|
1119
|
+
l.loadUserData().catch(() => {
|
|
1199
1120
|
});
|
|
1200
|
-
},
|
|
1201
|
-
return () => clearInterval(
|
|
1202
|
-
}, [u,
|
|
1121
|
+
}, L);
|
|
1122
|
+
return () => clearInterval(x);
|
|
1123
|
+
}, [u, f, l, L]), /* @__PURE__ */ n(Me.Provider, { value: l, children: e });
|
|
1203
1124
|
}
|
|
1204
|
-
function
|
|
1205
|
-
const i =
|
|
1125
|
+
function ae() {
|
|
1126
|
+
const i = ce(Me);
|
|
1206
1127
|
if (!i)
|
|
1207
1128
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
1208
1129
|
return i;
|
|
@@ -1287,58 +1208,58 @@ class ze {
|
|
|
1287
1208
|
})).data;
|
|
1288
1209
|
}
|
|
1289
1210
|
}
|
|
1290
|
-
const
|
|
1291
|
-
function
|
|
1292
|
-
const { baseUrl: t, appId: r } =
|
|
1293
|
-
const
|
|
1294
|
-
return new ze(
|
|
1295
|
-
}, [t]),
|
|
1211
|
+
const Ie = he(null);
|
|
1212
|
+
function It({ config: i = {}, children: e }) {
|
|
1213
|
+
const { baseUrl: t, appId: r } = oe(), { tenant: s } = se(), [o, g] = k([]), [y, A] = k(!1), [w, T] = k(null), f = Q(() => {
|
|
1214
|
+
const m = new re(t);
|
|
1215
|
+
return new ze(m);
|
|
1216
|
+
}, [t]), p = async () => {
|
|
1296
1217
|
if (!(s != null && s.id)) {
|
|
1297
|
-
|
|
1218
|
+
g([]);
|
|
1298
1219
|
return;
|
|
1299
1220
|
}
|
|
1300
1221
|
A(!0), T(null);
|
|
1301
1222
|
try {
|
|
1302
|
-
const
|
|
1303
|
-
|
|
1304
|
-
} catch (
|
|
1305
|
-
const
|
|
1306
|
-
T(
|
|
1223
|
+
const m = await f.getTenantFeatureFlags(s.id, r);
|
|
1224
|
+
g(m);
|
|
1225
|
+
} catch (m) {
|
|
1226
|
+
const R = m instanceof Error ? m.message : "Failed to fetch feature flags";
|
|
1227
|
+
T(R), i.onError && i.onError(m instanceof Error ? m : new Error(R));
|
|
1307
1228
|
} finally {
|
|
1308
1229
|
A(!1);
|
|
1309
1230
|
}
|
|
1310
1231
|
};
|
|
1311
1232
|
te(() => {
|
|
1312
|
-
|
|
1313
|
-
const
|
|
1314
|
-
return () => clearInterval(
|
|
1233
|
+
p();
|
|
1234
|
+
const m = i.refreshInterval || 5 * 60 * 1e3, R = setInterval(p, m);
|
|
1235
|
+
return () => clearInterval(R);
|
|
1315
1236
|
}, [s == null ? void 0 : s.id, i.refreshInterval]);
|
|
1316
1237
|
const h = Q(() => ({
|
|
1317
1238
|
featureFlags: o,
|
|
1318
|
-
loading:
|
|
1319
|
-
error:
|
|
1320
|
-
isEnabled: (
|
|
1321
|
-
const u = o.find((
|
|
1239
|
+
loading: y,
|
|
1240
|
+
error: w,
|
|
1241
|
+
isEnabled: (P) => {
|
|
1242
|
+
const u = o.find((M) => M.key === P);
|
|
1322
1243
|
return (u == null ? void 0 : u.value) === !0;
|
|
1323
1244
|
},
|
|
1324
|
-
getFlag: (
|
|
1325
|
-
getFlagState: (
|
|
1326
|
-
const u = o.find((
|
|
1245
|
+
getFlag: (P) => o.find((u) => u.key === P),
|
|
1246
|
+
getFlagState: (P) => {
|
|
1247
|
+
const u = o.find((M) => M.key === P);
|
|
1327
1248
|
return u ? u.value ? "enabled" : "disabled" : "not_found";
|
|
1328
1249
|
},
|
|
1329
1250
|
refresh: async () => {
|
|
1330
|
-
await
|
|
1251
|
+
await p();
|
|
1331
1252
|
}
|
|
1332
|
-
}), [o,
|
|
1333
|
-
return /* @__PURE__ */ n(
|
|
1253
|
+
}), [o, y, w]);
|
|
1254
|
+
return /* @__PURE__ */ n(Ie.Provider, { value: h, children: e });
|
|
1334
1255
|
}
|
|
1335
1256
|
function Oe() {
|
|
1336
|
-
const i =
|
|
1257
|
+
const i = ce(Ie);
|
|
1337
1258
|
if (!i)
|
|
1338
1259
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1339
1260
|
return i;
|
|
1340
1261
|
}
|
|
1341
|
-
class
|
|
1262
|
+
class We {
|
|
1342
1263
|
constructor(e, t) {
|
|
1343
1264
|
this.httpService = e, this.sessionManager = t;
|
|
1344
1265
|
}
|
|
@@ -1404,64 +1325,64 @@ class je {
|
|
|
1404
1325
|
)).data;
|
|
1405
1326
|
}
|
|
1406
1327
|
}
|
|
1407
|
-
const
|
|
1408
|
-
function
|
|
1409
|
-
const { baseUrl: t } =
|
|
1328
|
+
const Le = he(void 0);
|
|
1329
|
+
function Lt({ config: i = {}, children: e }) {
|
|
1330
|
+
const { baseUrl: t } = oe(), { tenant: r } = se(), [s, o] = k(null), [g, y] = k(!1), [A, w] = k(null), T = Q(() => {
|
|
1410
1331
|
const h = new re(t);
|
|
1411
|
-
return new
|
|
1412
|
-
}, [t]),
|
|
1332
|
+
return new We(h);
|
|
1333
|
+
}, [t]), f = async () => {
|
|
1413
1334
|
if (!(r != null && r.id)) {
|
|
1414
1335
|
o(null);
|
|
1415
1336
|
return;
|
|
1416
1337
|
}
|
|
1417
|
-
|
|
1338
|
+
y(!0), w(null);
|
|
1418
1339
|
try {
|
|
1419
1340
|
const h = await T.getTenantSubscriptionFeatures(r.id);
|
|
1420
1341
|
o(h);
|
|
1421
1342
|
} catch (h) {
|
|
1422
|
-
const
|
|
1423
|
-
|
|
1343
|
+
const m = h instanceof Error ? h.message : "Failed to fetch subscription";
|
|
1344
|
+
w(m), i.onError && i.onError(h instanceof Error ? h : new Error(m));
|
|
1424
1345
|
} finally {
|
|
1425
|
-
|
|
1346
|
+
y(!1);
|
|
1426
1347
|
}
|
|
1427
1348
|
};
|
|
1428
1349
|
te(() => {
|
|
1429
|
-
if (
|
|
1430
|
-
const h = i.refreshInterval || 10 * 60 * 1e3,
|
|
1431
|
-
return () => clearInterval(
|
|
1350
|
+
if (f(), !i.refreshInterval) return;
|
|
1351
|
+
const h = i.refreshInterval || 10 * 60 * 1e3, m = setInterval(f, h);
|
|
1352
|
+
return () => clearInterval(m);
|
|
1432
1353
|
}, [r == null ? void 0 : r.id, i.refreshInterval]);
|
|
1433
|
-
const
|
|
1354
|
+
const p = Q(() => {
|
|
1434
1355
|
const h = (s == null ? void 0 : s.features) || [];
|
|
1435
1356
|
return {
|
|
1436
1357
|
subscription: s,
|
|
1437
1358
|
features: h,
|
|
1438
|
-
loading:
|
|
1359
|
+
loading: g,
|
|
1439
1360
|
error: A,
|
|
1440
1361
|
isFeatureEnabled: (u) => {
|
|
1441
|
-
const
|
|
1442
|
-
return
|
|
1362
|
+
const M = h.find((E) => E.key === u);
|
|
1363
|
+
return M ? M.type === "BOOLEAN" || M.type === "boolean" ? M.value === !0 : !!M.value : !1;
|
|
1443
1364
|
},
|
|
1444
|
-
getFeature: (u) => h.find((
|
|
1445
|
-
getFeatureValue: (u,
|
|
1446
|
-
const
|
|
1447
|
-
return
|
|
1365
|
+
getFeature: (u) => h.find((M) => M.key === u),
|
|
1366
|
+
getFeatureValue: (u, M) => {
|
|
1367
|
+
const E = h.find((q) => q.key === u);
|
|
1368
|
+
return E ? E.value : M;
|
|
1448
1369
|
},
|
|
1449
1370
|
hasAllowedPlan: (u) => !s || !s.isActive ? !1 : u.includes(s.planId),
|
|
1450
1371
|
refresh: async () => {
|
|
1451
|
-
await
|
|
1372
|
+
await f();
|
|
1452
1373
|
}
|
|
1453
1374
|
};
|
|
1454
|
-
}, [s,
|
|
1455
|
-
return /* @__PURE__ */ n(
|
|
1375
|
+
}, [s, g, A]);
|
|
1376
|
+
return /* @__PURE__ */ n(Le.Provider, { value: p, children: e });
|
|
1456
1377
|
}
|
|
1457
|
-
function
|
|
1458
|
-
const i =
|
|
1378
|
+
function je() {
|
|
1379
|
+
const i = ce(Le);
|
|
1459
1380
|
if (i === void 0)
|
|
1460
1381
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1461
1382
|
return i;
|
|
1462
1383
|
}
|
|
1463
1384
|
var ie = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(ie || {});
|
|
1464
|
-
const
|
|
1385
|
+
const xe = () => /* @__PURE__ */ a(
|
|
1465
1386
|
"div",
|
|
1466
1387
|
{
|
|
1467
1388
|
style: {
|
|
@@ -1498,11 +1419,11 @@ const ve = () => /* @__PURE__ */ l(
|
|
|
1498
1419
|
)
|
|
1499
1420
|
]
|
|
1500
1421
|
}
|
|
1501
|
-
),
|
|
1422
|
+
), ke = ({
|
|
1502
1423
|
userType: i,
|
|
1503
1424
|
minUserType: e,
|
|
1504
1425
|
missingPermissions: t
|
|
1505
|
-
}) => /* @__PURE__ */
|
|
1426
|
+
}) => /* @__PURE__ */ a(
|
|
1506
1427
|
"div",
|
|
1507
1428
|
{
|
|
1508
1429
|
style: {
|
|
@@ -1520,26 +1441,26 @@ const ve = () => /* @__PURE__ */ l(
|
|
|
1520
1441
|
children: [
|
|
1521
1442
|
/* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
|
|
1522
1443
|
/* @__PURE__ */ n("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
|
|
1523
|
-
e && i ? /* @__PURE__ */
|
|
1524
|
-
/* @__PURE__ */
|
|
1444
|
+
e && i ? /* @__PURE__ */ a(B, { children: [
|
|
1445
|
+
/* @__PURE__ */ a("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
|
|
1525
1446
|
"This content requires ",
|
|
1526
1447
|
/* @__PURE__ */ n("strong", { children: e }),
|
|
1527
1448
|
" access level or higher."
|
|
1528
1449
|
] }),
|
|
1529
|
-
/* @__PURE__ */
|
|
1450
|
+
/* @__PURE__ */ a("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1530
1451
|
"Your current access level: ",
|
|
1531
1452
|
/* @__PURE__ */ n("strong", { children: i })
|
|
1532
1453
|
] })
|
|
1533
|
-
] }) : /* @__PURE__ */
|
|
1454
|
+
] }) : /* @__PURE__ */ a(B, { children: [
|
|
1534
1455
|
/* @__PURE__ */ n("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
|
|
1535
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1456
|
+
t && t.length > 0 && /* @__PURE__ */ a("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1536
1457
|
"Required permissions: ",
|
|
1537
1458
|
/* @__PURE__ */ n("strong", { children: t.join(", ") })
|
|
1538
1459
|
] })
|
|
1539
1460
|
] })
|
|
1540
1461
|
]
|
|
1541
1462
|
}
|
|
1542
|
-
),
|
|
1463
|
+
), Ve = (i, e) => {
|
|
1543
1464
|
const t = {
|
|
1544
1465
|
[ie.USER]: 1,
|
|
1545
1466
|
[ie.TENANT_ADMIN]: 2,
|
|
@@ -1547,26 +1468,26 @@ const ve = () => /* @__PURE__ */ l(
|
|
|
1547
1468
|
};
|
|
1548
1469
|
return t[i] >= t[e];
|
|
1549
1470
|
};
|
|
1550
|
-
function
|
|
1471
|
+
function Et({
|
|
1551
1472
|
children: i,
|
|
1552
1473
|
fallback: e,
|
|
1553
1474
|
minUserType: t,
|
|
1554
1475
|
requiredPermissions: r,
|
|
1555
1476
|
requireAllPermissions: s = !1
|
|
1556
1477
|
}) {
|
|
1557
|
-
const { hasValidSession: o, sessionManager:
|
|
1478
|
+
const { hasValidSession: o, sessionManager: g, hasPermission: y, hasAnyPermission: A, hasAllPermissions: w } = ae();
|
|
1558
1479
|
if (!o())
|
|
1559
|
-
return /* @__PURE__ */ n(
|
|
1560
|
-
const T =
|
|
1480
|
+
return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(xe, {}) });
|
|
1481
|
+
const T = g.getUser();
|
|
1561
1482
|
if (!T)
|
|
1562
|
-
return /* @__PURE__ */ n(
|
|
1563
|
-
if (t && !
|
|
1564
|
-
return /* @__PURE__ */ n(
|
|
1565
|
-
if (r && r.length > 0 && !(s ?
|
|
1566
|
-
const
|
|
1567
|
-
return /* @__PURE__ */ n(
|
|
1568
|
-
}
|
|
1569
|
-
return /* @__PURE__ */ n(
|
|
1483
|
+
return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(xe, {}) });
|
|
1484
|
+
if (t && !Ve(T.userType, t))
|
|
1485
|
+
return /* @__PURE__ */ n(ke, { userType: T.userType, minUserType: t });
|
|
1486
|
+
if (r && r.length > 0 && !(s ? w(r) : A(r))) {
|
|
1487
|
+
const p = r.filter((h) => !y(h)).map((h) => typeof h == "string" ? h : h.name);
|
|
1488
|
+
return /* @__PURE__ */ n(ke, { missingPermissions: p });
|
|
1489
|
+
}
|
|
1490
|
+
return /* @__PURE__ */ n(B, { children: i });
|
|
1570
1491
|
}
|
|
1571
1492
|
const Ge = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1572
1493
|
"div",
|
|
@@ -1581,7 +1502,7 @@ const Ge = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1581
1502
|
backgroundColor: "#f9fafb",
|
|
1582
1503
|
textAlign: "center"
|
|
1583
1504
|
},
|
|
1584
|
-
children: /* @__PURE__ */
|
|
1505
|
+
children: /* @__PURE__ */ a(
|
|
1585
1506
|
"div",
|
|
1586
1507
|
{
|
|
1587
1508
|
style: {
|
|
@@ -1595,7 +1516,7 @@ const Ge = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1595
1516
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
|
|
1596
1517
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
|
|
1597
1518
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
|
|
1598
|
-
/* @__PURE__ */
|
|
1519
|
+
/* @__PURE__ */ a("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1599
1520
|
"Redirecting to ",
|
|
1600
1521
|
i,
|
|
1601
1522
|
"..."
|
|
@@ -1604,7 +1525,7 @@ const Ge = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1604
1525
|
}
|
|
1605
1526
|
)
|
|
1606
1527
|
}
|
|
1607
|
-
),
|
|
1528
|
+
), Ae = ({
|
|
1608
1529
|
userType: i,
|
|
1609
1530
|
minUserType: e,
|
|
1610
1531
|
missingPermissions: t
|
|
@@ -1621,7 +1542,7 @@ const Ge = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1621
1542
|
backgroundColor: "#f9fafb",
|
|
1622
1543
|
textAlign: "center"
|
|
1623
1544
|
},
|
|
1624
|
-
children: /* @__PURE__ */
|
|
1545
|
+
children: /* @__PURE__ */ a(
|
|
1625
1546
|
"div",
|
|
1626
1547
|
{
|
|
1627
1548
|
style: {
|
|
@@ -1634,19 +1555,19 @@ const Ge = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1634
1555
|
children: [
|
|
1635
1556
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
|
|
1636
1557
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
|
|
1637
|
-
e && i ? /* @__PURE__ */
|
|
1638
|
-
/* @__PURE__ */
|
|
1558
|
+
e && i ? /* @__PURE__ */ a(B, { children: [
|
|
1559
|
+
/* @__PURE__ */ a("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
|
|
1639
1560
|
"This page requires ",
|
|
1640
1561
|
/* @__PURE__ */ n("strong", { children: e }),
|
|
1641
1562
|
" access level or higher."
|
|
1642
1563
|
] }),
|
|
1643
|
-
/* @__PURE__ */
|
|
1564
|
+
/* @__PURE__ */ a("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1644
1565
|
"Your current access level: ",
|
|
1645
1566
|
/* @__PURE__ */ n("strong", { children: i })
|
|
1646
1567
|
] })
|
|
1647
|
-
] }) : /* @__PURE__ */
|
|
1568
|
+
] }) : /* @__PURE__ */ a(B, { children: [
|
|
1648
1569
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
|
|
1649
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1570
|
+
t && t.length > 0 && /* @__PURE__ */ a("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1650
1571
|
"Required permissions: ",
|
|
1651
1572
|
/* @__PURE__ */ n("strong", { children: t.join(", ") })
|
|
1652
1573
|
] })
|
|
@@ -1655,7 +1576,7 @@ const Ge = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1655
1576
|
}
|
|
1656
1577
|
)
|
|
1657
1578
|
}
|
|
1658
|
-
),
|
|
1579
|
+
), _e = (i, e) => {
|
|
1659
1580
|
const t = {
|
|
1660
1581
|
[ie.USER]: 1,
|
|
1661
1582
|
[ie.TENANT_ADMIN]: 2,
|
|
@@ -1663,7 +1584,7 @@ const Ge = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1663
1584
|
};
|
|
1664
1585
|
return t[i] >= t[e];
|
|
1665
1586
|
};
|
|
1666
|
-
function
|
|
1587
|
+
function Rt({
|
|
1667
1588
|
children: i,
|
|
1668
1589
|
redirectTo: e = "/login",
|
|
1669
1590
|
minUserType: t,
|
|
@@ -1671,24 +1592,24 @@ function Et({
|
|
|
1671
1592
|
requireAllPermissions: s = !1,
|
|
1672
1593
|
fallback: o
|
|
1673
1594
|
}) {
|
|
1674
|
-
const { hasValidSession:
|
|
1675
|
-
if (!
|
|
1676
|
-
return o ? /* @__PURE__ */ n(
|
|
1595
|
+
const { hasValidSession: g, sessionManager: y, hasPermission: A, hasAnyPermission: w, hasAllPermissions: T } = ae(), f = we();
|
|
1596
|
+
if (!g())
|
|
1597
|
+
return o ? /* @__PURE__ */ n(B, { children: o }) : /* @__PURE__ */ a(B, { children: [
|
|
1677
1598
|
/* @__PURE__ */ n(Ge, { redirectPath: e }),
|
|
1678
|
-
/* @__PURE__ */ n(pe, { to: e, state: { from:
|
|
1599
|
+
/* @__PURE__ */ n(pe, { to: e, state: { from: f.pathname }, replace: !0 })
|
|
1679
1600
|
] });
|
|
1680
|
-
const
|
|
1681
|
-
if (!
|
|
1682
|
-
return /* @__PURE__ */ n(pe, { to: e, state: { from:
|
|
1683
|
-
if (t && !
|
|
1684
|
-
return /* @__PURE__ */ n(
|
|
1685
|
-
if (r && r.length > 0 && !(s ? T(r) :
|
|
1686
|
-
const
|
|
1687
|
-
return /* @__PURE__ */ n(
|
|
1688
|
-
}
|
|
1689
|
-
return /* @__PURE__ */ n(
|
|
1601
|
+
const p = y.getUser();
|
|
1602
|
+
if (!p)
|
|
1603
|
+
return /* @__PURE__ */ n(pe, { to: e, state: { from: f.pathname }, replace: !0 });
|
|
1604
|
+
if (t && !_e(p.userType, t))
|
|
1605
|
+
return /* @__PURE__ */ n(Ae, { userType: p.userType, minUserType: t });
|
|
1606
|
+
if (r && r.length > 0 && !(s ? T(r) : w(r))) {
|
|
1607
|
+
const m = r.filter((R) => !A(R)).map((R) => typeof R == "string" ? R : R.name);
|
|
1608
|
+
return /* @__PURE__ */ n(Ae, { missingPermissions: m });
|
|
1609
|
+
}
|
|
1610
|
+
return /* @__PURE__ */ n(B, { children: i });
|
|
1690
1611
|
}
|
|
1691
|
-
const
|
|
1612
|
+
const Ke = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1692
1613
|
"div",
|
|
1693
1614
|
{
|
|
1694
1615
|
style: {
|
|
@@ -1701,7 +1622,7 @@ const _e = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1701
1622
|
backgroundColor: "#f9fafb",
|
|
1702
1623
|
textAlign: "center"
|
|
1703
1624
|
},
|
|
1704
|
-
children: /* @__PURE__ */
|
|
1625
|
+
children: /* @__PURE__ */ a(
|
|
1705
1626
|
"div",
|
|
1706
1627
|
{
|
|
1707
1628
|
style: {
|
|
@@ -1715,7 +1636,7 @@ const _e = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1715
1636
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
|
|
1716
1637
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
|
|
1717
1638
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
|
|
1718
|
-
/* @__PURE__ */
|
|
1639
|
+
/* @__PURE__ */ a("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1719
1640
|
"Redirecting to ",
|
|
1720
1641
|
i,
|
|
1721
1642
|
"..."
|
|
@@ -1726,10 +1647,10 @@ const _e = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1726
1647
|
}
|
|
1727
1648
|
);
|
|
1728
1649
|
function Ct({ children: i, redirectTo: e = "/", fallback: t }) {
|
|
1729
|
-
const { tenant: r, isLoading: s, error: o } = se(),
|
|
1730
|
-
return s || o ? null : r ? /* @__PURE__ */ n(
|
|
1731
|
-
/* @__PURE__ */ n(
|
|
1732
|
-
/* @__PURE__ */ n(pe, { to: e, state: { from:
|
|
1650
|
+
const { tenant: r, isLoading: s, error: o } = se(), g = we();
|
|
1651
|
+
return s || o ? null : r ? /* @__PURE__ */ n(B, { children: i }) : t ? /* @__PURE__ */ n(B, { children: t }) : /* @__PURE__ */ a(B, { children: [
|
|
1652
|
+
/* @__PURE__ */ n(Ke, { redirectPath: e }),
|
|
1653
|
+
/* @__PURE__ */ n(pe, { to: e, state: { from: g.pathname }, replace: !0 })
|
|
1733
1654
|
] });
|
|
1734
1655
|
}
|
|
1735
1656
|
const Je = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
@@ -1745,7 +1666,7 @@ const Je = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1745
1666
|
backgroundColor: "#f9fafb",
|
|
1746
1667
|
textAlign: "center"
|
|
1747
1668
|
},
|
|
1748
|
-
children: /* @__PURE__ */
|
|
1669
|
+
children: /* @__PURE__ */ a(
|
|
1749
1670
|
"div",
|
|
1750
1671
|
{
|
|
1751
1672
|
style: {
|
|
@@ -1759,7 +1680,7 @@ const Je = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1759
1680
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
|
|
1760
1681
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
|
|
1761
1682
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
|
|
1762
|
-
/* @__PURE__ */
|
|
1683
|
+
/* @__PURE__ */ a("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1763
1684
|
"Redirecting to ",
|
|
1764
1685
|
i,
|
|
1765
1686
|
"..."
|
|
@@ -1769,14 +1690,14 @@ const Je = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1769
1690
|
)
|
|
1770
1691
|
}
|
|
1771
1692
|
);
|
|
1772
|
-
function
|
|
1773
|
-
const { tenant: r, isLoading: s, error: o } = se(),
|
|
1774
|
-
return s || o ? null : r ? t ? /* @__PURE__ */ n(
|
|
1693
|
+
function $t({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
|
|
1694
|
+
const { tenant: r, isLoading: s, error: o } = se(), g = we();
|
|
1695
|
+
return s || o ? null : r ? t ? /* @__PURE__ */ n(B, { children: t }) : /* @__PURE__ */ a(B, { children: [
|
|
1775
1696
|
/* @__PURE__ */ n(Je, { redirectPath: e }),
|
|
1776
|
-
/* @__PURE__ */ n(pe, { to: e, state: { from:
|
|
1777
|
-
] }) : /* @__PURE__ */ n(
|
|
1697
|
+
/* @__PURE__ */ n(pe, { to: e, state: { from: g.pathname }, replace: !0 })
|
|
1698
|
+
] }) : /* @__PURE__ */ n(B, { children: i });
|
|
1778
1699
|
}
|
|
1779
|
-
const Ye = () => /* @__PURE__ */
|
|
1700
|
+
const Ye = () => /* @__PURE__ */ a(
|
|
1780
1701
|
"div",
|
|
1781
1702
|
{
|
|
1782
1703
|
style: {
|
|
@@ -1793,14 +1714,14 @@ const Ye = () => /* @__PURE__ */ l(
|
|
|
1793
1714
|
]
|
|
1794
1715
|
}
|
|
1795
1716
|
);
|
|
1796
|
-
function
|
|
1717
|
+
function Ft({
|
|
1797
1718
|
children: i,
|
|
1798
1719
|
fallback: e = /* @__PURE__ */ n(Ye, {}),
|
|
1799
1720
|
allowedPlans: t,
|
|
1800
1721
|
requiredFeature: r
|
|
1801
1722
|
}) {
|
|
1802
|
-
const { subscription: s, hasAllowedPlan: o, isFeatureEnabled:
|
|
1803
|
-
return
|
|
1723
|
+
const { subscription: s, hasAllowedPlan: o, isFeatureEnabled: g, loading: y } = je();
|
|
1724
|
+
return y ? /* @__PURE__ */ n(
|
|
1804
1725
|
"div",
|
|
1805
1726
|
{
|
|
1806
1727
|
style: {
|
|
@@ -1810,9 +1731,9 @@ function Lt({
|
|
|
1810
1731
|
},
|
|
1811
1732
|
children: "Loading subscription..."
|
|
1812
1733
|
}
|
|
1813
|
-
) : s ? s.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ n(
|
|
1734
|
+
) : s ? s.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ n(B, { children: e }) : r && !g(r) ? /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: i }) : /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: e });
|
|
1814
1735
|
}
|
|
1815
|
-
const Qe = ({ flagName: i }) => /* @__PURE__ */
|
|
1736
|
+
const Qe = ({ flagName: i }) => /* @__PURE__ */ a(
|
|
1816
1737
|
"div",
|
|
1817
1738
|
{
|
|
1818
1739
|
style: {
|
|
@@ -1831,7 +1752,7 @@ const Qe = ({ flagName: i }) => /* @__PURE__ */ l(
|
|
|
1831
1752
|
children: [
|
|
1832
1753
|
/* @__PURE__ */ n("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
|
|
1833
1754
|
/* @__PURE__ */ n("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
|
|
1834
|
-
/* @__PURE__ */
|
|
1755
|
+
/* @__PURE__ */ a("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
|
|
1835
1756
|
'Feature flag "',
|
|
1836
1757
|
i,
|
|
1837
1758
|
'" is disabled'
|
|
@@ -1839,7 +1760,7 @@ const Qe = ({ flagName: i }) => /* @__PURE__ */ l(
|
|
|
1839
1760
|
]
|
|
1840
1761
|
}
|
|
1841
1762
|
);
|
|
1842
|
-
function
|
|
1763
|
+
function Dt({ name: i, children: e, fallback: t }) {
|
|
1843
1764
|
const { isEnabled: r, loading: s } = Oe();
|
|
1844
1765
|
return s ? /* @__PURE__ */ n(
|
|
1845
1766
|
"div",
|
|
@@ -1854,9 +1775,9 @@ function Ft({ name: i, children: e, fallback: t }) {
|
|
|
1854
1775
|
},
|
|
1855
1776
|
children: "Loading feature flags..."
|
|
1856
1777
|
}
|
|
1857
|
-
) : r(i) ? /* @__PURE__ */ n(
|
|
1778
|
+
) : r(i) ? /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: t || /* @__PURE__ */ n(Qe, { flagName: i }) });
|
|
1858
1779
|
}
|
|
1859
|
-
const Xe = () => /* @__PURE__ */
|
|
1780
|
+
const Xe = () => /* @__PURE__ */ a(
|
|
1860
1781
|
"svg",
|
|
1861
1782
|
{
|
|
1862
1783
|
width: "16",
|
|
@@ -1873,7 +1794,7 @@ const Xe = () => /* @__PURE__ */ l(
|
|
|
1873
1794
|
/* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "3" })
|
|
1874
1795
|
]
|
|
1875
1796
|
}
|
|
1876
|
-
), Ze = () => /* @__PURE__ */
|
|
1797
|
+
), Ze = () => /* @__PURE__ */ a(
|
|
1877
1798
|
"svg",
|
|
1878
1799
|
{
|
|
1879
1800
|
width: "16",
|
|
@@ -2014,128 +1935,128 @@ const Xe = () => /* @__PURE__ */ l(
|
|
|
2014
1935
|
fontSize: "0.875rem"
|
|
2015
1936
|
}
|
|
2016
1937
|
};
|
|
2017
|
-
function
|
|
1938
|
+
function Ht({
|
|
2018
1939
|
copy: i = {},
|
|
2019
1940
|
styles: e = {},
|
|
2020
1941
|
icons: t = {},
|
|
2021
1942
|
onSuccess: r,
|
|
2022
1943
|
onError: s,
|
|
2023
1944
|
onForgotPassword: o,
|
|
2024
|
-
onSignupClick:
|
|
2025
|
-
onMagicLinkClick:
|
|
1945
|
+
onSignupClick: g,
|
|
1946
|
+
onMagicLinkClick: y,
|
|
2026
1947
|
showForgotPassword: A = !0,
|
|
2027
|
-
showSignupLink:
|
|
1948
|
+
showSignupLink: w = !0,
|
|
2028
1949
|
showMagicLinkOption: T = !0,
|
|
2029
|
-
className:
|
|
1950
|
+
className: f
|
|
2030
1951
|
}) {
|
|
2031
|
-
const [
|
|
2032
|
-
const
|
|
2033
|
-
return
|
|
2034
|
-
},
|
|
2035
|
-
if (
|
|
2036
|
-
if (!(
|
|
2037
|
-
|
|
1952
|
+
const [p, h] = k(""), [m, R] = k(""), [C, U] = k(!1), [P, u] = k(!1), [M, E] = k(""), [q, V] = k({}), { login: $ } = ae(), { tenant: j } = se(), v = { ...tt, ...i }, I = { ...rt, ...e }, L = { ...et, ...t }, l = () => {
|
|
1953
|
+
const c = {};
|
|
1954
|
+
return p.trim() || (c.username = !0), m.trim() || (c.password = !0), V(c), Object.keys(c).length === 0;
|
|
1955
|
+
}, x = async (c) => {
|
|
1956
|
+
if (c.preventDefault(), !!l()) {
|
|
1957
|
+
if (!(j != null && j.id)) {
|
|
1958
|
+
E("Tenant not found");
|
|
2038
1959
|
return;
|
|
2039
1960
|
}
|
|
2040
|
-
u(!0),
|
|
1961
|
+
u(!0), E("");
|
|
2041
1962
|
try {
|
|
2042
|
-
const
|
|
2043
|
-
username:
|
|
2044
|
-
password:
|
|
1963
|
+
const S = await $({
|
|
1964
|
+
username: p,
|
|
1965
|
+
password: m
|
|
2045
1966
|
// tenantId inferred from context automatically
|
|
2046
1967
|
});
|
|
2047
|
-
r == null || r(
|
|
2048
|
-
} catch (
|
|
2049
|
-
const G =
|
|
2050
|
-
|
|
1968
|
+
r == null || r(S);
|
|
1969
|
+
} catch (S) {
|
|
1970
|
+
const G = S.message || v.errorMessage;
|
|
1971
|
+
E(G), s == null || s(G);
|
|
2051
1972
|
} finally {
|
|
2052
1973
|
u(!1);
|
|
2053
1974
|
}
|
|
2054
1975
|
}
|
|
2055
|
-
},
|
|
2056
|
-
...
|
|
2057
|
-
...
|
|
2058
|
-
}),
|
|
2059
|
-
...
|
|
2060
|
-
...
|
|
2061
|
-
...!
|
|
1976
|
+
}, b = (c) => ({
|
|
1977
|
+
...I.input,
|
|
1978
|
+
...q[c] ? I.inputError : {}
|
|
1979
|
+
}), d = () => ({
|
|
1980
|
+
...I.button,
|
|
1981
|
+
...P ? I.buttonLoading : {},
|
|
1982
|
+
...!p || !m || P ? I.buttonDisabled : {}
|
|
2062
1983
|
});
|
|
2063
|
-
return /* @__PURE__ */
|
|
2064
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2065
|
-
/* @__PURE__ */
|
|
2066
|
-
/* @__PURE__ */
|
|
2067
|
-
/* @__PURE__ */ n("label", { style:
|
|
1984
|
+
return /* @__PURE__ */ a("div", { className: f, style: I.container, children: [
|
|
1985
|
+
/* @__PURE__ */ n("h2", { style: I.title, children: v.title }),
|
|
1986
|
+
/* @__PURE__ */ a("form", { onSubmit: x, style: I.form, children: [
|
|
1987
|
+
/* @__PURE__ */ a("div", { style: I.fieldGroup, children: [
|
|
1988
|
+
/* @__PURE__ */ n("label", { style: I.label, children: v.usernameLabel }),
|
|
2068
1989
|
/* @__PURE__ */ n(
|
|
2069
1990
|
"input",
|
|
2070
1991
|
{
|
|
2071
1992
|
id: "username",
|
|
2072
1993
|
name: "username",
|
|
2073
1994
|
type: "text",
|
|
2074
|
-
value:
|
|
2075
|
-
onChange: (
|
|
2076
|
-
h(
|
|
1995
|
+
value: p,
|
|
1996
|
+
onChange: (c) => {
|
|
1997
|
+
h(c.target.value), q.username && V((S) => ({ ...S, username: !1 }));
|
|
2077
1998
|
},
|
|
2078
|
-
placeholder:
|
|
2079
|
-
style:
|
|
2080
|
-
disabled:
|
|
1999
|
+
placeholder: v.usernamePlaceholder,
|
|
2000
|
+
style: b("username"),
|
|
2001
|
+
disabled: P
|
|
2081
2002
|
}
|
|
2082
2003
|
)
|
|
2083
2004
|
] }),
|
|
2084
|
-
/* @__PURE__ */
|
|
2085
|
-
/* @__PURE__ */ n("label", { style:
|
|
2086
|
-
/* @__PURE__ */
|
|
2005
|
+
/* @__PURE__ */ a("div", { style: I.fieldGroup, children: [
|
|
2006
|
+
/* @__PURE__ */ n("label", { style: I.label, children: v.passwordLabel }),
|
|
2007
|
+
/* @__PURE__ */ a("div", { style: I.inputContainer, children: [
|
|
2087
2008
|
/* @__PURE__ */ n(
|
|
2088
2009
|
"input",
|
|
2089
2010
|
{
|
|
2090
2011
|
id: "password",
|
|
2091
2012
|
name: "password",
|
|
2092
|
-
type:
|
|
2093
|
-
value:
|
|
2094
|
-
onChange: (
|
|
2095
|
-
|
|
2013
|
+
type: C ? "text" : "password",
|
|
2014
|
+
value: m,
|
|
2015
|
+
onChange: (c) => {
|
|
2016
|
+
R(c.target.value), q.password && V((S) => ({ ...S, password: !1 }));
|
|
2096
2017
|
},
|
|
2097
|
-
placeholder:
|
|
2018
|
+
placeholder: v.passwordPlaceholder,
|
|
2098
2019
|
style: {
|
|
2099
|
-
...
|
|
2020
|
+
...b("password"),
|
|
2100
2021
|
paddingRight: "2.5rem"
|
|
2101
2022
|
// Make room for the icon
|
|
2102
2023
|
},
|
|
2103
|
-
disabled:
|
|
2024
|
+
disabled: P
|
|
2104
2025
|
}
|
|
2105
2026
|
),
|
|
2106
2027
|
/* @__PURE__ */ n(
|
|
2107
2028
|
"button",
|
|
2108
2029
|
{
|
|
2109
2030
|
type: "button",
|
|
2110
|
-
onClick: () =>
|
|
2111
|
-
style:
|
|
2112
|
-
disabled:
|
|
2113
|
-
"aria-label":
|
|
2114
|
-
children:
|
|
2031
|
+
onClick: () => U(!C),
|
|
2032
|
+
style: I.passwordToggle,
|
|
2033
|
+
disabled: P,
|
|
2034
|
+
"aria-label": C ? "Hide password" : "Show password",
|
|
2035
|
+
children: C ? L.hidePassword : L.showPassword
|
|
2115
2036
|
}
|
|
2116
2037
|
)
|
|
2117
2038
|
] })
|
|
2118
2039
|
] }),
|
|
2119
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !
|
|
2120
|
-
|
|
2040
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !p || !m || P, style: d(), children: P ? v.loadingText : v.submitButton }),
|
|
2041
|
+
M && /* @__PURE__ */ n("div", { style: I.errorText, children: M })
|
|
2121
2042
|
] }),
|
|
2122
|
-
(A ||
|
|
2123
|
-
T && /* @__PURE__ */
|
|
2124
|
-
/* @__PURE__ */
|
|
2125
|
-
|
|
2043
|
+
(A || w || T) && /* @__PURE__ */ a("div", { style: I.linkContainer, children: [
|
|
2044
|
+
T && /* @__PURE__ */ a("div", { children: [
|
|
2045
|
+
/* @__PURE__ */ a("span", { style: I.divider, children: [
|
|
2046
|
+
v.magicLinkText,
|
|
2126
2047
|
" "
|
|
2127
2048
|
] }),
|
|
2128
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
2049
|
+
/* @__PURE__ */ n("a", { onClick: y, style: I.link, children: v.magicLinkLink })
|
|
2129
2050
|
] }),
|
|
2130
|
-
T && (A ||
|
|
2131
|
-
A && /* @__PURE__ */ n("a", { onClick: o, style:
|
|
2132
|
-
A &&
|
|
2133
|
-
|
|
2134
|
-
/* @__PURE__ */
|
|
2135
|
-
|
|
2051
|
+
T && (A || w) && /* @__PURE__ */ n("div", { style: I.divider, children: "•" }),
|
|
2052
|
+
A && /* @__PURE__ */ n("a", { onClick: o, style: I.link, children: v.forgotPasswordLink }),
|
|
2053
|
+
A && w && /* @__PURE__ */ n("div", { style: I.divider, children: "•" }),
|
|
2054
|
+
w && /* @__PURE__ */ a("div", { children: [
|
|
2055
|
+
/* @__PURE__ */ a("span", { style: I.divider, children: [
|
|
2056
|
+
v.signupText,
|
|
2136
2057
|
" "
|
|
2137
2058
|
] }),
|
|
2138
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
2059
|
+
/* @__PURE__ */ n("a", { onClick: g, style: I.link, children: v.signupLink })
|
|
2139
2060
|
] })
|
|
2140
2061
|
] })
|
|
2141
2062
|
] });
|
|
@@ -2265,69 +2186,69 @@ const nt = {
|
|
|
2265
2186
|
fontSize: "0.875rem"
|
|
2266
2187
|
}
|
|
2267
2188
|
};
|
|
2268
|
-
function
|
|
2189
|
+
function Nt({
|
|
2269
2190
|
copy: i = {},
|
|
2270
2191
|
styles: e = {},
|
|
2271
2192
|
signupType: t = "user",
|
|
2272
2193
|
onSuccess: r,
|
|
2273
2194
|
onError: s,
|
|
2274
2195
|
onLoginClick: o,
|
|
2275
|
-
onMagicLinkClick:
|
|
2276
|
-
showLoginLink:
|
|
2196
|
+
onMagicLinkClick: g,
|
|
2197
|
+
showLoginLink: y = !0,
|
|
2277
2198
|
showMagicLinkOption: A = !0,
|
|
2278
|
-
className:
|
|
2199
|
+
className: w
|
|
2279
2200
|
}) {
|
|
2280
|
-
const [T,
|
|
2201
|
+
const [T, f] = k(""), [p, h] = k(""), [m, R] = k(""), [C, U] = k(""), [P, u] = k(""), [M, E] = k(""), [q, V] = k(""), [$, j] = k(!1), [v, I] = k(""), [L, l] = k({}), { signup: x, signupTenantAdmin: b } = ae(), { tenant: d } = se(), c = { ...nt, ...i }, S = { ...st, ...e }, G = () => {
|
|
2281
2202
|
const D = {};
|
|
2282
|
-
return T.trim() || (D.name = !0), !
|
|
2203
|
+
return T.trim() || (D.name = !0), !m.trim() && !C.trim() && (D.email = !0, D.phoneNumber = !0), P.trim() || (D.password = !0), M.trim() || (D.confirmPassword = !0), t === "tenant" && !q.trim() && (D.tenantName = !0), l(D), Object.keys(D).length === 0;
|
|
2283
2204
|
}, ee = async (D) => {
|
|
2284
2205
|
if (D.preventDefault(), !!G()) {
|
|
2285
|
-
if (
|
|
2286
|
-
|
|
2206
|
+
if (P !== M) {
|
|
2207
|
+
I(c.passwordMismatchError), l({ confirmPassword: !0 });
|
|
2287
2208
|
return;
|
|
2288
2209
|
}
|
|
2289
|
-
if (t === "user" && !(
|
|
2290
|
-
|
|
2210
|
+
if (t === "user" && !(d != null && d.id)) {
|
|
2211
|
+
I("Tenant not found");
|
|
2291
2212
|
return;
|
|
2292
2213
|
}
|
|
2293
|
-
|
|
2214
|
+
j(!0), I("");
|
|
2294
2215
|
try {
|
|
2295
|
-
let
|
|
2296
|
-
t === "tenant" ?
|
|
2297
|
-
email:
|
|
2298
|
-
phoneNumber:
|
|
2216
|
+
let K;
|
|
2217
|
+
t === "tenant" ? K = await b({
|
|
2218
|
+
email: m || void 0,
|
|
2219
|
+
phoneNumber: C || void 0,
|
|
2299
2220
|
name: T,
|
|
2300
|
-
password:
|
|
2301
|
-
tenantName:
|
|
2302
|
-
lastName:
|
|
2303
|
-
}) :
|
|
2304
|
-
email:
|
|
2305
|
-
phoneNumber:
|
|
2221
|
+
password: P,
|
|
2222
|
+
tenantName: q,
|
|
2223
|
+
lastName: p || void 0
|
|
2224
|
+
}) : K = await x({
|
|
2225
|
+
email: m || void 0,
|
|
2226
|
+
phoneNumber: C || void 0,
|
|
2306
2227
|
name: T,
|
|
2307
|
-
password:
|
|
2308
|
-
tenantId:
|
|
2309
|
-
lastName:
|
|
2310
|
-
}), r == null || r(
|
|
2311
|
-
} catch (
|
|
2312
|
-
const ge =
|
|
2313
|
-
|
|
2228
|
+
password: P,
|
|
2229
|
+
tenantId: d.id,
|
|
2230
|
+
lastName: p || void 0
|
|
2231
|
+
}), r == null || r(K);
|
|
2232
|
+
} catch (K) {
|
|
2233
|
+
const ge = K.message || c.errorMessage;
|
|
2234
|
+
I(ge), s == null || s(ge);
|
|
2314
2235
|
} finally {
|
|
2315
|
-
|
|
2236
|
+
j(!1);
|
|
2316
2237
|
}
|
|
2317
2238
|
}
|
|
2318
2239
|
}, z = (D) => ({
|
|
2319
|
-
...
|
|
2320
|
-
...
|
|
2321
|
-
}),
|
|
2322
|
-
...
|
|
2323
|
-
|
|
2324
|
-
...!T || !
|
|
2325
|
-
}), O = T && (
|
|
2326
|
-
return /* @__PURE__ */
|
|
2327
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2328
|
-
/* @__PURE__ */
|
|
2329
|
-
/* @__PURE__ */
|
|
2330
|
-
/* @__PURE__ */ n("label", { style:
|
|
2240
|
+
...S.input,
|
|
2241
|
+
...L[D] ? S.inputError : {}
|
|
2242
|
+
}), H = () => ({
|
|
2243
|
+
...S.button,
|
|
2244
|
+
...$ ? S.buttonLoading : {},
|
|
2245
|
+
...!T || !m && !C || !P || !M || $ || t === "tenant" && !q ? S.buttonDisabled : {}
|
|
2246
|
+
}), O = T && (m || C) && P && M && (t === "user" || q);
|
|
2247
|
+
return /* @__PURE__ */ a("div", { className: w, style: S.container, children: [
|
|
2248
|
+
/* @__PURE__ */ n("h2", { style: S.title, children: c.title }),
|
|
2249
|
+
/* @__PURE__ */ a("form", { onSubmit: ee, style: S.form, children: [
|
|
2250
|
+
/* @__PURE__ */ a("div", { style: S.fieldGroup, children: [
|
|
2251
|
+
/* @__PURE__ */ n("label", { style: S.label, children: c.nameLabel }),
|
|
2331
2252
|
/* @__PURE__ */ n(
|
|
2332
2253
|
"input",
|
|
2333
2254
|
{
|
|
@@ -2336,63 +2257,63 @@ function Dt({
|
|
|
2336
2257
|
type: "text",
|
|
2337
2258
|
value: T,
|
|
2338
2259
|
onChange: (D) => {
|
|
2339
|
-
|
|
2260
|
+
f(D.target.value), L.name && l((K) => ({ ...K, name: !1 }));
|
|
2340
2261
|
},
|
|
2341
|
-
placeholder:
|
|
2262
|
+
placeholder: c.namePlaceholder,
|
|
2342
2263
|
style: z("name"),
|
|
2343
|
-
disabled:
|
|
2264
|
+
disabled: $
|
|
2344
2265
|
}
|
|
2345
2266
|
)
|
|
2346
2267
|
] }),
|
|
2347
|
-
/* @__PURE__ */
|
|
2348
|
-
/* @__PURE__ */ n("label", { style:
|
|
2268
|
+
/* @__PURE__ */ a("div", { style: S.fieldGroup, children: [
|
|
2269
|
+
/* @__PURE__ */ n("label", { style: S.label, children: c.lastNameLabel }),
|
|
2349
2270
|
/* @__PURE__ */ n(
|
|
2350
2271
|
"input",
|
|
2351
2272
|
{
|
|
2352
2273
|
id: "lastName",
|
|
2353
2274
|
name: "lastName",
|
|
2354
2275
|
type: "text",
|
|
2355
|
-
value:
|
|
2276
|
+
value: p,
|
|
2356
2277
|
onChange: (D) => h(D.target.value),
|
|
2357
|
-
placeholder:
|
|
2358
|
-
style:
|
|
2359
|
-
disabled:
|
|
2278
|
+
placeholder: c.lastNamePlaceholder,
|
|
2279
|
+
style: S.input,
|
|
2280
|
+
disabled: $
|
|
2360
2281
|
}
|
|
2361
2282
|
)
|
|
2362
2283
|
] }),
|
|
2363
|
-
/* @__PURE__ */
|
|
2364
|
-
/* @__PURE__ */ n("label", { style:
|
|
2284
|
+
/* @__PURE__ */ a("div", { style: S.fieldGroup, children: [
|
|
2285
|
+
/* @__PURE__ */ n("label", { style: S.label, children: c.emailLabel }),
|
|
2365
2286
|
/* @__PURE__ */ n(
|
|
2366
2287
|
"input",
|
|
2367
2288
|
{
|
|
2368
2289
|
id: "email",
|
|
2369
2290
|
name: "email",
|
|
2370
2291
|
type: "email",
|
|
2371
|
-
value:
|
|
2292
|
+
value: m,
|
|
2372
2293
|
onChange: (D) => {
|
|
2373
|
-
|
|
2294
|
+
R(D.target.value), L.email && l((K) => ({ ...K, email: !1, phoneNumber: !1 }));
|
|
2374
2295
|
},
|
|
2375
|
-
placeholder:
|
|
2296
|
+
placeholder: c.emailPlaceholder,
|
|
2376
2297
|
style: z("email"),
|
|
2377
|
-
disabled:
|
|
2298
|
+
disabled: $
|
|
2378
2299
|
}
|
|
2379
2300
|
)
|
|
2380
2301
|
] }),
|
|
2381
|
-
/* @__PURE__ */
|
|
2382
|
-
/* @__PURE__ */ n("label", { style:
|
|
2302
|
+
/* @__PURE__ */ a("div", { style: S.fieldGroup, children: [
|
|
2303
|
+
/* @__PURE__ */ n("label", { style: S.label, children: c.phoneNumberLabel }),
|
|
2383
2304
|
/* @__PURE__ */ n(
|
|
2384
2305
|
"input",
|
|
2385
2306
|
{
|
|
2386
2307
|
id: "phoneNumber",
|
|
2387
2308
|
name: "phoneNumber",
|
|
2388
2309
|
type: "tel",
|
|
2389
|
-
value:
|
|
2310
|
+
value: C,
|
|
2390
2311
|
onChange: (D) => {
|
|
2391
|
-
|
|
2312
|
+
U(D.target.value), L.phoneNumber && l((K) => ({ ...K, email: !1, phoneNumber: !1 }));
|
|
2392
2313
|
},
|
|
2393
|
-
placeholder:
|
|
2314
|
+
placeholder: c.phoneNumberPlaceholder,
|
|
2394
2315
|
style: z("phoneNumber"),
|
|
2395
|
-
disabled:
|
|
2316
|
+
disabled: $
|
|
2396
2317
|
}
|
|
2397
2318
|
)
|
|
2398
2319
|
] }),
|
|
@@ -2408,78 +2329,78 @@ function Dt({
|
|
|
2408
2329
|
children: "At least one contact method (email or phone) is required"
|
|
2409
2330
|
}
|
|
2410
2331
|
),
|
|
2411
|
-
/* @__PURE__ */
|
|
2412
|
-
/* @__PURE__ */ n("label", { style:
|
|
2332
|
+
/* @__PURE__ */ a("div", { style: S.fieldGroup, children: [
|
|
2333
|
+
/* @__PURE__ */ n("label", { style: S.label, children: c.passwordLabel }),
|
|
2413
2334
|
/* @__PURE__ */ n(
|
|
2414
2335
|
"input",
|
|
2415
2336
|
{
|
|
2416
2337
|
id: "password",
|
|
2417
2338
|
name: "password",
|
|
2418
2339
|
type: "password",
|
|
2419
|
-
value:
|
|
2340
|
+
value: P,
|
|
2420
2341
|
onChange: (D) => {
|
|
2421
|
-
u(D.target.value),
|
|
2342
|
+
u(D.target.value), L.password && l((K) => ({ ...K, password: !1 }));
|
|
2422
2343
|
},
|
|
2423
|
-
placeholder:
|
|
2344
|
+
placeholder: c.passwordPlaceholder,
|
|
2424
2345
|
style: z("password"),
|
|
2425
|
-
disabled:
|
|
2346
|
+
disabled: $
|
|
2426
2347
|
}
|
|
2427
2348
|
)
|
|
2428
2349
|
] }),
|
|
2429
|
-
/* @__PURE__ */
|
|
2430
|
-
/* @__PURE__ */ n("label", { style:
|
|
2350
|
+
/* @__PURE__ */ a("div", { style: S.fieldGroup, children: [
|
|
2351
|
+
/* @__PURE__ */ n("label", { style: S.label, children: c.confirmPasswordLabel }),
|
|
2431
2352
|
/* @__PURE__ */ n(
|
|
2432
2353
|
"input",
|
|
2433
2354
|
{
|
|
2434
2355
|
id: "confirmPassword",
|
|
2435
2356
|
name: "confirmPassword",
|
|
2436
2357
|
type: "password",
|
|
2437
|
-
value:
|
|
2358
|
+
value: M,
|
|
2438
2359
|
onChange: (D) => {
|
|
2439
|
-
|
|
2360
|
+
E(D.target.value), L.confirmPassword && l((K) => ({ ...K, confirmPassword: !1 })), v === c.passwordMismatchError && I("");
|
|
2440
2361
|
},
|
|
2441
|
-
placeholder:
|
|
2362
|
+
placeholder: c.confirmPasswordPlaceholder,
|
|
2442
2363
|
style: z("confirmPassword"),
|
|
2443
|
-
disabled:
|
|
2364
|
+
disabled: $
|
|
2444
2365
|
}
|
|
2445
2366
|
)
|
|
2446
2367
|
] }),
|
|
2447
|
-
t === "tenant" && /* @__PURE__ */
|
|
2448
|
-
/* @__PURE__ */ n("label", { style:
|
|
2368
|
+
t === "tenant" && /* @__PURE__ */ a("div", { style: S.fieldGroup, children: [
|
|
2369
|
+
/* @__PURE__ */ n("label", { style: S.label, children: c.tenantNameLabel }),
|
|
2449
2370
|
/* @__PURE__ */ n(
|
|
2450
2371
|
"input",
|
|
2451
2372
|
{
|
|
2452
2373
|
id: "tenantName",
|
|
2453
2374
|
name: "tenantName",
|
|
2454
2375
|
type: "text",
|
|
2455
|
-
value:
|
|
2376
|
+
value: q,
|
|
2456
2377
|
onChange: (D) => {
|
|
2457
|
-
|
|
2378
|
+
V(D.target.value), L.tenantName && l((K) => ({ ...K, tenantName: !1 }));
|
|
2458
2379
|
},
|
|
2459
|
-
placeholder:
|
|
2380
|
+
placeholder: c.tenantNamePlaceholder,
|
|
2460
2381
|
style: z("tenantName"),
|
|
2461
|
-
disabled:
|
|
2382
|
+
disabled: $
|
|
2462
2383
|
}
|
|
2463
2384
|
)
|
|
2464
2385
|
] }),
|
|
2465
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !O ||
|
|
2466
|
-
|
|
2386
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !O || $, style: H(), children: $ ? c.loadingText : c.submitButton }),
|
|
2387
|
+
v && /* @__PURE__ */ n("div", { style: S.errorText, children: v })
|
|
2467
2388
|
] }),
|
|
2468
|
-
(
|
|
2469
|
-
A && /* @__PURE__ */
|
|
2470
|
-
/* @__PURE__ */
|
|
2471
|
-
|
|
2389
|
+
(y || A) && /* @__PURE__ */ a("div", { style: S.linkContainer, children: [
|
|
2390
|
+
A && /* @__PURE__ */ a("div", { children: [
|
|
2391
|
+
/* @__PURE__ */ a("span", { style: S.divider, children: [
|
|
2392
|
+
c.magicLinkText,
|
|
2472
2393
|
" "
|
|
2473
2394
|
] }),
|
|
2474
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
2395
|
+
/* @__PURE__ */ n("a", { onClick: g, style: S.link, children: c.magicLinkLink })
|
|
2475
2396
|
] }),
|
|
2476
|
-
A &&
|
|
2477
|
-
|
|
2478
|
-
/* @__PURE__ */
|
|
2479
|
-
|
|
2397
|
+
A && y && /* @__PURE__ */ n("div", { style: S.divider, children: "•" }),
|
|
2398
|
+
y && /* @__PURE__ */ a("div", { children: [
|
|
2399
|
+
/* @__PURE__ */ a("span", { style: S.divider, children: [
|
|
2400
|
+
c.loginText,
|
|
2480
2401
|
" "
|
|
2481
2402
|
] }),
|
|
2482
|
-
/* @__PURE__ */ n("a", { onClick: o, style:
|
|
2403
|
+
/* @__PURE__ */ n("a", { onClick: o, style: S.link, children: c.loginLink })
|
|
2483
2404
|
] })
|
|
2484
2405
|
] })
|
|
2485
2406
|
] });
|
|
@@ -2605,84 +2526,84 @@ const it = {
|
|
|
2605
2526
|
fontSize: "0.875rem"
|
|
2606
2527
|
}
|
|
2607
2528
|
};
|
|
2608
|
-
function
|
|
2529
|
+
function Bt({
|
|
2609
2530
|
copy: i = {},
|
|
2610
2531
|
styles: e = {},
|
|
2611
2532
|
onSuccess: t,
|
|
2612
2533
|
onError: r,
|
|
2613
2534
|
onLoginClick: s,
|
|
2614
2535
|
onSignupClick: o,
|
|
2615
|
-
showTraditionalLinks:
|
|
2616
|
-
className:
|
|
2536
|
+
showTraditionalLinks: g = !0,
|
|
2537
|
+
className: y,
|
|
2617
2538
|
verifyToken: A,
|
|
2618
|
-
frontendUrl:
|
|
2539
|
+
frontendUrl: w
|
|
2619
2540
|
}) {
|
|
2620
|
-
const [T,
|
|
2541
|
+
const [T, f] = k(""), [p, h] = k(""), [m, R] = k(""), [C, U] = k(!1), [P, u] = k(!1), [M, E] = k(""), [q, V] = k(""), [$, j] = k({}), [v, I] = k(!1), { sendMagicLink: L, verifyMagicLink: l } = ae(), { tenant: x } = se(), b = { ...it, ...i }, d = { ...ot, ...e };
|
|
2621
2542
|
te(() => {
|
|
2622
|
-
A &&
|
|
2543
|
+
A && c(A);
|
|
2623
2544
|
}, [A]);
|
|
2624
|
-
const
|
|
2625
|
-
if (!
|
|
2626
|
-
|
|
2545
|
+
const c = async (H) => {
|
|
2546
|
+
if (!x || !T) {
|
|
2547
|
+
E("Missing tenant or email");
|
|
2627
2548
|
return;
|
|
2628
2549
|
}
|
|
2629
|
-
u(!0),
|
|
2550
|
+
u(!0), E("");
|
|
2630
2551
|
try {
|
|
2631
|
-
const O = await
|
|
2632
|
-
token:
|
|
2552
|
+
const O = await l({
|
|
2553
|
+
token: H,
|
|
2633
2554
|
email: T
|
|
2634
2555
|
// tenantId inferred from context automatically
|
|
2635
2556
|
});
|
|
2636
2557
|
t == null || t(O);
|
|
2637
2558
|
} catch (O) {
|
|
2638
2559
|
const D = O.message || "Failed to verify magic link";
|
|
2639
|
-
|
|
2560
|
+
E(D), r == null || r(D);
|
|
2640
2561
|
} finally {
|
|
2641
2562
|
u(!1);
|
|
2642
2563
|
}
|
|
2643
|
-
},
|
|
2644
|
-
const
|
|
2645
|
-
return T.trim() || (
|
|
2646
|
-
}, G = async (
|
|
2647
|
-
if (
|
|
2648
|
-
if (!(
|
|
2649
|
-
|
|
2564
|
+
}, S = () => {
|
|
2565
|
+
const H = {};
|
|
2566
|
+
return T.trim() || (H.email = !0), v && !p.trim() && (H.name = !0), j(H), Object.keys(H).length === 0;
|
|
2567
|
+
}, G = async (H) => {
|
|
2568
|
+
if (H.preventDefault(), !!S()) {
|
|
2569
|
+
if (!(x != null && x.id)) {
|
|
2570
|
+
E("Tenant not found");
|
|
2650
2571
|
return;
|
|
2651
2572
|
}
|
|
2652
|
-
|
|
2573
|
+
U(!0), E(""), V("");
|
|
2653
2574
|
try {
|
|
2654
|
-
const O =
|
|
2575
|
+
const O = w || (typeof window < "u" ? window.location.origin : ""), D = await L({
|
|
2655
2576
|
email: T,
|
|
2656
|
-
tenantId:
|
|
2577
|
+
tenantId: x.id,
|
|
2657
2578
|
frontendUrl: O,
|
|
2658
|
-
name:
|
|
2659
|
-
lastName:
|
|
2579
|
+
name: v ? p : void 0,
|
|
2580
|
+
lastName: v ? m : void 0
|
|
2660
2581
|
});
|
|
2661
|
-
|
|
2582
|
+
V(b.successMessage), t == null || t(D);
|
|
2662
2583
|
} catch (O) {
|
|
2663
|
-
const D = O.message ||
|
|
2664
|
-
|
|
2584
|
+
const D = O.message || b.errorMessage;
|
|
2585
|
+
E(D), r == null || r(D);
|
|
2665
2586
|
} finally {
|
|
2666
|
-
|
|
2587
|
+
U(!1);
|
|
2667
2588
|
}
|
|
2668
2589
|
}
|
|
2669
|
-
}, ee = (
|
|
2670
|
-
...
|
|
2671
|
-
|
|
2590
|
+
}, ee = (H) => ({
|
|
2591
|
+
...d.input,
|
|
2592
|
+
...$[H] ? d.inputError : {}
|
|
2672
2593
|
}), z = () => ({
|
|
2673
|
-
...
|
|
2674
|
-
...
|
|
2675
|
-
...!T ||
|
|
2594
|
+
...d.button,
|
|
2595
|
+
...C || P ? d.buttonLoading : {},
|
|
2596
|
+
...!T || C || P ? d.buttonDisabled : {}
|
|
2676
2597
|
});
|
|
2677
|
-
return
|
|
2678
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2598
|
+
return P ? /* @__PURE__ */ a("div", { className: y, style: d.container, children: [
|
|
2599
|
+
/* @__PURE__ */ n("h2", { style: d.title, children: b.verifyingText }),
|
|
2679
2600
|
/* @__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..." }) })
|
|
2680
|
-
] }) : /* @__PURE__ */
|
|
2681
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2682
|
-
/* @__PURE__ */ n("p", { style:
|
|
2683
|
-
/* @__PURE__ */
|
|
2684
|
-
/* @__PURE__ */
|
|
2685
|
-
/* @__PURE__ */ n("label", { style:
|
|
2601
|
+
] }) : /* @__PURE__ */ a("div", { className: y, style: d.container, children: [
|
|
2602
|
+
/* @__PURE__ */ n("h2", { style: d.title, children: b.title }),
|
|
2603
|
+
/* @__PURE__ */ n("p", { style: d.description, children: b.description }),
|
|
2604
|
+
/* @__PURE__ */ a("form", { onSubmit: G, style: d.form, children: [
|
|
2605
|
+
/* @__PURE__ */ a("div", { style: d.fieldGroup, children: [
|
|
2606
|
+
/* @__PURE__ */ n("label", { style: d.label, children: b.emailLabel }),
|
|
2686
2607
|
/* @__PURE__ */ n(
|
|
2687
2608
|
"input",
|
|
2688
2609
|
{
|
|
@@ -2690,20 +2611,20 @@ function Ht({
|
|
|
2690
2611
|
name: "email",
|
|
2691
2612
|
type: "email",
|
|
2692
2613
|
value: T,
|
|
2693
|
-
onChange: (
|
|
2694
|
-
|
|
2614
|
+
onChange: (H) => {
|
|
2615
|
+
f(H.target.value), $.email && j((O) => ({ ...O, email: !1 }));
|
|
2695
2616
|
},
|
|
2696
|
-
placeholder:
|
|
2617
|
+
placeholder: b.emailPlaceholder,
|
|
2697
2618
|
style: ee("email"),
|
|
2698
|
-
disabled:
|
|
2619
|
+
disabled: C || P
|
|
2699
2620
|
}
|
|
2700
2621
|
)
|
|
2701
2622
|
] }),
|
|
2702
|
-
!
|
|
2623
|
+
!v && /* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
|
|
2703
2624
|
"button",
|
|
2704
2625
|
{
|
|
2705
2626
|
type: "button",
|
|
2706
|
-
onClick: () =>
|
|
2627
|
+
onClick: () => I(!0),
|
|
2707
2628
|
style: {
|
|
2708
2629
|
background: "none",
|
|
2709
2630
|
border: "none",
|
|
@@ -2715,38 +2636,38 @@ function Ht({
|
|
|
2715
2636
|
children: "New user? Add your name"
|
|
2716
2637
|
}
|
|
2717
2638
|
) }),
|
|
2718
|
-
|
|
2719
|
-
/* @__PURE__ */
|
|
2720
|
-
/* @__PURE__ */ n("label", { style:
|
|
2639
|
+
v && /* @__PURE__ */ a(B, { children: [
|
|
2640
|
+
/* @__PURE__ */ a("div", { style: d.fieldGroup, children: [
|
|
2641
|
+
/* @__PURE__ */ n("label", { style: d.label, children: b.nameLabel }),
|
|
2721
2642
|
/* @__PURE__ */ n(
|
|
2722
2643
|
"input",
|
|
2723
2644
|
{
|
|
2724
2645
|
id: "name",
|
|
2725
2646
|
name: "name",
|
|
2726
2647
|
type: "text",
|
|
2727
|
-
value:
|
|
2728
|
-
onChange: (
|
|
2729
|
-
h(
|
|
2648
|
+
value: p,
|
|
2649
|
+
onChange: (H) => {
|
|
2650
|
+
h(H.target.value), $.name && j((O) => ({ ...O, name: !1 }));
|
|
2730
2651
|
},
|
|
2731
|
-
placeholder:
|
|
2652
|
+
placeholder: b.namePlaceholder,
|
|
2732
2653
|
style: ee("name"),
|
|
2733
|
-
disabled:
|
|
2654
|
+
disabled: C || P
|
|
2734
2655
|
}
|
|
2735
2656
|
)
|
|
2736
2657
|
] }),
|
|
2737
|
-
/* @__PURE__ */
|
|
2738
|
-
/* @__PURE__ */ n("label", { style:
|
|
2658
|
+
/* @__PURE__ */ a("div", { style: d.fieldGroup, children: [
|
|
2659
|
+
/* @__PURE__ */ n("label", { style: d.label, children: b.lastNameLabel }),
|
|
2739
2660
|
/* @__PURE__ */ n(
|
|
2740
2661
|
"input",
|
|
2741
2662
|
{
|
|
2742
2663
|
id: "lastName",
|
|
2743
2664
|
name: "lastName",
|
|
2744
2665
|
type: "text",
|
|
2745
|
-
value:
|
|
2746
|
-
onChange: (
|
|
2747
|
-
placeholder:
|
|
2748
|
-
style:
|
|
2749
|
-
disabled:
|
|
2666
|
+
value: m,
|
|
2667
|
+
onChange: (H) => R(H.target.value),
|
|
2668
|
+
placeholder: b.lastNamePlaceholder,
|
|
2669
|
+
style: d.input,
|
|
2670
|
+
disabled: C || P
|
|
2750
2671
|
}
|
|
2751
2672
|
)
|
|
2752
2673
|
] }),
|
|
@@ -2755,7 +2676,7 @@ function Ht({
|
|
|
2755
2676
|
{
|
|
2756
2677
|
type: "button",
|
|
2757
2678
|
onClick: () => {
|
|
2758
|
-
|
|
2679
|
+
I(!1), h(""), R("");
|
|
2759
2680
|
},
|
|
2760
2681
|
style: {
|
|
2761
2682
|
background: "none",
|
|
@@ -2769,25 +2690,25 @@ function Ht({
|
|
|
2769
2690
|
}
|
|
2770
2691
|
) })
|
|
2771
2692
|
] }),
|
|
2772
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !T ||
|
|
2773
|
-
|
|
2774
|
-
|
|
2693
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !T || C || P, style: z(), children: C ? b.loadingText : b.submitButton }),
|
|
2694
|
+
M && /* @__PURE__ */ n("div", { style: d.errorText, children: M }),
|
|
2695
|
+
q && /* @__PURE__ */ n("div", { style: d.successText, children: q })
|
|
2775
2696
|
] }),
|
|
2776
|
-
|
|
2777
|
-
/* @__PURE__ */
|
|
2778
|
-
/* @__PURE__ */
|
|
2779
|
-
|
|
2697
|
+
g && /* @__PURE__ */ a("div", { style: d.linkContainer, children: [
|
|
2698
|
+
/* @__PURE__ */ a("div", { children: [
|
|
2699
|
+
/* @__PURE__ */ a("span", { style: d.divider, children: [
|
|
2700
|
+
b.loginText,
|
|
2780
2701
|
" "
|
|
2781
2702
|
] }),
|
|
2782
|
-
/* @__PURE__ */ n("a", { onClick: s, style:
|
|
2703
|
+
/* @__PURE__ */ n("a", { onClick: s, style: d.link, children: b.loginLink })
|
|
2783
2704
|
] }),
|
|
2784
|
-
/* @__PURE__ */ n("div", { style:
|
|
2785
|
-
/* @__PURE__ */
|
|
2786
|
-
/* @__PURE__ */
|
|
2787
|
-
|
|
2705
|
+
/* @__PURE__ */ n("div", { style: d.divider, children: "•" }),
|
|
2706
|
+
/* @__PURE__ */ a("div", { children: [
|
|
2707
|
+
/* @__PURE__ */ a("span", { style: d.divider, children: [
|
|
2708
|
+
b.signupText,
|
|
2788
2709
|
" "
|
|
2789
2710
|
] }),
|
|
2790
|
-
/* @__PURE__ */ n("a", { onClick: o, style:
|
|
2711
|
+
/* @__PURE__ */ n("a", { onClick: o, style: d.link, children: b.signupLink })
|
|
2791
2712
|
] })
|
|
2792
2713
|
] })
|
|
2793
2714
|
] });
|
|
@@ -2887,7 +2808,7 @@ const at = {
|
|
|
2887
2808
|
cursor: "pointer",
|
|
2888
2809
|
transition: "all 0.15s ease-in-out"
|
|
2889
2810
|
}
|
|
2890
|
-
}, lt = () => /* @__PURE__ */ n("div", { style: Ee.spinner }), ct = () => /* @__PURE__ */
|
|
2811
|
+
}, lt = () => /* @__PURE__ */ n("div", { style: Ee.spinner }), ct = () => /* @__PURE__ */ a(
|
|
2891
2812
|
"svg",
|
|
2892
2813
|
{
|
|
2893
2814
|
width: "48",
|
|
@@ -2904,7 +2825,7 @@ const at = {
|
|
|
2904
2825
|
/* @__PURE__ */ n("polyline", { points: "22,4 12,14.01 9,11.01" })
|
|
2905
2826
|
]
|
|
2906
2827
|
}
|
|
2907
|
-
), dt = () => /* @__PURE__ */
|
|
2828
|
+
), dt = () => /* @__PURE__ */ a(
|
|
2908
2829
|
"svg",
|
|
2909
2830
|
{
|
|
2910
2831
|
width: "48",
|
|
@@ -2927,104 +2848,104 @@ const at = {
|
|
|
2927
2848
|
success: /* @__PURE__ */ n(ct, {}),
|
|
2928
2849
|
error: /* @__PURE__ */ n(dt, {})
|
|
2929
2850
|
};
|
|
2930
|
-
function
|
|
2851
|
+
function Ut({
|
|
2931
2852
|
copy: i = {},
|
|
2932
2853
|
styles: e = {},
|
|
2933
2854
|
icons: t = {},
|
|
2934
2855
|
onSuccess: r,
|
|
2935
2856
|
onError: s,
|
|
2936
2857
|
onRetry: o,
|
|
2937
|
-
onBackToLogin:
|
|
2938
|
-
className:
|
|
2858
|
+
onBackToLogin: g,
|
|
2859
|
+
className: y,
|
|
2939
2860
|
token: A,
|
|
2940
|
-
email:
|
|
2861
|
+
email: w,
|
|
2941
2862
|
appId: T,
|
|
2942
|
-
tenantSlug:
|
|
2943
|
-
autoRedirectDelay:
|
|
2863
|
+
tenantSlug: f,
|
|
2864
|
+
autoRedirectDelay: p = 3e3
|
|
2944
2865
|
}) {
|
|
2945
|
-
const [h,
|
|
2866
|
+
const [h, m] = k("verifying"), [R, C] = k(""), { verifyMagicLink: U } = ae(), P = { ...at, ...i }, u = { ...Ee, ...e }, M = { ...ut, ...t }, E = () => {
|
|
2946
2867
|
if (typeof window > "u") return {};
|
|
2947
|
-
const
|
|
2868
|
+
const v = new URLSearchParams(window.location.search);
|
|
2948
2869
|
return {
|
|
2949
|
-
token: A ||
|
|
2950
|
-
email:
|
|
2951
|
-
appId: T ||
|
|
2952
|
-
tenantSlug:
|
|
2870
|
+
token: A || v.get("token") || "",
|
|
2871
|
+
email: w || v.get("email") || "",
|
|
2872
|
+
appId: T || v.get("appId") || "",
|
|
2873
|
+
tenantSlug: f || v.get("tenantSlug") || void 0
|
|
2953
2874
|
};
|
|
2954
|
-
},
|
|
2955
|
-
|
|
2875
|
+
}, q = async () => {
|
|
2876
|
+
m("verifying"), C("");
|
|
2956
2877
|
try {
|
|
2957
|
-
const
|
|
2958
|
-
if (!
|
|
2878
|
+
const v = E();
|
|
2879
|
+
if (!v.token || !v.email)
|
|
2959
2880
|
throw new Error("Missing required parameters: token or email");
|
|
2960
|
-
const
|
|
2961
|
-
token:
|
|
2962
|
-
email:
|
|
2963
|
-
tenantSlug:
|
|
2881
|
+
const I = await U({
|
|
2882
|
+
token: v.token,
|
|
2883
|
+
email: v.email,
|
|
2884
|
+
tenantSlug: v.tenantSlug
|
|
2964
2885
|
});
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
},
|
|
2968
|
-
} catch (
|
|
2969
|
-
const
|
|
2970
|
-
|
|
2886
|
+
m("success"), r == null || r(I), p > 0 && setTimeout(() => {
|
|
2887
|
+
m("redirecting");
|
|
2888
|
+
}, p);
|
|
2889
|
+
} catch (v) {
|
|
2890
|
+
const I = v.message || P.errorMessage;
|
|
2891
|
+
C(I), m("error"), s == null || s(I);
|
|
2971
2892
|
}
|
|
2972
|
-
},
|
|
2973
|
-
o == null || o(),
|
|
2974
|
-
},
|
|
2975
|
-
|
|
2893
|
+
}, V = () => {
|
|
2894
|
+
o == null || o(), q();
|
|
2895
|
+
}, $ = () => {
|
|
2896
|
+
g == null || g();
|
|
2976
2897
|
};
|
|
2977
2898
|
te(() => {
|
|
2978
|
-
|
|
2899
|
+
q();
|
|
2979
2900
|
}, []);
|
|
2980
|
-
const
|
|
2901
|
+
const j = () => {
|
|
2981
2902
|
switch (h) {
|
|
2982
2903
|
case "verifying":
|
|
2983
|
-
return /* @__PURE__ */
|
|
2984
|
-
|
|
2985
|
-
|
|
2904
|
+
return /* @__PURE__ */ a("div", { style: u.message, children: [
|
|
2905
|
+
M.loading,
|
|
2906
|
+
P.verifyingMessage
|
|
2986
2907
|
] });
|
|
2987
2908
|
case "success":
|
|
2988
|
-
return /* @__PURE__ */
|
|
2989
|
-
|
|
2990
|
-
/* @__PURE__ */ n("div", { style: u.successMessage, children:
|
|
2909
|
+
return /* @__PURE__ */ a(B, { children: [
|
|
2910
|
+
M.success,
|
|
2911
|
+
/* @__PURE__ */ n("div", { style: u.successMessage, children: P.successMessage })
|
|
2991
2912
|
] });
|
|
2992
2913
|
case "redirecting":
|
|
2993
|
-
return /* @__PURE__ */
|
|
2994
|
-
|
|
2995
|
-
/* @__PURE__ */ n("div", { style: u.message, children:
|
|
2914
|
+
return /* @__PURE__ */ a(B, { children: [
|
|
2915
|
+
M.loading,
|
|
2916
|
+
/* @__PURE__ */ n("div", { style: u.message, children: P.redirectingMessage })
|
|
2996
2917
|
] });
|
|
2997
2918
|
case "error":
|
|
2998
|
-
return /* @__PURE__ */
|
|
2999
|
-
|
|
3000
|
-
/* @__PURE__ */ n("div", { style: u.errorMessage, children:
|
|
3001
|
-
/* @__PURE__ */
|
|
2919
|
+
return /* @__PURE__ */ a(B, { children: [
|
|
2920
|
+
M.error,
|
|
2921
|
+
/* @__PURE__ */ n("div", { style: u.errorMessage, children: R || P.errorMessage }),
|
|
2922
|
+
/* @__PURE__ */ a("div", { style: u.buttonContainer, children: [
|
|
3002
2923
|
/* @__PURE__ */ n(
|
|
3003
2924
|
"button",
|
|
3004
2925
|
{
|
|
3005
|
-
onClick:
|
|
2926
|
+
onClick: V,
|
|
3006
2927
|
style: u.retryButton,
|
|
3007
|
-
onMouseOver: (
|
|
3008
|
-
|
|
2928
|
+
onMouseOver: (v) => {
|
|
2929
|
+
v.currentTarget.style.backgroundColor = "#2563eb";
|
|
3009
2930
|
},
|
|
3010
|
-
onMouseOut: (
|
|
3011
|
-
|
|
2931
|
+
onMouseOut: (v) => {
|
|
2932
|
+
v.currentTarget.style.backgroundColor = "#3b82f6";
|
|
3012
2933
|
},
|
|
3013
|
-
children:
|
|
2934
|
+
children: P.retryButton
|
|
3014
2935
|
}
|
|
3015
2936
|
),
|
|
3016
2937
|
/* @__PURE__ */ n(
|
|
3017
2938
|
"button",
|
|
3018
2939
|
{
|
|
3019
|
-
onClick:
|
|
2940
|
+
onClick: $,
|
|
3020
2941
|
style: u.backButton,
|
|
3021
|
-
onMouseOver: (
|
|
3022
|
-
|
|
2942
|
+
onMouseOver: (v) => {
|
|
2943
|
+
v.currentTarget.style.backgroundColor = "#e5e7eb";
|
|
3023
2944
|
},
|
|
3024
|
-
onMouseOut: (
|
|
3025
|
-
|
|
2945
|
+
onMouseOut: (v) => {
|
|
2946
|
+
v.currentTarget.style.backgroundColor = "#f3f4f6";
|
|
3026
2947
|
},
|
|
3027
|
-
children:
|
|
2948
|
+
children: P.backToLoginButton
|
|
3028
2949
|
}
|
|
3029
2950
|
)
|
|
3030
2951
|
] })
|
|
@@ -3033,15 +2954,15 @@ function Nt({
|
|
|
3033
2954
|
return null;
|
|
3034
2955
|
}
|
|
3035
2956
|
};
|
|
3036
|
-
return /* @__PURE__ */
|
|
2957
|
+
return /* @__PURE__ */ a("div", { style: u.container, className: y, children: [
|
|
3037
2958
|
/* @__PURE__ */ n("style", { children: `
|
|
3038
2959
|
@keyframes spin {
|
|
3039
2960
|
0% { transform: rotate(0deg); }
|
|
3040
2961
|
100% { transform: rotate(360deg); }
|
|
3041
2962
|
}
|
|
3042
2963
|
` }),
|
|
3043
|
-
/* @__PURE__ */ n("h1", { style: u.title, children:
|
|
3044
|
-
|
|
2964
|
+
/* @__PURE__ */ n("h1", { style: u.title, children: P.title }),
|
|
2965
|
+
j()
|
|
3045
2966
|
] });
|
|
3046
2967
|
}
|
|
3047
2968
|
const ht = {
|
|
@@ -3158,113 +3079,113 @@ const ht = {
|
|
|
3158
3079
|
cursor: "pointer"
|
|
3159
3080
|
}
|
|
3160
3081
|
};
|
|
3161
|
-
function
|
|
3082
|
+
function qt({
|
|
3162
3083
|
copy: i = {},
|
|
3163
3084
|
styles: e = {},
|
|
3164
3085
|
mode: t = "request",
|
|
3165
3086
|
token: r = "",
|
|
3166
3087
|
onSuccess: s,
|
|
3167
3088
|
onError: o,
|
|
3168
|
-
onBackToLogin:
|
|
3169
|
-
onModeChange:
|
|
3089
|
+
onBackToLogin: g,
|
|
3090
|
+
onModeChange: y,
|
|
3170
3091
|
className: A
|
|
3171
3092
|
}) {
|
|
3172
|
-
const [
|
|
3093
|
+
const [w, T] = k(""), [f, p] = k(r), [h, m] = k(""), [R, C] = k(""), [U, P] = k(!1), [u, M] = k(""), [E, q] = k(""), [V, $] = k({}), { requestPasswordReset: j, confirmPasswordReset: v } = ae(), { tenant: I } = se(), L = { ...ht, ...i }, l = { ...gt, ...e }, x = () => {
|
|
3173
3094
|
const z = {};
|
|
3174
|
-
return
|
|
3175
|
-
},
|
|
3095
|
+
return w.trim() || (z.email = !0), $(z), Object.keys(z).length === 0;
|
|
3096
|
+
}, b = () => {
|
|
3176
3097
|
const z = {};
|
|
3177
|
-
return
|
|
3178
|
-
},
|
|
3179
|
-
if (z.preventDefault(), !!
|
|
3180
|
-
if (!(
|
|
3181
|
-
|
|
3098
|
+
return f.trim() || (z.token = !0), h.trim() || (z.newPassword = !0), R.trim() || (z.confirmPassword = !0), $(z), Object.keys(z).length === 0;
|
|
3099
|
+
}, d = async (z) => {
|
|
3100
|
+
if (z.preventDefault(), !!x()) {
|
|
3101
|
+
if (!(I != null && I.id)) {
|
|
3102
|
+
M("Tenant not found");
|
|
3182
3103
|
return;
|
|
3183
3104
|
}
|
|
3184
|
-
|
|
3105
|
+
P(!0), M(""), q("");
|
|
3185
3106
|
try {
|
|
3186
|
-
await
|
|
3187
|
-
} catch (
|
|
3188
|
-
const O =
|
|
3189
|
-
|
|
3107
|
+
await j({ email: w, tenantId: I.id }), q(L.successMessage), s == null || s();
|
|
3108
|
+
} catch (H) {
|
|
3109
|
+
const O = H.message || L.errorMessage;
|
|
3110
|
+
M(O), o == null || o(O);
|
|
3190
3111
|
} finally {
|
|
3191
|
-
|
|
3112
|
+
P(!1);
|
|
3192
3113
|
}
|
|
3193
3114
|
}
|
|
3194
|
-
},
|
|
3195
|
-
if (z.preventDefault(), !!
|
|
3196
|
-
if (h !==
|
|
3197
|
-
|
|
3115
|
+
}, c = async (z) => {
|
|
3116
|
+
if (z.preventDefault(), !!b()) {
|
|
3117
|
+
if (h !== R) {
|
|
3118
|
+
M(L.passwordMismatchError), $({ confirmPassword: !0 });
|
|
3198
3119
|
return;
|
|
3199
3120
|
}
|
|
3200
|
-
|
|
3121
|
+
P(!0), M(""), q("");
|
|
3201
3122
|
try {
|
|
3202
|
-
await
|
|
3203
|
-
} catch (
|
|
3204
|
-
const O =
|
|
3205
|
-
|
|
3123
|
+
await v({ token: f, newPassword: h }), q(L.resetSuccessMessage), s == null || s();
|
|
3124
|
+
} catch (H) {
|
|
3125
|
+
const O = H.message || L.errorMessage;
|
|
3126
|
+
M(O), o == null || o(O);
|
|
3206
3127
|
} finally {
|
|
3207
|
-
|
|
3128
|
+
P(!1);
|
|
3208
3129
|
}
|
|
3209
3130
|
}
|
|
3210
|
-
},
|
|
3211
|
-
...
|
|
3212
|
-
...
|
|
3131
|
+
}, S = (z) => ({
|
|
3132
|
+
...l.input,
|
|
3133
|
+
...V[z] ? l.inputError : {}
|
|
3213
3134
|
}), G = () => ({
|
|
3214
|
-
...
|
|
3215
|
-
...
|
|
3135
|
+
...l.button,
|
|
3136
|
+
...U ? l.buttonLoading : {}
|
|
3216
3137
|
});
|
|
3217
3138
|
if (t === "reset") {
|
|
3218
|
-
const z =
|
|
3219
|
-
return /* @__PURE__ */
|
|
3220
|
-
/* @__PURE__ */ n("h2", { style:
|
|
3221
|
-
/* @__PURE__ */ n("p", { style:
|
|
3222
|
-
/* @__PURE__ */
|
|
3223
|
-
/* @__PURE__ */
|
|
3224
|
-
/* @__PURE__ */ n("label", { style:
|
|
3139
|
+
const z = f && h && R;
|
|
3140
|
+
return /* @__PURE__ */ a("div", { className: A, style: l.container, children: [
|
|
3141
|
+
/* @__PURE__ */ n("h2", { style: l.title, children: L.resetTitle }),
|
|
3142
|
+
/* @__PURE__ */ n("p", { style: l.subtitle, children: L.resetSubtitle }),
|
|
3143
|
+
/* @__PURE__ */ a("form", { onSubmit: c, style: l.form, children: [
|
|
3144
|
+
/* @__PURE__ */ a("div", { style: l.fieldGroup, children: [
|
|
3145
|
+
/* @__PURE__ */ n("label", { style: l.label, children: L.tokenLabel }),
|
|
3225
3146
|
/* @__PURE__ */ n(
|
|
3226
3147
|
"input",
|
|
3227
3148
|
{
|
|
3228
3149
|
type: "text",
|
|
3229
|
-
value:
|
|
3230
|
-
onChange: (
|
|
3231
|
-
|
|
3150
|
+
value: f,
|
|
3151
|
+
onChange: (H) => {
|
|
3152
|
+
p(H.target.value), V.token && $((O) => ({ ...O, token: !1 }));
|
|
3232
3153
|
},
|
|
3233
|
-
placeholder:
|
|
3234
|
-
style:
|
|
3235
|
-
disabled:
|
|
3154
|
+
placeholder: L.tokenPlaceholder,
|
|
3155
|
+
style: S("token"),
|
|
3156
|
+
disabled: U
|
|
3236
3157
|
}
|
|
3237
3158
|
)
|
|
3238
3159
|
] }),
|
|
3239
|
-
/* @__PURE__ */
|
|
3240
|
-
/* @__PURE__ */ n("label", { style:
|
|
3160
|
+
/* @__PURE__ */ a("div", { style: l.fieldGroup, children: [
|
|
3161
|
+
/* @__PURE__ */ n("label", { style: l.label, children: L.newPasswordLabel }),
|
|
3241
3162
|
/* @__PURE__ */ n(
|
|
3242
3163
|
"input",
|
|
3243
3164
|
{
|
|
3244
3165
|
type: "password",
|
|
3245
3166
|
value: h,
|
|
3246
|
-
onChange: (
|
|
3247
|
-
|
|
3167
|
+
onChange: (H) => {
|
|
3168
|
+
m(H.target.value), V.newPassword && $((O) => ({ ...O, newPassword: !1 }));
|
|
3248
3169
|
},
|
|
3249
|
-
placeholder:
|
|
3250
|
-
style:
|
|
3251
|
-
disabled:
|
|
3170
|
+
placeholder: L.newPasswordPlaceholder,
|
|
3171
|
+
style: S("newPassword"),
|
|
3172
|
+
disabled: U
|
|
3252
3173
|
}
|
|
3253
3174
|
)
|
|
3254
3175
|
] }),
|
|
3255
|
-
/* @__PURE__ */
|
|
3256
|
-
/* @__PURE__ */ n("label", { style:
|
|
3176
|
+
/* @__PURE__ */ a("div", { style: l.fieldGroup, children: [
|
|
3177
|
+
/* @__PURE__ */ n("label", { style: l.label, children: L.confirmPasswordLabel }),
|
|
3257
3178
|
/* @__PURE__ */ n(
|
|
3258
3179
|
"input",
|
|
3259
3180
|
{
|
|
3260
3181
|
type: "password",
|
|
3261
|
-
value:
|
|
3262
|
-
onChange: (
|
|
3263
|
-
|
|
3182
|
+
value: R,
|
|
3183
|
+
onChange: (H) => {
|
|
3184
|
+
C(H.target.value), V.confirmPassword && $((O) => ({ ...O, confirmPassword: !1 })), u === L.passwordMismatchError && M("");
|
|
3264
3185
|
},
|
|
3265
|
-
placeholder:
|
|
3266
|
-
style:
|
|
3267
|
-
disabled:
|
|
3186
|
+
placeholder: L.confirmPasswordPlaceholder,
|
|
3187
|
+
style: S("confirmPassword"),
|
|
3188
|
+
disabled: U
|
|
3268
3189
|
}
|
|
3269
3190
|
)
|
|
3270
3191
|
] }),
|
|
@@ -3272,44 +3193,44 @@ function Bt({
|
|
|
3272
3193
|
"button",
|
|
3273
3194
|
{
|
|
3274
3195
|
type: "submit",
|
|
3275
|
-
disabled: !z ||
|
|
3196
|
+
disabled: !z || U,
|
|
3276
3197
|
style: {
|
|
3277
3198
|
...G(),
|
|
3278
|
-
...!z ||
|
|
3199
|
+
...!z || U ? l.buttonDisabled : {}
|
|
3279
3200
|
},
|
|
3280
|
-
children:
|
|
3201
|
+
children: U ? L.resetLoadingText : L.resetSubmitButton
|
|
3281
3202
|
}
|
|
3282
3203
|
),
|
|
3283
|
-
u && /* @__PURE__ */ n("div", { style:
|
|
3284
|
-
|
|
3204
|
+
u && /* @__PURE__ */ n("div", { style: l.errorText, children: u }),
|
|
3205
|
+
E && /* @__PURE__ */ n("div", { style: l.successText, children: E })
|
|
3285
3206
|
] }),
|
|
3286
|
-
/* @__PURE__ */
|
|
3287
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
3288
|
-
|
|
3207
|
+
/* @__PURE__ */ a("div", { style: l.linkContainer, children: [
|
|
3208
|
+
/* @__PURE__ */ n("a", { onClick: g, style: l.link, children: L.backToLoginLink }),
|
|
3209
|
+
y && /* @__PURE__ */ a(B, { children: [
|
|
3289
3210
|
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3290
|
-
/* @__PURE__ */ n("a", { onClick: () =>
|
|
3211
|
+
/* @__PURE__ */ n("a", { onClick: () => y("request"), style: l.link, children: "Request New Link" })
|
|
3291
3212
|
] })
|
|
3292
3213
|
] })
|
|
3293
3214
|
] });
|
|
3294
3215
|
}
|
|
3295
|
-
const ee =
|
|
3296
|
-
return /* @__PURE__ */
|
|
3297
|
-
/* @__PURE__ */ n("h2", { style:
|
|
3298
|
-
/* @__PURE__ */ n("p", { style:
|
|
3299
|
-
/* @__PURE__ */
|
|
3300
|
-
/* @__PURE__ */
|
|
3301
|
-
/* @__PURE__ */ n("label", { style:
|
|
3216
|
+
const ee = w;
|
|
3217
|
+
return /* @__PURE__ */ a("div", { className: A, style: l.container, children: [
|
|
3218
|
+
/* @__PURE__ */ n("h2", { style: l.title, children: L.title }),
|
|
3219
|
+
/* @__PURE__ */ n("p", { style: l.subtitle, children: L.subtitle }),
|
|
3220
|
+
/* @__PURE__ */ a("form", { onSubmit: d, style: l.form, children: [
|
|
3221
|
+
/* @__PURE__ */ a("div", { style: l.fieldGroup, children: [
|
|
3222
|
+
/* @__PURE__ */ n("label", { style: l.label, children: L.emailLabel }),
|
|
3302
3223
|
/* @__PURE__ */ n(
|
|
3303
3224
|
"input",
|
|
3304
3225
|
{
|
|
3305
3226
|
type: "email",
|
|
3306
|
-
value:
|
|
3227
|
+
value: w,
|
|
3307
3228
|
onChange: (z) => {
|
|
3308
|
-
T(z.target.value),
|
|
3229
|
+
T(z.target.value), V.email && $((H) => ({ ...H, email: !1 }));
|
|
3309
3230
|
},
|
|
3310
|
-
placeholder:
|
|
3311
|
-
style:
|
|
3312
|
-
disabled:
|
|
3231
|
+
placeholder: L.emailPlaceholder,
|
|
3232
|
+
style: S("email"),
|
|
3233
|
+
disabled: U
|
|
3313
3234
|
}
|
|
3314
3235
|
)
|
|
3315
3236
|
] }),
|
|
@@ -3317,27 +3238,106 @@ function Bt({
|
|
|
3317
3238
|
"button",
|
|
3318
3239
|
{
|
|
3319
3240
|
type: "submit",
|
|
3320
|
-
disabled: !ee ||
|
|
3241
|
+
disabled: !ee || U,
|
|
3321
3242
|
style: {
|
|
3322
3243
|
...G(),
|
|
3323
|
-
...!ee ||
|
|
3244
|
+
...!ee || U ? l.buttonDisabled : {}
|
|
3324
3245
|
},
|
|
3325
|
-
children:
|
|
3246
|
+
children: U ? L.loadingText : L.submitButton
|
|
3326
3247
|
}
|
|
3327
3248
|
),
|
|
3328
|
-
u && /* @__PURE__ */ n("div", { style:
|
|
3329
|
-
|
|
3249
|
+
u && /* @__PURE__ */ n("div", { style: l.errorText, children: u }),
|
|
3250
|
+
E && /* @__PURE__ */ n("div", { style: l.successText, children: E })
|
|
3330
3251
|
] }),
|
|
3331
|
-
/* @__PURE__ */
|
|
3332
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
3333
|
-
|
|
3252
|
+
/* @__PURE__ */ a("div", { style: l.linkContainer, children: [
|
|
3253
|
+
/* @__PURE__ */ n("a", { onClick: g, style: l.link, children: L.backToLoginLink }),
|
|
3254
|
+
y && /* @__PURE__ */ a(B, { children: [
|
|
3334
3255
|
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3335
|
-
/* @__PURE__ */ n("a", { onClick: () =>
|
|
3256
|
+
/* @__PURE__ */ n("a", { onClick: () => y("reset"), style: l.link, children: "I have a token" })
|
|
3336
3257
|
] })
|
|
3337
3258
|
] })
|
|
3338
3259
|
] });
|
|
3339
3260
|
}
|
|
3340
|
-
|
|
3261
|
+
const pt = () => /* @__PURE__ */ n(
|
|
3262
|
+
"div",
|
|
3263
|
+
{
|
|
3264
|
+
style: {
|
|
3265
|
+
display: "flex",
|
|
3266
|
+
justifyContent: "center",
|
|
3267
|
+
alignItems: "center",
|
|
3268
|
+
height: "100vh",
|
|
3269
|
+
fontFamily: "system-ui, sans-serif"
|
|
3270
|
+
},
|
|
3271
|
+
children: /* @__PURE__ */ n("div", { children: "Loading..." })
|
|
3272
|
+
}
|
|
3273
|
+
), ft = ({ error: i, retry: e }) => /* @__PURE__ */ a(
|
|
3274
|
+
"div",
|
|
3275
|
+
{
|
|
3276
|
+
style: {
|
|
3277
|
+
display: "flex",
|
|
3278
|
+
flexDirection: "column",
|
|
3279
|
+
justifyContent: "center",
|
|
3280
|
+
alignItems: "center",
|
|
3281
|
+
height: "100vh",
|
|
3282
|
+
fontFamily: "system-ui, sans-serif",
|
|
3283
|
+
textAlign: "center",
|
|
3284
|
+
padding: "20px"
|
|
3285
|
+
},
|
|
3286
|
+
children: [
|
|
3287
|
+
/* @__PURE__ */ n("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Error" }),
|
|
3288
|
+
/* @__PURE__ */ n("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load application" }),
|
|
3289
|
+
/* @__PURE__ */ n(
|
|
3290
|
+
"button",
|
|
3291
|
+
{
|
|
3292
|
+
onClick: e,
|
|
3293
|
+
style: {
|
|
3294
|
+
padding: "8px 16px",
|
|
3295
|
+
backgroundColor: "#007bff",
|
|
3296
|
+
color: "white",
|
|
3297
|
+
border: "none",
|
|
3298
|
+
borderRadius: "4px",
|
|
3299
|
+
cursor: "pointer"
|
|
3300
|
+
},
|
|
3301
|
+
children: "Retry"
|
|
3302
|
+
}
|
|
3303
|
+
)
|
|
3304
|
+
]
|
|
3305
|
+
}
|
|
3306
|
+
);
|
|
3307
|
+
function zt({
|
|
3308
|
+
children: i,
|
|
3309
|
+
loadingFallback: e,
|
|
3310
|
+
errorFallback: t,
|
|
3311
|
+
requireTenant: r = !0
|
|
3312
|
+
}) {
|
|
3313
|
+
const { isAppLoading: s, appError: o, retryApp: g } = oe(), y = Pe(), A = (y == null ? void 0 : y.isTenantLoading) ?? !1, w = (y == null ? void 0 : y.tenantError) ?? null, T = (y == null ? void 0 : y.tenantSlug) ?? null, f = (y == null ? void 0 : y.retryTenant) ?? (() => {
|
|
3314
|
+
}), p = r && y && T, h = s || p && A, m = o || (p ? w : null), R = () => {
|
|
3315
|
+
o && g(), w && y && f();
|
|
3316
|
+
};
|
|
3317
|
+
if (h)
|
|
3318
|
+
return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(pt, {}) });
|
|
3319
|
+
if (m) {
|
|
3320
|
+
const C = typeof t == "function" ? t(m, R) : t || /* @__PURE__ */ n(ft, { error: m, retry: R });
|
|
3321
|
+
return /* @__PURE__ */ n(B, { children: C });
|
|
3322
|
+
}
|
|
3323
|
+
return /* @__PURE__ */ n(B, { children: i });
|
|
3324
|
+
}
|
|
3325
|
+
function Ot(i = !0) {
|
|
3326
|
+
const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = oe(), o = Pe(), g = (o == null ? void 0 : o.isTenantLoading) ?? !1, y = (o == null ? void 0 : o.tenantError) ?? null, A = (o == null ? void 0 : o.tenant) ?? null, w = (o == null ? void 0 : o.tenantSlug) ?? null, T = (o == null ? void 0 : o.retryTenant) ?? (() => {
|
|
3327
|
+
}), f = i && o && w, p = e || f && g, h = t || (f ? y : null);
|
|
3328
|
+
return {
|
|
3329
|
+
isLoading: p,
|
|
3330
|
+
error: h,
|
|
3331
|
+
isReady: !p && !h && s !== null && (!f || A !== null),
|
|
3332
|
+
retry: () => {
|
|
3333
|
+
t && r(), y && o && T();
|
|
3334
|
+
},
|
|
3335
|
+
// Individual states
|
|
3336
|
+
app: { isLoading: e, error: t, data: s },
|
|
3337
|
+
tenant: o ? { isLoading: g, error: y, data: A } : null
|
|
3338
|
+
};
|
|
3339
|
+
}
|
|
3340
|
+
class Wt {
|
|
3341
3341
|
constructor(e, t) {
|
|
3342
3342
|
this.httpService = e, this.sessionManager = t;
|
|
3343
3343
|
}
|
|
@@ -3405,7 +3405,7 @@ class Ut {
|
|
|
3405
3405
|
};
|
|
3406
3406
|
}
|
|
3407
3407
|
}
|
|
3408
|
-
class
|
|
3408
|
+
class jt {
|
|
3409
3409
|
constructor(e, t) {
|
|
3410
3410
|
this.httpService = e, this.sessionManager = t;
|
|
3411
3411
|
}
|
|
@@ -3456,7 +3456,7 @@ class qt {
|
|
|
3456
3456
|
});
|
|
3457
3457
|
}
|
|
3458
3458
|
}
|
|
3459
|
-
class
|
|
3459
|
+
class Vt {
|
|
3460
3460
|
constructor(e) {
|
|
3461
3461
|
this.httpService = e;
|
|
3462
3462
|
}
|
|
@@ -3465,7 +3465,7 @@ class zt {
|
|
|
3465
3465
|
return await this.httpService.get("/health");
|
|
3466
3466
|
}
|
|
3467
3467
|
}
|
|
3468
|
-
class
|
|
3468
|
+
class Gt {
|
|
3469
3469
|
// Date string to Date object
|
|
3470
3470
|
static toDate(e) {
|
|
3471
3471
|
return new Date(e);
|
|
@@ -3588,44 +3588,47 @@ class Ot {
|
|
|
3588
3588
|
}
|
|
3589
3589
|
}
|
|
3590
3590
|
export {
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3591
|
+
Gt as ApiMappers,
|
|
3592
|
+
Se as AppApiService,
|
|
3593
|
+
zt as AppLoader,
|
|
3594
|
+
xt as AppProvider,
|
|
3595
|
+
He as AuthApiService,
|
|
3596
|
+
Mt as AuthProvider,
|
|
3597
|
+
Dt as FeatureFlag,
|
|
3597
3598
|
ze as FeatureFlagApiService,
|
|
3598
|
-
|
|
3599
|
-
|
|
3599
|
+
It as FeatureFlagProvider,
|
|
3600
|
+
Vt as HealthApiService,
|
|
3600
3601
|
re as HttpService,
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3602
|
+
$t as LandingRoute,
|
|
3603
|
+
Ht as LoginForm,
|
|
3604
|
+
Bt as MagicLinkForm,
|
|
3605
|
+
Ut as MagicLinkVerify,
|
|
3606
|
+
qt as PasswordRecoveryForm,
|
|
3607
|
+
Wt as PermissionApiService,
|
|
3608
|
+
Et as Protected,
|
|
3609
|
+
Rt as ProtectedRoute,
|
|
3610
|
+
ve as RoleApiService,
|
|
3610
3611
|
ye as SessionManager,
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3612
|
+
Nt as SignupForm,
|
|
3613
|
+
We as SubscriptionApiService,
|
|
3614
|
+
Ft as SubscriptionGuard,
|
|
3615
|
+
jt as SubscriptionPlanApiService,
|
|
3616
|
+
Lt as SubscriptionProvider,
|
|
3617
|
+
ue as TenantApiService,
|
|
3618
|
+
At as TenantProvider,
|
|
3618
3619
|
Ct as TenantRoute,
|
|
3619
|
-
|
|
3620
|
+
Ne as UserApiService,
|
|
3620
3621
|
ie as UserType,
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3622
|
+
kt as useApi,
|
|
3623
|
+
oe as useApp,
|
|
3624
|
+
Ot as useAppLoaderState,
|
|
3625
|
+
ae as useAuth,
|
|
3624
3626
|
Oe as useFeatureFlags,
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
+
Pt as useSettings,
|
|
3628
|
+
je as useSubscription,
|
|
3627
3629
|
fe as useTenant,
|
|
3628
3630
|
se as useTenantInfo,
|
|
3629
|
-
|
|
3631
|
+
Pe as useTenantOptional,
|
|
3632
|
+
Tt as useTenantSettings
|
|
3630
3633
|
};
|
|
3631
3634
|
//# sourceMappingURL=index.es.js.map
|