@skylabs-digital/react-identity-access 1.6.0 → 2.0.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/LoginForm.d.ts.map +1 -1
- package/dist/components/MagicLinkForm.d.ts.map +1 -1
- package/dist/components/MagicLinkVerify.d.ts +2 -2
- package/dist/components/MagicLinkVerify.d.ts.map +1 -1
- package/dist/components/SignupForm.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +1206 -1003
- 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 +5 -0
- package/dist/providers/AppProvider.d.ts.map +1 -1
- package/dist/providers/AuthProvider.d.ts +15 -9
- package/dist/providers/AuthProvider.d.ts.map +1 -1
- package/dist/providers/TenantProvider.d.ts +6 -0
- package/dist/providers/TenantProvider.d.ts.map +1 -1
- package/dist/services/SessionManager.d.ts +22 -0
- package/dist/services/SessionManager.d.ts.map +1 -1
- package/dist/types/api.d.ts +4 -2
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/authParams.d.ts +49 -0
- package/dist/types/authParams.d.ts.map +1 -0
- package/package.json +4 -1
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as n, Fragment as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { useLocation as
|
|
4
|
-
class
|
|
1
|
+
import { jsx as n, Fragment as N, jsxs as l } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as de, useMemo as Q, useState as v, useCallback as ne, useEffect as te, useContext as ue } from "react";
|
|
3
|
+
import { useLocation as we, Navigate as pe } from "react-router-dom";
|
|
4
|
+
class re {
|
|
5
5
|
// SessionManager instance
|
|
6
6
|
constructor(e, t = 1e4) {
|
|
7
7
|
this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
|
|
@@ -16,40 +16,40 @@ class te {
|
|
|
16
16
|
return this.executeRequest(e, t, r, s, !1);
|
|
17
17
|
}
|
|
18
18
|
async executeRequest(e, t, r, s, a = !1) {
|
|
19
|
-
const
|
|
20
|
-
let
|
|
19
|
+
const p = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, I = (s == null ? void 0 : s.timeout) || this.timeout;
|
|
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
|
-
|
|
28
|
-
} catch (
|
|
29
|
-
console.warn("Failed to inject auth headers:",
|
|
26
|
+
const b = await this.sessionManager.getAuthHeaders();
|
|
27
|
+
A = { ...A, ...b };
|
|
28
|
+
} catch (b) {
|
|
29
|
+
console.warn("Failed to inject auth headers:", b);
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const x = new AbortController(), P = setTimeout(() => x.abort(), I);
|
|
32
32
|
try {
|
|
33
|
-
const
|
|
33
|
+
const b = await fetch(p, {
|
|
34
34
|
method: e,
|
|
35
|
-
headers:
|
|
35
|
+
headers: A,
|
|
36
36
|
body: r ? JSON.stringify(r) : void 0,
|
|
37
|
-
signal:
|
|
37
|
+
signal: x.signal
|
|
38
38
|
});
|
|
39
|
-
if (clearTimeout(
|
|
39
|
+
if (clearTimeout(P), b.status === 401 && !(s != null && s.skipRetry) && !a && this.sessionManager)
|
|
40
40
|
try {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
41
|
+
const h = this.sessionManager.getTokens();
|
|
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 ${b.status}: ${b.statusText}`);
|
|
46
46
|
}
|
|
47
|
-
if (!
|
|
48
|
-
throw new Error(`HTTP ${
|
|
49
|
-
const
|
|
50
|
-
return !
|
|
51
|
-
} catch (
|
|
52
|
-
throw clearTimeout(
|
|
47
|
+
if (!b.ok)
|
|
48
|
+
throw new Error(`HTTP ${b.status}: ${b.statusText}`);
|
|
49
|
+
const m = b.headers.get("content-type");
|
|
50
|
+
return !m || !m.includes("application/json") ? {} : await b.json();
|
|
51
|
+
} catch (b) {
|
|
52
|
+
throw clearTimeout(P), b instanceof Error && b.name === "AbortError" ? new Error(`Request timeout after ${I}ms`) : b;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
async get(e, t) {
|
|
@@ -65,7 +65,7 @@ class te {
|
|
|
65
65
|
return this.request("DELETE", e, void 0, t);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
class
|
|
68
|
+
class be {
|
|
69
69
|
constructor(e, t) {
|
|
70
70
|
this.httpService = e, this.sessionManager = t;
|
|
71
71
|
}
|
|
@@ -124,7 +124,7 @@ class Te {
|
|
|
124
124
|
})).data;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
const
|
|
127
|
+
const Ae = de(null), De = () => /* @__PURE__ */ n(
|
|
128
128
|
"div",
|
|
129
129
|
{
|
|
130
130
|
style: {
|
|
@@ -136,7 +136,7 @@ const we = ae(null), Me = () => /* @__PURE__ */ n(
|
|
|
136
136
|
},
|
|
137
137
|
children: /* @__PURE__ */ n("div", { children: "Loading application..." })
|
|
138
138
|
}
|
|
139
|
-
),
|
|
139
|
+
), He = ({ error: i, retry: e }) => /* @__PURE__ */ l(
|
|
140
140
|
"div",
|
|
141
141
|
{
|
|
142
142
|
style: {
|
|
@@ -170,55 +170,113 @@ const we = ae(null), Me = () => /* @__PURE__ */ n(
|
|
|
170
170
|
]
|
|
171
171
|
}
|
|
172
172
|
);
|
|
173
|
-
function
|
|
174
|
-
const
|
|
175
|
-
|
|
173
|
+
function St({ config: i, children: e }) {
|
|
174
|
+
const t = Q(
|
|
175
|
+
() => {
|
|
176
|
+
var m, h, S;
|
|
177
|
+
return {
|
|
178
|
+
enabled: ((m = i.cache) == null ? void 0 : m.enabled) ?? !0,
|
|
179
|
+
ttl: ((h = i.cache) == null ? void 0 : h.ttl) ?? 3e5,
|
|
180
|
+
// 5 minutes default
|
|
181
|
+
storageKey: ((S = i.cache) == null ? void 0 : S.storageKey) ?? `app_cache_${i.appId}`
|
|
182
|
+
};
|
|
183
|
+
},
|
|
184
|
+
[i.cache, i.appId]
|
|
185
|
+
), [r, s] = v(() => {
|
|
186
|
+
if (!t.enabled) return null;
|
|
187
|
+
try {
|
|
188
|
+
const m = localStorage.getItem(t.storageKey);
|
|
189
|
+
if (!m) return null;
|
|
190
|
+
const h = JSON.parse(m);
|
|
191
|
+
return Date.now() - h.timestamp < t.ttl && h.appId === i.appId ? h.data : (localStorage.removeItem(t.storageKey), null);
|
|
192
|
+
} catch {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
}), [a, p] = v(!r), [I, A] = v(null), x = Q(() => {
|
|
196
|
+
const m = () => {
|
|
176
197
|
P();
|
|
177
198
|
};
|
|
178
199
|
return {
|
|
179
200
|
appId: i.appId,
|
|
180
201
|
baseUrl: i.baseUrl,
|
|
181
202
|
// App info
|
|
182
|
-
appInfo:
|
|
183
|
-
isAppLoading:
|
|
184
|
-
appError:
|
|
185
|
-
retryApp:
|
|
203
|
+
appInfo: r,
|
|
204
|
+
isAppLoading: a,
|
|
205
|
+
appError: I,
|
|
206
|
+
retryApp: m
|
|
186
207
|
};
|
|
187
|
-
}, [i,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
+
}, [i, r, a, I]), P = ne(
|
|
209
|
+
async (m = !1) => {
|
|
210
|
+
if (!(!m && t.enabled && r))
|
|
211
|
+
try {
|
|
212
|
+
p(!0), A(null);
|
|
213
|
+
const h = new re(i.baseUrl), L = await new be(h, {}).getPublicAppInfo(i.appId);
|
|
214
|
+
if (s(L), t.enabled)
|
|
215
|
+
try {
|
|
216
|
+
const C = {
|
|
217
|
+
data: L,
|
|
218
|
+
timestamp: Date.now(),
|
|
219
|
+
appId: i.appId
|
|
220
|
+
};
|
|
221
|
+
localStorage.setItem(t.storageKey, JSON.stringify(C));
|
|
222
|
+
} catch (C) {
|
|
223
|
+
console.warn("Failed to cache app info:", C);
|
|
224
|
+
}
|
|
225
|
+
} catch (h) {
|
|
226
|
+
const S = h instanceof Error ? h : new Error("Failed to load app information");
|
|
227
|
+
A(S), s(null);
|
|
228
|
+
} finally {
|
|
229
|
+
p(!1);
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
[i.baseUrl, i.appId, t, r]
|
|
233
|
+
), b = ne(async () => {
|
|
234
|
+
if (!(!t.enabled || !r))
|
|
235
|
+
try {
|
|
236
|
+
const m = localStorage.getItem(t.storageKey);
|
|
237
|
+
if (!m) return;
|
|
238
|
+
const h = JSON.parse(m);
|
|
239
|
+
if (Date.now() - h.timestamp > t.ttl * 0.5) {
|
|
240
|
+
const L = new re(i.baseUrl), q = await new be(L, {}).getPublicAppInfo(i.appId);
|
|
241
|
+
s(q);
|
|
242
|
+
const k = {
|
|
243
|
+
data: q,
|
|
244
|
+
timestamp: Date.now(),
|
|
245
|
+
appId: i.appId
|
|
246
|
+
};
|
|
247
|
+
localStorage.setItem(t.storageKey, JSON.stringify(k));
|
|
248
|
+
}
|
|
249
|
+
} catch (m) {
|
|
250
|
+
console.warn("Background app refresh failed:", m);
|
|
251
|
+
}
|
|
252
|
+
}, [i, t, r]);
|
|
253
|
+
if (te(() => {
|
|
254
|
+
r ? b() : P();
|
|
255
|
+
}, []), a)
|
|
256
|
+
return /* @__PURE__ */ n(N, { children: i.loadingFallback || /* @__PURE__ */ n(De, {}) });
|
|
257
|
+
if (I) {
|
|
258
|
+
const m = typeof i.errorFallback == "function" ? i.errorFallback(I, () => P()) : i.errorFallback || /* @__PURE__ */ n(He, { error: I, retry: () => P() });
|
|
259
|
+
return /* @__PURE__ */ n(N, { children: m });
|
|
260
|
+
}
|
|
261
|
+
return /* @__PURE__ */ n(Ae.Provider, { value: x, children: e });
|
|
208
262
|
}
|
|
209
|
-
function
|
|
210
|
-
const i =
|
|
263
|
+
function he() {
|
|
264
|
+
const i = ue(Ae);
|
|
211
265
|
if (!i)
|
|
212
266
|
throw new Error("useApp must be used within an AppProvider");
|
|
213
267
|
return i;
|
|
214
268
|
}
|
|
215
|
-
const
|
|
216
|
-
class
|
|
269
|
+
const vt = he;
|
|
270
|
+
class ye {
|
|
217
271
|
constructor(e = {}) {
|
|
218
|
-
this.refreshPromise = null, this.refreshQueue = [], 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 ||
|
|
272
|
+
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);
|
|
273
|
+
}
|
|
274
|
+
// Helper to create a TokenStorage for a specific key
|
|
275
|
+
createTokenStorage(e) {
|
|
276
|
+
return {
|
|
219
277
|
get: () => {
|
|
220
278
|
try {
|
|
221
|
-
const t = localStorage.getItem(
|
|
279
|
+
const t = localStorage.getItem(e);
|
|
222
280
|
return t ? JSON.parse(t) : null;
|
|
223
281
|
} catch {
|
|
224
282
|
return null;
|
|
@@ -226,13 +284,13 @@ class Le {
|
|
|
226
284
|
},
|
|
227
285
|
set: (t) => {
|
|
228
286
|
try {
|
|
229
|
-
localStorage.setItem(
|
|
287
|
+
localStorage.setItem(e, JSON.stringify(t));
|
|
230
288
|
} catch {
|
|
231
289
|
}
|
|
232
290
|
},
|
|
233
291
|
clear: () => {
|
|
234
292
|
try {
|
|
235
|
-
localStorage.removeItem(
|
|
293
|
+
localStorage.removeItem(e);
|
|
236
294
|
} catch {
|
|
237
295
|
}
|
|
238
296
|
}
|
|
@@ -325,12 +383,37 @@ class Le {
|
|
|
325
383
|
clearSession() {
|
|
326
384
|
this.clearTokens(), this.clearUser();
|
|
327
385
|
}
|
|
386
|
+
/**
|
|
387
|
+
* Decode JWT token and extract payload
|
|
388
|
+
* Returns null if token is invalid or cannot be decoded
|
|
389
|
+
*/
|
|
390
|
+
getTokenPayload() {
|
|
391
|
+
try {
|
|
392
|
+
const e = this.getTokens();
|
|
393
|
+
if (!(e != null && e.accessToken)) return null;
|
|
394
|
+
const t = e.accessToken.split(".");
|
|
395
|
+
if (t.length !== 3) return null;
|
|
396
|
+
const r = t[1], s = atob(r.replace(/-/g, "+").replace(/_/g, "/"));
|
|
397
|
+
return JSON.parse(s);
|
|
398
|
+
} catch {
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Get userId from token (source of truth) or fallback to stored user
|
|
404
|
+
*/
|
|
405
|
+
getUserId() {
|
|
406
|
+
const e = this.getTokenPayload();
|
|
407
|
+
if (e != null && e.userId) return e.userId;
|
|
408
|
+
const t = this.getUser();
|
|
409
|
+
return (t == null ? void 0 : t.id) || null;
|
|
410
|
+
}
|
|
328
411
|
hasValidSession() {
|
|
329
412
|
const e = this.getTokens();
|
|
330
413
|
return e !== null && !this.isTokenExpired(e);
|
|
331
414
|
}
|
|
332
415
|
}
|
|
333
|
-
class
|
|
416
|
+
class Ne {
|
|
334
417
|
constructor(e) {
|
|
335
418
|
this.httpService = e;
|
|
336
419
|
}
|
|
@@ -376,7 +459,7 @@ class Re {
|
|
|
376
459
|
});
|
|
377
460
|
}
|
|
378
461
|
}
|
|
379
|
-
class
|
|
462
|
+
class Se {
|
|
380
463
|
constructor(e, t) {
|
|
381
464
|
this.httpService = e, this.sessionManager = t;
|
|
382
465
|
}
|
|
@@ -443,16 +526,16 @@ class pe {
|
|
|
443
526
|
throw new Error("SessionManager is required for private endpoints");
|
|
444
527
|
const r = await this.sessionManager.getAuthHeaders(), s = new URLSearchParams();
|
|
445
528
|
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);
|
|
446
|
-
const a = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`,
|
|
529
|
+
const a = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, p = await this.httpService.get(a, {
|
|
447
530
|
headers: r
|
|
448
531
|
});
|
|
449
532
|
return {
|
|
450
|
-
roles:
|
|
451
|
-
meta:
|
|
533
|
+
roles: p.data,
|
|
534
|
+
meta: p.meta
|
|
452
535
|
};
|
|
453
536
|
}
|
|
454
537
|
}
|
|
455
|
-
class
|
|
538
|
+
class Be {
|
|
456
539
|
constructor(e, t) {
|
|
457
540
|
this.httpService = e, this.sessionManager = t;
|
|
458
541
|
}
|
|
@@ -492,7 +575,7 @@ class Ce {
|
|
|
492
575
|
});
|
|
493
576
|
}
|
|
494
577
|
}
|
|
495
|
-
class
|
|
578
|
+
class ce {
|
|
496
579
|
constructor(e, t, r) {
|
|
497
580
|
this.httpService = e, this.appId = t, this.sessionManager = r;
|
|
498
581
|
}
|
|
@@ -570,7 +653,7 @@ class fe {
|
|
|
570
653
|
)).data;
|
|
571
654
|
}
|
|
572
655
|
}
|
|
573
|
-
const
|
|
656
|
+
const Pe = de(null), Ue = () => /* @__PURE__ */ n(
|
|
574
657
|
"div",
|
|
575
658
|
{
|
|
576
659
|
style: {
|
|
@@ -582,7 +665,7 @@ const ve = ae(null), Ie = () => /* @__PURE__ */ n(
|
|
|
582
665
|
},
|
|
583
666
|
children: /* @__PURE__ */ n("div", { children: "Loading tenant..." })
|
|
584
667
|
}
|
|
585
|
-
),
|
|
668
|
+
), qe = ({ error: i, retry: e }) => /* @__PURE__ */ l(
|
|
586
669
|
"div",
|
|
587
670
|
{
|
|
588
671
|
style: {
|
|
@@ -616,77 +699,134 @@ const ve = ae(null), Ie = () => /* @__PURE__ */ n(
|
|
|
616
699
|
]
|
|
617
700
|
}
|
|
618
701
|
);
|
|
619
|
-
function
|
|
620
|
-
const { baseUrl: t, appInfo: r, appId: s } =
|
|
621
|
-
const
|
|
702
|
+
function xt({ config: i, children: e }) {
|
|
703
|
+
const { baseUrl: t, appInfo: r, appId: s } = he(), a = ne(() => {
|
|
704
|
+
const o = i.tenantMode || "selector", g = "tenant";
|
|
622
705
|
if (typeof window > "u") return null;
|
|
623
|
-
if (
|
|
624
|
-
const
|
|
625
|
-
if (
|
|
626
|
-
const
|
|
627
|
-
return localStorage.setItem(
|
|
706
|
+
if (o === "subdomain") {
|
|
707
|
+
const d = window.location.hostname.split(".");
|
|
708
|
+
if (d.length >= 3) {
|
|
709
|
+
const c = d[0];
|
|
710
|
+
return localStorage.setItem(g, c), c;
|
|
628
711
|
}
|
|
629
|
-
return localStorage.getItem(
|
|
630
|
-
} else if (
|
|
631
|
-
const
|
|
632
|
-
return
|
|
712
|
+
return localStorage.getItem(g);
|
|
713
|
+
} else if (o === "selector") {
|
|
714
|
+
const d = new URLSearchParams(window.location.search).get(i.selectorParam || "tenant");
|
|
715
|
+
return d ? (localStorage.setItem(g, d), d) : localStorage.getItem(g);
|
|
633
716
|
}
|
|
634
717
|
return null;
|
|
635
|
-
}, [i.tenantMode, i.selectorParam]),
|
|
636
|
-
|
|
718
|
+
}, [i.tenantMode, i.selectorParam]), [p, I] = v(() => a()), A = Q(
|
|
719
|
+
() => {
|
|
720
|
+
var o, g, f;
|
|
721
|
+
return {
|
|
722
|
+
enabled: ((o = i.cache) == null ? void 0 : o.enabled) ?? !0,
|
|
723
|
+
ttl: ((g = i.cache) == null ? void 0 : g.ttl) ?? 5 * 60 * 1e3,
|
|
724
|
+
// 5 minutes default
|
|
725
|
+
storageKey: ((f = i.cache) == null ? void 0 : f.storageKey) ?? `tenant_cache_${p || "default"}`
|
|
726
|
+
};
|
|
727
|
+
},
|
|
728
|
+
[i.cache, p]
|
|
729
|
+
), [x, P] = v(() => {
|
|
730
|
+
if (i.initialTenant) return i.initialTenant;
|
|
731
|
+
if (!A.enabled || !p) return null;
|
|
732
|
+
try {
|
|
733
|
+
const o = localStorage.getItem(A.storageKey);
|
|
734
|
+
if (!o) return null;
|
|
735
|
+
const g = JSON.parse(o);
|
|
736
|
+
return Date.now() - g.timestamp < A.ttl && g.tenantSlug === p ? g.data : (localStorage.removeItem(A.storageKey), null);
|
|
737
|
+
} catch {
|
|
738
|
+
return null;
|
|
739
|
+
}
|
|
740
|
+
}), [b, m] = v(!x && !i.initialTenant), [h, S] = v(null), [L, C] = v(null), [q, k] = v(!1), [u, T] = v(null);
|
|
741
|
+
te(() => {
|
|
742
|
+
const o = a();
|
|
743
|
+
I(o);
|
|
744
|
+
}, [a]);
|
|
745
|
+
const R = (r == null ? void 0 : r.settingsSchema) || null, H = ne(
|
|
746
|
+
async (o, g = !1) => {
|
|
747
|
+
if (!(!g && A.enabled && x && x.domain === o))
|
|
748
|
+
try {
|
|
749
|
+
m(!0), S(null);
|
|
750
|
+
const f = new re(t), c = await new ce(f, s).getPublicTenantInfo(o);
|
|
751
|
+
if (P(c), A.enabled)
|
|
752
|
+
try {
|
|
753
|
+
const y = {
|
|
754
|
+
data: c,
|
|
755
|
+
timestamp: Date.now(),
|
|
756
|
+
tenantSlug: o
|
|
757
|
+
};
|
|
758
|
+
localStorage.setItem(A.storageKey, JSON.stringify(y));
|
|
759
|
+
} catch (y) {
|
|
760
|
+
console.warn("Failed to cache tenant info:", y);
|
|
761
|
+
}
|
|
762
|
+
} catch (f) {
|
|
763
|
+
const d = f instanceof Error ? f : new Error("Failed to load tenant information");
|
|
764
|
+
S(d), P(null);
|
|
765
|
+
} finally {
|
|
766
|
+
m(!1);
|
|
767
|
+
}
|
|
768
|
+
},
|
|
769
|
+
[t, s, A, x]
|
|
770
|
+
), G = ne(async () => {
|
|
771
|
+
if (!(!A.enabled || !x || !p))
|
|
637
772
|
try {
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
773
|
+
const o = localStorage.getItem(A.storageKey);
|
|
774
|
+
if (!o) return;
|
|
775
|
+
const g = JSON.parse(o);
|
|
776
|
+
if (Date.now() - g.timestamp > A.ttl * 0.5) {
|
|
777
|
+
const d = new re(t), y = await new ce(d, s).getPublicTenantInfo(p);
|
|
778
|
+
P(y);
|
|
779
|
+
const W = {
|
|
780
|
+
data: y,
|
|
781
|
+
timestamp: Date.now(),
|
|
782
|
+
tenantSlug: p
|
|
783
|
+
};
|
|
784
|
+
localStorage.setItem(A.storageKey, JSON.stringify(W));
|
|
785
|
+
}
|
|
786
|
+
} catch (o) {
|
|
787
|
+
console.warn("Background tenant refresh failed:", o);
|
|
646
788
|
}
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
), F = oe(async () => {
|
|
650
|
-
if (a != null && a.id)
|
|
789
|
+
}, [t, s, A, x, p]), F = ne(async () => {
|
|
790
|
+
if (x != null && x.id)
|
|
651
791
|
try {
|
|
652
|
-
|
|
653
|
-
const
|
|
654
|
-
|
|
655
|
-
} catch (
|
|
656
|
-
const
|
|
657
|
-
g
|
|
792
|
+
k(!0), T(null);
|
|
793
|
+
const o = new re(t), f = await new ce(o, x.appId).getTenantSettings(x.id);
|
|
794
|
+
C(f);
|
|
795
|
+
} catch (o) {
|
|
796
|
+
const g = o instanceof Error ? o : new Error("Failed to load tenant settings");
|
|
797
|
+
T(g), C(null);
|
|
658
798
|
} finally {
|
|
659
|
-
|
|
799
|
+
k(!1);
|
|
660
800
|
}
|
|
661
|
-
}, [t,
|
|
801
|
+
}, [t, x]), V = ne(() => {
|
|
662
802
|
F();
|
|
663
|
-
}, [F]),
|
|
664
|
-
(
|
|
665
|
-
if (!
|
|
803
|
+
}, [F]), w = ne(
|
|
804
|
+
(o) => {
|
|
805
|
+
if (!R)
|
|
666
806
|
return { isValid: !0, errors: [] };
|
|
667
|
-
const
|
|
807
|
+
const g = [];
|
|
668
808
|
try {
|
|
669
|
-
return
|
|
670
|
-
var
|
|
671
|
-
const
|
|
672
|
-
if ((
|
|
673
|
-
|
|
809
|
+
return R.properties && Object.entries(R.properties).forEach(([f, d]) => {
|
|
810
|
+
var y;
|
|
811
|
+
const c = o[f];
|
|
812
|
+
if ((y = R.required) != null && y.includes(f) && c == null) {
|
|
813
|
+
g.push(`Field '${f}' is required`);
|
|
674
814
|
return;
|
|
675
815
|
}
|
|
676
|
-
if (
|
|
677
|
-
if (
|
|
678
|
-
const
|
|
679
|
-
|
|
816
|
+
if (c != null) {
|
|
817
|
+
if (d.type) {
|
|
818
|
+
const W = d.type, ee = typeof c;
|
|
819
|
+
W === "string" && ee !== "string" ? g.push(`Field '${f}' must be a string`) : (W === "number" || W === "integer") && ee !== "number" ? g.push(`Field '${f}' must be a number`) : W === "boolean" && ee !== "boolean" ? g.push(`Field '${f}' must be a boolean`) : W === "array" && !Array.isArray(c) && g.push(`Field '${f}' must be an array`);
|
|
680
820
|
}
|
|
681
|
-
|
|
682
|
-
`Field '${
|
|
683
|
-
),
|
|
684
|
-
`Field '${
|
|
685
|
-
),
|
|
821
|
+
d.minLength !== void 0 && typeof c == "string" && c.length < d.minLength && g.push(
|
|
822
|
+
`Field '${f}' must be at least ${d.minLength} characters long`
|
|
823
|
+
), d.maxLength !== void 0 && typeof c == "string" && c.length > d.maxLength && g.push(
|
|
824
|
+
`Field '${f}' must be no more than ${d.maxLength} characters long`
|
|
825
|
+
), d.minimum !== void 0 && typeof c == "number" && c < d.minimum && g.push(`Field '${f}' must be at least ${d.minimum}`), d.maximum !== void 0 && typeof c == "number" && c > d.maximum && g.push(`Field '${f}' must be no more than ${d.maximum}`), d.pattern && typeof c == "string" && (new RegExp(d.pattern).test(c) || g.push(`Field '${f}' does not match the required pattern`)), d.enum && !d.enum.includes(c) && g.push(`Field '${f}' must be one of: ${d.enum.join(", ")}`);
|
|
686
826
|
}
|
|
687
827
|
}), {
|
|
688
|
-
isValid:
|
|
689
|
-
errors:
|
|
828
|
+
isValid: g.length === 0,
|
|
829
|
+
errors: g
|
|
690
830
|
};
|
|
691
831
|
} catch {
|
|
692
832
|
return {
|
|
@@ -695,60 +835,93 @@ function pt({ config: i, children: e }) {
|
|
|
695
835
|
};
|
|
696
836
|
}
|
|
697
837
|
},
|
|
698
|
-
[
|
|
838
|
+
[R]
|
|
699
839
|
);
|
|
700
|
-
|
|
701
|
-
!i.initialTenant &&
|
|
702
|
-
}, [i.initialTenant,
|
|
703
|
-
|
|
704
|
-
}, [
|
|
705
|
-
const
|
|
840
|
+
te(() => {
|
|
841
|
+
!i.initialTenant && p ? x ? G() : H(p) : !i.initialTenant && !p && (P(null), S(null), m(!1));
|
|
842
|
+
}, [i.initialTenant, p, x, H, G]), te(() => {
|
|
843
|
+
x != null && x.id ? F() : (C(null), T(null), k(!1));
|
|
844
|
+
}, [x == null ? void 0 : x.id, F]);
|
|
845
|
+
const M = ne(
|
|
846
|
+
(o, g = "reload") => {
|
|
847
|
+
const f = i.tenantMode || "selector";
|
|
848
|
+
if (console.log("[TenantProvider] Switching tenant:", {
|
|
849
|
+
targetTenantSlug: o,
|
|
850
|
+
currentTenantSlug: p,
|
|
851
|
+
tenantMode: f,
|
|
852
|
+
mode: g
|
|
853
|
+
}), localStorage.setItem("tenant", o), f === "subdomain") {
|
|
854
|
+
const d = window.location.hostname, c = d.split(".");
|
|
855
|
+
if (c.length >= 2) {
|
|
856
|
+
c[0] = o;
|
|
857
|
+
const y = c.join("."), W = `${window.location.protocol}//${y}${window.location.pathname}${window.location.search}`;
|
|
858
|
+
console.log("[TenantProvider] Redirecting to:", W), window.location.href = W;
|
|
859
|
+
} else
|
|
860
|
+
console.warn(
|
|
861
|
+
"[TenantProvider] Cannot switch subdomain, invalid hostname:",
|
|
862
|
+
d
|
|
863
|
+
);
|
|
864
|
+
} else if (f === "selector") {
|
|
865
|
+
const d = new URLSearchParams(window.location.search);
|
|
866
|
+
if (d.set(i.selectorParam || "tenant", o), g === "reload") {
|
|
867
|
+
const c = `${window.location.pathname}?${d.toString()}${window.location.hash}`;
|
|
868
|
+
console.log("[TenantProvider] Reloading with new tenant:", c), window.location.href = c;
|
|
869
|
+
} else {
|
|
870
|
+
const c = `${window.location.pathname}?${d.toString()}${window.location.hash}`;
|
|
871
|
+
console.log("[TenantProvider] Navigating without reload:", c), window.history.pushState({}, "", c), I(o), H(o);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
},
|
|
875
|
+
[i.tenantMode, i.selectorParam, H, p]
|
|
876
|
+
), E = Q(() => ({
|
|
706
877
|
// Tenant info
|
|
707
|
-
tenant:
|
|
708
|
-
tenantSlug:
|
|
709
|
-
isTenantLoading:
|
|
710
|
-
tenantError:
|
|
878
|
+
tenant: x,
|
|
879
|
+
tenantSlug: p,
|
|
880
|
+
isTenantLoading: b,
|
|
881
|
+
tenantError: h,
|
|
711
882
|
retryTenant: () => {
|
|
712
|
-
|
|
883
|
+
p && H(p);
|
|
713
884
|
},
|
|
714
885
|
// Settings
|
|
715
|
-
settings:
|
|
716
|
-
settingsSchema:
|
|
717
|
-
isSettingsLoading:
|
|
718
|
-
settingsError:
|
|
886
|
+
settings: L,
|
|
887
|
+
settingsSchema: R,
|
|
888
|
+
isSettingsLoading: q,
|
|
889
|
+
settingsError: u,
|
|
719
890
|
// Actions
|
|
720
|
-
refreshSettings:
|
|
891
|
+
refreshSettings: V,
|
|
892
|
+
switchTenant: M,
|
|
721
893
|
// Validation
|
|
722
|
-
validateSettings:
|
|
894
|
+
validateSettings: w
|
|
723
895
|
}), [
|
|
724
|
-
|
|
896
|
+
x,
|
|
897
|
+
p,
|
|
898
|
+
b,
|
|
899
|
+
h,
|
|
900
|
+
L,
|
|
901
|
+
R,
|
|
902
|
+
q,
|
|
725
903
|
u,
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
y,
|
|
730
|
-
w,
|
|
731
|
-
I,
|
|
732
|
-
B,
|
|
733
|
-
z
|
|
904
|
+
V,
|
|
905
|
+
M,
|
|
906
|
+
w
|
|
734
907
|
]);
|
|
735
|
-
if (
|
|
736
|
-
return /* @__PURE__ */ n(
|
|
737
|
-
if (
|
|
738
|
-
const
|
|
739
|
-
return /* @__PURE__ */ n(
|
|
908
|
+
if (b)
|
|
909
|
+
return /* @__PURE__ */ n(N, { children: i.loadingFallback || /* @__PURE__ */ n(Ue, {}) });
|
|
910
|
+
if (h) {
|
|
911
|
+
const o = typeof i.errorFallback == "function" ? i.errorFallback(h, () => H(p || "")) : i.errorFallback || /* @__PURE__ */ n(qe, { error: h, retry: () => H(p || "") });
|
|
912
|
+
return /* @__PURE__ */ n(N, { children: o });
|
|
740
913
|
}
|
|
741
|
-
return /* @__PURE__ */ n(
|
|
914
|
+
return /* @__PURE__ */ n(Pe.Provider, { value: E, children: e });
|
|
742
915
|
}
|
|
743
|
-
function
|
|
744
|
-
const i =
|
|
916
|
+
function fe() {
|
|
917
|
+
const i = ue(Pe);
|
|
745
918
|
if (!i)
|
|
746
919
|
throw new Error("useTenant must be used within a TenantProvider");
|
|
747
920
|
return i;
|
|
748
921
|
}
|
|
749
|
-
const
|
|
750
|
-
function
|
|
751
|
-
const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } =
|
|
922
|
+
const kt = fe;
|
|
923
|
+
function At() {
|
|
924
|
+
const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } = fe();
|
|
752
925
|
return {
|
|
753
926
|
settings: i,
|
|
754
927
|
settingsSchema: e,
|
|
@@ -757,8 +930,8 @@ function mt() {
|
|
|
757
930
|
validateSettings: s
|
|
758
931
|
};
|
|
759
932
|
}
|
|
760
|
-
function
|
|
761
|
-
const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } =
|
|
933
|
+
function se() {
|
|
934
|
+
const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } = fe();
|
|
762
935
|
return {
|
|
763
936
|
tenant: i,
|
|
764
937
|
tenantSlug: e,
|
|
@@ -767,249 +940,273 @@ function re() {
|
|
|
767
940
|
retry: s
|
|
768
941
|
};
|
|
769
942
|
}
|
|
770
|
-
const
|
|
771
|
-
function
|
|
772
|
-
const { appId: t, baseUrl: r } =
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
set: (h) => {
|
|
783
|
-
try {
|
|
784
|
-
localStorage.setItem(S, JSON.stringify(h));
|
|
785
|
-
} catch {
|
|
786
|
-
}
|
|
787
|
-
},
|
|
788
|
-
clear: () => {
|
|
789
|
-
try {
|
|
790
|
-
localStorage.removeItem(S);
|
|
791
|
-
} catch {
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
};
|
|
795
|
-
return new Le({
|
|
796
|
-
onRefreshFailed: i.onRefreshFailed,
|
|
797
|
-
tokenStorage: c,
|
|
798
|
-
baseUrl: r
|
|
799
|
-
});
|
|
800
|
-
}, [a, r, i.onRefreshFailed]), U = _(() => {
|
|
801
|
-
const S = new te(r);
|
|
802
|
-
return S.setSessionManager(g), S;
|
|
803
|
-
}, [r, g]), u = _(() => new Re(new te(r)), [r]), y = _(() => new Ce(U, g), [U, g]), x = _(() => new pe(new te(r)), [r]), F = _(() => f || g.getUser(), [f, g]), B = _(() => F != null && F.roleId && b.find((S) => S.id === F.roleId) || null, [F, b]), z = _(() => (B == null ? void 0 : B.permissions) || [], [B]);
|
|
804
|
-
Z(() => {
|
|
805
|
-
console.log("AuthProvider - userPermissions changed:", z);
|
|
806
|
-
}, [z]);
|
|
807
|
-
const q = _(() => {
|
|
808
|
-
const S = async () => {
|
|
943
|
+
const Te = de(null);
|
|
944
|
+
function Pt({ config: i = {}, children: e }) {
|
|
945
|
+
const { appId: t, baseUrl: r } = he(), { tenant: s, tenantSlug: a, switchTenant: p } = fe(), [I, A] = v(i.initialRoles || []), [x, P] = v(!i.initialRoles), [b, m] = v(null), [h, S] = v(!1), [L, C] = v(null), [q, k] = v(0), u = Q(() => new ye({
|
|
946
|
+
tenantSlug: a,
|
|
947
|
+
// SessionManager will generate storageKey internally
|
|
948
|
+
onRefreshFailed: i.onRefreshFailed,
|
|
949
|
+
baseUrl: r
|
|
950
|
+
}), [a, r, i.onRefreshFailed]), T = Q(() => {
|
|
951
|
+
const g = new re(r);
|
|
952
|
+
return g.setSessionManager(u), g;
|
|
953
|
+
}, [r, u]), R = Q(() => new Ne(new re(r)), [r]), H = Q(() => new Be(T, u), [T, u]), G = Q(() => new Se(new re(r)), [r]), F = Q(() => b || u.getUser(), [b, u]), V = Q(() => F != null && F.roleId && I.find((g) => g.id === F.roleId) || null, [F, I]), w = Q(() => (V == null ? void 0 : V.permissions) || [], [V]), M = Q(() => u.hasValidSession() && b !== null, [u, b]), E = 5 * 60 * 1e3, o = Q(() => {
|
|
954
|
+
const g = async ($ = !1) => {
|
|
809
955
|
try {
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
956
|
+
if (!u.hasValidSession())
|
|
957
|
+
return;
|
|
958
|
+
const U = Date.now();
|
|
959
|
+
if (!$ && U - q < E && b)
|
|
960
|
+
return;
|
|
961
|
+
const j = u.getUserId();
|
|
962
|
+
if (!j) {
|
|
963
|
+
console.warn("[AuthProvider] No userId available in token or storage");
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
S(!0), C(null);
|
|
967
|
+
const X = await H.getUserById(j);
|
|
968
|
+
m(X), u.setUser(X), k(Date.now());
|
|
969
|
+
} catch (U) {
|
|
970
|
+
const K = U instanceof Error ? U : new Error("Failed to load user data");
|
|
971
|
+
C(K), console.error("[AuthProvider] Failed to load user data:", K);
|
|
819
972
|
} finally {
|
|
820
|
-
|
|
973
|
+
S(!1);
|
|
821
974
|
}
|
|
822
|
-
},
|
|
823
|
-
await
|
|
824
|
-
},
|
|
825
|
-
const
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
975
|
+
}, f = async () => {
|
|
976
|
+
await g();
|
|
977
|
+
}, d = async ($) => {
|
|
978
|
+
const { username: U, password: K, tenantSlug: j } = $;
|
|
979
|
+
let X = s == null ? void 0 : s.id, Y = a, Z = u;
|
|
980
|
+
j && (X = (await new ce(T, t).getPublicTenantInfo(j)).id, Y = j);
|
|
981
|
+
const J = await R.login({
|
|
982
|
+
username: U,
|
|
983
|
+
password: K,
|
|
984
|
+
appId: t,
|
|
829
985
|
tenantId: X
|
|
830
|
-
});
|
|
831
|
-
if (
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
986
|
+
}), ae = j && j !== a;
|
|
987
|
+
if (ae && (Z = new ye({
|
|
988
|
+
tenantSlug: Y,
|
|
989
|
+
baseUrl: r
|
|
990
|
+
})), Z.setTokens({
|
|
991
|
+
accessToken: J.accessToken,
|
|
992
|
+
refreshToken: J.refreshToken,
|
|
993
|
+
expiresIn: J.expiresIn
|
|
994
|
+
}), J.user) {
|
|
995
|
+
Z.setUser(J.user), m(J.user);
|
|
837
996
|
try {
|
|
838
|
-
await
|
|
839
|
-
} catch (
|
|
840
|
-
console.warn("Failed to load complete user data after login:",
|
|
997
|
+
await g();
|
|
998
|
+
} catch (le) {
|
|
999
|
+
console.warn("Failed to load complete user data after login:", le);
|
|
841
1000
|
}
|
|
842
1001
|
}
|
|
843
|
-
return
|
|
844
|
-
},
|
|
845
|
-
|
|
1002
|
+
return ae && Y && Y !== a && p(Y), J;
|
|
1003
|
+
}, c = async ($) => {
|
|
1004
|
+
const { email: U, phoneNumber: K, name: j, password: X, lastName: Y, tenantId: Z } = $;
|
|
1005
|
+
if (!U && !K)
|
|
846
1006
|
throw new Error("Either email or phoneNumber is required");
|
|
847
|
-
if (!
|
|
1007
|
+
if (!j || !X)
|
|
848
1008
|
throw new Error("Name and password are required");
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
1009
|
+
const J = Z ?? (s == null ? void 0 : s.id);
|
|
1010
|
+
return await R.signup({
|
|
1011
|
+
email: U,
|
|
1012
|
+
phoneNumber: K,
|
|
1013
|
+
name: j,
|
|
853
1014
|
password: X,
|
|
854
|
-
tenantId:
|
|
855
|
-
lastName:
|
|
856
|
-
appId:
|
|
1015
|
+
tenantId: J,
|
|
1016
|
+
lastName: Y,
|
|
1017
|
+
appId: t
|
|
857
1018
|
});
|
|
858
|
-
},
|
|
859
|
-
|
|
1019
|
+
}, y = async ($) => {
|
|
1020
|
+
const { email: U, phoneNumber: K, name: j, password: X, tenantName: Y, lastName: Z } = $;
|
|
1021
|
+
if (!U && !K)
|
|
860
1022
|
throw new Error("Either email or phoneNumber is required");
|
|
861
|
-
if (!
|
|
1023
|
+
if (!j || !X || !Y)
|
|
862
1024
|
throw new Error("Name, password, and tenantName are required");
|
|
863
|
-
return await
|
|
864
|
-
email:
|
|
865
|
-
phoneNumber:
|
|
866
|
-
name:
|
|
1025
|
+
return await R.signupTenantAdmin({
|
|
1026
|
+
email: U,
|
|
1027
|
+
phoneNumber: K,
|
|
1028
|
+
name: j,
|
|
867
1029
|
password: X,
|
|
868
|
-
tenantName:
|
|
869
|
-
appId:
|
|
870
|
-
lastName:
|
|
1030
|
+
tenantName: Y,
|
|
1031
|
+
appId: t,
|
|
1032
|
+
lastName: Z
|
|
871
1033
|
});
|
|
872
|
-
},
|
|
873
|
-
const
|
|
874
|
-
await
|
|
875
|
-
},
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
lastName:
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
1034
|
+
}, W = async ($) => {
|
|
1035
|
+
const { currentPassword: U, newPassword: K } = $, j = await u.getAuthHeaders();
|
|
1036
|
+
await R.changePassword({ currentPassword: U, newPassword: K }, j);
|
|
1037
|
+
}, ee = async ($) => {
|
|
1038
|
+
const { email: U, tenantId: K } = $, j = K ?? (s == null ? void 0 : s.id);
|
|
1039
|
+
if (!j)
|
|
1040
|
+
throw new Error("tenantId is required for password reset");
|
|
1041
|
+
await R.requestPasswordReset({ email: U, tenantId: j });
|
|
1042
|
+
}, z = async ($) => {
|
|
1043
|
+
const { token: U, newPassword: K } = $;
|
|
1044
|
+
await R.confirmPasswordReset({ token: U, newPassword: K });
|
|
1045
|
+
}, B = async ($) => {
|
|
1046
|
+
const { email: U, frontendUrl: K, name: j, lastName: X, tenantId: Y } = $, Z = Y ?? (s == null ? void 0 : s.id);
|
|
1047
|
+
if (!Z)
|
|
1048
|
+
throw new Error("tenantId is required for magic link authentication");
|
|
1049
|
+
return await R.sendMagicLink({
|
|
1050
|
+
email: U,
|
|
1051
|
+
tenantId: Z,
|
|
1052
|
+
frontendUrl: K,
|
|
1053
|
+
name: j,
|
|
1054
|
+
lastName: X,
|
|
1055
|
+
appId: t
|
|
892
1056
|
});
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
1057
|
+
}, O = async ($) => {
|
|
1058
|
+
const { token: U, email: K, tenantSlug: j } = $;
|
|
1059
|
+
let X = s == null ? void 0 : s.id, Y = a, Z = u;
|
|
1060
|
+
j && (X = (await new ce(T, t).getPublicTenantInfo(j)).id, Y = j);
|
|
1061
|
+
const J = await R.verifyMagicLink({
|
|
1062
|
+
token: U,
|
|
1063
|
+
email: K,
|
|
1064
|
+
appId: t,
|
|
1065
|
+
tenantId: X
|
|
1066
|
+
}), ae = j && j !== a;
|
|
1067
|
+
if (ae && (Z = new ye({
|
|
1068
|
+
tenantSlug: Y,
|
|
1069
|
+
baseUrl: r
|
|
1070
|
+
})), Z.setTokens({
|
|
1071
|
+
accessToken: J.accessToken,
|
|
1072
|
+
refreshToken: J.refreshToken,
|
|
1073
|
+
expiresIn: J.expiresIn
|
|
1074
|
+
}), J.user) {
|
|
1075
|
+
Z.setUser(J.user), m(J.user);
|
|
899
1076
|
try {
|
|
900
|
-
await
|
|
901
|
-
} catch (
|
|
902
|
-
console.warn("Failed to load complete user data after magic link login:",
|
|
1077
|
+
await g();
|
|
1078
|
+
} catch (le) {
|
|
1079
|
+
console.warn("Failed to load complete user data after magic link login:", le);
|
|
903
1080
|
}
|
|
904
1081
|
}
|
|
905
|
-
return
|
|
906
|
-
},
|
|
907
|
-
const
|
|
908
|
-
if (!(
|
|
1082
|
+
return ae && Y && Y !== a && p(Y), J;
|
|
1083
|
+
}, D = async () => {
|
|
1084
|
+
const $ = u.getTokens();
|
|
1085
|
+
if (!($ != null && $.refreshToken))
|
|
909
1086
|
throw new Error("No refresh token available");
|
|
910
|
-
const
|
|
911
|
-
refreshToken:
|
|
1087
|
+
const U = await R.refreshToken({
|
|
1088
|
+
refreshToken: $.refreshToken
|
|
912
1089
|
});
|
|
913
|
-
|
|
914
|
-
accessToken:
|
|
915
|
-
refreshToken:
|
|
916
|
-
expiresIn:
|
|
1090
|
+
u.setTokens({
|
|
1091
|
+
accessToken: U.accessToken,
|
|
1092
|
+
refreshToken: U.refreshToken || $.refreshToken,
|
|
1093
|
+
expiresIn: U.expiresIn
|
|
917
1094
|
});
|
|
918
|
-
},
|
|
919
|
-
|
|
920
|
-
},
|
|
921
|
-
|
|
922
|
-
},
|
|
923
|
-
|
|
924
|
-
},
|
|
1095
|
+
}, _ = () => {
|
|
1096
|
+
u.clearSession(), m(null), C(null);
|
|
1097
|
+
}, ge = ($) => {
|
|
1098
|
+
u.setTokens($);
|
|
1099
|
+
}, Re = () => u.hasValidSession(), Ce = () => {
|
|
1100
|
+
u.clearSession(), m(null), C(null);
|
|
1101
|
+
}, Le = async () => {
|
|
925
1102
|
if (t)
|
|
926
1103
|
try {
|
|
927
1104
|
P(!0);
|
|
928
|
-
const { roles:
|
|
929
|
-
|
|
930
|
-
} catch (
|
|
931
|
-
console.error("Failed to fetch roles:",
|
|
1105
|
+
const { roles: $ } = await G.getRolesByApp(t);
|
|
1106
|
+
A($);
|
|
1107
|
+
} catch ($) {
|
|
1108
|
+
console.error("Failed to fetch roles:", $);
|
|
932
1109
|
} finally {
|
|
933
1110
|
P(!1);
|
|
934
1111
|
}
|
|
935
|
-
},
|
|
936
|
-
await
|
|
937
|
-
},
|
|
938
|
-
if (!
|
|
1112
|
+
}, Fe = async () => {
|
|
1113
|
+
await Le();
|
|
1114
|
+
}, me = ($) => {
|
|
1115
|
+
if (!w || w.length === 0)
|
|
939
1116
|
return !1;
|
|
940
|
-
if (typeof
|
|
941
|
-
return
|
|
942
|
-
const
|
|
943
|
-
return
|
|
1117
|
+
if (typeof $ == "string")
|
|
1118
|
+
return w.includes($);
|
|
1119
|
+
const U = `${$.resource}.${$.action}`;
|
|
1120
|
+
return w.includes(U);
|
|
944
1121
|
};
|
|
945
1122
|
return {
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
1123
|
+
// RFC-003: Authentication state
|
|
1124
|
+
isAuthenticated: M,
|
|
1125
|
+
sessionManager: u,
|
|
1126
|
+
authenticatedHttpService: T,
|
|
1127
|
+
login: d,
|
|
1128
|
+
signup: c,
|
|
1129
|
+
signupTenantAdmin: y,
|
|
1130
|
+
sendMagicLink: B,
|
|
1131
|
+
verifyMagicLink: O,
|
|
1132
|
+
changePassword: W,
|
|
1133
|
+
requestPasswordReset: ee,
|
|
1134
|
+
confirmPasswordReset: z,
|
|
1135
|
+
refreshToken: D,
|
|
1136
|
+
logout: _,
|
|
1137
|
+
setTokens: ge,
|
|
1138
|
+
hasValidSession: Re,
|
|
1139
|
+
clearSession: Ce,
|
|
1140
|
+
currentUser: b,
|
|
1141
|
+
isUserLoading: h,
|
|
1142
|
+
userError: L,
|
|
1143
|
+
loadUserData: g,
|
|
1144
|
+
refreshUser: f,
|
|
1145
|
+
userRole: V,
|
|
1146
|
+
userPermissions: w,
|
|
1147
|
+
availableRoles: I,
|
|
1148
|
+
rolesLoading: x,
|
|
1149
|
+
hasPermission: me,
|
|
1150
|
+
hasAnyPermission: ($) => $.some((U) => me(U)),
|
|
1151
|
+
hasAllPermissions: ($) => $.every((U) => me(U)),
|
|
1152
|
+
getUserPermissionStrings: () => w || [],
|
|
1153
|
+
refreshRoles: Fe
|
|
974
1154
|
};
|
|
975
1155
|
}, [
|
|
976
|
-
|
|
977
|
-
U,
|
|
1156
|
+
M,
|
|
978
1157
|
u,
|
|
979
|
-
|
|
980
|
-
|
|
1158
|
+
T,
|
|
1159
|
+
R,
|
|
1160
|
+
H,
|
|
1161
|
+
G,
|
|
981
1162
|
t,
|
|
1163
|
+
s,
|
|
1164
|
+
a,
|
|
1165
|
+
p,
|
|
1166
|
+
I,
|
|
982
1167
|
b,
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1168
|
+
h,
|
|
1169
|
+
L,
|
|
1170
|
+
V,
|
|
1171
|
+
w,
|
|
1172
|
+
q,
|
|
1173
|
+
E
|
|
988
1174
|
]);
|
|
989
|
-
return
|
|
1175
|
+
return te(() => {
|
|
990
1176
|
!i.initialRoles && t && (async () => {
|
|
991
1177
|
try {
|
|
992
1178
|
P(!0);
|
|
993
|
-
const
|
|
994
|
-
|
|
995
|
-
} catch (
|
|
996
|
-
console.error("Failed to fetch roles:",
|
|
1179
|
+
const f = new re(r), d = new Se(f), { roles: c } = await d.getRolesByApp(t);
|
|
1180
|
+
A(c);
|
|
1181
|
+
} catch (f) {
|
|
1182
|
+
console.error("Failed to fetch roles:", f);
|
|
997
1183
|
} finally {
|
|
998
1184
|
P(!1);
|
|
999
1185
|
}
|
|
1000
1186
|
})();
|
|
1001
|
-
}, [t, r, i.initialRoles]),
|
|
1002
|
-
const
|
|
1003
|
-
|
|
1004
|
-
}, [
|
|
1187
|
+
}, [t, r, i.initialRoles]), te(() => {
|
|
1188
|
+
const g = u.getUser();
|
|
1189
|
+
g && u.hasValidSession() && m(g);
|
|
1190
|
+
}, [u]), te(() => {
|
|
1191
|
+
!b && !h && o.loadUserData().catch(() => {
|
|
1192
|
+
});
|
|
1193
|
+
}, [b, h, o]), te(() => {
|
|
1194
|
+
if (!u.hasValidSession() || !b)
|
|
1195
|
+
return;
|
|
1196
|
+
const g = setInterval(() => {
|
|
1197
|
+
o.loadUserData().catch(() => {
|
|
1198
|
+
});
|
|
1199
|
+
}, E);
|
|
1200
|
+
return () => clearInterval(g);
|
|
1201
|
+
}, [u, b, o, E]), /* @__PURE__ */ n(Te.Provider, { value: o, children: e });
|
|
1005
1202
|
}
|
|
1006
|
-
function
|
|
1007
|
-
const i =
|
|
1203
|
+
function oe() {
|
|
1204
|
+
const i = ue(Te);
|
|
1008
1205
|
if (!i)
|
|
1009
1206
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
1010
1207
|
return i;
|
|
1011
1208
|
}
|
|
1012
|
-
class
|
|
1209
|
+
class ze {
|
|
1013
1210
|
constructor(e, t) {
|
|
1014
1211
|
this.httpService = e, this.sessionManager = t;
|
|
1015
1212
|
}
|
|
@@ -1089,58 +1286,58 @@ class He {
|
|
|
1089
1286
|
})).data;
|
|
1090
1287
|
}
|
|
1091
1288
|
}
|
|
1092
|
-
const
|
|
1093
|
-
function
|
|
1094
|
-
const { baseUrl: t, appId: r } =
|
|
1095
|
-
const
|
|
1096
|
-
return new
|
|
1097
|
-
}, [t]),
|
|
1289
|
+
const Me = de(null);
|
|
1290
|
+
function Tt({ config: i = {}, children: e }) {
|
|
1291
|
+
const { baseUrl: t, appId: r } = he(), { tenant: s } = se(), [a, p] = v([]), [I, A] = v(!1), [x, P] = v(null), b = Q(() => {
|
|
1292
|
+
const S = new re(t);
|
|
1293
|
+
return new ze(S);
|
|
1294
|
+
}, [t]), m = async () => {
|
|
1098
1295
|
if (!(s != null && s.id)) {
|
|
1099
|
-
|
|
1296
|
+
p([]);
|
|
1100
1297
|
return;
|
|
1101
1298
|
}
|
|
1102
|
-
|
|
1299
|
+
A(!0), P(null);
|
|
1103
1300
|
try {
|
|
1104
|
-
const
|
|
1105
|
-
|
|
1106
|
-
} catch (
|
|
1107
|
-
const
|
|
1108
|
-
|
|
1301
|
+
const S = await b.getTenantFeatureFlags(s.id, r);
|
|
1302
|
+
p(S);
|
|
1303
|
+
} catch (S) {
|
|
1304
|
+
const L = S instanceof Error ? S.message : "Failed to fetch feature flags";
|
|
1305
|
+
P(L), i.onError && i.onError(S instanceof Error ? S : new Error(L));
|
|
1109
1306
|
} finally {
|
|
1110
|
-
|
|
1307
|
+
A(!1);
|
|
1111
1308
|
}
|
|
1112
1309
|
};
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
const
|
|
1116
|
-
return () => clearInterval(
|
|
1310
|
+
te(() => {
|
|
1311
|
+
m();
|
|
1312
|
+
const S = i.refreshInterval || 5 * 60 * 1e3, L = setInterval(m, S);
|
|
1313
|
+
return () => clearInterval(L);
|
|
1117
1314
|
}, [s == null ? void 0 : s.id, i.refreshInterval]);
|
|
1118
|
-
const
|
|
1315
|
+
const h = Q(() => ({
|
|
1119
1316
|
featureFlags: a,
|
|
1120
|
-
loading:
|
|
1121
|
-
error:
|
|
1122
|
-
isEnabled: (
|
|
1123
|
-
const
|
|
1124
|
-
return (
|
|
1317
|
+
loading: I,
|
|
1318
|
+
error: x,
|
|
1319
|
+
isEnabled: (k) => {
|
|
1320
|
+
const u = a.find((T) => T.key === k);
|
|
1321
|
+
return (u == null ? void 0 : u.value) === !0;
|
|
1125
1322
|
},
|
|
1126
|
-
getFlag: (
|
|
1127
|
-
getFlagState: (
|
|
1128
|
-
const
|
|
1129
|
-
return
|
|
1323
|
+
getFlag: (k) => a.find((u) => u.key === k),
|
|
1324
|
+
getFlagState: (k) => {
|
|
1325
|
+
const u = a.find((T) => T.key === k);
|
|
1326
|
+
return u ? u.value ? "enabled" : "disabled" : "not_found";
|
|
1130
1327
|
},
|
|
1131
1328
|
refresh: async () => {
|
|
1132
|
-
await
|
|
1329
|
+
await m();
|
|
1133
1330
|
}
|
|
1134
|
-
}), [a,
|
|
1135
|
-
return /* @__PURE__ */ n(
|
|
1331
|
+
}), [a, I, x]);
|
|
1332
|
+
return /* @__PURE__ */ n(Me.Provider, { value: h, children: e });
|
|
1136
1333
|
}
|
|
1137
|
-
function
|
|
1138
|
-
const i =
|
|
1334
|
+
function Oe() {
|
|
1335
|
+
const i = ue(Me);
|
|
1139
1336
|
if (!i)
|
|
1140
1337
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1141
1338
|
return i;
|
|
1142
1339
|
}
|
|
1143
|
-
class
|
|
1340
|
+
class je {
|
|
1144
1341
|
constructor(e, t) {
|
|
1145
1342
|
this.httpService = e, this.sessionManager = t;
|
|
1146
1343
|
}
|
|
@@ -1206,64 +1403,64 @@ class De {
|
|
|
1206
1403
|
)).data;
|
|
1207
1404
|
}
|
|
1208
1405
|
}
|
|
1209
|
-
const
|
|
1210
|
-
function
|
|
1211
|
-
const { baseUrl: t } =
|
|
1212
|
-
const
|
|
1213
|
-
return new
|
|
1214
|
-
}, [t]),
|
|
1406
|
+
const Ie = de(void 0);
|
|
1407
|
+
function Mt({ config: i = {}, children: e }) {
|
|
1408
|
+
const { baseUrl: t } = he(), { tenant: r } = se(), [s, a] = v(null), [p, I] = v(!1), [A, x] = v(null), P = Q(() => {
|
|
1409
|
+
const h = new re(t);
|
|
1410
|
+
return new je(h);
|
|
1411
|
+
}, [t]), b = async () => {
|
|
1215
1412
|
if (!(r != null && r.id)) {
|
|
1216
1413
|
a(null);
|
|
1217
1414
|
return;
|
|
1218
1415
|
}
|
|
1219
|
-
|
|
1416
|
+
I(!0), x(null);
|
|
1220
1417
|
try {
|
|
1221
|
-
const
|
|
1222
|
-
a(
|
|
1223
|
-
} catch (
|
|
1224
|
-
const
|
|
1225
|
-
|
|
1418
|
+
const h = await P.getTenantSubscriptionFeatures(r.id);
|
|
1419
|
+
a(h);
|
|
1420
|
+
} catch (h) {
|
|
1421
|
+
const S = h instanceof Error ? h.message : "Failed to fetch subscription";
|
|
1422
|
+
x(S), i.onError && i.onError(h instanceof Error ? h : new Error(S));
|
|
1226
1423
|
} finally {
|
|
1227
|
-
|
|
1424
|
+
I(!1);
|
|
1228
1425
|
}
|
|
1229
1426
|
};
|
|
1230
|
-
|
|
1231
|
-
if (
|
|
1232
|
-
const
|
|
1233
|
-
return () => clearInterval(
|
|
1427
|
+
te(() => {
|
|
1428
|
+
if (b(), !i.refreshInterval) return;
|
|
1429
|
+
const h = i.refreshInterval || 10 * 60 * 1e3, S = setInterval(b, h);
|
|
1430
|
+
return () => clearInterval(S);
|
|
1234
1431
|
}, [r == null ? void 0 : r.id, i.refreshInterval]);
|
|
1235
|
-
const
|
|
1236
|
-
const
|
|
1432
|
+
const m = Q(() => {
|
|
1433
|
+
const h = (s == null ? void 0 : s.features) || [];
|
|
1237
1434
|
return {
|
|
1238
1435
|
subscription: s,
|
|
1239
|
-
features:
|
|
1240
|
-
loading:
|
|
1241
|
-
error:
|
|
1242
|
-
isFeatureEnabled: (
|
|
1243
|
-
const
|
|
1244
|
-
return
|
|
1436
|
+
features: h,
|
|
1437
|
+
loading: p,
|
|
1438
|
+
error: A,
|
|
1439
|
+
isFeatureEnabled: (u) => {
|
|
1440
|
+
const T = h.find((R) => R.key === u);
|
|
1441
|
+
return T ? T.type === "BOOLEAN" || T.type === "boolean" ? T.value === !0 : !!T.value : !1;
|
|
1245
1442
|
},
|
|
1246
|
-
getFeature: (
|
|
1247
|
-
getFeatureValue: (
|
|
1248
|
-
const
|
|
1249
|
-
return
|
|
1443
|
+
getFeature: (u) => h.find((T) => T.key === u),
|
|
1444
|
+
getFeatureValue: (u, T) => {
|
|
1445
|
+
const R = h.find((H) => H.key === u);
|
|
1446
|
+
return R ? R.value : T;
|
|
1250
1447
|
},
|
|
1251
|
-
hasAllowedPlan: (
|
|
1448
|
+
hasAllowedPlan: (u) => !s || !s.isActive ? !1 : u.includes(s.planId),
|
|
1252
1449
|
refresh: async () => {
|
|
1253
|
-
await
|
|
1450
|
+
await b();
|
|
1254
1451
|
}
|
|
1255
1452
|
};
|
|
1256
|
-
}, [s,
|
|
1257
|
-
return /* @__PURE__ */ n(
|
|
1453
|
+
}, [s, p, A]);
|
|
1454
|
+
return /* @__PURE__ */ n(Ie.Provider, { value: m, children: e });
|
|
1258
1455
|
}
|
|
1259
|
-
function
|
|
1260
|
-
const i =
|
|
1456
|
+
function Ve() {
|
|
1457
|
+
const i = ue(Ie);
|
|
1261
1458
|
if (i === void 0)
|
|
1262
1459
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1263
1460
|
return i;
|
|
1264
1461
|
}
|
|
1265
|
-
var
|
|
1266
|
-
const
|
|
1462
|
+
var ie = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(ie || {});
|
|
1463
|
+
const ve = () => /* @__PURE__ */ l(
|
|
1267
1464
|
"div",
|
|
1268
1465
|
{
|
|
1269
1466
|
style: {
|
|
@@ -1300,7 +1497,7 @@ const me = () => /* @__PURE__ */ l(
|
|
|
1300
1497
|
)
|
|
1301
1498
|
]
|
|
1302
1499
|
}
|
|
1303
|
-
),
|
|
1500
|
+
), xe = ({
|
|
1304
1501
|
userType: i,
|
|
1305
1502
|
minUserType: e,
|
|
1306
1503
|
missingPermissions: t
|
|
@@ -1322,7 +1519,7 @@ const me = () => /* @__PURE__ */ l(
|
|
|
1322
1519
|
children: [
|
|
1323
1520
|
/* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
|
|
1324
1521
|
/* @__PURE__ */ n("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
|
|
1325
|
-
e && i ? /* @__PURE__ */ l(
|
|
1522
|
+
e && i ? /* @__PURE__ */ l(N, { children: [
|
|
1326
1523
|
/* @__PURE__ */ l("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
|
|
1327
1524
|
"This content requires ",
|
|
1328
1525
|
/* @__PURE__ */ n("strong", { children: e }),
|
|
@@ -1332,7 +1529,7 @@ const me = () => /* @__PURE__ */ l(
|
|
|
1332
1529
|
"Your current access level: ",
|
|
1333
1530
|
/* @__PURE__ */ n("strong", { children: i })
|
|
1334
1531
|
] })
|
|
1335
|
-
] }) : /* @__PURE__ */ l(
|
|
1532
|
+
] }) : /* @__PURE__ */ l(N, { children: [
|
|
1336
1533
|
/* @__PURE__ */ n("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
|
|
1337
1534
|
t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1338
1535
|
"Required permissions: ",
|
|
@@ -1341,36 +1538,36 @@ const me = () => /* @__PURE__ */ l(
|
|
|
1341
1538
|
] })
|
|
1342
1539
|
]
|
|
1343
1540
|
}
|
|
1344
|
-
),
|
|
1541
|
+
), We = (i, e) => {
|
|
1345
1542
|
const t = {
|
|
1346
|
-
[
|
|
1347
|
-
[
|
|
1348
|
-
[
|
|
1543
|
+
[ie.USER]: 1,
|
|
1544
|
+
[ie.TENANT_ADMIN]: 2,
|
|
1545
|
+
[ie.SUPERUSER]: 3
|
|
1349
1546
|
};
|
|
1350
1547
|
return t[i] >= t[e];
|
|
1351
1548
|
};
|
|
1352
|
-
function
|
|
1549
|
+
function It({
|
|
1353
1550
|
children: i,
|
|
1354
1551
|
fallback: e,
|
|
1355
1552
|
minUserType: t,
|
|
1356
1553
|
requiredPermissions: r,
|
|
1357
1554
|
requireAllPermissions: s = !1
|
|
1358
1555
|
}) {
|
|
1359
|
-
const { hasValidSession: a, sessionManager:
|
|
1556
|
+
const { hasValidSession: a, sessionManager: p, hasPermission: I, hasAnyPermission: A, hasAllPermissions: x } = oe();
|
|
1360
1557
|
if (!a())
|
|
1361
|
-
return /* @__PURE__ */ n(
|
|
1362
|
-
const
|
|
1363
|
-
if (!
|
|
1364
|
-
return /* @__PURE__ */ n(
|
|
1365
|
-
if (t && !
|
|
1366
|
-
return /* @__PURE__ */ n(
|
|
1367
|
-
if (r && r.length > 0 && !(s ?
|
|
1368
|
-
const
|
|
1369
|
-
return /* @__PURE__ */ n(
|
|
1370
|
-
}
|
|
1371
|
-
return /* @__PURE__ */ n(
|
|
1558
|
+
return /* @__PURE__ */ n(N, { children: e || /* @__PURE__ */ n(ve, {}) });
|
|
1559
|
+
const P = p.getUser();
|
|
1560
|
+
if (!P)
|
|
1561
|
+
return /* @__PURE__ */ n(N, { children: e || /* @__PURE__ */ n(ve, {}) });
|
|
1562
|
+
if (t && !We(P.userType, t))
|
|
1563
|
+
return /* @__PURE__ */ n(xe, { userType: P.userType, minUserType: t });
|
|
1564
|
+
if (r && r.length > 0 && !(s ? x(r) : A(r))) {
|
|
1565
|
+
const m = r.filter((h) => !I(h)).map((h) => typeof h == "string" ? h : h.name);
|
|
1566
|
+
return /* @__PURE__ */ n(xe, { missingPermissions: m });
|
|
1567
|
+
}
|
|
1568
|
+
return /* @__PURE__ */ n(N, { children: i });
|
|
1372
1569
|
}
|
|
1373
|
-
const
|
|
1570
|
+
const Ge = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1374
1571
|
"div",
|
|
1375
1572
|
{
|
|
1376
1573
|
style: {
|
|
@@ -1406,7 +1603,7 @@ const qe = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1406
1603
|
}
|
|
1407
1604
|
)
|
|
1408
1605
|
}
|
|
1409
|
-
),
|
|
1606
|
+
), ke = ({
|
|
1410
1607
|
userType: i,
|
|
1411
1608
|
minUserType: e,
|
|
1412
1609
|
missingPermissions: t
|
|
@@ -1436,7 +1633,7 @@ const qe = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1436
1633
|
children: [
|
|
1437
1634
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
|
|
1438
1635
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
|
|
1439
|
-
e && i ? /* @__PURE__ */ l(
|
|
1636
|
+
e && i ? /* @__PURE__ */ l(N, { children: [
|
|
1440
1637
|
/* @__PURE__ */ l("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
|
|
1441
1638
|
"This page requires ",
|
|
1442
1639
|
/* @__PURE__ */ n("strong", { children: e }),
|
|
@@ -1446,7 +1643,7 @@ const qe = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1446
1643
|
"Your current access level: ",
|
|
1447
1644
|
/* @__PURE__ */ n("strong", { children: i })
|
|
1448
1645
|
] })
|
|
1449
|
-
] }) : /* @__PURE__ */ l(
|
|
1646
|
+
] }) : /* @__PURE__ */ l(N, { children: [
|
|
1450
1647
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
|
|
1451
1648
|
t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1452
1649
|
"Required permissions: ",
|
|
@@ -1457,15 +1654,15 @@ const qe = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1457
1654
|
}
|
|
1458
1655
|
)
|
|
1459
1656
|
}
|
|
1460
|
-
),
|
|
1657
|
+
), Ke = (i, e) => {
|
|
1461
1658
|
const t = {
|
|
1462
|
-
[
|
|
1463
|
-
[
|
|
1464
|
-
[
|
|
1659
|
+
[ie.USER]: 1,
|
|
1660
|
+
[ie.TENANT_ADMIN]: 2,
|
|
1661
|
+
[ie.SUPERUSER]: 3
|
|
1465
1662
|
};
|
|
1466
1663
|
return t[i] >= t[e];
|
|
1467
1664
|
};
|
|
1468
|
-
function
|
|
1665
|
+
function Et({
|
|
1469
1666
|
children: i,
|
|
1470
1667
|
redirectTo: e = "/login",
|
|
1471
1668
|
minUserType: t,
|
|
@@ -1473,24 +1670,24 @@ function St({
|
|
|
1473
1670
|
requireAllPermissions: s = !1,
|
|
1474
1671
|
fallback: a
|
|
1475
1672
|
}) {
|
|
1476
|
-
const { hasValidSession:
|
|
1477
|
-
if (!
|
|
1478
|
-
return a ? /* @__PURE__ */ n(
|
|
1479
|
-
/* @__PURE__ */ n(
|
|
1480
|
-
/* @__PURE__ */ n(
|
|
1673
|
+
const { hasValidSession: p, sessionManager: I, hasPermission: A, hasAnyPermission: x, hasAllPermissions: P } = oe(), b = we();
|
|
1674
|
+
if (!p())
|
|
1675
|
+
return a ? /* @__PURE__ */ n(N, { children: a }) : /* @__PURE__ */ l(N, { children: [
|
|
1676
|
+
/* @__PURE__ */ n(Ge, { redirectPath: e }),
|
|
1677
|
+
/* @__PURE__ */ n(pe, { to: e, state: { from: b.pathname }, replace: !0 })
|
|
1481
1678
|
] });
|
|
1482
|
-
const
|
|
1483
|
-
if (!
|
|
1484
|
-
return /* @__PURE__ */ n(
|
|
1485
|
-
if (t && !
|
|
1486
|
-
return /* @__PURE__ */ n(
|
|
1487
|
-
if (r && r.length > 0 && !(s ?
|
|
1488
|
-
const
|
|
1489
|
-
return /* @__PURE__ */ n(
|
|
1490
|
-
}
|
|
1491
|
-
return /* @__PURE__ */ n(
|
|
1679
|
+
const m = I.getUser();
|
|
1680
|
+
if (!m)
|
|
1681
|
+
return /* @__PURE__ */ n(pe, { to: e, state: { from: b.pathname }, replace: !0 });
|
|
1682
|
+
if (t && !Ke(m.userType, t))
|
|
1683
|
+
return /* @__PURE__ */ n(ke, { userType: m.userType, minUserType: t });
|
|
1684
|
+
if (r && r.length > 0 && !(s ? P(r) : x(r))) {
|
|
1685
|
+
const S = r.filter((L) => !A(L)).map((L) => typeof L == "string" ? L : L.name);
|
|
1686
|
+
return /* @__PURE__ */ n(ke, { missingPermissions: S });
|
|
1687
|
+
}
|
|
1688
|
+
return /* @__PURE__ */ n(N, { children: i });
|
|
1492
1689
|
}
|
|
1493
|
-
const
|
|
1690
|
+
const _e = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1494
1691
|
"div",
|
|
1495
1692
|
{
|
|
1496
1693
|
style: {
|
|
@@ -1527,14 +1724,14 @@ const ze = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1527
1724
|
)
|
|
1528
1725
|
}
|
|
1529
1726
|
);
|
|
1530
|
-
function
|
|
1531
|
-
const { tenant: r, isLoading: s, error: a } =
|
|
1532
|
-
return s || a ? null : r ? /* @__PURE__ */ n(
|
|
1533
|
-
/* @__PURE__ */ n(
|
|
1534
|
-
/* @__PURE__ */ n(
|
|
1727
|
+
function Rt({ children: i, redirectTo: e = "/", fallback: t }) {
|
|
1728
|
+
const { tenant: r, isLoading: s, error: a } = se(), p = we();
|
|
1729
|
+
return s || a ? null : r ? /* @__PURE__ */ n(N, { children: i }) : t ? /* @__PURE__ */ n(N, { children: t }) : /* @__PURE__ */ l(N, { children: [
|
|
1730
|
+
/* @__PURE__ */ n(_e, { redirectPath: e }),
|
|
1731
|
+
/* @__PURE__ */ n(pe, { to: e, state: { from: p.pathname }, replace: !0 })
|
|
1535
1732
|
] });
|
|
1536
1733
|
}
|
|
1537
|
-
const
|
|
1734
|
+
const Je = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1538
1735
|
"div",
|
|
1539
1736
|
{
|
|
1540
1737
|
style: {
|
|
@@ -1571,14 +1768,14 @@ const Oe = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1571
1768
|
)
|
|
1572
1769
|
}
|
|
1573
1770
|
);
|
|
1574
|
-
function
|
|
1575
|
-
const { tenant: r, isLoading: s, error: a } =
|
|
1576
|
-
return s || a ? null : r ? t ? /* @__PURE__ */ n(
|
|
1577
|
-
/* @__PURE__ */ n(
|
|
1578
|
-
/* @__PURE__ */ n(
|
|
1579
|
-
] }) : /* @__PURE__ */ n(
|
|
1771
|
+
function Ct({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
|
|
1772
|
+
const { tenant: r, isLoading: s, error: a } = se(), p = we();
|
|
1773
|
+
return s || a ? null : r ? t ? /* @__PURE__ */ n(N, { children: t }) : /* @__PURE__ */ l(N, { children: [
|
|
1774
|
+
/* @__PURE__ */ n(Je, { redirectPath: e }),
|
|
1775
|
+
/* @__PURE__ */ n(pe, { to: e, state: { from: p.pathname }, replace: !0 })
|
|
1776
|
+
] }) : /* @__PURE__ */ n(N, { children: i });
|
|
1580
1777
|
}
|
|
1581
|
-
const
|
|
1778
|
+
const Ye = () => /* @__PURE__ */ l(
|
|
1582
1779
|
"div",
|
|
1583
1780
|
{
|
|
1584
1781
|
style: {
|
|
@@ -1595,14 +1792,14 @@ const je = () => /* @__PURE__ */ l(
|
|
|
1595
1792
|
]
|
|
1596
1793
|
}
|
|
1597
1794
|
);
|
|
1598
|
-
function
|
|
1795
|
+
function Lt({
|
|
1599
1796
|
children: i,
|
|
1600
|
-
fallback: e = /* @__PURE__ */ n(
|
|
1797
|
+
fallback: e = /* @__PURE__ */ n(Ye, {}),
|
|
1601
1798
|
allowedPlans: t,
|
|
1602
1799
|
requiredFeature: r
|
|
1603
1800
|
}) {
|
|
1604
|
-
const { subscription: s, hasAllowedPlan: a, isFeatureEnabled:
|
|
1605
|
-
return
|
|
1801
|
+
const { subscription: s, hasAllowedPlan: a, isFeatureEnabled: p, loading: I } = Ve();
|
|
1802
|
+
return I ? /* @__PURE__ */ n(
|
|
1606
1803
|
"div",
|
|
1607
1804
|
{
|
|
1608
1805
|
style: {
|
|
@@ -1612,9 +1809,9 @@ function At({
|
|
|
1612
1809
|
},
|
|
1613
1810
|
children: "Loading subscription..."
|
|
1614
1811
|
}
|
|
1615
|
-
) : s ? s.isActive ? t && t.length > 0 && !a(t) ? /* @__PURE__ */ n(
|
|
1812
|
+
) : s ? s.isActive ? t && t.length > 0 && !a(t) ? /* @__PURE__ */ n(N, { children: e }) : r && !p(r) ? /* @__PURE__ */ n(N, { children: e }) : /* @__PURE__ */ n(N, { children: i }) : /* @__PURE__ */ n(N, { children: e }) : /* @__PURE__ */ n(N, { children: e });
|
|
1616
1813
|
}
|
|
1617
|
-
const
|
|
1814
|
+
const Qe = ({ flagName: i }) => /* @__PURE__ */ l(
|
|
1618
1815
|
"div",
|
|
1619
1816
|
{
|
|
1620
1817
|
style: {
|
|
@@ -1641,8 +1838,8 @@ const We = ({ flagName: i }) => /* @__PURE__ */ l(
|
|
|
1641
1838
|
]
|
|
1642
1839
|
}
|
|
1643
1840
|
);
|
|
1644
|
-
function
|
|
1645
|
-
const { isEnabled: r, loading: s } =
|
|
1841
|
+
function Ft({ name: i, children: e, fallback: t }) {
|
|
1842
|
+
const { isEnabled: r, loading: s } = Oe();
|
|
1646
1843
|
return s ? /* @__PURE__ */ n(
|
|
1647
1844
|
"div",
|
|
1648
1845
|
{
|
|
@@ -1656,9 +1853,9 @@ function Pt({ name: i, children: e, fallback: t }) {
|
|
|
1656
1853
|
},
|
|
1657
1854
|
children: "Loading feature flags..."
|
|
1658
1855
|
}
|
|
1659
|
-
) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */ n(
|
|
1856
|
+
) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */ n(N, { children: e }) : /* @__PURE__ */ n(N, { children: t || /* @__PURE__ */ n(Qe, { flagName: i }) }));
|
|
1660
1857
|
}
|
|
1661
|
-
const
|
|
1858
|
+
const Xe = () => /* @__PURE__ */ l(
|
|
1662
1859
|
"svg",
|
|
1663
1860
|
{
|
|
1664
1861
|
width: "16",
|
|
@@ -1675,7 +1872,7 @@ const Ve = () => /* @__PURE__ */ l(
|
|
|
1675
1872
|
/* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "3" })
|
|
1676
1873
|
]
|
|
1677
1874
|
}
|
|
1678
|
-
),
|
|
1875
|
+
), Ze = () => /* @__PURE__ */ l(
|
|
1679
1876
|
"svg",
|
|
1680
1877
|
{
|
|
1681
1878
|
width: "16",
|
|
@@ -1692,10 +1889,10 @@ const Ve = () => /* @__PURE__ */ l(
|
|
|
1692
1889
|
/* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
1693
1890
|
]
|
|
1694
1891
|
}
|
|
1695
|
-
),
|
|
1696
|
-
showPassword: /* @__PURE__ */ n(
|
|
1697
|
-
hidePassword: /* @__PURE__ */ n(
|
|
1698
|
-
},
|
|
1892
|
+
), et = {
|
|
1893
|
+
showPassword: /* @__PURE__ */ n(Xe, {}),
|
|
1894
|
+
hidePassword: /* @__PURE__ */ n(Ze, {})
|
|
1895
|
+
}, tt = {
|
|
1699
1896
|
title: "Sign In",
|
|
1700
1897
|
usernameLabel: "Email or Phone",
|
|
1701
1898
|
usernamePlaceholder: "Enter your email or phone number",
|
|
@@ -1709,7 +1906,7 @@ const Ve = () => /* @__PURE__ */ l(
|
|
|
1709
1906
|
magicLinkLink: "Use Magic Link",
|
|
1710
1907
|
errorMessage: "Invalid credentials",
|
|
1711
1908
|
loadingText: "Signing in..."
|
|
1712
|
-
},
|
|
1909
|
+
}, rt = {
|
|
1713
1910
|
container: {
|
|
1714
1911
|
maxWidth: "400px",
|
|
1715
1912
|
width: "100%",
|
|
@@ -1816,129 +2013,133 @@ const Ve = () => /* @__PURE__ */ l(
|
|
|
1816
2013
|
fontSize: "0.875rem"
|
|
1817
2014
|
}
|
|
1818
2015
|
};
|
|
1819
|
-
function
|
|
2016
|
+
function $t({
|
|
1820
2017
|
copy: i = {},
|
|
1821
2018
|
styles: e = {},
|
|
1822
2019
|
icons: t = {},
|
|
1823
2020
|
onSuccess: r,
|
|
1824
2021
|
onError: s,
|
|
1825
2022
|
onForgotPassword: a,
|
|
1826
|
-
onSignupClick:
|
|
1827
|
-
onMagicLinkClick:
|
|
1828
|
-
showForgotPassword:
|
|
1829
|
-
showSignupLink:
|
|
1830
|
-
showMagicLinkOption:
|
|
1831
|
-
className:
|
|
2023
|
+
onSignupClick: p,
|
|
2024
|
+
onMagicLinkClick: I,
|
|
2025
|
+
showForgotPassword: A = !0,
|
|
2026
|
+
showSignupLink: x = !0,
|
|
2027
|
+
showMagicLinkOption: P = !0,
|
|
2028
|
+
className: b
|
|
1832
2029
|
}) {
|
|
1833
|
-
const [
|
|
1834
|
-
const
|
|
1835
|
-
return
|
|
1836
|
-
},
|
|
1837
|
-
if (
|
|
1838
|
-
if (!(
|
|
1839
|
-
|
|
2030
|
+
const [m, h] = v(""), [S, L] = v(""), [C, q] = v(!1), [k, u] = v(!1), [T, R] = v(""), [H, G] = v({}), { login: F } = oe(), { tenant: V } = se(), w = { ...tt, ...i }, M = { ...rt, ...e }, E = { ...et, ...t }, o = () => {
|
|
2031
|
+
const c = {};
|
|
2032
|
+
return m.trim() || (c.username = !0), S.trim() || (c.password = !0), G(c), Object.keys(c).length === 0;
|
|
2033
|
+
}, g = async (c) => {
|
|
2034
|
+
if (c.preventDefault(), !!o()) {
|
|
2035
|
+
if (!(V != null && V.id)) {
|
|
2036
|
+
R("Tenant not found");
|
|
1840
2037
|
return;
|
|
1841
2038
|
}
|
|
1842
|
-
|
|
2039
|
+
u(!0), R("");
|
|
1843
2040
|
try {
|
|
1844
|
-
const
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
2041
|
+
const y = await F({
|
|
2042
|
+
username: m,
|
|
2043
|
+
password: S
|
|
2044
|
+
// tenantId inferred from context automatically
|
|
2045
|
+
});
|
|
2046
|
+
r == null || r(y);
|
|
2047
|
+
} catch (y) {
|
|
2048
|
+
const W = y.message || w.errorMessage;
|
|
2049
|
+
R(W), s == null || s(W);
|
|
1849
2050
|
} finally {
|
|
1850
|
-
|
|
2051
|
+
u(!1);
|
|
1851
2052
|
}
|
|
1852
2053
|
}
|
|
1853
|
-
},
|
|
1854
|
-
...
|
|
1855
|
-
...
|
|
1856
|
-
}),
|
|
1857
|
-
...
|
|
1858
|
-
...
|
|
1859
|
-
...!
|
|
2054
|
+
}, f = (c) => ({
|
|
2055
|
+
...M.input,
|
|
2056
|
+
...H[c] ? M.inputError : {}
|
|
2057
|
+
}), d = () => ({
|
|
2058
|
+
...M.button,
|
|
2059
|
+
...k ? M.buttonLoading : {},
|
|
2060
|
+
...!m || !S || k ? M.buttonDisabled : {}
|
|
1860
2061
|
});
|
|
1861
|
-
return /* @__PURE__ */ l("div", { className:
|
|
1862
|
-
/* @__PURE__ */ n("h2", { style:
|
|
1863
|
-
/* @__PURE__ */ l("form", { onSubmit:
|
|
1864
|
-
/* @__PURE__ */ l("div", { style:
|
|
1865
|
-
/* @__PURE__ */ n("label", { style:
|
|
2062
|
+
return /* @__PURE__ */ l("div", { className: b, style: M.container, children: [
|
|
2063
|
+
/* @__PURE__ */ n("h2", { style: M.title, children: w.title }),
|
|
2064
|
+
/* @__PURE__ */ l("form", { onSubmit: g, style: M.form, children: [
|
|
2065
|
+
/* @__PURE__ */ l("div", { style: M.fieldGroup, children: [
|
|
2066
|
+
/* @__PURE__ */ n("label", { style: M.label, children: w.usernameLabel }),
|
|
1866
2067
|
/* @__PURE__ */ n(
|
|
1867
2068
|
"input",
|
|
1868
2069
|
{
|
|
1869
2070
|
id: "username",
|
|
1870
2071
|
name: "username",
|
|
1871
2072
|
type: "text",
|
|
1872
|
-
value:
|
|
1873
|
-
onChange: (
|
|
1874
|
-
|
|
2073
|
+
value: m,
|
|
2074
|
+
onChange: (c) => {
|
|
2075
|
+
h(c.target.value), H.username && G((y) => ({ ...y, username: !1 }));
|
|
1875
2076
|
},
|
|
1876
|
-
placeholder:
|
|
1877
|
-
style:
|
|
1878
|
-
disabled:
|
|
2077
|
+
placeholder: w.usernamePlaceholder,
|
|
2078
|
+
style: f("username"),
|
|
2079
|
+
disabled: k
|
|
1879
2080
|
}
|
|
1880
2081
|
)
|
|
1881
2082
|
] }),
|
|
1882
|
-
/* @__PURE__ */ l("div", { style:
|
|
1883
|
-
/* @__PURE__ */ n("label", { style:
|
|
1884
|
-
/* @__PURE__ */ l("div", { style:
|
|
2083
|
+
/* @__PURE__ */ l("div", { style: M.fieldGroup, children: [
|
|
2084
|
+
/* @__PURE__ */ n("label", { style: M.label, children: w.passwordLabel }),
|
|
2085
|
+
/* @__PURE__ */ l("div", { style: M.inputContainer, children: [
|
|
1885
2086
|
/* @__PURE__ */ n(
|
|
1886
2087
|
"input",
|
|
1887
2088
|
{
|
|
1888
2089
|
id: "password",
|
|
1889
2090
|
name: "password",
|
|
1890
|
-
type:
|
|
1891
|
-
value:
|
|
1892
|
-
onChange: (
|
|
1893
|
-
|
|
2091
|
+
type: C ? "text" : "password",
|
|
2092
|
+
value: S,
|
|
2093
|
+
onChange: (c) => {
|
|
2094
|
+
L(c.target.value), H.password && G((y) => ({ ...y, password: !1 }));
|
|
1894
2095
|
},
|
|
1895
|
-
placeholder:
|
|
2096
|
+
placeholder: w.passwordPlaceholder,
|
|
1896
2097
|
style: {
|
|
1897
|
-
...
|
|
2098
|
+
...f("password"),
|
|
1898
2099
|
paddingRight: "2.5rem"
|
|
1899
2100
|
// Make room for the icon
|
|
1900
2101
|
},
|
|
1901
|
-
disabled:
|
|
2102
|
+
disabled: k
|
|
1902
2103
|
}
|
|
1903
2104
|
),
|
|
1904
2105
|
/* @__PURE__ */ n(
|
|
1905
2106
|
"button",
|
|
1906
2107
|
{
|
|
1907
2108
|
type: "button",
|
|
1908
|
-
onClick: () =>
|
|
1909
|
-
style:
|
|
1910
|
-
disabled:
|
|
1911
|
-
"aria-label":
|
|
1912
|
-
children:
|
|
2109
|
+
onClick: () => q(!C),
|
|
2110
|
+
style: M.passwordToggle,
|
|
2111
|
+
disabled: k,
|
|
2112
|
+
"aria-label": C ? "Hide password" : "Show password",
|
|
2113
|
+
children: C ? E.hidePassword : E.showPassword
|
|
1913
2114
|
}
|
|
1914
2115
|
)
|
|
1915
2116
|
] })
|
|
1916
2117
|
] }),
|
|
1917
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !
|
|
1918
|
-
|
|
2118
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !m || !S || k, style: d(), children: k ? w.loadingText : w.submitButton }),
|
|
2119
|
+
T && /* @__PURE__ */ n("div", { style: M.errorText, children: T })
|
|
1919
2120
|
] }),
|
|
1920
|
-
(
|
|
1921
|
-
|
|
1922
|
-
/* @__PURE__ */ l("span", { style:
|
|
1923
|
-
|
|
2121
|
+
(A || x || P) && /* @__PURE__ */ l("div", { style: M.linkContainer, children: [
|
|
2122
|
+
P && /* @__PURE__ */ l("div", { children: [
|
|
2123
|
+
/* @__PURE__ */ l("span", { style: M.divider, children: [
|
|
2124
|
+
w.magicLinkText,
|
|
1924
2125
|
" "
|
|
1925
2126
|
] }),
|
|
1926
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
2127
|
+
/* @__PURE__ */ n("a", { onClick: I, style: M.link, children: w.magicLinkLink })
|
|
1927
2128
|
] }),
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
/* @__PURE__ */ l("span", { style:
|
|
1933
|
-
|
|
2129
|
+
P && (A || x) && /* @__PURE__ */ n("div", { style: M.divider, children: "•" }),
|
|
2130
|
+
A && /* @__PURE__ */ n("a", { onClick: a, style: M.link, children: w.forgotPasswordLink }),
|
|
2131
|
+
A && x && /* @__PURE__ */ n("div", { style: M.divider, children: "•" }),
|
|
2132
|
+
x && /* @__PURE__ */ l("div", { children: [
|
|
2133
|
+
/* @__PURE__ */ l("span", { style: M.divider, children: [
|
|
2134
|
+
w.signupText,
|
|
1934
2135
|
" "
|
|
1935
2136
|
] }),
|
|
1936
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
2137
|
+
/* @__PURE__ */ n("a", { onClick: p, style: M.link, children: w.signupLink })
|
|
1937
2138
|
] })
|
|
1938
2139
|
] })
|
|
1939
2140
|
] });
|
|
1940
2141
|
}
|
|
1941
|
-
const
|
|
2142
|
+
const nt = {
|
|
1942
2143
|
title: "Create Account",
|
|
1943
2144
|
nameLabel: "First Name",
|
|
1944
2145
|
namePlaceholder: "Enter your first name",
|
|
@@ -1964,7 +2165,7 @@ const Qe = {
|
|
|
1964
2165
|
passwordMismatchError: "Passwords do not match",
|
|
1965
2166
|
isAdminLabel: "Create new organization",
|
|
1966
2167
|
isAdminDescription: "Check this if you want to create a new organization"
|
|
1967
|
-
},
|
|
2168
|
+
}, st = {
|
|
1968
2169
|
container: {
|
|
1969
2170
|
maxWidth: "400px",
|
|
1970
2171
|
width: "100%",
|
|
@@ -2063,136 +2264,134 @@ const Qe = {
|
|
|
2063
2264
|
fontSize: "0.875rem"
|
|
2064
2265
|
}
|
|
2065
2266
|
};
|
|
2066
|
-
function
|
|
2267
|
+
function Dt({
|
|
2067
2268
|
copy: i = {},
|
|
2068
2269
|
styles: e = {},
|
|
2069
2270
|
signupType: t = "user",
|
|
2070
2271
|
onSuccess: r,
|
|
2071
2272
|
onError: s,
|
|
2072
2273
|
onLoginClick: a,
|
|
2073
|
-
onMagicLinkClick:
|
|
2074
|
-
showLoginLink:
|
|
2075
|
-
showMagicLinkOption:
|
|
2076
|
-
className:
|
|
2274
|
+
onMagicLinkClick: p,
|
|
2275
|
+
showLoginLink: I = !0,
|
|
2276
|
+
showMagicLinkOption: A = !0,
|
|
2277
|
+
className: x
|
|
2077
2278
|
}) {
|
|
2078
|
-
const [
|
|
2079
|
-
const
|
|
2080
|
-
return
|
|
2081
|
-
},
|
|
2082
|
-
if (
|
|
2083
|
-
if (
|
|
2084
|
-
|
|
2279
|
+
const [P, b] = v(""), [m, h] = v(""), [S, L] = v(""), [C, q] = v(""), [k, u] = v(""), [T, R] = v(""), [H, G] = v(""), [F, V] = v(!1), [w, M] = v(""), [E, o] = v({}), { signup: g, signupTenantAdmin: f } = oe(), { tenant: d } = se(), c = { ...nt, ...i }, y = { ...st, ...e }, W = () => {
|
|
2280
|
+
const D = {};
|
|
2281
|
+
return P.trim() || (D.name = !0), !S.trim() && !C.trim() && (D.email = !0, D.phoneNumber = !0), k.trim() || (D.password = !0), T.trim() || (D.confirmPassword = !0), t === "tenant" && !H.trim() && (D.tenantName = !0), o(D), Object.keys(D).length === 0;
|
|
2282
|
+
}, ee = async (D) => {
|
|
2283
|
+
if (D.preventDefault(), !!W()) {
|
|
2284
|
+
if (k !== T) {
|
|
2285
|
+
M(c.passwordMismatchError), o({ confirmPassword: !0 });
|
|
2085
2286
|
return;
|
|
2086
2287
|
}
|
|
2087
|
-
if (t === "user" && !(
|
|
2088
|
-
|
|
2288
|
+
if (t === "user" && !(d != null && d.id)) {
|
|
2289
|
+
M("Tenant not found");
|
|
2089
2290
|
return;
|
|
2090
2291
|
}
|
|
2091
|
-
|
|
2292
|
+
V(!0), M("");
|
|
2092
2293
|
try {
|
|
2093
|
-
let
|
|
2094
|
-
t === "tenant" ?
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
const ue = V.message || k.errorMessage;
|
|
2113
|
-
h(ue), s == null || s(ue);
|
|
2294
|
+
let _;
|
|
2295
|
+
t === "tenant" ? _ = await f({
|
|
2296
|
+
email: S || void 0,
|
|
2297
|
+
phoneNumber: C || void 0,
|
|
2298
|
+
name: P,
|
|
2299
|
+
password: k,
|
|
2300
|
+
tenantName: H,
|
|
2301
|
+
lastName: m || void 0
|
|
2302
|
+
}) : _ = await g({
|
|
2303
|
+
email: S || void 0,
|
|
2304
|
+
phoneNumber: C || void 0,
|
|
2305
|
+
name: P,
|
|
2306
|
+
password: k,
|
|
2307
|
+
tenantId: d.id,
|
|
2308
|
+
lastName: m || void 0
|
|
2309
|
+
}), r == null || r(_);
|
|
2310
|
+
} catch (_) {
|
|
2311
|
+
const ge = _.message || c.errorMessage;
|
|
2312
|
+
M(ge), s == null || s(ge);
|
|
2114
2313
|
} finally {
|
|
2115
|
-
|
|
2314
|
+
V(!1);
|
|
2116
2315
|
}
|
|
2117
2316
|
}
|
|
2118
|
-
},
|
|
2119
|
-
...
|
|
2120
|
-
...
|
|
2121
|
-
}),
|
|
2122
|
-
...
|
|
2123
|
-
...
|
|
2124
|
-
...!
|
|
2125
|
-
}),
|
|
2126
|
-
return /* @__PURE__ */ l("div", { className:
|
|
2127
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2128
|
-
/* @__PURE__ */ l("form", { onSubmit:
|
|
2129
|
-
/* @__PURE__ */ l("div", { style:
|
|
2130
|
-
/* @__PURE__ */ n("label", { style:
|
|
2317
|
+
}, z = (D) => ({
|
|
2318
|
+
...y.input,
|
|
2319
|
+
...E[D] ? y.inputError : {}
|
|
2320
|
+
}), B = () => ({
|
|
2321
|
+
...y.button,
|
|
2322
|
+
...F ? y.buttonLoading : {},
|
|
2323
|
+
...!P || !S && !C || !k || !T || F || t === "tenant" && !H ? y.buttonDisabled : {}
|
|
2324
|
+
}), O = P && (S || C) && k && T && (t === "user" || H);
|
|
2325
|
+
return /* @__PURE__ */ l("div", { className: x, style: y.container, children: [
|
|
2326
|
+
/* @__PURE__ */ n("h2", { style: y.title, children: c.title }),
|
|
2327
|
+
/* @__PURE__ */ l("form", { onSubmit: ee, style: y.form, children: [
|
|
2328
|
+
/* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
|
|
2329
|
+
/* @__PURE__ */ n("label", { style: y.label, children: c.nameLabel }),
|
|
2131
2330
|
/* @__PURE__ */ n(
|
|
2132
2331
|
"input",
|
|
2133
2332
|
{
|
|
2134
2333
|
id: "name",
|
|
2135
2334
|
name: "name",
|
|
2136
2335
|
type: "text",
|
|
2137
|
-
value:
|
|
2138
|
-
onChange: (
|
|
2139
|
-
|
|
2336
|
+
value: P,
|
|
2337
|
+
onChange: (D) => {
|
|
2338
|
+
b(D.target.value), E.name && o((_) => ({ ..._, name: !1 }));
|
|
2140
2339
|
},
|
|
2141
|
-
placeholder:
|
|
2142
|
-
style:
|
|
2143
|
-
disabled:
|
|
2340
|
+
placeholder: c.namePlaceholder,
|
|
2341
|
+
style: z("name"),
|
|
2342
|
+
disabled: F
|
|
2144
2343
|
}
|
|
2145
2344
|
)
|
|
2146
2345
|
] }),
|
|
2147
|
-
/* @__PURE__ */ l("div", { style:
|
|
2148
|
-
/* @__PURE__ */ n("label", { style:
|
|
2346
|
+
/* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
|
|
2347
|
+
/* @__PURE__ */ n("label", { style: y.label, children: c.lastNameLabel }),
|
|
2149
2348
|
/* @__PURE__ */ n(
|
|
2150
2349
|
"input",
|
|
2151
2350
|
{
|
|
2152
2351
|
id: "lastName",
|
|
2153
2352
|
name: "lastName",
|
|
2154
2353
|
type: "text",
|
|
2155
|
-
value:
|
|
2156
|
-
onChange: (
|
|
2157
|
-
placeholder:
|
|
2158
|
-
style:
|
|
2159
|
-
disabled:
|
|
2354
|
+
value: m,
|
|
2355
|
+
onChange: (D) => h(D.target.value),
|
|
2356
|
+
placeholder: c.lastNamePlaceholder,
|
|
2357
|
+
style: y.input,
|
|
2358
|
+
disabled: F
|
|
2160
2359
|
}
|
|
2161
2360
|
)
|
|
2162
2361
|
] }),
|
|
2163
|
-
/* @__PURE__ */ l("div", { style:
|
|
2164
|
-
/* @__PURE__ */ n("label", { style:
|
|
2362
|
+
/* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
|
|
2363
|
+
/* @__PURE__ */ n("label", { style: y.label, children: c.emailLabel }),
|
|
2165
2364
|
/* @__PURE__ */ n(
|
|
2166
2365
|
"input",
|
|
2167
2366
|
{
|
|
2168
2367
|
id: "email",
|
|
2169
2368
|
name: "email",
|
|
2170
2369
|
type: "email",
|
|
2171
|
-
value:
|
|
2172
|
-
onChange: (
|
|
2173
|
-
|
|
2370
|
+
value: S,
|
|
2371
|
+
onChange: (D) => {
|
|
2372
|
+
L(D.target.value), E.email && o((_) => ({ ..._, email: !1, phoneNumber: !1 }));
|
|
2174
2373
|
},
|
|
2175
|
-
placeholder:
|
|
2176
|
-
style:
|
|
2177
|
-
disabled:
|
|
2374
|
+
placeholder: c.emailPlaceholder,
|
|
2375
|
+
style: z("email"),
|
|
2376
|
+
disabled: F
|
|
2178
2377
|
}
|
|
2179
2378
|
)
|
|
2180
2379
|
] }),
|
|
2181
|
-
/* @__PURE__ */ l("div", { style:
|
|
2182
|
-
/* @__PURE__ */ n("label", { style:
|
|
2380
|
+
/* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
|
|
2381
|
+
/* @__PURE__ */ n("label", { style: y.label, children: c.phoneNumberLabel }),
|
|
2183
2382
|
/* @__PURE__ */ n(
|
|
2184
2383
|
"input",
|
|
2185
2384
|
{
|
|
2186
2385
|
id: "phoneNumber",
|
|
2187
2386
|
name: "phoneNumber",
|
|
2188
2387
|
type: "tel",
|
|
2189
|
-
value:
|
|
2190
|
-
onChange: (
|
|
2191
|
-
|
|
2388
|
+
value: C,
|
|
2389
|
+
onChange: (D) => {
|
|
2390
|
+
q(D.target.value), E.phoneNumber && o((_) => ({ ..._, email: !1, phoneNumber: !1 }));
|
|
2192
2391
|
},
|
|
2193
|
-
placeholder:
|
|
2194
|
-
style:
|
|
2195
|
-
disabled:
|
|
2392
|
+
placeholder: c.phoneNumberPlaceholder,
|
|
2393
|
+
style: z("phoneNumber"),
|
|
2394
|
+
disabled: F
|
|
2196
2395
|
}
|
|
2197
2396
|
)
|
|
2198
2397
|
] }),
|
|
@@ -2208,83 +2407,83 @@ function Mt({
|
|
|
2208
2407
|
children: "At least one contact method (email or phone) is required"
|
|
2209
2408
|
}
|
|
2210
2409
|
),
|
|
2211
|
-
/* @__PURE__ */ l("div", { style:
|
|
2212
|
-
/* @__PURE__ */ n("label", { style:
|
|
2410
|
+
/* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
|
|
2411
|
+
/* @__PURE__ */ n("label", { style: y.label, children: c.passwordLabel }),
|
|
2213
2412
|
/* @__PURE__ */ n(
|
|
2214
2413
|
"input",
|
|
2215
2414
|
{
|
|
2216
2415
|
id: "password",
|
|
2217
2416
|
name: "password",
|
|
2218
2417
|
type: "password",
|
|
2219
|
-
value:
|
|
2220
|
-
onChange: (
|
|
2221
|
-
|
|
2418
|
+
value: k,
|
|
2419
|
+
onChange: (D) => {
|
|
2420
|
+
u(D.target.value), E.password && o((_) => ({ ..._, password: !1 }));
|
|
2222
2421
|
},
|
|
2223
|
-
placeholder:
|
|
2224
|
-
style:
|
|
2225
|
-
disabled:
|
|
2422
|
+
placeholder: c.passwordPlaceholder,
|
|
2423
|
+
style: z("password"),
|
|
2424
|
+
disabled: F
|
|
2226
2425
|
}
|
|
2227
2426
|
)
|
|
2228
2427
|
] }),
|
|
2229
|
-
/* @__PURE__ */ l("div", { style:
|
|
2230
|
-
/* @__PURE__ */ n("label", { style:
|
|
2428
|
+
/* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
|
|
2429
|
+
/* @__PURE__ */ n("label", { style: y.label, children: c.confirmPasswordLabel }),
|
|
2231
2430
|
/* @__PURE__ */ n(
|
|
2232
2431
|
"input",
|
|
2233
2432
|
{
|
|
2234
2433
|
id: "confirmPassword",
|
|
2235
2434
|
name: "confirmPassword",
|
|
2236
2435
|
type: "password",
|
|
2237
|
-
value:
|
|
2238
|
-
onChange: (
|
|
2239
|
-
|
|
2436
|
+
value: T,
|
|
2437
|
+
onChange: (D) => {
|
|
2438
|
+
R(D.target.value), E.confirmPassword && o((_) => ({ ..._, confirmPassword: !1 })), w === c.passwordMismatchError && M("");
|
|
2240
2439
|
},
|
|
2241
|
-
placeholder:
|
|
2242
|
-
style:
|
|
2243
|
-
disabled:
|
|
2440
|
+
placeholder: c.confirmPasswordPlaceholder,
|
|
2441
|
+
style: z("confirmPassword"),
|
|
2442
|
+
disabled: F
|
|
2244
2443
|
}
|
|
2245
2444
|
)
|
|
2246
2445
|
] }),
|
|
2247
|
-
t === "tenant" && /* @__PURE__ */ l("div", { style:
|
|
2248
|
-
/* @__PURE__ */ n("label", { style:
|
|
2446
|
+
t === "tenant" && /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
|
|
2447
|
+
/* @__PURE__ */ n("label", { style: y.label, children: c.tenantNameLabel }),
|
|
2249
2448
|
/* @__PURE__ */ n(
|
|
2250
2449
|
"input",
|
|
2251
2450
|
{
|
|
2252
2451
|
id: "tenantName",
|
|
2253
2452
|
name: "tenantName",
|
|
2254
2453
|
type: "text",
|
|
2255
|
-
value:
|
|
2256
|
-
onChange: (
|
|
2257
|
-
|
|
2454
|
+
value: H,
|
|
2455
|
+
onChange: (D) => {
|
|
2456
|
+
G(D.target.value), E.tenantName && o((_) => ({ ..._, tenantName: !1 }));
|
|
2258
2457
|
},
|
|
2259
|
-
placeholder:
|
|
2260
|
-
style:
|
|
2261
|
-
disabled:
|
|
2458
|
+
placeholder: c.tenantNamePlaceholder,
|
|
2459
|
+
style: z("tenantName"),
|
|
2460
|
+
disabled: F
|
|
2262
2461
|
}
|
|
2263
2462
|
)
|
|
2264
2463
|
] }),
|
|
2265
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !
|
|
2266
|
-
|
|
2464
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !O || F, style: B(), children: F ? c.loadingText : c.submitButton }),
|
|
2465
|
+
w && /* @__PURE__ */ n("div", { style: y.errorText, children: w })
|
|
2267
2466
|
] }),
|
|
2268
|
-
(
|
|
2269
|
-
|
|
2270
|
-
/* @__PURE__ */ l("span", { style:
|
|
2271
|
-
|
|
2467
|
+
(I || A) && /* @__PURE__ */ l("div", { style: y.linkContainer, children: [
|
|
2468
|
+
A && /* @__PURE__ */ l("div", { children: [
|
|
2469
|
+
/* @__PURE__ */ l("span", { style: y.divider, children: [
|
|
2470
|
+
c.magicLinkText,
|
|
2272
2471
|
" "
|
|
2273
2472
|
] }),
|
|
2274
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
2473
|
+
/* @__PURE__ */ n("a", { onClick: p, style: y.link, children: c.magicLinkLink })
|
|
2275
2474
|
] }),
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
/* @__PURE__ */ l("span", { style:
|
|
2279
|
-
|
|
2475
|
+
A && I && /* @__PURE__ */ n("div", { style: y.divider, children: "•" }),
|
|
2476
|
+
I && /* @__PURE__ */ l("div", { children: [
|
|
2477
|
+
/* @__PURE__ */ l("span", { style: y.divider, children: [
|
|
2478
|
+
c.loginText,
|
|
2280
2479
|
" "
|
|
2281
2480
|
] }),
|
|
2282
|
-
/* @__PURE__ */ n("a", { onClick: a, style:
|
|
2481
|
+
/* @__PURE__ */ n("a", { onClick: a, style: y.link, children: c.loginLink })
|
|
2283
2482
|
] })
|
|
2284
2483
|
] })
|
|
2285
2484
|
] });
|
|
2286
2485
|
}
|
|
2287
|
-
const
|
|
2486
|
+
const it = {
|
|
2288
2487
|
title: "Sign In with Magic Link",
|
|
2289
2488
|
emailLabel: "Email",
|
|
2290
2489
|
emailPlaceholder: "Enter your email",
|
|
@@ -2302,7 +2501,7 @@ const Xe = {
|
|
|
2302
2501
|
loadingText: "Sending magic link...",
|
|
2303
2502
|
verifyingText: "Verifying magic link...",
|
|
2304
2503
|
description: "Enter your email to receive a magic link. If you don't have an account, we'll create one for you."
|
|
2305
|
-
},
|
|
2504
|
+
}, ot = {
|
|
2306
2505
|
container: {
|
|
2307
2506
|
maxWidth: "400px",
|
|
2308
2507
|
width: "100%",
|
|
@@ -2405,100 +2604,105 @@ const Xe = {
|
|
|
2405
2604
|
fontSize: "0.875rem"
|
|
2406
2605
|
}
|
|
2407
2606
|
};
|
|
2408
|
-
function
|
|
2607
|
+
function Ht({
|
|
2409
2608
|
copy: i = {},
|
|
2410
2609
|
styles: e = {},
|
|
2411
2610
|
onSuccess: t,
|
|
2412
2611
|
onError: r,
|
|
2413
2612
|
onLoginClick: s,
|
|
2414
2613
|
onSignupClick: a,
|
|
2415
|
-
showTraditionalLinks:
|
|
2416
|
-
className:
|
|
2417
|
-
verifyToken:
|
|
2418
|
-
frontendUrl:
|
|
2614
|
+
showTraditionalLinks: p = !0,
|
|
2615
|
+
className: I,
|
|
2616
|
+
verifyToken: A,
|
|
2617
|
+
frontendUrl: x
|
|
2419
2618
|
}) {
|
|
2420
|
-
const [
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
}, [
|
|
2424
|
-
const
|
|
2425
|
-
|
|
2619
|
+
const [P, b] = v(""), [m, h] = v(""), [S, L] = v(""), [C, q] = v(!1), [k, u] = v(!1), [T, R] = v(""), [H, G] = v(""), [F, V] = v({}), [w, M] = v(!1), { sendMagicLink: E, verifyMagicLink: o } = oe(), { tenant: g } = se(), f = { ...it, ...i }, d = { ...ot, ...e };
|
|
2620
|
+
te(() => {
|
|
2621
|
+
A && c(A);
|
|
2622
|
+
}, [A]);
|
|
2623
|
+
const c = async (B) => {
|
|
2624
|
+
if (!g || !P) {
|
|
2625
|
+
R("Missing tenant or email");
|
|
2626
|
+
return;
|
|
2627
|
+
}
|
|
2628
|
+
u(!0), R("");
|
|
2426
2629
|
try {
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2630
|
+
const O = await o({
|
|
2631
|
+
token: B,
|
|
2632
|
+
email: P
|
|
2633
|
+
// tenantId inferred from context automatically
|
|
2634
|
+
});
|
|
2635
|
+
t == null || t(O);
|
|
2636
|
+
} catch (O) {
|
|
2637
|
+
const D = O.message || "Failed to verify magic link";
|
|
2638
|
+
R(D), r == null || r(D);
|
|
2434
2639
|
} finally {
|
|
2435
|
-
|
|
2640
|
+
u(!1);
|
|
2436
2641
|
}
|
|
2437
|
-
},
|
|
2438
|
-
const
|
|
2439
|
-
return
|
|
2440
|
-
},
|
|
2441
|
-
if (
|
|
2442
|
-
if (!(
|
|
2443
|
-
|
|
2642
|
+
}, y = () => {
|
|
2643
|
+
const B = {};
|
|
2644
|
+
return P.trim() || (B.email = !0), w && !m.trim() && (B.name = !0), V(B), Object.keys(B).length === 0;
|
|
2645
|
+
}, W = async (B) => {
|
|
2646
|
+
if (B.preventDefault(), !!y()) {
|
|
2647
|
+
if (!(g != null && g.id)) {
|
|
2648
|
+
R("Tenant not found");
|
|
2444
2649
|
return;
|
|
2445
2650
|
}
|
|
2446
|
-
|
|
2651
|
+
q(!0), R(""), G("");
|
|
2447
2652
|
try {
|
|
2448
|
-
const
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
);
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
F(R), r == null || r(R);
|
|
2653
|
+
const O = x || (typeof window < "u" ? window.location.origin : ""), D = await E({
|
|
2654
|
+
email: P,
|
|
2655
|
+
tenantId: g.id,
|
|
2656
|
+
frontendUrl: O,
|
|
2657
|
+
name: w ? m : void 0,
|
|
2658
|
+
lastName: w ? S : void 0
|
|
2659
|
+
});
|
|
2660
|
+
G(f.successMessage), t == null || t(D);
|
|
2661
|
+
} catch (O) {
|
|
2662
|
+
const D = O.message || f.errorMessage;
|
|
2663
|
+
R(D), r == null || r(D);
|
|
2460
2664
|
} finally {
|
|
2461
|
-
|
|
2665
|
+
q(!1);
|
|
2462
2666
|
}
|
|
2463
2667
|
}
|
|
2464
|
-
},
|
|
2465
|
-
...
|
|
2466
|
-
...
|
|
2467
|
-
}),
|
|
2468
|
-
...
|
|
2469
|
-
...
|
|
2470
|
-
...!
|
|
2668
|
+
}, ee = (B) => ({
|
|
2669
|
+
...d.input,
|
|
2670
|
+
...F[B] ? d.inputError : {}
|
|
2671
|
+
}), z = () => ({
|
|
2672
|
+
...d.button,
|
|
2673
|
+
...C || k ? d.buttonLoading : {},
|
|
2674
|
+
...!P || C || k ? d.buttonDisabled : {}
|
|
2471
2675
|
});
|
|
2472
|
-
return
|
|
2473
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2676
|
+
return k ? /* @__PURE__ */ l("div", { className: I, style: d.container, children: [
|
|
2677
|
+
/* @__PURE__ */ n("h2", { style: d.title, children: f.verifyingText }),
|
|
2474
2678
|
/* @__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..." }) })
|
|
2475
|
-
] }) : /* @__PURE__ */ l("div", { className:
|
|
2476
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2477
|
-
/* @__PURE__ */ n("p", { style:
|
|
2478
|
-
/* @__PURE__ */ l("form", { onSubmit:
|
|
2479
|
-
/* @__PURE__ */ l("div", { style:
|
|
2480
|
-
/* @__PURE__ */ n("label", { style:
|
|
2679
|
+
] }) : /* @__PURE__ */ l("div", { className: I, style: d.container, children: [
|
|
2680
|
+
/* @__PURE__ */ n("h2", { style: d.title, children: f.title }),
|
|
2681
|
+
/* @__PURE__ */ n("p", { style: d.description, children: f.description }),
|
|
2682
|
+
/* @__PURE__ */ l("form", { onSubmit: W, style: d.form, children: [
|
|
2683
|
+
/* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
|
|
2684
|
+
/* @__PURE__ */ n("label", { style: d.label, children: f.emailLabel }),
|
|
2481
2685
|
/* @__PURE__ */ n(
|
|
2482
2686
|
"input",
|
|
2483
2687
|
{
|
|
2484
2688
|
id: "email",
|
|
2485
2689
|
name: "email",
|
|
2486
2690
|
type: "email",
|
|
2487
|
-
value:
|
|
2488
|
-
onChange: (
|
|
2489
|
-
|
|
2691
|
+
value: P,
|
|
2692
|
+
onChange: (B) => {
|
|
2693
|
+
b(B.target.value), F.email && V((O) => ({ ...O, email: !1 }));
|
|
2490
2694
|
},
|
|
2491
|
-
placeholder:
|
|
2492
|
-
style:
|
|
2493
|
-
disabled:
|
|
2695
|
+
placeholder: f.emailPlaceholder,
|
|
2696
|
+
style: ee("email"),
|
|
2697
|
+
disabled: C || k
|
|
2494
2698
|
}
|
|
2495
2699
|
)
|
|
2496
2700
|
] }),
|
|
2497
|
-
!
|
|
2701
|
+
!w && /* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
|
|
2498
2702
|
"button",
|
|
2499
2703
|
{
|
|
2500
2704
|
type: "button",
|
|
2501
|
-
onClick: () =>
|
|
2705
|
+
onClick: () => M(!0),
|
|
2502
2706
|
style: {
|
|
2503
2707
|
background: "none",
|
|
2504
2708
|
border: "none",
|
|
@@ -2510,38 +2714,38 @@ function Et({
|
|
|
2510
2714
|
children: "New user? Add your name"
|
|
2511
2715
|
}
|
|
2512
2716
|
) }),
|
|
2513
|
-
|
|
2514
|
-
/* @__PURE__ */ l("div", { style:
|
|
2515
|
-
/* @__PURE__ */ n("label", { style:
|
|
2717
|
+
w && /* @__PURE__ */ l(N, { children: [
|
|
2718
|
+
/* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
|
|
2719
|
+
/* @__PURE__ */ n("label", { style: d.label, children: f.nameLabel }),
|
|
2516
2720
|
/* @__PURE__ */ n(
|
|
2517
2721
|
"input",
|
|
2518
2722
|
{
|
|
2519
2723
|
id: "name",
|
|
2520
2724
|
name: "name",
|
|
2521
2725
|
type: "text",
|
|
2522
|
-
value:
|
|
2523
|
-
onChange: (
|
|
2524
|
-
|
|
2726
|
+
value: m,
|
|
2727
|
+
onChange: (B) => {
|
|
2728
|
+
h(B.target.value), F.name && V((O) => ({ ...O, name: !1 }));
|
|
2525
2729
|
},
|
|
2526
|
-
placeholder:
|
|
2527
|
-
style:
|
|
2528
|
-
disabled:
|
|
2730
|
+
placeholder: f.namePlaceholder,
|
|
2731
|
+
style: ee("name"),
|
|
2732
|
+
disabled: C || k
|
|
2529
2733
|
}
|
|
2530
2734
|
)
|
|
2531
2735
|
] }),
|
|
2532
|
-
/* @__PURE__ */ l("div", { style:
|
|
2533
|
-
/* @__PURE__ */ n("label", { style:
|
|
2736
|
+
/* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
|
|
2737
|
+
/* @__PURE__ */ n("label", { style: d.label, children: f.lastNameLabel }),
|
|
2534
2738
|
/* @__PURE__ */ n(
|
|
2535
2739
|
"input",
|
|
2536
2740
|
{
|
|
2537
2741
|
id: "lastName",
|
|
2538
2742
|
name: "lastName",
|
|
2539
2743
|
type: "text",
|
|
2540
|
-
value:
|
|
2541
|
-
onChange: (
|
|
2542
|
-
placeholder:
|
|
2543
|
-
style:
|
|
2544
|
-
disabled:
|
|
2744
|
+
value: S,
|
|
2745
|
+
onChange: (B) => L(B.target.value),
|
|
2746
|
+
placeholder: f.lastNamePlaceholder,
|
|
2747
|
+
style: d.input,
|
|
2748
|
+
disabled: C || k
|
|
2545
2749
|
}
|
|
2546
2750
|
)
|
|
2547
2751
|
] }),
|
|
@@ -2550,7 +2754,7 @@ function Et({
|
|
|
2550
2754
|
{
|
|
2551
2755
|
type: "button",
|
|
2552
2756
|
onClick: () => {
|
|
2553
|
-
|
|
2757
|
+
M(!1), h(""), L("");
|
|
2554
2758
|
},
|
|
2555
2759
|
style: {
|
|
2556
2760
|
background: "none",
|
|
@@ -2564,30 +2768,30 @@ function Et({
|
|
|
2564
2768
|
}
|
|
2565
2769
|
) })
|
|
2566
2770
|
] }),
|
|
2567
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !
|
|
2568
|
-
|
|
2569
|
-
|
|
2771
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !P || C || k, style: z(), children: C ? f.loadingText : f.submitButton }),
|
|
2772
|
+
T && /* @__PURE__ */ n("div", { style: d.errorText, children: T }),
|
|
2773
|
+
H && /* @__PURE__ */ n("div", { style: d.successText, children: H })
|
|
2570
2774
|
] }),
|
|
2571
|
-
|
|
2775
|
+
p && /* @__PURE__ */ l("div", { style: d.linkContainer, children: [
|
|
2572
2776
|
/* @__PURE__ */ l("div", { children: [
|
|
2573
|
-
/* @__PURE__ */ l("span", { style:
|
|
2574
|
-
|
|
2777
|
+
/* @__PURE__ */ l("span", { style: d.divider, children: [
|
|
2778
|
+
f.loginText,
|
|
2575
2779
|
" "
|
|
2576
2780
|
] }),
|
|
2577
|
-
/* @__PURE__ */ n("a", { onClick: s, style:
|
|
2781
|
+
/* @__PURE__ */ n("a", { onClick: s, style: d.link, children: f.loginLink })
|
|
2578
2782
|
] }),
|
|
2579
|
-
/* @__PURE__ */ n("div", { style:
|
|
2783
|
+
/* @__PURE__ */ n("div", { style: d.divider, children: "•" }),
|
|
2580
2784
|
/* @__PURE__ */ l("div", { children: [
|
|
2581
|
-
/* @__PURE__ */ l("span", { style:
|
|
2582
|
-
|
|
2785
|
+
/* @__PURE__ */ l("span", { style: d.divider, children: [
|
|
2786
|
+
f.signupText,
|
|
2583
2787
|
" "
|
|
2584
2788
|
] }),
|
|
2585
|
-
/* @__PURE__ */ n("a", { onClick: a, style:
|
|
2789
|
+
/* @__PURE__ */ n("a", { onClick: a, style: d.link, children: f.signupLink })
|
|
2586
2790
|
] })
|
|
2587
2791
|
] })
|
|
2588
2792
|
] });
|
|
2589
2793
|
}
|
|
2590
|
-
const
|
|
2794
|
+
const at = {
|
|
2591
2795
|
title: "Verifying Magic Link",
|
|
2592
2796
|
verifyingMessage: "Please wait while we verify your magic link...",
|
|
2593
2797
|
successMessage: "Magic link verified successfully! You are now logged in.",
|
|
@@ -2595,7 +2799,7 @@ const et = {
|
|
|
2595
2799
|
redirectingMessage: "Redirecting you to the dashboard...",
|
|
2596
2800
|
retryButton: "Try Again",
|
|
2597
2801
|
backToLoginButton: "Back to Login"
|
|
2598
|
-
},
|
|
2802
|
+
}, Ee = {
|
|
2599
2803
|
container: {
|
|
2600
2804
|
maxWidth: "400px",
|
|
2601
2805
|
width: "100%",
|
|
@@ -2682,7 +2886,7 @@ const et = {
|
|
|
2682
2886
|
cursor: "pointer",
|
|
2683
2887
|
transition: "all 0.15s ease-in-out"
|
|
2684
2888
|
}
|
|
2685
|
-
},
|
|
2889
|
+
}, lt = () => /* @__PURE__ */ n("div", { style: Ee.spinner }), ct = () => /* @__PURE__ */ l(
|
|
2686
2890
|
"svg",
|
|
2687
2891
|
{
|
|
2688
2892
|
width: "48",
|
|
@@ -2699,7 +2903,7 @@ const et = {
|
|
|
2699
2903
|
/* @__PURE__ */ n("polyline", { points: "22,4 12,14.01 9,11.01" })
|
|
2700
2904
|
]
|
|
2701
2905
|
}
|
|
2702
|
-
),
|
|
2906
|
+
), dt = () => /* @__PURE__ */ l(
|
|
2703
2907
|
"svg",
|
|
2704
2908
|
{
|
|
2705
2909
|
width: "48",
|
|
@@ -2717,110 +2921,109 @@ const et = {
|
|
|
2717
2921
|
/* @__PURE__ */ n("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
|
|
2718
2922
|
]
|
|
2719
2923
|
}
|
|
2720
|
-
),
|
|
2721
|
-
loading: /* @__PURE__ */ n(
|
|
2722
|
-
success: /* @__PURE__ */ n(
|
|
2723
|
-
error: /* @__PURE__ */ n(
|
|
2924
|
+
), ut = {
|
|
2925
|
+
loading: /* @__PURE__ */ n(lt, {}),
|
|
2926
|
+
success: /* @__PURE__ */ n(ct, {}),
|
|
2927
|
+
error: /* @__PURE__ */ n(dt, {})
|
|
2724
2928
|
};
|
|
2725
|
-
function
|
|
2929
|
+
function Nt({
|
|
2726
2930
|
copy: i = {},
|
|
2727
2931
|
styles: e = {},
|
|
2728
2932
|
icons: t = {},
|
|
2729
2933
|
onSuccess: r,
|
|
2730
2934
|
onError: s,
|
|
2731
2935
|
onRetry: a,
|
|
2732
|
-
onBackToLogin:
|
|
2733
|
-
className:
|
|
2734
|
-
token:
|
|
2735
|
-
email:
|
|
2736
|
-
appId:
|
|
2737
|
-
|
|
2738
|
-
autoRedirectDelay:
|
|
2936
|
+
onBackToLogin: p,
|
|
2937
|
+
className: I,
|
|
2938
|
+
token: A,
|
|
2939
|
+
email: x,
|
|
2940
|
+
appId: P,
|
|
2941
|
+
tenantSlug: b,
|
|
2942
|
+
autoRedirectDelay: m = 3e3
|
|
2739
2943
|
}) {
|
|
2740
|
-
const [
|
|
2944
|
+
const [h, S] = v("verifying"), [L, C] = v(""), { verifyMagicLink: q } = oe(), k = { ...at, ...i }, u = { ...Ee, ...e }, T = { ...ut, ...t }, R = () => {
|
|
2741
2945
|
if (typeof window > "u") return {};
|
|
2742
|
-
const
|
|
2946
|
+
const w = new URLSearchParams(window.location.search);
|
|
2743
2947
|
return {
|
|
2744
|
-
token:
|
|
2745
|
-
email:
|
|
2746
|
-
appId:
|
|
2747
|
-
|
|
2948
|
+
token: A || w.get("token") || "",
|
|
2949
|
+
email: x || w.get("email") || "",
|
|
2950
|
+
appId: P || w.get("appId") || "",
|
|
2951
|
+
tenantSlug: b || w.get("tenantSlug") || void 0
|
|
2748
2952
|
};
|
|
2749
|
-
},
|
|
2750
|
-
|
|
2953
|
+
}, H = async () => {
|
|
2954
|
+
S("verifying"), C("");
|
|
2751
2955
|
try {
|
|
2752
|
-
const
|
|
2753
|
-
if (!
|
|
2754
|
-
throw new Error("Missing required parameters: token
|
|
2755
|
-
const
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
)
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
g(h), v("error"), s == null || s(h);
|
|
2956
|
+
const w = R();
|
|
2957
|
+
if (!w.token || !w.email)
|
|
2958
|
+
throw new Error("Missing required parameters: token or email");
|
|
2959
|
+
const M = await q({
|
|
2960
|
+
token: w.token,
|
|
2961
|
+
email: w.email,
|
|
2962
|
+
tenantSlug: w.tenantSlug
|
|
2963
|
+
});
|
|
2964
|
+
S("success"), r == null || r(M), m > 0 && setTimeout(() => {
|
|
2965
|
+
S("redirecting");
|
|
2966
|
+
}, m);
|
|
2967
|
+
} catch (w) {
|
|
2968
|
+
const M = w.message || k.errorMessage;
|
|
2969
|
+
C(M), S("error"), s == null || s(M);
|
|
2767
2970
|
}
|
|
2768
|
-
},
|
|
2769
|
-
a == null || a(),
|
|
2770
|
-
},
|
|
2771
|
-
|
|
2971
|
+
}, G = () => {
|
|
2972
|
+
a == null || a(), H();
|
|
2973
|
+
}, F = () => {
|
|
2974
|
+
p == null || p();
|
|
2772
2975
|
};
|
|
2773
|
-
|
|
2774
|
-
|
|
2976
|
+
te(() => {
|
|
2977
|
+
H();
|
|
2775
2978
|
}, []);
|
|
2776
|
-
const
|
|
2777
|
-
switch (
|
|
2979
|
+
const V = () => {
|
|
2980
|
+
switch (h) {
|
|
2778
2981
|
case "verifying":
|
|
2779
|
-
return /* @__PURE__ */ l("div", { style:
|
|
2780
|
-
|
|
2781
|
-
|
|
2982
|
+
return /* @__PURE__ */ l("div", { style: u.message, children: [
|
|
2983
|
+
T.loading,
|
|
2984
|
+
k.verifyingMessage
|
|
2782
2985
|
] });
|
|
2783
2986
|
case "success":
|
|
2784
|
-
return /* @__PURE__ */ l(
|
|
2785
|
-
|
|
2786
|
-
/* @__PURE__ */ n("div", { style:
|
|
2987
|
+
return /* @__PURE__ */ l(N, { children: [
|
|
2988
|
+
T.success,
|
|
2989
|
+
/* @__PURE__ */ n("div", { style: u.successMessage, children: k.successMessage })
|
|
2787
2990
|
] });
|
|
2788
2991
|
case "redirecting":
|
|
2789
|
-
return /* @__PURE__ */ l(
|
|
2790
|
-
|
|
2791
|
-
/* @__PURE__ */ n("div", { style:
|
|
2992
|
+
return /* @__PURE__ */ l(N, { children: [
|
|
2993
|
+
T.loading,
|
|
2994
|
+
/* @__PURE__ */ n("div", { style: u.message, children: k.redirectingMessage })
|
|
2792
2995
|
] });
|
|
2793
2996
|
case "error":
|
|
2794
|
-
return /* @__PURE__ */ l(
|
|
2795
|
-
|
|
2796
|
-
/* @__PURE__ */ n("div", { style:
|
|
2797
|
-
/* @__PURE__ */ l("div", { style:
|
|
2997
|
+
return /* @__PURE__ */ l(N, { children: [
|
|
2998
|
+
T.error,
|
|
2999
|
+
/* @__PURE__ */ n("div", { style: u.errorMessage, children: L || k.errorMessage }),
|
|
3000
|
+
/* @__PURE__ */ l("div", { style: u.buttonContainer, children: [
|
|
2798
3001
|
/* @__PURE__ */ n(
|
|
2799
3002
|
"button",
|
|
2800
3003
|
{
|
|
2801
|
-
onClick:
|
|
2802
|
-
style:
|
|
2803
|
-
onMouseOver: (
|
|
2804
|
-
|
|
3004
|
+
onClick: G,
|
|
3005
|
+
style: u.retryButton,
|
|
3006
|
+
onMouseOver: (w) => {
|
|
3007
|
+
w.currentTarget.style.backgroundColor = "#2563eb";
|
|
2805
3008
|
},
|
|
2806
|
-
onMouseOut: (
|
|
2807
|
-
|
|
3009
|
+
onMouseOut: (w) => {
|
|
3010
|
+
w.currentTarget.style.backgroundColor = "#3b82f6";
|
|
2808
3011
|
},
|
|
2809
|
-
children:
|
|
3012
|
+
children: k.retryButton
|
|
2810
3013
|
}
|
|
2811
3014
|
),
|
|
2812
3015
|
/* @__PURE__ */ n(
|
|
2813
3016
|
"button",
|
|
2814
3017
|
{
|
|
2815
|
-
onClick:
|
|
2816
|
-
style:
|
|
2817
|
-
onMouseOver: (
|
|
2818
|
-
|
|
3018
|
+
onClick: F,
|
|
3019
|
+
style: u.backButton,
|
|
3020
|
+
onMouseOver: (w) => {
|
|
3021
|
+
w.currentTarget.style.backgroundColor = "#e5e7eb";
|
|
2819
3022
|
},
|
|
2820
|
-
onMouseOut: (
|
|
2821
|
-
|
|
3023
|
+
onMouseOut: (w) => {
|
|
3024
|
+
w.currentTarget.style.backgroundColor = "#f3f4f6";
|
|
2822
3025
|
},
|
|
2823
|
-
children:
|
|
3026
|
+
children: k.backToLoginButton
|
|
2824
3027
|
}
|
|
2825
3028
|
)
|
|
2826
3029
|
] })
|
|
@@ -2829,18 +3032,18 @@ function Lt({
|
|
|
2829
3032
|
return null;
|
|
2830
3033
|
}
|
|
2831
3034
|
};
|
|
2832
|
-
return /* @__PURE__ */ l("div", { style:
|
|
3035
|
+
return /* @__PURE__ */ l("div", { style: u.container, className: I, children: [
|
|
2833
3036
|
/* @__PURE__ */ n("style", { children: `
|
|
2834
3037
|
@keyframes spin {
|
|
2835
3038
|
0% { transform: rotate(0deg); }
|
|
2836
3039
|
100% { transform: rotate(360deg); }
|
|
2837
3040
|
}
|
|
2838
3041
|
` }),
|
|
2839
|
-
/* @__PURE__ */ n("h1", { style:
|
|
2840
|
-
|
|
3042
|
+
/* @__PURE__ */ n("h1", { style: u.title, children: k.title }),
|
|
3043
|
+
V()
|
|
2841
3044
|
] });
|
|
2842
3045
|
}
|
|
2843
|
-
const
|
|
3046
|
+
const ht = {
|
|
2844
3047
|
title: "Reset Password",
|
|
2845
3048
|
subtitle: "Enter your email address and we'll send you a link to reset your password.",
|
|
2846
3049
|
emailLabel: "Email",
|
|
@@ -2862,7 +3065,7 @@ const it = {
|
|
|
2862
3065
|
resetLoadingText: "Resetting...",
|
|
2863
3066
|
resetSuccessMessage: "Password reset successfully!",
|
|
2864
3067
|
passwordMismatchError: "Passwords do not match"
|
|
2865
|
-
},
|
|
3068
|
+
}, gt = {
|
|
2866
3069
|
container: {
|
|
2867
3070
|
maxWidth: "400px",
|
|
2868
3071
|
margin: "0 auto",
|
|
@@ -2954,113 +3157,113 @@ const it = {
|
|
|
2954
3157
|
cursor: "pointer"
|
|
2955
3158
|
}
|
|
2956
3159
|
};
|
|
2957
|
-
function
|
|
3160
|
+
function Bt({
|
|
2958
3161
|
copy: i = {},
|
|
2959
3162
|
styles: e = {},
|
|
2960
3163
|
mode: t = "request",
|
|
2961
3164
|
token: r = "",
|
|
2962
3165
|
onSuccess: s,
|
|
2963
3166
|
onError: a,
|
|
2964
|
-
onBackToLogin:
|
|
2965
|
-
onModeChange:
|
|
2966
|
-
className:
|
|
3167
|
+
onBackToLogin: p,
|
|
3168
|
+
onModeChange: I,
|
|
3169
|
+
className: A
|
|
2967
3170
|
}) {
|
|
2968
|
-
const [
|
|
2969
|
-
const
|
|
2970
|
-
return
|
|
2971
|
-
},
|
|
2972
|
-
const
|
|
2973
|
-
return
|
|
2974
|
-
},
|
|
2975
|
-
if (
|
|
2976
|
-
if (!(
|
|
2977
|
-
|
|
3171
|
+
const [x, P] = v(""), [b, m] = v(r), [h, S] = v(""), [L, C] = v(""), [q, k] = v(!1), [u, T] = v(""), [R, H] = v(""), [G, F] = v({}), { requestPasswordReset: V, confirmPasswordReset: w } = oe(), { tenant: M } = se(), E = { ...ht, ...i }, o = { ...gt, ...e }, g = () => {
|
|
3172
|
+
const z = {};
|
|
3173
|
+
return x.trim() || (z.email = !0), F(z), Object.keys(z).length === 0;
|
|
3174
|
+
}, f = () => {
|
|
3175
|
+
const z = {};
|
|
3176
|
+
return b.trim() || (z.token = !0), h.trim() || (z.newPassword = !0), L.trim() || (z.confirmPassword = !0), F(z), Object.keys(z).length === 0;
|
|
3177
|
+
}, d = async (z) => {
|
|
3178
|
+
if (z.preventDefault(), !!g()) {
|
|
3179
|
+
if (!(M != null && M.id)) {
|
|
3180
|
+
T("Tenant not found");
|
|
2978
3181
|
return;
|
|
2979
3182
|
}
|
|
2980
|
-
|
|
3183
|
+
k(!0), T(""), H("");
|
|
2981
3184
|
try {
|
|
2982
|
-
await
|
|
2983
|
-
} catch (
|
|
2984
|
-
const
|
|
2985
|
-
|
|
3185
|
+
await V({ email: x, tenantId: M.id }), H(E.successMessage), s == null || s();
|
|
3186
|
+
} catch (B) {
|
|
3187
|
+
const O = B.message || E.errorMessage;
|
|
3188
|
+
T(O), a == null || a(O);
|
|
2986
3189
|
} finally {
|
|
2987
|
-
|
|
3190
|
+
k(!1);
|
|
2988
3191
|
}
|
|
2989
3192
|
}
|
|
2990
|
-
},
|
|
2991
|
-
if (
|
|
2992
|
-
if (
|
|
2993
|
-
|
|
3193
|
+
}, c = async (z) => {
|
|
3194
|
+
if (z.preventDefault(), !!f()) {
|
|
3195
|
+
if (h !== L) {
|
|
3196
|
+
T(E.passwordMismatchError), F({ confirmPassword: !0 });
|
|
2994
3197
|
return;
|
|
2995
3198
|
}
|
|
2996
|
-
|
|
3199
|
+
k(!0), T(""), H("");
|
|
2997
3200
|
try {
|
|
2998
|
-
await
|
|
2999
|
-
} catch (
|
|
3000
|
-
const
|
|
3001
|
-
|
|
3201
|
+
await w({ token: b, newPassword: h }), H(E.resetSuccessMessage), s == null || s();
|
|
3202
|
+
} catch (B) {
|
|
3203
|
+
const O = B.message || E.errorMessage;
|
|
3204
|
+
T(O), a == null || a(O);
|
|
3002
3205
|
} finally {
|
|
3003
|
-
|
|
3206
|
+
k(!1);
|
|
3004
3207
|
}
|
|
3005
3208
|
}
|
|
3006
|
-
},
|
|
3007
|
-
...
|
|
3008
|
-
...z
|
|
3009
|
-
}),
|
|
3010
|
-
...
|
|
3011
|
-
...
|
|
3209
|
+
}, y = (z) => ({
|
|
3210
|
+
...o.input,
|
|
3211
|
+
...G[z] ? o.inputError : {}
|
|
3212
|
+
}), W = () => ({
|
|
3213
|
+
...o.button,
|
|
3214
|
+
...q ? o.buttonLoading : {}
|
|
3012
3215
|
});
|
|
3013
3216
|
if (t === "reset") {
|
|
3014
|
-
const
|
|
3015
|
-
return /* @__PURE__ */ l("div", { className:
|
|
3016
|
-
/* @__PURE__ */ n("h2", { style:
|
|
3017
|
-
/* @__PURE__ */ n("p", { style:
|
|
3018
|
-
/* @__PURE__ */ l("form", { onSubmit:
|
|
3019
|
-
/* @__PURE__ */ l("div", { style:
|
|
3020
|
-
/* @__PURE__ */ n("label", { style:
|
|
3217
|
+
const z = b && h && L;
|
|
3218
|
+
return /* @__PURE__ */ l("div", { className: A, style: o.container, children: [
|
|
3219
|
+
/* @__PURE__ */ n("h2", { style: o.title, children: E.resetTitle }),
|
|
3220
|
+
/* @__PURE__ */ n("p", { style: o.subtitle, children: E.resetSubtitle }),
|
|
3221
|
+
/* @__PURE__ */ l("form", { onSubmit: c, style: o.form, children: [
|
|
3222
|
+
/* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
|
|
3223
|
+
/* @__PURE__ */ n("label", { style: o.label, children: E.tokenLabel }),
|
|
3021
3224
|
/* @__PURE__ */ n(
|
|
3022
3225
|
"input",
|
|
3023
3226
|
{
|
|
3024
3227
|
type: "text",
|
|
3025
|
-
value:
|
|
3026
|
-
onChange: (
|
|
3027
|
-
|
|
3228
|
+
value: b,
|
|
3229
|
+
onChange: (B) => {
|
|
3230
|
+
m(B.target.value), G.token && F((O) => ({ ...O, token: !1 }));
|
|
3028
3231
|
},
|
|
3029
|
-
placeholder:
|
|
3030
|
-
style:
|
|
3031
|
-
disabled:
|
|
3232
|
+
placeholder: E.tokenPlaceholder,
|
|
3233
|
+
style: y("token"),
|
|
3234
|
+
disabled: q
|
|
3032
3235
|
}
|
|
3033
3236
|
)
|
|
3034
3237
|
] }),
|
|
3035
|
-
/* @__PURE__ */ l("div", { style:
|
|
3036
|
-
/* @__PURE__ */ n("label", { style:
|
|
3238
|
+
/* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
|
|
3239
|
+
/* @__PURE__ */ n("label", { style: o.label, children: E.newPasswordLabel }),
|
|
3037
3240
|
/* @__PURE__ */ n(
|
|
3038
3241
|
"input",
|
|
3039
3242
|
{
|
|
3040
3243
|
type: "password",
|
|
3041
|
-
value:
|
|
3042
|
-
onChange: (
|
|
3043
|
-
|
|
3244
|
+
value: h,
|
|
3245
|
+
onChange: (B) => {
|
|
3246
|
+
S(B.target.value), G.newPassword && F((O) => ({ ...O, newPassword: !1 }));
|
|
3044
3247
|
},
|
|
3045
|
-
placeholder:
|
|
3046
|
-
style:
|
|
3047
|
-
disabled:
|
|
3248
|
+
placeholder: E.newPasswordPlaceholder,
|
|
3249
|
+
style: y("newPassword"),
|
|
3250
|
+
disabled: q
|
|
3048
3251
|
}
|
|
3049
3252
|
)
|
|
3050
3253
|
] }),
|
|
3051
|
-
/* @__PURE__ */ l("div", { style:
|
|
3052
|
-
/* @__PURE__ */ n("label", { style:
|
|
3254
|
+
/* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
|
|
3255
|
+
/* @__PURE__ */ n("label", { style: o.label, children: E.confirmPasswordLabel }),
|
|
3053
3256
|
/* @__PURE__ */ n(
|
|
3054
3257
|
"input",
|
|
3055
3258
|
{
|
|
3056
3259
|
type: "password",
|
|
3057
|
-
value:
|
|
3058
|
-
onChange: (
|
|
3059
|
-
|
|
3260
|
+
value: L,
|
|
3261
|
+
onChange: (B) => {
|
|
3262
|
+
C(B.target.value), G.confirmPassword && F((O) => ({ ...O, confirmPassword: !1 })), u === E.passwordMismatchError && T("");
|
|
3060
3263
|
},
|
|
3061
|
-
placeholder:
|
|
3062
|
-
style:
|
|
3063
|
-
disabled:
|
|
3264
|
+
placeholder: E.confirmPasswordPlaceholder,
|
|
3265
|
+
style: y("confirmPassword"),
|
|
3266
|
+
disabled: q
|
|
3064
3267
|
}
|
|
3065
3268
|
)
|
|
3066
3269
|
] }),
|
|
@@ -3068,44 +3271,44 @@ function Rt({
|
|
|
3068
3271
|
"button",
|
|
3069
3272
|
{
|
|
3070
3273
|
type: "submit",
|
|
3071
|
-
disabled: !
|
|
3274
|
+
disabled: !z || q,
|
|
3072
3275
|
style: {
|
|
3073
|
-
...
|
|
3074
|
-
...!
|
|
3276
|
+
...W(),
|
|
3277
|
+
...!z || q ? o.buttonDisabled : {}
|
|
3075
3278
|
},
|
|
3076
|
-
children:
|
|
3279
|
+
children: q ? E.resetLoadingText : E.resetSubmitButton
|
|
3077
3280
|
}
|
|
3078
3281
|
),
|
|
3079
|
-
|
|
3080
|
-
|
|
3282
|
+
u && /* @__PURE__ */ n("div", { style: o.errorText, children: u }),
|
|
3283
|
+
R && /* @__PURE__ */ n("div", { style: o.successText, children: R })
|
|
3081
3284
|
] }),
|
|
3082
|
-
/* @__PURE__ */ l("div", { style:
|
|
3083
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
3084
|
-
|
|
3285
|
+
/* @__PURE__ */ l("div", { style: o.linkContainer, children: [
|
|
3286
|
+
/* @__PURE__ */ n("a", { onClick: p, style: o.link, children: E.backToLoginLink }),
|
|
3287
|
+
I && /* @__PURE__ */ l(N, { children: [
|
|
3085
3288
|
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3086
|
-
/* @__PURE__ */ n("a", { onClick: () =>
|
|
3289
|
+
/* @__PURE__ */ n("a", { onClick: () => I("request"), style: o.link, children: "Request New Link" })
|
|
3087
3290
|
] })
|
|
3088
3291
|
] })
|
|
3089
3292
|
] });
|
|
3090
3293
|
}
|
|
3091
|
-
const
|
|
3092
|
-
return /* @__PURE__ */ l("div", { className:
|
|
3093
|
-
/* @__PURE__ */ n("h2", { style:
|
|
3094
|
-
/* @__PURE__ */ n("p", { style:
|
|
3095
|
-
/* @__PURE__ */ l("form", { onSubmit:
|
|
3096
|
-
/* @__PURE__ */ l("div", { style:
|
|
3097
|
-
/* @__PURE__ */ n("label", { style:
|
|
3294
|
+
const ee = x;
|
|
3295
|
+
return /* @__PURE__ */ l("div", { className: A, style: o.container, children: [
|
|
3296
|
+
/* @__PURE__ */ n("h2", { style: o.title, children: E.title }),
|
|
3297
|
+
/* @__PURE__ */ n("p", { style: o.subtitle, children: E.subtitle }),
|
|
3298
|
+
/* @__PURE__ */ l("form", { onSubmit: d, style: o.form, children: [
|
|
3299
|
+
/* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
|
|
3300
|
+
/* @__PURE__ */ n("label", { style: o.label, children: E.emailLabel }),
|
|
3098
3301
|
/* @__PURE__ */ n(
|
|
3099
3302
|
"input",
|
|
3100
3303
|
{
|
|
3101
3304
|
type: "email",
|
|
3102
|
-
value:
|
|
3103
|
-
onChange: (
|
|
3104
|
-
|
|
3305
|
+
value: x,
|
|
3306
|
+
onChange: (z) => {
|
|
3307
|
+
P(z.target.value), G.email && F((B) => ({ ...B, email: !1 }));
|
|
3105
3308
|
},
|
|
3106
|
-
placeholder:
|
|
3107
|
-
style:
|
|
3108
|
-
disabled:
|
|
3309
|
+
placeholder: E.emailPlaceholder,
|
|
3310
|
+
style: y("email"),
|
|
3311
|
+
disabled: q
|
|
3109
3312
|
}
|
|
3110
3313
|
)
|
|
3111
3314
|
] }),
|
|
@@ -3113,27 +3316,27 @@ function Rt({
|
|
|
3113
3316
|
"button",
|
|
3114
3317
|
{
|
|
3115
3318
|
type: "submit",
|
|
3116
|
-
disabled: !
|
|
3319
|
+
disabled: !ee || q,
|
|
3117
3320
|
style: {
|
|
3118
|
-
...
|
|
3119
|
-
...!
|
|
3321
|
+
...W(),
|
|
3322
|
+
...!ee || q ? o.buttonDisabled : {}
|
|
3120
3323
|
},
|
|
3121
|
-
children:
|
|
3324
|
+
children: q ? E.loadingText : E.submitButton
|
|
3122
3325
|
}
|
|
3123
3326
|
),
|
|
3124
|
-
|
|
3125
|
-
|
|
3327
|
+
u && /* @__PURE__ */ n("div", { style: o.errorText, children: u }),
|
|
3328
|
+
R && /* @__PURE__ */ n("div", { style: o.successText, children: R })
|
|
3126
3329
|
] }),
|
|
3127
|
-
/* @__PURE__ */ l("div", { style:
|
|
3128
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
3129
|
-
|
|
3330
|
+
/* @__PURE__ */ l("div", { style: o.linkContainer, children: [
|
|
3331
|
+
/* @__PURE__ */ n("a", { onClick: p, style: o.link, children: E.backToLoginLink }),
|
|
3332
|
+
I && /* @__PURE__ */ l(N, { children: [
|
|
3130
3333
|
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3131
|
-
/* @__PURE__ */ n("a", { onClick: () =>
|
|
3334
|
+
/* @__PURE__ */ n("a", { onClick: () => I("reset"), style: o.link, children: "I have a token" })
|
|
3132
3335
|
] })
|
|
3133
3336
|
] })
|
|
3134
3337
|
] });
|
|
3135
3338
|
}
|
|
3136
|
-
class
|
|
3339
|
+
class Ut {
|
|
3137
3340
|
constructor(e, t) {
|
|
3138
3341
|
this.httpService = e, this.sessionManager = t;
|
|
3139
3342
|
}
|
|
@@ -3201,7 +3404,7 @@ class Ct {
|
|
|
3201
3404
|
};
|
|
3202
3405
|
}
|
|
3203
3406
|
}
|
|
3204
|
-
class
|
|
3407
|
+
class qt {
|
|
3205
3408
|
constructor(e, t) {
|
|
3206
3409
|
this.httpService = e, this.sessionManager = t;
|
|
3207
3410
|
}
|
|
@@ -3252,7 +3455,7 @@ class It {
|
|
|
3252
3455
|
});
|
|
3253
3456
|
}
|
|
3254
3457
|
}
|
|
3255
|
-
class
|
|
3458
|
+
class zt {
|
|
3256
3459
|
constructor(e) {
|
|
3257
3460
|
this.httpService = e;
|
|
3258
3461
|
}
|
|
@@ -3261,7 +3464,7 @@ class Ft {
|
|
|
3261
3464
|
return await this.httpService.get("/health");
|
|
3262
3465
|
}
|
|
3263
3466
|
}
|
|
3264
|
-
class
|
|
3467
|
+
class Ot {
|
|
3265
3468
|
// Date string to Date object
|
|
3266
3469
|
static toDate(e) {
|
|
3267
3470
|
return new Date(e);
|
|
@@ -3384,44 +3587,44 @@ class Ht {
|
|
|
3384
3587
|
}
|
|
3385
3588
|
}
|
|
3386
3589
|
export {
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3590
|
+
Ot as ApiMappers,
|
|
3591
|
+
be as AppApiService,
|
|
3592
|
+
St as AppProvider,
|
|
3593
|
+
Ne as AuthApiService,
|
|
3594
|
+
Pt as AuthProvider,
|
|
3595
|
+
Ft as FeatureFlag,
|
|
3596
|
+
ze as FeatureFlagApiService,
|
|
3597
|
+
Tt as FeatureFlagProvider,
|
|
3598
|
+
zt as HealthApiService,
|
|
3599
|
+
re as HttpService,
|
|
3600
|
+
Ct as LandingRoute,
|
|
3601
|
+
$t as LoginForm,
|
|
3602
|
+
Ht as MagicLinkForm,
|
|
3603
|
+
Nt as MagicLinkVerify,
|
|
3604
|
+
Bt as PasswordRecoveryForm,
|
|
3605
|
+
Ut as PermissionApiService,
|
|
3606
|
+
It as Protected,
|
|
3607
|
+
Et as ProtectedRoute,
|
|
3608
|
+
Se as RoleApiService,
|
|
3609
|
+
ye as SessionManager,
|
|
3610
|
+
Dt as SignupForm,
|
|
3611
|
+
je as SubscriptionApiService,
|
|
3612
|
+
Lt as SubscriptionGuard,
|
|
3613
|
+
qt as SubscriptionPlanApiService,
|
|
3614
|
+
Mt as SubscriptionProvider,
|
|
3615
|
+
ce as TenantApiService,
|
|
3616
|
+
xt as TenantProvider,
|
|
3617
|
+
Rt as TenantRoute,
|
|
3618
|
+
Be as UserApiService,
|
|
3619
|
+
ie as UserType,
|
|
3620
|
+
vt as useApi,
|
|
3621
|
+
he as useApp,
|
|
3622
|
+
oe as useAuth,
|
|
3623
|
+
Oe as useFeatureFlags,
|
|
3624
|
+
At as useSettings,
|
|
3625
|
+
Ve as useSubscription,
|
|
3626
|
+
fe as useTenant,
|
|
3627
|
+
se as useTenantInfo,
|
|
3628
|
+
kt as useTenantSettings
|
|
3426
3629
|
};
|
|
3427
3630
|
//# sourceMappingURL=index.es.js.map
|