@skylabs-digital/react-identity-access 2.18.0 → 2.19.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 +247 -230
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/services/SessionManager.d.ts +5 -0
- package/dist/services/SessionManager.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as s, Fragment as _, jsxs as d } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { useLocation as
|
|
2
|
+
import { createContext as fe, useMemo as J, useState as T, useCallback as se, useEffect as ee, useContext as ae, useRef as Qe } from "react";
|
|
3
|
+
import { useLocation as Te, Navigate as be, useNavigate as ft, useSearchParams as gt } from "react-router-dom";
|
|
4
4
|
class le {
|
|
5
5
|
constructor(e, t = 1e4) {
|
|
6
6
|
this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
|
|
@@ -109,9 +109,9 @@ class Oe {
|
|
|
109
109
|
})).data;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
const Le =
|
|
112
|
+
const Le = fe(null);
|
|
113
113
|
function mr({ config: n, children: e }) {
|
|
114
|
-
const t =
|
|
114
|
+
const t = J(
|
|
115
115
|
() => {
|
|
116
116
|
var p, x, R;
|
|
117
117
|
return {
|
|
@@ -132,7 +132,7 @@ function mr({ config: n, children: e }) {
|
|
|
132
132
|
} catch {
|
|
133
133
|
return null;
|
|
134
134
|
}
|
|
135
|
-
}), [o, a] = T(!r), [f, g] = T(null), w =
|
|
135
|
+
}), [o, a] = T(!r), [f, g] = T(null), w = J(() => {
|
|
136
136
|
const p = () => {
|
|
137
137
|
c();
|
|
138
138
|
};
|
|
@@ -153,14 +153,14 @@ function mr({ config: n, children: e }) {
|
|
|
153
153
|
const x = new le(n.baseUrl), F = await new Oe(x, {}).getPublicAppInfo(n.appId);
|
|
154
154
|
if (i(F), t.enabled)
|
|
155
155
|
try {
|
|
156
|
-
const
|
|
156
|
+
const E = {
|
|
157
157
|
data: F,
|
|
158
158
|
timestamp: Date.now(),
|
|
159
159
|
appId: n.appId
|
|
160
160
|
};
|
|
161
|
-
localStorage.setItem(t.storageKey, JSON.stringify(
|
|
162
|
-
} catch (
|
|
163
|
-
console.warn("Failed to cache app info:",
|
|
161
|
+
localStorage.setItem(t.storageKey, JSON.stringify(E));
|
|
162
|
+
} catch (E) {
|
|
163
|
+
console.warn("Failed to cache app info:", E);
|
|
164
164
|
}
|
|
165
165
|
} catch (x) {
|
|
166
166
|
const R = x instanceof Error ? x : new Error("Failed to load app information");
|
|
@@ -194,7 +194,7 @@ function mr({ config: n, children: e }) {
|
|
|
194
194
|
r ? I() : c();
|
|
195
195
|
}, []), /* @__PURE__ */ s(Le.Provider, { value: w, children: e });
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function Se() {
|
|
198
198
|
const n = ae(Le);
|
|
199
199
|
if (!n)
|
|
200
200
|
throw new Error("useApp must be used within an AppProvider");
|
|
@@ -203,7 +203,7 @@ function be() {
|
|
|
203
203
|
function Ze() {
|
|
204
204
|
return ae(Le);
|
|
205
205
|
}
|
|
206
|
-
const yr =
|
|
206
|
+
const yr = Se;
|
|
207
207
|
class ie extends Error {
|
|
208
208
|
constructor(e, t) {
|
|
209
209
|
const r = {
|
|
@@ -226,7 +226,7 @@ class yt extends Error {
|
|
|
226
226
|
), this.name = "TokenRefreshError", this.attempts = e, this.lastError = t;
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
|
-
class
|
|
229
|
+
class pe {
|
|
230
230
|
constructor(e = {}) {
|
|
231
231
|
this.refreshPromise = null, this.refreshQueue = [], this.proactiveTimerId = null, this.backgroundRetryTimerId = null, this.isDestroyed = !1, 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.onSessionExpired = e.onSessionExpired, this.baseUrl = e.baseUrl || "", this.proactiveRefreshMargin = e.proactiveRefreshMargin ?? 6e4, this.refreshQueueTimeout = e.refreshQueueTimeout ?? 1e4, this.maxRefreshRetries = e.maxRefreshRetries ?? 3, this.retryBackoffBase = e.retryBackoffBase ?? 1e3, this.tokenStorage = e.tokenStorage || this.createTokenStorage(this.storageKey), this.scheduleProactiveRefresh();
|
|
232
232
|
}
|
|
@@ -256,22 +256,39 @@ class Ie {
|
|
|
256
256
|
};
|
|
257
257
|
}
|
|
258
258
|
// --- Token CRUD ---
|
|
259
|
+
/**
|
|
260
|
+
* Extract the `exp` claim from a JWT and convert to milliseconds.
|
|
261
|
+
* Returns undefined if the token cannot be decoded or has no exp.
|
|
262
|
+
*/
|
|
263
|
+
static extractJwtExpiry(e) {
|
|
264
|
+
try {
|
|
265
|
+
const t = e.split(".");
|
|
266
|
+
if (t.length !== 3) return;
|
|
267
|
+
const r = JSON.parse(atob(t[1].replace(/-/g, "+").replace(/_/g, "/")));
|
|
268
|
+
return typeof r.exp == "number" ? r.exp * 1e3 : void 0;
|
|
269
|
+
} catch {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
259
273
|
setTokens(e) {
|
|
260
|
-
const t = {
|
|
274
|
+
const t = e.expiresAt || (e.expiresIn ? Date.now() + e.expiresIn * 1e3 : void 0) || pe.extractJwtExpiry(e.accessToken), r = {
|
|
261
275
|
...e,
|
|
262
|
-
expiresAt:
|
|
276
|
+
expiresAt: t
|
|
263
277
|
};
|
|
264
|
-
this.tokenStorage.set(
|
|
278
|
+
this.tokenStorage.set(r), this.scheduleProactiveRefresh();
|
|
265
279
|
}
|
|
266
280
|
getTokens() {
|
|
267
281
|
const { accessToken: e, refreshToken: t, expiresAt: r, expiresIn: i, tokenType: o } = this.tokenStorage.get() || {};
|
|
268
|
-
|
|
282
|
+
if (!e)
|
|
283
|
+
return null;
|
|
284
|
+
const a = r || pe.extractJwtExpiry(e);
|
|
285
|
+
return {
|
|
269
286
|
accessToken: e,
|
|
270
287
|
refreshToken: t,
|
|
271
|
-
expiresAt:
|
|
288
|
+
expiresAt: a,
|
|
272
289
|
expiresIn: i,
|
|
273
290
|
tokenType: o
|
|
274
|
-
}
|
|
291
|
+
};
|
|
275
292
|
}
|
|
276
293
|
clearTokens() {
|
|
277
294
|
this.tokenStorage.clear();
|
|
@@ -678,7 +695,7 @@ class bt {
|
|
|
678
695
|
});
|
|
679
696
|
}
|
|
680
697
|
}
|
|
681
|
-
class
|
|
698
|
+
class we {
|
|
682
699
|
constructor(e, t, r) {
|
|
683
700
|
this.httpService = e, this.appId = t, this.sessionManager = r;
|
|
684
701
|
}
|
|
@@ -827,9 +844,9 @@ function Pt() {
|
|
|
827
844
|
newUrl: n.toString()
|
|
828
845
|
}), window.history.replaceState({}, "", n.toString());
|
|
829
846
|
}
|
|
830
|
-
const Fe =
|
|
847
|
+
const Fe = fe(null);
|
|
831
848
|
function wr({ config: n, children: e }) {
|
|
832
|
-
const { baseUrl: t, appInfo: r, appId: i } =
|
|
849
|
+
const { baseUrl: t, appInfo: r, appId: i } = Se(), o = se(() => typeof window > "u" ? null : Tt(
|
|
833
850
|
{
|
|
834
851
|
tenantMode: n.tenantMode || "selector",
|
|
835
852
|
baseDomain: n.baseDomain,
|
|
@@ -841,7 +858,7 @@ function wr({ config: n, children: e }) {
|
|
|
841
858
|
search: window.location.search
|
|
842
859
|
},
|
|
843
860
|
window.localStorage
|
|
844
|
-
), [n.tenantMode, n.baseDomain, n.selectorParam, n.fixedTenantSlug]), [a, f] = T(() => o()), g =
|
|
861
|
+
), [n.tenantMode, n.baseDomain, n.selectorParam, n.fixedTenantSlug]), [a, f] = T(() => o()), g = J(
|
|
845
862
|
() => {
|
|
846
863
|
var h, C, S;
|
|
847
864
|
return {
|
|
@@ -863,18 +880,18 @@ function wr({ config: n, children: e }) {
|
|
|
863
880
|
} catch {
|
|
864
881
|
return null;
|
|
865
882
|
}
|
|
866
|
-
}), [I, p] = T(!w && !n.initialTenant), [x, R] = T(null), [F,
|
|
883
|
+
}), [I, p] = T(!w && !n.initialTenant), [x, R] = T(null), [F, E] = T(null), [A, u] = T(!1), [k, m] = T(null);
|
|
867
884
|
ee(() => {
|
|
868
885
|
if (n.tenantMode === "fixed") return;
|
|
869
886
|
const h = o();
|
|
870
887
|
f(h);
|
|
871
888
|
}, [o, n.tenantMode]);
|
|
872
|
-
const
|
|
889
|
+
const M = (r == null ? void 0 : r.settingsSchema) || null, L = se(
|
|
873
890
|
async (h, C = !1) => {
|
|
874
891
|
if (!(!C && g.enabled && w && w.domain === h))
|
|
875
892
|
try {
|
|
876
893
|
p(!0), R(null);
|
|
877
|
-
const S = new le(t), y = await new
|
|
894
|
+
const S = new le(t), y = await new we(S, i).getPublicTenantInfo(h);
|
|
878
895
|
if (c(y), g.enabled)
|
|
879
896
|
try {
|
|
880
897
|
const v = {
|
|
@@ -901,7 +918,7 @@ function wr({ config: n, children: e }) {
|
|
|
901
918
|
if (!h) return;
|
|
902
919
|
const C = JSON.parse(h);
|
|
903
920
|
if (Date.now() - C.timestamp > g.ttl * 0.5) {
|
|
904
|
-
const b = new le(t), v = await new
|
|
921
|
+
const b = new le(t), v = await new we(b, i).getPublicTenantInfo(a);
|
|
905
922
|
c(v);
|
|
906
923
|
const j = {
|
|
907
924
|
data: v,
|
|
@@ -917,11 +934,11 @@ function wr({ config: n, children: e }) {
|
|
|
917
934
|
if (w != null && w.id)
|
|
918
935
|
try {
|
|
919
936
|
u(!0), m(null);
|
|
920
|
-
const h = new le(t), S = await new
|
|
921
|
-
|
|
937
|
+
const h = new le(t), S = await new we(h, w.appId).getTenantSettings(w.id);
|
|
938
|
+
E(S);
|
|
922
939
|
} catch (h) {
|
|
923
940
|
const C = h instanceof Error ? h : new Error("Failed to load tenant settings");
|
|
924
|
-
m(C),
|
|
941
|
+
m(C), E(null);
|
|
925
942
|
} finally {
|
|
926
943
|
u(!1);
|
|
927
944
|
}
|
|
@@ -929,14 +946,14 @@ function wr({ config: n, children: e }) {
|
|
|
929
946
|
P();
|
|
930
947
|
}, [P]), l = se(
|
|
931
948
|
(h) => {
|
|
932
|
-
if (!
|
|
949
|
+
if (!M)
|
|
933
950
|
return { isValid: !0, errors: [] };
|
|
934
951
|
const C = [];
|
|
935
952
|
try {
|
|
936
|
-
return
|
|
953
|
+
return M.properties && Object.entries(M.properties).forEach(([S, b]) => {
|
|
937
954
|
var v;
|
|
938
955
|
const y = h[S];
|
|
939
|
-
if ((v =
|
|
956
|
+
if ((v = M.required) != null && v.includes(S) && y == null) {
|
|
940
957
|
C.push(`Field '${S}' is required`);
|
|
941
958
|
return;
|
|
942
959
|
}
|
|
@@ -962,12 +979,12 @@ function wr({ config: n, children: e }) {
|
|
|
962
979
|
};
|
|
963
980
|
}
|
|
964
981
|
},
|
|
965
|
-
[
|
|
982
|
+
[M]
|
|
966
983
|
);
|
|
967
984
|
ee(() => {
|
|
968
985
|
!n.initialTenant && a ? w ? D() : L(a) : !n.initialTenant && !a && (c(null), R(null), p(!1));
|
|
969
986
|
}, [n.initialTenant, a, w, L, D]), ee(() => {
|
|
970
|
-
w != null && w.id ? P() : (
|
|
987
|
+
w != null && w.id ? P() : (E(null), m(null), u(!1));
|
|
971
988
|
}, [w == null ? void 0 : w.id, P]);
|
|
972
989
|
const N = se(
|
|
973
990
|
(h, C) => {
|
|
@@ -1008,7 +1025,7 @@ function wr({ config: n, children: e }) {
|
|
|
1008
1025
|
}
|
|
1009
1026
|
},
|
|
1010
1027
|
[n.tenantMode, n.selectorParam, n.baseDomain, L]
|
|
1011
|
-
), $ =
|
|
1028
|
+
), $ = J(() => ({
|
|
1012
1029
|
// Tenant info
|
|
1013
1030
|
tenant: w,
|
|
1014
1031
|
tenantSlug: a,
|
|
@@ -1019,7 +1036,7 @@ function wr({ config: n, children: e }) {
|
|
|
1019
1036
|
},
|
|
1020
1037
|
// Settings
|
|
1021
1038
|
settings: F,
|
|
1022
|
-
settingsSchema:
|
|
1039
|
+
settingsSchema: M,
|
|
1023
1040
|
isSettingsLoading: A,
|
|
1024
1041
|
settingsError: k,
|
|
1025
1042
|
// Actions
|
|
@@ -1033,7 +1050,7 @@ function wr({ config: n, children: e }) {
|
|
|
1033
1050
|
I,
|
|
1034
1051
|
x,
|
|
1035
1052
|
F,
|
|
1036
|
-
|
|
1053
|
+
M,
|
|
1037
1054
|
A,
|
|
1038
1055
|
k,
|
|
1039
1056
|
U,
|
|
@@ -1042,18 +1059,18 @@ function wr({ config: n, children: e }) {
|
|
|
1042
1059
|
]);
|
|
1043
1060
|
return /* @__PURE__ */ s(Fe.Provider, { value: $, children: e });
|
|
1044
1061
|
}
|
|
1045
|
-
function
|
|
1062
|
+
function ge() {
|
|
1046
1063
|
const n = ae(Fe);
|
|
1047
1064
|
if (!n)
|
|
1048
1065
|
throw new Error("useTenant must be used within a TenantProvider");
|
|
1049
1066
|
return n;
|
|
1050
1067
|
}
|
|
1051
|
-
function
|
|
1068
|
+
function ke() {
|
|
1052
1069
|
return ae(Fe);
|
|
1053
1070
|
}
|
|
1054
|
-
const br =
|
|
1071
|
+
const br = ge;
|
|
1055
1072
|
function Sr() {
|
|
1056
|
-
const { settings: n, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: i } =
|
|
1073
|
+
const { settings: n, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: i } = ge();
|
|
1057
1074
|
return {
|
|
1058
1075
|
settings: n,
|
|
1059
1076
|
settingsSchema: e,
|
|
@@ -1062,8 +1079,8 @@ function Sr() {
|
|
|
1062
1079
|
validateSettings: i
|
|
1063
1080
|
};
|
|
1064
1081
|
}
|
|
1065
|
-
function
|
|
1066
|
-
const { tenant: n, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: i } =
|
|
1082
|
+
function me() {
|
|
1083
|
+
const { tenant: n, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: i } = ge();
|
|
1067
1084
|
return {
|
|
1068
1085
|
tenant: n,
|
|
1069
1086
|
tenantSlug: e,
|
|
@@ -1072,30 +1089,30 @@ function ge() {
|
|
|
1072
1089
|
retry: i
|
|
1073
1090
|
};
|
|
1074
1091
|
}
|
|
1075
|
-
const De =
|
|
1092
|
+
const De = fe(null);
|
|
1076
1093
|
function vr({ config: n = {}, children: e }) {
|
|
1077
|
-
const { appId: t, baseUrl: r } =
|
|
1094
|
+
const { appId: t, baseUrl: r } = Se(), { tenant: i, tenantSlug: o, switchTenant: a } = ge(), [f, g] = T(n.initialRoles || []), [w, c] = T(!n.initialRoles), [I, p] = T(null), [x, R] = T(!1), [F, E] = T(null), [A, u] = T(0), [k, m] = T(() => {
|
|
1078
1095
|
try {
|
|
1079
1096
|
const G = localStorage.getItem("userTenants");
|
|
1080
1097
|
return G ? JSON.parse(G) : [];
|
|
1081
1098
|
} catch {
|
|
1082
1099
|
return [];
|
|
1083
1100
|
}
|
|
1084
|
-
}), [
|
|
1101
|
+
}), [M, L] = T(!1), D = Qe({ done: !1, urlTokens: null });
|
|
1085
1102
|
D.current.done || (D.current.done = !0, D.current.urlTokens = At(), D.current.urlTokens && console.log(
|
|
1086
1103
|
"[AuthProvider] SYNC: URL tokens found, will block isAuthReady until user loaded"
|
|
1087
1104
|
));
|
|
1088
1105
|
const [P, U] = T(() => {
|
|
1089
1106
|
const G = D.current.urlTokens !== null;
|
|
1090
1107
|
return console.log("[AuthProvider] SYNC: isLoadingAfterUrlTokens initial:", G), G;
|
|
1091
|
-
}), l =
|
|
1092
|
-
const G = new
|
|
1108
|
+
}), l = J(() => {
|
|
1109
|
+
const G = new pe({
|
|
1093
1110
|
tenantSlug: o,
|
|
1094
1111
|
baseUrl: r,
|
|
1095
1112
|
refreshQueueTimeout: n.refreshQueueTimeout,
|
|
1096
1113
|
proactiveRefreshMargin: n.proactiveRefreshMargin,
|
|
1097
1114
|
onSessionExpired: (ue) => {
|
|
1098
|
-
p(null),
|
|
1115
|
+
p(null), E(null), m([]), L(!1);
|
|
1099
1116
|
try {
|
|
1100
1117
|
localStorage.removeItem("userTenants");
|
|
1101
1118
|
} catch {
|
|
@@ -1108,10 +1125,10 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1108
1125
|
refreshToken: D.current.urlTokens.refreshToken,
|
|
1109
1126
|
expiresIn: D.current.urlTokens.expiresIn
|
|
1110
1127
|
}), console.log("[AuthProvider] SYNC: Session valid:", G.hasValidSession())), G;
|
|
1111
|
-
}, [o, r, n.refreshQueueTimeout, n.proactiveRefreshMargin]), [N, $] = T(() => D.current.urlTokens ? !1 : l.hasValidSession()), h = D.current.done && !P && !N, C =
|
|
1128
|
+
}, [o, r, n.refreshQueueTimeout, n.proactiveRefreshMargin]), [N, $] = T(() => D.current.urlTokens ? !1 : l.hasValidSession()), h = D.current.done && !P && !N, C = J(() => {
|
|
1112
1129
|
const G = new le(r);
|
|
1113
1130
|
return G.setSessionManager(l), G;
|
|
1114
|
-
}, [r, l]), S =
|
|
1131
|
+
}, [r, l]), S = J(() => new wt(new le(r)), [r]), b = J(() => new bt(C, l), [C, l]), y = J(() => new ze(new le(r)), [r]), v = J(() => I || l.getUser(), [I, l]), j = J(() => v != null && v.roleId && f.find((G) => G.id === v.roleId) || null, [v, f]), Q = J(() => (j == null ? void 0 : j.permissions) || [], [j]), O = J(() => l.hasValidSession() && I !== null, [l, I]), q = 5 * 60 * 1e3, W = J(() => {
|
|
1115
1132
|
const G = async (H = !1) => {
|
|
1116
1133
|
try {
|
|
1117
1134
|
if (!l.hasValidSession())
|
|
@@ -1124,29 +1141,29 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1124
1141
|
console.warn("[AuthProvider] No userId available in token or storage");
|
|
1125
1142
|
return;
|
|
1126
1143
|
}
|
|
1127
|
-
R(!0),
|
|
1128
|
-
const
|
|
1129
|
-
p(
|
|
1144
|
+
R(!0), E(null);
|
|
1145
|
+
const K = await b.getUserById(V);
|
|
1146
|
+
p(K), l.setUser(K), u(Date.now());
|
|
1130
1147
|
} catch (z) {
|
|
1131
1148
|
const Y = z instanceof Error ? z : new Error("Failed to load user data");
|
|
1132
|
-
|
|
1149
|
+
E(Y), console.error("[AuthProvider] Failed to load user data:", Y);
|
|
1133
1150
|
} finally {
|
|
1134
1151
|
R(!1);
|
|
1135
1152
|
}
|
|
1136
1153
|
}, ue = async () => {
|
|
1137
1154
|
await G();
|
|
1138
|
-
},
|
|
1155
|
+
}, xe = async (H) => {
|
|
1139
1156
|
var Be;
|
|
1140
|
-
const { username: z, password: Y, tenantSlug: V, redirectPath:
|
|
1157
|
+
const { username: z, password: Y, tenantSlug: V, redirectPath: K } = H;
|
|
1141
1158
|
let te = i == null ? void 0 : i.id, re = o, ne = l;
|
|
1142
|
-
V && (te = (await new
|
|
1159
|
+
V && (te = (await new we(C, t).getPublicTenantInfo(V)).id, re = V);
|
|
1143
1160
|
const Z = await S.login({
|
|
1144
1161
|
username: z,
|
|
1145
1162
|
password: Y,
|
|
1146
1163
|
appId: t,
|
|
1147
1164
|
tenantId: te
|
|
1148
|
-
}),
|
|
1149
|
-
if (
|
|
1165
|
+
}), ye = V && V !== o;
|
|
1166
|
+
if (ye && (ne = new pe({
|
|
1150
1167
|
tenantSlug: re,
|
|
1151
1168
|
baseUrl: r
|
|
1152
1169
|
})), ne.setTokens({
|
|
@@ -1157,8 +1174,8 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1157
1174
|
ne.setUser(Z.user), p(Z.user);
|
|
1158
1175
|
try {
|
|
1159
1176
|
await G();
|
|
1160
|
-
} catch (
|
|
1161
|
-
console.warn("Failed to load complete user data after login:",
|
|
1177
|
+
} catch (ve) {
|
|
1178
|
+
console.warn("Failed to load complete user data after login:", ve);
|
|
1162
1179
|
}
|
|
1163
1180
|
}
|
|
1164
1181
|
if (Z.tenants && Z.tenants.length > 0) {
|
|
@@ -1168,52 +1185,52 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1168
1185
|
} catch {
|
|
1169
1186
|
}
|
|
1170
1187
|
}
|
|
1171
|
-
const
|
|
1172
|
-
L(
|
|
1173
|
-
const
|
|
1188
|
+
const Re = ((Be = Z.user) == null ? void 0 : Be.tenantId) !== null;
|
|
1189
|
+
L(Re);
|
|
1190
|
+
const Ie = {
|
|
1174
1191
|
accessToken: Z.accessToken,
|
|
1175
1192
|
refreshToken: Z.refreshToken,
|
|
1176
1193
|
expiresIn: Z.expiresIn
|
|
1177
1194
|
};
|
|
1178
|
-
if (
|
|
1179
|
-
return a(re, { tokens:
|
|
1180
|
-
if (
|
|
1181
|
-
return a(re || o || "", { tokens:
|
|
1182
|
-
if (!
|
|
1183
|
-
const
|
|
1184
|
-
if (Z.tenants.length === 1 &&
|
|
1195
|
+
if (ye && re)
|
|
1196
|
+
return a(re, { tokens: Ie, redirectPath: K }), Z;
|
|
1197
|
+
if (K && K !== window.location.pathname)
|
|
1198
|
+
return a(re || o || "", { tokens: Ie, redirectPath: K }), Z;
|
|
1199
|
+
if (!Re && Z.tenants && Z.tenants.length > 0) {
|
|
1200
|
+
const ve = H.autoSwitch !== !1 && n.autoSwitchSingleTenant !== !1;
|
|
1201
|
+
if (Z.tenants.length === 1 && ve) {
|
|
1185
1202
|
const qe = Z.tenants[0];
|
|
1186
|
-
return a(qe.subdomain, { tokens:
|
|
1203
|
+
return a(qe.subdomain, { tokens: Ie, redirectPath: K }), Z;
|
|
1187
1204
|
} else Z.tenants.length > 1 && n.onTenantSelectionRequired && n.onTenantSelectionRequired(Z.tenants);
|
|
1188
1205
|
}
|
|
1189
1206
|
return Z;
|
|
1190
|
-
},
|
|
1191
|
-
const { email: z, phoneNumber: Y, name: V, password:
|
|
1207
|
+
}, Ae = async (H) => {
|
|
1208
|
+
const { email: z, phoneNumber: Y, name: V, password: K, lastName: te, tenantId: re } = H;
|
|
1192
1209
|
if (!z && !Y)
|
|
1193
1210
|
throw new Error("Either email or phoneNumber is required");
|
|
1194
|
-
if (!V || !
|
|
1211
|
+
if (!V || !K)
|
|
1195
1212
|
throw new Error("Name and password are required");
|
|
1196
1213
|
const ne = re ?? (i == null ? void 0 : i.id);
|
|
1197
1214
|
return await S.signup({
|
|
1198
1215
|
email: z,
|
|
1199
1216
|
phoneNumber: Y,
|
|
1200
1217
|
name: V,
|
|
1201
|
-
password:
|
|
1218
|
+
password: K,
|
|
1202
1219
|
tenantId: ne,
|
|
1203
1220
|
lastName: te,
|
|
1204
1221
|
appId: t
|
|
1205
1222
|
});
|
|
1206
1223
|
}, tt = async (H) => {
|
|
1207
|
-
const { email: z, phoneNumber: Y, name: V, password:
|
|
1224
|
+
const { email: z, phoneNumber: Y, name: V, password: K, tenantName: te, lastName: re } = H;
|
|
1208
1225
|
if (!z && !Y)
|
|
1209
1226
|
throw new Error("Either email or phoneNumber is required");
|
|
1210
|
-
if (!V || !
|
|
1227
|
+
if (!V || !K || !te)
|
|
1211
1228
|
throw new Error("Name, password, and tenantName are required");
|
|
1212
1229
|
return await S.signupTenantAdmin({
|
|
1213
1230
|
email: z,
|
|
1214
1231
|
phoneNumber: Y,
|
|
1215
1232
|
name: V,
|
|
1216
|
-
password:
|
|
1233
|
+
password: K,
|
|
1217
1234
|
tenantName: te,
|
|
1218
1235
|
appId: t,
|
|
1219
1236
|
lastName: re
|
|
@@ -1230,7 +1247,7 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1230
1247
|
const { token: z, newPassword: Y } = H;
|
|
1231
1248
|
await S.confirmPasswordReset({ token: z, newPassword: Y });
|
|
1232
1249
|
}, it = async (H) => {
|
|
1233
|
-
const { email: z, frontendUrl: Y, name: V, lastName:
|
|
1250
|
+
const { email: z, frontendUrl: Y, name: V, lastName: K, tenantId: te } = H, re = te ?? (i == null ? void 0 : i.id);
|
|
1234
1251
|
if (!re)
|
|
1235
1252
|
throw new Error("tenantId is required for magic link authentication");
|
|
1236
1253
|
return await S.sendMagicLink({
|
|
@@ -1238,20 +1255,20 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1238
1255
|
tenantId: re,
|
|
1239
1256
|
frontendUrl: Y,
|
|
1240
1257
|
name: V,
|
|
1241
|
-
lastName:
|
|
1258
|
+
lastName: K,
|
|
1242
1259
|
appId: t
|
|
1243
1260
|
});
|
|
1244
1261
|
}, ot = async (H) => {
|
|
1245
1262
|
const { token: z, email: Y, tenantSlug: V } = H;
|
|
1246
|
-
let
|
|
1247
|
-
V && (
|
|
1263
|
+
let K = i == null ? void 0 : i.id, te = o, re = l;
|
|
1264
|
+
V && (K = (await new we(C, t).getPublicTenantInfo(V)).id, te = V);
|
|
1248
1265
|
const ne = await S.verifyMagicLink({
|
|
1249
1266
|
token: z,
|
|
1250
1267
|
email: Y,
|
|
1251
1268
|
appId: t,
|
|
1252
|
-
tenantId:
|
|
1269
|
+
tenantId: K
|
|
1253
1270
|
}), Z = V && V !== o;
|
|
1254
|
-
if (Z && (re = new
|
|
1271
|
+
if (Z && (re = new pe({
|
|
1255
1272
|
tenantSlug: te,
|
|
1256
1273
|
baseUrl: r
|
|
1257
1274
|
})), re.setTokens({
|
|
@@ -1262,8 +1279,8 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1262
1279
|
re.setUser(ne.user), p(ne.user);
|
|
1263
1280
|
try {
|
|
1264
1281
|
await G();
|
|
1265
|
-
} catch (
|
|
1266
|
-
console.warn("Failed to load complete user data after magic link login:",
|
|
1282
|
+
} catch (ye) {
|
|
1283
|
+
console.warn("Failed to load complete user data after magic link login:", ye);
|
|
1267
1284
|
}
|
|
1268
1285
|
}
|
|
1269
1286
|
return Z && te && te !== o && a(te, {
|
|
@@ -1286,7 +1303,7 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1286
1303
|
expiresIn: z.expiresIn
|
|
1287
1304
|
});
|
|
1288
1305
|
}, lt = () => {
|
|
1289
|
-
l.clearSession(), p(null),
|
|
1306
|
+
l.clearSession(), p(null), E(null), m([]), L(!1);
|
|
1290
1307
|
try {
|
|
1291
1308
|
localStorage.removeItem("userTenants");
|
|
1292
1309
|
} catch {
|
|
@@ -1294,7 +1311,7 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1294
1311
|
}, ct = (H) => {
|
|
1295
1312
|
l.setTokens(H);
|
|
1296
1313
|
}, dt = () => l.hasValidSession(), ut = () => {
|
|
1297
|
-
l.clearSession(), p(null),
|
|
1314
|
+
l.clearSession(), p(null), E(null);
|
|
1298
1315
|
}, ht = async () => {
|
|
1299
1316
|
if (t)
|
|
1300
1317
|
try {
|
|
@@ -1308,7 +1325,7 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1308
1325
|
}
|
|
1309
1326
|
}, pt = async () => {
|
|
1310
1327
|
await ht();
|
|
1311
|
-
},
|
|
1328
|
+
}, Pe = (H) => {
|
|
1312
1329
|
if (!Q || Q.length === 0)
|
|
1313
1330
|
return !1;
|
|
1314
1331
|
if (typeof H == "string")
|
|
@@ -1321,8 +1338,8 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1321
1338
|
isAuthenticated: O,
|
|
1322
1339
|
sessionManager: l,
|
|
1323
1340
|
authenticatedHttpService: C,
|
|
1324
|
-
login:
|
|
1325
|
-
signup:
|
|
1341
|
+
login: xe,
|
|
1342
|
+
signup: Ae,
|
|
1326
1343
|
signupTenantAdmin: tt,
|
|
1327
1344
|
sendMagicLink: it,
|
|
1328
1345
|
verifyMagicLink: ot,
|
|
@@ -1345,34 +1362,34 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1345
1362
|
userPermissions: Q,
|
|
1346
1363
|
availableRoles: f,
|
|
1347
1364
|
rolesLoading: w,
|
|
1348
|
-
hasPermission:
|
|
1349
|
-
hasAnyPermission: (H) => H.some((z) =>
|
|
1350
|
-
hasAllPermissions: (H) => H.every((z) =>
|
|
1365
|
+
hasPermission: Pe,
|
|
1366
|
+
hasAnyPermission: (H) => H.some((z) => Pe(z)),
|
|
1367
|
+
hasAllPermissions: (H) => H.every((z) => Pe(z)),
|
|
1351
1368
|
getUserPermissionStrings: () => Q || [],
|
|
1352
1369
|
refreshRoles: pt,
|
|
1353
1370
|
// RFC-004: Multi-tenant user membership
|
|
1354
1371
|
userTenants: k,
|
|
1355
|
-
hasTenantContext:
|
|
1372
|
+
hasTenantContext: M,
|
|
1356
1373
|
switchToTenant: async (H, z) => {
|
|
1357
1374
|
const { redirectPath: Y } = z || {}, V = l.getTokens();
|
|
1358
1375
|
if (!(V != null && V.refreshToken))
|
|
1359
1376
|
throw new Error("No refresh token available for tenant switch");
|
|
1360
|
-
const
|
|
1377
|
+
const K = await S.switchTenant({
|
|
1361
1378
|
refreshToken: V.refreshToken,
|
|
1362
1379
|
tenantId: H
|
|
1363
1380
|
});
|
|
1364
1381
|
l.setTokens({
|
|
1365
|
-
accessToken:
|
|
1382
|
+
accessToken: K.accessToken,
|
|
1366
1383
|
refreshToken: V.refreshToken,
|
|
1367
1384
|
// Keep the same refresh token
|
|
1368
|
-
expiresIn:
|
|
1369
|
-
}), p(
|
|
1385
|
+
expiresIn: K.expiresIn
|
|
1386
|
+
}), p(K.user), l.setUser(K.user), L(!0);
|
|
1370
1387
|
const te = k.find((re) => re.id === H);
|
|
1371
1388
|
te && a(te.subdomain, {
|
|
1372
1389
|
tokens: {
|
|
1373
|
-
accessToken:
|
|
1390
|
+
accessToken: K.accessToken,
|
|
1374
1391
|
refreshToken: V.refreshToken,
|
|
1375
|
-
expiresIn:
|
|
1392
|
+
expiresIn: K.expiresIn
|
|
1376
1393
|
},
|
|
1377
1394
|
redirectPath: Y
|
|
1378
1395
|
});
|
|
@@ -1403,7 +1420,7 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1403
1420
|
x,
|
|
1404
1421
|
F,
|
|
1405
1422
|
k,
|
|
1406
|
-
|
|
1423
|
+
M,
|
|
1407
1424
|
h,
|
|
1408
1425
|
j,
|
|
1409
1426
|
Q,
|
|
@@ -1414,8 +1431,8 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1414
1431
|
!n.initialRoles && t && (async () => {
|
|
1415
1432
|
try {
|
|
1416
1433
|
c(!0);
|
|
1417
|
-
const ue = new le(r),
|
|
1418
|
-
g(
|
|
1434
|
+
const ue = new le(r), xe = new ze(ue), { roles: Ae } = await xe.getRolesByApp(t);
|
|
1435
|
+
g(Ae);
|
|
1419
1436
|
} catch (ue) {
|
|
1420
1437
|
console.error("Failed to fetch roles:", ue);
|
|
1421
1438
|
} finally {
|
|
@@ -1537,12 +1554,12 @@ class Rt {
|
|
|
1537
1554
|
})).data;
|
|
1538
1555
|
}
|
|
1539
1556
|
}
|
|
1540
|
-
const Ce =
|
|
1557
|
+
const Ce = fe(null);
|
|
1541
1558
|
function Tr({ config: n = {}, children: e }) {
|
|
1542
|
-
const t = Ze(), r =
|
|
1559
|
+
const t = Ze(), r = ke(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (r == null ? void 0 : r.tenant) ?? null, [f, g] = T([]), [w, c] = T(!1), [I, p] = T(null), [x, R] = T(!1), F = J(() => {
|
|
1543
1560
|
const u = new le(i);
|
|
1544
1561
|
return new Rt(u);
|
|
1545
|
-
}, [i]),
|
|
1562
|
+
}, [i]), E = async () => {
|
|
1546
1563
|
if (!(a != null && a.id)) {
|
|
1547
1564
|
g([]);
|
|
1548
1565
|
return;
|
|
@@ -1560,19 +1577,19 @@ function Tr({ config: n = {}, children: e }) {
|
|
|
1560
1577
|
};
|
|
1561
1578
|
ee(() => {
|
|
1562
1579
|
if (!i || !o) return;
|
|
1563
|
-
|
|
1564
|
-
const u = n.refreshInterval || 5 * 60 * 1e3, k = setInterval(
|
|
1580
|
+
E().finally(() => R(!0));
|
|
1581
|
+
const u = n.refreshInterval || 5 * 60 * 1e3, k = setInterval(E, u);
|
|
1565
1582
|
return () => clearInterval(k);
|
|
1566
1583
|
}, [a == null ? void 0 : a.id, i, o, n.refreshInterval]);
|
|
1567
|
-
const A =
|
|
1584
|
+
const A = J(() => {
|
|
1568
1585
|
const u = (D) => {
|
|
1569
1586
|
const P = f.find((U) => U.key === D);
|
|
1570
1587
|
return (P == null ? void 0 : P.value) === !0;
|
|
1571
1588
|
}, k = (D) => f.find((P) => P.key === D), m = (D) => {
|
|
1572
1589
|
const P = f.find((U) => U.key === D);
|
|
1573
1590
|
return P ? P.value ? "enabled" : "disabled" : "not_found";
|
|
1574
|
-
},
|
|
1575
|
-
await
|
|
1591
|
+
}, M = async () => {
|
|
1592
|
+
await E();
|
|
1576
1593
|
}, L = !!(i && o) && (x || !(a != null && a.id));
|
|
1577
1594
|
return {
|
|
1578
1595
|
featureFlags: f,
|
|
@@ -1582,7 +1599,7 @@ function Tr({ config: n = {}, children: e }) {
|
|
|
1582
1599
|
isEnabled: u,
|
|
1583
1600
|
getFlag: k,
|
|
1584
1601
|
getFlagState: m,
|
|
1585
|
-
refresh:
|
|
1602
|
+
refresh: M
|
|
1586
1603
|
};
|
|
1587
1604
|
}, [f, w, I, i, o, a == null ? void 0 : a.id, x]);
|
|
1588
1605
|
return /* @__PURE__ */ s(Ce.Provider, { value: A, children: e });
|
|
@@ -1593,10 +1610,10 @@ function It() {
|
|
|
1593
1610
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1594
1611
|
return n;
|
|
1595
1612
|
}
|
|
1596
|
-
function
|
|
1613
|
+
function Je() {
|
|
1597
1614
|
return ae(Ce);
|
|
1598
1615
|
}
|
|
1599
|
-
class
|
|
1616
|
+
class Et {
|
|
1600
1617
|
constructor(e, t) {
|
|
1601
1618
|
this.httpService = e, this.sessionManager = t;
|
|
1602
1619
|
}
|
|
@@ -1662,11 +1679,11 @@ class Mt {
|
|
|
1662
1679
|
)).data;
|
|
1663
1680
|
}
|
|
1664
1681
|
}
|
|
1665
|
-
const Ue =
|
|
1682
|
+
const Ue = fe(void 0);
|
|
1666
1683
|
function kr({ config: n = {}, children: e }) {
|
|
1667
|
-
const t = Ze(), r =
|
|
1684
|
+
const t = Ze(), r = ke(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a, f] = T(null), [g, w] = T(!1), [c, I] = T(null), [p, x] = T(!1), R = J(() => {
|
|
1668
1685
|
const A = new le(i);
|
|
1669
|
-
return new
|
|
1686
|
+
return new Et(A);
|
|
1670
1687
|
}, [i]), F = async () => {
|
|
1671
1688
|
if (!(o != null && o.id)) {
|
|
1672
1689
|
f(null);
|
|
@@ -1688,14 +1705,14 @@ function kr({ config: n = {}, children: e }) {
|
|
|
1688
1705
|
const A = n.refreshInterval || 10 * 60 * 1e3, u = setInterval(F, A);
|
|
1689
1706
|
return () => clearInterval(u);
|
|
1690
1707
|
}, [o == null ? void 0 : o.id, i, n.refreshInterval]);
|
|
1691
|
-
const
|
|
1708
|
+
const E = J(() => {
|
|
1692
1709
|
const A = (a == null ? void 0 : a.features) || [], u = (P) => {
|
|
1693
1710
|
const U = A.find((l) => l.key === P);
|
|
1694
1711
|
return U ? U.type === "BOOLEAN" || U.type === "boolean" ? U.value === !0 : !!U.value : !1;
|
|
1695
1712
|
}, k = (P) => A.find((U) => U.key === P), m = (P, U) => {
|
|
1696
1713
|
const l = A.find((N) => N.key === P);
|
|
1697
1714
|
return l ? l.value : U;
|
|
1698
|
-
},
|
|
1715
|
+
}, M = (P) => !a || !a.isActive ? !1 : P.includes(a.planId), L = async () => {
|
|
1699
1716
|
await F();
|
|
1700
1717
|
}, D = !!i && (p || !(o != null && o.id));
|
|
1701
1718
|
return {
|
|
@@ -1707,19 +1724,19 @@ function kr({ config: n = {}, children: e }) {
|
|
|
1707
1724
|
isFeatureEnabled: u,
|
|
1708
1725
|
getFeature: k,
|
|
1709
1726
|
getFeatureValue: m,
|
|
1710
|
-
hasAllowedPlan:
|
|
1727
|
+
hasAllowedPlan: M,
|
|
1711
1728
|
refresh: L
|
|
1712
1729
|
};
|
|
1713
1730
|
}, [a, g, c, i, o == null ? void 0 : o.id, p]);
|
|
1714
|
-
return /* @__PURE__ */ s(Ue.Provider, { value:
|
|
1731
|
+
return /* @__PURE__ */ s(Ue.Provider, { value: E, children: e });
|
|
1715
1732
|
}
|
|
1716
|
-
function
|
|
1733
|
+
function Mt() {
|
|
1717
1734
|
const n = ae(Ue);
|
|
1718
1735
|
if (n === void 0)
|
|
1719
1736
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1720
1737
|
return n;
|
|
1721
1738
|
}
|
|
1722
|
-
function
|
|
1739
|
+
function Ke() {
|
|
1723
1740
|
return ae(Ue) ?? null;
|
|
1724
1741
|
}
|
|
1725
1742
|
var oe = /* @__PURE__ */ ((n) => (n.SUPERUSER = "SUPERUSER", n.TENANT_ADMIN = "TENANT_ADMIN", n.USER = "USER", n))(oe || {});
|
|
@@ -1748,9 +1765,9 @@ const $e = {
|
|
|
1748
1765
|
admin: { tenant: "required", auth: "required", userType: oe.TENANT_ADMIN },
|
|
1749
1766
|
// Fully open
|
|
1750
1767
|
open: { tenant: "optional", auth: "optional" }
|
|
1751
|
-
}, He =
|
|
1768
|
+
}, He = fe(null);
|
|
1752
1769
|
function xr({ config: n = {}, children: e }) {
|
|
1753
|
-
const t =
|
|
1770
|
+
const t = J(() => {
|
|
1754
1771
|
const r = {
|
|
1755
1772
|
...$e,
|
|
1756
1773
|
...n.zoneRoots
|
|
@@ -1991,7 +2008,7 @@ function Rr({
|
|
|
1991
2008
|
requireAllPermissions: i = !1,
|
|
1992
2009
|
fallback: o
|
|
1993
2010
|
}) {
|
|
1994
|
-
const { hasValidSession: a, sessionManager: f, hasPermission: g, hasAnyPermission: w, hasAllPermissions: c } = de(), I =
|
|
2011
|
+
const { hasValidSession: a, sessionManager: f, hasPermission: g, hasAnyPermission: w, hasAllPermissions: c } = de(), I = Te();
|
|
1995
2012
|
if (ee(() => {
|
|
1996
2013
|
process.env.NODE_ENV === "development" && console.warn(
|
|
1997
2014
|
"[react-identity-access] ProtectedRoute is deprecated. Use AuthenticatedZone or AdminZone from ZoneRoute instead."
|
|
@@ -1999,11 +2016,11 @@ function Rr({
|
|
|
1999
2016
|
}, []), !a())
|
|
2000
2017
|
return o ? /* @__PURE__ */ s(_, { children: o }) : /* @__PURE__ */ d(_, { children: [
|
|
2001
2018
|
/* @__PURE__ */ s(Dt, { redirectPath: e }),
|
|
2002
|
-
/* @__PURE__ */ s(
|
|
2019
|
+
/* @__PURE__ */ s(be, { to: e, state: { from: I.pathname }, replace: !0 })
|
|
2003
2020
|
] });
|
|
2004
2021
|
const p = f.getUser();
|
|
2005
2022
|
if (!p)
|
|
2006
|
-
return /* @__PURE__ */ s(
|
|
2023
|
+
return /* @__PURE__ */ s(be, { to: e, state: { from: I.pathname }, replace: !0 });
|
|
2007
2024
|
if (t && !Nt(p.userType, t))
|
|
2008
2025
|
return /* @__PURE__ */ s(
|
|
2009
2026
|
je,
|
|
@@ -2056,14 +2073,14 @@ const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2056
2073
|
}
|
|
2057
2074
|
);
|
|
2058
2075
|
function Ir({ children: n, redirectTo: e = "/", fallback: t }) {
|
|
2059
|
-
const { tenant: r, isLoading: i, error: o } =
|
|
2076
|
+
const { tenant: r, isLoading: i, error: o } = me(), a = Te();
|
|
2060
2077
|
return ee(() => {
|
|
2061
2078
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2062
2079
|
"[react-identity-access] TenantRoute is deprecated. Use TenantZone from ZoneRoute instead."
|
|
2063
2080
|
);
|
|
2064
2081
|
}, []), i || o ? null : r ? /* @__PURE__ */ s(_, { children: n }) : t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ d(_, { children: [
|
|
2065
2082
|
/* @__PURE__ */ s(Ct, { redirectPath: e }),
|
|
2066
|
-
/* @__PURE__ */ s(
|
|
2083
|
+
/* @__PURE__ */ s(be, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
2067
2084
|
] });
|
|
2068
2085
|
}
|
|
2069
2086
|
const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
@@ -2103,15 +2120,15 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2103
2120
|
)
|
|
2104
2121
|
}
|
|
2105
2122
|
);
|
|
2106
|
-
function
|
|
2107
|
-
const { tenant: r, isLoading: i, error: o } =
|
|
2123
|
+
function Er({ children: n, redirectTo: e = "/dashboard", fallback: t }) {
|
|
2124
|
+
const { tenant: r, isLoading: i, error: o } = me(), a = Te();
|
|
2108
2125
|
return ee(() => {
|
|
2109
2126
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2110
2127
|
"[react-identity-access] LandingRoute is deprecated. Use PublicZone from ZoneRoute instead."
|
|
2111
2128
|
);
|
|
2112
2129
|
}, []), i || o ? null : r ? t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ d(_, { children: [
|
|
2113
2130
|
/* @__PURE__ */ s(Ut, { redirectPath: e }),
|
|
2114
|
-
/* @__PURE__ */ s(
|
|
2131
|
+
/* @__PURE__ */ s(be, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
2115
2132
|
] }) : /* @__PURE__ */ s(_, { children: n });
|
|
2116
2133
|
}
|
|
2117
2134
|
function $t(n, e) {
|
|
@@ -2151,10 +2168,10 @@ const ce = ({
|
|
|
2151
2168
|
loadingFallback: c,
|
|
2152
2169
|
accessDeniedFallback: I
|
|
2153
2170
|
}) => {
|
|
2154
|
-
const p =
|
|
2171
|
+
const p = Te(), { isAuthenticated: x, isAuthInitializing: R, currentUser: F, userPermissions: E } = de(), { tenant: A, isTenantLoading: u } = ge(), k = Lt(), m = J(() => {
|
|
2155
2172
|
if (e)
|
|
2156
2173
|
return k.presets[e];
|
|
2157
|
-
}, [e, k.presets]),
|
|
2174
|
+
}, [e, k.presets]), M = J(
|
|
2158
2175
|
() => ({
|
|
2159
2176
|
tenant: t ?? (m == null ? void 0 : m.tenant),
|
|
2160
2177
|
auth: r ?? (m == null ? void 0 : m.auth),
|
|
@@ -2163,29 +2180,29 @@ const ce = ({
|
|
|
2163
2180
|
requireAllPermissions: a
|
|
2164
2181
|
}),
|
|
2165
2182
|
[t, r, i, o, m, a]
|
|
2166
|
-
), L =
|
|
2183
|
+
), L = J(
|
|
2167
2184
|
() => ({
|
|
2168
2185
|
hasTenant: !!A,
|
|
2169
2186
|
isAuthenticated: x,
|
|
2170
2187
|
userType: F == null ? void 0 : F.userType,
|
|
2171
|
-
permissions:
|
|
2188
|
+
permissions: E,
|
|
2172
2189
|
isLoading: R || u
|
|
2173
2190
|
}),
|
|
2174
2191
|
[
|
|
2175
2192
|
A,
|
|
2176
2193
|
x,
|
|
2177
2194
|
F == null ? void 0 : F.userType,
|
|
2178
|
-
|
|
2195
|
+
E,
|
|
2179
2196
|
R,
|
|
2180
2197
|
u
|
|
2181
2198
|
]
|
|
2182
|
-
), D =
|
|
2199
|
+
), D = J(() => L.isLoading ? null : Ht(M, L), [M, L]), P = J(() => D ? w || Bt(L, k.zoneRoots) : null, [D, w, L, k.zoneRoots]), U = J(() => !D || !P ? null : {
|
|
2183
2200
|
type: D,
|
|
2184
2201
|
required: {
|
|
2185
|
-
tenant:
|
|
2186
|
-
auth:
|
|
2187
|
-
userType:
|
|
2188
|
-
permissions:
|
|
2202
|
+
tenant: M.tenant,
|
|
2203
|
+
auth: M.auth,
|
|
2204
|
+
userType: M.userType,
|
|
2205
|
+
permissions: M.permissions
|
|
2189
2206
|
},
|
|
2190
2207
|
current: {
|
|
2191
2208
|
hasTenant: L.hasTenant,
|
|
@@ -2194,7 +2211,7 @@ const ce = ({
|
|
|
2194
2211
|
permissions: L.permissions
|
|
2195
2212
|
},
|
|
2196
2213
|
redirectTo: P
|
|
2197
|
-
}, [D, P,
|
|
2214
|
+
}, [D, P, M, L]);
|
|
2198
2215
|
if (ee(() => {
|
|
2199
2216
|
U && (g ? g(U) : k.onAccessDenied && k.onAccessDenied(U));
|
|
2200
2217
|
}, [U, g, k]), ee(() => {
|
|
@@ -2218,10 +2235,10 @@ const ce = ({
|
|
|
2218
2235
|
k.returnToParam,
|
|
2219
2236
|
k.returnToStorage
|
|
2220
2237
|
);
|
|
2221
|
-
return /* @__PURE__ */ s(
|
|
2238
|
+
return /* @__PURE__ */ s(be, { to: N, replace: !0 });
|
|
2222
2239
|
}
|
|
2223
2240
|
return /* @__PURE__ */ s(_, { children: n });
|
|
2224
|
-
},
|
|
2241
|
+
}, Mr = (n) => /* @__PURE__ */ s(ce, { tenant: "required", ...n }), Lr = (n) => /* @__PURE__ */ s(ce, { tenant: "forbidden", ...n }), Fr = (n) => /* @__PURE__ */ s(ce, { auth: "required", ...n }), Dr = (n) => /* @__PURE__ */ s(ce, { auth: "forbidden", ...n }), Nr = (n) => /* @__PURE__ */ s(ce, { auth: "required", userType: oe.TENANT_ADMIN, ...n }), Cr = (n) => /* @__PURE__ */ s(ce, { auth: "required", userType: oe.USER, ...n }), Ur = (n) => /* @__PURE__ */ s(ce, { tenant: "optional", auth: "optional", ...n }), $r = (n) => /* @__PURE__ */ s(ce, { tenant: "required", auth: "required", ...n }), Hr = (n) => /* @__PURE__ */ s(ce, { tenant: "required", auth: "optional", ...n }), Br = (n) => /* @__PURE__ */ s(ce, { tenant: "required", auth: "forbidden", ...n }), zt = () => /* @__PURE__ */ d(
|
|
2225
2242
|
"div",
|
|
2226
2243
|
{
|
|
2227
2244
|
style: {
|
|
@@ -2244,7 +2261,7 @@ function qr({
|
|
|
2244
2261
|
allowedPlans: t,
|
|
2245
2262
|
requiredFeature: r
|
|
2246
2263
|
}) {
|
|
2247
|
-
const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: f } =
|
|
2264
|
+
const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: f } = Mt();
|
|
2248
2265
|
return f ? /* @__PURE__ */ s(
|
|
2249
2266
|
"div",
|
|
2250
2267
|
{
|
|
@@ -2473,16 +2490,16 @@ function zr({
|
|
|
2473
2490
|
showMagicLinkOption: c = !0,
|
|
2474
2491
|
className: I
|
|
2475
2492
|
}) {
|
|
2476
|
-
const [p, x] = T(""), [R, F] = T(""), [
|
|
2493
|
+
const [p, x] = T(""), [R, F] = T(""), [E, A] = T(!1), [u, k] = T(!1), [m, M] = T(""), [L, D] = T({}), { login: P } = de(), { tenant: U } = me(), l = { ...Gt, ...n }, N = { ...Qt, ...e }, $ = { ...jt, ...t }, h = () => {
|
|
2477
2494
|
const y = {};
|
|
2478
2495
|
return p.trim() || (y.username = !0), R.trim() || (y.password = !0), D(y), Object.keys(y).length === 0;
|
|
2479
2496
|
}, C = async (y) => {
|
|
2480
2497
|
if (y.preventDefault(), !!h()) {
|
|
2481
2498
|
if (!(U != null && U.id)) {
|
|
2482
|
-
|
|
2499
|
+
M("Tenant not found");
|
|
2483
2500
|
return;
|
|
2484
2501
|
}
|
|
2485
|
-
k(!0),
|
|
2502
|
+
k(!0), M("");
|
|
2486
2503
|
try {
|
|
2487
2504
|
const v = await P({
|
|
2488
2505
|
username: p,
|
|
@@ -2492,7 +2509,7 @@ function zr({
|
|
|
2492
2509
|
r == null || r(v);
|
|
2493
2510
|
} catch (v) {
|
|
2494
2511
|
const j = v.message || l.errorMessage;
|
|
2495
|
-
|
|
2512
|
+
M(j), i == null || i(j);
|
|
2496
2513
|
} finally {
|
|
2497
2514
|
k(!1);
|
|
2498
2515
|
}
|
|
@@ -2534,7 +2551,7 @@ function zr({
|
|
|
2534
2551
|
{
|
|
2535
2552
|
id: "password",
|
|
2536
2553
|
name: "password",
|
|
2537
|
-
type:
|
|
2554
|
+
type: E ? "text" : "password",
|
|
2538
2555
|
value: R,
|
|
2539
2556
|
onChange: (y) => {
|
|
2540
2557
|
F(y.target.value), L.password && D((v) => ({ ...v, password: !1 }));
|
|
@@ -2552,11 +2569,11 @@ function zr({
|
|
|
2552
2569
|
"button",
|
|
2553
2570
|
{
|
|
2554
2571
|
type: "button",
|
|
2555
|
-
onClick: () => A(!
|
|
2572
|
+
onClick: () => A(!E),
|
|
2556
2573
|
style: N.passwordToggle,
|
|
2557
2574
|
disabled: u,
|
|
2558
|
-
"aria-label":
|
|
2559
|
-
children:
|
|
2575
|
+
"aria-label": E ? "Hide password" : "Show password",
|
|
2576
|
+
children: E ? $.hidePassword : $.showPassword
|
|
2560
2577
|
}
|
|
2561
2578
|
)
|
|
2562
2579
|
] })
|
|
@@ -2611,7 +2628,7 @@ const Zt = {
|
|
|
2611
2628
|
passwordMismatchError: "Passwords do not match",
|
|
2612
2629
|
isAdminLabel: "Create new organization",
|
|
2613
2630
|
isAdminDescription: "Check this if you want to create a new organization"
|
|
2614
|
-
},
|
|
2631
|
+
}, Jt = {
|
|
2615
2632
|
container: {
|
|
2616
2633
|
maxWidth: "400px",
|
|
2617
2634
|
width: "100%",
|
|
@@ -2722,9 +2739,9 @@ function _r({
|
|
|
2722
2739
|
showMagicLinkOption: g = !0,
|
|
2723
2740
|
className: w
|
|
2724
2741
|
}) {
|
|
2725
|
-
const [c, I] = T(""), [p, x] = T(""), [R, F] = T(""), [
|
|
2742
|
+
const [c, I] = T(""), [p, x] = T(""), [R, F] = T(""), [E, A] = T(""), [u, k] = T(""), [m, M] = T(""), [L, D] = T(""), [P, U] = T(!1), [l, N] = T(""), [$, h] = T({}), { signup: C, signupTenantAdmin: S } = de(), { tenant: b } = me(), y = { ...Zt, ...n }, v = { ...Jt, ...e }, j = () => {
|
|
2726
2743
|
const B = {};
|
|
2727
|
-
return c.trim() || (B.name = !0), !R.trim() && !
|
|
2744
|
+
return c.trim() || (B.name = !0), !R.trim() && !E.trim() && (B.email = !0, B.phoneNumber = !0), u.trim() || (B.password = !0), m.trim() || (B.confirmPassword = !0), t === "tenant" && !L.trim() && (B.tenantName = !0), h(B), Object.keys(B).length === 0;
|
|
2728
2745
|
}, Q = async (B) => {
|
|
2729
2746
|
if (B.preventDefault(), !!j()) {
|
|
2730
2747
|
if (u !== m) {
|
|
@@ -2740,14 +2757,14 @@ function _r({
|
|
|
2740
2757
|
let X;
|
|
2741
2758
|
t === "tenant" ? X = await S({
|
|
2742
2759
|
email: R || void 0,
|
|
2743
|
-
phoneNumber:
|
|
2760
|
+
phoneNumber: E || void 0,
|
|
2744
2761
|
name: c,
|
|
2745
2762
|
password: u,
|
|
2746
2763
|
tenantName: L,
|
|
2747
2764
|
lastName: p || void 0
|
|
2748
2765
|
}) : X = await C({
|
|
2749
2766
|
email: R || void 0,
|
|
2750
|
-
phoneNumber:
|
|
2767
|
+
phoneNumber: E || void 0,
|
|
2751
2768
|
name: c,
|
|
2752
2769
|
password: u,
|
|
2753
2770
|
tenantId: b.id,
|
|
@@ -2766,8 +2783,8 @@ function _r({
|
|
|
2766
2783
|
}), q = () => ({
|
|
2767
2784
|
...v.button,
|
|
2768
2785
|
...P ? v.buttonLoading : {},
|
|
2769
|
-
...!c || !R && !
|
|
2770
|
-
}), W = c && (R ||
|
|
2786
|
+
...!c || !R && !E || !u || !m || P || t === "tenant" && !L ? v.buttonDisabled : {}
|
|
2787
|
+
}), W = c && (R || E) && u && m && (t === "user" || L);
|
|
2771
2788
|
return /* @__PURE__ */ d("div", { className: w, style: v.container, children: [
|
|
2772
2789
|
/* @__PURE__ */ s("h2", { style: v.title, children: y.title }),
|
|
2773
2790
|
/* @__PURE__ */ d("form", { onSubmit: Q, style: v.form, children: [
|
|
@@ -2831,7 +2848,7 @@ function _r({
|
|
|
2831
2848
|
id: "phoneNumber",
|
|
2832
2849
|
name: "phoneNumber",
|
|
2833
2850
|
type: "tel",
|
|
2834
|
-
value:
|
|
2851
|
+
value: E,
|
|
2835
2852
|
onChange: (B) => {
|
|
2836
2853
|
A(B.target.value), $.phoneNumber && h((X) => ({ ...X, email: !1, phoneNumber: !1 }));
|
|
2837
2854
|
},
|
|
@@ -2881,7 +2898,7 @@ function _r({
|
|
|
2881
2898
|
type: "password",
|
|
2882
2899
|
value: m,
|
|
2883
2900
|
onChange: (B) => {
|
|
2884
|
-
|
|
2901
|
+
M(B.target.value), $.confirmPassword && h((X) => ({ ...X, confirmPassword: !1 })), l === y.passwordMismatchError && N("");
|
|
2885
2902
|
},
|
|
2886
2903
|
placeholder: y.confirmPasswordPlaceholder,
|
|
2887
2904
|
style: O("confirmPassword"),
|
|
@@ -2929,7 +2946,7 @@ function _r({
|
|
|
2929
2946
|
] })
|
|
2930
2947
|
] });
|
|
2931
2948
|
}
|
|
2932
|
-
const
|
|
2949
|
+
const Kt = {
|
|
2933
2950
|
title: "Sign In with Magic Link",
|
|
2934
2951
|
emailLabel: "Email",
|
|
2935
2952
|
emailPlaceholder: "Enter your email",
|
|
@@ -3062,16 +3079,16 @@ function Wr({
|
|
|
3062
3079
|
verifyToken: g,
|
|
3063
3080
|
frontendUrl: w
|
|
3064
3081
|
}) {
|
|
3065
|
-
const [c, I] = T(""), [p, x] = T(""), [R, F] = T(""), [
|
|
3082
|
+
const [c, I] = T(""), [p, x] = T(""), [R, F] = T(""), [E, A] = T(!1), [u, k] = T(!1), [m, M] = T(""), [L, D] = T(""), [P, U] = T({}), [l, N] = T(!1), { sendMagicLink: $, verifyMagicLink: h } = de(), { tenant: C } = me(), S = { ...Kt, ...n }, b = { ...Yt, ...e };
|
|
3066
3083
|
ee(() => {
|
|
3067
3084
|
g && y(g);
|
|
3068
3085
|
}, [g]);
|
|
3069
3086
|
const y = async (q) => {
|
|
3070
3087
|
if (!C || !c) {
|
|
3071
|
-
|
|
3088
|
+
M("Missing tenant or email");
|
|
3072
3089
|
return;
|
|
3073
3090
|
}
|
|
3074
|
-
k(!0),
|
|
3091
|
+
k(!0), M("");
|
|
3075
3092
|
try {
|
|
3076
3093
|
const W = await h({
|
|
3077
3094
|
token: q,
|
|
@@ -3081,7 +3098,7 @@ function Wr({
|
|
|
3081
3098
|
t == null || t(W);
|
|
3082
3099
|
} catch (W) {
|
|
3083
3100
|
const B = W.message || "Failed to verify magic link";
|
|
3084
|
-
|
|
3101
|
+
M(B), r == null || r(B);
|
|
3085
3102
|
} finally {
|
|
3086
3103
|
k(!1);
|
|
3087
3104
|
}
|
|
@@ -3091,10 +3108,10 @@ function Wr({
|
|
|
3091
3108
|
}, j = async (q) => {
|
|
3092
3109
|
if (q.preventDefault(), !!v()) {
|
|
3093
3110
|
if (!(C != null && C.id)) {
|
|
3094
|
-
|
|
3111
|
+
M("Tenant not found");
|
|
3095
3112
|
return;
|
|
3096
3113
|
}
|
|
3097
|
-
A(!0),
|
|
3114
|
+
A(!0), M(""), D("");
|
|
3098
3115
|
try {
|
|
3099
3116
|
const W = w || (typeof window < "u" ? window.location.origin : ""), B = await $({
|
|
3100
3117
|
email: c,
|
|
@@ -3106,7 +3123,7 @@ function Wr({
|
|
|
3106
3123
|
D(S.successMessage), t == null || t(B);
|
|
3107
3124
|
} catch (W) {
|
|
3108
3125
|
const B = W.message || S.errorMessage;
|
|
3109
|
-
|
|
3126
|
+
M(B), r == null || r(B);
|
|
3110
3127
|
} finally {
|
|
3111
3128
|
A(!1);
|
|
3112
3129
|
}
|
|
@@ -3116,8 +3133,8 @@ function Wr({
|
|
|
3116
3133
|
...P[q] ? b.inputError : {}
|
|
3117
3134
|
}), O = () => ({
|
|
3118
3135
|
...b.button,
|
|
3119
|
-
...
|
|
3120
|
-
...!c ||
|
|
3136
|
+
...E || u ? b.buttonLoading : {},
|
|
3137
|
+
...!c || E || u ? b.buttonDisabled : {}
|
|
3121
3138
|
});
|
|
3122
3139
|
return u ? /* @__PURE__ */ d("div", { className: f, style: b.container, children: [
|
|
3123
3140
|
/* @__PURE__ */ s("h2", { style: b.title, children: S.verifyingText }),
|
|
@@ -3140,7 +3157,7 @@ function Wr({
|
|
|
3140
3157
|
},
|
|
3141
3158
|
placeholder: S.emailPlaceholder,
|
|
3142
3159
|
style: Q("email"),
|
|
3143
|
-
disabled:
|
|
3160
|
+
disabled: E || u
|
|
3144
3161
|
}
|
|
3145
3162
|
)
|
|
3146
3163
|
] }),
|
|
@@ -3175,7 +3192,7 @@ function Wr({
|
|
|
3175
3192
|
},
|
|
3176
3193
|
placeholder: S.namePlaceholder,
|
|
3177
3194
|
style: Q("name"),
|
|
3178
|
-
disabled:
|
|
3195
|
+
disabled: E || u
|
|
3179
3196
|
}
|
|
3180
3197
|
)
|
|
3181
3198
|
] }),
|
|
@@ -3191,7 +3208,7 @@ function Wr({
|
|
|
3191
3208
|
onChange: (q) => F(q.target.value),
|
|
3192
3209
|
placeholder: S.lastNamePlaceholder,
|
|
3193
3210
|
style: b.input,
|
|
3194
|
-
disabled:
|
|
3211
|
+
disabled: E || u
|
|
3195
3212
|
}
|
|
3196
3213
|
)
|
|
3197
3214
|
] }),
|
|
@@ -3214,7 +3231,7 @@ function Wr({
|
|
|
3214
3231
|
}
|
|
3215
3232
|
) })
|
|
3216
3233
|
] }),
|
|
3217
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: !c ||
|
|
3234
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !c || E || u, style: O(), children: E ? S.loadingText : S.submitButton }),
|
|
3218
3235
|
m && /* @__PURE__ */ s("div", { style: b.errorText, children: m }),
|
|
3219
3236
|
L && /* @__PURE__ */ s("div", { style: b.successText, children: L })
|
|
3220
3237
|
] }),
|
|
@@ -3387,7 +3404,7 @@ function Vr({
|
|
|
3387
3404
|
tenantSlug: I,
|
|
3388
3405
|
autoRedirectDelay: p = 3e3
|
|
3389
3406
|
}) {
|
|
3390
|
-
const [x, R] = T("verifying"), [F,
|
|
3407
|
+
const [x, R] = T("verifying"), [F, E] = T(""), { verifyMagicLink: A } = de(), u = { ...Xt, ...n }, k = { ...Xe, ...e }, m = { ...nr, ...t }, M = () => {
|
|
3391
3408
|
if (typeof window > "u") return {};
|
|
3392
3409
|
const l = new URLSearchParams(window.location.search);
|
|
3393
3410
|
return {
|
|
@@ -3397,9 +3414,9 @@ function Vr({
|
|
|
3397
3414
|
tenantSlug: I || l.get("tenantSlug") || void 0
|
|
3398
3415
|
};
|
|
3399
3416
|
}, L = async () => {
|
|
3400
|
-
R("verifying"),
|
|
3417
|
+
R("verifying"), E("");
|
|
3401
3418
|
try {
|
|
3402
|
-
const l =
|
|
3419
|
+
const l = M();
|
|
3403
3420
|
if (!l.token || !l.email)
|
|
3404
3421
|
throw new Error("Missing required parameters: token or email");
|
|
3405
3422
|
const N = await A({
|
|
@@ -3412,7 +3429,7 @@ function Vr({
|
|
|
3412
3429
|
}, p);
|
|
3413
3430
|
} catch (l) {
|
|
3414
3431
|
const N = l.message || u.errorMessage;
|
|
3415
|
-
|
|
3432
|
+
E(N), R("error"), i == null || i(N);
|
|
3416
3433
|
}
|
|
3417
3434
|
}, D = () => {
|
|
3418
3435
|
o == null || o(), L();
|
|
@@ -3614,7 +3631,7 @@ function jr({
|
|
|
3614
3631
|
onModeChange: f,
|
|
3615
3632
|
className: g
|
|
3616
3633
|
}) {
|
|
3617
|
-
const [w, c] = T(""), [I, p] = T(r), [x, R] = T(""), [F,
|
|
3634
|
+
const [w, c] = T(""), [I, p] = T(r), [x, R] = T(""), [F, E] = T(""), [A, u] = T(!1), [k, m] = T(""), [M, L] = T(""), [D, P] = T({}), { requestPasswordReset: U, confirmPasswordReset: l } = de(), { tenant: N } = me(), $ = { ...sr, ...n }, h = { ...ir, ...e }, C = () => {
|
|
3618
3635
|
const O = {};
|
|
3619
3636
|
return w.trim() || (O.email = !0), P(O), Object.keys(O).length === 0;
|
|
3620
3637
|
}, S = () => {
|
|
@@ -3705,7 +3722,7 @@ function jr({
|
|
|
3705
3722
|
type: "password",
|
|
3706
3723
|
value: F,
|
|
3707
3724
|
onChange: (q) => {
|
|
3708
|
-
|
|
3725
|
+
E(q.target.value), D.confirmPassword && P((W) => ({ ...W, confirmPassword: !1 })), k === $.passwordMismatchError && m("");
|
|
3709
3726
|
},
|
|
3710
3727
|
placeholder: $.confirmPasswordPlaceholder,
|
|
3711
3728
|
style: v("confirmPassword"),
|
|
@@ -3726,7 +3743,7 @@ function jr({
|
|
|
3726
3743
|
}
|
|
3727
3744
|
),
|
|
3728
3745
|
k && /* @__PURE__ */ s("div", { style: h.errorText, children: k }),
|
|
3729
|
-
|
|
3746
|
+
M && /* @__PURE__ */ s("div", { style: h.successText, children: M })
|
|
3730
3747
|
] }),
|
|
3731
3748
|
/* @__PURE__ */ d("div", { style: h.linkContainer, children: [
|
|
3732
3749
|
/* @__PURE__ */ s("a", { onClick: a, style: h.link, children: $.backToLoginLink }),
|
|
@@ -3771,7 +3788,7 @@ function jr({
|
|
|
3771
3788
|
}
|
|
3772
3789
|
),
|
|
3773
3790
|
k && /* @__PURE__ */ s("div", { style: h.errorText, children: k }),
|
|
3774
|
-
|
|
3791
|
+
M && /* @__PURE__ */ s("div", { style: h.successText, children: M })
|
|
3775
3792
|
] }),
|
|
3776
3793
|
/* @__PURE__ */ d("div", { style: h.linkContainer, children: [
|
|
3777
3794
|
/* @__PURE__ */ s("a", { onClick: a, style: h.link, children: $.backToLoginLink }),
|
|
@@ -3834,8 +3851,8 @@ function Gr({
|
|
|
3834
3851
|
errorFallback: t,
|
|
3835
3852
|
requireTenant: r = !0
|
|
3836
3853
|
}) {
|
|
3837
|
-
const { isAppLoading: i, appError: o, retryApp: a } =
|
|
3838
|
-
}), F = (g == null ? void 0 : g.isAuthReady) ?? !0,
|
|
3854
|
+
const { isAppLoading: i, appError: o, retryApp: a } = Se(), f = ke(), g = Ne(), w = Je(), c = Ke(), I = (f == null ? void 0 : f.isTenantLoading) ?? !1, p = (f == null ? void 0 : f.tenantError) ?? null, x = (f == null ? void 0 : f.tenantSlug) ?? null, R = (f == null ? void 0 : f.retryTenant) ?? (() => {
|
|
3855
|
+
}), F = (g == null ? void 0 : g.isAuthReady) ?? !0, E = (w == null ? void 0 : w.isReady) ?? !0, A = (c == null ? void 0 : c.isReady) ?? !0, u = r && f && x, L = i || u && I || g && !F || w && !E || c && !A, D = o || (u ? p : null), P = () => {
|
|
3839
3856
|
o && a(), p && f && R();
|
|
3840
3857
|
};
|
|
3841
3858
|
if (L)
|
|
@@ -3847,12 +3864,12 @@ function Gr({
|
|
|
3847
3864
|
return /* @__PURE__ */ s(_, { children: n });
|
|
3848
3865
|
}
|
|
3849
3866
|
function Qr(n = !0) {
|
|
3850
|
-
const { isAppLoading: e, appError: t, retryApp: r, appInfo: i } =
|
|
3851
|
-
}), R = (a == null ? void 0 : a.isAuthReady) ?? !0, F = (f == null ? void 0 : f.isReady) ?? !0,
|
|
3867
|
+
const { isAppLoading: e, appError: t, retryApp: r, appInfo: i } = Se(), o = ke(), a = Ne(), f = Je(), g = Ke(), w = (o == null ? void 0 : o.isTenantLoading) ?? !1, c = (o == null ? void 0 : o.tenantError) ?? null, I = (o == null ? void 0 : o.tenant) ?? null, p = (o == null ? void 0 : o.tenantSlug) ?? null, x = (o == null ? void 0 : o.retryTenant) ?? (() => {
|
|
3868
|
+
}), R = (a == null ? void 0 : a.isAuthReady) ?? !0, F = (f == null ? void 0 : f.isReady) ?? !0, E = (g == null ? void 0 : g.isReady) ?? !0, A = n && o && p, M = e || A && w || a && !R || f && !F || g && !E, L = t || (A ? c : null);
|
|
3852
3869
|
return {
|
|
3853
|
-
isLoading:
|
|
3870
|
+
isLoading: M,
|
|
3854
3871
|
error: L,
|
|
3855
|
-
isReady: !
|
|
3872
|
+
isReady: !M && !L && i !== null && (!A || I !== null),
|
|
3856
3873
|
retry: () => {
|
|
3857
3874
|
t && r(), c && o && x();
|
|
3858
3875
|
},
|
|
@@ -3861,7 +3878,7 @@ function Qr(n = !0) {
|
|
|
3861
3878
|
tenant: o ? { isLoading: w, error: c, data: I } : null,
|
|
3862
3879
|
auth: a ? { isReady: R } : null,
|
|
3863
3880
|
featureFlags: f ? { isReady: F } : null,
|
|
3864
|
-
subscription: g ? { isReady:
|
|
3881
|
+
subscription: g ? { isReady: E } : null
|
|
3865
3882
|
};
|
|
3866
3883
|
}
|
|
3867
3884
|
function Zr({
|
|
@@ -3877,12 +3894,12 @@ function Zr({
|
|
|
3877
3894
|
showCurrentTenant: w = !0
|
|
3878
3895
|
}) {
|
|
3879
3896
|
var k;
|
|
3880
|
-
const c = Ne(), [I, p] = T(!1), x = Qe(null), R = n ?? (c == null ? void 0 : c.userTenants) ?? [], F = e ?? ((k = c == null ? void 0 : c.currentUser) == null ? void 0 : k.tenantId) ?? null,
|
|
3897
|
+
const c = Ne(), [I, p] = T(!1), x = Qe(null), R = n ?? (c == null ? void 0 : c.userTenants) ?? [], F = e ?? ((k = c == null ? void 0 : c.currentUser) == null ? void 0 : k.tenantId) ?? null, E = async (m) => {
|
|
3881
3898
|
p(!1), t ? t(m) : c != null && c.switchToTenant && await c.switchToTenant(m);
|
|
3882
3899
|
};
|
|
3883
3900
|
ee(() => {
|
|
3884
|
-
const m = (
|
|
3885
|
-
x.current && !x.current.contains(
|
|
3901
|
+
const m = (M) => {
|
|
3902
|
+
x.current && !x.current.contains(M.target) && p(!1);
|
|
3886
3903
|
};
|
|
3887
3904
|
return document.addEventListener("mousedown", m), () => document.removeEventListener("mousedown", m);
|
|
3888
3905
|
}, []);
|
|
@@ -3891,7 +3908,7 @@ function Zr({
|
|
|
3891
3908
|
return null;
|
|
3892
3909
|
if (R.length === 1 && w)
|
|
3893
3910
|
return /* @__PURE__ */ s("div", { className: r, children: /* @__PURE__ */ s("span", { children: R[0].name }) });
|
|
3894
|
-
const u = (m,
|
|
3911
|
+
const u = (m, M) => /* @__PURE__ */ d("span", { style: { fontWeight: M ? "bold" : "normal" }, children: [
|
|
3895
3912
|
m.name,
|
|
3896
3913
|
m.role && /* @__PURE__ */ d("span", { style: { opacity: 0.7, marginLeft: 8 }, children: [
|
|
3897
3914
|
"(",
|
|
@@ -3934,24 +3951,24 @@ function Zr({
|
|
|
3934
3951
|
overflowY: "auto"
|
|
3935
3952
|
},
|
|
3936
3953
|
children: R.map((m) => {
|
|
3937
|
-
const
|
|
3954
|
+
const M = m.id === F;
|
|
3938
3955
|
return /* @__PURE__ */ s(
|
|
3939
3956
|
"div",
|
|
3940
3957
|
{
|
|
3941
3958
|
className: o,
|
|
3942
|
-
onClick: () =>
|
|
3959
|
+
onClick: () => E(m.id),
|
|
3943
3960
|
style: {
|
|
3944
3961
|
padding: "8px 12px",
|
|
3945
3962
|
cursor: "pointer",
|
|
3946
|
-
backgroundColor:
|
|
3963
|
+
backgroundColor: M ? "#f0f0f0" : "transparent"
|
|
3947
3964
|
},
|
|
3948
3965
|
onMouseEnter: (L) => {
|
|
3949
|
-
|
|
3966
|
+
M || (L.target.style.backgroundColor = "#f5f5f5");
|
|
3950
3967
|
},
|
|
3951
3968
|
onMouseLeave: (L) => {
|
|
3952
|
-
|
|
3969
|
+
M || (L.target.style.backgroundColor = "transparent");
|
|
3953
3970
|
},
|
|
3954
|
-
children: a ? a(m,
|
|
3971
|
+
children: a ? a(m, M) : u(m, M)
|
|
3955
3972
|
},
|
|
3956
3973
|
m.id
|
|
3957
3974
|
);
|
|
@@ -3960,7 +3977,7 @@ function Zr({
|
|
|
3960
3977
|
)
|
|
3961
3978
|
] });
|
|
3962
3979
|
}
|
|
3963
|
-
class
|
|
3980
|
+
class Jr {
|
|
3964
3981
|
constructor(e, t) {
|
|
3965
3982
|
this.httpService = e, this.sessionManager = t;
|
|
3966
3983
|
}
|
|
@@ -4028,7 +4045,7 @@ class Kr {
|
|
|
4028
4045
|
};
|
|
4029
4046
|
}
|
|
4030
4047
|
}
|
|
4031
|
-
class
|
|
4048
|
+
class Kr {
|
|
4032
4049
|
constructor(e, t) {
|
|
4033
4050
|
this.httpService = e, this.sessionManager = t;
|
|
4034
4051
|
}
|
|
@@ -4210,20 +4227,20 @@ class Xr {
|
|
|
4210
4227
|
}), t;
|
|
4211
4228
|
}
|
|
4212
4229
|
}
|
|
4213
|
-
const et = "returnTo",
|
|
4230
|
+
const et = "returnTo", Ee = "zone_return_to", Me = "zone_return_to";
|
|
4214
4231
|
function en(n = {}) {
|
|
4215
4232
|
const {
|
|
4216
4233
|
zoneRoots: e = {},
|
|
4217
4234
|
returnToParam: t = et,
|
|
4218
4235
|
returnToStorage: r = "url"
|
|
4219
|
-
} = n, i = ft(), [o, a] = gt(), { isAuthenticated: f, currentUser: g } = de(), { tenant: w } =
|
|
4236
|
+
} = n, i = ft(), [o, a] = gt(), { isAuthenticated: f, currentUser: g } = de(), { tenant: w } = ge(), c = J(() => ({ ...$e, ...e }), [e]), I = !!w, p = g == null ? void 0 : g.userType, x = J(() => {
|
|
4220
4237
|
switch (r) {
|
|
4221
4238
|
case "url":
|
|
4222
4239
|
return o.get(t);
|
|
4223
4240
|
case "session":
|
|
4224
|
-
return sessionStorage.getItem(
|
|
4241
|
+
return sessionStorage.getItem(Ee);
|
|
4225
4242
|
case "local":
|
|
4226
|
-
return localStorage.getItem(
|
|
4243
|
+
return localStorage.getItem(Me);
|
|
4227
4244
|
default:
|
|
4228
4245
|
return null;
|
|
4229
4246
|
}
|
|
@@ -4235,10 +4252,10 @@ function en(n = {}) {
|
|
|
4235
4252
|
break;
|
|
4236
4253
|
}
|
|
4237
4254
|
case "session":
|
|
4238
|
-
sessionStorage.removeItem(
|
|
4255
|
+
sessionStorage.removeItem(Ee);
|
|
4239
4256
|
break;
|
|
4240
4257
|
case "local":
|
|
4241
|
-
localStorage.removeItem(
|
|
4258
|
+
localStorage.removeItem(Me);
|
|
4242
4259
|
break;
|
|
4243
4260
|
}
|
|
4244
4261
|
}, [r, o, t, a]), F = se(
|
|
@@ -4250,15 +4267,15 @@ function en(n = {}) {
|
|
|
4250
4267
|
break;
|
|
4251
4268
|
}
|
|
4252
4269
|
case "session":
|
|
4253
|
-
sessionStorage.setItem(
|
|
4270
|
+
sessionStorage.setItem(Ee, u);
|
|
4254
4271
|
break;
|
|
4255
4272
|
case "local":
|
|
4256
|
-
localStorage.setItem(
|
|
4273
|
+
localStorage.setItem(Me, u);
|
|
4257
4274
|
break;
|
|
4258
4275
|
}
|
|
4259
4276
|
},
|
|
4260
4277
|
[r, o, t, a]
|
|
4261
|
-
),
|
|
4278
|
+
), E = se(
|
|
4262
4279
|
(u) => {
|
|
4263
4280
|
const k = c[u] || c.default;
|
|
4264
4281
|
i(k);
|
|
@@ -4269,7 +4286,7 @@ function en(n = {}) {
|
|
|
4269
4286
|
returnToUrl: x,
|
|
4270
4287
|
clearReturnTo: R,
|
|
4271
4288
|
setReturnTo: F,
|
|
4272
|
-
navigateToZone:
|
|
4289
|
+
navigateToZone: E,
|
|
4273
4290
|
getSmartRedirect: A
|
|
4274
4291
|
};
|
|
4275
4292
|
}
|
|
@@ -4296,33 +4313,33 @@ export {
|
|
|
4296
4313
|
Dr as GuestZone,
|
|
4297
4314
|
Yr as HealthApiService,
|
|
4298
4315
|
le as HttpService,
|
|
4299
|
-
|
|
4316
|
+
Er as LandingRoute,
|
|
4300
4317
|
zr as LoginForm,
|
|
4301
4318
|
Wr as MagicLinkForm,
|
|
4302
4319
|
Vr as MagicLinkVerify,
|
|
4303
4320
|
Ur as OpenZone,
|
|
4304
4321
|
jr as PasswordRecoveryForm,
|
|
4305
|
-
|
|
4322
|
+
Jr as PermissionApiService,
|
|
4306
4323
|
Pr as Protected,
|
|
4307
4324
|
Rr as ProtectedRoute,
|
|
4308
4325
|
Lr as PublicZone,
|
|
4309
4326
|
ze as RoleApiService,
|
|
4310
4327
|
xr as RoutingProvider,
|
|
4311
4328
|
ie as SessionExpiredError,
|
|
4312
|
-
|
|
4329
|
+
pe as SessionManager,
|
|
4313
4330
|
_r as SignupForm,
|
|
4314
|
-
|
|
4331
|
+
Et as SubscriptionApiService,
|
|
4315
4332
|
qr as SubscriptionGuard,
|
|
4316
|
-
|
|
4333
|
+
Kr as SubscriptionPlanApiService,
|
|
4317
4334
|
kr as SubscriptionProvider,
|
|
4318
|
-
|
|
4335
|
+
we as TenantApiService,
|
|
4319
4336
|
$r as TenantAuthenticatedZone,
|
|
4320
4337
|
Br as TenantGuestZone,
|
|
4321
4338
|
Hr as TenantOpenZone,
|
|
4322
4339
|
wr as TenantProvider,
|
|
4323
4340
|
Ir as TenantRoute,
|
|
4324
4341
|
Zr as TenantSelector,
|
|
4325
|
-
|
|
4342
|
+
Mr as TenantZone,
|
|
4326
4343
|
yt as TokenRefreshError,
|
|
4327
4344
|
mt as TokenRefreshTimeoutError,
|
|
4328
4345
|
bt as UserApiService,
|
|
@@ -4331,17 +4348,17 @@ export {
|
|
|
4331
4348
|
ce as ZoneRoute,
|
|
4332
4349
|
tn as buildRedirectUrl,
|
|
4333
4350
|
yr as useApi,
|
|
4334
|
-
|
|
4351
|
+
Se as useApp,
|
|
4335
4352
|
Qr as useAppLoaderState,
|
|
4336
4353
|
de as useAuth,
|
|
4337
4354
|
It as useFeatureFlags,
|
|
4338
4355
|
Ar as useRouting,
|
|
4339
4356
|
Lt as useRoutingOptional,
|
|
4340
4357
|
Sr as useSettings,
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4358
|
+
Mt as useSubscription,
|
|
4359
|
+
ge as useTenant,
|
|
4360
|
+
me as useTenantInfo,
|
|
4361
|
+
ke as useTenantOptional,
|
|
4345
4362
|
br as useTenantSettings,
|
|
4346
4363
|
en as useZoneNavigation
|
|
4347
4364
|
};
|