@skylabs-digital/react-identity-access 1.2.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 +284 -289
- 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 -2
- package/dist/providers/TenantProvider.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -16,40 +16,40 @@ class G {
|
|
|
16
16
|
return this.executeRequest(e, t, r, s, !1);
|
|
17
17
|
}
|
|
18
18
|
async executeRequest(e, t, r, s, a = !1) {
|
|
19
|
-
const v = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`,
|
|
20
|
-
let
|
|
19
|
+
const v = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, T = (s == null ? void 0 : s.timeout) || this.timeout;
|
|
20
|
+
let M = {
|
|
21
21
|
"Content-Type": "application/json",
|
|
22
22
|
...s == null ? void 0 : s.headers
|
|
23
23
|
};
|
|
24
24
|
if (!(s != null && s.skipAuth) && this.sessionManager)
|
|
25
25
|
try {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
} catch (
|
|
29
|
-
console.warn("Failed to inject auth headers:",
|
|
26
|
+
const h = await this.sessionManager.getAuthHeaders();
|
|
27
|
+
M = { ...M, ...h };
|
|
28
|
+
} catch (h) {
|
|
29
|
+
console.warn("Failed to inject auth headers:", h);
|
|
30
30
|
}
|
|
31
|
-
const P = new AbortController(),
|
|
31
|
+
const P = new AbortController(), g = setTimeout(() => P.abort(), T);
|
|
32
32
|
try {
|
|
33
|
-
const
|
|
33
|
+
const h = await fetch(v, {
|
|
34
34
|
method: e,
|
|
35
|
-
headers:
|
|
35
|
+
headers: M,
|
|
36
36
|
body: r ? JSON.stringify(r) : void 0,
|
|
37
37
|
signal: P.signal
|
|
38
38
|
});
|
|
39
|
-
if (clearTimeout(
|
|
39
|
+
if (clearTimeout(g), h.status === 401 && !(s != null && s.skipRetry) && !a && this.sessionManager)
|
|
40
40
|
try {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
41
|
+
const 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
|
-
throw new Error(`HTTP ${
|
|
45
|
+
throw new Error(`HTTP ${h.status}: ${h.statusText}`);
|
|
46
46
|
}
|
|
47
|
-
if (!
|
|
48
|
-
throw new Error(`HTTP ${
|
|
49
|
-
const x =
|
|
50
|
-
return !x || !x.includes("application/json") ? {} : await
|
|
51
|
-
} catch (
|
|
52
|
-
throw clearTimeout(
|
|
47
|
+
if (!h.ok)
|
|
48
|
+
throw new Error(`HTTP ${h.status}: ${h.statusText}`);
|
|
49
|
+
const x = h.headers.get("content-type");
|
|
50
|
+
return !x || !x.includes("application/json") ? {} : await h.json();
|
|
51
|
+
} catch (h) {
|
|
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) {
|
|
@@ -171,8 +171,8 @@ const ge = ee(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), [v,
|
|
175
|
-
const
|
|
174
|
+
const [t, r] = m(null), [s, a] = m(!0), [v, T] = m(null), M = O(() => {
|
|
175
|
+
const g = () => {
|
|
176
176
|
P();
|
|
177
177
|
};
|
|
178
178
|
return {
|
|
@@ -182,16 +182,16 @@ function Je({ config: i, children: e }) {
|
|
|
182
182
|
appInfo: t,
|
|
183
183
|
isAppLoading: s,
|
|
184
184
|
appError: v,
|
|
185
|
-
retryApp:
|
|
185
|
+
retryApp: g
|
|
186
186
|
};
|
|
187
187
|
}, [i, t, s, v]), P = X(async () => {
|
|
188
188
|
try {
|
|
189
|
-
a(!0),
|
|
190
|
-
const
|
|
189
|
+
a(!0), T(null);
|
|
190
|
+
const g = new G(i.baseUrl), x = await new be(g, {}).getPublicAppInfo(i.appId);
|
|
191
191
|
r(x);
|
|
192
|
-
} catch (
|
|
193
|
-
const
|
|
194
|
-
|
|
192
|
+
} catch (g) {
|
|
193
|
+
const h = g instanceof Error ? g : new Error("Failed to load app information");
|
|
194
|
+
T(h), r(null);
|
|
195
195
|
} finally {
|
|
196
196
|
a(!1);
|
|
197
197
|
}
|
|
@@ -201,10 +201,10 @@ function Je({ config: i, children: e }) {
|
|
|
201
201
|
}, [P]), s)
|
|
202
202
|
return /* @__PURE__ */ n(B, { children: i.loadingFallback || /* @__PURE__ */ n(Se, {}) });
|
|
203
203
|
if (v) {
|
|
204
|
-
const
|
|
205
|
-
return /* @__PURE__ */ n(B, { children:
|
|
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
|
-
return /* @__PURE__ */ n(ge.Provider, { value:
|
|
207
|
+
return /* @__PURE__ */ n(ge.Provider, { value: M, children: e });
|
|
208
208
|
}
|
|
209
209
|
function re() {
|
|
210
210
|
const i = te(ge);
|
|
@@ -558,7 +558,7 @@ class ce {
|
|
|
558
558
|
)).data;
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
|
-
const pe = ee(null),
|
|
561
|
+
const pe = ee(null), ke = () => /* @__PURE__ */ n(
|
|
562
562
|
"div",
|
|
563
563
|
{
|
|
564
564
|
style: {
|
|
@@ -570,7 +570,7 @@ const pe = ee(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,74 +605,72 @@ const pe = ee(null), Te = () => /* @__PURE__ */ n(
|
|
|
605
605
|
}
|
|
606
606
|
);
|
|
607
607
|
function Ze({ config: i, children: e }) {
|
|
608
|
-
const { baseUrl: t, appInfo: r, appId: s } = re(), [a, v] = m(i.initialTenant || null), [
|
|
609
|
-
const
|
|
610
|
-
if (l === "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 (
|
|
611
|
+
if (c === "subdomain") {
|
|
614
612
|
const o = window.location.hostname.split(".");
|
|
615
613
|
if (o.length >= 3) {
|
|
616
|
-
const
|
|
617
|
-
return localStorage.setItem(w,
|
|
614
|
+
const l = o[0];
|
|
615
|
+
return localStorage.setItem(w, l), l;
|
|
618
616
|
}
|
|
619
617
|
return localStorage.getItem(w);
|
|
620
|
-
} else if (
|
|
618
|
+
} else if (c === "selector") {
|
|
621
619
|
const o = new URLSearchParams(window.location.search).get(i.selectorParam || "tenant");
|
|
622
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 w = new G(t), o = await new ce(w, s).getPublicTenantInfo(
|
|
626
|
+
M(!0), g(null);
|
|
627
|
+
const w = new G(t), o = await new ce(w, s).getPublicTenantInfo(c);
|
|
630
628
|
v(o);
|
|
631
629
|
} catch (w) {
|
|
632
630
|
const d = w instanceof Error ? w : new Error("Failed to load tenant information");
|
|
633
|
-
|
|
631
|
+
g(d), v(null);
|
|
634
632
|
} finally {
|
|
635
|
-
|
|
633
|
+
M(!1);
|
|
636
634
|
}
|
|
637
635
|
},
|
|
638
636
|
[t, s]
|
|
639
637
|
), R = X(async () => {
|
|
640
638
|
if (a != null && a.id)
|
|
641
639
|
try {
|
|
642
|
-
A(!0),
|
|
643
|
-
const
|
|
640
|
+
A(!0), f(null);
|
|
641
|
+
const c = new G(t), d = await new ce(c, a.appId).getTenantSettings(a.id);
|
|
644
642
|
x(d);
|
|
645
|
-
} catch (
|
|
646
|
-
const w =
|
|
647
|
-
|
|
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
647
|
A(!1);
|
|
650
648
|
}
|
|
651
649
|
}, [t, a]), L = X(() => {
|
|
652
650
|
R();
|
|
653
651
|
}, [R]), E = X(
|
|
654
|
-
(
|
|
652
|
+
(c) => {
|
|
655
653
|
if (!b)
|
|
656
654
|
return { isValid: !0, errors: [] };
|
|
657
655
|
const w = [];
|
|
658
656
|
try {
|
|
659
657
|
return b.properties && Object.entries(b.properties).forEach(([d, o]) => {
|
|
660
658
|
var W;
|
|
661
|
-
const
|
|
662
|
-
if ((W = b.required) != null && W.includes(d) &&
|
|
659
|
+
const l = c[d];
|
|
660
|
+
if ((W = b.required) != null && W.includes(d) && l == null) {
|
|
663
661
|
w.push(`Field '${d}' is required`);
|
|
664
662
|
return;
|
|
665
663
|
}
|
|
666
|
-
if (
|
|
664
|
+
if (l != null) {
|
|
667
665
|
if (o.type) {
|
|
668
|
-
const I = o.type, N = typeof
|
|
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(
|
|
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`);
|
|
670
668
|
}
|
|
671
|
-
o.minLength !== void 0 && typeof
|
|
669
|
+
o.minLength !== void 0 && typeof l == "string" && l.length < o.minLength && w.push(
|
|
672
670
|
`Field '${d}' must be at least ${o.minLength} characters long`
|
|
673
|
-
), o.maxLength !== void 0 && typeof
|
|
671
|
+
), o.maxLength !== void 0 && typeof l == "string" && l.length > o.maxLength && w.push(
|
|
674
672
|
`Field '${d}' must be no more than ${o.maxLength} characters long`
|
|
675
|
-
), o.minimum !== void 0 && typeof
|
|
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(", ")}`);
|
|
676
674
|
}
|
|
677
675
|
}), {
|
|
678
676
|
isValid: w.length === 0,
|
|
@@ -688,26 +686,23 @@ function Ze({ config: i, children: e }) {
|
|
|
688
686
|
[b]
|
|
689
687
|
);
|
|
690
688
|
K(() => {
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
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));
|
|
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));
|
|
697
692
|
}, [a == null ? void 0 : a.id, R]);
|
|
698
693
|
const D = O(() => ({
|
|
699
694
|
// Tenant info
|
|
700
695
|
tenant: a,
|
|
701
|
-
tenantSlug:
|
|
702
|
-
isTenantLoading:
|
|
696
|
+
tenantSlug: y,
|
|
697
|
+
isTenantLoading: T,
|
|
703
698
|
tenantError: P,
|
|
704
699
|
retryTenant: () => {
|
|
705
|
-
|
|
700
|
+
y && k(y);
|
|
706
701
|
},
|
|
707
702
|
// Settings
|
|
708
|
-
settings:
|
|
703
|
+
settings: h,
|
|
709
704
|
settingsSchema: b,
|
|
710
|
-
isSettingsLoading:
|
|
705
|
+
isSettingsLoading: p,
|
|
711
706
|
settingsError: F,
|
|
712
707
|
// Actions
|
|
713
708
|
refreshSettings: L,
|
|
@@ -715,21 +710,21 @@ function Ze({ config: i, children: e }) {
|
|
|
715
710
|
validateSettings: E
|
|
716
711
|
}), [
|
|
717
712
|
a,
|
|
718
|
-
|
|
719
|
-
|
|
713
|
+
y,
|
|
714
|
+
T,
|
|
720
715
|
P,
|
|
721
|
-
|
|
716
|
+
h,
|
|
722
717
|
b,
|
|
723
|
-
|
|
718
|
+
p,
|
|
724
719
|
F,
|
|
725
720
|
L,
|
|
726
721
|
E
|
|
727
722
|
]);
|
|
728
|
-
if (
|
|
729
|
-
return /* @__PURE__ */ n(B, { children: i.loadingFallback || /* @__PURE__ */ n(
|
|
730
|
-
if (P
|
|
731
|
-
const
|
|
732
|
-
return /* @__PURE__ */ n(B, { children:
|
|
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 });
|
|
733
728
|
}
|
|
734
729
|
return /* @__PURE__ */ n(pe.Provider, { value: D, children: e });
|
|
735
730
|
}
|
|
@@ -768,11 +763,11 @@ function Z() {
|
|
|
768
763
|
}
|
|
769
764
|
const fe = ee(null);
|
|
770
765
|
function rt({ config: i = {}, children: e }) {
|
|
771
|
-
const { appId: t, baseUrl: r } = re(), s = Z(), a = (s == null ? void 0 : s.tenantSlug) || null, [v,
|
|
772
|
-
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 = {
|
|
773
768
|
get: () => {
|
|
774
769
|
try {
|
|
775
|
-
const d = localStorage.getItem(
|
|
770
|
+
const d = localStorage.getItem(c);
|
|
776
771
|
return d ? JSON.parse(d) : null;
|
|
777
772
|
} catch {
|
|
778
773
|
return null;
|
|
@@ -780,13 +775,13 @@ function rt({ config: i = {}, children: e }) {
|
|
|
780
775
|
},
|
|
781
776
|
set: (d) => {
|
|
782
777
|
try {
|
|
783
|
-
localStorage.setItem(
|
|
778
|
+
localStorage.setItem(c, JSON.stringify(d));
|
|
784
779
|
} catch {
|
|
785
780
|
}
|
|
786
781
|
},
|
|
787
782
|
clear: () => {
|
|
788
783
|
try {
|
|
789
|
-
localStorage.removeItem(
|
|
784
|
+
localStorage.removeItem(c);
|
|
790
785
|
} catch {
|
|
791
786
|
}
|
|
792
787
|
}
|
|
@@ -797,85 +792,85 @@ function rt({ config: i = {}, children: e }) {
|
|
|
797
792
|
baseUrl: r
|
|
798
793
|
});
|
|
799
794
|
}, [a, r, i.onRefreshFailed]), C = O(() => {
|
|
800
|
-
const
|
|
801
|
-
return
|
|
802
|
-
}, [r,
|
|
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]);
|
|
803
798
|
K(() => {
|
|
804
799
|
console.log("AuthProvider - userPermissions changed:", E);
|
|
805
800
|
}, [E]);
|
|
806
801
|
const D = O(() => {
|
|
807
|
-
const
|
|
802
|
+
const c = async () => {
|
|
808
803
|
try {
|
|
809
|
-
|
|
810
|
-
const S =
|
|
804
|
+
p(!0), F(null);
|
|
805
|
+
const S = f.getUser();
|
|
811
806
|
if (!(S != null && S.id))
|
|
812
807
|
throw new Error("No user ID available in session");
|
|
813
808
|
const $ = await b.getUserById(S.id);
|
|
814
|
-
|
|
809
|
+
h($), f.setUser($);
|
|
815
810
|
} catch (S) {
|
|
816
811
|
const $ = S instanceof Error ? S : new Error("Failed to load user data");
|
|
817
812
|
F($), console.error("Failed to load user data:", $);
|
|
818
813
|
} finally {
|
|
819
|
-
|
|
814
|
+
p(!1);
|
|
820
815
|
}
|
|
821
816
|
}, w = async () => {
|
|
822
|
-
await
|
|
817
|
+
await c();
|
|
823
818
|
}, d = async (S, $, Q) => {
|
|
824
|
-
const V = await
|
|
819
|
+
const V = await y.login({
|
|
825
820
|
email: S,
|
|
826
821
|
password: $,
|
|
827
822
|
tenantId: Q
|
|
828
823
|
});
|
|
829
|
-
if (
|
|
824
|
+
if (f.setTokens({
|
|
830
825
|
accessToken: V.accessToken,
|
|
831
826
|
refreshToken: V.refreshToken,
|
|
832
827
|
expiresIn: V.expiresIn
|
|
833
828
|
}), V.user) {
|
|
834
|
-
|
|
829
|
+
f.setUser(V.user), h(V.user);
|
|
835
830
|
try {
|
|
836
|
-
await
|
|
831
|
+
await c();
|
|
837
832
|
} catch (ie) {
|
|
838
833
|
console.warn("Failed to load complete user data after login:", ie);
|
|
839
834
|
}
|
|
840
835
|
}
|
|
841
836
|
return V;
|
|
842
|
-
}, o = async (S, $, Q, V) => await
|
|
837
|
+
}, o = async (S, $, Q, V) => await y.signup({ email: S, name: $, password: Q, tenantId: V }), l = async (S, $, Q, V) => await y.signupTenantAdmin({
|
|
843
838
|
email: S,
|
|
844
839
|
name: $,
|
|
845
840
|
password: Q,
|
|
846
841
|
tenantName: V,
|
|
847
842
|
appId: t
|
|
848
843
|
}), W = async (S, $) => {
|
|
849
|
-
const Q = await
|
|
850
|
-
await
|
|
844
|
+
const Q = await f.getAuthHeaders();
|
|
845
|
+
await y.changePassword({ currentPassword: S, newPassword: $ }, Q);
|
|
851
846
|
}, I = async (S, $) => {
|
|
852
|
-
await
|
|
847
|
+
await y.requestPasswordReset({ email: S, tenantId: $ });
|
|
853
848
|
}, N = async (S, $) => {
|
|
854
|
-
await
|
|
849
|
+
await y.confirmPasswordReset({ token: S, newPassword: $ });
|
|
855
850
|
}, _ = async () => {
|
|
856
|
-
const S =
|
|
851
|
+
const S = f.getTokens();
|
|
857
852
|
if (!(S != null && S.refreshToken))
|
|
858
853
|
throw new Error("No refresh token available");
|
|
859
|
-
const $ = await
|
|
854
|
+
const $ = await y.refreshToken({
|
|
860
855
|
refreshToken: S.refreshToken
|
|
861
856
|
});
|
|
862
|
-
|
|
857
|
+
f.setTokens({
|
|
863
858
|
accessToken: $.accessToken,
|
|
864
859
|
refreshToken: $.refreshToken || S.refreshToken,
|
|
865
860
|
expiresIn: $.expiresIn
|
|
866
861
|
});
|
|
867
862
|
}, H = () => {
|
|
868
|
-
|
|
863
|
+
f.clearSession(), h(null), F(null);
|
|
869
864
|
}, q = (S) => {
|
|
870
|
-
|
|
871
|
-
}, Y = () =>
|
|
872
|
-
|
|
865
|
+
f.setTokens(S);
|
|
866
|
+
}, Y = () => f.hasValidSession(), U = () => {
|
|
867
|
+
f.clearSession(), h(null), F(null);
|
|
873
868
|
}, z = async () => {
|
|
874
869
|
if (t)
|
|
875
870
|
try {
|
|
876
871
|
P(!0);
|
|
877
|
-
const { roles: S } = await
|
|
878
|
-
|
|
872
|
+
const { roles: S } = await k.getRolesByApp(t);
|
|
873
|
+
T(S);
|
|
879
874
|
} catch (S) {
|
|
880
875
|
console.error("Failed to fetch roles:", S);
|
|
881
876
|
} finally {
|
|
@@ -892,11 +887,11 @@ function rt({ config: i = {}, children: e }) {
|
|
|
892
887
|
return E.includes($);
|
|
893
888
|
};
|
|
894
889
|
return {
|
|
895
|
-
sessionManager:
|
|
890
|
+
sessionManager: f,
|
|
896
891
|
authenticatedHttpService: C,
|
|
897
892
|
login: d,
|
|
898
893
|
signup: o,
|
|
899
|
-
signupTenantAdmin:
|
|
894
|
+
signupTenantAdmin: l,
|
|
900
895
|
changePassword: W,
|
|
901
896
|
requestPasswordReset: I,
|
|
902
897
|
confirmPasswordReset: N,
|
|
@@ -905,14 +900,14 @@ function rt({ config: i = {}, children: e }) {
|
|
|
905
900
|
setTokens: q,
|
|
906
901
|
hasValidSession: Y,
|
|
907
902
|
clearSession: U,
|
|
908
|
-
currentUser:
|
|
903
|
+
currentUser: g,
|
|
909
904
|
isUserLoading: x,
|
|
910
905
|
userError: A,
|
|
911
906
|
refreshUser: w,
|
|
912
907
|
userRole: L,
|
|
913
908
|
userPermissions: E,
|
|
914
909
|
availableRoles: v,
|
|
915
|
-
rolesLoading:
|
|
910
|
+
rolesLoading: M,
|
|
916
911
|
hasPermission: ne,
|
|
917
912
|
hasAnyPermission: (S) => S.some(($) => ne($)),
|
|
918
913
|
hasAllPermissions: (S) => S.every(($) => ne($)),
|
|
@@ -920,14 +915,14 @@ function rt({ config: i = {}, children: e }) {
|
|
|
920
915
|
refreshRoles: j
|
|
921
916
|
};
|
|
922
917
|
}, [
|
|
923
|
-
|
|
918
|
+
f,
|
|
924
919
|
C,
|
|
925
|
-
|
|
920
|
+
y,
|
|
926
921
|
b,
|
|
927
|
-
|
|
922
|
+
k,
|
|
928
923
|
t,
|
|
929
924
|
v,
|
|
930
|
-
|
|
925
|
+
g,
|
|
931
926
|
x,
|
|
932
927
|
A,
|
|
933
928
|
L,
|
|
@@ -938,7 +933,7 @@ function rt({ config: i = {}, children: e }) {
|
|
|
938
933
|
try {
|
|
939
934
|
P(!0);
|
|
940
935
|
const w = new G(r), d = new le(w), { roles: o } = await d.getRolesByApp(t);
|
|
941
|
-
|
|
936
|
+
T(o);
|
|
942
937
|
} catch (w) {
|
|
943
938
|
console.error("Failed to fetch roles:", w);
|
|
944
939
|
} finally {
|
|
@@ -946,9 +941,9 @@ function rt({ config: i = {}, children: e }) {
|
|
|
946
941
|
}
|
|
947
942
|
})();
|
|
948
943
|
}, [t, r, i.initialRoles]), K(() => {
|
|
949
|
-
const
|
|
950
|
-
|
|
951
|
-
}, [
|
|
944
|
+
const c = f.getUser();
|
|
945
|
+
c && f.hasValidSession() && h(c);
|
|
946
|
+
}, [f]), /* @__PURE__ */ n(fe.Provider, { value: D, children: e });
|
|
952
947
|
}
|
|
953
948
|
function se() {
|
|
954
949
|
const i = te(fe);
|
|
@@ -1038,7 +1033,7 @@ class Me {
|
|
|
1038
1033
|
}
|
|
1039
1034
|
const ye = ee(null);
|
|
1040
1035
|
function st({ config: i = {}, children: e }) {
|
|
1041
|
-
const { baseUrl: t, appId: r } = re(), { tenant: s } = Z(), [a, v] = m([]), [
|
|
1036
|
+
const { baseUrl: t, appId: r } = re(), { tenant: s } = Z(), [a, v] = m([]), [T, M] = m(!1), [P, g] = m(null), h = O(() => {
|
|
1042
1037
|
const A = new G(t);
|
|
1043
1038
|
return new Me(A);
|
|
1044
1039
|
}, [t]), x = async () => {
|
|
@@ -1046,15 +1041,15 @@ function st({ config: i = {}, children: e }) {
|
|
|
1046
1041
|
v([]);
|
|
1047
1042
|
return;
|
|
1048
1043
|
}
|
|
1049
|
-
|
|
1044
|
+
M(!0), g(null);
|
|
1050
1045
|
try {
|
|
1051
|
-
const A = await
|
|
1046
|
+
const A = await h.getTenantFeatureFlags(s.id, r);
|
|
1052
1047
|
v(A);
|
|
1053
1048
|
} catch (A) {
|
|
1054
1049
|
const F = A instanceof Error ? A.message : "Failed to fetch feature flags";
|
|
1055
|
-
|
|
1050
|
+
g(F), i.onError && i.onError(A instanceof Error ? A : new Error(F));
|
|
1056
1051
|
} finally {
|
|
1057
|
-
|
|
1052
|
+
M(!1);
|
|
1058
1053
|
}
|
|
1059
1054
|
};
|
|
1060
1055
|
K(() => {
|
|
@@ -1062,24 +1057,24 @@ function st({ config: i = {}, children: e }) {
|
|
|
1062
1057
|
const A = i.refreshInterval || 5 * 60 * 1e3, F = setInterval(x, A);
|
|
1063
1058
|
return () => clearInterval(F);
|
|
1064
1059
|
}, [s == null ? void 0 : s.id, i.refreshInterval]);
|
|
1065
|
-
const
|
|
1060
|
+
const p = O(() => ({
|
|
1066
1061
|
featureFlags: a,
|
|
1067
|
-
loading:
|
|
1062
|
+
loading: T,
|
|
1068
1063
|
error: P,
|
|
1069
|
-
isEnabled: (
|
|
1070
|
-
const b = a.find((
|
|
1064
|
+
isEnabled: (y) => {
|
|
1065
|
+
const b = a.find((k) => k.key === y);
|
|
1071
1066
|
return (b == null ? void 0 : b.value) === !0;
|
|
1072
1067
|
},
|
|
1073
|
-
getFlag: (
|
|
1074
|
-
getFlagState: (
|
|
1075
|
-
const b = a.find((
|
|
1068
|
+
getFlag: (y) => a.find((b) => b.key === y),
|
|
1069
|
+
getFlagState: (y) => {
|
|
1070
|
+
const b = a.find((k) => k.key === y);
|
|
1076
1071
|
return b ? b.value ? "enabled" : "disabled" : "not_found";
|
|
1077
1072
|
},
|
|
1078
1073
|
refresh: async () => {
|
|
1079
1074
|
await x();
|
|
1080
1075
|
}
|
|
1081
|
-
}), [a,
|
|
1082
|
-
return /* @__PURE__ */ n(ye.Provider, { value:
|
|
1076
|
+
}), [a, T, P]);
|
|
1077
|
+
return /* @__PURE__ */ n(ye.Provider, { value: p, children: e });
|
|
1083
1078
|
}
|
|
1084
1079
|
function Ee() {
|
|
1085
1080
|
const i = te(ye);
|
|
@@ -1155,52 +1150,52 @@ class Re {
|
|
|
1155
1150
|
}
|
|
1156
1151
|
const we = ee(void 0);
|
|
1157
1152
|
function nt({ config: i = {}, children: e }) {
|
|
1158
|
-
const { baseUrl: t } = re(), { tenant: r } = Z(), [s, a] = m(null), [v,
|
|
1159
|
-
const
|
|
1160
|
-
return new Re(
|
|
1161
|
-
}, [t]),
|
|
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);
|
|
1156
|
+
}, [t]), h = async () => {
|
|
1162
1157
|
if (!(r != null && r.id)) {
|
|
1163
1158
|
a(null);
|
|
1164
1159
|
return;
|
|
1165
1160
|
}
|
|
1166
|
-
|
|
1161
|
+
T(!0), P(null);
|
|
1167
1162
|
try {
|
|
1168
|
-
const
|
|
1169
|
-
a(
|
|
1170
|
-
} catch (
|
|
1171
|
-
const A =
|
|
1172
|
-
P(A), i.onError && i.onError(
|
|
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));
|
|
1173
1168
|
} finally {
|
|
1174
|
-
|
|
1169
|
+
T(!1);
|
|
1175
1170
|
}
|
|
1176
1171
|
};
|
|
1177
1172
|
K(() => {
|
|
1178
|
-
if (
|
|
1179
|
-
const
|
|
1173
|
+
if (h(), !i.refreshInterval) return;
|
|
1174
|
+
const p = i.refreshInterval || 10 * 60 * 1e3, A = setInterval(h, p);
|
|
1180
1175
|
return () => clearInterval(A);
|
|
1181
1176
|
}, [r == null ? void 0 : r.id, i.refreshInterval]);
|
|
1182
1177
|
const x = O(() => {
|
|
1183
|
-
const
|
|
1178
|
+
const p = (s == null ? void 0 : s.features) || [];
|
|
1184
1179
|
return {
|
|
1185
1180
|
subscription: s,
|
|
1186
|
-
features:
|
|
1181
|
+
features: p,
|
|
1187
1182
|
loading: v,
|
|
1188
|
-
error:
|
|
1183
|
+
error: M,
|
|
1189
1184
|
isFeatureEnabled: (b) => {
|
|
1190
|
-
const
|
|
1191
|
-
return
|
|
1185
|
+
const k = p.find((R) => R.key === b);
|
|
1186
|
+
return k ? k.type === "BOOLEAN" || k.type === "boolean" ? k.value === !0 : !!k.value : !1;
|
|
1192
1187
|
},
|
|
1193
|
-
getFeature: (b) =>
|
|
1194
|
-
getFeatureValue: (b,
|
|
1195
|
-
const R =
|
|
1196
|
-
return R ? R.value :
|
|
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;
|
|
1197
1192
|
},
|
|
1198
1193
|
hasAllowedPlan: (b) => !s || !s.isActive ? !1 : b.includes(s.planId),
|
|
1199
1194
|
refresh: async () => {
|
|
1200
|
-
await
|
|
1195
|
+
await h();
|
|
1201
1196
|
}
|
|
1202
1197
|
};
|
|
1203
|
-
}, [s, v,
|
|
1198
|
+
}, [s, v, M]);
|
|
1204
1199
|
return /* @__PURE__ */ n(we.Provider, { value: x, children: e });
|
|
1205
1200
|
}
|
|
1206
1201
|
function Fe() {
|
|
@@ -1303,16 +1298,16 @@ function it({
|
|
|
1303
1298
|
requiredPermissions: r,
|
|
1304
1299
|
requireAllPermissions: s = !1
|
|
1305
1300
|
}) {
|
|
1306
|
-
const { hasValidSession: a, sessionManager: v, hasPermission:
|
|
1301
|
+
const { hasValidSession: a, sessionManager: v, hasPermission: T, hasAnyPermission: M, hasAllPermissions: P } = se();
|
|
1307
1302
|
if (!a())
|
|
1308
1303
|
return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(de, {}) });
|
|
1309
|
-
const
|
|
1310
|
-
if (!
|
|
1304
|
+
const g = v.getUser();
|
|
1305
|
+
if (!g)
|
|
1311
1306
|
return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(de, {}) });
|
|
1312
|
-
if (t && !Ie(
|
|
1313
|
-
return /* @__PURE__ */ n(ue, { userType:
|
|
1314
|
-
if (r && r.length > 0 && !(s ? P(r) :
|
|
1315
|
-
const x = r.filter((
|
|
1307
|
+
if (t && !Ie(g.userType, t))
|
|
1308
|
+
return /* @__PURE__ */ n(ue, { userType: g.userType, minUserType: t });
|
|
1309
|
+
if (r && r.length > 0 && !(s ? P(r) : M(r))) {
|
|
1310
|
+
const x = r.filter((p) => !T(p)).map((p) => typeof p == "string" ? p : p.name);
|
|
1316
1311
|
return /* @__PURE__ */ n(ue, { missingPermissions: x });
|
|
1317
1312
|
}
|
|
1318
1313
|
return /* @__PURE__ */ n(B, { children: i });
|
|
@@ -1420,19 +1415,19 @@ function ot({
|
|
|
1420
1415
|
requireAllPermissions: s = !1,
|
|
1421
1416
|
fallback: a
|
|
1422
1417
|
}) {
|
|
1423
|
-
const { hasValidSession: v, sessionManager:
|
|
1418
|
+
const { hasValidSession: v, sessionManager: T, hasPermission: M, hasAnyPermission: P, hasAllPermissions: g } = se(), h = me();
|
|
1424
1419
|
if (!v())
|
|
1425
1420
|
return a ? /* @__PURE__ */ n(B, { children: a }) : /* @__PURE__ */ u(B, { children: [
|
|
1426
1421
|
/* @__PURE__ */ n(He, { redirectPath: e }),
|
|
1427
|
-
/* @__PURE__ */ n(ae, { to: e, state: { from:
|
|
1422
|
+
/* @__PURE__ */ n(ae, { to: e, state: { from: h.pathname }, replace: !0 })
|
|
1428
1423
|
] });
|
|
1429
|
-
const x =
|
|
1424
|
+
const x = T.getUser();
|
|
1430
1425
|
if (!x)
|
|
1431
|
-
return /* @__PURE__ */ n(ae, { to: e, state: { from:
|
|
1426
|
+
return /* @__PURE__ */ n(ae, { to: e, state: { from: h.pathname }, replace: !0 });
|
|
1432
1427
|
if (t && !$e(x.userType, t))
|
|
1433
1428
|
return /* @__PURE__ */ n(he, { userType: x.userType, minUserType: t });
|
|
1434
|
-
if (r && r.length > 0 && !(s ?
|
|
1435
|
-
const A = r.filter((F) => !
|
|
1429
|
+
if (r && r.length > 0 && !(s ? g(r) : P(r))) {
|
|
1430
|
+
const A = r.filter((F) => !M(F)).map((F) => typeof F == "string" ? F : F.name);
|
|
1436
1431
|
return /* @__PURE__ */ n(he, { missingPermissions: A });
|
|
1437
1432
|
}
|
|
1438
1433
|
return /* @__PURE__ */ n(B, { children: i });
|
|
@@ -1460,8 +1455,8 @@ function at({
|
|
|
1460
1455
|
allowedPlans: t,
|
|
1461
1456
|
requiredFeature: r
|
|
1462
1457
|
}) {
|
|
1463
|
-
const { subscription: s, hasAllowedPlan: a, isFeatureEnabled: v, loading:
|
|
1464
|
-
return
|
|
1458
|
+
const { subscription: s, hasAllowedPlan: a, isFeatureEnabled: v, loading: T } = Fe();
|
|
1459
|
+
return T ? /* @__PURE__ */ n(
|
|
1465
1460
|
"div",
|
|
1466
1461
|
{
|
|
1467
1462
|
style: {
|
|
@@ -1681,13 +1676,13 @@ function ct({
|
|
|
1681
1676
|
onError: s,
|
|
1682
1677
|
onForgotPassword: a,
|
|
1683
1678
|
onSignupClick: v,
|
|
1684
|
-
showForgotPassword:
|
|
1685
|
-
showSignupLink:
|
|
1679
|
+
showForgotPassword: T = !0,
|
|
1680
|
+
showSignupLink: M = !0,
|
|
1686
1681
|
className: P
|
|
1687
1682
|
}) {
|
|
1688
|
-
const [
|
|
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 = () => {
|
|
1689
1684
|
const I = {};
|
|
1690
|
-
return
|
|
1685
|
+
return g.trim() || (I.email = !0), x.trim() || (I.password = !0), R(I), Object.keys(I).length === 0;
|
|
1691
1686
|
}, o = async (I) => {
|
|
1692
1687
|
if (I.preventDefault(), !!d()) {
|
|
1693
1688
|
if (!(E != null && E.id)) {
|
|
@@ -1696,7 +1691,7 @@ function ct({
|
|
|
1696
1691
|
}
|
|
1697
1692
|
C(!0), b("");
|
|
1698
1693
|
try {
|
|
1699
|
-
const N = await L(
|
|
1694
|
+
const N = await L(g, x, E.id);
|
|
1700
1695
|
r == null || r(N);
|
|
1701
1696
|
} catch (N) {
|
|
1702
1697
|
const _ = N.message || D.errorMessage;
|
|
@@ -1705,38 +1700,38 @@ function ct({
|
|
|
1705
1700
|
C(!1);
|
|
1706
1701
|
}
|
|
1707
1702
|
}
|
|
1708
|
-
},
|
|
1709
|
-
...
|
|
1710
|
-
...
|
|
1703
|
+
}, l = (I) => ({
|
|
1704
|
+
...c.input,
|
|
1705
|
+
...k[I] ? c.inputError : {}
|
|
1711
1706
|
}), W = () => ({
|
|
1712
|
-
...
|
|
1713
|
-
...
|
|
1714
|
-
...!
|
|
1707
|
+
...c.button,
|
|
1708
|
+
...f ? c.buttonLoading : {},
|
|
1709
|
+
...!g || !x || f ? c.buttonDisabled : {}
|
|
1715
1710
|
});
|
|
1716
|
-
return /* @__PURE__ */ u("div", { className: P, style:
|
|
1717
|
-
/* @__PURE__ */ n("h2", { style:
|
|
1718
|
-
/* @__PURE__ */ u("form", { onSubmit: o, style:
|
|
1719
|
-
/* @__PURE__ */ u("div", { style:
|
|
1720
|
-
/* @__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 }),
|
|
1721
1716
|
/* @__PURE__ */ n(
|
|
1722
1717
|
"input",
|
|
1723
1718
|
{
|
|
1724
1719
|
id: "email",
|
|
1725
1720
|
name: "email",
|
|
1726
1721
|
type: "email",
|
|
1727
|
-
value:
|
|
1722
|
+
value: g,
|
|
1728
1723
|
onChange: (I) => {
|
|
1729
|
-
|
|
1724
|
+
h(I.target.value), k.email && R((N) => ({ ...N, email: !1 }));
|
|
1730
1725
|
},
|
|
1731
1726
|
placeholder: D.emailPlaceholder,
|
|
1732
|
-
style:
|
|
1733
|
-
disabled:
|
|
1727
|
+
style: l("email"),
|
|
1728
|
+
disabled: f
|
|
1734
1729
|
}
|
|
1735
1730
|
)
|
|
1736
1731
|
] }),
|
|
1737
|
-
/* @__PURE__ */ u("div", { style:
|
|
1738
|
-
/* @__PURE__ */ n("label", { style:
|
|
1739
|
-
/* @__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: [
|
|
1740
1735
|
/* @__PURE__ */ n(
|
|
1741
1736
|
"input",
|
|
1742
1737
|
{
|
|
@@ -1745,15 +1740,15 @@ function ct({
|
|
|
1745
1740
|
type: A ? "text" : "password",
|
|
1746
1741
|
value: x,
|
|
1747
1742
|
onChange: (I) => {
|
|
1748
|
-
|
|
1743
|
+
p(I.target.value), k.password && R((N) => ({ ...N, password: !1 }));
|
|
1749
1744
|
},
|
|
1750
1745
|
placeholder: D.passwordPlaceholder,
|
|
1751
1746
|
style: {
|
|
1752
|
-
...
|
|
1747
|
+
...l("password"),
|
|
1753
1748
|
paddingRight: "2.5rem"
|
|
1754
1749
|
// Make room for the icon
|
|
1755
1750
|
},
|
|
1756
|
-
disabled:
|
|
1751
|
+
disabled: f
|
|
1757
1752
|
}
|
|
1758
1753
|
),
|
|
1759
1754
|
/* @__PURE__ */ n(
|
|
@@ -1761,26 +1756,26 @@ function ct({
|
|
|
1761
1756
|
{
|
|
1762
1757
|
type: "button",
|
|
1763
1758
|
onClick: () => F(!A),
|
|
1764
|
-
style:
|
|
1765
|
-
disabled:
|
|
1759
|
+
style: c.passwordToggle,
|
|
1760
|
+
disabled: f,
|
|
1766
1761
|
"aria-label": A ? "Hide password" : "Show password",
|
|
1767
1762
|
children: A ? w.hidePassword : w.showPassword
|
|
1768
1763
|
}
|
|
1769
1764
|
)
|
|
1770
1765
|
] })
|
|
1771
1766
|
] }),
|
|
1772
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !
|
|
1773
|
-
|
|
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 })
|
|
1774
1769
|
] }),
|
|
1775
|
-
(
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
/* @__PURE__ */ u("span", { style:
|
|
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: "•" }),
|
|
1773
|
+
M && /* @__PURE__ */ u("div", { children: [
|
|
1774
|
+
/* @__PURE__ */ u("span", { style: c.divider, children: [
|
|
1780
1775
|
D.signupText,
|
|
1781
1776
|
" "
|
|
1782
1777
|
] }),
|
|
1783
|
-
/* @__PURE__ */ n("a", { onClick: v, style:
|
|
1778
|
+
/* @__PURE__ */ n("a", { onClick: v, style: c.link, children: D.signupLink })
|
|
1784
1779
|
] })
|
|
1785
1780
|
] })
|
|
1786
1781
|
] });
|
|
@@ -1912,13 +1907,13 @@ function dt({
|
|
|
1912
1907
|
onError: s,
|
|
1913
1908
|
onLoginClick: a,
|
|
1914
1909
|
showLoginLink: v = !0,
|
|
1915
|
-
className:
|
|
1910
|
+
className: T
|
|
1916
1911
|
}) {
|
|
1917
|
-
const [
|
|
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 = () => {
|
|
1918
1913
|
const H = {};
|
|
1919
|
-
return
|
|
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;
|
|
1920
1915
|
}, W = async (H) => {
|
|
1921
|
-
if (H.preventDefault(), !!
|
|
1916
|
+
if (H.preventDefault(), !!l()) {
|
|
1922
1917
|
if (x !== A) {
|
|
1923
1918
|
R(d.passwordMismatchError), E({ confirmPassword: !0 });
|
|
1924
1919
|
return;
|
|
@@ -1930,7 +1925,7 @@ function dt({
|
|
|
1930
1925
|
b(!0), R("");
|
|
1931
1926
|
try {
|
|
1932
1927
|
let q;
|
|
1933
|
-
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);
|
|
1934
1929
|
} catch (q) {
|
|
1935
1930
|
const Y = q.message || d.errorMessage;
|
|
1936
1931
|
R(Y), s == null || s(Y);
|
|
@@ -1943,10 +1938,10 @@ function dt({
|
|
|
1943
1938
|
...L[H] ? o.inputError : {}
|
|
1944
1939
|
}), N = () => ({
|
|
1945
1940
|
...o.button,
|
|
1946
|
-
...
|
|
1947
|
-
...!
|
|
1948
|
-
}), _ =
|
|
1949
|
-
return /* @__PURE__ */ u("div", { className:
|
|
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: [
|
|
1950
1945
|
/* @__PURE__ */ n("h2", { style: o.title, children: d.title }),
|
|
1951
1946
|
/* @__PURE__ */ u("form", { onSubmit: W, style: o.form, children: [
|
|
1952
1947
|
/* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
|
|
@@ -1957,13 +1952,13 @@ function dt({
|
|
|
1957
1952
|
id: "name",
|
|
1958
1953
|
name: "name",
|
|
1959
1954
|
type: "text",
|
|
1960
|
-
value:
|
|
1955
|
+
value: M,
|
|
1961
1956
|
onChange: (H) => {
|
|
1962
1957
|
P(H.target.value), L.name && E((q) => ({ ...q, name: !1 }));
|
|
1963
1958
|
},
|
|
1964
1959
|
placeholder: d.namePlaceholder,
|
|
1965
1960
|
style: I("name"),
|
|
1966
|
-
disabled:
|
|
1961
|
+
disabled: y
|
|
1967
1962
|
}
|
|
1968
1963
|
)
|
|
1969
1964
|
] }),
|
|
@@ -1975,13 +1970,13 @@ function dt({
|
|
|
1975
1970
|
id: "email",
|
|
1976
1971
|
name: "email",
|
|
1977
1972
|
type: "email",
|
|
1978
|
-
value:
|
|
1973
|
+
value: g,
|
|
1979
1974
|
onChange: (H) => {
|
|
1980
|
-
|
|
1975
|
+
h(H.target.value), L.email && E((q) => ({ ...q, email: !1 }));
|
|
1981
1976
|
},
|
|
1982
1977
|
placeholder: d.emailPlaceholder,
|
|
1983
1978
|
style: I("email"),
|
|
1984
|
-
disabled:
|
|
1979
|
+
disabled: y
|
|
1985
1980
|
}
|
|
1986
1981
|
)
|
|
1987
1982
|
] }),
|
|
@@ -1995,11 +1990,11 @@ function dt({
|
|
|
1995
1990
|
type: "password",
|
|
1996
1991
|
value: x,
|
|
1997
1992
|
onChange: (H) => {
|
|
1998
|
-
|
|
1993
|
+
p(H.target.value), L.password && E((q) => ({ ...q, password: !1 }));
|
|
1999
1994
|
},
|
|
2000
1995
|
placeholder: d.passwordPlaceholder,
|
|
2001
1996
|
style: I("password"),
|
|
2002
|
-
disabled:
|
|
1997
|
+
disabled: y
|
|
2003
1998
|
}
|
|
2004
1999
|
)
|
|
2005
2000
|
] }),
|
|
@@ -2013,11 +2008,11 @@ function dt({
|
|
|
2013
2008
|
type: "password",
|
|
2014
2009
|
value: A,
|
|
2015
2010
|
onChange: (H) => {
|
|
2016
|
-
F(H.target.value), L.confirmPassword && E((q) => ({ ...q, confirmPassword: !1 })),
|
|
2011
|
+
F(H.target.value), L.confirmPassword && E((q) => ({ ...q, confirmPassword: !1 })), k === d.passwordMismatchError && R("");
|
|
2017
2012
|
},
|
|
2018
2013
|
placeholder: d.confirmPasswordPlaceholder,
|
|
2019
2014
|
style: I("confirmPassword"),
|
|
2020
|
-
disabled:
|
|
2015
|
+
disabled: y
|
|
2021
2016
|
}
|
|
2022
2017
|
)
|
|
2023
2018
|
] }),
|
|
@@ -2029,18 +2024,18 @@ function dt({
|
|
|
2029
2024
|
id: "tenantName",
|
|
2030
2025
|
name: "tenantName",
|
|
2031
2026
|
type: "text",
|
|
2032
|
-
value:
|
|
2027
|
+
value: f,
|
|
2033
2028
|
onChange: (H) => {
|
|
2034
2029
|
C(H.target.value), L.tenantName && E((q) => ({ ...q, tenantName: !1 }));
|
|
2035
2030
|
},
|
|
2036
2031
|
placeholder: d.tenantNamePlaceholder,
|
|
2037
2032
|
style: I("tenantName"),
|
|
2038
|
-
disabled:
|
|
2033
|
+
disabled: y
|
|
2039
2034
|
}
|
|
2040
2035
|
)
|
|
2041
2036
|
] }),
|
|
2042
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !_ ||
|
|
2043
|
-
|
|
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 })
|
|
2044
2039
|
] }),
|
|
2045
2040
|
v && /* @__PURE__ */ u("div", { style: o.linkContainer, children: [
|
|
2046
2041
|
/* @__PURE__ */ u("span", { style: o.divider, children: [
|
|
@@ -2173,67 +2168,67 @@ function ut({
|
|
|
2173
2168
|
onSuccess: s,
|
|
2174
2169
|
onError: a,
|
|
2175
2170
|
onBackToLogin: v,
|
|
2176
|
-
onModeChange:
|
|
2177
|
-
className:
|
|
2171
|
+
onModeChange: T,
|
|
2172
|
+
className: M
|
|
2178
2173
|
}) {
|
|
2179
|
-
const [P,
|
|
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 = () => {
|
|
2180
2175
|
const U = {};
|
|
2181
2176
|
return P.trim() || (U.email = !0), D(U), Object.keys(U).length === 0;
|
|
2182
2177
|
}, I = () => {
|
|
2183
2178
|
const U = {};
|
|
2184
|
-
return
|
|
2179
|
+
return h.trim() || (U.token = !0), p.trim() || (U.newPassword = !0), F.trim() || (U.confirmPassword = !0), D(U), Object.keys(U).length === 0;
|
|
2185
2180
|
}, N = async (U) => {
|
|
2186
2181
|
if (U.preventDefault(), !!W()) {
|
|
2187
2182
|
if (!(d != null && d.id)) {
|
|
2188
|
-
|
|
2183
|
+
k("Tenant not found");
|
|
2189
2184
|
return;
|
|
2190
2185
|
}
|
|
2191
|
-
|
|
2186
|
+
y(!0), k(""), L("");
|
|
2192
2187
|
try {
|
|
2193
|
-
await
|
|
2188
|
+
await c(P, d.id), L(o.successMessage), s == null || s();
|
|
2194
2189
|
} catch (z) {
|
|
2195
2190
|
const j = z.message || o.errorMessage;
|
|
2196
|
-
|
|
2191
|
+
k(j), a == null || a(j);
|
|
2197
2192
|
} finally {
|
|
2198
|
-
|
|
2193
|
+
y(!1);
|
|
2199
2194
|
}
|
|
2200
2195
|
}
|
|
2201
2196
|
}, _ = async (U) => {
|
|
2202
2197
|
if (U.preventDefault(), !!I()) {
|
|
2203
|
-
if (
|
|
2204
|
-
|
|
2198
|
+
if (p !== F) {
|
|
2199
|
+
k(o.passwordMismatchError), D({ confirmPassword: !0 });
|
|
2205
2200
|
return;
|
|
2206
2201
|
}
|
|
2207
|
-
|
|
2202
|
+
y(!0), k(""), L("");
|
|
2208
2203
|
try {
|
|
2209
|
-
await w(
|
|
2204
|
+
await w(h, p), L(o.resetSuccessMessage), s == null || s();
|
|
2210
2205
|
} catch (z) {
|
|
2211
2206
|
const j = z.message || o.errorMessage;
|
|
2212
|
-
|
|
2207
|
+
k(j), a == null || a(j);
|
|
2213
2208
|
} finally {
|
|
2214
|
-
|
|
2209
|
+
y(!1);
|
|
2215
2210
|
}
|
|
2216
2211
|
}
|
|
2217
2212
|
}, H = (U) => ({
|
|
2218
|
-
...
|
|
2219
|
-
...E[U] ?
|
|
2213
|
+
...l.input,
|
|
2214
|
+
...E[U] ? l.inputError : {}
|
|
2220
2215
|
}), q = () => ({
|
|
2221
|
-
...
|
|
2222
|
-
...C ?
|
|
2216
|
+
...l.button,
|
|
2217
|
+
...C ? l.buttonLoading : {}
|
|
2223
2218
|
});
|
|
2224
2219
|
if (t === "reset") {
|
|
2225
|
-
const U =
|
|
2226
|
-
return /* @__PURE__ */ u("div", { className:
|
|
2227
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2228
|
-
/* @__PURE__ */ n("p", { style:
|
|
2229
|
-
/* @__PURE__ */ u("form", { onSubmit: _, style:
|
|
2230
|
-
/* @__PURE__ */ u("div", { style:
|
|
2231
|
-
/* @__PURE__ */ n("label", { style:
|
|
2220
|
+
const U = h && p && F;
|
|
2221
|
+
return /* @__PURE__ */ u("div", { className: M, style: l.container, children: [
|
|
2222
|
+
/* @__PURE__ */ n("h2", { style: l.title, children: o.resetTitle }),
|
|
2223
|
+
/* @__PURE__ */ n("p", { style: l.subtitle, children: o.resetSubtitle }),
|
|
2224
|
+
/* @__PURE__ */ u("form", { onSubmit: _, style: l.form, children: [
|
|
2225
|
+
/* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
|
|
2226
|
+
/* @__PURE__ */ n("label", { style: l.label, children: o.tokenLabel }),
|
|
2232
2227
|
/* @__PURE__ */ n(
|
|
2233
2228
|
"input",
|
|
2234
2229
|
{
|
|
2235
2230
|
type: "text",
|
|
2236
|
-
value:
|
|
2231
|
+
value: h,
|
|
2237
2232
|
onChange: (z) => {
|
|
2238
2233
|
x(z.target.value), E.token && D((j) => ({ ...j, token: !1 }));
|
|
2239
2234
|
},
|
|
@@ -2243,13 +2238,13 @@ function ut({
|
|
|
2243
2238
|
}
|
|
2244
2239
|
)
|
|
2245
2240
|
] }),
|
|
2246
|
-
/* @__PURE__ */ u("div", { style:
|
|
2247
|
-
/* @__PURE__ */ n("label", { style:
|
|
2241
|
+
/* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
|
|
2242
|
+
/* @__PURE__ */ n("label", { style: l.label, children: o.newPasswordLabel }),
|
|
2248
2243
|
/* @__PURE__ */ n(
|
|
2249
2244
|
"input",
|
|
2250
2245
|
{
|
|
2251
2246
|
type: "password",
|
|
2252
|
-
value:
|
|
2247
|
+
value: p,
|
|
2253
2248
|
onChange: (z) => {
|
|
2254
2249
|
A(z.target.value), E.newPassword && D((j) => ({ ...j, newPassword: !1 }));
|
|
2255
2250
|
},
|
|
@@ -2259,15 +2254,15 @@ function ut({
|
|
|
2259
2254
|
}
|
|
2260
2255
|
)
|
|
2261
2256
|
] }),
|
|
2262
|
-
/* @__PURE__ */ u("div", { style:
|
|
2263
|
-
/* @__PURE__ */ n("label", { style:
|
|
2257
|
+
/* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
|
|
2258
|
+
/* @__PURE__ */ n("label", { style: l.label, children: o.confirmPasswordLabel }),
|
|
2264
2259
|
/* @__PURE__ */ n(
|
|
2265
2260
|
"input",
|
|
2266
2261
|
{
|
|
2267
2262
|
type: "password",
|
|
2268
2263
|
value: F,
|
|
2269
2264
|
onChange: (z) => {
|
|
2270
|
-
|
|
2265
|
+
f(z.target.value), E.confirmPassword && D((j) => ({ ...j, confirmPassword: !1 })), b === o.passwordMismatchError && k("");
|
|
2271
2266
|
},
|
|
2272
2267
|
placeholder: o.confirmPasswordPlaceholder,
|
|
2273
2268
|
style: H("confirmPassword"),
|
|
@@ -2282,37 +2277,37 @@ function ut({
|
|
|
2282
2277
|
disabled: !U || C,
|
|
2283
2278
|
style: {
|
|
2284
2279
|
...q(),
|
|
2285
|
-
...!U || C ?
|
|
2280
|
+
...!U || C ? l.buttonDisabled : {}
|
|
2286
2281
|
},
|
|
2287
2282
|
children: C ? o.resetLoadingText : o.resetSubmitButton
|
|
2288
2283
|
}
|
|
2289
2284
|
),
|
|
2290
|
-
b && /* @__PURE__ */ n("div", { style:
|
|
2291
|
-
R && /* @__PURE__ */ n("div", { style:
|
|
2285
|
+
b && /* @__PURE__ */ n("div", { style: l.errorText, children: b }),
|
|
2286
|
+
R && /* @__PURE__ */ n("div", { style: l.successText, children: R })
|
|
2292
2287
|
] }),
|
|
2293
|
-
/* @__PURE__ */ u("div", { style:
|
|
2294
|
-
/* @__PURE__ */ n("a", { onClick: v, style:
|
|
2295
|
-
|
|
2288
|
+
/* @__PURE__ */ u("div", { style: l.linkContainer, children: [
|
|
2289
|
+
/* @__PURE__ */ n("a", { onClick: v, style: l.link, children: o.backToLoginLink }),
|
|
2290
|
+
T && /* @__PURE__ */ u(B, { children: [
|
|
2296
2291
|
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
2297
|
-
/* @__PURE__ */ n("a", { onClick: () =>
|
|
2292
|
+
/* @__PURE__ */ n("a", { onClick: () => T("request"), style: l.link, children: "Request New Link" })
|
|
2298
2293
|
] })
|
|
2299
2294
|
] })
|
|
2300
2295
|
] });
|
|
2301
2296
|
}
|
|
2302
2297
|
const Y = P;
|
|
2303
|
-
return /* @__PURE__ */ u("div", { className:
|
|
2304
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2305
|
-
/* @__PURE__ */ n("p", { style:
|
|
2306
|
-
/* @__PURE__ */ u("form", { onSubmit: N, style:
|
|
2307
|
-
/* @__PURE__ */ u("div", { style:
|
|
2308
|
-
/* @__PURE__ */ n("label", { style:
|
|
2298
|
+
return /* @__PURE__ */ u("div", { className: M, style: l.container, children: [
|
|
2299
|
+
/* @__PURE__ */ n("h2", { style: l.title, children: o.title }),
|
|
2300
|
+
/* @__PURE__ */ n("p", { style: l.subtitle, children: o.subtitle }),
|
|
2301
|
+
/* @__PURE__ */ u("form", { onSubmit: N, style: l.form, children: [
|
|
2302
|
+
/* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
|
|
2303
|
+
/* @__PURE__ */ n("label", { style: l.label, children: o.emailLabel }),
|
|
2309
2304
|
/* @__PURE__ */ n(
|
|
2310
2305
|
"input",
|
|
2311
2306
|
{
|
|
2312
2307
|
type: "email",
|
|
2313
2308
|
value: P,
|
|
2314
2309
|
onChange: (U) => {
|
|
2315
|
-
|
|
2310
|
+
g(U.target.value), E.email && D((z) => ({ ...z, email: !1 }));
|
|
2316
2311
|
},
|
|
2317
2312
|
placeholder: o.emailPlaceholder,
|
|
2318
2313
|
style: H("email"),
|
|
@@ -2327,19 +2322,19 @@ function ut({
|
|
|
2327
2322
|
disabled: !Y || C,
|
|
2328
2323
|
style: {
|
|
2329
2324
|
...q(),
|
|
2330
|
-
...!Y || C ?
|
|
2325
|
+
...!Y || C ? l.buttonDisabled : {}
|
|
2331
2326
|
},
|
|
2332
2327
|
children: C ? o.loadingText : o.submitButton
|
|
2333
2328
|
}
|
|
2334
2329
|
),
|
|
2335
|
-
b && /* @__PURE__ */ n("div", { style:
|
|
2336
|
-
R && /* @__PURE__ */ n("div", { style:
|
|
2330
|
+
b && /* @__PURE__ */ n("div", { style: l.errorText, children: b }),
|
|
2331
|
+
R && /* @__PURE__ */ n("div", { style: l.successText, children: R })
|
|
2337
2332
|
] }),
|
|
2338
|
-
/* @__PURE__ */ u("div", { style:
|
|
2339
|
-
/* @__PURE__ */ n("a", { onClick: v, style:
|
|
2340
|
-
|
|
2333
|
+
/* @__PURE__ */ u("div", { style: l.linkContainer, children: [
|
|
2334
|
+
/* @__PURE__ */ n("a", { onClick: v, style: l.link, children: o.backToLoginLink }),
|
|
2335
|
+
T && /* @__PURE__ */ u(B, { children: [
|
|
2341
2336
|
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
2342
|
-
/* @__PURE__ */ n("a", { onClick: () =>
|
|
2337
|
+
/* @__PURE__ */ n("a", { onClick: () => T("reset"), style: l.link, children: "I have a token" })
|
|
2343
2338
|
] })
|
|
2344
2339
|
] })
|
|
2345
2340
|
] });
|