@skylabs-digital/react-identity-access 1.0.0 → 1.2.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/CHANGELOG.md +32 -0
- package/README.md +8 -8
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +971 -946
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/providers/AppProvider.d.ts +1 -17
- package/dist/providers/AppProvider.d.ts.map +1 -1
- package/dist/providers/AuthProvider.d.ts.map +1 -1
- package/dist/providers/FeatureFlagProvider.d.ts.map +1 -1
- package/dist/providers/SubscriptionProvider.d.ts.map +1 -1
- package/dist/providers/TenantProvider.d.ts +25 -5
- package/dist/providers/TenantProvider.d.ts.map +1 -1
- package/package.json +5 -2
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 B, jsxs as u } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as ee, useState as m, useMemo as O, useCallback as X, useEffect as K, useContext as te } from "react";
|
|
3
|
+
import { useLocation as me, Navigate as ae } from "react-router";
|
|
4
|
+
class G {
|
|
5
5
|
// SessionManager instance
|
|
6
6
|
constructor(e, t = 1e4) {
|
|
7
7
|
this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
|
|
@@ -15,41 +15,41 @@ class W {
|
|
|
15
15
|
async request(e, t, r, s) {
|
|
16
16
|
return this.executeRequest(e, t, r, s, !1);
|
|
17
17
|
}
|
|
18
|
-
async executeRequest(e, t, r, s,
|
|
19
|
-
const
|
|
20
|
-
let
|
|
18
|
+
async executeRequest(e, t, r, s, a = !1) {
|
|
19
|
+
const v = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, M = (s == null ? void 0 : s.timeout) || this.timeout;
|
|
20
|
+
let k = {
|
|
21
21
|
"Content-Type": "application/json",
|
|
22
22
|
...s == null ? void 0 : s.headers
|
|
23
23
|
};
|
|
24
24
|
if (!(s != null && s.skipAuth) && this.sessionManager)
|
|
25
25
|
try {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
} catch (
|
|
29
|
-
console.warn("Failed to inject auth headers:",
|
|
26
|
+
const g = await this.sessionManager.getAuthHeaders();
|
|
27
|
+
k = { ...k, ...g };
|
|
28
|
+
} catch (g) {
|
|
29
|
+
console.warn("Failed to inject auth headers:", g);
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const P = new AbortController(), h = setTimeout(() => P.abort(), M);
|
|
32
32
|
try {
|
|
33
|
-
const
|
|
33
|
+
const g = await fetch(v, {
|
|
34
34
|
method: e,
|
|
35
|
-
headers:
|
|
35
|
+
headers: k,
|
|
36
36
|
body: r ? JSON.stringify(r) : void 0,
|
|
37
|
-
signal:
|
|
37
|
+
signal: P.signal
|
|
38
38
|
});
|
|
39
|
-
if (clearTimeout(
|
|
39
|
+
if (clearTimeout(h), g.status === 401 && !(s != null && s.skipRetry) && !a && this.sessionManager)
|
|
40
40
|
try {
|
|
41
41
|
const f = this.sessionManager.getTokens();
|
|
42
42
|
if (f != null && f.refreshToken)
|
|
43
43
|
return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, r, s, !0);
|
|
44
44
|
} catch {
|
|
45
|
-
throw new Error(`HTTP ${
|
|
45
|
+
throw new Error(`HTTP ${g.status}: ${g.statusText}`);
|
|
46
46
|
}
|
|
47
|
-
if (!
|
|
48
|
-
throw new Error(`HTTP ${
|
|
49
|
-
const
|
|
50
|
-
return !
|
|
51
|
-
} catch (
|
|
52
|
-
throw clearTimeout(
|
|
47
|
+
if (!g.ok)
|
|
48
|
+
throw new Error(`HTTP ${g.status}: ${g.statusText}`);
|
|
49
|
+
const x = g.headers.get("content-type");
|
|
50
|
+
return !x || !x.includes("application/json") ? {} : await g.json();
|
|
51
|
+
} catch (g) {
|
|
52
|
+
throw clearTimeout(h), g instanceof Error && g.name === "AbortError" ? new Error(`Request timeout after ${M}ms`) : g;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
async get(e, t) {
|
|
@@ -65,85 +65,7 @@ class W {
|
|
|
65
65
|
return this.request("DELETE", e, void 0, t);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
class
|
|
69
|
-
constructor(e, t, r) {
|
|
70
|
-
this.httpService = e, this.appId = t, this.sessionManager = r;
|
|
71
|
-
}
|
|
72
|
-
async createTenant(e) {
|
|
73
|
-
if (!this.sessionManager)
|
|
74
|
-
throw new Error("SessionManager is required for private endpoints");
|
|
75
|
-
const t = await this.sessionManager.getAuthHeaders();
|
|
76
|
-
return (await this.httpService.post("/tenants/", e, {
|
|
77
|
-
headers: t
|
|
78
|
-
})).data;
|
|
79
|
-
}
|
|
80
|
-
async getTenants(e) {
|
|
81
|
-
if (!this.sessionManager)
|
|
82
|
-
throw new Error("SessionManager is required for private endpoints");
|
|
83
|
-
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
84
|
-
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);
|
|
85
|
-
const s = `/tenants/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
|
|
86
|
-
headers: t
|
|
87
|
-
});
|
|
88
|
-
return {
|
|
89
|
-
tenants: o.data,
|
|
90
|
-
meta: o.meta
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
async getTenantById(e) {
|
|
94
|
-
if (!this.sessionManager)
|
|
95
|
-
throw new Error("SessionManager is required for private endpoints");
|
|
96
|
-
const t = await this.sessionManager.getAuthHeaders();
|
|
97
|
-
return (await this.httpService.get(`/tenants/${e}`, {
|
|
98
|
-
headers: t
|
|
99
|
-
})).data;
|
|
100
|
-
}
|
|
101
|
-
async updateTenant(e, t) {
|
|
102
|
-
if (!this.sessionManager)
|
|
103
|
-
throw new Error("SessionManager is required for private endpoints");
|
|
104
|
-
const r = await this.sessionManager.getAuthHeaders();
|
|
105
|
-
return (await this.httpService.put(`/tenants/${e}`, t, {
|
|
106
|
-
headers: r
|
|
107
|
-
})).data;
|
|
108
|
-
}
|
|
109
|
-
async adminUpdateTenant(e, t) {
|
|
110
|
-
if (!this.sessionManager)
|
|
111
|
-
throw new Error("SessionManager is required for private endpoints");
|
|
112
|
-
const r = await this.sessionManager.getAuthHeaders();
|
|
113
|
-
return (await this.httpService.put(
|
|
114
|
-
`/tenants/${e}/admin-update`,
|
|
115
|
-
t,
|
|
116
|
-
{
|
|
117
|
-
headers: r
|
|
118
|
-
}
|
|
119
|
-
)).data;
|
|
120
|
-
}
|
|
121
|
-
// Public endpoint - no auth required
|
|
122
|
-
async getPublicTenantInfo(e) {
|
|
123
|
-
return (await this.httpService.get(
|
|
124
|
-
`/tenants/${this.appId}/${e}/public`
|
|
125
|
-
)).data;
|
|
126
|
-
}
|
|
127
|
-
// Settings endpoints
|
|
128
|
-
async getTenantSettings(e) {
|
|
129
|
-
return (await this.httpService.get(
|
|
130
|
-
`/tenants/${e}/settings`
|
|
131
|
-
)).data;
|
|
132
|
-
}
|
|
133
|
-
async updateTenantSettings(e, t) {
|
|
134
|
-
if (!this.sessionManager)
|
|
135
|
-
throw new Error("SessionManager is required for private endpoints");
|
|
136
|
-
const r = await this.sessionManager.getAuthHeaders();
|
|
137
|
-
return (await this.httpService.put(
|
|
138
|
-
`/tenants/${e}/settings`,
|
|
139
|
-
t,
|
|
140
|
-
{
|
|
141
|
-
headers: r
|
|
142
|
-
}
|
|
143
|
-
)).data;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
class ye {
|
|
68
|
+
class be {
|
|
147
69
|
constructor(e, t) {
|
|
148
70
|
this.httpService = e, this.sessionManager = t;
|
|
149
71
|
}
|
|
@@ -156,12 +78,12 @@ class ye {
|
|
|
156
78
|
async getApps(e) {
|
|
157
79
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
158
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);
|
|
159
|
-
const s = `/apps/${r.toString() ? `?${r.toString()}` : ""}`,
|
|
81
|
+
const s = `/apps/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
|
|
160
82
|
headers: t
|
|
161
83
|
});
|
|
162
84
|
return {
|
|
163
|
-
apps:
|
|
164
|
-
meta:
|
|
85
|
+
apps: a.data,
|
|
86
|
+
meta: a.meta
|
|
165
87
|
};
|
|
166
88
|
}
|
|
167
89
|
async getAppById(e) {
|
|
@@ -202,7 +124,7 @@ class ye {
|
|
|
202
124
|
})).data;
|
|
203
125
|
}
|
|
204
126
|
}
|
|
205
|
-
const
|
|
127
|
+
const ge = ee(null), Se = () => /* @__PURE__ */ n(
|
|
206
128
|
"div",
|
|
207
129
|
{
|
|
208
130
|
style: {
|
|
@@ -212,9 +134,9 @@ const ue = te(null), me = () => /* @__PURE__ */ i(
|
|
|
212
134
|
height: "100vh",
|
|
213
135
|
fontFamily: "system-ui, sans-serif"
|
|
214
136
|
},
|
|
215
|
-
children: /* @__PURE__ */
|
|
137
|
+
children: /* @__PURE__ */ n("div", { children: "Loading application..." })
|
|
216
138
|
}
|
|
217
|
-
),
|
|
139
|
+
), ve = ({ error: i, retry: e }) => /* @__PURE__ */ u(
|
|
218
140
|
"div",
|
|
219
141
|
{
|
|
220
142
|
style: {
|
|
@@ -228,9 +150,9 @@ const ue = te(null), me = () => /* @__PURE__ */ i(
|
|
|
228
150
|
padding: "20px"
|
|
229
151
|
},
|
|
230
152
|
children: [
|
|
231
|
-
/* @__PURE__ */
|
|
232
|
-
/* @__PURE__ */
|
|
233
|
-
/* @__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(
|
|
234
156
|
"button",
|
|
235
157
|
{
|
|
236
158
|
onClick: e,
|
|
@@ -248,113 +170,50 @@ const ue = te(null), me = () => /* @__PURE__ */ i(
|
|
|
248
170
|
]
|
|
249
171
|
}
|
|
250
172
|
);
|
|
251
|
-
function
|
|
252
|
-
const [t, r] =
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
return n.fixedTenantSlug || null;
|
|
256
|
-
if (typeof window > "u") return null;
|
|
257
|
-
if (l === "subdomain") {
|
|
258
|
-
const k = window.location.hostname.split(".");
|
|
259
|
-
if (k.length >= 3) {
|
|
260
|
-
const F = k[0];
|
|
261
|
-
return localStorage.setItem(a, F), F;
|
|
262
|
-
}
|
|
263
|
-
return localStorage.getItem(a);
|
|
264
|
-
} else {
|
|
265
|
-
const k = new URLSearchParams(window.location.search).get(n.selectorParam || "tenant");
|
|
266
|
-
return k ? (localStorage.setItem(a, k), k) : localStorage.getItem(a);
|
|
267
|
-
}
|
|
268
|
-
}, [n.tenantMode, n.fixedTenantSlug, n.selectorParam]), c = N(() => y(), [y]), C = N(() => {
|
|
269
|
-
const l = () => {
|
|
270
|
-
c && d(c);
|
|
271
|
-
}, a = () => {
|
|
272
|
-
x();
|
|
173
|
+
function Je({ config: i, children: e }) {
|
|
174
|
+
const [t, r] = m(null), [s, a] = m(!0), [v, M] = m(null), k = O(() => {
|
|
175
|
+
const h = () => {
|
|
176
|
+
P();
|
|
273
177
|
};
|
|
274
178
|
return {
|
|
275
|
-
appId:
|
|
276
|
-
baseUrl:
|
|
277
|
-
// Tenant info
|
|
278
|
-
tenant: t,
|
|
279
|
-
tenantSlug: c,
|
|
280
|
-
isTenantLoading: s,
|
|
281
|
-
tenantError: T,
|
|
282
|
-
retryTenant: l,
|
|
179
|
+
appId: i.appId,
|
|
180
|
+
baseUrl: i.baseUrl,
|
|
283
181
|
// App info
|
|
284
|
-
appInfo:
|
|
285
|
-
isAppLoading:
|
|
182
|
+
appInfo: t,
|
|
183
|
+
isAppLoading: s,
|
|
286
184
|
appError: v,
|
|
287
|
-
retryApp:
|
|
185
|
+
retryApp: h
|
|
288
186
|
};
|
|
289
|
-
}, [
|
|
187
|
+
}, [i, t, s, v]), P = X(async () => {
|
|
290
188
|
try {
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
} catch (
|
|
295
|
-
const
|
|
296
|
-
|
|
189
|
+
a(!0), M(null);
|
|
190
|
+
const h = new G(i.baseUrl), x = await new be(h, {}).getPublicAppInfo(i.appId);
|
|
191
|
+
r(x);
|
|
192
|
+
} catch (h) {
|
|
193
|
+
const g = h instanceof Error ? h : new Error("Failed to load app information");
|
|
194
|
+
M(g), r(null);
|
|
297
195
|
} finally {
|
|
298
|
-
|
|
196
|
+
a(!1);
|
|
299
197
|
}
|
|
300
|
-
}, [
|
|
301
|
-
async (l) => {
|
|
302
|
-
try {
|
|
303
|
-
o(!0), M(null);
|
|
304
|
-
const a = new W(n.baseUrl), k = await new ne(a, n.appId).getPublicTenantInfo(l);
|
|
305
|
-
r(k);
|
|
306
|
-
} catch (a) {
|
|
307
|
-
const u = a instanceof Error ? a : new Error("Failed to load tenant information");
|
|
308
|
-
M(u), r(null);
|
|
309
|
-
} finally {
|
|
310
|
-
o(!1);
|
|
311
|
-
}
|
|
312
|
-
},
|
|
313
|
-
[n.baseUrl, n.appId]
|
|
314
|
-
);
|
|
198
|
+
}, [i.baseUrl, i.appId]);
|
|
315
199
|
if (K(() => {
|
|
316
|
-
|
|
317
|
-
}, [
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
), o(!1);
|
|
325
|
-
} else n.tenantMode === "fixed" && !n.fixedTenantSlug && (M(new Error("Fixed tenant mode requires fixedTenantSlug configuration")), o(!1));
|
|
326
|
-
}, [n.initialTenant, c, d, n.tenantMode, n.fixedTenantSlug]), s)
|
|
327
|
-
return /* @__PURE__ */ i(B, { children: n.loadingFallback || /* @__PURE__ */ i(me, {}) });
|
|
328
|
-
if (T) {
|
|
329
|
-
const l = typeof n.errorFallback == "function" ? n.errorFallback(T, () => d(c || "")) : n.errorFallback || /* @__PURE__ */ i(oe, { error: T, retry: () => d(c || "") });
|
|
330
|
-
return /* @__PURE__ */ i(B, { children: l });
|
|
331
|
-
}
|
|
332
|
-
return !t && n.tenantMode !== "fixed" ? /* @__PURE__ */ i(
|
|
333
|
-
oe,
|
|
334
|
-
{
|
|
335
|
-
error: new Error("No tenant information available"),
|
|
336
|
-
retry: () => d(c || "")
|
|
337
|
-
}
|
|
338
|
-
) : /* @__PURE__ */ i(ue.Provider, { value: C, children: e });
|
|
200
|
+
P();
|
|
201
|
+
}, [P]), s)
|
|
202
|
+
return /* @__PURE__ */ n(B, { children: i.loadingFallback || /* @__PURE__ */ n(Se, {}) });
|
|
203
|
+
if (v) {
|
|
204
|
+
const h = typeof i.errorFallback == "function" ? i.errorFallback(v, () => P()) : i.errorFallback || /* @__PURE__ */ n(ve, { error: v, retry: () => P() });
|
|
205
|
+
return /* @__PURE__ */ n(B, { children: h });
|
|
206
|
+
}
|
|
207
|
+
return /* @__PURE__ */ n(ge.Provider, { value: k, children: e });
|
|
339
208
|
}
|
|
340
|
-
function
|
|
341
|
-
const
|
|
342
|
-
if (!
|
|
209
|
+
function re() {
|
|
210
|
+
const i = te(ge);
|
|
211
|
+
if (!i)
|
|
343
212
|
throw new Error("useApp must be used within an AppProvider");
|
|
344
|
-
return
|
|
213
|
+
return i;
|
|
345
214
|
}
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
const { tenant: n, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } = G();
|
|
349
|
-
return {
|
|
350
|
-
tenant: n,
|
|
351
|
-
tenantSlug: e,
|
|
352
|
-
isLoading: t,
|
|
353
|
-
error: r,
|
|
354
|
-
retry: s
|
|
355
|
-
};
|
|
356
|
-
}
|
|
357
|
-
class be {
|
|
215
|
+
const Xe = re;
|
|
216
|
+
class xe {
|
|
358
217
|
constructor(e = {}) {
|
|
359
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 || {
|
|
360
219
|
get: () => {
|
|
@@ -471,7 +330,7 @@ class be {
|
|
|
471
330
|
return e !== null && !this.isTokenExpired(e);
|
|
472
331
|
}
|
|
473
332
|
}
|
|
474
|
-
class
|
|
333
|
+
class Ae {
|
|
475
334
|
constructor(e) {
|
|
476
335
|
this.httpService = e;
|
|
477
336
|
}
|
|
@@ -505,7 +364,7 @@ class Se {
|
|
|
505
364
|
});
|
|
506
365
|
}
|
|
507
366
|
}
|
|
508
|
-
class
|
|
367
|
+
class le {
|
|
509
368
|
constructor(e, t) {
|
|
510
369
|
this.httpService = e, this.sessionManager = t;
|
|
511
370
|
}
|
|
@@ -545,10 +404,10 @@ class ae {
|
|
|
545
404
|
async getRolesByApp(e, t) {
|
|
546
405
|
const r = new URLSearchParams();
|
|
547
406
|
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);
|
|
548
|
-
const s = `/roles/app/${e}${r.toString() ? `?${r.toString()}` : ""}`,
|
|
407
|
+
const s = `/roles/app/${e}${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s);
|
|
549
408
|
return {
|
|
550
|
-
roles:
|
|
551
|
-
meta:
|
|
409
|
+
roles: a.data,
|
|
410
|
+
meta: a.meta
|
|
552
411
|
};
|
|
553
412
|
}
|
|
554
413
|
async assignRole(e, t) {
|
|
@@ -572,16 +431,16 @@ class ae {
|
|
|
572
431
|
throw new Error("SessionManager is required for private endpoints");
|
|
573
432
|
const r = await this.sessionManager.getAuthHeaders(), s = new URLSearchParams();
|
|
574
433
|
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);
|
|
575
|
-
const
|
|
434
|
+
const a = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, v = await this.httpService.get(a, {
|
|
576
435
|
headers: r
|
|
577
436
|
});
|
|
578
437
|
return {
|
|
579
|
-
roles:
|
|
580
|
-
meta:
|
|
438
|
+
roles: v.data,
|
|
439
|
+
meta: v.meta
|
|
581
440
|
};
|
|
582
441
|
}
|
|
583
442
|
}
|
|
584
|
-
class
|
|
443
|
+
class Pe {
|
|
585
444
|
constructor(e, t) {
|
|
586
445
|
this.httpService = e, this.sessionManager = t;
|
|
587
446
|
}
|
|
@@ -594,12 +453,12 @@ class ve {
|
|
|
594
453
|
async getUsers(e) {
|
|
595
454
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
596
455
|
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);
|
|
597
|
-
const s = `/users/${r.toString() ? `?${r.toString()}` : ""}`,
|
|
456
|
+
const s = `/users/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
|
|
598
457
|
headers: t
|
|
599
458
|
});
|
|
600
459
|
return {
|
|
601
|
-
users:
|
|
602
|
-
meta:
|
|
460
|
+
users: a.data,
|
|
461
|
+
meta: a.meta
|
|
603
462
|
};
|
|
604
463
|
}
|
|
605
464
|
async getUserById(e) {
|
|
@@ -621,197 +480,483 @@ class ve {
|
|
|
621
480
|
});
|
|
622
481
|
}
|
|
623
482
|
}
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
483
|
+
class ce {
|
|
484
|
+
constructor(e, t, r) {
|
|
485
|
+
this.httpService = e, this.appId = t, this.sessionManager = r;
|
|
486
|
+
}
|
|
487
|
+
async createTenant(e) {
|
|
488
|
+
if (!this.sessionManager)
|
|
489
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
490
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
491
|
+
return (await this.httpService.post("/tenants/", e, {
|
|
492
|
+
headers: t
|
|
493
|
+
})).data;
|
|
494
|
+
}
|
|
495
|
+
async getTenants(e) {
|
|
496
|
+
if (!this.sessionManager)
|
|
497
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
498
|
+
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
499
|
+
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 s = `/tenants/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
|
|
501
|
+
headers: t
|
|
502
|
+
});
|
|
503
|
+
return {
|
|
504
|
+
tenants: a.data,
|
|
505
|
+
meta: a.meta
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
async getTenantById(e) {
|
|
509
|
+
if (!this.sessionManager)
|
|
510
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
511
|
+
const t = await this.sessionManager.getAuthHeaders();
|
|
512
|
+
return (await this.httpService.get(`/tenants/${e}`, {
|
|
513
|
+
headers: t
|
|
514
|
+
})).data;
|
|
515
|
+
}
|
|
516
|
+
async updateTenant(e, t) {
|
|
517
|
+
if (!this.sessionManager)
|
|
518
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
519
|
+
const r = await this.sessionManager.getAuthHeaders();
|
|
520
|
+
return (await this.httpService.put(`/tenants/${e}`, t, {
|
|
521
|
+
headers: r
|
|
522
|
+
})).data;
|
|
523
|
+
}
|
|
524
|
+
async adminUpdateTenant(e, t) {
|
|
525
|
+
if (!this.sessionManager)
|
|
526
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
527
|
+
const r = await this.sessionManager.getAuthHeaders();
|
|
528
|
+
return (await this.httpService.put(
|
|
529
|
+
`/tenants/${e}/admin-update`,
|
|
530
|
+
t,
|
|
531
|
+
{
|
|
532
|
+
headers: r
|
|
533
|
+
}
|
|
534
|
+
)).data;
|
|
535
|
+
}
|
|
536
|
+
// Public endpoint - no auth required
|
|
537
|
+
async getPublicTenantInfo(e) {
|
|
538
|
+
return (await this.httpService.get(
|
|
539
|
+
`/tenants/${this.appId}/${e}/public`
|
|
540
|
+
)).data;
|
|
541
|
+
}
|
|
542
|
+
// Settings endpoints
|
|
543
|
+
async getTenantSettings(e) {
|
|
544
|
+
return (await this.httpService.get(
|
|
545
|
+
`/tenants/${e}/settings`
|
|
546
|
+
)).data;
|
|
547
|
+
}
|
|
548
|
+
async updateTenantSettings(e, t) {
|
|
549
|
+
if (!this.sessionManager)
|
|
550
|
+
throw new Error("SessionManager is required for private endpoints");
|
|
551
|
+
const r = await this.sessionManager.getAuthHeaders();
|
|
552
|
+
return (await this.httpService.put(
|
|
553
|
+
`/tenants/${e}/settings`,
|
|
554
|
+
t,
|
|
555
|
+
{
|
|
556
|
+
headers: r
|
|
557
|
+
}
|
|
558
|
+
)).data;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
const pe = ee(null), Te = () => /* @__PURE__ */ n(
|
|
562
|
+
"div",
|
|
563
|
+
{
|
|
564
|
+
style: {
|
|
565
|
+
display: "flex",
|
|
566
|
+
justifyContent: "center",
|
|
567
|
+
alignItems: "center",
|
|
568
|
+
height: "100vh",
|
|
569
|
+
fontFamily: "system-ui, sans-serif"
|
|
570
|
+
},
|
|
571
|
+
children: /* @__PURE__ */ n("div", { children: "Loading tenant..." })
|
|
572
|
+
}
|
|
573
|
+
), ke = ({ error: i, retry: e }) => /* @__PURE__ */ u(
|
|
574
|
+
"div",
|
|
575
|
+
{
|
|
576
|
+
style: {
|
|
577
|
+
display: "flex",
|
|
578
|
+
flexDirection: "column",
|
|
579
|
+
justifyContent: "center",
|
|
580
|
+
alignItems: "center",
|
|
581
|
+
height: "100vh",
|
|
582
|
+
fontFamily: "system-ui, sans-serif",
|
|
583
|
+
textAlign: "center",
|
|
584
|
+
padding: "20px"
|
|
585
|
+
},
|
|
586
|
+
children: [
|
|
587
|
+
/* @__PURE__ */ n("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Tenant Error" }),
|
|
588
|
+
/* @__PURE__ */ n("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load tenant" }),
|
|
589
|
+
/* @__PURE__ */ n(
|
|
590
|
+
"button",
|
|
591
|
+
{
|
|
592
|
+
onClick: e,
|
|
593
|
+
style: {
|
|
594
|
+
padding: "8px 16px",
|
|
595
|
+
backgroundColor: "#007bff",
|
|
596
|
+
color: "white",
|
|
597
|
+
border: "none",
|
|
598
|
+
borderRadius: "4px",
|
|
599
|
+
cursor: "pointer"
|
|
600
|
+
},
|
|
601
|
+
children: "Retry"
|
|
602
|
+
}
|
|
603
|
+
)
|
|
604
|
+
]
|
|
605
|
+
}
|
|
606
|
+
);
|
|
607
|
+
function Ze({ config: i, children: e }) {
|
|
608
|
+
const { baseUrl: t, appInfo: r, appId: s } = re(), [a, v] = m(i.initialTenant || null), [M, k] = m(!i.initialTenant), [P, h] = m(null), [g, x] = m(null), [f, A] = m(!1), [F, y] = m(null), C = X(() => {
|
|
609
|
+
const l = i.tenantMode || "optional", w = "tenant";
|
|
610
|
+
if (l === "fixed")
|
|
611
|
+
return i.fixedTenantSlug || null;
|
|
612
|
+
if (typeof window > "u") return null;
|
|
613
|
+
if (l === "subdomain") {
|
|
614
|
+
const o = window.location.hostname.split(".");
|
|
615
|
+
if (o.length >= 3) {
|
|
616
|
+
const c = o[0];
|
|
617
|
+
return localStorage.setItem(w, c), c;
|
|
618
|
+
}
|
|
619
|
+
return localStorage.getItem(w);
|
|
620
|
+
} else if (l === "selector") {
|
|
621
|
+
const o = new URLSearchParams(window.location.search).get(i.selectorParam || "tenant");
|
|
622
|
+
return o ? (localStorage.setItem(w, o), o) : localStorage.getItem(w);
|
|
623
|
+
}
|
|
624
|
+
return null;
|
|
625
|
+
}, [i.tenantMode, i.fixedTenantSlug, i.selectorParam]), p = O(() => C(), [C]), b = (r == null ? void 0 : r.settingsSchema) || null, T = X(
|
|
626
|
+
async (l) => {
|
|
627
|
+
try {
|
|
628
|
+
k(!0), h(null);
|
|
629
|
+
const w = new G(t), o = await new ce(w, s).getPublicTenantInfo(l);
|
|
630
|
+
v(o);
|
|
631
|
+
} catch (w) {
|
|
632
|
+
const d = w instanceof Error ? w : new Error("Failed to load tenant information");
|
|
633
|
+
h(d), v(null);
|
|
634
|
+
} finally {
|
|
635
|
+
k(!1);
|
|
636
|
+
}
|
|
637
|
+
},
|
|
638
|
+
[t, s]
|
|
639
|
+
), R = X(async () => {
|
|
640
|
+
if (a != null && a.id)
|
|
641
|
+
try {
|
|
642
|
+
A(!0), y(null);
|
|
643
|
+
const l = new G(t), d = await new ce(l, a.appId).getTenantSettings(a.id);
|
|
644
|
+
x(d);
|
|
645
|
+
} catch (l) {
|
|
646
|
+
const w = l instanceof Error ? l : new Error("Failed to load tenant settings");
|
|
647
|
+
y(w), x(null);
|
|
648
|
+
} finally {
|
|
649
|
+
A(!1);
|
|
650
|
+
}
|
|
651
|
+
}, [t, a]), L = X(() => {
|
|
652
|
+
R();
|
|
653
|
+
}, [R]), E = X(
|
|
654
|
+
(l) => {
|
|
655
|
+
if (!b)
|
|
656
|
+
return { isValid: !0, errors: [] };
|
|
657
|
+
const w = [];
|
|
658
|
+
try {
|
|
659
|
+
return b.properties && Object.entries(b.properties).forEach(([d, o]) => {
|
|
660
|
+
var W;
|
|
661
|
+
const c = l[d];
|
|
662
|
+
if ((W = b.required) != null && W.includes(d) && c == null) {
|
|
663
|
+
w.push(`Field '${d}' is required`);
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
if (c != null) {
|
|
667
|
+
if (o.type) {
|
|
668
|
+
const I = o.type, N = typeof c;
|
|
669
|
+
I === "string" && N !== "string" ? w.push(`Field '${d}' must be a string`) : (I === "number" || I === "integer") && N !== "number" ? w.push(`Field '${d}' must be a number`) : I === "boolean" && N !== "boolean" ? w.push(`Field '${d}' must be a boolean`) : I === "array" && !Array.isArray(c) && w.push(`Field '${d}' must be an array`);
|
|
670
|
+
}
|
|
671
|
+
o.minLength !== void 0 && typeof c == "string" && c.length < o.minLength && w.push(
|
|
672
|
+
`Field '${d}' must be at least ${o.minLength} characters long`
|
|
673
|
+
), o.maxLength !== void 0 && typeof c == "string" && c.length > o.maxLength && w.push(
|
|
674
|
+
`Field '${d}' must be no more than ${o.maxLength} characters long`
|
|
675
|
+
), o.minimum !== void 0 && typeof c == "number" && c < o.minimum && w.push(`Field '${d}' must be at least ${o.minimum}`), o.maximum !== void 0 && typeof c == "number" && c > o.maximum && w.push(`Field '${d}' must be no more than ${o.maximum}`), o.pattern && typeof c == "string" && (new RegExp(o.pattern).test(c) || w.push(`Field '${d}' does not match the required pattern`)), o.enum && !o.enum.includes(c) && w.push(`Field '${d}' must be one of: ${o.enum.join(", ")}`);
|
|
676
|
+
}
|
|
677
|
+
}), {
|
|
678
|
+
isValid: w.length === 0,
|
|
679
|
+
errors: w
|
|
680
|
+
};
|
|
681
|
+
} catch {
|
|
682
|
+
return {
|
|
683
|
+
isValid: !1,
|
|
684
|
+
errors: ["Invalid settings schema or validation error"]
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
},
|
|
688
|
+
[b]
|
|
689
|
+
);
|
|
690
|
+
K(() => {
|
|
691
|
+
const l = i.tenantMode || "optional";
|
|
692
|
+
!i.initialTenant && p ? T(p) : !i.initialTenant && !p && l === "fixed" ? (h(new Error("Fixed tenant mode requires fixedTenantSlug configuration")), k(!1)) : !i.initialTenant && !p && (l === "subdomain" || l === "selector") ? (h(
|
|
693
|
+
new Error(`No tenant ${l === "subdomain" ? "subdomain" : "parameter"} found`)
|
|
694
|
+
), k(!1)) : !i.initialTenant && !p && l === "optional" && (v(null), h(null), k(!1));
|
|
695
|
+
}, [i.initialTenant, p, T, i.tenantMode, i.fixedTenantSlug]), K(() => {
|
|
696
|
+
a != null && a.id ? R() : (x(null), y(null), A(!1));
|
|
697
|
+
}, [a == null ? void 0 : a.id, R]);
|
|
698
|
+
const D = O(() => ({
|
|
699
|
+
// Tenant info
|
|
700
|
+
tenant: a,
|
|
701
|
+
tenantSlug: p,
|
|
702
|
+
isTenantLoading: M,
|
|
703
|
+
tenantError: P,
|
|
704
|
+
retryTenant: () => {
|
|
705
|
+
p && T(p);
|
|
706
|
+
},
|
|
707
|
+
// Settings
|
|
708
|
+
settings: g,
|
|
709
|
+
settingsSchema: b,
|
|
710
|
+
isSettingsLoading: f,
|
|
711
|
+
settingsError: F,
|
|
712
|
+
// Actions
|
|
713
|
+
refreshSettings: L,
|
|
714
|
+
// Validation
|
|
715
|
+
validateSettings: E
|
|
716
|
+
}), [
|
|
717
|
+
a,
|
|
718
|
+
p,
|
|
719
|
+
M,
|
|
720
|
+
P,
|
|
721
|
+
g,
|
|
722
|
+
b,
|
|
723
|
+
f,
|
|
724
|
+
F,
|
|
725
|
+
L,
|
|
726
|
+
E
|
|
727
|
+
]);
|
|
728
|
+
if (M)
|
|
729
|
+
return /* @__PURE__ */ n(B, { children: i.loadingFallback || /* @__PURE__ */ n(Te, {}) });
|
|
730
|
+
if (P && i.tenantMode !== "optional") {
|
|
731
|
+
const l = typeof i.errorFallback == "function" ? i.errorFallback(P, () => T(p || "")) : i.errorFallback || /* @__PURE__ */ n(ke, { error: P, retry: () => T(p || "") });
|
|
732
|
+
return /* @__PURE__ */ n(B, { children: l });
|
|
733
|
+
}
|
|
734
|
+
return /* @__PURE__ */ n(pe.Provider, { value: D, children: e });
|
|
735
|
+
}
|
|
736
|
+
function oe() {
|
|
737
|
+
const i = te(pe);
|
|
738
|
+
if (!i)
|
|
739
|
+
throw new Error("useTenant must be used within a TenantProvider");
|
|
740
|
+
return i;
|
|
741
|
+
}
|
|
742
|
+
const et = oe;
|
|
743
|
+
function tt() {
|
|
744
|
+
const {
|
|
745
|
+
settings: i,
|
|
746
|
+
settingsSchema: e,
|
|
747
|
+
isSettingsLoading: t,
|
|
748
|
+
settingsError: r,
|
|
749
|
+
validateSettings: s
|
|
750
|
+
} = oe();
|
|
751
|
+
return {
|
|
752
|
+
settings: i,
|
|
753
|
+
settingsSchema: e,
|
|
754
|
+
isLoading: t,
|
|
755
|
+
error: r,
|
|
756
|
+
validateSettings: s
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
function Z() {
|
|
760
|
+
const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } = oe();
|
|
761
|
+
return {
|
|
762
|
+
tenant: i,
|
|
763
|
+
tenantSlug: e,
|
|
764
|
+
isLoading: t,
|
|
765
|
+
error: r,
|
|
766
|
+
retry: s
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
const fe = ee(null);
|
|
770
|
+
function rt({ config: i = {}, children: e }) {
|
|
771
|
+
const { appId: t, baseUrl: r } = re(), s = Z(), a = (s == null ? void 0 : s.tenantSlug) || null, [v, M] = m(i.initialRoles || []), [k, P] = m(!i.initialRoles), [h, g] = m(null), [x, f] = m(!1), [A, F] = m(null), y = O(() => {
|
|
772
|
+
const l = a ? `auth_tokens_${a}` : "auth_tokens", w = {
|
|
628
773
|
get: () => {
|
|
629
774
|
try {
|
|
630
|
-
const
|
|
631
|
-
return
|
|
775
|
+
const d = localStorage.getItem(l);
|
|
776
|
+
return d ? JSON.parse(d) : null;
|
|
632
777
|
} catch {
|
|
633
778
|
return null;
|
|
634
779
|
}
|
|
635
780
|
},
|
|
636
|
-
set: (
|
|
781
|
+
set: (d) => {
|
|
637
782
|
try {
|
|
638
|
-
localStorage.setItem(
|
|
783
|
+
localStorage.setItem(l, JSON.stringify(d));
|
|
639
784
|
} catch {
|
|
640
785
|
}
|
|
641
786
|
},
|
|
642
787
|
clear: () => {
|
|
643
788
|
try {
|
|
644
|
-
localStorage.removeItem(
|
|
789
|
+
localStorage.removeItem(l);
|
|
645
790
|
} catch {
|
|
646
791
|
}
|
|
647
792
|
}
|
|
648
793
|
};
|
|
649
|
-
return new
|
|
650
|
-
onRefreshFailed:
|
|
651
|
-
tokenStorage:
|
|
652
|
-
baseUrl:
|
|
794
|
+
return new xe({
|
|
795
|
+
onRefreshFailed: i.onRefreshFailed,
|
|
796
|
+
tokenStorage: w,
|
|
797
|
+
baseUrl: r
|
|
653
798
|
});
|
|
654
|
-
}, [
|
|
655
|
-
const
|
|
656
|
-
return
|
|
657
|
-
}, [
|
|
799
|
+
}, [a, r, i.onRefreshFailed]), C = O(() => {
|
|
800
|
+
const l = new G(r);
|
|
801
|
+
return l.setSessionManager(y), l;
|
|
802
|
+
}, [r, y]), p = O(() => new Ae(new G(r)), [r]), b = O(() => new Pe(C, y), [C, y]), T = O(() => new le(new G(r)), [r]), R = O(() => h || y.getUser(), [h, y]), L = O(() => R != null && R.roleId && v.find((l) => l.id === R.roleId) || null, [R, v]), E = O(() => (L == null ? void 0 : L.permissions) || [], [L]);
|
|
658
803
|
K(() => {
|
|
659
|
-
console.log("AuthProvider - userPermissions changed:",
|
|
660
|
-
}, [
|
|
661
|
-
const
|
|
662
|
-
const
|
|
804
|
+
console.log("AuthProvider - userPermissions changed:", E);
|
|
805
|
+
}, [E]);
|
|
806
|
+
const D = O(() => {
|
|
807
|
+
const l = async () => {
|
|
663
808
|
try {
|
|
664
|
-
|
|
665
|
-
const
|
|
666
|
-
if (!(
|
|
809
|
+
f(!0), F(null);
|
|
810
|
+
const S = y.getUser();
|
|
811
|
+
if (!(S != null && S.id))
|
|
667
812
|
throw new Error("No user ID available in session");
|
|
668
|
-
const $ = await
|
|
669
|
-
|
|
670
|
-
} catch (
|
|
671
|
-
const $ =
|
|
672
|
-
|
|
813
|
+
const $ = await b.getUserById(S.id);
|
|
814
|
+
g($), y.setUser($);
|
|
815
|
+
} catch (S) {
|
|
816
|
+
const $ = S instanceof Error ? S : new Error("Failed to load user data");
|
|
817
|
+
F($), console.error("Failed to load user data:", $);
|
|
673
818
|
} finally {
|
|
674
|
-
|
|
819
|
+
f(!1);
|
|
675
820
|
}
|
|
676
|
-
},
|
|
677
|
-
await
|
|
678
|
-
},
|
|
679
|
-
const V = await
|
|
680
|
-
email:
|
|
821
|
+
}, w = async () => {
|
|
822
|
+
await l();
|
|
823
|
+
}, d = async (S, $, Q) => {
|
|
824
|
+
const V = await p.login({
|
|
825
|
+
email: S,
|
|
681
826
|
password: $,
|
|
682
|
-
tenantId:
|
|
827
|
+
tenantId: Q
|
|
683
828
|
});
|
|
684
|
-
if (
|
|
829
|
+
if (y.setTokens({
|
|
685
830
|
accessToken: V.accessToken,
|
|
686
831
|
refreshToken: V.refreshToken,
|
|
687
832
|
expiresIn: V.expiresIn
|
|
688
833
|
}), V.user) {
|
|
689
|
-
|
|
834
|
+
y.setUser(V.user), g(V.user);
|
|
690
835
|
try {
|
|
691
|
-
await
|
|
692
|
-
} catch (
|
|
693
|
-
console.warn("Failed to load complete user data after login:",
|
|
836
|
+
await l();
|
|
837
|
+
} catch (ie) {
|
|
838
|
+
console.warn("Failed to load complete user data after login:", ie);
|
|
694
839
|
}
|
|
695
840
|
}
|
|
696
841
|
return V;
|
|
697
|
-
},
|
|
698
|
-
email:
|
|
842
|
+
}, o = async (S, $, Q, V) => await p.signup({ email: S, name: $, password: Q, tenantId: V }), c = async (S, $, Q, V) => await p.signupTenantAdmin({
|
|
843
|
+
email: S,
|
|
699
844
|
name: $,
|
|
700
|
-
password:
|
|
845
|
+
password: Q,
|
|
701
846
|
tenantName: V,
|
|
702
847
|
appId: t
|
|
703
|
-
}),
|
|
704
|
-
const
|
|
705
|
-
await
|
|
706
|
-
},
|
|
707
|
-
await
|
|
708
|
-
},
|
|
709
|
-
await
|
|
710
|
-
},
|
|
711
|
-
const
|
|
712
|
-
if (!(
|
|
848
|
+
}), W = async (S, $) => {
|
|
849
|
+
const Q = await y.getAuthHeaders();
|
|
850
|
+
await p.changePassword({ currentPassword: S, newPassword: $ }, Q);
|
|
851
|
+
}, I = async (S, $) => {
|
|
852
|
+
await p.requestPasswordReset({ email: S, tenantId: $ });
|
|
853
|
+
}, N = async (S, $) => {
|
|
854
|
+
await p.confirmPasswordReset({ token: S, newPassword: $ });
|
|
855
|
+
}, _ = async () => {
|
|
856
|
+
const S = y.getTokens();
|
|
857
|
+
if (!(S != null && S.refreshToken))
|
|
713
858
|
throw new Error("No refresh token available");
|
|
714
|
-
const $ = await
|
|
715
|
-
refreshToken:
|
|
859
|
+
const $ = await p.refreshToken({
|
|
860
|
+
refreshToken: S.refreshToken
|
|
716
861
|
});
|
|
717
|
-
|
|
862
|
+
y.setTokens({
|
|
718
863
|
accessToken: $.accessToken,
|
|
719
|
-
refreshToken: $.refreshToken ||
|
|
864
|
+
refreshToken: $.refreshToken || S.refreshToken,
|
|
720
865
|
expiresIn: $.expiresIn
|
|
721
866
|
});
|
|
722
|
-
},
|
|
723
|
-
|
|
724
|
-
},
|
|
725
|
-
|
|
726
|
-
},
|
|
727
|
-
|
|
728
|
-
},
|
|
867
|
+
}, H = () => {
|
|
868
|
+
y.clearSession(), g(null), F(null);
|
|
869
|
+
}, q = (S) => {
|
|
870
|
+
y.setTokens(S);
|
|
871
|
+
}, Y = () => y.hasValidSession(), U = () => {
|
|
872
|
+
y.clearSession(), g(null), F(null);
|
|
873
|
+
}, z = async () => {
|
|
729
874
|
if (t)
|
|
730
875
|
try {
|
|
731
|
-
|
|
732
|
-
const { roles:
|
|
733
|
-
|
|
734
|
-
} catch (
|
|
735
|
-
console.error("Failed to fetch roles:",
|
|
876
|
+
P(!0);
|
|
877
|
+
const { roles: S } = await T.getRolesByApp(t);
|
|
878
|
+
M(S);
|
|
879
|
+
} catch (S) {
|
|
880
|
+
console.error("Failed to fetch roles:", S);
|
|
736
881
|
} finally {
|
|
737
|
-
|
|
882
|
+
P(!1);
|
|
738
883
|
}
|
|
739
884
|
}, j = async () => {
|
|
740
|
-
await
|
|
741
|
-
},
|
|
742
|
-
if (!
|
|
885
|
+
await z();
|
|
886
|
+
}, ne = (S) => {
|
|
887
|
+
if (!E || E.length === 0)
|
|
743
888
|
return !1;
|
|
744
|
-
if (typeof
|
|
745
|
-
return
|
|
746
|
-
const $ = `${
|
|
747
|
-
return
|
|
889
|
+
if (typeof S == "string")
|
|
890
|
+
return E.includes(S);
|
|
891
|
+
const $ = `${S.resource}.${S.action}`;
|
|
892
|
+
return E.includes($);
|
|
748
893
|
};
|
|
749
894
|
return {
|
|
750
|
-
sessionManager:
|
|
895
|
+
sessionManager: y,
|
|
751
896
|
authenticatedHttpService: C,
|
|
752
|
-
login:
|
|
753
|
-
signup:
|
|
754
|
-
signupTenantAdmin:
|
|
755
|
-
changePassword:
|
|
756
|
-
requestPasswordReset:
|
|
757
|
-
confirmPasswordReset:
|
|
758
|
-
refreshToken:
|
|
759
|
-
logout:
|
|
760
|
-
setTokens:
|
|
761
|
-
hasValidSession:
|
|
762
|
-
clearSession:
|
|
763
|
-
currentUser:
|
|
764
|
-
isUserLoading:
|
|
765
|
-
userError:
|
|
766
|
-
refreshUser:
|
|
767
|
-
userRole:
|
|
768
|
-
userPermissions:
|
|
769
|
-
availableRoles:
|
|
770
|
-
rolesLoading:
|
|
771
|
-
hasPermission:
|
|
772
|
-
hasAnyPermission: (
|
|
773
|
-
hasAllPermissions: (
|
|
774
|
-
getUserPermissionStrings: () =>
|
|
897
|
+
login: d,
|
|
898
|
+
signup: o,
|
|
899
|
+
signupTenantAdmin: c,
|
|
900
|
+
changePassword: W,
|
|
901
|
+
requestPasswordReset: I,
|
|
902
|
+
confirmPasswordReset: N,
|
|
903
|
+
refreshToken: _,
|
|
904
|
+
logout: H,
|
|
905
|
+
setTokens: q,
|
|
906
|
+
hasValidSession: Y,
|
|
907
|
+
clearSession: U,
|
|
908
|
+
currentUser: h,
|
|
909
|
+
isUserLoading: x,
|
|
910
|
+
userError: A,
|
|
911
|
+
refreshUser: w,
|
|
912
|
+
userRole: L,
|
|
913
|
+
userPermissions: E,
|
|
914
|
+
availableRoles: v,
|
|
915
|
+
rolesLoading: k,
|
|
916
|
+
hasPermission: ne,
|
|
917
|
+
hasAnyPermission: (S) => S.some(($) => ne($)),
|
|
918
|
+
hasAllPermissions: (S) => S.every(($) => ne($)),
|
|
919
|
+
getUserPermissionStrings: () => E || [],
|
|
775
920
|
refreshRoles: j
|
|
776
921
|
};
|
|
777
922
|
}, [
|
|
778
|
-
|
|
923
|
+
y,
|
|
779
924
|
C,
|
|
780
|
-
x,
|
|
781
|
-
d,
|
|
782
|
-
l,
|
|
783
|
-
t,
|
|
784
|
-
o,
|
|
785
|
-
E,
|
|
786
925
|
p,
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
926
|
+
b,
|
|
927
|
+
T,
|
|
928
|
+
t,
|
|
929
|
+
v,
|
|
930
|
+
h,
|
|
931
|
+
x,
|
|
932
|
+
A,
|
|
933
|
+
L,
|
|
934
|
+
E
|
|
790
935
|
]);
|
|
791
936
|
return K(() => {
|
|
792
|
-
!
|
|
937
|
+
!i.initialRoles && t && (async () => {
|
|
793
938
|
try {
|
|
794
|
-
|
|
795
|
-
const
|
|
796
|
-
|
|
797
|
-
} catch (
|
|
798
|
-
console.error("Failed to fetch roles:",
|
|
939
|
+
P(!0);
|
|
940
|
+
const w = new G(r), d = new le(w), { roles: o } = await d.getRolesByApp(t);
|
|
941
|
+
M(o);
|
|
942
|
+
} catch (w) {
|
|
943
|
+
console.error("Failed to fetch roles:", w);
|
|
799
944
|
} finally {
|
|
800
|
-
|
|
945
|
+
P(!1);
|
|
801
946
|
}
|
|
802
947
|
})();
|
|
803
|
-
}, [t,
|
|
804
|
-
const
|
|
805
|
-
|
|
806
|
-
}, [
|
|
948
|
+
}, [t, r, i.initialRoles]), K(() => {
|
|
949
|
+
const l = y.getUser();
|
|
950
|
+
l && y.hasValidSession() && g(l);
|
|
951
|
+
}, [y]), /* @__PURE__ */ n(fe.Provider, { value: D, children: e });
|
|
807
952
|
}
|
|
808
|
-
function
|
|
809
|
-
const
|
|
810
|
-
if (!
|
|
953
|
+
function se() {
|
|
954
|
+
const i = te(fe);
|
|
955
|
+
if (!i)
|
|
811
956
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
812
|
-
return
|
|
957
|
+
return i;
|
|
813
958
|
}
|
|
814
|
-
class
|
|
959
|
+
class Me {
|
|
815
960
|
constructor(e, t) {
|
|
816
961
|
this.httpService = e, this.sessionManager = t;
|
|
817
962
|
}
|
|
@@ -832,12 +977,12 @@ class xe {
|
|
|
832
977
|
throw new Error("SessionManager is required for private endpoints");
|
|
833
978
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
834
979
|
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);
|
|
835
|
-
const s = `/feature-flags/${r.toString() ? `?${r.toString()}` : ""}`,
|
|
980
|
+
const s = `/feature-flags/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
|
|
836
981
|
headers: t
|
|
837
982
|
});
|
|
838
983
|
return {
|
|
839
|
-
featureFlags:
|
|
840
|
-
meta:
|
|
984
|
+
featureFlags: a.data,
|
|
985
|
+
meta: a.meta
|
|
841
986
|
};
|
|
842
987
|
}
|
|
843
988
|
async getFeatureFlagById(e) {
|
|
@@ -885,64 +1030,64 @@ class xe {
|
|
|
885
1030
|
throw new Error("Flag Key, Tenant ID and App ID are required");
|
|
886
1031
|
const s = new URLSearchParams();
|
|
887
1032
|
s.append("tenantId", t), s.append("appId", r);
|
|
888
|
-
const
|
|
889
|
-
return (await this.httpService.get(
|
|
1033
|
+
const a = `/tenant-feature-flags/${e}${s.toString() ? `?${s.toString()}` : ""}`;
|
|
1034
|
+
return (await this.httpService.get(a, {
|
|
890
1035
|
headers: { "X-Tenant-ID": t }
|
|
891
1036
|
})).data;
|
|
892
1037
|
}
|
|
893
1038
|
}
|
|
894
|
-
const
|
|
895
|
-
function
|
|
896
|
-
const {
|
|
897
|
-
const
|
|
898
|
-
return new
|
|
899
|
-
}, [
|
|
900
|
-
if (!(
|
|
901
|
-
|
|
1039
|
+
const ye = ee(null);
|
|
1040
|
+
function st({ config: i = {}, children: e }) {
|
|
1041
|
+
const { baseUrl: t, appId: r } = re(), { tenant: s } = Z(), [a, v] = m([]), [M, k] = m(!1), [P, h] = m(null), g = O(() => {
|
|
1042
|
+
const A = new G(t);
|
|
1043
|
+
return new Me(A);
|
|
1044
|
+
}, [t]), x = async () => {
|
|
1045
|
+
if (!(s != null && s.id)) {
|
|
1046
|
+
v([]);
|
|
902
1047
|
return;
|
|
903
1048
|
}
|
|
904
|
-
|
|
1049
|
+
k(!0), h(null);
|
|
905
1050
|
try {
|
|
906
|
-
const
|
|
907
|
-
|
|
908
|
-
} catch (
|
|
909
|
-
const
|
|
910
|
-
|
|
1051
|
+
const A = await g.getTenantFeatureFlags(s.id, r);
|
|
1052
|
+
v(A);
|
|
1053
|
+
} catch (A) {
|
|
1054
|
+
const F = A instanceof Error ? A.message : "Failed to fetch feature flags";
|
|
1055
|
+
h(F), i.onError && i.onError(A instanceof Error ? A : new Error(F));
|
|
911
1056
|
} finally {
|
|
912
|
-
|
|
1057
|
+
k(!1);
|
|
913
1058
|
}
|
|
914
1059
|
};
|
|
915
1060
|
K(() => {
|
|
916
|
-
|
|
917
|
-
const
|
|
918
|
-
return () => clearInterval(
|
|
919
|
-
}, [
|
|
920
|
-
const f =
|
|
921
|
-
featureFlags:
|
|
1061
|
+
x();
|
|
1062
|
+
const A = i.refreshInterval || 5 * 60 * 1e3, F = setInterval(x, A);
|
|
1063
|
+
return () => clearInterval(F);
|
|
1064
|
+
}, [s == null ? void 0 : s.id, i.refreshInterval]);
|
|
1065
|
+
const f = O(() => ({
|
|
1066
|
+
featureFlags: a,
|
|
922
1067
|
loading: M,
|
|
923
|
-
error:
|
|
924
|
-
isEnabled: (
|
|
925
|
-
const
|
|
926
|
-
return (
|
|
1068
|
+
error: P,
|
|
1069
|
+
isEnabled: (p) => {
|
|
1070
|
+
const b = a.find((T) => T.key === p);
|
|
1071
|
+
return (b == null ? void 0 : b.value) === !0;
|
|
927
1072
|
},
|
|
928
|
-
getFlag: (
|
|
929
|
-
getFlagState: (
|
|
930
|
-
const
|
|
931
|
-
return
|
|
1073
|
+
getFlag: (p) => a.find((b) => b.key === p),
|
|
1074
|
+
getFlagState: (p) => {
|
|
1075
|
+
const b = a.find((T) => T.key === p);
|
|
1076
|
+
return b ? b.value ? "enabled" : "disabled" : "not_found";
|
|
932
1077
|
},
|
|
933
1078
|
refresh: async () => {
|
|
934
|
-
await
|
|
1079
|
+
await x();
|
|
935
1080
|
}
|
|
936
|
-
}), [
|
|
937
|
-
return /* @__PURE__ */
|
|
1081
|
+
}), [a, M, P]);
|
|
1082
|
+
return /* @__PURE__ */ n(ye.Provider, { value: f, children: e });
|
|
938
1083
|
}
|
|
939
|
-
function
|
|
940
|
-
const
|
|
941
|
-
if (!
|
|
1084
|
+
function Ee() {
|
|
1085
|
+
const i = te(ye);
|
|
1086
|
+
if (!i)
|
|
942
1087
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
943
|
-
return
|
|
1088
|
+
return i;
|
|
944
1089
|
}
|
|
945
|
-
class
|
|
1090
|
+
class Re {
|
|
946
1091
|
constructor(e, t) {
|
|
947
1092
|
this.httpService = e, this.sessionManager = t;
|
|
948
1093
|
}
|
|
@@ -1008,185 +1153,64 @@ class Pe {
|
|
|
1008
1153
|
)).data;
|
|
1009
1154
|
}
|
|
1010
1155
|
}
|
|
1011
|
-
const
|
|
1012
|
-
function
|
|
1013
|
-
const {
|
|
1014
|
-
const f = new
|
|
1015
|
-
return new
|
|
1016
|
-
}, [
|
|
1017
|
-
if (!(
|
|
1018
|
-
|
|
1156
|
+
const we = ee(void 0);
|
|
1157
|
+
function nt({ config: i = {}, children: e }) {
|
|
1158
|
+
const { baseUrl: t } = re(), { tenant: r } = Z(), [s, a] = m(null), [v, M] = m(!1), [k, P] = m(null), h = O(() => {
|
|
1159
|
+
const f = new G(t);
|
|
1160
|
+
return new Re(f);
|
|
1161
|
+
}, [t]), g = async () => {
|
|
1162
|
+
if (!(r != null && r.id)) {
|
|
1163
|
+
a(null);
|
|
1019
1164
|
return;
|
|
1020
1165
|
}
|
|
1021
|
-
M(!0),
|
|
1166
|
+
M(!0), P(null);
|
|
1022
1167
|
try {
|
|
1023
|
-
const f = await
|
|
1024
|
-
|
|
1168
|
+
const f = await h.getTenantSubscriptionFeatures(r.id);
|
|
1169
|
+
a(f);
|
|
1025
1170
|
} catch (f) {
|
|
1026
|
-
const
|
|
1027
|
-
|
|
1171
|
+
const A = f instanceof Error ? f.message : "Failed to fetch subscription";
|
|
1172
|
+
P(A), i.onError && i.onError(f instanceof Error ? f : new Error(A));
|
|
1028
1173
|
} finally {
|
|
1029
1174
|
M(!1);
|
|
1030
1175
|
}
|
|
1031
1176
|
};
|
|
1032
1177
|
K(() => {
|
|
1033
|
-
if (
|
|
1034
|
-
const f =
|
|
1035
|
-
return () => clearInterval(
|
|
1036
|
-
}, [
|
|
1037
|
-
const
|
|
1178
|
+
if (g(), !i.refreshInterval) return;
|
|
1179
|
+
const f = i.refreshInterval || 10 * 60 * 1e3, A = setInterval(g, f);
|
|
1180
|
+
return () => clearInterval(A);
|
|
1181
|
+
}, [r == null ? void 0 : r.id, i.refreshInterval]);
|
|
1182
|
+
const x = O(() => {
|
|
1038
1183
|
const f = (s == null ? void 0 : s.features) || [];
|
|
1039
1184
|
return {
|
|
1040
1185
|
subscription: s,
|
|
1041
1186
|
features: f,
|
|
1042
|
-
loading:
|
|
1043
|
-
error:
|
|
1044
|
-
isFeatureEnabled: (
|
|
1045
|
-
const
|
|
1046
|
-
return
|
|
1187
|
+
loading: v,
|
|
1188
|
+
error: k,
|
|
1189
|
+
isFeatureEnabled: (b) => {
|
|
1190
|
+
const T = f.find((R) => R.key === b);
|
|
1191
|
+
return T ? T.type === "BOOLEAN" || T.type === "boolean" ? T.value === !0 : !!T.value : !1;
|
|
1047
1192
|
},
|
|
1048
|
-
getFeature: (
|
|
1049
|
-
getFeatureValue: (
|
|
1050
|
-
const
|
|
1051
|
-
return
|
|
1193
|
+
getFeature: (b) => f.find((T) => T.key === b),
|
|
1194
|
+
getFeatureValue: (b, T) => {
|
|
1195
|
+
const R = f.find((L) => L.key === b);
|
|
1196
|
+
return R ? R.value : T;
|
|
1052
1197
|
},
|
|
1053
|
-
hasAllowedPlan: (
|
|
1198
|
+
hasAllowedPlan: (b) => !s || !s.isActive ? !1 : b.includes(s.planId),
|
|
1054
1199
|
refresh: async () => {
|
|
1055
|
-
await
|
|
1200
|
+
await g();
|
|
1056
1201
|
}
|
|
1057
1202
|
};
|
|
1058
|
-
}, [s,
|
|
1059
|
-
return /* @__PURE__ */
|
|
1203
|
+
}, [s, v, k]);
|
|
1204
|
+
return /* @__PURE__ */ n(we.Provider, { value: x, children: e });
|
|
1060
1205
|
}
|
|
1061
|
-
function
|
|
1062
|
-
const
|
|
1063
|
-
if (
|
|
1206
|
+
function Fe() {
|
|
1207
|
+
const i = te(we);
|
|
1208
|
+
if (i === void 0)
|
|
1064
1209
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1065
|
-
return
|
|
1066
|
-
}
|
|
1067
|
-
const fe = te(null);
|
|
1068
|
-
function Ze({ children: n }) {
|
|
1069
|
-
const { baseUrl: e, tenant: t, appInfo: r } = G(), { sessionManager: s } = ee(), [o, T] = b(null), [M, S] = b(!1), [E, w] = b(null), p = (r == null ? void 0 : r.settingsSchema) || null, v = X(async () => {
|
|
1070
|
-
if (t != null && t.id)
|
|
1071
|
-
try {
|
|
1072
|
-
S(!0), w(null);
|
|
1073
|
-
const x = new W(e), l = await new ne(x, t.appId).getTenantSettings(t.id);
|
|
1074
|
-
T(l);
|
|
1075
|
-
} catch (x) {
|
|
1076
|
-
const d = x instanceof Error ? x : new Error("Failed to load tenant settings");
|
|
1077
|
-
w(d), T(null);
|
|
1078
|
-
} finally {
|
|
1079
|
-
S(!1);
|
|
1080
|
-
}
|
|
1081
|
-
}, [e, t]), f = X(
|
|
1082
|
-
async (x) => {
|
|
1083
|
-
if (!(t != null && t.id) || !s)
|
|
1084
|
-
throw new Error("Tenant ID and authentication required to update settings");
|
|
1085
|
-
try {
|
|
1086
|
-
S(!0), w(null);
|
|
1087
|
-
const d = new W(e), l = new ne(d, t.appId, s), a = { settings: x }, u = await l.updateTenantSettings(t.id, a);
|
|
1088
|
-
T(u);
|
|
1089
|
-
} catch (d) {
|
|
1090
|
-
const l = d instanceof Error ? d : new Error("Failed to update tenant settings");
|
|
1091
|
-
throw w(l), l;
|
|
1092
|
-
} finally {
|
|
1093
|
-
S(!1);
|
|
1094
|
-
}
|
|
1095
|
-
},
|
|
1096
|
-
[e, t, s]
|
|
1097
|
-
), y = X(() => {
|
|
1098
|
-
v();
|
|
1099
|
-
}, [v]), c = X(
|
|
1100
|
-
(x) => {
|
|
1101
|
-
if (!p)
|
|
1102
|
-
return { isValid: !0, errors: [] };
|
|
1103
|
-
const d = [];
|
|
1104
|
-
try {
|
|
1105
|
-
return p.properties && Object.entries(p.properties).forEach(([l, a]) => {
|
|
1106
|
-
var k;
|
|
1107
|
-
const u = x[l];
|
|
1108
|
-
if ((k = p.required) != null && k.includes(l) && u == null) {
|
|
1109
|
-
d.push(`Field '${l}' is required`);
|
|
1110
|
-
return;
|
|
1111
|
-
}
|
|
1112
|
-
if (u != null) {
|
|
1113
|
-
if (a.type) {
|
|
1114
|
-
const F = a.type, m = typeof u;
|
|
1115
|
-
F === "string" && m !== "string" ? d.push(`Field '${l}' must be a string`) : (F === "number" || F === "integer") && m !== "number" ? d.push(`Field '${l}' must be a number`) : F === "boolean" && m !== "boolean" ? d.push(`Field '${l}' must be a boolean`) : F === "array" && !Array.isArray(u) && d.push(`Field '${l}' must be an array`);
|
|
1116
|
-
}
|
|
1117
|
-
a.minLength !== void 0 && typeof u == "string" && u.length < a.minLength && d.push(
|
|
1118
|
-
`Field '${l}' must be at least ${a.minLength} characters long`
|
|
1119
|
-
), a.maxLength !== void 0 && typeof u == "string" && u.length > a.maxLength && d.push(
|
|
1120
|
-
`Field '${l}' must be no more than ${a.maxLength} characters long`
|
|
1121
|
-
), a.minimum !== void 0 && typeof u == "number" && u < a.minimum && d.push(`Field '${l}' must be at least ${a.minimum}`), a.maximum !== void 0 && typeof u == "number" && u > a.maximum && d.push(`Field '${l}' must be no more than ${a.maximum}`), a.pattern && typeof u == "string" && (new RegExp(a.pattern).test(u) || d.push(`Field '${l}' does not match the required pattern`)), a.enum && !a.enum.includes(u) && d.push(`Field '${l}' must be one of: ${a.enum.join(", ")}`);
|
|
1122
|
-
}
|
|
1123
|
-
}), {
|
|
1124
|
-
isValid: d.length === 0,
|
|
1125
|
-
errors: d
|
|
1126
|
-
};
|
|
1127
|
-
} catch {
|
|
1128
|
-
return {
|
|
1129
|
-
isValid: !1,
|
|
1130
|
-
errors: ["Invalid settings schema or validation error"]
|
|
1131
|
-
};
|
|
1132
|
-
}
|
|
1133
|
-
},
|
|
1134
|
-
[p]
|
|
1135
|
-
);
|
|
1136
|
-
K(() => {
|
|
1137
|
-
t != null && t.id ? v() : (T(null), w(null), S(!1));
|
|
1138
|
-
}, [t == null ? void 0 : t.id, v]);
|
|
1139
|
-
const C = N(
|
|
1140
|
-
() => ({
|
|
1141
|
-
// Settings
|
|
1142
|
-
settings: o,
|
|
1143
|
-
settingsSchema: p,
|
|
1144
|
-
isSettingsLoading: M,
|
|
1145
|
-
settingsError: E,
|
|
1146
|
-
// Actions
|
|
1147
|
-
updateSettings: f,
|
|
1148
|
-
refreshSettings: y,
|
|
1149
|
-
// Validation
|
|
1150
|
-
validateSettings: c
|
|
1151
|
-
}),
|
|
1152
|
-
[
|
|
1153
|
-
o,
|
|
1154
|
-
p,
|
|
1155
|
-
M,
|
|
1156
|
-
E,
|
|
1157
|
-
f,
|
|
1158
|
-
y,
|
|
1159
|
-
c
|
|
1160
|
-
]
|
|
1161
|
-
);
|
|
1162
|
-
return /* @__PURE__ */ i(fe.Provider, { value: C, children: n });
|
|
1163
|
-
}
|
|
1164
|
-
function ke() {
|
|
1165
|
-
const n = re(fe);
|
|
1166
|
-
if (!n)
|
|
1167
|
-
throw new Error("useTenantSettings must be used within a TenantProvider");
|
|
1168
|
-
return n;
|
|
1169
|
-
}
|
|
1170
|
-
function et() {
|
|
1171
|
-
const {
|
|
1172
|
-
settings: n,
|
|
1173
|
-
settingsSchema: e,
|
|
1174
|
-
isSettingsLoading: t,
|
|
1175
|
-
settingsError: r,
|
|
1176
|
-
updateSettings: s,
|
|
1177
|
-
validateSettings: o
|
|
1178
|
-
} = ke();
|
|
1179
|
-
return {
|
|
1180
|
-
settings: n,
|
|
1181
|
-
settingsSchema: e,
|
|
1182
|
-
isLoading: t,
|
|
1183
|
-
error: r,
|
|
1184
|
-
updateSettings: s,
|
|
1185
|
-
validateSettings: o
|
|
1186
|
-
};
|
|
1210
|
+
return i;
|
|
1187
1211
|
}
|
|
1188
|
-
var
|
|
1189
|
-
const
|
|
1212
|
+
var J = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(J || {});
|
|
1213
|
+
const de = () => /* @__PURE__ */ u(
|
|
1190
1214
|
"div",
|
|
1191
1215
|
{
|
|
1192
1216
|
style: {
|
|
@@ -1202,10 +1226,10 @@ const le = () => /* @__PURE__ */ g(
|
|
|
1202
1226
|
margin: "20px 0"
|
|
1203
1227
|
},
|
|
1204
1228
|
children: [
|
|
1205
|
-
/* @__PURE__ */
|
|
1206
|
-
/* @__PURE__ */
|
|
1207
|
-
/* @__PURE__ */
|
|
1208
|
-
/* @__PURE__ */
|
|
1229
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "🔒" }),
|
|
1230
|
+
/* @__PURE__ */ n("h3", { style: { color: "#495057", marginBottom: "10px" }, children: "Access Required" }),
|
|
1231
|
+
/* @__PURE__ */ n("p", { style: { color: "#6c757d", fontSize: "14px", marginBottom: "15px" }, children: "You need to be signed in to view this content." }),
|
|
1232
|
+
/* @__PURE__ */ n(
|
|
1209
1233
|
"button",
|
|
1210
1234
|
{
|
|
1211
1235
|
style: {
|
|
@@ -1223,11 +1247,11 @@ const le = () => /* @__PURE__ */ g(
|
|
|
1223
1247
|
)
|
|
1224
1248
|
]
|
|
1225
1249
|
}
|
|
1226
|
-
),
|
|
1227
|
-
userType:
|
|
1250
|
+
), ue = ({
|
|
1251
|
+
userType: i,
|
|
1228
1252
|
minUserType: e,
|
|
1229
1253
|
missingPermissions: t
|
|
1230
|
-
}) => /* @__PURE__ */
|
|
1254
|
+
}) => /* @__PURE__ */ u(
|
|
1231
1255
|
"div",
|
|
1232
1256
|
{
|
|
1233
1257
|
style: {
|
|
@@ -1243,57 +1267,57 @@ const le = () => /* @__PURE__ */ g(
|
|
|
1243
1267
|
margin: "20px 0"
|
|
1244
1268
|
},
|
|
1245
1269
|
children: [
|
|
1246
|
-
/* @__PURE__ */
|
|
1247
|
-
/* @__PURE__ */
|
|
1248
|
-
e &&
|
|
1249
|
-
/* @__PURE__ */
|
|
1270
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
|
|
1271
|
+
/* @__PURE__ */ n("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
|
|
1272
|
+
e && i ? /* @__PURE__ */ u(B, { children: [
|
|
1273
|
+
/* @__PURE__ */ u("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
|
|
1250
1274
|
"This content requires ",
|
|
1251
|
-
/* @__PURE__ */
|
|
1275
|
+
/* @__PURE__ */ n("strong", { children: e }),
|
|
1252
1276
|
" access level or higher."
|
|
1253
1277
|
] }),
|
|
1254
|
-
/* @__PURE__ */
|
|
1278
|
+
/* @__PURE__ */ u("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1255
1279
|
"Your current access level: ",
|
|
1256
|
-
/* @__PURE__ */
|
|
1280
|
+
/* @__PURE__ */ n("strong", { children: i })
|
|
1257
1281
|
] })
|
|
1258
|
-
] }) : /* @__PURE__ */
|
|
1259
|
-
/* @__PURE__ */
|
|
1260
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1282
|
+
] }) : /* @__PURE__ */ u(B, { children: [
|
|
1283
|
+
/* @__PURE__ */ n("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
|
|
1284
|
+
t && t.length > 0 && /* @__PURE__ */ u("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1261
1285
|
"Required permissions: ",
|
|
1262
|
-
/* @__PURE__ */
|
|
1286
|
+
/* @__PURE__ */ n("strong", { children: t.join(", ") })
|
|
1263
1287
|
] })
|
|
1264
1288
|
] })
|
|
1265
1289
|
]
|
|
1266
1290
|
}
|
|
1267
|
-
),
|
|
1291
|
+
), Ie = (i, e) => {
|
|
1268
1292
|
const t = {
|
|
1269
|
-
[
|
|
1270
|
-
[
|
|
1271
|
-
[
|
|
1293
|
+
[J.USER]: 1,
|
|
1294
|
+
[J.TENANT_ADMIN]: 2,
|
|
1295
|
+
[J.SUPERUSER]: 3
|
|
1272
1296
|
};
|
|
1273
|
-
return t[
|
|
1297
|
+
return t[i] >= t[e];
|
|
1274
1298
|
};
|
|
1275
|
-
function
|
|
1276
|
-
children:
|
|
1299
|
+
function it({
|
|
1300
|
+
children: i,
|
|
1277
1301
|
fallback: e,
|
|
1278
1302
|
minUserType: t,
|
|
1279
1303
|
requiredPermissions: r,
|
|
1280
1304
|
requireAllPermissions: s = !1
|
|
1281
1305
|
}) {
|
|
1282
|
-
const { hasValidSession:
|
|
1283
|
-
if (!
|
|
1284
|
-
return /* @__PURE__ */
|
|
1285
|
-
const
|
|
1286
|
-
if (!
|
|
1287
|
-
return /* @__PURE__ */
|
|
1288
|
-
if (t && !
|
|
1289
|
-
return /* @__PURE__ */
|
|
1290
|
-
if (r && r.length > 0 && !(s ?
|
|
1291
|
-
const
|
|
1292
|
-
return /* @__PURE__ */
|
|
1293
|
-
}
|
|
1294
|
-
return /* @__PURE__ */
|
|
1306
|
+
const { hasValidSession: a, sessionManager: v, hasPermission: M, hasAnyPermission: k, hasAllPermissions: P } = se();
|
|
1307
|
+
if (!a())
|
|
1308
|
+
return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(de, {}) });
|
|
1309
|
+
const h = v.getUser();
|
|
1310
|
+
if (!h)
|
|
1311
|
+
return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(de, {}) });
|
|
1312
|
+
if (t && !Ie(h.userType, t))
|
|
1313
|
+
return /* @__PURE__ */ n(ue, { userType: h.userType, minUserType: t });
|
|
1314
|
+
if (r && r.length > 0 && !(s ? P(r) : k(r))) {
|
|
1315
|
+
const x = r.filter((f) => !M(f)).map((f) => typeof f == "string" ? f : f.name);
|
|
1316
|
+
return /* @__PURE__ */ n(ue, { missingPermissions: x });
|
|
1317
|
+
}
|
|
1318
|
+
return /* @__PURE__ */ n(B, { children: i });
|
|
1295
1319
|
}
|
|
1296
|
-
const
|
|
1320
|
+
const He = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1297
1321
|
"div",
|
|
1298
1322
|
{
|
|
1299
1323
|
style: {
|
|
@@ -1306,7 +1330,7 @@ const Ee = ({ redirectPath: n }) => /* @__PURE__ */ i(
|
|
|
1306
1330
|
backgroundColor: "#f9fafb",
|
|
1307
1331
|
textAlign: "center"
|
|
1308
1332
|
},
|
|
1309
|
-
children: /* @__PURE__ */
|
|
1333
|
+
children: /* @__PURE__ */ u(
|
|
1310
1334
|
"div",
|
|
1311
1335
|
{
|
|
1312
1336
|
style: {
|
|
@@ -1317,23 +1341,23 @@ const Ee = ({ redirectPath: n }) => /* @__PURE__ */ i(
|
|
|
1317
1341
|
maxWidth: "400px"
|
|
1318
1342
|
},
|
|
1319
1343
|
children: [
|
|
1320
|
-
/* @__PURE__ */
|
|
1321
|
-
/* @__PURE__ */
|
|
1322
|
-
/* @__PURE__ */
|
|
1323
|
-
/* @__PURE__ */
|
|
1344
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
|
|
1345
|
+
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
|
|
1346
|
+
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
|
|
1347
|
+
/* @__PURE__ */ u("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1324
1348
|
"Redirecting to ",
|
|
1325
|
-
|
|
1349
|
+
i,
|
|
1326
1350
|
"..."
|
|
1327
1351
|
] })
|
|
1328
1352
|
]
|
|
1329
1353
|
}
|
|
1330
1354
|
)
|
|
1331
1355
|
}
|
|
1332
|
-
),
|
|
1333
|
-
userType:
|
|
1356
|
+
), he = ({
|
|
1357
|
+
userType: i,
|
|
1334
1358
|
minUserType: e,
|
|
1335
1359
|
missingPermissions: t
|
|
1336
|
-
}) => /* @__PURE__ */
|
|
1360
|
+
}) => /* @__PURE__ */ n(
|
|
1337
1361
|
"div",
|
|
1338
1362
|
{
|
|
1339
1363
|
style: {
|
|
@@ -1346,7 +1370,7 @@ const Ee = ({ redirectPath: n }) => /* @__PURE__ */ i(
|
|
|
1346
1370
|
backgroundColor: "#f9fafb",
|
|
1347
1371
|
textAlign: "center"
|
|
1348
1372
|
},
|
|
1349
|
-
children: /* @__PURE__ */
|
|
1373
|
+
children: /* @__PURE__ */ u(
|
|
1350
1374
|
"div",
|
|
1351
1375
|
{
|
|
1352
1376
|
style: {
|
|
@@ -1357,63 +1381,63 @@ const Ee = ({ redirectPath: n }) => /* @__PURE__ */ i(
|
|
|
1357
1381
|
maxWidth: "400px"
|
|
1358
1382
|
},
|
|
1359
1383
|
children: [
|
|
1360
|
-
/* @__PURE__ */
|
|
1361
|
-
/* @__PURE__ */
|
|
1362
|
-
e &&
|
|
1363
|
-
/* @__PURE__ */
|
|
1384
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
|
|
1385
|
+
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
|
|
1386
|
+
e && i ? /* @__PURE__ */ u(B, { children: [
|
|
1387
|
+
/* @__PURE__ */ u("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
|
|
1364
1388
|
"This page requires ",
|
|
1365
|
-
/* @__PURE__ */
|
|
1389
|
+
/* @__PURE__ */ n("strong", { children: e }),
|
|
1366
1390
|
" access level or higher."
|
|
1367
1391
|
] }),
|
|
1368
|
-
/* @__PURE__ */
|
|
1392
|
+
/* @__PURE__ */ u("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1369
1393
|
"Your current access level: ",
|
|
1370
|
-
/* @__PURE__ */
|
|
1394
|
+
/* @__PURE__ */ n("strong", { children: i })
|
|
1371
1395
|
] })
|
|
1372
|
-
] }) : /* @__PURE__ */
|
|
1373
|
-
/* @__PURE__ */
|
|
1374
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1396
|
+
] }) : /* @__PURE__ */ u(B, { children: [
|
|
1397
|
+
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
|
|
1398
|
+
t && t.length > 0 && /* @__PURE__ */ u("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1375
1399
|
"Required permissions: ",
|
|
1376
|
-
/* @__PURE__ */
|
|
1400
|
+
/* @__PURE__ */ n("strong", { children: t.join(", ") })
|
|
1377
1401
|
] })
|
|
1378
1402
|
] })
|
|
1379
1403
|
]
|
|
1380
1404
|
}
|
|
1381
1405
|
)
|
|
1382
1406
|
}
|
|
1383
|
-
),
|
|
1407
|
+
), $e = (i, e) => {
|
|
1384
1408
|
const t = {
|
|
1385
|
-
[
|
|
1386
|
-
[
|
|
1387
|
-
[
|
|
1409
|
+
[J.USER]: 1,
|
|
1410
|
+
[J.TENANT_ADMIN]: 2,
|
|
1411
|
+
[J.SUPERUSER]: 3
|
|
1388
1412
|
};
|
|
1389
|
-
return t[
|
|
1413
|
+
return t[i] >= t[e];
|
|
1390
1414
|
};
|
|
1391
|
-
function
|
|
1392
|
-
children:
|
|
1415
|
+
function ot({
|
|
1416
|
+
children: i,
|
|
1393
1417
|
redirectTo: e = "/login",
|
|
1394
1418
|
minUserType: t,
|
|
1395
1419
|
requiredPermissions: r,
|
|
1396
1420
|
requireAllPermissions: s = !1,
|
|
1397
|
-
fallback:
|
|
1421
|
+
fallback: a
|
|
1398
1422
|
}) {
|
|
1399
|
-
const { hasValidSession:
|
|
1400
|
-
if (!
|
|
1401
|
-
return
|
|
1402
|
-
/* @__PURE__ */
|
|
1403
|
-
/* @__PURE__ */
|
|
1423
|
+
const { hasValidSession: v, sessionManager: M, hasPermission: k, hasAnyPermission: P, hasAllPermissions: h } = se(), g = me();
|
|
1424
|
+
if (!v())
|
|
1425
|
+
return a ? /* @__PURE__ */ n(B, { children: a }) : /* @__PURE__ */ u(B, { children: [
|
|
1426
|
+
/* @__PURE__ */ n(He, { redirectPath: e }),
|
|
1427
|
+
/* @__PURE__ */ n(ae, { to: e, state: { from: g.pathname }, replace: !0 })
|
|
1404
1428
|
] });
|
|
1405
|
-
const
|
|
1406
|
-
if (!
|
|
1407
|
-
return /* @__PURE__ */
|
|
1408
|
-
if (t &&
|
|
1409
|
-
return /* @__PURE__ */
|
|
1410
|
-
if (r && r.length > 0 && !(s ?
|
|
1411
|
-
const
|
|
1412
|
-
return /* @__PURE__ */
|
|
1413
|
-
}
|
|
1414
|
-
return /* @__PURE__ */
|
|
1429
|
+
const x = M.getUser();
|
|
1430
|
+
if (!x)
|
|
1431
|
+
return /* @__PURE__ */ n(ae, { to: e, state: { from: g.pathname }, replace: !0 });
|
|
1432
|
+
if (t && !$e(x.userType, t))
|
|
1433
|
+
return /* @__PURE__ */ n(he, { userType: x.userType, minUserType: t });
|
|
1434
|
+
if (r && r.length > 0 && !(s ? h(r) : P(r))) {
|
|
1435
|
+
const A = r.filter((F) => !k(F)).map((F) => typeof F == "string" ? F : F.name);
|
|
1436
|
+
return /* @__PURE__ */ n(he, { missingPermissions: A });
|
|
1437
|
+
}
|
|
1438
|
+
return /* @__PURE__ */ n(B, { children: i });
|
|
1415
1439
|
}
|
|
1416
|
-
const
|
|
1440
|
+
const Ce = () => /* @__PURE__ */ u(
|
|
1417
1441
|
"div",
|
|
1418
1442
|
{
|
|
1419
1443
|
style: {
|
|
@@ -1425,19 +1449,19 @@ const Fe = () => /* @__PURE__ */ g(
|
|
|
1425
1449
|
color: "#dc2626"
|
|
1426
1450
|
},
|
|
1427
1451
|
children: [
|
|
1428
|
-
/* @__PURE__ */
|
|
1429
|
-
/* @__PURE__ */
|
|
1452
|
+
/* @__PURE__ */ n("h3", { style: { margin: "0 0 1rem 0" }, children: "🔒 Subscription Required" }),
|
|
1453
|
+
/* @__PURE__ */ n("p", { style: { margin: 0 }, children: "This feature requires a higher subscription plan. Please upgrade your plan to access this content." })
|
|
1430
1454
|
]
|
|
1431
1455
|
}
|
|
1432
1456
|
);
|
|
1433
|
-
function
|
|
1434
|
-
children:
|
|
1435
|
-
fallback: e = /* @__PURE__ */
|
|
1457
|
+
function at({
|
|
1458
|
+
children: i,
|
|
1459
|
+
fallback: e = /* @__PURE__ */ n(Ce, {}),
|
|
1436
1460
|
allowedPlans: t,
|
|
1437
1461
|
requiredFeature: r
|
|
1438
1462
|
}) {
|
|
1439
|
-
const { subscription: s, hasAllowedPlan:
|
|
1440
|
-
return M ? /* @__PURE__ */
|
|
1463
|
+
const { subscription: s, hasAllowedPlan: a, isFeatureEnabled: v, loading: M } = Fe();
|
|
1464
|
+
return M ? /* @__PURE__ */ n(
|
|
1441
1465
|
"div",
|
|
1442
1466
|
{
|
|
1443
1467
|
style: {
|
|
@@ -1447,9 +1471,9 @@ function st({
|
|
|
1447
1471
|
},
|
|
1448
1472
|
children: "Loading subscription..."
|
|
1449
1473
|
}
|
|
1450
|
-
) : s ? s.isActive ? t && t.length > 0 && !
|
|
1474
|
+
) : s ? s.isActive ? t && t.length > 0 && !a(t) ? /* @__PURE__ */ n(B, { children: e }) : r && !v(r) ? /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: i }) : /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: e });
|
|
1451
1475
|
}
|
|
1452
|
-
const
|
|
1476
|
+
const Le = ({ flagName: i }) => /* @__PURE__ */ u(
|
|
1453
1477
|
"div",
|
|
1454
1478
|
{
|
|
1455
1479
|
style: {
|
|
@@ -1466,19 +1490,19 @@ const Ie = ({ flagName: n }) => /* @__PURE__ */ g(
|
|
|
1466
1490
|
color: "#6c757d"
|
|
1467
1491
|
},
|
|
1468
1492
|
children: [
|
|
1469
|
-
/* @__PURE__ */
|
|
1470
|
-
/* @__PURE__ */
|
|
1471
|
-
/* @__PURE__ */
|
|
1493
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
|
|
1494
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
|
|
1495
|
+
/* @__PURE__ */ u("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
|
|
1472
1496
|
'Feature flag "',
|
|
1473
|
-
|
|
1497
|
+
i,
|
|
1474
1498
|
'" is disabled'
|
|
1475
1499
|
] })
|
|
1476
1500
|
]
|
|
1477
1501
|
}
|
|
1478
1502
|
);
|
|
1479
|
-
function
|
|
1480
|
-
const { isEnabled: r, loading: s } =
|
|
1481
|
-
return s ? /* @__PURE__ */
|
|
1503
|
+
function lt({ name: i, children: e, fallback: t }) {
|
|
1504
|
+
const { isEnabled: r, loading: s } = Ee();
|
|
1505
|
+
return s ? /* @__PURE__ */ n(
|
|
1482
1506
|
"div",
|
|
1483
1507
|
{
|
|
1484
1508
|
style: {
|
|
@@ -1491,9 +1515,9 @@ function nt({ name: n, children: e, fallback: t }) {
|
|
|
1491
1515
|
},
|
|
1492
1516
|
children: "Loading feature flags..."
|
|
1493
1517
|
}
|
|
1494
|
-
) : (console.log(
|
|
1518
|
+
) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: t || /* @__PURE__ */ n(Le, { flagName: i }) }));
|
|
1495
1519
|
}
|
|
1496
|
-
const
|
|
1520
|
+
const De = () => /* @__PURE__ */ u(
|
|
1497
1521
|
"svg",
|
|
1498
1522
|
{
|
|
1499
1523
|
width: "16",
|
|
@@ -1506,11 +1530,11 @@ const He = () => /* @__PURE__ */ g(
|
|
|
1506
1530
|
strokeLinejoin: "round",
|
|
1507
1531
|
style: { flexShrink: 0 },
|
|
1508
1532
|
children: [
|
|
1509
|
-
/* @__PURE__ */
|
|
1510
|
-
/* @__PURE__ */
|
|
1533
|
+
/* @__PURE__ */ n("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
|
|
1534
|
+
/* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "3" })
|
|
1511
1535
|
]
|
|
1512
1536
|
}
|
|
1513
|
-
),
|
|
1537
|
+
), Be = () => /* @__PURE__ */ u(
|
|
1514
1538
|
"svg",
|
|
1515
1539
|
{
|
|
1516
1540
|
width: "16",
|
|
@@ -1523,14 +1547,14 @@ const He = () => /* @__PURE__ */ g(
|
|
|
1523
1547
|
strokeLinejoin: "round",
|
|
1524
1548
|
style: { flexShrink: 0 },
|
|
1525
1549
|
children: [
|
|
1526
|
-
/* @__PURE__ */
|
|
1527
|
-
/* @__PURE__ */
|
|
1550
|
+
/* @__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" }),
|
|
1551
|
+
/* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
1528
1552
|
]
|
|
1529
1553
|
}
|
|
1530
|
-
),
|
|
1531
|
-
showPassword: /* @__PURE__ */
|
|
1532
|
-
hidePassword: /* @__PURE__ */
|
|
1533
|
-
},
|
|
1554
|
+
), Ue = {
|
|
1555
|
+
showPassword: /* @__PURE__ */ n(De, {}),
|
|
1556
|
+
hidePassword: /* @__PURE__ */ n(Be, {})
|
|
1557
|
+
}, qe = {
|
|
1534
1558
|
title: "Sign In",
|
|
1535
1559
|
emailLabel: "Email",
|
|
1536
1560
|
emailPlaceholder: "Enter your email",
|
|
@@ -1542,7 +1566,7 @@ const He = () => /* @__PURE__ */ g(
|
|
|
1542
1566
|
signupText: "Don't have an account?",
|
|
1543
1567
|
errorMessage: "Invalid email or password",
|
|
1544
1568
|
loadingText: "Signing in..."
|
|
1545
|
-
},
|
|
1569
|
+
}, Ne = {
|
|
1546
1570
|
container: {
|
|
1547
1571
|
maxWidth: "400px",
|
|
1548
1572
|
width: "100%",
|
|
@@ -1649,119 +1673,119 @@ const He = () => /* @__PURE__ */ g(
|
|
|
1649
1673
|
fontSize: "0.875rem"
|
|
1650
1674
|
}
|
|
1651
1675
|
};
|
|
1652
|
-
function
|
|
1653
|
-
copy:
|
|
1676
|
+
function ct({
|
|
1677
|
+
copy: i = {},
|
|
1654
1678
|
styles: e = {},
|
|
1655
1679
|
icons: t = {},
|
|
1656
1680
|
onSuccess: r,
|
|
1657
1681
|
onError: s,
|
|
1658
|
-
onForgotPassword:
|
|
1659
|
-
onSignupClick:
|
|
1682
|
+
onForgotPassword: a,
|
|
1683
|
+
onSignupClick: v,
|
|
1660
1684
|
showForgotPassword: M = !0,
|
|
1661
|
-
showSignupLink:
|
|
1662
|
-
className:
|
|
1685
|
+
showSignupLink: k = !0,
|
|
1686
|
+
className: P
|
|
1663
1687
|
}) {
|
|
1664
|
-
const [
|
|
1665
|
-
const
|
|
1666
|
-
return
|
|
1667
|
-
},
|
|
1668
|
-
if (
|
|
1669
|
-
if (!(
|
|
1670
|
-
|
|
1688
|
+
const [h, g] = m(""), [x, f] = m(""), [A, F] = m(!1), [y, C] = m(!1), [p, b] = m(""), [T, R] = m({}), { login: L } = se(), { tenant: E } = Z(), D = { ...qe, ...i }, l = { ...Ne, ...e }, w = { ...Ue, ...t }, d = () => {
|
|
1689
|
+
const I = {};
|
|
1690
|
+
return h.trim() || (I.email = !0), x.trim() || (I.password = !0), R(I), Object.keys(I).length === 0;
|
|
1691
|
+
}, o = async (I) => {
|
|
1692
|
+
if (I.preventDefault(), !!d()) {
|
|
1693
|
+
if (!(E != null && E.id)) {
|
|
1694
|
+
b("Tenant not found");
|
|
1671
1695
|
return;
|
|
1672
1696
|
}
|
|
1673
|
-
|
|
1697
|
+
C(!0), b("");
|
|
1674
1698
|
try {
|
|
1675
|
-
const
|
|
1676
|
-
r == null || r(
|
|
1677
|
-
} catch (
|
|
1678
|
-
const _ =
|
|
1679
|
-
|
|
1699
|
+
const N = await L(h, x, E.id);
|
|
1700
|
+
r == null || r(N);
|
|
1701
|
+
} catch (N) {
|
|
1702
|
+
const _ = N.message || D.errorMessage;
|
|
1703
|
+
b(_), s == null || s(_);
|
|
1680
1704
|
} finally {
|
|
1681
|
-
|
|
1705
|
+
C(!1);
|
|
1682
1706
|
}
|
|
1683
1707
|
}
|
|
1684
|
-
},
|
|
1685
|
-
...
|
|
1686
|
-
...
|
|
1687
|
-
}),
|
|
1688
|
-
...
|
|
1689
|
-
...
|
|
1690
|
-
...!
|
|
1708
|
+
}, c = (I) => ({
|
|
1709
|
+
...l.input,
|
|
1710
|
+
...T[I] ? l.inputError : {}
|
|
1711
|
+
}), W = () => ({
|
|
1712
|
+
...l.button,
|
|
1713
|
+
...y ? l.buttonLoading : {},
|
|
1714
|
+
...!h || !x || y ? l.buttonDisabled : {}
|
|
1691
1715
|
});
|
|
1692
|
-
return /* @__PURE__ */
|
|
1693
|
-
/* @__PURE__ */
|
|
1694
|
-
/* @__PURE__ */
|
|
1695
|
-
/* @__PURE__ */
|
|
1696
|
-
/* @__PURE__ */
|
|
1697
|
-
/* @__PURE__ */
|
|
1716
|
+
return /* @__PURE__ */ u("div", { className: P, style: l.container, children: [
|
|
1717
|
+
/* @__PURE__ */ n("h2", { style: l.title, children: D.title }),
|
|
1718
|
+
/* @__PURE__ */ u("form", { onSubmit: o, style: l.form, children: [
|
|
1719
|
+
/* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
|
|
1720
|
+
/* @__PURE__ */ n("label", { style: l.label, children: D.emailLabel }),
|
|
1721
|
+
/* @__PURE__ */ n(
|
|
1698
1722
|
"input",
|
|
1699
1723
|
{
|
|
1700
1724
|
id: "email",
|
|
1701
1725
|
name: "email",
|
|
1702
1726
|
type: "email",
|
|
1703
|
-
value:
|
|
1704
|
-
onChange: (
|
|
1705
|
-
|
|
1727
|
+
value: h,
|
|
1728
|
+
onChange: (I) => {
|
|
1729
|
+
g(I.target.value), T.email && R((N) => ({ ...N, email: !1 }));
|
|
1706
1730
|
},
|
|
1707
|
-
placeholder:
|
|
1708
|
-
style:
|
|
1709
|
-
disabled:
|
|
1731
|
+
placeholder: D.emailPlaceholder,
|
|
1732
|
+
style: c("email"),
|
|
1733
|
+
disabled: y
|
|
1710
1734
|
}
|
|
1711
1735
|
)
|
|
1712
1736
|
] }),
|
|
1713
|
-
/* @__PURE__ */
|
|
1714
|
-
/* @__PURE__ */
|
|
1715
|
-
/* @__PURE__ */
|
|
1716
|
-
/* @__PURE__ */
|
|
1737
|
+
/* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
|
|
1738
|
+
/* @__PURE__ */ n("label", { style: l.label, children: D.passwordLabel }),
|
|
1739
|
+
/* @__PURE__ */ u("div", { style: l.inputContainer, children: [
|
|
1740
|
+
/* @__PURE__ */ n(
|
|
1717
1741
|
"input",
|
|
1718
1742
|
{
|
|
1719
1743
|
id: "password",
|
|
1720
1744
|
name: "password",
|
|
1721
|
-
type:
|
|
1722
|
-
value:
|
|
1723
|
-
onChange: (
|
|
1724
|
-
f(
|
|
1745
|
+
type: A ? "text" : "password",
|
|
1746
|
+
value: x,
|
|
1747
|
+
onChange: (I) => {
|
|
1748
|
+
f(I.target.value), T.password && R((N) => ({ ...N, password: !1 }));
|
|
1725
1749
|
},
|
|
1726
|
-
placeholder:
|
|
1750
|
+
placeholder: D.passwordPlaceholder,
|
|
1727
1751
|
style: {
|
|
1728
|
-
...
|
|
1752
|
+
...c("password"),
|
|
1729
1753
|
paddingRight: "2.5rem"
|
|
1730
1754
|
// Make room for the icon
|
|
1731
1755
|
},
|
|
1732
|
-
disabled:
|
|
1756
|
+
disabled: y
|
|
1733
1757
|
}
|
|
1734
1758
|
),
|
|
1735
|
-
/* @__PURE__ */
|
|
1759
|
+
/* @__PURE__ */ n(
|
|
1736
1760
|
"button",
|
|
1737
1761
|
{
|
|
1738
1762
|
type: "button",
|
|
1739
|
-
onClick: () =>
|
|
1740
|
-
style:
|
|
1741
|
-
disabled:
|
|
1742
|
-
"aria-label":
|
|
1743
|
-
children:
|
|
1763
|
+
onClick: () => F(!A),
|
|
1764
|
+
style: l.passwordToggle,
|
|
1765
|
+
disabled: y,
|
|
1766
|
+
"aria-label": A ? "Hide password" : "Show password",
|
|
1767
|
+
children: A ? w.hidePassword : w.showPassword
|
|
1744
1768
|
}
|
|
1745
1769
|
)
|
|
1746
1770
|
] })
|
|
1747
1771
|
] }),
|
|
1748
|
-
/* @__PURE__ */
|
|
1749
|
-
|
|
1772
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !h || !x || y, style: W(), children: y ? D.loadingText : D.submitButton }),
|
|
1773
|
+
p && /* @__PURE__ */ n("div", { style: l.errorText, children: p })
|
|
1750
1774
|
] }),
|
|
1751
|
-
(M ||
|
|
1752
|
-
M && /* @__PURE__ */
|
|
1753
|
-
M &&
|
|
1754
|
-
|
|
1755
|
-
/* @__PURE__ */
|
|
1756
|
-
|
|
1775
|
+
(M || k) && /* @__PURE__ */ u("div", { style: l.linkContainer, children: [
|
|
1776
|
+
M && /* @__PURE__ */ n("a", { onClick: a, style: l.link, children: D.forgotPasswordLink }),
|
|
1777
|
+
M && k && /* @__PURE__ */ n("div", { style: l.divider, children: "•" }),
|
|
1778
|
+
k && /* @__PURE__ */ u("div", { children: [
|
|
1779
|
+
/* @__PURE__ */ u("span", { style: l.divider, children: [
|
|
1780
|
+
D.signupText,
|
|
1757
1781
|
" "
|
|
1758
1782
|
] }),
|
|
1759
|
-
/* @__PURE__ */
|
|
1783
|
+
/* @__PURE__ */ n("a", { onClick: v, style: l.link, children: D.signupLink })
|
|
1760
1784
|
] })
|
|
1761
1785
|
] })
|
|
1762
1786
|
] });
|
|
1763
1787
|
}
|
|
1764
|
-
const
|
|
1788
|
+
const Oe = {
|
|
1765
1789
|
title: "Create Account",
|
|
1766
1790
|
nameLabel: "Full Name",
|
|
1767
1791
|
namePlaceholder: "Enter your full name",
|
|
@@ -1781,7 +1805,7 @@ const Be = {
|
|
|
1781
1805
|
passwordMismatchError: "Passwords do not match",
|
|
1782
1806
|
isAdminLabel: "Create new organization",
|
|
1783
1807
|
isAdminDescription: "Check this if you want to create a new organization"
|
|
1784
|
-
},
|
|
1808
|
+
}, ze = {
|
|
1785
1809
|
container: {
|
|
1786
1810
|
maxWidth: "400px",
|
|
1787
1811
|
width: "100%",
|
|
@@ -1880,154 +1904,154 @@ const Be = {
|
|
|
1880
1904
|
fontSize: "0.875rem"
|
|
1881
1905
|
}
|
|
1882
1906
|
};
|
|
1883
|
-
function
|
|
1884
|
-
copy:
|
|
1907
|
+
function dt({
|
|
1908
|
+
copy: i = {},
|
|
1885
1909
|
styles: e = {},
|
|
1886
1910
|
signupType: t = "user",
|
|
1887
1911
|
onSuccess: r,
|
|
1888
1912
|
onError: s,
|
|
1889
|
-
onLoginClick:
|
|
1890
|
-
showLoginLink:
|
|
1913
|
+
onLoginClick: a,
|
|
1914
|
+
showLoginLink: v = !0,
|
|
1891
1915
|
className: M
|
|
1892
1916
|
}) {
|
|
1893
|
-
const [
|
|
1917
|
+
const [k, P] = m(""), [h, g] = m(""), [x, f] = m(""), [A, F] = m(""), [y, C] = m(""), [p, b] = m(!1), [T, R] = m(""), [L, E] = m({}), { signup: D, signupTenantAdmin: l } = se(), { tenant: w } = Z(), d = { ...Oe, ...i }, o = { ...ze, ...e }, c = () => {
|
|
1894
1918
|
const H = {};
|
|
1895
|
-
return
|
|
1896
|
-
},
|
|
1897
|
-
if (H.preventDefault(), !!
|
|
1898
|
-
if (
|
|
1899
|
-
|
|
1919
|
+
return k.trim() || (H.name = !0), h.trim() || (H.email = !0), x.trim() || (H.password = !0), A.trim() || (H.confirmPassword = !0), t === "tenant" && !y.trim() && (H.tenantName = !0), E(H), Object.keys(H).length === 0;
|
|
1920
|
+
}, W = async (H) => {
|
|
1921
|
+
if (H.preventDefault(), !!c()) {
|
|
1922
|
+
if (x !== A) {
|
|
1923
|
+
R(d.passwordMismatchError), E({ confirmPassword: !0 });
|
|
1900
1924
|
return;
|
|
1901
1925
|
}
|
|
1902
|
-
if (t === "user" && !(
|
|
1903
|
-
|
|
1926
|
+
if (t === "user" && !(w != null && w.id)) {
|
|
1927
|
+
R("Tenant not found");
|
|
1904
1928
|
return;
|
|
1905
1929
|
}
|
|
1906
|
-
|
|
1930
|
+
b(!0), R("");
|
|
1907
1931
|
try {
|
|
1908
1932
|
let q;
|
|
1909
|
-
t === "tenant" ? q = await
|
|
1933
|
+
t === "tenant" ? q = await l(h, k, x, y) : q = await D(h, k, x, w.id), r == null || r(q);
|
|
1910
1934
|
} catch (q) {
|
|
1911
|
-
const
|
|
1912
|
-
|
|
1935
|
+
const Y = q.message || d.errorMessage;
|
|
1936
|
+
R(Y), s == null || s(Y);
|
|
1913
1937
|
} finally {
|
|
1914
|
-
|
|
1938
|
+
b(!1);
|
|
1915
1939
|
}
|
|
1916
1940
|
}
|
|
1917
|
-
},
|
|
1918
|
-
...
|
|
1919
|
-
...
|
|
1920
|
-
}),
|
|
1921
|
-
...
|
|
1922
|
-
...
|
|
1923
|
-
...!
|
|
1924
|
-
}), _ =
|
|
1925
|
-
return /* @__PURE__ */
|
|
1926
|
-
/* @__PURE__ */
|
|
1927
|
-
/* @__PURE__ */
|
|
1928
|
-
/* @__PURE__ */
|
|
1929
|
-
/* @__PURE__ */
|
|
1930
|
-
/* @__PURE__ */
|
|
1941
|
+
}, I = (H) => ({
|
|
1942
|
+
...o.input,
|
|
1943
|
+
...L[H] ? o.inputError : {}
|
|
1944
|
+
}), N = () => ({
|
|
1945
|
+
...o.button,
|
|
1946
|
+
...p ? o.buttonLoading : {},
|
|
1947
|
+
...!k || !h || !x || !A || p || t === "tenant" && !y ? o.buttonDisabled : {}
|
|
1948
|
+
}), _ = k && h && x && A && (t === "user" || y);
|
|
1949
|
+
return /* @__PURE__ */ u("div", { className: M, style: o.container, children: [
|
|
1950
|
+
/* @__PURE__ */ n("h2", { style: o.title, children: d.title }),
|
|
1951
|
+
/* @__PURE__ */ u("form", { onSubmit: W, style: o.form, children: [
|
|
1952
|
+
/* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
|
|
1953
|
+
/* @__PURE__ */ n("label", { style: o.label, children: d.nameLabel }),
|
|
1954
|
+
/* @__PURE__ */ n(
|
|
1931
1955
|
"input",
|
|
1932
1956
|
{
|
|
1933
1957
|
id: "name",
|
|
1934
1958
|
name: "name",
|
|
1935
1959
|
type: "text",
|
|
1936
|
-
value:
|
|
1960
|
+
value: k,
|
|
1937
1961
|
onChange: (H) => {
|
|
1938
|
-
|
|
1962
|
+
P(H.target.value), L.name && E((q) => ({ ...q, name: !1 }));
|
|
1939
1963
|
},
|
|
1940
|
-
placeholder:
|
|
1941
|
-
style:
|
|
1942
|
-
disabled:
|
|
1964
|
+
placeholder: d.namePlaceholder,
|
|
1965
|
+
style: I("name"),
|
|
1966
|
+
disabled: p
|
|
1943
1967
|
}
|
|
1944
1968
|
)
|
|
1945
1969
|
] }),
|
|
1946
|
-
/* @__PURE__ */
|
|
1947
|
-
/* @__PURE__ */
|
|
1948
|
-
/* @__PURE__ */
|
|
1970
|
+
/* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
|
|
1971
|
+
/* @__PURE__ */ n("label", { style: o.label, children: d.emailLabel }),
|
|
1972
|
+
/* @__PURE__ */ n(
|
|
1949
1973
|
"input",
|
|
1950
1974
|
{
|
|
1951
1975
|
id: "email",
|
|
1952
1976
|
name: "email",
|
|
1953
1977
|
type: "email",
|
|
1954
|
-
value:
|
|
1978
|
+
value: h,
|
|
1955
1979
|
onChange: (H) => {
|
|
1956
|
-
|
|
1980
|
+
g(H.target.value), L.email && E((q) => ({ ...q, email: !1 }));
|
|
1957
1981
|
},
|
|
1958
|
-
placeholder:
|
|
1959
|
-
style:
|
|
1960
|
-
disabled:
|
|
1982
|
+
placeholder: d.emailPlaceholder,
|
|
1983
|
+
style: I("email"),
|
|
1984
|
+
disabled: p
|
|
1961
1985
|
}
|
|
1962
1986
|
)
|
|
1963
1987
|
] }),
|
|
1964
|
-
/* @__PURE__ */
|
|
1965
|
-
/* @__PURE__ */
|
|
1966
|
-
/* @__PURE__ */
|
|
1988
|
+
/* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
|
|
1989
|
+
/* @__PURE__ */ n("label", { style: o.label, children: d.passwordLabel }),
|
|
1990
|
+
/* @__PURE__ */ n(
|
|
1967
1991
|
"input",
|
|
1968
1992
|
{
|
|
1969
1993
|
id: "password",
|
|
1970
1994
|
name: "password",
|
|
1971
1995
|
type: "password",
|
|
1972
|
-
value:
|
|
1996
|
+
value: x,
|
|
1973
1997
|
onChange: (H) => {
|
|
1974
|
-
f(H.target.value),
|
|
1998
|
+
f(H.target.value), L.password && E((q) => ({ ...q, password: !1 }));
|
|
1975
1999
|
},
|
|
1976
|
-
placeholder:
|
|
1977
|
-
style:
|
|
1978
|
-
disabled:
|
|
2000
|
+
placeholder: d.passwordPlaceholder,
|
|
2001
|
+
style: I("password"),
|
|
2002
|
+
disabled: p
|
|
1979
2003
|
}
|
|
1980
2004
|
)
|
|
1981
2005
|
] }),
|
|
1982
|
-
/* @__PURE__ */
|
|
1983
|
-
/* @__PURE__ */
|
|
1984
|
-
/* @__PURE__ */
|
|
2006
|
+
/* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
|
|
2007
|
+
/* @__PURE__ */ n("label", { style: o.label, children: d.confirmPasswordLabel }),
|
|
2008
|
+
/* @__PURE__ */ n(
|
|
1985
2009
|
"input",
|
|
1986
2010
|
{
|
|
1987
2011
|
id: "confirmPassword",
|
|
1988
2012
|
name: "confirmPassword",
|
|
1989
2013
|
type: "password",
|
|
1990
|
-
value:
|
|
2014
|
+
value: A,
|
|
1991
2015
|
onChange: (H) => {
|
|
1992
|
-
|
|
2016
|
+
F(H.target.value), L.confirmPassword && E((q) => ({ ...q, confirmPassword: !1 })), T === d.passwordMismatchError && R("");
|
|
1993
2017
|
},
|
|
1994
|
-
placeholder:
|
|
1995
|
-
style:
|
|
1996
|
-
disabled:
|
|
2018
|
+
placeholder: d.confirmPasswordPlaceholder,
|
|
2019
|
+
style: I("confirmPassword"),
|
|
2020
|
+
disabled: p
|
|
1997
2021
|
}
|
|
1998
2022
|
)
|
|
1999
2023
|
] }),
|
|
2000
|
-
t === "tenant" && /* @__PURE__ */
|
|
2001
|
-
/* @__PURE__ */
|
|
2002
|
-
/* @__PURE__ */
|
|
2024
|
+
t === "tenant" && /* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
|
|
2025
|
+
/* @__PURE__ */ n("label", { style: o.label, children: d.tenantNameLabel }),
|
|
2026
|
+
/* @__PURE__ */ n(
|
|
2003
2027
|
"input",
|
|
2004
2028
|
{
|
|
2005
2029
|
id: "tenantName",
|
|
2006
2030
|
name: "tenantName",
|
|
2007
2031
|
type: "text",
|
|
2008
|
-
value:
|
|
2032
|
+
value: y,
|
|
2009
2033
|
onChange: (H) => {
|
|
2010
|
-
|
|
2034
|
+
C(H.target.value), L.tenantName && E((q) => ({ ...q, tenantName: !1 }));
|
|
2011
2035
|
},
|
|
2012
|
-
placeholder:
|
|
2013
|
-
style:
|
|
2014
|
-
disabled:
|
|
2036
|
+
placeholder: d.tenantNamePlaceholder,
|
|
2037
|
+
style: I("tenantName"),
|
|
2038
|
+
disabled: p
|
|
2015
2039
|
}
|
|
2016
2040
|
)
|
|
2017
2041
|
] }),
|
|
2018
|
-
/* @__PURE__ */
|
|
2019
|
-
|
|
2042
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !_ || p, style: N(), children: p ? d.loadingText : d.submitButton }),
|
|
2043
|
+
T && /* @__PURE__ */ n("div", { style: o.errorText, children: T })
|
|
2020
2044
|
] }),
|
|
2021
|
-
|
|
2022
|
-
/* @__PURE__ */
|
|
2023
|
-
|
|
2045
|
+
v && /* @__PURE__ */ u("div", { style: o.linkContainer, children: [
|
|
2046
|
+
/* @__PURE__ */ u("span", { style: o.divider, children: [
|
|
2047
|
+
d.loginText,
|
|
2024
2048
|
" "
|
|
2025
2049
|
] }),
|
|
2026
|
-
/* @__PURE__ */
|
|
2050
|
+
/* @__PURE__ */ n("a", { onClick: a, style: o.link, children: d.loginLink })
|
|
2027
2051
|
] })
|
|
2028
2052
|
] });
|
|
2029
2053
|
}
|
|
2030
|
-
const
|
|
2054
|
+
const je = {
|
|
2031
2055
|
title: "Reset Password",
|
|
2032
2056
|
subtitle: "Enter your email address and we'll send you a link to reset your password.",
|
|
2033
2057
|
emailLabel: "Email",
|
|
@@ -2049,7 +2073,7 @@ const Ue = {
|
|
|
2049
2073
|
resetLoadingText: "Resetting...",
|
|
2050
2074
|
resetSuccessMessage: "Password reset successfully!",
|
|
2051
2075
|
passwordMismatchError: "Passwords do not match"
|
|
2052
|
-
},
|
|
2076
|
+
}, Ve = {
|
|
2053
2077
|
container: {
|
|
2054
2078
|
maxWidth: "400px",
|
|
2055
2079
|
margin: "0 auto",
|
|
@@ -2141,186 +2165,186 @@ const Ue = {
|
|
|
2141
2165
|
cursor: "pointer"
|
|
2142
2166
|
}
|
|
2143
2167
|
};
|
|
2144
|
-
function
|
|
2145
|
-
copy:
|
|
2168
|
+
function ut({
|
|
2169
|
+
copy: i = {},
|
|
2146
2170
|
styles: e = {},
|
|
2147
2171
|
mode: t = "request",
|
|
2148
2172
|
token: r = "",
|
|
2149
2173
|
onSuccess: s,
|
|
2150
|
-
onError:
|
|
2151
|
-
onBackToLogin:
|
|
2174
|
+
onError: a,
|
|
2175
|
+
onBackToLogin: v,
|
|
2152
2176
|
onModeChange: M,
|
|
2153
|
-
className:
|
|
2177
|
+
className: k
|
|
2154
2178
|
}) {
|
|
2155
|
-
const [
|
|
2156
|
-
const
|
|
2157
|
-
return
|
|
2158
|
-
},
|
|
2159
|
-
const
|
|
2160
|
-
return
|
|
2161
|
-
},
|
|
2162
|
-
if (
|
|
2163
|
-
if (!(
|
|
2164
|
-
|
|
2179
|
+
const [P, h] = m(""), [g, x] = m(r), [f, A] = m(""), [F, y] = m(""), [C, p] = m(!1), [b, T] = m(""), [R, L] = m(""), [E, D] = m({}), { requestPasswordReset: l, confirmPasswordReset: w } = se(), { tenant: d } = Z(), o = { ...je, ...i }, c = { ...Ve, ...e }, W = () => {
|
|
2180
|
+
const U = {};
|
|
2181
|
+
return P.trim() || (U.email = !0), D(U), Object.keys(U).length === 0;
|
|
2182
|
+
}, I = () => {
|
|
2183
|
+
const U = {};
|
|
2184
|
+
return g.trim() || (U.token = !0), f.trim() || (U.newPassword = !0), F.trim() || (U.confirmPassword = !0), D(U), Object.keys(U).length === 0;
|
|
2185
|
+
}, N = async (U) => {
|
|
2186
|
+
if (U.preventDefault(), !!W()) {
|
|
2187
|
+
if (!(d != null && d.id)) {
|
|
2188
|
+
T("Tenant not found");
|
|
2165
2189
|
return;
|
|
2166
2190
|
}
|
|
2167
|
-
|
|
2191
|
+
p(!0), T(""), L("");
|
|
2168
2192
|
try {
|
|
2169
|
-
await
|
|
2170
|
-
} catch (
|
|
2171
|
-
const
|
|
2172
|
-
|
|
2193
|
+
await l(P, d.id), L(o.successMessage), s == null || s();
|
|
2194
|
+
} catch (z) {
|
|
2195
|
+
const j = z.message || o.errorMessage;
|
|
2196
|
+
T(j), a == null || a(j);
|
|
2173
2197
|
} finally {
|
|
2174
|
-
|
|
2198
|
+
p(!1);
|
|
2175
2199
|
}
|
|
2176
2200
|
}
|
|
2177
|
-
}, _ = async (
|
|
2178
|
-
if (
|
|
2179
|
-
if (f !==
|
|
2180
|
-
|
|
2201
|
+
}, _ = async (U) => {
|
|
2202
|
+
if (U.preventDefault(), !!I()) {
|
|
2203
|
+
if (f !== F) {
|
|
2204
|
+
T(o.passwordMismatchError), D({ confirmPassword: !0 });
|
|
2181
2205
|
return;
|
|
2182
2206
|
}
|
|
2183
|
-
|
|
2207
|
+
p(!0), T(""), L("");
|
|
2184
2208
|
try {
|
|
2185
|
-
await
|
|
2186
|
-
} catch (
|
|
2187
|
-
const
|
|
2188
|
-
|
|
2209
|
+
await w(g, f), L(o.resetSuccessMessage), s == null || s();
|
|
2210
|
+
} catch (z) {
|
|
2211
|
+
const j = z.message || o.errorMessage;
|
|
2212
|
+
T(j), a == null || a(j);
|
|
2189
2213
|
} finally {
|
|
2190
|
-
|
|
2214
|
+
p(!1);
|
|
2191
2215
|
}
|
|
2192
2216
|
}
|
|
2193
|
-
}, H = (
|
|
2194
|
-
...
|
|
2195
|
-
...
|
|
2217
|
+
}, H = (U) => ({
|
|
2218
|
+
...c.input,
|
|
2219
|
+
...E[U] ? c.inputError : {}
|
|
2196
2220
|
}), q = () => ({
|
|
2197
|
-
...
|
|
2198
|
-
...
|
|
2221
|
+
...c.button,
|
|
2222
|
+
...C ? c.buttonLoading : {}
|
|
2199
2223
|
});
|
|
2200
2224
|
if (t === "reset") {
|
|
2201
|
-
const
|
|
2202
|
-
return /* @__PURE__ */
|
|
2203
|
-
/* @__PURE__ */
|
|
2204
|
-
/* @__PURE__ */
|
|
2205
|
-
/* @__PURE__ */
|
|
2206
|
-
/* @__PURE__ */
|
|
2207
|
-
/* @__PURE__ */
|
|
2208
|
-
/* @__PURE__ */
|
|
2225
|
+
const U = g && f && F;
|
|
2226
|
+
return /* @__PURE__ */ u("div", { className: k, style: c.container, children: [
|
|
2227
|
+
/* @__PURE__ */ n("h2", { style: c.title, children: o.resetTitle }),
|
|
2228
|
+
/* @__PURE__ */ n("p", { style: c.subtitle, children: o.resetSubtitle }),
|
|
2229
|
+
/* @__PURE__ */ u("form", { onSubmit: _, style: c.form, children: [
|
|
2230
|
+
/* @__PURE__ */ u("div", { style: c.fieldGroup, children: [
|
|
2231
|
+
/* @__PURE__ */ n("label", { style: c.label, children: o.tokenLabel }),
|
|
2232
|
+
/* @__PURE__ */ n(
|
|
2209
2233
|
"input",
|
|
2210
2234
|
{
|
|
2211
2235
|
type: "text",
|
|
2212
|
-
value:
|
|
2213
|
-
onChange: (
|
|
2214
|
-
|
|
2236
|
+
value: g,
|
|
2237
|
+
onChange: (z) => {
|
|
2238
|
+
x(z.target.value), E.token && D((j) => ({ ...j, token: !1 }));
|
|
2215
2239
|
},
|
|
2216
|
-
placeholder:
|
|
2240
|
+
placeholder: o.tokenPlaceholder,
|
|
2217
2241
|
style: H("token"),
|
|
2218
|
-
disabled:
|
|
2242
|
+
disabled: C
|
|
2219
2243
|
}
|
|
2220
2244
|
)
|
|
2221
2245
|
] }),
|
|
2222
|
-
/* @__PURE__ */
|
|
2223
|
-
/* @__PURE__ */
|
|
2224
|
-
/* @__PURE__ */
|
|
2246
|
+
/* @__PURE__ */ u("div", { style: c.fieldGroup, children: [
|
|
2247
|
+
/* @__PURE__ */ n("label", { style: c.label, children: o.newPasswordLabel }),
|
|
2248
|
+
/* @__PURE__ */ n(
|
|
2225
2249
|
"input",
|
|
2226
2250
|
{
|
|
2227
2251
|
type: "password",
|
|
2228
2252
|
value: f,
|
|
2229
|
-
onChange: (
|
|
2230
|
-
|
|
2253
|
+
onChange: (z) => {
|
|
2254
|
+
A(z.target.value), E.newPassword && D((j) => ({ ...j, newPassword: !1 }));
|
|
2231
2255
|
},
|
|
2232
|
-
placeholder:
|
|
2256
|
+
placeholder: o.newPasswordPlaceholder,
|
|
2233
2257
|
style: H("newPassword"),
|
|
2234
|
-
disabled:
|
|
2258
|
+
disabled: C
|
|
2235
2259
|
}
|
|
2236
2260
|
)
|
|
2237
2261
|
] }),
|
|
2238
|
-
/* @__PURE__ */
|
|
2239
|
-
/* @__PURE__ */
|
|
2240
|
-
/* @__PURE__ */
|
|
2262
|
+
/* @__PURE__ */ u("div", { style: c.fieldGroup, children: [
|
|
2263
|
+
/* @__PURE__ */ n("label", { style: c.label, children: o.confirmPasswordLabel }),
|
|
2264
|
+
/* @__PURE__ */ n(
|
|
2241
2265
|
"input",
|
|
2242
2266
|
{
|
|
2243
2267
|
type: "password",
|
|
2244
|
-
value:
|
|
2245
|
-
onChange: (
|
|
2246
|
-
|
|
2268
|
+
value: F,
|
|
2269
|
+
onChange: (z) => {
|
|
2270
|
+
y(z.target.value), E.confirmPassword && D((j) => ({ ...j, confirmPassword: !1 })), b === o.passwordMismatchError && T("");
|
|
2247
2271
|
},
|
|
2248
|
-
placeholder:
|
|
2272
|
+
placeholder: o.confirmPasswordPlaceholder,
|
|
2249
2273
|
style: H("confirmPassword"),
|
|
2250
|
-
disabled:
|
|
2274
|
+
disabled: C
|
|
2251
2275
|
}
|
|
2252
2276
|
)
|
|
2253
2277
|
] }),
|
|
2254
|
-
/* @__PURE__ */
|
|
2278
|
+
/* @__PURE__ */ n(
|
|
2255
2279
|
"button",
|
|
2256
2280
|
{
|
|
2257
2281
|
type: "submit",
|
|
2258
|
-
disabled: !
|
|
2282
|
+
disabled: !U || C,
|
|
2259
2283
|
style: {
|
|
2260
2284
|
...q(),
|
|
2261
|
-
...!
|
|
2285
|
+
...!U || C ? c.buttonDisabled : {}
|
|
2262
2286
|
},
|
|
2263
|
-
children:
|
|
2287
|
+
children: C ? o.resetLoadingText : o.resetSubmitButton
|
|
2264
2288
|
}
|
|
2265
2289
|
),
|
|
2266
|
-
|
|
2267
|
-
|
|
2290
|
+
b && /* @__PURE__ */ n("div", { style: c.errorText, children: b }),
|
|
2291
|
+
R && /* @__PURE__ */ n("div", { style: c.successText, children: R })
|
|
2268
2292
|
] }),
|
|
2269
|
-
/* @__PURE__ */
|
|
2270
|
-
/* @__PURE__ */
|
|
2271
|
-
M && /* @__PURE__ */
|
|
2272
|
-
/* @__PURE__ */
|
|
2273
|
-
/* @__PURE__ */
|
|
2293
|
+
/* @__PURE__ */ u("div", { style: c.linkContainer, children: [
|
|
2294
|
+
/* @__PURE__ */ n("a", { onClick: v, style: c.link, children: o.backToLoginLink }),
|
|
2295
|
+
M && /* @__PURE__ */ u(B, { children: [
|
|
2296
|
+
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
2297
|
+
/* @__PURE__ */ n("a", { onClick: () => M("request"), style: c.link, children: "Request New Link" })
|
|
2274
2298
|
] })
|
|
2275
2299
|
] })
|
|
2276
2300
|
] });
|
|
2277
2301
|
}
|
|
2278
|
-
const
|
|
2279
|
-
return /* @__PURE__ */
|
|
2280
|
-
/* @__PURE__ */
|
|
2281
|
-
/* @__PURE__ */
|
|
2282
|
-
/* @__PURE__ */
|
|
2283
|
-
/* @__PURE__ */
|
|
2284
|
-
/* @__PURE__ */
|
|
2285
|
-
/* @__PURE__ */
|
|
2302
|
+
const Y = P;
|
|
2303
|
+
return /* @__PURE__ */ u("div", { className: k, style: c.container, children: [
|
|
2304
|
+
/* @__PURE__ */ n("h2", { style: c.title, children: o.title }),
|
|
2305
|
+
/* @__PURE__ */ n("p", { style: c.subtitle, children: o.subtitle }),
|
|
2306
|
+
/* @__PURE__ */ u("form", { onSubmit: N, style: c.form, children: [
|
|
2307
|
+
/* @__PURE__ */ u("div", { style: c.fieldGroup, children: [
|
|
2308
|
+
/* @__PURE__ */ n("label", { style: c.label, children: o.emailLabel }),
|
|
2309
|
+
/* @__PURE__ */ n(
|
|
2286
2310
|
"input",
|
|
2287
2311
|
{
|
|
2288
2312
|
type: "email",
|
|
2289
|
-
value:
|
|
2290
|
-
onChange: (
|
|
2291
|
-
|
|
2313
|
+
value: P,
|
|
2314
|
+
onChange: (U) => {
|
|
2315
|
+
h(U.target.value), E.email && D((z) => ({ ...z, email: !1 }));
|
|
2292
2316
|
},
|
|
2293
|
-
placeholder:
|
|
2317
|
+
placeholder: o.emailPlaceholder,
|
|
2294
2318
|
style: H("email"),
|
|
2295
|
-
disabled:
|
|
2319
|
+
disabled: C
|
|
2296
2320
|
}
|
|
2297
2321
|
)
|
|
2298
2322
|
] }),
|
|
2299
|
-
/* @__PURE__ */
|
|
2323
|
+
/* @__PURE__ */ n(
|
|
2300
2324
|
"button",
|
|
2301
2325
|
{
|
|
2302
2326
|
type: "submit",
|
|
2303
|
-
disabled: !
|
|
2327
|
+
disabled: !Y || C,
|
|
2304
2328
|
style: {
|
|
2305
2329
|
...q(),
|
|
2306
|
-
...!
|
|
2330
|
+
...!Y || C ? c.buttonDisabled : {}
|
|
2307
2331
|
},
|
|
2308
|
-
children:
|
|
2332
|
+
children: C ? o.loadingText : o.submitButton
|
|
2309
2333
|
}
|
|
2310
2334
|
),
|
|
2311
|
-
|
|
2312
|
-
|
|
2335
|
+
b && /* @__PURE__ */ n("div", { style: c.errorText, children: b }),
|
|
2336
|
+
R && /* @__PURE__ */ n("div", { style: c.successText, children: R })
|
|
2313
2337
|
] }),
|
|
2314
|
-
/* @__PURE__ */
|
|
2315
|
-
/* @__PURE__ */
|
|
2316
|
-
M && /* @__PURE__ */
|
|
2317
|
-
/* @__PURE__ */
|
|
2318
|
-
/* @__PURE__ */
|
|
2338
|
+
/* @__PURE__ */ u("div", { style: c.linkContainer, children: [
|
|
2339
|
+
/* @__PURE__ */ n("a", { onClick: v, style: c.link, children: o.backToLoginLink }),
|
|
2340
|
+
M && /* @__PURE__ */ u(B, { children: [
|
|
2341
|
+
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
2342
|
+
/* @__PURE__ */ n("a", { onClick: () => M("reset"), style: c.link, children: "I have a token" })
|
|
2319
2343
|
] })
|
|
2320
2344
|
] })
|
|
2321
2345
|
] });
|
|
2322
2346
|
}
|
|
2323
|
-
class
|
|
2347
|
+
class ht {
|
|
2324
2348
|
constructor(e, t) {
|
|
2325
2349
|
this.httpService = e, this.sessionManager = t;
|
|
2326
2350
|
}
|
|
@@ -2341,12 +2365,12 @@ class lt {
|
|
|
2341
2365
|
throw new Error("SessionManager is required for private endpoints");
|
|
2342
2366
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
2343
2367
|
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);
|
|
2344
|
-
const s = `/permissions/${r.toString() ? `?${r.toString()}` : ""}`,
|
|
2368
|
+
const s = `/permissions/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
|
|
2345
2369
|
headers: t
|
|
2346
2370
|
});
|
|
2347
2371
|
return {
|
|
2348
|
-
permissions:
|
|
2349
|
-
meta:
|
|
2372
|
+
permissions: a.data,
|
|
2373
|
+
meta: a.meta
|
|
2350
2374
|
};
|
|
2351
2375
|
}
|
|
2352
2376
|
async getPermissionById(e) {
|
|
@@ -2381,14 +2405,14 @@ class lt {
|
|
|
2381
2405
|
async getAppPermissions(e, t) {
|
|
2382
2406
|
const r = new URLSearchParams();
|
|
2383
2407
|
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);
|
|
2384
|
-
const s = `/permissions/apps/${e}${r.toString() ? `?${r.toString()}` : ""}`,
|
|
2408
|
+
const s = `/permissions/apps/${e}${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s);
|
|
2385
2409
|
return {
|
|
2386
|
-
permissions:
|
|
2387
|
-
meta:
|
|
2410
|
+
permissions: a.data,
|
|
2411
|
+
meta: a.meta
|
|
2388
2412
|
};
|
|
2389
2413
|
}
|
|
2390
2414
|
}
|
|
2391
|
-
class
|
|
2415
|
+
class gt {
|
|
2392
2416
|
constructor(e, t) {
|
|
2393
2417
|
this.httpService = e, this.sessionManager = t;
|
|
2394
2418
|
}
|
|
@@ -2405,12 +2429,12 @@ class ct {
|
|
|
2405
2429
|
async getSubscriptionPlans(e) {
|
|
2406
2430
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
2407
2431
|
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);
|
|
2408
|
-
const s = `/subscription-plans/${r.toString() ? `?${r.toString()}` : ""}`,
|
|
2432
|
+
const s = `/subscription-plans/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
|
|
2409
2433
|
headers: t
|
|
2410
2434
|
});
|
|
2411
2435
|
return {
|
|
2412
|
-
plans:
|
|
2413
|
-
meta:
|
|
2436
|
+
plans: a.data,
|
|
2437
|
+
meta: a.meta
|
|
2414
2438
|
};
|
|
2415
2439
|
}
|
|
2416
2440
|
async getSubscriptionPlanById(e) {
|
|
@@ -2439,7 +2463,7 @@ class ct {
|
|
|
2439
2463
|
});
|
|
2440
2464
|
}
|
|
2441
2465
|
}
|
|
2442
|
-
class
|
|
2466
|
+
class pt {
|
|
2443
2467
|
constructor(e) {
|
|
2444
2468
|
this.httpService = e;
|
|
2445
2469
|
}
|
|
@@ -2448,7 +2472,7 @@ class dt {
|
|
|
2448
2472
|
return await this.httpService.get("/health");
|
|
2449
2473
|
}
|
|
2450
2474
|
}
|
|
2451
|
-
class
|
|
2475
|
+
class ft {
|
|
2452
2476
|
// Date string to Date object
|
|
2453
2477
|
static toDate(e) {
|
|
2454
2478
|
return new Date(e);
|
|
@@ -2571,39 +2595,40 @@ class ut {
|
|
|
2571
2595
|
}
|
|
2572
2596
|
}
|
|
2573
2597
|
export {
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2598
|
+
ft as ApiMappers,
|
|
2599
|
+
be as AppApiService,
|
|
2600
|
+
Je as AppProvider,
|
|
2601
|
+
Ae as AuthApiService,
|
|
2602
|
+
rt as AuthProvider,
|
|
2603
|
+
lt as FeatureFlag,
|
|
2604
|
+
Me as FeatureFlagApiService,
|
|
2605
|
+
st as FeatureFlagProvider,
|
|
2606
|
+
pt as HealthApiService,
|
|
2607
|
+
G as HttpService,
|
|
2608
|
+
ct as LoginForm,
|
|
2609
|
+
ut as PasswordRecoveryForm,
|
|
2610
|
+
ht as PermissionApiService,
|
|
2611
|
+
it as Protected,
|
|
2612
|
+
ot as ProtectedRoute,
|
|
2613
|
+
le as RoleApiService,
|
|
2614
|
+
xe as SessionManager,
|
|
2615
|
+
dt as SignupForm,
|
|
2616
|
+
Re as SubscriptionApiService,
|
|
2617
|
+
at as SubscriptionGuard,
|
|
2618
|
+
gt as SubscriptionPlanApiService,
|
|
2619
|
+
nt as SubscriptionProvider,
|
|
2620
|
+
ce as TenantApiService,
|
|
2597
2621
|
Ze as TenantProvider,
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2622
|
+
Pe as UserApiService,
|
|
2623
|
+
J as UserType,
|
|
2624
|
+
Xe as useApi,
|
|
2625
|
+
re as useApp,
|
|
2626
|
+
se as useAuth,
|
|
2627
|
+
Ee as useFeatureFlags,
|
|
2628
|
+
tt as useSettings,
|
|
2629
|
+
Fe as useSubscription,
|
|
2630
|
+
oe as useTenant,
|
|
2631
|
+
Z as useTenantInfo,
|
|
2632
|
+
et as useTenantSettings
|
|
2608
2633
|
};
|
|
2609
2634
|
//# sourceMappingURL=index.es.js.map
|