@skylabs-digital/react-identity-access 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +1017 -972
- 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 -3
- 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 te, useState as
|
|
3
|
-
import { useLocation as
|
|
4
|
-
class
|
|
1
|
+
import { jsx as n, Fragment as U, jsxs as u } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as te, useState as m, useMemo as z, useCallback as J, useEffect as K, useContext as re } from "react";
|
|
3
|
+
import { useLocation as me, Navigate as le } from "react-router";
|
|
4
|
+
class _ {
|
|
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 x = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, d = (s == null ? void 0 : s.timeout) || this.timeout;
|
|
20
|
+
let M = {
|
|
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 h = await this.sessionManager.getAuthHeaders();
|
|
27
|
+
M = { ...M, ...h };
|
|
28
|
+
} catch (h) {
|
|
29
|
+
console.warn("Failed to inject auth headers:", h);
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const P = new AbortController(), g = setTimeout(() => P.abort(), d);
|
|
32
32
|
try {
|
|
33
|
-
const
|
|
33
|
+
const h = await fetch(x, {
|
|
34
34
|
method: e,
|
|
35
|
-
headers:
|
|
35
|
+
headers: M,
|
|
36
36
|
body: r ? JSON.stringify(r) : void 0,
|
|
37
|
-
signal:
|
|
37
|
+
signal: P.signal
|
|
38
38
|
});
|
|
39
|
-
if (clearTimeout(
|
|
39
|
+
if (clearTimeout(g), h.status === 401 && !(s != null && s.skipRetry) && !a && this.sessionManager)
|
|
40
40
|
try {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
41
|
+
const y = this.sessionManager.getTokens();
|
|
42
|
+
if (y != null && y.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 ${h.status}: ${h.statusText}`);
|
|
46
46
|
}
|
|
47
|
-
if (!
|
|
48
|
-
throw new Error(`HTTP ${
|
|
49
|
-
const
|
|
50
|
-
return !
|
|
51
|
-
} catch (
|
|
52
|
-
throw clearTimeout(
|
|
47
|
+
if (!h.ok)
|
|
48
|
+
throw new Error(`HTTP ${h.status}: ${h.statusText}`);
|
|
49
|
+
const b = h.headers.get("content-type");
|
|
50
|
+
return !b || !b.includes("application/json") ? {} : await h.json();
|
|
51
|
+
} catch (h) {
|
|
52
|
+
throw clearTimeout(g), h instanceof Error && h.name === "AbortError" ? new Error(`Request timeout after ${d}ms`) : h;
|
|
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 = te(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), [x, d] = m(null), M = z(() => {
|
|
175
|
+
const g = () => {
|
|
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:
|
|
286
|
-
appError:
|
|
287
|
-
retryApp:
|
|
182
|
+
appInfo: t,
|
|
183
|
+
isAppLoading: s,
|
|
184
|
+
appError: x,
|
|
185
|
+
retryApp: g
|
|
288
186
|
};
|
|
289
|
-
}, [
|
|
187
|
+
}, [i, t, s, x]), P = J(async () => {
|
|
290
188
|
try {
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
} catch (
|
|
295
|
-
const
|
|
296
|
-
|
|
189
|
+
a(!0), d(null);
|
|
190
|
+
const g = new _(i.baseUrl), b = await new be(g, {}).getPublicAppInfo(i.appId);
|
|
191
|
+
r(b);
|
|
192
|
+
} catch (g) {
|
|
193
|
+
const h = g instanceof Error ? g : new Error("Failed to load app information");
|
|
194
|
+
d(h), 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(U, { children: i.loadingFallback || /* @__PURE__ */ n(Se, {}) });
|
|
203
|
+
if (x) {
|
|
204
|
+
const g = typeof i.errorFallback == "function" ? i.errorFallback(x, () => P()) : i.errorFallback || /* @__PURE__ */ n(ve, { error: x, retry: () => P() });
|
|
205
|
+
return /* @__PURE__ */ n(U, { children: g });
|
|
206
|
+
}
|
|
207
|
+
return /* @__PURE__ */ n(ge.Provider, { value: M, children: e });
|
|
339
208
|
}
|
|
340
|
-
function
|
|
341
|
-
const
|
|
342
|
-
if (!
|
|
209
|
+
function se() {
|
|
210
|
+
const i = re(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 = se;
|
|
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 ce {
|
|
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()}` : ""}`, x = await this.httpService.get(a, {
|
|
576
435
|
headers: r
|
|
577
436
|
});
|
|
578
437
|
return {
|
|
579
|
-
roles:
|
|
580
|
-
meta:
|
|
438
|
+
roles: x.data,
|
|
439
|
+
meta: x.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,503 @@ class ve {
|
|
|
621
480
|
});
|
|
622
481
|
}
|
|
623
482
|
}
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
483
|
+
class oe {
|
|
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 = te(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 } = se(), a = ee(), x = a == null ? void 0 : a.sessionManager, [d, M] = m(i.initialTenant || null), [P, g] = m(!i.initialTenant), [h, b] = m(null), [y, S] = m(null), [$, p] = m(!1), [D, A] = m(null), E = J(() => {
|
|
609
|
+
const o = i.tenantMode || "optional", l = "tenant";
|
|
610
|
+
if (o === "fixed")
|
|
611
|
+
return i.fixedTenantSlug || null;
|
|
612
|
+
if (typeof window > "u") return null;
|
|
613
|
+
if (o === "subdomain") {
|
|
614
|
+
const c = window.location.hostname.split(".");
|
|
615
|
+
if (c.length >= 3) {
|
|
616
|
+
const k = c[0];
|
|
617
|
+
return localStorage.setItem(l, k), k;
|
|
618
|
+
}
|
|
619
|
+
return localStorage.getItem(l);
|
|
620
|
+
} else if (o === "selector") {
|
|
621
|
+
const c = new URLSearchParams(window.location.search).get(i.selectorParam || "tenant");
|
|
622
|
+
return c ? (localStorage.setItem(l, c), c) : localStorage.getItem(l);
|
|
623
|
+
}
|
|
624
|
+
return null;
|
|
625
|
+
}, [i.tenantMode, i.fixedTenantSlug, i.selectorParam]), f = z(() => E(), [E]), I = (r == null ? void 0 : r.settingsSchema) || null, C = J(
|
|
626
|
+
async (o) => {
|
|
627
|
+
try {
|
|
628
|
+
g(!0), b(null);
|
|
629
|
+
const l = new _(t), c = await new oe(l, s).getPublicTenantInfo(o);
|
|
630
|
+
M(c);
|
|
631
|
+
} catch (l) {
|
|
632
|
+
const H = l instanceof Error ? l : new Error("Failed to load tenant information");
|
|
633
|
+
b(H), M(null);
|
|
634
|
+
} finally {
|
|
635
|
+
g(!1);
|
|
636
|
+
}
|
|
637
|
+
},
|
|
638
|
+
[t, s]
|
|
639
|
+
), F = J(async () => {
|
|
640
|
+
if (d != null && d.id)
|
|
641
|
+
try {
|
|
642
|
+
p(!0), A(null);
|
|
643
|
+
const o = new _(t), H = await new oe(o, d.appId).getTenantSettings(d.id);
|
|
644
|
+
S(H);
|
|
645
|
+
} catch (o) {
|
|
646
|
+
const l = o instanceof Error ? o : new Error("Failed to load tenant settings");
|
|
647
|
+
A(l), S(null);
|
|
648
|
+
} finally {
|
|
649
|
+
p(!1);
|
|
650
|
+
}
|
|
651
|
+
}, [t, d]), B = J(
|
|
652
|
+
async (o) => {
|
|
653
|
+
if (!(d != null && d.id) || !x)
|
|
654
|
+
throw new Error("Tenant ID and authentication required to update settings");
|
|
655
|
+
try {
|
|
656
|
+
p(!0), A(null);
|
|
657
|
+
const l = new _(t), H = new oe(l, d.appId, x), c = { settings: o }, k = await H.updateTenantSettings(d.id, c);
|
|
658
|
+
S(k);
|
|
659
|
+
} catch (l) {
|
|
660
|
+
const H = l instanceof Error ? l : new Error("Failed to update tenant settings");
|
|
661
|
+
throw A(H), H;
|
|
662
|
+
} finally {
|
|
663
|
+
p(!1);
|
|
664
|
+
}
|
|
665
|
+
},
|
|
666
|
+
[t, d, x]
|
|
667
|
+
), w = J(() => {
|
|
668
|
+
F();
|
|
669
|
+
}, [F]), O = J(
|
|
670
|
+
(o) => {
|
|
671
|
+
if (!I)
|
|
672
|
+
return { isValid: !0, errors: [] };
|
|
673
|
+
const l = [];
|
|
674
|
+
try {
|
|
675
|
+
return I.properties && Object.entries(I.properties).forEach(([H, c]) => {
|
|
676
|
+
var W;
|
|
677
|
+
const k = o[H];
|
|
678
|
+
if ((W = I.required) != null && W.includes(H) && k == null) {
|
|
679
|
+
l.push(`Field '${H}' is required`);
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
if (k != null) {
|
|
683
|
+
if (c.type) {
|
|
684
|
+
const R = c.type, q = typeof k;
|
|
685
|
+
R === "string" && q !== "string" ? l.push(`Field '${H}' must be a string`) : (R === "number" || R === "integer") && q !== "number" ? l.push(`Field '${H}' must be a number`) : R === "boolean" && q !== "boolean" ? l.push(`Field '${H}' must be a boolean`) : R === "array" && !Array.isArray(k) && l.push(`Field '${H}' must be an array`);
|
|
686
|
+
}
|
|
687
|
+
c.minLength !== void 0 && typeof k == "string" && k.length < c.minLength && l.push(
|
|
688
|
+
`Field '${H}' must be at least ${c.minLength} characters long`
|
|
689
|
+
), c.maxLength !== void 0 && typeof k == "string" && k.length > c.maxLength && l.push(
|
|
690
|
+
`Field '${H}' must be no more than ${c.maxLength} characters long`
|
|
691
|
+
), c.minimum !== void 0 && typeof k == "number" && k < c.minimum && l.push(`Field '${H}' must be at least ${c.minimum}`), c.maximum !== void 0 && typeof k == "number" && k > c.maximum && l.push(`Field '${H}' must be no more than ${c.maximum}`), c.pattern && typeof k == "string" && (new RegExp(c.pattern).test(k) || l.push(`Field '${H}' does not match the required pattern`)), c.enum && !c.enum.includes(k) && l.push(`Field '${H}' must be one of: ${c.enum.join(", ")}`);
|
|
692
|
+
}
|
|
693
|
+
}), {
|
|
694
|
+
isValid: l.length === 0,
|
|
695
|
+
errors: l
|
|
696
|
+
};
|
|
697
|
+
} catch {
|
|
698
|
+
return {
|
|
699
|
+
isValid: !1,
|
|
700
|
+
errors: ["Invalid settings schema or validation error"]
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
},
|
|
704
|
+
[I]
|
|
705
|
+
);
|
|
706
|
+
K(() => {
|
|
707
|
+
const o = i.tenantMode || "optional";
|
|
708
|
+
!i.initialTenant && f ? C(f) : !i.initialTenant && !f && o === "fixed" ? (b(new Error("Fixed tenant mode requires fixedTenantSlug configuration")), g(!1)) : !i.initialTenant && !f && (o === "subdomain" || o === "selector") ? (b(
|
|
709
|
+
new Error(`No tenant ${o === "subdomain" ? "subdomain" : "parameter"} found`)
|
|
710
|
+
), g(!1)) : !i.initialTenant && !f && o === "optional" && (M(null), b(null), g(!1));
|
|
711
|
+
}, [i.initialTenant, f, C, i.tenantMode, i.fixedTenantSlug]), K(() => {
|
|
712
|
+
d != null && d.id ? F() : (S(null), A(null), p(!1));
|
|
713
|
+
}, [d == null ? void 0 : d.id, F]);
|
|
714
|
+
const T = z(() => ({
|
|
715
|
+
// Tenant info
|
|
716
|
+
tenant: d,
|
|
717
|
+
tenantSlug: f,
|
|
718
|
+
isTenantLoading: P,
|
|
719
|
+
tenantError: h,
|
|
720
|
+
retryTenant: () => {
|
|
721
|
+
f && C(f);
|
|
722
|
+
},
|
|
723
|
+
// Settings
|
|
724
|
+
settings: y,
|
|
725
|
+
settingsSchema: I,
|
|
726
|
+
isSettingsLoading: $,
|
|
727
|
+
settingsError: D,
|
|
728
|
+
// Actions
|
|
729
|
+
updateSettings: B,
|
|
730
|
+
refreshSettings: w,
|
|
731
|
+
// Validation
|
|
732
|
+
validateSettings: O
|
|
733
|
+
}), [
|
|
734
|
+
d,
|
|
735
|
+
f,
|
|
736
|
+
P,
|
|
737
|
+
h,
|
|
738
|
+
y,
|
|
739
|
+
I,
|
|
740
|
+
$,
|
|
741
|
+
D,
|
|
742
|
+
B,
|
|
743
|
+
w,
|
|
744
|
+
O
|
|
745
|
+
]);
|
|
746
|
+
if (P)
|
|
747
|
+
return /* @__PURE__ */ n(U, { children: i.loadingFallback || /* @__PURE__ */ n(Te, {}) });
|
|
748
|
+
if (h && i.tenantMode !== "optional") {
|
|
749
|
+
const o = typeof i.errorFallback == "function" ? i.errorFallback(h, () => C(f || "")) : i.errorFallback || /* @__PURE__ */ n(ke, { error: h, retry: () => C(f || "") });
|
|
750
|
+
return /* @__PURE__ */ n(U, { children: o });
|
|
751
|
+
}
|
|
752
|
+
return /* @__PURE__ */ n(pe.Provider, { value: T, children: e });
|
|
753
|
+
}
|
|
754
|
+
function ae() {
|
|
755
|
+
const i = re(pe);
|
|
756
|
+
if (!i)
|
|
757
|
+
throw new Error("useTenant must be used within a TenantProvider");
|
|
758
|
+
return i;
|
|
759
|
+
}
|
|
760
|
+
const et = ae;
|
|
761
|
+
function tt() {
|
|
762
|
+
const {
|
|
763
|
+
settings: i,
|
|
764
|
+
settingsSchema: e,
|
|
765
|
+
isSettingsLoading: t,
|
|
766
|
+
settingsError: r,
|
|
767
|
+
updateSettings: s,
|
|
768
|
+
validateSettings: a
|
|
769
|
+
} = ae();
|
|
770
|
+
return {
|
|
771
|
+
settings: i,
|
|
772
|
+
settingsSchema: e,
|
|
773
|
+
isLoading: t,
|
|
774
|
+
error: r,
|
|
775
|
+
updateSettings: s,
|
|
776
|
+
validateSettings: a
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
function Z() {
|
|
780
|
+
const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } = ae();
|
|
781
|
+
return {
|
|
782
|
+
tenant: i,
|
|
783
|
+
tenantSlug: e,
|
|
784
|
+
isLoading: t,
|
|
785
|
+
error: r,
|
|
786
|
+
retry: s
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
const fe = te(null);
|
|
790
|
+
function rt({ config: i = {}, children: e }) {
|
|
791
|
+
const { appId: t, baseUrl: r } = se(), s = Z(), a = (s == null ? void 0 : s.tenantSlug) || null, [x, d] = m(i.initialRoles || []), [M, P] = m(!i.initialRoles), [g, h] = m(null), [b, y] = m(!1), [S, $] = m(null), p = z(() => {
|
|
792
|
+
const w = a ? `auth_tokens_${a}` : "auth_tokens", O = {
|
|
628
793
|
get: () => {
|
|
629
794
|
try {
|
|
630
|
-
const
|
|
631
|
-
return
|
|
795
|
+
const T = localStorage.getItem(w);
|
|
796
|
+
return T ? JSON.parse(T) : null;
|
|
632
797
|
} catch {
|
|
633
798
|
return null;
|
|
634
799
|
}
|
|
635
800
|
},
|
|
636
|
-
set: (
|
|
801
|
+
set: (T) => {
|
|
637
802
|
try {
|
|
638
|
-
localStorage.setItem(
|
|
803
|
+
localStorage.setItem(w, JSON.stringify(T));
|
|
639
804
|
} catch {
|
|
640
805
|
}
|
|
641
806
|
},
|
|
642
807
|
clear: () => {
|
|
643
808
|
try {
|
|
644
|
-
localStorage.removeItem(
|
|
809
|
+
localStorage.removeItem(w);
|
|
645
810
|
} catch {
|
|
646
811
|
}
|
|
647
812
|
}
|
|
648
813
|
};
|
|
649
|
-
return new
|
|
650
|
-
onRefreshFailed:
|
|
651
|
-
tokenStorage:
|
|
652
|
-
baseUrl:
|
|
814
|
+
return new xe({
|
|
815
|
+
onRefreshFailed: i.onRefreshFailed,
|
|
816
|
+
tokenStorage: O,
|
|
817
|
+
baseUrl: r
|
|
653
818
|
});
|
|
654
|
-
}, [
|
|
655
|
-
const
|
|
656
|
-
return
|
|
657
|
-
}, [
|
|
819
|
+
}, [a, r, i.onRefreshFailed]), D = z(() => {
|
|
820
|
+
const w = new _(r);
|
|
821
|
+
return w.setSessionManager(p), w;
|
|
822
|
+
}, [r, p]), A = z(() => new Ae(new _(r)), [r]), E = z(() => new Pe(D, p), [D, p]), f = z(() => new ce(new _(r)), [r]), I = z(() => g || p.getUser(), [g, p]), C = z(() => I != null && I.roleId && x.find((w) => w.id === I.roleId) || null, [I, x]), F = z(() => (C == null ? void 0 : C.permissions) || [], [C]);
|
|
658
823
|
K(() => {
|
|
659
|
-
console.log("AuthProvider - userPermissions changed:",
|
|
660
|
-
}, [
|
|
661
|
-
const
|
|
662
|
-
const
|
|
824
|
+
console.log("AuthProvider - userPermissions changed:", F);
|
|
825
|
+
}, [F]);
|
|
826
|
+
const B = z(() => {
|
|
827
|
+
const w = async () => {
|
|
663
828
|
try {
|
|
664
|
-
|
|
665
|
-
const
|
|
666
|
-
if (!(
|
|
829
|
+
y(!0), $(null);
|
|
830
|
+
const v = p.getUser();
|
|
831
|
+
if (!(v != null && v.id))
|
|
667
832
|
throw new Error("No user ID available in session");
|
|
668
|
-
const
|
|
669
|
-
|
|
670
|
-
} catch (
|
|
671
|
-
const
|
|
672
|
-
|
|
833
|
+
const L = await E.getUserById(v.id);
|
|
834
|
+
h(L), p.setUser(L);
|
|
835
|
+
} catch (v) {
|
|
836
|
+
const L = v instanceof Error ? v : new Error("Failed to load user data");
|
|
837
|
+
$(L), console.error("Failed to load user data:", L);
|
|
673
838
|
} finally {
|
|
674
|
-
|
|
839
|
+
y(!1);
|
|
675
840
|
}
|
|
676
|
-
},
|
|
677
|
-
await
|
|
678
|
-
},
|
|
679
|
-
const
|
|
680
|
-
email:
|
|
681
|
-
password:
|
|
682
|
-
tenantId:
|
|
841
|
+
}, O = async () => {
|
|
842
|
+
await w();
|
|
843
|
+
}, T = async (v, L, Q) => {
|
|
844
|
+
const G = await A.login({
|
|
845
|
+
email: v,
|
|
846
|
+
password: L,
|
|
847
|
+
tenantId: Q
|
|
683
848
|
});
|
|
684
|
-
if (
|
|
685
|
-
accessToken:
|
|
686
|
-
refreshToken:
|
|
687
|
-
expiresIn:
|
|
688
|
-
}),
|
|
689
|
-
|
|
849
|
+
if (p.setTokens({
|
|
850
|
+
accessToken: G.accessToken,
|
|
851
|
+
refreshToken: G.refreshToken,
|
|
852
|
+
expiresIn: G.expiresIn
|
|
853
|
+
}), G.user) {
|
|
854
|
+
p.setUser(G.user), h(G.user);
|
|
690
855
|
try {
|
|
691
|
-
await
|
|
692
|
-
} catch (
|
|
693
|
-
console.warn("Failed to load complete user data after login:",
|
|
856
|
+
await w();
|
|
857
|
+
} catch (ie) {
|
|
858
|
+
console.warn("Failed to load complete user data after login:", ie);
|
|
694
859
|
}
|
|
695
860
|
}
|
|
696
|
-
return
|
|
697
|
-
},
|
|
698
|
-
email:
|
|
699
|
-
name:
|
|
700
|
-
password:
|
|
701
|
-
tenantName:
|
|
861
|
+
return G;
|
|
862
|
+
}, o = async (v, L, Q, G) => await A.signup({ email: v, name: L, password: Q, tenantId: G }), l = async (v, L, Q, G) => await A.signupTenantAdmin({
|
|
863
|
+
email: v,
|
|
864
|
+
name: L,
|
|
865
|
+
password: Q,
|
|
866
|
+
tenantName: G,
|
|
702
867
|
appId: t
|
|
703
|
-
}),
|
|
704
|
-
const
|
|
705
|
-
await
|
|
706
|
-
},
|
|
707
|
-
await
|
|
708
|
-
},
|
|
709
|
-
await
|
|
710
|
-
},
|
|
711
|
-
const
|
|
712
|
-
if (!(
|
|
868
|
+
}), H = async (v, L) => {
|
|
869
|
+
const Q = await p.getAuthHeaders();
|
|
870
|
+
await A.changePassword({ currentPassword: v, newPassword: L }, Q);
|
|
871
|
+
}, c = async (v, L) => {
|
|
872
|
+
await A.requestPasswordReset({ email: v, tenantId: L });
|
|
873
|
+
}, k = async (v, L) => {
|
|
874
|
+
await A.confirmPasswordReset({ token: v, newPassword: L });
|
|
875
|
+
}, W = async () => {
|
|
876
|
+
const v = p.getTokens();
|
|
877
|
+
if (!(v != null && v.refreshToken))
|
|
713
878
|
throw new Error("No refresh token available");
|
|
714
|
-
const
|
|
715
|
-
refreshToken:
|
|
879
|
+
const L = await A.refreshToken({
|
|
880
|
+
refreshToken: v.refreshToken
|
|
716
881
|
});
|
|
717
|
-
|
|
718
|
-
accessToken:
|
|
719
|
-
refreshToken:
|
|
720
|
-
expiresIn:
|
|
882
|
+
p.setTokens({
|
|
883
|
+
accessToken: L.accessToken,
|
|
884
|
+
refreshToken: L.refreshToken || v.refreshToken,
|
|
885
|
+
expiresIn: L.expiresIn
|
|
721
886
|
});
|
|
722
|
-
},
|
|
723
|
-
|
|
724
|
-
},
|
|
725
|
-
|
|
726
|
-
},
|
|
727
|
-
|
|
728
|
-
},
|
|
887
|
+
}, R = () => {
|
|
888
|
+
p.clearSession(), h(null), $(null);
|
|
889
|
+
}, q = (v) => {
|
|
890
|
+
p.setTokens(v);
|
|
891
|
+
}, Y = () => p.hasValidSession(), N = () => {
|
|
892
|
+
p.clearSession(), h(null), $(null);
|
|
893
|
+
}, j = async () => {
|
|
729
894
|
if (t)
|
|
730
895
|
try {
|
|
731
|
-
|
|
732
|
-
const { roles:
|
|
733
|
-
|
|
734
|
-
} catch (
|
|
735
|
-
console.error("Failed to fetch roles:",
|
|
896
|
+
P(!0);
|
|
897
|
+
const { roles: v } = await f.getRolesByApp(t);
|
|
898
|
+
d(v);
|
|
899
|
+
} catch (v) {
|
|
900
|
+
console.error("Failed to fetch roles:", v);
|
|
736
901
|
} finally {
|
|
737
|
-
|
|
902
|
+
P(!1);
|
|
738
903
|
}
|
|
739
|
-
},
|
|
740
|
-
await
|
|
741
|
-
},
|
|
742
|
-
if (!
|
|
904
|
+
}, V = async () => {
|
|
905
|
+
await j();
|
|
906
|
+
}, ne = (v) => {
|
|
907
|
+
if (!F || F.length === 0)
|
|
743
908
|
return !1;
|
|
744
|
-
if (typeof
|
|
745
|
-
return
|
|
746
|
-
const
|
|
747
|
-
return
|
|
909
|
+
if (typeof v == "string")
|
|
910
|
+
return F.includes(v);
|
|
911
|
+
const L = `${v.resource}.${v.action}`;
|
|
912
|
+
return F.includes(L);
|
|
748
913
|
};
|
|
749
914
|
return {
|
|
750
|
-
sessionManager:
|
|
751
|
-
authenticatedHttpService:
|
|
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:
|
|
915
|
+
sessionManager: p,
|
|
916
|
+
authenticatedHttpService: D,
|
|
917
|
+
login: T,
|
|
918
|
+
signup: o,
|
|
919
|
+
signupTenantAdmin: l,
|
|
920
|
+
changePassword: H,
|
|
921
|
+
requestPasswordReset: c,
|
|
922
|
+
confirmPasswordReset: k,
|
|
923
|
+
refreshToken: W,
|
|
924
|
+
logout: R,
|
|
925
|
+
setTokens: q,
|
|
926
|
+
hasValidSession: Y,
|
|
927
|
+
clearSession: N,
|
|
928
|
+
currentUser: g,
|
|
929
|
+
isUserLoading: b,
|
|
930
|
+
userError: S,
|
|
931
|
+
refreshUser: O,
|
|
932
|
+
userRole: C,
|
|
933
|
+
userPermissions: F,
|
|
934
|
+
availableRoles: x,
|
|
770
935
|
rolesLoading: M,
|
|
771
|
-
hasPermission:
|
|
772
|
-
hasAnyPermission: (
|
|
773
|
-
hasAllPermissions: (
|
|
774
|
-
getUserPermissionStrings: () =>
|
|
775
|
-
refreshRoles:
|
|
936
|
+
hasPermission: ne,
|
|
937
|
+
hasAnyPermission: (v) => v.some((L) => ne(L)),
|
|
938
|
+
hasAllPermissions: (v) => v.every((L) => ne(L)),
|
|
939
|
+
getUserPermissionStrings: () => F || [],
|
|
940
|
+
refreshRoles: V
|
|
776
941
|
};
|
|
777
942
|
}, [
|
|
778
|
-
c,
|
|
779
|
-
C,
|
|
780
|
-
x,
|
|
781
|
-
d,
|
|
782
|
-
l,
|
|
783
|
-
t,
|
|
784
|
-
o,
|
|
785
|
-
E,
|
|
786
943
|
p,
|
|
944
|
+
D,
|
|
945
|
+
A,
|
|
946
|
+
E,
|
|
787
947
|
f,
|
|
788
|
-
|
|
789
|
-
|
|
948
|
+
t,
|
|
949
|
+
x,
|
|
950
|
+
g,
|
|
951
|
+
b,
|
|
952
|
+
S,
|
|
953
|
+
C,
|
|
954
|
+
F
|
|
790
955
|
]);
|
|
791
956
|
return K(() => {
|
|
792
|
-
!
|
|
957
|
+
!i.initialRoles && t && (async () => {
|
|
793
958
|
try {
|
|
794
|
-
|
|
795
|
-
const
|
|
796
|
-
|
|
797
|
-
} catch (
|
|
798
|
-
console.error("Failed to fetch roles:",
|
|
959
|
+
P(!0);
|
|
960
|
+
const O = new _(r), T = new ce(O), { roles: o } = await T.getRolesByApp(t);
|
|
961
|
+
d(o);
|
|
962
|
+
} catch (O) {
|
|
963
|
+
console.error("Failed to fetch roles:", O);
|
|
799
964
|
} finally {
|
|
800
|
-
|
|
965
|
+
P(!1);
|
|
801
966
|
}
|
|
802
967
|
})();
|
|
803
|
-
}, [t,
|
|
804
|
-
const
|
|
805
|
-
|
|
806
|
-
}, [
|
|
968
|
+
}, [t, r, i.initialRoles]), K(() => {
|
|
969
|
+
const w = p.getUser();
|
|
970
|
+
w && p.hasValidSession() && h(w);
|
|
971
|
+
}, [p]), /* @__PURE__ */ n(fe.Provider, { value: B, children: e });
|
|
807
972
|
}
|
|
808
973
|
function ee() {
|
|
809
|
-
const
|
|
810
|
-
if (!
|
|
974
|
+
const i = re(fe);
|
|
975
|
+
if (!i)
|
|
811
976
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
812
|
-
return
|
|
977
|
+
return i;
|
|
813
978
|
}
|
|
814
|
-
class
|
|
979
|
+
class Me {
|
|
815
980
|
constructor(e, t) {
|
|
816
981
|
this.httpService = e, this.sessionManager = t;
|
|
817
982
|
}
|
|
@@ -832,12 +997,12 @@ class xe {
|
|
|
832
997
|
throw new Error("SessionManager is required for private endpoints");
|
|
833
998
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
834
999
|
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()}` : ""}`,
|
|
1000
|
+
const s = `/feature-flags/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
|
|
836
1001
|
headers: t
|
|
837
1002
|
});
|
|
838
1003
|
return {
|
|
839
|
-
featureFlags:
|
|
840
|
-
meta:
|
|
1004
|
+
featureFlags: a.data,
|
|
1005
|
+
meta: a.meta
|
|
841
1006
|
};
|
|
842
1007
|
}
|
|
843
1008
|
async getFeatureFlagById(e) {
|
|
@@ -885,64 +1050,64 @@ class xe {
|
|
|
885
1050
|
throw new Error("Flag Key, Tenant ID and App ID are required");
|
|
886
1051
|
const s = new URLSearchParams();
|
|
887
1052
|
s.append("tenantId", t), s.append("appId", r);
|
|
888
|
-
const
|
|
889
|
-
return (await this.httpService.get(
|
|
1053
|
+
const a = `/tenant-feature-flags/${e}${s.toString() ? `?${s.toString()}` : ""}`;
|
|
1054
|
+
return (await this.httpService.get(a, {
|
|
890
1055
|
headers: { "X-Tenant-ID": t }
|
|
891
1056
|
})).data;
|
|
892
1057
|
}
|
|
893
1058
|
}
|
|
894
|
-
const
|
|
895
|
-
function
|
|
896
|
-
const {
|
|
897
|
-
const
|
|
898
|
-
return new
|
|
899
|
-
}, [
|
|
900
|
-
if (!(
|
|
901
|
-
|
|
1059
|
+
const ye = te(null);
|
|
1060
|
+
function st({ config: i = {}, children: e }) {
|
|
1061
|
+
const { baseUrl: t, appId: r } = se(), { tenant: s } = Z(), [a, x] = m([]), [d, M] = m(!1), [P, g] = m(null), h = z(() => {
|
|
1062
|
+
const S = new _(t);
|
|
1063
|
+
return new Me(S);
|
|
1064
|
+
}, [t]), b = async () => {
|
|
1065
|
+
if (!(s != null && s.id)) {
|
|
1066
|
+
x([]);
|
|
902
1067
|
return;
|
|
903
1068
|
}
|
|
904
|
-
|
|
1069
|
+
M(!0), g(null);
|
|
905
1070
|
try {
|
|
906
|
-
const
|
|
907
|
-
|
|
908
|
-
} catch (
|
|
909
|
-
const
|
|
910
|
-
|
|
1071
|
+
const S = await h.getTenantFeatureFlags(s.id, r);
|
|
1072
|
+
x(S);
|
|
1073
|
+
} catch (S) {
|
|
1074
|
+
const $ = S instanceof Error ? S.message : "Failed to fetch feature flags";
|
|
1075
|
+
g($), i.onError && i.onError(S instanceof Error ? S : new Error($));
|
|
911
1076
|
} finally {
|
|
912
|
-
|
|
1077
|
+
M(!1);
|
|
913
1078
|
}
|
|
914
1079
|
};
|
|
915
1080
|
K(() => {
|
|
916
|
-
|
|
917
|
-
const
|
|
918
|
-
return () => clearInterval(
|
|
919
|
-
}, [
|
|
920
|
-
const
|
|
921
|
-
featureFlags:
|
|
922
|
-
loading:
|
|
923
|
-
error:
|
|
924
|
-
isEnabled: (
|
|
925
|
-
const
|
|
926
|
-
return (
|
|
1081
|
+
b();
|
|
1082
|
+
const S = i.refreshInterval || 5 * 60 * 1e3, $ = setInterval(b, S);
|
|
1083
|
+
return () => clearInterval($);
|
|
1084
|
+
}, [s == null ? void 0 : s.id, i.refreshInterval]);
|
|
1085
|
+
const y = z(() => ({
|
|
1086
|
+
featureFlags: a,
|
|
1087
|
+
loading: d,
|
|
1088
|
+
error: P,
|
|
1089
|
+
isEnabled: (A) => {
|
|
1090
|
+
const E = a.find((f) => f.key === A);
|
|
1091
|
+
return (E == null ? void 0 : E.value) === !0;
|
|
927
1092
|
},
|
|
928
|
-
getFlag: (
|
|
929
|
-
getFlagState: (
|
|
930
|
-
const
|
|
931
|
-
return
|
|
1093
|
+
getFlag: (A) => a.find((E) => E.key === A),
|
|
1094
|
+
getFlagState: (A) => {
|
|
1095
|
+
const E = a.find((f) => f.key === A);
|
|
1096
|
+
return E ? E.value ? "enabled" : "disabled" : "not_found";
|
|
932
1097
|
},
|
|
933
1098
|
refresh: async () => {
|
|
934
|
-
await
|
|
1099
|
+
await b();
|
|
935
1100
|
}
|
|
936
|
-
}), [
|
|
937
|
-
return /* @__PURE__ */
|
|
1101
|
+
}), [a, d, P]);
|
|
1102
|
+
return /* @__PURE__ */ n(ye.Provider, { value: y, children: e });
|
|
938
1103
|
}
|
|
939
|
-
function
|
|
940
|
-
const
|
|
941
|
-
if (!
|
|
1104
|
+
function Ee() {
|
|
1105
|
+
const i = re(ye);
|
|
1106
|
+
if (!i)
|
|
942
1107
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
943
|
-
return
|
|
1108
|
+
return i;
|
|
944
1109
|
}
|
|
945
|
-
class
|
|
1110
|
+
class Re {
|
|
946
1111
|
constructor(e, t) {
|
|
947
1112
|
this.httpService = e, this.sessionManager = t;
|
|
948
1113
|
}
|
|
@@ -1008,185 +1173,64 @@ class Pe {
|
|
|
1008
1173
|
)).data;
|
|
1009
1174
|
}
|
|
1010
1175
|
}
|
|
1011
|
-
const
|
|
1012
|
-
function
|
|
1013
|
-
const {
|
|
1014
|
-
const
|
|
1015
|
-
return new
|
|
1016
|
-
}, [
|
|
1017
|
-
if (!(
|
|
1018
|
-
|
|
1176
|
+
const we = te(void 0);
|
|
1177
|
+
function nt({ config: i = {}, children: e }) {
|
|
1178
|
+
const { baseUrl: t } = se(), { tenant: r } = Z(), [s, a] = m(null), [x, d] = m(!1), [M, P] = m(null), g = z(() => {
|
|
1179
|
+
const y = new _(t);
|
|
1180
|
+
return new Re(y);
|
|
1181
|
+
}, [t]), h = async () => {
|
|
1182
|
+
if (!(r != null && r.id)) {
|
|
1183
|
+
a(null);
|
|
1019
1184
|
return;
|
|
1020
1185
|
}
|
|
1021
|
-
|
|
1186
|
+
d(!0), P(null);
|
|
1022
1187
|
try {
|
|
1023
|
-
const
|
|
1024
|
-
|
|
1025
|
-
} catch (
|
|
1026
|
-
const
|
|
1027
|
-
|
|
1188
|
+
const y = await g.getTenantSubscriptionFeatures(r.id);
|
|
1189
|
+
a(y);
|
|
1190
|
+
} catch (y) {
|
|
1191
|
+
const S = y instanceof Error ? y.message : "Failed to fetch subscription";
|
|
1192
|
+
P(S), i.onError && i.onError(y instanceof Error ? y : new Error(S));
|
|
1028
1193
|
} finally {
|
|
1029
|
-
|
|
1194
|
+
d(!1);
|
|
1030
1195
|
}
|
|
1031
1196
|
};
|
|
1032
1197
|
K(() => {
|
|
1033
|
-
if (
|
|
1034
|
-
const
|
|
1035
|
-
return () => clearInterval(
|
|
1036
|
-
}, [
|
|
1037
|
-
const
|
|
1038
|
-
const
|
|
1198
|
+
if (h(), !i.refreshInterval) return;
|
|
1199
|
+
const y = i.refreshInterval || 10 * 60 * 1e3, S = setInterval(h, y);
|
|
1200
|
+
return () => clearInterval(S);
|
|
1201
|
+
}, [r == null ? void 0 : r.id, i.refreshInterval]);
|
|
1202
|
+
const b = z(() => {
|
|
1203
|
+
const y = (s == null ? void 0 : s.features) || [];
|
|
1039
1204
|
return {
|
|
1040
1205
|
subscription: s,
|
|
1041
|
-
features:
|
|
1042
|
-
loading:
|
|
1043
|
-
error:
|
|
1044
|
-
isFeatureEnabled: (
|
|
1045
|
-
const
|
|
1046
|
-
return
|
|
1206
|
+
features: y,
|
|
1207
|
+
loading: x,
|
|
1208
|
+
error: M,
|
|
1209
|
+
isFeatureEnabled: (E) => {
|
|
1210
|
+
const f = y.find((I) => I.key === E);
|
|
1211
|
+
return f ? f.type === "BOOLEAN" || f.type === "boolean" ? f.value === !0 : !!f.value : !1;
|
|
1047
1212
|
},
|
|
1048
|
-
getFeature: (
|
|
1049
|
-
getFeatureValue: (
|
|
1050
|
-
const
|
|
1051
|
-
return
|
|
1213
|
+
getFeature: (E) => y.find((f) => f.key === E),
|
|
1214
|
+
getFeatureValue: (E, f) => {
|
|
1215
|
+
const I = y.find((C) => C.key === E);
|
|
1216
|
+
return I ? I.value : f;
|
|
1052
1217
|
},
|
|
1053
|
-
hasAllowedPlan: (
|
|
1218
|
+
hasAllowedPlan: (E) => !s || !s.isActive ? !1 : E.includes(s.planId),
|
|
1054
1219
|
refresh: async () => {
|
|
1055
|
-
await
|
|
1220
|
+
await h();
|
|
1056
1221
|
}
|
|
1057
1222
|
};
|
|
1058
|
-
}, [s,
|
|
1059
|
-
return /* @__PURE__ */
|
|
1223
|
+
}, [s, x, M]);
|
|
1224
|
+
return /* @__PURE__ */ n(we.Provider, { value: b, children: e });
|
|
1060
1225
|
}
|
|
1061
|
-
function
|
|
1062
|
-
const
|
|
1063
|
-
if (
|
|
1226
|
+
function Fe() {
|
|
1227
|
+
const i = re(we);
|
|
1228
|
+
if (i === void 0)
|
|
1064
1229
|
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
|
-
};
|
|
1230
|
+
return i;
|
|
1187
1231
|
}
|
|
1188
|
-
var
|
|
1189
|
-
const
|
|
1232
|
+
var X = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(X || {});
|
|
1233
|
+
const de = () => /* @__PURE__ */ u(
|
|
1190
1234
|
"div",
|
|
1191
1235
|
{
|
|
1192
1236
|
style: {
|
|
@@ -1202,10 +1246,10 @@ const le = () => /* @__PURE__ */ g(
|
|
|
1202
1246
|
margin: "20px 0"
|
|
1203
1247
|
},
|
|
1204
1248
|
children: [
|
|
1205
|
-
/* @__PURE__ */
|
|
1206
|
-
/* @__PURE__ */
|
|
1207
|
-
/* @__PURE__ */
|
|
1208
|
-
/* @__PURE__ */
|
|
1249
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "🔒" }),
|
|
1250
|
+
/* @__PURE__ */ n("h3", { style: { color: "#495057", marginBottom: "10px" }, children: "Access Required" }),
|
|
1251
|
+
/* @__PURE__ */ n("p", { style: { color: "#6c757d", fontSize: "14px", marginBottom: "15px" }, children: "You need to be signed in to view this content." }),
|
|
1252
|
+
/* @__PURE__ */ n(
|
|
1209
1253
|
"button",
|
|
1210
1254
|
{
|
|
1211
1255
|
style: {
|
|
@@ -1223,11 +1267,11 @@ const le = () => /* @__PURE__ */ g(
|
|
|
1223
1267
|
)
|
|
1224
1268
|
]
|
|
1225
1269
|
}
|
|
1226
|
-
),
|
|
1227
|
-
userType:
|
|
1270
|
+
), ue = ({
|
|
1271
|
+
userType: i,
|
|
1228
1272
|
minUserType: e,
|
|
1229
1273
|
missingPermissions: t
|
|
1230
|
-
}) => /* @__PURE__ */
|
|
1274
|
+
}) => /* @__PURE__ */ u(
|
|
1231
1275
|
"div",
|
|
1232
1276
|
{
|
|
1233
1277
|
style: {
|
|
@@ -1243,57 +1287,57 @@ const le = () => /* @__PURE__ */ g(
|
|
|
1243
1287
|
margin: "20px 0"
|
|
1244
1288
|
},
|
|
1245
1289
|
children: [
|
|
1246
|
-
/* @__PURE__ */
|
|
1247
|
-
/* @__PURE__ */
|
|
1248
|
-
e &&
|
|
1249
|
-
/* @__PURE__ */
|
|
1290
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
|
|
1291
|
+
/* @__PURE__ */ n("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
|
|
1292
|
+
e && i ? /* @__PURE__ */ u(U, { children: [
|
|
1293
|
+
/* @__PURE__ */ u("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
|
|
1250
1294
|
"This content requires ",
|
|
1251
|
-
/* @__PURE__ */
|
|
1295
|
+
/* @__PURE__ */ n("strong", { children: e }),
|
|
1252
1296
|
" access level or higher."
|
|
1253
1297
|
] }),
|
|
1254
|
-
/* @__PURE__ */
|
|
1298
|
+
/* @__PURE__ */ u("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1255
1299
|
"Your current access level: ",
|
|
1256
|
-
/* @__PURE__ */
|
|
1300
|
+
/* @__PURE__ */ n("strong", { children: i })
|
|
1257
1301
|
] })
|
|
1258
|
-
] }) : /* @__PURE__ */
|
|
1259
|
-
/* @__PURE__ */
|
|
1260
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1302
|
+
] }) : /* @__PURE__ */ u(U, { children: [
|
|
1303
|
+
/* @__PURE__ */ n("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
|
|
1304
|
+
t && t.length > 0 && /* @__PURE__ */ u("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1261
1305
|
"Required permissions: ",
|
|
1262
|
-
/* @__PURE__ */
|
|
1306
|
+
/* @__PURE__ */ n("strong", { children: t.join(", ") })
|
|
1263
1307
|
] })
|
|
1264
1308
|
] })
|
|
1265
1309
|
]
|
|
1266
1310
|
}
|
|
1267
|
-
),
|
|
1311
|
+
), Ie = (i, e) => {
|
|
1268
1312
|
const t = {
|
|
1269
|
-
[
|
|
1270
|
-
[
|
|
1271
|
-
[
|
|
1313
|
+
[X.USER]: 1,
|
|
1314
|
+
[X.TENANT_ADMIN]: 2,
|
|
1315
|
+
[X.SUPERUSER]: 3
|
|
1272
1316
|
};
|
|
1273
|
-
return t[
|
|
1317
|
+
return t[i] >= t[e];
|
|
1274
1318
|
};
|
|
1275
|
-
function
|
|
1276
|
-
children:
|
|
1319
|
+
function it({
|
|
1320
|
+
children: i,
|
|
1277
1321
|
fallback: e,
|
|
1278
1322
|
minUserType: t,
|
|
1279
1323
|
requiredPermissions: r,
|
|
1280
1324
|
requireAllPermissions: s = !1
|
|
1281
1325
|
}) {
|
|
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__ */
|
|
1326
|
+
const { hasValidSession: a, sessionManager: x, hasPermission: d, hasAnyPermission: M, hasAllPermissions: P } = ee();
|
|
1327
|
+
if (!a())
|
|
1328
|
+
return /* @__PURE__ */ n(U, { children: e || /* @__PURE__ */ n(de, {}) });
|
|
1329
|
+
const g = x.getUser();
|
|
1330
|
+
if (!g)
|
|
1331
|
+
return /* @__PURE__ */ n(U, { children: e || /* @__PURE__ */ n(de, {}) });
|
|
1332
|
+
if (t && !Ie(g.userType, t))
|
|
1333
|
+
return /* @__PURE__ */ n(ue, { userType: g.userType, minUserType: t });
|
|
1334
|
+
if (r && r.length > 0 && !(s ? P(r) : M(r))) {
|
|
1335
|
+
const b = r.filter((y) => !d(y)).map((y) => typeof y == "string" ? y : y.name);
|
|
1336
|
+
return /* @__PURE__ */ n(ue, { missingPermissions: b });
|
|
1337
|
+
}
|
|
1338
|
+
return /* @__PURE__ */ n(U, { children: i });
|
|
1295
1339
|
}
|
|
1296
|
-
const
|
|
1340
|
+
const He = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1297
1341
|
"div",
|
|
1298
1342
|
{
|
|
1299
1343
|
style: {
|
|
@@ -1306,7 +1350,7 @@ const Ee = ({ redirectPath: n }) => /* @__PURE__ */ i(
|
|
|
1306
1350
|
backgroundColor: "#f9fafb",
|
|
1307
1351
|
textAlign: "center"
|
|
1308
1352
|
},
|
|
1309
|
-
children: /* @__PURE__ */
|
|
1353
|
+
children: /* @__PURE__ */ u(
|
|
1310
1354
|
"div",
|
|
1311
1355
|
{
|
|
1312
1356
|
style: {
|
|
@@ -1317,23 +1361,23 @@ const Ee = ({ redirectPath: n }) => /* @__PURE__ */ i(
|
|
|
1317
1361
|
maxWidth: "400px"
|
|
1318
1362
|
},
|
|
1319
1363
|
children: [
|
|
1320
|
-
/* @__PURE__ */
|
|
1321
|
-
/* @__PURE__ */
|
|
1322
|
-
/* @__PURE__ */
|
|
1323
|
-
/* @__PURE__ */
|
|
1364
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
|
|
1365
|
+
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
|
|
1366
|
+
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
|
|
1367
|
+
/* @__PURE__ */ u("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1324
1368
|
"Redirecting to ",
|
|
1325
|
-
|
|
1369
|
+
i,
|
|
1326
1370
|
"..."
|
|
1327
1371
|
] })
|
|
1328
1372
|
]
|
|
1329
1373
|
}
|
|
1330
1374
|
)
|
|
1331
1375
|
}
|
|
1332
|
-
),
|
|
1333
|
-
userType:
|
|
1376
|
+
), he = ({
|
|
1377
|
+
userType: i,
|
|
1334
1378
|
minUserType: e,
|
|
1335
1379
|
missingPermissions: t
|
|
1336
|
-
}) => /* @__PURE__ */
|
|
1380
|
+
}) => /* @__PURE__ */ n(
|
|
1337
1381
|
"div",
|
|
1338
1382
|
{
|
|
1339
1383
|
style: {
|
|
@@ -1346,7 +1390,7 @@ const Ee = ({ redirectPath: n }) => /* @__PURE__ */ i(
|
|
|
1346
1390
|
backgroundColor: "#f9fafb",
|
|
1347
1391
|
textAlign: "center"
|
|
1348
1392
|
},
|
|
1349
|
-
children: /* @__PURE__ */
|
|
1393
|
+
children: /* @__PURE__ */ u(
|
|
1350
1394
|
"div",
|
|
1351
1395
|
{
|
|
1352
1396
|
style: {
|
|
@@ -1357,63 +1401,63 @@ const Ee = ({ redirectPath: n }) => /* @__PURE__ */ i(
|
|
|
1357
1401
|
maxWidth: "400px"
|
|
1358
1402
|
},
|
|
1359
1403
|
children: [
|
|
1360
|
-
/* @__PURE__ */
|
|
1361
|
-
/* @__PURE__ */
|
|
1362
|
-
e &&
|
|
1363
|
-
/* @__PURE__ */
|
|
1404
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
|
|
1405
|
+
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
|
|
1406
|
+
e && i ? /* @__PURE__ */ u(U, { children: [
|
|
1407
|
+
/* @__PURE__ */ u("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
|
|
1364
1408
|
"This page requires ",
|
|
1365
|
-
/* @__PURE__ */
|
|
1409
|
+
/* @__PURE__ */ n("strong", { children: e }),
|
|
1366
1410
|
" access level or higher."
|
|
1367
1411
|
] }),
|
|
1368
|
-
/* @__PURE__ */
|
|
1412
|
+
/* @__PURE__ */ u("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1369
1413
|
"Your current access level: ",
|
|
1370
|
-
/* @__PURE__ */
|
|
1414
|
+
/* @__PURE__ */ n("strong", { children: i })
|
|
1371
1415
|
] })
|
|
1372
|
-
] }) : /* @__PURE__ */
|
|
1373
|
-
/* @__PURE__ */
|
|
1374
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1416
|
+
] }) : /* @__PURE__ */ u(U, { children: [
|
|
1417
|
+
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
|
|
1418
|
+
t && t.length > 0 && /* @__PURE__ */ u("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1375
1419
|
"Required permissions: ",
|
|
1376
|
-
/* @__PURE__ */
|
|
1420
|
+
/* @__PURE__ */ n("strong", { children: t.join(", ") })
|
|
1377
1421
|
] })
|
|
1378
1422
|
] })
|
|
1379
1423
|
]
|
|
1380
1424
|
}
|
|
1381
1425
|
)
|
|
1382
1426
|
}
|
|
1383
|
-
),
|
|
1427
|
+
), $e = (i, e) => {
|
|
1384
1428
|
const t = {
|
|
1385
|
-
[
|
|
1386
|
-
[
|
|
1387
|
-
[
|
|
1429
|
+
[X.USER]: 1,
|
|
1430
|
+
[X.TENANT_ADMIN]: 2,
|
|
1431
|
+
[X.SUPERUSER]: 3
|
|
1388
1432
|
};
|
|
1389
|
-
return t[
|
|
1433
|
+
return t[i] >= t[e];
|
|
1390
1434
|
};
|
|
1391
|
-
function
|
|
1392
|
-
children:
|
|
1435
|
+
function ot({
|
|
1436
|
+
children: i,
|
|
1393
1437
|
redirectTo: e = "/login",
|
|
1394
1438
|
minUserType: t,
|
|
1395
1439
|
requiredPermissions: r,
|
|
1396
1440
|
requireAllPermissions: s = !1,
|
|
1397
|
-
fallback:
|
|
1441
|
+
fallback: a
|
|
1398
1442
|
}) {
|
|
1399
|
-
const { hasValidSession:
|
|
1400
|
-
if (!
|
|
1401
|
-
return
|
|
1402
|
-
/* @__PURE__ */
|
|
1403
|
-
/* @__PURE__ */
|
|
1443
|
+
const { hasValidSession: x, sessionManager: d, hasPermission: M, hasAnyPermission: P, hasAllPermissions: g } = ee(), h = me();
|
|
1444
|
+
if (!x())
|
|
1445
|
+
return a ? /* @__PURE__ */ n(U, { children: a }) : /* @__PURE__ */ u(U, { children: [
|
|
1446
|
+
/* @__PURE__ */ n(He, { redirectPath: e }),
|
|
1447
|
+
/* @__PURE__ */ n(le, { to: e, state: { from: h.pathname }, replace: !0 })
|
|
1404
1448
|
] });
|
|
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__ */
|
|
1449
|
+
const b = d.getUser();
|
|
1450
|
+
if (!b)
|
|
1451
|
+
return /* @__PURE__ */ n(le, { to: e, state: { from: h.pathname }, replace: !0 });
|
|
1452
|
+
if (t && !$e(b.userType, t))
|
|
1453
|
+
return /* @__PURE__ */ n(he, { userType: b.userType, minUserType: t });
|
|
1454
|
+
if (r && r.length > 0 && !(s ? g(r) : P(r))) {
|
|
1455
|
+
const S = r.filter(($) => !M($)).map(($) => typeof $ == "string" ? $ : $.name);
|
|
1456
|
+
return /* @__PURE__ */ n(he, { missingPermissions: S });
|
|
1457
|
+
}
|
|
1458
|
+
return /* @__PURE__ */ n(U, { children: i });
|
|
1415
1459
|
}
|
|
1416
|
-
const
|
|
1460
|
+
const Ce = () => /* @__PURE__ */ u(
|
|
1417
1461
|
"div",
|
|
1418
1462
|
{
|
|
1419
1463
|
style: {
|
|
@@ -1425,19 +1469,19 @@ const Fe = () => /* @__PURE__ */ g(
|
|
|
1425
1469
|
color: "#dc2626"
|
|
1426
1470
|
},
|
|
1427
1471
|
children: [
|
|
1428
|
-
/* @__PURE__ */
|
|
1429
|
-
/* @__PURE__ */
|
|
1472
|
+
/* @__PURE__ */ n("h3", { style: { margin: "0 0 1rem 0" }, children: "🔒 Subscription Required" }),
|
|
1473
|
+
/* @__PURE__ */ n("p", { style: { margin: 0 }, children: "This feature requires a higher subscription plan. Please upgrade your plan to access this content." })
|
|
1430
1474
|
]
|
|
1431
1475
|
}
|
|
1432
1476
|
);
|
|
1433
|
-
function
|
|
1434
|
-
children:
|
|
1435
|
-
fallback: e = /* @__PURE__ */
|
|
1477
|
+
function at({
|
|
1478
|
+
children: i,
|
|
1479
|
+
fallback: e = /* @__PURE__ */ n(Ce, {}),
|
|
1436
1480
|
allowedPlans: t,
|
|
1437
1481
|
requiredFeature: r
|
|
1438
1482
|
}) {
|
|
1439
|
-
const { subscription: s, hasAllowedPlan:
|
|
1440
|
-
return
|
|
1483
|
+
const { subscription: s, hasAllowedPlan: a, isFeatureEnabled: x, loading: d } = Fe();
|
|
1484
|
+
return d ? /* @__PURE__ */ n(
|
|
1441
1485
|
"div",
|
|
1442
1486
|
{
|
|
1443
1487
|
style: {
|
|
@@ -1447,9 +1491,9 @@ function st({
|
|
|
1447
1491
|
},
|
|
1448
1492
|
children: "Loading subscription..."
|
|
1449
1493
|
}
|
|
1450
|
-
) : s ? s.isActive ? t && t.length > 0 && !
|
|
1494
|
+
) : s ? s.isActive ? t && t.length > 0 && !a(t) ? /* @__PURE__ */ n(U, { children: e }) : r && !x(r) ? /* @__PURE__ */ n(U, { children: e }) : /* @__PURE__ */ n(U, { children: i }) : /* @__PURE__ */ n(U, { children: e }) : /* @__PURE__ */ n(U, { children: e });
|
|
1451
1495
|
}
|
|
1452
|
-
const
|
|
1496
|
+
const Le = ({ flagName: i }) => /* @__PURE__ */ u(
|
|
1453
1497
|
"div",
|
|
1454
1498
|
{
|
|
1455
1499
|
style: {
|
|
@@ -1466,19 +1510,19 @@ const Ie = ({ flagName: n }) => /* @__PURE__ */ g(
|
|
|
1466
1510
|
color: "#6c757d"
|
|
1467
1511
|
},
|
|
1468
1512
|
children: [
|
|
1469
|
-
/* @__PURE__ */
|
|
1470
|
-
/* @__PURE__ */
|
|
1471
|
-
/* @__PURE__ */
|
|
1513
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
|
|
1514
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
|
|
1515
|
+
/* @__PURE__ */ u("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
|
|
1472
1516
|
'Feature flag "',
|
|
1473
|
-
|
|
1517
|
+
i,
|
|
1474
1518
|
'" is disabled'
|
|
1475
1519
|
] })
|
|
1476
1520
|
]
|
|
1477
1521
|
}
|
|
1478
1522
|
);
|
|
1479
|
-
function
|
|
1480
|
-
const { isEnabled: r, loading: s } =
|
|
1481
|
-
return s ? /* @__PURE__ */
|
|
1523
|
+
function lt({ name: i, children: e, fallback: t }) {
|
|
1524
|
+
const { isEnabled: r, loading: s } = Ee();
|
|
1525
|
+
return s ? /* @__PURE__ */ n(
|
|
1482
1526
|
"div",
|
|
1483
1527
|
{
|
|
1484
1528
|
style: {
|
|
@@ -1491,9 +1535,9 @@ function nt({ name: n, children: e, fallback: t }) {
|
|
|
1491
1535
|
},
|
|
1492
1536
|
children: "Loading feature flags..."
|
|
1493
1537
|
}
|
|
1494
|
-
) : (console.log(
|
|
1538
|
+
) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */ n(U, { children: e }) : /* @__PURE__ */ n(U, { children: t || /* @__PURE__ */ n(Le, { flagName: i }) }));
|
|
1495
1539
|
}
|
|
1496
|
-
const
|
|
1540
|
+
const De = () => /* @__PURE__ */ u(
|
|
1497
1541
|
"svg",
|
|
1498
1542
|
{
|
|
1499
1543
|
width: "16",
|
|
@@ -1506,11 +1550,11 @@ const He = () => /* @__PURE__ */ g(
|
|
|
1506
1550
|
strokeLinejoin: "round",
|
|
1507
1551
|
style: { flexShrink: 0 },
|
|
1508
1552
|
children: [
|
|
1509
|
-
/* @__PURE__ */
|
|
1510
|
-
/* @__PURE__ */
|
|
1553
|
+
/* @__PURE__ */ n("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
|
|
1554
|
+
/* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "3" })
|
|
1511
1555
|
]
|
|
1512
1556
|
}
|
|
1513
|
-
),
|
|
1557
|
+
), Be = () => /* @__PURE__ */ u(
|
|
1514
1558
|
"svg",
|
|
1515
1559
|
{
|
|
1516
1560
|
width: "16",
|
|
@@ -1523,14 +1567,14 @@ const He = () => /* @__PURE__ */ g(
|
|
|
1523
1567
|
strokeLinejoin: "round",
|
|
1524
1568
|
style: { flexShrink: 0 },
|
|
1525
1569
|
children: [
|
|
1526
|
-
/* @__PURE__ */
|
|
1527
|
-
/* @__PURE__ */
|
|
1570
|
+
/* @__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" }),
|
|
1571
|
+
/* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
1528
1572
|
]
|
|
1529
1573
|
}
|
|
1530
|
-
),
|
|
1531
|
-
showPassword: /* @__PURE__ */
|
|
1532
|
-
hidePassword: /* @__PURE__ */
|
|
1533
|
-
},
|
|
1574
|
+
), qe = {
|
|
1575
|
+
showPassword: /* @__PURE__ */ n(De, {}),
|
|
1576
|
+
hidePassword: /* @__PURE__ */ n(Be, {})
|
|
1577
|
+
}, Ue = {
|
|
1534
1578
|
title: "Sign In",
|
|
1535
1579
|
emailLabel: "Email",
|
|
1536
1580
|
emailPlaceholder: "Enter your email",
|
|
@@ -1542,7 +1586,7 @@ const He = () => /* @__PURE__ */ g(
|
|
|
1542
1586
|
signupText: "Don't have an account?",
|
|
1543
1587
|
errorMessage: "Invalid email or password",
|
|
1544
1588
|
loadingText: "Signing in..."
|
|
1545
|
-
},
|
|
1589
|
+
}, Ne = {
|
|
1546
1590
|
container: {
|
|
1547
1591
|
maxWidth: "400px",
|
|
1548
1592
|
width: "100%",
|
|
@@ -1649,119 +1693,119 @@ const He = () => /* @__PURE__ */ g(
|
|
|
1649
1693
|
fontSize: "0.875rem"
|
|
1650
1694
|
}
|
|
1651
1695
|
};
|
|
1652
|
-
function
|
|
1653
|
-
copy:
|
|
1696
|
+
function ct({
|
|
1697
|
+
copy: i = {},
|
|
1654
1698
|
styles: e = {},
|
|
1655
1699
|
icons: t = {},
|
|
1656
1700
|
onSuccess: r,
|
|
1657
1701
|
onError: s,
|
|
1658
|
-
onForgotPassword:
|
|
1659
|
-
onSignupClick:
|
|
1660
|
-
showForgotPassword:
|
|
1661
|
-
showSignupLink:
|
|
1662
|
-
className:
|
|
1702
|
+
onForgotPassword: a,
|
|
1703
|
+
onSignupClick: x,
|
|
1704
|
+
showForgotPassword: d = !0,
|
|
1705
|
+
showSignupLink: M = !0,
|
|
1706
|
+
className: P
|
|
1663
1707
|
}) {
|
|
1664
|
-
const [
|
|
1665
|
-
const
|
|
1666
|
-
return
|
|
1667
|
-
},
|
|
1668
|
-
if (
|
|
1708
|
+
const [g, h] = m(""), [b, y] = m(""), [S, $] = m(!1), [p, D] = m(!1), [A, E] = m(""), [f, I] = m({}), { login: C } = ee(), { tenant: F } = Z(), B = { ...Ue, ...i }, w = { ...Ne, ...e }, O = { ...qe, ...t }, T = () => {
|
|
1709
|
+
const c = {};
|
|
1710
|
+
return g.trim() || (c.email = !0), b.trim() || (c.password = !0), I(c), Object.keys(c).length === 0;
|
|
1711
|
+
}, o = async (c) => {
|
|
1712
|
+
if (c.preventDefault(), !!T()) {
|
|
1669
1713
|
if (!(F != null && F.id)) {
|
|
1670
|
-
|
|
1714
|
+
E("Tenant not found");
|
|
1671
1715
|
return;
|
|
1672
1716
|
}
|
|
1673
|
-
|
|
1717
|
+
D(!0), E("");
|
|
1674
1718
|
try {
|
|
1675
|
-
const
|
|
1676
|
-
r == null || r(
|
|
1677
|
-
} catch (
|
|
1678
|
-
const
|
|
1679
|
-
|
|
1719
|
+
const k = await C(g, b, F.id);
|
|
1720
|
+
r == null || r(k);
|
|
1721
|
+
} catch (k) {
|
|
1722
|
+
const W = k.message || B.errorMessage;
|
|
1723
|
+
E(W), s == null || s(W);
|
|
1680
1724
|
} finally {
|
|
1681
|
-
|
|
1725
|
+
D(!1);
|
|
1682
1726
|
}
|
|
1683
1727
|
}
|
|
1684
|
-
},
|
|
1685
|
-
...
|
|
1686
|
-
...
|
|
1687
|
-
}),
|
|
1688
|
-
...
|
|
1689
|
-
...
|
|
1690
|
-
...!
|
|
1728
|
+
}, l = (c) => ({
|
|
1729
|
+
...w.input,
|
|
1730
|
+
...f[c] ? w.inputError : {}
|
|
1731
|
+
}), H = () => ({
|
|
1732
|
+
...w.button,
|
|
1733
|
+
...p ? w.buttonLoading : {},
|
|
1734
|
+
...!g || !b || p ? w.buttonDisabled : {}
|
|
1691
1735
|
});
|
|
1692
|
-
return /* @__PURE__ */
|
|
1693
|
-
/* @__PURE__ */
|
|
1694
|
-
/* @__PURE__ */
|
|
1695
|
-
/* @__PURE__ */
|
|
1696
|
-
/* @__PURE__ */
|
|
1697
|
-
/* @__PURE__ */
|
|
1736
|
+
return /* @__PURE__ */ u("div", { className: P, style: w.container, children: [
|
|
1737
|
+
/* @__PURE__ */ n("h2", { style: w.title, children: B.title }),
|
|
1738
|
+
/* @__PURE__ */ u("form", { onSubmit: o, style: w.form, children: [
|
|
1739
|
+
/* @__PURE__ */ u("div", { style: w.fieldGroup, children: [
|
|
1740
|
+
/* @__PURE__ */ n("label", { style: w.label, children: B.emailLabel }),
|
|
1741
|
+
/* @__PURE__ */ n(
|
|
1698
1742
|
"input",
|
|
1699
1743
|
{
|
|
1700
1744
|
id: "email",
|
|
1701
1745
|
name: "email",
|
|
1702
1746
|
type: "email",
|
|
1703
|
-
value:
|
|
1704
|
-
onChange: (
|
|
1705
|
-
|
|
1747
|
+
value: g,
|
|
1748
|
+
onChange: (c) => {
|
|
1749
|
+
h(c.target.value), f.email && I((k) => ({ ...k, email: !1 }));
|
|
1706
1750
|
},
|
|
1707
|
-
placeholder:
|
|
1708
|
-
style:
|
|
1709
|
-
disabled:
|
|
1751
|
+
placeholder: B.emailPlaceholder,
|
|
1752
|
+
style: l("email"),
|
|
1753
|
+
disabled: p
|
|
1710
1754
|
}
|
|
1711
1755
|
)
|
|
1712
1756
|
] }),
|
|
1713
|
-
/* @__PURE__ */
|
|
1714
|
-
/* @__PURE__ */
|
|
1715
|
-
/* @__PURE__ */
|
|
1716
|
-
/* @__PURE__ */
|
|
1757
|
+
/* @__PURE__ */ u("div", { style: w.fieldGroup, children: [
|
|
1758
|
+
/* @__PURE__ */ n("label", { style: w.label, children: B.passwordLabel }),
|
|
1759
|
+
/* @__PURE__ */ u("div", { style: w.inputContainer, children: [
|
|
1760
|
+
/* @__PURE__ */ n(
|
|
1717
1761
|
"input",
|
|
1718
1762
|
{
|
|
1719
1763
|
id: "password",
|
|
1720
1764
|
name: "password",
|
|
1721
|
-
type:
|
|
1722
|
-
value:
|
|
1723
|
-
onChange: (
|
|
1724
|
-
|
|
1765
|
+
type: S ? "text" : "password",
|
|
1766
|
+
value: b,
|
|
1767
|
+
onChange: (c) => {
|
|
1768
|
+
y(c.target.value), f.password && I((k) => ({ ...k, password: !1 }));
|
|
1725
1769
|
},
|
|
1726
|
-
placeholder:
|
|
1770
|
+
placeholder: B.passwordPlaceholder,
|
|
1727
1771
|
style: {
|
|
1728
|
-
...
|
|
1772
|
+
...l("password"),
|
|
1729
1773
|
paddingRight: "2.5rem"
|
|
1730
1774
|
// Make room for the icon
|
|
1731
1775
|
},
|
|
1732
|
-
disabled:
|
|
1776
|
+
disabled: p
|
|
1733
1777
|
}
|
|
1734
1778
|
),
|
|
1735
|
-
/* @__PURE__ */
|
|
1779
|
+
/* @__PURE__ */ n(
|
|
1736
1780
|
"button",
|
|
1737
1781
|
{
|
|
1738
1782
|
type: "button",
|
|
1739
|
-
onClick: () =>
|
|
1740
|
-
style:
|
|
1741
|
-
disabled:
|
|
1742
|
-
"aria-label":
|
|
1743
|
-
children:
|
|
1783
|
+
onClick: () => $(!S),
|
|
1784
|
+
style: w.passwordToggle,
|
|
1785
|
+
disabled: p,
|
|
1786
|
+
"aria-label": S ? "Hide password" : "Show password",
|
|
1787
|
+
children: S ? O.hidePassword : O.showPassword
|
|
1744
1788
|
}
|
|
1745
1789
|
)
|
|
1746
1790
|
] })
|
|
1747
1791
|
] }),
|
|
1748
|
-
/* @__PURE__ */
|
|
1749
|
-
|
|
1792
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !g || !b || p, style: H(), children: p ? B.loadingText : B.submitButton }),
|
|
1793
|
+
A && /* @__PURE__ */ n("div", { style: w.errorText, children: A })
|
|
1750
1794
|
] }),
|
|
1751
|
-
(
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
/* @__PURE__ */
|
|
1756
|
-
|
|
1795
|
+
(d || M) && /* @__PURE__ */ u("div", { style: w.linkContainer, children: [
|
|
1796
|
+
d && /* @__PURE__ */ n("a", { onClick: a, style: w.link, children: B.forgotPasswordLink }),
|
|
1797
|
+
d && M && /* @__PURE__ */ n("div", { style: w.divider, children: "•" }),
|
|
1798
|
+
M && /* @__PURE__ */ u("div", { children: [
|
|
1799
|
+
/* @__PURE__ */ u("span", { style: w.divider, children: [
|
|
1800
|
+
B.signupText,
|
|
1757
1801
|
" "
|
|
1758
1802
|
] }),
|
|
1759
|
-
/* @__PURE__ */
|
|
1803
|
+
/* @__PURE__ */ n("a", { onClick: x, style: w.link, children: B.signupLink })
|
|
1760
1804
|
] })
|
|
1761
1805
|
] })
|
|
1762
1806
|
] });
|
|
1763
1807
|
}
|
|
1764
|
-
const
|
|
1808
|
+
const Oe = {
|
|
1765
1809
|
title: "Create Account",
|
|
1766
1810
|
nameLabel: "Full Name",
|
|
1767
1811
|
namePlaceholder: "Enter your full name",
|
|
@@ -1781,7 +1825,7 @@ const Be = {
|
|
|
1781
1825
|
passwordMismatchError: "Passwords do not match",
|
|
1782
1826
|
isAdminLabel: "Create new organization",
|
|
1783
1827
|
isAdminDescription: "Check this if you want to create a new organization"
|
|
1784
|
-
},
|
|
1828
|
+
}, ze = {
|
|
1785
1829
|
container: {
|
|
1786
1830
|
maxWidth: "400px",
|
|
1787
1831
|
width: "100%",
|
|
@@ -1880,154 +1924,154 @@ const Be = {
|
|
|
1880
1924
|
fontSize: "0.875rem"
|
|
1881
1925
|
}
|
|
1882
1926
|
};
|
|
1883
|
-
function
|
|
1884
|
-
copy:
|
|
1927
|
+
function dt({
|
|
1928
|
+
copy: i = {},
|
|
1885
1929
|
styles: e = {},
|
|
1886
1930
|
signupType: t = "user",
|
|
1887
1931
|
onSuccess: r,
|
|
1888
1932
|
onError: s,
|
|
1889
|
-
onLoginClick:
|
|
1890
|
-
showLoginLink:
|
|
1891
|
-
className:
|
|
1933
|
+
onLoginClick: a,
|
|
1934
|
+
showLoginLink: x = !0,
|
|
1935
|
+
className: d
|
|
1892
1936
|
}) {
|
|
1893
|
-
const [
|
|
1894
|
-
const
|
|
1895
|
-
return
|
|
1896
|
-
},
|
|
1897
|
-
if (
|
|
1898
|
-
if (
|
|
1899
|
-
|
|
1937
|
+
const [M, P] = m(""), [g, h] = m(""), [b, y] = m(""), [S, $] = m(""), [p, D] = m(""), [A, E] = m(!1), [f, I] = m(""), [C, F] = m({}), { signup: B, signupTenantAdmin: w } = ee(), { tenant: O } = Z(), T = { ...Oe, ...i }, o = { ...ze, ...e }, l = () => {
|
|
1938
|
+
const R = {};
|
|
1939
|
+
return M.trim() || (R.name = !0), g.trim() || (R.email = !0), b.trim() || (R.password = !0), S.trim() || (R.confirmPassword = !0), t === "tenant" && !p.trim() && (R.tenantName = !0), F(R), Object.keys(R).length === 0;
|
|
1940
|
+
}, H = async (R) => {
|
|
1941
|
+
if (R.preventDefault(), !!l()) {
|
|
1942
|
+
if (b !== S) {
|
|
1943
|
+
I(T.passwordMismatchError), F({ confirmPassword: !0 });
|
|
1900
1944
|
return;
|
|
1901
1945
|
}
|
|
1902
|
-
if (t === "user" && !(
|
|
1903
|
-
|
|
1946
|
+
if (t === "user" && !(O != null && O.id)) {
|
|
1947
|
+
I("Tenant not found");
|
|
1904
1948
|
return;
|
|
1905
1949
|
}
|
|
1906
|
-
|
|
1950
|
+
E(!0), I("");
|
|
1907
1951
|
try {
|
|
1908
1952
|
let q;
|
|
1909
|
-
t === "tenant" ? q = await
|
|
1953
|
+
t === "tenant" ? q = await w(g, M, b, p) : q = await B(g, M, b, O.id), r == null || r(q);
|
|
1910
1954
|
} catch (q) {
|
|
1911
|
-
const
|
|
1912
|
-
|
|
1955
|
+
const Y = q.message || T.errorMessage;
|
|
1956
|
+
I(Y), s == null || s(Y);
|
|
1913
1957
|
} finally {
|
|
1914
|
-
|
|
1958
|
+
E(!1);
|
|
1915
1959
|
}
|
|
1916
1960
|
}
|
|
1917
|
-
},
|
|
1918
|
-
...
|
|
1919
|
-
...
|
|
1920
|
-
}),
|
|
1921
|
-
...
|
|
1922
|
-
...
|
|
1923
|
-
...!
|
|
1924
|
-
}),
|
|
1925
|
-
return /* @__PURE__ */
|
|
1926
|
-
/* @__PURE__ */
|
|
1927
|
-
/* @__PURE__ */
|
|
1928
|
-
/* @__PURE__ */
|
|
1929
|
-
/* @__PURE__ */
|
|
1930
|
-
/* @__PURE__ */
|
|
1961
|
+
}, c = (R) => ({
|
|
1962
|
+
...o.input,
|
|
1963
|
+
...C[R] ? o.inputError : {}
|
|
1964
|
+
}), k = () => ({
|
|
1965
|
+
...o.button,
|
|
1966
|
+
...A ? o.buttonLoading : {},
|
|
1967
|
+
...!M || !g || !b || !S || A || t === "tenant" && !p ? o.buttonDisabled : {}
|
|
1968
|
+
}), W = M && g && b && S && (t === "user" || p);
|
|
1969
|
+
return /* @__PURE__ */ u("div", { className: d, style: o.container, children: [
|
|
1970
|
+
/* @__PURE__ */ n("h2", { style: o.title, children: T.title }),
|
|
1971
|
+
/* @__PURE__ */ u("form", { onSubmit: H, style: o.form, children: [
|
|
1972
|
+
/* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
|
|
1973
|
+
/* @__PURE__ */ n("label", { style: o.label, children: T.nameLabel }),
|
|
1974
|
+
/* @__PURE__ */ n(
|
|
1931
1975
|
"input",
|
|
1932
1976
|
{
|
|
1933
1977
|
id: "name",
|
|
1934
1978
|
name: "name",
|
|
1935
1979
|
type: "text",
|
|
1936
|
-
value:
|
|
1937
|
-
onChange: (
|
|
1938
|
-
|
|
1980
|
+
value: M,
|
|
1981
|
+
onChange: (R) => {
|
|
1982
|
+
P(R.target.value), C.name && F((q) => ({ ...q, name: !1 }));
|
|
1939
1983
|
},
|
|
1940
|
-
placeholder:
|
|
1941
|
-
style:
|
|
1942
|
-
disabled:
|
|
1984
|
+
placeholder: T.namePlaceholder,
|
|
1985
|
+
style: c("name"),
|
|
1986
|
+
disabled: A
|
|
1943
1987
|
}
|
|
1944
1988
|
)
|
|
1945
1989
|
] }),
|
|
1946
|
-
/* @__PURE__ */
|
|
1947
|
-
/* @__PURE__ */
|
|
1948
|
-
/* @__PURE__ */
|
|
1990
|
+
/* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
|
|
1991
|
+
/* @__PURE__ */ n("label", { style: o.label, children: T.emailLabel }),
|
|
1992
|
+
/* @__PURE__ */ n(
|
|
1949
1993
|
"input",
|
|
1950
1994
|
{
|
|
1951
1995
|
id: "email",
|
|
1952
1996
|
name: "email",
|
|
1953
1997
|
type: "email",
|
|
1954
|
-
value:
|
|
1955
|
-
onChange: (
|
|
1956
|
-
|
|
1998
|
+
value: g,
|
|
1999
|
+
onChange: (R) => {
|
|
2000
|
+
h(R.target.value), C.email && F((q) => ({ ...q, email: !1 }));
|
|
1957
2001
|
},
|
|
1958
|
-
placeholder:
|
|
1959
|
-
style:
|
|
1960
|
-
disabled:
|
|
2002
|
+
placeholder: T.emailPlaceholder,
|
|
2003
|
+
style: c("email"),
|
|
2004
|
+
disabled: A
|
|
1961
2005
|
}
|
|
1962
2006
|
)
|
|
1963
2007
|
] }),
|
|
1964
|
-
/* @__PURE__ */
|
|
1965
|
-
/* @__PURE__ */
|
|
1966
|
-
/* @__PURE__ */
|
|
2008
|
+
/* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
|
|
2009
|
+
/* @__PURE__ */ n("label", { style: o.label, children: T.passwordLabel }),
|
|
2010
|
+
/* @__PURE__ */ n(
|
|
1967
2011
|
"input",
|
|
1968
2012
|
{
|
|
1969
2013
|
id: "password",
|
|
1970
2014
|
name: "password",
|
|
1971
2015
|
type: "password",
|
|
1972
|
-
value:
|
|
1973
|
-
onChange: (
|
|
1974
|
-
|
|
2016
|
+
value: b,
|
|
2017
|
+
onChange: (R) => {
|
|
2018
|
+
y(R.target.value), C.password && F((q) => ({ ...q, password: !1 }));
|
|
1975
2019
|
},
|
|
1976
|
-
placeholder:
|
|
1977
|
-
style:
|
|
1978
|
-
disabled:
|
|
2020
|
+
placeholder: T.passwordPlaceholder,
|
|
2021
|
+
style: c("password"),
|
|
2022
|
+
disabled: A
|
|
1979
2023
|
}
|
|
1980
2024
|
)
|
|
1981
2025
|
] }),
|
|
1982
|
-
/* @__PURE__ */
|
|
1983
|
-
/* @__PURE__ */
|
|
1984
|
-
/* @__PURE__ */
|
|
2026
|
+
/* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
|
|
2027
|
+
/* @__PURE__ */ n("label", { style: o.label, children: T.confirmPasswordLabel }),
|
|
2028
|
+
/* @__PURE__ */ n(
|
|
1985
2029
|
"input",
|
|
1986
2030
|
{
|
|
1987
2031
|
id: "confirmPassword",
|
|
1988
2032
|
name: "confirmPassword",
|
|
1989
2033
|
type: "password",
|
|
1990
|
-
value:
|
|
1991
|
-
onChange: (
|
|
1992
|
-
|
|
2034
|
+
value: S,
|
|
2035
|
+
onChange: (R) => {
|
|
2036
|
+
$(R.target.value), C.confirmPassword && F((q) => ({ ...q, confirmPassword: !1 })), f === T.passwordMismatchError && I("");
|
|
1993
2037
|
},
|
|
1994
|
-
placeholder:
|
|
1995
|
-
style:
|
|
1996
|
-
disabled:
|
|
2038
|
+
placeholder: T.confirmPasswordPlaceholder,
|
|
2039
|
+
style: c("confirmPassword"),
|
|
2040
|
+
disabled: A
|
|
1997
2041
|
}
|
|
1998
2042
|
)
|
|
1999
2043
|
] }),
|
|
2000
|
-
t === "tenant" && /* @__PURE__ */
|
|
2001
|
-
/* @__PURE__ */
|
|
2002
|
-
/* @__PURE__ */
|
|
2044
|
+
t === "tenant" && /* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
|
|
2045
|
+
/* @__PURE__ */ n("label", { style: o.label, children: T.tenantNameLabel }),
|
|
2046
|
+
/* @__PURE__ */ n(
|
|
2003
2047
|
"input",
|
|
2004
2048
|
{
|
|
2005
2049
|
id: "tenantName",
|
|
2006
2050
|
name: "tenantName",
|
|
2007
2051
|
type: "text",
|
|
2008
|
-
value:
|
|
2009
|
-
onChange: (
|
|
2010
|
-
|
|
2052
|
+
value: p,
|
|
2053
|
+
onChange: (R) => {
|
|
2054
|
+
D(R.target.value), C.tenantName && F((q) => ({ ...q, tenantName: !1 }));
|
|
2011
2055
|
},
|
|
2012
|
-
placeholder:
|
|
2013
|
-
style:
|
|
2014
|
-
disabled:
|
|
2056
|
+
placeholder: T.tenantNamePlaceholder,
|
|
2057
|
+
style: c("tenantName"),
|
|
2058
|
+
disabled: A
|
|
2015
2059
|
}
|
|
2016
2060
|
)
|
|
2017
2061
|
] }),
|
|
2018
|
-
/* @__PURE__ */
|
|
2019
|
-
|
|
2062
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !W || A, style: k(), children: A ? T.loadingText : T.submitButton }),
|
|
2063
|
+
f && /* @__PURE__ */ n("div", { style: o.errorText, children: f })
|
|
2020
2064
|
] }),
|
|
2021
|
-
|
|
2022
|
-
/* @__PURE__ */
|
|
2023
|
-
|
|
2065
|
+
x && /* @__PURE__ */ u("div", { style: o.linkContainer, children: [
|
|
2066
|
+
/* @__PURE__ */ u("span", { style: o.divider, children: [
|
|
2067
|
+
T.loginText,
|
|
2024
2068
|
" "
|
|
2025
2069
|
] }),
|
|
2026
|
-
/* @__PURE__ */
|
|
2070
|
+
/* @__PURE__ */ n("a", { onClick: a, style: o.link, children: T.loginLink })
|
|
2027
2071
|
] })
|
|
2028
2072
|
] });
|
|
2029
2073
|
}
|
|
2030
|
-
const
|
|
2074
|
+
const je = {
|
|
2031
2075
|
title: "Reset Password",
|
|
2032
2076
|
subtitle: "Enter your email address and we'll send you a link to reset your password.",
|
|
2033
2077
|
emailLabel: "Email",
|
|
@@ -2049,7 +2093,7 @@ const Ue = {
|
|
|
2049
2093
|
resetLoadingText: "Resetting...",
|
|
2050
2094
|
resetSuccessMessage: "Password reset successfully!",
|
|
2051
2095
|
passwordMismatchError: "Passwords do not match"
|
|
2052
|
-
},
|
|
2096
|
+
}, Ve = {
|
|
2053
2097
|
container: {
|
|
2054
2098
|
maxWidth: "400px",
|
|
2055
2099
|
margin: "0 auto",
|
|
@@ -2141,186 +2185,186 @@ const Ue = {
|
|
|
2141
2185
|
cursor: "pointer"
|
|
2142
2186
|
}
|
|
2143
2187
|
};
|
|
2144
|
-
function
|
|
2145
|
-
copy:
|
|
2188
|
+
function ut({
|
|
2189
|
+
copy: i = {},
|
|
2146
2190
|
styles: e = {},
|
|
2147
2191
|
mode: t = "request",
|
|
2148
2192
|
token: r = "",
|
|
2149
2193
|
onSuccess: s,
|
|
2150
|
-
onError:
|
|
2151
|
-
onBackToLogin:
|
|
2152
|
-
onModeChange:
|
|
2153
|
-
className:
|
|
2194
|
+
onError: a,
|
|
2195
|
+
onBackToLogin: x,
|
|
2196
|
+
onModeChange: d,
|
|
2197
|
+
className: M
|
|
2154
2198
|
}) {
|
|
2155
|
-
const [
|
|
2156
|
-
const
|
|
2157
|
-
return
|
|
2158
|
-
},
|
|
2159
|
-
const
|
|
2160
|
-
return
|
|
2161
|
-
},
|
|
2162
|
-
if (
|
|
2163
|
-
if (!(
|
|
2164
|
-
|
|
2199
|
+
const [P, g] = m(""), [h, b] = m(r), [y, S] = m(""), [$, p] = m(""), [D, A] = m(!1), [E, f] = m(""), [I, C] = m(""), [F, B] = m({}), { requestPasswordReset: w, confirmPasswordReset: O } = ee(), { tenant: T } = Z(), o = { ...je, ...i }, l = { ...Ve, ...e }, H = () => {
|
|
2200
|
+
const N = {};
|
|
2201
|
+
return P.trim() || (N.email = !0), B(N), Object.keys(N).length === 0;
|
|
2202
|
+
}, c = () => {
|
|
2203
|
+
const N = {};
|
|
2204
|
+
return h.trim() || (N.token = !0), y.trim() || (N.newPassword = !0), $.trim() || (N.confirmPassword = !0), B(N), Object.keys(N).length === 0;
|
|
2205
|
+
}, k = async (N) => {
|
|
2206
|
+
if (N.preventDefault(), !!H()) {
|
|
2207
|
+
if (!(T != null && T.id)) {
|
|
2208
|
+
f("Tenant not found");
|
|
2165
2209
|
return;
|
|
2166
2210
|
}
|
|
2167
|
-
|
|
2211
|
+
A(!0), f(""), C("");
|
|
2168
2212
|
try {
|
|
2169
|
-
await
|
|
2213
|
+
await w(P, T.id), C(o.successMessage), s == null || s();
|
|
2170
2214
|
} catch (j) {
|
|
2171
|
-
const
|
|
2172
|
-
|
|
2215
|
+
const V = j.message || o.errorMessage;
|
|
2216
|
+
f(V), a == null || a(V);
|
|
2173
2217
|
} finally {
|
|
2174
|
-
|
|
2218
|
+
A(!1);
|
|
2175
2219
|
}
|
|
2176
2220
|
}
|
|
2177
|
-
},
|
|
2178
|
-
if (
|
|
2179
|
-
if (
|
|
2180
|
-
|
|
2221
|
+
}, W = async (N) => {
|
|
2222
|
+
if (N.preventDefault(), !!c()) {
|
|
2223
|
+
if (y !== $) {
|
|
2224
|
+
f(o.passwordMismatchError), B({ confirmPassword: !0 });
|
|
2181
2225
|
return;
|
|
2182
2226
|
}
|
|
2183
|
-
|
|
2227
|
+
A(!0), f(""), C("");
|
|
2184
2228
|
try {
|
|
2185
|
-
await
|
|
2229
|
+
await O(h, y), C(o.resetSuccessMessage), s == null || s();
|
|
2186
2230
|
} catch (j) {
|
|
2187
|
-
const
|
|
2188
|
-
|
|
2231
|
+
const V = j.message || o.errorMessage;
|
|
2232
|
+
f(V), a == null || a(V);
|
|
2189
2233
|
} finally {
|
|
2190
|
-
|
|
2234
|
+
A(!1);
|
|
2191
2235
|
}
|
|
2192
2236
|
}
|
|
2193
|
-
},
|
|
2194
|
-
...
|
|
2195
|
-
...F[
|
|
2237
|
+
}, R = (N) => ({
|
|
2238
|
+
...l.input,
|
|
2239
|
+
...F[N] ? l.inputError : {}
|
|
2196
2240
|
}), q = () => ({
|
|
2197
|
-
...
|
|
2198
|
-
...
|
|
2241
|
+
...l.button,
|
|
2242
|
+
...D ? l.buttonLoading : {}
|
|
2199
2243
|
});
|
|
2200
2244
|
if (t === "reset") {
|
|
2201
|
-
const
|
|
2202
|
-
return /* @__PURE__ */
|
|
2203
|
-
/* @__PURE__ */
|
|
2204
|
-
/* @__PURE__ */
|
|
2205
|
-
/* @__PURE__ */
|
|
2206
|
-
/* @__PURE__ */
|
|
2207
|
-
/* @__PURE__ */
|
|
2208
|
-
/* @__PURE__ */
|
|
2245
|
+
const N = h && y && $;
|
|
2246
|
+
return /* @__PURE__ */ u("div", { className: M, style: l.container, children: [
|
|
2247
|
+
/* @__PURE__ */ n("h2", { style: l.title, children: o.resetTitle }),
|
|
2248
|
+
/* @__PURE__ */ n("p", { style: l.subtitle, children: o.resetSubtitle }),
|
|
2249
|
+
/* @__PURE__ */ u("form", { onSubmit: W, style: l.form, children: [
|
|
2250
|
+
/* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
|
|
2251
|
+
/* @__PURE__ */ n("label", { style: l.label, children: o.tokenLabel }),
|
|
2252
|
+
/* @__PURE__ */ n(
|
|
2209
2253
|
"input",
|
|
2210
2254
|
{
|
|
2211
2255
|
type: "text",
|
|
2212
|
-
value:
|
|
2256
|
+
value: h,
|
|
2213
2257
|
onChange: (j) => {
|
|
2214
|
-
|
|
2258
|
+
b(j.target.value), F.token && B((V) => ({ ...V, token: !1 }));
|
|
2215
2259
|
},
|
|
2216
|
-
placeholder:
|
|
2217
|
-
style:
|
|
2218
|
-
disabled:
|
|
2260
|
+
placeholder: o.tokenPlaceholder,
|
|
2261
|
+
style: R("token"),
|
|
2262
|
+
disabled: D
|
|
2219
2263
|
}
|
|
2220
2264
|
)
|
|
2221
2265
|
] }),
|
|
2222
|
-
/* @__PURE__ */
|
|
2223
|
-
/* @__PURE__ */
|
|
2224
|
-
/* @__PURE__ */
|
|
2266
|
+
/* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
|
|
2267
|
+
/* @__PURE__ */ n("label", { style: l.label, children: o.newPasswordLabel }),
|
|
2268
|
+
/* @__PURE__ */ n(
|
|
2225
2269
|
"input",
|
|
2226
2270
|
{
|
|
2227
2271
|
type: "password",
|
|
2228
|
-
value:
|
|
2272
|
+
value: y,
|
|
2229
2273
|
onChange: (j) => {
|
|
2230
|
-
|
|
2274
|
+
S(j.target.value), F.newPassword && B((V) => ({ ...V, newPassword: !1 }));
|
|
2231
2275
|
},
|
|
2232
|
-
placeholder:
|
|
2233
|
-
style:
|
|
2234
|
-
disabled:
|
|
2276
|
+
placeholder: o.newPasswordPlaceholder,
|
|
2277
|
+
style: R("newPassword"),
|
|
2278
|
+
disabled: D
|
|
2235
2279
|
}
|
|
2236
2280
|
)
|
|
2237
2281
|
] }),
|
|
2238
|
-
/* @__PURE__ */
|
|
2239
|
-
/* @__PURE__ */
|
|
2240
|
-
/* @__PURE__ */
|
|
2282
|
+
/* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
|
|
2283
|
+
/* @__PURE__ */ n("label", { style: l.label, children: o.confirmPasswordLabel }),
|
|
2284
|
+
/* @__PURE__ */ n(
|
|
2241
2285
|
"input",
|
|
2242
2286
|
{
|
|
2243
2287
|
type: "password",
|
|
2244
|
-
value:
|
|
2288
|
+
value: $,
|
|
2245
2289
|
onChange: (j) => {
|
|
2246
|
-
|
|
2290
|
+
p(j.target.value), F.confirmPassword && B((V) => ({ ...V, confirmPassword: !1 })), E === o.passwordMismatchError && f("");
|
|
2247
2291
|
},
|
|
2248
|
-
placeholder:
|
|
2249
|
-
style:
|
|
2250
|
-
disabled:
|
|
2292
|
+
placeholder: o.confirmPasswordPlaceholder,
|
|
2293
|
+
style: R("confirmPassword"),
|
|
2294
|
+
disabled: D
|
|
2251
2295
|
}
|
|
2252
2296
|
)
|
|
2253
2297
|
] }),
|
|
2254
|
-
/* @__PURE__ */
|
|
2298
|
+
/* @__PURE__ */ n(
|
|
2255
2299
|
"button",
|
|
2256
2300
|
{
|
|
2257
2301
|
type: "submit",
|
|
2258
|
-
disabled: !
|
|
2302
|
+
disabled: !N || D,
|
|
2259
2303
|
style: {
|
|
2260
2304
|
...q(),
|
|
2261
|
-
...!
|
|
2305
|
+
...!N || D ? l.buttonDisabled : {}
|
|
2262
2306
|
},
|
|
2263
|
-
children:
|
|
2307
|
+
children: D ? o.resetLoadingText : o.resetSubmitButton
|
|
2264
2308
|
}
|
|
2265
2309
|
),
|
|
2266
|
-
|
|
2267
|
-
|
|
2310
|
+
E && /* @__PURE__ */ n("div", { style: l.errorText, children: E }),
|
|
2311
|
+
I && /* @__PURE__ */ n("div", { style: l.successText, children: I })
|
|
2268
2312
|
] }),
|
|
2269
|
-
/* @__PURE__ */
|
|
2270
|
-
/* @__PURE__ */
|
|
2271
|
-
|
|
2272
|
-
/* @__PURE__ */
|
|
2273
|
-
/* @__PURE__ */
|
|
2313
|
+
/* @__PURE__ */ u("div", { style: l.linkContainer, children: [
|
|
2314
|
+
/* @__PURE__ */ n("a", { onClick: x, style: l.link, children: o.backToLoginLink }),
|
|
2315
|
+
d && /* @__PURE__ */ u(U, { children: [
|
|
2316
|
+
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
2317
|
+
/* @__PURE__ */ n("a", { onClick: () => d("request"), style: l.link, children: "Request New Link" })
|
|
2274
2318
|
] })
|
|
2275
2319
|
] })
|
|
2276
2320
|
] });
|
|
2277
2321
|
}
|
|
2278
|
-
const
|
|
2279
|
-
return /* @__PURE__ */
|
|
2280
|
-
/* @__PURE__ */
|
|
2281
|
-
/* @__PURE__ */
|
|
2282
|
-
/* @__PURE__ */
|
|
2283
|
-
/* @__PURE__ */
|
|
2284
|
-
/* @__PURE__ */
|
|
2285
|
-
/* @__PURE__ */
|
|
2322
|
+
const Y = P;
|
|
2323
|
+
return /* @__PURE__ */ u("div", { className: M, style: l.container, children: [
|
|
2324
|
+
/* @__PURE__ */ n("h2", { style: l.title, children: o.title }),
|
|
2325
|
+
/* @__PURE__ */ n("p", { style: l.subtitle, children: o.subtitle }),
|
|
2326
|
+
/* @__PURE__ */ u("form", { onSubmit: k, style: l.form, children: [
|
|
2327
|
+
/* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
|
|
2328
|
+
/* @__PURE__ */ n("label", { style: l.label, children: o.emailLabel }),
|
|
2329
|
+
/* @__PURE__ */ n(
|
|
2286
2330
|
"input",
|
|
2287
2331
|
{
|
|
2288
2332
|
type: "email",
|
|
2289
|
-
value:
|
|
2290
|
-
onChange: (
|
|
2291
|
-
|
|
2333
|
+
value: P,
|
|
2334
|
+
onChange: (N) => {
|
|
2335
|
+
g(N.target.value), F.email && B((j) => ({ ...j, email: !1 }));
|
|
2292
2336
|
},
|
|
2293
|
-
placeholder:
|
|
2294
|
-
style:
|
|
2295
|
-
disabled:
|
|
2337
|
+
placeholder: o.emailPlaceholder,
|
|
2338
|
+
style: R("email"),
|
|
2339
|
+
disabled: D
|
|
2296
2340
|
}
|
|
2297
2341
|
)
|
|
2298
2342
|
] }),
|
|
2299
|
-
/* @__PURE__ */
|
|
2343
|
+
/* @__PURE__ */ n(
|
|
2300
2344
|
"button",
|
|
2301
2345
|
{
|
|
2302
2346
|
type: "submit",
|
|
2303
|
-
disabled: !
|
|
2347
|
+
disabled: !Y || D,
|
|
2304
2348
|
style: {
|
|
2305
2349
|
...q(),
|
|
2306
|
-
...!
|
|
2350
|
+
...!Y || D ? l.buttonDisabled : {}
|
|
2307
2351
|
},
|
|
2308
|
-
children:
|
|
2352
|
+
children: D ? o.loadingText : o.submitButton
|
|
2309
2353
|
}
|
|
2310
2354
|
),
|
|
2311
|
-
|
|
2312
|
-
|
|
2355
|
+
E && /* @__PURE__ */ n("div", { style: l.errorText, children: E }),
|
|
2356
|
+
I && /* @__PURE__ */ n("div", { style: l.successText, children: I })
|
|
2313
2357
|
] }),
|
|
2314
|
-
/* @__PURE__ */
|
|
2315
|
-
/* @__PURE__ */
|
|
2316
|
-
|
|
2317
|
-
/* @__PURE__ */
|
|
2318
|
-
/* @__PURE__ */
|
|
2358
|
+
/* @__PURE__ */ u("div", { style: l.linkContainer, children: [
|
|
2359
|
+
/* @__PURE__ */ n("a", { onClick: x, style: l.link, children: o.backToLoginLink }),
|
|
2360
|
+
d && /* @__PURE__ */ u(U, { children: [
|
|
2361
|
+
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
2362
|
+
/* @__PURE__ */ n("a", { onClick: () => d("reset"), style: l.link, children: "I have a token" })
|
|
2319
2363
|
] })
|
|
2320
2364
|
] })
|
|
2321
2365
|
] });
|
|
2322
2366
|
}
|
|
2323
|
-
class
|
|
2367
|
+
class ht {
|
|
2324
2368
|
constructor(e, t) {
|
|
2325
2369
|
this.httpService = e, this.sessionManager = t;
|
|
2326
2370
|
}
|
|
@@ -2341,12 +2385,12 @@ class lt {
|
|
|
2341
2385
|
throw new Error("SessionManager is required for private endpoints");
|
|
2342
2386
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
2343
2387
|
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()}` : ""}`,
|
|
2388
|
+
const s = `/permissions/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
|
|
2345
2389
|
headers: t
|
|
2346
2390
|
});
|
|
2347
2391
|
return {
|
|
2348
|
-
permissions:
|
|
2349
|
-
meta:
|
|
2392
|
+
permissions: a.data,
|
|
2393
|
+
meta: a.meta
|
|
2350
2394
|
};
|
|
2351
2395
|
}
|
|
2352
2396
|
async getPermissionById(e) {
|
|
@@ -2381,14 +2425,14 @@ class lt {
|
|
|
2381
2425
|
async getAppPermissions(e, t) {
|
|
2382
2426
|
const r = new URLSearchParams();
|
|
2383
2427
|
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()}` : ""}`,
|
|
2428
|
+
const s = `/permissions/apps/${e}${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s);
|
|
2385
2429
|
return {
|
|
2386
|
-
permissions:
|
|
2387
|
-
meta:
|
|
2430
|
+
permissions: a.data,
|
|
2431
|
+
meta: a.meta
|
|
2388
2432
|
};
|
|
2389
2433
|
}
|
|
2390
2434
|
}
|
|
2391
|
-
class
|
|
2435
|
+
class gt {
|
|
2392
2436
|
constructor(e, t) {
|
|
2393
2437
|
this.httpService = e, this.sessionManager = t;
|
|
2394
2438
|
}
|
|
@@ -2405,12 +2449,12 @@ class ct {
|
|
|
2405
2449
|
async getSubscriptionPlans(e) {
|
|
2406
2450
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
2407
2451
|
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()}` : ""}`,
|
|
2452
|
+
const s = `/subscription-plans/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
|
|
2409
2453
|
headers: t
|
|
2410
2454
|
});
|
|
2411
2455
|
return {
|
|
2412
|
-
plans:
|
|
2413
|
-
meta:
|
|
2456
|
+
plans: a.data,
|
|
2457
|
+
meta: a.meta
|
|
2414
2458
|
};
|
|
2415
2459
|
}
|
|
2416
2460
|
async getSubscriptionPlanById(e) {
|
|
@@ -2439,7 +2483,7 @@ class ct {
|
|
|
2439
2483
|
});
|
|
2440
2484
|
}
|
|
2441
2485
|
}
|
|
2442
|
-
class
|
|
2486
|
+
class pt {
|
|
2443
2487
|
constructor(e) {
|
|
2444
2488
|
this.httpService = e;
|
|
2445
2489
|
}
|
|
@@ -2448,7 +2492,7 @@ class dt {
|
|
|
2448
2492
|
return await this.httpService.get("/health");
|
|
2449
2493
|
}
|
|
2450
2494
|
}
|
|
2451
|
-
class
|
|
2495
|
+
class ft {
|
|
2452
2496
|
// Date string to Date object
|
|
2453
2497
|
static toDate(e) {
|
|
2454
2498
|
return new Date(e);
|
|
@@ -2571,39 +2615,40 @@ class ut {
|
|
|
2571
2615
|
}
|
|
2572
2616
|
}
|
|
2573
2617
|
export {
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2618
|
+
ft as ApiMappers,
|
|
2619
|
+
be as AppApiService,
|
|
2620
|
+
Je as AppProvider,
|
|
2621
|
+
Ae as AuthApiService,
|
|
2622
|
+
rt as AuthProvider,
|
|
2623
|
+
lt as FeatureFlag,
|
|
2624
|
+
Me as FeatureFlagApiService,
|
|
2625
|
+
st as FeatureFlagProvider,
|
|
2626
|
+
pt as HealthApiService,
|
|
2627
|
+
_ as HttpService,
|
|
2628
|
+
ct as LoginForm,
|
|
2629
|
+
ut as PasswordRecoveryForm,
|
|
2630
|
+
ht as PermissionApiService,
|
|
2631
|
+
it as Protected,
|
|
2632
|
+
ot as ProtectedRoute,
|
|
2633
|
+
ce as RoleApiService,
|
|
2634
|
+
xe as SessionManager,
|
|
2635
|
+
dt as SignupForm,
|
|
2636
|
+
Re as SubscriptionApiService,
|
|
2637
|
+
at as SubscriptionGuard,
|
|
2638
|
+
gt as SubscriptionPlanApiService,
|
|
2639
|
+
nt as SubscriptionProvider,
|
|
2640
|
+
oe as TenantApiService,
|
|
2597
2641
|
Ze as TenantProvider,
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2642
|
+
Pe as UserApiService,
|
|
2643
|
+
X as UserType,
|
|
2644
|
+
Xe as useApi,
|
|
2645
|
+
se as useApp,
|
|
2602
2646
|
ee as useAuth,
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2647
|
+
Ee as useFeatureFlags,
|
|
2648
|
+
tt as useSettings,
|
|
2649
|
+
Fe as useSubscription,
|
|
2650
|
+
ae as useTenant,
|
|
2651
|
+
Z as useTenantInfo,
|
|
2652
|
+
et as useTenantSettings
|
|
2608
2653
|
};
|
|
2609
2654
|
//# sourceMappingURL=index.es.js.map
|