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