@skylabs-digital/react-identity-access 3.1.0 → 3.1.1
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 +143 -138
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/services/AuthApiService.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -21,7 +21,7 @@ class he {
|
|
|
21
21
|
const c = await this.sessionManager.getValidAccessToken();
|
|
22
22
|
d = { ...d, Authorization: `Bearer ${c}` };
|
|
23
23
|
}
|
|
24
|
-
const T = new AbortController(),
|
|
24
|
+
const T = new AbortController(), A = setTimeout(() => T.abort(), l);
|
|
25
25
|
try {
|
|
26
26
|
const c = await fetch(a, {
|
|
27
27
|
method: e,
|
|
@@ -29,12 +29,12 @@ class he {
|
|
|
29
29
|
body: n ? JSON.stringify(n) : void 0,
|
|
30
30
|
signal: T.signal
|
|
31
31
|
});
|
|
32
|
-
if (clearTimeout(
|
|
32
|
+
if (clearTimeout(A), !c.ok)
|
|
33
33
|
throw new Error(`HTTP ${c.status}: ${c.statusText}`);
|
|
34
34
|
const S = c.headers.get("content-type");
|
|
35
35
|
return !S || !S.includes("application/json") ? {} : await c.json();
|
|
36
36
|
} catch (c) {
|
|
37
|
-
throw clearTimeout(
|
|
37
|
+
throw clearTimeout(A), c instanceof Error && c.name === "AbortError" ? new Error(`Request timeout after ${l}ms`) : c;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
async get(e, t) {
|
|
@@ -111,7 +111,7 @@ function Sr({ config: r, children: e }) {
|
|
|
111
111
|
} catch {
|
|
112
112
|
return null;
|
|
113
113
|
}
|
|
114
|
-
}), [
|
|
114
|
+
}), [A, c] = N(!d), [S, h] = N(null), x = Ee(d);
|
|
115
115
|
x.current = d;
|
|
116
116
|
const P = te(
|
|
117
117
|
async (b = !1) => {
|
|
@@ -156,24 +156,24 @@ function Sr({ config: r, children: e }) {
|
|
|
156
156
|
} catch (b) {
|
|
157
157
|
process.env.NODE_ENV === "development" && console.warn("[AppProvider] Background app refresh failed:", b);
|
|
158
158
|
}
|
|
159
|
-
}, [n, t, i, a, l]),
|
|
159
|
+
}, [n, t, i, a, l]), R = V(
|
|
160
160
|
() => ({
|
|
161
161
|
appId: t,
|
|
162
162
|
baseUrl: n,
|
|
163
163
|
appInfo: d,
|
|
164
|
-
isAppLoading:
|
|
164
|
+
isAppLoading: A,
|
|
165
165
|
appError: S,
|
|
166
166
|
retryApp: () => {
|
|
167
167
|
P(!0);
|
|
168
168
|
}
|
|
169
169
|
}),
|
|
170
|
-
[t, n, d,
|
|
170
|
+
[t, n, d, A, S, P]
|
|
171
171
|
);
|
|
172
172
|
return re(() => {
|
|
173
173
|
x.current ? I() : P();
|
|
174
|
-
}, []), /* @__PURE__ */ s($e.Provider, { value:
|
|
174
|
+
}, []), /* @__PURE__ */ s($e.Provider, { value: R, children: e });
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function Ae() {
|
|
177
177
|
const r = ne($e);
|
|
178
178
|
if (!r)
|
|
179
179
|
throw new Error("useApp must be used within an AppProvider");
|
|
@@ -182,7 +182,7 @@ function Re() {
|
|
|
182
182
|
function Ue() {
|
|
183
183
|
return ne($e);
|
|
184
184
|
}
|
|
185
|
-
const kr =
|
|
185
|
+
const kr = Ae;
|
|
186
186
|
class ee extends Error {
|
|
187
187
|
constructor(e, t) {
|
|
188
188
|
const n = {
|
|
@@ -222,7 +222,7 @@ function Et(r) {
|
|
|
222
222
|
function Ze(r) {
|
|
223
223
|
return JSON.parse(atob(r.replace(/-/g, "+").replace(/_/g, "/")));
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function Re(r) {
|
|
226
226
|
const e = r.split(".");
|
|
227
227
|
if (e.length !== 3) return null;
|
|
228
228
|
try {
|
|
@@ -232,22 +232,22 @@ function Ae(r) {
|
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
function Ke(r) {
|
|
235
|
-
const e =
|
|
235
|
+
const e = Re(r), t = e == null ? void 0 : e.payload.exp;
|
|
236
236
|
return typeof t == "number" ? t * 1e3 : void 0;
|
|
237
237
|
}
|
|
238
238
|
function xt(r, e) {
|
|
239
239
|
var n;
|
|
240
|
-
const t = (n =
|
|
240
|
+
const t = (n = Re(r)) == null ? void 0 : n.payload[e];
|
|
241
241
|
return typeof t == "string" ? t : void 0;
|
|
242
242
|
}
|
|
243
|
-
const
|
|
243
|
+
const At = /^(javascript|data|vbscript|file):/i, Rt = /^https?:\/\//i;
|
|
244
244
|
function Pt(r, e = "baseUrl") {
|
|
245
245
|
if (!(r == null || r === "")) {
|
|
246
246
|
if (typeof r != "string")
|
|
247
247
|
throw new oe(e, r, "must be a string");
|
|
248
|
-
if (
|
|
248
|
+
if (At.test(r))
|
|
249
249
|
throw new oe(e, r, "dangerous URL scheme is not allowed");
|
|
250
|
-
if (!
|
|
250
|
+
if (!Rt.test(r))
|
|
251
251
|
throw new oe(e, r, "must start with http:// or https://");
|
|
252
252
|
}
|
|
253
253
|
}
|
|
@@ -276,7 +276,7 @@ function It(r, e = "accessToken") {
|
|
|
276
276
|
`<${t.length}-segment token>`,
|
|
277
277
|
"JWT must have exactly 3 segments (header.payload.signature)"
|
|
278
278
|
);
|
|
279
|
-
if (
|
|
279
|
+
if (Re(r) === null)
|
|
280
280
|
throw new oe(
|
|
281
281
|
e,
|
|
282
282
|
"<malformed JWT>",
|
|
@@ -664,11 +664,11 @@ const ie = class ie {
|
|
|
664
664
|
}
|
|
665
665
|
if (this.sessionGeneration !== t)
|
|
666
666
|
throw new ee("token_invalid", "Session cleared during refresh");
|
|
667
|
-
const
|
|
667
|
+
const A = await T.json();
|
|
668
668
|
this.setTokens({
|
|
669
|
-
accessToken:
|
|
670
|
-
refreshToken:
|
|
671
|
-
expiresIn:
|
|
669
|
+
accessToken: A.accessToken,
|
|
670
|
+
refreshToken: A.refreshToken || i,
|
|
671
|
+
expiresIn: A.expiresIn
|
|
672
672
|
});
|
|
673
673
|
}
|
|
674
674
|
// --- Session expiry handler ---
|
|
@@ -707,7 +707,7 @@ const ie = class ie {
|
|
|
707
707
|
getTokenPayload() {
|
|
708
708
|
var t, n;
|
|
709
709
|
const e = (t = this.getTokens()) == null ? void 0 : t.accessToken;
|
|
710
|
-
return e ? ((n =
|
|
710
|
+
return e ? ((n = Re(e)) == null ? void 0 : n.payload) ?? null : null;
|
|
711
711
|
}
|
|
712
712
|
/**
|
|
713
713
|
* Get userId from token (source of truth) or fallback to stored user
|
|
@@ -733,21 +733,26 @@ class Nt {
|
|
|
733
733
|
constructor(e) {
|
|
734
734
|
this.httpService = e, this.pendingVerifications = /* @__PURE__ */ new Map(), this.pendingMagicLinks = /* @__PURE__ */ new Map();
|
|
735
735
|
}
|
|
736
|
-
// Public endpoints - no auth required
|
|
736
|
+
// Public endpoints - no auth required.
|
|
737
|
+
// Must pass `{ skipAuth: true }` so HttpService does NOT call
|
|
738
|
+
// SessionManager.getValidAccessToken (which throws when no tokens exist).
|
|
737
739
|
async login(e) {
|
|
738
|
-
return
|
|
740
|
+
return this.httpService.post("/auth/login", e, { skipAuth: !0 });
|
|
739
741
|
}
|
|
740
742
|
async signup(e) {
|
|
741
|
-
return
|
|
743
|
+
return this.httpService.post("/auth/signup", e, { skipAuth: !0 });
|
|
742
744
|
}
|
|
743
745
|
async signupTenantAdmin(e) {
|
|
744
|
-
return
|
|
746
|
+
return this.httpService.post(
|
|
745
747
|
"/auth/signup/tenant-admin",
|
|
746
|
-
e
|
|
748
|
+
e,
|
|
749
|
+
{ skipAuth: !0 }
|
|
747
750
|
);
|
|
748
751
|
}
|
|
749
752
|
async refreshToken(e) {
|
|
750
|
-
return
|
|
753
|
+
return this.httpService.post("/auth/refresh", e, {
|
|
754
|
+
skipAuth: !0
|
|
755
|
+
});
|
|
751
756
|
}
|
|
752
757
|
async switchTenant(e) {
|
|
753
758
|
return await this.httpService.post(
|
|
@@ -759,7 +764,7 @@ class Nt {
|
|
|
759
764
|
return this.httpService.get("/auth/tenants");
|
|
760
765
|
}
|
|
761
766
|
async requestPasswordReset(e) {
|
|
762
|
-
await this.httpService.post("/auth/password-reset/request", e);
|
|
767
|
+
await this.httpService.post("/auth/password-reset/request", e, { skipAuth: !0 });
|
|
763
768
|
}
|
|
764
769
|
async sendMagicLink(e) {
|
|
765
770
|
const t = JSON.stringify([
|
|
@@ -769,7 +774,7 @@ class Nt {
|
|
|
769
774
|
e.frontendUrl ?? ""
|
|
770
775
|
]), n = this.pendingMagicLinks.get(t);
|
|
771
776
|
if (n) return n;
|
|
772
|
-
const i = this.httpService.post("/auth/magic-link/send", e).finally(() => {
|
|
777
|
+
const i = this.httpService.post("/auth/magic-link/send", e, { skipAuth: !0 }).finally(() => {
|
|
773
778
|
this.pendingMagicLinks.delete(t);
|
|
774
779
|
});
|
|
775
780
|
return this.pendingMagicLinks.set(t, i), i;
|
|
@@ -777,13 +782,13 @@ class Nt {
|
|
|
777
782
|
async verifyMagicLink(e) {
|
|
778
783
|
const t = e.token, n = this.pendingVerifications.get(t);
|
|
779
784
|
if (n) return n;
|
|
780
|
-
const i = this.httpService.post("/auth/magic-link/verify", e).finally(() => {
|
|
785
|
+
const i = this.httpService.post("/auth/magic-link/verify", e, { skipAuth: !0 }).finally(() => {
|
|
781
786
|
this.pendingVerifications.delete(t);
|
|
782
787
|
});
|
|
783
788
|
return this.pendingVerifications.set(t, i), i;
|
|
784
789
|
}
|
|
785
790
|
async confirmPasswordReset(e) {
|
|
786
|
-
await this.httpService.post("/auth/password-reset/confirm", e);
|
|
791
|
+
await this.httpService.post("/auth/password-reset/confirm", e, { skipAuth: !0 });
|
|
787
792
|
}
|
|
788
793
|
async changePassword(e) {
|
|
789
794
|
await this.httpService.post("/auth/change-password", e);
|
|
@@ -925,7 +930,7 @@ function Bt(r, e, t) {
|
|
|
925
930
|
const Be = fe(null);
|
|
926
931
|
function Er({ config: r, children: e }) {
|
|
927
932
|
var j, Z, $;
|
|
928
|
-
const { baseUrl: t, appInfo: n, appId: i } =
|
|
933
|
+
const { baseUrl: t, appInfo: n, appId: i } = Ae(), a = te(() => typeof window > "u" ? null : Ut(
|
|
929
934
|
{
|
|
930
935
|
tenantMode: r.tenantMode || "selector",
|
|
931
936
|
baseDomain: r.baseDomain,
|
|
@@ -937,9 +942,9 @@ function Er({ config: r, children: e }) {
|
|
|
937
942
|
search: window.location.search
|
|
938
943
|
},
|
|
939
944
|
window.localStorage
|
|
940
|
-
), [r.tenantMode, r.baseDomain, r.selectorParam, r.fixedTenantSlug]), [l, d] = N(() => a()), T = ((j = r.cache) == null ? void 0 : j.enabled) ?? !0,
|
|
941
|
-
() => ({ enabled: T, ttl:
|
|
942
|
-
[T,
|
|
945
|
+
), [r.tenantMode, r.baseDomain, r.selectorParam, r.fixedTenantSlug]), [l, d] = N(() => a()), T = ((j = r.cache) == null ? void 0 : j.enabled) ?? !0, A = ((Z = r.cache) == null ? void 0 : Z.ttl) ?? 5 * 60 * 1e3, c = (($ = r.cache) == null ? void 0 : $.storageKey) ?? `tenant_cache_${l || "default"}`, S = V(
|
|
946
|
+
() => ({ enabled: T, ttl: A, storageKey: c }),
|
|
947
|
+
[T, A, c]
|
|
943
948
|
), [h, x] = N(() => {
|
|
944
949
|
if (r.initialTenant) return r.initialTenant;
|
|
945
950
|
if (!S.enabled || !l) return null;
|
|
@@ -951,7 +956,7 @@ function Er({ config: r, children: e }) {
|
|
|
951
956
|
} catch {
|
|
952
957
|
return null;
|
|
953
958
|
}
|
|
954
|
-
}), [P, I] = N(!h && !r.initialTenant), [
|
|
959
|
+
}), [P, I] = N(!h && !r.initialTenant), [R, k] = N(null), [m, g] = N(null), [b, C] = N(!1), [o, p] = N(null);
|
|
955
960
|
re(() => {
|
|
956
961
|
if (r.tenantMode === "fixed") return;
|
|
957
962
|
const U = a();
|
|
@@ -1101,7 +1106,7 @@ function Er({ config: r, children: e }) {
|
|
|
1101
1106
|
tenant: h,
|
|
1102
1107
|
tenantSlug: l,
|
|
1103
1108
|
isTenantLoading: P,
|
|
1104
|
-
tenantError:
|
|
1109
|
+
tenantError: R,
|
|
1105
1110
|
retryTenant: () => {
|
|
1106
1111
|
l && y(l);
|
|
1107
1112
|
},
|
|
@@ -1119,7 +1124,7 @@ function Er({ config: r, children: e }) {
|
|
|
1119
1124
|
h,
|
|
1120
1125
|
l,
|
|
1121
1126
|
P,
|
|
1122
|
-
|
|
1127
|
+
R,
|
|
1123
1128
|
m,
|
|
1124
1129
|
E,
|
|
1125
1130
|
b,
|
|
@@ -1140,7 +1145,7 @@ function pe() {
|
|
|
1140
1145
|
return ne(Be);
|
|
1141
1146
|
}
|
|
1142
1147
|
const xr = ve;
|
|
1143
|
-
function
|
|
1148
|
+
function Ar() {
|
|
1144
1149
|
const { settings: r, settingsSchema: e, isSettingsLoading: t, settingsError: n, validateSettings: i } = ve();
|
|
1145
1150
|
return {
|
|
1146
1151
|
settings: r,
|
|
@@ -1182,14 +1187,14 @@ function et() {
|
|
|
1182
1187
|
}
|
|
1183
1188
|
}
|
|
1184
1189
|
const Pe = fe(null), Ie = fe(null);
|
|
1185
|
-
function
|
|
1190
|
+
function Rr({ config: r = {}, children: e }) {
|
|
1186
1191
|
const t = Ue(), n = pe(), i = (t == null ? void 0 : t.baseUrl) ?? r.baseUrl ?? "", a = (t == null ? void 0 : t.appId) ?? r.appId, l = (n == null ? void 0 : n.tenant) ?? null, d = (n == null ? void 0 : n.tenantSlug) ?? null, T = (n == null ? void 0 : n.switchTenant) ?? (() => {
|
|
1187
1192
|
});
|
|
1188
1193
|
if (!i)
|
|
1189
1194
|
throw new Error(
|
|
1190
1195
|
"[AuthProvider] baseUrl is required. Provide it via AppProvider or AuthConfig.baseUrl."
|
|
1191
1196
|
);
|
|
1192
|
-
const [
|
|
1197
|
+
const [A, c] = N(r.initialRoles || []), [S, h] = N(!r.initialRoles), [x, P] = N(null), [I, R] = N(!1), [k, m] = N(null), [g, b] = N(() => _t()), C = Ee({ done: !1 });
|
|
1193
1198
|
C.current.done || (C.current.done = !0);
|
|
1194
1199
|
const o = V(() => Me.getInstance({
|
|
1195
1200
|
baseUrl: i,
|
|
@@ -1219,7 +1224,7 @@ function Ar({ config: r = {}, children: e }) {
|
|
|
1219
1224
|
), se = V(
|
|
1220
1225
|
() => new Ct(u),
|
|
1221
1226
|
[u]
|
|
1222
|
-
), F = V(() => x != null && x.roleId &&
|
|
1227
|
+
), F = V(() => x != null && x.roleId && A.find((w) => w.id === x.roleId) || null, [x, A]), H = V(() => (F == null ? void 0 : F.permissions) || [], [F]), j = V(
|
|
1223
1228
|
() => o.hasValidSession() && x !== null,
|
|
1224
1229
|
[o, x]
|
|
1225
1230
|
), Z = V(() => (x == null ? void 0 : x.tenantId) != null, [x]), $ = Ee(null), U = async (w = !1) => {
|
|
@@ -1230,14 +1235,14 @@ function Ar({ config: r = {}, children: e }) {
|
|
|
1230
1235
|
process.env.NODE_ENV === "development" && console.warn("[AuthProvider] No userId available in token or storage");
|
|
1231
1236
|
return;
|
|
1232
1237
|
}
|
|
1233
|
-
|
|
1238
|
+
R(!0), m(null);
|
|
1234
1239
|
const z = await D.getUserById(M);
|
|
1235
1240
|
P(z), o.setUser(z);
|
|
1236
1241
|
} catch (M) {
|
|
1237
1242
|
const z = M instanceof Error ? M : new Error("Failed to load user data");
|
|
1238
1243
|
m(z), process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to load user data:", z);
|
|
1239
1244
|
} finally {
|
|
1240
|
-
|
|
1245
|
+
R(!1);
|
|
1241
1246
|
}
|
|
1242
1247
|
}, L = async (w) => {
|
|
1243
1248
|
var He;
|
|
@@ -1451,7 +1456,7 @@ function Ar({ config: r = {}, children: e }) {
|
|
|
1451
1456
|
userError: k,
|
|
1452
1457
|
userRole: F,
|
|
1453
1458
|
userPermissions: H,
|
|
1454
|
-
availableRoles:
|
|
1459
|
+
availableRoles: A,
|
|
1455
1460
|
rolesLoading: S,
|
|
1456
1461
|
userTenants: g,
|
|
1457
1462
|
hasTenantContext: Z,
|
|
@@ -1470,7 +1475,7 @@ function Ar({ config: r = {}, children: e }) {
|
|
|
1470
1475
|
k,
|
|
1471
1476
|
F,
|
|
1472
1477
|
H,
|
|
1473
|
-
|
|
1478
|
+
A,
|
|
1474
1479
|
S,
|
|
1475
1480
|
g,
|
|
1476
1481
|
Z,
|
|
@@ -1578,10 +1583,10 @@ class Ot {
|
|
|
1578
1583
|
}
|
|
1579
1584
|
const Ve = fe(null);
|
|
1580
1585
|
function Lr({ config: r = {}, children: e }) {
|
|
1581
|
-
const t = Ue(), n = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", a = (t == null ? void 0 : t.appId) ?? "", l = (n == null ? void 0 : n.tenant) ?? null, [d, T] = N([]), [
|
|
1586
|
+
const t = Ue(), n = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", a = (t == null ? void 0 : t.appId) ?? "", l = (n == null ? void 0 : n.tenant) ?? null, [d, T] = N([]), [A, c] = N(!1), [S, h] = N(null), [x, P] = N(!1), I = V(() => {
|
|
1582
1587
|
const m = new he(i);
|
|
1583
1588
|
return new Ot(m);
|
|
1584
|
-
}, [i]),
|
|
1589
|
+
}, [i]), R = async () => {
|
|
1585
1590
|
if (!(l != null && l.id)) {
|
|
1586
1591
|
T([]);
|
|
1587
1592
|
return;
|
|
@@ -1599,8 +1604,8 @@ function Lr({ config: r = {}, children: e }) {
|
|
|
1599
1604
|
};
|
|
1600
1605
|
re(() => {
|
|
1601
1606
|
if (!i || !a) return;
|
|
1602
|
-
|
|
1603
|
-
const m = r.refreshInterval || 5 * 60 * 1e3, g = setInterval(
|
|
1607
|
+
R().finally(() => P(!0));
|
|
1608
|
+
const m = r.refreshInterval || 5 * 60 * 1e3, g = setInterval(R, m);
|
|
1604
1609
|
return () => clearInterval(g);
|
|
1605
1610
|
}, [l == null ? void 0 : l.id, i, a, r.refreshInterval]);
|
|
1606
1611
|
const k = V(() => {
|
|
@@ -1611,11 +1616,11 @@ function Lr({ config: r = {}, children: e }) {
|
|
|
1611
1616
|
const E = d.find((y) => y.key === p);
|
|
1612
1617
|
return E ? E.value ? "enabled" : "disabled" : "not_found";
|
|
1613
1618
|
}, C = async () => {
|
|
1614
|
-
await
|
|
1619
|
+
await R();
|
|
1615
1620
|
}, o = !!(i && a) && (x || !(l != null && l.id));
|
|
1616
1621
|
return {
|
|
1617
1622
|
featureFlags: d,
|
|
1618
|
-
loading:
|
|
1623
|
+
loading: A,
|
|
1619
1624
|
error: S,
|
|
1620
1625
|
isReady: o,
|
|
1621
1626
|
isEnabled: m,
|
|
@@ -1623,7 +1628,7 @@ function Lr({ config: r = {}, children: e }) {
|
|
|
1623
1628
|
getFlagState: b,
|
|
1624
1629
|
refresh: C
|
|
1625
1630
|
};
|
|
1626
|
-
}, [d,
|
|
1631
|
+
}, [d, A, S, i, a, l == null ? void 0 : l.id, x]);
|
|
1627
1632
|
return /* @__PURE__ */ s(Ve.Provider, { value: k, children: e });
|
|
1628
1633
|
}
|
|
1629
1634
|
function Vt() {
|
|
@@ -1677,7 +1682,7 @@ class qt {
|
|
|
1677
1682
|
}
|
|
1678
1683
|
const qe = fe(void 0);
|
|
1679
1684
|
function Fr({ config: r = {}, children: e }) {
|
|
1680
|
-
const t = Ue(), n = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", a = (n == null ? void 0 : n.tenant) ?? null, [l, d] = N(null), [T,
|
|
1685
|
+
const t = Ue(), n = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", a = (n == null ? void 0 : n.tenant) ?? null, [l, d] = N(null), [T, A] = N(!1), [c, S] = N(null), [h, x] = N(!1), P = V(() => {
|
|
1681
1686
|
const k = new he(i);
|
|
1682
1687
|
return new qt(k);
|
|
1683
1688
|
}, [i]), I = async () => {
|
|
@@ -1685,7 +1690,7 @@ function Fr({ config: r = {}, children: e }) {
|
|
|
1685
1690
|
d(null);
|
|
1686
1691
|
return;
|
|
1687
1692
|
}
|
|
1688
|
-
|
|
1693
|
+
A(!0), S(null);
|
|
1689
1694
|
try {
|
|
1690
1695
|
const k = await P.getTenantSubscriptionFeatures(a.id);
|
|
1691
1696
|
d(k);
|
|
@@ -1693,7 +1698,7 @@ function Fr({ config: r = {}, children: e }) {
|
|
|
1693
1698
|
const m = k instanceof Error ? k.message : "Failed to fetch subscription";
|
|
1694
1699
|
S(m), r.onError && r.onError(k instanceof Error ? k : new Error(m));
|
|
1695
1700
|
} finally {
|
|
1696
|
-
|
|
1701
|
+
A(!1);
|
|
1697
1702
|
}
|
|
1698
1703
|
};
|
|
1699
1704
|
re(() => {
|
|
@@ -1701,7 +1706,7 @@ function Fr({ config: r = {}, children: e }) {
|
|
|
1701
1706
|
const k = r.refreshInterval || 10 * 60 * 1e3, m = setInterval(I, k);
|
|
1702
1707
|
return () => clearInterval(m);
|
|
1703
1708
|
}, [a == null ? void 0 : a.id, i, r.refreshInterval]);
|
|
1704
|
-
const
|
|
1709
|
+
const R = V(() => {
|
|
1705
1710
|
const k = (l == null ? void 0 : l.features) || [], m = (E) => {
|
|
1706
1711
|
const y = k.find((u) => u.key === E);
|
|
1707
1712
|
return y ? y.type === "BOOLEAN" || y.type === "boolean" ? y.value === !0 : !!y.value : !1;
|
|
@@ -1724,7 +1729,7 @@ function Fr({ config: r = {}, children: e }) {
|
|
|
1724
1729
|
refresh: o
|
|
1725
1730
|
};
|
|
1726
1731
|
}, [l, T, c, i, a == null ? void 0 : a.id, h]);
|
|
1727
|
-
return /* @__PURE__ */ s(qe.Provider, { value:
|
|
1732
|
+
return /* @__PURE__ */ s(qe.Provider, { value: R, children: e });
|
|
1728
1733
|
}
|
|
1729
1734
|
function zt() {
|
|
1730
1735
|
const r = ne(qe);
|
|
@@ -1893,7 +1898,7 @@ function Dr({
|
|
|
1893
1898
|
requiredPermissions: n,
|
|
1894
1899
|
requireAllPermissions: i = !1
|
|
1895
1900
|
}) {
|
|
1896
|
-
const { hasValidSession: a, sessionManager: l, hasPermission: d, hasAnyPermission: T, hasAllPermissions:
|
|
1901
|
+
const { hasValidSession: a, sessionManager: l, hasPermission: d, hasAnyPermission: T, hasAllPermissions: A } = de();
|
|
1897
1902
|
if (!a())
|
|
1898
1903
|
return /* @__PURE__ */ s(B, { children: e || /* @__PURE__ */ s(tt, {}) });
|
|
1899
1904
|
const c = l.getUser();
|
|
@@ -1901,7 +1906,7 @@ function Dr({
|
|
|
1901
1906
|
return /* @__PURE__ */ s(B, { children: e || /* @__PURE__ */ s(tt, {}) });
|
|
1902
1907
|
if (t && !Gt(c.userType, t))
|
|
1903
1908
|
return /* @__PURE__ */ s(rt, { userType: c.userType, minUserType: t });
|
|
1904
|
-
if (n && n.length > 0 && !(i ?
|
|
1909
|
+
if (n && n.length > 0 && !(i ? A(n) : T(n))) {
|
|
1905
1910
|
const h = n.filter((x) => !d(x)).map((x) => typeof x == "string" ? x : x.name);
|
|
1906
1911
|
return /* @__PURE__ */ s(rt, { missingPermissions: h });
|
|
1907
1912
|
}
|
|
@@ -2003,7 +2008,7 @@ function Mr({
|
|
|
2003
2008
|
requireAllPermissions: i = !1,
|
|
2004
2009
|
fallback: a
|
|
2005
2010
|
}) {
|
|
2006
|
-
const { hasValidSession: l, sessionManager: d, hasPermission: T, hasAnyPermission:
|
|
2011
|
+
const { hasValidSession: l, sessionManager: d, hasPermission: T, hasAnyPermission: A, hasAllPermissions: c } = de(), S = xe();
|
|
2007
2012
|
if (re(() => {
|
|
2008
2013
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2009
2014
|
"[react-identity-access] ProtectedRoute is deprecated. Use AuthenticatedZone or AdminZone from ZoneRoute instead."
|
|
@@ -2024,7 +2029,7 @@ function Mr({
|
|
|
2024
2029
|
requiredUserType: t
|
|
2025
2030
|
}
|
|
2026
2031
|
);
|
|
2027
|
-
if (n && n.length > 0 && !(i ? c(n) :
|
|
2032
|
+
if (n && n.length > 0 && !(i ? c(n) : A(n))) {
|
|
2028
2033
|
const P = n.filter((I) => !T(I)).map((I) => typeof I == "string" ? I : I.name);
|
|
2029
2034
|
return /* @__PURE__ */ s(nt, { missingPermissions: P });
|
|
2030
2035
|
}
|
|
@@ -2159,11 +2164,11 @@ const ue = ({
|
|
|
2159
2164
|
requireAllPermissions: l = !0,
|
|
2160
2165
|
returnTo: d,
|
|
2161
2166
|
onAccessDenied: T,
|
|
2162
|
-
redirectTo:
|
|
2167
|
+
redirectTo: A,
|
|
2163
2168
|
loadingFallback: c,
|
|
2164
2169
|
accessDeniedFallback: S
|
|
2165
2170
|
}) => {
|
|
2166
|
-
const h = xe(), { isAuthenticated: x, isAuthInitializing: P, currentUser: I, userPermissions:
|
|
2171
|
+
const h = xe(), { isAuthenticated: x, isAuthInitializing: P, currentUser: I, userPermissions: R } = de(), { tenant: k, isTenantLoading: m } = ve(), g = Wt(), b = V(() => {
|
|
2167
2172
|
if (e)
|
|
2168
2173
|
return g.presets[e];
|
|
2169
2174
|
}, [e, g.presets]), C = V(
|
|
@@ -2180,18 +2185,18 @@ const ue = ({
|
|
|
2180
2185
|
hasTenant: !!k,
|
|
2181
2186
|
isAuthenticated: x,
|
|
2182
2187
|
userType: I == null ? void 0 : I.userType,
|
|
2183
|
-
permissions:
|
|
2188
|
+
permissions: R,
|
|
2184
2189
|
isLoading: P || m
|
|
2185
2190
|
}),
|
|
2186
2191
|
[
|
|
2187
2192
|
k,
|
|
2188
2193
|
x,
|
|
2189
2194
|
I == null ? void 0 : I.userType,
|
|
2190
|
-
|
|
2195
|
+
R,
|
|
2191
2196
|
P,
|
|
2192
2197
|
m
|
|
2193
2198
|
]
|
|
2194
|
-
), p = V(() => o.isLoading ? null : Yt(C, o), [C, o]), E = V(() => p ?
|
|
2199
|
+
), p = V(() => o.isLoading ? null : Yt(C, o), [C, o]), E = V(() => p ? A || Xt(o, g.zoneRoots) : null, [p, A, o, g.zoneRoots]), y = V(() => !p || !E ? null : {
|
|
2195
2200
|
type: p,
|
|
2196
2201
|
required: {
|
|
2197
2202
|
tenant: C.tenant,
|
|
@@ -2314,26 +2319,26 @@ function Jr({ name: r, children: e, fallback: t }) {
|
|
|
2314
2319
|
) : n(r) ? /* @__PURE__ */ s(B, { children: e }) : /* @__PURE__ */ s(B, { children: t || /* @__PURE__ */ s(nr, { flagName: r }) });
|
|
2315
2320
|
}
|
|
2316
2321
|
function we(r) {
|
|
2317
|
-
const { submit: e, defaultErrorMessage: t, validate: n, onSuccess: i, onError: a } = r, [l, d] = N(!1), [T,
|
|
2318
|
-
S((m) => ({ ...m, [
|
|
2319
|
-
}, []), x = te((
|
|
2322
|
+
const { submit: e, defaultErrorMessage: t, validate: n, onSuccess: i, onError: a } = r, [l, d] = N(!1), [T, A] = N(""), [c, S] = N({}), h = te((R, k) => {
|
|
2323
|
+
S((m) => ({ ...m, [R]: k }));
|
|
2324
|
+
}, []), x = te((R) => {
|
|
2320
2325
|
S((k) => {
|
|
2321
|
-
if (!k[
|
|
2326
|
+
if (!k[R]) return k;
|
|
2322
2327
|
const m = { ...k };
|
|
2323
|
-
return delete m[
|
|
2328
|
+
return delete m[R], m;
|
|
2324
2329
|
});
|
|
2325
2330
|
}, []), P = te(() => {
|
|
2326
|
-
|
|
2331
|
+
A(""), S({});
|
|
2327
2332
|
}, []), I = te(
|
|
2328
|
-
async (
|
|
2329
|
-
if (
|
|
2330
|
-
d(!0),
|
|
2333
|
+
async (R) => {
|
|
2334
|
+
if (R && R.preventDefault(), !(n && !n())) {
|
|
2335
|
+
d(!0), A("");
|
|
2331
2336
|
try {
|
|
2332
2337
|
const k = await e();
|
|
2333
2338
|
return i == null || i(k), k;
|
|
2334
2339
|
} catch (k) {
|
|
2335
2340
|
const m = k instanceof Error ? k.message : t;
|
|
2336
|
-
|
|
2341
|
+
A(m), a == null || a(m);
|
|
2337
2342
|
return;
|
|
2338
2343
|
} finally {
|
|
2339
2344
|
d(!1);
|
|
@@ -2345,7 +2350,7 @@ function we(r) {
|
|
|
2345
2350
|
return {
|
|
2346
2351
|
loading: l,
|
|
2347
2352
|
error: T,
|
|
2348
|
-
setError:
|
|
2353
|
+
setError: A,
|
|
2349
2354
|
fieldErrors: c,
|
|
2350
2355
|
setFieldError: h,
|
|
2351
2356
|
clearFieldError: x,
|
|
@@ -2592,11 +2597,11 @@ function Zr({
|
|
|
2592
2597
|
onSignupClick: l,
|
|
2593
2598
|
onMagicLinkClick: d,
|
|
2594
2599
|
showForgotPassword: T = !0,
|
|
2595
|
-
showSignupLink:
|
|
2600
|
+
showSignupLink: A = !0,
|
|
2596
2601
|
showMagicLinkOption: c = !0,
|
|
2597
2602
|
className: S
|
|
2598
2603
|
}) {
|
|
2599
|
-
const [h, x] = N(""), [P, I] = N(""), [
|
|
2604
|
+
const [h, x] = N(""), [P, I] = N(""), [R, k] = N(!1), { login: m } = de(), g = { ...ar, ...r }, b = Le("#3b82f6", e), C = { ...or, ...t }, o = we({
|
|
2600
2605
|
defaultErrorMessage: g.errorMessage,
|
|
2601
2606
|
validate: () => {
|
|
2602
2607
|
const u = [];
|
|
@@ -2642,7 +2647,7 @@ function Zr({
|
|
|
2642
2647
|
{
|
|
2643
2648
|
id: "password",
|
|
2644
2649
|
name: "password",
|
|
2645
|
-
type:
|
|
2650
|
+
type: R ? "text" : "password",
|
|
2646
2651
|
value: P,
|
|
2647
2652
|
onChange: (u) => {
|
|
2648
2653
|
I(u.target.value), o.clearFieldError("password");
|
|
@@ -2656,11 +2661,11 @@ function Zr({
|
|
|
2656
2661
|
"button",
|
|
2657
2662
|
{
|
|
2658
2663
|
type: "button",
|
|
2659
|
-
onClick: () => k(!
|
|
2664
|
+
onClick: () => k(!R),
|
|
2660
2665
|
style: b.passwordToggle,
|
|
2661
2666
|
disabled: o.loading,
|
|
2662
|
-
"aria-label":
|
|
2663
|
-
children:
|
|
2667
|
+
"aria-label": R ? g.hidePasswordAriaLabel : g.showPasswordAriaLabel,
|
|
2668
|
+
children: R ? C.hidePassword : C.showPassword
|
|
2664
2669
|
}
|
|
2665
2670
|
)
|
|
2666
2671
|
] })
|
|
@@ -2668,7 +2673,7 @@ function Zr({
|
|
|
2668
2673
|
/* @__PURE__ */ s("button", { type: "submit", disabled: E, style: y, children: o.loading ? g.loadingText : g.submitButton }),
|
|
2669
2674
|
o.error && /* @__PURE__ */ s("div", { style: b.errorText, children: o.error })
|
|
2670
2675
|
] }),
|
|
2671
|
-
(T ||
|
|
2676
|
+
(T || A || c) && /* @__PURE__ */ f("div", { style: b.linkContainer, children: [
|
|
2672
2677
|
c && /* @__PURE__ */ f("div", { children: [
|
|
2673
2678
|
/* @__PURE__ */ f("span", { style: b.divider, children: [
|
|
2674
2679
|
g.magicLinkText,
|
|
@@ -2676,10 +2681,10 @@ function Zr({
|
|
|
2676
2681
|
] }),
|
|
2677
2682
|
/* @__PURE__ */ s("a", { onClick: d, style: b.link, children: g.magicLinkLink })
|
|
2678
2683
|
] }),
|
|
2679
|
-
c && (T ||
|
|
2684
|
+
c && (T || A) && /* @__PURE__ */ s("div", { style: b.divider, children: g.dividerBullet }),
|
|
2680
2685
|
T && /* @__PURE__ */ s("a", { onClick: a, style: b.link, children: g.forgotPasswordLink }),
|
|
2681
|
-
T &&
|
|
2682
|
-
|
|
2686
|
+
T && A && /* @__PURE__ */ s("div", { style: b.divider, children: g.dividerBullet }),
|
|
2687
|
+
A && /* @__PURE__ */ f("div", { children: [
|
|
2683
2688
|
/* @__PURE__ */ f("span", { style: b.divider, children: [
|
|
2684
2689
|
g.signupText,
|
|
2685
2690
|
" "
|
|
@@ -2729,25 +2734,25 @@ function Kr({
|
|
|
2729
2734
|
onMagicLinkClick: l,
|
|
2730
2735
|
showLoginLink: d = !0,
|
|
2731
2736
|
showMagicLinkOption: T = !0,
|
|
2732
|
-
className:
|
|
2737
|
+
className: A
|
|
2733
2738
|
}) {
|
|
2734
2739
|
var U;
|
|
2735
|
-
const [c, S] = N(""), [h, x] = N(""), [P, I] = N(""), [
|
|
2740
|
+
const [c, S] = N(""), [h, x] = N(""), [P, I] = N(""), [R, k] = N(""), [m, g] = N(""), [b, C] = N(""), [o, p] = N(""), { signup: E, signupTenantAdmin: y } = de(), u = ((U = pe()) == null ? void 0 : U.tenant) ?? null, v = { ...lr, ...r }, D = Le("#10b981", e), se = !!c && (!!P || !!R) && !!m && !!b && (t === "user" || !!o), F = we({
|
|
2736
2741
|
defaultErrorMessage: v.errorMessage,
|
|
2737
2742
|
validate: () => {
|
|
2738
2743
|
const L = [];
|
|
2739
|
-
return c.trim() || L.push("name"), !P.trim() && !
|
|
2744
|
+
return c.trim() || L.push("name"), !P.trim() && !R.trim() && (L.push("email"), L.push("phoneNumber")), m.trim() || L.push("password"), b.trim() || L.push("confirmPassword"), t === "tenant" && !o.trim() && L.push("tenantName"), L.forEach((q) => F.setFieldError(q, !0)), L.length > 0 ? !1 : m !== b ? (F.setError(v.passwordMismatchError), F.setFieldError("confirmPassword", !0), !1) : t === "user" && !(u != null && u.id) ? (F.setError(v.tenantNotFoundError), !1) : !0;
|
|
2740
2745
|
},
|
|
2741
2746
|
submit: async () => t === "tenant" ? y({
|
|
2742
2747
|
email: P || void 0,
|
|
2743
|
-
phoneNumber:
|
|
2748
|
+
phoneNumber: R || void 0,
|
|
2744
2749
|
name: c,
|
|
2745
2750
|
password: m,
|
|
2746
2751
|
tenantName: o,
|
|
2747
2752
|
lastName: h || void 0
|
|
2748
2753
|
}) : E({
|
|
2749
2754
|
email: P || void 0,
|
|
2750
|
-
phoneNumber:
|
|
2755
|
+
phoneNumber: R || void 0,
|
|
2751
2756
|
name: c,
|
|
2752
2757
|
password: m,
|
|
2753
2758
|
tenantId: u.id,
|
|
@@ -2765,7 +2770,7 @@ function Kr({
|
|
|
2765
2770
|
}, $ = () => {
|
|
2766
2771
|
F.clearFieldError("email"), F.clearFieldError("phoneNumber");
|
|
2767
2772
|
};
|
|
2768
|
-
return /* @__PURE__ */ f("div", { className:
|
|
2773
|
+
return /* @__PURE__ */ f("div", { className: A, style: D.container, children: [
|
|
2769
2774
|
/* @__PURE__ */ s("h2", { style: D.title, children: v.title }),
|
|
2770
2775
|
/* @__PURE__ */ f("form", { onSubmit: F.handleSubmit, style: D.form, children: [
|
|
2771
2776
|
/* @__PURE__ */ f("div", { style: D.fieldGroup, children: [
|
|
@@ -2828,7 +2833,7 @@ function Kr({
|
|
|
2828
2833
|
id: "phoneNumber",
|
|
2829
2834
|
name: "phoneNumber",
|
|
2830
2835
|
type: "tel",
|
|
2831
|
-
value:
|
|
2836
|
+
value: R,
|
|
2832
2837
|
onChange: (L) => {
|
|
2833
2838
|
k(L.target.value), $();
|
|
2834
2839
|
},
|
|
@@ -2950,10 +2955,10 @@ function Yr({
|
|
|
2950
2955
|
showTraditionalLinks: l = !0,
|
|
2951
2956
|
className: d,
|
|
2952
2957
|
verifyToken: T,
|
|
2953
|
-
frontendUrl:
|
|
2958
|
+
frontendUrl: A
|
|
2954
2959
|
}) {
|
|
2955
2960
|
var H;
|
|
2956
|
-
const [c, S] = N(""), [h, x] = N(""), [P, I] = N(""), [
|
|
2961
|
+
const [c, S] = N(""), [h, x] = N(""), [P, I] = N(""), [R, k] = N(!1), [m, g] = N(""), [b, C] = N(!1), { sendMagicLink: o, verifyMagicLink: p } = de(), E = ((H = pe()) == null ? void 0 : H.tenant) ?? null, y = { ...cr, ...r }, u = Le("#3b82f6", e), v = we({
|
|
2957
2962
|
defaultErrorMessage: y.errorMessage,
|
|
2958
2963
|
validate: () => {
|
|
2959
2964
|
const j = [];
|
|
@@ -2961,7 +2966,7 @@ function Yr({
|
|
|
2961
2966
|
},
|
|
2962
2967
|
submit: async () => {
|
|
2963
2968
|
g("");
|
|
2964
|
-
const j =
|
|
2969
|
+
const j = A || (typeof window < "u" ? window.location.origin : ""), Z = await o({
|
|
2965
2970
|
email: c,
|
|
2966
2971
|
tenantId: E.id,
|
|
2967
2972
|
frontendUrl: j,
|
|
@@ -2995,12 +3000,12 @@ function Yr({
|
|
|
2995
3000
|
const D = (j) => ({
|
|
2996
3001
|
...u.input,
|
|
2997
3002
|
...v.fieldErrors[j] ? u.inputError : {}
|
|
2998
|
-
}), se = !c || v.loading ||
|
|
3003
|
+
}), se = !c || v.loading || R, F = {
|
|
2999
3004
|
...u.button,
|
|
3000
|
-
...v.loading ||
|
|
3005
|
+
...v.loading || R ? u.buttonLoading : {},
|
|
3001
3006
|
...se ? u.buttonDisabled : {}
|
|
3002
3007
|
};
|
|
3003
|
-
return
|
|
3008
|
+
return R ? /* @__PURE__ */ f("div", { className: d, style: u.container, children: [
|
|
3004
3009
|
/* @__PURE__ */ s("h2", { style: u.title, children: y.verifyingText }),
|
|
3005
3010
|
/* @__PURE__ */ s("div", { style: u.verifyingContainer, children: /* @__PURE__ */ s("div", { style: u.verifyingText, children: y.verifyingDescription }) })
|
|
3006
3011
|
] }) : /* @__PURE__ */ f("div", { className: d, style: u.container, children: [
|
|
@@ -3021,7 +3026,7 @@ function Yr({
|
|
|
3021
3026
|
},
|
|
3022
3027
|
placeholder: y.emailPlaceholder,
|
|
3023
3028
|
style: D("email"),
|
|
3024
|
-
disabled: v.loading ||
|
|
3029
|
+
disabled: v.loading || R
|
|
3025
3030
|
}
|
|
3026
3031
|
)
|
|
3027
3032
|
] }),
|
|
@@ -3049,7 +3054,7 @@ function Yr({
|
|
|
3049
3054
|
},
|
|
3050
3055
|
placeholder: y.namePlaceholder,
|
|
3051
3056
|
style: D("name"),
|
|
3052
|
-
disabled: v.loading ||
|
|
3057
|
+
disabled: v.loading || R
|
|
3053
3058
|
}
|
|
3054
3059
|
)
|
|
3055
3060
|
] }),
|
|
@@ -3065,7 +3070,7 @@ function Yr({
|
|
|
3065
3070
|
onChange: (j) => I(j.target.value),
|
|
3066
3071
|
placeholder: y.lastNamePlaceholder,
|
|
3067
3072
|
style: u.input,
|
|
3068
|
-
disabled: v.loading ||
|
|
3073
|
+
disabled: v.loading || R
|
|
3069
3074
|
}
|
|
3070
3075
|
)
|
|
3071
3076
|
] }),
|
|
@@ -3256,22 +3261,22 @@ function Xr({
|
|
|
3256
3261
|
onBackToLogin: l,
|
|
3257
3262
|
className: d,
|
|
3258
3263
|
token: T,
|
|
3259
|
-
email:
|
|
3264
|
+
email: A,
|
|
3260
3265
|
appId: c,
|
|
3261
3266
|
tenantSlug: S,
|
|
3262
3267
|
autoRedirectDelay: h = 3e3
|
|
3263
3268
|
}) {
|
|
3264
|
-
const [x, P] = N("verifying"), [I,
|
|
3269
|
+
const [x, P] = N("verifying"), [I, R] = N(""), { verifyMagicLink: k } = de(), m = { ...ur, ...r }, g = { ...ut, ...e }, b = { ...fr, ...t }, C = () => {
|
|
3265
3270
|
if (typeof window > "u") return {};
|
|
3266
3271
|
const u = new URLSearchParams(window.location.search);
|
|
3267
3272
|
return {
|
|
3268
3273
|
token: T || u.get("token") || "",
|
|
3269
|
-
email:
|
|
3274
|
+
email: A || u.get("email") || "",
|
|
3270
3275
|
appId: c || u.get("appId") || "",
|
|
3271
3276
|
tenantSlug: S || u.get("tenantSlug") || void 0
|
|
3272
3277
|
};
|
|
3273
3278
|
}, o = async () => {
|
|
3274
|
-
P("verifying"),
|
|
3279
|
+
P("verifying"), R("");
|
|
3275
3280
|
try {
|
|
3276
3281
|
const u = C();
|
|
3277
3282
|
if (!u.token || !u.email)
|
|
@@ -3286,7 +3291,7 @@ function Xr({
|
|
|
3286
3291
|
}, h);
|
|
3287
3292
|
} catch (u) {
|
|
3288
3293
|
const v = u.message || m.errorMessage;
|
|
3289
|
-
|
|
3294
|
+
R(v), P("error"), i == null || i(v);
|
|
3290
3295
|
}
|
|
3291
3296
|
}, p = () => {
|
|
3292
3297
|
a == null || a(), o();
|
|
@@ -3408,11 +3413,11 @@ function en({
|
|
|
3408
3413
|
className: T
|
|
3409
3414
|
}) {
|
|
3410
3415
|
var se;
|
|
3411
|
-
const [
|
|
3416
|
+
const [A, c] = N(""), [S, h] = N(n), [x, P] = N(""), [I, R] = N(""), [k, m] = N(""), { requestPasswordReset: g, confirmPasswordReset: b } = de(), C = ((se = pe()) == null ? void 0 : se.tenant) ?? null, o = { ...mr, ...r }, p = Le("#f59e0b", e), E = we({
|
|
3412
3417
|
defaultErrorMessage: o.errorMessage,
|
|
3413
|
-
validate: () =>
|
|
3418
|
+
validate: () => A.trim() ? C != null && C.id ? !0 : (E.setError(o.tenantNotFoundError), !1) : (E.setFieldError("email", !0), !1),
|
|
3414
3419
|
submit: async () => {
|
|
3415
|
-
m(""), await g({ email:
|
|
3420
|
+
m(""), await g({ email: A, tenantId: C.id }), m(o.successMessage);
|
|
3416
3421
|
},
|
|
3417
3422
|
onSuccess: () => i == null ? void 0 : i(),
|
|
3418
3423
|
onError: a
|
|
@@ -3481,7 +3486,7 @@ function en({
|
|
|
3481
3486
|
type: "password",
|
|
3482
3487
|
value: I,
|
|
3483
3488
|
onChange: ($) => {
|
|
3484
|
-
|
|
3489
|
+
R($.target.value), y.clearFieldError("confirmPassword"), y.error === o.passwordMismatchError && y.setError("");
|
|
3485
3490
|
},
|
|
3486
3491
|
placeholder: o.confirmPasswordPlaceholder,
|
|
3487
3492
|
style: F("confirmPassword"),
|
|
@@ -3505,7 +3510,7 @@ function en({
|
|
|
3505
3510
|
const u = (F) => ({
|
|
3506
3511
|
...p.input,
|
|
3507
3512
|
...E.fieldErrors[F] ? p.inputError : {}
|
|
3508
|
-
}), v = !
|
|
3513
|
+
}), v = !A || E.loading, D = {
|
|
3509
3514
|
...p.button,
|
|
3510
3515
|
...E.loading ? p.buttonLoading : {},
|
|
3511
3516
|
...v ? p.buttonDisabled : {}
|
|
@@ -3520,7 +3525,7 @@ function en({
|
|
|
3520
3525
|
"input",
|
|
3521
3526
|
{
|
|
3522
3527
|
type: "email",
|
|
3523
|
-
value:
|
|
3528
|
+
value: A,
|
|
3524
3529
|
onChange: (F) => {
|
|
3525
3530
|
c(F.target.value), E.clearFieldError("email");
|
|
3526
3531
|
},
|
|
@@ -3595,8 +3600,8 @@ function tn({
|
|
|
3595
3600
|
errorFallback: t,
|
|
3596
3601
|
requireTenant: n = !0
|
|
3597
3602
|
}) {
|
|
3598
|
-
const { isAppLoading: i, appError: a, retryApp: l } =
|
|
3599
|
-
}), I = (T == null ? void 0 : T.isAuthReady) ?? !0,
|
|
3603
|
+
const { isAppLoading: i, appError: a, retryApp: l } = Ae(), d = pe(), T = Oe(), A = at(), c = lt(), S = (d == null ? void 0 : d.isTenantLoading) ?? !1, h = (d == null ? void 0 : d.tenantError) ?? null, x = (d == null ? void 0 : d.tenantSlug) ?? null, P = (d == null ? void 0 : d.retryTenant) ?? (() => {
|
|
3604
|
+
}), I = (T == null ? void 0 : T.isAuthReady) ?? !0, R = (A == null ? void 0 : A.isReady) ?? !0, k = (c == null ? void 0 : c.isReady) ?? !0, m = n && d && x, o = i || m && S || T && !I || A && !R || c && !k, p = a || (m ? h : null), E = () => {
|
|
3600
3605
|
a && l(), h && d && P();
|
|
3601
3606
|
};
|
|
3602
3607
|
if (o)
|
|
@@ -3608,8 +3613,8 @@ function tn({
|
|
|
3608
3613
|
return /* @__PURE__ */ s(B, { children: r });
|
|
3609
3614
|
}
|
|
3610
3615
|
function rn(r = !0) {
|
|
3611
|
-
const { isAppLoading: e, appError: t, retryApp: n, appInfo: i } =
|
|
3612
|
-
}), P = (l == null ? void 0 : l.isAuthReady) ?? !0, I = (d == null ? void 0 : d.isReady) ?? !0,
|
|
3616
|
+
const { isAppLoading: e, appError: t, retryApp: n, appInfo: i } = Ae(), a = pe(), l = Oe(), d = at(), T = lt(), A = (a == null ? void 0 : a.isTenantLoading) ?? !1, c = (a == null ? void 0 : a.tenantError) ?? null, S = (a == null ? void 0 : a.tenant) ?? null, h = (a == null ? void 0 : a.tenantSlug) ?? null, x = (a == null ? void 0 : a.retryTenant) ?? (() => {
|
|
3617
|
+
}), P = (l == null ? void 0 : l.isAuthReady) ?? !0, I = (d == null ? void 0 : d.isReady) ?? !0, R = (T == null ? void 0 : T.isReady) ?? !0, k = r && a && h, C = e || k && A || l && !P || d && !I || T && !R, o = t || (k ? c : null);
|
|
3613
3618
|
return {
|
|
3614
3619
|
isLoading: C,
|
|
3615
3620
|
error: o,
|
|
@@ -3619,10 +3624,10 @@ function rn(r = !0) {
|
|
|
3619
3624
|
},
|
|
3620
3625
|
// Individual states
|
|
3621
3626
|
app: { isLoading: e, error: t, data: i },
|
|
3622
|
-
tenant: a ? { isLoading:
|
|
3627
|
+
tenant: a ? { isLoading: A, error: c, data: S } : null,
|
|
3623
3628
|
auth: l ? { isReady: P } : null,
|
|
3624
3629
|
featureFlags: d ? { isReady: I } : null,
|
|
3625
|
-
subscription: T ? { isReady:
|
|
3630
|
+
subscription: T ? { isReady: R } : null
|
|
3626
3631
|
};
|
|
3627
3632
|
}
|
|
3628
3633
|
const br = {
|
|
@@ -3679,11 +3684,11 @@ function nn({
|
|
|
3679
3684
|
itemClassName: l = "",
|
|
3680
3685
|
renderItem: d,
|
|
3681
3686
|
placeholder: T = "Select tenant",
|
|
3682
|
-
disabled:
|
|
3687
|
+
disabled: A = !1,
|
|
3683
3688
|
showCurrentTenant: c = !0
|
|
3684
3689
|
}) {
|
|
3685
3690
|
var C;
|
|
3686
|
-
const S = { ...br, ...n }, h = Oe(), [x, P] = N(!1), I = Ee(null),
|
|
3691
|
+
const S = { ...br, ...n }, h = Oe(), [x, P] = N(!1), I = Ee(null), R = r ?? (h == null ? void 0 : h.userTenants) ?? [], k = e ?? ((C = h == null ? void 0 : h.currentUser) == null ? void 0 : C.tenantId) ?? null, m = async (o) => {
|
|
3687
3692
|
P(!1), t ? t(o) : h != null && h.switchToTenant && await h.switchToTenant(o);
|
|
3688
3693
|
};
|
|
3689
3694
|
re(() => {
|
|
@@ -3692,11 +3697,11 @@ function nn({
|
|
|
3692
3697
|
};
|
|
3693
3698
|
return document.addEventListener("mousedown", o), () => document.removeEventListener("mousedown", o);
|
|
3694
3699
|
}, []);
|
|
3695
|
-
const g =
|
|
3696
|
-
if (
|
|
3700
|
+
const g = R.find((o) => o.id === k);
|
|
3701
|
+
if (R.length === 0)
|
|
3697
3702
|
return null;
|
|
3698
|
-
if (
|
|
3699
|
-
return /* @__PURE__ */ s("div", { className: i, children: /* @__PURE__ */ s("span", { children:
|
|
3703
|
+
if (R.length === 1 && c)
|
|
3704
|
+
return /* @__PURE__ */ s("div", { className: i, children: /* @__PURE__ */ s("span", { children: R[0].name }) });
|
|
3700
3705
|
const b = (o, p) => /* @__PURE__ */ f("span", { style: { fontWeight: p ? "bold" : "normal" }, children: [
|
|
3701
3706
|
o.name,
|
|
3702
3707
|
o.role && /* @__PURE__ */ f("span", { style: S.itemRole, children: [
|
|
@@ -3710,11 +3715,11 @@ function nn({
|
|
|
3710
3715
|
"button",
|
|
3711
3716
|
{
|
|
3712
3717
|
type: "button",
|
|
3713
|
-
onClick: () => !
|
|
3714
|
-
disabled:
|
|
3718
|
+
onClick: () => !A && P(!x),
|
|
3719
|
+
disabled: A,
|
|
3715
3720
|
style: {
|
|
3716
3721
|
...S.button,
|
|
3717
|
-
...
|
|
3722
|
+
...A ? S.buttonDisabled : {}
|
|
3718
3723
|
},
|
|
3719
3724
|
children: [
|
|
3720
3725
|
g ? g.name : T,
|
|
@@ -3722,7 +3727,7 @@ function nn({
|
|
|
3722
3727
|
]
|
|
3723
3728
|
}
|
|
3724
3729
|
),
|
|
3725
|
-
x && /* @__PURE__ */ s("div", { className: a, style: S.dropdown, children:
|
|
3730
|
+
x && /* @__PURE__ */ s("div", { className: a, style: S.dropdown, children: R.map((o) => {
|
|
3726
3731
|
const p = o.id === k;
|
|
3727
3732
|
return /* @__PURE__ */ s(
|
|
3728
3733
|
"div",
|
|
@@ -3830,7 +3835,7 @@ function ln(r = {}) {
|
|
|
3830
3835
|
zoneRoots: e = {},
|
|
3831
3836
|
returnToParam: t = dt,
|
|
3832
3837
|
returnToStorage: n = "url"
|
|
3833
|
-
} = r, i = wt(), [a, l] = vt(), { isAuthenticated: d, currentUser: T } = de(), { tenant:
|
|
3838
|
+
} = r, i = wt(), [a, l] = vt(), { isAuthenticated: d, currentUser: T } = de(), { tenant: A } = ve(), c = V(() => ({ ...ze, ...e }), [e]), S = !!A, h = T == null ? void 0 : T.userType, x = V(() => {
|
|
3834
3839
|
switch (n) {
|
|
3835
3840
|
case "url":
|
|
3836
3841
|
return a.get(t);
|
|
@@ -3872,7 +3877,7 @@ function ln(r = {}) {
|
|
|
3872
3877
|
}
|
|
3873
3878
|
},
|
|
3874
3879
|
[n, a, t, l]
|
|
3875
|
-
),
|
|
3880
|
+
), R = te(
|
|
3876
3881
|
(m) => {
|
|
3877
3882
|
const g = c[m] || c.default;
|
|
3878
3883
|
i(g);
|
|
@@ -3883,7 +3888,7 @@ function ln(r = {}) {
|
|
|
3883
3888
|
returnToUrl: x,
|
|
3884
3889
|
clearReturnTo: P,
|
|
3885
3890
|
setReturnTo: I,
|
|
3886
|
-
navigateToZone:
|
|
3891
|
+
navigateToZone: R,
|
|
3887
3892
|
getSmartRedirect: k
|
|
3888
3893
|
};
|
|
3889
3894
|
}
|
|
@@ -3899,7 +3904,7 @@ export {
|
|
|
3899
3904
|
tn as AppLoader,
|
|
3900
3905
|
Sr as AppProvider,
|
|
3901
3906
|
Nt as AuthApiService,
|
|
3902
|
-
|
|
3907
|
+
Rr as AuthProvider,
|
|
3903
3908
|
Or as AuthenticatedZone,
|
|
3904
3909
|
oe as ConfigurationError,
|
|
3905
3910
|
ct as DEFAULT_ZONE_PRESETS,
|
|
@@ -3945,7 +3950,7 @@ export {
|
|
|
3945
3950
|
ue as ZoneRoute,
|
|
3946
3951
|
cn as buildRedirectUrl,
|
|
3947
3952
|
kr as useApi,
|
|
3948
|
-
|
|
3953
|
+
Ae as useApp,
|
|
3949
3954
|
rn as useAppLoaderState,
|
|
3950
3955
|
de as useAuth,
|
|
3951
3956
|
Ir as useAuthActions,
|
|
@@ -3954,7 +3959,7 @@ export {
|
|
|
3954
3959
|
Vt as useFeatureFlags,
|
|
3955
3960
|
Cr as useRouting,
|
|
3956
3961
|
Wt as useRoutingOptional,
|
|
3957
|
-
|
|
3962
|
+
Ar as useSettings,
|
|
3958
3963
|
zt as useSubscription,
|
|
3959
3964
|
ve as useTenant,
|
|
3960
3965
|
ot as useTenantInfo,
|