@skylabs-digital/react-identity-access 1.4.0 → 1.6.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/README.md +203 -42
- package/dist/components/FeatureFlag.d.ts +1 -0
- package/dist/components/LandingRoute.d.ts +2 -1
- package/dist/components/LandingRoute.d.ts.map +1 -1
- package/dist/components/LoginForm.d.ts +8 -3
- package/dist/components/LoginForm.d.ts.map +1 -1
- package/dist/components/MagicLinkForm.d.ts +53 -0
- package/dist/components/MagicLinkForm.d.ts.map +1 -0
- package/dist/components/MagicLinkVerify.d.ts +45 -0
- package/dist/components/MagicLinkVerify.d.ts.map +1 -0
- package/dist/components/PasswordRecoveryForm.d.ts +1 -0
- package/dist/components/Protected.d.ts +1 -0
- package/dist/components/ProtectedRoute.d.ts +1 -0
- package/dist/components/SignupForm.d.ts +10 -1
- package/dist/components/SignupForm.d.ts.map +1 -1
- package/dist/components/SubscriptionGuard.d.ts +1 -0
- package/dist/components/TenantRoute.d.ts +2 -1
- package/dist/components/TenantRoute.d.ts.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +1565 -865
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/providers/AppProvider.d.ts +1 -0
- package/dist/providers/AppProvider.d.ts.map +1 -1
- package/dist/providers/AuthProvider.d.ts +6 -3
- package/dist/providers/AuthProvider.d.ts.map +1 -1
- package/dist/providers/FeatureFlagProvider.d.ts +1 -0
- package/dist/providers/SubscriptionProvider.d.ts +1 -0
- package/dist/providers/TenantProvider.d.ts +1 -0
- package/dist/providers/TenantProvider.d.ts.map +1 -1
- package/dist/services/AppApiService.d.ts +1 -0
- package/dist/services/AuthApiService.d.ts +8 -3
- package/dist/services/AuthApiService.d.ts.map +1 -1
- package/dist/services/FeatureFlagApiService.d.ts +1 -0
- package/dist/services/HealthApiService.d.ts +1 -0
- package/dist/services/PermissionApiService.d.ts +1 -0
- package/dist/services/RoleApiService.d.ts +1 -0
- package/dist/services/SubscriptionApiService.d.ts +1 -0
- package/dist/services/SubscriptionPlanApiService.d.ts +1 -0
- package/dist/services/TenantApiService.d.ts +1 -0
- package/dist/services/UserApiService.d.ts +1 -0
- package/dist/types/api.d.ts +39 -6
- package/dist/types/api.d.ts.map +1 -1
- package/package.json +26 -25
- package/CHANGELOG.md +0 -32
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { useLocation as
|
|
4
|
-
class
|
|
1
|
+
import { jsx as n, Fragment as D, jsxs as l } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as ae, useState as p, useMemo as _, useCallback as oe, useEffect as Z, useContext as le } from "react";
|
|
3
|
+
import { useLocation as he, Navigate as de } from "react-router-dom";
|
|
4
|
+
class te {
|
|
5
5
|
// SessionManager instance
|
|
6
6
|
constructor(e, t = 1e4) {
|
|
7
7
|
this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
|
|
@@ -12,44 +12,44 @@ class G {
|
|
|
12
12
|
getBaseUrl() {
|
|
13
13
|
return this.baseUrl;
|
|
14
14
|
}
|
|
15
|
-
async request(e, t, r,
|
|
16
|
-
return this.executeRequest(e, t, r,
|
|
15
|
+
async request(e, t, r, s) {
|
|
16
|
+
return this.executeRequest(e, t, r, s, !1);
|
|
17
17
|
}
|
|
18
|
-
async executeRequest(e, t, r,
|
|
19
|
-
const
|
|
20
|
-
let
|
|
18
|
+
async executeRequest(e, t, r, s, a = !1) {
|
|
19
|
+
const b = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, E = (s == null ? void 0 : s.timeout) || this.timeout;
|
|
20
|
+
let L = {
|
|
21
21
|
"Content-Type": "application/json",
|
|
22
|
-
...
|
|
22
|
+
...s == null ? void 0 : s.headers
|
|
23
23
|
};
|
|
24
|
-
if (!(
|
|
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 m = await this.sessionManager.getAuthHeaders();
|
|
27
|
+
L = { ...L, ...m };
|
|
28
|
+
} catch (m) {
|
|
29
|
+
console.warn("Failed to inject auth headers:", m);
|
|
30
30
|
}
|
|
31
|
-
const P = new AbortController(),
|
|
31
|
+
const P = new AbortController(), f = setTimeout(() => P.abort(), E);
|
|
32
32
|
try {
|
|
33
|
-
const
|
|
33
|
+
const m = await fetch(b, {
|
|
34
34
|
method: e,
|
|
35
|
-
headers:
|
|
35
|
+
headers: L,
|
|
36
36
|
body: r ? JSON.stringify(r) : void 0,
|
|
37
37
|
signal: P.signal
|
|
38
38
|
});
|
|
39
|
-
if (clearTimeout(
|
|
39
|
+
if (clearTimeout(f), m.status === 401 && !(s != null && s.skipRetry) && !a && this.sessionManager)
|
|
40
40
|
try {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, r,
|
|
41
|
+
const w = this.sessionManager.getTokens();
|
|
42
|
+
if (w != null && w.refreshToken)
|
|
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 ${m.status}: ${m.statusText}`);
|
|
46
46
|
}
|
|
47
|
-
if (!
|
|
48
|
-
throw new Error(`HTTP ${
|
|
49
|
-
const
|
|
50
|
-
return !
|
|
51
|
-
} catch (
|
|
52
|
-
throw clearTimeout(
|
|
47
|
+
if (!m.ok)
|
|
48
|
+
throw new Error(`HTTP ${m.status}: ${m.statusText}`);
|
|
49
|
+
const M = m.headers.get("content-type");
|
|
50
|
+
return !M || !M.includes("application/json") ? {} : await m.json();
|
|
51
|
+
} catch (m) {
|
|
52
|
+
throw clearTimeout(f), m instanceof Error && m.name === "AbortError" ? new Error(`Request timeout after ${E}ms`) : m;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
async get(e, t) {
|
|
@@ -65,7 +65,7 @@ class G {
|
|
|
65
65
|
return this.request("DELETE", e, void 0, t);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
class
|
|
68
|
+
class Te {
|
|
69
69
|
constructor(e, t) {
|
|
70
70
|
this.httpService = e, this.sessionManager = t;
|
|
71
71
|
}
|
|
@@ -78,12 +78,12 @@ class be {
|
|
|
78
78
|
async getApps(e) {
|
|
79
79
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
80
80
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
81
|
-
const
|
|
81
|
+
const s = `/apps/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
|
|
82
82
|
headers: t
|
|
83
83
|
});
|
|
84
84
|
return {
|
|
85
|
-
apps:
|
|
86
|
-
meta:
|
|
85
|
+
apps: a.data,
|
|
86
|
+
meta: a.meta
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
async getAppById(e) {
|
|
@@ -110,11 +110,11 @@ class be {
|
|
|
110
110
|
)).data;
|
|
111
111
|
}
|
|
112
112
|
async updateSettingsSchema(e, t, r) {
|
|
113
|
-
const
|
|
113
|
+
const s = await this.sessionManager.getAuthHeaders();
|
|
114
114
|
return (await this.httpService.put(
|
|
115
115
|
`/apps/${e}/settings-schema`,
|
|
116
116
|
{ schema: t, defaultSettings: r },
|
|
117
|
-
{ headers:
|
|
117
|
+
{ headers: s }
|
|
118
118
|
)).data;
|
|
119
119
|
}
|
|
120
120
|
async exportConfig(e) {
|
|
@@ -124,7 +124,7 @@ class be {
|
|
|
124
124
|
})).data;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
const
|
|
127
|
+
const we = ae(null), Me = () => /* @__PURE__ */ n(
|
|
128
128
|
"div",
|
|
129
129
|
{
|
|
130
130
|
style: {
|
|
@@ -134,9 +134,9 @@ const pe = ee(null), Se = () => /* @__PURE__ */ s(
|
|
|
134
134
|
height: "100vh",
|
|
135
135
|
fontFamily: "system-ui, sans-serif"
|
|
136
136
|
},
|
|
137
|
-
children: /* @__PURE__ */
|
|
137
|
+
children: /* @__PURE__ */ n("div", { children: "Loading application..." })
|
|
138
138
|
}
|
|
139
|
-
),
|
|
139
|
+
), Ee = ({ error: i, retry: e }) => /* @__PURE__ */ l(
|
|
140
140
|
"div",
|
|
141
141
|
{
|
|
142
142
|
style: {
|
|
@@ -150,9 +150,9 @@ const pe = ee(null), Se = () => /* @__PURE__ */ s(
|
|
|
150
150
|
padding: "20px"
|
|
151
151
|
},
|
|
152
152
|
children: [
|
|
153
|
-
/* @__PURE__ */
|
|
154
|
-
/* @__PURE__ */
|
|
155
|
-
/* @__PURE__ */
|
|
153
|
+
/* @__PURE__ */ n("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Application Error" }),
|
|
154
|
+
/* @__PURE__ */ n("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load application" }),
|
|
155
|
+
/* @__PURE__ */ n(
|
|
156
156
|
"button",
|
|
157
157
|
{
|
|
158
158
|
onClick: e,
|
|
@@ -170,9 +170,9 @@ const pe = ee(null), Se = () => /* @__PURE__ */ s(
|
|
|
170
170
|
]
|
|
171
171
|
}
|
|
172
172
|
);
|
|
173
|
-
function
|
|
174
|
-
const [t, r] =
|
|
175
|
-
const
|
|
173
|
+
function ht({ config: i, children: e }) {
|
|
174
|
+
const [t, r] = p(null), [s, a] = p(!0), [b, E] = p(null), L = _(() => {
|
|
175
|
+
const f = () => {
|
|
176
176
|
P();
|
|
177
177
|
};
|
|
178
178
|
return {
|
|
@@ -180,40 +180,40 @@ function Ze({ config: i, children: e }) {
|
|
|
180
180
|
baseUrl: i.baseUrl,
|
|
181
181
|
// App info
|
|
182
182
|
appInfo: t,
|
|
183
|
-
isAppLoading:
|
|
184
|
-
appError:
|
|
185
|
-
retryApp:
|
|
183
|
+
isAppLoading: s,
|
|
184
|
+
appError: b,
|
|
185
|
+
retryApp: f
|
|
186
186
|
};
|
|
187
|
-
}, [i, t,
|
|
187
|
+
}, [i, t, s, b]), P = oe(async () => {
|
|
188
188
|
try {
|
|
189
|
-
|
|
190
|
-
const
|
|
191
|
-
r(
|
|
192
|
-
} catch (
|
|
193
|
-
const
|
|
194
|
-
|
|
189
|
+
a(!0), E(null);
|
|
190
|
+
const f = new te(i.baseUrl), M = await new Te(f, {}).getPublicAppInfo(i.appId);
|
|
191
|
+
r(M);
|
|
192
|
+
} catch (f) {
|
|
193
|
+
const m = f instanceof Error ? f : new Error("Failed to load app information");
|
|
194
|
+
E(m), r(null);
|
|
195
195
|
} finally {
|
|
196
|
-
|
|
196
|
+
a(!1);
|
|
197
197
|
}
|
|
198
198
|
}, [i.baseUrl, i.appId]);
|
|
199
|
-
if (
|
|
199
|
+
if (Z(() => {
|
|
200
200
|
P();
|
|
201
|
-
}, [P]),
|
|
202
|
-
return /* @__PURE__ */
|
|
203
|
-
if (
|
|
204
|
-
const
|
|
205
|
-
return /* @__PURE__ */
|
|
201
|
+
}, [P]), s)
|
|
202
|
+
return /* @__PURE__ */ n(D, { children: i.loadingFallback || /* @__PURE__ */ n(Me, {}) });
|
|
203
|
+
if (b) {
|
|
204
|
+
const f = typeof i.errorFallback == "function" ? i.errorFallback(b, () => P()) : i.errorFallback || /* @__PURE__ */ n(Ee, { error: b, retry: () => P() });
|
|
205
|
+
return /* @__PURE__ */ n(D, { children: f });
|
|
206
206
|
}
|
|
207
|
-
return /* @__PURE__ */
|
|
207
|
+
return /* @__PURE__ */ n(we.Provider, { value: L, children: e });
|
|
208
208
|
}
|
|
209
|
-
function
|
|
210
|
-
const i =
|
|
209
|
+
function ne() {
|
|
210
|
+
const i = le(we);
|
|
211
211
|
if (!i)
|
|
212
212
|
throw new Error("useApp must be used within an AppProvider");
|
|
213
213
|
return i;
|
|
214
214
|
}
|
|
215
|
-
const
|
|
216
|
-
class
|
|
215
|
+
const gt = ne;
|
|
216
|
+
class Le {
|
|
217
217
|
constructor(e = {}) {
|
|
218
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 || {
|
|
219
219
|
get: () => {
|
|
@@ -281,10 +281,10 @@ class xe {
|
|
|
281
281
|
try {
|
|
282
282
|
await this.refreshPromise;
|
|
283
283
|
const t = this.getTokens(), r = t != null && t.accessToken ? { Authorization: `Bearer ${t.accessToken}` } : {};
|
|
284
|
-
return this.refreshQueue.forEach(({ resolve:
|
|
284
|
+
return this.refreshQueue.forEach(({ resolve: s }) => s(r)), this.refreshQueue = [], r;
|
|
285
285
|
} catch (t) {
|
|
286
286
|
const r = t instanceof Error ? t : new Error("Token refresh failed");
|
|
287
|
-
return this.refreshQueue.forEach(({ reject:
|
|
287
|
+
return this.refreshQueue.forEach(({ reject: s }) => s(r)), this.refreshQueue = [], this.clearSession(), this.onRefreshFailed && this.onRefreshFailed(), {};
|
|
288
288
|
} finally {
|
|
289
289
|
this.refreshPromise = null;
|
|
290
290
|
}
|
|
@@ -303,11 +303,11 @@ class xe {
|
|
|
303
303
|
});
|
|
304
304
|
if (!r.ok)
|
|
305
305
|
throw new Error(`Token refresh failed: ${r.status} ${r.statusText}`);
|
|
306
|
-
const
|
|
306
|
+
const s = await r.json();
|
|
307
307
|
this.setTokens({
|
|
308
|
-
accessToken:
|
|
309
|
-
refreshToken:
|
|
310
|
-
expiresIn:
|
|
308
|
+
accessToken: s.accessToken,
|
|
309
|
+
refreshToken: s.refreshToken || e,
|
|
310
|
+
expiresIn: s.expiresIn
|
|
311
311
|
});
|
|
312
312
|
}
|
|
313
313
|
setUser(e) {
|
|
@@ -330,7 +330,7 @@ class xe {
|
|
|
330
330
|
return e !== null && !this.isTokenExpired(e);
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
|
-
class
|
|
333
|
+
class Re {
|
|
334
334
|
constructor(e) {
|
|
335
335
|
this.httpService = e;
|
|
336
336
|
}
|
|
@@ -354,6 +354,18 @@ class Ae {
|
|
|
354
354
|
async requestPasswordReset(e) {
|
|
355
355
|
await this.httpService.post("/auth/password-reset/request", e);
|
|
356
356
|
}
|
|
357
|
+
async sendMagicLink(e) {
|
|
358
|
+
return await this.httpService.post(
|
|
359
|
+
"/auth/magic-link/send",
|
|
360
|
+
e
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
async verifyMagicLink(e) {
|
|
364
|
+
return await this.httpService.post(
|
|
365
|
+
"/auth/magic-link/verify",
|
|
366
|
+
e
|
|
367
|
+
);
|
|
368
|
+
}
|
|
357
369
|
async confirmPasswordReset(e) {
|
|
358
370
|
await this.httpService.post("/auth/password-reset/confirm", e);
|
|
359
371
|
}
|
|
@@ -364,7 +376,7 @@ class Ae {
|
|
|
364
376
|
});
|
|
365
377
|
}
|
|
366
378
|
}
|
|
367
|
-
class
|
|
379
|
+
class pe {
|
|
368
380
|
constructor(e, t) {
|
|
369
381
|
this.httpService = e, this.sessionManager = t;
|
|
370
382
|
}
|
|
@@ -404,10 +416,10 @@ class ce {
|
|
|
404
416
|
async getRolesByApp(e, t) {
|
|
405
417
|
const r = new URLSearchParams();
|
|
406
418
|
t != null && t.page && r.append("page", t.page.toString()), t != null && t.limit && r.append("limit", t.limit.toString()), t != null && t.sortBy && r.append("sortBy", t.sortBy), t != null && t.sortOrder && r.append("sortOrder", t.sortOrder);
|
|
407
|
-
const
|
|
419
|
+
const s = `/roles/app/${e}${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s);
|
|
408
420
|
return {
|
|
409
|
-
roles:
|
|
410
|
-
meta:
|
|
421
|
+
roles: a.data,
|
|
422
|
+
meta: a.meta
|
|
411
423
|
};
|
|
412
424
|
}
|
|
413
425
|
async assignRole(e, t) {
|
|
@@ -429,18 +441,18 @@ class ce {
|
|
|
429
441
|
async getUserRoles(e, t) {
|
|
430
442
|
if (!this.sessionManager)
|
|
431
443
|
throw new Error("SessionManager is required for private endpoints");
|
|
432
|
-
const r = await this.sessionManager.getAuthHeaders(),
|
|
433
|
-
t != null && t.page &&
|
|
434
|
-
const
|
|
444
|
+
const r = await this.sessionManager.getAuthHeaders(), s = new URLSearchParams();
|
|
445
|
+
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()}` : ""}`, b = await this.httpService.get(a, {
|
|
435
447
|
headers: r
|
|
436
448
|
});
|
|
437
449
|
return {
|
|
438
|
-
roles:
|
|
439
|
-
meta:
|
|
450
|
+
roles: b.data,
|
|
451
|
+
meta: b.meta
|
|
440
452
|
};
|
|
441
453
|
}
|
|
442
454
|
}
|
|
443
|
-
class
|
|
455
|
+
class Ce {
|
|
444
456
|
constructor(e, t) {
|
|
445
457
|
this.httpService = e, this.sessionManager = t;
|
|
446
458
|
}
|
|
@@ -453,12 +465,12 @@ class Pe {
|
|
|
453
465
|
async getUsers(e) {
|
|
454
466
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
455
467
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
456
|
-
const
|
|
468
|
+
const s = `/users/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
|
|
457
469
|
headers: t
|
|
458
470
|
});
|
|
459
471
|
return {
|
|
460
|
-
users:
|
|
461
|
-
meta:
|
|
472
|
+
users: a.data,
|
|
473
|
+
meta: a.meta
|
|
462
474
|
};
|
|
463
475
|
}
|
|
464
476
|
async getUserById(e) {
|
|
@@ -480,7 +492,7 @@ class Pe {
|
|
|
480
492
|
});
|
|
481
493
|
}
|
|
482
494
|
}
|
|
483
|
-
class
|
|
495
|
+
class fe {
|
|
484
496
|
constructor(e, t, r) {
|
|
485
497
|
this.httpService = e, this.appId = t, this.sessionManager = r;
|
|
486
498
|
}
|
|
@@ -497,12 +509,12 @@ class de {
|
|
|
497
509
|
throw new Error("SessionManager is required for private endpoints");
|
|
498
510
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
499
511
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
500
|
-
const
|
|
512
|
+
const s = `/tenants/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
|
|
501
513
|
headers: t
|
|
502
514
|
});
|
|
503
515
|
return {
|
|
504
|
-
tenants:
|
|
505
|
-
meta:
|
|
516
|
+
tenants: a.data,
|
|
517
|
+
meta: a.meta
|
|
506
518
|
};
|
|
507
519
|
}
|
|
508
520
|
async getTenantById(e) {
|
|
@@ -558,7 +570,7 @@ class de {
|
|
|
558
570
|
)).data;
|
|
559
571
|
}
|
|
560
572
|
}
|
|
561
|
-
const
|
|
573
|
+
const ve = ae(null), Ie = () => /* @__PURE__ */ n(
|
|
562
574
|
"div",
|
|
563
575
|
{
|
|
564
576
|
style: {
|
|
@@ -568,9 +580,9 @@ const fe = ee(null), ke = () => /* @__PURE__ */ s(
|
|
|
568
580
|
height: "100vh",
|
|
569
581
|
fontFamily: "system-ui, sans-serif"
|
|
570
582
|
},
|
|
571
|
-
children: /* @__PURE__ */
|
|
583
|
+
children: /* @__PURE__ */ n("div", { children: "Loading tenant..." })
|
|
572
584
|
}
|
|
573
|
-
),
|
|
585
|
+
), Fe = ({ error: i, retry: e }) => /* @__PURE__ */ l(
|
|
574
586
|
"div",
|
|
575
587
|
{
|
|
576
588
|
style: {
|
|
@@ -584,9 +596,9 @@ const fe = ee(null), ke = () => /* @__PURE__ */ s(
|
|
|
584
596
|
padding: "20px"
|
|
585
597
|
},
|
|
586
598
|
children: [
|
|
587
|
-
/* @__PURE__ */
|
|
588
|
-
/* @__PURE__ */
|
|
589
|
-
/* @__PURE__ */
|
|
599
|
+
/* @__PURE__ */ n("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Tenant Error" }),
|
|
600
|
+
/* @__PURE__ */ n("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load tenant" }),
|
|
601
|
+
/* @__PURE__ */ n(
|
|
590
602
|
"button",
|
|
591
603
|
{
|
|
592
604
|
onClick: e,
|
|
@@ -604,77 +616,77 @@ const fe = ee(null), ke = () => /* @__PURE__ */ s(
|
|
|
604
616
|
]
|
|
605
617
|
}
|
|
606
618
|
);
|
|
607
|
-
function
|
|
608
|
-
const { baseUrl: t, appInfo: r, appId:
|
|
609
|
-
const
|
|
619
|
+
function pt({ config: i, children: e }) {
|
|
620
|
+
const { baseUrl: t, appInfo: r, appId: s } = ne(), [a, b] = p(i.initialTenant || null), [E, L] = p(!i.initialTenant), [P, f] = p(null), [m, M] = p(null), [w, v] = p(!1), [I, g] = p(null), U = oe(() => {
|
|
621
|
+
const S = i.tenantMode || "selector", c = "tenant";
|
|
610
622
|
if (typeof window > "u") return null;
|
|
611
|
-
if (
|
|
612
|
-
const
|
|
613
|
-
if (
|
|
614
|
-
const
|
|
615
|
-
return localStorage.setItem(
|
|
623
|
+
if (S === "subdomain") {
|
|
624
|
+
const o = window.location.hostname.split(".");
|
|
625
|
+
if (o.length >= 3) {
|
|
626
|
+
const d = o[0];
|
|
627
|
+
return localStorage.setItem(c, d), d;
|
|
616
628
|
}
|
|
617
|
-
return localStorage.getItem(
|
|
618
|
-
} else if (
|
|
619
|
-
const
|
|
620
|
-
return
|
|
629
|
+
return localStorage.getItem(c);
|
|
630
|
+
} else if (S === "selector") {
|
|
631
|
+
const o = new URLSearchParams(window.location.search).get(i.selectorParam || "tenant");
|
|
632
|
+
return o ? (localStorage.setItem(c, o), o) : localStorage.getItem(c);
|
|
621
633
|
}
|
|
622
634
|
return null;
|
|
623
|
-
}, [i.tenantMode, i.selectorParam]),
|
|
624
|
-
async (
|
|
635
|
+
}, [i.tenantMode, i.selectorParam]), u = _(() => U(), [U]), y = (r == null ? void 0 : r.settingsSchema) || null, x = oe(
|
|
636
|
+
async (S) => {
|
|
625
637
|
try {
|
|
626
|
-
|
|
627
|
-
const
|
|
628
|
-
|
|
629
|
-
} catch (
|
|
630
|
-
const
|
|
631
|
-
|
|
638
|
+
L(!0), f(null);
|
|
639
|
+
const c = new te(t), o = await new fe(c, s).getPublicTenantInfo(S);
|
|
640
|
+
b(o);
|
|
641
|
+
} catch (c) {
|
|
642
|
+
const h = c instanceof Error ? c : new Error("Failed to load tenant information");
|
|
643
|
+
f(h), b(null);
|
|
632
644
|
} finally {
|
|
633
|
-
|
|
645
|
+
L(!1);
|
|
634
646
|
}
|
|
635
647
|
},
|
|
636
|
-
[t,
|
|
637
|
-
),
|
|
638
|
-
if (
|
|
648
|
+
[t, s]
|
|
649
|
+
), F = oe(async () => {
|
|
650
|
+
if (a != null && a.id)
|
|
639
651
|
try {
|
|
640
|
-
|
|
641
|
-
const
|
|
642
|
-
|
|
643
|
-
} catch (
|
|
644
|
-
const
|
|
645
|
-
|
|
652
|
+
v(!0), g(null);
|
|
653
|
+
const S = new te(t), h = await new fe(S, a.appId).getTenantSettings(a.id);
|
|
654
|
+
M(h);
|
|
655
|
+
} catch (S) {
|
|
656
|
+
const c = S instanceof Error ? S : new Error("Failed to load tenant settings");
|
|
657
|
+
g(c), M(null);
|
|
646
658
|
} finally {
|
|
647
|
-
|
|
659
|
+
v(!1);
|
|
648
660
|
}
|
|
649
|
-
}, [t,
|
|
650
|
-
|
|
651
|
-
}, [
|
|
652
|
-
(
|
|
653
|
-
if (!
|
|
661
|
+
}, [t, a]), B = oe(() => {
|
|
662
|
+
F();
|
|
663
|
+
}, [F]), z = oe(
|
|
664
|
+
(S) => {
|
|
665
|
+
if (!y)
|
|
654
666
|
return { isValid: !0, errors: [] };
|
|
655
|
-
const
|
|
667
|
+
const c = [];
|
|
656
668
|
try {
|
|
657
|
-
return
|
|
658
|
-
var
|
|
659
|
-
const
|
|
660
|
-
if ((
|
|
661
|
-
|
|
669
|
+
return y.properties && Object.entries(y.properties).forEach(([h, o]) => {
|
|
670
|
+
var G;
|
|
671
|
+
const d = S[h];
|
|
672
|
+
if ((G = y.required) != null && G.includes(h) && d == null) {
|
|
673
|
+
c.push(`Field '${h}' is required`);
|
|
662
674
|
return;
|
|
663
675
|
}
|
|
664
|
-
if (
|
|
665
|
-
if (
|
|
666
|
-
const
|
|
667
|
-
|
|
676
|
+
if (d != null) {
|
|
677
|
+
if (o.type) {
|
|
678
|
+
const Y = o.type, H = typeof d;
|
|
679
|
+
Y === "string" && H !== "string" ? c.push(`Field '${h}' must be a string`) : (Y === "number" || Y === "integer") && H !== "number" ? c.push(`Field '${h}' must be a number`) : Y === "boolean" && H !== "boolean" ? c.push(`Field '${h}' must be a boolean`) : Y === "array" && !Array.isArray(d) && c.push(`Field '${h}' must be an array`);
|
|
668
680
|
}
|
|
669
|
-
|
|
670
|
-
`Field '${
|
|
671
|
-
),
|
|
672
|
-
`Field '${
|
|
673
|
-
),
|
|
681
|
+
o.minLength !== void 0 && typeof d == "string" && d.length < o.minLength && c.push(
|
|
682
|
+
`Field '${h}' must be at least ${o.minLength} characters long`
|
|
683
|
+
), o.maxLength !== void 0 && typeof d == "string" && d.length > o.maxLength && c.push(
|
|
684
|
+
`Field '${h}' must be no more than ${o.maxLength} characters long`
|
|
685
|
+
), o.minimum !== void 0 && typeof d == "number" && d < o.minimum && c.push(`Field '${h}' must be at least ${o.minimum}`), o.maximum !== void 0 && typeof d == "number" && d > o.maximum && c.push(`Field '${h}' must be no more than ${o.maximum}`), o.pattern && typeof d == "string" && (new RegExp(o.pattern).test(d) || c.push(`Field '${h}' does not match the required pattern`)), o.enum && !o.enum.includes(d) && c.push(`Field '${h}' must be one of: ${o.enum.join(", ")}`);
|
|
674
686
|
}
|
|
675
687
|
}), {
|
|
676
|
-
isValid:
|
|
677
|
-
errors:
|
|
688
|
+
isValid: c.length === 0,
|
|
689
|
+
errors: c
|
|
678
690
|
};
|
|
679
691
|
} catch {
|
|
680
692
|
return {
|
|
@@ -683,275 +695,321 @@ function tt({ config: i, children: e }) {
|
|
|
683
695
|
};
|
|
684
696
|
}
|
|
685
697
|
},
|
|
686
|
-
[
|
|
698
|
+
[y]
|
|
687
699
|
);
|
|
688
|
-
|
|
689
|
-
!i.initialTenant &&
|
|
690
|
-
}, [i.initialTenant,
|
|
691
|
-
|
|
692
|
-
}, [
|
|
693
|
-
const
|
|
700
|
+
Z(() => {
|
|
701
|
+
!i.initialTenant && u ? x(u) : !i.initialTenant && !u && (b(null), f(null), L(!1));
|
|
702
|
+
}, [i.initialTenant, u, x]), Z(() => {
|
|
703
|
+
a != null && a.id ? F() : (M(null), g(null), v(!1));
|
|
704
|
+
}, [a == null ? void 0 : a.id, F]);
|
|
705
|
+
const q = _(() => ({
|
|
694
706
|
// Tenant info
|
|
695
|
-
tenant:
|
|
696
|
-
tenantSlug:
|
|
697
|
-
isTenantLoading:
|
|
707
|
+
tenant: a,
|
|
708
|
+
tenantSlug: u,
|
|
709
|
+
isTenantLoading: E,
|
|
698
710
|
tenantError: P,
|
|
699
711
|
retryTenant: () => {
|
|
700
|
-
|
|
712
|
+
u && x(u);
|
|
701
713
|
},
|
|
702
714
|
// Settings
|
|
703
|
-
settings:
|
|
704
|
-
settingsSchema:
|
|
705
|
-
isSettingsLoading:
|
|
706
|
-
settingsError:
|
|
715
|
+
settings: m,
|
|
716
|
+
settingsSchema: y,
|
|
717
|
+
isSettingsLoading: w,
|
|
718
|
+
settingsError: I,
|
|
707
719
|
// Actions
|
|
708
|
-
refreshSettings:
|
|
720
|
+
refreshSettings: B,
|
|
709
721
|
// Validation
|
|
710
|
-
validateSettings:
|
|
722
|
+
validateSettings: z
|
|
711
723
|
}), [
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
724
|
+
a,
|
|
725
|
+
u,
|
|
726
|
+
E,
|
|
715
727
|
P,
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
728
|
+
m,
|
|
729
|
+
y,
|
|
730
|
+
w,
|
|
731
|
+
I,
|
|
732
|
+
B,
|
|
733
|
+
z
|
|
722
734
|
]);
|
|
723
|
-
if (
|
|
724
|
-
return /* @__PURE__ */
|
|
735
|
+
if (E)
|
|
736
|
+
return /* @__PURE__ */ n(D, { children: i.loadingFallback || /* @__PURE__ */ n(Ie, {}) });
|
|
725
737
|
if (P) {
|
|
726
|
-
const
|
|
727
|
-
return /* @__PURE__ */
|
|
738
|
+
const S = typeof i.errorFallback == "function" ? i.errorFallback(P, () => x(u || "")) : i.errorFallback || /* @__PURE__ */ n(Fe, { error: P, retry: () => x(u || "") });
|
|
739
|
+
return /* @__PURE__ */ n(D, { children: S });
|
|
728
740
|
}
|
|
729
|
-
return /* @__PURE__ */
|
|
741
|
+
return /* @__PURE__ */ n(ve.Provider, { value: q, children: e });
|
|
730
742
|
}
|
|
731
|
-
function
|
|
732
|
-
const i =
|
|
743
|
+
function ge() {
|
|
744
|
+
const i = le(ve);
|
|
733
745
|
if (!i)
|
|
734
746
|
throw new Error("useTenant must be used within a TenantProvider");
|
|
735
747
|
return i;
|
|
736
748
|
}
|
|
737
|
-
const
|
|
738
|
-
function
|
|
739
|
-
const {
|
|
740
|
-
settings: i,
|
|
741
|
-
settingsSchema: e,
|
|
742
|
-
isSettingsLoading: t,
|
|
743
|
-
settingsError: r,
|
|
744
|
-
validateSettings: n
|
|
745
|
-
} = le();
|
|
749
|
+
const ft = ge;
|
|
750
|
+
function mt() {
|
|
751
|
+
const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } = ge();
|
|
746
752
|
return {
|
|
747
753
|
settings: i,
|
|
748
754
|
settingsSchema: e,
|
|
749
755
|
isLoading: t,
|
|
750
756
|
error: r,
|
|
751
|
-
validateSettings:
|
|
757
|
+
validateSettings: s
|
|
752
758
|
};
|
|
753
759
|
}
|
|
754
|
-
function
|
|
755
|
-
const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant:
|
|
760
|
+
function re() {
|
|
761
|
+
const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } = ge();
|
|
756
762
|
return {
|
|
757
763
|
tenant: i,
|
|
758
764
|
tenantSlug: e,
|
|
759
765
|
isLoading: t,
|
|
760
766
|
error: r,
|
|
761
|
-
retry:
|
|
767
|
+
retry: s
|
|
762
768
|
};
|
|
763
769
|
}
|
|
764
|
-
const
|
|
765
|
-
function
|
|
766
|
-
const { appId: t, baseUrl: r } =
|
|
767
|
-
const
|
|
770
|
+
const Se = ae(null);
|
|
771
|
+
function yt({ config: i = {}, children: e }) {
|
|
772
|
+
const { appId: t, baseUrl: r } = ne(), s = re(), a = (s == null ? void 0 : s.tenantSlug) || null, [b, E] = p(i.initialRoles || []), [L, P] = p(!i.initialRoles), [f, m] = p(null), [M, w] = p(!1), [v, I] = p(null), g = _(() => {
|
|
773
|
+
const S = a ? `auth_tokens_${a}` : "auth_tokens", c = {
|
|
768
774
|
get: () => {
|
|
769
775
|
try {
|
|
770
|
-
const
|
|
771
|
-
return
|
|
776
|
+
const h = localStorage.getItem(S);
|
|
777
|
+
return h ? JSON.parse(h) : null;
|
|
772
778
|
} catch {
|
|
773
779
|
return null;
|
|
774
780
|
}
|
|
775
781
|
},
|
|
776
|
-
set: (
|
|
782
|
+
set: (h) => {
|
|
777
783
|
try {
|
|
778
|
-
localStorage.setItem(
|
|
784
|
+
localStorage.setItem(S, JSON.stringify(h));
|
|
779
785
|
} catch {
|
|
780
786
|
}
|
|
781
787
|
},
|
|
782
788
|
clear: () => {
|
|
783
789
|
try {
|
|
784
|
-
localStorage.removeItem(
|
|
790
|
+
localStorage.removeItem(S);
|
|
785
791
|
} catch {
|
|
786
792
|
}
|
|
787
793
|
}
|
|
788
794
|
};
|
|
789
|
-
return new
|
|
795
|
+
return new Le({
|
|
790
796
|
onRefreshFailed: i.onRefreshFailed,
|
|
791
|
-
tokenStorage:
|
|
797
|
+
tokenStorage: c,
|
|
792
798
|
baseUrl: r
|
|
793
799
|
});
|
|
794
|
-
}, [
|
|
795
|
-
const
|
|
796
|
-
return
|
|
797
|
-
}, [r,
|
|
798
|
-
|
|
799
|
-
console.log("AuthProvider - userPermissions changed:",
|
|
800
|
-
}, [
|
|
801
|
-
const
|
|
802
|
-
const
|
|
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 () => {
|
|
803
809
|
try {
|
|
804
|
-
|
|
805
|
-
const
|
|
806
|
-
if (!(
|
|
810
|
+
w(!0), I(null);
|
|
811
|
+
const A = g.getUser();
|
|
812
|
+
if (!(A != null && A.id))
|
|
807
813
|
throw new Error("No user ID available in session");
|
|
808
|
-
const $ = await
|
|
809
|
-
|
|
810
|
-
} catch (
|
|
811
|
-
const $ =
|
|
812
|
-
|
|
814
|
+
const $ = await y.getUserById(A.id);
|
|
815
|
+
m($), g.setUser($);
|
|
816
|
+
} catch (A) {
|
|
817
|
+
const $ = A instanceof Error ? A : new Error("Failed to load user data");
|
|
818
|
+
I($), console.error("Failed to load user data:", $);
|
|
813
819
|
} finally {
|
|
814
|
-
|
|
820
|
+
w(!1);
|
|
815
821
|
}
|
|
816
|
-
},
|
|
817
|
-
await
|
|
818
|
-
},
|
|
819
|
-
const
|
|
820
|
-
|
|
822
|
+
}, c = async () => {
|
|
823
|
+
await S();
|
|
824
|
+
}, h = async (A, $, Q, X) => {
|
|
825
|
+
const W = await u.login({
|
|
826
|
+
username: A,
|
|
821
827
|
password: $,
|
|
822
|
-
|
|
828
|
+
appId: Q,
|
|
829
|
+
tenantId: X
|
|
830
|
+
});
|
|
831
|
+
if (g.setTokens({
|
|
832
|
+
accessToken: W.accessToken,
|
|
833
|
+
refreshToken: W.refreshToken,
|
|
834
|
+
expiresIn: W.expiresIn
|
|
835
|
+
}), W.user) {
|
|
836
|
+
g.setUser(W.user), m(W.user);
|
|
837
|
+
try {
|
|
838
|
+
await S();
|
|
839
|
+
} catch (ee) {
|
|
840
|
+
console.warn("Failed to load complete user data after login:", ee);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
return W;
|
|
844
|
+
}, o = async (A, $, Q, X, W, ee, ce) => {
|
|
845
|
+
if (!A && !$)
|
|
846
|
+
throw new Error("Either email or phoneNumber is required");
|
|
847
|
+
if (!Q || !X)
|
|
848
|
+
throw new Error("Name and password are required");
|
|
849
|
+
return await u.signup({
|
|
850
|
+
email: A,
|
|
851
|
+
phoneNumber: $,
|
|
852
|
+
name: Q,
|
|
853
|
+
password: X,
|
|
854
|
+
tenantId: W,
|
|
855
|
+
lastName: ee,
|
|
856
|
+
appId: ce
|
|
823
857
|
});
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
858
|
+
}, d = async (A, $, Q, X, W, ee, ce) => {
|
|
859
|
+
if (!A && !$)
|
|
860
|
+
throw new Error("Either email or phoneNumber is required");
|
|
861
|
+
if (!Q || !X || !W)
|
|
862
|
+
throw new Error("Name, password, and tenantName are required");
|
|
863
|
+
return await u.signupTenantAdmin({
|
|
864
|
+
email: A,
|
|
865
|
+
phoneNumber: $,
|
|
866
|
+
name: Q,
|
|
867
|
+
password: X,
|
|
868
|
+
tenantName: W,
|
|
869
|
+
appId: ce,
|
|
870
|
+
lastName: ee
|
|
871
|
+
});
|
|
872
|
+
}, G = async (A, $) => {
|
|
873
|
+
const Q = await g.getAuthHeaders();
|
|
874
|
+
await u.changePassword({ currentPassword: A, newPassword: $ }, Q);
|
|
875
|
+
}, Y = async (A, $) => {
|
|
876
|
+
await u.requestPasswordReset({ email: A, tenantId: $ });
|
|
877
|
+
}, H = async (A, $) => {
|
|
878
|
+
await u.confirmPasswordReset({ token: A, newPassword: $ });
|
|
879
|
+
}, C = async (A, $, Q, X, W, ee) => await u.sendMagicLink({
|
|
880
|
+
email: A,
|
|
881
|
+
tenantId: $,
|
|
882
|
+
frontendUrl: Q,
|
|
883
|
+
name: X,
|
|
884
|
+
lastName: W,
|
|
885
|
+
appId: ee
|
|
886
|
+
}), k = async (A, $, Q, X) => {
|
|
887
|
+
const W = await u.verifyMagicLink({
|
|
888
|
+
token: A,
|
|
889
|
+
email: $,
|
|
890
|
+
appId: Q,
|
|
891
|
+
tenantId: X
|
|
892
|
+
});
|
|
893
|
+
if (g.setTokens({
|
|
894
|
+
accessToken: W.accessToken,
|
|
895
|
+
refreshToken: W.refreshToken,
|
|
896
|
+
expiresIn: W.expiresIn
|
|
897
|
+
}), W.user) {
|
|
898
|
+
g.setUser(W.user), m(W.user);
|
|
830
899
|
try {
|
|
831
|
-
await
|
|
832
|
-
} catch (
|
|
833
|
-
console.warn("Failed to load complete user data after login:",
|
|
900
|
+
await S();
|
|
901
|
+
} catch (ee) {
|
|
902
|
+
console.warn("Failed to load complete user data after magic link login:", ee);
|
|
834
903
|
}
|
|
835
904
|
}
|
|
836
|
-
return
|
|
837
|
-
},
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
password: J,
|
|
841
|
-
tenantName: V,
|
|
842
|
-
appId: t
|
|
843
|
-
}), W = async (v, $) => {
|
|
844
|
-
const J = await f.getAuthHeaders();
|
|
845
|
-
await y.changePassword({ currentPassword: v, newPassword: $ }, J);
|
|
846
|
-
}, I = async (v, $) => {
|
|
847
|
-
await y.requestPasswordReset({ email: v, tenantId: $ });
|
|
848
|
-
}, N = async (v, $) => {
|
|
849
|
-
await y.confirmPasswordReset({ token: v, newPassword: $ });
|
|
850
|
-
}, _ = async () => {
|
|
851
|
-
const v = f.getTokens();
|
|
852
|
-
if (!(v != null && v.refreshToken))
|
|
905
|
+
return W;
|
|
906
|
+
}, T = async () => {
|
|
907
|
+
const A = g.getTokens();
|
|
908
|
+
if (!(A != null && A.refreshToken))
|
|
853
909
|
throw new Error("No refresh token available");
|
|
854
|
-
const $ = await
|
|
855
|
-
refreshToken:
|
|
910
|
+
const $ = await u.refreshToken({
|
|
911
|
+
refreshToken: A.refreshToken
|
|
856
912
|
});
|
|
857
|
-
|
|
913
|
+
g.setTokens({
|
|
858
914
|
accessToken: $.accessToken,
|
|
859
|
-
refreshToken: $.refreshToken ||
|
|
915
|
+
refreshToken: $.refreshToken || A.refreshToken,
|
|
860
916
|
expiresIn: $.expiresIn
|
|
861
917
|
});
|
|
862
|
-
},
|
|
863
|
-
|
|
864
|
-
},
|
|
865
|
-
|
|
866
|
-
},
|
|
867
|
-
|
|
868
|
-
},
|
|
918
|
+
}, J = () => {
|
|
919
|
+
g.clearSession(), m(null), I(null);
|
|
920
|
+
}, O = (A) => {
|
|
921
|
+
g.setTokens(A);
|
|
922
|
+
}, j = () => g.hasValidSession(), N = () => {
|
|
923
|
+
g.clearSession(), m(null), I(null);
|
|
924
|
+
}, K = async () => {
|
|
869
925
|
if (t)
|
|
870
926
|
try {
|
|
871
927
|
P(!0);
|
|
872
|
-
const { roles:
|
|
873
|
-
|
|
874
|
-
} catch (
|
|
875
|
-
console.error("Failed to fetch roles:",
|
|
928
|
+
const { roles: A } = await x.getRolesByApp(t);
|
|
929
|
+
E(A);
|
|
930
|
+
} catch (A) {
|
|
931
|
+
console.error("Failed to fetch roles:", A);
|
|
876
932
|
} finally {
|
|
877
933
|
P(!1);
|
|
878
934
|
}
|
|
879
|
-
},
|
|
880
|
-
await
|
|
881
|
-
},
|
|
882
|
-
if (!
|
|
935
|
+
}, R = async () => {
|
|
936
|
+
await K();
|
|
937
|
+
}, V = (A) => {
|
|
938
|
+
if (!z || z.length === 0)
|
|
883
939
|
return !1;
|
|
884
|
-
if (typeof
|
|
885
|
-
return
|
|
886
|
-
const $ = `${
|
|
887
|
-
return
|
|
940
|
+
if (typeof A == "string")
|
|
941
|
+
return z.includes(A);
|
|
942
|
+
const $ = `${A.resource}.${A.action}`;
|
|
943
|
+
return z.includes($);
|
|
888
944
|
};
|
|
889
945
|
return {
|
|
890
|
-
sessionManager:
|
|
891
|
-
authenticatedHttpService:
|
|
892
|
-
login:
|
|
893
|
-
signup:
|
|
894
|
-
signupTenantAdmin:
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
946
|
+
sessionManager: g,
|
|
947
|
+
authenticatedHttpService: U,
|
|
948
|
+
login: h,
|
|
949
|
+
signup: o,
|
|
950
|
+
signupTenantAdmin: d,
|
|
951
|
+
sendMagicLink: C,
|
|
952
|
+
verifyMagicLink: k,
|
|
953
|
+
changePassword: G,
|
|
954
|
+
requestPasswordReset: Y,
|
|
955
|
+
confirmPasswordReset: H,
|
|
956
|
+
refreshToken: T,
|
|
957
|
+
logout: J,
|
|
958
|
+
setTokens: O,
|
|
959
|
+
hasValidSession: j,
|
|
960
|
+
clearSession: N,
|
|
961
|
+
currentUser: f,
|
|
962
|
+
isUserLoading: M,
|
|
963
|
+
userError: v,
|
|
964
|
+
refreshUser: c,
|
|
965
|
+
userRole: B,
|
|
966
|
+
userPermissions: z,
|
|
967
|
+
availableRoles: b,
|
|
968
|
+
rolesLoading: L,
|
|
969
|
+
hasPermission: V,
|
|
970
|
+
hasAnyPermission: (A) => A.some(($) => V($)),
|
|
971
|
+
hasAllPermissions: (A) => A.every(($) => V($)),
|
|
972
|
+
getUserPermissionStrings: () => z || [],
|
|
973
|
+
refreshRoles: R
|
|
916
974
|
};
|
|
917
975
|
}, [
|
|
918
|
-
f,
|
|
919
|
-
L,
|
|
920
|
-
y,
|
|
921
|
-
S,
|
|
922
|
-
k,
|
|
923
|
-
t,
|
|
924
|
-
m,
|
|
925
976
|
g,
|
|
977
|
+
U,
|
|
978
|
+
u,
|
|
979
|
+
y,
|
|
926
980
|
x,
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
981
|
+
t,
|
|
982
|
+
b,
|
|
983
|
+
f,
|
|
984
|
+
M,
|
|
985
|
+
v,
|
|
986
|
+
B,
|
|
987
|
+
z
|
|
930
988
|
]);
|
|
931
|
-
return
|
|
989
|
+
return Z(() => {
|
|
932
990
|
!i.initialRoles && t && (async () => {
|
|
933
991
|
try {
|
|
934
992
|
P(!0);
|
|
935
|
-
const
|
|
936
|
-
|
|
937
|
-
} catch (
|
|
938
|
-
console.error("Failed to fetch roles:",
|
|
993
|
+
const c = new te(r), h = new pe(c), { roles: o } = await h.getRolesByApp(t);
|
|
994
|
+
E(o);
|
|
995
|
+
} catch (c) {
|
|
996
|
+
console.error("Failed to fetch roles:", c);
|
|
939
997
|
} finally {
|
|
940
998
|
P(!1);
|
|
941
999
|
}
|
|
942
1000
|
})();
|
|
943
|
-
}, [t, r, i.initialRoles]),
|
|
944
|
-
const
|
|
945
|
-
|
|
946
|
-
}, [
|
|
1001
|
+
}, [t, r, i.initialRoles]), Z(() => {
|
|
1002
|
+
const S = g.getUser();
|
|
1003
|
+
S && g.hasValidSession() && m(S);
|
|
1004
|
+
}, [g]), /* @__PURE__ */ n(Se.Provider, { value: q, children: e });
|
|
947
1005
|
}
|
|
948
|
-
function
|
|
949
|
-
const i =
|
|
1006
|
+
function ie() {
|
|
1007
|
+
const i = le(Se);
|
|
950
1008
|
if (!i)
|
|
951
1009
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
952
1010
|
return i;
|
|
953
1011
|
}
|
|
954
|
-
class
|
|
1012
|
+
class He {
|
|
955
1013
|
constructor(e, t) {
|
|
956
1014
|
this.httpService = e, this.sessionManager = t;
|
|
957
1015
|
}
|
|
@@ -972,12 +1030,12 @@ class Me {
|
|
|
972
1030
|
throw new Error("SessionManager is required for private endpoints");
|
|
973
1031
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
974
1032
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
975
|
-
const
|
|
1033
|
+
const s = `/feature-flags/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
|
|
976
1034
|
headers: t
|
|
977
1035
|
});
|
|
978
1036
|
return {
|
|
979
|
-
featureFlags:
|
|
980
|
-
meta:
|
|
1037
|
+
featureFlags: a.data,
|
|
1038
|
+
meta: a.meta
|
|
981
1039
|
};
|
|
982
1040
|
}
|
|
983
1041
|
async getFeatureFlagById(e) {
|
|
@@ -1014,8 +1072,8 @@ class Me {
|
|
|
1014
1072
|
throw new Error("Tenant ID and App ID are required");
|
|
1015
1073
|
const r = new URLSearchParams();
|
|
1016
1074
|
r.append("tenantId", e), r.append("appId", t);
|
|
1017
|
-
const
|
|
1018
|
-
return (await this.httpService.get(
|
|
1075
|
+
const s = `/tenant-feature-flags${r.toString() ? `?${r.toString()}` : ""}`;
|
|
1076
|
+
return (await this.httpService.get(s, {
|
|
1019
1077
|
headers: { "X-Tenant-ID": e }
|
|
1020
1078
|
})).data;
|
|
1021
1079
|
}
|
|
@@ -1023,66 +1081,66 @@ class Me {
|
|
|
1023
1081
|
async getTenantFeatureFlag(e, t, r) {
|
|
1024
1082
|
if (!e || !t || !r)
|
|
1025
1083
|
throw new Error("Flag Key, Tenant ID and App ID are required");
|
|
1026
|
-
const
|
|
1027
|
-
|
|
1028
|
-
const
|
|
1029
|
-
return (await this.httpService.get(
|
|
1084
|
+
const s = new URLSearchParams();
|
|
1085
|
+
s.append("tenantId", t), s.append("appId", r);
|
|
1086
|
+
const a = `/tenant-feature-flags/${e}${s.toString() ? `?${s.toString()}` : ""}`;
|
|
1087
|
+
return (await this.httpService.get(a, {
|
|
1030
1088
|
headers: { "X-Tenant-ID": t }
|
|
1031
1089
|
})).data;
|
|
1032
1090
|
}
|
|
1033
1091
|
}
|
|
1034
|
-
const
|
|
1035
|
-
function
|
|
1036
|
-
const { baseUrl: t, appId: r } =
|
|
1037
|
-
const
|
|
1038
|
-
return new
|
|
1039
|
-
}, [t]),
|
|
1040
|
-
if (!(
|
|
1041
|
-
|
|
1092
|
+
const xe = ae(null);
|
|
1093
|
+
function bt({ config: i = {}, children: e }) {
|
|
1094
|
+
const { baseUrl: t, appId: r } = ne(), { tenant: s } = re(), [a, b] = p([]), [E, L] = p(!1), [P, f] = p(null), m = _(() => {
|
|
1095
|
+
const v = new te(t);
|
|
1096
|
+
return new He(v);
|
|
1097
|
+
}, [t]), M = async () => {
|
|
1098
|
+
if (!(s != null && s.id)) {
|
|
1099
|
+
b([]);
|
|
1042
1100
|
return;
|
|
1043
1101
|
}
|
|
1044
|
-
|
|
1102
|
+
L(!0), f(null);
|
|
1045
1103
|
try {
|
|
1046
|
-
const
|
|
1047
|
-
|
|
1048
|
-
} catch (
|
|
1049
|
-
const
|
|
1050
|
-
|
|
1104
|
+
const v = await m.getTenantFeatureFlags(s.id, r);
|
|
1105
|
+
b(v);
|
|
1106
|
+
} catch (v) {
|
|
1107
|
+
const I = v instanceof Error ? v.message : "Failed to fetch feature flags";
|
|
1108
|
+
f(I), i.onError && i.onError(v instanceof Error ? v : new Error(I));
|
|
1051
1109
|
} finally {
|
|
1052
|
-
|
|
1110
|
+
L(!1);
|
|
1053
1111
|
}
|
|
1054
1112
|
};
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
const
|
|
1058
|
-
return () => clearInterval(
|
|
1059
|
-
}, [
|
|
1060
|
-
const
|
|
1061
|
-
featureFlags:
|
|
1062
|
-
loading:
|
|
1113
|
+
Z(() => {
|
|
1114
|
+
M();
|
|
1115
|
+
const v = i.refreshInterval || 5 * 60 * 1e3, I = setInterval(M, v);
|
|
1116
|
+
return () => clearInterval(I);
|
|
1117
|
+
}, [s == null ? void 0 : s.id, i.refreshInterval]);
|
|
1118
|
+
const w = _(() => ({
|
|
1119
|
+
featureFlags: a,
|
|
1120
|
+
loading: E,
|
|
1063
1121
|
error: P,
|
|
1064
|
-
isEnabled: (
|
|
1065
|
-
const
|
|
1066
|
-
return (
|
|
1122
|
+
isEnabled: (u) => {
|
|
1123
|
+
const y = a.find((x) => x.key === u);
|
|
1124
|
+
return (y == null ? void 0 : y.value) === !0;
|
|
1067
1125
|
},
|
|
1068
|
-
getFlag: (
|
|
1069
|
-
getFlagState: (
|
|
1070
|
-
const
|
|
1071
|
-
return
|
|
1126
|
+
getFlag: (u) => a.find((y) => y.key === u),
|
|
1127
|
+
getFlagState: (u) => {
|
|
1128
|
+
const y = a.find((x) => x.key === u);
|
|
1129
|
+
return y ? y.value ? "enabled" : "disabled" : "not_found";
|
|
1072
1130
|
},
|
|
1073
1131
|
refresh: async () => {
|
|
1074
|
-
await
|
|
1132
|
+
await M();
|
|
1075
1133
|
}
|
|
1076
|
-
}), [
|
|
1077
|
-
return /* @__PURE__ */
|
|
1134
|
+
}), [a, E, P]);
|
|
1135
|
+
return /* @__PURE__ */ n(xe.Provider, { value: w, children: e });
|
|
1078
1136
|
}
|
|
1079
|
-
function
|
|
1080
|
-
const i =
|
|
1137
|
+
function $e() {
|
|
1138
|
+
const i = le(xe);
|
|
1081
1139
|
if (!i)
|
|
1082
1140
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1083
1141
|
return i;
|
|
1084
1142
|
}
|
|
1085
|
-
class
|
|
1143
|
+
class De {
|
|
1086
1144
|
constructor(e, t) {
|
|
1087
1145
|
this.httpService = e, this.sessionManager = t;
|
|
1088
1146
|
}
|
|
@@ -1148,64 +1206,64 @@ class Re {
|
|
|
1148
1206
|
)).data;
|
|
1149
1207
|
}
|
|
1150
1208
|
}
|
|
1151
|
-
const
|
|
1152
|
-
function
|
|
1153
|
-
const { baseUrl: t } =
|
|
1154
|
-
const
|
|
1155
|
-
return new
|
|
1156
|
-
}, [t]),
|
|
1209
|
+
const ke = ae(void 0);
|
|
1210
|
+
function wt({ config: i = {}, children: e }) {
|
|
1211
|
+
const { baseUrl: t } = ne(), { tenant: r } = re(), [s, a] = p(null), [b, E] = p(!1), [L, P] = p(null), f = _(() => {
|
|
1212
|
+
const w = new te(t);
|
|
1213
|
+
return new De(w);
|
|
1214
|
+
}, [t]), m = async () => {
|
|
1157
1215
|
if (!(r != null && r.id)) {
|
|
1158
|
-
|
|
1216
|
+
a(null);
|
|
1159
1217
|
return;
|
|
1160
1218
|
}
|
|
1161
|
-
|
|
1219
|
+
E(!0), P(null);
|
|
1162
1220
|
try {
|
|
1163
|
-
const
|
|
1164
|
-
|
|
1165
|
-
} catch (
|
|
1166
|
-
const
|
|
1167
|
-
P(
|
|
1221
|
+
const w = await f.getTenantSubscriptionFeatures(r.id);
|
|
1222
|
+
a(w);
|
|
1223
|
+
} catch (w) {
|
|
1224
|
+
const v = w instanceof Error ? w.message : "Failed to fetch subscription";
|
|
1225
|
+
P(v), i.onError && i.onError(w instanceof Error ? w : new Error(v));
|
|
1168
1226
|
} finally {
|
|
1169
|
-
|
|
1227
|
+
E(!1);
|
|
1170
1228
|
}
|
|
1171
1229
|
};
|
|
1172
|
-
|
|
1173
|
-
if (
|
|
1174
|
-
const
|
|
1175
|
-
return () => clearInterval(
|
|
1230
|
+
Z(() => {
|
|
1231
|
+
if (m(), !i.refreshInterval) return;
|
|
1232
|
+
const w = i.refreshInterval || 10 * 60 * 1e3, v = setInterval(m, w);
|
|
1233
|
+
return () => clearInterval(v);
|
|
1176
1234
|
}, [r == null ? void 0 : r.id, i.refreshInterval]);
|
|
1177
|
-
const
|
|
1178
|
-
const
|
|
1235
|
+
const M = _(() => {
|
|
1236
|
+
const w = (s == null ? void 0 : s.features) || [];
|
|
1179
1237
|
return {
|
|
1180
|
-
subscription:
|
|
1181
|
-
features:
|
|
1182
|
-
loading:
|
|
1183
|
-
error:
|
|
1184
|
-
isFeatureEnabled: (
|
|
1185
|
-
const
|
|
1186
|
-
return
|
|
1238
|
+
subscription: s,
|
|
1239
|
+
features: w,
|
|
1240
|
+
loading: b,
|
|
1241
|
+
error: L,
|
|
1242
|
+
isFeatureEnabled: (y) => {
|
|
1243
|
+
const x = w.find((F) => F.key === y);
|
|
1244
|
+
return x ? x.type === "BOOLEAN" || x.type === "boolean" ? x.value === !0 : !!x.value : !1;
|
|
1187
1245
|
},
|
|
1188
|
-
getFeature: (
|
|
1189
|
-
getFeatureValue: (
|
|
1190
|
-
const
|
|
1191
|
-
return
|
|
1246
|
+
getFeature: (y) => w.find((x) => x.key === y),
|
|
1247
|
+
getFeatureValue: (y, x) => {
|
|
1248
|
+
const F = w.find((B) => B.key === y);
|
|
1249
|
+
return F ? F.value : x;
|
|
1192
1250
|
},
|
|
1193
|
-
hasAllowedPlan: (
|
|
1251
|
+
hasAllowedPlan: (y) => !s || !s.isActive ? !1 : y.includes(s.planId),
|
|
1194
1252
|
refresh: async () => {
|
|
1195
|
-
await
|
|
1253
|
+
await m();
|
|
1196
1254
|
}
|
|
1197
1255
|
};
|
|
1198
|
-
}, [
|
|
1199
|
-
return /* @__PURE__ */
|
|
1256
|
+
}, [s, b, L]);
|
|
1257
|
+
return /* @__PURE__ */ n(ke.Provider, { value: M, children: e });
|
|
1200
1258
|
}
|
|
1201
|
-
function
|
|
1202
|
-
const i =
|
|
1259
|
+
function Be() {
|
|
1260
|
+
const i = le(ke);
|
|
1203
1261
|
if (i === void 0)
|
|
1204
1262
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1205
1263
|
return i;
|
|
1206
1264
|
}
|
|
1207
|
-
var
|
|
1208
|
-
const
|
|
1265
|
+
var se = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(se || {});
|
|
1266
|
+
const me = () => /* @__PURE__ */ l(
|
|
1209
1267
|
"div",
|
|
1210
1268
|
{
|
|
1211
1269
|
style: {
|
|
@@ -1221,10 +1279,10 @@ const ue = () => /* @__PURE__ */ c(
|
|
|
1221
1279
|
margin: "20px 0"
|
|
1222
1280
|
},
|
|
1223
1281
|
children: [
|
|
1224
|
-
/* @__PURE__ */
|
|
1225
|
-
/* @__PURE__ */
|
|
1226
|
-
/* @__PURE__ */
|
|
1227
|
-
/* @__PURE__ */
|
|
1282
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "🔒" }),
|
|
1283
|
+
/* @__PURE__ */ n("h3", { style: { color: "#495057", marginBottom: "10px" }, children: "Access Required" }),
|
|
1284
|
+
/* @__PURE__ */ n("p", { style: { color: "#6c757d", fontSize: "14px", marginBottom: "15px" }, children: "You need to be signed in to view this content." }),
|
|
1285
|
+
/* @__PURE__ */ n(
|
|
1228
1286
|
"button",
|
|
1229
1287
|
{
|
|
1230
1288
|
style: {
|
|
@@ -1242,11 +1300,11 @@ const ue = () => /* @__PURE__ */ c(
|
|
|
1242
1300
|
)
|
|
1243
1301
|
]
|
|
1244
1302
|
}
|
|
1245
|
-
),
|
|
1303
|
+
), ye = ({
|
|
1246
1304
|
userType: i,
|
|
1247
1305
|
minUserType: e,
|
|
1248
1306
|
missingPermissions: t
|
|
1249
|
-
}) => /* @__PURE__ */
|
|
1307
|
+
}) => /* @__PURE__ */ l(
|
|
1250
1308
|
"div",
|
|
1251
1309
|
{
|
|
1252
1310
|
style: {
|
|
@@ -1262,57 +1320,57 @@ const ue = () => /* @__PURE__ */ c(
|
|
|
1262
1320
|
margin: "20px 0"
|
|
1263
1321
|
},
|
|
1264
1322
|
children: [
|
|
1265
|
-
/* @__PURE__ */
|
|
1266
|
-
/* @__PURE__ */
|
|
1267
|
-
e && i ? /* @__PURE__ */
|
|
1268
|
-
/* @__PURE__ */
|
|
1323
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
|
|
1324
|
+
/* @__PURE__ */ n("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
|
|
1325
|
+
e && i ? /* @__PURE__ */ l(D, { children: [
|
|
1326
|
+
/* @__PURE__ */ l("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
|
|
1269
1327
|
"This content requires ",
|
|
1270
|
-
/* @__PURE__ */
|
|
1328
|
+
/* @__PURE__ */ n("strong", { children: e }),
|
|
1271
1329
|
" access level or higher."
|
|
1272
1330
|
] }),
|
|
1273
|
-
/* @__PURE__ */
|
|
1331
|
+
/* @__PURE__ */ l("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1274
1332
|
"Your current access level: ",
|
|
1275
|
-
/* @__PURE__ */
|
|
1333
|
+
/* @__PURE__ */ n("strong", { children: i })
|
|
1276
1334
|
] })
|
|
1277
|
-
] }) : /* @__PURE__ */
|
|
1278
|
-
/* @__PURE__ */
|
|
1279
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1335
|
+
] }) : /* @__PURE__ */ l(D, { children: [
|
|
1336
|
+
/* @__PURE__ */ n("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
|
|
1337
|
+
t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1280
1338
|
"Required permissions: ",
|
|
1281
|
-
/* @__PURE__ */
|
|
1339
|
+
/* @__PURE__ */ n("strong", { children: t.join(", ") })
|
|
1282
1340
|
] })
|
|
1283
1341
|
] })
|
|
1284
1342
|
]
|
|
1285
1343
|
}
|
|
1286
|
-
),
|
|
1344
|
+
), Ne = (i, e) => {
|
|
1287
1345
|
const t = {
|
|
1288
|
-
[
|
|
1289
|
-
[
|
|
1290
|
-
[
|
|
1346
|
+
[se.USER]: 1,
|
|
1347
|
+
[se.TENANT_ADMIN]: 2,
|
|
1348
|
+
[se.SUPERUSER]: 3
|
|
1291
1349
|
};
|
|
1292
1350
|
return t[i] >= t[e];
|
|
1293
1351
|
};
|
|
1294
|
-
function
|
|
1352
|
+
function vt({
|
|
1295
1353
|
children: i,
|
|
1296
1354
|
fallback: e,
|
|
1297
1355
|
minUserType: t,
|
|
1298
1356
|
requiredPermissions: r,
|
|
1299
|
-
requireAllPermissions:
|
|
1357
|
+
requireAllPermissions: s = !1
|
|
1300
1358
|
}) {
|
|
1301
|
-
const { hasValidSession:
|
|
1302
|
-
if (!
|
|
1303
|
-
return /* @__PURE__ */
|
|
1304
|
-
const
|
|
1305
|
-
if (!
|
|
1306
|
-
return /* @__PURE__ */
|
|
1307
|
-
if (t && !
|
|
1308
|
-
return /* @__PURE__ */
|
|
1309
|
-
if (r && r.length > 0 && !(
|
|
1310
|
-
const
|
|
1311
|
-
return /* @__PURE__ */
|
|
1312
|
-
}
|
|
1313
|
-
return /* @__PURE__ */
|
|
1359
|
+
const { hasValidSession: a, sessionManager: b, hasPermission: E, hasAnyPermission: L, hasAllPermissions: P } = ie();
|
|
1360
|
+
if (!a())
|
|
1361
|
+
return /* @__PURE__ */ n(D, { children: e || /* @__PURE__ */ n(me, {}) });
|
|
1362
|
+
const f = b.getUser();
|
|
1363
|
+
if (!f)
|
|
1364
|
+
return /* @__PURE__ */ n(D, { children: e || /* @__PURE__ */ n(me, {}) });
|
|
1365
|
+
if (t && !Ne(f.userType, t))
|
|
1366
|
+
return /* @__PURE__ */ n(ye, { userType: f.userType, minUserType: t });
|
|
1367
|
+
if (r && r.length > 0 && !(s ? P(r) : L(r))) {
|
|
1368
|
+
const M = r.filter((w) => !E(w)).map((w) => typeof w == "string" ? w : w.name);
|
|
1369
|
+
return /* @__PURE__ */ n(ye, { missingPermissions: M });
|
|
1370
|
+
}
|
|
1371
|
+
return /* @__PURE__ */ n(D, { children: i });
|
|
1314
1372
|
}
|
|
1315
|
-
const
|
|
1373
|
+
const qe = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1316
1374
|
"div",
|
|
1317
1375
|
{
|
|
1318
1376
|
style: {
|
|
@@ -1325,7 +1383,7 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
|
1325
1383
|
backgroundColor: "#f9fafb",
|
|
1326
1384
|
textAlign: "center"
|
|
1327
1385
|
},
|
|
1328
|
-
children: /* @__PURE__ */
|
|
1386
|
+
children: /* @__PURE__ */ l(
|
|
1329
1387
|
"div",
|
|
1330
1388
|
{
|
|
1331
1389
|
style: {
|
|
@@ -1336,10 +1394,10 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
|
1336
1394
|
maxWidth: "400px"
|
|
1337
1395
|
},
|
|
1338
1396
|
children: [
|
|
1339
|
-
/* @__PURE__ */
|
|
1340
|
-
/* @__PURE__ */
|
|
1341
|
-
/* @__PURE__ */
|
|
1342
|
-
/* @__PURE__ */
|
|
1397
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
|
|
1398
|
+
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
|
|
1399
|
+
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
|
|
1400
|
+
/* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1343
1401
|
"Redirecting to ",
|
|
1344
1402
|
i,
|
|
1345
1403
|
"..."
|
|
@@ -1348,11 +1406,11 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
|
1348
1406
|
}
|
|
1349
1407
|
)
|
|
1350
1408
|
}
|
|
1351
|
-
),
|
|
1409
|
+
), be = ({
|
|
1352
1410
|
userType: i,
|
|
1353
1411
|
minUserType: e,
|
|
1354
1412
|
missingPermissions: t
|
|
1355
|
-
}) => /* @__PURE__ */
|
|
1413
|
+
}) => /* @__PURE__ */ n(
|
|
1356
1414
|
"div",
|
|
1357
1415
|
{
|
|
1358
1416
|
style: {
|
|
@@ -1365,7 +1423,7 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
|
1365
1423
|
backgroundColor: "#f9fafb",
|
|
1366
1424
|
textAlign: "center"
|
|
1367
1425
|
},
|
|
1368
|
-
children: /* @__PURE__ */
|
|
1426
|
+
children: /* @__PURE__ */ l(
|
|
1369
1427
|
"div",
|
|
1370
1428
|
{
|
|
1371
1429
|
style: {
|
|
@@ -1376,63 +1434,63 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
|
1376
1434
|
maxWidth: "400px"
|
|
1377
1435
|
},
|
|
1378
1436
|
children: [
|
|
1379
|
-
/* @__PURE__ */
|
|
1380
|
-
/* @__PURE__ */
|
|
1381
|
-
e && i ? /* @__PURE__ */
|
|
1382
|
-
/* @__PURE__ */
|
|
1437
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
|
|
1438
|
+
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
|
|
1439
|
+
e && i ? /* @__PURE__ */ l(D, { children: [
|
|
1440
|
+
/* @__PURE__ */ l("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
|
|
1383
1441
|
"This page requires ",
|
|
1384
|
-
/* @__PURE__ */
|
|
1442
|
+
/* @__PURE__ */ n("strong", { children: e }),
|
|
1385
1443
|
" access level or higher."
|
|
1386
1444
|
] }),
|
|
1387
|
-
/* @__PURE__ */
|
|
1445
|
+
/* @__PURE__ */ l("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1388
1446
|
"Your current access level: ",
|
|
1389
|
-
/* @__PURE__ */
|
|
1447
|
+
/* @__PURE__ */ n("strong", { children: i })
|
|
1390
1448
|
] })
|
|
1391
|
-
] }) : /* @__PURE__ */
|
|
1392
|
-
/* @__PURE__ */
|
|
1393
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1449
|
+
] }) : /* @__PURE__ */ l(D, { children: [
|
|
1450
|
+
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
|
|
1451
|
+
t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1394
1452
|
"Required permissions: ",
|
|
1395
|
-
/* @__PURE__ */
|
|
1453
|
+
/* @__PURE__ */ n("strong", { children: t.join(", ") })
|
|
1396
1454
|
] })
|
|
1397
1455
|
] })
|
|
1398
1456
|
]
|
|
1399
1457
|
}
|
|
1400
1458
|
)
|
|
1401
1459
|
}
|
|
1402
|
-
),
|
|
1460
|
+
), Ue = (i, e) => {
|
|
1403
1461
|
const t = {
|
|
1404
|
-
[
|
|
1405
|
-
[
|
|
1406
|
-
[
|
|
1462
|
+
[se.USER]: 1,
|
|
1463
|
+
[se.TENANT_ADMIN]: 2,
|
|
1464
|
+
[se.SUPERUSER]: 3
|
|
1407
1465
|
};
|
|
1408
1466
|
return t[i] >= t[e];
|
|
1409
1467
|
};
|
|
1410
|
-
function
|
|
1468
|
+
function St({
|
|
1411
1469
|
children: i,
|
|
1412
1470
|
redirectTo: e = "/login",
|
|
1413
1471
|
minUserType: t,
|
|
1414
1472
|
requiredPermissions: r,
|
|
1415
|
-
requireAllPermissions:
|
|
1416
|
-
fallback:
|
|
1473
|
+
requireAllPermissions: s = !1,
|
|
1474
|
+
fallback: a
|
|
1417
1475
|
}) {
|
|
1418
|
-
const { hasValidSession:
|
|
1419
|
-
if (!
|
|
1420
|
-
return
|
|
1421
|
-
/* @__PURE__ */
|
|
1422
|
-
/* @__PURE__ */
|
|
1476
|
+
const { hasValidSession: b, sessionManager: E, hasPermission: L, hasAnyPermission: P, hasAllPermissions: f } = ie(), m = he();
|
|
1477
|
+
if (!b())
|
|
1478
|
+
return a ? /* @__PURE__ */ n(D, { children: a }) : /* @__PURE__ */ l(D, { children: [
|
|
1479
|
+
/* @__PURE__ */ n(qe, { redirectPath: e }),
|
|
1480
|
+
/* @__PURE__ */ n(de, { to: e, state: { from: m.pathname }, replace: !0 })
|
|
1423
1481
|
] });
|
|
1424
|
-
const
|
|
1425
|
-
if (!
|
|
1426
|
-
return /* @__PURE__ */
|
|
1427
|
-
if (t && !
|
|
1428
|
-
return /* @__PURE__ */
|
|
1429
|
-
if (r && r.length > 0 && !(
|
|
1430
|
-
const
|
|
1431
|
-
return /* @__PURE__ */
|
|
1432
|
-
}
|
|
1433
|
-
return /* @__PURE__ */
|
|
1482
|
+
const M = E.getUser();
|
|
1483
|
+
if (!M)
|
|
1484
|
+
return /* @__PURE__ */ n(de, { to: e, state: { from: m.pathname }, replace: !0 });
|
|
1485
|
+
if (t && !Ue(M.userType, t))
|
|
1486
|
+
return /* @__PURE__ */ n(be, { userType: M.userType, minUserType: t });
|
|
1487
|
+
if (r && r.length > 0 && !(s ? f(r) : P(r))) {
|
|
1488
|
+
const v = r.filter((I) => !L(I)).map((I) => typeof I == "string" ? I : I.name);
|
|
1489
|
+
return /* @__PURE__ */ n(be, { missingPermissions: v });
|
|
1490
|
+
}
|
|
1491
|
+
return /* @__PURE__ */ n(D, { children: i });
|
|
1434
1492
|
}
|
|
1435
|
-
const
|
|
1493
|
+
const ze = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1436
1494
|
"div",
|
|
1437
1495
|
{
|
|
1438
1496
|
style: {
|
|
@@ -1445,7 +1503,7 @@ const $e = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
|
1445
1503
|
backgroundColor: "#f9fafb",
|
|
1446
1504
|
textAlign: "center"
|
|
1447
1505
|
},
|
|
1448
|
-
children: /* @__PURE__ */
|
|
1506
|
+
children: /* @__PURE__ */ l(
|
|
1449
1507
|
"div",
|
|
1450
1508
|
{
|
|
1451
1509
|
style: {
|
|
@@ -1456,10 +1514,10 @@ const $e = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
|
1456
1514
|
maxWidth: "400px"
|
|
1457
1515
|
},
|
|
1458
1516
|
children: [
|
|
1459
|
-
/* @__PURE__ */
|
|
1460
|
-
/* @__PURE__ */
|
|
1461
|
-
/* @__PURE__ */
|
|
1462
|
-
/* @__PURE__ */
|
|
1517
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
|
|
1518
|
+
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
|
|
1519
|
+
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
|
|
1520
|
+
/* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1463
1521
|
"Redirecting to ",
|
|
1464
1522
|
i,
|
|
1465
1523
|
"..."
|
|
@@ -1469,18 +1527,14 @@ const $e = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
|
1469
1527
|
)
|
|
1470
1528
|
}
|
|
1471
1529
|
);
|
|
1472
|
-
function
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
})
|
|
1477
|
-
const { tenant: r, isLoading: n, error: o } = K(), m = ae();
|
|
1478
|
-
return n || o ? null : r ? /* @__PURE__ */ s(H, { children: i }) : t ? /* @__PURE__ */ s(H, { children: t }) : /* @__PURE__ */ c(H, { children: [
|
|
1479
|
-
/* @__PURE__ */ s($e, { redirectPath: e }),
|
|
1480
|
-
/* @__PURE__ */ s(ne, { to: e, state: { from: m.pathname }, replace: !0 })
|
|
1530
|
+
function xt({ children: i, redirectTo: e = "/", fallback: t }) {
|
|
1531
|
+
const { tenant: r, isLoading: s, error: a } = re(), b = he();
|
|
1532
|
+
return s || a ? null : r ? /* @__PURE__ */ n(D, { children: i }) : t ? /* @__PURE__ */ n(D, { children: t }) : /* @__PURE__ */ l(D, { children: [
|
|
1533
|
+
/* @__PURE__ */ n(ze, { redirectPath: e }),
|
|
1534
|
+
/* @__PURE__ */ n(de, { to: e, state: { from: b.pathname }, replace: !0 })
|
|
1481
1535
|
] });
|
|
1482
1536
|
}
|
|
1483
|
-
const
|
|
1537
|
+
const Oe = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1484
1538
|
"div",
|
|
1485
1539
|
{
|
|
1486
1540
|
style: {
|
|
@@ -1493,7 +1547,7 @@ const Le = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
|
1493
1547
|
backgroundColor: "#f9fafb",
|
|
1494
1548
|
textAlign: "center"
|
|
1495
1549
|
},
|
|
1496
|
-
children: /* @__PURE__ */
|
|
1550
|
+
children: /* @__PURE__ */ l(
|
|
1497
1551
|
"div",
|
|
1498
1552
|
{
|
|
1499
1553
|
style: {
|
|
@@ -1504,10 +1558,10 @@ const Le = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
|
1504
1558
|
maxWidth: "400px"
|
|
1505
1559
|
},
|
|
1506
1560
|
children: [
|
|
1507
|
-
/* @__PURE__ */
|
|
1508
|
-
/* @__PURE__ */
|
|
1509
|
-
/* @__PURE__ */
|
|
1510
|
-
/* @__PURE__ */
|
|
1561
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
|
|
1562
|
+
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
|
|
1563
|
+
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
|
|
1564
|
+
/* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1511
1565
|
"Redirecting to ",
|
|
1512
1566
|
i,
|
|
1513
1567
|
"..."
|
|
@@ -1517,18 +1571,14 @@ const Le = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
|
1517
1571
|
)
|
|
1518
1572
|
}
|
|
1519
1573
|
);
|
|
1520
|
-
function
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
})
|
|
1525
|
-
|
|
1526
|
-
return n || o ? null : r ? t ? /* @__PURE__ */ s(H, { children: t }) : /* @__PURE__ */ c(H, { children: [
|
|
1527
|
-
/* @__PURE__ */ s(Le, { redirectPath: e }),
|
|
1528
|
-
/* @__PURE__ */ s(ne, { to: e, state: { from: m.pathname }, replace: !0 })
|
|
1529
|
-
] }) : /* @__PURE__ */ s(H, { children: i });
|
|
1574
|
+
function kt({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
|
|
1575
|
+
const { tenant: r, isLoading: s, error: a } = re(), b = he();
|
|
1576
|
+
return s || a ? null : r ? t ? /* @__PURE__ */ n(D, { children: t }) : /* @__PURE__ */ l(D, { children: [
|
|
1577
|
+
/* @__PURE__ */ n(Oe, { redirectPath: e }),
|
|
1578
|
+
/* @__PURE__ */ n(de, { to: e, state: { from: b.pathname }, replace: !0 })
|
|
1579
|
+
] }) : /* @__PURE__ */ n(D, { children: i });
|
|
1530
1580
|
}
|
|
1531
|
-
const
|
|
1581
|
+
const je = () => /* @__PURE__ */ l(
|
|
1532
1582
|
"div",
|
|
1533
1583
|
{
|
|
1534
1584
|
style: {
|
|
@@ -1540,19 +1590,19 @@ const De = () => /* @__PURE__ */ c(
|
|
|
1540
1590
|
color: "#dc2626"
|
|
1541
1591
|
},
|
|
1542
1592
|
children: [
|
|
1543
|
-
/* @__PURE__ */
|
|
1544
|
-
/* @__PURE__ */
|
|
1593
|
+
/* @__PURE__ */ n("h3", { style: { margin: "0 0 1rem 0" }, children: "🔒 Subscription Required" }),
|
|
1594
|
+
/* @__PURE__ */ n("p", { style: { margin: 0 }, children: "This feature requires a higher subscription plan. Please upgrade your plan to access this content." })
|
|
1545
1595
|
]
|
|
1546
1596
|
}
|
|
1547
1597
|
);
|
|
1548
|
-
function
|
|
1598
|
+
function At({
|
|
1549
1599
|
children: i,
|
|
1550
|
-
fallback: e = /* @__PURE__ */
|
|
1600
|
+
fallback: e = /* @__PURE__ */ n(je, {}),
|
|
1551
1601
|
allowedPlans: t,
|
|
1552
1602
|
requiredFeature: r
|
|
1553
1603
|
}) {
|
|
1554
|
-
const { subscription:
|
|
1555
|
-
return
|
|
1604
|
+
const { subscription: s, hasAllowedPlan: a, isFeatureEnabled: b, loading: E } = Be();
|
|
1605
|
+
return E ? /* @__PURE__ */ n(
|
|
1556
1606
|
"div",
|
|
1557
1607
|
{
|
|
1558
1608
|
style: {
|
|
@@ -1562,9 +1612,9 @@ function ut({
|
|
|
1562
1612
|
},
|
|
1563
1613
|
children: "Loading subscription..."
|
|
1564
1614
|
}
|
|
1565
|
-
) :
|
|
1615
|
+
) : s ? s.isActive ? t && t.length > 0 && !a(t) ? /* @__PURE__ */ n(D, { children: e }) : r && !b(r) ? /* @__PURE__ */ n(D, { children: e }) : /* @__PURE__ */ n(D, { children: i }) : /* @__PURE__ */ n(D, { children: e }) : /* @__PURE__ */ n(D, { children: e });
|
|
1566
1616
|
}
|
|
1567
|
-
const
|
|
1617
|
+
const We = ({ flagName: i }) => /* @__PURE__ */ l(
|
|
1568
1618
|
"div",
|
|
1569
1619
|
{
|
|
1570
1620
|
style: {
|
|
@@ -1581,9 +1631,9 @@ const Be = ({ flagName: i }) => /* @__PURE__ */ c(
|
|
|
1581
1631
|
color: "#6c757d"
|
|
1582
1632
|
},
|
|
1583
1633
|
children: [
|
|
1584
|
-
/* @__PURE__ */
|
|
1585
|
-
/* @__PURE__ */
|
|
1586
|
-
/* @__PURE__ */
|
|
1634
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
|
|
1635
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
|
|
1636
|
+
/* @__PURE__ */ l("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
|
|
1587
1637
|
'Feature flag "',
|
|
1588
1638
|
i,
|
|
1589
1639
|
'" is disabled'
|
|
@@ -1591,9 +1641,9 @@ const Be = ({ flagName: i }) => /* @__PURE__ */ c(
|
|
|
1591
1641
|
]
|
|
1592
1642
|
}
|
|
1593
1643
|
);
|
|
1594
|
-
function
|
|
1595
|
-
const { isEnabled: r, loading:
|
|
1596
|
-
return
|
|
1644
|
+
function Pt({ name: i, children: e, fallback: t }) {
|
|
1645
|
+
const { isEnabled: r, loading: s } = $e();
|
|
1646
|
+
return s ? /* @__PURE__ */ n(
|
|
1597
1647
|
"div",
|
|
1598
1648
|
{
|
|
1599
1649
|
style: {
|
|
@@ -1606,9 +1656,9 @@ function ht({ name: i, children: e, fallback: t }) {
|
|
|
1606
1656
|
},
|
|
1607
1657
|
children: "Loading feature flags..."
|
|
1608
1658
|
}
|
|
1609
|
-
) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */
|
|
1659
|
+
) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */ n(D, { children: e }) : /* @__PURE__ */ n(D, { children: t || /* @__PURE__ */ n(We, { flagName: i }) }));
|
|
1610
1660
|
}
|
|
1611
|
-
const
|
|
1661
|
+
const Ve = () => /* @__PURE__ */ l(
|
|
1612
1662
|
"svg",
|
|
1613
1663
|
{
|
|
1614
1664
|
width: "16",
|
|
@@ -1621,11 +1671,11 @@ const qe = () => /* @__PURE__ */ c(
|
|
|
1621
1671
|
strokeLinejoin: "round",
|
|
1622
1672
|
style: { flexShrink: 0 },
|
|
1623
1673
|
children: [
|
|
1624
|
-
/* @__PURE__ */
|
|
1625
|
-
/* @__PURE__ */
|
|
1674
|
+
/* @__PURE__ */ n("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
|
|
1675
|
+
/* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "3" })
|
|
1626
1676
|
]
|
|
1627
1677
|
}
|
|
1628
|
-
),
|
|
1678
|
+
), Ge = () => /* @__PURE__ */ l(
|
|
1629
1679
|
"svg",
|
|
1630
1680
|
{
|
|
1631
1681
|
width: "16",
|
|
@@ -1638,26 +1688,28 @@ const qe = () => /* @__PURE__ */ c(
|
|
|
1638
1688
|
strokeLinejoin: "round",
|
|
1639
1689
|
style: { flexShrink: 0 },
|
|
1640
1690
|
children: [
|
|
1641
|
-
/* @__PURE__ */
|
|
1642
|
-
/* @__PURE__ */
|
|
1691
|
+
/* @__PURE__ */ n("path", { d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24" }),
|
|
1692
|
+
/* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
1643
1693
|
]
|
|
1644
1694
|
}
|
|
1645
|
-
),
|
|
1646
|
-
showPassword: /* @__PURE__ */
|
|
1647
|
-
hidePassword: /* @__PURE__ */
|
|
1648
|
-
},
|
|
1695
|
+
), Ye = {
|
|
1696
|
+
showPassword: /* @__PURE__ */ n(Ve, {}),
|
|
1697
|
+
hidePassword: /* @__PURE__ */ n(Ge, {})
|
|
1698
|
+
}, _e = {
|
|
1649
1699
|
title: "Sign In",
|
|
1650
|
-
|
|
1651
|
-
|
|
1700
|
+
usernameLabel: "Email or Phone",
|
|
1701
|
+
usernamePlaceholder: "Enter your email or phone number",
|
|
1652
1702
|
passwordLabel: "Password",
|
|
1653
1703
|
passwordPlaceholder: "Enter your password",
|
|
1654
1704
|
submitButton: "Sign In",
|
|
1655
1705
|
forgotPasswordLink: "Forgot your password?",
|
|
1656
1706
|
signupLink: "Sign up here",
|
|
1657
1707
|
signupText: "Don't have an account?",
|
|
1658
|
-
|
|
1708
|
+
magicLinkText: "Prefer passwordless?",
|
|
1709
|
+
magicLinkLink: "Use Magic Link",
|
|
1710
|
+
errorMessage: "Invalid credentials",
|
|
1659
1711
|
loadingText: "Signing in..."
|
|
1660
|
-
},
|
|
1712
|
+
}, Ke = {
|
|
1661
1713
|
container: {
|
|
1662
1714
|
maxWidth: "400px",
|
|
1663
1715
|
width: "100%",
|
|
@@ -1764,124 +1816,138 @@ const qe = () => /* @__PURE__ */ c(
|
|
|
1764
1816
|
fontSize: "0.875rem"
|
|
1765
1817
|
}
|
|
1766
1818
|
};
|
|
1767
|
-
function
|
|
1819
|
+
function Tt({
|
|
1768
1820
|
copy: i = {},
|
|
1769
1821
|
styles: e = {},
|
|
1770
1822
|
icons: t = {},
|
|
1771
1823
|
onSuccess: r,
|
|
1772
|
-
onError:
|
|
1773
|
-
onForgotPassword:
|
|
1774
|
-
onSignupClick:
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1824
|
+
onError: s,
|
|
1825
|
+
onForgotPassword: a,
|
|
1826
|
+
onSignupClick: b,
|
|
1827
|
+
onMagicLinkClick: E,
|
|
1828
|
+
showForgotPassword: L = !0,
|
|
1829
|
+
showSignupLink: P = !0,
|
|
1830
|
+
showMagicLinkOption: f = !0,
|
|
1831
|
+
className: m
|
|
1778
1832
|
}) {
|
|
1779
|
-
const [
|
|
1780
|
-
const
|
|
1781
|
-
return
|
|
1782
|
-
},
|
|
1783
|
-
if (
|
|
1784
|
-
if (!(
|
|
1785
|
-
|
|
1833
|
+
const [M, w] = p(""), [v, I] = p(""), [g, U] = p(!1), [u, y] = p(!1), [x, F] = p(""), [B, z] = p({}), { login: q } = ie(), { tenant: S } = re(), { appId: c } = ne(), h = { ..._e, ...i }, o = { ...Ke, ...e }, d = { ...Ye, ...t }, G = () => {
|
|
1834
|
+
const k = {};
|
|
1835
|
+
return M.trim() || (k.username = !0), v.trim() || (k.password = !0), z(k), Object.keys(k).length === 0;
|
|
1836
|
+
}, Y = async (k) => {
|
|
1837
|
+
if (k.preventDefault(), !!G()) {
|
|
1838
|
+
if (!(S != null && S.id)) {
|
|
1839
|
+
F("Tenant not found");
|
|
1786
1840
|
return;
|
|
1787
1841
|
}
|
|
1788
|
-
|
|
1842
|
+
y(!0), F("");
|
|
1789
1843
|
try {
|
|
1790
|
-
const
|
|
1791
|
-
r == null || r(
|
|
1792
|
-
} catch (
|
|
1793
|
-
const
|
|
1794
|
-
|
|
1844
|
+
const T = await q(M, v, c, S.id);
|
|
1845
|
+
r == null || r(T);
|
|
1846
|
+
} catch (T) {
|
|
1847
|
+
const J = T.message || h.errorMessage;
|
|
1848
|
+
F(J), s == null || s(J);
|
|
1795
1849
|
} finally {
|
|
1796
|
-
|
|
1850
|
+
y(!1);
|
|
1797
1851
|
}
|
|
1798
1852
|
}
|
|
1799
|
-
},
|
|
1800
|
-
...
|
|
1801
|
-
...k
|
|
1802
|
-
}),
|
|
1803
|
-
...
|
|
1804
|
-
...
|
|
1805
|
-
...!
|
|
1853
|
+
}, H = (k) => ({
|
|
1854
|
+
...o.input,
|
|
1855
|
+
...B[k] ? o.inputError : {}
|
|
1856
|
+
}), C = () => ({
|
|
1857
|
+
...o.button,
|
|
1858
|
+
...u ? o.buttonLoading : {},
|
|
1859
|
+
...!M || !v || u ? o.buttonDisabled : {}
|
|
1806
1860
|
});
|
|
1807
|
-
return /* @__PURE__ */
|
|
1808
|
-
/* @__PURE__ */
|
|
1809
|
-
/* @__PURE__ */
|
|
1810
|
-
/* @__PURE__ */
|
|
1811
|
-
/* @__PURE__ */
|
|
1812
|
-
/* @__PURE__ */
|
|
1861
|
+
return /* @__PURE__ */ l("div", { className: m, style: o.container, children: [
|
|
1862
|
+
/* @__PURE__ */ n("h2", { style: o.title, children: h.title }),
|
|
1863
|
+
/* @__PURE__ */ l("form", { onSubmit: Y, style: o.form, children: [
|
|
1864
|
+
/* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
|
|
1865
|
+
/* @__PURE__ */ n("label", { style: o.label, children: h.usernameLabel }),
|
|
1866
|
+
/* @__PURE__ */ n(
|
|
1813
1867
|
"input",
|
|
1814
1868
|
{
|
|
1815
|
-
id: "
|
|
1816
|
-
name: "
|
|
1817
|
-
type: "
|
|
1818
|
-
value:
|
|
1819
|
-
onChange: (
|
|
1820
|
-
|
|
1869
|
+
id: "username",
|
|
1870
|
+
name: "username",
|
|
1871
|
+
type: "text",
|
|
1872
|
+
value: M,
|
|
1873
|
+
onChange: (k) => {
|
|
1874
|
+
w(k.target.value), B.username && z((T) => ({ ...T, username: !1 }));
|
|
1821
1875
|
},
|
|
1822
|
-
placeholder:
|
|
1823
|
-
style:
|
|
1824
|
-
disabled:
|
|
1876
|
+
placeholder: h.usernamePlaceholder,
|
|
1877
|
+
style: H("username"),
|
|
1878
|
+
disabled: u
|
|
1825
1879
|
}
|
|
1826
1880
|
)
|
|
1827
1881
|
] }),
|
|
1828
|
-
/* @__PURE__ */
|
|
1829
|
-
/* @__PURE__ */
|
|
1830
|
-
/* @__PURE__ */
|
|
1831
|
-
/* @__PURE__ */
|
|
1882
|
+
/* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
|
|
1883
|
+
/* @__PURE__ */ n("label", { style: o.label, children: h.passwordLabel }),
|
|
1884
|
+
/* @__PURE__ */ l("div", { style: o.inputContainer, children: [
|
|
1885
|
+
/* @__PURE__ */ n(
|
|
1832
1886
|
"input",
|
|
1833
1887
|
{
|
|
1834
1888
|
id: "password",
|
|
1835
1889
|
name: "password",
|
|
1836
|
-
type:
|
|
1837
|
-
value:
|
|
1838
|
-
onChange: (
|
|
1839
|
-
|
|
1890
|
+
type: g ? "text" : "password",
|
|
1891
|
+
value: v,
|
|
1892
|
+
onChange: (k) => {
|
|
1893
|
+
I(k.target.value), B.password && z((T) => ({ ...T, password: !1 }));
|
|
1840
1894
|
},
|
|
1841
|
-
placeholder:
|
|
1895
|
+
placeholder: h.passwordPlaceholder,
|
|
1842
1896
|
style: {
|
|
1843
|
-
...
|
|
1897
|
+
...H("password"),
|
|
1844
1898
|
paddingRight: "2.5rem"
|
|
1845
1899
|
// Make room for the icon
|
|
1846
1900
|
},
|
|
1847
|
-
disabled:
|
|
1901
|
+
disabled: u
|
|
1848
1902
|
}
|
|
1849
1903
|
),
|
|
1850
|
-
/* @__PURE__ */
|
|
1904
|
+
/* @__PURE__ */ n(
|
|
1851
1905
|
"button",
|
|
1852
1906
|
{
|
|
1853
1907
|
type: "button",
|
|
1854
|
-
onClick: () =>
|
|
1855
|
-
style:
|
|
1856
|
-
disabled:
|
|
1857
|
-
"aria-label":
|
|
1858
|
-
children:
|
|
1908
|
+
onClick: () => U(!g),
|
|
1909
|
+
style: o.passwordToggle,
|
|
1910
|
+
disabled: u,
|
|
1911
|
+
"aria-label": g ? "Hide password" : "Show password",
|
|
1912
|
+
children: g ? d.hidePassword : d.showPassword
|
|
1859
1913
|
}
|
|
1860
1914
|
)
|
|
1861
1915
|
] })
|
|
1862
1916
|
] }),
|
|
1863
|
-
/* @__PURE__ */
|
|
1864
|
-
|
|
1917
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !M || !v || u, style: C(), children: u ? h.loadingText : h.submitButton }),
|
|
1918
|
+
x && /* @__PURE__ */ n("div", { style: o.errorText, children: x })
|
|
1865
1919
|
] }),
|
|
1866
|
-
(
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
/* @__PURE__ */ c("span", { style: d.divider, children: [
|
|
1871
|
-
B.signupText,
|
|
1920
|
+
(L || P || f) && /* @__PURE__ */ l("div", { style: o.linkContainer, children: [
|
|
1921
|
+
f && /* @__PURE__ */ l("div", { children: [
|
|
1922
|
+
/* @__PURE__ */ l("span", { style: o.divider, children: [
|
|
1923
|
+
h.magicLinkText,
|
|
1872
1924
|
" "
|
|
1873
1925
|
] }),
|
|
1874
|
-
/* @__PURE__ */
|
|
1926
|
+
/* @__PURE__ */ n("a", { onClick: E, style: o.link, children: h.magicLinkLink })
|
|
1927
|
+
] }),
|
|
1928
|
+
f && (L || P) && /* @__PURE__ */ n("div", { style: o.divider, children: "•" }),
|
|
1929
|
+
L && /* @__PURE__ */ n("a", { onClick: a, style: o.link, children: h.forgotPasswordLink }),
|
|
1930
|
+
L && P && /* @__PURE__ */ n("div", { style: o.divider, children: "•" }),
|
|
1931
|
+
P && /* @__PURE__ */ l("div", { children: [
|
|
1932
|
+
/* @__PURE__ */ l("span", { style: o.divider, children: [
|
|
1933
|
+
h.signupText,
|
|
1934
|
+
" "
|
|
1935
|
+
] }),
|
|
1936
|
+
/* @__PURE__ */ n("a", { onClick: b, style: o.link, children: h.signupLink })
|
|
1875
1937
|
] })
|
|
1876
1938
|
] })
|
|
1877
1939
|
] });
|
|
1878
1940
|
}
|
|
1879
|
-
const
|
|
1941
|
+
const Qe = {
|
|
1880
1942
|
title: "Create Account",
|
|
1881
|
-
nameLabel: "
|
|
1882
|
-
namePlaceholder: "Enter your
|
|
1943
|
+
nameLabel: "First Name",
|
|
1944
|
+
namePlaceholder: "Enter your first name",
|
|
1945
|
+
lastNameLabel: "Last Name",
|
|
1946
|
+
lastNamePlaceholder: "Enter your last name",
|
|
1883
1947
|
emailLabel: "Email",
|
|
1884
1948
|
emailPlaceholder: "Enter your email",
|
|
1949
|
+
phoneNumberLabel: "Phone Number",
|
|
1950
|
+
phoneNumberPlaceholder: "Enter your phone number",
|
|
1885
1951
|
passwordLabel: "Password",
|
|
1886
1952
|
passwordPlaceholder: "Enter your password",
|
|
1887
1953
|
confirmPasswordLabel: "Confirm Password",
|
|
@@ -1891,12 +1957,14 @@ const je = {
|
|
|
1891
1957
|
submitButton: "Create Account",
|
|
1892
1958
|
loginLink: "Sign in here",
|
|
1893
1959
|
loginText: "Already have an account?",
|
|
1960
|
+
magicLinkText: "Prefer passwordless?",
|
|
1961
|
+
magicLinkLink: "Use Magic Link",
|
|
1894
1962
|
errorMessage: "Failed to create account",
|
|
1895
1963
|
loadingText: "Creating account...",
|
|
1896
1964
|
passwordMismatchError: "Passwords do not match",
|
|
1897
1965
|
isAdminLabel: "Create new organization",
|
|
1898
1966
|
isAdminDescription: "Check this if you want to create a new organization"
|
|
1899
|
-
},
|
|
1967
|
+
}, Je = {
|
|
1900
1968
|
container: {
|
|
1901
1969
|
maxWidth: "400px",
|
|
1902
1970
|
width: "100%",
|
|
@@ -1995,154 +2063,784 @@ const je = {
|
|
|
1995
2063
|
fontSize: "0.875rem"
|
|
1996
2064
|
}
|
|
1997
2065
|
};
|
|
1998
|
-
function
|
|
2066
|
+
function Mt({
|
|
1999
2067
|
copy: i = {},
|
|
2000
2068
|
styles: e = {},
|
|
2001
2069
|
signupType: t = "user",
|
|
2002
2070
|
onSuccess: r,
|
|
2003
|
-
onError:
|
|
2004
|
-
onLoginClick:
|
|
2005
|
-
|
|
2006
|
-
|
|
2071
|
+
onError: s,
|
|
2072
|
+
onLoginClick: a,
|
|
2073
|
+
onMagicLinkClick: b,
|
|
2074
|
+
showLoginLink: E = !0,
|
|
2075
|
+
showMagicLinkOption: L = !0,
|
|
2076
|
+
className: P
|
|
2007
2077
|
}) {
|
|
2008
|
-
const [M,
|
|
2009
|
-
const
|
|
2010
|
-
return
|
|
2011
|
-
},
|
|
2012
|
-
if (
|
|
2013
|
-
if (
|
|
2014
|
-
|
|
2078
|
+
const [f, m] = p(""), [M, w] = p(""), [v, I] = p(""), [g, U] = p(""), [u, y] = p(""), [x, F] = p(""), [B, z] = p(""), [q, S] = p(!1), [c, h] = p(""), [o, d] = p({}), { signup: G, signupTenantAdmin: Y } = ie(), { tenant: H } = re(), { appId: C } = ne(), k = { ...Qe, ...i }, T = { ...Je, ...e }, J = () => {
|
|
2079
|
+
const R = {};
|
|
2080
|
+
return f.trim() || (R.name = !0), !v.trim() && !g.trim() && (R.email = !0, R.phoneNumber = !0), u.trim() || (R.password = !0), x.trim() || (R.confirmPassword = !0), t === "tenant" && !B.trim() && (R.tenantName = !0), d(R), Object.keys(R).length === 0;
|
|
2081
|
+
}, O = async (R) => {
|
|
2082
|
+
if (R.preventDefault(), !!J()) {
|
|
2083
|
+
if (u !== x) {
|
|
2084
|
+
h(k.passwordMismatchError), d({ confirmPassword: !0 });
|
|
2015
2085
|
return;
|
|
2016
2086
|
}
|
|
2017
|
-
if (t === "user" && !(
|
|
2018
|
-
|
|
2087
|
+
if (t === "user" && !(H != null && H.id)) {
|
|
2088
|
+
h("Tenant not found");
|
|
2019
2089
|
return;
|
|
2020
2090
|
}
|
|
2021
|
-
S(!0),
|
|
2091
|
+
S(!0), h("");
|
|
2022
2092
|
try {
|
|
2023
|
-
let
|
|
2024
|
-
t === "tenant" ?
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2093
|
+
let V;
|
|
2094
|
+
t === "tenant" ? V = await Y(
|
|
2095
|
+
v || void 0,
|
|
2096
|
+
g || void 0,
|
|
2097
|
+
f,
|
|
2098
|
+
u,
|
|
2099
|
+
B,
|
|
2100
|
+
M || void 0,
|
|
2101
|
+
C
|
|
2102
|
+
) : V = await G(
|
|
2103
|
+
v || void 0,
|
|
2104
|
+
g || void 0,
|
|
2105
|
+
f,
|
|
2106
|
+
u,
|
|
2107
|
+
H.id,
|
|
2108
|
+
M || void 0,
|
|
2109
|
+
C
|
|
2110
|
+
), r == null || r(V);
|
|
2111
|
+
} catch (V) {
|
|
2112
|
+
const ue = V.message || k.errorMessage;
|
|
2113
|
+
h(ue), s == null || s(ue);
|
|
2028
2114
|
} finally {
|
|
2029
2115
|
S(!1);
|
|
2030
2116
|
}
|
|
2031
2117
|
}
|
|
2032
|
-
},
|
|
2033
|
-
...
|
|
2034
|
-
...
|
|
2118
|
+
}, j = (R) => ({
|
|
2119
|
+
...T.input,
|
|
2120
|
+
...o[R] ? T.inputError : {}
|
|
2035
2121
|
}), N = () => ({
|
|
2036
|
-
...
|
|
2037
|
-
...
|
|
2038
|
-
...!
|
|
2039
|
-
}),
|
|
2040
|
-
return /* @__PURE__ */
|
|
2041
|
-
/* @__PURE__ */
|
|
2042
|
-
/* @__PURE__ */
|
|
2043
|
-
/* @__PURE__ */
|
|
2044
|
-
/* @__PURE__ */
|
|
2045
|
-
/* @__PURE__ */
|
|
2122
|
+
...T.button,
|
|
2123
|
+
...q ? T.buttonLoading : {},
|
|
2124
|
+
...!f || !v && !g || !u || !x || q || t === "tenant" && !B ? T.buttonDisabled : {}
|
|
2125
|
+
}), K = f && (v || g) && u && x && (t === "user" || B);
|
|
2126
|
+
return /* @__PURE__ */ l("div", { className: P, style: T.container, children: [
|
|
2127
|
+
/* @__PURE__ */ n("h2", { style: T.title, children: k.title }),
|
|
2128
|
+
/* @__PURE__ */ l("form", { onSubmit: O, style: T.form, children: [
|
|
2129
|
+
/* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
|
|
2130
|
+
/* @__PURE__ */ n("label", { style: T.label, children: k.nameLabel }),
|
|
2131
|
+
/* @__PURE__ */ n(
|
|
2046
2132
|
"input",
|
|
2047
2133
|
{
|
|
2048
2134
|
id: "name",
|
|
2049
2135
|
name: "name",
|
|
2050
2136
|
type: "text",
|
|
2051
|
-
value:
|
|
2052
|
-
onChange: (
|
|
2053
|
-
|
|
2137
|
+
value: f,
|
|
2138
|
+
onChange: (R) => {
|
|
2139
|
+
m(R.target.value), o.name && d((V) => ({ ...V, name: !1 }));
|
|
2054
2140
|
},
|
|
2055
|
-
placeholder:
|
|
2056
|
-
style:
|
|
2057
|
-
disabled:
|
|
2141
|
+
placeholder: k.namePlaceholder,
|
|
2142
|
+
style: j("name"),
|
|
2143
|
+
disabled: q
|
|
2144
|
+
}
|
|
2145
|
+
)
|
|
2146
|
+
] }),
|
|
2147
|
+
/* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
|
|
2148
|
+
/* @__PURE__ */ n("label", { style: T.label, children: k.lastNameLabel }),
|
|
2149
|
+
/* @__PURE__ */ n(
|
|
2150
|
+
"input",
|
|
2151
|
+
{
|
|
2152
|
+
id: "lastName",
|
|
2153
|
+
name: "lastName",
|
|
2154
|
+
type: "text",
|
|
2155
|
+
value: M,
|
|
2156
|
+
onChange: (R) => w(R.target.value),
|
|
2157
|
+
placeholder: k.lastNamePlaceholder,
|
|
2158
|
+
style: T.input,
|
|
2159
|
+
disabled: q
|
|
2058
2160
|
}
|
|
2059
2161
|
)
|
|
2060
2162
|
] }),
|
|
2061
|
-
/* @__PURE__ */
|
|
2062
|
-
/* @__PURE__ */
|
|
2063
|
-
/* @__PURE__ */
|
|
2163
|
+
/* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
|
|
2164
|
+
/* @__PURE__ */ n("label", { style: T.label, children: k.emailLabel }),
|
|
2165
|
+
/* @__PURE__ */ n(
|
|
2064
2166
|
"input",
|
|
2065
2167
|
{
|
|
2066
2168
|
id: "email",
|
|
2067
2169
|
name: "email",
|
|
2068
2170
|
type: "email",
|
|
2171
|
+
value: v,
|
|
2172
|
+
onChange: (R) => {
|
|
2173
|
+
I(R.target.value), o.email && d((V) => ({ ...V, email: !1, phoneNumber: !1 }));
|
|
2174
|
+
},
|
|
2175
|
+
placeholder: k.emailPlaceholder,
|
|
2176
|
+
style: j("email"),
|
|
2177
|
+
disabled: q
|
|
2178
|
+
}
|
|
2179
|
+
)
|
|
2180
|
+
] }),
|
|
2181
|
+
/* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
|
|
2182
|
+
/* @__PURE__ */ n("label", { style: T.label, children: k.phoneNumberLabel }),
|
|
2183
|
+
/* @__PURE__ */ n(
|
|
2184
|
+
"input",
|
|
2185
|
+
{
|
|
2186
|
+
id: "phoneNumber",
|
|
2187
|
+
name: "phoneNumber",
|
|
2188
|
+
type: "tel",
|
|
2069
2189
|
value: g,
|
|
2070
|
-
onChange: (
|
|
2071
|
-
|
|
2190
|
+
onChange: (R) => {
|
|
2191
|
+
U(R.target.value), o.phoneNumber && d((V) => ({ ...V, email: !1, phoneNumber: !1 }));
|
|
2072
2192
|
},
|
|
2073
|
-
placeholder:
|
|
2074
|
-
style:
|
|
2075
|
-
disabled:
|
|
2193
|
+
placeholder: k.phoneNumberPlaceholder,
|
|
2194
|
+
style: j("phoneNumber"),
|
|
2195
|
+
disabled: q
|
|
2076
2196
|
}
|
|
2077
2197
|
)
|
|
2078
2198
|
] }),
|
|
2079
|
-
/* @__PURE__ */
|
|
2080
|
-
|
|
2081
|
-
|
|
2199
|
+
/* @__PURE__ */ n(
|
|
2200
|
+
"div",
|
|
2201
|
+
{
|
|
2202
|
+
style: {
|
|
2203
|
+
fontSize: "0.875rem",
|
|
2204
|
+
color: "#6b7280",
|
|
2205
|
+
textAlign: "center",
|
|
2206
|
+
margin: "0.5rem 0"
|
|
2207
|
+
},
|
|
2208
|
+
children: "At least one contact method (email or phone) is required"
|
|
2209
|
+
}
|
|
2210
|
+
),
|
|
2211
|
+
/* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
|
|
2212
|
+
/* @__PURE__ */ n("label", { style: T.label, children: k.passwordLabel }),
|
|
2213
|
+
/* @__PURE__ */ n(
|
|
2082
2214
|
"input",
|
|
2083
2215
|
{
|
|
2084
2216
|
id: "password",
|
|
2085
2217
|
name: "password",
|
|
2086
2218
|
type: "password",
|
|
2087
|
-
value:
|
|
2088
|
-
onChange: (
|
|
2089
|
-
|
|
2219
|
+
value: u,
|
|
2220
|
+
onChange: (R) => {
|
|
2221
|
+
y(R.target.value), o.password && d((V) => ({ ...V, password: !1 }));
|
|
2090
2222
|
},
|
|
2091
|
-
placeholder:
|
|
2092
|
-
style:
|
|
2093
|
-
disabled:
|
|
2223
|
+
placeholder: k.passwordPlaceholder,
|
|
2224
|
+
style: j("password"),
|
|
2225
|
+
disabled: q
|
|
2094
2226
|
}
|
|
2095
2227
|
)
|
|
2096
2228
|
] }),
|
|
2097
|
-
/* @__PURE__ */
|
|
2098
|
-
/* @__PURE__ */
|
|
2099
|
-
/* @__PURE__ */
|
|
2229
|
+
/* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
|
|
2230
|
+
/* @__PURE__ */ n("label", { style: T.label, children: k.confirmPasswordLabel }),
|
|
2231
|
+
/* @__PURE__ */ n(
|
|
2100
2232
|
"input",
|
|
2101
2233
|
{
|
|
2102
2234
|
id: "confirmPassword",
|
|
2103
2235
|
name: "confirmPassword",
|
|
2104
2236
|
type: "password",
|
|
2105
|
-
value:
|
|
2106
|
-
onChange: (
|
|
2107
|
-
F(
|
|
2237
|
+
value: x,
|
|
2238
|
+
onChange: (R) => {
|
|
2239
|
+
F(R.target.value), o.confirmPassword && d((V) => ({ ...V, confirmPassword: !1 })), c === k.passwordMismatchError && h("");
|
|
2108
2240
|
},
|
|
2109
|
-
placeholder:
|
|
2110
|
-
style:
|
|
2111
|
-
disabled:
|
|
2241
|
+
placeholder: k.confirmPasswordPlaceholder,
|
|
2242
|
+
style: j("confirmPassword"),
|
|
2243
|
+
disabled: q
|
|
2112
2244
|
}
|
|
2113
2245
|
)
|
|
2114
2246
|
] }),
|
|
2115
|
-
t === "tenant" && /* @__PURE__ */
|
|
2116
|
-
/* @__PURE__ */
|
|
2117
|
-
/* @__PURE__ */
|
|
2247
|
+
t === "tenant" && /* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
|
|
2248
|
+
/* @__PURE__ */ n("label", { style: T.label, children: k.tenantNameLabel }),
|
|
2249
|
+
/* @__PURE__ */ n(
|
|
2118
2250
|
"input",
|
|
2119
2251
|
{
|
|
2120
2252
|
id: "tenantName",
|
|
2121
2253
|
name: "tenantName",
|
|
2122
2254
|
type: "text",
|
|
2255
|
+
value: B,
|
|
2256
|
+
onChange: (R) => {
|
|
2257
|
+
z(R.target.value), o.tenantName && d((V) => ({ ...V, tenantName: !1 }));
|
|
2258
|
+
},
|
|
2259
|
+
placeholder: k.tenantNamePlaceholder,
|
|
2260
|
+
style: j("tenantName"),
|
|
2261
|
+
disabled: q
|
|
2262
|
+
}
|
|
2263
|
+
)
|
|
2264
|
+
] }),
|
|
2265
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !K || q, style: N(), children: q ? k.loadingText : k.submitButton }),
|
|
2266
|
+
c && /* @__PURE__ */ n("div", { style: T.errorText, children: c })
|
|
2267
|
+
] }),
|
|
2268
|
+
(E || L) && /* @__PURE__ */ l("div", { style: T.linkContainer, children: [
|
|
2269
|
+
L && /* @__PURE__ */ l("div", { children: [
|
|
2270
|
+
/* @__PURE__ */ l("span", { style: T.divider, children: [
|
|
2271
|
+
k.magicLinkText,
|
|
2272
|
+
" "
|
|
2273
|
+
] }),
|
|
2274
|
+
/* @__PURE__ */ n("a", { onClick: b, style: T.link, children: k.magicLinkLink })
|
|
2275
|
+
] }),
|
|
2276
|
+
L && E && /* @__PURE__ */ n("div", { style: T.divider, children: "•" }),
|
|
2277
|
+
E && /* @__PURE__ */ l("div", { children: [
|
|
2278
|
+
/* @__PURE__ */ l("span", { style: T.divider, children: [
|
|
2279
|
+
k.loginText,
|
|
2280
|
+
" "
|
|
2281
|
+
] }),
|
|
2282
|
+
/* @__PURE__ */ n("a", { onClick: a, style: T.link, children: k.loginLink })
|
|
2283
|
+
] })
|
|
2284
|
+
] })
|
|
2285
|
+
] });
|
|
2286
|
+
}
|
|
2287
|
+
const Xe = {
|
|
2288
|
+
title: "Sign In with Magic Link",
|
|
2289
|
+
emailLabel: "Email",
|
|
2290
|
+
emailPlaceholder: "Enter your email",
|
|
2291
|
+
nameLabel: "Name",
|
|
2292
|
+
namePlaceholder: "Enter your name",
|
|
2293
|
+
lastNameLabel: "Last Name",
|
|
2294
|
+
lastNamePlaceholder: "Enter your last name",
|
|
2295
|
+
submitButton: "Send Magic Link",
|
|
2296
|
+
loginLink: "Sign in with password",
|
|
2297
|
+
signupLink: "Sign up with password",
|
|
2298
|
+
loginText: "Already have an account?",
|
|
2299
|
+
signupText: "Prefer traditional signup?",
|
|
2300
|
+
successMessage: "Magic link sent! Check your email and click the link to sign in.",
|
|
2301
|
+
errorMessage: "Failed to send magic link. Please try again.",
|
|
2302
|
+
loadingText: "Sending magic link...",
|
|
2303
|
+
verifyingText: "Verifying magic link...",
|
|
2304
|
+
description: "Enter your email to receive a magic link. If you don't have an account, we'll create one for you."
|
|
2305
|
+
}, Ze = {
|
|
2306
|
+
container: {
|
|
2307
|
+
maxWidth: "400px",
|
|
2308
|
+
width: "100%",
|
|
2309
|
+
margin: "0 auto",
|
|
2310
|
+
padding: "2rem",
|
|
2311
|
+
backgroundColor: "#ffffff",
|
|
2312
|
+
borderRadius: "8px",
|
|
2313
|
+
boxShadow: "0 2px 10px rgba(0, 0, 0, 0.1)"
|
|
2314
|
+
},
|
|
2315
|
+
title: {
|
|
2316
|
+
fontSize: "1.5rem",
|
|
2317
|
+
fontWeight: "bold",
|
|
2318
|
+
textAlign: "center",
|
|
2319
|
+
marginBottom: "1rem",
|
|
2320
|
+
color: "#333333"
|
|
2321
|
+
},
|
|
2322
|
+
description: {
|
|
2323
|
+
fontSize: "0.875rem",
|
|
2324
|
+
color: "#6b7280",
|
|
2325
|
+
textAlign: "center",
|
|
2326
|
+
marginBottom: "1.5rem",
|
|
2327
|
+
lineHeight: "1.5"
|
|
2328
|
+
},
|
|
2329
|
+
form: {
|
|
2330
|
+
display: "flex",
|
|
2331
|
+
flexDirection: "column",
|
|
2332
|
+
gap: "1rem"
|
|
2333
|
+
},
|
|
2334
|
+
fieldGroup: {
|
|
2335
|
+
display: "flex",
|
|
2336
|
+
flexDirection: "column",
|
|
2337
|
+
gap: "0.5rem"
|
|
2338
|
+
},
|
|
2339
|
+
label: {
|
|
2340
|
+
fontSize: "0.875rem",
|
|
2341
|
+
fontWeight: "500",
|
|
2342
|
+
color: "#374151"
|
|
2343
|
+
},
|
|
2344
|
+
input: {
|
|
2345
|
+
padding: "0.75rem",
|
|
2346
|
+
border: "1px solid #d1d5db",
|
|
2347
|
+
borderRadius: "6px",
|
|
2348
|
+
fontSize: "1rem",
|
|
2349
|
+
transition: "border-color 0.15s ease-in-out",
|
|
2350
|
+
outline: "none",
|
|
2351
|
+
width: "100%"
|
|
2352
|
+
},
|
|
2353
|
+
inputError: {
|
|
2354
|
+
borderColor: "#ef4444",
|
|
2355
|
+
boxShadow: "0 0 0 3px rgba(239, 68, 68, 0.1)"
|
|
2356
|
+
},
|
|
2357
|
+
button: {
|
|
2358
|
+
padding: "0.75rem 1rem",
|
|
2359
|
+
backgroundColor: "#3b82f6",
|
|
2360
|
+
color: "white",
|
|
2361
|
+
border: "none",
|
|
2362
|
+
borderRadius: "6px",
|
|
2363
|
+
fontSize: "1rem",
|
|
2364
|
+
fontWeight: "500",
|
|
2365
|
+
cursor: "pointer",
|
|
2366
|
+
transition: "background-color 0.15s ease-in-out",
|
|
2367
|
+
marginTop: "0.5rem"
|
|
2368
|
+
},
|
|
2369
|
+
buttonDisabled: {
|
|
2370
|
+
backgroundColor: "#9ca3af",
|
|
2371
|
+
cursor: "not-allowed"
|
|
2372
|
+
},
|
|
2373
|
+
buttonLoading: {
|
|
2374
|
+
backgroundColor: "#6b7280"
|
|
2375
|
+
},
|
|
2376
|
+
errorText: {
|
|
2377
|
+
color: "#ef4444",
|
|
2378
|
+
fontSize: "0.875rem",
|
|
2379
|
+
textAlign: "center",
|
|
2380
|
+
marginTop: "0.5rem"
|
|
2381
|
+
},
|
|
2382
|
+
successText: {
|
|
2383
|
+
color: "#10b981",
|
|
2384
|
+
fontSize: "0.875rem",
|
|
2385
|
+
textAlign: "center",
|
|
2386
|
+
marginTop: "0.5rem",
|
|
2387
|
+
padding: "0.75rem",
|
|
2388
|
+
backgroundColor: "#f0fdf4",
|
|
2389
|
+
borderRadius: "6px",
|
|
2390
|
+
border: "1px solid #bbf7d0"
|
|
2391
|
+
},
|
|
2392
|
+
linkContainer: {
|
|
2393
|
+
textAlign: "center",
|
|
2394
|
+
marginTop: "1rem"
|
|
2395
|
+
},
|
|
2396
|
+
link: {
|
|
2397
|
+
color: "#3b82f6",
|
|
2398
|
+
textDecoration: "none",
|
|
2399
|
+
fontSize: "0.875rem",
|
|
2400
|
+
cursor: "pointer"
|
|
2401
|
+
},
|
|
2402
|
+
divider: {
|
|
2403
|
+
margin: "0.5rem 0",
|
|
2404
|
+
color: "#6b7280",
|
|
2405
|
+
fontSize: "0.875rem"
|
|
2406
|
+
}
|
|
2407
|
+
};
|
|
2408
|
+
function Et({
|
|
2409
|
+
copy: i = {},
|
|
2410
|
+
styles: e = {},
|
|
2411
|
+
onSuccess: t,
|
|
2412
|
+
onError: r,
|
|
2413
|
+
onLoginClick: s,
|
|
2414
|
+
onSignupClick: a,
|
|
2415
|
+
showTraditionalLinks: b = !0,
|
|
2416
|
+
className: E,
|
|
2417
|
+
verifyToken: L,
|
|
2418
|
+
frontendUrl: P
|
|
2419
|
+
}) {
|
|
2420
|
+
const [f, m] = p(""), [M, w] = p(""), [v, I] = p(""), [g, U] = p(!1), [u, y] = p(!1), [x, F] = p(""), [B, z] = p(""), [q, S] = p({}), [c, h] = p(!1), { sendMagicLink: o, verifyMagicLink: d } = ie(), { tenant: G } = re(), { appId: Y } = ne(), H = { ...Xe, ...i }, C = { ...Ze, ...e };
|
|
2421
|
+
Z(() => {
|
|
2422
|
+
L && k(L);
|
|
2423
|
+
}, [L]);
|
|
2424
|
+
const k = async (N) => {
|
|
2425
|
+
y(!0), F("");
|
|
2426
|
+
try {
|
|
2427
|
+
if (!f || !Y)
|
|
2428
|
+
throw new Error("Email and App ID are required for magic link verification");
|
|
2429
|
+
const K = await d(N, f, Y, G == null ? void 0 : G.id);
|
|
2430
|
+
t == null || t(K);
|
|
2431
|
+
} catch (K) {
|
|
2432
|
+
const R = K.message || "Failed to verify magic link";
|
|
2433
|
+
F(R), r == null || r(R);
|
|
2434
|
+
} finally {
|
|
2435
|
+
y(!1);
|
|
2436
|
+
}
|
|
2437
|
+
}, T = () => {
|
|
2438
|
+
const N = {};
|
|
2439
|
+
return f.trim() || (N.email = !0), c && !M.trim() && (N.name = !0), S(N), Object.keys(N).length === 0;
|
|
2440
|
+
}, J = async (N) => {
|
|
2441
|
+
if (N.preventDefault(), !!T()) {
|
|
2442
|
+
if (!(G != null && G.id)) {
|
|
2443
|
+
F("Tenant not found");
|
|
2444
|
+
return;
|
|
2445
|
+
}
|
|
2446
|
+
U(!0), F(""), z("");
|
|
2447
|
+
try {
|
|
2448
|
+
const K = P || (typeof window < "u" ? window.location.origin : ""), R = await o(
|
|
2449
|
+
f,
|
|
2450
|
+
G.id,
|
|
2451
|
+
K,
|
|
2452
|
+
c ? M : void 0,
|
|
2453
|
+
c ? v : void 0,
|
|
2454
|
+
Y
|
|
2455
|
+
);
|
|
2456
|
+
z(H.successMessage), t == null || t(R);
|
|
2457
|
+
} catch (K) {
|
|
2458
|
+
const R = K.message || H.errorMessage;
|
|
2459
|
+
F(R), r == null || r(R);
|
|
2460
|
+
} finally {
|
|
2461
|
+
U(!1);
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
}, O = (N) => ({
|
|
2465
|
+
...C.input,
|
|
2466
|
+
...q[N] ? C.inputError : {}
|
|
2467
|
+
}), j = () => ({
|
|
2468
|
+
...C.button,
|
|
2469
|
+
...g || u ? C.buttonLoading : {},
|
|
2470
|
+
...!f || g || u ? C.buttonDisabled : {}
|
|
2471
|
+
});
|
|
2472
|
+
return u ? /* @__PURE__ */ l("div", { className: E, style: C.container, children: [
|
|
2473
|
+
/* @__PURE__ */ n("h2", { style: C.title, children: H.verifyingText }),
|
|
2474
|
+
/* @__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: E, style: C.container, children: [
|
|
2476
|
+
/* @__PURE__ */ n("h2", { style: C.title, children: H.title }),
|
|
2477
|
+
/* @__PURE__ */ n("p", { style: C.description, children: H.description }),
|
|
2478
|
+
/* @__PURE__ */ l("form", { onSubmit: J, style: C.form, children: [
|
|
2479
|
+
/* @__PURE__ */ l("div", { style: C.fieldGroup, children: [
|
|
2480
|
+
/* @__PURE__ */ n("label", { style: C.label, children: H.emailLabel }),
|
|
2481
|
+
/* @__PURE__ */ n(
|
|
2482
|
+
"input",
|
|
2483
|
+
{
|
|
2484
|
+
id: "email",
|
|
2485
|
+
name: "email",
|
|
2486
|
+
type: "email",
|
|
2123
2487
|
value: f,
|
|
2124
|
-
onChange: (
|
|
2125
|
-
|
|
2488
|
+
onChange: (N) => {
|
|
2489
|
+
m(N.target.value), q.email && S((K) => ({ ...K, email: !1 }));
|
|
2126
2490
|
},
|
|
2127
|
-
placeholder:
|
|
2128
|
-
style:
|
|
2129
|
-
disabled:
|
|
2491
|
+
placeholder: H.emailPlaceholder,
|
|
2492
|
+
style: O("email"),
|
|
2493
|
+
disabled: g || u
|
|
2130
2494
|
}
|
|
2131
2495
|
)
|
|
2132
2496
|
] }),
|
|
2133
|
-
/* @__PURE__ */
|
|
2134
|
-
|
|
2497
|
+
!c && /* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
|
|
2498
|
+
"button",
|
|
2499
|
+
{
|
|
2500
|
+
type: "button",
|
|
2501
|
+
onClick: () => h(!0),
|
|
2502
|
+
style: {
|
|
2503
|
+
background: "none",
|
|
2504
|
+
border: "none",
|
|
2505
|
+
color: "#3b82f6",
|
|
2506
|
+
fontSize: "0.875rem",
|
|
2507
|
+
cursor: "pointer",
|
|
2508
|
+
textDecoration: "underline"
|
|
2509
|
+
},
|
|
2510
|
+
children: "New user? Add your name"
|
|
2511
|
+
}
|
|
2512
|
+
) }),
|
|
2513
|
+
c && /* @__PURE__ */ l(D, { children: [
|
|
2514
|
+
/* @__PURE__ */ l("div", { style: C.fieldGroup, children: [
|
|
2515
|
+
/* @__PURE__ */ n("label", { style: C.label, children: H.nameLabel }),
|
|
2516
|
+
/* @__PURE__ */ n(
|
|
2517
|
+
"input",
|
|
2518
|
+
{
|
|
2519
|
+
id: "name",
|
|
2520
|
+
name: "name",
|
|
2521
|
+
type: "text",
|
|
2522
|
+
value: M,
|
|
2523
|
+
onChange: (N) => {
|
|
2524
|
+
w(N.target.value), q.name && S((K) => ({ ...K, name: !1 }));
|
|
2525
|
+
},
|
|
2526
|
+
placeholder: H.namePlaceholder,
|
|
2527
|
+
style: O("name"),
|
|
2528
|
+
disabled: g || u
|
|
2529
|
+
}
|
|
2530
|
+
)
|
|
2531
|
+
] }),
|
|
2532
|
+
/* @__PURE__ */ l("div", { style: C.fieldGroup, children: [
|
|
2533
|
+
/* @__PURE__ */ n("label", { style: C.label, children: H.lastNameLabel }),
|
|
2534
|
+
/* @__PURE__ */ n(
|
|
2535
|
+
"input",
|
|
2536
|
+
{
|
|
2537
|
+
id: "lastName",
|
|
2538
|
+
name: "lastName",
|
|
2539
|
+
type: "text",
|
|
2540
|
+
value: v,
|
|
2541
|
+
onChange: (N) => I(N.target.value),
|
|
2542
|
+
placeholder: H.lastNamePlaceholder,
|
|
2543
|
+
style: C.input,
|
|
2544
|
+
disabled: g || u
|
|
2545
|
+
}
|
|
2546
|
+
)
|
|
2547
|
+
] }),
|
|
2548
|
+
/* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
|
|
2549
|
+
"button",
|
|
2550
|
+
{
|
|
2551
|
+
type: "button",
|
|
2552
|
+
onClick: () => {
|
|
2553
|
+
h(!1), w(""), I("");
|
|
2554
|
+
},
|
|
2555
|
+
style: {
|
|
2556
|
+
background: "none",
|
|
2557
|
+
border: "none",
|
|
2558
|
+
color: "#6b7280",
|
|
2559
|
+
fontSize: "0.875rem",
|
|
2560
|
+
cursor: "pointer",
|
|
2561
|
+
textDecoration: "underline"
|
|
2562
|
+
},
|
|
2563
|
+
children: "Existing user? Hide name fields"
|
|
2564
|
+
}
|
|
2565
|
+
) })
|
|
2566
|
+
] }),
|
|
2567
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !f || g || u, style: j(), children: g ? H.loadingText : H.submitButton }),
|
|
2568
|
+
x && /* @__PURE__ */ n("div", { style: C.errorText, children: x }),
|
|
2569
|
+
B && /* @__PURE__ */ n("div", { style: C.successText, children: B })
|
|
2135
2570
|
] }),
|
|
2136
|
-
|
|
2137
|
-
/* @__PURE__ */
|
|
2138
|
-
|
|
2139
|
-
|
|
2571
|
+
b && /* @__PURE__ */ l("div", { style: C.linkContainer, children: [
|
|
2572
|
+
/* @__PURE__ */ l("div", { children: [
|
|
2573
|
+
/* @__PURE__ */ l("span", { style: C.divider, children: [
|
|
2574
|
+
H.loginText,
|
|
2575
|
+
" "
|
|
2576
|
+
] }),
|
|
2577
|
+
/* @__PURE__ */ n("a", { onClick: s, style: C.link, children: H.loginLink })
|
|
2140
2578
|
] }),
|
|
2141
|
-
/* @__PURE__ */
|
|
2579
|
+
/* @__PURE__ */ n("div", { style: C.divider, children: "•" }),
|
|
2580
|
+
/* @__PURE__ */ l("div", { children: [
|
|
2581
|
+
/* @__PURE__ */ l("span", { style: C.divider, children: [
|
|
2582
|
+
H.signupText,
|
|
2583
|
+
" "
|
|
2584
|
+
] }),
|
|
2585
|
+
/* @__PURE__ */ n("a", { onClick: a, style: C.link, children: H.signupLink })
|
|
2586
|
+
] })
|
|
2142
2587
|
] })
|
|
2143
2588
|
] });
|
|
2144
2589
|
}
|
|
2145
|
-
const
|
|
2590
|
+
const et = {
|
|
2591
|
+
title: "Verifying Magic Link",
|
|
2592
|
+
verifyingMessage: "Please wait while we verify your magic link...",
|
|
2593
|
+
successMessage: "Magic link verified successfully! You are now logged in.",
|
|
2594
|
+
errorMessage: "Failed to verify magic link. The link may be expired or invalid.",
|
|
2595
|
+
redirectingMessage: "Redirecting you to the dashboard...",
|
|
2596
|
+
retryButton: "Try Again",
|
|
2597
|
+
backToLoginButton: "Back to Login"
|
|
2598
|
+
}, Ae = {
|
|
2599
|
+
container: {
|
|
2600
|
+
maxWidth: "400px",
|
|
2601
|
+
width: "100%",
|
|
2602
|
+
margin: "0 auto",
|
|
2603
|
+
padding: "2rem",
|
|
2604
|
+
backgroundColor: "#ffffff",
|
|
2605
|
+
borderRadius: "8px",
|
|
2606
|
+
boxShadow: "0 2px 10px rgba(0, 0, 0, 0.1)"
|
|
2607
|
+
},
|
|
2608
|
+
card: {
|
|
2609
|
+
// Not used in new design, keeping for compatibility
|
|
2610
|
+
backgroundColor: "transparent",
|
|
2611
|
+
padding: "0",
|
|
2612
|
+
borderRadius: "0",
|
|
2613
|
+
boxShadow: "none",
|
|
2614
|
+
maxWidth: "100%",
|
|
2615
|
+
width: "100%",
|
|
2616
|
+
textAlign: "center"
|
|
2617
|
+
},
|
|
2618
|
+
title: {
|
|
2619
|
+
fontSize: "1.5rem",
|
|
2620
|
+
fontWeight: "bold",
|
|
2621
|
+
textAlign: "center",
|
|
2622
|
+
marginBottom: "1.5rem",
|
|
2623
|
+
color: "#333333"
|
|
2624
|
+
},
|
|
2625
|
+
message: {
|
|
2626
|
+
fontSize: "1rem",
|
|
2627
|
+
color: "#6b7280",
|
|
2628
|
+
marginBottom: "1.5rem",
|
|
2629
|
+
lineHeight: "1.5",
|
|
2630
|
+
textAlign: "center"
|
|
2631
|
+
},
|
|
2632
|
+
successMessage: {
|
|
2633
|
+
fontSize: "1rem",
|
|
2634
|
+
color: "#059669",
|
|
2635
|
+
marginBottom: "1.5rem",
|
|
2636
|
+
lineHeight: "1.5",
|
|
2637
|
+
textAlign: "center"
|
|
2638
|
+
},
|
|
2639
|
+
errorMessage: {
|
|
2640
|
+
fontSize: "0.875rem",
|
|
2641
|
+
color: "#ef4444",
|
|
2642
|
+
textAlign: "center",
|
|
2643
|
+
marginBottom: "1rem",
|
|
2644
|
+
lineHeight: "1.5"
|
|
2645
|
+
},
|
|
2646
|
+
spinner: {
|
|
2647
|
+
display: "inline-block",
|
|
2648
|
+
width: "20px",
|
|
2649
|
+
height: "20px",
|
|
2650
|
+
border: "2px solid #e5e7eb",
|
|
2651
|
+
borderTop: "2px solid #3b82f6",
|
|
2652
|
+
borderRadius: "50%",
|
|
2653
|
+
animation: "spin 1s linear infinite",
|
|
2654
|
+
marginRight: "0.5rem"
|
|
2655
|
+
},
|
|
2656
|
+
buttonContainer: {
|
|
2657
|
+
display: "flex",
|
|
2658
|
+
gap: "0.75rem",
|
|
2659
|
+
justifyContent: "center",
|
|
2660
|
+
flexWrap: "wrap",
|
|
2661
|
+
marginTop: "1rem"
|
|
2662
|
+
},
|
|
2663
|
+
retryButton: {
|
|
2664
|
+
padding: "0.75rem 1rem",
|
|
2665
|
+
backgroundColor: "#3b82f6",
|
|
2666
|
+
color: "white",
|
|
2667
|
+
border: "none",
|
|
2668
|
+
borderRadius: "6px",
|
|
2669
|
+
fontSize: "1rem",
|
|
2670
|
+
fontWeight: "500",
|
|
2671
|
+
cursor: "pointer",
|
|
2672
|
+
transition: "background-color 0.15s ease-in-out"
|
|
2673
|
+
},
|
|
2674
|
+
backButton: {
|
|
2675
|
+
padding: "0.75rem 1rem",
|
|
2676
|
+
backgroundColor: "#f3f4f6",
|
|
2677
|
+
color: "#374151",
|
|
2678
|
+
border: "1px solid #d1d5db",
|
|
2679
|
+
borderRadius: "6px",
|
|
2680
|
+
fontSize: "1rem",
|
|
2681
|
+
fontWeight: "500",
|
|
2682
|
+
cursor: "pointer",
|
|
2683
|
+
transition: "all 0.15s ease-in-out"
|
|
2684
|
+
}
|
|
2685
|
+
}, tt = () => /* @__PURE__ */ n("div", { style: Ae.spinner }), rt = () => /* @__PURE__ */ l(
|
|
2686
|
+
"svg",
|
|
2687
|
+
{
|
|
2688
|
+
width: "48",
|
|
2689
|
+
height: "48",
|
|
2690
|
+
viewBox: "0 0 24 24",
|
|
2691
|
+
fill: "none",
|
|
2692
|
+
stroke: "#059669",
|
|
2693
|
+
strokeWidth: "2",
|
|
2694
|
+
strokeLinecap: "round",
|
|
2695
|
+
strokeLinejoin: "round",
|
|
2696
|
+
style: { margin: "0 auto 1rem auto", display: "block" },
|
|
2697
|
+
children: [
|
|
2698
|
+
/* @__PURE__ */ n("path", { d: "M22 11.08V12a10 10 0 1 1-5.93-9.14" }),
|
|
2699
|
+
/* @__PURE__ */ n("polyline", { points: "22,4 12,14.01 9,11.01" })
|
|
2700
|
+
]
|
|
2701
|
+
}
|
|
2702
|
+
), nt = () => /* @__PURE__ */ l(
|
|
2703
|
+
"svg",
|
|
2704
|
+
{
|
|
2705
|
+
width: "48",
|
|
2706
|
+
height: "48",
|
|
2707
|
+
viewBox: "0 0 24 24",
|
|
2708
|
+
fill: "none",
|
|
2709
|
+
stroke: "#ef4444",
|
|
2710
|
+
strokeWidth: "2",
|
|
2711
|
+
strokeLinecap: "round",
|
|
2712
|
+
strokeLinejoin: "round",
|
|
2713
|
+
style: { margin: "0 auto 1rem auto", display: "block" },
|
|
2714
|
+
children: [
|
|
2715
|
+
/* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "10" }),
|
|
2716
|
+
/* @__PURE__ */ n("line", { x1: "15", y1: "9", x2: "9", y2: "15" }),
|
|
2717
|
+
/* @__PURE__ */ n("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
|
|
2718
|
+
]
|
|
2719
|
+
}
|
|
2720
|
+
), st = {
|
|
2721
|
+
loading: /* @__PURE__ */ n(tt, {}),
|
|
2722
|
+
success: /* @__PURE__ */ n(rt, {}),
|
|
2723
|
+
error: /* @__PURE__ */ n(nt, {})
|
|
2724
|
+
};
|
|
2725
|
+
function Lt({
|
|
2726
|
+
copy: i = {},
|
|
2727
|
+
styles: e = {},
|
|
2728
|
+
icons: t = {},
|
|
2729
|
+
onSuccess: r,
|
|
2730
|
+
onError: s,
|
|
2731
|
+
onRetry: a,
|
|
2732
|
+
onBackToLogin: b,
|
|
2733
|
+
className: E,
|
|
2734
|
+
token: L,
|
|
2735
|
+
email: P,
|
|
2736
|
+
appId: f,
|
|
2737
|
+
tenantId: m,
|
|
2738
|
+
autoRedirectDelay: M = 3e3
|
|
2739
|
+
}) {
|
|
2740
|
+
const [w, v] = p("verifying"), [I, g] = p(""), { verifyMagicLink: U } = ie(), u = { ...et, ...i }, y = { ...Ae, ...e }, x = { ...st, ...t }, F = () => {
|
|
2741
|
+
if (typeof window > "u") return {};
|
|
2742
|
+
const c = new URLSearchParams(window.location.search);
|
|
2743
|
+
return {
|
|
2744
|
+
token: L || c.get("token") || "",
|
|
2745
|
+
email: P || c.get("email") || "",
|
|
2746
|
+
appId: f || c.get("appId") || "",
|
|
2747
|
+
tenantId: m || c.get("tenantId") || void 0
|
|
2748
|
+
};
|
|
2749
|
+
}, B = async () => {
|
|
2750
|
+
v("verifying"), g("");
|
|
2751
|
+
try {
|
|
2752
|
+
const c = F();
|
|
2753
|
+
if (!c.token || !c.email || !c.appId)
|
|
2754
|
+
throw new Error("Missing required parameters: token, email, or appId");
|
|
2755
|
+
const h = await U(
|
|
2756
|
+
c.token,
|
|
2757
|
+
c.email,
|
|
2758
|
+
c.appId,
|
|
2759
|
+
c.tenantId
|
|
2760
|
+
);
|
|
2761
|
+
v("success"), r == null || r(h), M > 0 && setTimeout(() => {
|
|
2762
|
+
v("redirecting");
|
|
2763
|
+
}, M);
|
|
2764
|
+
} catch (c) {
|
|
2765
|
+
const h = c.message || u.errorMessage;
|
|
2766
|
+
g(h), v("error"), s == null || s(h);
|
|
2767
|
+
}
|
|
2768
|
+
}, z = () => {
|
|
2769
|
+
a == null || a(), B();
|
|
2770
|
+
}, q = () => {
|
|
2771
|
+
b == null || b();
|
|
2772
|
+
};
|
|
2773
|
+
Z(() => {
|
|
2774
|
+
B();
|
|
2775
|
+
}, []);
|
|
2776
|
+
const S = () => {
|
|
2777
|
+
switch (w) {
|
|
2778
|
+
case "verifying":
|
|
2779
|
+
return /* @__PURE__ */ l("div", { style: y.message, children: [
|
|
2780
|
+
x.loading,
|
|
2781
|
+
u.verifyingMessage
|
|
2782
|
+
] });
|
|
2783
|
+
case "success":
|
|
2784
|
+
return /* @__PURE__ */ l(D, { children: [
|
|
2785
|
+
x.success,
|
|
2786
|
+
/* @__PURE__ */ n("div", { style: y.successMessage, children: u.successMessage })
|
|
2787
|
+
] });
|
|
2788
|
+
case "redirecting":
|
|
2789
|
+
return /* @__PURE__ */ l(D, { children: [
|
|
2790
|
+
x.loading,
|
|
2791
|
+
/* @__PURE__ */ n("div", { style: y.message, children: u.redirectingMessage })
|
|
2792
|
+
] });
|
|
2793
|
+
case "error":
|
|
2794
|
+
return /* @__PURE__ */ l(D, { children: [
|
|
2795
|
+
x.error,
|
|
2796
|
+
/* @__PURE__ */ n("div", { style: y.errorMessage, children: I || u.errorMessage }),
|
|
2797
|
+
/* @__PURE__ */ l("div", { style: y.buttonContainer, children: [
|
|
2798
|
+
/* @__PURE__ */ n(
|
|
2799
|
+
"button",
|
|
2800
|
+
{
|
|
2801
|
+
onClick: z,
|
|
2802
|
+
style: y.retryButton,
|
|
2803
|
+
onMouseOver: (c) => {
|
|
2804
|
+
c.currentTarget.style.backgroundColor = "#2563eb";
|
|
2805
|
+
},
|
|
2806
|
+
onMouseOut: (c) => {
|
|
2807
|
+
c.currentTarget.style.backgroundColor = "#3b82f6";
|
|
2808
|
+
},
|
|
2809
|
+
children: u.retryButton
|
|
2810
|
+
}
|
|
2811
|
+
),
|
|
2812
|
+
/* @__PURE__ */ n(
|
|
2813
|
+
"button",
|
|
2814
|
+
{
|
|
2815
|
+
onClick: q,
|
|
2816
|
+
style: y.backButton,
|
|
2817
|
+
onMouseOver: (c) => {
|
|
2818
|
+
c.currentTarget.style.backgroundColor = "#e5e7eb";
|
|
2819
|
+
},
|
|
2820
|
+
onMouseOut: (c) => {
|
|
2821
|
+
c.currentTarget.style.backgroundColor = "#f3f4f6";
|
|
2822
|
+
},
|
|
2823
|
+
children: u.backToLoginButton
|
|
2824
|
+
}
|
|
2825
|
+
)
|
|
2826
|
+
] })
|
|
2827
|
+
] });
|
|
2828
|
+
default:
|
|
2829
|
+
return null;
|
|
2830
|
+
}
|
|
2831
|
+
};
|
|
2832
|
+
return /* @__PURE__ */ l("div", { style: y.container, className: E, children: [
|
|
2833
|
+
/* @__PURE__ */ n("style", { children: `
|
|
2834
|
+
@keyframes spin {
|
|
2835
|
+
0% { transform: rotate(0deg); }
|
|
2836
|
+
100% { transform: rotate(360deg); }
|
|
2837
|
+
}
|
|
2838
|
+
` }),
|
|
2839
|
+
/* @__PURE__ */ n("h1", { style: y.title, children: u.title }),
|
|
2840
|
+
S()
|
|
2841
|
+
] });
|
|
2842
|
+
}
|
|
2843
|
+
const it = {
|
|
2146
2844
|
title: "Reset Password",
|
|
2147
2845
|
subtitle: "Enter your email address and we'll send you a link to reset your password.",
|
|
2148
2846
|
emailLabel: "Email",
|
|
@@ -2164,7 +2862,7 @@ const We = {
|
|
|
2164
2862
|
resetLoadingText: "Resetting...",
|
|
2165
2863
|
resetSuccessMessage: "Password reset successfully!",
|
|
2166
2864
|
passwordMismatchError: "Passwords do not match"
|
|
2167
|
-
},
|
|
2865
|
+
}, ot = {
|
|
2168
2866
|
container: {
|
|
2169
2867
|
maxWidth: "400px",
|
|
2170
2868
|
margin: "0 auto",
|
|
@@ -2256,186 +2954,186 @@ const We = {
|
|
|
2256
2954
|
cursor: "pointer"
|
|
2257
2955
|
}
|
|
2258
2956
|
};
|
|
2259
|
-
function
|
|
2957
|
+
function Rt({
|
|
2260
2958
|
copy: i = {},
|
|
2261
2959
|
styles: e = {},
|
|
2262
2960
|
mode: t = "request",
|
|
2263
2961
|
token: r = "",
|
|
2264
|
-
onSuccess:
|
|
2265
|
-
onError:
|
|
2266
|
-
onBackToLogin:
|
|
2267
|
-
onModeChange:
|
|
2268
|
-
className:
|
|
2962
|
+
onSuccess: s,
|
|
2963
|
+
onError: a,
|
|
2964
|
+
onBackToLogin: b,
|
|
2965
|
+
onModeChange: E,
|
|
2966
|
+
className: L
|
|
2269
2967
|
}) {
|
|
2270
|
-
const [P,
|
|
2271
|
-
const
|
|
2272
|
-
return P.trim() || (
|
|
2273
|
-
},
|
|
2274
|
-
const
|
|
2275
|
-
return
|
|
2276
|
-
},
|
|
2277
|
-
if (
|
|
2278
|
-
if (!(
|
|
2279
|
-
|
|
2968
|
+
const [P, f] = p(""), [m, M] = p(r), [w, v] = p(""), [I, g] = p(""), [U, u] = p(!1), [y, x] = p(""), [F, B] = p(""), [z, q] = p({}), { requestPasswordReset: S, confirmPasswordReset: c } = ie(), { tenant: h } = re(), o = { ...it, ...i }, d = { ...ot, ...e }, G = () => {
|
|
2969
|
+
const O = {};
|
|
2970
|
+
return P.trim() || (O.email = !0), q(O), Object.keys(O).length === 0;
|
|
2971
|
+
}, Y = () => {
|
|
2972
|
+
const O = {};
|
|
2973
|
+
return m.trim() || (O.token = !0), w.trim() || (O.newPassword = !0), I.trim() || (O.confirmPassword = !0), q(O), Object.keys(O).length === 0;
|
|
2974
|
+
}, H = async (O) => {
|
|
2975
|
+
if (O.preventDefault(), !!G()) {
|
|
2976
|
+
if (!(h != null && h.id)) {
|
|
2977
|
+
x("Tenant not found");
|
|
2280
2978
|
return;
|
|
2281
2979
|
}
|
|
2282
|
-
|
|
2980
|
+
u(!0), x(""), B("");
|
|
2283
2981
|
try {
|
|
2284
|
-
await
|
|
2285
|
-
} catch (
|
|
2286
|
-
const
|
|
2287
|
-
|
|
2982
|
+
await S(P, h.id), B(o.successMessage), s == null || s();
|
|
2983
|
+
} catch (j) {
|
|
2984
|
+
const N = j.message || o.errorMessage;
|
|
2985
|
+
x(N), a == null || a(N);
|
|
2288
2986
|
} finally {
|
|
2289
|
-
|
|
2987
|
+
u(!1);
|
|
2290
2988
|
}
|
|
2291
2989
|
}
|
|
2292
|
-
},
|
|
2293
|
-
if (
|
|
2294
|
-
if (
|
|
2295
|
-
|
|
2990
|
+
}, C = async (O) => {
|
|
2991
|
+
if (O.preventDefault(), !!Y()) {
|
|
2992
|
+
if (w !== I) {
|
|
2993
|
+
x(o.passwordMismatchError), q({ confirmPassword: !0 });
|
|
2296
2994
|
return;
|
|
2297
2995
|
}
|
|
2298
|
-
|
|
2996
|
+
u(!0), x(""), B("");
|
|
2299
2997
|
try {
|
|
2300
|
-
await
|
|
2301
|
-
} catch (
|
|
2302
|
-
const
|
|
2303
|
-
|
|
2998
|
+
await c(m, w), B(o.resetSuccessMessage), s == null || s();
|
|
2999
|
+
} catch (j) {
|
|
3000
|
+
const N = j.message || o.errorMessage;
|
|
3001
|
+
x(N), a == null || a(N);
|
|
2304
3002
|
} finally {
|
|
2305
|
-
|
|
3003
|
+
u(!1);
|
|
2306
3004
|
}
|
|
2307
3005
|
}
|
|
2308
|
-
},
|
|
2309
|
-
...
|
|
2310
|
-
...
|
|
2311
|
-
}),
|
|
2312
|
-
...
|
|
2313
|
-
...
|
|
3006
|
+
}, k = (O) => ({
|
|
3007
|
+
...d.input,
|
|
3008
|
+
...z[O] ? d.inputError : {}
|
|
3009
|
+
}), T = () => ({
|
|
3010
|
+
...d.button,
|
|
3011
|
+
...U ? d.buttonLoading : {}
|
|
2314
3012
|
});
|
|
2315
3013
|
if (t === "reset") {
|
|
2316
|
-
const
|
|
2317
|
-
return /* @__PURE__ */
|
|
2318
|
-
/* @__PURE__ */
|
|
2319
|
-
/* @__PURE__ */
|
|
2320
|
-
/* @__PURE__ */
|
|
2321
|
-
/* @__PURE__ */
|
|
2322
|
-
/* @__PURE__ */
|
|
2323
|
-
/* @__PURE__ */
|
|
3014
|
+
const O = m && w && I;
|
|
3015
|
+
return /* @__PURE__ */ l("div", { className: L, style: d.container, children: [
|
|
3016
|
+
/* @__PURE__ */ n("h2", { style: d.title, children: o.resetTitle }),
|
|
3017
|
+
/* @__PURE__ */ n("p", { style: d.subtitle, children: o.resetSubtitle }),
|
|
3018
|
+
/* @__PURE__ */ l("form", { onSubmit: C, style: d.form, children: [
|
|
3019
|
+
/* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
|
|
3020
|
+
/* @__PURE__ */ n("label", { style: d.label, children: o.tokenLabel }),
|
|
3021
|
+
/* @__PURE__ */ n(
|
|
2324
3022
|
"input",
|
|
2325
3023
|
{
|
|
2326
3024
|
type: "text",
|
|
2327
|
-
value:
|
|
2328
|
-
onChange: (
|
|
2329
|
-
|
|
3025
|
+
value: m,
|
|
3026
|
+
onChange: (j) => {
|
|
3027
|
+
M(j.target.value), z.token && q((N) => ({ ...N, token: !1 }));
|
|
2330
3028
|
},
|
|
2331
|
-
placeholder:
|
|
2332
|
-
style:
|
|
2333
|
-
disabled:
|
|
3029
|
+
placeholder: o.tokenPlaceholder,
|
|
3030
|
+
style: k("token"),
|
|
3031
|
+
disabled: U
|
|
2334
3032
|
}
|
|
2335
3033
|
)
|
|
2336
3034
|
] }),
|
|
2337
|
-
/* @__PURE__ */
|
|
2338
|
-
/* @__PURE__ */
|
|
2339
|
-
/* @__PURE__ */
|
|
3035
|
+
/* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
|
|
3036
|
+
/* @__PURE__ */ n("label", { style: d.label, children: o.newPasswordLabel }),
|
|
3037
|
+
/* @__PURE__ */ n(
|
|
2340
3038
|
"input",
|
|
2341
3039
|
{
|
|
2342
3040
|
type: "password",
|
|
2343
|
-
value:
|
|
2344
|
-
onChange: (
|
|
2345
|
-
|
|
3041
|
+
value: w,
|
|
3042
|
+
onChange: (j) => {
|
|
3043
|
+
v(j.target.value), z.newPassword && q((N) => ({ ...N, newPassword: !1 }));
|
|
2346
3044
|
},
|
|
2347
|
-
placeholder:
|
|
2348
|
-
style:
|
|
2349
|
-
disabled:
|
|
3045
|
+
placeholder: o.newPasswordPlaceholder,
|
|
3046
|
+
style: k("newPassword"),
|
|
3047
|
+
disabled: U
|
|
2350
3048
|
}
|
|
2351
3049
|
)
|
|
2352
3050
|
] }),
|
|
2353
|
-
/* @__PURE__ */
|
|
2354
|
-
/* @__PURE__ */
|
|
2355
|
-
/* @__PURE__ */
|
|
3051
|
+
/* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
|
|
3052
|
+
/* @__PURE__ */ n("label", { style: d.label, children: o.confirmPasswordLabel }),
|
|
3053
|
+
/* @__PURE__ */ n(
|
|
2356
3054
|
"input",
|
|
2357
3055
|
{
|
|
2358
3056
|
type: "password",
|
|
2359
|
-
value:
|
|
2360
|
-
onChange: (
|
|
2361
|
-
|
|
3057
|
+
value: I,
|
|
3058
|
+
onChange: (j) => {
|
|
3059
|
+
g(j.target.value), z.confirmPassword && q((N) => ({ ...N, confirmPassword: !1 })), y === o.passwordMismatchError && x("");
|
|
2362
3060
|
},
|
|
2363
|
-
placeholder:
|
|
2364
|
-
style:
|
|
2365
|
-
disabled:
|
|
3061
|
+
placeholder: o.confirmPasswordPlaceholder,
|
|
3062
|
+
style: k("confirmPassword"),
|
|
3063
|
+
disabled: U
|
|
2366
3064
|
}
|
|
2367
3065
|
)
|
|
2368
3066
|
] }),
|
|
2369
|
-
/* @__PURE__ */
|
|
3067
|
+
/* @__PURE__ */ n(
|
|
2370
3068
|
"button",
|
|
2371
3069
|
{
|
|
2372
3070
|
type: "submit",
|
|
2373
|
-
disabled: !
|
|
3071
|
+
disabled: !O || U,
|
|
2374
3072
|
style: {
|
|
2375
|
-
...
|
|
2376
|
-
...!
|
|
3073
|
+
...T(),
|
|
3074
|
+
...!O || U ? d.buttonDisabled : {}
|
|
2377
3075
|
},
|
|
2378
|
-
children:
|
|
3076
|
+
children: U ? o.resetLoadingText : o.resetSubmitButton
|
|
2379
3077
|
}
|
|
2380
3078
|
),
|
|
2381
|
-
|
|
2382
|
-
|
|
3079
|
+
y && /* @__PURE__ */ n("div", { style: d.errorText, children: y }),
|
|
3080
|
+
F && /* @__PURE__ */ n("div", { style: d.successText, children: F })
|
|
2383
3081
|
] }),
|
|
2384
|
-
/* @__PURE__ */
|
|
2385
|
-
/* @__PURE__ */
|
|
2386
|
-
|
|
2387
|
-
/* @__PURE__ */
|
|
2388
|
-
/* @__PURE__ */
|
|
3082
|
+
/* @__PURE__ */ l("div", { style: d.linkContainer, children: [
|
|
3083
|
+
/* @__PURE__ */ n("a", { onClick: b, style: d.link, children: o.backToLoginLink }),
|
|
3084
|
+
E && /* @__PURE__ */ l(D, { children: [
|
|
3085
|
+
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3086
|
+
/* @__PURE__ */ n("a", { onClick: () => E("request"), style: d.link, children: "Request New Link" })
|
|
2389
3087
|
] })
|
|
2390
3088
|
] })
|
|
2391
3089
|
] });
|
|
2392
3090
|
}
|
|
2393
|
-
const
|
|
2394
|
-
return /* @__PURE__ */
|
|
2395
|
-
/* @__PURE__ */
|
|
2396
|
-
/* @__PURE__ */
|
|
2397
|
-
/* @__PURE__ */
|
|
2398
|
-
/* @__PURE__ */
|
|
2399
|
-
/* @__PURE__ */
|
|
2400
|
-
/* @__PURE__ */
|
|
3091
|
+
const J = P;
|
|
3092
|
+
return /* @__PURE__ */ l("div", { className: L, style: d.container, children: [
|
|
3093
|
+
/* @__PURE__ */ n("h2", { style: d.title, children: o.title }),
|
|
3094
|
+
/* @__PURE__ */ n("p", { style: d.subtitle, children: o.subtitle }),
|
|
3095
|
+
/* @__PURE__ */ l("form", { onSubmit: H, style: d.form, children: [
|
|
3096
|
+
/* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
|
|
3097
|
+
/* @__PURE__ */ n("label", { style: d.label, children: o.emailLabel }),
|
|
3098
|
+
/* @__PURE__ */ n(
|
|
2401
3099
|
"input",
|
|
2402
3100
|
{
|
|
2403
3101
|
type: "email",
|
|
2404
3102
|
value: P,
|
|
2405
|
-
onChange: (
|
|
2406
|
-
|
|
3103
|
+
onChange: (O) => {
|
|
3104
|
+
f(O.target.value), z.email && q((j) => ({ ...j, email: !1 }));
|
|
2407
3105
|
},
|
|
2408
|
-
placeholder:
|
|
2409
|
-
style:
|
|
2410
|
-
disabled:
|
|
3106
|
+
placeholder: o.emailPlaceholder,
|
|
3107
|
+
style: k("email"),
|
|
3108
|
+
disabled: U
|
|
2411
3109
|
}
|
|
2412
3110
|
)
|
|
2413
3111
|
] }),
|
|
2414
|
-
/* @__PURE__ */
|
|
3112
|
+
/* @__PURE__ */ n(
|
|
2415
3113
|
"button",
|
|
2416
3114
|
{
|
|
2417
3115
|
type: "submit",
|
|
2418
|
-
disabled: !
|
|
3116
|
+
disabled: !J || U,
|
|
2419
3117
|
style: {
|
|
2420
|
-
...
|
|
2421
|
-
...!
|
|
3118
|
+
...T(),
|
|
3119
|
+
...!J || U ? d.buttonDisabled : {}
|
|
2422
3120
|
},
|
|
2423
|
-
children:
|
|
3121
|
+
children: U ? o.loadingText : o.submitButton
|
|
2424
3122
|
}
|
|
2425
3123
|
),
|
|
2426
|
-
|
|
2427
|
-
|
|
3124
|
+
y && /* @__PURE__ */ n("div", { style: d.errorText, children: y }),
|
|
3125
|
+
F && /* @__PURE__ */ n("div", { style: d.successText, children: F })
|
|
2428
3126
|
] }),
|
|
2429
|
-
/* @__PURE__ */
|
|
2430
|
-
/* @__PURE__ */
|
|
2431
|
-
|
|
2432
|
-
/* @__PURE__ */
|
|
2433
|
-
/* @__PURE__ */
|
|
3127
|
+
/* @__PURE__ */ l("div", { style: d.linkContainer, children: [
|
|
3128
|
+
/* @__PURE__ */ n("a", { onClick: b, style: d.link, children: o.backToLoginLink }),
|
|
3129
|
+
E && /* @__PURE__ */ l(D, { children: [
|
|
3130
|
+
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3131
|
+
/* @__PURE__ */ n("a", { onClick: () => E("reset"), style: d.link, children: "I have a token" })
|
|
2434
3132
|
] })
|
|
2435
3133
|
] })
|
|
2436
3134
|
] });
|
|
2437
3135
|
}
|
|
2438
|
-
class
|
|
3136
|
+
class Ct {
|
|
2439
3137
|
constructor(e, t) {
|
|
2440
3138
|
this.httpService = e, this.sessionManager = t;
|
|
2441
3139
|
}
|
|
@@ -2456,12 +3154,12 @@ class yt {
|
|
|
2456
3154
|
throw new Error("SessionManager is required for private endpoints");
|
|
2457
3155
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
2458
3156
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
2459
|
-
const
|
|
3157
|
+
const s = `/permissions/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
|
|
2460
3158
|
headers: t
|
|
2461
3159
|
});
|
|
2462
3160
|
return {
|
|
2463
|
-
permissions:
|
|
2464
|
-
meta:
|
|
3161
|
+
permissions: a.data,
|
|
3162
|
+
meta: a.meta
|
|
2465
3163
|
};
|
|
2466
3164
|
}
|
|
2467
3165
|
async getPermissionById(e) {
|
|
@@ -2496,14 +3194,14 @@ class yt {
|
|
|
2496
3194
|
async getAppPermissions(e, t) {
|
|
2497
3195
|
const r = new URLSearchParams();
|
|
2498
3196
|
t != null && t.page && r.append("page", t.page.toString()), t != null && t.limit && r.append("limit", t.limit.toString()), t != null && t.sortBy && r.append("sortBy", t.sortBy), t != null && t.sortOrder && r.append("sortOrder", t.sortOrder);
|
|
2499
|
-
const
|
|
3197
|
+
const s = `/permissions/apps/${e}${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s);
|
|
2500
3198
|
return {
|
|
2501
|
-
permissions:
|
|
2502
|
-
meta:
|
|
3199
|
+
permissions: a.data,
|
|
3200
|
+
meta: a.meta
|
|
2503
3201
|
};
|
|
2504
3202
|
}
|
|
2505
3203
|
}
|
|
2506
|
-
class
|
|
3204
|
+
class It {
|
|
2507
3205
|
constructor(e, t) {
|
|
2508
3206
|
this.httpService = e, this.sessionManager = t;
|
|
2509
3207
|
}
|
|
@@ -2520,12 +3218,12 @@ class wt {
|
|
|
2520
3218
|
async getSubscriptionPlans(e) {
|
|
2521
3219
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
2522
3220
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder), e != null && e.appId && r.append("appId", e.appId);
|
|
2523
|
-
const
|
|
3221
|
+
const s = `/subscription-plans/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
|
|
2524
3222
|
headers: t
|
|
2525
3223
|
});
|
|
2526
3224
|
return {
|
|
2527
|
-
plans:
|
|
2528
|
-
meta:
|
|
3225
|
+
plans: a.data,
|
|
3226
|
+
meta: a.meta
|
|
2529
3227
|
};
|
|
2530
3228
|
}
|
|
2531
3229
|
async getSubscriptionPlanById(e) {
|
|
@@ -2554,7 +3252,7 @@ class wt {
|
|
|
2554
3252
|
});
|
|
2555
3253
|
}
|
|
2556
3254
|
}
|
|
2557
|
-
class
|
|
3255
|
+
class Ft {
|
|
2558
3256
|
constructor(e) {
|
|
2559
3257
|
this.httpService = e;
|
|
2560
3258
|
}
|
|
@@ -2563,7 +3261,7 @@ class mt {
|
|
|
2563
3261
|
return await this.httpService.get("/health");
|
|
2564
3262
|
}
|
|
2565
3263
|
}
|
|
2566
|
-
class
|
|
3264
|
+
class Ht {
|
|
2567
3265
|
// Date string to Date object
|
|
2568
3266
|
static toDate(e) {
|
|
2569
3267
|
return new Date(e);
|
|
@@ -2589,7 +3287,7 @@ class bt {
|
|
|
2589
3287
|
...e,
|
|
2590
3288
|
createdAt: this.toDate(e.createdAt),
|
|
2591
3289
|
updatedAt: this.toDate(e.updatedAt),
|
|
2592
|
-
displayName: e.name,
|
|
3290
|
+
displayName: e.lastName ? `${e.name} ${e.lastName}` : e.name,
|
|
2593
3291
|
isActiveUser: e.isActive
|
|
2594
3292
|
};
|
|
2595
3293
|
}
|
|
@@ -2680,48 +3378,50 @@ class bt {
|
|
|
2680
3378
|
// Transform query parameters for API calls
|
|
2681
3379
|
static transformQueryParams(e) {
|
|
2682
3380
|
const t = new URLSearchParams();
|
|
2683
|
-
return Object.entries(e).forEach(([r,
|
|
2684
|
-
|
|
3381
|
+
return Object.entries(e).forEach(([r, s]) => {
|
|
3382
|
+
s != null && s !== "" && t.append(r, String(s));
|
|
2685
3383
|
}), t;
|
|
2686
3384
|
}
|
|
2687
3385
|
}
|
|
2688
3386
|
export {
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
3387
|
+
Ht as ApiMappers,
|
|
3388
|
+
Te as AppApiService,
|
|
3389
|
+
ht as AppProvider,
|
|
3390
|
+
Re as AuthApiService,
|
|
3391
|
+
yt as AuthProvider,
|
|
3392
|
+
Pt as FeatureFlag,
|
|
3393
|
+
He as FeatureFlagApiService,
|
|
3394
|
+
bt as FeatureFlagProvider,
|
|
3395
|
+
Ft as HealthApiService,
|
|
3396
|
+
te as HttpService,
|
|
3397
|
+
kt as LandingRoute,
|
|
3398
|
+
Tt as LoginForm,
|
|
3399
|
+
Et as MagicLinkForm,
|
|
3400
|
+
Lt as MagicLinkVerify,
|
|
3401
|
+
Rt as PasswordRecoveryForm,
|
|
3402
|
+
Ct as PermissionApiService,
|
|
3403
|
+
vt as Protected,
|
|
3404
|
+
St as ProtectedRoute,
|
|
3405
|
+
pe as RoleApiService,
|
|
3406
|
+
Le as SessionManager,
|
|
3407
|
+
Mt as SignupForm,
|
|
3408
|
+
De as SubscriptionApiService,
|
|
3409
|
+
At as SubscriptionGuard,
|
|
3410
|
+
It as SubscriptionPlanApiService,
|
|
3411
|
+
wt as SubscriptionProvider,
|
|
3412
|
+
fe as TenantApiService,
|
|
3413
|
+
pt as TenantProvider,
|
|
3414
|
+
xt as TenantRoute,
|
|
3415
|
+
Ce as UserApiService,
|
|
3416
|
+
se as UserType,
|
|
3417
|
+
gt as useApi,
|
|
3418
|
+
ne as useApp,
|
|
3419
|
+
ie as useAuth,
|
|
3420
|
+
$e as useFeatureFlags,
|
|
3421
|
+
mt as useSettings,
|
|
3422
|
+
Be as useSubscription,
|
|
3423
|
+
ge as useTenant,
|
|
3424
|
+
re as useTenantInfo,
|
|
3425
|
+
ft as useTenantSettings
|
|
2726
3426
|
};
|
|
2727
3427
|
//# sourceMappingURL=index.es.js.map
|