@skylabs-digital/react-identity-access 2.27.0 → 2.28.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 +350 -337
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/services/SessionManager.d.ts +2 -0
- package/dist/services/SessionManager.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as s, Fragment as _, jsxs as u } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as ye, useMemo as Z, useState as x, useCallback as
|
|
2
|
+
import { createContext as ye, useMemo as Z, useState as x, useCallback as oe, useEffect as ne, useContext as le, useRef as Ne } from "react";
|
|
3
3
|
import { useLocation as xe, Navigate as Se, useNavigate as mt, useSearchParams as yt } from "react-router-dom";
|
|
4
4
|
class de {
|
|
5
5
|
constructor(e, t = 1e4) {
|
|
@@ -31,8 +31,8 @@ class de {
|
|
|
31
31
|
});
|
|
32
32
|
if (clearTimeout(y), !f.ok)
|
|
33
33
|
throw new Error(`HTTP ${f.status}: ${f.statusText}`);
|
|
34
|
-
const
|
|
35
|
-
return !
|
|
34
|
+
const F = f.headers.get("content-type");
|
|
35
|
+
return !F || !F.includes("application/json") ? {} : await f.json();
|
|
36
36
|
} catch (f) {
|
|
37
37
|
throw clearTimeout(y), f instanceof Error && f.name === "AbortError" ? new Error(`Request timeout after ${a}ms`) : f;
|
|
38
38
|
}
|
|
@@ -109,7 +109,7 @@ class Ve {
|
|
|
109
109
|
})).data;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
const
|
|
112
|
+
const Fe = ye(null);
|
|
113
113
|
function br({ config: n, children: e }) {
|
|
114
114
|
const t = Z(
|
|
115
115
|
() => {
|
|
@@ -145,7 +145,7 @@ function br({ config: n, children: e }) {
|
|
|
145
145
|
appError: c,
|
|
146
146
|
retryApp: g
|
|
147
147
|
};
|
|
148
|
-
}, [n, r, o, c]), f =
|
|
148
|
+
}, [n, r, o, c]), f = oe(
|
|
149
149
|
async (g = !1) => {
|
|
150
150
|
if (!(!g && t.enabled && r))
|
|
151
151
|
try {
|
|
@@ -170,7 +170,7 @@ function br({ config: n, children: e }) {
|
|
|
170
170
|
}
|
|
171
171
|
},
|
|
172
172
|
[n.baseUrl, n.appId, t, r]
|
|
173
|
-
),
|
|
173
|
+
), F = oe(async () => {
|
|
174
174
|
if (!(!t.enabled || !r))
|
|
175
175
|
try {
|
|
176
176
|
const g = localStorage.getItem(t.storageKey);
|
|
@@ -191,17 +191,17 @@ function br({ config: n, children: e }) {
|
|
|
191
191
|
}
|
|
192
192
|
}, [n, t, r]);
|
|
193
193
|
return ne(() => {
|
|
194
|
-
r ?
|
|
195
|
-
}, []), /* @__PURE__ */ s(
|
|
194
|
+
r ? F() : f();
|
|
195
|
+
}, []), /* @__PURE__ */ s(Fe.Provider, { value: y, children: e });
|
|
196
196
|
}
|
|
197
197
|
function Ae() {
|
|
198
|
-
const n = le(
|
|
198
|
+
const n = le(Fe);
|
|
199
199
|
if (!n)
|
|
200
200
|
throw new Error("useApp must be used within an AppProvider");
|
|
201
201
|
return n;
|
|
202
202
|
}
|
|
203
|
-
function
|
|
204
|
-
return le(
|
|
203
|
+
function De() {
|
|
204
|
+
return le(Fe);
|
|
205
205
|
}
|
|
206
206
|
const vr = Ae;
|
|
207
207
|
class se extends Error {
|
|
@@ -226,9 +226,9 @@ class bt extends Error {
|
|
|
226
226
|
), this.name = "TokenRefreshError", this.attempts = e, this.lastError = t;
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
|
-
const
|
|
229
|
+
const ie = class ie {
|
|
230
230
|
constructor(e = {}) {
|
|
231
|
-
this.refreshPromise = null, this.refreshQueue = [], this.proactiveTimerId = null, this.backgroundRetryTimerId = null, this.isDestroyed = !1, this.sessionGeneration = 0, 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();
|
|
231
|
+
this.refreshPromise = null, this.refreshQueue = [], this.proactiveTimerId = null, this.backgroundRetryTimerId = null, this.isDestroyed = !1, this.sessionGeneration = 0, this.consecutiveBackgroundFailures = 0, 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
|
}
|
|
233
233
|
/**
|
|
234
234
|
* Get or create a SessionManager instance for the given config.
|
|
@@ -236,17 +236,17 @@ const oe = class oe {
|
|
|
236
236
|
* Mutable config (callbacks, baseUrl) is updated on the existing instance.
|
|
237
237
|
*/
|
|
238
238
|
static getInstance(e = {}) {
|
|
239
|
-
const t =
|
|
239
|
+
const t = ie.resolveStorageKey(e), r = ie.instances.get(t);
|
|
240
240
|
if (r)
|
|
241
241
|
return r.updateConfig(e), r;
|
|
242
|
-
const i = new
|
|
243
|
-
return
|
|
242
|
+
const i = new ie(e);
|
|
243
|
+
return ie.instances.set(t, i), i;
|
|
244
244
|
}
|
|
245
245
|
/** Reset all singleton instances. For testing only. */
|
|
246
246
|
static resetAllInstances() {
|
|
247
|
-
for (const e of
|
|
247
|
+
for (const e of ie.instances.values())
|
|
248
248
|
e.destroy();
|
|
249
|
-
|
|
249
|
+
ie.instances.clear();
|
|
250
250
|
}
|
|
251
251
|
static resolveStorageKey(e) {
|
|
252
252
|
return e.storageKey ? e.storageKey : e.tenantSlug !== void 0 && e.tenantSlug ? `auth_tokens_${e.tenantSlug}` : "auth_tokens";
|
|
@@ -296,7 +296,7 @@ const oe = class oe {
|
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
298
|
setTokens(e) {
|
|
299
|
-
const t = e.expiresAt || (e.expiresIn ? Date.now() + e.expiresIn * 1e3 : void 0) ||
|
|
299
|
+
const t = e.expiresAt || (e.expiresIn ? Date.now() + e.expiresIn * 1e3 : void 0) || ie.extractJwtExpiry(e.accessToken), r = {
|
|
300
300
|
...e,
|
|
301
301
|
expiresAt: t
|
|
302
302
|
}, i = this.tokenStorage.get() || {};
|
|
@@ -306,7 +306,7 @@ const oe = class oe {
|
|
|
306
306
|
const { accessToken: e, refreshToken: t, expiresAt: r, expiresIn: i, tokenType: o } = this.tokenStorage.get() || {};
|
|
307
307
|
if (!e)
|
|
308
308
|
return null;
|
|
309
|
-
const a = r ||
|
|
309
|
+
const a = r || ie.extractJwtExpiry(e);
|
|
310
310
|
return {
|
|
311
311
|
accessToken: e,
|
|
312
312
|
refreshToken: t,
|
|
@@ -353,13 +353,26 @@ const oe = class oe {
|
|
|
353
353
|
if (!(e != null && e.refreshToken) || this.refreshPromise) return;
|
|
354
354
|
const t = this.sessionGeneration;
|
|
355
355
|
this.startRefreshAndResolveQueue(e.refreshToken).then(() => {
|
|
356
|
+
this.consecutiveBackgroundFailures = 0;
|
|
356
357
|
}).catch((r) => {
|
|
357
|
-
r instanceof se
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
358
|
+
if (!(r instanceof se)) {
|
|
359
|
+
if (this.sessionGeneration === t) {
|
|
360
|
+
if (this.consecutiveBackgroundFailures++, this.consecutiveBackgroundFailures >= ie.MAX_BACKGROUND_FAILURES) {
|
|
361
|
+
process.env.NODE_ENV === "development" && console.error(
|
|
362
|
+
`[SessionManager] Background refresh failed ${this.consecutiveBackgroundFailures} consecutive times — expiring session`
|
|
363
|
+
), this.consecutiveBackgroundFailures = 0, this.handleSessionExpired(
|
|
364
|
+
new se("token_invalid", "Background refresh failed repeatedly")
|
|
365
|
+
);
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
process.env.NODE_ENV === "development" && console.warn(
|
|
369
|
+
"[SessionManager] Background refresh failed, retrying in 30s:",
|
|
370
|
+
r.message
|
|
371
|
+
), this.backgroundRetryTimerId = setTimeout(() => {
|
|
372
|
+
this.backgroundRefresh();
|
|
373
|
+
}, 3e4);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
363
376
|
});
|
|
364
377
|
}
|
|
365
378
|
/**
|
|
@@ -490,7 +503,7 @@ const oe = class oe {
|
|
|
490
503
|
} catch {
|
|
491
504
|
a = i.statusText.toLowerCase();
|
|
492
505
|
}
|
|
493
|
-
throw i.status === 401 ? a.includes("expired") ? new se("token_expired") : a.includes("invalid") ? new se("token_invalid") : new se("token_invalid", `Unauthorized: ${a}`) : i.status === 400 ? a.includes("inactive") ? new se("user_inactive") : a.includes("expired") || a.includes("invalid") ? new se("token_invalid", a) : new Error(`Token refresh failed (400): ${a}`) : new Error(`Token refresh failed: ${i.status} ${a}`);
|
|
506
|
+
throw i.status === 401 ? a.includes("expired") ? new se("token_expired") : a.includes("invalid") ? new se("token_invalid") : new se("token_invalid", `Unauthorized: ${a}`) : i.status === 400 ? a.includes("inactive") ? new se("user_inactive") : a.includes("expired") || a.includes("invalid") ? new se("token_invalid", a) : a.includes("reuse") || a.includes("revoked") ? new se("token_invalid", a) : new Error(`Token refresh failed (400): ${a}`) : new Error(`Token refresh failed: ${i.status} ${a}`);
|
|
494
507
|
}
|
|
495
508
|
if (this.sessionGeneration !== t)
|
|
496
509
|
throw new se("token_invalid", "Session cleared during refresh");
|
|
@@ -529,7 +542,7 @@ const oe = class oe {
|
|
|
529
542
|
* Cancels all timers and rejects pending queue entries.
|
|
530
543
|
*/
|
|
531
544
|
destroy() {
|
|
532
|
-
this.isDestroyed = !0,
|
|
545
|
+
this.isDestroyed = !0, ie.instances.delete(this.storageKey), this.cancelProactiveTimer();
|
|
533
546
|
const e = new se("token_invalid", "SessionManager destroyed");
|
|
534
547
|
this.rejectQueue(e);
|
|
535
548
|
}
|
|
@@ -568,8 +581,8 @@ const oe = class oe {
|
|
|
568
581
|
return new Promise((t) => setTimeout(t, e));
|
|
569
582
|
}
|
|
570
583
|
};
|
|
571
|
-
|
|
572
|
-
let be =
|
|
584
|
+
ie.instances = /* @__PURE__ */ new Map(), ie.MAX_BACKGROUND_FAILURES = 3;
|
|
585
|
+
let be = ie;
|
|
573
586
|
const Ie = /* @__PURE__ */ new Map();
|
|
574
587
|
class vt {
|
|
575
588
|
constructor(e) {
|
|
@@ -882,7 +895,7 @@ function Et() {
|
|
|
882
895
|
}
|
|
883
896
|
const Ue = ye(null);
|
|
884
897
|
function Sr({ config: n, children: e }) {
|
|
885
|
-
const { baseUrl: t, appInfo: r, appId: i } = Ae(), o =
|
|
898
|
+
const { baseUrl: t, appInfo: r, appId: i } = Ae(), o = oe(() => typeof window > "u" ? null : xt(
|
|
886
899
|
{
|
|
887
900
|
tenantMode: n.tenantMode || "selector",
|
|
888
901
|
baseDomain: n.baseDomain,
|
|
@@ -916,13 +929,13 @@ function Sr({ config: n, children: e }) {
|
|
|
916
929
|
} catch {
|
|
917
930
|
return null;
|
|
918
931
|
}
|
|
919
|
-
}), [
|
|
932
|
+
}), [F, g] = x(!y && !n.initialTenant), [T, A] = x(null), [L, M] = x(null), [P, d] = x(!1), [v, N] = x(null);
|
|
920
933
|
ne(() => {
|
|
921
934
|
if (n.tenantMode === "fixed") return;
|
|
922
935
|
const p = o();
|
|
923
936
|
c(p);
|
|
924
937
|
}, [o, n.tenantMode]);
|
|
925
|
-
const
|
|
938
|
+
const B = (r == null ? void 0 : r.settingsSchema) || null, w = oe(
|
|
926
939
|
async (p, U = !1) => {
|
|
927
940
|
if (!(!U && m.enabled && y && y.domain === p))
|
|
928
941
|
try {
|
|
@@ -947,7 +960,7 @@ function Sr({ config: n, children: e }) {
|
|
|
947
960
|
}
|
|
948
961
|
},
|
|
949
962
|
[t, i, m, y]
|
|
950
|
-
), R =
|
|
963
|
+
), R = oe(async () => {
|
|
951
964
|
if (!(!m.enabled || !y || !a))
|
|
952
965
|
try {
|
|
953
966
|
const p = localStorage.getItem(m.storageKey);
|
|
@@ -956,17 +969,17 @@ function Sr({ config: n, children: e }) {
|
|
|
956
969
|
if (Date.now() - U.timestamp > m.ttl * 0.5) {
|
|
957
970
|
const h = new de(t), E = await new ve(h, i).getPublicTenantInfo(a);
|
|
958
971
|
f(E);
|
|
959
|
-
const
|
|
972
|
+
const K = {
|
|
960
973
|
data: E,
|
|
961
974
|
timestamp: Date.now(),
|
|
962
975
|
tenantSlug: a
|
|
963
976
|
};
|
|
964
|
-
localStorage.setItem(m.storageKey, JSON.stringify(
|
|
977
|
+
localStorage.setItem(m.storageKey, JSON.stringify(K));
|
|
965
978
|
}
|
|
966
979
|
} catch (p) {
|
|
967
980
|
process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Background tenant refresh failed:", p);
|
|
968
981
|
}
|
|
969
|
-
}, [t, i, m, y, a]), k =
|
|
982
|
+
}, [t, i, m, y, a]), k = oe(async () => {
|
|
970
983
|
if (y != null && y.id)
|
|
971
984
|
try {
|
|
972
985
|
d(!0), N(null);
|
|
@@ -978,25 +991,25 @@ function Sr({ config: n, children: e }) {
|
|
|
978
991
|
} finally {
|
|
979
992
|
d(!1);
|
|
980
993
|
}
|
|
981
|
-
}, [t, y]), I =
|
|
994
|
+
}, [t, y]), I = oe(() => {
|
|
982
995
|
k();
|
|
983
|
-
}, [k]), l =
|
|
996
|
+
}, [k]), l = oe(
|
|
984
997
|
(p) => {
|
|
985
|
-
if (
|
|
998
|
+
if (!B)
|
|
986
999
|
return { isValid: !0, errors: [] };
|
|
987
1000
|
const U = [];
|
|
988
1001
|
try {
|
|
989
|
-
return
|
|
1002
|
+
return B.properties && Object.entries(B.properties).forEach(([b, h]) => {
|
|
990
1003
|
var E;
|
|
991
1004
|
const S = p[b];
|
|
992
|
-
if ((E =
|
|
1005
|
+
if ((E = B.required) != null && E.includes(b) && S == null) {
|
|
993
1006
|
U.push(`Field '${b}' is required`);
|
|
994
1007
|
return;
|
|
995
1008
|
}
|
|
996
1009
|
if (S != null) {
|
|
997
1010
|
if (h.type) {
|
|
998
|
-
const
|
|
999
|
-
|
|
1011
|
+
const K = h.type, G = typeof S;
|
|
1012
|
+
K === "string" && G !== "string" ? U.push(`Field '${b}' must be a string`) : (K === "number" || K === "integer") && G !== "number" ? U.push(`Field '${b}' must be a number`) : K === "boolean" && G !== "boolean" ? U.push(`Field '${b}' must be a boolean`) : K === "array" && !Array.isArray(S) && U.push(`Field '${b}' must be an array`);
|
|
1000
1013
|
}
|
|
1001
1014
|
h.minLength !== void 0 && typeof S == "string" && S.length < h.minLength && U.push(
|
|
1002
1015
|
`Field '${b}' must be at least ${h.minLength} characters long`
|
|
@@ -1015,14 +1028,14 @@ function Sr({ config: n, children: e }) {
|
|
|
1015
1028
|
};
|
|
1016
1029
|
}
|
|
1017
1030
|
},
|
|
1018
|
-
[
|
|
1031
|
+
[B]
|
|
1019
1032
|
);
|
|
1020
1033
|
ne(() => {
|
|
1021
1034
|
!n.initialTenant && a ? y ? R() : w(a) : !n.initialTenant && !a && (f(null), A(null), g(!1));
|
|
1022
1035
|
}, [n.initialTenant, a, y, w, R]), ne(() => {
|
|
1023
1036
|
y != null && y.id ? k() : (M(null), N(null), d(!1));
|
|
1024
1037
|
}, [y == null ? void 0 : y.id, k]);
|
|
1025
|
-
const z =
|
|
1038
|
+
const z = oe(
|
|
1026
1039
|
(p, U) => {
|
|
1027
1040
|
const { mode: b = "reload", tokens: h, redirectPath: S } = U || {}, E = n.tenantMode || "selector";
|
|
1028
1041
|
if (E === "fixed") {
|
|
@@ -1033,46 +1046,46 @@ function Sr({ config: n, children: e }) {
|
|
|
1033
1046
|
return;
|
|
1034
1047
|
}
|
|
1035
1048
|
if (localStorage.setItem("tenant", p), E === "subdomain") {
|
|
1036
|
-
const
|
|
1049
|
+
const K = window.location.hostname, G = At(
|
|
1037
1050
|
p,
|
|
1038
|
-
|
|
1051
|
+
K,
|
|
1039
1052
|
n.baseDomain
|
|
1040
1053
|
);
|
|
1041
1054
|
if (!G) {
|
|
1042
1055
|
process.env.NODE_ENV === "development" && console.warn(
|
|
1043
1056
|
"[TenantProvider] Cannot switch subdomain, invalid hostname:",
|
|
1044
|
-
|
|
1057
|
+
K
|
|
1045
1058
|
);
|
|
1046
1059
|
return;
|
|
1047
1060
|
}
|
|
1048
1061
|
const X = S || window.location.pathname, W = new URL(`${window.location.protocol}//${G}${X}`);
|
|
1049
|
-
new URLSearchParams(window.location.search).forEach((V,
|
|
1050
|
-
|
|
1062
|
+
new URLSearchParams(window.location.search).forEach((V, H) => {
|
|
1063
|
+
H !== me && W.searchParams.set(H, V);
|
|
1051
1064
|
}), h && W.searchParams.set(me, je(h)), window.location.href = W.toString();
|
|
1052
1065
|
} else if (E === "selector") {
|
|
1053
|
-
const
|
|
1066
|
+
const K = S || window.location.pathname, G = new URLSearchParams(window.location.search);
|
|
1054
1067
|
if (G.set(n.selectorParam || "tenant", p), G.delete(me), h && G.set(me, je(h)), b === "reload") {
|
|
1055
|
-
const X = `${
|
|
1068
|
+
const X = `${K}?${G.toString()}${window.location.hash}`;
|
|
1056
1069
|
window.location.href = X;
|
|
1057
1070
|
} else {
|
|
1058
|
-
const X = `${
|
|
1071
|
+
const X = `${K}?${G.toString()}${window.location.hash}`;
|
|
1059
1072
|
window.history.pushState({}, "", X), c(p), w(p);
|
|
1060
1073
|
}
|
|
1061
1074
|
}
|
|
1062
1075
|
},
|
|
1063
1076
|
[n.tenantMode, n.selectorParam, n.baseDomain, w]
|
|
1064
|
-
),
|
|
1077
|
+
), D = Z(() => ({
|
|
1065
1078
|
// Tenant info
|
|
1066
1079
|
tenant: y,
|
|
1067
1080
|
tenantSlug: a,
|
|
1068
|
-
isTenantLoading:
|
|
1081
|
+
isTenantLoading: F,
|
|
1069
1082
|
tenantError: T,
|
|
1070
1083
|
retryTenant: () => {
|
|
1071
1084
|
a && w(a);
|
|
1072
1085
|
},
|
|
1073
1086
|
// Settings
|
|
1074
1087
|
settings: L,
|
|
1075
|
-
settingsSchema:
|
|
1088
|
+
settingsSchema: B,
|
|
1076
1089
|
isSettingsLoading: P,
|
|
1077
1090
|
settingsError: v,
|
|
1078
1091
|
// Actions
|
|
@@ -1083,17 +1096,17 @@ function Sr({ config: n, children: e }) {
|
|
|
1083
1096
|
}), [
|
|
1084
1097
|
y,
|
|
1085
1098
|
a,
|
|
1086
|
-
|
|
1099
|
+
F,
|
|
1087
1100
|
T,
|
|
1088
1101
|
L,
|
|
1089
|
-
|
|
1102
|
+
B,
|
|
1090
1103
|
P,
|
|
1091
1104
|
v,
|
|
1092
1105
|
I,
|
|
1093
1106
|
z,
|
|
1094
1107
|
l
|
|
1095
1108
|
]);
|
|
1096
|
-
return /* @__PURE__ */ s(Ue.Provider, { value:
|
|
1109
|
+
return /* @__PURE__ */ s(Ue.Provider, { value: D, children: e });
|
|
1097
1110
|
}
|
|
1098
1111
|
function Te() {
|
|
1099
1112
|
const n = le(Ue);
|
|
@@ -1125,25 +1138,25 @@ function Je() {
|
|
|
1125
1138
|
retry: i
|
|
1126
1139
|
};
|
|
1127
1140
|
}
|
|
1128
|
-
const
|
|
1141
|
+
const Be = ye(null);
|
|
1129
1142
|
function xr({ config: n = {}, children: e }) {
|
|
1130
|
-
const t =
|
|
1143
|
+
const t = De(), r = pe(), i = (t == null ? void 0 : t.baseUrl) ?? n.baseUrl ?? "", o = (t == null ? void 0 : t.appId) ?? n.appId, a = (r == null ? void 0 : r.tenant) ?? null, c = (r == null ? void 0 : r.tenantSlug) ?? null, m = (r == null ? void 0 : r.switchTenant) ?? (() => {
|
|
1131
1144
|
});
|
|
1132
1145
|
if (!i)
|
|
1133
1146
|
throw new Error(
|
|
1134
1147
|
"[AuthProvider] baseUrl is required. Provide it via AppProvider or AuthConfig.baseUrl."
|
|
1135
1148
|
);
|
|
1136
|
-
const [y, f] = x(n.initialRoles || []), [
|
|
1149
|
+
const [y, f] = x(n.initialRoles || []), [F, g] = x(!n.initialRoles), [T, A] = x(null), [L, M] = x(!1), [P, d] = x(null), [v, N] = x(() => {
|
|
1137
1150
|
try {
|
|
1138
|
-
const
|
|
1139
|
-
return
|
|
1151
|
+
const $ = localStorage.getItem("userTenants");
|
|
1152
|
+
return $ ? JSON.parse($) : [];
|
|
1140
1153
|
} catch {
|
|
1141
1154
|
return [];
|
|
1142
1155
|
}
|
|
1143
|
-
}), [
|
|
1156
|
+
}), [B, w] = x(!1), R = Ne({ done: !1, urlTokens: null });
|
|
1144
1157
|
R.current.done || (R.current.done = !0, R.current.urlTokens = Rt());
|
|
1145
1158
|
const [k, I] = x(() => R.current.urlTokens !== null), l = Z(() => {
|
|
1146
|
-
const
|
|
1159
|
+
const $ = be.getInstance({
|
|
1147
1160
|
tenantSlug: c,
|
|
1148
1161
|
baseUrl: i,
|
|
1149
1162
|
refreshQueueTimeout: n.refreshQueueTimeout,
|
|
@@ -1157,23 +1170,23 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1157
1170
|
n.onSessionExpired ? n.onSessionExpired(ce) : n.onRefreshFailed && n.onRefreshFailed();
|
|
1158
1171
|
}
|
|
1159
1172
|
});
|
|
1160
|
-
return R.current.urlTokens &&
|
|
1173
|
+
return R.current.urlTokens && $.setTokens({
|
|
1161
1174
|
accessToken: R.current.urlTokens.accessToken,
|
|
1162
1175
|
refreshToken: R.current.urlTokens.refreshToken,
|
|
1163
1176
|
expiresIn: R.current.urlTokens.expiresIn
|
|
1164
|
-
}),
|
|
1165
|
-
}, [c, i, n.refreshQueueTimeout, n.proactiveRefreshMargin]), [z,
|
|
1177
|
+
}), $;
|
|
1178
|
+
}, [c, i, n.refreshQueueTimeout, n.proactiveRefreshMargin]), [z, D] = x(() => {
|
|
1166
1179
|
if (R.current.urlTokens) return !1;
|
|
1167
|
-
const
|
|
1168
|
-
return
|
|
1180
|
+
const $ = l.getTokens();
|
|
1181
|
+
return $ ? l.hasValidSession() || !!$.refreshToken : !1;
|
|
1169
1182
|
}), p = R.current.done && !k && !z, U = Z(() => {
|
|
1170
|
-
const
|
|
1171
|
-
return
|
|
1172
|
-
}, [i, l]), b = Z(() => new vt(new de(i)), [i]), h = Z(() => new St(U, l), [U, l]), S = Z(() => new We(new de(i)), [i]), E = Z(() => T || l.getUser(), [T, l]),
|
|
1183
|
+
const $ = new de(i);
|
|
1184
|
+
return $.setSessionManager(l), $;
|
|
1185
|
+
}, [i, l]), b = Z(() => new vt(new de(i)), [i]), h = Z(() => new St(U, l), [U, l]), S = Z(() => new We(new de(i)), [i]), E = Z(() => T || l.getUser(), [T, l]), K = Z(() => E != null && E.roleId && y.find(($) => $.id === E.roleId) || null, [E, y]), G = Z(() => (K == null ? void 0 : K.permissions) || [], [K]), X = Z(() => l.hasValidSession() && T !== null, [l, T]), W = Ne(async () => {
|
|
1173
1186
|
}), q = Z(() => {
|
|
1174
|
-
const
|
|
1187
|
+
const $ = async (C = !1) => {
|
|
1175
1188
|
try {
|
|
1176
|
-
if (!l.hasValidSession() || !
|
|
1189
|
+
if (!l.hasValidSession() || !C && T)
|
|
1177
1190
|
return;
|
|
1178
1191
|
const O = l.getUserId();
|
|
1179
1192
|
if (!O) {
|
|
@@ -1190,13 +1203,13 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1190
1203
|
M(!1);
|
|
1191
1204
|
}
|
|
1192
1205
|
}, ce = async () => {
|
|
1193
|
-
await
|
|
1194
|
-
}, fe = async (
|
|
1206
|
+
await $();
|
|
1207
|
+
}, fe = async (C) => {
|
|
1195
1208
|
var _e;
|
|
1196
|
-
const { username: O, password: J, tenantSlug: j, redirectPath: Y } =
|
|
1209
|
+
const { username: O, password: J, tenantSlug: j, redirectPath: Y } = C;
|
|
1197
1210
|
let ee = a == null ? void 0 : a.id, te = c, re = l;
|
|
1198
1211
|
j && (ee = (await new ve(U, o).getPublicTenantInfo(j)).id, te = j);
|
|
1199
|
-
const
|
|
1212
|
+
const Q = await b.login({
|
|
1200
1213
|
username: O,
|
|
1201
1214
|
password: J,
|
|
1202
1215
|
appId: o,
|
|
@@ -1206,45 +1219,45 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1206
1219
|
tenantSlug: te,
|
|
1207
1220
|
baseUrl: i
|
|
1208
1221
|
})), re.setTokens({
|
|
1209
|
-
accessToken:
|
|
1210
|
-
refreshToken:
|
|
1211
|
-
expiresIn:
|
|
1212
|
-
}),
|
|
1213
|
-
re.setUser(
|
|
1222
|
+
accessToken: Q.accessToken,
|
|
1223
|
+
refreshToken: Q.refreshToken,
|
|
1224
|
+
expiresIn: Q.expiresIn
|
|
1225
|
+
}), Q.user) {
|
|
1226
|
+
re.setUser(Q.user), A(Q.user);
|
|
1214
1227
|
try {
|
|
1215
|
-
await
|
|
1228
|
+
await $();
|
|
1216
1229
|
} catch (ke) {
|
|
1217
1230
|
process.env.NODE_ENV === "development" && console.warn("[AuthProvider] Failed to load complete user data after login:", ke);
|
|
1218
1231
|
}
|
|
1219
1232
|
}
|
|
1220
|
-
if (
|
|
1221
|
-
N(
|
|
1233
|
+
if (Q.tenants && Q.tenants.length > 0) {
|
|
1234
|
+
N(Q.tenants);
|
|
1222
1235
|
try {
|
|
1223
|
-
localStorage.setItem("userTenants", JSON.stringify(
|
|
1236
|
+
localStorage.setItem("userTenants", JSON.stringify(Q.tenants));
|
|
1224
1237
|
} catch {
|
|
1225
1238
|
}
|
|
1226
1239
|
}
|
|
1227
|
-
const Re = ((_e =
|
|
1240
|
+
const Re = ((_e = Q.user) == null ? void 0 : _e.tenantId) !== null;
|
|
1228
1241
|
w(Re);
|
|
1229
1242
|
const Ee = {
|
|
1230
|
-
accessToken:
|
|
1231
|
-
refreshToken:
|
|
1232
|
-
expiresIn:
|
|
1243
|
+
accessToken: Q.accessToken,
|
|
1244
|
+
refreshToken: Q.refreshToken,
|
|
1245
|
+
expiresIn: Q.expiresIn
|
|
1233
1246
|
};
|
|
1234
1247
|
if (we && te)
|
|
1235
|
-
return m(te, { tokens: Ee, redirectPath: Y }),
|
|
1248
|
+
return m(te, { tokens: Ee, redirectPath: Y }), Q;
|
|
1236
1249
|
if (Y && Y !== window.location.pathname)
|
|
1237
|
-
return m(te || c || "", { tokens: Ee, redirectPath: Y }),
|
|
1238
|
-
if (!Re &&
|
|
1239
|
-
const ke =
|
|
1240
|
-
if (
|
|
1241
|
-
const ze =
|
|
1242
|
-
return m(ze.subdomain, { tokens: Ee, redirectPath: Y }),
|
|
1243
|
-
} else
|
|
1250
|
+
return m(te || c || "", { tokens: Ee, redirectPath: Y }), Q;
|
|
1251
|
+
if (!Re && Q.tenants && Q.tenants.length > 0) {
|
|
1252
|
+
const ke = C.autoSwitch !== !1 && n.autoSwitchSingleTenant !== !1;
|
|
1253
|
+
if (Q.tenants.length === 1 && ke) {
|
|
1254
|
+
const ze = Q.tenants[0];
|
|
1255
|
+
return m(ze.subdomain, { tokens: Ee, redirectPath: Y }), Q;
|
|
1256
|
+
} else Q.tenants.length > 1 && n.onTenantSelectionRequired && n.onTenantSelectionRequired(Q.tenants);
|
|
1244
1257
|
}
|
|
1245
|
-
return
|
|
1246
|
-
}, ge = async (
|
|
1247
|
-
const { email: O, phoneNumber: J, name: j, password: Y, lastName: ee, tenantId: te } =
|
|
1258
|
+
return Q;
|
|
1259
|
+
}, ge = async (C) => {
|
|
1260
|
+
const { email: O, phoneNumber: J, name: j, password: Y, lastName: ee, tenantId: te } = C;
|
|
1248
1261
|
if (!O && !J)
|
|
1249
1262
|
throw new Error("Either email or phoneNumber is required");
|
|
1250
1263
|
if (!j || !Y)
|
|
@@ -1259,8 +1272,8 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1259
1272
|
lastName: ee,
|
|
1260
1273
|
appId: o
|
|
1261
1274
|
});
|
|
1262
|
-
}, nt = async (
|
|
1263
|
-
const { email: O, phoneNumber: J, name: j, password: Y, tenantName: ee, lastName: te } =
|
|
1275
|
+
}, nt = async (C) => {
|
|
1276
|
+
const { email: O, phoneNumber: J, name: j, password: Y, tenantName: ee, lastName: te } = C;
|
|
1264
1277
|
if (!O && !J)
|
|
1265
1278
|
throw new Error("Either email or phoneNumber is required");
|
|
1266
1279
|
if (!j || !Y || !ee)
|
|
@@ -1274,19 +1287,19 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1274
1287
|
appId: o,
|
|
1275
1288
|
lastName: te
|
|
1276
1289
|
});
|
|
1277
|
-
}, st = async (
|
|
1278
|
-
const { currentPassword: O, newPassword: J } =
|
|
1290
|
+
}, st = async (C) => {
|
|
1291
|
+
const { currentPassword: O, newPassword: J } = C, j = await l.getAuthHeaders();
|
|
1279
1292
|
await b.changePassword({ currentPassword: O, newPassword: J }, j);
|
|
1280
|
-
}, it = async (
|
|
1281
|
-
const { email: O, tenantId: J } =
|
|
1293
|
+
}, it = async (C) => {
|
|
1294
|
+
const { email: O, tenantId: J } = C, j = J ?? (a == null ? void 0 : a.id);
|
|
1282
1295
|
if (!j)
|
|
1283
1296
|
throw new Error("tenantId is required for password reset");
|
|
1284
1297
|
await b.requestPasswordReset({ email: O, tenantId: j });
|
|
1285
|
-
}, ot = async (
|
|
1286
|
-
const { token: O, newPassword: J } =
|
|
1298
|
+
}, ot = async (C) => {
|
|
1299
|
+
const { token: O, newPassword: J } = C;
|
|
1287
1300
|
await b.confirmPasswordReset({ token: O, newPassword: J });
|
|
1288
|
-
}, at = async (
|
|
1289
|
-
const { email: O, frontendUrl: J, name: j, lastName: Y, tenantId: ee } =
|
|
1301
|
+
}, at = async (C) => {
|
|
1302
|
+
const { email: O, frontendUrl: J, name: j, lastName: Y, tenantId: ee } = C, te = ee ?? (a == null ? void 0 : a.id);
|
|
1290
1303
|
if (!te)
|
|
1291
1304
|
throw new Error("tenantId is required for magic link authentication");
|
|
1292
1305
|
return await b.sendMagicLink({
|
|
@@ -1297,8 +1310,8 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1297
1310
|
lastName: Y,
|
|
1298
1311
|
appId: o
|
|
1299
1312
|
});
|
|
1300
|
-
}, lt = async (
|
|
1301
|
-
const { token: O, email: J, tenantSlug: j } =
|
|
1313
|
+
}, lt = async (C) => {
|
|
1314
|
+
const { token: O, email: J, tenantSlug: j } = C;
|
|
1302
1315
|
let Y = a == null ? void 0 : a.id, ee = c, te = l;
|
|
1303
1316
|
j && (Y = (await new ve(U, o).getPublicTenantInfo(j)).id, ee = j);
|
|
1304
1317
|
const re = await b.verifyMagicLink({
|
|
@@ -1306,8 +1319,8 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1306
1319
|
email: J,
|
|
1307
1320
|
appId: o,
|
|
1308
1321
|
tenantId: Y
|
|
1309
|
-
}),
|
|
1310
|
-
if (
|
|
1322
|
+
}), Q = j && j !== c;
|
|
1323
|
+
if (Q && (te = new be({
|
|
1311
1324
|
tenantSlug: ee,
|
|
1312
1325
|
baseUrl: i
|
|
1313
1326
|
})), te.setTokens({
|
|
@@ -1317,7 +1330,7 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1317
1330
|
}), re.user) {
|
|
1318
1331
|
te.setUser(re.user), A(re.user);
|
|
1319
1332
|
try {
|
|
1320
|
-
await
|
|
1333
|
+
await $();
|
|
1321
1334
|
} catch (we) {
|
|
1322
1335
|
process.env.NODE_ENV === "development" && console.warn(
|
|
1323
1336
|
"[AuthProvider] Failed to load complete user data after magic link:",
|
|
@@ -1325,7 +1338,7 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1325
1338
|
);
|
|
1326
1339
|
}
|
|
1327
1340
|
}
|
|
1328
|
-
return
|
|
1341
|
+
return Q && ee && ee !== c && m(ee, {
|
|
1329
1342
|
tokens: {
|
|
1330
1343
|
accessToken: re.accessToken,
|
|
1331
1344
|
refreshToken: re.refreshToken,
|
|
@@ -1333,15 +1346,15 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1333
1346
|
}
|
|
1334
1347
|
}), re;
|
|
1335
1348
|
}, ct = async () => {
|
|
1336
|
-
const
|
|
1337
|
-
if (!(
|
|
1349
|
+
const C = l.getTokens();
|
|
1350
|
+
if (!(C != null && C.refreshToken))
|
|
1338
1351
|
throw new Error("No refresh token available");
|
|
1339
1352
|
const O = await b.refreshToken({
|
|
1340
|
-
refreshToken:
|
|
1353
|
+
refreshToken: C.refreshToken
|
|
1341
1354
|
});
|
|
1342
1355
|
l.setTokens({
|
|
1343
1356
|
accessToken: O.accessToken,
|
|
1344
|
-
refreshToken: O.refreshToken ||
|
|
1357
|
+
refreshToken: O.refreshToken || C.refreshToken,
|
|
1345
1358
|
expiresIn: O.expiresIn
|
|
1346
1359
|
});
|
|
1347
1360
|
}, dt = () => {
|
|
@@ -1350,29 +1363,29 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1350
1363
|
localStorage.removeItem("userTenants");
|
|
1351
1364
|
} catch {
|
|
1352
1365
|
}
|
|
1353
|
-
}, ut = (
|
|
1354
|
-
l.setTokens(
|
|
1366
|
+
}, ut = (C) => {
|
|
1367
|
+
l.setTokens(C);
|
|
1355
1368
|
}, ht = () => l.hasValidSession(), pt = () => {
|
|
1356
1369
|
l.clearSession(), A(null), d(null);
|
|
1357
1370
|
}, ft = async () => {
|
|
1358
1371
|
if (o)
|
|
1359
1372
|
try {
|
|
1360
1373
|
g(!0);
|
|
1361
|
-
const { roles:
|
|
1362
|
-
f(
|
|
1363
|
-
} catch (
|
|
1364
|
-
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:",
|
|
1374
|
+
const { roles: C } = await S.getRolesByApp(o);
|
|
1375
|
+
f(C);
|
|
1376
|
+
} catch (C) {
|
|
1377
|
+
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:", C);
|
|
1365
1378
|
} finally {
|
|
1366
1379
|
g(!1);
|
|
1367
1380
|
}
|
|
1368
1381
|
}, gt = async () => {
|
|
1369
1382
|
await ft();
|
|
1370
|
-
}, Pe = (
|
|
1383
|
+
}, Pe = (C) => {
|
|
1371
1384
|
if (!G || G.length === 0)
|
|
1372
1385
|
return !1;
|
|
1373
|
-
if (typeof
|
|
1374
|
-
return G.includes(
|
|
1375
|
-
const O = `${
|
|
1386
|
+
if (typeof C == "string")
|
|
1387
|
+
return G.includes(C);
|
|
1388
|
+
const O = `${C.resource}.${C.action}`;
|
|
1376
1389
|
return G.includes(O);
|
|
1377
1390
|
};
|
|
1378
1391
|
return {
|
|
@@ -1396,29 +1409,29 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1396
1409
|
currentUser: T,
|
|
1397
1410
|
isUserLoading: L,
|
|
1398
1411
|
userError: P,
|
|
1399
|
-
loadUserData:
|
|
1412
|
+
loadUserData: $,
|
|
1400
1413
|
refreshUser: ce,
|
|
1401
1414
|
isAuthInitializing: !p,
|
|
1402
1415
|
isAuthReady: p,
|
|
1403
|
-
userRole:
|
|
1416
|
+
userRole: K,
|
|
1404
1417
|
userPermissions: G,
|
|
1405
1418
|
availableRoles: y,
|
|
1406
|
-
rolesLoading:
|
|
1419
|
+
rolesLoading: F,
|
|
1407
1420
|
hasPermission: Pe,
|
|
1408
|
-
hasAnyPermission: (
|
|
1409
|
-
hasAllPermissions: (
|
|
1421
|
+
hasAnyPermission: (C) => C.some((O) => Pe(O)),
|
|
1422
|
+
hasAllPermissions: (C) => C.every((O) => Pe(O)),
|
|
1410
1423
|
getUserPermissionStrings: () => G || [],
|
|
1411
1424
|
refreshRoles: gt,
|
|
1412
1425
|
// RFC-004: Multi-tenant user membership
|
|
1413
1426
|
userTenants: v,
|
|
1414
|
-
hasTenantContext:
|
|
1415
|
-
switchToTenant: async (
|
|
1427
|
+
hasTenantContext: B,
|
|
1428
|
+
switchToTenant: async (C, O) => {
|
|
1416
1429
|
const { redirectPath: J } = O || {}, j = l.getTokens();
|
|
1417
1430
|
if (!(j != null && j.refreshToken))
|
|
1418
1431
|
throw new Error("No refresh token available for tenant switch");
|
|
1419
1432
|
const Y = await b.switchTenant({
|
|
1420
1433
|
refreshToken: j.refreshToken,
|
|
1421
|
-
tenantId:
|
|
1434
|
+
tenantId: C
|
|
1422
1435
|
});
|
|
1423
1436
|
l.setTokens({
|
|
1424
1437
|
accessToken: Y.accessToken,
|
|
@@ -1426,7 +1439,7 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1426
1439
|
// Keep the same refresh token
|
|
1427
1440
|
expiresIn: Y.expiresIn
|
|
1428
1441
|
}), A(Y.user), l.setUser(Y.user), w(!0);
|
|
1429
|
-
const ee = v.find((te) => te.id ===
|
|
1442
|
+
const ee = v.find((te) => te.id === C);
|
|
1430
1443
|
ee && m(ee.subdomain, {
|
|
1431
1444
|
tokens: {
|
|
1432
1445
|
accessToken: Y.accessToken,
|
|
@@ -1437,7 +1450,7 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1437
1450
|
});
|
|
1438
1451
|
},
|
|
1439
1452
|
refreshUserTenants: async () => {
|
|
1440
|
-
const
|
|
1453
|
+
const C = await l.getAuthHeaders(), O = await b.getUserTenants(C);
|
|
1441
1454
|
N(O);
|
|
1442
1455
|
try {
|
|
1443
1456
|
localStorage.setItem("userTenants", JSON.stringify(O));
|
|
@@ -1462,9 +1475,9 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1462
1475
|
L,
|
|
1463
1476
|
P,
|
|
1464
1477
|
v,
|
|
1465
|
-
|
|
1478
|
+
B,
|
|
1466
1479
|
p,
|
|
1467
|
-
|
|
1480
|
+
K,
|
|
1468
1481
|
G
|
|
1469
1482
|
]);
|
|
1470
1483
|
W.current = q.loadUserData, ne(() => {
|
|
@@ -1480,38 +1493,38 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1480
1493
|
}
|
|
1481
1494
|
})();
|
|
1482
1495
|
}, [o, i, n.initialRoles]);
|
|
1483
|
-
const [V,
|
|
1496
|
+
const [V, H] = x(!1);
|
|
1484
1497
|
return ne(() => {
|
|
1485
|
-
V || (
|
|
1486
|
-
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to load user data after URL tokens:",
|
|
1498
|
+
V || (H(!0), R.current.urlTokens && (Et(), I(!0), q.loadUserData().catch(($) => {
|
|
1499
|
+
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to load user data after URL tokens:", $);
|
|
1487
1500
|
}).finally(() => {
|
|
1488
1501
|
I(!1);
|
|
1489
1502
|
})));
|
|
1490
1503
|
}, [q, V]), ne(() => {
|
|
1491
|
-
let
|
|
1504
|
+
let $ = !1;
|
|
1492
1505
|
return (async () => {
|
|
1493
1506
|
var ge;
|
|
1494
|
-
if (!l.hasValidSession() && ((ge = l.getTokens()) != null && ge.refreshToken) && await l.waitForPendingRefresh(),
|
|
1507
|
+
if (!l.hasValidSession() && ((ge = l.getTokens()) != null && ge.refreshToken) && await l.waitForPendingRefresh(), $) return;
|
|
1495
1508
|
const fe = l.getUser();
|
|
1496
|
-
fe && l.hasValidSession() && A(fe),
|
|
1509
|
+
fe && l.hasValidSession() && A(fe), D(!1);
|
|
1497
1510
|
})(), () => {
|
|
1498
|
-
|
|
1511
|
+
$ = !0;
|
|
1499
1512
|
};
|
|
1500
1513
|
}, [l]), ne(() => {
|
|
1501
1514
|
V && (R.current.urlTokens || (!T && !L && !P && l.hasValidSession() ? W.current().catch(() => {
|
|
1502
1515
|
}).finally(() => {
|
|
1503
|
-
|
|
1504
|
-
}) :
|
|
1505
|
-
}, [T, L, P, l, V]), /* @__PURE__ */ s(
|
|
1516
|
+
D(!1);
|
|
1517
|
+
}) : D(!1)));
|
|
1518
|
+
}, [T, L, P, l, V]), /* @__PURE__ */ s(Be.Provider, { value: q, children: e });
|
|
1506
1519
|
}
|
|
1507
1520
|
function he() {
|
|
1508
|
-
const n = le(
|
|
1521
|
+
const n = le(Be);
|
|
1509
1522
|
if (!n)
|
|
1510
1523
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
1511
1524
|
return n;
|
|
1512
1525
|
}
|
|
1513
|
-
function
|
|
1514
|
-
return le(
|
|
1526
|
+
function $e() {
|
|
1527
|
+
return le(Be);
|
|
1515
1528
|
}
|
|
1516
1529
|
class It {
|
|
1517
1530
|
constructor(e, t) {
|
|
@@ -1593,9 +1606,9 @@ class It {
|
|
|
1593
1606
|
})).data;
|
|
1594
1607
|
}
|
|
1595
1608
|
}
|
|
1596
|
-
const
|
|
1609
|
+
const Ce = ye(null);
|
|
1597
1610
|
function Ar({ config: n = {}, children: e }) {
|
|
1598
|
-
const t =
|
|
1611
|
+
const t = De(), r = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (r == null ? void 0 : r.tenant) ?? null, [c, m] = x([]), [y, f] = x(!1), [F, g] = x(null), [T, A] = x(!1), L = Z(() => {
|
|
1599
1612
|
const d = new de(i);
|
|
1600
1613
|
return new It(d);
|
|
1601
1614
|
}, [i]), M = async () => {
|
|
@@ -1627,30 +1640,30 @@ function Ar({ config: n = {}, children: e }) {
|
|
|
1627
1640
|
}, v = (R) => c.find((k) => k.key === R), N = (R) => {
|
|
1628
1641
|
const k = c.find((I) => I.key === R);
|
|
1629
1642
|
return k ? k.value ? "enabled" : "disabled" : "not_found";
|
|
1630
|
-
},
|
|
1643
|
+
}, B = async () => {
|
|
1631
1644
|
await M();
|
|
1632
1645
|
}, w = !!(i && o) && (T || !(a != null && a.id));
|
|
1633
1646
|
return {
|
|
1634
1647
|
featureFlags: c,
|
|
1635
1648
|
loading: y,
|
|
1636
|
-
error:
|
|
1649
|
+
error: F,
|
|
1637
1650
|
isReady: w,
|
|
1638
1651
|
isEnabled: d,
|
|
1639
1652
|
getFlag: v,
|
|
1640
1653
|
getFlagState: N,
|
|
1641
|
-
refresh:
|
|
1654
|
+
refresh: B
|
|
1642
1655
|
};
|
|
1643
|
-
}, [c, y,
|
|
1644
|
-
return /* @__PURE__ */ s(
|
|
1656
|
+
}, [c, y, F, i, o, a == null ? void 0 : a.id, T]);
|
|
1657
|
+
return /* @__PURE__ */ s(Ce.Provider, { value: P, children: e });
|
|
1645
1658
|
}
|
|
1646
1659
|
function Mt() {
|
|
1647
|
-
const n = le(
|
|
1660
|
+
const n = le(Ce);
|
|
1648
1661
|
if (!n)
|
|
1649
1662
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1650
1663
|
return n;
|
|
1651
1664
|
}
|
|
1652
1665
|
function Ye() {
|
|
1653
|
-
return le(
|
|
1666
|
+
return le(Ce);
|
|
1654
1667
|
}
|
|
1655
1668
|
class Lt {
|
|
1656
1669
|
constructor(e, t) {
|
|
@@ -1718,9 +1731,9 @@ class Lt {
|
|
|
1718
1731
|
)).data;
|
|
1719
1732
|
}
|
|
1720
1733
|
}
|
|
1721
|
-
const
|
|
1734
|
+
const He = ye(void 0);
|
|
1722
1735
|
function Pr({ config: n = {}, children: e }) {
|
|
1723
|
-
const t =
|
|
1736
|
+
const t = De(), r = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a, c] = x(null), [m, y] = x(!1), [f, F] = x(null), [g, T] = x(!1), A = Z(() => {
|
|
1724
1737
|
const P = new de(i);
|
|
1725
1738
|
return new Lt(P);
|
|
1726
1739
|
}, [i]), L = async () => {
|
|
@@ -1728,13 +1741,13 @@ function Pr({ config: n = {}, children: e }) {
|
|
|
1728
1741
|
c(null);
|
|
1729
1742
|
return;
|
|
1730
1743
|
}
|
|
1731
|
-
y(!0),
|
|
1744
|
+
y(!0), F(null);
|
|
1732
1745
|
try {
|
|
1733
1746
|
const P = await A.getTenantSubscriptionFeatures(o.id);
|
|
1734
1747
|
c(P);
|
|
1735
1748
|
} catch (P) {
|
|
1736
1749
|
const d = P instanceof Error ? P.message : "Failed to fetch subscription";
|
|
1737
|
-
|
|
1750
|
+
F(d), n.onError && n.onError(P instanceof Error ? P : new Error(d));
|
|
1738
1751
|
} finally {
|
|
1739
1752
|
y(!1);
|
|
1740
1753
|
}
|
|
@@ -1751,7 +1764,7 @@ function Pr({ config: n = {}, children: e }) {
|
|
|
1751
1764
|
}, v = (k) => P.find((I) => I.key === k), N = (k, I) => {
|
|
1752
1765
|
const l = P.find((z) => z.key === k);
|
|
1753
1766
|
return l ? l.value : I;
|
|
1754
|
-
},
|
|
1767
|
+
}, B = (k) => !a || !a.isActive ? !1 : k.includes(a.planId), w = async () => {
|
|
1755
1768
|
await L();
|
|
1756
1769
|
}, R = !!i && (g || !(o != null && o.id));
|
|
1757
1770
|
return {
|
|
@@ -1763,20 +1776,20 @@ function Pr({ config: n = {}, children: e }) {
|
|
|
1763
1776
|
isFeatureEnabled: d,
|
|
1764
1777
|
getFeature: v,
|
|
1765
1778
|
getFeatureValue: N,
|
|
1766
|
-
hasAllowedPlan:
|
|
1779
|
+
hasAllowedPlan: B,
|
|
1767
1780
|
refresh: w
|
|
1768
1781
|
};
|
|
1769
1782
|
}, [a, m, f, i, o == null ? void 0 : o.id, g]);
|
|
1770
|
-
return /* @__PURE__ */ s(
|
|
1783
|
+
return /* @__PURE__ */ s(He.Provider, { value: M, children: e });
|
|
1771
1784
|
}
|
|
1772
1785
|
function Nt() {
|
|
1773
|
-
const n = le(
|
|
1786
|
+
const n = le(He);
|
|
1774
1787
|
if (n === void 0)
|
|
1775
1788
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1776
1789
|
return n;
|
|
1777
1790
|
}
|
|
1778
1791
|
function Xe() {
|
|
1779
|
-
return le(
|
|
1792
|
+
return le(He) ?? null;
|
|
1780
1793
|
}
|
|
1781
1794
|
var ae = /* @__PURE__ */ ((n) => (n.SUPERUSER = "SUPERUSER", n.TENANT_ADMIN = "TENANT_ADMIN", n.USER = "USER", n))(ae || {});
|
|
1782
1795
|
const Oe = {
|
|
@@ -1832,7 +1845,7 @@ function Er() {
|
|
|
1832
1845
|
throw new Error("useRouting must be used within a RoutingProvider");
|
|
1833
1846
|
return n;
|
|
1834
1847
|
}
|
|
1835
|
-
function
|
|
1848
|
+
function Ft() {
|
|
1836
1849
|
const n = le(qe);
|
|
1837
1850
|
return n || {
|
|
1838
1851
|
zoneRoots: Oe,
|
|
@@ -1881,7 +1894,7 @@ const Ge = () => /* @__PURE__ */ u(
|
|
|
1881
1894
|
)
|
|
1882
1895
|
]
|
|
1883
1896
|
}
|
|
1884
|
-
),
|
|
1897
|
+
), Ke = ({
|
|
1885
1898
|
userType: n,
|
|
1886
1899
|
minUserType: e,
|
|
1887
1900
|
missingPermissions: t
|
|
@@ -1922,7 +1935,7 @@ const Ge = () => /* @__PURE__ */ u(
|
|
|
1922
1935
|
] })
|
|
1923
1936
|
]
|
|
1924
1937
|
}
|
|
1925
|
-
),
|
|
1938
|
+
), Dt = (n, e) => {
|
|
1926
1939
|
const t = {
|
|
1927
1940
|
[ae.USER]: 1,
|
|
1928
1941
|
[ae.TENANT_ADMIN]: 2,
|
|
@@ -1943,11 +1956,11 @@ function Ir({
|
|
|
1943
1956
|
const f = a.getUser();
|
|
1944
1957
|
if (!f)
|
|
1945
1958
|
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(Ge, {}) });
|
|
1946
|
-
if (t && !
|
|
1947
|
-
return /* @__PURE__ */ s(
|
|
1959
|
+
if (t && !Dt(f.userType, t))
|
|
1960
|
+
return /* @__PURE__ */ s(Ke, { userType: f.userType, minUserType: t });
|
|
1948
1961
|
if (r && r.length > 0 && !(i ? y(r) : m(r))) {
|
|
1949
1962
|
const g = r.filter((T) => !c(T)).map((T) => typeof T == "string" ? T : T.name);
|
|
1950
|
-
return /* @__PURE__ */ s(
|
|
1963
|
+
return /* @__PURE__ */ s(Ke, { missingPermissions: g });
|
|
1951
1964
|
}
|
|
1952
1965
|
return /* @__PURE__ */ s(_, { children: n });
|
|
1953
1966
|
}
|
|
@@ -1987,7 +2000,7 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
1987
2000
|
}
|
|
1988
2001
|
)
|
|
1989
2002
|
}
|
|
1990
|
-
),
|
|
2003
|
+
), Qe = ({
|
|
1991
2004
|
userType: n,
|
|
1992
2005
|
requiredUserType: e,
|
|
1993
2006
|
missingPermissions: t
|
|
@@ -2038,7 +2051,7 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2038
2051
|
}
|
|
2039
2052
|
)
|
|
2040
2053
|
}
|
|
2041
|
-
),
|
|
2054
|
+
), Bt = (n, e) => n === e;
|
|
2042
2055
|
function Mr({
|
|
2043
2056
|
children: n,
|
|
2044
2057
|
redirectTo: e = "/login",
|
|
@@ -2047,7 +2060,7 @@ function Mr({
|
|
|
2047
2060
|
requireAllPermissions: i = !1,
|
|
2048
2061
|
fallback: o
|
|
2049
2062
|
}) {
|
|
2050
|
-
const { hasValidSession: a, sessionManager: c, hasPermission: m, hasAnyPermission: y, hasAllPermissions: f } = he(),
|
|
2063
|
+
const { hasValidSession: a, sessionManager: c, hasPermission: m, hasAnyPermission: y, hasAllPermissions: f } = he(), F = xe();
|
|
2051
2064
|
if (ne(() => {
|
|
2052
2065
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2053
2066
|
"[react-identity-access] ProtectedRoute is deprecated. Use AuthenticatedZone or AdminZone from ZoneRoute instead."
|
|
@@ -2055,14 +2068,14 @@ function Mr({
|
|
|
2055
2068
|
}, []), !a())
|
|
2056
2069
|
return o ? /* @__PURE__ */ s(_, { children: o }) : /* @__PURE__ */ u(_, { children: [
|
|
2057
2070
|
/* @__PURE__ */ s(Ut, { redirectPath: e }),
|
|
2058
|
-
/* @__PURE__ */ s(Se, { to: e, state: { from:
|
|
2071
|
+
/* @__PURE__ */ s(Se, { to: e, state: { from: F.pathname }, replace: !0 })
|
|
2059
2072
|
] });
|
|
2060
2073
|
const g = c.getUser();
|
|
2061
2074
|
if (!g)
|
|
2062
|
-
return /* @__PURE__ */ s(Se, { to: e, state: { from:
|
|
2063
|
-
if (t &&
|
|
2075
|
+
return /* @__PURE__ */ s(Se, { to: e, state: { from: F.pathname }, replace: !0 });
|
|
2076
|
+
if (t && !Bt(g.userType, t))
|
|
2064
2077
|
return /* @__PURE__ */ s(
|
|
2065
|
-
|
|
2078
|
+
Qe,
|
|
2066
2079
|
{
|
|
2067
2080
|
userType: g.userType,
|
|
2068
2081
|
requiredUserType: t
|
|
@@ -2070,11 +2083,11 @@ function Mr({
|
|
|
2070
2083
|
);
|
|
2071
2084
|
if (r && r.length > 0 && !(i ? f(r) : y(r))) {
|
|
2072
2085
|
const A = r.filter((L) => !m(L)).map((L) => typeof L == "string" ? L : L.name);
|
|
2073
|
-
return /* @__PURE__ */ s(
|
|
2086
|
+
return /* @__PURE__ */ s(Qe, { missingPermissions: A });
|
|
2074
2087
|
}
|
|
2075
2088
|
return /* @__PURE__ */ s(_, { children: n });
|
|
2076
2089
|
}
|
|
2077
|
-
const
|
|
2090
|
+
const $t = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
2078
2091
|
"div",
|
|
2079
2092
|
{
|
|
2080
2093
|
style: {
|
|
@@ -2118,11 +2131,11 @@ function Lr({ children: n, redirectTo: e = "/", fallback: t }) {
|
|
|
2118
2131
|
"[react-identity-access] TenantRoute is deprecated. Use TenantZone from ZoneRoute instead."
|
|
2119
2132
|
);
|
|
2120
2133
|
}, []), i || o ? null : r ? /* @__PURE__ */ s(_, { children: n }) : t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ u(_, { children: [
|
|
2121
|
-
/* @__PURE__ */ s(
|
|
2134
|
+
/* @__PURE__ */ s($t, { redirectPath: e }),
|
|
2122
2135
|
/* @__PURE__ */ s(Se, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
2123
2136
|
] });
|
|
2124
2137
|
}
|
|
2125
|
-
const
|
|
2138
|
+
const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
2126
2139
|
"div",
|
|
2127
2140
|
{
|
|
2128
2141
|
style: {
|
|
@@ -2166,18 +2179,18 @@ function Nr({ children: n, redirectTo: e = "/dashboard", fallback: t }) {
|
|
|
2166
2179
|
"[react-identity-access] LandingRoute is deprecated. Use PublicZone from ZoneRoute instead."
|
|
2167
2180
|
);
|
|
2168
2181
|
}, []), i || o ? null : r ? t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ u(_, { children: [
|
|
2169
|
-
/* @__PURE__ */ s(
|
|
2182
|
+
/* @__PURE__ */ s(Ct, { redirectPath: e }),
|
|
2170
2183
|
/* @__PURE__ */ s(Se, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
2171
2184
|
] }) : /* @__PURE__ */ s(_, { children: n });
|
|
2172
2185
|
}
|
|
2173
|
-
function
|
|
2186
|
+
function Ht(n, e) {
|
|
2174
2187
|
return e ? n ? Array.isArray(e) ? e.includes(n) : n === e : !1 : !0;
|
|
2175
2188
|
}
|
|
2176
2189
|
function Ze(n, e) {
|
|
2177
2190
|
return !n || n === "optional" ? "skip" : n === "required" ? e ? "pass" : "fail" : n === "forbidden" ? e ? "fail" : "pass" : "skip";
|
|
2178
2191
|
}
|
|
2179
2192
|
function Ot(n, e) {
|
|
2180
|
-
return Ze(n.tenant, e.hasTenant) === "fail" ? e.hasTenant ? "has_tenant" : "no_tenant" : Ze(n.auth, e.isAuthenticated) === "fail" ? e.isAuthenticated ? "already_authenticated" : "not_authenticated" : n.userType && e.isAuthenticated && !
|
|
2193
|
+
return Ze(n.tenant, e.hasTenant) === "fail" ? e.hasTenant ? "has_tenant" : "no_tenant" : Ze(n.auth, e.isAuthenticated) === "fail" ? e.isAuthenticated ? "already_authenticated" : "not_authenticated" : n.userType && e.isAuthenticated && !Ht(e.userType, n.userType) ? "wrong_user_type" : n.permissions && n.permissions.length > 0 && !(n.requireAllPermissions !== !1 ? (o) => o.every((a) => e.permissions.includes(a)) : (o) => o.some((a) => e.permissions.includes(a)))(n.permissions) ? "missing_permissions" : null;
|
|
2181
2194
|
}
|
|
2182
2195
|
function qt(n, e) {
|
|
2183
2196
|
return n.hasTenant ? n.isAuthenticated ? n.userType === ae.TENANT_ADMIN ? e.tenantAdmin : e.tenantUser : e.tenantGuest : n.isAuthenticated ? n.userType === ae.TENANT_ADMIN ? e.publicAdmin : e.publicUser : e.publicGuest;
|
|
@@ -2205,12 +2218,12 @@ const ue = ({
|
|
|
2205
2218
|
onAccessDenied: m,
|
|
2206
2219
|
redirectTo: y,
|
|
2207
2220
|
loadingFallback: f,
|
|
2208
|
-
accessDeniedFallback:
|
|
2221
|
+
accessDeniedFallback: F
|
|
2209
2222
|
}) => {
|
|
2210
|
-
const g = xe(), { isAuthenticated: T, isAuthInitializing: A, currentUser: L, userPermissions: M } = he(), { tenant: P, isTenantLoading: d } = Te(), v =
|
|
2223
|
+
const g = xe(), { isAuthenticated: T, isAuthInitializing: A, currentUser: L, userPermissions: M } = he(), { tenant: P, isTenantLoading: d } = Te(), v = Ft(), N = Z(() => {
|
|
2211
2224
|
if (e)
|
|
2212
2225
|
return v.presets[e];
|
|
2213
|
-
}, [e, v.presets]),
|
|
2226
|
+
}, [e, v.presets]), B = Z(
|
|
2214
2227
|
() => ({
|
|
2215
2228
|
tenant: t ?? (N == null ? void 0 : N.tenant),
|
|
2216
2229
|
auth: r ?? (N == null ? void 0 : N.auth),
|
|
@@ -2235,13 +2248,13 @@ const ue = ({
|
|
|
2235
2248
|
A,
|
|
2236
2249
|
d
|
|
2237
2250
|
]
|
|
2238
|
-
), R = Z(() => w.isLoading ? null : Ot(
|
|
2251
|
+
), R = Z(() => w.isLoading ? null : Ot(B, w), [B, w]), k = Z(() => R ? y || qt(w, v.zoneRoots) : null, [R, y, w, v.zoneRoots]), I = Z(() => !R || !k ? null : {
|
|
2239
2252
|
type: R,
|
|
2240
2253
|
required: {
|
|
2241
|
-
tenant:
|
|
2242
|
-
auth:
|
|
2243
|
-
userType:
|
|
2244
|
-
permissions:
|
|
2254
|
+
tenant: B.tenant,
|
|
2255
|
+
auth: B.auth,
|
|
2256
|
+
userType: B.userType,
|
|
2257
|
+
permissions: B.permissions
|
|
2245
2258
|
},
|
|
2246
2259
|
current: {
|
|
2247
2260
|
hasTenant: w.hasTenant,
|
|
@@ -2250,7 +2263,7 @@ const ue = ({
|
|
|
2250
2263
|
permissions: w.permissions
|
|
2251
2264
|
},
|
|
2252
2265
|
redirectTo: k
|
|
2253
|
-
}, [R, k,
|
|
2266
|
+
}, [R, k, B, w]);
|
|
2254
2267
|
if (ne(() => {
|
|
2255
2268
|
I && (m ? m(I) : v.onAccessDenied && v.onAccessDenied(I));
|
|
2256
2269
|
}, [I, m, v]), ne(() => {
|
|
@@ -2264,7 +2277,7 @@ const ue = ({
|
|
|
2264
2277
|
]), w.isLoading)
|
|
2265
2278
|
return /* @__PURE__ */ s(_, { children: f ?? v.loadingFallback ?? null });
|
|
2266
2279
|
if (I && k) {
|
|
2267
|
-
const l =
|
|
2280
|
+
const l = F ?? v.accessDeniedFallback;
|
|
2268
2281
|
if (l)
|
|
2269
2282
|
return /* @__PURE__ */ s(_, { children: l });
|
|
2270
2283
|
const z = _t(
|
|
@@ -2277,7 +2290,7 @@ const ue = ({
|
|
|
2277
2290
|
return /* @__PURE__ */ s(Se, { to: z, replace: !0 });
|
|
2278
2291
|
}
|
|
2279
2292
|
return /* @__PURE__ */ s(_, { children: n });
|
|
2280
|
-
},
|
|
2293
|
+
}, Fr = (n) => /* @__PURE__ */ s(ue, { tenant: "required", ...n }), Dr = (n) => /* @__PURE__ */ s(ue, { tenant: "forbidden", ...n }), Ur = (n) => /* @__PURE__ */ s(ue, { auth: "required", ...n }), Br = (n) => /* @__PURE__ */ s(ue, { auth: "forbidden", ...n }), $r = (n) => /* @__PURE__ */ s(ue, { auth: "required", userType: ae.TENANT_ADMIN, ...n }), Cr = (n) => /* @__PURE__ */ s(ue, { auth: "required", userType: ae.USER, ...n }), Hr = (n) => /* @__PURE__ */ s(ue, { tenant: "optional", auth: "optional", ...n }), Or = (n) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "required", ...n }), qr = (n) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "optional", ...n }), _r = (n) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "forbidden", ...n }), Vt = () => /* @__PURE__ */ u(
|
|
2281
2294
|
"div",
|
|
2282
2295
|
{
|
|
2283
2296
|
style: {
|
|
@@ -2391,10 +2404,10 @@ const jt = () => /* @__PURE__ */ u(
|
|
|
2391
2404
|
/* @__PURE__ */ s("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
2392
2405
|
]
|
|
2393
2406
|
}
|
|
2394
|
-
),
|
|
2407
|
+
), Kt = {
|
|
2395
2408
|
showPassword: /* @__PURE__ */ s(jt, {}),
|
|
2396
2409
|
hidePassword: /* @__PURE__ */ s(Gt, {})
|
|
2397
|
-
},
|
|
2410
|
+
}, Qt = {
|
|
2398
2411
|
title: "Sign In",
|
|
2399
2412
|
usernameLabel: "Email or Phone",
|
|
2400
2413
|
usernamePlaceholder: "Enter your email or phone number",
|
|
@@ -2534,14 +2547,14 @@ function Wr({
|
|
|
2534
2547
|
showForgotPassword: m = !0,
|
|
2535
2548
|
showSignupLink: y = !0,
|
|
2536
2549
|
showMagicLinkOption: f = !0,
|
|
2537
|
-
className:
|
|
2550
|
+
className: F
|
|
2538
2551
|
}) {
|
|
2539
|
-
const [g, T] = x(""), [A, L] = x(""), [M, P] = x(!1), [d, v] = x(!1), [N,
|
|
2552
|
+
const [g, T] = x(""), [A, L] = x(""), [M, P] = x(!1), [d, v] = x(!1), [N, B] = x(""), [w, R] = x({}), { login: k } = he(), I = { ...Qt, ...n }, l = { ...Zt, ...e }, z = { ...Kt, ...t }, D = () => {
|
|
2540
2553
|
const h = {};
|
|
2541
2554
|
return g.trim() || (h.username = !0), A.trim() || (h.password = !0), R(h), Object.keys(h).length === 0;
|
|
2542
2555
|
}, p = async (h) => {
|
|
2543
|
-
if (h.preventDefault(), !!
|
|
2544
|
-
v(!0),
|
|
2556
|
+
if (h.preventDefault(), !!D()) {
|
|
2557
|
+
v(!0), B("");
|
|
2545
2558
|
try {
|
|
2546
2559
|
const S = await k({
|
|
2547
2560
|
username: g,
|
|
@@ -2551,7 +2564,7 @@ function Wr({
|
|
|
2551
2564
|
r == null || r(S);
|
|
2552
2565
|
} catch (S) {
|
|
2553
2566
|
const E = S.message || I.errorMessage;
|
|
2554
|
-
|
|
2567
|
+
B(E), i == null || i(E);
|
|
2555
2568
|
} finally {
|
|
2556
2569
|
v(!1);
|
|
2557
2570
|
}
|
|
@@ -2564,7 +2577,7 @@ function Wr({
|
|
|
2564
2577
|
...d ? l.buttonLoading : {},
|
|
2565
2578
|
...!g || !A || d ? l.buttonDisabled : {}
|
|
2566
2579
|
});
|
|
2567
|
-
return /* @__PURE__ */ u("div", { className:
|
|
2580
|
+
return /* @__PURE__ */ u("div", { className: F, style: l.container, children: [
|
|
2568
2581
|
/* @__PURE__ */ s("h2", { style: l.title, children: I.title }),
|
|
2569
2582
|
/* @__PURE__ */ u("form", { onSubmit: p, style: l.form, children: [
|
|
2570
2583
|
/* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
|
|
@@ -2790,11 +2803,11 @@ function jr({
|
|
|
2790
2803
|
className: y
|
|
2791
2804
|
}) {
|
|
2792
2805
|
var V;
|
|
2793
|
-
const [f,
|
|
2794
|
-
const
|
|
2795
|
-
return f.trim() || (
|
|
2796
|
-
}, G = async (
|
|
2797
|
-
if (
|
|
2806
|
+
const [f, F] = x(""), [g, T] = x(""), [A, L] = x(""), [M, P] = x(""), [d, v] = x(""), [N, B] = x(""), [w, R] = x(""), [k, I] = x(!1), [l, z] = x(""), [D, p] = x({}), { signup: U, signupTenantAdmin: b } = he(), h = ((V = pe()) == null ? void 0 : V.tenant) ?? null, S = { ...Jt, ...n }, E = { ...Yt, ...e }, K = () => {
|
|
2807
|
+
const H = {};
|
|
2808
|
+
return f.trim() || (H.name = !0), !A.trim() && !M.trim() && (H.email = !0, H.phoneNumber = !0), d.trim() || (H.password = !0), N.trim() || (H.confirmPassword = !0), t === "tenant" && !w.trim() && (H.tenantName = !0), p(H), Object.keys(H).length === 0;
|
|
2809
|
+
}, G = async (H) => {
|
|
2810
|
+
if (H.preventDefault(), !!K()) {
|
|
2798
2811
|
if (d !== N) {
|
|
2799
2812
|
z(S.passwordMismatchError), p({ confirmPassword: !0 });
|
|
2800
2813
|
return;
|
|
@@ -2805,32 +2818,32 @@ function jr({
|
|
|
2805
2818
|
}
|
|
2806
2819
|
I(!0), z("");
|
|
2807
2820
|
try {
|
|
2808
|
-
let
|
|
2809
|
-
t === "tenant" ?
|
|
2821
|
+
let $;
|
|
2822
|
+
t === "tenant" ? $ = await b({
|
|
2810
2823
|
email: A || void 0,
|
|
2811
2824
|
phoneNumber: M || void 0,
|
|
2812
2825
|
name: f,
|
|
2813
2826
|
password: d,
|
|
2814
2827
|
tenantName: w,
|
|
2815
2828
|
lastName: g || void 0
|
|
2816
|
-
}) :
|
|
2829
|
+
}) : $ = await U({
|
|
2817
2830
|
email: A || void 0,
|
|
2818
2831
|
phoneNumber: M || void 0,
|
|
2819
2832
|
name: f,
|
|
2820
2833
|
password: d,
|
|
2821
2834
|
tenantId: h.id,
|
|
2822
2835
|
lastName: g || void 0
|
|
2823
|
-
}), r == null || r(
|
|
2824
|
-
} catch (
|
|
2825
|
-
const ce =
|
|
2836
|
+
}), r == null || r($);
|
|
2837
|
+
} catch ($) {
|
|
2838
|
+
const ce = $.message || S.errorMessage;
|
|
2826
2839
|
z(ce), i == null || i(ce);
|
|
2827
2840
|
} finally {
|
|
2828
2841
|
I(!1);
|
|
2829
2842
|
}
|
|
2830
2843
|
}
|
|
2831
|
-
}, X = (
|
|
2844
|
+
}, X = (H) => ({
|
|
2832
2845
|
...E.input,
|
|
2833
|
-
...
|
|
2846
|
+
...D[H] ? E.inputError : {}
|
|
2834
2847
|
}), W = () => ({
|
|
2835
2848
|
...E.button,
|
|
2836
2849
|
...k ? E.buttonLoading : {},
|
|
@@ -2848,8 +2861,8 @@ function jr({
|
|
|
2848
2861
|
name: "name",
|
|
2849
2862
|
type: "text",
|
|
2850
2863
|
value: f,
|
|
2851
|
-
onChange: (
|
|
2852
|
-
|
|
2864
|
+
onChange: (H) => {
|
|
2865
|
+
F(H.target.value), D.name && p(($) => ({ ...$, name: !1 }));
|
|
2853
2866
|
},
|
|
2854
2867
|
placeholder: S.namePlaceholder,
|
|
2855
2868
|
style: X("name"),
|
|
@@ -2866,7 +2879,7 @@ function jr({
|
|
|
2866
2879
|
name: "lastName",
|
|
2867
2880
|
type: "text",
|
|
2868
2881
|
value: g,
|
|
2869
|
-
onChange: (
|
|
2882
|
+
onChange: (H) => T(H.target.value),
|
|
2870
2883
|
placeholder: S.lastNamePlaceholder,
|
|
2871
2884
|
style: E.input,
|
|
2872
2885
|
disabled: k
|
|
@@ -2882,8 +2895,8 @@ function jr({
|
|
|
2882
2895
|
name: "email",
|
|
2883
2896
|
type: "email",
|
|
2884
2897
|
value: A,
|
|
2885
|
-
onChange: (
|
|
2886
|
-
L(
|
|
2898
|
+
onChange: (H) => {
|
|
2899
|
+
L(H.target.value), D.email && p(($) => ({ ...$, email: !1, phoneNumber: !1 }));
|
|
2887
2900
|
},
|
|
2888
2901
|
placeholder: S.emailPlaceholder,
|
|
2889
2902
|
style: X("email"),
|
|
@@ -2900,8 +2913,8 @@ function jr({
|
|
|
2900
2913
|
name: "phoneNumber",
|
|
2901
2914
|
type: "tel",
|
|
2902
2915
|
value: M,
|
|
2903
|
-
onChange: (
|
|
2904
|
-
P(
|
|
2916
|
+
onChange: (H) => {
|
|
2917
|
+
P(H.target.value), D.phoneNumber && p(($) => ({ ...$, email: !1, phoneNumber: !1 }));
|
|
2905
2918
|
},
|
|
2906
2919
|
placeholder: S.phoneNumberPlaceholder,
|
|
2907
2920
|
style: X("phoneNumber"),
|
|
@@ -2919,8 +2932,8 @@ function jr({
|
|
|
2919
2932
|
name: "password",
|
|
2920
2933
|
type: "password",
|
|
2921
2934
|
value: d,
|
|
2922
|
-
onChange: (
|
|
2923
|
-
v(
|
|
2935
|
+
onChange: (H) => {
|
|
2936
|
+
v(H.target.value), D.password && p(($) => ({ ...$, password: !1 }));
|
|
2924
2937
|
},
|
|
2925
2938
|
placeholder: S.passwordPlaceholder,
|
|
2926
2939
|
style: X("password"),
|
|
@@ -2937,8 +2950,8 @@ function jr({
|
|
|
2937
2950
|
name: "confirmPassword",
|
|
2938
2951
|
type: "password",
|
|
2939
2952
|
value: N,
|
|
2940
|
-
onChange: (
|
|
2941
|
-
|
|
2953
|
+
onChange: (H) => {
|
|
2954
|
+
B(H.target.value), D.confirmPassword && p(($) => ({ ...$, confirmPassword: !1 })), l === S.passwordMismatchError && z("");
|
|
2942
2955
|
},
|
|
2943
2956
|
placeholder: S.confirmPasswordPlaceholder,
|
|
2944
2957
|
style: X("confirmPassword"),
|
|
@@ -2955,8 +2968,8 @@ function jr({
|
|
|
2955
2968
|
name: "tenantName",
|
|
2956
2969
|
type: "text",
|
|
2957
2970
|
value: w,
|
|
2958
|
-
onChange: (
|
|
2959
|
-
R(
|
|
2971
|
+
onChange: (H) => {
|
|
2972
|
+
R(H.target.value), D.tenantName && p(($) => ({ ...$, tenantName: !1 }));
|
|
2960
2973
|
},
|
|
2961
2974
|
placeholder: S.tenantNamePlaceholder,
|
|
2962
2975
|
style: X("tenantName"),
|
|
@@ -3146,16 +3159,16 @@ function Gr({
|
|
|
3146
3159
|
frontendUrl: y
|
|
3147
3160
|
}) {
|
|
3148
3161
|
var W;
|
|
3149
|
-
const [f,
|
|
3162
|
+
const [f, F] = x(""), [g, T] = x(""), [A, L] = x(""), [M, P] = x(!1), [d, v] = x(!1), [N, B] = x(""), [w, R] = x(""), [k, I] = x({}), [l, z] = x(!1), { sendMagicLink: D, verifyMagicLink: p } = he(), U = ((W = pe()) == null ? void 0 : W.tenant) ?? null, b = { ...Xt, ...n }, h = { ...er, ...e };
|
|
3150
3163
|
ne(() => {
|
|
3151
3164
|
m && S(m);
|
|
3152
3165
|
}, [m]);
|
|
3153
3166
|
const S = async (q) => {
|
|
3154
3167
|
if (!U || !f) {
|
|
3155
|
-
|
|
3168
|
+
B(b.missingTenantOrEmailError);
|
|
3156
3169
|
return;
|
|
3157
3170
|
}
|
|
3158
|
-
v(!0),
|
|
3171
|
+
v(!0), B("");
|
|
3159
3172
|
try {
|
|
3160
3173
|
const V = await p({
|
|
3161
3174
|
token: q,
|
|
@@ -3164,33 +3177,33 @@ function Gr({
|
|
|
3164
3177
|
});
|
|
3165
3178
|
t == null || t(V);
|
|
3166
3179
|
} catch (V) {
|
|
3167
|
-
const
|
|
3168
|
-
|
|
3180
|
+
const H = V.message || "Failed to verify magic link";
|
|
3181
|
+
B(H), r == null || r(H);
|
|
3169
3182
|
} finally {
|
|
3170
3183
|
v(!1);
|
|
3171
3184
|
}
|
|
3172
3185
|
}, E = () => {
|
|
3173
3186
|
const q = {};
|
|
3174
3187
|
return f.trim() || (q.email = !0), l && !g.trim() && (q.name = !0), I(q), Object.keys(q).length === 0;
|
|
3175
|
-
},
|
|
3188
|
+
}, K = async (q) => {
|
|
3176
3189
|
if (q.preventDefault(), !!E()) {
|
|
3177
3190
|
if (!(U != null && U.id)) {
|
|
3178
|
-
|
|
3191
|
+
B(b.tenantNotFoundError);
|
|
3179
3192
|
return;
|
|
3180
3193
|
}
|
|
3181
|
-
P(!0),
|
|
3194
|
+
P(!0), B(""), R("");
|
|
3182
3195
|
try {
|
|
3183
|
-
const V = y || (typeof window < "u" ? window.location.origin : ""),
|
|
3196
|
+
const V = y || (typeof window < "u" ? window.location.origin : ""), H = await D({
|
|
3184
3197
|
email: f,
|
|
3185
3198
|
tenantId: U.id,
|
|
3186
3199
|
frontendUrl: V,
|
|
3187
3200
|
name: l ? g : void 0,
|
|
3188
3201
|
lastName: l ? A : void 0
|
|
3189
3202
|
});
|
|
3190
|
-
R(b.successMessage), t == null || t(
|
|
3203
|
+
R(b.successMessage), t == null || t(H);
|
|
3191
3204
|
} catch (V) {
|
|
3192
|
-
const
|
|
3193
|
-
|
|
3205
|
+
const H = V.message || b.errorMessage;
|
|
3206
|
+
B(H), r == null || r(H);
|
|
3194
3207
|
} finally {
|
|
3195
3208
|
P(!1);
|
|
3196
3209
|
}
|
|
@@ -3209,7 +3222,7 @@ function Gr({
|
|
|
3209
3222
|
] }) : /* @__PURE__ */ u("div", { className: c, style: h.container, children: [
|
|
3210
3223
|
/* @__PURE__ */ s("h2", { style: h.title, children: b.title }),
|
|
3211
3224
|
/* @__PURE__ */ s("p", { style: h.description, children: b.description }),
|
|
3212
|
-
/* @__PURE__ */ u("form", { onSubmit:
|
|
3225
|
+
/* @__PURE__ */ u("form", { onSubmit: K, style: h.form, children: [
|
|
3213
3226
|
/* @__PURE__ */ u("div", { style: h.fieldGroup, children: [
|
|
3214
3227
|
/* @__PURE__ */ s("label", { style: h.label, children: b.emailLabel }),
|
|
3215
3228
|
/* @__PURE__ */ s(
|
|
@@ -3220,7 +3233,7 @@ function Gr({
|
|
|
3220
3233
|
type: "email",
|
|
3221
3234
|
value: f,
|
|
3222
3235
|
onChange: (q) => {
|
|
3223
|
-
|
|
3236
|
+
F(q.target.value), k.email && I((V) => ({ ...V, email: !1 }));
|
|
3224
3237
|
},
|
|
3225
3238
|
placeholder: b.emailPlaceholder,
|
|
3226
3239
|
style: G("email"),
|
|
@@ -3449,7 +3462,7 @@ const tr = {
|
|
|
3449
3462
|
success: /* @__PURE__ */ s(nr, {}),
|
|
3450
3463
|
error: /* @__PURE__ */ s(sr, {})
|
|
3451
3464
|
};
|
|
3452
|
-
function
|
|
3465
|
+
function Kr({
|
|
3453
3466
|
copy: n = {},
|
|
3454
3467
|
styles: e = {},
|
|
3455
3468
|
icons: t = {},
|
|
@@ -3461,22 +3474,22 @@ function Qr({
|
|
|
3461
3474
|
token: m,
|
|
3462
3475
|
email: y,
|
|
3463
3476
|
appId: f,
|
|
3464
|
-
tenantSlug:
|
|
3477
|
+
tenantSlug: F,
|
|
3465
3478
|
autoRedirectDelay: g = 3e3
|
|
3466
3479
|
}) {
|
|
3467
|
-
const [T, A] = x("verifying"), [L, M] = x(""), { verifyMagicLink: P } = he(), d = { ...tr, ...n }, v = { ...tt, ...e }, N = { ...ir, ...t },
|
|
3480
|
+
const [T, A] = x("verifying"), [L, M] = x(""), { verifyMagicLink: P } = he(), d = { ...tr, ...n }, v = { ...tt, ...e }, N = { ...ir, ...t }, B = () => {
|
|
3468
3481
|
if (typeof window > "u") return {};
|
|
3469
3482
|
const l = new URLSearchParams(window.location.search);
|
|
3470
3483
|
return {
|
|
3471
3484
|
token: m || l.get("token") || "",
|
|
3472
3485
|
email: y || l.get("email") || "",
|
|
3473
3486
|
appId: f || l.get("appId") || "",
|
|
3474
|
-
tenantSlug:
|
|
3487
|
+
tenantSlug: F || l.get("tenantSlug") || void 0
|
|
3475
3488
|
};
|
|
3476
3489
|
}, w = async () => {
|
|
3477
3490
|
A("verifying"), M("");
|
|
3478
3491
|
try {
|
|
3479
|
-
const l =
|
|
3492
|
+
const l = B();
|
|
3480
3493
|
if (!l.token || !l.email)
|
|
3481
3494
|
throw new Error(d.missingParamsError);
|
|
3482
3495
|
const z = await P({
|
|
@@ -3531,8 +3544,8 @@ function Qr({
|
|
|
3531
3544
|
},
|
|
3532
3545
|
onMouseOut: (l) => {
|
|
3533
3546
|
const z = v.retryButton || {};
|
|
3534
|
-
Object.keys(v.retryButtonHover || {}).forEach((
|
|
3535
|
-
l.currentTarget.style[
|
|
3547
|
+
Object.keys(v.retryButtonHover || {}).forEach((D) => {
|
|
3548
|
+
l.currentTarget.style[D] = z[D] ?? "";
|
|
3536
3549
|
});
|
|
3537
3550
|
},
|
|
3538
3551
|
children: d.retryButton
|
|
@@ -3548,8 +3561,8 @@ function Qr({
|
|
|
3548
3561
|
},
|
|
3549
3562
|
onMouseOut: (l) => {
|
|
3550
3563
|
const z = v.backButton || {};
|
|
3551
|
-
Object.keys(v.backButtonHover || {}).forEach((
|
|
3552
|
-
l.currentTarget.style[
|
|
3564
|
+
Object.keys(v.backButtonHover || {}).forEach((D) => {
|
|
3565
|
+
l.currentTarget.style[D] = z[D] ?? "";
|
|
3553
3566
|
});
|
|
3554
3567
|
},
|
|
3555
3568
|
children: d.backToLoginButton
|
|
@@ -3694,7 +3707,7 @@ const or = {
|
|
|
3694
3707
|
color: "#6b7280"
|
|
3695
3708
|
}
|
|
3696
3709
|
};
|
|
3697
|
-
function
|
|
3710
|
+
function Qr({
|
|
3698
3711
|
copy: n = {},
|
|
3699
3712
|
styles: e = {},
|
|
3700
3713
|
mode: t = "request",
|
|
@@ -3706,23 +3719,23 @@ function Kr({
|
|
|
3706
3719
|
className: m
|
|
3707
3720
|
}) {
|
|
3708
3721
|
var X;
|
|
3709
|
-
const [y, f] = x(""), [
|
|
3722
|
+
const [y, f] = x(""), [F, g] = x(r), [T, A] = x(""), [L, M] = x(""), [P, d] = x(!1), [v, N] = x(""), [B, w] = x(""), [R, k] = x({}), { requestPasswordReset: I, confirmPasswordReset: l } = he(), z = ((X = pe()) == null ? void 0 : X.tenant) ?? null, D = { ...or, ...n }, p = { ...ar, ...e }, U = () => {
|
|
3710
3723
|
const W = {};
|
|
3711
3724
|
return y.trim() || (W.email = !0), k(W), Object.keys(W).length === 0;
|
|
3712
3725
|
}, b = () => {
|
|
3713
3726
|
const W = {};
|
|
3714
|
-
return
|
|
3727
|
+
return F.trim() || (W.token = !0), T.trim() || (W.newPassword = !0), L.trim() || (W.confirmPassword = !0), k(W), Object.keys(W).length === 0;
|
|
3715
3728
|
}, h = async (W) => {
|
|
3716
3729
|
if (W.preventDefault(), !!U()) {
|
|
3717
3730
|
if (!(z != null && z.id)) {
|
|
3718
|
-
N(
|
|
3731
|
+
N(D.tenantNotFoundError);
|
|
3719
3732
|
return;
|
|
3720
3733
|
}
|
|
3721
3734
|
d(!0), N(""), w("");
|
|
3722
3735
|
try {
|
|
3723
|
-
await I({ email: y, tenantId: z.id }), w(
|
|
3736
|
+
await I({ email: y, tenantId: z.id }), w(D.successMessage), i == null || i();
|
|
3724
3737
|
} catch (q) {
|
|
3725
|
-
const V = q.message ||
|
|
3738
|
+
const V = q.message || D.errorMessage;
|
|
3726
3739
|
N(V), o == null || o(V);
|
|
3727
3740
|
} finally {
|
|
3728
3741
|
d(!1);
|
|
@@ -3731,14 +3744,14 @@ function Kr({
|
|
|
3731
3744
|
}, S = async (W) => {
|
|
3732
3745
|
if (W.preventDefault(), !!b()) {
|
|
3733
3746
|
if (T !== L) {
|
|
3734
|
-
N(
|
|
3747
|
+
N(D.passwordMismatchError), k({ confirmPassword: !0 });
|
|
3735
3748
|
return;
|
|
3736
3749
|
}
|
|
3737
3750
|
d(!0), N(""), w("");
|
|
3738
3751
|
try {
|
|
3739
|
-
await l({ token:
|
|
3752
|
+
await l({ token: F, newPassword: T }), w(D.resetSuccessMessage), i == null || i();
|
|
3740
3753
|
} catch (q) {
|
|
3741
|
-
const V = q.message ||
|
|
3754
|
+
const V = q.message || D.errorMessage;
|
|
3742
3755
|
N(V), o == null || o(V);
|
|
3743
3756
|
} finally {
|
|
3744
3757
|
d(!1);
|
|
@@ -3747,34 +3760,34 @@ function Kr({
|
|
|
3747
3760
|
}, E = (W) => ({
|
|
3748
3761
|
...p.input,
|
|
3749
3762
|
...R[W] ? p.inputError : {}
|
|
3750
|
-
}),
|
|
3763
|
+
}), K = () => ({
|
|
3751
3764
|
...p.button,
|
|
3752
3765
|
...P ? p.buttonLoading : {}
|
|
3753
3766
|
});
|
|
3754
3767
|
if (t === "reset") {
|
|
3755
|
-
const W =
|
|
3768
|
+
const W = F && T && L;
|
|
3756
3769
|
return /* @__PURE__ */ u("div", { className: m, style: p.container, children: [
|
|
3757
|
-
/* @__PURE__ */ s("h2", { style: p.title, children:
|
|
3758
|
-
/* @__PURE__ */ s("p", { style: p.subtitle, children:
|
|
3770
|
+
/* @__PURE__ */ s("h2", { style: p.title, children: D.resetTitle }),
|
|
3771
|
+
/* @__PURE__ */ s("p", { style: p.subtitle, children: D.resetSubtitle }),
|
|
3759
3772
|
/* @__PURE__ */ u("form", { onSubmit: S, style: p.form, children: [
|
|
3760
3773
|
/* @__PURE__ */ u("div", { style: p.fieldGroup, children: [
|
|
3761
|
-
/* @__PURE__ */ s("label", { style: p.label, children:
|
|
3774
|
+
/* @__PURE__ */ s("label", { style: p.label, children: D.tokenLabel }),
|
|
3762
3775
|
/* @__PURE__ */ s(
|
|
3763
3776
|
"input",
|
|
3764
3777
|
{
|
|
3765
3778
|
type: "text",
|
|
3766
|
-
value:
|
|
3779
|
+
value: F,
|
|
3767
3780
|
onChange: (q) => {
|
|
3768
3781
|
g(q.target.value), R.token && k((V) => ({ ...V, token: !1 }));
|
|
3769
3782
|
},
|
|
3770
|
-
placeholder:
|
|
3783
|
+
placeholder: D.tokenPlaceholder,
|
|
3771
3784
|
style: E("token"),
|
|
3772
3785
|
disabled: P
|
|
3773
3786
|
}
|
|
3774
3787
|
)
|
|
3775
3788
|
] }),
|
|
3776
3789
|
/* @__PURE__ */ u("div", { style: p.fieldGroup, children: [
|
|
3777
|
-
/* @__PURE__ */ s("label", { style: p.label, children:
|
|
3790
|
+
/* @__PURE__ */ s("label", { style: p.label, children: D.newPasswordLabel }),
|
|
3778
3791
|
/* @__PURE__ */ s(
|
|
3779
3792
|
"input",
|
|
3780
3793
|
{
|
|
@@ -3783,23 +3796,23 @@ function Kr({
|
|
|
3783
3796
|
onChange: (q) => {
|
|
3784
3797
|
A(q.target.value), R.newPassword && k((V) => ({ ...V, newPassword: !1 }));
|
|
3785
3798
|
},
|
|
3786
|
-
placeholder:
|
|
3799
|
+
placeholder: D.newPasswordPlaceholder,
|
|
3787
3800
|
style: E("newPassword"),
|
|
3788
3801
|
disabled: P
|
|
3789
3802
|
}
|
|
3790
3803
|
)
|
|
3791
3804
|
] }),
|
|
3792
3805
|
/* @__PURE__ */ u("div", { style: p.fieldGroup, children: [
|
|
3793
|
-
/* @__PURE__ */ s("label", { style: p.label, children:
|
|
3806
|
+
/* @__PURE__ */ s("label", { style: p.label, children: D.confirmPasswordLabel }),
|
|
3794
3807
|
/* @__PURE__ */ s(
|
|
3795
3808
|
"input",
|
|
3796
3809
|
{
|
|
3797
3810
|
type: "password",
|
|
3798
3811
|
value: L,
|
|
3799
3812
|
onChange: (q) => {
|
|
3800
|
-
M(q.target.value), R.confirmPassword && k((V) => ({ ...V, confirmPassword: !1 })), v ===
|
|
3813
|
+
M(q.target.value), R.confirmPassword && k((V) => ({ ...V, confirmPassword: !1 })), v === D.passwordMismatchError && N("");
|
|
3801
3814
|
},
|
|
3802
|
-
placeholder:
|
|
3815
|
+
placeholder: D.confirmPasswordPlaceholder,
|
|
3803
3816
|
style: E("confirmPassword"),
|
|
3804
3817
|
disabled: P
|
|
3805
3818
|
}
|
|
@@ -3811,31 +3824,31 @@ function Kr({
|
|
|
3811
3824
|
type: "submit",
|
|
3812
3825
|
disabled: !W || P,
|
|
3813
3826
|
style: {
|
|
3814
|
-
...
|
|
3827
|
+
...K(),
|
|
3815
3828
|
...!W || P ? p.buttonDisabled : {}
|
|
3816
3829
|
},
|
|
3817
|
-
children: P ?
|
|
3830
|
+
children: P ? D.resetLoadingText : D.resetSubmitButton
|
|
3818
3831
|
}
|
|
3819
3832
|
),
|
|
3820
3833
|
v && /* @__PURE__ */ s("div", { style: p.errorText, children: v }),
|
|
3821
|
-
|
|
3834
|
+
B && /* @__PURE__ */ s("div", { style: p.successText, children: B })
|
|
3822
3835
|
] }),
|
|
3823
3836
|
/* @__PURE__ */ u("div", { style: p.linkContainer, children: [
|
|
3824
|
-
/* @__PURE__ */ s("a", { onClick: a, style: p.link, children:
|
|
3837
|
+
/* @__PURE__ */ s("a", { onClick: a, style: p.link, children: D.backToLoginLink }),
|
|
3825
3838
|
c && /* @__PURE__ */ u(_, { children: [
|
|
3826
|
-
/* @__PURE__ */ s("span", { style: p.modeSwitchDivider, children:
|
|
3827
|
-
/* @__PURE__ */ s("a", { onClick: () => c("request"), style: p.link, children:
|
|
3839
|
+
/* @__PURE__ */ s("span", { style: p.modeSwitchDivider, children: D.dividerBullet }),
|
|
3840
|
+
/* @__PURE__ */ s("a", { onClick: () => c("request"), style: p.link, children: D.requestNewLinkLink })
|
|
3828
3841
|
] })
|
|
3829
3842
|
] })
|
|
3830
3843
|
] });
|
|
3831
3844
|
}
|
|
3832
3845
|
const G = y;
|
|
3833
3846
|
return /* @__PURE__ */ u("div", { className: m, style: p.container, children: [
|
|
3834
|
-
/* @__PURE__ */ s("h2", { style: p.title, children:
|
|
3835
|
-
/* @__PURE__ */ s("p", { style: p.subtitle, children:
|
|
3847
|
+
/* @__PURE__ */ s("h2", { style: p.title, children: D.title }),
|
|
3848
|
+
/* @__PURE__ */ s("p", { style: p.subtitle, children: D.subtitle }),
|
|
3836
3849
|
/* @__PURE__ */ u("form", { onSubmit: h, style: p.form, children: [
|
|
3837
3850
|
/* @__PURE__ */ u("div", { style: p.fieldGroup, children: [
|
|
3838
|
-
/* @__PURE__ */ s("label", { style: p.label, children:
|
|
3851
|
+
/* @__PURE__ */ s("label", { style: p.label, children: D.emailLabel }),
|
|
3839
3852
|
/* @__PURE__ */ s(
|
|
3840
3853
|
"input",
|
|
3841
3854
|
{
|
|
@@ -3844,7 +3857,7 @@ function Kr({
|
|
|
3844
3857
|
onChange: (W) => {
|
|
3845
3858
|
f(W.target.value), R.email && k((q) => ({ ...q, email: !1 }));
|
|
3846
3859
|
},
|
|
3847
|
-
placeholder:
|
|
3860
|
+
placeholder: D.emailPlaceholder,
|
|
3848
3861
|
style: E("email"),
|
|
3849
3862
|
disabled: P
|
|
3850
3863
|
}
|
|
@@ -3856,20 +3869,20 @@ function Kr({
|
|
|
3856
3869
|
type: "submit",
|
|
3857
3870
|
disabled: !G || P,
|
|
3858
3871
|
style: {
|
|
3859
|
-
...
|
|
3872
|
+
...K(),
|
|
3860
3873
|
...!G || P ? p.buttonDisabled : {}
|
|
3861
3874
|
},
|
|
3862
|
-
children: P ?
|
|
3875
|
+
children: P ? D.loadingText : D.submitButton
|
|
3863
3876
|
}
|
|
3864
3877
|
),
|
|
3865
3878
|
v && /* @__PURE__ */ s("div", { style: p.errorText, children: v }),
|
|
3866
|
-
|
|
3879
|
+
B && /* @__PURE__ */ s("div", { style: p.successText, children: B })
|
|
3867
3880
|
] }),
|
|
3868
3881
|
/* @__PURE__ */ u("div", { style: p.linkContainer, children: [
|
|
3869
|
-
/* @__PURE__ */ s("a", { onClick: a, style: p.link, children:
|
|
3882
|
+
/* @__PURE__ */ s("a", { onClick: a, style: p.link, children: D.backToLoginLink }),
|
|
3870
3883
|
c && /* @__PURE__ */ u(_, { children: [
|
|
3871
|
-
/* @__PURE__ */ s("span", { style: p.modeSwitchDivider, children:
|
|
3872
|
-
/* @__PURE__ */ s("a", { onClick: () => c("reset"), style: p.link, children:
|
|
3884
|
+
/* @__PURE__ */ s("span", { style: p.modeSwitchDivider, children: D.dividerBullet }),
|
|
3885
|
+
/* @__PURE__ */ s("a", { onClick: () => c("reset"), style: p.link, children: D.haveTokenLink })
|
|
3873
3886
|
] })
|
|
3874
3887
|
] })
|
|
3875
3888
|
] });
|
|
@@ -3926,8 +3939,8 @@ function Zr({
|
|
|
3926
3939
|
errorFallback: t,
|
|
3927
3940
|
requireTenant: r = !0
|
|
3928
3941
|
}) {
|
|
3929
|
-
const { isAppLoading: i, appError: o, retryApp: a } = Ae(), c = pe(), m =
|
|
3930
|
-
}), L = (m == null ? void 0 : m.isAuthReady) ?? !0, M = (y == null ? void 0 : y.isReady) ?? !0, P = (f == null ? void 0 : f.isReady) ?? !0, d = r && c && T, w = i || d &&
|
|
3942
|
+
const { isAppLoading: i, appError: o, retryApp: a } = Ae(), c = pe(), m = $e(), y = Ye(), f = Xe(), F = (c == null ? void 0 : c.isTenantLoading) ?? !1, g = (c == null ? void 0 : c.tenantError) ?? null, T = (c == null ? void 0 : c.tenantSlug) ?? null, A = (c == null ? void 0 : c.retryTenant) ?? (() => {
|
|
3943
|
+
}), L = (m == null ? void 0 : m.isAuthReady) ?? !0, M = (y == null ? void 0 : y.isReady) ?? !0, P = (f == null ? void 0 : f.isReady) ?? !0, d = r && c && T, w = i || d && F || m && !L || y && !M || f && !P, R = o || (d ? g : null), k = () => {
|
|
3931
3944
|
o && a(), g && c && A();
|
|
3932
3945
|
};
|
|
3933
3946
|
if (w)
|
|
@@ -3939,18 +3952,18 @@ function Zr({
|
|
|
3939
3952
|
return /* @__PURE__ */ s(_, { children: n });
|
|
3940
3953
|
}
|
|
3941
3954
|
function Jr(n = !0) {
|
|
3942
|
-
const { isAppLoading: e, appError: t, retryApp: r, appInfo: i } = Ae(), o = pe(), a =
|
|
3943
|
-
}), A = (a == null ? void 0 : a.isAuthReady) ?? !0, L = (c == null ? void 0 : c.isReady) ?? !0, M = (m == null ? void 0 : m.isReady) ?? !0, P = n && o && g,
|
|
3955
|
+
const { isAppLoading: e, appError: t, retryApp: r, appInfo: i } = Ae(), o = pe(), a = $e(), c = Ye(), m = Xe(), y = (o == null ? void 0 : o.isTenantLoading) ?? !1, f = (o == null ? void 0 : o.tenantError) ?? null, F = (o == null ? void 0 : o.tenant) ?? null, g = (o == null ? void 0 : o.tenantSlug) ?? null, T = (o == null ? void 0 : o.retryTenant) ?? (() => {
|
|
3956
|
+
}), A = (a == null ? void 0 : a.isAuthReady) ?? !0, L = (c == null ? void 0 : c.isReady) ?? !0, M = (m == null ? void 0 : m.isReady) ?? !0, P = n && o && g, B = e || P && y || a && !A || c && !L || m && !M, w = t || (P ? f : null);
|
|
3944
3957
|
return {
|
|
3945
|
-
isLoading:
|
|
3958
|
+
isLoading: B,
|
|
3946
3959
|
error: w,
|
|
3947
|
-
isReady:
|
|
3960
|
+
isReady: !B && !w && i !== null && (!P || F !== null),
|
|
3948
3961
|
retry: () => {
|
|
3949
3962
|
t && r(), f && o && T();
|
|
3950
3963
|
},
|
|
3951
3964
|
// Individual states
|
|
3952
3965
|
app: { isLoading: e, error: t, data: i },
|
|
3953
|
-
tenant: o ? { isLoading: y, error: f, data:
|
|
3966
|
+
tenant: o ? { isLoading: y, error: f, data: F } : null,
|
|
3954
3967
|
auth: a ? { isReady: A } : null,
|
|
3955
3968
|
featureFlags: c ? { isReady: L } : null,
|
|
3956
3969
|
subscription: m ? { isReady: M } : null
|
|
@@ -4013,8 +4026,8 @@ function Yr({
|
|
|
4013
4026
|
disabled: y = !1,
|
|
4014
4027
|
showCurrentTenant: f = !0
|
|
4015
4028
|
}) {
|
|
4016
|
-
var
|
|
4017
|
-
const
|
|
4029
|
+
var B;
|
|
4030
|
+
const F = { ...dr, ...r }, g = $e(), [T, A] = x(!1), L = Ne(null), M = n ?? (g == null ? void 0 : g.userTenants) ?? [], P = e ?? ((B = g == null ? void 0 : g.currentUser) == null ? void 0 : B.tenantId) ?? null, d = async (w) => {
|
|
4018
4031
|
A(!1), t ? t(w) : g != null && g.switchToTenant && await g.switchToTenant(w);
|
|
4019
4032
|
};
|
|
4020
4033
|
ne(() => {
|
|
@@ -4030,13 +4043,13 @@ function Yr({
|
|
|
4030
4043
|
return /* @__PURE__ */ s("div", { className: i, children: /* @__PURE__ */ s("span", { children: M[0].name }) });
|
|
4031
4044
|
const N = (w, R) => /* @__PURE__ */ u("span", { style: { fontWeight: R ? "bold" : "normal" }, children: [
|
|
4032
4045
|
w.name,
|
|
4033
|
-
w.role && /* @__PURE__ */ u("span", { style:
|
|
4046
|
+
w.role && /* @__PURE__ */ u("span", { style: F.itemRole, children: [
|
|
4034
4047
|
"(",
|
|
4035
4048
|
w.role,
|
|
4036
4049
|
")"
|
|
4037
4050
|
] })
|
|
4038
4051
|
] });
|
|
4039
|
-
return /* @__PURE__ */ u("div", { ref: L, className: i, style:
|
|
4052
|
+
return /* @__PURE__ */ u("div", { ref: L, className: i, style: F.wrapper, children: [
|
|
4040
4053
|
/* @__PURE__ */ u(
|
|
4041
4054
|
"button",
|
|
4042
4055
|
{
|
|
@@ -4044,16 +4057,16 @@ function Yr({
|
|
|
4044
4057
|
onClick: () => !y && A(!T),
|
|
4045
4058
|
disabled: y,
|
|
4046
4059
|
style: {
|
|
4047
|
-
...
|
|
4048
|
-
...y ?
|
|
4060
|
+
...F.button,
|
|
4061
|
+
...y ? F.buttonDisabled : {}
|
|
4049
4062
|
},
|
|
4050
4063
|
children: [
|
|
4051
4064
|
v ? v.name : m,
|
|
4052
|
-
/* @__PURE__ */ s("span", { style:
|
|
4065
|
+
/* @__PURE__ */ s("span", { style: F.arrow, children: T ? "▲" : "▼" })
|
|
4053
4066
|
]
|
|
4054
4067
|
}
|
|
4055
4068
|
),
|
|
4056
|
-
T && /* @__PURE__ */ s("div", { className: o, style:
|
|
4069
|
+
T && /* @__PURE__ */ s("div", { className: o, style: F.dropdown, children: M.map((w) => {
|
|
4057
4070
|
const R = w.id === P;
|
|
4058
4071
|
return /* @__PURE__ */ s(
|
|
4059
4072
|
"div",
|
|
@@ -4061,16 +4074,16 @@ function Yr({
|
|
|
4061
4074
|
className: a,
|
|
4062
4075
|
onClick: () => d(w.id),
|
|
4063
4076
|
style: {
|
|
4064
|
-
...
|
|
4065
|
-
...R ?
|
|
4077
|
+
...F.item,
|
|
4078
|
+
...R ? F.itemSelected : {}
|
|
4066
4079
|
},
|
|
4067
4080
|
onMouseEnter: (k) => {
|
|
4068
|
-
R || Object.assign(k.currentTarget.style,
|
|
4081
|
+
R || Object.assign(k.currentTarget.style, F.itemHover);
|
|
4069
4082
|
},
|
|
4070
4083
|
onMouseLeave: (k) => {
|
|
4071
4084
|
if (!R) {
|
|
4072
|
-
const I =
|
|
4073
|
-
Object.keys(
|
|
4085
|
+
const I = F.item || {};
|
|
4086
|
+
Object.keys(F.itemHover || {}).forEach((l) => {
|
|
4074
4087
|
k.currentTarget.style[l] = I[l] ?? "";
|
|
4075
4088
|
});
|
|
4076
4089
|
}
|
|
@@ -4338,7 +4351,7 @@ function nn(n = {}) {
|
|
|
4338
4351
|
zoneRoots: e = {},
|
|
4339
4352
|
returnToParam: t = rt,
|
|
4340
4353
|
returnToStorage: r = "url"
|
|
4341
|
-
} = n, i = mt(), [o, a] = yt(), { isAuthenticated: c, currentUser: m } = he(), { tenant: y } = Te(), f = Z(() => ({ ...Oe, ...e }), [e]),
|
|
4354
|
+
} = n, i = mt(), [o, a] = yt(), { isAuthenticated: c, currentUser: m } = he(), { tenant: y } = Te(), f = Z(() => ({ ...Oe, ...e }), [e]), F = !!y, g = m == null ? void 0 : m.userType, T = Z(() => {
|
|
4342
4355
|
switch (r) {
|
|
4343
4356
|
case "url":
|
|
4344
4357
|
return o.get(t);
|
|
@@ -4349,7 +4362,7 @@ function nn(n = {}) {
|
|
|
4349
4362
|
default:
|
|
4350
4363
|
return null;
|
|
4351
4364
|
}
|
|
4352
|
-
}, [r, o, t]), A =
|
|
4365
|
+
}, [r, o, t]), A = oe(() => {
|
|
4353
4366
|
switch (r) {
|
|
4354
4367
|
case "url": {
|
|
4355
4368
|
const d = new URLSearchParams(o);
|
|
@@ -4363,7 +4376,7 @@ function nn(n = {}) {
|
|
|
4363
4376
|
localStorage.removeItem(Le);
|
|
4364
4377
|
break;
|
|
4365
4378
|
}
|
|
4366
|
-
}, [r, o, t, a]), L =
|
|
4379
|
+
}, [r, o, t, a]), L = oe(
|
|
4367
4380
|
(d) => {
|
|
4368
4381
|
switch (r) {
|
|
4369
4382
|
case "url": {
|
|
@@ -4380,13 +4393,13 @@ function nn(n = {}) {
|
|
|
4380
4393
|
}
|
|
4381
4394
|
},
|
|
4382
4395
|
[r, o, t, a]
|
|
4383
|
-
), M =
|
|
4396
|
+
), M = oe(
|
|
4384
4397
|
(d) => {
|
|
4385
4398
|
const v = f[d] || f.default;
|
|
4386
4399
|
i(v);
|
|
4387
4400
|
},
|
|
4388
4401
|
[i, f]
|
|
4389
|
-
), P =
|
|
4402
|
+
), P = oe(() => F ? c ? g === ae.TENANT_ADMIN ? f.tenantAdmin : f.tenantUser : f.tenantGuest : c ? g === ae.TENANT_ADMIN ? f.publicAdmin : f.publicUser : f.publicGuest, [F, c, g, f]);
|
|
4390
4403
|
return {
|
|
4391
4404
|
returnToUrl: T,
|
|
4392
4405
|
clearReturnTo: A,
|
|
@@ -4402,7 +4415,7 @@ function sn(n, e, t = rt, r = "url") {
|
|
|
4402
4415
|
return i.searchParams.set(t, e), i.pathname + i.search;
|
|
4403
4416
|
}
|
|
4404
4417
|
export {
|
|
4405
|
-
|
|
4418
|
+
$r as AdminZone,
|
|
4406
4419
|
rn as ApiMappers,
|
|
4407
4420
|
Ve as AppApiService,
|
|
4408
4421
|
Zr as AppLoader,
|
|
@@ -4415,19 +4428,19 @@ export {
|
|
|
4415
4428
|
Vr as FeatureFlag,
|
|
4416
4429
|
It as FeatureFlagApiService,
|
|
4417
4430
|
Ar as FeatureFlagProvider,
|
|
4418
|
-
|
|
4431
|
+
Br as GuestZone,
|
|
4419
4432
|
tn as HealthApiService,
|
|
4420
4433
|
de as HttpService,
|
|
4421
4434
|
Nr as LandingRoute,
|
|
4422
4435
|
Wr as LoginForm,
|
|
4423
4436
|
Gr as MagicLinkForm,
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4437
|
+
Kr as MagicLinkVerify,
|
|
4438
|
+
Hr as OpenZone,
|
|
4439
|
+
Qr as PasswordRecoveryForm,
|
|
4427
4440
|
Xr as PermissionApiService,
|
|
4428
4441
|
Ir as Protected,
|
|
4429
4442
|
Mr as ProtectedRoute,
|
|
4430
|
-
|
|
4443
|
+
Dr as PublicZone,
|
|
4431
4444
|
We as RoleApiService,
|
|
4432
4445
|
Rr as RoutingProvider,
|
|
4433
4446
|
se as SessionExpiredError,
|
|
@@ -4444,12 +4457,12 @@ export {
|
|
|
4444
4457
|
Sr as TenantProvider,
|
|
4445
4458
|
Lr as TenantRoute,
|
|
4446
4459
|
Yr as TenantSelector,
|
|
4447
|
-
|
|
4460
|
+
Fr as TenantZone,
|
|
4448
4461
|
bt as TokenRefreshError,
|
|
4449
4462
|
wt as TokenRefreshTimeoutError,
|
|
4450
4463
|
St as UserApiService,
|
|
4451
4464
|
ae as UserType,
|
|
4452
|
-
|
|
4465
|
+
Cr as UserZone,
|
|
4453
4466
|
ue as ZoneRoute,
|
|
4454
4467
|
sn as buildRedirectUrl,
|
|
4455
4468
|
vr as useApi,
|
|
@@ -4458,7 +4471,7 @@ export {
|
|
|
4458
4471
|
he as useAuth,
|
|
4459
4472
|
Mt as useFeatureFlags,
|
|
4460
4473
|
Er as useRouting,
|
|
4461
|
-
|
|
4474
|
+
Ft as useRoutingOptional,
|
|
4462
4475
|
kr as useSettings,
|
|
4463
4476
|
Nt as useSubscription,
|
|
4464
4477
|
Te as useTenant,
|