@skylabs-digital/react-identity-access 2.15.0 → 2.16.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 +97 -88
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/providers/TenantProvider.d.ts +2 -1
- package/dist/providers/TenantProvider.d.ts.map +1 -1
- package/dist/utils/tenantDetection.d.ts +2 -1
- package/dist/utils/tenantDetection.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as s, Fragment as _, jsxs as d } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as ue, useMemo as Z, useState as
|
|
2
|
+
import { createContext as ue, useMemo as Z, useState as x, useCallback as re, useEffect as X, useContext as ie, useRef as Ve } from "react";
|
|
3
3
|
import { useLocation as be, Navigate as me, useNavigate as ut, useSearchParams as ht } from "react-router-dom";
|
|
4
4
|
class oe {
|
|
5
5
|
// SessionManager instance
|
|
@@ -137,7 +137,7 @@ function hn({ config: r, children: e }) {
|
|
|
137
137
|
};
|
|
138
138
|
},
|
|
139
139
|
[r.cache, r.appId]
|
|
140
|
-
), [n, i] =
|
|
140
|
+
), [n, i] = x(() => {
|
|
141
141
|
if (!t.enabled) return null;
|
|
142
142
|
try {
|
|
143
143
|
const g = localStorage.getItem(t.storageKey);
|
|
@@ -147,7 +147,7 @@ function hn({ config: r, children: e }) {
|
|
|
147
147
|
} catch {
|
|
148
148
|
return null;
|
|
149
149
|
}
|
|
150
|
-
}), [o, a] =
|
|
150
|
+
}), [o, a] = x(!n), [p, f] = x(null), w = Z(() => {
|
|
151
151
|
const g = () => {
|
|
152
152
|
u();
|
|
153
153
|
};
|
|
@@ -219,7 +219,7 @@ function je() {
|
|
|
219
219
|
return ie(Ie);
|
|
220
220
|
}
|
|
221
221
|
const gn = ye;
|
|
222
|
-
class
|
|
222
|
+
class Ae {
|
|
223
223
|
constructor(e = {}) {
|
|
224
224
|
this.refreshPromise = null, this.refreshQueue = [], e.tenantSlug !== void 0 ? this.storageKey = e.tenantSlug ? `auth_tokens_${e.tenantSlug}` : "auth_tokens" : 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 || this.createTokenStorage(this.storageKey);
|
|
225
225
|
}
|
|
@@ -643,8 +643,8 @@ function mt(r, e = "tenant", t) {
|
|
|
643
643
|
return i ? (t && t.setItem("tenant", i), i) : t ? t.getItem("tenant") : null;
|
|
644
644
|
}
|
|
645
645
|
function yt(r, e, t) {
|
|
646
|
-
const { tenantMode: n, baseDomain: i, selectorParam: o } = r;
|
|
647
|
-
return n === "subdomain" ? ft(e.hostname, i) : n === "selector" ? mt(e.search, o, t) : null;
|
|
646
|
+
const { tenantMode: n, baseDomain: i, selectorParam: o, fixedTenantSlug: a } = r;
|
|
647
|
+
return n === "fixed" ? a || null : n === "subdomain" ? ft(e.hostname, i) : n === "selector" ? mt(e.search, o, t) : null;
|
|
648
648
|
}
|
|
649
649
|
function wt(r, e, t) {
|
|
650
650
|
if (t)
|
|
@@ -699,14 +699,15 @@ function pn({ config: r, children: e }) {
|
|
|
699
699
|
{
|
|
700
700
|
tenantMode: r.tenantMode || "selector",
|
|
701
701
|
baseDomain: r.baseDomain,
|
|
702
|
-
selectorParam: r.selectorParam
|
|
702
|
+
selectorParam: r.selectorParam,
|
|
703
|
+
fixedTenantSlug: r.fixedTenantSlug
|
|
703
704
|
},
|
|
704
705
|
{
|
|
705
706
|
hostname: window.location.hostname,
|
|
706
707
|
search: window.location.search
|
|
707
708
|
},
|
|
708
709
|
window.localStorage
|
|
709
|
-
), [r.tenantMode, r.baseDomain, r.selectorParam]), [a, p] =
|
|
710
|
+
), [r.tenantMode, r.baseDomain, r.selectorParam, r.fixedTenantSlug]), [a, p] = x(() => o()), f = Z(
|
|
710
711
|
() => {
|
|
711
712
|
var c, H, F;
|
|
712
713
|
return {
|
|
@@ -717,7 +718,7 @@ function pn({ config: r, children: e }) {
|
|
|
717
718
|
};
|
|
718
719
|
},
|
|
719
720
|
[r.cache, a]
|
|
720
|
-
), [w, u] =
|
|
721
|
+
), [w, u] = x(() => {
|
|
721
722
|
if (r.initialTenant) return r.initialTenant;
|
|
722
723
|
if (!f.enabled || !a) return null;
|
|
723
724
|
try {
|
|
@@ -728,11 +729,12 @@ function pn({ config: r, children: e }) {
|
|
|
728
729
|
} catch {
|
|
729
730
|
return null;
|
|
730
731
|
}
|
|
731
|
-
}), [b, g] =
|
|
732
|
+
}), [b, g] = x(!w && !r.initialTenant), [T, I] = x(null), [N, M] = x(null), [P, h] = x(!1), [A, S] = x(null);
|
|
732
733
|
X(() => {
|
|
734
|
+
if (r.tenantMode === "fixed") return;
|
|
733
735
|
const c = o();
|
|
734
736
|
p(c);
|
|
735
|
-
}, [o]);
|
|
737
|
+
}, [o, r.tenantMode]);
|
|
736
738
|
const L = (n == null ? void 0 : n.settingsSchema) || null, E = re(
|
|
737
739
|
async (c, H = !1) => {
|
|
738
740
|
if (!(!H && f.enabled && w && w.domain === c))
|
|
@@ -836,6 +838,13 @@ function pn({ config: r, children: e }) {
|
|
|
836
838
|
const D = re(
|
|
837
839
|
(c, H) => {
|
|
838
840
|
const { mode: F = "reload", tokens: y, redirectPath: m } = H || {}, v = r.tenantMode || "selector";
|
|
841
|
+
if (v === "fixed") {
|
|
842
|
+
console.warn(
|
|
843
|
+
"[TenantProvider] switchTenant is a no-op in fixed mode. Tenant is always:",
|
|
844
|
+
r.fixedTenantSlug
|
|
845
|
+
), m && (window.location.href = m);
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
839
848
|
if (localStorage.setItem("tenant", c), v === "subdomain") {
|
|
840
849
|
const G = window.location.hostname, Y = wt(
|
|
841
850
|
c,
|
|
@@ -878,7 +887,7 @@ function pn({ config: r, children: e }) {
|
|
|
878
887
|
settings: N,
|
|
879
888
|
settingsSchema: L,
|
|
880
889
|
isSettingsLoading: P,
|
|
881
|
-
settingsError:
|
|
890
|
+
settingsError: A,
|
|
882
891
|
// Actions
|
|
883
892
|
refreshSettings: $,
|
|
884
893
|
switchTenant: D,
|
|
@@ -892,7 +901,7 @@ function pn({ config: r, children: e }) {
|
|
|
892
901
|
N,
|
|
893
902
|
L,
|
|
894
903
|
P,
|
|
895
|
-
|
|
904
|
+
A,
|
|
896
905
|
$,
|
|
897
906
|
D,
|
|
898
907
|
l
|
|
@@ -931,22 +940,22 @@ function ge() {
|
|
|
931
940
|
}
|
|
932
941
|
const Le = ue(null);
|
|
933
942
|
function yn({ config: r = {}, children: e }) {
|
|
934
|
-
const { appId: t, baseUrl: n } = ye(), { tenant: i, tenantSlug: o, switchTenant: a } = he(), [p, f] =
|
|
943
|
+
const { appId: t, baseUrl: n } = ye(), { tenant: i, tenantSlug: o, switchTenant: a } = he(), [p, f] = x(r.initialRoles || []), [w, u] = x(!r.initialRoles), [b, g] = x(null), [T, I] = x(!1), [N, M] = x(null), [P, h] = x(0), [A, S] = x(() => {
|
|
935
944
|
try {
|
|
936
945
|
const k = localStorage.getItem("userTenants");
|
|
937
946
|
return k ? JSON.parse(k) : [];
|
|
938
947
|
} catch {
|
|
939
948
|
return [];
|
|
940
949
|
}
|
|
941
|
-
}), [L, E] =
|
|
950
|
+
}), [L, E] = x(!1), C = Ve({ done: !1, urlTokens: null });
|
|
942
951
|
C.current.done || (C.current.done = !0, C.current.urlTokens = St(), C.current.urlTokens && console.log(
|
|
943
952
|
"[AuthProvider] SYNC: URL tokens found, will block isAuthReady until user loaded"
|
|
944
953
|
));
|
|
945
|
-
const [R, $] =
|
|
954
|
+
const [R, $] = x(() => {
|
|
946
955
|
const k = C.current.urlTokens !== null;
|
|
947
956
|
return console.log("[AuthProvider] SYNC: isLoadingAfterUrlTokens initial:", k), k;
|
|
948
957
|
}), l = Z(() => {
|
|
949
|
-
const k = new
|
|
958
|
+
const k = new Ae({
|
|
950
959
|
tenantSlug: o,
|
|
951
960
|
onRefreshFailed: r.onRefreshFailed,
|
|
952
961
|
baseUrl: n
|
|
@@ -994,7 +1003,7 @@ function yn({ config: r = {}, children: e }) {
|
|
|
994
1003
|
appId: t,
|
|
995
1004
|
tenantId: ee
|
|
996
1005
|
}), pe = W && W !== o;
|
|
997
|
-
if (pe && (ne = new
|
|
1006
|
+
if (pe && (ne = new Ae({
|
|
998
1007
|
tenantSlug: te,
|
|
999
1008
|
baseUrl: n
|
|
1000
1009
|
})), ne.setTokens({
|
|
@@ -1018,20 +1027,20 @@ function yn({ config: r = {}, children: e }) {
|
|
|
1018
1027
|
}
|
|
1019
1028
|
const ke = ((Ue = j.user) == null ? void 0 : Ue.tenantId) !== null;
|
|
1020
1029
|
E(ke);
|
|
1021
|
-
const
|
|
1030
|
+
const xe = {
|
|
1022
1031
|
accessToken: j.accessToken,
|
|
1023
1032
|
refreshToken: j.refreshToken,
|
|
1024
1033
|
expiresIn: j.expiresIn
|
|
1025
1034
|
};
|
|
1026
1035
|
if (pe && te)
|
|
1027
|
-
return a(te, { tokens:
|
|
1036
|
+
return a(te, { tokens: xe, redirectPath: J }), j;
|
|
1028
1037
|
if (J && J !== window.location.pathname)
|
|
1029
|
-
return a(te || o || "", { tokens:
|
|
1038
|
+
return a(te || o || "", { tokens: xe, redirectPath: J }), j;
|
|
1030
1039
|
if (!ke && j.tenants && j.tenants.length > 0) {
|
|
1031
1040
|
const we = B.autoSwitch !== !1 && r.autoSwitchSingleTenant !== !1;
|
|
1032
1041
|
if (j.tenants.length === 1 && we) {
|
|
1033
1042
|
const $e = j.tenants[0];
|
|
1034
|
-
return a($e.subdomain, { tokens:
|
|
1043
|
+
return a($e.subdomain, { tokens: xe, redirectPath: J }), j;
|
|
1035
1044
|
} else j.tenants.length > 1 && r.onTenantSelectionRequired && r.onTenantSelectionRequired(j.tenants);
|
|
1036
1045
|
}
|
|
1037
1046
|
return j;
|
|
@@ -1099,7 +1108,7 @@ function yn({ config: r = {}, children: e }) {
|
|
|
1099
1108
|
appId: t,
|
|
1100
1109
|
tenantId: J
|
|
1101
1110
|
}), j = W && W !== o;
|
|
1102
|
-
if (j && (te = new
|
|
1111
|
+
if (j && (te = new Ae({
|
|
1103
1112
|
tenantSlug: ee,
|
|
1104
1113
|
baseUrl: n
|
|
1105
1114
|
})), te.setTokens({
|
|
@@ -1199,7 +1208,7 @@ function yn({ config: r = {}, children: e }) {
|
|
|
1199
1208
|
getUserPermissionStrings: () => v || [],
|
|
1200
1209
|
refreshRoles: dt,
|
|
1201
1210
|
// RFC-004: Multi-tenant user membership
|
|
1202
|
-
userTenants:
|
|
1211
|
+
userTenants: A,
|
|
1203
1212
|
hasTenantContext: L,
|
|
1204
1213
|
switchToTenant: async (B, z) => {
|
|
1205
1214
|
const { redirectPath: Q } = z || {}, W = l.getTokens();
|
|
@@ -1215,7 +1224,7 @@ function yn({ config: r = {}, children: e }) {
|
|
|
1215
1224
|
// Keep the same refresh token
|
|
1216
1225
|
expiresIn: J.expiresIn
|
|
1217
1226
|
}), g(J.user), l.setUser(J.user), E(!0);
|
|
1218
|
-
const ee =
|
|
1227
|
+
const ee = A.find((te) => te.id === B);
|
|
1219
1228
|
ee && a(ee.subdomain, {
|
|
1220
1229
|
tokens: {
|
|
1221
1230
|
accessToken: J.accessToken,
|
|
@@ -1250,7 +1259,7 @@ function yn({ config: r = {}, children: e }) {
|
|
|
1250
1259
|
b,
|
|
1251
1260
|
T,
|
|
1252
1261
|
N,
|
|
1253
|
-
|
|
1262
|
+
A,
|
|
1254
1263
|
L,
|
|
1255
1264
|
D,
|
|
1256
1265
|
m,
|
|
@@ -1271,7 +1280,7 @@ function yn({ config: r = {}, children: e }) {
|
|
|
1271
1280
|
}
|
|
1272
1281
|
})();
|
|
1273
1282
|
}, [t, n, r.initialRoles]);
|
|
1274
|
-
const [O, V] =
|
|
1283
|
+
const [O, V] = x(!1);
|
|
1275
1284
|
return X(() => {
|
|
1276
1285
|
O || (V(!0), C.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), vt(), $(!0), console.log("[AuthProvider] EFFECT: Loading user data (blocking isAuthReady)..."), q.loadUserData().catch((k) => {
|
|
1277
1286
|
console.error("[AuthProvider] Failed to load user data:", k);
|
|
@@ -1385,7 +1394,7 @@ class Tt {
|
|
|
1385
1394
|
}
|
|
1386
1395
|
const Fe = ue(null);
|
|
1387
1396
|
function wn({ config: r = {}, children: e }) {
|
|
1388
|
-
const t = je(), n = Se(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (n == null ? void 0 : n.tenant) ?? null, [p, f] =
|
|
1397
|
+
const t = je(), n = Se(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (n == null ? void 0 : n.tenant) ?? null, [p, f] = x([]), [w, u] = x(!1), [b, g] = x(null), [T, I] = x(!1), N = Z(() => {
|
|
1389
1398
|
const h = new oe(i);
|
|
1390
1399
|
return new Tt(h);
|
|
1391
1400
|
}, [i]), M = async () => {
|
|
@@ -1398,8 +1407,8 @@ function wn({ config: r = {}, children: e }) {
|
|
|
1398
1407
|
const h = await N.getTenantFeatureFlags(a.id, o);
|
|
1399
1408
|
f(h);
|
|
1400
1409
|
} catch (h) {
|
|
1401
|
-
const
|
|
1402
|
-
g(
|
|
1410
|
+
const A = h instanceof Error ? h.message : "Failed to fetch feature flags";
|
|
1411
|
+
g(A), r.onError && r.onError(h instanceof Error ? h : new Error(A));
|
|
1403
1412
|
} finally {
|
|
1404
1413
|
u(!1);
|
|
1405
1414
|
}
|
|
@@ -1407,14 +1416,14 @@ function wn({ config: r = {}, children: e }) {
|
|
|
1407
1416
|
X(() => {
|
|
1408
1417
|
if (!i || !o) return;
|
|
1409
1418
|
M().finally(() => I(!0));
|
|
1410
|
-
const h = r.refreshInterval || 5 * 60 * 1e3,
|
|
1411
|
-
return () => clearInterval(
|
|
1419
|
+
const h = r.refreshInterval || 5 * 60 * 1e3, A = setInterval(M, h);
|
|
1420
|
+
return () => clearInterval(A);
|
|
1412
1421
|
}, [a == null ? void 0 : a.id, i, o, r.refreshInterval]);
|
|
1413
1422
|
const P = Z(() => {
|
|
1414
1423
|
const h = (C) => {
|
|
1415
1424
|
const R = p.find(($) => $.key === C);
|
|
1416
1425
|
return (R == null ? void 0 : R.value) === !0;
|
|
1417
|
-
},
|
|
1426
|
+
}, A = (C) => p.find((R) => R.key === C), S = (C) => {
|
|
1418
1427
|
const R = p.find(($) => $.key === C);
|
|
1419
1428
|
return R ? R.value ? "enabled" : "disabled" : "not_found";
|
|
1420
1429
|
}, L = async () => {
|
|
@@ -1426,7 +1435,7 @@ function wn({ config: r = {}, children: e }) {
|
|
|
1426
1435
|
error: b,
|
|
1427
1436
|
isReady: E,
|
|
1428
1437
|
isEnabled: h,
|
|
1429
|
-
getFlag:
|
|
1438
|
+
getFlag: A,
|
|
1430
1439
|
getFlagState: S,
|
|
1431
1440
|
refresh: L
|
|
1432
1441
|
};
|
|
@@ -1442,7 +1451,7 @@ function kt() {
|
|
|
1442
1451
|
function Ge() {
|
|
1443
1452
|
return ie(Fe);
|
|
1444
1453
|
}
|
|
1445
|
-
class
|
|
1454
|
+
class xt {
|
|
1446
1455
|
constructor(e, t) {
|
|
1447
1456
|
this.httpService = e, this.sessionManager = t;
|
|
1448
1457
|
}
|
|
@@ -1510,9 +1519,9 @@ class At {
|
|
|
1510
1519
|
}
|
|
1511
1520
|
const Ne = ue(void 0);
|
|
1512
1521
|
function bn({ config: r = {}, children: e }) {
|
|
1513
|
-
const t = je(), n = Se(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (n == null ? void 0 : n.tenant) ?? null, [a, p] =
|
|
1522
|
+
const t = je(), n = Se(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (n == null ? void 0 : n.tenant) ?? null, [a, p] = x(null), [f, w] = x(!1), [u, b] = x(null), [g, T] = x(!1), I = Z(() => {
|
|
1514
1523
|
const P = new oe(i);
|
|
1515
|
-
return new
|
|
1524
|
+
return new xt(P);
|
|
1516
1525
|
}, [i]), N = async () => {
|
|
1517
1526
|
if (!(o != null && o.id)) {
|
|
1518
1527
|
p(null);
|
|
@@ -1538,7 +1547,7 @@ function bn({ config: r = {}, children: e }) {
|
|
|
1538
1547
|
const P = (a == null ? void 0 : a.features) || [], h = (R) => {
|
|
1539
1548
|
const $ = P.find((l) => l.key === R);
|
|
1540
1549
|
return $ ? $.type === "BOOLEAN" || $.type === "boolean" ? $.value === !0 : !!$.value : !1;
|
|
1541
|
-
},
|
|
1550
|
+
}, A = (R) => P.find(($) => $.key === R), S = (R, $) => {
|
|
1542
1551
|
const l = P.find((D) => D.key === R);
|
|
1543
1552
|
return l ? l.value : $;
|
|
1544
1553
|
}, L = (R) => !a || !a.isActive ? !1 : R.includes(a.planId), E = async () => {
|
|
@@ -1551,7 +1560,7 @@ function bn({ config: r = {}, children: e }) {
|
|
|
1551
1560
|
error: u,
|
|
1552
1561
|
isReady: C,
|
|
1553
1562
|
isFeatureEnabled: h,
|
|
1554
|
-
getFeature:
|
|
1563
|
+
getFeature: A,
|
|
1555
1564
|
getFeatureValue: S,
|
|
1556
1565
|
hasAllowedPlan: L,
|
|
1557
1566
|
refresh: E
|
|
@@ -1559,7 +1568,7 @@ function bn({ config: r = {}, children: e }) {
|
|
|
1559
1568
|
}, [a, f, u, i, o == null ? void 0 : o.id, g]);
|
|
1560
1569
|
return /* @__PURE__ */ s(Ne.Provider, { value: M, children: e });
|
|
1561
1570
|
}
|
|
1562
|
-
function
|
|
1571
|
+
function At() {
|
|
1563
1572
|
const r = ie(Ne);
|
|
1564
1573
|
if (r === void 0)
|
|
1565
1574
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
@@ -1901,7 +1910,7 @@ const Lt = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1901
1910
|
)
|
|
1902
1911
|
}
|
|
1903
1912
|
);
|
|
1904
|
-
function
|
|
1913
|
+
function xn({ children: r, redirectTo: e = "/", fallback: t }) {
|
|
1905
1914
|
const { tenant: n, isLoading: i, error: o } = ge(), a = be();
|
|
1906
1915
|
return X(() => {
|
|
1907
1916
|
process.env.NODE_ENV === "development" && console.warn(
|
|
@@ -1949,7 +1958,7 @@ const Et = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1949
1958
|
)
|
|
1950
1959
|
}
|
|
1951
1960
|
);
|
|
1952
|
-
function
|
|
1961
|
+
function An({ children: r, redirectTo: e = "/dashboard", fallback: t }) {
|
|
1953
1962
|
const { tenant: n, isLoading: i, error: o } = ge(), a = be();
|
|
1954
1963
|
return X(() => {
|
|
1955
1964
|
process.env.NODE_ENV === "development" && console.warn(
|
|
@@ -1997,10 +2006,10 @@ const ae = ({
|
|
|
1997
2006
|
loadingFallback: u,
|
|
1998
2007
|
accessDeniedFallback: b
|
|
1999
2008
|
}) => {
|
|
2000
|
-
const g = be(), { isAuthenticated: T, isAuthInitializing: I, currentUser: N, userPermissions: M } = le(), { tenant: P, isTenantLoading: h } = he(),
|
|
2009
|
+
const g = be(), { isAuthenticated: T, isAuthInitializing: I, currentUser: N, userPermissions: M } = le(), { tenant: P, isTenantLoading: h } = he(), A = Pt(), S = Z(() => {
|
|
2001
2010
|
if (e)
|
|
2002
|
-
return
|
|
2003
|
-
}, [e,
|
|
2011
|
+
return A.presets[e];
|
|
2012
|
+
}, [e, A.presets]), L = Z(
|
|
2004
2013
|
() => ({
|
|
2005
2014
|
tenant: t ?? (S == null ? void 0 : S.tenant),
|
|
2006
2015
|
auth: n ?? (S == null ? void 0 : S.auth),
|
|
@@ -2025,7 +2034,7 @@ const ae = ({
|
|
|
2025
2034
|
I,
|
|
2026
2035
|
h
|
|
2027
2036
|
]
|
|
2028
|
-
), C = Z(() => E.isLoading ? null : Nt(L, E), [L, E]), R = Z(() => C ? w || Dt(E,
|
|
2037
|
+
), C = Z(() => E.isLoading ? null : Nt(L, E), [L, E]), R = Z(() => C ? w || Dt(E, A.zoneRoots) : null, [C, w, E, A.zoneRoots]), $ = Z(() => !C || !R ? null : {
|
|
2029
2038
|
type: C,
|
|
2030
2039
|
required: {
|
|
2031
2040
|
tenant: L.tenant,
|
|
@@ -2042,27 +2051,27 @@ const ae = ({
|
|
|
2042
2051
|
redirectTo: R
|
|
2043
2052
|
}, [C, R, L, E]);
|
|
2044
2053
|
if (X(() => {
|
|
2045
|
-
$ && (f ? f($) :
|
|
2046
|
-
}, [$, f,
|
|
2047
|
-
$ && p && Ut(p, g.pathname + g.search,
|
|
2054
|
+
$ && (f ? f($) : A.onAccessDenied && A.onAccessDenied($));
|
|
2055
|
+
}, [$, f, A]), X(() => {
|
|
2056
|
+
$ && p && Ut(p, g.pathname + g.search, A.returnToStorage);
|
|
2048
2057
|
}, [
|
|
2049
2058
|
$,
|
|
2050
2059
|
p,
|
|
2051
2060
|
g.pathname,
|
|
2052
2061
|
g.search,
|
|
2053
|
-
|
|
2062
|
+
A.returnToStorage
|
|
2054
2063
|
]), E.isLoading)
|
|
2055
|
-
return /* @__PURE__ */ s(_, { children: u ??
|
|
2064
|
+
return /* @__PURE__ */ s(_, { children: u ?? A.loadingFallback ?? null });
|
|
2056
2065
|
if ($ && R) {
|
|
2057
|
-
const l = b ??
|
|
2066
|
+
const l = b ?? A.accessDeniedFallback;
|
|
2058
2067
|
if (l)
|
|
2059
2068
|
return /* @__PURE__ */ s(_, { children: l });
|
|
2060
2069
|
const D = Ct(
|
|
2061
2070
|
R,
|
|
2062
2071
|
p,
|
|
2063
2072
|
g.pathname + g.search,
|
|
2064
|
-
|
|
2065
|
-
|
|
2073
|
+
A.returnToParam,
|
|
2074
|
+
A.returnToStorage
|
|
2066
2075
|
);
|
|
2067
2076
|
return /* @__PURE__ */ s(me, { to: D, replace: !0 });
|
|
2068
2077
|
}
|
|
@@ -2090,7 +2099,7 @@ function Un({
|
|
|
2090
2099
|
allowedPlans: t,
|
|
2091
2100
|
requiredFeature: n
|
|
2092
2101
|
}) {
|
|
2093
|
-
const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: p } =
|
|
2102
|
+
const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: p } = At();
|
|
2094
2103
|
return p ? /* @__PURE__ */ s(
|
|
2095
2104
|
"div",
|
|
2096
2105
|
{
|
|
@@ -2319,7 +2328,7 @@ function Hn({
|
|
|
2319
2328
|
showMagicLinkOption: u = !0,
|
|
2320
2329
|
className: b
|
|
2321
2330
|
}) {
|
|
2322
|
-
const [g, T] =
|
|
2331
|
+
const [g, T] = x(""), [I, N] = x(""), [M, P] = x(!1), [h, A] = x(!1), [S, L] = x(""), [E, C] = x({}), { login: R } = le(), { tenant: $ } = ge(), l = { ...zt, ...r }, D = { ..._t, ...e }, U = { ...Ot, ...t }, c = () => {
|
|
2323
2332
|
const m = {};
|
|
2324
2333
|
return g.trim() || (m.username = !0), I.trim() || (m.password = !0), C(m), Object.keys(m).length === 0;
|
|
2325
2334
|
}, H = async (m) => {
|
|
@@ -2328,7 +2337,7 @@ function Hn({
|
|
|
2328
2337
|
L("Tenant not found");
|
|
2329
2338
|
return;
|
|
2330
2339
|
}
|
|
2331
|
-
|
|
2340
|
+
A(!0), L("");
|
|
2332
2341
|
try {
|
|
2333
2342
|
const v = await R({
|
|
2334
2343
|
username: g,
|
|
@@ -2340,7 +2349,7 @@ function Hn({
|
|
|
2340
2349
|
const G = v.message || l.errorMessage;
|
|
2341
2350
|
L(G), i == null || i(G);
|
|
2342
2351
|
} finally {
|
|
2343
|
-
|
|
2352
|
+
A(!1);
|
|
2344
2353
|
}
|
|
2345
2354
|
}
|
|
2346
2355
|
}, F = (m) => ({
|
|
@@ -2568,7 +2577,7 @@ function Bn({
|
|
|
2568
2577
|
showMagicLinkOption: f = !0,
|
|
2569
2578
|
className: w
|
|
2570
2579
|
}) {
|
|
2571
|
-
const [u, b] =
|
|
2580
|
+
const [u, b] = x(""), [g, T] = x(""), [I, N] = x(""), [M, P] = x(""), [h, A] = x(""), [S, L] = x(""), [E, C] = x(""), [R, $] = x(!1), [l, D] = x(""), [U, c] = x({}), { signup: H, signupTenantAdmin: F } = le(), { tenant: y } = ge(), m = { ...Wt, ...r }, v = { ...Vt, ...e }, G = () => {
|
|
2572
2581
|
const k = {};
|
|
2573
2582
|
return u.trim() || (k.name = !0), !I.trim() && !M.trim() && (k.email = !0, k.phoneNumber = !0), h.trim() || (k.password = !0), S.trim() || (k.confirmPassword = !0), t === "tenant" && !E.trim() && (k.tenantName = !0), c(k), Object.keys(k).length === 0;
|
|
2574
2583
|
}, Y = async (k) => {
|
|
@@ -2709,7 +2718,7 @@ function Bn({
|
|
|
2709
2718
|
type: "password",
|
|
2710
2719
|
value: h,
|
|
2711
2720
|
onChange: (k) => {
|
|
2712
|
-
|
|
2721
|
+
A(k.target.value), U.password && c((K) => ({ ...K, password: !1 }));
|
|
2713
2722
|
},
|
|
2714
2723
|
placeholder: m.passwordPlaceholder,
|
|
2715
2724
|
style: q("password"),
|
|
@@ -2908,7 +2917,7 @@ function qn({
|
|
|
2908
2917
|
verifyToken: f,
|
|
2909
2918
|
frontendUrl: w
|
|
2910
2919
|
}) {
|
|
2911
|
-
const [u, b] =
|
|
2920
|
+
const [u, b] = x(""), [g, T] = x(""), [I, N] = x(""), [M, P] = x(!1), [h, A] = x(!1), [S, L] = x(""), [E, C] = x(""), [R, $] = x({}), [l, D] = x(!1), { sendMagicLink: U, verifyMagicLink: c } = le(), { tenant: H } = ge(), F = { ...jt, ...r }, y = { ...Gt, ...e };
|
|
2912
2921
|
X(() => {
|
|
2913
2922
|
f && m(f);
|
|
2914
2923
|
}, [f]);
|
|
@@ -2917,7 +2926,7 @@ function qn({
|
|
|
2917
2926
|
L("Missing tenant or email");
|
|
2918
2927
|
return;
|
|
2919
2928
|
}
|
|
2920
|
-
|
|
2929
|
+
A(!0), L("");
|
|
2921
2930
|
try {
|
|
2922
2931
|
const V = await c({
|
|
2923
2932
|
token: O,
|
|
@@ -2929,7 +2938,7 @@ function qn({
|
|
|
2929
2938
|
const k = V.message || "Failed to verify magic link";
|
|
2930
2939
|
L(k), n == null || n(k);
|
|
2931
2940
|
} finally {
|
|
2932
|
-
|
|
2941
|
+
A(!1);
|
|
2933
2942
|
}
|
|
2934
2943
|
}, v = () => {
|
|
2935
2944
|
const O = {};
|
|
@@ -3233,7 +3242,7 @@ function On({
|
|
|
3233
3242
|
tenantSlug: b,
|
|
3234
3243
|
autoRedirectDelay: g = 3e3
|
|
3235
3244
|
}) {
|
|
3236
|
-
const [T, I] =
|
|
3245
|
+
const [T, I] = x("verifying"), [N, M] = x(""), { verifyMagicLink: P } = le(), h = { ...Zt, ...r }, A = { ...Je, ...e }, S = { ...Qt, ...t }, L = () => {
|
|
3237
3246
|
if (typeof window > "u") return {};
|
|
3238
3247
|
const l = new URLSearchParams(window.location.search);
|
|
3239
3248
|
return {
|
|
@@ -3271,30 +3280,30 @@ function On({
|
|
|
3271
3280
|
const $ = () => {
|
|
3272
3281
|
switch (T) {
|
|
3273
3282
|
case "verifying":
|
|
3274
|
-
return /* @__PURE__ */ d("div", { style:
|
|
3283
|
+
return /* @__PURE__ */ d("div", { style: A.message, children: [
|
|
3275
3284
|
S.loading,
|
|
3276
3285
|
h.verifyingMessage
|
|
3277
3286
|
] });
|
|
3278
3287
|
case "success":
|
|
3279
3288
|
return /* @__PURE__ */ d(_, { children: [
|
|
3280
3289
|
S.success,
|
|
3281
|
-
/* @__PURE__ */ s("div", { style:
|
|
3290
|
+
/* @__PURE__ */ s("div", { style: A.successMessage, children: h.successMessage })
|
|
3282
3291
|
] });
|
|
3283
3292
|
case "redirecting":
|
|
3284
3293
|
return /* @__PURE__ */ d(_, { children: [
|
|
3285
3294
|
S.loading,
|
|
3286
|
-
/* @__PURE__ */ s("div", { style:
|
|
3295
|
+
/* @__PURE__ */ s("div", { style: A.message, children: h.redirectingMessage })
|
|
3287
3296
|
] });
|
|
3288
3297
|
case "error":
|
|
3289
3298
|
return /* @__PURE__ */ d(_, { children: [
|
|
3290
3299
|
S.error,
|
|
3291
|
-
/* @__PURE__ */ s("div", { style:
|
|
3292
|
-
/* @__PURE__ */ d("div", { style:
|
|
3300
|
+
/* @__PURE__ */ s("div", { style: A.errorMessage, children: N || h.errorMessage }),
|
|
3301
|
+
/* @__PURE__ */ d("div", { style: A.buttonContainer, children: [
|
|
3293
3302
|
/* @__PURE__ */ s(
|
|
3294
3303
|
"button",
|
|
3295
3304
|
{
|
|
3296
3305
|
onClick: C,
|
|
3297
|
-
style:
|
|
3306
|
+
style: A.retryButton,
|
|
3298
3307
|
onMouseOver: (l) => {
|
|
3299
3308
|
l.currentTarget.style.backgroundColor = "#2563eb";
|
|
3300
3309
|
},
|
|
@@ -3308,7 +3317,7 @@ function On({
|
|
|
3308
3317
|
"button",
|
|
3309
3318
|
{
|
|
3310
3319
|
onClick: R,
|
|
3311
|
-
style:
|
|
3320
|
+
style: A.backButton,
|
|
3312
3321
|
onMouseOver: (l) => {
|
|
3313
3322
|
l.currentTarget.style.backgroundColor = "#e5e7eb";
|
|
3314
3323
|
},
|
|
@@ -3324,14 +3333,14 @@ function On({
|
|
|
3324
3333
|
return null;
|
|
3325
3334
|
}
|
|
3326
3335
|
};
|
|
3327
|
-
return /* @__PURE__ */ d("div", { style:
|
|
3336
|
+
return /* @__PURE__ */ d("div", { style: A.container, className: p, children: [
|
|
3328
3337
|
/* @__PURE__ */ s("style", { children: `
|
|
3329
3338
|
@keyframes spin {
|
|
3330
3339
|
0% { transform: rotate(0deg); }
|
|
3331
3340
|
100% { transform: rotate(360deg); }
|
|
3332
3341
|
}
|
|
3333
3342
|
` }),
|
|
3334
|
-
/* @__PURE__ */ s("h1", { style:
|
|
3343
|
+
/* @__PURE__ */ s("h1", { style: A.title, children: h.title }),
|
|
3335
3344
|
$()
|
|
3336
3345
|
] });
|
|
3337
3346
|
}
|
|
@@ -3460,7 +3469,7 @@ function zn({
|
|
|
3460
3469
|
onModeChange: p,
|
|
3461
3470
|
className: f
|
|
3462
3471
|
}) {
|
|
3463
|
-
const [w, u] =
|
|
3472
|
+
const [w, u] = x(""), [b, g] = x(n), [T, I] = x(""), [N, M] = x(""), [P, h] = x(!1), [A, S] = x(""), [L, E] = x(""), [C, R] = x({}), { requestPasswordReset: $, confirmPasswordReset: l } = le(), { tenant: D } = ge(), U = { ...Xt, ...r }, c = { ...en, ...e }, H = () => {
|
|
3464
3473
|
const q = {};
|
|
3465
3474
|
return w.trim() || (q.email = !0), R(q), Object.keys(q).length === 0;
|
|
3466
3475
|
}, F = () => {
|
|
@@ -3551,7 +3560,7 @@ function zn({
|
|
|
3551
3560
|
type: "password",
|
|
3552
3561
|
value: N,
|
|
3553
3562
|
onChange: (O) => {
|
|
3554
|
-
M(O.target.value), C.confirmPassword && R((V) => ({ ...V, confirmPassword: !1 })),
|
|
3563
|
+
M(O.target.value), C.confirmPassword && R((V) => ({ ...V, confirmPassword: !1 })), A === U.passwordMismatchError && S("");
|
|
3555
3564
|
},
|
|
3556
3565
|
placeholder: U.confirmPasswordPlaceholder,
|
|
3557
3566
|
style: v("confirmPassword"),
|
|
@@ -3571,7 +3580,7 @@ function zn({
|
|
|
3571
3580
|
children: P ? U.resetLoadingText : U.resetSubmitButton
|
|
3572
3581
|
}
|
|
3573
3582
|
),
|
|
3574
|
-
|
|
3583
|
+
A && /* @__PURE__ */ s("div", { style: c.errorText, children: A }),
|
|
3575
3584
|
L && /* @__PURE__ */ s("div", { style: c.successText, children: L })
|
|
3576
3585
|
] }),
|
|
3577
3586
|
/* @__PURE__ */ d("div", { style: c.linkContainer, children: [
|
|
@@ -3616,7 +3625,7 @@ function zn({
|
|
|
3616
3625
|
children: P ? U.loadingText : U.submitButton
|
|
3617
3626
|
}
|
|
3618
3627
|
),
|
|
3619
|
-
|
|
3628
|
+
A && /* @__PURE__ */ s("div", { style: c.errorText, children: A }),
|
|
3620
3629
|
L && /* @__PURE__ */ s("div", { style: c.successText, children: L })
|
|
3621
3630
|
] }),
|
|
3622
3631
|
/* @__PURE__ */ d("div", { style: c.linkContainer, children: [
|
|
@@ -3722,8 +3731,8 @@ function Vn({
|
|
|
3722
3731
|
disabled: f = !1,
|
|
3723
3732
|
showCurrentTenant: w = !0
|
|
3724
3733
|
}) {
|
|
3725
|
-
var
|
|
3726
|
-
const u = Ee(), [b, g] =
|
|
3734
|
+
var A;
|
|
3735
|
+
const u = Ee(), [b, g] = x(!1), T = Ve(null), I = r ?? (u == null ? void 0 : u.userTenants) ?? [], N = e ?? ((A = u == null ? void 0 : u.currentUser) == null ? void 0 : A.tenantId) ?? null, M = async (S) => {
|
|
3727
3736
|
g(!1), t ? t(S) : u != null && u.switchToTenant && await u.switchToTenant(S);
|
|
3728
3737
|
};
|
|
3729
3738
|
X(() => {
|
|
@@ -4091,8 +4100,8 @@ function Jn(r = {}) {
|
|
|
4091
4100
|
(h) => {
|
|
4092
4101
|
switch (n) {
|
|
4093
4102
|
case "url": {
|
|
4094
|
-
const
|
|
4095
|
-
|
|
4103
|
+
const A = new URLSearchParams(o);
|
|
4104
|
+
A.set(t, h), a(A, { replace: !0 });
|
|
4096
4105
|
break;
|
|
4097
4106
|
}
|
|
4098
4107
|
case "session":
|
|
@@ -4106,8 +4115,8 @@ function Jn(r = {}) {
|
|
|
4106
4115
|
[n, o, t, a]
|
|
4107
4116
|
), M = re(
|
|
4108
4117
|
(h) => {
|
|
4109
|
-
const
|
|
4110
|
-
i(
|
|
4118
|
+
const A = u[h] || u.default;
|
|
4119
|
+
i(A);
|
|
4111
4120
|
},
|
|
4112
4121
|
[i, u]
|
|
4113
4122
|
), P = re(() => b ? p ? g === se.TENANT_ADMIN ? u.tenantAdmin : u.tenantUser : u.tenantGuest : p ? g === se.TENANT_ADMIN ? u.publicAdmin : u.publicUser : u.publicGuest, [b, p, g, u]);
|
|
@@ -4142,7 +4151,7 @@ export {
|
|
|
4142
4151
|
Mn as GuestZone,
|
|
4143
4152
|
Zn as HealthApiService,
|
|
4144
4153
|
oe as HttpService,
|
|
4145
|
-
|
|
4154
|
+
An as LandingRoute,
|
|
4146
4155
|
Hn as LoginForm,
|
|
4147
4156
|
qn as MagicLinkForm,
|
|
4148
4157
|
On as MagicLinkVerify,
|
|
@@ -4154,9 +4163,9 @@ export {
|
|
|
4154
4163
|
Rn as PublicZone,
|
|
4155
4164
|
Be as RoleApiService,
|
|
4156
4165
|
Sn as RoutingProvider,
|
|
4157
|
-
|
|
4166
|
+
Ae as SessionManager,
|
|
4158
4167
|
Bn as SignupForm,
|
|
4159
|
-
|
|
4168
|
+
xt as SubscriptionApiService,
|
|
4160
4169
|
Un as SubscriptionGuard,
|
|
4161
4170
|
Gn as SubscriptionPlanApiService,
|
|
4162
4171
|
bn as SubscriptionProvider,
|
|
@@ -4165,7 +4174,7 @@ export {
|
|
|
4165
4174
|
Cn as TenantGuestZone,
|
|
4166
4175
|
Dn as TenantOpenZone,
|
|
4167
4176
|
pn as TenantProvider,
|
|
4168
|
-
|
|
4177
|
+
xn as TenantRoute,
|
|
4169
4178
|
Vn as TenantSelector,
|
|
4170
4179
|
Pn as TenantZone,
|
|
4171
4180
|
pt as UserApiService,
|
|
@@ -4181,7 +4190,7 @@ export {
|
|
|
4181
4190
|
vn as useRouting,
|
|
4182
4191
|
Pt as useRoutingOptional,
|
|
4183
4192
|
mn as useSettings,
|
|
4184
|
-
|
|
4193
|
+
At as useSubscription,
|
|
4185
4194
|
he as useTenant,
|
|
4186
4195
|
ge as useTenantInfo,
|
|
4187
4196
|
Se as useTenantOptional,
|