@skylabs-digital/react-identity-access 2.28.0 → 2.30.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 +610 -586
- 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 +6 -0
- package/dist/services/SessionManager.d.ts.map +1 -1
- package/package.json +4 -1
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as s, Fragment as _, jsxs as
|
|
2
|
-
import { createContext as ye, useMemo as
|
|
1
|
+
import { jsx as s, Fragment as _, jsxs as h } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as ye, useMemo as J, 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) {
|
|
@@ -13,28 +13,28 @@ class de {
|
|
|
13
13
|
}
|
|
14
14
|
async executeRequest(e, t, r, i) {
|
|
15
15
|
const o = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, a = (i == null ? void 0 : i.timeout) || this.timeout;
|
|
16
|
-
let
|
|
16
|
+
let d = {
|
|
17
17
|
"Content-Type": "application/json",
|
|
18
18
|
...i == null ? void 0 : i.headers
|
|
19
19
|
};
|
|
20
20
|
if (!(i != null && i.skipAuth) && this.sessionManager) {
|
|
21
|
-
const
|
|
22
|
-
|
|
21
|
+
const c = await this.sessionManager.getValidAccessToken();
|
|
22
|
+
d = { ...d, Authorization: `Bearer ${c}` };
|
|
23
23
|
}
|
|
24
|
-
const
|
|
24
|
+
const f = new AbortController(), y = setTimeout(() => f.abort(), a);
|
|
25
25
|
try {
|
|
26
|
-
const
|
|
26
|
+
const c = await fetch(o, {
|
|
27
27
|
method: e,
|
|
28
|
-
headers:
|
|
28
|
+
headers: d,
|
|
29
29
|
body: r ? JSON.stringify(r) : void 0,
|
|
30
|
-
signal:
|
|
30
|
+
signal: f.signal
|
|
31
31
|
});
|
|
32
|
-
if (clearTimeout(y), !
|
|
33
|
-
throw new Error(`HTTP ${
|
|
34
|
-
const
|
|
35
|
-
return !
|
|
36
|
-
} catch (
|
|
37
|
-
throw clearTimeout(y),
|
|
32
|
+
if (clearTimeout(y), !c.ok)
|
|
33
|
+
throw new Error(`HTTP ${c.status}: ${c.statusText}`);
|
|
34
|
+
const L = c.headers.get("content-type");
|
|
35
|
+
return !L || !L.includes("application/json") ? {} : await c.json();
|
|
36
|
+
} catch (c) {
|
|
37
|
+
throw clearTimeout(y), c instanceof Error && c.name === "AbortError" ? new Error(`Request timeout after ${a}ms`) : c;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
async get(e, t) {
|
|
@@ -111,11 +111,11 @@ class Ve {
|
|
|
111
111
|
}
|
|
112
112
|
const Fe = ye(null);
|
|
113
113
|
function br({ config: n, children: e }) {
|
|
114
|
-
const t =
|
|
114
|
+
const t = J(
|
|
115
115
|
() => {
|
|
116
|
-
var
|
|
116
|
+
var m, T, A;
|
|
117
117
|
return {
|
|
118
|
-
enabled: ((
|
|
118
|
+
enabled: ((m = n.cache) == null ? void 0 : m.enabled) ?? !0,
|
|
119
119
|
ttl: ((T = n.cache) == null ? void 0 : T.ttl) ?? 3e5,
|
|
120
120
|
// 5 minutes default
|
|
121
121
|
storageKey: ((A = n.cache) == null ? void 0 : A.storageKey) ?? `app_cache_${n.appId}`
|
|
@@ -125,16 +125,16 @@ function br({ config: n, children: e }) {
|
|
|
125
125
|
), [r, i] = x(() => {
|
|
126
126
|
if (!t.enabled) return null;
|
|
127
127
|
try {
|
|
128
|
-
const
|
|
129
|
-
if (!
|
|
130
|
-
const T = JSON.parse(
|
|
128
|
+
const m = localStorage.getItem(t.storageKey);
|
|
129
|
+
if (!m) return null;
|
|
130
|
+
const T = JSON.parse(m);
|
|
131
131
|
return Date.now() - T.timestamp < t.ttl && T.appId === n.appId ? T.data : (localStorage.removeItem(t.storageKey), null);
|
|
132
132
|
} catch {
|
|
133
133
|
return null;
|
|
134
134
|
}
|
|
135
|
-
}), [o, a] = x(!r), [
|
|
136
|
-
const
|
|
137
|
-
|
|
135
|
+
}), [o, a] = x(!r), [d, f] = x(null), y = J(() => {
|
|
136
|
+
const m = () => {
|
|
137
|
+
c();
|
|
138
138
|
};
|
|
139
139
|
return {
|
|
140
140
|
appId: n.appId,
|
|
@@ -142,19 +142,19 @@ function br({ config: n, children: e }) {
|
|
|
142
142
|
// App info
|
|
143
143
|
appInfo: r,
|
|
144
144
|
isAppLoading: o,
|
|
145
|
-
appError:
|
|
146
|
-
retryApp:
|
|
145
|
+
appError: d,
|
|
146
|
+
retryApp: m
|
|
147
147
|
};
|
|
148
|
-
}, [n, r, o,
|
|
149
|
-
async (
|
|
150
|
-
if (!(!
|
|
148
|
+
}, [n, r, o, d]), c = oe(
|
|
149
|
+
async (m = !1) => {
|
|
150
|
+
if (!(!m && t.enabled && r))
|
|
151
151
|
try {
|
|
152
|
-
a(!0),
|
|
153
|
-
const T = new de(n.baseUrl),
|
|
154
|
-
if (i(
|
|
152
|
+
a(!0), f(null);
|
|
153
|
+
const T = new de(n.baseUrl), N = await new Ve(T, {}).getPublicAppInfo(n.appId);
|
|
154
|
+
if (i(N), t.enabled)
|
|
155
155
|
try {
|
|
156
156
|
const M = {
|
|
157
|
-
data:
|
|
157
|
+
data: N,
|
|
158
158
|
timestamp: Date.now(),
|
|
159
159
|
appId: n.appId
|
|
160
160
|
};
|
|
@@ -164,34 +164,34 @@ function br({ config: n, children: e }) {
|
|
|
164
164
|
}
|
|
165
165
|
} catch (T) {
|
|
166
166
|
const A = T instanceof Error ? T : new Error("Failed to load app information");
|
|
167
|
-
|
|
167
|
+
f(A), i(null);
|
|
168
168
|
} finally {
|
|
169
169
|
a(!1);
|
|
170
170
|
}
|
|
171
171
|
},
|
|
172
172
|
[n.baseUrl, n.appId, t, r]
|
|
173
|
-
),
|
|
173
|
+
), L = oe(async () => {
|
|
174
174
|
if (!(!t.enabled || !r))
|
|
175
175
|
try {
|
|
176
|
-
const
|
|
177
|
-
if (!
|
|
178
|
-
const T = JSON.parse(
|
|
176
|
+
const m = localStorage.getItem(t.storageKey);
|
|
177
|
+
if (!m) return;
|
|
178
|
+
const T = JSON.parse(m);
|
|
179
179
|
if (Date.now() - T.timestamp > t.ttl * 0.5) {
|
|
180
|
-
const
|
|
180
|
+
const N = new de(n.baseUrl), P = await new Ve(N, {}).getPublicAppInfo(n.appId);
|
|
181
181
|
i(P);
|
|
182
|
-
const
|
|
182
|
+
const u = {
|
|
183
183
|
data: P,
|
|
184
184
|
timestamp: Date.now(),
|
|
185
185
|
appId: n.appId
|
|
186
186
|
};
|
|
187
|
-
localStorage.setItem(t.storageKey, JSON.stringify(
|
|
187
|
+
localStorage.setItem(t.storageKey, JSON.stringify(u));
|
|
188
188
|
}
|
|
189
|
-
} catch (
|
|
190
|
-
process.env.NODE_ENV === "development" && console.warn("[AppProvider] Background app refresh failed:",
|
|
189
|
+
} catch (m) {
|
|
190
|
+
process.env.NODE_ENV === "development" && console.warn("[AppProvider] Background app refresh failed:", m);
|
|
191
191
|
}
|
|
192
192
|
}, [n, t, r]);
|
|
193
193
|
return ne(() => {
|
|
194
|
-
r ?
|
|
194
|
+
r ? L() : c();
|
|
195
195
|
}, []), /* @__PURE__ */ s(Fe.Provider, { value: y, children: e });
|
|
196
196
|
}
|
|
197
197
|
function Ae() {
|
|
@@ -295,6 +295,20 @@ const ie = class ie {
|
|
|
295
295
|
return;
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
+
/**
|
|
299
|
+
* Extract an arbitrary claim from a JWT token.
|
|
300
|
+
* Returns undefined if the token cannot be decoded or the claim is missing.
|
|
301
|
+
*/
|
|
302
|
+
static extractJwtClaim(e, t) {
|
|
303
|
+
try {
|
|
304
|
+
const r = e.split(".");
|
|
305
|
+
if (r.length !== 3) return;
|
|
306
|
+
const i = JSON.parse(atob(r[1].replace(/-/g, "+").replace(/_/g, "/")));
|
|
307
|
+
return typeof i[t] == "string" ? i[t] : void 0;
|
|
308
|
+
} catch {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
298
312
|
setTokens(e) {
|
|
299
313
|
const t = e.expiresAt || (e.expiresIn ? Date.now() + e.expiresIn * 1e3 : void 0) || ie.extractJwtExpiry(e.accessToken), r = {
|
|
300
314
|
...e,
|
|
@@ -469,8 +483,8 @@ const ie = class ie {
|
|
|
469
483
|
if (a instanceof se)
|
|
470
484
|
throw a;
|
|
471
485
|
if (t = a, i < this.maxRefreshRetries) {
|
|
472
|
-
const
|
|
473
|
-
await this.sleep(
|
|
486
|
+
const d = this.retryBackoffBase * Math.pow(2, i);
|
|
487
|
+
await this.sleep(d);
|
|
474
488
|
}
|
|
475
489
|
}
|
|
476
490
|
}
|
|
@@ -482,36 +496,46 @@ const ie = class ie {
|
|
|
482
496
|
* Throws generic Error for transient errors (will be retried).
|
|
483
497
|
*/
|
|
484
498
|
async performTokenRefresh(e, t) {
|
|
499
|
+
return typeof navigator < "u" && navigator.locks ? navigator.locks.request(
|
|
500
|
+
`session-refresh:${this.storageKey}`,
|
|
501
|
+
() => this.performTokenRefreshInner(e, t)
|
|
502
|
+
) : this.performTokenRefreshInner(e, t);
|
|
503
|
+
}
|
|
504
|
+
async performTokenRefreshInner(e, t) {
|
|
485
505
|
if (!this.baseUrl)
|
|
486
506
|
throw new Error("Base URL not configured for token refresh");
|
|
487
|
-
const r =
|
|
488
|
-
|
|
507
|
+
const r = this.getTokens();
|
|
508
|
+
if (r != null && r.accessToken && !this.isTokenExpired(r) && !this.shouldRefreshToken(r))
|
|
509
|
+
return;
|
|
510
|
+
const i = (r == null ? void 0 : r.refreshToken) || e, o = `${this.baseUrl}/auth/refresh`, a = ie.extractJwtClaim(i, "deviceId"), d = { refreshToken: i };
|
|
511
|
+
a && (d.deviceId = a);
|
|
512
|
+
let f;
|
|
489
513
|
try {
|
|
490
|
-
|
|
514
|
+
f = await fetch(o, {
|
|
491
515
|
method: "POST",
|
|
492
516
|
headers: { "Content-Type": "application/json" },
|
|
493
|
-
body: JSON.stringify(
|
|
517
|
+
body: JSON.stringify(d)
|
|
494
518
|
});
|
|
495
|
-
} catch (
|
|
496
|
-
throw
|
|
519
|
+
} catch (c) {
|
|
520
|
+
throw c instanceof Error ? c : new Error("Network error during token refresh");
|
|
497
521
|
}
|
|
498
|
-
if (!
|
|
499
|
-
let
|
|
522
|
+
if (!f.ok) {
|
|
523
|
+
let c = "";
|
|
500
524
|
try {
|
|
501
|
-
const
|
|
502
|
-
|
|
525
|
+
const L = await f.json();
|
|
526
|
+
c = (L.message || L.error || "").toLowerCase();
|
|
503
527
|
} catch {
|
|
504
|
-
|
|
528
|
+
c = f.statusText.toLowerCase();
|
|
505
529
|
}
|
|
506
|
-
throw
|
|
530
|
+
throw f.status === 401 ? c.includes("expired") ? new se("token_expired") : c.includes("invalid") ? new se("token_invalid") : new se("token_invalid", `Unauthorized: ${c}`) : f.status === 400 ? c.includes("inactive") ? new se("user_inactive") : c.includes("expired") || c.includes("invalid") ? new se("token_invalid", c) : c.includes("reuse") || c.includes("revoked") ? new se("token_invalid", c) : new Error(`Token refresh failed (400): ${c}`) : new Error(`Token refresh failed: ${f.status} ${c}`);
|
|
507
531
|
}
|
|
508
532
|
if (this.sessionGeneration !== t)
|
|
509
533
|
throw new se("token_invalid", "Session cleared during refresh");
|
|
510
|
-
const
|
|
534
|
+
const y = await f.json();
|
|
511
535
|
this.setTokens({
|
|
512
|
-
accessToken:
|
|
513
|
-
refreshToken:
|
|
514
|
-
expiresIn:
|
|
536
|
+
accessToken: y.accessToken,
|
|
537
|
+
refreshToken: y.refreshToken || i,
|
|
538
|
+
expiresIn: y.expiresIn
|
|
515
539
|
});
|
|
516
540
|
}
|
|
517
541
|
// --- Session expiry handler ---
|
|
@@ -907,115 +931,115 @@ function Sr({ config: n, children: e }) {
|
|
|
907
931
|
search: window.location.search
|
|
908
932
|
},
|
|
909
933
|
window.localStorage
|
|
910
|
-
), [n.tenantMode, n.baseDomain, n.selectorParam, n.fixedTenantSlug]), [a,
|
|
934
|
+
), [n.tenantMode, n.baseDomain, n.selectorParam, n.fixedTenantSlug]), [a, d] = x(() => o()), f = J(
|
|
911
935
|
() => {
|
|
912
|
-
var
|
|
936
|
+
var g, U, b;
|
|
913
937
|
return {
|
|
914
|
-
enabled: ((
|
|
938
|
+
enabled: ((g = n.cache) == null ? void 0 : g.enabled) ?? !0,
|
|
915
939
|
ttl: ((U = n.cache) == null ? void 0 : U.ttl) ?? 5 * 60 * 1e3,
|
|
916
940
|
// 5 minutes default
|
|
917
941
|
storageKey: ((b = n.cache) == null ? void 0 : b.storageKey) ?? `tenant_cache_${a || "default"}`
|
|
918
942
|
};
|
|
919
943
|
},
|
|
920
944
|
[n.cache, a]
|
|
921
|
-
), [y,
|
|
945
|
+
), [y, c] = x(() => {
|
|
922
946
|
if (n.initialTenant) return n.initialTenant;
|
|
923
|
-
if (!
|
|
947
|
+
if (!f.enabled || !a) return null;
|
|
924
948
|
try {
|
|
925
|
-
const
|
|
926
|
-
if (!
|
|
927
|
-
const U = JSON.parse(
|
|
928
|
-
return Date.now() - U.timestamp <
|
|
949
|
+
const g = localStorage.getItem(f.storageKey);
|
|
950
|
+
if (!g) return null;
|
|
951
|
+
const U = JSON.parse(g);
|
|
952
|
+
return Date.now() - U.timestamp < f.ttl && U.tenantSlug === a ? U.data : (localStorage.removeItem(f.storageKey), null);
|
|
929
953
|
} catch {
|
|
930
954
|
return null;
|
|
931
955
|
}
|
|
932
|
-
}), [
|
|
956
|
+
}), [L, m] = x(!y && !n.initialTenant), [T, A] = x(null), [N, M] = x(null), [P, u] = x(!1), [v, F] = x(null);
|
|
933
957
|
ne(() => {
|
|
934
958
|
if (n.tenantMode === "fixed") return;
|
|
935
|
-
const
|
|
936
|
-
|
|
959
|
+
const g = o();
|
|
960
|
+
d(g);
|
|
937
961
|
}, [o, n.tenantMode]);
|
|
938
962
|
const B = (r == null ? void 0 : r.settingsSchema) || null, w = oe(
|
|
939
|
-
async (
|
|
940
|
-
if (!(!U &&
|
|
963
|
+
async (g, U = !1) => {
|
|
964
|
+
if (!(!U && f.enabled && y && y.domain === g))
|
|
941
965
|
try {
|
|
942
|
-
|
|
943
|
-
const b = new de(t), S = await new ve(b, i).getPublicTenantInfo(
|
|
944
|
-
if (
|
|
966
|
+
m(!0), A(null);
|
|
967
|
+
const b = new de(t), S = await new ve(b, i).getPublicTenantInfo(g);
|
|
968
|
+
if (c(S), f.enabled)
|
|
945
969
|
try {
|
|
946
970
|
const E = {
|
|
947
971
|
data: S,
|
|
948
972
|
timestamp: Date.now(),
|
|
949
|
-
tenantSlug:
|
|
973
|
+
tenantSlug: g
|
|
950
974
|
};
|
|
951
|
-
localStorage.setItem(
|
|
975
|
+
localStorage.setItem(f.storageKey, JSON.stringify(E));
|
|
952
976
|
} catch (E) {
|
|
953
977
|
process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Failed to cache tenant info:", E);
|
|
954
978
|
}
|
|
955
979
|
} catch (b) {
|
|
956
|
-
const
|
|
957
|
-
A(
|
|
980
|
+
const p = b instanceof Error ? b : new Error("Failed to load tenant information");
|
|
981
|
+
A(p), c(null);
|
|
958
982
|
} finally {
|
|
959
|
-
|
|
983
|
+
m(!1);
|
|
960
984
|
}
|
|
961
985
|
},
|
|
962
|
-
[t, i,
|
|
986
|
+
[t, i, f, y]
|
|
963
987
|
), R = oe(async () => {
|
|
964
|
-
if (!(!
|
|
988
|
+
if (!(!f.enabled || !y || !a))
|
|
965
989
|
try {
|
|
966
|
-
const
|
|
967
|
-
if (!
|
|
968
|
-
const U = JSON.parse(
|
|
969
|
-
if (Date.now() - U.timestamp >
|
|
970
|
-
const
|
|
971
|
-
|
|
990
|
+
const g = localStorage.getItem(f.storageKey);
|
|
991
|
+
if (!g) return;
|
|
992
|
+
const U = JSON.parse(g);
|
|
993
|
+
if (Date.now() - U.timestamp > f.ttl * 0.5) {
|
|
994
|
+
const p = new de(t), E = await new ve(p, i).getPublicTenantInfo(a);
|
|
995
|
+
c(E);
|
|
972
996
|
const K = {
|
|
973
997
|
data: E,
|
|
974
998
|
timestamp: Date.now(),
|
|
975
999
|
tenantSlug: a
|
|
976
1000
|
};
|
|
977
|
-
localStorage.setItem(
|
|
1001
|
+
localStorage.setItem(f.storageKey, JSON.stringify(K));
|
|
978
1002
|
}
|
|
979
|
-
} catch (
|
|
980
|
-
process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Background tenant refresh failed:",
|
|
1003
|
+
} catch (g) {
|
|
1004
|
+
process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Background tenant refresh failed:", g);
|
|
981
1005
|
}
|
|
982
|
-
}, [t, i,
|
|
1006
|
+
}, [t, i, f, y, a]), k = oe(async () => {
|
|
983
1007
|
if (y != null && y.id)
|
|
984
1008
|
try {
|
|
985
|
-
|
|
986
|
-
const
|
|
1009
|
+
u(!0), F(null);
|
|
1010
|
+
const g = new de(t), b = await new ve(g, y.appId).getTenantSettings(y.id);
|
|
987
1011
|
M(b);
|
|
988
|
-
} catch (
|
|
989
|
-
const U =
|
|
990
|
-
|
|
1012
|
+
} catch (g) {
|
|
1013
|
+
const U = g instanceof Error ? g : new Error("Failed to load tenant settings");
|
|
1014
|
+
F(U), M(null);
|
|
991
1015
|
} finally {
|
|
992
|
-
|
|
1016
|
+
u(!1);
|
|
993
1017
|
}
|
|
994
1018
|
}, [t, y]), I = oe(() => {
|
|
995
1019
|
k();
|
|
996
1020
|
}, [k]), l = oe(
|
|
997
|
-
(
|
|
1021
|
+
(g) => {
|
|
998
1022
|
if (!B)
|
|
999
1023
|
return { isValid: !0, errors: [] };
|
|
1000
1024
|
const U = [];
|
|
1001
1025
|
try {
|
|
1002
|
-
return B.properties && Object.entries(B.properties).forEach(([b,
|
|
1026
|
+
return B.properties && Object.entries(B.properties).forEach(([b, p]) => {
|
|
1003
1027
|
var E;
|
|
1004
|
-
const S =
|
|
1028
|
+
const S = g[b];
|
|
1005
1029
|
if ((E = B.required) != null && E.includes(b) && S == null) {
|
|
1006
1030
|
U.push(`Field '${b}' is required`);
|
|
1007
1031
|
return;
|
|
1008
1032
|
}
|
|
1009
1033
|
if (S != null) {
|
|
1010
|
-
if (
|
|
1011
|
-
const K =
|
|
1034
|
+
if (p.type) {
|
|
1035
|
+
const K = p.type, G = typeof S;
|
|
1012
1036
|
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`);
|
|
1013
1037
|
}
|
|
1014
|
-
|
|
1015
|
-
`Field '${b}' must be at least ${
|
|
1016
|
-
),
|
|
1017
|
-
`Field '${b}' must be no more than ${
|
|
1018
|
-
),
|
|
1038
|
+
p.minLength !== void 0 && typeof S == "string" && S.length < p.minLength && U.push(
|
|
1039
|
+
`Field '${b}' must be at least ${p.minLength} characters long`
|
|
1040
|
+
), p.maxLength !== void 0 && typeof S == "string" && S.length > p.maxLength && U.push(
|
|
1041
|
+
`Field '${b}' must be no more than ${p.maxLength} characters long`
|
|
1042
|
+
), p.minimum !== void 0 && typeof S == "number" && S < p.minimum && U.push(`Field '${b}' must be at least ${p.minimum}`), p.maximum !== void 0 && typeof S == "number" && S > p.maximum && U.push(`Field '${b}' must be no more than ${p.maximum}`), p.pattern && typeof S == "string" && (new RegExp(p.pattern).test(S) || U.push(`Field '${b}' does not match the required pattern`)), p.enum && !p.enum.includes(S) && U.push(`Field '${b}' must be one of: ${p.enum.join(", ")}`);
|
|
1019
1043
|
}
|
|
1020
1044
|
}), {
|
|
1021
1045
|
isValid: U.length === 0,
|
|
@@ -1031,13 +1055,13 @@ function Sr({ config: n, children: e }) {
|
|
|
1031
1055
|
[B]
|
|
1032
1056
|
);
|
|
1033
1057
|
ne(() => {
|
|
1034
|
-
!n.initialTenant && a ? y ? R() : w(a) : !n.initialTenant && !a && (
|
|
1058
|
+
!n.initialTenant && a ? y ? R() : w(a) : !n.initialTenant && !a && (c(null), A(null), m(!1));
|
|
1035
1059
|
}, [n.initialTenant, a, y, w, R]), ne(() => {
|
|
1036
|
-
y != null && y.id ? k() : (M(null),
|
|
1060
|
+
y != null && y.id ? k() : (M(null), F(null), u(!1));
|
|
1037
1061
|
}, [y == null ? void 0 : y.id, k]);
|
|
1038
1062
|
const z = oe(
|
|
1039
|
-
(
|
|
1040
|
-
const { mode: b = "reload", tokens:
|
|
1063
|
+
(g, U) => {
|
|
1064
|
+
const { mode: b = "reload", tokens: p, redirectPath: S } = U || {}, E = n.tenantMode || "selector";
|
|
1041
1065
|
if (E === "fixed") {
|
|
1042
1066
|
process.env.NODE_ENV === "development" && console.warn(
|
|
1043
1067
|
"[TenantProvider] switchTenant is a no-op in fixed mode. Tenant is always:",
|
|
@@ -1045,9 +1069,9 @@ function Sr({ config: n, children: e }) {
|
|
|
1045
1069
|
), S && (window.location.href = S);
|
|
1046
1070
|
return;
|
|
1047
1071
|
}
|
|
1048
|
-
if (localStorage.setItem("tenant",
|
|
1072
|
+
if (localStorage.setItem("tenant", g), E === "subdomain") {
|
|
1049
1073
|
const K = window.location.hostname, G = At(
|
|
1050
|
-
|
|
1074
|
+
g,
|
|
1051
1075
|
K,
|
|
1052
1076
|
n.baseDomain
|
|
1053
1077
|
);
|
|
@@ -1061,30 +1085,30 @@ function Sr({ config: n, children: e }) {
|
|
|
1061
1085
|
const X = S || window.location.pathname, W = new URL(`${window.location.protocol}//${G}${X}`);
|
|
1062
1086
|
new URLSearchParams(window.location.search).forEach((V, H) => {
|
|
1063
1087
|
H !== me && W.searchParams.set(H, V);
|
|
1064
|
-
}),
|
|
1088
|
+
}), p && W.searchParams.set(me, je(p)), window.location.href = W.toString();
|
|
1065
1089
|
} else if (E === "selector") {
|
|
1066
1090
|
const K = S || window.location.pathname, G = new URLSearchParams(window.location.search);
|
|
1067
|
-
if (G.set(n.selectorParam || "tenant",
|
|
1091
|
+
if (G.set(n.selectorParam || "tenant", g), G.delete(me), p && G.set(me, je(p)), b === "reload") {
|
|
1068
1092
|
const X = `${K}?${G.toString()}${window.location.hash}`;
|
|
1069
1093
|
window.location.href = X;
|
|
1070
1094
|
} else {
|
|
1071
1095
|
const X = `${K}?${G.toString()}${window.location.hash}`;
|
|
1072
|
-
window.history.pushState({}, "", X),
|
|
1096
|
+
window.history.pushState({}, "", X), d(g), w(g);
|
|
1073
1097
|
}
|
|
1074
1098
|
}
|
|
1075
1099
|
},
|
|
1076
1100
|
[n.tenantMode, n.selectorParam, n.baseDomain, w]
|
|
1077
|
-
), D =
|
|
1101
|
+
), D = J(() => ({
|
|
1078
1102
|
// Tenant info
|
|
1079
1103
|
tenant: y,
|
|
1080
1104
|
tenantSlug: a,
|
|
1081
|
-
isTenantLoading:
|
|
1105
|
+
isTenantLoading: L,
|
|
1082
1106
|
tenantError: T,
|
|
1083
1107
|
retryTenant: () => {
|
|
1084
1108
|
a && w(a);
|
|
1085
1109
|
},
|
|
1086
1110
|
// Settings
|
|
1087
|
-
settings:
|
|
1111
|
+
settings: N,
|
|
1088
1112
|
settingsSchema: B,
|
|
1089
1113
|
isSettingsLoading: P,
|
|
1090
1114
|
settingsError: v,
|
|
@@ -1096,9 +1120,9 @@ function Sr({ config: n, children: e }) {
|
|
|
1096
1120
|
}), [
|
|
1097
1121
|
y,
|
|
1098
1122
|
a,
|
|
1099
|
-
F,
|
|
1100
|
-
T,
|
|
1101
1123
|
L,
|
|
1124
|
+
T,
|
|
1125
|
+
N,
|
|
1102
1126
|
B,
|
|
1103
1127
|
P,
|
|
1104
1128
|
v,
|
|
@@ -1128,7 +1152,7 @@ function kr() {
|
|
|
1128
1152
|
validateSettings: i
|
|
1129
1153
|
};
|
|
1130
1154
|
}
|
|
1131
|
-
function
|
|
1155
|
+
function Ze() {
|
|
1132
1156
|
const { tenant: n, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: i } = Te();
|
|
1133
1157
|
return {
|
|
1134
1158
|
tenant: n,
|
|
@@ -1140,13 +1164,13 @@ function Je() {
|
|
|
1140
1164
|
}
|
|
1141
1165
|
const Be = ye(null);
|
|
1142
1166
|
function xr({ config: n = {}, children: e }) {
|
|
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,
|
|
1167
|
+
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, d = (r == null ? void 0 : r.tenantSlug) ?? null, f = (r == null ? void 0 : r.switchTenant) ?? (() => {
|
|
1144
1168
|
});
|
|
1145
1169
|
if (!i)
|
|
1146
1170
|
throw new Error(
|
|
1147
1171
|
"[AuthProvider] baseUrl is required. Provide it via AppProvider or AuthConfig.baseUrl."
|
|
1148
1172
|
);
|
|
1149
|
-
const [y,
|
|
1173
|
+
const [y, c] = x(n.initialRoles || []), [L, m] = x(!n.initialRoles), [T, A] = x(null), [N, M] = x(!1), [P, u] = x(null), [v, F] = x(() => {
|
|
1150
1174
|
try {
|
|
1151
1175
|
const $ = localStorage.getItem("userTenants");
|
|
1152
1176
|
return $ ? JSON.parse($) : [];
|
|
@@ -1155,14 +1179,14 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1155
1179
|
}
|
|
1156
1180
|
}), [B, w] = x(!1), R = Ne({ done: !1, urlTokens: null });
|
|
1157
1181
|
R.current.done || (R.current.done = !0, R.current.urlTokens = Rt());
|
|
1158
|
-
const [k, I] = x(() => R.current.urlTokens !== null), l =
|
|
1182
|
+
const [k, I] = x(() => R.current.urlTokens !== null), l = J(() => {
|
|
1159
1183
|
const $ = be.getInstance({
|
|
1160
|
-
tenantSlug:
|
|
1184
|
+
tenantSlug: d,
|
|
1161
1185
|
baseUrl: i,
|
|
1162
1186
|
refreshQueueTimeout: n.refreshQueueTimeout,
|
|
1163
1187
|
proactiveRefreshMargin: n.proactiveRefreshMargin,
|
|
1164
1188
|
onSessionExpired: (ce) => {
|
|
1165
|
-
A(null),
|
|
1189
|
+
A(null), u(null), F([]), w(!1);
|
|
1166
1190
|
try {
|
|
1167
1191
|
localStorage.removeItem("userTenants");
|
|
1168
1192
|
} catch {
|
|
@@ -1175,15 +1199,15 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1175
1199
|
refreshToken: R.current.urlTokens.refreshToken,
|
|
1176
1200
|
expiresIn: R.current.urlTokens.expiresIn
|
|
1177
1201
|
}), $;
|
|
1178
|
-
}, [
|
|
1202
|
+
}, [d, i, n.refreshQueueTimeout, n.proactiveRefreshMargin]), [z, D] = x(() => {
|
|
1179
1203
|
if (R.current.urlTokens) return !1;
|
|
1180
1204
|
const $ = l.getTokens();
|
|
1181
1205
|
return $ ? l.hasValidSession() || !!$.refreshToken : !1;
|
|
1182
|
-
}),
|
|
1206
|
+
}), g = R.current.done && !k && !z, U = J(() => {
|
|
1183
1207
|
const $ = new de(i);
|
|
1184
1208
|
return $.setSessionManager(l), $;
|
|
1185
|
-
}, [i, l]), b =
|
|
1186
|
-
}), q =
|
|
1209
|
+
}, [i, l]), b = J(() => new vt(new de(i)), [i]), p = J(() => new St(U, l), [U, l]), S = J(() => new We(new de(i)), [i]), E = J(() => T || l.getUser(), [T, l]), K = J(() => E != null && E.roleId && y.find(($) => $.id === E.roleId) || null, [E, y]), G = J(() => (K == null ? void 0 : K.permissions) || [], [K]), X = J(() => l.hasValidSession() && T !== null, [l, T]), W = Ne(async () => {
|
|
1210
|
+
}), q = J(() => {
|
|
1187
1211
|
const $ = async (C = !1) => {
|
|
1188
1212
|
try {
|
|
1189
1213
|
if (!l.hasValidSession() || !C && T)
|
|
@@ -1193,12 +1217,12 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1193
1217
|
process.env.NODE_ENV === "development" && console.warn("[AuthProvider] No userId available in token or storage");
|
|
1194
1218
|
return;
|
|
1195
1219
|
}
|
|
1196
|
-
M(!0),
|
|
1197
|
-
const
|
|
1198
|
-
A(
|
|
1220
|
+
M(!0), u(null);
|
|
1221
|
+
const Z = await p.getUserById(O);
|
|
1222
|
+
A(Z), l.setUser(Z);
|
|
1199
1223
|
} catch (O) {
|
|
1200
|
-
const
|
|
1201
|
-
|
|
1224
|
+
const Z = O instanceof Error ? O : new Error("Failed to load user data");
|
|
1225
|
+
u(Z), process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to load user data:", Z);
|
|
1202
1226
|
} finally {
|
|
1203
1227
|
M(!1);
|
|
1204
1228
|
}
|
|
@@ -1206,15 +1230,15 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1206
1230
|
await $();
|
|
1207
1231
|
}, fe = async (C) => {
|
|
1208
1232
|
var _e;
|
|
1209
|
-
const { username: O, password:
|
|
1210
|
-
let ee = a == null ? void 0 : a.id, te =
|
|
1233
|
+
const { username: O, password: Z, tenantSlug: j, redirectPath: Y } = C;
|
|
1234
|
+
let ee = a == null ? void 0 : a.id, te = d, re = l;
|
|
1211
1235
|
j && (ee = (await new ve(U, o).getPublicTenantInfo(j)).id, te = j);
|
|
1212
1236
|
const Q = await b.login({
|
|
1213
1237
|
username: O,
|
|
1214
|
-
password:
|
|
1238
|
+
password: Z,
|
|
1215
1239
|
appId: o,
|
|
1216
1240
|
tenantId: ee
|
|
1217
|
-
}), we = j && j !==
|
|
1241
|
+
}), we = j && j !== d;
|
|
1218
1242
|
if (we && (re = new be({
|
|
1219
1243
|
tenantSlug: te,
|
|
1220
1244
|
baseUrl: i
|
|
@@ -1231,7 +1255,7 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1231
1255
|
}
|
|
1232
1256
|
}
|
|
1233
1257
|
if (Q.tenants && Q.tenants.length > 0) {
|
|
1234
|
-
|
|
1258
|
+
F(Q.tenants);
|
|
1235
1259
|
try {
|
|
1236
1260
|
localStorage.setItem("userTenants", JSON.stringify(Q.tenants));
|
|
1237
1261
|
} catch {
|
|
@@ -1245,27 +1269,27 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1245
1269
|
expiresIn: Q.expiresIn
|
|
1246
1270
|
};
|
|
1247
1271
|
if (we && te)
|
|
1248
|
-
return
|
|
1272
|
+
return f(te, { tokens: Ee, redirectPath: Y }), Q;
|
|
1249
1273
|
if (Y && Y !== window.location.pathname)
|
|
1250
|
-
return
|
|
1274
|
+
return f(te || d || "", { tokens: Ee, redirectPath: Y }), Q;
|
|
1251
1275
|
if (!Re && Q.tenants && Q.tenants.length > 0) {
|
|
1252
1276
|
const ke = C.autoSwitch !== !1 && n.autoSwitchSingleTenant !== !1;
|
|
1253
1277
|
if (Q.tenants.length === 1 && ke) {
|
|
1254
1278
|
const ze = Q.tenants[0];
|
|
1255
|
-
return
|
|
1279
|
+
return f(ze.subdomain, { tokens: Ee, redirectPath: Y }), Q;
|
|
1256
1280
|
} else Q.tenants.length > 1 && n.onTenantSelectionRequired && n.onTenantSelectionRequired(Q.tenants);
|
|
1257
1281
|
}
|
|
1258
1282
|
return Q;
|
|
1259
1283
|
}, ge = async (C) => {
|
|
1260
|
-
const { email: O, phoneNumber:
|
|
1261
|
-
if (!O && !
|
|
1284
|
+
const { email: O, phoneNumber: Z, name: j, password: Y, lastName: ee, tenantId: te } = C;
|
|
1285
|
+
if (!O && !Z)
|
|
1262
1286
|
throw new Error("Either email or phoneNumber is required");
|
|
1263
1287
|
if (!j || !Y)
|
|
1264
1288
|
throw new Error("Name and password are required");
|
|
1265
1289
|
const re = te ?? (a == null ? void 0 : a.id);
|
|
1266
1290
|
return await b.signup({
|
|
1267
1291
|
email: O,
|
|
1268
|
-
phoneNumber:
|
|
1292
|
+
phoneNumber: Z,
|
|
1269
1293
|
name: j,
|
|
1270
1294
|
password: Y,
|
|
1271
1295
|
tenantId: re,
|
|
@@ -1273,14 +1297,14 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1273
1297
|
appId: o
|
|
1274
1298
|
});
|
|
1275
1299
|
}, nt = async (C) => {
|
|
1276
|
-
const { email: O, phoneNumber:
|
|
1277
|
-
if (!O && !
|
|
1300
|
+
const { email: O, phoneNumber: Z, name: j, password: Y, tenantName: ee, lastName: te } = C;
|
|
1301
|
+
if (!O && !Z)
|
|
1278
1302
|
throw new Error("Either email or phoneNumber is required");
|
|
1279
1303
|
if (!j || !Y || !ee)
|
|
1280
1304
|
throw new Error("Name, password, and tenantName are required");
|
|
1281
1305
|
return await b.signupTenantAdmin({
|
|
1282
1306
|
email: O,
|
|
1283
|
-
phoneNumber:
|
|
1307
|
+
phoneNumber: Z,
|
|
1284
1308
|
name: j,
|
|
1285
1309
|
password: Y,
|
|
1286
1310
|
tenantName: ee,
|
|
@@ -1288,38 +1312,38 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1288
1312
|
lastName: te
|
|
1289
1313
|
});
|
|
1290
1314
|
}, st = async (C) => {
|
|
1291
|
-
const { currentPassword: O, newPassword:
|
|
1292
|
-
await b.changePassword({ currentPassword: O, newPassword:
|
|
1315
|
+
const { currentPassword: O, newPassword: Z } = C, j = await l.getAuthHeaders();
|
|
1316
|
+
await b.changePassword({ currentPassword: O, newPassword: Z }, j);
|
|
1293
1317
|
}, it = async (C) => {
|
|
1294
|
-
const { email: O, tenantId:
|
|
1318
|
+
const { email: O, tenantId: Z } = C, j = Z ?? (a == null ? void 0 : a.id);
|
|
1295
1319
|
if (!j)
|
|
1296
1320
|
throw new Error("tenantId is required for password reset");
|
|
1297
1321
|
await b.requestPasswordReset({ email: O, tenantId: j });
|
|
1298
1322
|
}, ot = async (C) => {
|
|
1299
|
-
const { token: O, newPassword:
|
|
1300
|
-
await b.confirmPasswordReset({ token: O, newPassword:
|
|
1323
|
+
const { token: O, newPassword: Z } = C;
|
|
1324
|
+
await b.confirmPasswordReset({ token: O, newPassword: Z });
|
|
1301
1325
|
}, at = async (C) => {
|
|
1302
|
-
const { email: O, frontendUrl:
|
|
1326
|
+
const { email: O, frontendUrl: Z, name: j, lastName: Y, tenantId: ee } = C, te = ee ?? (a == null ? void 0 : a.id);
|
|
1303
1327
|
if (!te)
|
|
1304
1328
|
throw new Error("tenantId is required for magic link authentication");
|
|
1305
1329
|
return await b.sendMagicLink({
|
|
1306
1330
|
email: O,
|
|
1307
1331
|
tenantId: te,
|
|
1308
|
-
frontendUrl:
|
|
1332
|
+
frontendUrl: Z,
|
|
1309
1333
|
name: j,
|
|
1310
1334
|
lastName: Y,
|
|
1311
1335
|
appId: o
|
|
1312
1336
|
});
|
|
1313
1337
|
}, lt = async (C) => {
|
|
1314
|
-
const { token: O, email:
|
|
1315
|
-
let Y = a == null ? void 0 : a.id, ee =
|
|
1338
|
+
const { token: O, email: Z, tenantSlug: j } = C;
|
|
1339
|
+
let Y = a == null ? void 0 : a.id, ee = d, te = l;
|
|
1316
1340
|
j && (Y = (await new ve(U, o).getPublicTenantInfo(j)).id, ee = j);
|
|
1317
1341
|
const re = await b.verifyMagicLink({
|
|
1318
1342
|
token: O,
|
|
1319
|
-
email:
|
|
1343
|
+
email: Z,
|
|
1320
1344
|
appId: o,
|
|
1321
1345
|
tenantId: Y
|
|
1322
|
-
}), Q = j && j !==
|
|
1346
|
+
}), Q = j && j !== d;
|
|
1323
1347
|
if (Q && (te = new be({
|
|
1324
1348
|
tenantSlug: ee,
|
|
1325
1349
|
baseUrl: i
|
|
@@ -1338,7 +1362,7 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1338
1362
|
);
|
|
1339
1363
|
}
|
|
1340
1364
|
}
|
|
1341
|
-
return Q && ee && ee !==
|
|
1365
|
+
return Q && ee && ee !== d && f(ee, {
|
|
1342
1366
|
tokens: {
|
|
1343
1367
|
accessToken: re.accessToken,
|
|
1344
1368
|
refreshToken: re.refreshToken,
|
|
@@ -1358,7 +1382,7 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1358
1382
|
expiresIn: O.expiresIn
|
|
1359
1383
|
});
|
|
1360
1384
|
}, dt = () => {
|
|
1361
|
-
l.clearSession(), A(null),
|
|
1385
|
+
l.clearSession(), A(null), u(null), F([]), w(!1);
|
|
1362
1386
|
try {
|
|
1363
1387
|
localStorage.removeItem("userTenants");
|
|
1364
1388
|
} catch {
|
|
@@ -1366,17 +1390,17 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1366
1390
|
}, ut = (C) => {
|
|
1367
1391
|
l.setTokens(C);
|
|
1368
1392
|
}, ht = () => l.hasValidSession(), pt = () => {
|
|
1369
|
-
l.clearSession(), A(null),
|
|
1393
|
+
l.clearSession(), A(null), u(null);
|
|
1370
1394
|
}, ft = async () => {
|
|
1371
1395
|
if (o)
|
|
1372
1396
|
try {
|
|
1373
|
-
|
|
1397
|
+
m(!0);
|
|
1374
1398
|
const { roles: C } = await S.getRolesByApp(o);
|
|
1375
|
-
|
|
1399
|
+
c(C);
|
|
1376
1400
|
} catch (C) {
|
|
1377
1401
|
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:", C);
|
|
1378
1402
|
} finally {
|
|
1379
|
-
|
|
1403
|
+
m(!1);
|
|
1380
1404
|
}
|
|
1381
1405
|
}, gt = async () => {
|
|
1382
1406
|
await ft();
|
|
@@ -1407,16 +1431,16 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1407
1431
|
hasValidSession: ht,
|
|
1408
1432
|
clearSession: pt,
|
|
1409
1433
|
currentUser: T,
|
|
1410
|
-
isUserLoading:
|
|
1434
|
+
isUserLoading: N,
|
|
1411
1435
|
userError: P,
|
|
1412
1436
|
loadUserData: $,
|
|
1413
1437
|
refreshUser: ce,
|
|
1414
|
-
isAuthInitializing: !
|
|
1415
|
-
isAuthReady:
|
|
1438
|
+
isAuthInitializing: !g,
|
|
1439
|
+
isAuthReady: g,
|
|
1416
1440
|
userRole: K,
|
|
1417
1441
|
userPermissions: G,
|
|
1418
1442
|
availableRoles: y,
|
|
1419
|
-
rolesLoading:
|
|
1443
|
+
rolesLoading: L,
|
|
1420
1444
|
hasPermission: Pe,
|
|
1421
1445
|
hasAnyPermission: (C) => C.some((O) => Pe(O)),
|
|
1422
1446
|
hasAllPermissions: (C) => C.every((O) => Pe(O)),
|
|
@@ -1426,7 +1450,7 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1426
1450
|
userTenants: v,
|
|
1427
1451
|
hasTenantContext: B,
|
|
1428
1452
|
switchToTenant: async (C, O) => {
|
|
1429
|
-
const { redirectPath:
|
|
1453
|
+
const { redirectPath: Z } = O || {}, j = l.getTokens();
|
|
1430
1454
|
if (!(j != null && j.refreshToken))
|
|
1431
1455
|
throw new Error("No refresh token available for tenant switch");
|
|
1432
1456
|
const Y = await b.switchTenant({
|
|
@@ -1440,18 +1464,18 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1440
1464
|
expiresIn: Y.expiresIn
|
|
1441
1465
|
}), A(Y.user), l.setUser(Y.user), w(!0);
|
|
1442
1466
|
const ee = v.find((te) => te.id === C);
|
|
1443
|
-
ee &&
|
|
1467
|
+
ee && f(ee.subdomain, {
|
|
1444
1468
|
tokens: {
|
|
1445
1469
|
accessToken: Y.accessToken,
|
|
1446
1470
|
refreshToken: j.refreshToken,
|
|
1447
1471
|
expiresIn: Y.expiresIn
|
|
1448
1472
|
},
|
|
1449
|
-
redirectPath:
|
|
1473
|
+
redirectPath: Z
|
|
1450
1474
|
});
|
|
1451
1475
|
},
|
|
1452
1476
|
refreshUserTenants: async () => {
|
|
1453
1477
|
const C = await l.getAuthHeaders(), O = await b.getUserTenants(C);
|
|
1454
|
-
|
|
1478
|
+
F(O);
|
|
1455
1479
|
try {
|
|
1456
1480
|
localStorage.setItem("userTenants", JSON.stringify(O));
|
|
1457
1481
|
} catch {
|
|
@@ -1464,32 +1488,32 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1464
1488
|
l,
|
|
1465
1489
|
U,
|
|
1466
1490
|
b,
|
|
1467
|
-
|
|
1491
|
+
p,
|
|
1468
1492
|
S,
|
|
1469
1493
|
o,
|
|
1470
1494
|
a,
|
|
1471
|
-
|
|
1472
|
-
|
|
1495
|
+
d,
|
|
1496
|
+
f,
|
|
1473
1497
|
y,
|
|
1474
1498
|
T,
|
|
1475
|
-
|
|
1499
|
+
N,
|
|
1476
1500
|
P,
|
|
1477
1501
|
v,
|
|
1478
1502
|
B,
|
|
1479
|
-
|
|
1503
|
+
g,
|
|
1480
1504
|
K,
|
|
1481
1505
|
G
|
|
1482
1506
|
]);
|
|
1483
1507
|
W.current = q.loadUserData, ne(() => {
|
|
1484
1508
|
!n.initialRoles && o && (async () => {
|
|
1485
1509
|
try {
|
|
1486
|
-
|
|
1510
|
+
m(!0);
|
|
1487
1511
|
const ce = new de(i), fe = new We(ce), { roles: ge } = await fe.getRolesByApp(o);
|
|
1488
|
-
|
|
1512
|
+
c(ge);
|
|
1489
1513
|
} catch (ce) {
|
|
1490
1514
|
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:", ce);
|
|
1491
1515
|
} finally {
|
|
1492
|
-
|
|
1516
|
+
m(!1);
|
|
1493
1517
|
}
|
|
1494
1518
|
})();
|
|
1495
1519
|
}, [o, i, n.initialRoles]);
|
|
@@ -1511,11 +1535,11 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1511
1535
|
$ = !0;
|
|
1512
1536
|
};
|
|
1513
1537
|
}, [l]), ne(() => {
|
|
1514
|
-
V && (R.current.urlTokens || (!T && !
|
|
1538
|
+
V && (R.current.urlTokens || (!T && !N && !P && l.hasValidSession() ? W.current().catch(() => {
|
|
1515
1539
|
}).finally(() => {
|
|
1516
1540
|
D(!1);
|
|
1517
1541
|
}) : D(!1)));
|
|
1518
|
-
}, [T,
|
|
1542
|
+
}, [T, N, P, l, V]), /* @__PURE__ */ s(Be.Provider, { value: q, children: e });
|
|
1519
1543
|
}
|
|
1520
1544
|
function he() {
|
|
1521
1545
|
const n = le(Be);
|
|
@@ -1608,52 +1632,52 @@ class It {
|
|
|
1608
1632
|
}
|
|
1609
1633
|
const Ce = ye(null);
|
|
1610
1634
|
function Ar({ config: n = {}, children: e }) {
|
|
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, [
|
|
1612
|
-
const
|
|
1613
|
-
return new It(
|
|
1635
|
+
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, [d, f] = x([]), [y, c] = x(!1), [L, m] = x(null), [T, A] = x(!1), N = J(() => {
|
|
1636
|
+
const u = new de(i);
|
|
1637
|
+
return new It(u);
|
|
1614
1638
|
}, [i]), M = async () => {
|
|
1615
1639
|
if (!(a != null && a.id)) {
|
|
1616
|
-
|
|
1640
|
+
f([]);
|
|
1617
1641
|
return;
|
|
1618
1642
|
}
|
|
1619
|
-
|
|
1643
|
+
c(!0), m(null);
|
|
1620
1644
|
try {
|
|
1621
|
-
const
|
|
1622
|
-
|
|
1623
|
-
} catch (
|
|
1624
|
-
const v =
|
|
1625
|
-
|
|
1645
|
+
const u = await N.getTenantFeatureFlags(a.id, o);
|
|
1646
|
+
f(u);
|
|
1647
|
+
} catch (u) {
|
|
1648
|
+
const v = u instanceof Error ? u.message : "Failed to fetch feature flags";
|
|
1649
|
+
m(v), n.onError && n.onError(u instanceof Error ? u : new Error(v));
|
|
1626
1650
|
} finally {
|
|
1627
|
-
|
|
1651
|
+
c(!1);
|
|
1628
1652
|
}
|
|
1629
1653
|
};
|
|
1630
1654
|
ne(() => {
|
|
1631
1655
|
if (!i || !o) return;
|
|
1632
1656
|
M().finally(() => A(!0));
|
|
1633
|
-
const
|
|
1657
|
+
const u = n.refreshInterval || 5 * 60 * 1e3, v = setInterval(M, u);
|
|
1634
1658
|
return () => clearInterval(v);
|
|
1635
1659
|
}, [a == null ? void 0 : a.id, i, o, n.refreshInterval]);
|
|
1636
|
-
const P =
|
|
1637
|
-
const
|
|
1638
|
-
const k =
|
|
1660
|
+
const P = J(() => {
|
|
1661
|
+
const u = (R) => {
|
|
1662
|
+
const k = d.find((I) => I.key === R);
|
|
1639
1663
|
return (k == null ? void 0 : k.value) === !0;
|
|
1640
|
-
}, v = (R) =>
|
|
1641
|
-
const k =
|
|
1664
|
+
}, v = (R) => d.find((k) => k.key === R), F = (R) => {
|
|
1665
|
+
const k = d.find((I) => I.key === R);
|
|
1642
1666
|
return k ? k.value ? "enabled" : "disabled" : "not_found";
|
|
1643
1667
|
}, B = async () => {
|
|
1644
1668
|
await M();
|
|
1645
1669
|
}, w = !!(i && o) && (T || !(a != null && a.id));
|
|
1646
1670
|
return {
|
|
1647
|
-
featureFlags:
|
|
1671
|
+
featureFlags: d,
|
|
1648
1672
|
loading: y,
|
|
1649
|
-
error:
|
|
1673
|
+
error: L,
|
|
1650
1674
|
isReady: w,
|
|
1651
|
-
isEnabled:
|
|
1675
|
+
isEnabled: u,
|
|
1652
1676
|
getFlag: v,
|
|
1653
|
-
getFlagState:
|
|
1677
|
+
getFlagState: F,
|
|
1654
1678
|
refresh: B
|
|
1655
1679
|
};
|
|
1656
|
-
}, [
|
|
1680
|
+
}, [d, y, L, i, o, a == null ? void 0 : a.id, T]);
|
|
1657
1681
|
return /* @__PURE__ */ s(Ce.Provider, { value: P, children: e });
|
|
1658
1682
|
}
|
|
1659
1683
|
function Mt() {
|
|
@@ -1733,53 +1757,53 @@ class Lt {
|
|
|
1733
1757
|
}
|
|
1734
1758
|
const He = ye(void 0);
|
|
1735
1759
|
function Pr({ config: n = {}, children: e }) {
|
|
1736
|
-
const t = De(), r = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a,
|
|
1760
|
+
const t = De(), r = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a, d] = x(null), [f, y] = x(!1), [c, L] = x(null), [m, T] = x(!1), A = J(() => {
|
|
1737
1761
|
const P = new de(i);
|
|
1738
1762
|
return new Lt(P);
|
|
1739
|
-
}, [i]),
|
|
1763
|
+
}, [i]), N = async () => {
|
|
1740
1764
|
if (!(o != null && o.id)) {
|
|
1741
|
-
|
|
1765
|
+
d(null);
|
|
1742
1766
|
return;
|
|
1743
1767
|
}
|
|
1744
|
-
y(!0),
|
|
1768
|
+
y(!0), L(null);
|
|
1745
1769
|
try {
|
|
1746
1770
|
const P = await A.getTenantSubscriptionFeatures(o.id);
|
|
1747
|
-
|
|
1771
|
+
d(P);
|
|
1748
1772
|
} catch (P) {
|
|
1749
|
-
const
|
|
1750
|
-
|
|
1773
|
+
const u = P instanceof Error ? P.message : "Failed to fetch subscription";
|
|
1774
|
+
L(u), n.onError && n.onError(P instanceof Error ? P : new Error(u));
|
|
1751
1775
|
} finally {
|
|
1752
1776
|
y(!1);
|
|
1753
1777
|
}
|
|
1754
1778
|
};
|
|
1755
1779
|
ne(() => {
|
|
1756
|
-
if (!i || (
|
|
1757
|
-
const P = n.refreshInterval || 10 * 60 * 1e3,
|
|
1758
|
-
return () => clearInterval(
|
|
1780
|
+
if (!i || (N().finally(() => T(!0)), !n.refreshInterval)) return;
|
|
1781
|
+
const P = n.refreshInterval || 10 * 60 * 1e3, u = setInterval(N, P);
|
|
1782
|
+
return () => clearInterval(u);
|
|
1759
1783
|
}, [o == null ? void 0 : o.id, i, n.refreshInterval]);
|
|
1760
|
-
const M =
|
|
1761
|
-
const P = (a == null ? void 0 : a.features) || [],
|
|
1784
|
+
const M = J(() => {
|
|
1785
|
+
const P = (a == null ? void 0 : a.features) || [], u = (k) => {
|
|
1762
1786
|
const I = P.find((l) => l.key === k);
|
|
1763
1787
|
return I ? I.type === "BOOLEAN" || I.type === "boolean" ? I.value === !0 : !!I.value : !1;
|
|
1764
|
-
}, v = (k) => P.find((I) => I.key === k),
|
|
1788
|
+
}, v = (k) => P.find((I) => I.key === k), F = (k, I) => {
|
|
1765
1789
|
const l = P.find((z) => z.key === k);
|
|
1766
1790
|
return l ? l.value : I;
|
|
1767
1791
|
}, B = (k) => !a || !a.isActive ? !1 : k.includes(a.planId), w = async () => {
|
|
1768
|
-
await
|
|
1769
|
-
}, R = !!i && (
|
|
1792
|
+
await N();
|
|
1793
|
+
}, R = !!i && (m || !(o != null && o.id));
|
|
1770
1794
|
return {
|
|
1771
1795
|
subscription: a,
|
|
1772
1796
|
features: P,
|
|
1773
|
-
loading:
|
|
1774
|
-
error:
|
|
1797
|
+
loading: f,
|
|
1798
|
+
error: c,
|
|
1775
1799
|
isReady: R,
|
|
1776
|
-
isFeatureEnabled:
|
|
1800
|
+
isFeatureEnabled: u,
|
|
1777
1801
|
getFeature: v,
|
|
1778
|
-
getFeatureValue:
|
|
1802
|
+
getFeatureValue: F,
|
|
1779
1803
|
hasAllowedPlan: B,
|
|
1780
1804
|
refresh: w
|
|
1781
1805
|
};
|
|
1782
|
-
}, [a,
|
|
1806
|
+
}, [a, f, c, i, o == null ? void 0 : o.id, m]);
|
|
1783
1807
|
return /* @__PURE__ */ s(He.Provider, { value: M, children: e });
|
|
1784
1808
|
}
|
|
1785
1809
|
function Nt() {
|
|
@@ -1819,7 +1843,7 @@ const Oe = {
|
|
|
1819
1843
|
open: { tenant: "optional", auth: "optional" }
|
|
1820
1844
|
}, qe = ye(null);
|
|
1821
1845
|
function Rr({ config: n = {}, children: e }) {
|
|
1822
|
-
const t =
|
|
1846
|
+
const t = J(() => {
|
|
1823
1847
|
const r = {
|
|
1824
1848
|
...Oe,
|
|
1825
1849
|
...n.zoneRoots
|
|
@@ -1857,7 +1881,7 @@ function Ft() {
|
|
|
1857
1881
|
returnToStorage: "url"
|
|
1858
1882
|
};
|
|
1859
1883
|
}
|
|
1860
|
-
const Ge = () => /* @__PURE__ */
|
|
1884
|
+
const Ge = () => /* @__PURE__ */ h(
|
|
1861
1885
|
"div",
|
|
1862
1886
|
{
|
|
1863
1887
|
style: {
|
|
@@ -1898,7 +1922,7 @@ const Ge = () => /* @__PURE__ */ u(
|
|
|
1898
1922
|
userType: n,
|
|
1899
1923
|
minUserType: e,
|
|
1900
1924
|
missingPermissions: t
|
|
1901
|
-
}) => /* @__PURE__ */
|
|
1925
|
+
}) => /* @__PURE__ */ h(
|
|
1902
1926
|
"div",
|
|
1903
1927
|
{
|
|
1904
1928
|
style: {
|
|
@@ -1916,19 +1940,19 @@ const Ge = () => /* @__PURE__ */ u(
|
|
|
1916
1940
|
children: [
|
|
1917
1941
|
/* @__PURE__ */ s("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
|
|
1918
1942
|
/* @__PURE__ */ s("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
|
|
1919
|
-
e && n ? /* @__PURE__ */
|
|
1920
|
-
/* @__PURE__ */
|
|
1943
|
+
e && n ? /* @__PURE__ */ h(_, { children: [
|
|
1944
|
+
/* @__PURE__ */ h("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
|
|
1921
1945
|
"This content requires ",
|
|
1922
1946
|
/* @__PURE__ */ s("strong", { children: e }),
|
|
1923
1947
|
" access level or higher."
|
|
1924
1948
|
] }),
|
|
1925
|
-
/* @__PURE__ */
|
|
1949
|
+
/* @__PURE__ */ h("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1926
1950
|
"Your current access level: ",
|
|
1927
1951
|
/* @__PURE__ */ s("strong", { children: n })
|
|
1928
1952
|
] })
|
|
1929
|
-
] }) : /* @__PURE__ */
|
|
1953
|
+
] }) : /* @__PURE__ */ h(_, { children: [
|
|
1930
1954
|
/* @__PURE__ */ s("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
|
|
1931
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1955
|
+
t && t.length > 0 && /* @__PURE__ */ h("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1932
1956
|
"Required permissions: ",
|
|
1933
1957
|
/* @__PURE__ */ s("strong", { children: t.join(", ") })
|
|
1934
1958
|
] })
|
|
@@ -1950,17 +1974,17 @@ function Ir({
|
|
|
1950
1974
|
requiredPermissions: r,
|
|
1951
1975
|
requireAllPermissions: i = !1
|
|
1952
1976
|
}) {
|
|
1953
|
-
const { hasValidSession: o, sessionManager: a, hasPermission:
|
|
1977
|
+
const { hasValidSession: o, sessionManager: a, hasPermission: d, hasAnyPermission: f, hasAllPermissions: y } = he();
|
|
1954
1978
|
if (!o())
|
|
1955
1979
|
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(Ge, {}) });
|
|
1956
|
-
const
|
|
1957
|
-
if (!
|
|
1980
|
+
const c = a.getUser();
|
|
1981
|
+
if (!c)
|
|
1958
1982
|
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(Ge, {}) });
|
|
1959
|
-
if (t && !Dt(
|
|
1960
|
-
return /* @__PURE__ */ s(Ke, { userType:
|
|
1961
|
-
if (r && r.length > 0 && !(i ? y(r) :
|
|
1962
|
-
const
|
|
1963
|
-
return /* @__PURE__ */ s(Ke, { missingPermissions:
|
|
1983
|
+
if (t && !Dt(c.userType, t))
|
|
1984
|
+
return /* @__PURE__ */ s(Ke, { userType: c.userType, minUserType: t });
|
|
1985
|
+
if (r && r.length > 0 && !(i ? y(r) : f(r))) {
|
|
1986
|
+
const m = r.filter((T) => !d(T)).map((T) => typeof T == "string" ? T : T.name);
|
|
1987
|
+
return /* @__PURE__ */ s(Ke, { missingPermissions: m });
|
|
1964
1988
|
}
|
|
1965
1989
|
return /* @__PURE__ */ s(_, { children: n });
|
|
1966
1990
|
}
|
|
@@ -1977,7 +2001,7 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
1977
2001
|
backgroundColor: "#f9fafb",
|
|
1978
2002
|
textAlign: "center"
|
|
1979
2003
|
},
|
|
1980
|
-
children: /* @__PURE__ */
|
|
2004
|
+
children: /* @__PURE__ */ h(
|
|
1981
2005
|
"div",
|
|
1982
2006
|
{
|
|
1983
2007
|
style: {
|
|
@@ -1991,7 +2015,7 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
1991
2015
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
|
|
1992
2016
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
|
|
1993
2017
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
|
|
1994
|
-
/* @__PURE__ */
|
|
2018
|
+
/* @__PURE__ */ h("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1995
2019
|
"Redirecting to ",
|
|
1996
2020
|
n,
|
|
1997
2021
|
"..."
|
|
@@ -2017,7 +2041,7 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2017
2041
|
backgroundColor: "#f9fafb",
|
|
2018
2042
|
textAlign: "center"
|
|
2019
2043
|
},
|
|
2020
|
-
children: /* @__PURE__ */
|
|
2044
|
+
children: /* @__PURE__ */ h(
|
|
2021
2045
|
"div",
|
|
2022
2046
|
{
|
|
2023
2047
|
style: {
|
|
@@ -2030,19 +2054,19 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2030
2054
|
children: [
|
|
2031
2055
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
|
|
2032
2056
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
|
|
2033
|
-
e && n ? /* @__PURE__ */
|
|
2034
|
-
/* @__PURE__ */
|
|
2057
|
+
e && n ? /* @__PURE__ */ h(_, { children: [
|
|
2058
|
+
/* @__PURE__ */ h("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
|
|
2035
2059
|
"This page requires ",
|
|
2036
2060
|
/* @__PURE__ */ s("strong", { children: e }),
|
|
2037
2061
|
" access."
|
|
2038
2062
|
] }),
|
|
2039
|
-
/* @__PURE__ */
|
|
2063
|
+
/* @__PURE__ */ h("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
2040
2064
|
"Your current user type: ",
|
|
2041
2065
|
/* @__PURE__ */ s("strong", { children: n })
|
|
2042
2066
|
] })
|
|
2043
|
-
] }) : /* @__PURE__ */
|
|
2067
|
+
] }) : /* @__PURE__ */ h(_, { children: [
|
|
2044
2068
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
|
|
2045
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
2069
|
+
t && t.length > 0 && /* @__PURE__ */ h("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
2046
2070
|
"Required permissions: ",
|
|
2047
2071
|
/* @__PURE__ */ s("strong", { children: t.join(", ") })
|
|
2048
2072
|
] })
|
|
@@ -2060,29 +2084,29 @@ function Mr({
|
|
|
2060
2084
|
requireAllPermissions: i = !1,
|
|
2061
2085
|
fallback: o
|
|
2062
2086
|
}) {
|
|
2063
|
-
const { hasValidSession: a, sessionManager:
|
|
2087
|
+
const { hasValidSession: a, sessionManager: d, hasPermission: f, hasAnyPermission: y, hasAllPermissions: c } = he(), L = xe();
|
|
2064
2088
|
if (ne(() => {
|
|
2065
2089
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2066
2090
|
"[react-identity-access] ProtectedRoute is deprecated. Use AuthenticatedZone or AdminZone from ZoneRoute instead."
|
|
2067
2091
|
);
|
|
2068
2092
|
}, []), !a())
|
|
2069
|
-
return o ? /* @__PURE__ */ s(_, { children: o }) : /* @__PURE__ */
|
|
2093
|
+
return o ? /* @__PURE__ */ s(_, { children: o }) : /* @__PURE__ */ h(_, { children: [
|
|
2070
2094
|
/* @__PURE__ */ s(Ut, { redirectPath: e }),
|
|
2071
|
-
/* @__PURE__ */ s(Se, { to: e, state: { from:
|
|
2095
|
+
/* @__PURE__ */ s(Se, { to: e, state: { from: L.pathname }, replace: !0 })
|
|
2072
2096
|
] });
|
|
2073
|
-
const
|
|
2074
|
-
if (!
|
|
2075
|
-
return /* @__PURE__ */ s(Se, { to: e, state: { from:
|
|
2076
|
-
if (t && !Bt(
|
|
2097
|
+
const m = d.getUser();
|
|
2098
|
+
if (!m)
|
|
2099
|
+
return /* @__PURE__ */ s(Se, { to: e, state: { from: L.pathname }, replace: !0 });
|
|
2100
|
+
if (t && !Bt(m.userType, t))
|
|
2077
2101
|
return /* @__PURE__ */ s(
|
|
2078
2102
|
Qe,
|
|
2079
2103
|
{
|
|
2080
|
-
userType:
|
|
2104
|
+
userType: m.userType,
|
|
2081
2105
|
requiredUserType: t
|
|
2082
2106
|
}
|
|
2083
2107
|
);
|
|
2084
|
-
if (r && r.length > 0 && !(i ?
|
|
2085
|
-
const A = r.filter((
|
|
2108
|
+
if (r && r.length > 0 && !(i ? c(r) : y(r))) {
|
|
2109
|
+
const A = r.filter((N) => !f(N)).map((N) => typeof N == "string" ? N : N.name);
|
|
2086
2110
|
return /* @__PURE__ */ s(Qe, { missingPermissions: A });
|
|
2087
2111
|
}
|
|
2088
2112
|
return /* @__PURE__ */ s(_, { children: n });
|
|
@@ -2100,7 +2124,7 @@ const $t = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2100
2124
|
backgroundColor: "#f9fafb",
|
|
2101
2125
|
textAlign: "center"
|
|
2102
2126
|
},
|
|
2103
|
-
children: /* @__PURE__ */
|
|
2127
|
+
children: /* @__PURE__ */ h(
|
|
2104
2128
|
"div",
|
|
2105
2129
|
{
|
|
2106
2130
|
style: {
|
|
@@ -2114,7 +2138,7 @@ const $t = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2114
2138
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
|
|
2115
2139
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
|
|
2116
2140
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
|
|
2117
|
-
/* @__PURE__ */
|
|
2141
|
+
/* @__PURE__ */ h("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
2118
2142
|
"Redirecting to ",
|
|
2119
2143
|
n,
|
|
2120
2144
|
"..."
|
|
@@ -2125,12 +2149,12 @@ const $t = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2125
2149
|
}
|
|
2126
2150
|
);
|
|
2127
2151
|
function Lr({ children: n, redirectTo: e = "/", fallback: t }) {
|
|
2128
|
-
const { tenant: r, isLoading: i, error: o } =
|
|
2152
|
+
const { tenant: r, isLoading: i, error: o } = Ze(), a = xe();
|
|
2129
2153
|
return ne(() => {
|
|
2130
2154
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2131
2155
|
"[react-identity-access] TenantRoute is deprecated. Use TenantZone from ZoneRoute instead."
|
|
2132
2156
|
);
|
|
2133
|
-
}, []), i || o ? null : r ? /* @__PURE__ */ s(_, { children: n }) : t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */
|
|
2157
|
+
}, []), i || o ? null : r ? /* @__PURE__ */ s(_, { children: n }) : t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ h(_, { children: [
|
|
2134
2158
|
/* @__PURE__ */ s($t, { redirectPath: e }),
|
|
2135
2159
|
/* @__PURE__ */ s(Se, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
2136
2160
|
] });
|
|
@@ -2148,7 +2172,7 @@ const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2148
2172
|
backgroundColor: "#f9fafb",
|
|
2149
2173
|
textAlign: "center"
|
|
2150
2174
|
},
|
|
2151
|
-
children: /* @__PURE__ */
|
|
2175
|
+
children: /* @__PURE__ */ h(
|
|
2152
2176
|
"div",
|
|
2153
2177
|
{
|
|
2154
2178
|
style: {
|
|
@@ -2162,7 +2186,7 @@ const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2162
2186
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
|
|
2163
2187
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
|
|
2164
2188
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
|
|
2165
|
-
/* @__PURE__ */
|
|
2189
|
+
/* @__PURE__ */ h("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
2166
2190
|
"Redirecting to ",
|
|
2167
2191
|
n,
|
|
2168
2192
|
"..."
|
|
@@ -2173,12 +2197,12 @@ const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2173
2197
|
}
|
|
2174
2198
|
);
|
|
2175
2199
|
function Nr({ children: n, redirectTo: e = "/dashboard", fallback: t }) {
|
|
2176
|
-
const { tenant: r, isLoading: i, error: o } =
|
|
2200
|
+
const { tenant: r, isLoading: i, error: o } = Ze(), a = xe();
|
|
2177
2201
|
return ne(() => {
|
|
2178
2202
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2179
2203
|
"[react-identity-access] LandingRoute is deprecated. Use PublicZone from ZoneRoute instead."
|
|
2180
2204
|
);
|
|
2181
|
-
}, []), i || o ? null : r ? t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */
|
|
2205
|
+
}, []), i || o ? null : r ? t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ h(_, { children: [
|
|
2182
2206
|
/* @__PURE__ */ s(Ct, { redirectPath: e }),
|
|
2183
2207
|
/* @__PURE__ */ s(Se, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
2184
2208
|
] }) : /* @__PURE__ */ s(_, { children: n });
|
|
@@ -2186,11 +2210,11 @@ function Nr({ children: n, redirectTo: e = "/dashboard", fallback: t }) {
|
|
|
2186
2210
|
function Ht(n, e) {
|
|
2187
2211
|
return e ? n ? Array.isArray(e) ? e.includes(n) : n === e : !1 : !0;
|
|
2188
2212
|
}
|
|
2189
|
-
function
|
|
2213
|
+
function Je(n, e) {
|
|
2190
2214
|
return !n || n === "optional" ? "skip" : n === "required" ? e ? "pass" : "fail" : n === "forbidden" ? e ? "fail" : "pass" : "skip";
|
|
2191
2215
|
}
|
|
2192
2216
|
function Ot(n, e) {
|
|
2193
|
-
return
|
|
2217
|
+
return Je(n.tenant, e.hasTenant) === "fail" ? e.hasTenant ? "has_tenant" : "no_tenant" : Je(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;
|
|
2194
2218
|
}
|
|
2195
2219
|
function qt(n, e) {
|
|
2196
2220
|
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;
|
|
@@ -2214,41 +2238,41 @@ const ue = ({
|
|
|
2214
2238
|
userType: i,
|
|
2215
2239
|
requiredPermissions: o,
|
|
2216
2240
|
requireAllPermissions: a = !0,
|
|
2217
|
-
returnTo:
|
|
2218
|
-
onAccessDenied:
|
|
2241
|
+
returnTo: d,
|
|
2242
|
+
onAccessDenied: f,
|
|
2219
2243
|
redirectTo: y,
|
|
2220
|
-
loadingFallback:
|
|
2221
|
-
accessDeniedFallback:
|
|
2244
|
+
loadingFallback: c,
|
|
2245
|
+
accessDeniedFallback: L
|
|
2222
2246
|
}) => {
|
|
2223
|
-
const
|
|
2247
|
+
const m = xe(), { isAuthenticated: T, isAuthInitializing: A, currentUser: N, userPermissions: M } = he(), { tenant: P, isTenantLoading: u } = Te(), v = Ft(), F = J(() => {
|
|
2224
2248
|
if (e)
|
|
2225
2249
|
return v.presets[e];
|
|
2226
|
-
}, [e, v.presets]), B =
|
|
2250
|
+
}, [e, v.presets]), B = J(
|
|
2227
2251
|
() => ({
|
|
2228
|
-
tenant: t ?? (
|
|
2229
|
-
auth: r ?? (
|
|
2230
|
-
userType: i ?? (
|
|
2231
|
-
permissions: o ?? (
|
|
2252
|
+
tenant: t ?? (F == null ? void 0 : F.tenant),
|
|
2253
|
+
auth: r ?? (F == null ? void 0 : F.auth),
|
|
2254
|
+
userType: i ?? (F == null ? void 0 : F.userType),
|
|
2255
|
+
permissions: o ?? (F == null ? void 0 : F.requiredPermissions),
|
|
2232
2256
|
requireAllPermissions: a
|
|
2233
2257
|
}),
|
|
2234
|
-
[t, r, i, o,
|
|
2235
|
-
), w =
|
|
2258
|
+
[t, r, i, o, F, a]
|
|
2259
|
+
), w = J(
|
|
2236
2260
|
() => ({
|
|
2237
2261
|
hasTenant: !!P,
|
|
2238
2262
|
isAuthenticated: T,
|
|
2239
|
-
userType:
|
|
2263
|
+
userType: N == null ? void 0 : N.userType,
|
|
2240
2264
|
permissions: M,
|
|
2241
|
-
isLoading: A ||
|
|
2265
|
+
isLoading: A || u
|
|
2242
2266
|
}),
|
|
2243
2267
|
[
|
|
2244
2268
|
P,
|
|
2245
2269
|
T,
|
|
2246
|
-
|
|
2270
|
+
N == null ? void 0 : N.userType,
|
|
2247
2271
|
M,
|
|
2248
2272
|
A,
|
|
2249
|
-
|
|
2273
|
+
u
|
|
2250
2274
|
]
|
|
2251
|
-
), R =
|
|
2275
|
+
), R = J(() => w.isLoading ? null : Ot(B, w), [B, w]), k = J(() => R ? y || qt(w, v.zoneRoots) : null, [R, y, w, v.zoneRoots]), I = J(() => !R || !k ? null : {
|
|
2252
2276
|
type: R,
|
|
2253
2277
|
required: {
|
|
2254
2278
|
tenant: B.tenant,
|
|
@@ -2265,32 +2289,32 @@ const ue = ({
|
|
|
2265
2289
|
redirectTo: k
|
|
2266
2290
|
}, [R, k, B, w]);
|
|
2267
2291
|
if (ne(() => {
|
|
2268
|
-
I && (
|
|
2269
|
-
}, [I,
|
|
2270
|
-
I &&
|
|
2292
|
+
I && (f ? f(I) : v.onAccessDenied && v.onAccessDenied(I));
|
|
2293
|
+
}, [I, f, v]), ne(() => {
|
|
2294
|
+
I && d && zt(d, m.pathname + m.search, v.returnToStorage);
|
|
2271
2295
|
}, [
|
|
2272
2296
|
I,
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2297
|
+
d,
|
|
2298
|
+
m.pathname,
|
|
2299
|
+
m.search,
|
|
2276
2300
|
v.returnToStorage
|
|
2277
2301
|
]), w.isLoading)
|
|
2278
|
-
return /* @__PURE__ */ s(_, { children:
|
|
2302
|
+
return /* @__PURE__ */ s(_, { children: c ?? v.loadingFallback ?? null });
|
|
2279
2303
|
if (I && k) {
|
|
2280
|
-
const l =
|
|
2304
|
+
const l = L ?? v.accessDeniedFallback;
|
|
2281
2305
|
if (l)
|
|
2282
2306
|
return /* @__PURE__ */ s(_, { children: l });
|
|
2283
2307
|
const z = _t(
|
|
2284
2308
|
k,
|
|
2285
|
-
|
|
2286
|
-
|
|
2309
|
+
d,
|
|
2310
|
+
m.pathname + m.search,
|
|
2287
2311
|
v.returnToParam,
|
|
2288
2312
|
v.returnToStorage
|
|
2289
2313
|
);
|
|
2290
2314
|
return /* @__PURE__ */ s(Se, { to: z, replace: !0 });
|
|
2291
2315
|
}
|
|
2292
2316
|
return /* @__PURE__ */ s(_, { children: n });
|
|
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__ */
|
|
2317
|
+
}, 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__ */ h(
|
|
2294
2318
|
"div",
|
|
2295
2319
|
{
|
|
2296
2320
|
style: {
|
|
@@ -2313,8 +2337,8 @@ function zr({
|
|
|
2313
2337
|
allowedPlans: t,
|
|
2314
2338
|
requiredFeature: r
|
|
2315
2339
|
}) {
|
|
2316
|
-
const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading:
|
|
2317
|
-
return
|
|
2340
|
+
const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: d } = Nt();
|
|
2341
|
+
return d ? /* @__PURE__ */ s(
|
|
2318
2342
|
"div",
|
|
2319
2343
|
{
|
|
2320
2344
|
style: {
|
|
@@ -2326,7 +2350,7 @@ function zr({
|
|
|
2326
2350
|
}
|
|
2327
2351
|
) : i ? i.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ s(_, { children: e }) : r && !a(r) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: n }) : /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: e });
|
|
2328
2352
|
}
|
|
2329
|
-
const Wt = ({ flagName: n }) => /* @__PURE__ */
|
|
2353
|
+
const Wt = ({ flagName: n }) => /* @__PURE__ */ h(
|
|
2330
2354
|
"div",
|
|
2331
2355
|
{
|
|
2332
2356
|
style: {
|
|
@@ -2345,7 +2369,7 @@ const Wt = ({ flagName: n }) => /* @__PURE__ */ u(
|
|
|
2345
2369
|
children: [
|
|
2346
2370
|
/* @__PURE__ */ s("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
|
|
2347
2371
|
/* @__PURE__ */ s("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
|
|
2348
|
-
/* @__PURE__ */
|
|
2372
|
+
/* @__PURE__ */ h("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
|
|
2349
2373
|
'Feature flag "',
|
|
2350
2374
|
n,
|
|
2351
2375
|
'" is disabled'
|
|
@@ -2370,7 +2394,7 @@ function Vr({ name: n, children: e, fallback: t }) {
|
|
|
2370
2394
|
}
|
|
2371
2395
|
) : r(n) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: t || /* @__PURE__ */ s(Wt, { flagName: n }) });
|
|
2372
2396
|
}
|
|
2373
|
-
const jt = () => /* @__PURE__ */
|
|
2397
|
+
const jt = () => /* @__PURE__ */ h(
|
|
2374
2398
|
"svg",
|
|
2375
2399
|
{
|
|
2376
2400
|
width: "16",
|
|
@@ -2387,7 +2411,7 @@ const jt = () => /* @__PURE__ */ u(
|
|
|
2387
2411
|
/* @__PURE__ */ s("circle", { cx: "12", cy: "12", r: "3" })
|
|
2388
2412
|
]
|
|
2389
2413
|
}
|
|
2390
|
-
), Gt = () => /* @__PURE__ */
|
|
2414
|
+
), Gt = () => /* @__PURE__ */ h(
|
|
2391
2415
|
"svg",
|
|
2392
2416
|
{
|
|
2393
2417
|
width: "16",
|
|
@@ -2425,7 +2449,7 @@ const jt = () => /* @__PURE__ */ u(
|
|
|
2425
2449
|
dividerBullet: "•",
|
|
2426
2450
|
showPasswordAriaLabel: "Show password",
|
|
2427
2451
|
hidePasswordAriaLabel: "Hide password"
|
|
2428
|
-
},
|
|
2452
|
+
}, Jt = {
|
|
2429
2453
|
container: {
|
|
2430
2454
|
maxWidth: "400px",
|
|
2431
2455
|
width: "100%",
|
|
@@ -2543,21 +2567,21 @@ function Wr({
|
|
|
2543
2567
|
onError: i,
|
|
2544
2568
|
onForgotPassword: o,
|
|
2545
2569
|
onSignupClick: a,
|
|
2546
|
-
onMagicLinkClick:
|
|
2547
|
-
showForgotPassword:
|
|
2570
|
+
onMagicLinkClick: d,
|
|
2571
|
+
showForgotPassword: f = !0,
|
|
2548
2572
|
showSignupLink: y = !0,
|
|
2549
|
-
showMagicLinkOption:
|
|
2550
|
-
className:
|
|
2573
|
+
showMagicLinkOption: c = !0,
|
|
2574
|
+
className: L
|
|
2551
2575
|
}) {
|
|
2552
|
-
const [
|
|
2553
|
-
const
|
|
2554
|
-
return
|
|
2555
|
-
},
|
|
2556
|
-
if (
|
|
2576
|
+
const [m, T] = x(""), [A, N] = x(""), [M, P] = x(!1), [u, v] = x(!1), [F, B] = x(""), [w, R] = x({}), { login: k } = he(), I = { ...Qt, ...n }, l = { ...Jt, ...e }, z = { ...Kt, ...t }, D = () => {
|
|
2577
|
+
const p = {};
|
|
2578
|
+
return m.trim() || (p.username = !0), A.trim() || (p.password = !0), R(p), Object.keys(p).length === 0;
|
|
2579
|
+
}, g = async (p) => {
|
|
2580
|
+
if (p.preventDefault(), !!D()) {
|
|
2557
2581
|
v(!0), B("");
|
|
2558
2582
|
try {
|
|
2559
2583
|
const S = await k({
|
|
2560
|
-
username:
|
|
2584
|
+
username: m,
|
|
2561
2585
|
password: A
|
|
2562
2586
|
// tenantId inferred from context automatically
|
|
2563
2587
|
});
|
|
@@ -2569,18 +2593,18 @@ function Wr({
|
|
|
2569
2593
|
v(!1);
|
|
2570
2594
|
}
|
|
2571
2595
|
}
|
|
2572
|
-
}, U = (
|
|
2596
|
+
}, U = (p) => ({
|
|
2573
2597
|
...l.input,
|
|
2574
|
-
...w[
|
|
2598
|
+
...w[p] ? l.inputError : {}
|
|
2575
2599
|
}), b = () => ({
|
|
2576
2600
|
...l.button,
|
|
2577
|
-
...
|
|
2578
|
-
...!
|
|
2601
|
+
...u ? l.buttonLoading : {},
|
|
2602
|
+
...!m || !A || u ? l.buttonDisabled : {}
|
|
2579
2603
|
});
|
|
2580
|
-
return /* @__PURE__ */
|
|
2604
|
+
return /* @__PURE__ */ h("div", { className: L, style: l.container, children: [
|
|
2581
2605
|
/* @__PURE__ */ s("h2", { style: l.title, children: I.title }),
|
|
2582
|
-
/* @__PURE__ */
|
|
2583
|
-
/* @__PURE__ */
|
|
2606
|
+
/* @__PURE__ */ h("form", { onSubmit: g, style: l.form, children: [
|
|
2607
|
+
/* @__PURE__ */ h("div", { style: l.fieldGroup, children: [
|
|
2584
2608
|
/* @__PURE__ */ s("label", { style: l.label, children: I.usernameLabel }),
|
|
2585
2609
|
/* @__PURE__ */ s(
|
|
2586
2610
|
"input",
|
|
@@ -2588,19 +2612,19 @@ function Wr({
|
|
|
2588
2612
|
id: "username",
|
|
2589
2613
|
name: "username",
|
|
2590
2614
|
type: "text",
|
|
2591
|
-
value:
|
|
2592
|
-
onChange: (
|
|
2593
|
-
T(
|
|
2615
|
+
value: m,
|
|
2616
|
+
onChange: (p) => {
|
|
2617
|
+
T(p.target.value), w.username && R((S) => ({ ...S, username: !1 }));
|
|
2594
2618
|
},
|
|
2595
2619
|
placeholder: I.usernamePlaceholder,
|
|
2596
2620
|
style: U("username"),
|
|
2597
|
-
disabled:
|
|
2621
|
+
disabled: u
|
|
2598
2622
|
}
|
|
2599
2623
|
)
|
|
2600
2624
|
] }),
|
|
2601
|
-
/* @__PURE__ */
|
|
2625
|
+
/* @__PURE__ */ h("div", { style: l.fieldGroup, children: [
|
|
2602
2626
|
/* @__PURE__ */ s("label", { style: l.label, children: I.passwordLabel }),
|
|
2603
|
-
/* @__PURE__ */
|
|
2627
|
+
/* @__PURE__ */ h("div", { style: l.inputContainer, children: [
|
|
2604
2628
|
/* @__PURE__ */ s(
|
|
2605
2629
|
"input",
|
|
2606
2630
|
{
|
|
@@ -2608,15 +2632,15 @@ function Wr({
|
|
|
2608
2632
|
name: "password",
|
|
2609
2633
|
type: M ? "text" : "password",
|
|
2610
2634
|
value: A,
|
|
2611
|
-
onChange: (
|
|
2612
|
-
|
|
2635
|
+
onChange: (p) => {
|
|
2636
|
+
N(p.target.value), w.password && R((S) => ({ ...S, password: !1 }));
|
|
2613
2637
|
},
|
|
2614
2638
|
placeholder: I.passwordPlaceholder,
|
|
2615
2639
|
style: {
|
|
2616
2640
|
...U("password"),
|
|
2617
2641
|
...l.inputWithIcon
|
|
2618
2642
|
},
|
|
2619
|
-
disabled:
|
|
2643
|
+
disabled: u
|
|
2620
2644
|
}
|
|
2621
2645
|
),
|
|
2622
2646
|
/* @__PURE__ */ s(
|
|
@@ -2625,29 +2649,29 @@ function Wr({
|
|
|
2625
2649
|
type: "button",
|
|
2626
2650
|
onClick: () => P(!M),
|
|
2627
2651
|
style: l.passwordToggle,
|
|
2628
|
-
disabled:
|
|
2652
|
+
disabled: u,
|
|
2629
2653
|
"aria-label": M ? I.hidePasswordAriaLabel : I.showPasswordAriaLabel,
|
|
2630
2654
|
children: M ? z.hidePassword : z.showPassword
|
|
2631
2655
|
}
|
|
2632
2656
|
)
|
|
2633
2657
|
] })
|
|
2634
2658
|
] }),
|
|
2635
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: !
|
|
2636
|
-
|
|
2659
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !m || !A || u, style: b(), children: u ? I.loadingText : I.submitButton }),
|
|
2660
|
+
F && /* @__PURE__ */ s("div", { style: l.errorText, children: F })
|
|
2637
2661
|
] }),
|
|
2638
|
-
(
|
|
2639
|
-
|
|
2640
|
-
/* @__PURE__ */
|
|
2662
|
+
(f || y || c) && /* @__PURE__ */ h("div", { style: l.linkContainer, children: [
|
|
2663
|
+
c && /* @__PURE__ */ h("div", { children: [
|
|
2664
|
+
/* @__PURE__ */ h("span", { style: l.divider, children: [
|
|
2641
2665
|
I.magicLinkText,
|
|
2642
2666
|
" "
|
|
2643
2667
|
] }),
|
|
2644
|
-
/* @__PURE__ */ s("a", { onClick:
|
|
2668
|
+
/* @__PURE__ */ s("a", { onClick: d, style: l.link, children: I.magicLinkLink })
|
|
2645
2669
|
] }),
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
y && /* @__PURE__ */
|
|
2650
|
-
/* @__PURE__ */
|
|
2670
|
+
c && (f || y) && /* @__PURE__ */ s("div", { style: l.divider, children: I.dividerBullet }),
|
|
2671
|
+
f && /* @__PURE__ */ s("a", { onClick: o, style: l.link, children: I.forgotPasswordLink }),
|
|
2672
|
+
f && y && /* @__PURE__ */ s("div", { style: l.divider, children: I.dividerBullet }),
|
|
2673
|
+
y && /* @__PURE__ */ h("div", { children: [
|
|
2674
|
+
/* @__PURE__ */ h("span", { style: l.divider, children: [
|
|
2651
2675
|
I.signupText,
|
|
2652
2676
|
" "
|
|
2653
2677
|
] }),
|
|
@@ -2656,7 +2680,7 @@ function Wr({
|
|
|
2656
2680
|
] })
|
|
2657
2681
|
] });
|
|
2658
2682
|
}
|
|
2659
|
-
const
|
|
2683
|
+
const Zt = {
|
|
2660
2684
|
title: "Create Account",
|
|
2661
2685
|
nameLabel: "First Name",
|
|
2662
2686
|
namePlaceholder: "Enter your first name",
|
|
@@ -2798,21 +2822,21 @@ function jr({
|
|
|
2798
2822
|
onError: i,
|
|
2799
2823
|
onLoginClick: o,
|
|
2800
2824
|
onMagicLinkClick: a,
|
|
2801
|
-
showLoginLink:
|
|
2802
|
-
showMagicLinkOption:
|
|
2825
|
+
showLoginLink: d = !0,
|
|
2826
|
+
showMagicLinkOption: f = !0,
|
|
2803
2827
|
className: y
|
|
2804
2828
|
}) {
|
|
2805
2829
|
var V;
|
|
2806
|
-
const [
|
|
2830
|
+
const [c, L] = x(""), [m, T] = x(""), [A, N] = x(""), [M, P] = x(""), [u, v] = x(""), [F, B] = x(""), [w, R] = x(""), [k, I] = x(!1), [l, z] = x(""), [D, g] = x({}), { signup: U, signupTenantAdmin: b } = he(), p = ((V = pe()) == null ? void 0 : V.tenant) ?? null, S = { ...Zt, ...n }, E = { ...Yt, ...e }, K = () => {
|
|
2807
2831
|
const H = {};
|
|
2808
|
-
return
|
|
2832
|
+
return c.trim() || (H.name = !0), !A.trim() && !M.trim() && (H.email = !0, H.phoneNumber = !0), u.trim() || (H.password = !0), F.trim() || (H.confirmPassword = !0), t === "tenant" && !w.trim() && (H.tenantName = !0), g(H), Object.keys(H).length === 0;
|
|
2809
2833
|
}, G = async (H) => {
|
|
2810
2834
|
if (H.preventDefault(), !!K()) {
|
|
2811
|
-
if (
|
|
2812
|
-
z(S.passwordMismatchError),
|
|
2835
|
+
if (u !== F) {
|
|
2836
|
+
z(S.passwordMismatchError), g({ confirmPassword: !0 });
|
|
2813
2837
|
return;
|
|
2814
2838
|
}
|
|
2815
|
-
if (t === "user" && !(
|
|
2839
|
+
if (t === "user" && !(p != null && p.id)) {
|
|
2816
2840
|
z(S.tenantNotFoundError);
|
|
2817
2841
|
return;
|
|
2818
2842
|
}
|
|
@@ -2822,17 +2846,17 @@ function jr({
|
|
|
2822
2846
|
t === "tenant" ? $ = await b({
|
|
2823
2847
|
email: A || void 0,
|
|
2824
2848
|
phoneNumber: M || void 0,
|
|
2825
|
-
name:
|
|
2826
|
-
password:
|
|
2849
|
+
name: c,
|
|
2850
|
+
password: u,
|
|
2827
2851
|
tenantName: w,
|
|
2828
|
-
lastName:
|
|
2852
|
+
lastName: m || void 0
|
|
2829
2853
|
}) : $ = await U({
|
|
2830
2854
|
email: A || void 0,
|
|
2831
2855
|
phoneNumber: M || void 0,
|
|
2832
|
-
name:
|
|
2833
|
-
password:
|
|
2834
|
-
tenantId:
|
|
2835
|
-
lastName:
|
|
2856
|
+
name: c,
|
|
2857
|
+
password: u,
|
|
2858
|
+
tenantId: p.id,
|
|
2859
|
+
lastName: m || void 0
|
|
2836
2860
|
}), r == null || r($);
|
|
2837
2861
|
} catch ($) {
|
|
2838
2862
|
const ce = $.message || S.errorMessage;
|
|
@@ -2847,12 +2871,12 @@ function jr({
|
|
|
2847
2871
|
}), W = () => ({
|
|
2848
2872
|
...E.button,
|
|
2849
2873
|
...k ? E.buttonLoading : {},
|
|
2850
|
-
...!
|
|
2851
|
-
}), q =
|
|
2852
|
-
return /* @__PURE__ */
|
|
2874
|
+
...!c || !A && !M || !u || !F || k || t === "tenant" && !w ? E.buttonDisabled : {}
|
|
2875
|
+
}), q = c && (A || M) && u && F && (t === "user" || w);
|
|
2876
|
+
return /* @__PURE__ */ h("div", { className: y, style: E.container, children: [
|
|
2853
2877
|
/* @__PURE__ */ s("h2", { style: E.title, children: S.title }),
|
|
2854
|
-
/* @__PURE__ */
|
|
2855
|
-
/* @__PURE__ */
|
|
2878
|
+
/* @__PURE__ */ h("form", { onSubmit: G, style: E.form, children: [
|
|
2879
|
+
/* @__PURE__ */ h("div", { style: E.fieldGroup, children: [
|
|
2856
2880
|
/* @__PURE__ */ s("label", { style: E.label, children: S.nameLabel }),
|
|
2857
2881
|
/* @__PURE__ */ s(
|
|
2858
2882
|
"input",
|
|
@@ -2860,9 +2884,9 @@ function jr({
|
|
|
2860
2884
|
id: "name",
|
|
2861
2885
|
name: "name",
|
|
2862
2886
|
type: "text",
|
|
2863
|
-
value:
|
|
2887
|
+
value: c,
|
|
2864
2888
|
onChange: (H) => {
|
|
2865
|
-
|
|
2889
|
+
L(H.target.value), D.name && g(($) => ({ ...$, name: !1 }));
|
|
2866
2890
|
},
|
|
2867
2891
|
placeholder: S.namePlaceholder,
|
|
2868
2892
|
style: X("name"),
|
|
@@ -2870,7 +2894,7 @@ function jr({
|
|
|
2870
2894
|
}
|
|
2871
2895
|
)
|
|
2872
2896
|
] }),
|
|
2873
|
-
/* @__PURE__ */
|
|
2897
|
+
/* @__PURE__ */ h("div", { style: E.fieldGroup, children: [
|
|
2874
2898
|
/* @__PURE__ */ s("label", { style: E.label, children: S.lastNameLabel }),
|
|
2875
2899
|
/* @__PURE__ */ s(
|
|
2876
2900
|
"input",
|
|
@@ -2878,7 +2902,7 @@ function jr({
|
|
|
2878
2902
|
id: "lastName",
|
|
2879
2903
|
name: "lastName",
|
|
2880
2904
|
type: "text",
|
|
2881
|
-
value:
|
|
2905
|
+
value: m,
|
|
2882
2906
|
onChange: (H) => T(H.target.value),
|
|
2883
2907
|
placeholder: S.lastNamePlaceholder,
|
|
2884
2908
|
style: E.input,
|
|
@@ -2886,7 +2910,7 @@ function jr({
|
|
|
2886
2910
|
}
|
|
2887
2911
|
)
|
|
2888
2912
|
] }),
|
|
2889
|
-
/* @__PURE__ */
|
|
2913
|
+
/* @__PURE__ */ h("div", { style: E.fieldGroup, children: [
|
|
2890
2914
|
/* @__PURE__ */ s("label", { style: E.label, children: S.emailLabel }),
|
|
2891
2915
|
/* @__PURE__ */ s(
|
|
2892
2916
|
"input",
|
|
@@ -2896,7 +2920,7 @@ function jr({
|
|
|
2896
2920
|
type: "email",
|
|
2897
2921
|
value: A,
|
|
2898
2922
|
onChange: (H) => {
|
|
2899
|
-
|
|
2923
|
+
N(H.target.value), D.email && g(($) => ({ ...$, email: !1, phoneNumber: !1 }));
|
|
2900
2924
|
},
|
|
2901
2925
|
placeholder: S.emailPlaceholder,
|
|
2902
2926
|
style: X("email"),
|
|
@@ -2904,7 +2928,7 @@ function jr({
|
|
|
2904
2928
|
}
|
|
2905
2929
|
)
|
|
2906
2930
|
] }),
|
|
2907
|
-
/* @__PURE__ */
|
|
2931
|
+
/* @__PURE__ */ h("div", { style: E.fieldGroup, children: [
|
|
2908
2932
|
/* @__PURE__ */ s("label", { style: E.label, children: S.phoneNumberLabel }),
|
|
2909
2933
|
/* @__PURE__ */ s(
|
|
2910
2934
|
"input",
|
|
@@ -2914,7 +2938,7 @@ function jr({
|
|
|
2914
2938
|
type: "tel",
|
|
2915
2939
|
value: M,
|
|
2916
2940
|
onChange: (H) => {
|
|
2917
|
-
P(H.target.value), D.phoneNumber &&
|
|
2941
|
+
P(H.target.value), D.phoneNumber && g(($) => ({ ...$, email: !1, phoneNumber: !1 }));
|
|
2918
2942
|
},
|
|
2919
2943
|
placeholder: S.phoneNumberPlaceholder,
|
|
2920
2944
|
style: X("phoneNumber"),
|
|
@@ -2923,7 +2947,7 @@ function jr({
|
|
|
2923
2947
|
)
|
|
2924
2948
|
] }),
|
|
2925
2949
|
/* @__PURE__ */ s("div", { style: E.hintText, children: S.contactMethodHint }),
|
|
2926
|
-
/* @__PURE__ */
|
|
2950
|
+
/* @__PURE__ */ h("div", { style: E.fieldGroup, children: [
|
|
2927
2951
|
/* @__PURE__ */ s("label", { style: E.label, children: S.passwordLabel }),
|
|
2928
2952
|
/* @__PURE__ */ s(
|
|
2929
2953
|
"input",
|
|
@@ -2931,9 +2955,9 @@ function jr({
|
|
|
2931
2955
|
id: "password",
|
|
2932
2956
|
name: "password",
|
|
2933
2957
|
type: "password",
|
|
2934
|
-
value:
|
|
2958
|
+
value: u,
|
|
2935
2959
|
onChange: (H) => {
|
|
2936
|
-
v(H.target.value), D.password &&
|
|
2960
|
+
v(H.target.value), D.password && g(($) => ({ ...$, password: !1 }));
|
|
2937
2961
|
},
|
|
2938
2962
|
placeholder: S.passwordPlaceholder,
|
|
2939
2963
|
style: X("password"),
|
|
@@ -2941,7 +2965,7 @@ function jr({
|
|
|
2941
2965
|
}
|
|
2942
2966
|
)
|
|
2943
2967
|
] }),
|
|
2944
|
-
/* @__PURE__ */
|
|
2968
|
+
/* @__PURE__ */ h("div", { style: E.fieldGroup, children: [
|
|
2945
2969
|
/* @__PURE__ */ s("label", { style: E.label, children: S.confirmPasswordLabel }),
|
|
2946
2970
|
/* @__PURE__ */ s(
|
|
2947
2971
|
"input",
|
|
@@ -2949,9 +2973,9 @@ function jr({
|
|
|
2949
2973
|
id: "confirmPassword",
|
|
2950
2974
|
name: "confirmPassword",
|
|
2951
2975
|
type: "password",
|
|
2952
|
-
value:
|
|
2976
|
+
value: F,
|
|
2953
2977
|
onChange: (H) => {
|
|
2954
|
-
B(H.target.value), D.confirmPassword &&
|
|
2978
|
+
B(H.target.value), D.confirmPassword && g(($) => ({ ...$, confirmPassword: !1 })), l === S.passwordMismatchError && z("");
|
|
2955
2979
|
},
|
|
2956
2980
|
placeholder: S.confirmPasswordPlaceholder,
|
|
2957
2981
|
style: X("confirmPassword"),
|
|
@@ -2959,7 +2983,7 @@ function jr({
|
|
|
2959
2983
|
}
|
|
2960
2984
|
)
|
|
2961
2985
|
] }),
|
|
2962
|
-
t === "tenant" && /* @__PURE__ */
|
|
2986
|
+
t === "tenant" && /* @__PURE__ */ h("div", { style: E.fieldGroup, children: [
|
|
2963
2987
|
/* @__PURE__ */ s("label", { style: E.label, children: S.tenantNameLabel }),
|
|
2964
2988
|
/* @__PURE__ */ s(
|
|
2965
2989
|
"input",
|
|
@@ -2969,7 +2993,7 @@ function jr({
|
|
|
2969
2993
|
type: "text",
|
|
2970
2994
|
value: w,
|
|
2971
2995
|
onChange: (H) => {
|
|
2972
|
-
R(H.target.value), D.tenantName &&
|
|
2996
|
+
R(H.target.value), D.tenantName && g(($) => ({ ...$, tenantName: !1 }));
|
|
2973
2997
|
},
|
|
2974
2998
|
placeholder: S.tenantNamePlaceholder,
|
|
2975
2999
|
style: X("tenantName"),
|
|
@@ -2980,17 +3004,17 @@ function jr({
|
|
|
2980
3004
|
/* @__PURE__ */ s("button", { type: "submit", disabled: !q || k, style: W(), children: k ? S.loadingText : S.submitButton }),
|
|
2981
3005
|
l && /* @__PURE__ */ s("div", { style: E.errorText, children: l })
|
|
2982
3006
|
] }),
|
|
2983
|
-
(
|
|
2984
|
-
|
|
2985
|
-
/* @__PURE__ */
|
|
3007
|
+
(d || f) && /* @__PURE__ */ h("div", { style: E.linkContainer, children: [
|
|
3008
|
+
f && /* @__PURE__ */ h("div", { children: [
|
|
3009
|
+
/* @__PURE__ */ h("span", { style: E.divider, children: [
|
|
2986
3010
|
S.magicLinkText,
|
|
2987
3011
|
" "
|
|
2988
3012
|
] }),
|
|
2989
3013
|
/* @__PURE__ */ s("a", { onClick: a, style: E.link, children: S.magicLinkLink })
|
|
2990
3014
|
] }),
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
/* @__PURE__ */
|
|
3015
|
+
f && d && /* @__PURE__ */ s("div", { style: E.divider, children: S.dividerBullet }),
|
|
3016
|
+
d && /* @__PURE__ */ h("div", { children: [
|
|
3017
|
+
/* @__PURE__ */ h("span", { style: E.divider, children: [
|
|
2994
3018
|
S.loginText,
|
|
2995
3019
|
" "
|
|
2996
3020
|
] }),
|
|
@@ -3154,25 +3178,25 @@ function Gr({
|
|
|
3154
3178
|
onLoginClick: i,
|
|
3155
3179
|
onSignupClick: o,
|
|
3156
3180
|
showTraditionalLinks: a = !0,
|
|
3157
|
-
className:
|
|
3158
|
-
verifyToken:
|
|
3181
|
+
className: d,
|
|
3182
|
+
verifyToken: f,
|
|
3159
3183
|
frontendUrl: y
|
|
3160
3184
|
}) {
|
|
3161
3185
|
var W;
|
|
3162
|
-
const [
|
|
3186
|
+
const [c, L] = x(""), [m, T] = x(""), [A, N] = x(""), [M, P] = x(!1), [u, v] = x(!1), [F, B] = x(""), [w, R] = x(""), [k, I] = x({}), [l, z] = x(!1), { sendMagicLink: D, verifyMagicLink: g } = he(), U = ((W = pe()) == null ? void 0 : W.tenant) ?? null, b = { ...Xt, ...n }, p = { ...er, ...e };
|
|
3163
3187
|
ne(() => {
|
|
3164
|
-
|
|
3165
|
-
}, [
|
|
3188
|
+
f && S(f);
|
|
3189
|
+
}, [f]);
|
|
3166
3190
|
const S = async (q) => {
|
|
3167
|
-
if (!U || !
|
|
3191
|
+
if (!U || !c) {
|
|
3168
3192
|
B(b.missingTenantOrEmailError);
|
|
3169
3193
|
return;
|
|
3170
3194
|
}
|
|
3171
3195
|
v(!0), B("");
|
|
3172
3196
|
try {
|
|
3173
|
-
const V = await
|
|
3197
|
+
const V = await g({
|
|
3174
3198
|
token: q,
|
|
3175
|
-
email:
|
|
3199
|
+
email: c
|
|
3176
3200
|
// tenantId inferred from context automatically
|
|
3177
3201
|
});
|
|
3178
3202
|
t == null || t(V);
|
|
@@ -3184,7 +3208,7 @@ function Gr({
|
|
|
3184
3208
|
}
|
|
3185
3209
|
}, E = () => {
|
|
3186
3210
|
const q = {};
|
|
3187
|
-
return
|
|
3211
|
+
return c.trim() || (q.email = !0), l && !m.trim() && (q.name = !0), I(q), Object.keys(q).length === 0;
|
|
3188
3212
|
}, K = async (q) => {
|
|
3189
3213
|
if (q.preventDefault(), !!E()) {
|
|
3190
3214
|
if (!(U != null && U.id)) {
|
|
@@ -3194,10 +3218,10 @@ function Gr({
|
|
|
3194
3218
|
P(!0), B(""), R("");
|
|
3195
3219
|
try {
|
|
3196
3220
|
const V = y || (typeof window < "u" ? window.location.origin : ""), H = await D({
|
|
3197
|
-
email:
|
|
3221
|
+
email: c,
|
|
3198
3222
|
tenantId: U.id,
|
|
3199
3223
|
frontendUrl: V,
|
|
3200
|
-
name: l ?
|
|
3224
|
+
name: l ? m : void 0,
|
|
3201
3225
|
lastName: l ? A : void 0
|
|
3202
3226
|
});
|
|
3203
3227
|
R(b.successMessage), t == null || t(H);
|
|
@@ -3209,68 +3233,68 @@ function Gr({
|
|
|
3209
3233
|
}
|
|
3210
3234
|
}
|
|
3211
3235
|
}, G = (q) => ({
|
|
3212
|
-
...
|
|
3213
|
-
...k[q] ?
|
|
3236
|
+
...p.input,
|
|
3237
|
+
...k[q] ? p.inputError : {}
|
|
3214
3238
|
}), X = () => ({
|
|
3215
|
-
...
|
|
3216
|
-
...M ||
|
|
3217
|
-
...!
|
|
3239
|
+
...p.button,
|
|
3240
|
+
...M || u ? p.buttonLoading : {},
|
|
3241
|
+
...!c || M || u ? p.buttonDisabled : {}
|
|
3218
3242
|
});
|
|
3219
|
-
return
|
|
3220
|
-
/* @__PURE__ */ s("h2", { style:
|
|
3221
|
-
/* @__PURE__ */ s("div", { style:
|
|
3222
|
-
] }) : /* @__PURE__ */
|
|
3223
|
-
/* @__PURE__ */ s("h2", { style:
|
|
3224
|
-
/* @__PURE__ */ s("p", { style:
|
|
3225
|
-
/* @__PURE__ */
|
|
3226
|
-
/* @__PURE__ */
|
|
3227
|
-
/* @__PURE__ */ s("label", { style:
|
|
3243
|
+
return u ? /* @__PURE__ */ h("div", { className: d, style: p.container, children: [
|
|
3244
|
+
/* @__PURE__ */ s("h2", { style: p.title, children: b.verifyingText }),
|
|
3245
|
+
/* @__PURE__ */ s("div", { style: p.verifyingContainer, children: /* @__PURE__ */ s("div", { style: p.verifyingText, children: b.verifyingDescription }) })
|
|
3246
|
+
] }) : /* @__PURE__ */ h("div", { className: d, style: p.container, children: [
|
|
3247
|
+
/* @__PURE__ */ s("h2", { style: p.title, children: b.title }),
|
|
3248
|
+
/* @__PURE__ */ s("p", { style: p.description, children: b.description }),
|
|
3249
|
+
/* @__PURE__ */ h("form", { onSubmit: K, style: p.form, children: [
|
|
3250
|
+
/* @__PURE__ */ h("div", { style: p.fieldGroup, children: [
|
|
3251
|
+
/* @__PURE__ */ s("label", { style: p.label, children: b.emailLabel }),
|
|
3228
3252
|
/* @__PURE__ */ s(
|
|
3229
3253
|
"input",
|
|
3230
3254
|
{
|
|
3231
3255
|
id: "email",
|
|
3232
3256
|
name: "email",
|
|
3233
3257
|
type: "email",
|
|
3234
|
-
value:
|
|
3258
|
+
value: c,
|
|
3235
3259
|
onChange: (q) => {
|
|
3236
|
-
|
|
3260
|
+
L(q.target.value), k.email && I((V) => ({ ...V, email: !1 }));
|
|
3237
3261
|
},
|
|
3238
3262
|
placeholder: b.emailPlaceholder,
|
|
3239
3263
|
style: G("email"),
|
|
3240
|
-
disabled: M ||
|
|
3264
|
+
disabled: M || u
|
|
3241
3265
|
}
|
|
3242
3266
|
)
|
|
3243
3267
|
] }),
|
|
3244
|
-
!l && /* @__PURE__ */ s("div", { style:
|
|
3268
|
+
!l && /* @__PURE__ */ s("div", { style: p.toggleContainer, children: /* @__PURE__ */ s(
|
|
3245
3269
|
"button",
|
|
3246
3270
|
{
|
|
3247
3271
|
type: "button",
|
|
3248
3272
|
onClick: () => z(!0),
|
|
3249
|
-
style:
|
|
3273
|
+
style: p.toggleLink,
|
|
3250
3274
|
children: b.showNameToggle
|
|
3251
3275
|
}
|
|
3252
3276
|
) }),
|
|
3253
|
-
l && /* @__PURE__ */
|
|
3254
|
-
/* @__PURE__ */
|
|
3255
|
-
/* @__PURE__ */ s("label", { style:
|
|
3277
|
+
l && /* @__PURE__ */ h(_, { children: [
|
|
3278
|
+
/* @__PURE__ */ h("div", { style: p.fieldGroup, children: [
|
|
3279
|
+
/* @__PURE__ */ s("label", { style: p.label, children: b.nameLabel }),
|
|
3256
3280
|
/* @__PURE__ */ s(
|
|
3257
3281
|
"input",
|
|
3258
3282
|
{
|
|
3259
3283
|
id: "name",
|
|
3260
3284
|
name: "name",
|
|
3261
3285
|
type: "text",
|
|
3262
|
-
value:
|
|
3286
|
+
value: m,
|
|
3263
3287
|
onChange: (q) => {
|
|
3264
3288
|
T(q.target.value), k.name && I((V) => ({ ...V, name: !1 }));
|
|
3265
3289
|
},
|
|
3266
3290
|
placeholder: b.namePlaceholder,
|
|
3267
3291
|
style: G("name"),
|
|
3268
|
-
disabled: M ||
|
|
3292
|
+
disabled: M || u
|
|
3269
3293
|
}
|
|
3270
3294
|
)
|
|
3271
3295
|
] }),
|
|
3272
|
-
/* @__PURE__ */
|
|
3273
|
-
/* @__PURE__ */ s("label", { style:
|
|
3296
|
+
/* @__PURE__ */ h("div", { style: p.fieldGroup, children: [
|
|
3297
|
+
/* @__PURE__ */ s("label", { style: p.label, children: b.lastNameLabel }),
|
|
3274
3298
|
/* @__PURE__ */ s(
|
|
3275
3299
|
"input",
|
|
3276
3300
|
{
|
|
@@ -3278,44 +3302,44 @@ function Gr({
|
|
|
3278
3302
|
name: "lastName",
|
|
3279
3303
|
type: "text",
|
|
3280
3304
|
value: A,
|
|
3281
|
-
onChange: (q) =>
|
|
3305
|
+
onChange: (q) => N(q.target.value),
|
|
3282
3306
|
placeholder: b.lastNamePlaceholder,
|
|
3283
|
-
style:
|
|
3284
|
-
disabled: M ||
|
|
3307
|
+
style: p.input,
|
|
3308
|
+
disabled: M || u
|
|
3285
3309
|
}
|
|
3286
3310
|
)
|
|
3287
3311
|
] }),
|
|
3288
|
-
/* @__PURE__ */ s("div", { style:
|
|
3312
|
+
/* @__PURE__ */ s("div", { style: p.toggleContainer, children: /* @__PURE__ */ s(
|
|
3289
3313
|
"button",
|
|
3290
3314
|
{
|
|
3291
3315
|
type: "button",
|
|
3292
3316
|
onClick: () => {
|
|
3293
|
-
z(!1), T(""),
|
|
3317
|
+
z(!1), T(""), N("");
|
|
3294
3318
|
},
|
|
3295
|
-
style:
|
|
3319
|
+
style: p.toggleLink,
|
|
3296
3320
|
children: b.hideNameToggle
|
|
3297
3321
|
}
|
|
3298
3322
|
) })
|
|
3299
3323
|
] }),
|
|
3300
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: !
|
|
3301
|
-
|
|
3302
|
-
w && /* @__PURE__ */ s("div", { style:
|
|
3324
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !c || M || u, style: X(), children: M ? b.loadingText : b.submitButton }),
|
|
3325
|
+
F && /* @__PURE__ */ s("div", { style: p.errorText, children: F }),
|
|
3326
|
+
w && /* @__PURE__ */ s("div", { style: p.successText, children: w })
|
|
3303
3327
|
] }),
|
|
3304
|
-
a && /* @__PURE__ */
|
|
3305
|
-
/* @__PURE__ */
|
|
3306
|
-
/* @__PURE__ */
|
|
3328
|
+
a && /* @__PURE__ */ h("div", { style: p.linkContainer, children: [
|
|
3329
|
+
/* @__PURE__ */ h("div", { children: [
|
|
3330
|
+
/* @__PURE__ */ h("span", { style: p.divider, children: [
|
|
3307
3331
|
b.loginText,
|
|
3308
3332
|
" "
|
|
3309
3333
|
] }),
|
|
3310
|
-
/* @__PURE__ */ s("a", { onClick: i, style:
|
|
3334
|
+
/* @__PURE__ */ s("a", { onClick: i, style: p.link, children: b.loginLink })
|
|
3311
3335
|
] }),
|
|
3312
|
-
/* @__PURE__ */ s("div", { style:
|
|
3313
|
-
/* @__PURE__ */
|
|
3314
|
-
/* @__PURE__ */
|
|
3336
|
+
/* @__PURE__ */ s("div", { style: p.divider, children: b.dividerBullet }),
|
|
3337
|
+
/* @__PURE__ */ h("div", { children: [
|
|
3338
|
+
/* @__PURE__ */ h("span", { style: p.divider, children: [
|
|
3315
3339
|
b.signupText,
|
|
3316
3340
|
" "
|
|
3317
3341
|
] }),
|
|
3318
|
-
/* @__PURE__ */ s("a", { onClick: o, style:
|
|
3342
|
+
/* @__PURE__ */ s("a", { onClick: o, style: p.link, children: b.signupLink })
|
|
3319
3343
|
] })
|
|
3320
3344
|
] })
|
|
3321
3345
|
] });
|
|
@@ -3422,7 +3446,7 @@ const tr = {
|
|
|
3422
3446
|
backButtonHover: {
|
|
3423
3447
|
backgroundColor: "#e5e7eb"
|
|
3424
3448
|
}
|
|
3425
|
-
}, rr = () => /* @__PURE__ */ s("div", { style: tt.spinner }), nr = () => /* @__PURE__ */
|
|
3449
|
+
}, rr = () => /* @__PURE__ */ s("div", { style: tt.spinner }), nr = () => /* @__PURE__ */ h(
|
|
3426
3450
|
"svg",
|
|
3427
3451
|
{
|
|
3428
3452
|
width: "48",
|
|
@@ -3439,7 +3463,7 @@ const tr = {
|
|
|
3439
3463
|
/* @__PURE__ */ s("polyline", { points: "22,4 12,14.01 9,11.01" })
|
|
3440
3464
|
]
|
|
3441
3465
|
}
|
|
3442
|
-
), sr = () => /* @__PURE__ */
|
|
3466
|
+
), sr = () => /* @__PURE__ */ h(
|
|
3443
3467
|
"svg",
|
|
3444
3468
|
{
|
|
3445
3469
|
width: "48",
|
|
@@ -3470,38 +3494,38 @@ function Kr({
|
|
|
3470
3494
|
onError: i,
|
|
3471
3495
|
onRetry: o,
|
|
3472
3496
|
onBackToLogin: a,
|
|
3473
|
-
className:
|
|
3474
|
-
token:
|
|
3497
|
+
className: d,
|
|
3498
|
+
token: f,
|
|
3475
3499
|
email: y,
|
|
3476
|
-
appId:
|
|
3477
|
-
tenantSlug:
|
|
3478
|
-
autoRedirectDelay:
|
|
3500
|
+
appId: c,
|
|
3501
|
+
tenantSlug: L,
|
|
3502
|
+
autoRedirectDelay: m = 3e3
|
|
3479
3503
|
}) {
|
|
3480
|
-
const [T, A] = x("verifying"), [
|
|
3504
|
+
const [T, A] = x("verifying"), [N, M] = x(""), { verifyMagicLink: P } = he(), u = { ...tr, ...n }, v = { ...tt, ...e }, F = { ...ir, ...t }, B = () => {
|
|
3481
3505
|
if (typeof window > "u") return {};
|
|
3482
3506
|
const l = new URLSearchParams(window.location.search);
|
|
3483
3507
|
return {
|
|
3484
|
-
token:
|
|
3508
|
+
token: f || l.get("token") || "",
|
|
3485
3509
|
email: y || l.get("email") || "",
|
|
3486
|
-
appId:
|
|
3487
|
-
tenantSlug:
|
|
3510
|
+
appId: c || l.get("appId") || "",
|
|
3511
|
+
tenantSlug: L || l.get("tenantSlug") || void 0
|
|
3488
3512
|
};
|
|
3489
3513
|
}, w = async () => {
|
|
3490
3514
|
A("verifying"), M("");
|
|
3491
3515
|
try {
|
|
3492
3516
|
const l = B();
|
|
3493
3517
|
if (!l.token || !l.email)
|
|
3494
|
-
throw new Error(
|
|
3518
|
+
throw new Error(u.missingParamsError);
|
|
3495
3519
|
const z = await P({
|
|
3496
3520
|
token: l.token,
|
|
3497
3521
|
email: l.email,
|
|
3498
3522
|
tenantSlug: l.tenantSlug
|
|
3499
3523
|
});
|
|
3500
|
-
A("success"), r == null || r(z),
|
|
3524
|
+
A("success"), r == null || r(z), m > 0 && setTimeout(() => {
|
|
3501
3525
|
A("redirecting");
|
|
3502
|
-
},
|
|
3526
|
+
}, m);
|
|
3503
3527
|
} catch (l) {
|
|
3504
|
-
const z = l.message ||
|
|
3528
|
+
const z = l.message || u.errorMessage;
|
|
3505
3529
|
M(z), A("error"), i == null || i(z);
|
|
3506
3530
|
}
|
|
3507
3531
|
}, R = () => {
|
|
@@ -3515,25 +3539,25 @@ function Kr({
|
|
|
3515
3539
|
const I = () => {
|
|
3516
3540
|
switch (T) {
|
|
3517
3541
|
case "verifying":
|
|
3518
|
-
return /* @__PURE__ */
|
|
3519
|
-
|
|
3520
|
-
|
|
3542
|
+
return /* @__PURE__ */ h("div", { style: v.message, children: [
|
|
3543
|
+
F.loading,
|
|
3544
|
+
u.verifyingMessage
|
|
3521
3545
|
] });
|
|
3522
3546
|
case "success":
|
|
3523
|
-
return /* @__PURE__ */
|
|
3524
|
-
|
|
3525
|
-
/* @__PURE__ */ s("div", { style: v.successMessage, children:
|
|
3547
|
+
return /* @__PURE__ */ h(_, { children: [
|
|
3548
|
+
F.success,
|
|
3549
|
+
/* @__PURE__ */ s("div", { style: v.successMessage, children: u.successMessage })
|
|
3526
3550
|
] });
|
|
3527
3551
|
case "redirecting":
|
|
3528
|
-
return /* @__PURE__ */
|
|
3529
|
-
|
|
3530
|
-
/* @__PURE__ */ s("div", { style: v.message, children:
|
|
3552
|
+
return /* @__PURE__ */ h(_, { children: [
|
|
3553
|
+
F.loading,
|
|
3554
|
+
/* @__PURE__ */ s("div", { style: v.message, children: u.redirectingMessage })
|
|
3531
3555
|
] });
|
|
3532
3556
|
case "error":
|
|
3533
|
-
return /* @__PURE__ */
|
|
3534
|
-
|
|
3535
|
-
/* @__PURE__ */ s("div", { style: v.errorMessage, children:
|
|
3536
|
-
/* @__PURE__ */
|
|
3557
|
+
return /* @__PURE__ */ h(_, { children: [
|
|
3558
|
+
F.error,
|
|
3559
|
+
/* @__PURE__ */ s("div", { style: v.errorMessage, children: N || u.errorMessage }),
|
|
3560
|
+
/* @__PURE__ */ h("div", { style: v.buttonContainer, children: [
|
|
3537
3561
|
/* @__PURE__ */ s(
|
|
3538
3562
|
"button",
|
|
3539
3563
|
{
|
|
@@ -3548,7 +3572,7 @@ function Kr({
|
|
|
3548
3572
|
l.currentTarget.style[D] = z[D] ?? "";
|
|
3549
3573
|
});
|
|
3550
3574
|
},
|
|
3551
|
-
children:
|
|
3575
|
+
children: u.retryButton
|
|
3552
3576
|
}
|
|
3553
3577
|
),
|
|
3554
3578
|
/* @__PURE__ */ s(
|
|
@@ -3565,7 +3589,7 @@ function Kr({
|
|
|
3565
3589
|
l.currentTarget.style[D] = z[D] ?? "";
|
|
3566
3590
|
});
|
|
3567
3591
|
},
|
|
3568
|
-
children:
|
|
3592
|
+
children: u.backToLoginButton
|
|
3569
3593
|
}
|
|
3570
3594
|
)
|
|
3571
3595
|
] })
|
|
@@ -3574,14 +3598,14 @@ function Kr({
|
|
|
3574
3598
|
return null;
|
|
3575
3599
|
}
|
|
3576
3600
|
};
|
|
3577
|
-
return /* @__PURE__ */
|
|
3601
|
+
return /* @__PURE__ */ h("div", { style: v.container, className: d, children: [
|
|
3578
3602
|
/* @__PURE__ */ s("style", { children: `
|
|
3579
3603
|
@keyframes spin {
|
|
3580
3604
|
0% { transform: rotate(0deg); }
|
|
3581
3605
|
100% { transform: rotate(360deg); }
|
|
3582
3606
|
}
|
|
3583
3607
|
` }),
|
|
3584
|
-
/* @__PURE__ */ s("h1", { style: v.title, children:
|
|
3608
|
+
/* @__PURE__ */ s("h1", { style: v.title, children: u.title }),
|
|
3585
3609
|
I()
|
|
3586
3610
|
] });
|
|
3587
3611
|
}
|
|
@@ -3715,70 +3739,70 @@ function Qr({
|
|
|
3715
3739
|
onSuccess: i,
|
|
3716
3740
|
onError: o,
|
|
3717
3741
|
onBackToLogin: a,
|
|
3718
|
-
onModeChange:
|
|
3719
|
-
className:
|
|
3742
|
+
onModeChange: d,
|
|
3743
|
+
className: f
|
|
3720
3744
|
}) {
|
|
3721
3745
|
var X;
|
|
3722
|
-
const [y,
|
|
3746
|
+
const [y, c] = x(""), [L, m] = x(r), [T, A] = x(""), [N, M] = x(""), [P, u] = x(!1), [v, F] = x(""), [B, w] = x(""), [R, k] = x({}), { requestPasswordReset: I, confirmPasswordReset: l } = he(), z = ((X = pe()) == null ? void 0 : X.tenant) ?? null, D = { ...or, ...n }, g = { ...ar, ...e }, U = () => {
|
|
3723
3747
|
const W = {};
|
|
3724
3748
|
return y.trim() || (W.email = !0), k(W), Object.keys(W).length === 0;
|
|
3725
3749
|
}, b = () => {
|
|
3726
3750
|
const W = {};
|
|
3727
|
-
return
|
|
3728
|
-
},
|
|
3751
|
+
return L.trim() || (W.token = !0), T.trim() || (W.newPassword = !0), N.trim() || (W.confirmPassword = !0), k(W), Object.keys(W).length === 0;
|
|
3752
|
+
}, p = async (W) => {
|
|
3729
3753
|
if (W.preventDefault(), !!U()) {
|
|
3730
3754
|
if (!(z != null && z.id)) {
|
|
3731
|
-
|
|
3755
|
+
F(D.tenantNotFoundError);
|
|
3732
3756
|
return;
|
|
3733
3757
|
}
|
|
3734
|
-
|
|
3758
|
+
u(!0), F(""), w("");
|
|
3735
3759
|
try {
|
|
3736
3760
|
await I({ email: y, tenantId: z.id }), w(D.successMessage), i == null || i();
|
|
3737
3761
|
} catch (q) {
|
|
3738
3762
|
const V = q.message || D.errorMessage;
|
|
3739
|
-
|
|
3763
|
+
F(V), o == null || o(V);
|
|
3740
3764
|
} finally {
|
|
3741
|
-
|
|
3765
|
+
u(!1);
|
|
3742
3766
|
}
|
|
3743
3767
|
}
|
|
3744
3768
|
}, S = async (W) => {
|
|
3745
3769
|
if (W.preventDefault(), !!b()) {
|
|
3746
|
-
if (T !==
|
|
3747
|
-
|
|
3770
|
+
if (T !== N) {
|
|
3771
|
+
F(D.passwordMismatchError), k({ confirmPassword: !0 });
|
|
3748
3772
|
return;
|
|
3749
3773
|
}
|
|
3750
|
-
|
|
3774
|
+
u(!0), F(""), w("");
|
|
3751
3775
|
try {
|
|
3752
|
-
await l({ token:
|
|
3776
|
+
await l({ token: L, newPassword: T }), w(D.resetSuccessMessage), i == null || i();
|
|
3753
3777
|
} catch (q) {
|
|
3754
3778
|
const V = q.message || D.errorMessage;
|
|
3755
|
-
|
|
3779
|
+
F(V), o == null || o(V);
|
|
3756
3780
|
} finally {
|
|
3757
|
-
|
|
3781
|
+
u(!1);
|
|
3758
3782
|
}
|
|
3759
3783
|
}
|
|
3760
3784
|
}, E = (W) => ({
|
|
3761
|
-
...
|
|
3762
|
-
...R[W] ?
|
|
3785
|
+
...g.input,
|
|
3786
|
+
...R[W] ? g.inputError : {}
|
|
3763
3787
|
}), K = () => ({
|
|
3764
|
-
...
|
|
3765
|
-
...P ?
|
|
3788
|
+
...g.button,
|
|
3789
|
+
...P ? g.buttonLoading : {}
|
|
3766
3790
|
});
|
|
3767
3791
|
if (t === "reset") {
|
|
3768
|
-
const W =
|
|
3769
|
-
return /* @__PURE__ */
|
|
3770
|
-
/* @__PURE__ */ s("h2", { style:
|
|
3771
|
-
/* @__PURE__ */ s("p", { style:
|
|
3772
|
-
/* @__PURE__ */
|
|
3773
|
-
/* @__PURE__ */
|
|
3774
|
-
/* @__PURE__ */ s("label", { style:
|
|
3792
|
+
const W = L && T && N;
|
|
3793
|
+
return /* @__PURE__ */ h("div", { className: f, style: g.container, children: [
|
|
3794
|
+
/* @__PURE__ */ s("h2", { style: g.title, children: D.resetTitle }),
|
|
3795
|
+
/* @__PURE__ */ s("p", { style: g.subtitle, children: D.resetSubtitle }),
|
|
3796
|
+
/* @__PURE__ */ h("form", { onSubmit: S, style: g.form, children: [
|
|
3797
|
+
/* @__PURE__ */ h("div", { style: g.fieldGroup, children: [
|
|
3798
|
+
/* @__PURE__ */ s("label", { style: g.label, children: D.tokenLabel }),
|
|
3775
3799
|
/* @__PURE__ */ s(
|
|
3776
3800
|
"input",
|
|
3777
3801
|
{
|
|
3778
3802
|
type: "text",
|
|
3779
|
-
value:
|
|
3803
|
+
value: L,
|
|
3780
3804
|
onChange: (q) => {
|
|
3781
|
-
|
|
3805
|
+
m(q.target.value), R.token && k((V) => ({ ...V, token: !1 }));
|
|
3782
3806
|
},
|
|
3783
3807
|
placeholder: D.tokenPlaceholder,
|
|
3784
3808
|
style: E("token"),
|
|
@@ -3786,8 +3810,8 @@ function Qr({
|
|
|
3786
3810
|
}
|
|
3787
3811
|
)
|
|
3788
3812
|
] }),
|
|
3789
|
-
/* @__PURE__ */
|
|
3790
|
-
/* @__PURE__ */ s("label", { style:
|
|
3813
|
+
/* @__PURE__ */ h("div", { style: g.fieldGroup, children: [
|
|
3814
|
+
/* @__PURE__ */ s("label", { style: g.label, children: D.newPasswordLabel }),
|
|
3791
3815
|
/* @__PURE__ */ s(
|
|
3792
3816
|
"input",
|
|
3793
3817
|
{
|
|
@@ -3802,15 +3826,15 @@ function Qr({
|
|
|
3802
3826
|
}
|
|
3803
3827
|
)
|
|
3804
3828
|
] }),
|
|
3805
|
-
/* @__PURE__ */
|
|
3806
|
-
/* @__PURE__ */ s("label", { style:
|
|
3829
|
+
/* @__PURE__ */ h("div", { style: g.fieldGroup, children: [
|
|
3830
|
+
/* @__PURE__ */ s("label", { style: g.label, children: D.confirmPasswordLabel }),
|
|
3807
3831
|
/* @__PURE__ */ s(
|
|
3808
3832
|
"input",
|
|
3809
3833
|
{
|
|
3810
3834
|
type: "password",
|
|
3811
|
-
value:
|
|
3835
|
+
value: N,
|
|
3812
3836
|
onChange: (q) => {
|
|
3813
|
-
M(q.target.value), R.confirmPassword && k((V) => ({ ...V, confirmPassword: !1 })), v === D.passwordMismatchError &&
|
|
3837
|
+
M(q.target.value), R.confirmPassword && k((V) => ({ ...V, confirmPassword: !1 })), v === D.passwordMismatchError && F("");
|
|
3814
3838
|
},
|
|
3815
3839
|
placeholder: D.confirmPasswordPlaceholder,
|
|
3816
3840
|
style: E("confirmPassword"),
|
|
@@ -3825,37 +3849,37 @@ function Qr({
|
|
|
3825
3849
|
disabled: !W || P,
|
|
3826
3850
|
style: {
|
|
3827
3851
|
...K(),
|
|
3828
|
-
...!W || P ?
|
|
3852
|
+
...!W || P ? g.buttonDisabled : {}
|
|
3829
3853
|
},
|
|
3830
3854
|
children: P ? D.resetLoadingText : D.resetSubmitButton
|
|
3831
3855
|
}
|
|
3832
3856
|
),
|
|
3833
|
-
v && /* @__PURE__ */ s("div", { style:
|
|
3834
|
-
B && /* @__PURE__ */ s("div", { style:
|
|
3857
|
+
v && /* @__PURE__ */ s("div", { style: g.errorText, children: v }),
|
|
3858
|
+
B && /* @__PURE__ */ s("div", { style: g.successText, children: B })
|
|
3835
3859
|
] }),
|
|
3836
|
-
/* @__PURE__ */
|
|
3837
|
-
/* @__PURE__ */ s("a", { onClick: a, style:
|
|
3838
|
-
|
|
3839
|
-
/* @__PURE__ */ s("span", { style:
|
|
3840
|
-
/* @__PURE__ */ s("a", { onClick: () =>
|
|
3860
|
+
/* @__PURE__ */ h("div", { style: g.linkContainer, children: [
|
|
3861
|
+
/* @__PURE__ */ s("a", { onClick: a, style: g.link, children: D.backToLoginLink }),
|
|
3862
|
+
d && /* @__PURE__ */ h(_, { children: [
|
|
3863
|
+
/* @__PURE__ */ s("span", { style: g.modeSwitchDivider, children: D.dividerBullet }),
|
|
3864
|
+
/* @__PURE__ */ s("a", { onClick: () => d("request"), style: g.link, children: D.requestNewLinkLink })
|
|
3841
3865
|
] })
|
|
3842
3866
|
] })
|
|
3843
3867
|
] });
|
|
3844
3868
|
}
|
|
3845
3869
|
const G = y;
|
|
3846
|
-
return /* @__PURE__ */
|
|
3847
|
-
/* @__PURE__ */ s("h2", { style:
|
|
3848
|
-
/* @__PURE__ */ s("p", { style:
|
|
3849
|
-
/* @__PURE__ */
|
|
3850
|
-
/* @__PURE__ */
|
|
3851
|
-
/* @__PURE__ */ s("label", { style:
|
|
3870
|
+
return /* @__PURE__ */ h("div", { className: f, style: g.container, children: [
|
|
3871
|
+
/* @__PURE__ */ s("h2", { style: g.title, children: D.title }),
|
|
3872
|
+
/* @__PURE__ */ s("p", { style: g.subtitle, children: D.subtitle }),
|
|
3873
|
+
/* @__PURE__ */ h("form", { onSubmit: p, style: g.form, children: [
|
|
3874
|
+
/* @__PURE__ */ h("div", { style: g.fieldGroup, children: [
|
|
3875
|
+
/* @__PURE__ */ s("label", { style: g.label, children: D.emailLabel }),
|
|
3852
3876
|
/* @__PURE__ */ s(
|
|
3853
3877
|
"input",
|
|
3854
3878
|
{
|
|
3855
3879
|
type: "email",
|
|
3856
3880
|
value: y,
|
|
3857
3881
|
onChange: (W) => {
|
|
3858
|
-
|
|
3882
|
+
c(W.target.value), R.email && k((q) => ({ ...q, email: !1 }));
|
|
3859
3883
|
},
|
|
3860
3884
|
placeholder: D.emailPlaceholder,
|
|
3861
3885
|
style: E("email"),
|
|
@@ -3870,19 +3894,19 @@ function Qr({
|
|
|
3870
3894
|
disabled: !G || P,
|
|
3871
3895
|
style: {
|
|
3872
3896
|
...K(),
|
|
3873
|
-
...!G || P ?
|
|
3897
|
+
...!G || P ? g.buttonDisabled : {}
|
|
3874
3898
|
},
|
|
3875
3899
|
children: P ? D.loadingText : D.submitButton
|
|
3876
3900
|
}
|
|
3877
3901
|
),
|
|
3878
|
-
v && /* @__PURE__ */ s("div", { style:
|
|
3879
|
-
B && /* @__PURE__ */ s("div", { style:
|
|
3902
|
+
v && /* @__PURE__ */ s("div", { style: g.errorText, children: v }),
|
|
3903
|
+
B && /* @__PURE__ */ s("div", { style: g.successText, children: B })
|
|
3880
3904
|
] }),
|
|
3881
|
-
/* @__PURE__ */
|
|
3882
|
-
/* @__PURE__ */ s("a", { onClick: a, style:
|
|
3883
|
-
|
|
3884
|
-
/* @__PURE__ */ s("span", { style:
|
|
3885
|
-
/* @__PURE__ */ s("a", { onClick: () =>
|
|
3905
|
+
/* @__PURE__ */ h("div", { style: g.linkContainer, children: [
|
|
3906
|
+
/* @__PURE__ */ s("a", { onClick: a, style: g.link, children: D.backToLoginLink }),
|
|
3907
|
+
d && /* @__PURE__ */ h(_, { children: [
|
|
3908
|
+
/* @__PURE__ */ s("span", { style: g.modeSwitchDivider, children: D.dividerBullet }),
|
|
3909
|
+
/* @__PURE__ */ s("a", { onClick: () => d("reset"), style: g.link, children: D.haveTokenLink })
|
|
3886
3910
|
] })
|
|
3887
3911
|
] })
|
|
3888
3912
|
] });
|
|
@@ -3899,7 +3923,7 @@ const lr = () => /* @__PURE__ */ s(
|
|
|
3899
3923
|
},
|
|
3900
3924
|
children: /* @__PURE__ */ s("div", { children: "Loading..." })
|
|
3901
3925
|
}
|
|
3902
|
-
), cr = ({ error: n, retry: e }) => /* @__PURE__ */
|
|
3926
|
+
), cr = ({ error: n, retry: e }) => /* @__PURE__ */ h(
|
|
3903
3927
|
"div",
|
|
3904
3928
|
{
|
|
3905
3929
|
style: {
|
|
@@ -3933,15 +3957,15 @@ const lr = () => /* @__PURE__ */ s(
|
|
|
3933
3957
|
]
|
|
3934
3958
|
}
|
|
3935
3959
|
);
|
|
3936
|
-
function
|
|
3960
|
+
function Jr({
|
|
3937
3961
|
children: n,
|
|
3938
3962
|
loadingFallback: e,
|
|
3939
3963
|
errorFallback: t,
|
|
3940
3964
|
requireTenant: r = !0
|
|
3941
3965
|
}) {
|
|
3942
|
-
const { isAppLoading: i, appError: o, retryApp: a } = Ae(),
|
|
3943
|
-
}),
|
|
3944
|
-
o && a(),
|
|
3966
|
+
const { isAppLoading: i, appError: o, retryApp: a } = Ae(), d = pe(), f = $e(), y = Ye(), c = Xe(), L = (d == null ? void 0 : d.isTenantLoading) ?? !1, m = (d == null ? void 0 : d.tenantError) ?? null, T = (d == null ? void 0 : d.tenantSlug) ?? null, A = (d == null ? void 0 : d.retryTenant) ?? (() => {
|
|
3967
|
+
}), N = (f == null ? void 0 : f.isAuthReady) ?? !0, M = (y == null ? void 0 : y.isReady) ?? !0, P = (c == null ? void 0 : c.isReady) ?? !0, u = r && d && T, w = i || u && L || f && !N || y && !M || c && !P, R = o || (u ? m : null), k = () => {
|
|
3968
|
+
o && a(), m && d && A();
|
|
3945
3969
|
};
|
|
3946
3970
|
if (w)
|
|
3947
3971
|
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(lr, {}) });
|
|
@@ -3951,22 +3975,22 @@ function Zr({
|
|
|
3951
3975
|
}
|
|
3952
3976
|
return /* @__PURE__ */ s(_, { children: n });
|
|
3953
3977
|
}
|
|
3954
|
-
function
|
|
3955
|
-
const { isAppLoading: e, appError: t, retryApp: r, appInfo: i } = Ae(), o = pe(), a = $e(),
|
|
3956
|
-
}), A = (a == null ? void 0 : a.isAuthReady) ?? !0,
|
|
3978
|
+
function Zr(n = !0) {
|
|
3979
|
+
const { isAppLoading: e, appError: t, retryApp: r, appInfo: i } = Ae(), o = pe(), a = $e(), d = Ye(), f = Xe(), y = (o == null ? void 0 : o.isTenantLoading) ?? !1, c = (o == null ? void 0 : o.tenantError) ?? null, L = (o == null ? void 0 : o.tenant) ?? null, m = (o == null ? void 0 : o.tenantSlug) ?? null, T = (o == null ? void 0 : o.retryTenant) ?? (() => {
|
|
3980
|
+
}), A = (a == null ? void 0 : a.isAuthReady) ?? !0, N = (d == null ? void 0 : d.isReady) ?? !0, M = (f == null ? void 0 : f.isReady) ?? !0, P = n && o && m, B = e || P && y || a && !A || d && !N || f && !M, w = t || (P ? c : null);
|
|
3957
3981
|
return {
|
|
3958
3982
|
isLoading: B,
|
|
3959
3983
|
error: w,
|
|
3960
|
-
isReady: !B && !w && i !== null && (!P ||
|
|
3984
|
+
isReady: !B && !w && i !== null && (!P || L !== null),
|
|
3961
3985
|
retry: () => {
|
|
3962
|
-
t && r(),
|
|
3986
|
+
t && r(), c && o && T();
|
|
3963
3987
|
},
|
|
3964
3988
|
// Individual states
|
|
3965
3989
|
app: { isLoading: e, error: t, data: i },
|
|
3966
|
-
tenant: o ? { isLoading: y, error:
|
|
3990
|
+
tenant: o ? { isLoading: y, error: c, data: L } : null,
|
|
3967
3991
|
auth: a ? { isReady: A } : null,
|
|
3968
|
-
featureFlags:
|
|
3969
|
-
subscription:
|
|
3992
|
+
featureFlags: d ? { isReady: N } : null,
|
|
3993
|
+
subscription: f ? { isReady: M } : null
|
|
3970
3994
|
};
|
|
3971
3995
|
}
|
|
3972
3996
|
const dr = {
|
|
@@ -4021,74 +4045,74 @@ function Yr({
|
|
|
4021
4045
|
className: i = "",
|
|
4022
4046
|
dropdownClassName: o = "",
|
|
4023
4047
|
itemClassName: a = "",
|
|
4024
|
-
renderItem:
|
|
4025
|
-
placeholder:
|
|
4048
|
+
renderItem: d,
|
|
4049
|
+
placeholder: f = "Select tenant",
|
|
4026
4050
|
disabled: y = !1,
|
|
4027
|
-
showCurrentTenant:
|
|
4051
|
+
showCurrentTenant: c = !0
|
|
4028
4052
|
}) {
|
|
4029
4053
|
var B;
|
|
4030
|
-
const
|
|
4031
|
-
A(!1), t ? t(w) :
|
|
4054
|
+
const L = { ...dr, ...r }, m = $e(), [T, A] = x(!1), N = Ne(null), M = n ?? (m == null ? void 0 : m.userTenants) ?? [], P = e ?? ((B = m == null ? void 0 : m.currentUser) == null ? void 0 : B.tenantId) ?? null, u = async (w) => {
|
|
4055
|
+
A(!1), t ? t(w) : m != null && m.switchToTenant && await m.switchToTenant(w);
|
|
4032
4056
|
};
|
|
4033
4057
|
ne(() => {
|
|
4034
4058
|
const w = (R) => {
|
|
4035
|
-
|
|
4059
|
+
N.current && !N.current.contains(R.target) && A(!1);
|
|
4036
4060
|
};
|
|
4037
4061
|
return document.addEventListener("mousedown", w), () => document.removeEventListener("mousedown", w);
|
|
4038
4062
|
}, []);
|
|
4039
4063
|
const v = M.find((w) => w.id === P);
|
|
4040
4064
|
if (M.length === 0)
|
|
4041
4065
|
return null;
|
|
4042
|
-
if (M.length === 1 &&
|
|
4066
|
+
if (M.length === 1 && c)
|
|
4043
4067
|
return /* @__PURE__ */ s("div", { className: i, children: /* @__PURE__ */ s("span", { children: M[0].name }) });
|
|
4044
|
-
const
|
|
4068
|
+
const F = (w, R) => /* @__PURE__ */ h("span", { style: { fontWeight: R ? "bold" : "normal" }, children: [
|
|
4045
4069
|
w.name,
|
|
4046
|
-
w.role && /* @__PURE__ */
|
|
4070
|
+
w.role && /* @__PURE__ */ h("span", { style: L.itemRole, children: [
|
|
4047
4071
|
"(",
|
|
4048
4072
|
w.role,
|
|
4049
4073
|
")"
|
|
4050
4074
|
] })
|
|
4051
4075
|
] });
|
|
4052
|
-
return /* @__PURE__ */
|
|
4053
|
-
/* @__PURE__ */
|
|
4076
|
+
return /* @__PURE__ */ h("div", { ref: N, className: i, style: L.wrapper, children: [
|
|
4077
|
+
/* @__PURE__ */ h(
|
|
4054
4078
|
"button",
|
|
4055
4079
|
{
|
|
4056
4080
|
type: "button",
|
|
4057
4081
|
onClick: () => !y && A(!T),
|
|
4058
4082
|
disabled: y,
|
|
4059
4083
|
style: {
|
|
4060
|
-
...
|
|
4061
|
-
...y ?
|
|
4084
|
+
...L.button,
|
|
4085
|
+
...y ? L.buttonDisabled : {}
|
|
4062
4086
|
},
|
|
4063
4087
|
children: [
|
|
4064
|
-
v ? v.name :
|
|
4065
|
-
/* @__PURE__ */ s("span", { style:
|
|
4088
|
+
v ? v.name : f,
|
|
4089
|
+
/* @__PURE__ */ s("span", { style: L.arrow, children: T ? "▲" : "▼" })
|
|
4066
4090
|
]
|
|
4067
4091
|
}
|
|
4068
4092
|
),
|
|
4069
|
-
T && /* @__PURE__ */ s("div", { className: o, style:
|
|
4093
|
+
T && /* @__PURE__ */ s("div", { className: o, style: L.dropdown, children: M.map((w) => {
|
|
4070
4094
|
const R = w.id === P;
|
|
4071
4095
|
return /* @__PURE__ */ s(
|
|
4072
4096
|
"div",
|
|
4073
4097
|
{
|
|
4074
4098
|
className: a,
|
|
4075
|
-
onClick: () =>
|
|
4099
|
+
onClick: () => u(w.id),
|
|
4076
4100
|
style: {
|
|
4077
|
-
...
|
|
4078
|
-
...R ?
|
|
4101
|
+
...L.item,
|
|
4102
|
+
...R ? L.itemSelected : {}
|
|
4079
4103
|
},
|
|
4080
4104
|
onMouseEnter: (k) => {
|
|
4081
|
-
R || Object.assign(k.currentTarget.style,
|
|
4105
|
+
R || Object.assign(k.currentTarget.style, L.itemHover);
|
|
4082
4106
|
},
|
|
4083
4107
|
onMouseLeave: (k) => {
|
|
4084
4108
|
if (!R) {
|
|
4085
|
-
const I =
|
|
4086
|
-
Object.keys(
|
|
4109
|
+
const I = L.item || {};
|
|
4110
|
+
Object.keys(L.itemHover || {}).forEach((l) => {
|
|
4087
4111
|
k.currentTarget.style[l] = I[l] ?? "";
|
|
4088
4112
|
});
|
|
4089
4113
|
}
|
|
4090
4114
|
},
|
|
4091
|
-
children:
|
|
4115
|
+
children: d ? d(w, R) : F(w, R)
|
|
4092
4116
|
},
|
|
4093
4117
|
w.id
|
|
4094
4118
|
);
|
|
@@ -4351,7 +4375,7 @@ function nn(n = {}) {
|
|
|
4351
4375
|
zoneRoots: e = {},
|
|
4352
4376
|
returnToParam: t = rt,
|
|
4353
4377
|
returnToStorage: r = "url"
|
|
4354
|
-
} = n, i = mt(), [o, a] = yt(), { isAuthenticated:
|
|
4378
|
+
} = n, i = mt(), [o, a] = yt(), { isAuthenticated: d, currentUser: f } = he(), { tenant: y } = Te(), c = J(() => ({ ...Oe, ...e }), [e]), L = !!y, m = f == null ? void 0 : f.userType, T = J(() => {
|
|
4355
4379
|
switch (r) {
|
|
4356
4380
|
case "url":
|
|
4357
4381
|
return o.get(t);
|
|
@@ -4365,8 +4389,8 @@ function nn(n = {}) {
|
|
|
4365
4389
|
}, [r, o, t]), A = oe(() => {
|
|
4366
4390
|
switch (r) {
|
|
4367
4391
|
case "url": {
|
|
4368
|
-
const
|
|
4369
|
-
|
|
4392
|
+
const u = new URLSearchParams(o);
|
|
4393
|
+
u.delete(t), a(u, { replace: !0 });
|
|
4370
4394
|
break;
|
|
4371
4395
|
}
|
|
4372
4396
|
case "session":
|
|
@@ -4376,34 +4400,34 @@ function nn(n = {}) {
|
|
|
4376
4400
|
localStorage.removeItem(Le);
|
|
4377
4401
|
break;
|
|
4378
4402
|
}
|
|
4379
|
-
}, [r, o, t, a]),
|
|
4380
|
-
(
|
|
4403
|
+
}, [r, o, t, a]), N = oe(
|
|
4404
|
+
(u) => {
|
|
4381
4405
|
switch (r) {
|
|
4382
4406
|
case "url": {
|
|
4383
4407
|
const v = new URLSearchParams(o);
|
|
4384
|
-
v.set(t,
|
|
4408
|
+
v.set(t, u), a(v, { replace: !0 });
|
|
4385
4409
|
break;
|
|
4386
4410
|
}
|
|
4387
4411
|
case "session":
|
|
4388
|
-
sessionStorage.setItem(Me,
|
|
4412
|
+
sessionStorage.setItem(Me, u);
|
|
4389
4413
|
break;
|
|
4390
4414
|
case "local":
|
|
4391
|
-
localStorage.setItem(Le,
|
|
4415
|
+
localStorage.setItem(Le, u);
|
|
4392
4416
|
break;
|
|
4393
4417
|
}
|
|
4394
4418
|
},
|
|
4395
4419
|
[r, o, t, a]
|
|
4396
4420
|
), M = oe(
|
|
4397
|
-
(
|
|
4398
|
-
const v =
|
|
4421
|
+
(u) => {
|
|
4422
|
+
const v = c[u] || c.default;
|
|
4399
4423
|
i(v);
|
|
4400
4424
|
},
|
|
4401
|
-
[i,
|
|
4402
|
-
), P = oe(() =>
|
|
4425
|
+
[i, c]
|
|
4426
|
+
), P = oe(() => L ? d ? m === ae.TENANT_ADMIN ? c.tenantAdmin : c.tenantUser : c.tenantGuest : d ? m === ae.TENANT_ADMIN ? c.publicAdmin : c.publicUser : c.publicGuest, [L, d, m, c]);
|
|
4403
4427
|
return {
|
|
4404
4428
|
returnToUrl: T,
|
|
4405
4429
|
clearReturnTo: A,
|
|
4406
|
-
setReturnTo:
|
|
4430
|
+
setReturnTo: N,
|
|
4407
4431
|
navigateToZone: M,
|
|
4408
4432
|
getSmartRedirect: P
|
|
4409
4433
|
};
|
|
@@ -4418,7 +4442,7 @@ export {
|
|
|
4418
4442
|
$r as AdminZone,
|
|
4419
4443
|
rn as ApiMappers,
|
|
4420
4444
|
Ve as AppApiService,
|
|
4421
|
-
|
|
4445
|
+
Jr as AppLoader,
|
|
4422
4446
|
br as AppProvider,
|
|
4423
4447
|
vt as AuthApiService,
|
|
4424
4448
|
xr as AuthProvider,
|
|
@@ -4467,7 +4491,7 @@ export {
|
|
|
4467
4491
|
sn as buildRedirectUrl,
|
|
4468
4492
|
vr as useApi,
|
|
4469
4493
|
Ae as useApp,
|
|
4470
|
-
|
|
4494
|
+
Zr as useAppLoaderState,
|
|
4471
4495
|
he as useAuth,
|
|
4472
4496
|
Mt as useFeatureFlags,
|
|
4473
4497
|
Er as useRouting,
|
|
@@ -4475,7 +4499,7 @@ export {
|
|
|
4475
4499
|
kr as useSettings,
|
|
4476
4500
|
Nt as useSubscription,
|
|
4477
4501
|
Te as useTenant,
|
|
4478
|
-
|
|
4502
|
+
Ze as useTenantInfo,
|
|
4479
4503
|
pe as useTenantOptional,
|
|
4480
4504
|
Tr as useTenantSettings,
|
|
4481
4505
|
nn as useZoneNavigation
|