@skylabs-digital/react-identity-access 2.18.0 → 2.20.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 +253 -232
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/providers/AuthProvider.d.ts.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();
|
|
@@ -295,7 +312,9 @@ class Ie {
|
|
|
295
312
|
if (!(e != null && e.expiresAt) || !e.refreshToken) return;
|
|
296
313
|
const r = e.expiresAt - this.proactiveRefreshMargin - Date.now();
|
|
297
314
|
if (r <= 0) {
|
|
298
|
-
this.
|
|
315
|
+
this.proactiveTimerId = setTimeout(() => {
|
|
316
|
+
this.backgroundRefresh();
|
|
317
|
+
}, 0);
|
|
299
318
|
return;
|
|
300
319
|
}
|
|
301
320
|
this.proactiveTimerId = setTimeout(() => {
|
|
@@ -678,7 +697,7 @@ class bt {
|
|
|
678
697
|
});
|
|
679
698
|
}
|
|
680
699
|
}
|
|
681
|
-
class
|
|
700
|
+
class we {
|
|
682
701
|
constructor(e, t, r) {
|
|
683
702
|
this.httpService = e, this.appId = t, this.sessionManager = r;
|
|
684
703
|
}
|
|
@@ -827,9 +846,9 @@ function Pt() {
|
|
|
827
846
|
newUrl: n.toString()
|
|
828
847
|
}), window.history.replaceState({}, "", n.toString());
|
|
829
848
|
}
|
|
830
|
-
const Fe =
|
|
849
|
+
const Fe = fe(null);
|
|
831
850
|
function wr({ config: n, children: e }) {
|
|
832
|
-
const { baseUrl: t, appInfo: r, appId: i } =
|
|
851
|
+
const { baseUrl: t, appInfo: r, appId: i } = Se(), o = se(() => typeof window > "u" ? null : Tt(
|
|
833
852
|
{
|
|
834
853
|
tenantMode: n.tenantMode || "selector",
|
|
835
854
|
baseDomain: n.baseDomain,
|
|
@@ -841,7 +860,7 @@ function wr({ config: n, children: e }) {
|
|
|
841
860
|
search: window.location.search
|
|
842
861
|
},
|
|
843
862
|
window.localStorage
|
|
844
|
-
), [n.tenantMode, n.baseDomain, n.selectorParam, n.fixedTenantSlug]), [a, f] = T(() => o()), g =
|
|
863
|
+
), [n.tenantMode, n.baseDomain, n.selectorParam, n.fixedTenantSlug]), [a, f] = T(() => o()), g = J(
|
|
845
864
|
() => {
|
|
846
865
|
var h, C, S;
|
|
847
866
|
return {
|
|
@@ -863,18 +882,18 @@ function wr({ config: n, children: e }) {
|
|
|
863
882
|
} catch {
|
|
864
883
|
return null;
|
|
865
884
|
}
|
|
866
|
-
}), [I, p] = T(!w && !n.initialTenant), [x, R] = T(null), [F,
|
|
885
|
+
}), [I, p] = T(!w && !n.initialTenant), [x, R] = T(null), [F, E] = T(null), [A, u] = T(!1), [k, m] = T(null);
|
|
867
886
|
ee(() => {
|
|
868
887
|
if (n.tenantMode === "fixed") return;
|
|
869
888
|
const h = o();
|
|
870
889
|
f(h);
|
|
871
890
|
}, [o, n.tenantMode]);
|
|
872
|
-
const
|
|
891
|
+
const M = (r == null ? void 0 : r.settingsSchema) || null, L = se(
|
|
873
892
|
async (h, C = !1) => {
|
|
874
893
|
if (!(!C && g.enabled && w && w.domain === h))
|
|
875
894
|
try {
|
|
876
895
|
p(!0), R(null);
|
|
877
|
-
const S = new le(t), y = await new
|
|
896
|
+
const S = new le(t), y = await new we(S, i).getPublicTenantInfo(h);
|
|
878
897
|
if (c(y), g.enabled)
|
|
879
898
|
try {
|
|
880
899
|
const v = {
|
|
@@ -901,7 +920,7 @@ function wr({ config: n, children: e }) {
|
|
|
901
920
|
if (!h) return;
|
|
902
921
|
const C = JSON.parse(h);
|
|
903
922
|
if (Date.now() - C.timestamp > g.ttl * 0.5) {
|
|
904
|
-
const b = new le(t), v = await new
|
|
923
|
+
const b = new le(t), v = await new we(b, i).getPublicTenantInfo(a);
|
|
905
924
|
c(v);
|
|
906
925
|
const j = {
|
|
907
926
|
data: v,
|
|
@@ -917,11 +936,11 @@ function wr({ config: n, children: e }) {
|
|
|
917
936
|
if (w != null && w.id)
|
|
918
937
|
try {
|
|
919
938
|
u(!0), m(null);
|
|
920
|
-
const h = new le(t), S = await new
|
|
921
|
-
|
|
939
|
+
const h = new le(t), S = await new we(h, w.appId).getTenantSettings(w.id);
|
|
940
|
+
E(S);
|
|
922
941
|
} catch (h) {
|
|
923
942
|
const C = h instanceof Error ? h : new Error("Failed to load tenant settings");
|
|
924
|
-
m(C),
|
|
943
|
+
m(C), E(null);
|
|
925
944
|
} finally {
|
|
926
945
|
u(!1);
|
|
927
946
|
}
|
|
@@ -929,14 +948,14 @@ function wr({ config: n, children: e }) {
|
|
|
929
948
|
P();
|
|
930
949
|
}, [P]), l = se(
|
|
931
950
|
(h) => {
|
|
932
|
-
if (!
|
|
951
|
+
if (!M)
|
|
933
952
|
return { isValid: !0, errors: [] };
|
|
934
953
|
const C = [];
|
|
935
954
|
try {
|
|
936
|
-
return
|
|
955
|
+
return M.properties && Object.entries(M.properties).forEach(([S, b]) => {
|
|
937
956
|
var v;
|
|
938
957
|
const y = h[S];
|
|
939
|
-
if ((v =
|
|
958
|
+
if ((v = M.required) != null && v.includes(S) && y == null) {
|
|
940
959
|
C.push(`Field '${S}' is required`);
|
|
941
960
|
return;
|
|
942
961
|
}
|
|
@@ -962,12 +981,12 @@ function wr({ config: n, children: e }) {
|
|
|
962
981
|
};
|
|
963
982
|
}
|
|
964
983
|
},
|
|
965
|
-
[
|
|
984
|
+
[M]
|
|
966
985
|
);
|
|
967
986
|
ee(() => {
|
|
968
987
|
!n.initialTenant && a ? w ? D() : L(a) : !n.initialTenant && !a && (c(null), R(null), p(!1));
|
|
969
988
|
}, [n.initialTenant, a, w, L, D]), ee(() => {
|
|
970
|
-
w != null && w.id ? P() : (
|
|
989
|
+
w != null && w.id ? P() : (E(null), m(null), u(!1));
|
|
971
990
|
}, [w == null ? void 0 : w.id, P]);
|
|
972
991
|
const N = se(
|
|
973
992
|
(h, C) => {
|
|
@@ -1008,7 +1027,7 @@ function wr({ config: n, children: e }) {
|
|
|
1008
1027
|
}
|
|
1009
1028
|
},
|
|
1010
1029
|
[n.tenantMode, n.selectorParam, n.baseDomain, L]
|
|
1011
|
-
), $ =
|
|
1030
|
+
), $ = J(() => ({
|
|
1012
1031
|
// Tenant info
|
|
1013
1032
|
tenant: w,
|
|
1014
1033
|
tenantSlug: a,
|
|
@@ -1019,7 +1038,7 @@ function wr({ config: n, children: e }) {
|
|
|
1019
1038
|
},
|
|
1020
1039
|
// Settings
|
|
1021
1040
|
settings: F,
|
|
1022
|
-
settingsSchema:
|
|
1041
|
+
settingsSchema: M,
|
|
1023
1042
|
isSettingsLoading: A,
|
|
1024
1043
|
settingsError: k,
|
|
1025
1044
|
// Actions
|
|
@@ -1033,7 +1052,7 @@ function wr({ config: n, children: e }) {
|
|
|
1033
1052
|
I,
|
|
1034
1053
|
x,
|
|
1035
1054
|
F,
|
|
1036
|
-
|
|
1055
|
+
M,
|
|
1037
1056
|
A,
|
|
1038
1057
|
k,
|
|
1039
1058
|
U,
|
|
@@ -1042,18 +1061,18 @@ function wr({ config: n, children: e }) {
|
|
|
1042
1061
|
]);
|
|
1043
1062
|
return /* @__PURE__ */ s(Fe.Provider, { value: $, children: e });
|
|
1044
1063
|
}
|
|
1045
|
-
function
|
|
1064
|
+
function ge() {
|
|
1046
1065
|
const n = ae(Fe);
|
|
1047
1066
|
if (!n)
|
|
1048
1067
|
throw new Error("useTenant must be used within a TenantProvider");
|
|
1049
1068
|
return n;
|
|
1050
1069
|
}
|
|
1051
|
-
function
|
|
1070
|
+
function ke() {
|
|
1052
1071
|
return ae(Fe);
|
|
1053
1072
|
}
|
|
1054
|
-
const br =
|
|
1073
|
+
const br = ge;
|
|
1055
1074
|
function Sr() {
|
|
1056
|
-
const { settings: n, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: i } =
|
|
1075
|
+
const { settings: n, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: i } = ge();
|
|
1057
1076
|
return {
|
|
1058
1077
|
settings: n,
|
|
1059
1078
|
settingsSchema: e,
|
|
@@ -1062,8 +1081,8 @@ function Sr() {
|
|
|
1062
1081
|
validateSettings: i
|
|
1063
1082
|
};
|
|
1064
1083
|
}
|
|
1065
|
-
function
|
|
1066
|
-
const { tenant: n, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: i } =
|
|
1084
|
+
function me() {
|
|
1085
|
+
const { tenant: n, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: i } = ge();
|
|
1067
1086
|
return {
|
|
1068
1087
|
tenant: n,
|
|
1069
1088
|
tenantSlug: e,
|
|
@@ -1072,30 +1091,30 @@ function ge() {
|
|
|
1072
1091
|
retry: i
|
|
1073
1092
|
};
|
|
1074
1093
|
}
|
|
1075
|
-
const De =
|
|
1094
|
+
const De = fe(null);
|
|
1076
1095
|
function vr({ config: n = {}, children: e }) {
|
|
1077
|
-
const { appId: t, baseUrl: r } =
|
|
1096
|
+
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
1097
|
try {
|
|
1079
1098
|
const G = localStorage.getItem("userTenants");
|
|
1080
1099
|
return G ? JSON.parse(G) : [];
|
|
1081
1100
|
} catch {
|
|
1082
1101
|
return [];
|
|
1083
1102
|
}
|
|
1084
|
-
}), [
|
|
1103
|
+
}), [M, L] = T(!1), D = Qe({ done: !1, urlTokens: null });
|
|
1085
1104
|
D.current.done || (D.current.done = !0, D.current.urlTokens = At(), D.current.urlTokens && console.log(
|
|
1086
1105
|
"[AuthProvider] SYNC: URL tokens found, will block isAuthReady until user loaded"
|
|
1087
1106
|
));
|
|
1088
1107
|
const [P, U] = T(() => {
|
|
1089
1108
|
const G = D.current.urlTokens !== null;
|
|
1090
1109
|
return console.log("[AuthProvider] SYNC: isLoadingAfterUrlTokens initial:", G), G;
|
|
1091
|
-
}), l =
|
|
1092
|
-
const G = new
|
|
1110
|
+
}), l = J(() => {
|
|
1111
|
+
const G = new pe({
|
|
1093
1112
|
tenantSlug: o,
|
|
1094
1113
|
baseUrl: r,
|
|
1095
1114
|
refreshQueueTimeout: n.refreshQueueTimeout,
|
|
1096
1115
|
proactiveRefreshMargin: n.proactiveRefreshMargin,
|
|
1097
1116
|
onSessionExpired: (ue) => {
|
|
1098
|
-
p(null),
|
|
1117
|
+
p(null), E(null), m([]), L(!1);
|
|
1099
1118
|
try {
|
|
1100
1119
|
localStorage.removeItem("userTenants");
|
|
1101
1120
|
} catch {
|
|
@@ -1108,10 +1127,10 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1108
1127
|
refreshToken: D.current.urlTokens.refreshToken,
|
|
1109
1128
|
expiresIn: D.current.urlTokens.expiresIn
|
|
1110
1129
|
}), 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 =
|
|
1130
|
+
}, [o, r, n.refreshQueueTimeout, n.proactiveRefreshMargin]), [N, $] = T(() => D.current.urlTokens ? !1 : l.hasValidSession()), h = D.current.done && !P && !N, C = J(() => {
|
|
1112
1131
|
const G = new le(r);
|
|
1113
1132
|
return G.setSessionManager(l), G;
|
|
1114
|
-
}, [r, l]), S =
|
|
1133
|
+
}, [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
1134
|
const G = async (H = !1) => {
|
|
1116
1135
|
try {
|
|
1117
1136
|
if (!l.hasValidSession())
|
|
@@ -1124,29 +1143,29 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1124
1143
|
console.warn("[AuthProvider] No userId available in token or storage");
|
|
1125
1144
|
return;
|
|
1126
1145
|
}
|
|
1127
|
-
R(!0),
|
|
1128
|
-
const
|
|
1129
|
-
p(
|
|
1146
|
+
R(!0), E(null);
|
|
1147
|
+
const K = await b.getUserById(V);
|
|
1148
|
+
p(K), l.setUser(K), u(Date.now());
|
|
1130
1149
|
} catch (z) {
|
|
1131
1150
|
const Y = z instanceof Error ? z : new Error("Failed to load user data");
|
|
1132
|
-
|
|
1151
|
+
E(Y), console.error("[AuthProvider] Failed to load user data:", Y);
|
|
1133
1152
|
} finally {
|
|
1134
1153
|
R(!1);
|
|
1135
1154
|
}
|
|
1136
1155
|
}, ue = async () => {
|
|
1137
1156
|
await G();
|
|
1138
|
-
},
|
|
1157
|
+
}, xe = async (H) => {
|
|
1139
1158
|
var Be;
|
|
1140
|
-
const { username: z, password: Y, tenantSlug: V, redirectPath:
|
|
1159
|
+
const { username: z, password: Y, tenantSlug: V, redirectPath: K } = H;
|
|
1141
1160
|
let te = i == null ? void 0 : i.id, re = o, ne = l;
|
|
1142
|
-
V && (te = (await new
|
|
1161
|
+
V && (te = (await new we(C, t).getPublicTenantInfo(V)).id, re = V);
|
|
1143
1162
|
const Z = await S.login({
|
|
1144
1163
|
username: z,
|
|
1145
1164
|
password: Y,
|
|
1146
1165
|
appId: t,
|
|
1147
1166
|
tenantId: te
|
|
1148
|
-
}),
|
|
1149
|
-
if (
|
|
1167
|
+
}), ye = V && V !== o;
|
|
1168
|
+
if (ye && (ne = new pe({
|
|
1150
1169
|
tenantSlug: re,
|
|
1151
1170
|
baseUrl: r
|
|
1152
1171
|
})), ne.setTokens({
|
|
@@ -1157,8 +1176,8 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1157
1176
|
ne.setUser(Z.user), p(Z.user);
|
|
1158
1177
|
try {
|
|
1159
1178
|
await G();
|
|
1160
|
-
} catch (
|
|
1161
|
-
console.warn("Failed to load complete user data after login:",
|
|
1179
|
+
} catch (ve) {
|
|
1180
|
+
console.warn("Failed to load complete user data after login:", ve);
|
|
1162
1181
|
}
|
|
1163
1182
|
}
|
|
1164
1183
|
if (Z.tenants && Z.tenants.length > 0) {
|
|
@@ -1168,52 +1187,52 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1168
1187
|
} catch {
|
|
1169
1188
|
}
|
|
1170
1189
|
}
|
|
1171
|
-
const
|
|
1172
|
-
L(
|
|
1173
|
-
const
|
|
1190
|
+
const Re = ((Be = Z.user) == null ? void 0 : Be.tenantId) !== null;
|
|
1191
|
+
L(Re);
|
|
1192
|
+
const Ie = {
|
|
1174
1193
|
accessToken: Z.accessToken,
|
|
1175
1194
|
refreshToken: Z.refreshToken,
|
|
1176
1195
|
expiresIn: Z.expiresIn
|
|
1177
1196
|
};
|
|
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 &&
|
|
1197
|
+
if (ye && re)
|
|
1198
|
+
return a(re, { tokens: Ie, redirectPath: K }), Z;
|
|
1199
|
+
if (K && K !== window.location.pathname)
|
|
1200
|
+
return a(re || o || "", { tokens: Ie, redirectPath: K }), Z;
|
|
1201
|
+
if (!Re && Z.tenants && Z.tenants.length > 0) {
|
|
1202
|
+
const ve = H.autoSwitch !== !1 && n.autoSwitchSingleTenant !== !1;
|
|
1203
|
+
if (Z.tenants.length === 1 && ve) {
|
|
1185
1204
|
const qe = Z.tenants[0];
|
|
1186
|
-
return a(qe.subdomain, { tokens:
|
|
1205
|
+
return a(qe.subdomain, { tokens: Ie, redirectPath: K }), Z;
|
|
1187
1206
|
} else Z.tenants.length > 1 && n.onTenantSelectionRequired && n.onTenantSelectionRequired(Z.tenants);
|
|
1188
1207
|
}
|
|
1189
1208
|
return Z;
|
|
1190
|
-
},
|
|
1191
|
-
const { email: z, phoneNumber: Y, name: V, password:
|
|
1209
|
+
}, Ae = async (H) => {
|
|
1210
|
+
const { email: z, phoneNumber: Y, name: V, password: K, lastName: te, tenantId: re } = H;
|
|
1192
1211
|
if (!z && !Y)
|
|
1193
1212
|
throw new Error("Either email or phoneNumber is required");
|
|
1194
|
-
if (!V || !
|
|
1213
|
+
if (!V || !K)
|
|
1195
1214
|
throw new Error("Name and password are required");
|
|
1196
1215
|
const ne = re ?? (i == null ? void 0 : i.id);
|
|
1197
1216
|
return await S.signup({
|
|
1198
1217
|
email: z,
|
|
1199
1218
|
phoneNumber: Y,
|
|
1200
1219
|
name: V,
|
|
1201
|
-
password:
|
|
1220
|
+
password: K,
|
|
1202
1221
|
tenantId: ne,
|
|
1203
1222
|
lastName: te,
|
|
1204
1223
|
appId: t
|
|
1205
1224
|
});
|
|
1206
1225
|
}, tt = async (H) => {
|
|
1207
|
-
const { email: z, phoneNumber: Y, name: V, password:
|
|
1226
|
+
const { email: z, phoneNumber: Y, name: V, password: K, tenantName: te, lastName: re } = H;
|
|
1208
1227
|
if (!z && !Y)
|
|
1209
1228
|
throw new Error("Either email or phoneNumber is required");
|
|
1210
|
-
if (!V || !
|
|
1229
|
+
if (!V || !K || !te)
|
|
1211
1230
|
throw new Error("Name, password, and tenantName are required");
|
|
1212
1231
|
return await S.signupTenantAdmin({
|
|
1213
1232
|
email: z,
|
|
1214
1233
|
phoneNumber: Y,
|
|
1215
1234
|
name: V,
|
|
1216
|
-
password:
|
|
1235
|
+
password: K,
|
|
1217
1236
|
tenantName: te,
|
|
1218
1237
|
appId: t,
|
|
1219
1238
|
lastName: re
|
|
@@ -1230,7 +1249,7 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1230
1249
|
const { token: z, newPassword: Y } = H;
|
|
1231
1250
|
await S.confirmPasswordReset({ token: z, newPassword: Y });
|
|
1232
1251
|
}, it = async (H) => {
|
|
1233
|
-
const { email: z, frontendUrl: Y, name: V, lastName:
|
|
1252
|
+
const { email: z, frontendUrl: Y, name: V, lastName: K, tenantId: te } = H, re = te ?? (i == null ? void 0 : i.id);
|
|
1234
1253
|
if (!re)
|
|
1235
1254
|
throw new Error("tenantId is required for magic link authentication");
|
|
1236
1255
|
return await S.sendMagicLink({
|
|
@@ -1238,20 +1257,20 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1238
1257
|
tenantId: re,
|
|
1239
1258
|
frontendUrl: Y,
|
|
1240
1259
|
name: V,
|
|
1241
|
-
lastName:
|
|
1260
|
+
lastName: K,
|
|
1242
1261
|
appId: t
|
|
1243
1262
|
});
|
|
1244
1263
|
}, ot = async (H) => {
|
|
1245
1264
|
const { token: z, email: Y, tenantSlug: V } = H;
|
|
1246
|
-
let
|
|
1247
|
-
V && (
|
|
1265
|
+
let K = i == null ? void 0 : i.id, te = o, re = l;
|
|
1266
|
+
V && (K = (await new we(C, t).getPublicTenantInfo(V)).id, te = V);
|
|
1248
1267
|
const ne = await S.verifyMagicLink({
|
|
1249
1268
|
token: z,
|
|
1250
1269
|
email: Y,
|
|
1251
1270
|
appId: t,
|
|
1252
|
-
tenantId:
|
|
1271
|
+
tenantId: K
|
|
1253
1272
|
}), Z = V && V !== o;
|
|
1254
|
-
if (Z && (re = new
|
|
1273
|
+
if (Z && (re = new pe({
|
|
1255
1274
|
tenantSlug: te,
|
|
1256
1275
|
baseUrl: r
|
|
1257
1276
|
})), re.setTokens({
|
|
@@ -1262,8 +1281,8 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1262
1281
|
re.setUser(ne.user), p(ne.user);
|
|
1263
1282
|
try {
|
|
1264
1283
|
await G();
|
|
1265
|
-
} catch (
|
|
1266
|
-
console.warn("Failed to load complete user data after magic link login:",
|
|
1284
|
+
} catch (ye) {
|
|
1285
|
+
console.warn("Failed to load complete user data after magic link login:", ye);
|
|
1267
1286
|
}
|
|
1268
1287
|
}
|
|
1269
1288
|
return Z && te && te !== o && a(te, {
|
|
@@ -1286,7 +1305,7 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1286
1305
|
expiresIn: z.expiresIn
|
|
1287
1306
|
});
|
|
1288
1307
|
}, lt = () => {
|
|
1289
|
-
l.clearSession(), p(null),
|
|
1308
|
+
l.clearSession(), p(null), E(null), m([]), L(!1);
|
|
1290
1309
|
try {
|
|
1291
1310
|
localStorage.removeItem("userTenants");
|
|
1292
1311
|
} catch {
|
|
@@ -1294,7 +1313,7 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1294
1313
|
}, ct = (H) => {
|
|
1295
1314
|
l.setTokens(H);
|
|
1296
1315
|
}, dt = () => l.hasValidSession(), ut = () => {
|
|
1297
|
-
l.clearSession(), p(null),
|
|
1316
|
+
l.clearSession(), p(null), E(null);
|
|
1298
1317
|
}, ht = async () => {
|
|
1299
1318
|
if (t)
|
|
1300
1319
|
try {
|
|
@@ -1308,7 +1327,7 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1308
1327
|
}
|
|
1309
1328
|
}, pt = async () => {
|
|
1310
1329
|
await ht();
|
|
1311
|
-
},
|
|
1330
|
+
}, Pe = (H) => {
|
|
1312
1331
|
if (!Q || Q.length === 0)
|
|
1313
1332
|
return !1;
|
|
1314
1333
|
if (typeof H == "string")
|
|
@@ -1321,8 +1340,8 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1321
1340
|
isAuthenticated: O,
|
|
1322
1341
|
sessionManager: l,
|
|
1323
1342
|
authenticatedHttpService: C,
|
|
1324
|
-
login:
|
|
1325
|
-
signup:
|
|
1343
|
+
login: xe,
|
|
1344
|
+
signup: Ae,
|
|
1326
1345
|
signupTenantAdmin: tt,
|
|
1327
1346
|
sendMagicLink: it,
|
|
1328
1347
|
verifyMagicLink: ot,
|
|
@@ -1345,34 +1364,34 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1345
1364
|
userPermissions: Q,
|
|
1346
1365
|
availableRoles: f,
|
|
1347
1366
|
rolesLoading: w,
|
|
1348
|
-
hasPermission:
|
|
1349
|
-
hasAnyPermission: (H) => H.some((z) =>
|
|
1350
|
-
hasAllPermissions: (H) => H.every((z) =>
|
|
1367
|
+
hasPermission: Pe,
|
|
1368
|
+
hasAnyPermission: (H) => H.some((z) => Pe(z)),
|
|
1369
|
+
hasAllPermissions: (H) => H.every((z) => Pe(z)),
|
|
1351
1370
|
getUserPermissionStrings: () => Q || [],
|
|
1352
1371
|
refreshRoles: pt,
|
|
1353
1372
|
// RFC-004: Multi-tenant user membership
|
|
1354
1373
|
userTenants: k,
|
|
1355
|
-
hasTenantContext:
|
|
1374
|
+
hasTenantContext: M,
|
|
1356
1375
|
switchToTenant: async (H, z) => {
|
|
1357
1376
|
const { redirectPath: Y } = z || {}, V = l.getTokens();
|
|
1358
1377
|
if (!(V != null && V.refreshToken))
|
|
1359
1378
|
throw new Error("No refresh token available for tenant switch");
|
|
1360
|
-
const
|
|
1379
|
+
const K = await S.switchTenant({
|
|
1361
1380
|
refreshToken: V.refreshToken,
|
|
1362
1381
|
tenantId: H
|
|
1363
1382
|
});
|
|
1364
1383
|
l.setTokens({
|
|
1365
|
-
accessToken:
|
|
1384
|
+
accessToken: K.accessToken,
|
|
1366
1385
|
refreshToken: V.refreshToken,
|
|
1367
1386
|
// Keep the same refresh token
|
|
1368
|
-
expiresIn:
|
|
1369
|
-
}), p(
|
|
1387
|
+
expiresIn: K.expiresIn
|
|
1388
|
+
}), p(K.user), l.setUser(K.user), L(!0);
|
|
1370
1389
|
const te = k.find((re) => re.id === H);
|
|
1371
1390
|
te && a(te.subdomain, {
|
|
1372
1391
|
tokens: {
|
|
1373
|
-
accessToken:
|
|
1392
|
+
accessToken: K.accessToken,
|
|
1374
1393
|
refreshToken: V.refreshToken,
|
|
1375
|
-
expiresIn:
|
|
1394
|
+
expiresIn: K.expiresIn
|
|
1376
1395
|
},
|
|
1377
1396
|
redirectPath: Y
|
|
1378
1397
|
});
|
|
@@ -1403,19 +1422,21 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1403
1422
|
x,
|
|
1404
1423
|
F,
|
|
1405
1424
|
k,
|
|
1406
|
-
|
|
1425
|
+
M,
|
|
1407
1426
|
h,
|
|
1408
1427
|
j,
|
|
1409
1428
|
Q,
|
|
1410
1429
|
A,
|
|
1411
1430
|
q
|
|
1412
1431
|
]);
|
|
1413
|
-
ee(() => {
|
|
1432
|
+
ee(() => () => {
|
|
1433
|
+
l.destroy();
|
|
1434
|
+
}, [l]), ee(() => {
|
|
1414
1435
|
!n.initialRoles && t && (async () => {
|
|
1415
1436
|
try {
|
|
1416
1437
|
c(!0);
|
|
1417
|
-
const ue = new le(r),
|
|
1418
|
-
g(
|
|
1438
|
+
const ue = new le(r), xe = new ze(ue), { roles: Ae } = await xe.getRolesByApp(t);
|
|
1439
|
+
g(Ae);
|
|
1419
1440
|
} catch (ue) {
|
|
1420
1441
|
console.error("Failed to fetch roles:", ue);
|
|
1421
1442
|
} finally {
|
|
@@ -1537,12 +1558,12 @@ class Rt {
|
|
|
1537
1558
|
})).data;
|
|
1538
1559
|
}
|
|
1539
1560
|
}
|
|
1540
|
-
const Ce =
|
|
1561
|
+
const Ce = fe(null);
|
|
1541
1562
|
function Tr({ config: n = {}, children: e }) {
|
|
1542
|
-
const t = Ze(), r =
|
|
1563
|
+
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
1564
|
const u = new le(i);
|
|
1544
1565
|
return new Rt(u);
|
|
1545
|
-
}, [i]),
|
|
1566
|
+
}, [i]), E = async () => {
|
|
1546
1567
|
if (!(a != null && a.id)) {
|
|
1547
1568
|
g([]);
|
|
1548
1569
|
return;
|
|
@@ -1560,19 +1581,19 @@ function Tr({ config: n = {}, children: e }) {
|
|
|
1560
1581
|
};
|
|
1561
1582
|
ee(() => {
|
|
1562
1583
|
if (!i || !o) return;
|
|
1563
|
-
|
|
1564
|
-
const u = n.refreshInterval || 5 * 60 * 1e3, k = setInterval(
|
|
1584
|
+
E().finally(() => R(!0));
|
|
1585
|
+
const u = n.refreshInterval || 5 * 60 * 1e3, k = setInterval(E, u);
|
|
1565
1586
|
return () => clearInterval(k);
|
|
1566
1587
|
}, [a == null ? void 0 : a.id, i, o, n.refreshInterval]);
|
|
1567
|
-
const A =
|
|
1588
|
+
const A = J(() => {
|
|
1568
1589
|
const u = (D) => {
|
|
1569
1590
|
const P = f.find((U) => U.key === D);
|
|
1570
1591
|
return (P == null ? void 0 : P.value) === !0;
|
|
1571
1592
|
}, k = (D) => f.find((P) => P.key === D), m = (D) => {
|
|
1572
1593
|
const P = f.find((U) => U.key === D);
|
|
1573
1594
|
return P ? P.value ? "enabled" : "disabled" : "not_found";
|
|
1574
|
-
},
|
|
1575
|
-
await
|
|
1595
|
+
}, M = async () => {
|
|
1596
|
+
await E();
|
|
1576
1597
|
}, L = !!(i && o) && (x || !(a != null && a.id));
|
|
1577
1598
|
return {
|
|
1578
1599
|
featureFlags: f,
|
|
@@ -1582,7 +1603,7 @@ function Tr({ config: n = {}, children: e }) {
|
|
|
1582
1603
|
isEnabled: u,
|
|
1583
1604
|
getFlag: k,
|
|
1584
1605
|
getFlagState: m,
|
|
1585
|
-
refresh:
|
|
1606
|
+
refresh: M
|
|
1586
1607
|
};
|
|
1587
1608
|
}, [f, w, I, i, o, a == null ? void 0 : a.id, x]);
|
|
1588
1609
|
return /* @__PURE__ */ s(Ce.Provider, { value: A, children: e });
|
|
@@ -1593,10 +1614,10 @@ function It() {
|
|
|
1593
1614
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1594
1615
|
return n;
|
|
1595
1616
|
}
|
|
1596
|
-
function
|
|
1617
|
+
function Je() {
|
|
1597
1618
|
return ae(Ce);
|
|
1598
1619
|
}
|
|
1599
|
-
class
|
|
1620
|
+
class Et {
|
|
1600
1621
|
constructor(e, t) {
|
|
1601
1622
|
this.httpService = e, this.sessionManager = t;
|
|
1602
1623
|
}
|
|
@@ -1662,11 +1683,11 @@ class Mt {
|
|
|
1662
1683
|
)).data;
|
|
1663
1684
|
}
|
|
1664
1685
|
}
|
|
1665
|
-
const Ue =
|
|
1686
|
+
const Ue = fe(void 0);
|
|
1666
1687
|
function kr({ config: n = {}, children: e }) {
|
|
1667
|
-
const t = Ze(), r =
|
|
1688
|
+
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
1689
|
const A = new le(i);
|
|
1669
|
-
return new
|
|
1690
|
+
return new Et(A);
|
|
1670
1691
|
}, [i]), F = async () => {
|
|
1671
1692
|
if (!(o != null && o.id)) {
|
|
1672
1693
|
f(null);
|
|
@@ -1688,14 +1709,14 @@ function kr({ config: n = {}, children: e }) {
|
|
|
1688
1709
|
const A = n.refreshInterval || 10 * 60 * 1e3, u = setInterval(F, A);
|
|
1689
1710
|
return () => clearInterval(u);
|
|
1690
1711
|
}, [o == null ? void 0 : o.id, i, n.refreshInterval]);
|
|
1691
|
-
const
|
|
1712
|
+
const E = J(() => {
|
|
1692
1713
|
const A = (a == null ? void 0 : a.features) || [], u = (P) => {
|
|
1693
1714
|
const U = A.find((l) => l.key === P);
|
|
1694
1715
|
return U ? U.type === "BOOLEAN" || U.type === "boolean" ? U.value === !0 : !!U.value : !1;
|
|
1695
1716
|
}, k = (P) => A.find((U) => U.key === P), m = (P, U) => {
|
|
1696
1717
|
const l = A.find((N) => N.key === P);
|
|
1697
1718
|
return l ? l.value : U;
|
|
1698
|
-
},
|
|
1719
|
+
}, M = (P) => !a || !a.isActive ? !1 : P.includes(a.planId), L = async () => {
|
|
1699
1720
|
await F();
|
|
1700
1721
|
}, D = !!i && (p || !(o != null && o.id));
|
|
1701
1722
|
return {
|
|
@@ -1707,19 +1728,19 @@ function kr({ config: n = {}, children: e }) {
|
|
|
1707
1728
|
isFeatureEnabled: u,
|
|
1708
1729
|
getFeature: k,
|
|
1709
1730
|
getFeatureValue: m,
|
|
1710
|
-
hasAllowedPlan:
|
|
1731
|
+
hasAllowedPlan: M,
|
|
1711
1732
|
refresh: L
|
|
1712
1733
|
};
|
|
1713
1734
|
}, [a, g, c, i, o == null ? void 0 : o.id, p]);
|
|
1714
|
-
return /* @__PURE__ */ s(Ue.Provider, { value:
|
|
1735
|
+
return /* @__PURE__ */ s(Ue.Provider, { value: E, children: e });
|
|
1715
1736
|
}
|
|
1716
|
-
function
|
|
1737
|
+
function Mt() {
|
|
1717
1738
|
const n = ae(Ue);
|
|
1718
1739
|
if (n === void 0)
|
|
1719
1740
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1720
1741
|
return n;
|
|
1721
1742
|
}
|
|
1722
|
-
function
|
|
1743
|
+
function Ke() {
|
|
1723
1744
|
return ae(Ue) ?? null;
|
|
1724
1745
|
}
|
|
1725
1746
|
var oe = /* @__PURE__ */ ((n) => (n.SUPERUSER = "SUPERUSER", n.TENANT_ADMIN = "TENANT_ADMIN", n.USER = "USER", n))(oe || {});
|
|
@@ -1748,9 +1769,9 @@ const $e = {
|
|
|
1748
1769
|
admin: { tenant: "required", auth: "required", userType: oe.TENANT_ADMIN },
|
|
1749
1770
|
// Fully open
|
|
1750
1771
|
open: { tenant: "optional", auth: "optional" }
|
|
1751
|
-
}, He =
|
|
1772
|
+
}, He = fe(null);
|
|
1752
1773
|
function xr({ config: n = {}, children: e }) {
|
|
1753
|
-
const t =
|
|
1774
|
+
const t = J(() => {
|
|
1754
1775
|
const r = {
|
|
1755
1776
|
...$e,
|
|
1756
1777
|
...n.zoneRoots
|
|
@@ -1991,7 +2012,7 @@ function Rr({
|
|
|
1991
2012
|
requireAllPermissions: i = !1,
|
|
1992
2013
|
fallback: o
|
|
1993
2014
|
}) {
|
|
1994
|
-
const { hasValidSession: a, sessionManager: f, hasPermission: g, hasAnyPermission: w, hasAllPermissions: c } = de(), I =
|
|
2015
|
+
const { hasValidSession: a, sessionManager: f, hasPermission: g, hasAnyPermission: w, hasAllPermissions: c } = de(), I = Te();
|
|
1995
2016
|
if (ee(() => {
|
|
1996
2017
|
process.env.NODE_ENV === "development" && console.warn(
|
|
1997
2018
|
"[react-identity-access] ProtectedRoute is deprecated. Use AuthenticatedZone or AdminZone from ZoneRoute instead."
|
|
@@ -1999,11 +2020,11 @@ function Rr({
|
|
|
1999
2020
|
}, []), !a())
|
|
2000
2021
|
return o ? /* @__PURE__ */ s(_, { children: o }) : /* @__PURE__ */ d(_, { children: [
|
|
2001
2022
|
/* @__PURE__ */ s(Dt, { redirectPath: e }),
|
|
2002
|
-
/* @__PURE__ */ s(
|
|
2023
|
+
/* @__PURE__ */ s(be, { to: e, state: { from: I.pathname }, replace: !0 })
|
|
2003
2024
|
] });
|
|
2004
2025
|
const p = f.getUser();
|
|
2005
2026
|
if (!p)
|
|
2006
|
-
return /* @__PURE__ */ s(
|
|
2027
|
+
return /* @__PURE__ */ s(be, { to: e, state: { from: I.pathname }, replace: !0 });
|
|
2007
2028
|
if (t && !Nt(p.userType, t))
|
|
2008
2029
|
return /* @__PURE__ */ s(
|
|
2009
2030
|
je,
|
|
@@ -2056,14 +2077,14 @@ const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2056
2077
|
}
|
|
2057
2078
|
);
|
|
2058
2079
|
function Ir({ children: n, redirectTo: e = "/", fallback: t }) {
|
|
2059
|
-
const { tenant: r, isLoading: i, error: o } =
|
|
2080
|
+
const { tenant: r, isLoading: i, error: o } = me(), a = Te();
|
|
2060
2081
|
return ee(() => {
|
|
2061
2082
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2062
2083
|
"[react-identity-access] TenantRoute is deprecated. Use TenantZone from ZoneRoute instead."
|
|
2063
2084
|
);
|
|
2064
2085
|
}, []), i || o ? null : r ? /* @__PURE__ */ s(_, { children: n }) : t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ d(_, { children: [
|
|
2065
2086
|
/* @__PURE__ */ s(Ct, { redirectPath: e }),
|
|
2066
|
-
/* @__PURE__ */ s(
|
|
2087
|
+
/* @__PURE__ */ s(be, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
2067
2088
|
] });
|
|
2068
2089
|
}
|
|
2069
2090
|
const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
@@ -2103,15 +2124,15 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2103
2124
|
)
|
|
2104
2125
|
}
|
|
2105
2126
|
);
|
|
2106
|
-
function
|
|
2107
|
-
const { tenant: r, isLoading: i, error: o } =
|
|
2127
|
+
function Er({ children: n, redirectTo: e = "/dashboard", fallback: t }) {
|
|
2128
|
+
const { tenant: r, isLoading: i, error: o } = me(), a = Te();
|
|
2108
2129
|
return ee(() => {
|
|
2109
2130
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2110
2131
|
"[react-identity-access] LandingRoute is deprecated. Use PublicZone from ZoneRoute instead."
|
|
2111
2132
|
);
|
|
2112
2133
|
}, []), i || o ? null : r ? t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ d(_, { children: [
|
|
2113
2134
|
/* @__PURE__ */ s(Ut, { redirectPath: e }),
|
|
2114
|
-
/* @__PURE__ */ s(
|
|
2135
|
+
/* @__PURE__ */ s(be, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
2115
2136
|
] }) : /* @__PURE__ */ s(_, { children: n });
|
|
2116
2137
|
}
|
|
2117
2138
|
function $t(n, e) {
|
|
@@ -2151,10 +2172,10 @@ const ce = ({
|
|
|
2151
2172
|
loadingFallback: c,
|
|
2152
2173
|
accessDeniedFallback: I
|
|
2153
2174
|
}) => {
|
|
2154
|
-
const p =
|
|
2175
|
+
const p = Te(), { isAuthenticated: x, isAuthInitializing: R, currentUser: F, userPermissions: E } = de(), { tenant: A, isTenantLoading: u } = ge(), k = Lt(), m = J(() => {
|
|
2155
2176
|
if (e)
|
|
2156
2177
|
return k.presets[e];
|
|
2157
|
-
}, [e, k.presets]),
|
|
2178
|
+
}, [e, k.presets]), M = J(
|
|
2158
2179
|
() => ({
|
|
2159
2180
|
tenant: t ?? (m == null ? void 0 : m.tenant),
|
|
2160
2181
|
auth: r ?? (m == null ? void 0 : m.auth),
|
|
@@ -2163,29 +2184,29 @@ const ce = ({
|
|
|
2163
2184
|
requireAllPermissions: a
|
|
2164
2185
|
}),
|
|
2165
2186
|
[t, r, i, o, m, a]
|
|
2166
|
-
), L =
|
|
2187
|
+
), L = J(
|
|
2167
2188
|
() => ({
|
|
2168
2189
|
hasTenant: !!A,
|
|
2169
2190
|
isAuthenticated: x,
|
|
2170
2191
|
userType: F == null ? void 0 : F.userType,
|
|
2171
|
-
permissions:
|
|
2192
|
+
permissions: E,
|
|
2172
2193
|
isLoading: R || u
|
|
2173
2194
|
}),
|
|
2174
2195
|
[
|
|
2175
2196
|
A,
|
|
2176
2197
|
x,
|
|
2177
2198
|
F == null ? void 0 : F.userType,
|
|
2178
|
-
|
|
2199
|
+
E,
|
|
2179
2200
|
R,
|
|
2180
2201
|
u
|
|
2181
2202
|
]
|
|
2182
|
-
), D =
|
|
2203
|
+
), 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
2204
|
type: D,
|
|
2184
2205
|
required: {
|
|
2185
|
-
tenant:
|
|
2186
|
-
auth:
|
|
2187
|
-
userType:
|
|
2188
|
-
permissions:
|
|
2206
|
+
tenant: M.tenant,
|
|
2207
|
+
auth: M.auth,
|
|
2208
|
+
userType: M.userType,
|
|
2209
|
+
permissions: M.permissions
|
|
2189
2210
|
},
|
|
2190
2211
|
current: {
|
|
2191
2212
|
hasTenant: L.hasTenant,
|
|
@@ -2194,7 +2215,7 @@ const ce = ({
|
|
|
2194
2215
|
permissions: L.permissions
|
|
2195
2216
|
},
|
|
2196
2217
|
redirectTo: P
|
|
2197
|
-
}, [D, P,
|
|
2218
|
+
}, [D, P, M, L]);
|
|
2198
2219
|
if (ee(() => {
|
|
2199
2220
|
U && (g ? g(U) : k.onAccessDenied && k.onAccessDenied(U));
|
|
2200
2221
|
}, [U, g, k]), ee(() => {
|
|
@@ -2218,10 +2239,10 @@ const ce = ({
|
|
|
2218
2239
|
k.returnToParam,
|
|
2219
2240
|
k.returnToStorage
|
|
2220
2241
|
);
|
|
2221
|
-
return /* @__PURE__ */ s(
|
|
2242
|
+
return /* @__PURE__ */ s(be, { to: N, replace: !0 });
|
|
2222
2243
|
}
|
|
2223
2244
|
return /* @__PURE__ */ s(_, { children: n });
|
|
2224
|
-
},
|
|
2245
|
+
}, 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
2246
|
"div",
|
|
2226
2247
|
{
|
|
2227
2248
|
style: {
|
|
@@ -2244,7 +2265,7 @@ function qr({
|
|
|
2244
2265
|
allowedPlans: t,
|
|
2245
2266
|
requiredFeature: r
|
|
2246
2267
|
}) {
|
|
2247
|
-
const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: f } =
|
|
2268
|
+
const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: f } = Mt();
|
|
2248
2269
|
return f ? /* @__PURE__ */ s(
|
|
2249
2270
|
"div",
|
|
2250
2271
|
{
|
|
@@ -2473,16 +2494,16 @@ function zr({
|
|
|
2473
2494
|
showMagicLinkOption: c = !0,
|
|
2474
2495
|
className: I
|
|
2475
2496
|
}) {
|
|
2476
|
-
const [p, x] = T(""), [R, F] = T(""), [
|
|
2497
|
+
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
2498
|
const y = {};
|
|
2478
2499
|
return p.trim() || (y.username = !0), R.trim() || (y.password = !0), D(y), Object.keys(y).length === 0;
|
|
2479
2500
|
}, C = async (y) => {
|
|
2480
2501
|
if (y.preventDefault(), !!h()) {
|
|
2481
2502
|
if (!(U != null && U.id)) {
|
|
2482
|
-
|
|
2503
|
+
M("Tenant not found");
|
|
2483
2504
|
return;
|
|
2484
2505
|
}
|
|
2485
|
-
k(!0),
|
|
2506
|
+
k(!0), M("");
|
|
2486
2507
|
try {
|
|
2487
2508
|
const v = await P({
|
|
2488
2509
|
username: p,
|
|
@@ -2492,7 +2513,7 @@ function zr({
|
|
|
2492
2513
|
r == null || r(v);
|
|
2493
2514
|
} catch (v) {
|
|
2494
2515
|
const j = v.message || l.errorMessage;
|
|
2495
|
-
|
|
2516
|
+
M(j), i == null || i(j);
|
|
2496
2517
|
} finally {
|
|
2497
2518
|
k(!1);
|
|
2498
2519
|
}
|
|
@@ -2534,7 +2555,7 @@ function zr({
|
|
|
2534
2555
|
{
|
|
2535
2556
|
id: "password",
|
|
2536
2557
|
name: "password",
|
|
2537
|
-
type:
|
|
2558
|
+
type: E ? "text" : "password",
|
|
2538
2559
|
value: R,
|
|
2539
2560
|
onChange: (y) => {
|
|
2540
2561
|
F(y.target.value), L.password && D((v) => ({ ...v, password: !1 }));
|
|
@@ -2552,11 +2573,11 @@ function zr({
|
|
|
2552
2573
|
"button",
|
|
2553
2574
|
{
|
|
2554
2575
|
type: "button",
|
|
2555
|
-
onClick: () => A(!
|
|
2576
|
+
onClick: () => A(!E),
|
|
2556
2577
|
style: N.passwordToggle,
|
|
2557
2578
|
disabled: u,
|
|
2558
|
-
"aria-label":
|
|
2559
|
-
children:
|
|
2579
|
+
"aria-label": E ? "Hide password" : "Show password",
|
|
2580
|
+
children: E ? $.hidePassword : $.showPassword
|
|
2560
2581
|
}
|
|
2561
2582
|
)
|
|
2562
2583
|
] })
|
|
@@ -2611,7 +2632,7 @@ const Zt = {
|
|
|
2611
2632
|
passwordMismatchError: "Passwords do not match",
|
|
2612
2633
|
isAdminLabel: "Create new organization",
|
|
2613
2634
|
isAdminDescription: "Check this if you want to create a new organization"
|
|
2614
|
-
},
|
|
2635
|
+
}, Jt = {
|
|
2615
2636
|
container: {
|
|
2616
2637
|
maxWidth: "400px",
|
|
2617
2638
|
width: "100%",
|
|
@@ -2722,9 +2743,9 @@ function _r({
|
|
|
2722
2743
|
showMagicLinkOption: g = !0,
|
|
2723
2744
|
className: w
|
|
2724
2745
|
}) {
|
|
2725
|
-
const [c, I] = T(""), [p, x] = T(""), [R, F] = T(""), [
|
|
2746
|
+
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
2747
|
const B = {};
|
|
2727
|
-
return c.trim() || (B.name = !0), !R.trim() && !
|
|
2748
|
+
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
2749
|
}, Q = async (B) => {
|
|
2729
2750
|
if (B.preventDefault(), !!j()) {
|
|
2730
2751
|
if (u !== m) {
|
|
@@ -2740,14 +2761,14 @@ function _r({
|
|
|
2740
2761
|
let X;
|
|
2741
2762
|
t === "tenant" ? X = await S({
|
|
2742
2763
|
email: R || void 0,
|
|
2743
|
-
phoneNumber:
|
|
2764
|
+
phoneNumber: E || void 0,
|
|
2744
2765
|
name: c,
|
|
2745
2766
|
password: u,
|
|
2746
2767
|
tenantName: L,
|
|
2747
2768
|
lastName: p || void 0
|
|
2748
2769
|
}) : X = await C({
|
|
2749
2770
|
email: R || void 0,
|
|
2750
|
-
phoneNumber:
|
|
2771
|
+
phoneNumber: E || void 0,
|
|
2751
2772
|
name: c,
|
|
2752
2773
|
password: u,
|
|
2753
2774
|
tenantId: b.id,
|
|
@@ -2766,8 +2787,8 @@ function _r({
|
|
|
2766
2787
|
}), q = () => ({
|
|
2767
2788
|
...v.button,
|
|
2768
2789
|
...P ? v.buttonLoading : {},
|
|
2769
|
-
...!c || !R && !
|
|
2770
|
-
}), W = c && (R ||
|
|
2790
|
+
...!c || !R && !E || !u || !m || P || t === "tenant" && !L ? v.buttonDisabled : {}
|
|
2791
|
+
}), W = c && (R || E) && u && m && (t === "user" || L);
|
|
2771
2792
|
return /* @__PURE__ */ d("div", { className: w, style: v.container, children: [
|
|
2772
2793
|
/* @__PURE__ */ s("h2", { style: v.title, children: y.title }),
|
|
2773
2794
|
/* @__PURE__ */ d("form", { onSubmit: Q, style: v.form, children: [
|
|
@@ -2831,7 +2852,7 @@ function _r({
|
|
|
2831
2852
|
id: "phoneNumber",
|
|
2832
2853
|
name: "phoneNumber",
|
|
2833
2854
|
type: "tel",
|
|
2834
|
-
value:
|
|
2855
|
+
value: E,
|
|
2835
2856
|
onChange: (B) => {
|
|
2836
2857
|
A(B.target.value), $.phoneNumber && h((X) => ({ ...X, email: !1, phoneNumber: !1 }));
|
|
2837
2858
|
},
|
|
@@ -2881,7 +2902,7 @@ function _r({
|
|
|
2881
2902
|
type: "password",
|
|
2882
2903
|
value: m,
|
|
2883
2904
|
onChange: (B) => {
|
|
2884
|
-
|
|
2905
|
+
M(B.target.value), $.confirmPassword && h((X) => ({ ...X, confirmPassword: !1 })), l === y.passwordMismatchError && N("");
|
|
2885
2906
|
},
|
|
2886
2907
|
placeholder: y.confirmPasswordPlaceholder,
|
|
2887
2908
|
style: O("confirmPassword"),
|
|
@@ -2929,7 +2950,7 @@ function _r({
|
|
|
2929
2950
|
] })
|
|
2930
2951
|
] });
|
|
2931
2952
|
}
|
|
2932
|
-
const
|
|
2953
|
+
const Kt = {
|
|
2933
2954
|
title: "Sign In with Magic Link",
|
|
2934
2955
|
emailLabel: "Email",
|
|
2935
2956
|
emailPlaceholder: "Enter your email",
|
|
@@ -3062,16 +3083,16 @@ function Wr({
|
|
|
3062
3083
|
verifyToken: g,
|
|
3063
3084
|
frontendUrl: w
|
|
3064
3085
|
}) {
|
|
3065
|
-
const [c, I] = T(""), [p, x] = T(""), [R, F] = T(""), [
|
|
3086
|
+
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
3087
|
ee(() => {
|
|
3067
3088
|
g && y(g);
|
|
3068
3089
|
}, [g]);
|
|
3069
3090
|
const y = async (q) => {
|
|
3070
3091
|
if (!C || !c) {
|
|
3071
|
-
|
|
3092
|
+
M("Missing tenant or email");
|
|
3072
3093
|
return;
|
|
3073
3094
|
}
|
|
3074
|
-
k(!0),
|
|
3095
|
+
k(!0), M("");
|
|
3075
3096
|
try {
|
|
3076
3097
|
const W = await h({
|
|
3077
3098
|
token: q,
|
|
@@ -3081,7 +3102,7 @@ function Wr({
|
|
|
3081
3102
|
t == null || t(W);
|
|
3082
3103
|
} catch (W) {
|
|
3083
3104
|
const B = W.message || "Failed to verify magic link";
|
|
3084
|
-
|
|
3105
|
+
M(B), r == null || r(B);
|
|
3085
3106
|
} finally {
|
|
3086
3107
|
k(!1);
|
|
3087
3108
|
}
|
|
@@ -3091,10 +3112,10 @@ function Wr({
|
|
|
3091
3112
|
}, j = async (q) => {
|
|
3092
3113
|
if (q.preventDefault(), !!v()) {
|
|
3093
3114
|
if (!(C != null && C.id)) {
|
|
3094
|
-
|
|
3115
|
+
M("Tenant not found");
|
|
3095
3116
|
return;
|
|
3096
3117
|
}
|
|
3097
|
-
A(!0),
|
|
3118
|
+
A(!0), M(""), D("");
|
|
3098
3119
|
try {
|
|
3099
3120
|
const W = w || (typeof window < "u" ? window.location.origin : ""), B = await $({
|
|
3100
3121
|
email: c,
|
|
@@ -3106,7 +3127,7 @@ function Wr({
|
|
|
3106
3127
|
D(S.successMessage), t == null || t(B);
|
|
3107
3128
|
} catch (W) {
|
|
3108
3129
|
const B = W.message || S.errorMessage;
|
|
3109
|
-
|
|
3130
|
+
M(B), r == null || r(B);
|
|
3110
3131
|
} finally {
|
|
3111
3132
|
A(!1);
|
|
3112
3133
|
}
|
|
@@ -3116,8 +3137,8 @@ function Wr({
|
|
|
3116
3137
|
...P[q] ? b.inputError : {}
|
|
3117
3138
|
}), O = () => ({
|
|
3118
3139
|
...b.button,
|
|
3119
|
-
...
|
|
3120
|
-
...!c ||
|
|
3140
|
+
...E || u ? b.buttonLoading : {},
|
|
3141
|
+
...!c || E || u ? b.buttonDisabled : {}
|
|
3121
3142
|
});
|
|
3122
3143
|
return u ? /* @__PURE__ */ d("div", { className: f, style: b.container, children: [
|
|
3123
3144
|
/* @__PURE__ */ s("h2", { style: b.title, children: S.verifyingText }),
|
|
@@ -3140,7 +3161,7 @@ function Wr({
|
|
|
3140
3161
|
},
|
|
3141
3162
|
placeholder: S.emailPlaceholder,
|
|
3142
3163
|
style: Q("email"),
|
|
3143
|
-
disabled:
|
|
3164
|
+
disabled: E || u
|
|
3144
3165
|
}
|
|
3145
3166
|
)
|
|
3146
3167
|
] }),
|
|
@@ -3175,7 +3196,7 @@ function Wr({
|
|
|
3175
3196
|
},
|
|
3176
3197
|
placeholder: S.namePlaceholder,
|
|
3177
3198
|
style: Q("name"),
|
|
3178
|
-
disabled:
|
|
3199
|
+
disabled: E || u
|
|
3179
3200
|
}
|
|
3180
3201
|
)
|
|
3181
3202
|
] }),
|
|
@@ -3191,7 +3212,7 @@ function Wr({
|
|
|
3191
3212
|
onChange: (q) => F(q.target.value),
|
|
3192
3213
|
placeholder: S.lastNamePlaceholder,
|
|
3193
3214
|
style: b.input,
|
|
3194
|
-
disabled:
|
|
3215
|
+
disabled: E || u
|
|
3195
3216
|
}
|
|
3196
3217
|
)
|
|
3197
3218
|
] }),
|
|
@@ -3214,7 +3235,7 @@ function Wr({
|
|
|
3214
3235
|
}
|
|
3215
3236
|
) })
|
|
3216
3237
|
] }),
|
|
3217
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: !c ||
|
|
3238
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !c || E || u, style: O(), children: E ? S.loadingText : S.submitButton }),
|
|
3218
3239
|
m && /* @__PURE__ */ s("div", { style: b.errorText, children: m }),
|
|
3219
3240
|
L && /* @__PURE__ */ s("div", { style: b.successText, children: L })
|
|
3220
3241
|
] }),
|
|
@@ -3387,7 +3408,7 @@ function Vr({
|
|
|
3387
3408
|
tenantSlug: I,
|
|
3388
3409
|
autoRedirectDelay: p = 3e3
|
|
3389
3410
|
}) {
|
|
3390
|
-
const [x, R] = T("verifying"), [F,
|
|
3411
|
+
const [x, R] = T("verifying"), [F, E] = T(""), { verifyMagicLink: A } = de(), u = { ...Xt, ...n }, k = { ...Xe, ...e }, m = { ...nr, ...t }, M = () => {
|
|
3391
3412
|
if (typeof window > "u") return {};
|
|
3392
3413
|
const l = new URLSearchParams(window.location.search);
|
|
3393
3414
|
return {
|
|
@@ -3397,9 +3418,9 @@ function Vr({
|
|
|
3397
3418
|
tenantSlug: I || l.get("tenantSlug") || void 0
|
|
3398
3419
|
};
|
|
3399
3420
|
}, L = async () => {
|
|
3400
|
-
R("verifying"),
|
|
3421
|
+
R("verifying"), E("");
|
|
3401
3422
|
try {
|
|
3402
|
-
const l =
|
|
3423
|
+
const l = M();
|
|
3403
3424
|
if (!l.token || !l.email)
|
|
3404
3425
|
throw new Error("Missing required parameters: token or email");
|
|
3405
3426
|
const N = await A({
|
|
@@ -3412,7 +3433,7 @@ function Vr({
|
|
|
3412
3433
|
}, p);
|
|
3413
3434
|
} catch (l) {
|
|
3414
3435
|
const N = l.message || u.errorMessage;
|
|
3415
|
-
|
|
3436
|
+
E(N), R("error"), i == null || i(N);
|
|
3416
3437
|
}
|
|
3417
3438
|
}, D = () => {
|
|
3418
3439
|
o == null || o(), L();
|
|
@@ -3614,7 +3635,7 @@ function jr({
|
|
|
3614
3635
|
onModeChange: f,
|
|
3615
3636
|
className: g
|
|
3616
3637
|
}) {
|
|
3617
|
-
const [w, c] = T(""), [I, p] = T(r), [x, R] = T(""), [F,
|
|
3638
|
+
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
3639
|
const O = {};
|
|
3619
3640
|
return w.trim() || (O.email = !0), P(O), Object.keys(O).length === 0;
|
|
3620
3641
|
}, S = () => {
|
|
@@ -3705,7 +3726,7 @@ function jr({
|
|
|
3705
3726
|
type: "password",
|
|
3706
3727
|
value: F,
|
|
3707
3728
|
onChange: (q) => {
|
|
3708
|
-
|
|
3729
|
+
E(q.target.value), D.confirmPassword && P((W) => ({ ...W, confirmPassword: !1 })), k === $.passwordMismatchError && m("");
|
|
3709
3730
|
},
|
|
3710
3731
|
placeholder: $.confirmPasswordPlaceholder,
|
|
3711
3732
|
style: v("confirmPassword"),
|
|
@@ -3726,7 +3747,7 @@ function jr({
|
|
|
3726
3747
|
}
|
|
3727
3748
|
),
|
|
3728
3749
|
k && /* @__PURE__ */ s("div", { style: h.errorText, children: k }),
|
|
3729
|
-
|
|
3750
|
+
M && /* @__PURE__ */ s("div", { style: h.successText, children: M })
|
|
3730
3751
|
] }),
|
|
3731
3752
|
/* @__PURE__ */ d("div", { style: h.linkContainer, children: [
|
|
3732
3753
|
/* @__PURE__ */ s("a", { onClick: a, style: h.link, children: $.backToLoginLink }),
|
|
@@ -3771,7 +3792,7 @@ function jr({
|
|
|
3771
3792
|
}
|
|
3772
3793
|
),
|
|
3773
3794
|
k && /* @__PURE__ */ s("div", { style: h.errorText, children: k }),
|
|
3774
|
-
|
|
3795
|
+
M && /* @__PURE__ */ s("div", { style: h.successText, children: M })
|
|
3775
3796
|
] }),
|
|
3776
3797
|
/* @__PURE__ */ d("div", { style: h.linkContainer, children: [
|
|
3777
3798
|
/* @__PURE__ */ s("a", { onClick: a, style: h.link, children: $.backToLoginLink }),
|
|
@@ -3834,8 +3855,8 @@ function Gr({
|
|
|
3834
3855
|
errorFallback: t,
|
|
3835
3856
|
requireTenant: r = !0
|
|
3836
3857
|
}) {
|
|
3837
|
-
const { isAppLoading: i, appError: o, retryApp: a } =
|
|
3838
|
-
}), F = (g == null ? void 0 : g.isAuthReady) ?? !0,
|
|
3858
|
+
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) ?? (() => {
|
|
3859
|
+
}), 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
3860
|
o && a(), p && f && R();
|
|
3840
3861
|
};
|
|
3841
3862
|
if (L)
|
|
@@ -3847,12 +3868,12 @@ function Gr({
|
|
|
3847
3868
|
return /* @__PURE__ */ s(_, { children: n });
|
|
3848
3869
|
}
|
|
3849
3870
|
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,
|
|
3871
|
+
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) ?? (() => {
|
|
3872
|
+
}), 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
3873
|
return {
|
|
3853
|
-
isLoading:
|
|
3874
|
+
isLoading: M,
|
|
3854
3875
|
error: L,
|
|
3855
|
-
isReady: !
|
|
3876
|
+
isReady: !M && !L && i !== null && (!A || I !== null),
|
|
3856
3877
|
retry: () => {
|
|
3857
3878
|
t && r(), c && o && x();
|
|
3858
3879
|
},
|
|
@@ -3861,7 +3882,7 @@ function Qr(n = !0) {
|
|
|
3861
3882
|
tenant: o ? { isLoading: w, error: c, data: I } : null,
|
|
3862
3883
|
auth: a ? { isReady: R } : null,
|
|
3863
3884
|
featureFlags: f ? { isReady: F } : null,
|
|
3864
|
-
subscription: g ? { isReady:
|
|
3885
|
+
subscription: g ? { isReady: E } : null
|
|
3865
3886
|
};
|
|
3866
3887
|
}
|
|
3867
3888
|
function Zr({
|
|
@@ -3877,12 +3898,12 @@ function Zr({
|
|
|
3877
3898
|
showCurrentTenant: w = !0
|
|
3878
3899
|
}) {
|
|
3879
3900
|
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,
|
|
3901
|
+
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
3902
|
p(!1), t ? t(m) : c != null && c.switchToTenant && await c.switchToTenant(m);
|
|
3882
3903
|
};
|
|
3883
3904
|
ee(() => {
|
|
3884
|
-
const m = (
|
|
3885
|
-
x.current && !x.current.contains(
|
|
3905
|
+
const m = (M) => {
|
|
3906
|
+
x.current && !x.current.contains(M.target) && p(!1);
|
|
3886
3907
|
};
|
|
3887
3908
|
return document.addEventListener("mousedown", m), () => document.removeEventListener("mousedown", m);
|
|
3888
3909
|
}, []);
|
|
@@ -3891,7 +3912,7 @@ function Zr({
|
|
|
3891
3912
|
return null;
|
|
3892
3913
|
if (R.length === 1 && w)
|
|
3893
3914
|
return /* @__PURE__ */ s("div", { className: r, children: /* @__PURE__ */ s("span", { children: R[0].name }) });
|
|
3894
|
-
const u = (m,
|
|
3915
|
+
const u = (m, M) => /* @__PURE__ */ d("span", { style: { fontWeight: M ? "bold" : "normal" }, children: [
|
|
3895
3916
|
m.name,
|
|
3896
3917
|
m.role && /* @__PURE__ */ d("span", { style: { opacity: 0.7, marginLeft: 8 }, children: [
|
|
3897
3918
|
"(",
|
|
@@ -3934,24 +3955,24 @@ function Zr({
|
|
|
3934
3955
|
overflowY: "auto"
|
|
3935
3956
|
},
|
|
3936
3957
|
children: R.map((m) => {
|
|
3937
|
-
const
|
|
3958
|
+
const M = m.id === F;
|
|
3938
3959
|
return /* @__PURE__ */ s(
|
|
3939
3960
|
"div",
|
|
3940
3961
|
{
|
|
3941
3962
|
className: o,
|
|
3942
|
-
onClick: () =>
|
|
3963
|
+
onClick: () => E(m.id),
|
|
3943
3964
|
style: {
|
|
3944
3965
|
padding: "8px 12px",
|
|
3945
3966
|
cursor: "pointer",
|
|
3946
|
-
backgroundColor:
|
|
3967
|
+
backgroundColor: M ? "#f0f0f0" : "transparent"
|
|
3947
3968
|
},
|
|
3948
3969
|
onMouseEnter: (L) => {
|
|
3949
|
-
|
|
3970
|
+
M || (L.target.style.backgroundColor = "#f5f5f5");
|
|
3950
3971
|
},
|
|
3951
3972
|
onMouseLeave: (L) => {
|
|
3952
|
-
|
|
3973
|
+
M || (L.target.style.backgroundColor = "transparent");
|
|
3953
3974
|
},
|
|
3954
|
-
children: a ? a(m,
|
|
3975
|
+
children: a ? a(m, M) : u(m, M)
|
|
3955
3976
|
},
|
|
3956
3977
|
m.id
|
|
3957
3978
|
);
|
|
@@ -3960,7 +3981,7 @@ function Zr({
|
|
|
3960
3981
|
)
|
|
3961
3982
|
] });
|
|
3962
3983
|
}
|
|
3963
|
-
class
|
|
3984
|
+
class Jr {
|
|
3964
3985
|
constructor(e, t) {
|
|
3965
3986
|
this.httpService = e, this.sessionManager = t;
|
|
3966
3987
|
}
|
|
@@ -4028,7 +4049,7 @@ class Kr {
|
|
|
4028
4049
|
};
|
|
4029
4050
|
}
|
|
4030
4051
|
}
|
|
4031
|
-
class
|
|
4052
|
+
class Kr {
|
|
4032
4053
|
constructor(e, t) {
|
|
4033
4054
|
this.httpService = e, this.sessionManager = t;
|
|
4034
4055
|
}
|
|
@@ -4210,20 +4231,20 @@ class Xr {
|
|
|
4210
4231
|
}), t;
|
|
4211
4232
|
}
|
|
4212
4233
|
}
|
|
4213
|
-
const et = "returnTo",
|
|
4234
|
+
const et = "returnTo", Ee = "zone_return_to", Me = "zone_return_to";
|
|
4214
4235
|
function en(n = {}) {
|
|
4215
4236
|
const {
|
|
4216
4237
|
zoneRoots: e = {},
|
|
4217
4238
|
returnToParam: t = et,
|
|
4218
4239
|
returnToStorage: r = "url"
|
|
4219
|
-
} = n, i = ft(), [o, a] = gt(), { isAuthenticated: f, currentUser: g } = de(), { tenant: w } =
|
|
4240
|
+
} = 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
4241
|
switch (r) {
|
|
4221
4242
|
case "url":
|
|
4222
4243
|
return o.get(t);
|
|
4223
4244
|
case "session":
|
|
4224
|
-
return sessionStorage.getItem(
|
|
4245
|
+
return sessionStorage.getItem(Ee);
|
|
4225
4246
|
case "local":
|
|
4226
|
-
return localStorage.getItem(
|
|
4247
|
+
return localStorage.getItem(Me);
|
|
4227
4248
|
default:
|
|
4228
4249
|
return null;
|
|
4229
4250
|
}
|
|
@@ -4235,10 +4256,10 @@ function en(n = {}) {
|
|
|
4235
4256
|
break;
|
|
4236
4257
|
}
|
|
4237
4258
|
case "session":
|
|
4238
|
-
sessionStorage.removeItem(
|
|
4259
|
+
sessionStorage.removeItem(Ee);
|
|
4239
4260
|
break;
|
|
4240
4261
|
case "local":
|
|
4241
|
-
localStorage.removeItem(
|
|
4262
|
+
localStorage.removeItem(Me);
|
|
4242
4263
|
break;
|
|
4243
4264
|
}
|
|
4244
4265
|
}, [r, o, t, a]), F = se(
|
|
@@ -4250,15 +4271,15 @@ function en(n = {}) {
|
|
|
4250
4271
|
break;
|
|
4251
4272
|
}
|
|
4252
4273
|
case "session":
|
|
4253
|
-
sessionStorage.setItem(
|
|
4274
|
+
sessionStorage.setItem(Ee, u);
|
|
4254
4275
|
break;
|
|
4255
4276
|
case "local":
|
|
4256
|
-
localStorage.setItem(
|
|
4277
|
+
localStorage.setItem(Me, u);
|
|
4257
4278
|
break;
|
|
4258
4279
|
}
|
|
4259
4280
|
},
|
|
4260
4281
|
[r, o, t, a]
|
|
4261
|
-
),
|
|
4282
|
+
), E = se(
|
|
4262
4283
|
(u) => {
|
|
4263
4284
|
const k = c[u] || c.default;
|
|
4264
4285
|
i(k);
|
|
@@ -4269,7 +4290,7 @@ function en(n = {}) {
|
|
|
4269
4290
|
returnToUrl: x,
|
|
4270
4291
|
clearReturnTo: R,
|
|
4271
4292
|
setReturnTo: F,
|
|
4272
|
-
navigateToZone:
|
|
4293
|
+
navigateToZone: E,
|
|
4273
4294
|
getSmartRedirect: A
|
|
4274
4295
|
};
|
|
4275
4296
|
}
|
|
@@ -4296,33 +4317,33 @@ export {
|
|
|
4296
4317
|
Dr as GuestZone,
|
|
4297
4318
|
Yr as HealthApiService,
|
|
4298
4319
|
le as HttpService,
|
|
4299
|
-
|
|
4320
|
+
Er as LandingRoute,
|
|
4300
4321
|
zr as LoginForm,
|
|
4301
4322
|
Wr as MagicLinkForm,
|
|
4302
4323
|
Vr as MagicLinkVerify,
|
|
4303
4324
|
Ur as OpenZone,
|
|
4304
4325
|
jr as PasswordRecoveryForm,
|
|
4305
|
-
|
|
4326
|
+
Jr as PermissionApiService,
|
|
4306
4327
|
Pr as Protected,
|
|
4307
4328
|
Rr as ProtectedRoute,
|
|
4308
4329
|
Lr as PublicZone,
|
|
4309
4330
|
ze as RoleApiService,
|
|
4310
4331
|
xr as RoutingProvider,
|
|
4311
4332
|
ie as SessionExpiredError,
|
|
4312
|
-
|
|
4333
|
+
pe as SessionManager,
|
|
4313
4334
|
_r as SignupForm,
|
|
4314
|
-
|
|
4335
|
+
Et as SubscriptionApiService,
|
|
4315
4336
|
qr as SubscriptionGuard,
|
|
4316
|
-
|
|
4337
|
+
Kr as SubscriptionPlanApiService,
|
|
4317
4338
|
kr as SubscriptionProvider,
|
|
4318
|
-
|
|
4339
|
+
we as TenantApiService,
|
|
4319
4340
|
$r as TenantAuthenticatedZone,
|
|
4320
4341
|
Br as TenantGuestZone,
|
|
4321
4342
|
Hr as TenantOpenZone,
|
|
4322
4343
|
wr as TenantProvider,
|
|
4323
4344
|
Ir as TenantRoute,
|
|
4324
4345
|
Zr as TenantSelector,
|
|
4325
|
-
|
|
4346
|
+
Mr as TenantZone,
|
|
4326
4347
|
yt as TokenRefreshError,
|
|
4327
4348
|
mt as TokenRefreshTimeoutError,
|
|
4328
4349
|
bt as UserApiService,
|
|
@@ -4331,17 +4352,17 @@ export {
|
|
|
4331
4352
|
ce as ZoneRoute,
|
|
4332
4353
|
tn as buildRedirectUrl,
|
|
4333
4354
|
yr as useApi,
|
|
4334
|
-
|
|
4355
|
+
Se as useApp,
|
|
4335
4356
|
Qr as useAppLoaderState,
|
|
4336
4357
|
de as useAuth,
|
|
4337
4358
|
It as useFeatureFlags,
|
|
4338
4359
|
Ar as useRouting,
|
|
4339
4360
|
Lt as useRoutingOptional,
|
|
4340
4361
|
Sr as useSettings,
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4362
|
+
Mt as useSubscription,
|
|
4363
|
+
ge as useTenant,
|
|
4364
|
+
me as useTenantInfo,
|
|
4365
|
+
ke as useTenantOptional,
|
|
4345
4366
|
br as useTenantSettings,
|
|
4346
4367
|
en as useZoneNavigation
|
|
4347
4368
|
};
|