@skylabs-digital/react-identity-access 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +583 -603
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/providers/TenantProvider.d.ts +0 -2
- package/dist/providers/TenantProvider.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as n, Fragment as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { useLocation as me, Navigate as
|
|
4
|
-
class
|
|
1
|
+
import { jsx as n, Fragment as B, jsxs as u } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as ee, useState as m, useMemo as O, useCallback as X, useEffect as K, useContext as te } from "react";
|
|
3
|
+
import { useLocation as me, Navigate as ae } from "react-router";
|
|
4
|
+
class G {
|
|
5
5
|
// SessionManager instance
|
|
6
6
|
constructor(e, t = 1e4) {
|
|
7
7
|
this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
|
|
@@ -16,40 +16,40 @@ class _ {
|
|
|
16
16
|
return this.executeRequest(e, t, r, s, !1);
|
|
17
17
|
}
|
|
18
18
|
async executeRequest(e, t, r, s, a = !1) {
|
|
19
|
-
const
|
|
20
|
-
let
|
|
19
|
+
const v = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, M = (s == null ? void 0 : s.timeout) || this.timeout;
|
|
20
|
+
let k = {
|
|
21
21
|
"Content-Type": "application/json",
|
|
22
22
|
...s == null ? void 0 : s.headers
|
|
23
23
|
};
|
|
24
24
|
if (!(s != null && s.skipAuth) && this.sessionManager)
|
|
25
25
|
try {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
} catch (
|
|
29
|
-
console.warn("Failed to inject auth headers:",
|
|
26
|
+
const g = await this.sessionManager.getAuthHeaders();
|
|
27
|
+
k = { ...k, ...g };
|
|
28
|
+
} catch (g) {
|
|
29
|
+
console.warn("Failed to inject auth headers:", g);
|
|
30
30
|
}
|
|
31
|
-
const P = new AbortController(),
|
|
31
|
+
const P = new AbortController(), h = setTimeout(() => P.abort(), M);
|
|
32
32
|
try {
|
|
33
|
-
const
|
|
33
|
+
const g = await fetch(v, {
|
|
34
34
|
method: e,
|
|
35
|
-
headers:
|
|
35
|
+
headers: k,
|
|
36
36
|
body: r ? JSON.stringify(r) : void 0,
|
|
37
37
|
signal: P.signal
|
|
38
38
|
});
|
|
39
|
-
if (clearTimeout(
|
|
39
|
+
if (clearTimeout(h), g.status === 401 && !(s != null && s.skipRetry) && !a && this.sessionManager)
|
|
40
40
|
try {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
41
|
+
const f = this.sessionManager.getTokens();
|
|
42
|
+
if (f != null && f.refreshToken)
|
|
43
43
|
return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, r, s, !0);
|
|
44
44
|
} catch {
|
|
45
|
-
throw new Error(`HTTP ${
|
|
45
|
+
throw new Error(`HTTP ${g.status}: ${g.statusText}`);
|
|
46
46
|
}
|
|
47
|
-
if (!
|
|
48
|
-
throw new Error(`HTTP ${
|
|
49
|
-
const
|
|
50
|
-
return !
|
|
51
|
-
} catch (
|
|
52
|
-
throw clearTimeout(
|
|
47
|
+
if (!g.ok)
|
|
48
|
+
throw new Error(`HTTP ${g.status}: ${g.statusText}`);
|
|
49
|
+
const x = g.headers.get("content-type");
|
|
50
|
+
return !x || !x.includes("application/json") ? {} : await g.json();
|
|
51
|
+
} catch (g) {
|
|
52
|
+
throw clearTimeout(h), g instanceof Error && g.name === "AbortError" ? new Error(`Request timeout after ${M}ms`) : g;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
async get(e, t) {
|
|
@@ -124,7 +124,7 @@ class be {
|
|
|
124
124
|
})).data;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
const ge =
|
|
127
|
+
const ge = ee(null), Se = () => /* @__PURE__ */ n(
|
|
128
128
|
"div",
|
|
129
129
|
{
|
|
130
130
|
style: {
|
|
@@ -171,8 +171,8 @@ const ge = te(null), Se = () => /* @__PURE__ */ n(
|
|
|
171
171
|
}
|
|
172
172
|
);
|
|
173
173
|
function Je({ config: i, children: e }) {
|
|
174
|
-
const [t, r] = m(null), [s, a] = m(!0), [
|
|
175
|
-
const
|
|
174
|
+
const [t, r] = m(null), [s, a] = m(!0), [v, M] = m(null), k = O(() => {
|
|
175
|
+
const h = () => {
|
|
176
176
|
P();
|
|
177
177
|
};
|
|
178
178
|
return {
|
|
@@ -181,17 +181,17 @@ function Je({ config: i, children: e }) {
|
|
|
181
181
|
// App info
|
|
182
182
|
appInfo: t,
|
|
183
183
|
isAppLoading: s,
|
|
184
|
-
appError:
|
|
185
|
-
retryApp:
|
|
184
|
+
appError: v,
|
|
185
|
+
retryApp: h
|
|
186
186
|
};
|
|
187
|
-
}, [i, t, s,
|
|
187
|
+
}, [i, t, s, v]), P = X(async () => {
|
|
188
188
|
try {
|
|
189
|
-
a(!0),
|
|
190
|
-
const
|
|
191
|
-
r(
|
|
192
|
-
} catch (
|
|
193
|
-
const
|
|
194
|
-
|
|
189
|
+
a(!0), M(null);
|
|
190
|
+
const h = new G(i.baseUrl), x = await new be(h, {}).getPublicAppInfo(i.appId);
|
|
191
|
+
r(x);
|
|
192
|
+
} catch (h) {
|
|
193
|
+
const g = h instanceof Error ? h : new Error("Failed to load app information");
|
|
194
|
+
M(g), r(null);
|
|
195
195
|
} finally {
|
|
196
196
|
a(!1);
|
|
197
197
|
}
|
|
@@ -199,20 +199,20 @@ function Je({ config: i, children: e }) {
|
|
|
199
199
|
if (K(() => {
|
|
200
200
|
P();
|
|
201
201
|
}, [P]), s)
|
|
202
|
-
return /* @__PURE__ */ n(
|
|
203
|
-
if (
|
|
204
|
-
const
|
|
205
|
-
return /* @__PURE__ */ n(
|
|
202
|
+
return /* @__PURE__ */ n(B, { children: i.loadingFallback || /* @__PURE__ */ n(Se, {}) });
|
|
203
|
+
if (v) {
|
|
204
|
+
const h = typeof i.errorFallback == "function" ? i.errorFallback(v, () => P()) : i.errorFallback || /* @__PURE__ */ n(ve, { error: v, retry: () => P() });
|
|
205
|
+
return /* @__PURE__ */ n(B, { children: h });
|
|
206
206
|
}
|
|
207
|
-
return /* @__PURE__ */ n(ge.Provider, { value:
|
|
207
|
+
return /* @__PURE__ */ n(ge.Provider, { value: k, children: e });
|
|
208
208
|
}
|
|
209
|
-
function
|
|
210
|
-
const i =
|
|
209
|
+
function re() {
|
|
210
|
+
const i = te(ge);
|
|
211
211
|
if (!i)
|
|
212
212
|
throw new Error("useApp must be used within an AppProvider");
|
|
213
213
|
return i;
|
|
214
214
|
}
|
|
215
|
-
const Xe =
|
|
215
|
+
const Xe = re;
|
|
216
216
|
class xe {
|
|
217
217
|
constructor(e = {}) {
|
|
218
218
|
this.refreshPromise = null, this.refreshQueue = [], this.storageKey = e.storageKey || "auth_tokens", this.autoRefresh = e.autoRefresh ?? !0, this.refreshThreshold = e.refreshThreshold || 3e5, this.onRefreshFailed = e.onRefreshFailed, this.baseUrl = e.baseUrl || "", this.tokenStorage = e.tokenStorage || {
|
|
@@ -364,7 +364,7 @@ class Ae {
|
|
|
364
364
|
});
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
|
-
class
|
|
367
|
+
class le {
|
|
368
368
|
constructor(e, t) {
|
|
369
369
|
this.httpService = e, this.sessionManager = t;
|
|
370
370
|
}
|
|
@@ -431,12 +431,12 @@ class ce {
|
|
|
431
431
|
throw new Error("SessionManager is required for private endpoints");
|
|
432
432
|
const r = await this.sessionManager.getAuthHeaders(), s = new URLSearchParams();
|
|
433
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);
|
|
434
|
-
const a = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`,
|
|
434
|
+
const a = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, v = await this.httpService.get(a, {
|
|
435
435
|
headers: r
|
|
436
436
|
});
|
|
437
437
|
return {
|
|
438
|
-
roles:
|
|
439
|
-
meta:
|
|
438
|
+
roles: v.data,
|
|
439
|
+
meta: v.meta
|
|
440
440
|
};
|
|
441
441
|
}
|
|
442
442
|
}
|
|
@@ -480,7 +480,7 @@ class Pe {
|
|
|
480
480
|
});
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
|
-
class
|
|
483
|
+
class ce {
|
|
484
484
|
constructor(e, t, r) {
|
|
485
485
|
this.httpService = e, this.appId = t, this.sessionManager = r;
|
|
486
486
|
}
|
|
@@ -558,7 +558,7 @@ class oe {
|
|
|
558
558
|
)).data;
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
|
-
const pe =
|
|
561
|
+
const pe = ee(null), Te = () => /* @__PURE__ */ n(
|
|
562
562
|
"div",
|
|
563
563
|
{
|
|
564
564
|
style: {
|
|
@@ -605,94 +605,78 @@ const pe = te(null), Te = () => /* @__PURE__ */ n(
|
|
|
605
605
|
}
|
|
606
606
|
);
|
|
607
607
|
function Ze({ config: i, children: e }) {
|
|
608
|
-
const { baseUrl: t, appInfo: r, appId: s } =
|
|
609
|
-
const
|
|
610
|
-
if (
|
|
608
|
+
const { baseUrl: t, appInfo: r, appId: s } = re(), [a, v] = m(i.initialTenant || null), [M, k] = m(!i.initialTenant), [P, h] = m(null), [g, x] = m(null), [f, A] = m(!1), [F, y] = m(null), C = X(() => {
|
|
609
|
+
const l = i.tenantMode || "optional", w = "tenant";
|
|
610
|
+
if (l === "fixed")
|
|
611
611
|
return i.fixedTenantSlug || null;
|
|
612
612
|
if (typeof window > "u") return null;
|
|
613
|
-
if (
|
|
614
|
-
const
|
|
615
|
-
if (
|
|
616
|
-
const
|
|
617
|
-
return localStorage.setItem(
|
|
613
|
+
if (l === "subdomain") {
|
|
614
|
+
const o = window.location.hostname.split(".");
|
|
615
|
+
if (o.length >= 3) {
|
|
616
|
+
const c = o[0];
|
|
617
|
+
return localStorage.setItem(w, c), c;
|
|
618
618
|
}
|
|
619
|
-
return localStorage.getItem(
|
|
620
|
-
} else if (
|
|
621
|
-
const
|
|
622
|
-
return
|
|
619
|
+
return localStorage.getItem(w);
|
|
620
|
+
} else if (l === "selector") {
|
|
621
|
+
const o = new URLSearchParams(window.location.search).get(i.selectorParam || "tenant");
|
|
622
|
+
return o ? (localStorage.setItem(w, o), o) : localStorage.getItem(w);
|
|
623
623
|
}
|
|
624
624
|
return null;
|
|
625
|
-
}, [i.tenantMode, i.fixedTenantSlug, i.selectorParam]),
|
|
626
|
-
async (
|
|
625
|
+
}, [i.tenantMode, i.fixedTenantSlug, i.selectorParam]), p = O(() => C(), [C]), b = (r == null ? void 0 : r.settingsSchema) || null, T = X(
|
|
626
|
+
async (l) => {
|
|
627
627
|
try {
|
|
628
|
-
|
|
629
|
-
const
|
|
630
|
-
|
|
631
|
-
} catch (
|
|
632
|
-
const
|
|
633
|
-
|
|
628
|
+
k(!0), h(null);
|
|
629
|
+
const w = new G(t), o = await new ce(w, s).getPublicTenantInfo(l);
|
|
630
|
+
v(o);
|
|
631
|
+
} catch (w) {
|
|
632
|
+
const d = w instanceof Error ? w : new Error("Failed to load tenant information");
|
|
633
|
+
h(d), v(null);
|
|
634
634
|
} finally {
|
|
635
|
-
|
|
635
|
+
k(!1);
|
|
636
636
|
}
|
|
637
637
|
},
|
|
638
638
|
[t, s]
|
|
639
|
-
),
|
|
640
|
-
if (
|
|
639
|
+
), R = X(async () => {
|
|
640
|
+
if (a != null && a.id)
|
|
641
641
|
try {
|
|
642
|
-
|
|
643
|
-
const
|
|
644
|
-
|
|
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);
|
|
642
|
+
A(!0), y(null);
|
|
643
|
+
const l = new G(t), d = await new ce(l, a.appId).getTenantSettings(a.id);
|
|
644
|
+
x(d);
|
|
659
645
|
} catch (l) {
|
|
660
|
-
const
|
|
661
|
-
|
|
646
|
+
const w = l instanceof Error ? l : new Error("Failed to load tenant settings");
|
|
647
|
+
y(w), x(null);
|
|
662
648
|
} finally {
|
|
663
|
-
|
|
649
|
+
A(!1);
|
|
664
650
|
}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
),
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
(o) => {
|
|
671
|
-
if (!I)
|
|
651
|
+
}, [t, a]), L = X(() => {
|
|
652
|
+
R();
|
|
653
|
+
}, [R]), E = X(
|
|
654
|
+
(l) => {
|
|
655
|
+
if (!b)
|
|
672
656
|
return { isValid: !0, errors: [] };
|
|
673
|
-
const
|
|
657
|
+
const w = [];
|
|
674
658
|
try {
|
|
675
|
-
return
|
|
659
|
+
return b.properties && Object.entries(b.properties).forEach(([d, o]) => {
|
|
676
660
|
var W;
|
|
677
|
-
const
|
|
678
|
-
if ((W =
|
|
679
|
-
|
|
661
|
+
const c = l[d];
|
|
662
|
+
if ((W = b.required) != null && W.includes(d) && c == null) {
|
|
663
|
+
w.push(`Field '${d}' is required`);
|
|
680
664
|
return;
|
|
681
665
|
}
|
|
682
|
-
if (
|
|
683
|
-
if (
|
|
684
|
-
const
|
|
685
|
-
|
|
666
|
+
if (c != null) {
|
|
667
|
+
if (o.type) {
|
|
668
|
+
const I = o.type, N = typeof c;
|
|
669
|
+
I === "string" && N !== "string" ? w.push(`Field '${d}' must be a string`) : (I === "number" || I === "integer") && N !== "number" ? w.push(`Field '${d}' must be a number`) : I === "boolean" && N !== "boolean" ? w.push(`Field '${d}' must be a boolean`) : I === "array" && !Array.isArray(c) && w.push(`Field '${d}' must be an array`);
|
|
686
670
|
}
|
|
687
|
-
|
|
688
|
-
`Field '${
|
|
689
|
-
),
|
|
690
|
-
`Field '${
|
|
691
|
-
),
|
|
671
|
+
o.minLength !== void 0 && typeof c == "string" && c.length < o.minLength && w.push(
|
|
672
|
+
`Field '${d}' must be at least ${o.minLength} characters long`
|
|
673
|
+
), o.maxLength !== void 0 && typeof c == "string" && c.length > o.maxLength && w.push(
|
|
674
|
+
`Field '${d}' must be no more than ${o.maxLength} characters long`
|
|
675
|
+
), o.minimum !== void 0 && typeof c == "number" && c < o.minimum && w.push(`Field '${d}' must be at least ${o.minimum}`), o.maximum !== void 0 && typeof c == "number" && c > o.maximum && w.push(`Field '${d}' must be no more than ${o.maximum}`), o.pattern && typeof c == "string" && (new RegExp(o.pattern).test(c) || w.push(`Field '${d}' does not match the required pattern`)), o.enum && !o.enum.includes(c) && w.push(`Field '${d}' must be one of: ${o.enum.join(", ")}`);
|
|
692
676
|
}
|
|
693
677
|
}), {
|
|
694
|
-
isValid:
|
|
695
|
-
errors:
|
|
678
|
+
isValid: w.length === 0,
|
|
679
|
+
errors: w
|
|
696
680
|
};
|
|
697
681
|
} catch {
|
|
698
682
|
return {
|
|
@@ -701,83 +685,79 @@ function Ze({ config: i, children: e }) {
|
|
|
701
685
|
};
|
|
702
686
|
}
|
|
703
687
|
},
|
|
704
|
-
[
|
|
688
|
+
[b]
|
|
705
689
|
);
|
|
706
690
|
K(() => {
|
|
707
|
-
const
|
|
708
|
-
!i.initialTenant &&
|
|
709
|
-
new Error(`No tenant ${
|
|
710
|
-
),
|
|
711
|
-
}, [i.initialTenant,
|
|
712
|
-
|
|
713
|
-
}, [
|
|
714
|
-
const
|
|
691
|
+
const l = i.tenantMode || "optional";
|
|
692
|
+
!i.initialTenant && p ? T(p) : !i.initialTenant && !p && l === "fixed" ? (h(new Error("Fixed tenant mode requires fixedTenantSlug configuration")), k(!1)) : !i.initialTenant && !p && (l === "subdomain" || l === "selector") ? (h(
|
|
693
|
+
new Error(`No tenant ${l === "subdomain" ? "subdomain" : "parameter"} found`)
|
|
694
|
+
), k(!1)) : !i.initialTenant && !p && l === "optional" && (v(null), h(null), k(!1));
|
|
695
|
+
}, [i.initialTenant, p, T, i.tenantMode, i.fixedTenantSlug]), K(() => {
|
|
696
|
+
a != null && a.id ? R() : (x(null), y(null), A(!1));
|
|
697
|
+
}, [a == null ? void 0 : a.id, R]);
|
|
698
|
+
const D = O(() => ({
|
|
715
699
|
// Tenant info
|
|
716
|
-
tenant:
|
|
717
|
-
tenantSlug:
|
|
718
|
-
isTenantLoading:
|
|
719
|
-
tenantError:
|
|
700
|
+
tenant: a,
|
|
701
|
+
tenantSlug: p,
|
|
702
|
+
isTenantLoading: M,
|
|
703
|
+
tenantError: P,
|
|
720
704
|
retryTenant: () => {
|
|
721
|
-
|
|
705
|
+
p && T(p);
|
|
722
706
|
},
|
|
723
707
|
// Settings
|
|
724
|
-
settings:
|
|
725
|
-
settingsSchema:
|
|
726
|
-
isSettingsLoading:
|
|
727
|
-
settingsError:
|
|
708
|
+
settings: g,
|
|
709
|
+
settingsSchema: b,
|
|
710
|
+
isSettingsLoading: f,
|
|
711
|
+
settingsError: F,
|
|
728
712
|
// Actions
|
|
729
|
-
|
|
730
|
-
refreshSettings: w,
|
|
713
|
+
refreshSettings: L,
|
|
731
714
|
// Validation
|
|
732
|
-
validateSettings:
|
|
715
|
+
validateSettings: E
|
|
733
716
|
}), [
|
|
734
|
-
|
|
735
|
-
|
|
717
|
+
a,
|
|
718
|
+
p,
|
|
719
|
+
M,
|
|
736
720
|
P,
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
w,
|
|
744
|
-
O
|
|
721
|
+
g,
|
|
722
|
+
b,
|
|
723
|
+
f,
|
|
724
|
+
F,
|
|
725
|
+
L,
|
|
726
|
+
E
|
|
745
727
|
]);
|
|
746
|
-
if (
|
|
747
|
-
return /* @__PURE__ */ n(
|
|
748
|
-
if (
|
|
749
|
-
const
|
|
750
|
-
return /* @__PURE__ */ n(
|
|
728
|
+
if (M)
|
|
729
|
+
return /* @__PURE__ */ n(B, { children: i.loadingFallback || /* @__PURE__ */ n(Te, {}) });
|
|
730
|
+
if (P && i.tenantMode !== "optional") {
|
|
731
|
+
const l = typeof i.errorFallback == "function" ? i.errorFallback(P, () => T(p || "")) : i.errorFallback || /* @__PURE__ */ n(ke, { error: P, retry: () => T(p || "") });
|
|
732
|
+
return /* @__PURE__ */ n(B, { children: l });
|
|
751
733
|
}
|
|
752
|
-
return /* @__PURE__ */ n(pe.Provider, { value:
|
|
734
|
+
return /* @__PURE__ */ n(pe.Provider, { value: D, children: e });
|
|
753
735
|
}
|
|
754
|
-
function
|
|
755
|
-
const i =
|
|
736
|
+
function oe() {
|
|
737
|
+
const i = te(pe);
|
|
756
738
|
if (!i)
|
|
757
739
|
throw new Error("useTenant must be used within a TenantProvider");
|
|
758
740
|
return i;
|
|
759
741
|
}
|
|
760
|
-
const et =
|
|
742
|
+
const et = oe;
|
|
761
743
|
function tt() {
|
|
762
744
|
const {
|
|
763
745
|
settings: i,
|
|
764
746
|
settingsSchema: e,
|
|
765
747
|
isSettingsLoading: t,
|
|
766
748
|
settingsError: r,
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
} = ae();
|
|
749
|
+
validateSettings: s
|
|
750
|
+
} = oe();
|
|
770
751
|
return {
|
|
771
752
|
settings: i,
|
|
772
753
|
settingsSchema: e,
|
|
773
754
|
isLoading: t,
|
|
774
755
|
error: r,
|
|
775
|
-
|
|
776
|
-
validateSettings: a
|
|
756
|
+
validateSettings: s
|
|
777
757
|
};
|
|
778
758
|
}
|
|
779
759
|
function Z() {
|
|
780
|
-
const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } =
|
|
760
|
+
const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } = oe();
|
|
781
761
|
return {
|
|
782
762
|
tenant: i,
|
|
783
763
|
tenantSlug: e,
|
|
@@ -786,192 +766,192 @@ function Z() {
|
|
|
786
766
|
retry: s
|
|
787
767
|
};
|
|
788
768
|
}
|
|
789
|
-
const fe =
|
|
769
|
+
const fe = ee(null);
|
|
790
770
|
function rt({ config: i = {}, children: e }) {
|
|
791
|
-
const { appId: t, baseUrl: r } =
|
|
792
|
-
const
|
|
771
|
+
const { appId: t, baseUrl: r } = re(), s = Z(), a = (s == null ? void 0 : s.tenantSlug) || null, [v, M] = m(i.initialRoles || []), [k, P] = m(!i.initialRoles), [h, g] = m(null), [x, f] = m(!1), [A, F] = m(null), y = O(() => {
|
|
772
|
+
const l = a ? `auth_tokens_${a}` : "auth_tokens", w = {
|
|
793
773
|
get: () => {
|
|
794
774
|
try {
|
|
795
|
-
const
|
|
796
|
-
return
|
|
775
|
+
const d = localStorage.getItem(l);
|
|
776
|
+
return d ? JSON.parse(d) : null;
|
|
797
777
|
} catch {
|
|
798
778
|
return null;
|
|
799
779
|
}
|
|
800
780
|
},
|
|
801
|
-
set: (
|
|
781
|
+
set: (d) => {
|
|
802
782
|
try {
|
|
803
|
-
localStorage.setItem(
|
|
783
|
+
localStorage.setItem(l, JSON.stringify(d));
|
|
804
784
|
} catch {
|
|
805
785
|
}
|
|
806
786
|
},
|
|
807
787
|
clear: () => {
|
|
808
788
|
try {
|
|
809
|
-
localStorage.removeItem(
|
|
789
|
+
localStorage.removeItem(l);
|
|
810
790
|
} catch {
|
|
811
791
|
}
|
|
812
792
|
}
|
|
813
793
|
};
|
|
814
794
|
return new xe({
|
|
815
795
|
onRefreshFailed: i.onRefreshFailed,
|
|
816
|
-
tokenStorage:
|
|
796
|
+
tokenStorage: w,
|
|
817
797
|
baseUrl: r
|
|
818
798
|
});
|
|
819
|
-
}, [a, r, i.onRefreshFailed]),
|
|
820
|
-
const
|
|
821
|
-
return
|
|
822
|
-
}, [r,
|
|
799
|
+
}, [a, r, i.onRefreshFailed]), C = O(() => {
|
|
800
|
+
const l = new G(r);
|
|
801
|
+
return l.setSessionManager(y), l;
|
|
802
|
+
}, [r, y]), p = O(() => new Ae(new G(r)), [r]), b = O(() => new Pe(C, y), [C, y]), T = O(() => new le(new G(r)), [r]), R = O(() => h || y.getUser(), [h, y]), L = O(() => R != null && R.roleId && v.find((l) => l.id === R.roleId) || null, [R, v]), E = O(() => (L == null ? void 0 : L.permissions) || [], [L]);
|
|
823
803
|
K(() => {
|
|
824
|
-
console.log("AuthProvider - userPermissions changed:",
|
|
825
|
-
}, [
|
|
826
|
-
const
|
|
827
|
-
const
|
|
804
|
+
console.log("AuthProvider - userPermissions changed:", E);
|
|
805
|
+
}, [E]);
|
|
806
|
+
const D = O(() => {
|
|
807
|
+
const l = async () => {
|
|
828
808
|
try {
|
|
829
|
-
|
|
830
|
-
const
|
|
831
|
-
if (!(
|
|
809
|
+
f(!0), F(null);
|
|
810
|
+
const S = y.getUser();
|
|
811
|
+
if (!(S != null && S.id))
|
|
832
812
|
throw new Error("No user ID available in session");
|
|
833
|
-
const
|
|
834
|
-
|
|
835
|
-
} catch (
|
|
836
|
-
const
|
|
837
|
-
$
|
|
813
|
+
const $ = await b.getUserById(S.id);
|
|
814
|
+
g($), y.setUser($);
|
|
815
|
+
} catch (S) {
|
|
816
|
+
const $ = S instanceof Error ? S : new Error("Failed to load user data");
|
|
817
|
+
F($), console.error("Failed to load user data:", $);
|
|
838
818
|
} finally {
|
|
839
|
-
|
|
819
|
+
f(!1);
|
|
840
820
|
}
|
|
841
|
-
},
|
|
842
|
-
await
|
|
843
|
-
},
|
|
844
|
-
const
|
|
845
|
-
email:
|
|
846
|
-
password:
|
|
821
|
+
}, w = async () => {
|
|
822
|
+
await l();
|
|
823
|
+
}, d = async (S, $, Q) => {
|
|
824
|
+
const V = await p.login({
|
|
825
|
+
email: S,
|
|
826
|
+
password: $,
|
|
847
827
|
tenantId: Q
|
|
848
828
|
});
|
|
849
|
-
if (
|
|
850
|
-
accessToken:
|
|
851
|
-
refreshToken:
|
|
852
|
-
expiresIn:
|
|
853
|
-
}),
|
|
854
|
-
|
|
829
|
+
if (y.setTokens({
|
|
830
|
+
accessToken: V.accessToken,
|
|
831
|
+
refreshToken: V.refreshToken,
|
|
832
|
+
expiresIn: V.expiresIn
|
|
833
|
+
}), V.user) {
|
|
834
|
+
y.setUser(V.user), g(V.user);
|
|
855
835
|
try {
|
|
856
|
-
await
|
|
836
|
+
await l();
|
|
857
837
|
} catch (ie) {
|
|
858
838
|
console.warn("Failed to load complete user data after login:", ie);
|
|
859
839
|
}
|
|
860
840
|
}
|
|
861
|
-
return
|
|
862
|
-
}, o = async (
|
|
863
|
-
email:
|
|
864
|
-
name:
|
|
841
|
+
return V;
|
|
842
|
+
}, o = async (S, $, Q, V) => await p.signup({ email: S, name: $, password: Q, tenantId: V }), c = async (S, $, Q, V) => await p.signupTenantAdmin({
|
|
843
|
+
email: S,
|
|
844
|
+
name: $,
|
|
865
845
|
password: Q,
|
|
866
|
-
tenantName:
|
|
846
|
+
tenantName: V,
|
|
867
847
|
appId: t
|
|
868
|
-
}),
|
|
869
|
-
const Q = await
|
|
870
|
-
await
|
|
871
|
-
},
|
|
872
|
-
await
|
|
873
|
-
},
|
|
874
|
-
await
|
|
875
|
-
},
|
|
876
|
-
const
|
|
877
|
-
if (!(
|
|
848
|
+
}), W = async (S, $) => {
|
|
849
|
+
const Q = await y.getAuthHeaders();
|
|
850
|
+
await p.changePassword({ currentPassword: S, newPassword: $ }, Q);
|
|
851
|
+
}, I = async (S, $) => {
|
|
852
|
+
await p.requestPasswordReset({ email: S, tenantId: $ });
|
|
853
|
+
}, N = async (S, $) => {
|
|
854
|
+
await p.confirmPasswordReset({ token: S, newPassword: $ });
|
|
855
|
+
}, _ = async () => {
|
|
856
|
+
const S = y.getTokens();
|
|
857
|
+
if (!(S != null && S.refreshToken))
|
|
878
858
|
throw new Error("No refresh token available");
|
|
879
|
-
const
|
|
880
|
-
refreshToken:
|
|
859
|
+
const $ = await p.refreshToken({
|
|
860
|
+
refreshToken: S.refreshToken
|
|
881
861
|
});
|
|
882
|
-
|
|
883
|
-
accessToken:
|
|
884
|
-
refreshToken:
|
|
885
|
-
expiresIn:
|
|
862
|
+
y.setTokens({
|
|
863
|
+
accessToken: $.accessToken,
|
|
864
|
+
refreshToken: $.refreshToken || S.refreshToken,
|
|
865
|
+
expiresIn: $.expiresIn
|
|
886
866
|
});
|
|
887
|
-
},
|
|
888
|
-
|
|
889
|
-
}, q = (
|
|
890
|
-
|
|
891
|
-
}, Y = () =>
|
|
892
|
-
|
|
893
|
-
},
|
|
867
|
+
}, H = () => {
|
|
868
|
+
y.clearSession(), g(null), F(null);
|
|
869
|
+
}, q = (S) => {
|
|
870
|
+
y.setTokens(S);
|
|
871
|
+
}, Y = () => y.hasValidSession(), U = () => {
|
|
872
|
+
y.clearSession(), g(null), F(null);
|
|
873
|
+
}, z = async () => {
|
|
894
874
|
if (t)
|
|
895
875
|
try {
|
|
896
876
|
P(!0);
|
|
897
|
-
const { roles:
|
|
898
|
-
|
|
899
|
-
} catch (
|
|
900
|
-
console.error("Failed to fetch roles:",
|
|
877
|
+
const { roles: S } = await T.getRolesByApp(t);
|
|
878
|
+
M(S);
|
|
879
|
+
} catch (S) {
|
|
880
|
+
console.error("Failed to fetch roles:", S);
|
|
901
881
|
} finally {
|
|
902
882
|
P(!1);
|
|
903
883
|
}
|
|
904
|
-
},
|
|
905
|
-
await
|
|
906
|
-
}, ne = (
|
|
907
|
-
if (!
|
|
884
|
+
}, j = async () => {
|
|
885
|
+
await z();
|
|
886
|
+
}, ne = (S) => {
|
|
887
|
+
if (!E || E.length === 0)
|
|
908
888
|
return !1;
|
|
909
|
-
if (typeof
|
|
910
|
-
return
|
|
911
|
-
const
|
|
912
|
-
return
|
|
889
|
+
if (typeof S == "string")
|
|
890
|
+
return E.includes(S);
|
|
891
|
+
const $ = `${S.resource}.${S.action}`;
|
|
892
|
+
return E.includes($);
|
|
913
893
|
};
|
|
914
894
|
return {
|
|
915
|
-
sessionManager:
|
|
916
|
-
authenticatedHttpService:
|
|
917
|
-
login:
|
|
895
|
+
sessionManager: y,
|
|
896
|
+
authenticatedHttpService: C,
|
|
897
|
+
login: d,
|
|
918
898
|
signup: o,
|
|
919
|
-
signupTenantAdmin:
|
|
920
|
-
changePassword:
|
|
921
|
-
requestPasswordReset:
|
|
922
|
-
confirmPasswordReset:
|
|
923
|
-
refreshToken:
|
|
924
|
-
logout:
|
|
899
|
+
signupTenantAdmin: c,
|
|
900
|
+
changePassword: W,
|
|
901
|
+
requestPasswordReset: I,
|
|
902
|
+
confirmPasswordReset: N,
|
|
903
|
+
refreshToken: _,
|
|
904
|
+
logout: H,
|
|
925
905
|
setTokens: q,
|
|
926
906
|
hasValidSession: Y,
|
|
927
|
-
clearSession:
|
|
928
|
-
currentUser:
|
|
929
|
-
isUserLoading:
|
|
930
|
-
userError:
|
|
931
|
-
refreshUser:
|
|
932
|
-
userRole:
|
|
933
|
-
userPermissions:
|
|
934
|
-
availableRoles:
|
|
935
|
-
rolesLoading:
|
|
907
|
+
clearSession: U,
|
|
908
|
+
currentUser: h,
|
|
909
|
+
isUserLoading: x,
|
|
910
|
+
userError: A,
|
|
911
|
+
refreshUser: w,
|
|
912
|
+
userRole: L,
|
|
913
|
+
userPermissions: E,
|
|
914
|
+
availableRoles: v,
|
|
915
|
+
rolesLoading: k,
|
|
936
916
|
hasPermission: ne,
|
|
937
|
-
hasAnyPermission: (
|
|
938
|
-
hasAllPermissions: (
|
|
939
|
-
getUserPermissionStrings: () =>
|
|
940
|
-
refreshRoles:
|
|
917
|
+
hasAnyPermission: (S) => S.some(($) => ne($)),
|
|
918
|
+
hasAllPermissions: (S) => S.every(($) => ne($)),
|
|
919
|
+
getUserPermissionStrings: () => E || [],
|
|
920
|
+
refreshRoles: j
|
|
941
921
|
};
|
|
942
922
|
}, [
|
|
923
|
+
y,
|
|
924
|
+
C,
|
|
943
925
|
p,
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
E,
|
|
947
|
-
f,
|
|
926
|
+
b,
|
|
927
|
+
T,
|
|
948
928
|
t,
|
|
929
|
+
v,
|
|
930
|
+
h,
|
|
949
931
|
x,
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
C,
|
|
954
|
-
F
|
|
932
|
+
A,
|
|
933
|
+
L,
|
|
934
|
+
E
|
|
955
935
|
]);
|
|
956
936
|
return K(() => {
|
|
957
937
|
!i.initialRoles && t && (async () => {
|
|
958
938
|
try {
|
|
959
939
|
P(!0);
|
|
960
|
-
const
|
|
961
|
-
|
|
962
|
-
} catch (
|
|
963
|
-
console.error("Failed to fetch roles:",
|
|
940
|
+
const w = new G(r), d = new le(w), { roles: o } = await d.getRolesByApp(t);
|
|
941
|
+
M(o);
|
|
942
|
+
} catch (w) {
|
|
943
|
+
console.error("Failed to fetch roles:", w);
|
|
964
944
|
} finally {
|
|
965
945
|
P(!1);
|
|
966
946
|
}
|
|
967
947
|
})();
|
|
968
948
|
}, [t, r, i.initialRoles]), K(() => {
|
|
969
|
-
const
|
|
970
|
-
|
|
971
|
-
}, [
|
|
949
|
+
const l = y.getUser();
|
|
950
|
+
l && y.hasValidSession() && g(l);
|
|
951
|
+
}, [y]), /* @__PURE__ */ n(fe.Provider, { value: D, children: e });
|
|
972
952
|
}
|
|
973
|
-
function
|
|
974
|
-
const i =
|
|
953
|
+
function se() {
|
|
954
|
+
const i = te(fe);
|
|
975
955
|
if (!i)
|
|
976
956
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
977
957
|
return i;
|
|
@@ -1056,53 +1036,53 @@ class Me {
|
|
|
1056
1036
|
})).data;
|
|
1057
1037
|
}
|
|
1058
1038
|
}
|
|
1059
|
-
const ye =
|
|
1039
|
+
const ye = ee(null);
|
|
1060
1040
|
function st({ config: i = {}, children: e }) {
|
|
1061
|
-
const { baseUrl: t, appId: r } =
|
|
1062
|
-
const
|
|
1063
|
-
return new Me(
|
|
1064
|
-
}, [t]),
|
|
1041
|
+
const { baseUrl: t, appId: r } = re(), { tenant: s } = Z(), [a, v] = m([]), [M, k] = m(!1), [P, h] = m(null), g = O(() => {
|
|
1042
|
+
const A = new G(t);
|
|
1043
|
+
return new Me(A);
|
|
1044
|
+
}, [t]), x = async () => {
|
|
1065
1045
|
if (!(s != null && s.id)) {
|
|
1066
|
-
|
|
1046
|
+
v([]);
|
|
1067
1047
|
return;
|
|
1068
1048
|
}
|
|
1069
|
-
|
|
1049
|
+
k(!0), h(null);
|
|
1070
1050
|
try {
|
|
1071
|
-
const
|
|
1072
|
-
|
|
1073
|
-
} catch (
|
|
1074
|
-
const
|
|
1075
|
-
|
|
1051
|
+
const A = await g.getTenantFeatureFlags(s.id, r);
|
|
1052
|
+
v(A);
|
|
1053
|
+
} catch (A) {
|
|
1054
|
+
const F = A instanceof Error ? A.message : "Failed to fetch feature flags";
|
|
1055
|
+
h(F), i.onError && i.onError(A instanceof Error ? A : new Error(F));
|
|
1076
1056
|
} finally {
|
|
1077
|
-
|
|
1057
|
+
k(!1);
|
|
1078
1058
|
}
|
|
1079
1059
|
};
|
|
1080
1060
|
K(() => {
|
|
1081
|
-
|
|
1082
|
-
const
|
|
1083
|
-
return () => clearInterval(
|
|
1061
|
+
x();
|
|
1062
|
+
const A = i.refreshInterval || 5 * 60 * 1e3, F = setInterval(x, A);
|
|
1063
|
+
return () => clearInterval(F);
|
|
1084
1064
|
}, [s == null ? void 0 : s.id, i.refreshInterval]);
|
|
1085
|
-
const
|
|
1065
|
+
const f = O(() => ({
|
|
1086
1066
|
featureFlags: a,
|
|
1087
|
-
loading:
|
|
1067
|
+
loading: M,
|
|
1088
1068
|
error: P,
|
|
1089
|
-
isEnabled: (
|
|
1090
|
-
const
|
|
1091
|
-
return (
|
|
1069
|
+
isEnabled: (p) => {
|
|
1070
|
+
const b = a.find((T) => T.key === p);
|
|
1071
|
+
return (b == null ? void 0 : b.value) === !0;
|
|
1092
1072
|
},
|
|
1093
|
-
getFlag: (
|
|
1094
|
-
getFlagState: (
|
|
1095
|
-
const
|
|
1096
|
-
return
|
|
1073
|
+
getFlag: (p) => a.find((b) => b.key === p),
|
|
1074
|
+
getFlagState: (p) => {
|
|
1075
|
+
const b = a.find((T) => T.key === p);
|
|
1076
|
+
return b ? b.value ? "enabled" : "disabled" : "not_found";
|
|
1097
1077
|
},
|
|
1098
1078
|
refresh: async () => {
|
|
1099
|
-
await
|
|
1079
|
+
await x();
|
|
1100
1080
|
}
|
|
1101
|
-
}), [a,
|
|
1102
|
-
return /* @__PURE__ */ n(ye.Provider, { value:
|
|
1081
|
+
}), [a, M, P]);
|
|
1082
|
+
return /* @__PURE__ */ n(ye.Provider, { value: f, children: e });
|
|
1103
1083
|
}
|
|
1104
1084
|
function Ee() {
|
|
1105
|
-
const i =
|
|
1085
|
+
const i = te(ye);
|
|
1106
1086
|
if (!i)
|
|
1107
1087
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1108
1088
|
return i;
|
|
@@ -1173,63 +1153,63 @@ class Re {
|
|
|
1173
1153
|
)).data;
|
|
1174
1154
|
}
|
|
1175
1155
|
}
|
|
1176
|
-
const we =
|
|
1156
|
+
const we = ee(void 0);
|
|
1177
1157
|
function nt({ config: i = {}, children: e }) {
|
|
1178
|
-
const { baseUrl: t } =
|
|
1179
|
-
const
|
|
1180
|
-
return new Re(
|
|
1181
|
-
}, [t]),
|
|
1158
|
+
const { baseUrl: t } = re(), { tenant: r } = Z(), [s, a] = m(null), [v, M] = m(!1), [k, P] = m(null), h = O(() => {
|
|
1159
|
+
const f = new G(t);
|
|
1160
|
+
return new Re(f);
|
|
1161
|
+
}, [t]), g = async () => {
|
|
1182
1162
|
if (!(r != null && r.id)) {
|
|
1183
1163
|
a(null);
|
|
1184
1164
|
return;
|
|
1185
1165
|
}
|
|
1186
|
-
|
|
1166
|
+
M(!0), P(null);
|
|
1187
1167
|
try {
|
|
1188
|
-
const
|
|
1189
|
-
a(
|
|
1190
|
-
} catch (
|
|
1191
|
-
const
|
|
1192
|
-
P(
|
|
1168
|
+
const f = await h.getTenantSubscriptionFeatures(r.id);
|
|
1169
|
+
a(f);
|
|
1170
|
+
} catch (f) {
|
|
1171
|
+
const A = f instanceof Error ? f.message : "Failed to fetch subscription";
|
|
1172
|
+
P(A), i.onError && i.onError(f instanceof Error ? f : new Error(A));
|
|
1193
1173
|
} finally {
|
|
1194
|
-
|
|
1174
|
+
M(!1);
|
|
1195
1175
|
}
|
|
1196
1176
|
};
|
|
1197
1177
|
K(() => {
|
|
1198
|
-
if (
|
|
1199
|
-
const
|
|
1200
|
-
return () => clearInterval(
|
|
1178
|
+
if (g(), !i.refreshInterval) return;
|
|
1179
|
+
const f = i.refreshInterval || 10 * 60 * 1e3, A = setInterval(g, f);
|
|
1180
|
+
return () => clearInterval(A);
|
|
1201
1181
|
}, [r == null ? void 0 : r.id, i.refreshInterval]);
|
|
1202
|
-
const
|
|
1203
|
-
const
|
|
1182
|
+
const x = O(() => {
|
|
1183
|
+
const f = (s == null ? void 0 : s.features) || [];
|
|
1204
1184
|
return {
|
|
1205
1185
|
subscription: s,
|
|
1206
|
-
features:
|
|
1207
|
-
loading:
|
|
1208
|
-
error:
|
|
1209
|
-
isFeatureEnabled: (
|
|
1210
|
-
const
|
|
1211
|
-
return
|
|
1186
|
+
features: f,
|
|
1187
|
+
loading: v,
|
|
1188
|
+
error: k,
|
|
1189
|
+
isFeatureEnabled: (b) => {
|
|
1190
|
+
const T = f.find((R) => R.key === b);
|
|
1191
|
+
return T ? T.type === "BOOLEAN" || T.type === "boolean" ? T.value === !0 : !!T.value : !1;
|
|
1212
1192
|
},
|
|
1213
|
-
getFeature: (
|
|
1214
|
-
getFeatureValue: (
|
|
1215
|
-
const
|
|
1216
|
-
return
|
|
1193
|
+
getFeature: (b) => f.find((T) => T.key === b),
|
|
1194
|
+
getFeatureValue: (b, T) => {
|
|
1195
|
+
const R = f.find((L) => L.key === b);
|
|
1196
|
+
return R ? R.value : T;
|
|
1217
1197
|
},
|
|
1218
|
-
hasAllowedPlan: (
|
|
1198
|
+
hasAllowedPlan: (b) => !s || !s.isActive ? !1 : b.includes(s.planId),
|
|
1219
1199
|
refresh: async () => {
|
|
1220
|
-
await
|
|
1200
|
+
await g();
|
|
1221
1201
|
}
|
|
1222
1202
|
};
|
|
1223
|
-
}, [s,
|
|
1224
|
-
return /* @__PURE__ */ n(we.Provider, { value:
|
|
1203
|
+
}, [s, v, k]);
|
|
1204
|
+
return /* @__PURE__ */ n(we.Provider, { value: x, children: e });
|
|
1225
1205
|
}
|
|
1226
1206
|
function Fe() {
|
|
1227
|
-
const i =
|
|
1207
|
+
const i = te(we);
|
|
1228
1208
|
if (i === void 0)
|
|
1229
1209
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1230
1210
|
return i;
|
|
1231
1211
|
}
|
|
1232
|
-
var
|
|
1212
|
+
var J = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(J || {});
|
|
1233
1213
|
const de = () => /* @__PURE__ */ u(
|
|
1234
1214
|
"div",
|
|
1235
1215
|
{
|
|
@@ -1289,7 +1269,7 @@ const de = () => /* @__PURE__ */ u(
|
|
|
1289
1269
|
children: [
|
|
1290
1270
|
/* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
|
|
1291
1271
|
/* @__PURE__ */ n("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
|
|
1292
|
-
e && i ? /* @__PURE__ */ u(
|
|
1272
|
+
e && i ? /* @__PURE__ */ u(B, { children: [
|
|
1293
1273
|
/* @__PURE__ */ u("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
|
|
1294
1274
|
"This content requires ",
|
|
1295
1275
|
/* @__PURE__ */ n("strong", { children: e }),
|
|
@@ -1299,7 +1279,7 @@ const de = () => /* @__PURE__ */ u(
|
|
|
1299
1279
|
"Your current access level: ",
|
|
1300
1280
|
/* @__PURE__ */ n("strong", { children: i })
|
|
1301
1281
|
] })
|
|
1302
|
-
] }) : /* @__PURE__ */ u(
|
|
1282
|
+
] }) : /* @__PURE__ */ u(B, { children: [
|
|
1303
1283
|
/* @__PURE__ */ n("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
|
|
1304
1284
|
t && t.length > 0 && /* @__PURE__ */ u("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1305
1285
|
"Required permissions: ",
|
|
@@ -1310,9 +1290,9 @@ const de = () => /* @__PURE__ */ u(
|
|
|
1310
1290
|
}
|
|
1311
1291
|
), Ie = (i, e) => {
|
|
1312
1292
|
const t = {
|
|
1313
|
-
[
|
|
1314
|
-
[
|
|
1315
|
-
[
|
|
1293
|
+
[J.USER]: 1,
|
|
1294
|
+
[J.TENANT_ADMIN]: 2,
|
|
1295
|
+
[J.SUPERUSER]: 3
|
|
1316
1296
|
};
|
|
1317
1297
|
return t[i] >= t[e];
|
|
1318
1298
|
};
|
|
@@ -1323,19 +1303,19 @@ function it({
|
|
|
1323
1303
|
requiredPermissions: r,
|
|
1324
1304
|
requireAllPermissions: s = !1
|
|
1325
1305
|
}) {
|
|
1326
|
-
const { hasValidSession: a, sessionManager:
|
|
1306
|
+
const { hasValidSession: a, sessionManager: v, hasPermission: M, hasAnyPermission: k, hasAllPermissions: P } = se();
|
|
1327
1307
|
if (!a())
|
|
1328
|
-
return /* @__PURE__ */ n(
|
|
1329
|
-
const
|
|
1330
|
-
if (!
|
|
1331
|
-
return /* @__PURE__ */ n(
|
|
1332
|
-
if (t && !Ie(
|
|
1333
|
-
return /* @__PURE__ */ n(ue, { userType:
|
|
1334
|
-
if (r && r.length > 0 && !(s ? P(r) :
|
|
1335
|
-
const
|
|
1336
|
-
return /* @__PURE__ */ n(ue, { missingPermissions:
|
|
1337
|
-
}
|
|
1338
|
-
return /* @__PURE__ */ n(
|
|
1308
|
+
return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(de, {}) });
|
|
1309
|
+
const h = v.getUser();
|
|
1310
|
+
if (!h)
|
|
1311
|
+
return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(de, {}) });
|
|
1312
|
+
if (t && !Ie(h.userType, t))
|
|
1313
|
+
return /* @__PURE__ */ n(ue, { userType: h.userType, minUserType: t });
|
|
1314
|
+
if (r && r.length > 0 && !(s ? P(r) : k(r))) {
|
|
1315
|
+
const x = r.filter((f) => !M(f)).map((f) => typeof f == "string" ? f : f.name);
|
|
1316
|
+
return /* @__PURE__ */ n(ue, { missingPermissions: x });
|
|
1317
|
+
}
|
|
1318
|
+
return /* @__PURE__ */ n(B, { children: i });
|
|
1339
1319
|
}
|
|
1340
1320
|
const He = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1341
1321
|
"div",
|
|
@@ -1403,7 +1383,7 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1403
1383
|
children: [
|
|
1404
1384
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
|
|
1405
1385
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
|
|
1406
|
-
e && i ? /* @__PURE__ */ u(
|
|
1386
|
+
e && i ? /* @__PURE__ */ u(B, { children: [
|
|
1407
1387
|
/* @__PURE__ */ u("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
|
|
1408
1388
|
"This page requires ",
|
|
1409
1389
|
/* @__PURE__ */ n("strong", { children: e }),
|
|
@@ -1413,7 +1393,7 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1413
1393
|
"Your current access level: ",
|
|
1414
1394
|
/* @__PURE__ */ n("strong", { children: i })
|
|
1415
1395
|
] })
|
|
1416
|
-
] }) : /* @__PURE__ */ u(
|
|
1396
|
+
] }) : /* @__PURE__ */ u(B, { children: [
|
|
1417
1397
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
|
|
1418
1398
|
t && t.length > 0 && /* @__PURE__ */ u("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1419
1399
|
"Required permissions: ",
|
|
@@ -1426,9 +1406,9 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1426
1406
|
}
|
|
1427
1407
|
), $e = (i, e) => {
|
|
1428
1408
|
const t = {
|
|
1429
|
-
[
|
|
1430
|
-
[
|
|
1431
|
-
[
|
|
1409
|
+
[J.USER]: 1,
|
|
1410
|
+
[J.TENANT_ADMIN]: 2,
|
|
1411
|
+
[J.SUPERUSER]: 3
|
|
1432
1412
|
};
|
|
1433
1413
|
return t[i] >= t[e];
|
|
1434
1414
|
};
|
|
@@ -1440,22 +1420,22 @@ function ot({
|
|
|
1440
1420
|
requireAllPermissions: s = !1,
|
|
1441
1421
|
fallback: a
|
|
1442
1422
|
}) {
|
|
1443
|
-
const { hasValidSession:
|
|
1444
|
-
if (!
|
|
1445
|
-
return a ? /* @__PURE__ */ n(
|
|
1423
|
+
const { hasValidSession: v, sessionManager: M, hasPermission: k, hasAnyPermission: P, hasAllPermissions: h } = se(), g = me();
|
|
1424
|
+
if (!v())
|
|
1425
|
+
return a ? /* @__PURE__ */ n(B, { children: a }) : /* @__PURE__ */ u(B, { children: [
|
|
1446
1426
|
/* @__PURE__ */ n(He, { redirectPath: e }),
|
|
1447
|
-
/* @__PURE__ */ n(
|
|
1427
|
+
/* @__PURE__ */ n(ae, { to: e, state: { from: g.pathname }, replace: !0 })
|
|
1448
1428
|
] });
|
|
1449
|
-
const
|
|
1450
|
-
if (!
|
|
1451
|
-
return /* @__PURE__ */ n(
|
|
1452
|
-
if (t && !$e(
|
|
1453
|
-
return /* @__PURE__ */ n(he, { userType:
|
|
1454
|
-
if (r && r.length > 0 && !(s ?
|
|
1455
|
-
const
|
|
1456
|
-
return /* @__PURE__ */ n(he, { missingPermissions:
|
|
1457
|
-
}
|
|
1458
|
-
return /* @__PURE__ */ n(
|
|
1429
|
+
const x = M.getUser();
|
|
1430
|
+
if (!x)
|
|
1431
|
+
return /* @__PURE__ */ n(ae, { to: e, state: { from: g.pathname }, replace: !0 });
|
|
1432
|
+
if (t && !$e(x.userType, t))
|
|
1433
|
+
return /* @__PURE__ */ n(he, { userType: x.userType, minUserType: t });
|
|
1434
|
+
if (r && r.length > 0 && !(s ? h(r) : P(r))) {
|
|
1435
|
+
const A = r.filter((F) => !k(F)).map((F) => typeof F == "string" ? F : F.name);
|
|
1436
|
+
return /* @__PURE__ */ n(he, { missingPermissions: A });
|
|
1437
|
+
}
|
|
1438
|
+
return /* @__PURE__ */ n(B, { children: i });
|
|
1459
1439
|
}
|
|
1460
1440
|
const Ce = () => /* @__PURE__ */ u(
|
|
1461
1441
|
"div",
|
|
@@ -1480,8 +1460,8 @@ function at({
|
|
|
1480
1460
|
allowedPlans: t,
|
|
1481
1461
|
requiredFeature: r
|
|
1482
1462
|
}) {
|
|
1483
|
-
const { subscription: s, hasAllowedPlan: a, isFeatureEnabled:
|
|
1484
|
-
return
|
|
1463
|
+
const { subscription: s, hasAllowedPlan: a, isFeatureEnabled: v, loading: M } = Fe();
|
|
1464
|
+
return M ? /* @__PURE__ */ n(
|
|
1485
1465
|
"div",
|
|
1486
1466
|
{
|
|
1487
1467
|
style: {
|
|
@@ -1491,7 +1471,7 @@ function at({
|
|
|
1491
1471
|
},
|
|
1492
1472
|
children: "Loading subscription..."
|
|
1493
1473
|
}
|
|
1494
|
-
) : s ? s.isActive ? t && t.length > 0 && !a(t) ? /* @__PURE__ */ n(
|
|
1474
|
+
) : s ? s.isActive ? t && t.length > 0 && !a(t) ? /* @__PURE__ */ n(B, { children: e }) : r && !v(r) ? /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: i }) : /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: e });
|
|
1495
1475
|
}
|
|
1496
1476
|
const Le = ({ flagName: i }) => /* @__PURE__ */ u(
|
|
1497
1477
|
"div",
|
|
@@ -1535,7 +1515,7 @@ function lt({ name: i, children: e, fallback: t }) {
|
|
|
1535
1515
|
},
|
|
1536
1516
|
children: "Loading feature flags..."
|
|
1537
1517
|
}
|
|
1538
|
-
) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */ n(
|
|
1518
|
+
) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: t || /* @__PURE__ */ n(Le, { flagName: i }) }));
|
|
1539
1519
|
}
|
|
1540
1520
|
const De = () => /* @__PURE__ */ u(
|
|
1541
1521
|
"svg",
|
|
@@ -1571,10 +1551,10 @@ const De = () => /* @__PURE__ */ u(
|
|
|
1571
1551
|
/* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
1572
1552
|
]
|
|
1573
1553
|
}
|
|
1574
|
-
),
|
|
1554
|
+
), Ue = {
|
|
1575
1555
|
showPassword: /* @__PURE__ */ n(De, {}),
|
|
1576
1556
|
hidePassword: /* @__PURE__ */ n(Be, {})
|
|
1577
|
-
},
|
|
1557
|
+
}, qe = {
|
|
1578
1558
|
title: "Sign In",
|
|
1579
1559
|
emailLabel: "Email",
|
|
1580
1560
|
emailPlaceholder: "Enter your email",
|
|
@@ -1700,107 +1680,107 @@ function ct({
|
|
|
1700
1680
|
onSuccess: r,
|
|
1701
1681
|
onError: s,
|
|
1702
1682
|
onForgotPassword: a,
|
|
1703
|
-
onSignupClick:
|
|
1704
|
-
showForgotPassword:
|
|
1705
|
-
showSignupLink:
|
|
1683
|
+
onSignupClick: v,
|
|
1684
|
+
showForgotPassword: M = !0,
|
|
1685
|
+
showSignupLink: k = !0,
|
|
1706
1686
|
className: P
|
|
1707
1687
|
}) {
|
|
1708
|
-
const [
|
|
1709
|
-
const
|
|
1710
|
-
return
|
|
1711
|
-
}, o = async (
|
|
1712
|
-
if (
|
|
1713
|
-
if (!(
|
|
1714
|
-
|
|
1688
|
+
const [h, g] = m(""), [x, f] = m(""), [A, F] = m(!1), [y, C] = m(!1), [p, b] = m(""), [T, R] = m({}), { login: L } = se(), { tenant: E } = Z(), D = { ...qe, ...i }, l = { ...Ne, ...e }, w = { ...Ue, ...t }, d = () => {
|
|
1689
|
+
const I = {};
|
|
1690
|
+
return h.trim() || (I.email = !0), x.trim() || (I.password = !0), R(I), Object.keys(I).length === 0;
|
|
1691
|
+
}, o = async (I) => {
|
|
1692
|
+
if (I.preventDefault(), !!d()) {
|
|
1693
|
+
if (!(E != null && E.id)) {
|
|
1694
|
+
b("Tenant not found");
|
|
1715
1695
|
return;
|
|
1716
1696
|
}
|
|
1717
|
-
|
|
1697
|
+
C(!0), b("");
|
|
1718
1698
|
try {
|
|
1719
|
-
const
|
|
1720
|
-
r == null || r(
|
|
1721
|
-
} catch (
|
|
1722
|
-
const
|
|
1723
|
-
|
|
1699
|
+
const N = await L(h, x, E.id);
|
|
1700
|
+
r == null || r(N);
|
|
1701
|
+
} catch (N) {
|
|
1702
|
+
const _ = N.message || D.errorMessage;
|
|
1703
|
+
b(_), s == null || s(_);
|
|
1724
1704
|
} finally {
|
|
1725
|
-
|
|
1705
|
+
C(!1);
|
|
1726
1706
|
}
|
|
1727
1707
|
}
|
|
1728
|
-
},
|
|
1729
|
-
...
|
|
1730
|
-
...
|
|
1731
|
-
}),
|
|
1732
|
-
...
|
|
1733
|
-
...
|
|
1734
|
-
...!
|
|
1708
|
+
}, c = (I) => ({
|
|
1709
|
+
...l.input,
|
|
1710
|
+
...T[I] ? l.inputError : {}
|
|
1711
|
+
}), W = () => ({
|
|
1712
|
+
...l.button,
|
|
1713
|
+
...y ? l.buttonLoading : {},
|
|
1714
|
+
...!h || !x || y ? l.buttonDisabled : {}
|
|
1735
1715
|
});
|
|
1736
|
-
return /* @__PURE__ */ u("div", { className: P, style:
|
|
1737
|
-
/* @__PURE__ */ n("h2", { style:
|
|
1738
|
-
/* @__PURE__ */ u("form", { onSubmit: o, style:
|
|
1739
|
-
/* @__PURE__ */ u("div", { style:
|
|
1740
|
-
/* @__PURE__ */ n("label", { style:
|
|
1716
|
+
return /* @__PURE__ */ u("div", { className: P, style: l.container, children: [
|
|
1717
|
+
/* @__PURE__ */ n("h2", { style: l.title, children: D.title }),
|
|
1718
|
+
/* @__PURE__ */ u("form", { onSubmit: o, style: l.form, children: [
|
|
1719
|
+
/* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
|
|
1720
|
+
/* @__PURE__ */ n("label", { style: l.label, children: D.emailLabel }),
|
|
1741
1721
|
/* @__PURE__ */ n(
|
|
1742
1722
|
"input",
|
|
1743
1723
|
{
|
|
1744
1724
|
id: "email",
|
|
1745
1725
|
name: "email",
|
|
1746
1726
|
type: "email",
|
|
1747
|
-
value:
|
|
1748
|
-
onChange: (
|
|
1749
|
-
|
|
1727
|
+
value: h,
|
|
1728
|
+
onChange: (I) => {
|
|
1729
|
+
g(I.target.value), T.email && R((N) => ({ ...N, email: !1 }));
|
|
1750
1730
|
},
|
|
1751
|
-
placeholder:
|
|
1752
|
-
style:
|
|
1753
|
-
disabled:
|
|
1731
|
+
placeholder: D.emailPlaceholder,
|
|
1732
|
+
style: c("email"),
|
|
1733
|
+
disabled: y
|
|
1754
1734
|
}
|
|
1755
1735
|
)
|
|
1756
1736
|
] }),
|
|
1757
|
-
/* @__PURE__ */ u("div", { style:
|
|
1758
|
-
/* @__PURE__ */ n("label", { style:
|
|
1759
|
-
/* @__PURE__ */ u("div", { style:
|
|
1737
|
+
/* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
|
|
1738
|
+
/* @__PURE__ */ n("label", { style: l.label, children: D.passwordLabel }),
|
|
1739
|
+
/* @__PURE__ */ u("div", { style: l.inputContainer, children: [
|
|
1760
1740
|
/* @__PURE__ */ n(
|
|
1761
1741
|
"input",
|
|
1762
1742
|
{
|
|
1763
1743
|
id: "password",
|
|
1764
1744
|
name: "password",
|
|
1765
|
-
type:
|
|
1766
|
-
value:
|
|
1767
|
-
onChange: (
|
|
1768
|
-
|
|
1745
|
+
type: A ? "text" : "password",
|
|
1746
|
+
value: x,
|
|
1747
|
+
onChange: (I) => {
|
|
1748
|
+
f(I.target.value), T.password && R((N) => ({ ...N, password: !1 }));
|
|
1769
1749
|
},
|
|
1770
|
-
placeholder:
|
|
1750
|
+
placeholder: D.passwordPlaceholder,
|
|
1771
1751
|
style: {
|
|
1772
|
-
...
|
|
1752
|
+
...c("password"),
|
|
1773
1753
|
paddingRight: "2.5rem"
|
|
1774
1754
|
// Make room for the icon
|
|
1775
1755
|
},
|
|
1776
|
-
disabled:
|
|
1756
|
+
disabled: y
|
|
1777
1757
|
}
|
|
1778
1758
|
),
|
|
1779
1759
|
/* @__PURE__ */ n(
|
|
1780
1760
|
"button",
|
|
1781
1761
|
{
|
|
1782
1762
|
type: "button",
|
|
1783
|
-
onClick: () =>
|
|
1784
|
-
style:
|
|
1785
|
-
disabled:
|
|
1786
|
-
"aria-label":
|
|
1787
|
-
children:
|
|
1763
|
+
onClick: () => F(!A),
|
|
1764
|
+
style: l.passwordToggle,
|
|
1765
|
+
disabled: y,
|
|
1766
|
+
"aria-label": A ? "Hide password" : "Show password",
|
|
1767
|
+
children: A ? w.hidePassword : w.showPassword
|
|
1788
1768
|
}
|
|
1789
1769
|
)
|
|
1790
1770
|
] })
|
|
1791
1771
|
] }),
|
|
1792
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !
|
|
1793
|
-
|
|
1772
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !h || !x || y, style: W(), children: y ? D.loadingText : D.submitButton }),
|
|
1773
|
+
p && /* @__PURE__ */ n("div", { style: l.errorText, children: p })
|
|
1794
1774
|
] }),
|
|
1795
|
-
(
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
/* @__PURE__ */ u("span", { style:
|
|
1800
|
-
|
|
1775
|
+
(M || k) && /* @__PURE__ */ u("div", { style: l.linkContainer, children: [
|
|
1776
|
+
M && /* @__PURE__ */ n("a", { onClick: a, style: l.link, children: D.forgotPasswordLink }),
|
|
1777
|
+
M && k && /* @__PURE__ */ n("div", { style: l.divider, children: "•" }),
|
|
1778
|
+
k && /* @__PURE__ */ u("div", { children: [
|
|
1779
|
+
/* @__PURE__ */ u("span", { style: l.divider, children: [
|
|
1780
|
+
D.signupText,
|
|
1801
1781
|
" "
|
|
1802
1782
|
] }),
|
|
1803
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
1783
|
+
/* @__PURE__ */ n("a", { onClick: v, style: l.link, children: D.signupLink })
|
|
1804
1784
|
] })
|
|
1805
1785
|
] })
|
|
1806
1786
|
] });
|
|
@@ -1931,143 +1911,143 @@ function dt({
|
|
|
1931
1911
|
onSuccess: r,
|
|
1932
1912
|
onError: s,
|
|
1933
1913
|
onLoginClick: a,
|
|
1934
|
-
showLoginLink:
|
|
1935
|
-
className:
|
|
1914
|
+
showLoginLink: v = !0,
|
|
1915
|
+
className: M
|
|
1936
1916
|
}) {
|
|
1937
|
-
const [
|
|
1938
|
-
const
|
|
1939
|
-
return
|
|
1940
|
-
},
|
|
1941
|
-
if (
|
|
1942
|
-
if (
|
|
1943
|
-
|
|
1917
|
+
const [k, P] = m(""), [h, g] = m(""), [x, f] = m(""), [A, F] = m(""), [y, C] = m(""), [p, b] = m(!1), [T, R] = m(""), [L, E] = m({}), { signup: D, signupTenantAdmin: l } = se(), { tenant: w } = Z(), d = { ...Oe, ...i }, o = { ...ze, ...e }, c = () => {
|
|
1918
|
+
const H = {};
|
|
1919
|
+
return k.trim() || (H.name = !0), h.trim() || (H.email = !0), x.trim() || (H.password = !0), A.trim() || (H.confirmPassword = !0), t === "tenant" && !y.trim() && (H.tenantName = !0), E(H), Object.keys(H).length === 0;
|
|
1920
|
+
}, W = async (H) => {
|
|
1921
|
+
if (H.preventDefault(), !!c()) {
|
|
1922
|
+
if (x !== A) {
|
|
1923
|
+
R(d.passwordMismatchError), E({ confirmPassword: !0 });
|
|
1944
1924
|
return;
|
|
1945
1925
|
}
|
|
1946
|
-
if (t === "user" && !(
|
|
1947
|
-
|
|
1926
|
+
if (t === "user" && !(w != null && w.id)) {
|
|
1927
|
+
R("Tenant not found");
|
|
1948
1928
|
return;
|
|
1949
1929
|
}
|
|
1950
|
-
|
|
1930
|
+
b(!0), R("");
|
|
1951
1931
|
try {
|
|
1952
1932
|
let q;
|
|
1953
|
-
t === "tenant" ? q = await
|
|
1933
|
+
t === "tenant" ? q = await l(h, k, x, y) : q = await D(h, k, x, w.id), r == null || r(q);
|
|
1954
1934
|
} catch (q) {
|
|
1955
|
-
const Y = q.message ||
|
|
1956
|
-
|
|
1935
|
+
const Y = q.message || d.errorMessage;
|
|
1936
|
+
R(Y), s == null || s(Y);
|
|
1957
1937
|
} finally {
|
|
1958
|
-
|
|
1938
|
+
b(!1);
|
|
1959
1939
|
}
|
|
1960
1940
|
}
|
|
1961
|
-
},
|
|
1941
|
+
}, I = (H) => ({
|
|
1962
1942
|
...o.input,
|
|
1963
|
-
...
|
|
1964
|
-
}),
|
|
1943
|
+
...L[H] ? o.inputError : {}
|
|
1944
|
+
}), N = () => ({
|
|
1965
1945
|
...o.button,
|
|
1966
|
-
...
|
|
1967
|
-
...!
|
|
1968
|
-
}),
|
|
1969
|
-
return /* @__PURE__ */ u("div", { className:
|
|
1970
|
-
/* @__PURE__ */ n("h2", { style: o.title, children:
|
|
1971
|
-
/* @__PURE__ */ u("form", { onSubmit:
|
|
1946
|
+
...p ? o.buttonLoading : {},
|
|
1947
|
+
...!k || !h || !x || !A || p || t === "tenant" && !y ? o.buttonDisabled : {}
|
|
1948
|
+
}), _ = k && h && x && A && (t === "user" || y);
|
|
1949
|
+
return /* @__PURE__ */ u("div", { className: M, style: o.container, children: [
|
|
1950
|
+
/* @__PURE__ */ n("h2", { style: o.title, children: d.title }),
|
|
1951
|
+
/* @__PURE__ */ u("form", { onSubmit: W, style: o.form, children: [
|
|
1972
1952
|
/* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
|
|
1973
|
-
/* @__PURE__ */ n("label", { style: o.label, children:
|
|
1953
|
+
/* @__PURE__ */ n("label", { style: o.label, children: d.nameLabel }),
|
|
1974
1954
|
/* @__PURE__ */ n(
|
|
1975
1955
|
"input",
|
|
1976
1956
|
{
|
|
1977
1957
|
id: "name",
|
|
1978
1958
|
name: "name",
|
|
1979
1959
|
type: "text",
|
|
1980
|
-
value:
|
|
1981
|
-
onChange: (
|
|
1982
|
-
P(
|
|
1960
|
+
value: k,
|
|
1961
|
+
onChange: (H) => {
|
|
1962
|
+
P(H.target.value), L.name && E((q) => ({ ...q, name: !1 }));
|
|
1983
1963
|
},
|
|
1984
|
-
placeholder:
|
|
1985
|
-
style:
|
|
1986
|
-
disabled:
|
|
1964
|
+
placeholder: d.namePlaceholder,
|
|
1965
|
+
style: I("name"),
|
|
1966
|
+
disabled: p
|
|
1987
1967
|
}
|
|
1988
1968
|
)
|
|
1989
1969
|
] }),
|
|
1990
1970
|
/* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
|
|
1991
|
-
/* @__PURE__ */ n("label", { style: o.label, children:
|
|
1971
|
+
/* @__PURE__ */ n("label", { style: o.label, children: d.emailLabel }),
|
|
1992
1972
|
/* @__PURE__ */ n(
|
|
1993
1973
|
"input",
|
|
1994
1974
|
{
|
|
1995
1975
|
id: "email",
|
|
1996
1976
|
name: "email",
|
|
1997
1977
|
type: "email",
|
|
1998
|
-
value:
|
|
1999
|
-
onChange: (
|
|
2000
|
-
|
|
1978
|
+
value: h,
|
|
1979
|
+
onChange: (H) => {
|
|
1980
|
+
g(H.target.value), L.email && E((q) => ({ ...q, email: !1 }));
|
|
2001
1981
|
},
|
|
2002
|
-
placeholder:
|
|
2003
|
-
style:
|
|
2004
|
-
disabled:
|
|
1982
|
+
placeholder: d.emailPlaceholder,
|
|
1983
|
+
style: I("email"),
|
|
1984
|
+
disabled: p
|
|
2005
1985
|
}
|
|
2006
1986
|
)
|
|
2007
1987
|
] }),
|
|
2008
1988
|
/* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
|
|
2009
|
-
/* @__PURE__ */ n("label", { style: o.label, children:
|
|
1989
|
+
/* @__PURE__ */ n("label", { style: o.label, children: d.passwordLabel }),
|
|
2010
1990
|
/* @__PURE__ */ n(
|
|
2011
1991
|
"input",
|
|
2012
1992
|
{
|
|
2013
1993
|
id: "password",
|
|
2014
1994
|
name: "password",
|
|
2015
1995
|
type: "password",
|
|
2016
|
-
value:
|
|
2017
|
-
onChange: (
|
|
2018
|
-
|
|
1996
|
+
value: x,
|
|
1997
|
+
onChange: (H) => {
|
|
1998
|
+
f(H.target.value), L.password && E((q) => ({ ...q, password: !1 }));
|
|
2019
1999
|
},
|
|
2020
|
-
placeholder:
|
|
2021
|
-
style:
|
|
2022
|
-
disabled:
|
|
2000
|
+
placeholder: d.passwordPlaceholder,
|
|
2001
|
+
style: I("password"),
|
|
2002
|
+
disabled: p
|
|
2023
2003
|
}
|
|
2024
2004
|
)
|
|
2025
2005
|
] }),
|
|
2026
2006
|
/* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
|
|
2027
|
-
/* @__PURE__ */ n("label", { style: o.label, children:
|
|
2007
|
+
/* @__PURE__ */ n("label", { style: o.label, children: d.confirmPasswordLabel }),
|
|
2028
2008
|
/* @__PURE__ */ n(
|
|
2029
2009
|
"input",
|
|
2030
2010
|
{
|
|
2031
2011
|
id: "confirmPassword",
|
|
2032
2012
|
name: "confirmPassword",
|
|
2033
2013
|
type: "password",
|
|
2034
|
-
value:
|
|
2035
|
-
onChange: (
|
|
2036
|
-
|
|
2014
|
+
value: A,
|
|
2015
|
+
onChange: (H) => {
|
|
2016
|
+
F(H.target.value), L.confirmPassword && E((q) => ({ ...q, confirmPassword: !1 })), T === d.passwordMismatchError && R("");
|
|
2037
2017
|
},
|
|
2038
|
-
placeholder:
|
|
2039
|
-
style:
|
|
2040
|
-
disabled:
|
|
2018
|
+
placeholder: d.confirmPasswordPlaceholder,
|
|
2019
|
+
style: I("confirmPassword"),
|
|
2020
|
+
disabled: p
|
|
2041
2021
|
}
|
|
2042
2022
|
)
|
|
2043
2023
|
] }),
|
|
2044
2024
|
t === "tenant" && /* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
|
|
2045
|
-
/* @__PURE__ */ n("label", { style: o.label, children:
|
|
2025
|
+
/* @__PURE__ */ n("label", { style: o.label, children: d.tenantNameLabel }),
|
|
2046
2026
|
/* @__PURE__ */ n(
|
|
2047
2027
|
"input",
|
|
2048
2028
|
{
|
|
2049
2029
|
id: "tenantName",
|
|
2050
2030
|
name: "tenantName",
|
|
2051
2031
|
type: "text",
|
|
2052
|
-
value:
|
|
2053
|
-
onChange: (
|
|
2054
|
-
|
|
2032
|
+
value: y,
|
|
2033
|
+
onChange: (H) => {
|
|
2034
|
+
C(H.target.value), L.tenantName && E((q) => ({ ...q, tenantName: !1 }));
|
|
2055
2035
|
},
|
|
2056
|
-
placeholder:
|
|
2057
|
-
style:
|
|
2058
|
-
disabled:
|
|
2036
|
+
placeholder: d.tenantNamePlaceholder,
|
|
2037
|
+
style: I("tenantName"),
|
|
2038
|
+
disabled: p
|
|
2059
2039
|
}
|
|
2060
2040
|
)
|
|
2061
2041
|
] }),
|
|
2062
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !
|
|
2063
|
-
|
|
2042
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !_ || p, style: N(), children: p ? d.loadingText : d.submitButton }),
|
|
2043
|
+
T && /* @__PURE__ */ n("div", { style: o.errorText, children: T })
|
|
2064
2044
|
] }),
|
|
2065
|
-
|
|
2045
|
+
v && /* @__PURE__ */ u("div", { style: o.linkContainer, children: [
|
|
2066
2046
|
/* @__PURE__ */ u("span", { style: o.divider, children: [
|
|
2067
|
-
|
|
2047
|
+
d.loginText,
|
|
2068
2048
|
" "
|
|
2069
2049
|
] }),
|
|
2070
|
-
/* @__PURE__ */ n("a", { onClick: a, style: o.link, children:
|
|
2050
|
+
/* @__PURE__ */ n("a", { onClick: a, style: o.link, children: d.loginLink })
|
|
2071
2051
|
] })
|
|
2072
2052
|
] });
|
|
2073
2053
|
}
|
|
@@ -2192,106 +2172,106 @@ function ut({
|
|
|
2192
2172
|
token: r = "",
|
|
2193
2173
|
onSuccess: s,
|
|
2194
2174
|
onError: a,
|
|
2195
|
-
onBackToLogin:
|
|
2196
|
-
onModeChange:
|
|
2197
|
-
className:
|
|
2175
|
+
onBackToLogin: v,
|
|
2176
|
+
onModeChange: M,
|
|
2177
|
+
className: k
|
|
2198
2178
|
}) {
|
|
2199
|
-
const [P,
|
|
2200
|
-
const
|
|
2201
|
-
return P.trim() || (
|
|
2202
|
-
},
|
|
2203
|
-
const
|
|
2204
|
-
return
|
|
2205
|
-
},
|
|
2206
|
-
if (
|
|
2207
|
-
if (!(
|
|
2208
|
-
|
|
2179
|
+
const [P, h] = m(""), [g, x] = m(r), [f, A] = m(""), [F, y] = m(""), [C, p] = m(!1), [b, T] = m(""), [R, L] = m(""), [E, D] = m({}), { requestPasswordReset: l, confirmPasswordReset: w } = se(), { tenant: d } = Z(), o = { ...je, ...i }, c = { ...Ve, ...e }, W = () => {
|
|
2180
|
+
const U = {};
|
|
2181
|
+
return P.trim() || (U.email = !0), D(U), Object.keys(U).length === 0;
|
|
2182
|
+
}, I = () => {
|
|
2183
|
+
const U = {};
|
|
2184
|
+
return g.trim() || (U.token = !0), f.trim() || (U.newPassword = !0), F.trim() || (U.confirmPassword = !0), D(U), Object.keys(U).length === 0;
|
|
2185
|
+
}, N = async (U) => {
|
|
2186
|
+
if (U.preventDefault(), !!W()) {
|
|
2187
|
+
if (!(d != null && d.id)) {
|
|
2188
|
+
T("Tenant not found");
|
|
2209
2189
|
return;
|
|
2210
2190
|
}
|
|
2211
|
-
|
|
2191
|
+
p(!0), T(""), L("");
|
|
2212
2192
|
try {
|
|
2213
|
-
await
|
|
2214
|
-
} catch (
|
|
2215
|
-
const
|
|
2216
|
-
|
|
2193
|
+
await l(P, d.id), L(o.successMessage), s == null || s();
|
|
2194
|
+
} catch (z) {
|
|
2195
|
+
const j = z.message || o.errorMessage;
|
|
2196
|
+
T(j), a == null || a(j);
|
|
2217
2197
|
} finally {
|
|
2218
|
-
|
|
2198
|
+
p(!1);
|
|
2219
2199
|
}
|
|
2220
2200
|
}
|
|
2221
|
-
},
|
|
2222
|
-
if (
|
|
2223
|
-
if (
|
|
2224
|
-
|
|
2201
|
+
}, _ = async (U) => {
|
|
2202
|
+
if (U.preventDefault(), !!I()) {
|
|
2203
|
+
if (f !== F) {
|
|
2204
|
+
T(o.passwordMismatchError), D({ confirmPassword: !0 });
|
|
2225
2205
|
return;
|
|
2226
2206
|
}
|
|
2227
|
-
|
|
2207
|
+
p(!0), T(""), L("");
|
|
2228
2208
|
try {
|
|
2229
|
-
await
|
|
2230
|
-
} catch (
|
|
2231
|
-
const
|
|
2232
|
-
|
|
2209
|
+
await w(g, f), L(o.resetSuccessMessage), s == null || s();
|
|
2210
|
+
} catch (z) {
|
|
2211
|
+
const j = z.message || o.errorMessage;
|
|
2212
|
+
T(j), a == null || a(j);
|
|
2233
2213
|
} finally {
|
|
2234
|
-
|
|
2214
|
+
p(!1);
|
|
2235
2215
|
}
|
|
2236
2216
|
}
|
|
2237
|
-
},
|
|
2238
|
-
...
|
|
2239
|
-
...
|
|
2217
|
+
}, H = (U) => ({
|
|
2218
|
+
...c.input,
|
|
2219
|
+
...E[U] ? c.inputError : {}
|
|
2240
2220
|
}), q = () => ({
|
|
2241
|
-
...
|
|
2242
|
-
...
|
|
2221
|
+
...c.button,
|
|
2222
|
+
...C ? c.buttonLoading : {}
|
|
2243
2223
|
});
|
|
2244
2224
|
if (t === "reset") {
|
|
2245
|
-
const
|
|
2246
|
-
return /* @__PURE__ */ u("div", { className:
|
|
2247
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2248
|
-
/* @__PURE__ */ n("p", { style:
|
|
2249
|
-
/* @__PURE__ */ u("form", { onSubmit:
|
|
2250
|
-
/* @__PURE__ */ u("div", { style:
|
|
2251
|
-
/* @__PURE__ */ n("label", { style:
|
|
2225
|
+
const U = g && f && F;
|
|
2226
|
+
return /* @__PURE__ */ u("div", { className: k, style: c.container, children: [
|
|
2227
|
+
/* @__PURE__ */ n("h2", { style: c.title, children: o.resetTitle }),
|
|
2228
|
+
/* @__PURE__ */ n("p", { style: c.subtitle, children: o.resetSubtitle }),
|
|
2229
|
+
/* @__PURE__ */ u("form", { onSubmit: _, style: c.form, children: [
|
|
2230
|
+
/* @__PURE__ */ u("div", { style: c.fieldGroup, children: [
|
|
2231
|
+
/* @__PURE__ */ n("label", { style: c.label, children: o.tokenLabel }),
|
|
2252
2232
|
/* @__PURE__ */ n(
|
|
2253
2233
|
"input",
|
|
2254
2234
|
{
|
|
2255
2235
|
type: "text",
|
|
2256
|
-
value:
|
|
2257
|
-
onChange: (
|
|
2258
|
-
|
|
2236
|
+
value: g,
|
|
2237
|
+
onChange: (z) => {
|
|
2238
|
+
x(z.target.value), E.token && D((j) => ({ ...j, token: !1 }));
|
|
2259
2239
|
},
|
|
2260
2240
|
placeholder: o.tokenPlaceholder,
|
|
2261
|
-
style:
|
|
2262
|
-
disabled:
|
|
2241
|
+
style: H("token"),
|
|
2242
|
+
disabled: C
|
|
2263
2243
|
}
|
|
2264
2244
|
)
|
|
2265
2245
|
] }),
|
|
2266
|
-
/* @__PURE__ */ u("div", { style:
|
|
2267
|
-
/* @__PURE__ */ n("label", { style:
|
|
2246
|
+
/* @__PURE__ */ u("div", { style: c.fieldGroup, children: [
|
|
2247
|
+
/* @__PURE__ */ n("label", { style: c.label, children: o.newPasswordLabel }),
|
|
2268
2248
|
/* @__PURE__ */ n(
|
|
2269
2249
|
"input",
|
|
2270
2250
|
{
|
|
2271
2251
|
type: "password",
|
|
2272
|
-
value:
|
|
2273
|
-
onChange: (
|
|
2274
|
-
|
|
2252
|
+
value: f,
|
|
2253
|
+
onChange: (z) => {
|
|
2254
|
+
A(z.target.value), E.newPassword && D((j) => ({ ...j, newPassword: !1 }));
|
|
2275
2255
|
},
|
|
2276
2256
|
placeholder: o.newPasswordPlaceholder,
|
|
2277
|
-
style:
|
|
2278
|
-
disabled:
|
|
2257
|
+
style: H("newPassword"),
|
|
2258
|
+
disabled: C
|
|
2279
2259
|
}
|
|
2280
2260
|
)
|
|
2281
2261
|
] }),
|
|
2282
|
-
/* @__PURE__ */ u("div", { style:
|
|
2283
|
-
/* @__PURE__ */ n("label", { style:
|
|
2262
|
+
/* @__PURE__ */ u("div", { style: c.fieldGroup, children: [
|
|
2263
|
+
/* @__PURE__ */ n("label", { style: c.label, children: o.confirmPasswordLabel }),
|
|
2284
2264
|
/* @__PURE__ */ n(
|
|
2285
2265
|
"input",
|
|
2286
2266
|
{
|
|
2287
2267
|
type: "password",
|
|
2288
|
-
value:
|
|
2289
|
-
onChange: (
|
|
2290
|
-
|
|
2268
|
+
value: F,
|
|
2269
|
+
onChange: (z) => {
|
|
2270
|
+
y(z.target.value), E.confirmPassword && D((j) => ({ ...j, confirmPassword: !1 })), b === o.passwordMismatchError && T("");
|
|
2291
2271
|
},
|
|
2292
2272
|
placeholder: o.confirmPasswordPlaceholder,
|
|
2293
|
-
style:
|
|
2294
|
-
disabled:
|
|
2273
|
+
style: H("confirmPassword"),
|
|
2274
|
+
disabled: C
|
|
2295
2275
|
}
|
|
2296
2276
|
)
|
|
2297
2277
|
] }),
|
|
@@ -2299,44 +2279,44 @@ function ut({
|
|
|
2299
2279
|
"button",
|
|
2300
2280
|
{
|
|
2301
2281
|
type: "submit",
|
|
2302
|
-
disabled: !
|
|
2282
|
+
disabled: !U || C,
|
|
2303
2283
|
style: {
|
|
2304
2284
|
...q(),
|
|
2305
|
-
...!
|
|
2285
|
+
...!U || C ? c.buttonDisabled : {}
|
|
2306
2286
|
},
|
|
2307
|
-
children:
|
|
2287
|
+
children: C ? o.resetLoadingText : o.resetSubmitButton
|
|
2308
2288
|
}
|
|
2309
2289
|
),
|
|
2310
|
-
|
|
2311
|
-
|
|
2290
|
+
b && /* @__PURE__ */ n("div", { style: c.errorText, children: b }),
|
|
2291
|
+
R && /* @__PURE__ */ n("div", { style: c.successText, children: R })
|
|
2312
2292
|
] }),
|
|
2313
|
-
/* @__PURE__ */ u("div", { style:
|
|
2314
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
2315
|
-
|
|
2293
|
+
/* @__PURE__ */ u("div", { style: c.linkContainer, children: [
|
|
2294
|
+
/* @__PURE__ */ n("a", { onClick: v, style: c.link, children: o.backToLoginLink }),
|
|
2295
|
+
M && /* @__PURE__ */ u(B, { children: [
|
|
2316
2296
|
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
2317
|
-
/* @__PURE__ */ n("a", { onClick: () =>
|
|
2297
|
+
/* @__PURE__ */ n("a", { onClick: () => M("request"), style: c.link, children: "Request New Link" })
|
|
2318
2298
|
] })
|
|
2319
2299
|
] })
|
|
2320
2300
|
] });
|
|
2321
2301
|
}
|
|
2322
2302
|
const Y = P;
|
|
2323
|
-
return /* @__PURE__ */ u("div", { className:
|
|
2324
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2325
|
-
/* @__PURE__ */ n("p", { style:
|
|
2326
|
-
/* @__PURE__ */ u("form", { onSubmit:
|
|
2327
|
-
/* @__PURE__ */ u("div", { style:
|
|
2328
|
-
/* @__PURE__ */ n("label", { style:
|
|
2303
|
+
return /* @__PURE__ */ u("div", { className: k, style: c.container, children: [
|
|
2304
|
+
/* @__PURE__ */ n("h2", { style: c.title, children: o.title }),
|
|
2305
|
+
/* @__PURE__ */ n("p", { style: c.subtitle, children: o.subtitle }),
|
|
2306
|
+
/* @__PURE__ */ u("form", { onSubmit: N, style: c.form, children: [
|
|
2307
|
+
/* @__PURE__ */ u("div", { style: c.fieldGroup, children: [
|
|
2308
|
+
/* @__PURE__ */ n("label", { style: c.label, children: o.emailLabel }),
|
|
2329
2309
|
/* @__PURE__ */ n(
|
|
2330
2310
|
"input",
|
|
2331
2311
|
{
|
|
2332
2312
|
type: "email",
|
|
2333
2313
|
value: P,
|
|
2334
|
-
onChange: (
|
|
2335
|
-
|
|
2314
|
+
onChange: (U) => {
|
|
2315
|
+
h(U.target.value), E.email && D((z) => ({ ...z, email: !1 }));
|
|
2336
2316
|
},
|
|
2337
2317
|
placeholder: o.emailPlaceholder,
|
|
2338
|
-
style:
|
|
2339
|
-
disabled:
|
|
2318
|
+
style: H("email"),
|
|
2319
|
+
disabled: C
|
|
2340
2320
|
}
|
|
2341
2321
|
)
|
|
2342
2322
|
] }),
|
|
@@ -2344,22 +2324,22 @@ function ut({
|
|
|
2344
2324
|
"button",
|
|
2345
2325
|
{
|
|
2346
2326
|
type: "submit",
|
|
2347
|
-
disabled: !Y ||
|
|
2327
|
+
disabled: !Y || C,
|
|
2348
2328
|
style: {
|
|
2349
2329
|
...q(),
|
|
2350
|
-
...!Y ||
|
|
2330
|
+
...!Y || C ? c.buttonDisabled : {}
|
|
2351
2331
|
},
|
|
2352
|
-
children:
|
|
2332
|
+
children: C ? o.loadingText : o.submitButton
|
|
2353
2333
|
}
|
|
2354
2334
|
),
|
|
2355
|
-
|
|
2356
|
-
|
|
2335
|
+
b && /* @__PURE__ */ n("div", { style: c.errorText, children: b }),
|
|
2336
|
+
R && /* @__PURE__ */ n("div", { style: c.successText, children: R })
|
|
2357
2337
|
] }),
|
|
2358
|
-
/* @__PURE__ */ u("div", { style:
|
|
2359
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
2360
|
-
|
|
2338
|
+
/* @__PURE__ */ u("div", { style: c.linkContainer, children: [
|
|
2339
|
+
/* @__PURE__ */ n("a", { onClick: v, style: c.link, children: o.backToLoginLink }),
|
|
2340
|
+
M && /* @__PURE__ */ u(B, { children: [
|
|
2361
2341
|
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
2362
|
-
/* @__PURE__ */ n("a", { onClick: () =>
|
|
2342
|
+
/* @__PURE__ */ n("a", { onClick: () => M("reset"), style: c.link, children: "I have a token" })
|
|
2363
2343
|
] })
|
|
2364
2344
|
] })
|
|
2365
2345
|
] });
|
|
@@ -2624,30 +2604,30 @@ export {
|
|
|
2624
2604
|
Me as FeatureFlagApiService,
|
|
2625
2605
|
st as FeatureFlagProvider,
|
|
2626
2606
|
pt as HealthApiService,
|
|
2627
|
-
|
|
2607
|
+
G as HttpService,
|
|
2628
2608
|
ct as LoginForm,
|
|
2629
2609
|
ut as PasswordRecoveryForm,
|
|
2630
2610
|
ht as PermissionApiService,
|
|
2631
2611
|
it as Protected,
|
|
2632
2612
|
ot as ProtectedRoute,
|
|
2633
|
-
|
|
2613
|
+
le as RoleApiService,
|
|
2634
2614
|
xe as SessionManager,
|
|
2635
2615
|
dt as SignupForm,
|
|
2636
2616
|
Re as SubscriptionApiService,
|
|
2637
2617
|
at as SubscriptionGuard,
|
|
2638
2618
|
gt as SubscriptionPlanApiService,
|
|
2639
2619
|
nt as SubscriptionProvider,
|
|
2640
|
-
|
|
2620
|
+
ce as TenantApiService,
|
|
2641
2621
|
Ze as TenantProvider,
|
|
2642
2622
|
Pe as UserApiService,
|
|
2643
|
-
|
|
2623
|
+
J as UserType,
|
|
2644
2624
|
Xe as useApi,
|
|
2645
|
-
|
|
2646
|
-
|
|
2625
|
+
re as useApp,
|
|
2626
|
+
se as useAuth,
|
|
2647
2627
|
Ee as useFeatureFlags,
|
|
2648
2628
|
tt as useSettings,
|
|
2649
2629
|
Fe as useSubscription,
|
|
2650
|
-
|
|
2630
|
+
oe as useTenant,
|
|
2651
2631
|
Z as useTenantInfo,
|
|
2652
2632
|
et as useTenantSettings
|
|
2653
2633
|
};
|