@skylabs-digital/react-identity-access 2.26.0 → 2.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/LoginForm.d.ts.map +1 -1
- package/dist/index.es.js +1374 -1353
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/providers/AuthProvider.d.ts +2 -0
- package/dist/providers/AuthProvider.d.ts.map +1 -1
- package/dist/services/AuthApiService.d.ts.map +1 -1
- package/dist/services/SessionManager.d.ts +2 -0
- package/dist/services/SessionManager.d.ts.map +1 -1
- package/dist/services/TenantApiService.d.ts +2 -2
- package/dist/services/TenantApiService.d.ts.map +1 -1
- package/dist/types/api.d.ts +2 -2
- package/dist/types/api.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as s, Fragment as _, jsxs as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { useLocation as
|
|
4
|
-
class
|
|
1
|
+
import { jsx as s, Fragment as _, jsxs as u } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as ye, useMemo as Z, useState as x, useCallback as oe, useEffect as ne, useContext as le, useRef as Ne } from "react";
|
|
3
|
+
import { useLocation as xe, Navigate as Se, useNavigate as mt, useSearchParams as yt } from "react-router-dom";
|
|
4
|
+
class de {
|
|
5
5
|
constructor(e, t = 1e4) {
|
|
6
6
|
this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
|
|
7
7
|
}
|
|
@@ -13,26 +13,26 @@ class le {
|
|
|
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 c = {
|
|
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
21
|
const f = await this.sessionManager.getValidAccessToken();
|
|
22
|
-
|
|
22
|
+
c = { ...c, Authorization: `Bearer ${f}` };
|
|
23
23
|
}
|
|
24
|
-
const
|
|
24
|
+
const m = new AbortController(), y = setTimeout(() => m.abort(), a);
|
|
25
25
|
try {
|
|
26
26
|
const f = await fetch(o, {
|
|
27
27
|
method: e,
|
|
28
|
-
headers:
|
|
28
|
+
headers: c,
|
|
29
29
|
body: r ? JSON.stringify(r) : void 0,
|
|
30
|
-
signal:
|
|
30
|
+
signal: m.signal
|
|
31
31
|
});
|
|
32
32
|
if (clearTimeout(y), !f.ok)
|
|
33
33
|
throw new Error(`HTTP ${f.status}: ${f.statusText}`);
|
|
34
|
-
const
|
|
35
|
-
return !
|
|
34
|
+
const F = f.headers.get("content-type");
|
|
35
|
+
return !F || !F.includes("application/json") ? {} : await f.json();
|
|
36
36
|
} catch (f) {
|
|
37
37
|
throw clearTimeout(y), f instanceof Error && f.name === "AbortError" ? new Error(`Request timeout after ${a}ms`) : f;
|
|
38
38
|
}
|
|
@@ -50,7 +50,7 @@ class le {
|
|
|
50
50
|
return this.executeRequest("DELETE", e, void 0, t);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
class
|
|
53
|
+
class Ve {
|
|
54
54
|
constructor(e, t) {
|
|
55
55
|
this.httpService = e, this.sessionManager = t;
|
|
56
56
|
}
|
|
@@ -109,31 +109,31 @@ class qe {
|
|
|
109
109
|
})).data;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
const
|
|
113
|
-
function
|
|
114
|
-
const t =
|
|
112
|
+
const Fe = ye(null);
|
|
113
|
+
function br({ config: n, children: e }) {
|
|
114
|
+
const t = Z(
|
|
115
115
|
() => {
|
|
116
|
-
var
|
|
116
|
+
var g, T, A;
|
|
117
117
|
return {
|
|
118
|
-
enabled: ((
|
|
119
|
-
ttl: ((
|
|
118
|
+
enabled: ((g = n.cache) == null ? void 0 : g.enabled) ?? !0,
|
|
119
|
+
ttl: ((T = n.cache) == null ? void 0 : T.ttl) ?? 3e5,
|
|
120
120
|
// 5 minutes default
|
|
121
|
-
storageKey: ((
|
|
121
|
+
storageKey: ((A = n.cache) == null ? void 0 : A.storageKey) ?? `app_cache_${n.appId}`
|
|
122
122
|
};
|
|
123
123
|
},
|
|
124
124
|
[n.cache, n.appId]
|
|
125
|
-
), [r, i] =
|
|
125
|
+
), [r, i] = x(() => {
|
|
126
126
|
if (!t.enabled) return null;
|
|
127
127
|
try {
|
|
128
|
-
const
|
|
129
|
-
if (!
|
|
130
|
-
const
|
|
131
|
-
return Date.now() -
|
|
128
|
+
const g = localStorage.getItem(t.storageKey);
|
|
129
|
+
if (!g) return null;
|
|
130
|
+
const T = JSON.parse(g);
|
|
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] =
|
|
136
|
-
const
|
|
135
|
+
}), [o, a] = x(!r), [c, m] = x(null), y = Z(() => {
|
|
136
|
+
const g = () => {
|
|
137
137
|
f();
|
|
138
138
|
};
|
|
139
139
|
return {
|
|
@@ -142,69 +142,69 @@ function mr({ config: n, children: e }) {
|
|
|
142
142
|
// App info
|
|
143
143
|
appInfo: r,
|
|
144
144
|
isAppLoading: o,
|
|
145
|
-
appError:
|
|
146
|
-
retryApp:
|
|
145
|
+
appError: c,
|
|
146
|
+
retryApp: g
|
|
147
147
|
};
|
|
148
|
-
}, [n, r, o,
|
|
149
|
-
async (
|
|
150
|
-
if (!(!
|
|
148
|
+
}, [n, r, o, c]), f = oe(
|
|
149
|
+
async (g = !1) => {
|
|
150
|
+
if (!(!g && t.enabled && r))
|
|
151
151
|
try {
|
|
152
|
-
a(!0),
|
|
153
|
-
const
|
|
154
|
-
if (i(
|
|
152
|
+
a(!0), m(null);
|
|
153
|
+
const T = new de(n.baseUrl), L = await new Ve(T, {}).getPublicAppInfo(n.appId);
|
|
154
|
+
if (i(L), t.enabled)
|
|
155
155
|
try {
|
|
156
|
-
const
|
|
157
|
-
data:
|
|
156
|
+
const M = {
|
|
157
|
+
data: L,
|
|
158
158
|
timestamp: Date.now(),
|
|
159
159
|
appId: n.appId
|
|
160
160
|
};
|
|
161
|
-
localStorage.setItem(t.storageKey, JSON.stringify(
|
|
162
|
-
} catch (
|
|
163
|
-
process.env.NODE_ENV === "development" && console.warn("[AppProvider] Failed to cache app info:",
|
|
161
|
+
localStorage.setItem(t.storageKey, JSON.stringify(M));
|
|
162
|
+
} catch (M) {
|
|
163
|
+
process.env.NODE_ENV === "development" && console.warn("[AppProvider] Failed to cache app info:", M);
|
|
164
164
|
}
|
|
165
|
-
} catch (
|
|
166
|
-
const
|
|
167
|
-
|
|
165
|
+
} catch (T) {
|
|
166
|
+
const A = T instanceof Error ? T : new Error("Failed to load app information");
|
|
167
|
+
m(A), i(null);
|
|
168
168
|
} finally {
|
|
169
169
|
a(!1);
|
|
170
170
|
}
|
|
171
171
|
},
|
|
172
172
|
[n.baseUrl, n.appId, t, r]
|
|
173
|
-
),
|
|
173
|
+
), F = oe(async () => {
|
|
174
174
|
if (!(!t.enabled || !r))
|
|
175
175
|
try {
|
|
176
|
-
const
|
|
177
|
-
if (!
|
|
178
|
-
const
|
|
179
|
-
if (Date.now() -
|
|
180
|
-
const
|
|
176
|
+
const g = localStorage.getItem(t.storageKey);
|
|
177
|
+
if (!g) return;
|
|
178
|
+
const T = JSON.parse(g);
|
|
179
|
+
if (Date.now() - T.timestamp > t.ttl * 0.5) {
|
|
180
|
+
const L = new de(n.baseUrl), P = await new Ve(L, {}).getPublicAppInfo(n.appId);
|
|
181
181
|
i(P);
|
|
182
|
-
const
|
|
182
|
+
const d = {
|
|
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(d));
|
|
188
188
|
}
|
|
189
|
-
} catch (
|
|
190
|
-
process.env.NODE_ENV === "development" && console.warn("[AppProvider] Background app refresh failed:",
|
|
189
|
+
} catch (g) {
|
|
190
|
+
process.env.NODE_ENV === "development" && console.warn("[AppProvider] Background app refresh failed:", g);
|
|
191
191
|
}
|
|
192
192
|
}, [n, t, r]);
|
|
193
|
-
return
|
|
194
|
-
r ?
|
|
195
|
-
}, []), /* @__PURE__ */ s(
|
|
193
|
+
return ne(() => {
|
|
194
|
+
r ? F() : f();
|
|
195
|
+
}, []), /* @__PURE__ */ s(Fe.Provider, { value: y, children: e });
|
|
196
196
|
}
|
|
197
|
-
function
|
|
198
|
-
const n =
|
|
197
|
+
function Ae() {
|
|
198
|
+
const n = le(Fe);
|
|
199
199
|
if (!n)
|
|
200
200
|
throw new Error("useApp must be used within an AppProvider");
|
|
201
201
|
return n;
|
|
202
202
|
}
|
|
203
|
-
function
|
|
204
|
-
return
|
|
203
|
+
function De() {
|
|
204
|
+
return le(Fe);
|
|
205
205
|
}
|
|
206
|
-
const
|
|
207
|
-
class
|
|
206
|
+
const vr = Ae;
|
|
207
|
+
class se extends Error {
|
|
208
208
|
constructor(e, t) {
|
|
209
209
|
const r = {
|
|
210
210
|
token_expired: "Refresh token has expired",
|
|
@@ -214,12 +214,12 @@ class ne extends Error {
|
|
|
214
214
|
super(t || r[e]), this.name = "SessionExpiredError", this.reason = e;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
class
|
|
217
|
+
class wt extends Error {
|
|
218
218
|
constructor(e) {
|
|
219
219
|
super(`Token refresh timed out after ${e}ms`), this.name = "TokenRefreshTimeoutError", this.timeoutMs = e;
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
|
-
class
|
|
222
|
+
class bt extends Error {
|
|
223
223
|
constructor(e, t) {
|
|
224
224
|
super(
|
|
225
225
|
`Token refresh failed after ${e} attempts: ${(t == null ? void 0 : t.message) || "Unknown error"}`
|
|
@@ -228,7 +228,7 @@ class mt extends Error {
|
|
|
228
228
|
}
|
|
229
229
|
const ie = class ie {
|
|
230
230
|
constructor(e = {}) {
|
|
231
|
-
this.refreshPromise = null, this.refreshQueue = [], this.proactiveTimerId = null, this.backgroundRetryTimerId = null, this.isDestroyed = !1, this.sessionGeneration = 0, e.tenantSlug !== void 0 ? this.storageKey = e.tenantSlug ? `auth_tokens_${e.tenantSlug}` : "auth_tokens" : this.storageKey = e.storageKey || "auth_tokens", this.autoRefresh = e.autoRefresh ?? !0, this.refreshThreshold = e.refreshThreshold || 3e5, this.onRefreshFailed = e.onRefreshFailed, this.onSessionExpired = e.onSessionExpired, this.baseUrl = e.baseUrl || "", this.proactiveRefreshMargin = e.proactiveRefreshMargin ?? 6e4, this.refreshQueueTimeout = e.refreshQueueTimeout ?? 1e4, this.maxRefreshRetries = e.maxRefreshRetries ?? 3, this.retryBackoffBase = e.retryBackoffBase ?? 1e3, this.tokenStorage = e.tokenStorage || this.createTokenStorage(this.storageKey), this.scheduleProactiveRefresh();
|
|
231
|
+
this.refreshPromise = null, this.refreshQueue = [], this.proactiveTimerId = null, this.backgroundRetryTimerId = null, this.isDestroyed = !1, this.sessionGeneration = 0, this.consecutiveBackgroundFailures = 0, e.tenantSlug !== void 0 ? this.storageKey = e.tenantSlug ? `auth_tokens_${e.tenantSlug}` : "auth_tokens" : this.storageKey = e.storageKey || "auth_tokens", this.autoRefresh = e.autoRefresh ?? !0, this.refreshThreshold = e.refreshThreshold || 3e5, this.onRefreshFailed = e.onRefreshFailed, this.onSessionExpired = e.onSessionExpired, this.baseUrl = e.baseUrl || "", this.proactiveRefreshMargin = e.proactiveRefreshMargin ?? 6e4, this.refreshQueueTimeout = e.refreshQueueTimeout ?? 1e4, this.maxRefreshRetries = e.maxRefreshRetries ?? 3, this.retryBackoffBase = e.retryBackoffBase ?? 1e3, this.tokenStorage = e.tokenStorage || this.createTokenStorage(this.storageKey), this.scheduleProactiveRefresh();
|
|
232
232
|
}
|
|
233
233
|
/**
|
|
234
234
|
* Get or create a SessionManager instance for the given config.
|
|
@@ -353,13 +353,26 @@ const ie = class ie {
|
|
|
353
353
|
if (!(e != null && e.refreshToken) || this.refreshPromise) return;
|
|
354
354
|
const t = this.sessionGeneration;
|
|
355
355
|
this.startRefreshAndResolveQueue(e.refreshToken).then(() => {
|
|
356
|
+
this.consecutiveBackgroundFailures = 0;
|
|
356
357
|
}).catch((r) => {
|
|
357
|
-
r instanceof
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
358
|
+
if (!(r instanceof se)) {
|
|
359
|
+
if (this.sessionGeneration === t) {
|
|
360
|
+
if (this.consecutiveBackgroundFailures++, this.consecutiveBackgroundFailures >= ie.MAX_BACKGROUND_FAILURES) {
|
|
361
|
+
process.env.NODE_ENV === "development" && console.error(
|
|
362
|
+
`[SessionManager] Background refresh failed ${this.consecutiveBackgroundFailures} consecutive times — expiring session`
|
|
363
|
+
), this.consecutiveBackgroundFailures = 0, this.handleSessionExpired(
|
|
364
|
+
new se("token_invalid", "Background refresh failed repeatedly")
|
|
365
|
+
);
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
process.env.NODE_ENV === "development" && console.warn(
|
|
369
|
+
"[SessionManager] Background refresh failed, retrying in 30s:",
|
|
370
|
+
r.message
|
|
371
|
+
), this.backgroundRetryTimerId = setTimeout(() => {
|
|
372
|
+
this.backgroundRefresh();
|
|
373
|
+
}, 3e4);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
363
376
|
});
|
|
364
377
|
}
|
|
365
378
|
/**
|
|
@@ -386,13 +399,13 @@ const ie = class ie {
|
|
|
386
399
|
async getValidAccessToken() {
|
|
387
400
|
const e = this.getTokens();
|
|
388
401
|
if (!(e != null && e.accessToken)) {
|
|
389
|
-
const t = new
|
|
402
|
+
const t = new se("token_invalid", "No tokens available");
|
|
390
403
|
throw this.handleSessionExpired(t), t;
|
|
391
404
|
}
|
|
392
405
|
if (!this.shouldRefreshToken(e) && !this.isTokenExpired(e))
|
|
393
406
|
return e.accessToken;
|
|
394
407
|
if (!e.refreshToken) {
|
|
395
|
-
const t = new
|
|
408
|
+
const t = new se("token_invalid", "No refresh token available");
|
|
396
409
|
throw this.handleSessionExpired(t), t;
|
|
397
410
|
}
|
|
398
411
|
return this.refreshPromise ? this.enqueueForToken() : this.startRefreshAndResolveQueue(e.refreshToken);
|
|
@@ -404,14 +417,14 @@ const ie = class ie {
|
|
|
404
417
|
try {
|
|
405
418
|
return { Authorization: `Bearer ${await this.getValidAccessToken()}` };
|
|
406
419
|
} catch (e) {
|
|
407
|
-
return e instanceof
|
|
420
|
+
return e instanceof se && this.onRefreshFailed && this.onRefreshFailed(), {};
|
|
408
421
|
}
|
|
409
422
|
}
|
|
410
423
|
enqueueForToken() {
|
|
411
424
|
return new Promise((e, t) => {
|
|
412
425
|
const r = setTimeout(() => {
|
|
413
426
|
const i = this.refreshQueue.findIndex((o) => o.timeoutId === r);
|
|
414
|
-
i !== -1 && this.refreshQueue.splice(i, 1), t(new
|
|
427
|
+
i !== -1 && this.refreshQueue.splice(i, 1), t(new wt(this.refreshQueueTimeout));
|
|
415
428
|
}, this.refreshQueueTimeout);
|
|
416
429
|
this.refreshQueue.push({ resolve: e, reject: t, timeoutId: r });
|
|
417
430
|
});
|
|
@@ -424,7 +437,7 @@ const ie = class ie {
|
|
|
424
437
|
return this.resolveQueue(r), r;
|
|
425
438
|
} catch (t) {
|
|
426
439
|
const r = t instanceof Error ? t : new Error("Token refresh failed");
|
|
427
|
-
throw r instanceof
|
|
440
|
+
throw r instanceof se ? (this.rejectQueue(r), this.handleSessionExpired(r)) : this.rejectQueue(r), r;
|
|
428
441
|
} finally {
|
|
429
442
|
this.refreshPromise = null;
|
|
430
443
|
}
|
|
@@ -447,21 +460,21 @@ const ie = class ie {
|
|
|
447
460
|
const r = this.sessionGeneration;
|
|
448
461
|
for (let i = 0; i <= this.maxRefreshRetries; i++) {
|
|
449
462
|
if (this.sessionGeneration !== r)
|
|
450
|
-
throw new
|
|
463
|
+
throw new se("token_invalid", "Session cleared during refresh");
|
|
451
464
|
try {
|
|
452
465
|
await this.performTokenRefresh(e, r);
|
|
453
466
|
return;
|
|
454
467
|
} catch (o) {
|
|
455
468
|
const a = o instanceof Error ? o : new Error(String(o));
|
|
456
|
-
if (a instanceof
|
|
469
|
+
if (a instanceof se)
|
|
457
470
|
throw a;
|
|
458
471
|
if (t = a, i < this.maxRefreshRetries) {
|
|
459
|
-
const
|
|
460
|
-
await this.sleep(
|
|
472
|
+
const c = this.retryBackoffBase * Math.pow(2, i);
|
|
473
|
+
await this.sleep(c);
|
|
461
474
|
}
|
|
462
475
|
}
|
|
463
476
|
}
|
|
464
|
-
throw new
|
|
477
|
+
throw new bt(this.maxRefreshRetries + 1, t);
|
|
465
478
|
}
|
|
466
479
|
/**
|
|
467
480
|
* Single refresh attempt with error classification.
|
|
@@ -485,15 +498,15 @@ const ie = class ie {
|
|
|
485
498
|
if (!i.ok) {
|
|
486
499
|
let a = "";
|
|
487
500
|
try {
|
|
488
|
-
const
|
|
489
|
-
a = (
|
|
501
|
+
const c = await i.json();
|
|
502
|
+
a = (c.message || c.error || "").toLowerCase();
|
|
490
503
|
} catch {
|
|
491
504
|
a = i.statusText.toLowerCase();
|
|
492
505
|
}
|
|
493
|
-
throw i.status === 401 ? a.includes("expired") ? new
|
|
506
|
+
throw i.status === 401 ? a.includes("expired") ? new se("token_expired") : a.includes("invalid") ? new se("token_invalid") : new se("token_invalid", `Unauthorized: ${a}`) : i.status === 400 ? a.includes("inactive") ? new se("user_inactive") : a.includes("expired") || a.includes("invalid") ? new se("token_invalid", a) : a.includes("reuse") || a.includes("revoked") ? new se("token_invalid", a) : new Error(`Token refresh failed (400): ${a}`) : new Error(`Token refresh failed: ${i.status} ${a}`);
|
|
494
507
|
}
|
|
495
508
|
if (this.sessionGeneration !== t)
|
|
496
|
-
throw new
|
|
509
|
+
throw new se("token_invalid", "Session cleared during refresh");
|
|
497
510
|
const o = await i.json();
|
|
498
511
|
this.setTokens({
|
|
499
512
|
accessToken: o.accessToken,
|
|
@@ -521,7 +534,7 @@ const ie = class ie {
|
|
|
521
534
|
// --- Session lifecycle ---
|
|
522
535
|
clearSession() {
|
|
523
536
|
this.sessionGeneration++, this.cancelProactiveTimer(), this.clearTokens();
|
|
524
|
-
const e = new
|
|
537
|
+
const e = new se("token_invalid", "Session cleared");
|
|
525
538
|
this.rejectQueue(e);
|
|
526
539
|
}
|
|
527
540
|
/**
|
|
@@ -530,7 +543,7 @@ const ie = class ie {
|
|
|
530
543
|
*/
|
|
531
544
|
destroy() {
|
|
532
545
|
this.isDestroyed = !0, ie.instances.delete(this.storageKey), this.cancelProactiveTimer();
|
|
533
|
-
const e = new
|
|
546
|
+
const e = new se("token_invalid", "SessionManager destroyed");
|
|
534
547
|
this.rejectQueue(e);
|
|
535
548
|
}
|
|
536
549
|
// --- JWT helpers ---
|
|
@@ -568,9 +581,10 @@ const ie = class ie {
|
|
|
568
581
|
return new Promise((t) => setTimeout(t, e));
|
|
569
582
|
}
|
|
570
583
|
};
|
|
571
|
-
ie.instances = /* @__PURE__ */ new Map();
|
|
572
|
-
let
|
|
573
|
-
|
|
584
|
+
ie.instances = /* @__PURE__ */ new Map(), ie.MAX_BACKGROUND_FAILURES = 3;
|
|
585
|
+
let be = ie;
|
|
586
|
+
const Ie = /* @__PURE__ */ new Map();
|
|
587
|
+
class vt {
|
|
574
588
|
constructor(e) {
|
|
575
589
|
this.httpService = e;
|
|
576
590
|
}
|
|
@@ -611,10 +625,12 @@ class yt {
|
|
|
611
625
|
);
|
|
612
626
|
}
|
|
613
627
|
async verifyMagicLink(e) {
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
628
|
+
const t = e.token, r = Ie.get(t);
|
|
629
|
+
if (r) return r;
|
|
630
|
+
const i = this.httpService.post("/auth/magic-link/verify", e).finally(() => {
|
|
631
|
+
Ie.delete(t);
|
|
632
|
+
});
|
|
633
|
+
return Ie.set(t, i), i;
|
|
618
634
|
}
|
|
619
635
|
async confirmPasswordReset(e) {
|
|
620
636
|
await this.httpService.post("/auth/password-reset/confirm", e);
|
|
@@ -626,7 +642,7 @@ class yt {
|
|
|
626
642
|
});
|
|
627
643
|
}
|
|
628
644
|
}
|
|
629
|
-
class
|
|
645
|
+
class We {
|
|
630
646
|
constructor(e, t) {
|
|
631
647
|
this.httpService = e, this.sessionManager = t;
|
|
632
648
|
}
|
|
@@ -702,7 +718,7 @@ class ze {
|
|
|
702
718
|
};
|
|
703
719
|
}
|
|
704
720
|
}
|
|
705
|
-
class
|
|
721
|
+
class St {
|
|
706
722
|
constructor(e, t) {
|
|
707
723
|
this.httpService = e, this.sessionManager = t;
|
|
708
724
|
}
|
|
@@ -742,7 +758,7 @@ class wt {
|
|
|
742
758
|
});
|
|
743
759
|
}
|
|
744
760
|
}
|
|
745
|
-
class
|
|
761
|
+
class ve {
|
|
746
762
|
constructor(e, t, r) {
|
|
747
763
|
this.httpService = e, this.appId = t, this.sessionManager = r;
|
|
748
764
|
}
|
|
@@ -820,7 +836,7 @@ class be {
|
|
|
820
836
|
)).data;
|
|
821
837
|
}
|
|
822
838
|
}
|
|
823
|
-
function
|
|
839
|
+
function Tt(n, e) {
|
|
824
840
|
if (n === "localhost" || n.startsWith("127.") || n.startsWith("192.168."))
|
|
825
841
|
return null;
|
|
826
842
|
if (e) {
|
|
@@ -836,26 +852,26 @@ function bt(n, e) {
|
|
|
836
852
|
const r = n.split(".");
|
|
837
853
|
return r.length >= 3 && r[0] !== "www" ? r[0] : null;
|
|
838
854
|
}
|
|
839
|
-
function
|
|
855
|
+
function kt(n, e = "tenant", t) {
|
|
840
856
|
const i = new URLSearchParams(n).get(e);
|
|
841
857
|
return i ? (t && t.setItem("tenant", i), i) : t ? t.getItem("tenant") : null;
|
|
842
858
|
}
|
|
843
|
-
function
|
|
859
|
+
function xt(n, e, t) {
|
|
844
860
|
const { tenantMode: r, baseDomain: i, selectorParam: o, fixedTenantSlug: a } = n;
|
|
845
|
-
return r === "fixed" ? a || null : r === "subdomain" ?
|
|
861
|
+
return r === "fixed" ? a || null : r === "subdomain" ? Tt(e.hostname, i) : r === "selector" ? kt(e.search, o, t) : null;
|
|
846
862
|
}
|
|
847
|
-
function
|
|
863
|
+
function At(n, e, t) {
|
|
848
864
|
if (t)
|
|
849
865
|
return `${n}.${t}`;
|
|
850
866
|
const r = e.split(".");
|
|
851
867
|
return r.length === 2 ? `${n}.${e}` : r.length >= 3 ? (r[0] = n, r.join(".")) : null;
|
|
852
868
|
}
|
|
853
|
-
const
|
|
854
|
-
function
|
|
869
|
+
const me = "_auth";
|
|
870
|
+
function je(n) {
|
|
855
871
|
const e = JSON.stringify(n);
|
|
856
872
|
return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
857
873
|
}
|
|
858
|
-
function
|
|
874
|
+
function Pt(n) {
|
|
859
875
|
try {
|
|
860
876
|
let e = n.replace(/-/g, "+").replace(/_/g, "/");
|
|
861
877
|
for (; e.length % 4; )
|
|
@@ -866,20 +882,20 @@ function kt(n) {
|
|
|
866
882
|
return null;
|
|
867
883
|
}
|
|
868
884
|
}
|
|
869
|
-
function
|
|
885
|
+
function Rt() {
|
|
870
886
|
if (typeof window > "u")
|
|
871
887
|
return null;
|
|
872
|
-
const e = new URLSearchParams(window.location.search).get(
|
|
873
|
-
return e ?
|
|
888
|
+
const e = new URLSearchParams(window.location.search).get(me);
|
|
889
|
+
return e ? Pt(e) : null;
|
|
874
890
|
}
|
|
875
|
-
function
|
|
891
|
+
function Et() {
|
|
876
892
|
if (typeof window > "u") return;
|
|
877
893
|
const n = new URL(window.location.href);
|
|
878
|
-
n.searchParams.delete(
|
|
894
|
+
n.searchParams.delete(me), window.history.replaceState({}, "", n.toString());
|
|
879
895
|
}
|
|
880
|
-
const
|
|
881
|
-
function
|
|
882
|
-
const { baseUrl: t, appInfo: r, appId: i } =
|
|
896
|
+
const Ue = ye(null);
|
|
897
|
+
function Sr({ config: n, children: e }) {
|
|
898
|
+
const { baseUrl: t, appInfo: r, appId: i } = Ae(), o = oe(() => typeof window > "u" ? null : xt(
|
|
883
899
|
{
|
|
884
900
|
tenantMode: n.tenantMode || "selector",
|
|
885
901
|
baseDomain: n.baseDomain,
|
|
@@ -891,119 +907,119 @@ function wr({ config: n, children: e }) {
|
|
|
891
907
|
search: window.location.search
|
|
892
908
|
},
|
|
893
909
|
window.localStorage
|
|
894
|
-
), [n.tenantMode, n.baseDomain, n.selectorParam, n.fixedTenantSlug]), [a,
|
|
910
|
+
), [n.tenantMode, n.baseDomain, n.selectorParam, n.fixedTenantSlug]), [a, c] = x(() => o()), m = Z(
|
|
895
911
|
() => {
|
|
896
|
-
var
|
|
912
|
+
var p, U, b;
|
|
897
913
|
return {
|
|
898
|
-
enabled: ((
|
|
899
|
-
ttl: ((
|
|
914
|
+
enabled: ((p = n.cache) == null ? void 0 : p.enabled) ?? !0,
|
|
915
|
+
ttl: ((U = n.cache) == null ? void 0 : U.ttl) ?? 5 * 60 * 1e3,
|
|
900
916
|
// 5 minutes default
|
|
901
|
-
storageKey: ((
|
|
917
|
+
storageKey: ((b = n.cache) == null ? void 0 : b.storageKey) ?? `tenant_cache_${a || "default"}`
|
|
902
918
|
};
|
|
903
919
|
},
|
|
904
920
|
[n.cache, a]
|
|
905
|
-
), [y, f] =
|
|
921
|
+
), [y, f] = x(() => {
|
|
906
922
|
if (n.initialTenant) return n.initialTenant;
|
|
907
|
-
if (!
|
|
923
|
+
if (!m.enabled || !a) return null;
|
|
908
924
|
try {
|
|
909
|
-
const
|
|
910
|
-
if (!
|
|
911
|
-
const
|
|
912
|
-
return Date.now() -
|
|
925
|
+
const p = localStorage.getItem(m.storageKey);
|
|
926
|
+
if (!p) return null;
|
|
927
|
+
const U = JSON.parse(p);
|
|
928
|
+
return Date.now() - U.timestamp < m.ttl && U.tenantSlug === a ? U.data : (localStorage.removeItem(m.storageKey), null);
|
|
913
929
|
} catch {
|
|
914
930
|
return null;
|
|
915
931
|
}
|
|
916
|
-
}), [
|
|
917
|
-
|
|
932
|
+
}), [F, g] = x(!y && !n.initialTenant), [T, A] = x(null), [L, M] = x(null), [P, d] = x(!1), [v, N] = x(null);
|
|
933
|
+
ne(() => {
|
|
918
934
|
if (n.tenantMode === "fixed") return;
|
|
919
|
-
const
|
|
920
|
-
p
|
|
935
|
+
const p = o();
|
|
936
|
+
c(p);
|
|
921
937
|
}, [o, n.tenantMode]);
|
|
922
|
-
const
|
|
923
|
-
async (
|
|
924
|
-
if (!(!
|
|
938
|
+
const B = (r == null ? void 0 : r.settingsSchema) || null, w = oe(
|
|
939
|
+
async (p, U = !1) => {
|
|
940
|
+
if (!(!U && m.enabled && y && y.domain === p))
|
|
925
941
|
try {
|
|
926
|
-
|
|
927
|
-
const
|
|
928
|
-
if (f(
|
|
942
|
+
g(!0), A(null);
|
|
943
|
+
const b = new de(t), S = await new ve(b, i).getPublicTenantInfo(p);
|
|
944
|
+
if (f(S), m.enabled)
|
|
929
945
|
try {
|
|
930
|
-
const
|
|
931
|
-
data:
|
|
946
|
+
const E = {
|
|
947
|
+
data: S,
|
|
932
948
|
timestamp: Date.now(),
|
|
933
|
-
tenantSlug:
|
|
949
|
+
tenantSlug: p
|
|
934
950
|
};
|
|
935
|
-
localStorage.setItem(
|
|
936
|
-
} catch (
|
|
937
|
-
process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Failed to cache tenant info:",
|
|
951
|
+
localStorage.setItem(m.storageKey, JSON.stringify(E));
|
|
952
|
+
} catch (E) {
|
|
953
|
+
process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Failed to cache tenant info:", E);
|
|
938
954
|
}
|
|
939
|
-
} catch (
|
|
940
|
-
const
|
|
941
|
-
|
|
955
|
+
} catch (b) {
|
|
956
|
+
const h = b instanceof Error ? b : new Error("Failed to load tenant information");
|
|
957
|
+
A(h), f(null);
|
|
942
958
|
} finally {
|
|
943
|
-
|
|
959
|
+
g(!1);
|
|
944
960
|
}
|
|
945
961
|
},
|
|
946
|
-
[t, i,
|
|
947
|
-
),
|
|
948
|
-
if (!(!
|
|
962
|
+
[t, i, m, y]
|
|
963
|
+
), R = oe(async () => {
|
|
964
|
+
if (!(!m.enabled || !y || !a))
|
|
949
965
|
try {
|
|
950
|
-
const
|
|
951
|
-
if (!
|
|
952
|
-
const
|
|
953
|
-
if (Date.now() -
|
|
954
|
-
const
|
|
955
|
-
f(
|
|
956
|
-
const
|
|
957
|
-
data:
|
|
966
|
+
const p = localStorage.getItem(m.storageKey);
|
|
967
|
+
if (!p) return;
|
|
968
|
+
const U = JSON.parse(p);
|
|
969
|
+
if (Date.now() - U.timestamp > m.ttl * 0.5) {
|
|
970
|
+
const h = new de(t), E = await new ve(h, i).getPublicTenantInfo(a);
|
|
971
|
+
f(E);
|
|
972
|
+
const K = {
|
|
973
|
+
data: E,
|
|
958
974
|
timestamp: Date.now(),
|
|
959
975
|
tenantSlug: a
|
|
960
976
|
};
|
|
961
|
-
localStorage.setItem(
|
|
977
|
+
localStorage.setItem(m.storageKey, JSON.stringify(K));
|
|
962
978
|
}
|
|
963
|
-
} catch (
|
|
964
|
-
process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Background tenant refresh failed:",
|
|
979
|
+
} catch (p) {
|
|
980
|
+
process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Background tenant refresh failed:", p);
|
|
965
981
|
}
|
|
966
|
-
}, [t, i,
|
|
982
|
+
}, [t, i, m, y, a]), k = oe(async () => {
|
|
967
983
|
if (y != null && y.id)
|
|
968
984
|
try {
|
|
969
|
-
|
|
970
|
-
const
|
|
971
|
-
|
|
972
|
-
} catch (
|
|
973
|
-
const
|
|
974
|
-
|
|
985
|
+
d(!0), N(null);
|
|
986
|
+
const p = new de(t), b = await new ve(p, y.appId).getTenantSettings(y.id);
|
|
987
|
+
M(b);
|
|
988
|
+
} catch (p) {
|
|
989
|
+
const U = p instanceof Error ? p : new Error("Failed to load tenant settings");
|
|
990
|
+
N(U), M(null);
|
|
975
991
|
} finally {
|
|
976
|
-
|
|
992
|
+
d(!1);
|
|
977
993
|
}
|
|
978
|
-
}, [t, y]),
|
|
979
|
-
|
|
980
|
-
}, [
|
|
981
|
-
(
|
|
982
|
-
if (!
|
|
994
|
+
}, [t, y]), I = oe(() => {
|
|
995
|
+
k();
|
|
996
|
+
}, [k]), l = oe(
|
|
997
|
+
(p) => {
|
|
998
|
+
if (!B)
|
|
983
999
|
return { isValid: !0, errors: [] };
|
|
984
|
-
const
|
|
1000
|
+
const U = [];
|
|
985
1001
|
try {
|
|
986
|
-
return
|
|
987
|
-
var
|
|
988
|
-
const
|
|
989
|
-
if ((
|
|
990
|
-
|
|
1002
|
+
return B.properties && Object.entries(B.properties).forEach(([b, h]) => {
|
|
1003
|
+
var E;
|
|
1004
|
+
const S = p[b];
|
|
1005
|
+
if ((E = B.required) != null && E.includes(b) && S == null) {
|
|
1006
|
+
U.push(`Field '${b}' is required`);
|
|
991
1007
|
return;
|
|
992
1008
|
}
|
|
993
|
-
if (
|
|
994
|
-
if (
|
|
995
|
-
const
|
|
996
|
-
|
|
1009
|
+
if (S != null) {
|
|
1010
|
+
if (h.type) {
|
|
1011
|
+
const K = h.type, G = typeof S;
|
|
1012
|
+
K === "string" && G !== "string" ? U.push(`Field '${b}' must be a string`) : (K === "number" || K === "integer") && G !== "number" ? U.push(`Field '${b}' must be a number`) : K === "boolean" && G !== "boolean" ? U.push(`Field '${b}' must be a boolean`) : K === "array" && !Array.isArray(S) && U.push(`Field '${b}' must be an array`);
|
|
997
1013
|
}
|
|
998
|
-
|
|
999
|
-
`Field '${
|
|
1000
|
-
),
|
|
1001
|
-
`Field '${
|
|
1002
|
-
),
|
|
1014
|
+
h.minLength !== void 0 && typeof S == "string" && S.length < h.minLength && U.push(
|
|
1015
|
+
`Field '${b}' must be at least ${h.minLength} characters long`
|
|
1016
|
+
), h.maxLength !== void 0 && typeof S == "string" && S.length > h.maxLength && U.push(
|
|
1017
|
+
`Field '${b}' must be no more than ${h.maxLength} characters long`
|
|
1018
|
+
), h.minimum !== void 0 && typeof S == "number" && S < h.minimum && U.push(`Field '${b}' must be at least ${h.minimum}`), h.maximum !== void 0 && typeof S == "number" && S > h.maximum && U.push(`Field '${b}' must be no more than ${h.maximum}`), h.pattern && typeof S == "string" && (new RegExp(h.pattern).test(S) || U.push(`Field '${b}' does not match the required pattern`)), h.enum && !h.enum.includes(S) && U.push(`Field '${b}' must be one of: ${h.enum.join(", ")}`);
|
|
1003
1019
|
}
|
|
1004
1020
|
}), {
|
|
1005
|
-
isValid:
|
|
1006
|
-
errors:
|
|
1021
|
+
isValid: U.length === 0,
|
|
1022
|
+
errors: U
|
|
1007
1023
|
};
|
|
1008
1024
|
} catch {
|
|
1009
1025
|
return {
|
|
@@ -1012,98 +1028,98 @@ function wr({ config: n, children: e }) {
|
|
|
1012
1028
|
};
|
|
1013
1029
|
}
|
|
1014
1030
|
},
|
|
1015
|
-
[
|
|
1031
|
+
[B]
|
|
1016
1032
|
);
|
|
1017
|
-
|
|
1018
|
-
!n.initialTenant && a ? y ?
|
|
1019
|
-
}, [n.initialTenant, a, y,
|
|
1020
|
-
y != null && y.id ?
|
|
1021
|
-
}, [y == null ? void 0 : y.id,
|
|
1022
|
-
const
|
|
1023
|
-
(
|
|
1024
|
-
const { mode:
|
|
1025
|
-
if (
|
|
1033
|
+
ne(() => {
|
|
1034
|
+
!n.initialTenant && a ? y ? R() : w(a) : !n.initialTenant && !a && (f(null), A(null), g(!1));
|
|
1035
|
+
}, [n.initialTenant, a, y, w, R]), ne(() => {
|
|
1036
|
+
y != null && y.id ? k() : (M(null), N(null), d(!1));
|
|
1037
|
+
}, [y == null ? void 0 : y.id, k]);
|
|
1038
|
+
const z = oe(
|
|
1039
|
+
(p, U) => {
|
|
1040
|
+
const { mode: b = "reload", tokens: h, redirectPath: S } = U || {}, E = n.tenantMode || "selector";
|
|
1041
|
+
if (E === "fixed") {
|
|
1026
1042
|
process.env.NODE_ENV === "development" && console.warn(
|
|
1027
1043
|
"[TenantProvider] switchTenant is a no-op in fixed mode. Tenant is always:",
|
|
1028
1044
|
n.fixedTenantSlug
|
|
1029
|
-
),
|
|
1045
|
+
), S && (window.location.href = S);
|
|
1030
1046
|
return;
|
|
1031
1047
|
}
|
|
1032
|
-
if (localStorage.setItem("tenant",
|
|
1033
|
-
const
|
|
1034
|
-
|
|
1035
|
-
|
|
1048
|
+
if (localStorage.setItem("tenant", p), E === "subdomain") {
|
|
1049
|
+
const K = window.location.hostname, G = At(
|
|
1050
|
+
p,
|
|
1051
|
+
K,
|
|
1036
1052
|
n.baseDomain
|
|
1037
1053
|
);
|
|
1038
|
-
if (!
|
|
1054
|
+
if (!G) {
|
|
1039
1055
|
process.env.NODE_ENV === "development" && console.warn(
|
|
1040
1056
|
"[TenantProvider] Cannot switch subdomain, invalid hostname:",
|
|
1041
|
-
|
|
1057
|
+
K
|
|
1042
1058
|
);
|
|
1043
1059
|
return;
|
|
1044
1060
|
}
|
|
1045
|
-
const
|
|
1046
|
-
new URLSearchParams(window.location.search).forEach((
|
|
1047
|
-
|
|
1048
|
-
}),
|
|
1049
|
-
} else if (
|
|
1050
|
-
const
|
|
1051
|
-
if (
|
|
1052
|
-
const
|
|
1053
|
-
window.location.href =
|
|
1061
|
+
const X = S || window.location.pathname, W = new URL(`${window.location.protocol}//${G}${X}`);
|
|
1062
|
+
new URLSearchParams(window.location.search).forEach((V, H) => {
|
|
1063
|
+
H !== me && W.searchParams.set(H, V);
|
|
1064
|
+
}), h && W.searchParams.set(me, je(h)), window.location.href = W.toString();
|
|
1065
|
+
} else if (E === "selector") {
|
|
1066
|
+
const K = S || window.location.pathname, G = new URLSearchParams(window.location.search);
|
|
1067
|
+
if (G.set(n.selectorParam || "tenant", p), G.delete(me), h && G.set(me, je(h)), b === "reload") {
|
|
1068
|
+
const X = `${K}?${G.toString()}${window.location.hash}`;
|
|
1069
|
+
window.location.href = X;
|
|
1054
1070
|
} else {
|
|
1055
|
-
const
|
|
1056
|
-
window.history.pushState({}, "",
|
|
1071
|
+
const X = `${K}?${G.toString()}${window.location.hash}`;
|
|
1072
|
+
window.history.pushState({}, "", X), c(p), w(p);
|
|
1057
1073
|
}
|
|
1058
1074
|
}
|
|
1059
1075
|
},
|
|
1060
|
-
[n.tenantMode, n.selectorParam, n.baseDomain,
|
|
1061
|
-
),
|
|
1076
|
+
[n.tenantMode, n.selectorParam, n.baseDomain, w]
|
|
1077
|
+
), D = Z(() => ({
|
|
1062
1078
|
// Tenant info
|
|
1063
1079
|
tenant: y,
|
|
1064
1080
|
tenantSlug: a,
|
|
1065
|
-
isTenantLoading:
|
|
1066
|
-
tenantError:
|
|
1081
|
+
isTenantLoading: F,
|
|
1082
|
+
tenantError: T,
|
|
1067
1083
|
retryTenant: () => {
|
|
1068
|
-
a &&
|
|
1084
|
+
a && w(a);
|
|
1069
1085
|
},
|
|
1070
1086
|
// Settings
|
|
1071
|
-
settings:
|
|
1072
|
-
settingsSchema:
|
|
1087
|
+
settings: L,
|
|
1088
|
+
settingsSchema: B,
|
|
1073
1089
|
isSettingsLoading: P,
|
|
1074
|
-
settingsError:
|
|
1090
|
+
settingsError: v,
|
|
1075
1091
|
// Actions
|
|
1076
|
-
refreshSettings:
|
|
1077
|
-
switchTenant:
|
|
1092
|
+
refreshSettings: I,
|
|
1093
|
+
switchTenant: z,
|
|
1078
1094
|
// Validation
|
|
1079
|
-
validateSettings:
|
|
1095
|
+
validateSettings: l
|
|
1080
1096
|
}), [
|
|
1081
1097
|
y,
|
|
1082
1098
|
a,
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
D,
|
|
1086
|
-
M,
|
|
1087
|
-
P,
|
|
1088
|
-
S,
|
|
1089
|
-
U,
|
|
1099
|
+
F,
|
|
1100
|
+
T,
|
|
1090
1101
|
L,
|
|
1091
|
-
|
|
1102
|
+
B,
|
|
1103
|
+
P,
|
|
1104
|
+
v,
|
|
1105
|
+
I,
|
|
1106
|
+
z,
|
|
1107
|
+
l
|
|
1092
1108
|
]);
|
|
1093
|
-
return /* @__PURE__ */ s(
|
|
1109
|
+
return /* @__PURE__ */ s(Ue.Provider, { value: D, children: e });
|
|
1094
1110
|
}
|
|
1095
|
-
function
|
|
1096
|
-
const n =
|
|
1111
|
+
function Te() {
|
|
1112
|
+
const n = le(Ue);
|
|
1097
1113
|
if (!n)
|
|
1098
1114
|
throw new Error("useTenant must be used within a TenantProvider");
|
|
1099
1115
|
return n;
|
|
1100
1116
|
}
|
|
1101
|
-
function
|
|
1102
|
-
return
|
|
1117
|
+
function pe() {
|
|
1118
|
+
return le(Ue);
|
|
1103
1119
|
}
|
|
1104
|
-
const
|
|
1105
|
-
function
|
|
1106
|
-
const { settings: n, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: i } =
|
|
1120
|
+
const Tr = Te;
|
|
1121
|
+
function kr() {
|
|
1122
|
+
const { settings: n, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: i } = Te();
|
|
1107
1123
|
return {
|
|
1108
1124
|
settings: n,
|
|
1109
1125
|
settingsSchema: e,
|
|
@@ -1112,8 +1128,8 @@ function vr() {
|
|
|
1112
1128
|
validateSettings: i
|
|
1113
1129
|
};
|
|
1114
1130
|
}
|
|
1115
|
-
function
|
|
1116
|
-
const { tenant: n, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: i } =
|
|
1131
|
+
function Je() {
|
|
1132
|
+
const { tenant: n, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: i } = Te();
|
|
1117
1133
|
return {
|
|
1118
1134
|
tenant: n,
|
|
1119
1135
|
tenantSlug: e,
|
|
@@ -1122,389 +1138,395 @@ function me() {
|
|
|
1122
1138
|
retry: i
|
|
1123
1139
|
};
|
|
1124
1140
|
}
|
|
1125
|
-
const
|
|
1126
|
-
function
|
|
1127
|
-
const
|
|
1141
|
+
const Be = ye(null);
|
|
1142
|
+
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, c = (r == null ? void 0 : r.tenantSlug) ?? null, m = (r == null ? void 0 : r.switchTenant) ?? (() => {
|
|
1144
|
+
});
|
|
1145
|
+
if (!i)
|
|
1146
|
+
throw new Error(
|
|
1147
|
+
"[AuthProvider] baseUrl is required. Provide it via AppProvider or AuthConfig.baseUrl."
|
|
1148
|
+
);
|
|
1149
|
+
const [y, f] = x(n.initialRoles || []), [F, g] = x(!n.initialRoles), [T, A] = x(null), [L, M] = x(!1), [P, d] = x(null), [v, N] = x(() => {
|
|
1128
1150
|
try {
|
|
1129
|
-
const
|
|
1130
|
-
return
|
|
1151
|
+
const $ = localStorage.getItem("userTenants");
|
|
1152
|
+
return $ ? JSON.parse($) : [];
|
|
1131
1153
|
} catch {
|
|
1132
1154
|
return [];
|
|
1133
1155
|
}
|
|
1134
|
-
}), [
|
|
1135
|
-
|
|
1136
|
-
const [
|
|
1137
|
-
const
|
|
1138
|
-
tenantSlug:
|
|
1139
|
-
baseUrl:
|
|
1156
|
+
}), [B, w] = x(!1), R = Ne({ done: !1, urlTokens: null });
|
|
1157
|
+
R.current.done || (R.current.done = !0, R.current.urlTokens = Rt());
|
|
1158
|
+
const [k, I] = x(() => R.current.urlTokens !== null), l = Z(() => {
|
|
1159
|
+
const $ = be.getInstance({
|
|
1160
|
+
tenantSlug: c,
|
|
1161
|
+
baseUrl: i,
|
|
1140
1162
|
refreshQueueTimeout: n.refreshQueueTimeout,
|
|
1141
1163
|
proactiveRefreshMargin: n.proactiveRefreshMargin,
|
|
1142
|
-
onSessionExpired: (
|
|
1143
|
-
|
|
1164
|
+
onSessionExpired: (ce) => {
|
|
1165
|
+
A(null), d(null), N([]), w(!1);
|
|
1144
1166
|
try {
|
|
1145
1167
|
localStorage.removeItem("userTenants");
|
|
1146
1168
|
} catch {
|
|
1147
1169
|
}
|
|
1148
|
-
n.onSessionExpired ? n.onSessionExpired(
|
|
1170
|
+
n.onSessionExpired ? n.onSessionExpired(ce) : n.onRefreshFailed && n.onRefreshFailed();
|
|
1149
1171
|
}
|
|
1150
1172
|
});
|
|
1151
|
-
return
|
|
1152
|
-
accessToken:
|
|
1153
|
-
refreshToken:
|
|
1154
|
-
expiresIn:
|
|
1155
|
-
}),
|
|
1156
|
-
}, [
|
|
1157
|
-
if (
|
|
1158
|
-
const
|
|
1159
|
-
return
|
|
1160
|
-
}),
|
|
1161
|
-
const
|
|
1162
|
-
return
|
|
1163
|
-
}, [
|
|
1164
|
-
}),
|
|
1165
|
-
const
|
|
1173
|
+
return R.current.urlTokens && $.setTokens({
|
|
1174
|
+
accessToken: R.current.urlTokens.accessToken,
|
|
1175
|
+
refreshToken: R.current.urlTokens.refreshToken,
|
|
1176
|
+
expiresIn: R.current.urlTokens.expiresIn
|
|
1177
|
+
}), $;
|
|
1178
|
+
}, [c, i, n.refreshQueueTimeout, n.proactiveRefreshMargin]), [z, D] = x(() => {
|
|
1179
|
+
if (R.current.urlTokens) return !1;
|
|
1180
|
+
const $ = l.getTokens();
|
|
1181
|
+
return $ ? l.hasValidSession() || !!$.refreshToken : !1;
|
|
1182
|
+
}), p = R.current.done && !k && !z, U = Z(() => {
|
|
1183
|
+
const $ = new de(i);
|
|
1184
|
+
return $.setSessionManager(l), $;
|
|
1185
|
+
}, [i, l]), b = Z(() => new vt(new de(i)), [i]), h = Z(() => new St(U, l), [U, l]), S = Z(() => new We(new de(i)), [i]), E = Z(() => T || l.getUser(), [T, l]), K = Z(() => E != null && E.roleId && y.find(($) => $.id === E.roleId) || null, [E, y]), G = Z(() => (K == null ? void 0 : K.permissions) || [], [K]), X = Z(() => l.hasValidSession() && T !== null, [l, T]), W = Ne(async () => {
|
|
1186
|
+
}), q = Z(() => {
|
|
1187
|
+
const $ = async (C = !1) => {
|
|
1166
1188
|
try {
|
|
1167
|
-
if (!l.hasValidSession() || !
|
|
1189
|
+
if (!l.hasValidSession() || !C && T)
|
|
1168
1190
|
return;
|
|
1169
|
-
const
|
|
1170
|
-
if (!
|
|
1191
|
+
const O = l.getUserId();
|
|
1192
|
+
if (!O) {
|
|
1171
1193
|
process.env.NODE_ENV === "development" && console.warn("[AuthProvider] No userId available in token or storage");
|
|
1172
1194
|
return;
|
|
1173
1195
|
}
|
|
1174
|
-
|
|
1175
|
-
const
|
|
1176
|
-
|
|
1177
|
-
} catch (
|
|
1178
|
-
const
|
|
1179
|
-
|
|
1196
|
+
M(!0), d(null);
|
|
1197
|
+
const J = await h.getUserById(O);
|
|
1198
|
+
A(J), l.setUser(J);
|
|
1199
|
+
} catch (O) {
|
|
1200
|
+
const J = O instanceof Error ? O : new Error("Failed to load user data");
|
|
1201
|
+
d(J), process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to load user data:", J);
|
|
1180
1202
|
} finally {
|
|
1181
|
-
|
|
1203
|
+
M(!1);
|
|
1182
1204
|
}
|
|
1183
|
-
},
|
|
1184
|
-
await
|
|
1185
|
-
},
|
|
1186
|
-
var
|
|
1187
|
-
const { username:
|
|
1188
|
-
let
|
|
1189
|
-
|
|
1190
|
-
const
|
|
1191
|
-
username:
|
|
1192
|
-
password:
|
|
1193
|
-
appId:
|
|
1194
|
-
tenantId:
|
|
1195
|
-
}),
|
|
1196
|
-
if (
|
|
1197
|
-
tenantSlug:
|
|
1198
|
-
baseUrl:
|
|
1199
|
-
})),
|
|
1200
|
-
accessToken:
|
|
1201
|
-
refreshToken:
|
|
1202
|
-
expiresIn:
|
|
1203
|
-
}),
|
|
1204
|
-
|
|
1205
|
+
}, ce = async () => {
|
|
1206
|
+
await $();
|
|
1207
|
+
}, fe = async (C) => {
|
|
1208
|
+
var _e;
|
|
1209
|
+
const { username: O, password: J, tenantSlug: j, redirectPath: Y } = C;
|
|
1210
|
+
let ee = a == null ? void 0 : a.id, te = c, re = l;
|
|
1211
|
+
j && (ee = (await new ve(U, o).getPublicTenantInfo(j)).id, te = j);
|
|
1212
|
+
const Q = await b.login({
|
|
1213
|
+
username: O,
|
|
1214
|
+
password: J,
|
|
1215
|
+
appId: o,
|
|
1216
|
+
tenantId: ee
|
|
1217
|
+
}), we = j && j !== c;
|
|
1218
|
+
if (we && (re = new be({
|
|
1219
|
+
tenantSlug: te,
|
|
1220
|
+
baseUrl: i
|
|
1221
|
+
})), re.setTokens({
|
|
1222
|
+
accessToken: Q.accessToken,
|
|
1223
|
+
refreshToken: Q.refreshToken,
|
|
1224
|
+
expiresIn: Q.expiresIn
|
|
1225
|
+
}), Q.user) {
|
|
1226
|
+
re.setUser(Q.user), A(Q.user);
|
|
1205
1227
|
try {
|
|
1206
|
-
await
|
|
1207
|
-
} catch (
|
|
1208
|
-
process.env.NODE_ENV === "development" && console.warn("[AuthProvider] Failed to load complete user data after login:",
|
|
1228
|
+
await $();
|
|
1229
|
+
} catch (ke) {
|
|
1230
|
+
process.env.NODE_ENV === "development" && console.warn("[AuthProvider] Failed to load complete user data after login:", ke);
|
|
1209
1231
|
}
|
|
1210
1232
|
}
|
|
1211
|
-
if (
|
|
1212
|
-
|
|
1233
|
+
if (Q.tenants && Q.tenants.length > 0) {
|
|
1234
|
+
N(Q.tenants);
|
|
1213
1235
|
try {
|
|
1214
|
-
localStorage.setItem("userTenants", JSON.stringify(
|
|
1236
|
+
localStorage.setItem("userTenants", JSON.stringify(Q.tenants));
|
|
1215
1237
|
} catch {
|
|
1216
1238
|
}
|
|
1217
1239
|
}
|
|
1218
|
-
const
|
|
1219
|
-
|
|
1220
|
-
const
|
|
1221
|
-
accessToken:
|
|
1222
|
-
refreshToken:
|
|
1223
|
-
expiresIn:
|
|
1240
|
+
const Re = ((_e = Q.user) == null ? void 0 : _e.tenantId) !== null;
|
|
1241
|
+
w(Re);
|
|
1242
|
+
const Ee = {
|
|
1243
|
+
accessToken: Q.accessToken,
|
|
1244
|
+
refreshToken: Q.refreshToken,
|
|
1245
|
+
expiresIn: Q.expiresIn
|
|
1224
1246
|
};
|
|
1225
|
-
if (
|
|
1226
|
-
return
|
|
1247
|
+
if (we && te)
|
|
1248
|
+
return m(te, { tokens: Ee, redirectPath: Y }), Q;
|
|
1227
1249
|
if (Y && Y !== window.location.pathname)
|
|
1228
|
-
return
|
|
1229
|
-
if (!
|
|
1230
|
-
const
|
|
1231
|
-
if (
|
|
1232
|
-
const
|
|
1233
|
-
return
|
|
1234
|
-
} else
|
|
1250
|
+
return m(te || c || "", { tokens: Ee, redirectPath: Y }), Q;
|
|
1251
|
+
if (!Re && Q.tenants && Q.tenants.length > 0) {
|
|
1252
|
+
const ke = C.autoSwitch !== !1 && n.autoSwitchSingleTenant !== !1;
|
|
1253
|
+
if (Q.tenants.length === 1 && ke) {
|
|
1254
|
+
const ze = Q.tenants[0];
|
|
1255
|
+
return m(ze.subdomain, { tokens: Ee, redirectPath: Y }), Q;
|
|
1256
|
+
} else Q.tenants.length > 1 && n.onTenantSelectionRequired && n.onTenantSelectionRequired(Q.tenants);
|
|
1235
1257
|
}
|
|
1236
|
-
return
|
|
1237
|
-
},
|
|
1238
|
-
const { email:
|
|
1239
|
-
if (!
|
|
1258
|
+
return Q;
|
|
1259
|
+
}, ge = async (C) => {
|
|
1260
|
+
const { email: O, phoneNumber: J, name: j, password: Y, lastName: ee, tenantId: te } = C;
|
|
1261
|
+
if (!O && !J)
|
|
1240
1262
|
throw new Error("Either email or phoneNumber is required");
|
|
1241
|
-
if (!
|
|
1263
|
+
if (!j || !Y)
|
|
1242
1264
|
throw new Error("Name and password are required");
|
|
1243
|
-
const
|
|
1244
|
-
return await
|
|
1245
|
-
email:
|
|
1246
|
-
phoneNumber:
|
|
1247
|
-
name:
|
|
1265
|
+
const re = te ?? (a == null ? void 0 : a.id);
|
|
1266
|
+
return await b.signup({
|
|
1267
|
+
email: O,
|
|
1268
|
+
phoneNumber: J,
|
|
1269
|
+
name: j,
|
|
1248
1270
|
password: Y,
|
|
1249
|
-
tenantId:
|
|
1250
|
-
lastName:
|
|
1251
|
-
appId:
|
|
1271
|
+
tenantId: re,
|
|
1272
|
+
lastName: ee,
|
|
1273
|
+
appId: o
|
|
1252
1274
|
});
|
|
1253
|
-
},
|
|
1254
|
-
const { email:
|
|
1255
|
-
if (!
|
|
1275
|
+
}, nt = async (C) => {
|
|
1276
|
+
const { email: O, phoneNumber: J, name: j, password: Y, tenantName: ee, lastName: te } = C;
|
|
1277
|
+
if (!O && !J)
|
|
1256
1278
|
throw new Error("Either email or phoneNumber is required");
|
|
1257
|
-
if (!
|
|
1279
|
+
if (!j || !Y || !ee)
|
|
1258
1280
|
throw new Error("Name, password, and tenantName are required");
|
|
1259
|
-
return await
|
|
1260
|
-
email:
|
|
1261
|
-
phoneNumber:
|
|
1262
|
-
name:
|
|
1281
|
+
return await b.signupTenantAdmin({
|
|
1282
|
+
email: O,
|
|
1283
|
+
phoneNumber: J,
|
|
1284
|
+
name: j,
|
|
1263
1285
|
password: Y,
|
|
1264
|
-
tenantName:
|
|
1265
|
-
appId:
|
|
1266
|
-
lastName:
|
|
1286
|
+
tenantName: ee,
|
|
1287
|
+
appId: o,
|
|
1288
|
+
lastName: te
|
|
1267
1289
|
});
|
|
1268
|
-
},
|
|
1269
|
-
const { currentPassword:
|
|
1270
|
-
await
|
|
1271
|
-
},
|
|
1272
|
-
const { email:
|
|
1273
|
-
if (!
|
|
1290
|
+
}, st = async (C) => {
|
|
1291
|
+
const { currentPassword: O, newPassword: J } = C, j = await l.getAuthHeaders();
|
|
1292
|
+
await b.changePassword({ currentPassword: O, newPassword: J }, j);
|
|
1293
|
+
}, it = async (C) => {
|
|
1294
|
+
const { email: O, tenantId: J } = C, j = J ?? (a == null ? void 0 : a.id);
|
|
1295
|
+
if (!j)
|
|
1274
1296
|
throw new Error("tenantId is required for password reset");
|
|
1275
|
-
await
|
|
1276
|
-
},
|
|
1277
|
-
const { token:
|
|
1278
|
-
await
|
|
1279
|
-
},
|
|
1280
|
-
const { email:
|
|
1281
|
-
if (!
|
|
1297
|
+
await b.requestPasswordReset({ email: O, tenantId: j });
|
|
1298
|
+
}, ot = async (C) => {
|
|
1299
|
+
const { token: O, newPassword: J } = C;
|
|
1300
|
+
await b.confirmPasswordReset({ token: O, newPassword: J });
|
|
1301
|
+
}, at = async (C) => {
|
|
1302
|
+
const { email: O, frontendUrl: J, name: j, lastName: Y, tenantId: ee } = C, te = ee ?? (a == null ? void 0 : a.id);
|
|
1303
|
+
if (!te)
|
|
1282
1304
|
throw new Error("tenantId is required for magic link authentication");
|
|
1283
|
-
return await
|
|
1284
|
-
email:
|
|
1285
|
-
tenantId:
|
|
1286
|
-
frontendUrl:
|
|
1287
|
-
name:
|
|
1305
|
+
return await b.sendMagicLink({
|
|
1306
|
+
email: O,
|
|
1307
|
+
tenantId: te,
|
|
1308
|
+
frontendUrl: J,
|
|
1309
|
+
name: j,
|
|
1288
1310
|
lastName: Y,
|
|
1289
|
-
appId:
|
|
1311
|
+
appId: o
|
|
1290
1312
|
});
|
|
1291
|
-
},
|
|
1292
|
-
const { token:
|
|
1293
|
-
let Y =
|
|
1294
|
-
|
|
1295
|
-
const
|
|
1296
|
-
token:
|
|
1297
|
-
email:
|
|
1298
|
-
appId:
|
|
1313
|
+
}, lt = async (C) => {
|
|
1314
|
+
const { token: O, email: J, tenantSlug: j } = C;
|
|
1315
|
+
let Y = a == null ? void 0 : a.id, ee = c, te = l;
|
|
1316
|
+
j && (Y = (await new ve(U, o).getPublicTenantInfo(j)).id, ee = j);
|
|
1317
|
+
const re = await b.verifyMagicLink({
|
|
1318
|
+
token: O,
|
|
1319
|
+
email: J,
|
|
1320
|
+
appId: o,
|
|
1299
1321
|
tenantId: Y
|
|
1300
|
-
}),
|
|
1301
|
-
if (
|
|
1302
|
-
tenantSlug:
|
|
1303
|
-
baseUrl:
|
|
1304
|
-
})),
|
|
1305
|
-
accessToken:
|
|
1306
|
-
refreshToken:
|
|
1307
|
-
expiresIn:
|
|
1308
|
-
}),
|
|
1309
|
-
|
|
1322
|
+
}), Q = j && j !== c;
|
|
1323
|
+
if (Q && (te = new be({
|
|
1324
|
+
tenantSlug: ee,
|
|
1325
|
+
baseUrl: i
|
|
1326
|
+
})), te.setTokens({
|
|
1327
|
+
accessToken: re.accessToken,
|
|
1328
|
+
refreshToken: re.refreshToken,
|
|
1329
|
+
expiresIn: re.expiresIn
|
|
1330
|
+
}), re.user) {
|
|
1331
|
+
te.setUser(re.user), A(re.user);
|
|
1310
1332
|
try {
|
|
1311
|
-
await
|
|
1312
|
-
} catch (
|
|
1333
|
+
await $();
|
|
1334
|
+
} catch (we) {
|
|
1313
1335
|
process.env.NODE_ENV === "development" && console.warn(
|
|
1314
1336
|
"[AuthProvider] Failed to load complete user data after magic link:",
|
|
1315
|
-
|
|
1337
|
+
we
|
|
1316
1338
|
);
|
|
1317
1339
|
}
|
|
1318
1340
|
}
|
|
1319
|
-
return
|
|
1341
|
+
return Q && ee && ee !== c && m(ee, {
|
|
1320
1342
|
tokens: {
|
|
1321
|
-
accessToken:
|
|
1322
|
-
refreshToken:
|
|
1323
|
-
expiresIn:
|
|
1343
|
+
accessToken: re.accessToken,
|
|
1344
|
+
refreshToken: re.refreshToken,
|
|
1345
|
+
expiresIn: re.expiresIn
|
|
1324
1346
|
}
|
|
1325
|
-
}),
|
|
1326
|
-
},
|
|
1327
|
-
const
|
|
1328
|
-
if (!(
|
|
1347
|
+
}), re;
|
|
1348
|
+
}, ct = async () => {
|
|
1349
|
+
const C = l.getTokens();
|
|
1350
|
+
if (!(C != null && C.refreshToken))
|
|
1329
1351
|
throw new Error("No refresh token available");
|
|
1330
|
-
const
|
|
1331
|
-
refreshToken:
|
|
1352
|
+
const O = await b.refreshToken({
|
|
1353
|
+
refreshToken: C.refreshToken
|
|
1332
1354
|
});
|
|
1333
1355
|
l.setTokens({
|
|
1334
|
-
accessToken:
|
|
1335
|
-
refreshToken:
|
|
1336
|
-
expiresIn:
|
|
1356
|
+
accessToken: O.accessToken,
|
|
1357
|
+
refreshToken: O.refreshToken || C.refreshToken,
|
|
1358
|
+
expiresIn: O.expiresIn
|
|
1337
1359
|
});
|
|
1338
|
-
},
|
|
1339
|
-
l.clearSession(),
|
|
1360
|
+
}, dt = () => {
|
|
1361
|
+
l.clearSession(), A(null), d(null), N([]), w(!1);
|
|
1340
1362
|
try {
|
|
1341
1363
|
localStorage.removeItem("userTenants");
|
|
1342
1364
|
} catch {
|
|
1343
1365
|
}
|
|
1344
|
-
},
|
|
1345
|
-
l.setTokens(
|
|
1346
|
-
},
|
|
1347
|
-
l.clearSession(),
|
|
1348
|
-
},
|
|
1349
|
-
if (
|
|
1366
|
+
}, ut = (C) => {
|
|
1367
|
+
l.setTokens(C);
|
|
1368
|
+
}, ht = () => l.hasValidSession(), pt = () => {
|
|
1369
|
+
l.clearSession(), A(null), d(null);
|
|
1370
|
+
}, ft = async () => {
|
|
1371
|
+
if (o)
|
|
1350
1372
|
try {
|
|
1351
|
-
|
|
1352
|
-
const { roles:
|
|
1353
|
-
|
|
1354
|
-
} catch (
|
|
1355
|
-
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:",
|
|
1373
|
+
g(!0);
|
|
1374
|
+
const { roles: C } = await S.getRolesByApp(o);
|
|
1375
|
+
f(C);
|
|
1376
|
+
} catch (C) {
|
|
1377
|
+
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:", C);
|
|
1356
1378
|
} finally {
|
|
1357
|
-
|
|
1379
|
+
g(!1);
|
|
1358
1380
|
}
|
|
1359
|
-
},
|
|
1360
|
-
await
|
|
1361
|
-
},
|
|
1362
|
-
if (!
|
|
1381
|
+
}, gt = async () => {
|
|
1382
|
+
await ft();
|
|
1383
|
+
}, Pe = (C) => {
|
|
1384
|
+
if (!G || G.length === 0)
|
|
1363
1385
|
return !1;
|
|
1364
|
-
if (typeof
|
|
1365
|
-
return
|
|
1366
|
-
const
|
|
1367
|
-
return
|
|
1386
|
+
if (typeof C == "string")
|
|
1387
|
+
return G.includes(C);
|
|
1388
|
+
const O = `${C.resource}.${C.action}`;
|
|
1389
|
+
return G.includes(O);
|
|
1368
1390
|
};
|
|
1369
1391
|
return {
|
|
1370
1392
|
// RFC-003: Authentication state
|
|
1371
|
-
isAuthenticated:
|
|
1393
|
+
isAuthenticated: X,
|
|
1372
1394
|
sessionManager: l,
|
|
1373
|
-
authenticatedHttpService:
|
|
1374
|
-
login:
|
|
1375
|
-
signup:
|
|
1376
|
-
signupTenantAdmin:
|
|
1377
|
-
sendMagicLink:
|
|
1378
|
-
verifyMagicLink:
|
|
1379
|
-
changePassword:
|
|
1380
|
-
requestPasswordReset:
|
|
1381
|
-
confirmPasswordReset:
|
|
1382
|
-
refreshToken:
|
|
1383
|
-
logout:
|
|
1384
|
-
setTokens:
|
|
1385
|
-
hasValidSession:
|
|
1386
|
-
clearSession:
|
|
1387
|
-
currentUser:
|
|
1388
|
-
isUserLoading:
|
|
1389
|
-
userError:
|
|
1390
|
-
loadUserData:
|
|
1391
|
-
refreshUser:
|
|
1392
|
-
isAuthInitializing: !
|
|
1393
|
-
isAuthReady:
|
|
1394
|
-
userRole:
|
|
1395
|
-
userPermissions:
|
|
1396
|
-
availableRoles:
|
|
1397
|
-
rolesLoading:
|
|
1398
|
-
hasPermission:
|
|
1399
|
-
hasAnyPermission: (
|
|
1400
|
-
hasAllPermissions: (
|
|
1401
|
-
getUserPermissionStrings: () =>
|
|
1402
|
-
refreshRoles:
|
|
1395
|
+
authenticatedHttpService: U,
|
|
1396
|
+
login: fe,
|
|
1397
|
+
signup: ge,
|
|
1398
|
+
signupTenantAdmin: nt,
|
|
1399
|
+
sendMagicLink: at,
|
|
1400
|
+
verifyMagicLink: lt,
|
|
1401
|
+
changePassword: st,
|
|
1402
|
+
requestPasswordReset: it,
|
|
1403
|
+
confirmPasswordReset: ot,
|
|
1404
|
+
refreshToken: ct,
|
|
1405
|
+
logout: dt,
|
|
1406
|
+
setTokens: ut,
|
|
1407
|
+
hasValidSession: ht,
|
|
1408
|
+
clearSession: pt,
|
|
1409
|
+
currentUser: T,
|
|
1410
|
+
isUserLoading: L,
|
|
1411
|
+
userError: P,
|
|
1412
|
+
loadUserData: $,
|
|
1413
|
+
refreshUser: ce,
|
|
1414
|
+
isAuthInitializing: !p,
|
|
1415
|
+
isAuthReady: p,
|
|
1416
|
+
userRole: K,
|
|
1417
|
+
userPermissions: G,
|
|
1418
|
+
availableRoles: y,
|
|
1419
|
+
rolesLoading: F,
|
|
1420
|
+
hasPermission: Pe,
|
|
1421
|
+
hasAnyPermission: (C) => C.some((O) => Pe(O)),
|
|
1422
|
+
hasAllPermissions: (C) => C.every((O) => Pe(O)),
|
|
1423
|
+
getUserPermissionStrings: () => G || [],
|
|
1424
|
+
refreshRoles: gt,
|
|
1403
1425
|
// RFC-004: Multi-tenant user membership
|
|
1404
|
-
userTenants:
|
|
1405
|
-
hasTenantContext:
|
|
1406
|
-
switchToTenant: async (
|
|
1407
|
-
const { redirectPath:
|
|
1408
|
-
if (!(
|
|
1426
|
+
userTenants: v,
|
|
1427
|
+
hasTenantContext: B,
|
|
1428
|
+
switchToTenant: async (C, O) => {
|
|
1429
|
+
const { redirectPath: J } = O || {}, j = l.getTokens();
|
|
1430
|
+
if (!(j != null && j.refreshToken))
|
|
1409
1431
|
throw new Error("No refresh token available for tenant switch");
|
|
1410
|
-
const Y = await
|
|
1411
|
-
refreshToken:
|
|
1412
|
-
tenantId:
|
|
1432
|
+
const Y = await b.switchTenant({
|
|
1433
|
+
refreshToken: j.refreshToken,
|
|
1434
|
+
tenantId: C
|
|
1413
1435
|
});
|
|
1414
1436
|
l.setTokens({
|
|
1415
1437
|
accessToken: Y.accessToken,
|
|
1416
|
-
refreshToken:
|
|
1438
|
+
refreshToken: j.refreshToken,
|
|
1417
1439
|
// Keep the same refresh token
|
|
1418
1440
|
expiresIn: Y.expiresIn
|
|
1419
|
-
}),
|
|
1420
|
-
const
|
|
1421
|
-
|
|
1441
|
+
}), A(Y.user), l.setUser(Y.user), w(!0);
|
|
1442
|
+
const ee = v.find((te) => te.id === C);
|
|
1443
|
+
ee && m(ee.subdomain, {
|
|
1422
1444
|
tokens: {
|
|
1423
1445
|
accessToken: Y.accessToken,
|
|
1424
|
-
refreshToken:
|
|
1446
|
+
refreshToken: j.refreshToken,
|
|
1425
1447
|
expiresIn: Y.expiresIn
|
|
1426
1448
|
},
|
|
1427
|
-
redirectPath:
|
|
1449
|
+
redirectPath: J
|
|
1428
1450
|
});
|
|
1429
1451
|
},
|
|
1430
1452
|
refreshUserTenants: async () => {
|
|
1431
|
-
const
|
|
1432
|
-
|
|
1453
|
+
const C = await l.getAuthHeaders(), O = await b.getUserTenants(C);
|
|
1454
|
+
N(O);
|
|
1433
1455
|
try {
|
|
1434
|
-
localStorage.setItem("userTenants", JSON.stringify(
|
|
1456
|
+
localStorage.setItem("userTenants", JSON.stringify(O));
|
|
1435
1457
|
} catch {
|
|
1436
1458
|
}
|
|
1437
|
-
return
|
|
1459
|
+
return O;
|
|
1438
1460
|
}
|
|
1439
1461
|
};
|
|
1440
1462
|
}, [
|
|
1441
|
-
|
|
1463
|
+
X,
|
|
1442
1464
|
l,
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
t,
|
|
1448
|
-
i,
|
|
1465
|
+
U,
|
|
1466
|
+
b,
|
|
1467
|
+
h,
|
|
1468
|
+
S,
|
|
1449
1469
|
o,
|
|
1450
1470
|
a,
|
|
1451
|
-
|
|
1452
|
-
x,
|
|
1453
|
-
R,
|
|
1454
|
-
D,
|
|
1455
|
-
P,
|
|
1456
|
-
S,
|
|
1457
|
-
L,
|
|
1471
|
+
c,
|
|
1458
1472
|
m,
|
|
1459
|
-
|
|
1473
|
+
y,
|
|
1474
|
+
T,
|
|
1475
|
+
L,
|
|
1476
|
+
P,
|
|
1477
|
+
v,
|
|
1478
|
+
B,
|
|
1479
|
+
p,
|
|
1480
|
+
K,
|
|
1481
|
+
G
|
|
1460
1482
|
]);
|
|
1461
|
-
|
|
1462
|
-
!n.initialRoles &&
|
|
1483
|
+
W.current = q.loadUserData, ne(() => {
|
|
1484
|
+
!n.initialRoles && o && (async () => {
|
|
1463
1485
|
try {
|
|
1464
|
-
|
|
1465
|
-
const
|
|
1466
|
-
|
|
1467
|
-
} catch (
|
|
1468
|
-
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:",
|
|
1486
|
+
g(!0);
|
|
1487
|
+
const ce = new de(i), fe = new We(ce), { roles: ge } = await fe.getRolesByApp(o);
|
|
1488
|
+
f(ge);
|
|
1489
|
+
} catch (ce) {
|
|
1490
|
+
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:", ce);
|
|
1469
1491
|
} finally {
|
|
1470
|
-
|
|
1492
|
+
g(!1);
|
|
1471
1493
|
}
|
|
1472
1494
|
})();
|
|
1473
|
-
}, [
|
|
1474
|
-
const [
|
|
1475
|
-
return
|
|
1476
|
-
|
|
1477
|
-
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to load user data after URL tokens:",
|
|
1495
|
+
}, [o, i, n.initialRoles]);
|
|
1496
|
+
const [V, H] = x(!1);
|
|
1497
|
+
return ne(() => {
|
|
1498
|
+
V || (H(!0), R.current.urlTokens && (Et(), I(!0), q.loadUserData().catch(($) => {
|
|
1499
|
+
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to load user data after URL tokens:", $);
|
|
1478
1500
|
}).finally(() => {
|
|
1479
|
-
|
|
1501
|
+
I(!1);
|
|
1480
1502
|
})));
|
|
1481
|
-
}, [
|
|
1482
|
-
let
|
|
1503
|
+
}, [q, V]), ne(() => {
|
|
1504
|
+
let $ = !1;
|
|
1483
1505
|
return (async () => {
|
|
1484
|
-
var
|
|
1485
|
-
if (!l.hasValidSession() && ((
|
|
1486
|
-
const
|
|
1487
|
-
|
|
1506
|
+
var ge;
|
|
1507
|
+
if (!l.hasValidSession() && ((ge = l.getTokens()) != null && ge.refreshToken) && await l.waitForPendingRefresh(), $) return;
|
|
1508
|
+
const fe = l.getUser();
|
|
1509
|
+
fe && l.hasValidSession() && A(fe), D(!1);
|
|
1488
1510
|
})(), () => {
|
|
1489
|
-
|
|
1511
|
+
$ = !0;
|
|
1490
1512
|
};
|
|
1491
|
-
}, [l]),
|
|
1492
|
-
|
|
1513
|
+
}, [l]), ne(() => {
|
|
1514
|
+
V && (R.current.urlTokens || (!T && !L && !P && l.hasValidSession() ? W.current().catch(() => {
|
|
1493
1515
|
}).finally(() => {
|
|
1494
|
-
|
|
1495
|
-
}) :
|
|
1496
|
-
}, [
|
|
1516
|
+
D(!1);
|
|
1517
|
+
}) : D(!1)));
|
|
1518
|
+
}, [T, L, P, l, V]), /* @__PURE__ */ s(Be.Provider, { value: q, children: e });
|
|
1497
1519
|
}
|
|
1498
|
-
function
|
|
1499
|
-
const n =
|
|
1520
|
+
function he() {
|
|
1521
|
+
const n = le(Be);
|
|
1500
1522
|
if (!n)
|
|
1501
1523
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
1502
1524
|
return n;
|
|
1503
1525
|
}
|
|
1504
|
-
function
|
|
1505
|
-
return
|
|
1526
|
+
function $e() {
|
|
1527
|
+
return le(Be);
|
|
1506
1528
|
}
|
|
1507
|
-
class
|
|
1529
|
+
class It {
|
|
1508
1530
|
constructor(e, t) {
|
|
1509
1531
|
this.httpService = e, this.sessionManager = t;
|
|
1510
1532
|
}
|
|
@@ -1584,66 +1606,66 @@ class Pt {
|
|
|
1584
1606
|
})).data;
|
|
1585
1607
|
}
|
|
1586
1608
|
}
|
|
1587
|
-
const Ce =
|
|
1588
|
-
function
|
|
1589
|
-
const t =
|
|
1590
|
-
const
|
|
1591
|
-
return new
|
|
1592
|
-
}, [i]),
|
|
1609
|
+
const Ce = ye(null);
|
|
1610
|
+
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, [c, m] = x([]), [y, f] = x(!1), [F, g] = x(null), [T, A] = x(!1), L = Z(() => {
|
|
1612
|
+
const d = new de(i);
|
|
1613
|
+
return new It(d);
|
|
1614
|
+
}, [i]), M = async () => {
|
|
1593
1615
|
if (!(a != null && a.id)) {
|
|
1594
|
-
|
|
1616
|
+
m([]);
|
|
1595
1617
|
return;
|
|
1596
1618
|
}
|
|
1597
|
-
f(!0),
|
|
1619
|
+
f(!0), g(null);
|
|
1598
1620
|
try {
|
|
1599
|
-
const
|
|
1600
|
-
|
|
1601
|
-
} catch (
|
|
1602
|
-
const
|
|
1603
|
-
|
|
1621
|
+
const d = await L.getTenantFeatureFlags(a.id, o);
|
|
1622
|
+
m(d);
|
|
1623
|
+
} catch (d) {
|
|
1624
|
+
const v = d instanceof Error ? d.message : "Failed to fetch feature flags";
|
|
1625
|
+
g(v), n.onError && n.onError(d instanceof Error ? d : new Error(v));
|
|
1604
1626
|
} finally {
|
|
1605
1627
|
f(!1);
|
|
1606
1628
|
}
|
|
1607
1629
|
};
|
|
1608
|
-
|
|
1630
|
+
ne(() => {
|
|
1609
1631
|
if (!i || !o) return;
|
|
1610
|
-
|
|
1611
|
-
const
|
|
1612
|
-
return () => clearInterval(
|
|
1632
|
+
M().finally(() => A(!0));
|
|
1633
|
+
const d = n.refreshInterval || 5 * 60 * 1e3, v = setInterval(M, d);
|
|
1634
|
+
return () => clearInterval(v);
|
|
1613
1635
|
}, [a == null ? void 0 : a.id, i, o, n.refreshInterval]);
|
|
1614
|
-
const P =
|
|
1615
|
-
const
|
|
1616
|
-
const
|
|
1617
|
-
return (
|
|
1618
|
-
},
|
|
1619
|
-
const
|
|
1620
|
-
return
|
|
1621
|
-
},
|
|
1622
|
-
await
|
|
1623
|
-
},
|
|
1636
|
+
const P = Z(() => {
|
|
1637
|
+
const d = (R) => {
|
|
1638
|
+
const k = c.find((I) => I.key === R);
|
|
1639
|
+
return (k == null ? void 0 : k.value) === !0;
|
|
1640
|
+
}, v = (R) => c.find((k) => k.key === R), N = (R) => {
|
|
1641
|
+
const k = c.find((I) => I.key === R);
|
|
1642
|
+
return k ? k.value ? "enabled" : "disabled" : "not_found";
|
|
1643
|
+
}, B = async () => {
|
|
1644
|
+
await M();
|
|
1645
|
+
}, w = !!(i && o) && (T || !(a != null && a.id));
|
|
1624
1646
|
return {
|
|
1625
|
-
featureFlags:
|
|
1647
|
+
featureFlags: c,
|
|
1626
1648
|
loading: y,
|
|
1627
|
-
error:
|
|
1628
|
-
isReady:
|
|
1629
|
-
isEnabled:
|
|
1630
|
-
getFlag:
|
|
1631
|
-
getFlagState:
|
|
1632
|
-
refresh:
|
|
1649
|
+
error: F,
|
|
1650
|
+
isReady: w,
|
|
1651
|
+
isEnabled: d,
|
|
1652
|
+
getFlag: v,
|
|
1653
|
+
getFlagState: N,
|
|
1654
|
+
refresh: B
|
|
1633
1655
|
};
|
|
1634
|
-
}, [
|
|
1656
|
+
}, [c, y, F, i, o, a == null ? void 0 : a.id, T]);
|
|
1635
1657
|
return /* @__PURE__ */ s(Ce.Provider, { value: P, children: e });
|
|
1636
1658
|
}
|
|
1637
|
-
function
|
|
1638
|
-
const n =
|
|
1659
|
+
function Mt() {
|
|
1660
|
+
const n = le(Ce);
|
|
1639
1661
|
if (!n)
|
|
1640
1662
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1641
1663
|
return n;
|
|
1642
1664
|
}
|
|
1643
|
-
function
|
|
1644
|
-
return
|
|
1665
|
+
function Ye() {
|
|
1666
|
+
return le(Ce);
|
|
1645
1667
|
}
|
|
1646
|
-
class
|
|
1668
|
+
class Lt {
|
|
1647
1669
|
constructor(e, t) {
|
|
1648
1670
|
this.httpService = e, this.sessionManager = t;
|
|
1649
1671
|
}
|
|
@@ -1709,68 +1731,68 @@ class Et {
|
|
|
1709
1731
|
)).data;
|
|
1710
1732
|
}
|
|
1711
1733
|
}
|
|
1712
|
-
const
|
|
1713
|
-
function
|
|
1714
|
-
const t =
|
|
1715
|
-
const P = new
|
|
1716
|
-
return new
|
|
1717
|
-
}, [i]),
|
|
1734
|
+
const He = ye(void 0);
|
|
1735
|
+
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, c] = x(null), [m, y] = x(!1), [f, F] = x(null), [g, T] = x(!1), A = Z(() => {
|
|
1737
|
+
const P = new de(i);
|
|
1738
|
+
return new Lt(P);
|
|
1739
|
+
}, [i]), L = async () => {
|
|
1718
1740
|
if (!(o != null && o.id)) {
|
|
1719
|
-
|
|
1741
|
+
c(null);
|
|
1720
1742
|
return;
|
|
1721
1743
|
}
|
|
1722
|
-
y(!0),
|
|
1744
|
+
y(!0), F(null);
|
|
1723
1745
|
try {
|
|
1724
|
-
const P = await
|
|
1725
|
-
|
|
1746
|
+
const P = await A.getTenantSubscriptionFeatures(o.id);
|
|
1747
|
+
c(P);
|
|
1726
1748
|
} catch (P) {
|
|
1727
|
-
const
|
|
1728
|
-
|
|
1749
|
+
const d = P instanceof Error ? P.message : "Failed to fetch subscription";
|
|
1750
|
+
F(d), n.onError && n.onError(P instanceof Error ? P : new Error(d));
|
|
1729
1751
|
} finally {
|
|
1730
1752
|
y(!1);
|
|
1731
1753
|
}
|
|
1732
1754
|
};
|
|
1733
|
-
|
|
1734
|
-
if (!i || (
|
|
1735
|
-
const P = n.refreshInterval || 10 * 60 * 1e3,
|
|
1736
|
-
return () => clearInterval(
|
|
1755
|
+
ne(() => {
|
|
1756
|
+
if (!i || (L().finally(() => T(!0)), !n.refreshInterval)) return;
|
|
1757
|
+
const P = n.refreshInterval || 10 * 60 * 1e3, d = setInterval(L, P);
|
|
1758
|
+
return () => clearInterval(d);
|
|
1737
1759
|
}, [o == null ? void 0 : o.id, i, n.refreshInterval]);
|
|
1738
|
-
const
|
|
1739
|
-
const P = (a == null ? void 0 : a.features) || [],
|
|
1740
|
-
const
|
|
1741
|
-
return
|
|
1742
|
-
},
|
|
1743
|
-
const
|
|
1744
|
-
return
|
|
1745
|
-
},
|
|
1746
|
-
await
|
|
1747
|
-
},
|
|
1760
|
+
const M = Z(() => {
|
|
1761
|
+
const P = (a == null ? void 0 : a.features) || [], d = (k) => {
|
|
1762
|
+
const I = P.find((l) => l.key === k);
|
|
1763
|
+
return I ? I.type === "BOOLEAN" || I.type === "boolean" ? I.value === !0 : !!I.value : !1;
|
|
1764
|
+
}, v = (k) => P.find((I) => I.key === k), N = (k, I) => {
|
|
1765
|
+
const l = P.find((z) => z.key === k);
|
|
1766
|
+
return l ? l.value : I;
|
|
1767
|
+
}, B = (k) => !a || !a.isActive ? !1 : k.includes(a.planId), w = async () => {
|
|
1768
|
+
await L();
|
|
1769
|
+
}, R = !!i && (g || !(o != null && o.id));
|
|
1748
1770
|
return {
|
|
1749
1771
|
subscription: a,
|
|
1750
1772
|
features: P,
|
|
1751
|
-
loading:
|
|
1773
|
+
loading: m,
|
|
1752
1774
|
error: f,
|
|
1753
|
-
isReady:
|
|
1754
|
-
isFeatureEnabled:
|
|
1755
|
-
getFeature:
|
|
1756
|
-
getFeatureValue:
|
|
1757
|
-
hasAllowedPlan:
|
|
1758
|
-
refresh:
|
|
1775
|
+
isReady: R,
|
|
1776
|
+
isFeatureEnabled: d,
|
|
1777
|
+
getFeature: v,
|
|
1778
|
+
getFeatureValue: N,
|
|
1779
|
+
hasAllowedPlan: B,
|
|
1780
|
+
refresh: w
|
|
1759
1781
|
};
|
|
1760
|
-
}, [a,
|
|
1761
|
-
return /* @__PURE__ */ s(
|
|
1782
|
+
}, [a, m, f, i, o == null ? void 0 : o.id, g]);
|
|
1783
|
+
return /* @__PURE__ */ s(He.Provider, { value: M, children: e });
|
|
1762
1784
|
}
|
|
1763
|
-
function
|
|
1764
|
-
const n =
|
|
1785
|
+
function Nt() {
|
|
1786
|
+
const n = le(He);
|
|
1765
1787
|
if (n === void 0)
|
|
1766
1788
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1767
1789
|
return n;
|
|
1768
1790
|
}
|
|
1769
|
-
function
|
|
1770
|
-
return
|
|
1791
|
+
function Xe() {
|
|
1792
|
+
return le(He) ?? null;
|
|
1771
1793
|
}
|
|
1772
|
-
var
|
|
1773
|
-
const
|
|
1794
|
+
var ae = /* @__PURE__ */ ((n) => (n.SUPERUSER = "SUPERUSER", n.TENANT_ADMIN = "TENANT_ADMIN", n.USER = "USER", n))(ae || {});
|
|
1795
|
+
const Oe = {
|
|
1774
1796
|
publicGuest: "/",
|
|
1775
1797
|
publicUser: "/account",
|
|
1776
1798
|
publicAdmin: "/admin",
|
|
@@ -1778,7 +1800,7 @@ const Ue = {
|
|
|
1778
1800
|
tenantUser: "/dashboard",
|
|
1779
1801
|
tenantAdmin: "/admin/dashboard",
|
|
1780
1802
|
default: "/"
|
|
1781
|
-
},
|
|
1803
|
+
}, et = {
|
|
1782
1804
|
// Public/Landing zones
|
|
1783
1805
|
landing: { tenant: "forbidden", auth: "optional" },
|
|
1784
1806
|
publicOnly: { tenant: "forbidden", auth: "forbidden" },
|
|
@@ -1791,18 +1813,18 @@ const Ue = {
|
|
|
1791
1813
|
tenantOpen: { tenant: "required", auth: "optional" },
|
|
1792
1814
|
tenantAuth: { tenant: "required", auth: "required" },
|
|
1793
1815
|
// User type zones
|
|
1794
|
-
user: { tenant: "required", auth: "required", userType:
|
|
1795
|
-
admin: { tenant: "required", auth: "required", userType:
|
|
1816
|
+
user: { tenant: "required", auth: "required", userType: ae.USER },
|
|
1817
|
+
admin: { tenant: "required", auth: "required", userType: ae.TENANT_ADMIN },
|
|
1796
1818
|
// Fully open
|
|
1797
1819
|
open: { tenant: "optional", auth: "optional" }
|
|
1798
|
-
},
|
|
1799
|
-
function
|
|
1800
|
-
const t =
|
|
1820
|
+
}, qe = ye(null);
|
|
1821
|
+
function Rr({ config: n = {}, children: e }) {
|
|
1822
|
+
const t = Z(() => {
|
|
1801
1823
|
const r = {
|
|
1802
|
-
...
|
|
1824
|
+
...Oe,
|
|
1803
1825
|
...n.zoneRoots
|
|
1804
1826
|
}, i = {
|
|
1805
|
-
...
|
|
1827
|
+
...et,
|
|
1806
1828
|
...n.presets
|
|
1807
1829
|
};
|
|
1808
1830
|
return {
|
|
@@ -1815,19 +1837,19 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1815
1837
|
returnToStorage: n.returnToStorage ?? "url"
|
|
1816
1838
|
};
|
|
1817
1839
|
}, [n]);
|
|
1818
|
-
return /* @__PURE__ */ s(
|
|
1840
|
+
return /* @__PURE__ */ s(qe.Provider, { value: t, children: e });
|
|
1819
1841
|
}
|
|
1820
|
-
function
|
|
1821
|
-
const n =
|
|
1842
|
+
function Er() {
|
|
1843
|
+
const n = le(qe);
|
|
1822
1844
|
if (!n)
|
|
1823
1845
|
throw new Error("useRouting must be used within a RoutingProvider");
|
|
1824
1846
|
return n;
|
|
1825
1847
|
}
|
|
1826
|
-
function
|
|
1827
|
-
const n =
|
|
1848
|
+
function Ft() {
|
|
1849
|
+
const n = le(qe);
|
|
1828
1850
|
return n || {
|
|
1829
|
-
zoneRoots:
|
|
1830
|
-
presets:
|
|
1851
|
+
zoneRoots: Oe,
|
|
1852
|
+
presets: et,
|
|
1831
1853
|
loadingFallback: null,
|
|
1832
1854
|
accessDeniedFallback: null,
|
|
1833
1855
|
onAccessDenied: void 0,
|
|
@@ -1835,7 +1857,7 @@ function Mt() {
|
|
|
1835
1857
|
returnToStorage: "url"
|
|
1836
1858
|
};
|
|
1837
1859
|
}
|
|
1838
|
-
const
|
|
1860
|
+
const Ge = () => /* @__PURE__ */ u(
|
|
1839
1861
|
"div",
|
|
1840
1862
|
{
|
|
1841
1863
|
style: {
|
|
@@ -1872,11 +1894,11 @@ const We = () => /* @__PURE__ */ d(
|
|
|
1872
1894
|
)
|
|
1873
1895
|
]
|
|
1874
1896
|
}
|
|
1875
|
-
),
|
|
1897
|
+
), Ke = ({
|
|
1876
1898
|
userType: n,
|
|
1877
1899
|
minUserType: e,
|
|
1878
1900
|
missingPermissions: t
|
|
1879
|
-
}) => /* @__PURE__ */
|
|
1901
|
+
}) => /* @__PURE__ */ u(
|
|
1880
1902
|
"div",
|
|
1881
1903
|
{
|
|
1882
1904
|
style: {
|
|
@@ -1894,55 +1916,55 @@ const We = () => /* @__PURE__ */ d(
|
|
|
1894
1916
|
children: [
|
|
1895
1917
|
/* @__PURE__ */ s("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
|
|
1896
1918
|
/* @__PURE__ */ s("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
|
|
1897
|
-
e && n ? /* @__PURE__ */
|
|
1898
|
-
/* @__PURE__ */
|
|
1919
|
+
e && n ? /* @__PURE__ */ u(_, { children: [
|
|
1920
|
+
/* @__PURE__ */ u("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
|
|
1899
1921
|
"This content requires ",
|
|
1900
1922
|
/* @__PURE__ */ s("strong", { children: e }),
|
|
1901
1923
|
" access level or higher."
|
|
1902
1924
|
] }),
|
|
1903
|
-
/* @__PURE__ */
|
|
1925
|
+
/* @__PURE__ */ u("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1904
1926
|
"Your current access level: ",
|
|
1905
1927
|
/* @__PURE__ */ s("strong", { children: n })
|
|
1906
1928
|
] })
|
|
1907
|
-
] }) : /* @__PURE__ */
|
|
1929
|
+
] }) : /* @__PURE__ */ u(_, { children: [
|
|
1908
1930
|
/* @__PURE__ */ s("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
|
|
1909
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1931
|
+
t && t.length > 0 && /* @__PURE__ */ u("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1910
1932
|
"Required permissions: ",
|
|
1911
1933
|
/* @__PURE__ */ s("strong", { children: t.join(", ") })
|
|
1912
1934
|
] })
|
|
1913
1935
|
] })
|
|
1914
1936
|
]
|
|
1915
1937
|
}
|
|
1916
|
-
),
|
|
1938
|
+
), Dt = (n, e) => {
|
|
1917
1939
|
const t = {
|
|
1918
|
-
[
|
|
1919
|
-
[
|
|
1920
|
-
[
|
|
1940
|
+
[ae.USER]: 1,
|
|
1941
|
+
[ae.TENANT_ADMIN]: 2,
|
|
1942
|
+
[ae.SUPERUSER]: 3
|
|
1921
1943
|
};
|
|
1922
1944
|
return t[n] >= t[e];
|
|
1923
1945
|
};
|
|
1924
|
-
function
|
|
1946
|
+
function Ir({
|
|
1925
1947
|
children: n,
|
|
1926
1948
|
fallback: e,
|
|
1927
1949
|
minUserType: t,
|
|
1928
1950
|
requiredPermissions: r,
|
|
1929
1951
|
requireAllPermissions: i = !1
|
|
1930
1952
|
}) {
|
|
1931
|
-
const { hasValidSession: o, sessionManager: a, hasPermission:
|
|
1953
|
+
const { hasValidSession: o, sessionManager: a, hasPermission: c, hasAnyPermission: m, hasAllPermissions: y } = he();
|
|
1932
1954
|
if (!o())
|
|
1933
|
-
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(
|
|
1955
|
+
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(Ge, {}) });
|
|
1934
1956
|
const f = a.getUser();
|
|
1935
1957
|
if (!f)
|
|
1936
|
-
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(
|
|
1937
|
-
if (t && !
|
|
1938
|
-
return /* @__PURE__ */ s(
|
|
1939
|
-
if (r && r.length > 0 && !(i ? y(r) :
|
|
1940
|
-
const
|
|
1941
|
-
return /* @__PURE__ */ s(
|
|
1958
|
+
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(Ge, {}) });
|
|
1959
|
+
if (t && !Dt(f.userType, t))
|
|
1960
|
+
return /* @__PURE__ */ s(Ke, { userType: f.userType, minUserType: t });
|
|
1961
|
+
if (r && r.length > 0 && !(i ? y(r) : m(r))) {
|
|
1962
|
+
const g = r.filter((T) => !c(T)).map((T) => typeof T == "string" ? T : T.name);
|
|
1963
|
+
return /* @__PURE__ */ s(Ke, { missingPermissions: g });
|
|
1942
1964
|
}
|
|
1943
1965
|
return /* @__PURE__ */ s(_, { children: n });
|
|
1944
1966
|
}
|
|
1945
|
-
const
|
|
1967
|
+
const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
1946
1968
|
"div",
|
|
1947
1969
|
{
|
|
1948
1970
|
style: {
|
|
@@ -1955,7 +1977,7 @@ const Nt = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
1955
1977
|
backgroundColor: "#f9fafb",
|
|
1956
1978
|
textAlign: "center"
|
|
1957
1979
|
},
|
|
1958
|
-
children: /* @__PURE__ */
|
|
1980
|
+
children: /* @__PURE__ */ u(
|
|
1959
1981
|
"div",
|
|
1960
1982
|
{
|
|
1961
1983
|
style: {
|
|
@@ -1969,7 +1991,7 @@ const Nt = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
1969
1991
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
|
|
1970
1992
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
|
|
1971
1993
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
|
|
1972
|
-
/* @__PURE__ */
|
|
1994
|
+
/* @__PURE__ */ u("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1973
1995
|
"Redirecting to ",
|
|
1974
1996
|
n,
|
|
1975
1997
|
"..."
|
|
@@ -1978,7 +2000,7 @@ const Nt = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
1978
2000
|
}
|
|
1979
2001
|
)
|
|
1980
2002
|
}
|
|
1981
|
-
),
|
|
2003
|
+
), Qe = ({
|
|
1982
2004
|
userType: n,
|
|
1983
2005
|
requiredUserType: e,
|
|
1984
2006
|
missingPermissions: t
|
|
@@ -1995,7 +2017,7 @@ const Nt = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
1995
2017
|
backgroundColor: "#f9fafb",
|
|
1996
2018
|
textAlign: "center"
|
|
1997
2019
|
},
|
|
1998
|
-
children: /* @__PURE__ */
|
|
2020
|
+
children: /* @__PURE__ */ u(
|
|
1999
2021
|
"div",
|
|
2000
2022
|
{
|
|
2001
2023
|
style: {
|
|
@@ -2008,19 +2030,19 @@ const Nt = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2008
2030
|
children: [
|
|
2009
2031
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
|
|
2010
2032
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
|
|
2011
|
-
e && n ? /* @__PURE__ */
|
|
2012
|
-
/* @__PURE__ */
|
|
2033
|
+
e && n ? /* @__PURE__ */ u(_, { children: [
|
|
2034
|
+
/* @__PURE__ */ u("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
|
|
2013
2035
|
"This page requires ",
|
|
2014
2036
|
/* @__PURE__ */ s("strong", { children: e }),
|
|
2015
2037
|
" access."
|
|
2016
2038
|
] }),
|
|
2017
|
-
/* @__PURE__ */
|
|
2039
|
+
/* @__PURE__ */ u("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
2018
2040
|
"Your current user type: ",
|
|
2019
2041
|
/* @__PURE__ */ s("strong", { children: n })
|
|
2020
2042
|
] })
|
|
2021
|
-
] }) : /* @__PURE__ */
|
|
2043
|
+
] }) : /* @__PURE__ */ u(_, { children: [
|
|
2022
2044
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
|
|
2023
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
2045
|
+
t && t.length > 0 && /* @__PURE__ */ u("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
2024
2046
|
"Required permissions: ",
|
|
2025
2047
|
/* @__PURE__ */ s("strong", { children: t.join(", ") })
|
|
2026
2048
|
] })
|
|
@@ -2029,8 +2051,8 @@ const Nt = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2029
2051
|
}
|
|
2030
2052
|
)
|
|
2031
2053
|
}
|
|
2032
|
-
),
|
|
2033
|
-
function
|
|
2054
|
+
), Bt = (n, e) => n === e;
|
|
2055
|
+
function Mr({
|
|
2034
2056
|
children: n,
|
|
2035
2057
|
redirectTo: e = "/login",
|
|
2036
2058
|
requiredUserType: t,
|
|
@@ -2038,34 +2060,34 @@ function Rr({
|
|
|
2038
2060
|
requireAllPermissions: i = !1,
|
|
2039
2061
|
fallback: o
|
|
2040
2062
|
}) {
|
|
2041
|
-
const { hasValidSession: a, sessionManager:
|
|
2042
|
-
if (
|
|
2063
|
+
const { hasValidSession: a, sessionManager: c, hasPermission: m, hasAnyPermission: y, hasAllPermissions: f } = he(), F = xe();
|
|
2064
|
+
if (ne(() => {
|
|
2043
2065
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2044
2066
|
"[react-identity-access] ProtectedRoute is deprecated. Use AuthenticatedZone or AdminZone from ZoneRoute instead."
|
|
2045
2067
|
);
|
|
2046
2068
|
}, []), !a())
|
|
2047
|
-
return o ? /* @__PURE__ */ s(_, { children: o }) : /* @__PURE__ */
|
|
2048
|
-
/* @__PURE__ */ s(
|
|
2049
|
-
/* @__PURE__ */ s(
|
|
2069
|
+
return o ? /* @__PURE__ */ s(_, { children: o }) : /* @__PURE__ */ u(_, { children: [
|
|
2070
|
+
/* @__PURE__ */ s(Ut, { redirectPath: e }),
|
|
2071
|
+
/* @__PURE__ */ s(Se, { to: e, state: { from: F.pathname }, replace: !0 })
|
|
2050
2072
|
] });
|
|
2051
|
-
const
|
|
2052
|
-
if (!
|
|
2053
|
-
return /* @__PURE__ */ s(
|
|
2054
|
-
if (t && !
|
|
2073
|
+
const g = c.getUser();
|
|
2074
|
+
if (!g)
|
|
2075
|
+
return /* @__PURE__ */ s(Se, { to: e, state: { from: F.pathname }, replace: !0 });
|
|
2076
|
+
if (t && !Bt(g.userType, t))
|
|
2055
2077
|
return /* @__PURE__ */ s(
|
|
2056
|
-
|
|
2078
|
+
Qe,
|
|
2057
2079
|
{
|
|
2058
|
-
userType:
|
|
2080
|
+
userType: g.userType,
|
|
2059
2081
|
requiredUserType: t
|
|
2060
2082
|
}
|
|
2061
2083
|
);
|
|
2062
2084
|
if (r && r.length > 0 && !(i ? f(r) : y(r))) {
|
|
2063
|
-
const
|
|
2064
|
-
return /* @__PURE__ */ s(
|
|
2085
|
+
const A = r.filter((L) => !m(L)).map((L) => typeof L == "string" ? L : L.name);
|
|
2086
|
+
return /* @__PURE__ */ s(Qe, { missingPermissions: A });
|
|
2065
2087
|
}
|
|
2066
2088
|
return /* @__PURE__ */ s(_, { children: n });
|
|
2067
2089
|
}
|
|
2068
|
-
const
|
|
2090
|
+
const $t = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
2069
2091
|
"div",
|
|
2070
2092
|
{
|
|
2071
2093
|
style: {
|
|
@@ -2078,7 +2100,7 @@ const Ft = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2078
2100
|
backgroundColor: "#f9fafb",
|
|
2079
2101
|
textAlign: "center"
|
|
2080
2102
|
},
|
|
2081
|
-
children: /* @__PURE__ */
|
|
2103
|
+
children: /* @__PURE__ */ u(
|
|
2082
2104
|
"div",
|
|
2083
2105
|
{
|
|
2084
2106
|
style: {
|
|
@@ -2092,7 +2114,7 @@ const Ft = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2092
2114
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
|
|
2093
2115
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
|
|
2094
2116
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
|
|
2095
|
-
/* @__PURE__ */
|
|
2117
|
+
/* @__PURE__ */ u("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
2096
2118
|
"Redirecting to ",
|
|
2097
2119
|
n,
|
|
2098
2120
|
"..."
|
|
@@ -2102,15 +2124,15 @@ const Ft = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2102
2124
|
)
|
|
2103
2125
|
}
|
|
2104
2126
|
);
|
|
2105
|
-
function
|
|
2106
|
-
const { tenant: r, isLoading: i, error: o } =
|
|
2107
|
-
return
|
|
2127
|
+
function Lr({ children: n, redirectTo: e = "/", fallback: t }) {
|
|
2128
|
+
const { tenant: r, isLoading: i, error: o } = Je(), a = xe();
|
|
2129
|
+
return ne(() => {
|
|
2108
2130
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2109
2131
|
"[react-identity-access] TenantRoute is deprecated. Use TenantZone from ZoneRoute instead."
|
|
2110
2132
|
);
|
|
2111
|
-
}, []), i || o ? null : r ? /* @__PURE__ */ s(_, { children: n }) : t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */
|
|
2112
|
-
/* @__PURE__ */ s(
|
|
2113
|
-
/* @__PURE__ */ s(
|
|
2133
|
+
}, []), i || o ? null : r ? /* @__PURE__ */ s(_, { children: n }) : t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ u(_, { children: [
|
|
2134
|
+
/* @__PURE__ */ s($t, { redirectPath: e }),
|
|
2135
|
+
/* @__PURE__ */ s(Se, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
2114
2136
|
] });
|
|
2115
2137
|
}
|
|
2116
2138
|
const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
@@ -2126,7 +2148,7 @@ const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2126
2148
|
backgroundColor: "#f9fafb",
|
|
2127
2149
|
textAlign: "center"
|
|
2128
2150
|
},
|
|
2129
|
-
children: /* @__PURE__ */
|
|
2151
|
+
children: /* @__PURE__ */ u(
|
|
2130
2152
|
"div",
|
|
2131
2153
|
{
|
|
2132
2154
|
style: {
|
|
@@ -2140,7 +2162,7 @@ const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2140
2162
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
|
|
2141
2163
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
|
|
2142
2164
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
|
|
2143
|
-
/* @__PURE__ */
|
|
2165
|
+
/* @__PURE__ */ u("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
2144
2166
|
"Redirecting to ",
|
|
2145
2167
|
n,
|
|
2146
2168
|
"..."
|
|
@@ -2150,41 +2172,41 @@ const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2150
2172
|
)
|
|
2151
2173
|
}
|
|
2152
2174
|
);
|
|
2153
|
-
function
|
|
2154
|
-
const { tenant: r, isLoading: i, error: o } =
|
|
2155
|
-
return
|
|
2175
|
+
function Nr({ children: n, redirectTo: e = "/dashboard", fallback: t }) {
|
|
2176
|
+
const { tenant: r, isLoading: i, error: o } = Je(), a = xe();
|
|
2177
|
+
return ne(() => {
|
|
2156
2178
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2157
2179
|
"[react-identity-access] LandingRoute is deprecated. Use PublicZone from ZoneRoute instead."
|
|
2158
2180
|
);
|
|
2159
|
-
}, []), i || o ? null : r ? t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */
|
|
2181
|
+
}, []), i || o ? null : r ? t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ u(_, { children: [
|
|
2160
2182
|
/* @__PURE__ */ s(Ct, { redirectPath: e }),
|
|
2161
|
-
/* @__PURE__ */ s(
|
|
2183
|
+
/* @__PURE__ */ s(Se, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
2162
2184
|
] }) : /* @__PURE__ */ s(_, { children: n });
|
|
2163
2185
|
}
|
|
2164
|
-
function
|
|
2186
|
+
function Ht(n, e) {
|
|
2165
2187
|
return e ? n ? Array.isArray(e) ? e.includes(n) : n === e : !1 : !0;
|
|
2166
2188
|
}
|
|
2167
|
-
function
|
|
2189
|
+
function Ze(n, e) {
|
|
2168
2190
|
return !n || n === "optional" ? "skip" : n === "required" ? e ? "pass" : "fail" : n === "forbidden" ? e ? "fail" : "pass" : "skip";
|
|
2169
2191
|
}
|
|
2170
|
-
function
|
|
2171
|
-
return
|
|
2192
|
+
function Ot(n, e) {
|
|
2193
|
+
return Ze(n.tenant, e.hasTenant) === "fail" ? e.hasTenant ? "has_tenant" : "no_tenant" : Ze(n.auth, e.isAuthenticated) === "fail" ? e.isAuthenticated ? "already_authenticated" : "not_authenticated" : n.userType && e.isAuthenticated && !Ht(e.userType, n.userType) ? "wrong_user_type" : n.permissions && n.permissions.length > 0 && !(n.requireAllPermissions !== !1 ? (o) => o.every((a) => e.permissions.includes(a)) : (o) => o.some((a) => e.permissions.includes(a)))(n.permissions) ? "missing_permissions" : null;
|
|
2172
2194
|
}
|
|
2173
|
-
function
|
|
2174
|
-
return n.hasTenant ? n.isAuthenticated ? n.userType ===
|
|
2195
|
+
function qt(n, e) {
|
|
2196
|
+
return n.hasTenant ? n.isAuthenticated ? n.userType === ae.TENANT_ADMIN ? e.tenantAdmin : e.tenantUser : e.tenantGuest : n.isAuthenticated ? n.userType === ae.TENANT_ADMIN ? e.publicAdmin : e.publicUser : e.publicGuest;
|
|
2175
2197
|
}
|
|
2176
|
-
function
|
|
2198
|
+
function _t(n, e, t, r, i) {
|
|
2177
2199
|
if (!e || i !== "url")
|
|
2178
2200
|
return n;
|
|
2179
2201
|
const o = typeof e == "string" ? e : t, a = n.includes("?") ? "&" : "?";
|
|
2180
2202
|
return `${n}${a}${r}=${encodeURIComponent(o)}`;
|
|
2181
2203
|
}
|
|
2182
|
-
function
|
|
2204
|
+
function zt(n, e, t) {
|
|
2183
2205
|
if (!n || t === "url") return;
|
|
2184
2206
|
const r = typeof n == "string" ? n : e, i = "zone_return_to";
|
|
2185
2207
|
t === "session" ? sessionStorage.setItem(i, r) : t === "local" && localStorage.setItem(i, r);
|
|
2186
2208
|
}
|
|
2187
|
-
const
|
|
2209
|
+
const ue = ({
|
|
2188
2210
|
children: n,
|
|
2189
2211
|
preset: e,
|
|
2190
2212
|
tenant: t,
|
|
@@ -2192,83 +2214,83 @@ const ce = ({
|
|
|
2192
2214
|
userType: i,
|
|
2193
2215
|
requiredPermissions: o,
|
|
2194
2216
|
requireAllPermissions: a = !0,
|
|
2195
|
-
returnTo:
|
|
2196
|
-
onAccessDenied:
|
|
2217
|
+
returnTo: c,
|
|
2218
|
+
onAccessDenied: m,
|
|
2197
2219
|
redirectTo: y,
|
|
2198
2220
|
loadingFallback: f,
|
|
2199
|
-
accessDeniedFallback:
|
|
2221
|
+
accessDeniedFallback: F
|
|
2200
2222
|
}) => {
|
|
2201
|
-
const
|
|
2223
|
+
const g = xe(), { isAuthenticated: T, isAuthInitializing: A, currentUser: L, userPermissions: M } = he(), { tenant: P, isTenantLoading: d } = Te(), v = Ft(), N = Z(() => {
|
|
2202
2224
|
if (e)
|
|
2203
|
-
return
|
|
2204
|
-
}, [e,
|
|
2225
|
+
return v.presets[e];
|
|
2226
|
+
}, [e, v.presets]), B = Z(
|
|
2205
2227
|
() => ({
|
|
2206
|
-
tenant: t ?? (
|
|
2207
|
-
auth: r ?? (
|
|
2208
|
-
userType: i ?? (
|
|
2209
|
-
permissions: o ?? (
|
|
2228
|
+
tenant: t ?? (N == null ? void 0 : N.tenant),
|
|
2229
|
+
auth: r ?? (N == null ? void 0 : N.auth),
|
|
2230
|
+
userType: i ?? (N == null ? void 0 : N.userType),
|
|
2231
|
+
permissions: o ?? (N == null ? void 0 : N.requiredPermissions),
|
|
2210
2232
|
requireAllPermissions: a
|
|
2211
2233
|
}),
|
|
2212
|
-
[t, r, i, o,
|
|
2213
|
-
),
|
|
2234
|
+
[t, r, i, o, N, a]
|
|
2235
|
+
), w = Z(
|
|
2214
2236
|
() => ({
|
|
2215
2237
|
hasTenant: !!P,
|
|
2216
|
-
isAuthenticated:
|
|
2217
|
-
userType:
|
|
2218
|
-
permissions:
|
|
2219
|
-
isLoading:
|
|
2238
|
+
isAuthenticated: T,
|
|
2239
|
+
userType: L == null ? void 0 : L.userType,
|
|
2240
|
+
permissions: M,
|
|
2241
|
+
isLoading: A || d
|
|
2220
2242
|
}),
|
|
2221
2243
|
[
|
|
2222
2244
|
P,
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2245
|
+
T,
|
|
2246
|
+
L == null ? void 0 : L.userType,
|
|
2247
|
+
M,
|
|
2248
|
+
A,
|
|
2249
|
+
d
|
|
2228
2250
|
]
|
|
2229
|
-
),
|
|
2230
|
-
type:
|
|
2251
|
+
), R = Z(() => w.isLoading ? null : Ot(B, w), [B, w]), k = Z(() => R ? y || qt(w, v.zoneRoots) : null, [R, y, w, v.zoneRoots]), I = Z(() => !R || !k ? null : {
|
|
2252
|
+
type: R,
|
|
2231
2253
|
required: {
|
|
2232
|
-
tenant:
|
|
2233
|
-
auth:
|
|
2234
|
-
userType:
|
|
2235
|
-
permissions:
|
|
2254
|
+
tenant: B.tenant,
|
|
2255
|
+
auth: B.auth,
|
|
2256
|
+
userType: B.userType,
|
|
2257
|
+
permissions: B.permissions
|
|
2236
2258
|
},
|
|
2237
2259
|
current: {
|
|
2238
|
-
hasTenant:
|
|
2239
|
-
isAuthenticated:
|
|
2240
|
-
userType:
|
|
2241
|
-
permissions:
|
|
2260
|
+
hasTenant: w.hasTenant,
|
|
2261
|
+
isAuthenticated: w.isAuthenticated,
|
|
2262
|
+
userType: w.userType,
|
|
2263
|
+
permissions: w.permissions
|
|
2242
2264
|
},
|
|
2243
|
-
redirectTo:
|
|
2244
|
-
}, [
|
|
2245
|
-
if (
|
|
2246
|
-
|
|
2247
|
-
}, [
|
|
2248
|
-
|
|
2265
|
+
redirectTo: k
|
|
2266
|
+
}, [R, k, B, w]);
|
|
2267
|
+
if (ne(() => {
|
|
2268
|
+
I && (m ? m(I) : v.onAccessDenied && v.onAccessDenied(I));
|
|
2269
|
+
}, [I, m, v]), ne(() => {
|
|
2270
|
+
I && c && zt(c, g.pathname + g.search, v.returnToStorage);
|
|
2249
2271
|
}, [
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
]),
|
|
2256
|
-
return /* @__PURE__ */ s(_, { children: f ??
|
|
2257
|
-
if (
|
|
2258
|
-
const
|
|
2259
|
-
if (
|
|
2260
|
-
return /* @__PURE__ */ s(_, { children:
|
|
2261
|
-
const
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2272
|
+
I,
|
|
2273
|
+
c,
|
|
2274
|
+
g.pathname,
|
|
2275
|
+
g.search,
|
|
2276
|
+
v.returnToStorage
|
|
2277
|
+
]), w.isLoading)
|
|
2278
|
+
return /* @__PURE__ */ s(_, { children: f ?? v.loadingFallback ?? null });
|
|
2279
|
+
if (I && k) {
|
|
2280
|
+
const l = F ?? v.accessDeniedFallback;
|
|
2281
|
+
if (l)
|
|
2282
|
+
return /* @__PURE__ */ s(_, { children: l });
|
|
2283
|
+
const z = _t(
|
|
2284
|
+
k,
|
|
2285
|
+
c,
|
|
2286
|
+
g.pathname + g.search,
|
|
2287
|
+
v.returnToParam,
|
|
2288
|
+
v.returnToStorage
|
|
2267
2289
|
);
|
|
2268
|
-
return /* @__PURE__ */ s(
|
|
2290
|
+
return /* @__PURE__ */ s(Se, { to: z, replace: !0 });
|
|
2269
2291
|
}
|
|
2270
2292
|
return /* @__PURE__ */ s(_, { children: n });
|
|
2271
|
-
},
|
|
2293
|
+
}, Fr = (n) => /* @__PURE__ */ s(ue, { tenant: "required", ...n }), Dr = (n) => /* @__PURE__ */ s(ue, { tenant: "forbidden", ...n }), Ur = (n) => /* @__PURE__ */ s(ue, { auth: "required", ...n }), Br = (n) => /* @__PURE__ */ s(ue, { auth: "forbidden", ...n }), $r = (n) => /* @__PURE__ */ s(ue, { auth: "required", userType: ae.TENANT_ADMIN, ...n }), Cr = (n) => /* @__PURE__ */ s(ue, { auth: "required", userType: ae.USER, ...n }), Hr = (n) => /* @__PURE__ */ s(ue, { tenant: "optional", auth: "optional", ...n }), Or = (n) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "required", ...n }), qr = (n) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "optional", ...n }), _r = (n) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "forbidden", ...n }), Vt = () => /* @__PURE__ */ u(
|
|
2272
2294
|
"div",
|
|
2273
2295
|
{
|
|
2274
2296
|
style: {
|
|
@@ -2285,14 +2307,14 @@ const ce = ({
|
|
|
2285
2307
|
]
|
|
2286
2308
|
}
|
|
2287
2309
|
);
|
|
2288
|
-
function
|
|
2310
|
+
function zr({
|
|
2289
2311
|
children: n,
|
|
2290
|
-
fallback: e = /* @__PURE__ */ s(
|
|
2312
|
+
fallback: e = /* @__PURE__ */ s(Vt, {}),
|
|
2291
2313
|
allowedPlans: t,
|
|
2292
2314
|
requiredFeature: r
|
|
2293
2315
|
}) {
|
|
2294
|
-
const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading:
|
|
2295
|
-
return
|
|
2316
|
+
const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: c } = Nt();
|
|
2317
|
+
return c ? /* @__PURE__ */ s(
|
|
2296
2318
|
"div",
|
|
2297
2319
|
{
|
|
2298
2320
|
style: {
|
|
@@ -2304,7 +2326,7 @@ function Or({
|
|
|
2304
2326
|
}
|
|
2305
2327
|
) : 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 });
|
|
2306
2328
|
}
|
|
2307
|
-
const
|
|
2329
|
+
const Wt = ({ flagName: n }) => /* @__PURE__ */ u(
|
|
2308
2330
|
"div",
|
|
2309
2331
|
{
|
|
2310
2332
|
style: {
|
|
@@ -2323,7 +2345,7 @@ const zt = ({ flagName: n }) => /* @__PURE__ */ d(
|
|
|
2323
2345
|
children: [
|
|
2324
2346
|
/* @__PURE__ */ s("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
|
|
2325
2347
|
/* @__PURE__ */ s("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
|
|
2326
|
-
/* @__PURE__ */
|
|
2348
|
+
/* @__PURE__ */ u("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
|
|
2327
2349
|
'Feature flag "',
|
|
2328
2350
|
n,
|
|
2329
2351
|
'" is disabled'
|
|
@@ -2331,8 +2353,8 @@ const zt = ({ flagName: n }) => /* @__PURE__ */ d(
|
|
|
2331
2353
|
]
|
|
2332
2354
|
}
|
|
2333
2355
|
);
|
|
2334
|
-
function
|
|
2335
|
-
const { isEnabled: r, loading: i } =
|
|
2356
|
+
function Vr({ name: n, children: e, fallback: t }) {
|
|
2357
|
+
const { isEnabled: r, loading: i } = Mt();
|
|
2336
2358
|
return i ? /* @__PURE__ */ s(
|
|
2337
2359
|
"div",
|
|
2338
2360
|
{
|
|
@@ -2346,9 +2368,9 @@ function qr({ name: n, children: e, fallback: t }) {
|
|
|
2346
2368
|
},
|
|
2347
2369
|
children: "Loading feature flags..."
|
|
2348
2370
|
}
|
|
2349
|
-
) : r(n) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: t || /* @__PURE__ */ s(
|
|
2371
|
+
) : r(n) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: t || /* @__PURE__ */ s(Wt, { flagName: n }) });
|
|
2350
2372
|
}
|
|
2351
|
-
const
|
|
2373
|
+
const jt = () => /* @__PURE__ */ u(
|
|
2352
2374
|
"svg",
|
|
2353
2375
|
{
|
|
2354
2376
|
width: "16",
|
|
@@ -2365,7 +2387,7 @@ const _t = () => /* @__PURE__ */ d(
|
|
|
2365
2387
|
/* @__PURE__ */ s("circle", { cx: "12", cy: "12", r: "3" })
|
|
2366
2388
|
]
|
|
2367
2389
|
}
|
|
2368
|
-
),
|
|
2390
|
+
), Gt = () => /* @__PURE__ */ u(
|
|
2369
2391
|
"svg",
|
|
2370
2392
|
{
|
|
2371
2393
|
width: "16",
|
|
@@ -2382,10 +2404,10 @@ const _t = () => /* @__PURE__ */ d(
|
|
|
2382
2404
|
/* @__PURE__ */ s("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
2383
2405
|
]
|
|
2384
2406
|
}
|
|
2385
|
-
),
|
|
2386
|
-
showPassword: /* @__PURE__ */ s(
|
|
2387
|
-
hidePassword: /* @__PURE__ */ s(
|
|
2388
|
-
},
|
|
2407
|
+
), Kt = {
|
|
2408
|
+
showPassword: /* @__PURE__ */ s(jt, {}),
|
|
2409
|
+
hidePassword: /* @__PURE__ */ s(Gt, {})
|
|
2410
|
+
}, Qt = {
|
|
2389
2411
|
title: "Sign In",
|
|
2390
2412
|
usernameLabel: "Email or Phone",
|
|
2391
2413
|
usernamePlaceholder: "Enter your email or phone number",
|
|
@@ -2403,7 +2425,7 @@ const _t = () => /* @__PURE__ */ d(
|
|
|
2403
2425
|
dividerBullet: "•",
|
|
2404
2426
|
showPasswordAriaLabel: "Show password",
|
|
2405
2427
|
hidePasswordAriaLabel: "Hide password"
|
|
2406
|
-
},
|
|
2428
|
+
}, Zt = {
|
|
2407
2429
|
container: {
|
|
2408
2430
|
maxWidth: "400px",
|
|
2409
2431
|
width: "100%",
|
|
@@ -2513,7 +2535,7 @@ const _t = () => /* @__PURE__ */ d(
|
|
|
2513
2535
|
paddingRight: "2.5rem"
|
|
2514
2536
|
}
|
|
2515
2537
|
};
|
|
2516
|
-
function
|
|
2538
|
+
function Wr({
|
|
2517
2539
|
copy: n = {},
|
|
2518
2540
|
styles: e = {},
|
|
2519
2541
|
icons: t = {},
|
|
@@ -2521,124 +2543,120 @@ function zr({
|
|
|
2521
2543
|
onError: i,
|
|
2522
2544
|
onForgotPassword: o,
|
|
2523
2545
|
onSignupClick: a,
|
|
2524
|
-
onMagicLinkClick:
|
|
2525
|
-
showForgotPassword:
|
|
2546
|
+
onMagicLinkClick: c,
|
|
2547
|
+
showForgotPassword: m = !0,
|
|
2526
2548
|
showSignupLink: y = !0,
|
|
2527
2549
|
showMagicLinkOption: f = !0,
|
|
2528
|
-
className:
|
|
2550
|
+
className: F
|
|
2529
2551
|
}) {
|
|
2530
|
-
const [
|
|
2531
|
-
const
|
|
2532
|
-
return
|
|
2533
|
-
},
|
|
2534
|
-
if (
|
|
2535
|
-
|
|
2536
|
-
M(b.tenantNotFoundError);
|
|
2537
|
-
return;
|
|
2538
|
-
}
|
|
2539
|
-
S(!0), M("");
|
|
2552
|
+
const [g, T] = x(""), [A, L] = x(""), [M, P] = x(!1), [d, v] = x(!1), [N, B] = x(""), [w, R] = x({}), { login: k } = he(), I = { ...Qt, ...n }, l = { ...Zt, ...e }, z = { ...Kt, ...t }, D = () => {
|
|
2553
|
+
const h = {};
|
|
2554
|
+
return g.trim() || (h.username = !0), A.trim() || (h.password = !0), R(h), Object.keys(h).length === 0;
|
|
2555
|
+
}, p = async (h) => {
|
|
2556
|
+
if (h.preventDefault(), !!D()) {
|
|
2557
|
+
v(!0), B("");
|
|
2540
2558
|
try {
|
|
2541
|
-
const
|
|
2542
|
-
username:
|
|
2543
|
-
password:
|
|
2559
|
+
const S = await k({
|
|
2560
|
+
username: g,
|
|
2561
|
+
password: A
|
|
2544
2562
|
// tenantId inferred from context automatically
|
|
2545
2563
|
});
|
|
2546
|
-
r == null || r(
|
|
2547
|
-
} catch (
|
|
2548
|
-
const
|
|
2549
|
-
|
|
2564
|
+
r == null || r(S);
|
|
2565
|
+
} catch (S) {
|
|
2566
|
+
const E = S.message || I.errorMessage;
|
|
2567
|
+
B(E), i == null || i(E);
|
|
2550
2568
|
} finally {
|
|
2551
|
-
|
|
2569
|
+
v(!1);
|
|
2552
2570
|
}
|
|
2553
2571
|
}
|
|
2554
|
-
},
|
|
2555
|
-
...
|
|
2556
|
-
...
|
|
2557
|
-
}),
|
|
2558
|
-
...
|
|
2559
|
-
...
|
|
2560
|
-
...!
|
|
2572
|
+
}, U = (h) => ({
|
|
2573
|
+
...l.input,
|
|
2574
|
+
...w[h] ? l.inputError : {}
|
|
2575
|
+
}), b = () => ({
|
|
2576
|
+
...l.button,
|
|
2577
|
+
...d ? l.buttonLoading : {},
|
|
2578
|
+
...!g || !A || d ? l.buttonDisabled : {}
|
|
2561
2579
|
});
|
|
2562
|
-
return /* @__PURE__ */
|
|
2563
|
-
/* @__PURE__ */ s("h2", { style:
|
|
2564
|
-
/* @__PURE__ */
|
|
2565
|
-
/* @__PURE__ */
|
|
2566
|
-
/* @__PURE__ */ s("label", { style:
|
|
2580
|
+
return /* @__PURE__ */ u("div", { className: F, style: l.container, children: [
|
|
2581
|
+
/* @__PURE__ */ s("h2", { style: l.title, children: I.title }),
|
|
2582
|
+
/* @__PURE__ */ u("form", { onSubmit: p, style: l.form, children: [
|
|
2583
|
+
/* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
|
|
2584
|
+
/* @__PURE__ */ s("label", { style: l.label, children: I.usernameLabel }),
|
|
2567
2585
|
/* @__PURE__ */ s(
|
|
2568
2586
|
"input",
|
|
2569
2587
|
{
|
|
2570
2588
|
id: "username",
|
|
2571
2589
|
name: "username",
|
|
2572
2590
|
type: "text",
|
|
2573
|
-
value:
|
|
2574
|
-
onChange: (
|
|
2575
|
-
|
|
2591
|
+
value: g,
|
|
2592
|
+
onChange: (h) => {
|
|
2593
|
+
T(h.target.value), w.username && R((S) => ({ ...S, username: !1 }));
|
|
2576
2594
|
},
|
|
2577
|
-
placeholder:
|
|
2578
|
-
style:
|
|
2579
|
-
disabled:
|
|
2595
|
+
placeholder: I.usernamePlaceholder,
|
|
2596
|
+
style: U("username"),
|
|
2597
|
+
disabled: d
|
|
2580
2598
|
}
|
|
2581
2599
|
)
|
|
2582
2600
|
] }),
|
|
2583
|
-
/* @__PURE__ */
|
|
2584
|
-
/* @__PURE__ */ s("label", { style:
|
|
2585
|
-
/* @__PURE__ */
|
|
2601
|
+
/* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
|
|
2602
|
+
/* @__PURE__ */ s("label", { style: l.label, children: I.passwordLabel }),
|
|
2603
|
+
/* @__PURE__ */ u("div", { style: l.inputContainer, children: [
|
|
2586
2604
|
/* @__PURE__ */ s(
|
|
2587
2605
|
"input",
|
|
2588
2606
|
{
|
|
2589
2607
|
id: "password",
|
|
2590
2608
|
name: "password",
|
|
2591
|
-
type:
|
|
2592
|
-
value:
|
|
2593
|
-
onChange: (
|
|
2594
|
-
|
|
2609
|
+
type: M ? "text" : "password",
|
|
2610
|
+
value: A,
|
|
2611
|
+
onChange: (h) => {
|
|
2612
|
+
L(h.target.value), w.password && R((S) => ({ ...S, password: !1 }));
|
|
2595
2613
|
},
|
|
2596
|
-
placeholder:
|
|
2614
|
+
placeholder: I.passwordPlaceholder,
|
|
2597
2615
|
style: {
|
|
2598
|
-
...
|
|
2599
|
-
...
|
|
2616
|
+
...U("password"),
|
|
2617
|
+
...l.inputWithIcon
|
|
2600
2618
|
},
|
|
2601
|
-
disabled:
|
|
2619
|
+
disabled: d
|
|
2602
2620
|
}
|
|
2603
2621
|
),
|
|
2604
2622
|
/* @__PURE__ */ s(
|
|
2605
2623
|
"button",
|
|
2606
2624
|
{
|
|
2607
2625
|
type: "button",
|
|
2608
|
-
onClick: () => P(!
|
|
2609
|
-
style:
|
|
2610
|
-
disabled:
|
|
2611
|
-
"aria-label":
|
|
2612
|
-
children:
|
|
2626
|
+
onClick: () => P(!M),
|
|
2627
|
+
style: l.passwordToggle,
|
|
2628
|
+
disabled: d,
|
|
2629
|
+
"aria-label": M ? I.hidePasswordAriaLabel : I.showPasswordAriaLabel,
|
|
2630
|
+
children: M ? z.hidePassword : z.showPassword
|
|
2613
2631
|
}
|
|
2614
2632
|
)
|
|
2615
2633
|
] })
|
|
2616
2634
|
] }),
|
|
2617
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: !
|
|
2618
|
-
|
|
2635
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !g || !A || d, style: b(), children: d ? I.loadingText : I.submitButton }),
|
|
2636
|
+
N && /* @__PURE__ */ s("div", { style: l.errorText, children: N })
|
|
2619
2637
|
] }),
|
|
2620
|
-
(
|
|
2621
|
-
f && /* @__PURE__ */
|
|
2622
|
-
/* @__PURE__ */
|
|
2623
|
-
|
|
2638
|
+
(m || y || f) && /* @__PURE__ */ u("div", { style: l.linkContainer, children: [
|
|
2639
|
+
f && /* @__PURE__ */ u("div", { children: [
|
|
2640
|
+
/* @__PURE__ */ u("span", { style: l.divider, children: [
|
|
2641
|
+
I.magicLinkText,
|
|
2624
2642
|
" "
|
|
2625
2643
|
] }),
|
|
2626
|
-
/* @__PURE__ */ s("a", { onClick:
|
|
2644
|
+
/* @__PURE__ */ s("a", { onClick: c, style: l.link, children: I.magicLinkLink })
|
|
2627
2645
|
] }),
|
|
2628
|
-
f && (
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
y && /* @__PURE__ */
|
|
2632
|
-
/* @__PURE__ */
|
|
2633
|
-
|
|
2646
|
+
f && (m || y) && /* @__PURE__ */ s("div", { style: l.divider, children: I.dividerBullet }),
|
|
2647
|
+
m && /* @__PURE__ */ s("a", { onClick: o, style: l.link, children: I.forgotPasswordLink }),
|
|
2648
|
+
m && y && /* @__PURE__ */ s("div", { style: l.divider, children: I.dividerBullet }),
|
|
2649
|
+
y && /* @__PURE__ */ u("div", { children: [
|
|
2650
|
+
/* @__PURE__ */ u("span", { style: l.divider, children: [
|
|
2651
|
+
I.signupText,
|
|
2634
2652
|
" "
|
|
2635
2653
|
] }),
|
|
2636
|
-
/* @__PURE__ */ s("a", { onClick: a, style:
|
|
2654
|
+
/* @__PURE__ */ s("a", { onClick: a, style: l.link, children: I.signupLink })
|
|
2637
2655
|
] })
|
|
2638
2656
|
] })
|
|
2639
2657
|
] });
|
|
2640
2658
|
}
|
|
2641
|
-
const
|
|
2659
|
+
const Jt = {
|
|
2642
2660
|
title: "Create Account",
|
|
2643
2661
|
nameLabel: "First Name",
|
|
2644
2662
|
namePlaceholder: "Enter your first name",
|
|
@@ -2667,7 +2685,7 @@ const Qt = {
|
|
|
2667
2685
|
contactMethodHint: "At least one contact method (email or phone) is required",
|
|
2668
2686
|
tenantNotFoundError: "Tenant not found",
|
|
2669
2687
|
dividerBullet: "•"
|
|
2670
|
-
},
|
|
2688
|
+
}, Yt = {
|
|
2671
2689
|
container: {
|
|
2672
2690
|
maxWidth: "400px",
|
|
2673
2691
|
width: "100%",
|
|
@@ -2772,7 +2790,7 @@ const Qt = {
|
|
|
2772
2790
|
margin: "0.5rem 0"
|
|
2773
2791
|
}
|
|
2774
2792
|
};
|
|
2775
|
-
function
|
|
2793
|
+
function jr({
|
|
2776
2794
|
copy: n = {},
|
|
2777
2795
|
styles: e = {},
|
|
2778
2796
|
signupType: t = "user",
|
|
@@ -2780,61 +2798,62 @@ function _r({
|
|
|
2780
2798
|
onError: i,
|
|
2781
2799
|
onLoginClick: o,
|
|
2782
2800
|
onMagicLinkClick: a,
|
|
2783
|
-
showLoginLink:
|
|
2784
|
-
showMagicLinkOption:
|
|
2801
|
+
showLoginLink: c = !0,
|
|
2802
|
+
showMagicLinkOption: m = !0,
|
|
2785
2803
|
className: y
|
|
2786
2804
|
}) {
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2805
|
+
var V;
|
|
2806
|
+
const [f, F] = x(""), [g, T] = x(""), [A, L] = x(""), [M, P] = x(""), [d, v] = x(""), [N, B] = x(""), [w, R] = x(""), [k, I] = x(!1), [l, z] = x(""), [D, p] = x({}), { signup: U, signupTenantAdmin: b } = he(), h = ((V = pe()) == null ? void 0 : V.tenant) ?? null, S = { ...Jt, ...n }, E = { ...Yt, ...e }, K = () => {
|
|
2807
|
+
const H = {};
|
|
2808
|
+
return f.trim() || (H.name = !0), !A.trim() && !M.trim() && (H.email = !0, H.phoneNumber = !0), d.trim() || (H.password = !0), N.trim() || (H.confirmPassword = !0), t === "tenant" && !w.trim() && (H.tenantName = !0), p(H), Object.keys(H).length === 0;
|
|
2809
|
+
}, G = async (H) => {
|
|
2810
|
+
if (H.preventDefault(), !!K()) {
|
|
2811
|
+
if (d !== N) {
|
|
2812
|
+
z(S.passwordMismatchError), p({ confirmPassword: !0 });
|
|
2794
2813
|
return;
|
|
2795
2814
|
}
|
|
2796
|
-
if (t === "user" && !(
|
|
2797
|
-
|
|
2815
|
+
if (t === "user" && !(h != null && h.id)) {
|
|
2816
|
+
z(S.tenantNotFoundError);
|
|
2798
2817
|
return;
|
|
2799
2818
|
}
|
|
2800
|
-
|
|
2819
|
+
I(!0), z("");
|
|
2801
2820
|
try {
|
|
2802
|
-
let
|
|
2803
|
-
t === "tenant" ?
|
|
2804
|
-
email:
|
|
2805
|
-
phoneNumber:
|
|
2821
|
+
let $;
|
|
2822
|
+
t === "tenant" ? $ = await b({
|
|
2823
|
+
email: A || void 0,
|
|
2824
|
+
phoneNumber: M || void 0,
|
|
2806
2825
|
name: f,
|
|
2807
|
-
password:
|
|
2808
|
-
tenantName:
|
|
2809
|
-
lastName:
|
|
2810
|
-
}) :
|
|
2811
|
-
email:
|
|
2812
|
-
phoneNumber:
|
|
2826
|
+
password: d,
|
|
2827
|
+
tenantName: w,
|
|
2828
|
+
lastName: g || void 0
|
|
2829
|
+
}) : $ = await U({
|
|
2830
|
+
email: A || void 0,
|
|
2831
|
+
phoneNumber: M || void 0,
|
|
2813
2832
|
name: f,
|
|
2814
|
-
password:
|
|
2815
|
-
tenantId:
|
|
2816
|
-
lastName:
|
|
2817
|
-
}), r == null || r(
|
|
2818
|
-
} catch (
|
|
2819
|
-
const
|
|
2820
|
-
|
|
2833
|
+
password: d,
|
|
2834
|
+
tenantId: h.id,
|
|
2835
|
+
lastName: g || void 0
|
|
2836
|
+
}), r == null || r($);
|
|
2837
|
+
} catch ($) {
|
|
2838
|
+
const ce = $.message || S.errorMessage;
|
|
2839
|
+
z(ce), i == null || i(ce);
|
|
2821
2840
|
} finally {
|
|
2822
|
-
|
|
2841
|
+
I(!1);
|
|
2823
2842
|
}
|
|
2824
2843
|
}
|
|
2825
|
-
},
|
|
2826
|
-
...
|
|
2827
|
-
...
|
|
2828
|
-
}),
|
|
2829
|
-
...
|
|
2830
|
-
...
|
|
2831
|
-
...!f || !
|
|
2832
|
-
}),
|
|
2833
|
-
return /* @__PURE__ */
|
|
2834
|
-
/* @__PURE__ */ s("h2", { style:
|
|
2835
|
-
/* @__PURE__ */
|
|
2836
|
-
/* @__PURE__ */
|
|
2837
|
-
/* @__PURE__ */ s("label", { style:
|
|
2844
|
+
}, X = (H) => ({
|
|
2845
|
+
...E.input,
|
|
2846
|
+
...D[H] ? E.inputError : {}
|
|
2847
|
+
}), W = () => ({
|
|
2848
|
+
...E.button,
|
|
2849
|
+
...k ? E.buttonLoading : {},
|
|
2850
|
+
...!f || !A && !M || !d || !N || k || t === "tenant" && !w ? E.buttonDisabled : {}
|
|
2851
|
+
}), q = f && (A || M) && d && N && (t === "user" || w);
|
|
2852
|
+
return /* @__PURE__ */ u("div", { className: y, style: E.container, children: [
|
|
2853
|
+
/* @__PURE__ */ s("h2", { style: E.title, children: S.title }),
|
|
2854
|
+
/* @__PURE__ */ u("form", { onSubmit: G, style: E.form, children: [
|
|
2855
|
+
/* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
|
|
2856
|
+
/* @__PURE__ */ s("label", { style: E.label, children: S.nameLabel }),
|
|
2838
2857
|
/* @__PURE__ */ s(
|
|
2839
2858
|
"input",
|
|
2840
2859
|
{
|
|
@@ -2842,145 +2861,145 @@ function _r({
|
|
|
2842
2861
|
name: "name",
|
|
2843
2862
|
type: "text",
|
|
2844
2863
|
value: f,
|
|
2845
|
-
onChange: (
|
|
2846
|
-
|
|
2864
|
+
onChange: (H) => {
|
|
2865
|
+
F(H.target.value), D.name && p(($) => ({ ...$, name: !1 }));
|
|
2847
2866
|
},
|
|
2848
|
-
placeholder:
|
|
2849
|
-
style:
|
|
2850
|
-
disabled:
|
|
2867
|
+
placeholder: S.namePlaceholder,
|
|
2868
|
+
style: X("name"),
|
|
2869
|
+
disabled: k
|
|
2851
2870
|
}
|
|
2852
2871
|
)
|
|
2853
2872
|
] }),
|
|
2854
|
-
/* @__PURE__ */
|
|
2855
|
-
/* @__PURE__ */ s("label", { style:
|
|
2873
|
+
/* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
|
|
2874
|
+
/* @__PURE__ */ s("label", { style: E.label, children: S.lastNameLabel }),
|
|
2856
2875
|
/* @__PURE__ */ s(
|
|
2857
2876
|
"input",
|
|
2858
2877
|
{
|
|
2859
2878
|
id: "lastName",
|
|
2860
2879
|
name: "lastName",
|
|
2861
2880
|
type: "text",
|
|
2862
|
-
value:
|
|
2863
|
-
onChange: (
|
|
2864
|
-
placeholder:
|
|
2865
|
-
style:
|
|
2866
|
-
disabled:
|
|
2881
|
+
value: g,
|
|
2882
|
+
onChange: (H) => T(H.target.value),
|
|
2883
|
+
placeholder: S.lastNamePlaceholder,
|
|
2884
|
+
style: E.input,
|
|
2885
|
+
disabled: k
|
|
2867
2886
|
}
|
|
2868
2887
|
)
|
|
2869
2888
|
] }),
|
|
2870
|
-
/* @__PURE__ */
|
|
2871
|
-
/* @__PURE__ */ s("label", { style:
|
|
2889
|
+
/* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
|
|
2890
|
+
/* @__PURE__ */ s("label", { style: E.label, children: S.emailLabel }),
|
|
2872
2891
|
/* @__PURE__ */ s(
|
|
2873
2892
|
"input",
|
|
2874
2893
|
{
|
|
2875
2894
|
id: "email",
|
|
2876
2895
|
name: "email",
|
|
2877
2896
|
type: "email",
|
|
2878
|
-
value:
|
|
2879
|
-
onChange: (
|
|
2880
|
-
|
|
2897
|
+
value: A,
|
|
2898
|
+
onChange: (H) => {
|
|
2899
|
+
L(H.target.value), D.email && p(($) => ({ ...$, email: !1, phoneNumber: !1 }));
|
|
2881
2900
|
},
|
|
2882
|
-
placeholder:
|
|
2883
|
-
style:
|
|
2884
|
-
disabled:
|
|
2901
|
+
placeholder: S.emailPlaceholder,
|
|
2902
|
+
style: X("email"),
|
|
2903
|
+
disabled: k
|
|
2885
2904
|
}
|
|
2886
2905
|
)
|
|
2887
2906
|
] }),
|
|
2888
|
-
/* @__PURE__ */
|
|
2889
|
-
/* @__PURE__ */ s("label", { style:
|
|
2907
|
+
/* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
|
|
2908
|
+
/* @__PURE__ */ s("label", { style: E.label, children: S.phoneNumberLabel }),
|
|
2890
2909
|
/* @__PURE__ */ s(
|
|
2891
2910
|
"input",
|
|
2892
2911
|
{
|
|
2893
2912
|
id: "phoneNumber",
|
|
2894
2913
|
name: "phoneNumber",
|
|
2895
2914
|
type: "tel",
|
|
2896
|
-
value:
|
|
2897
|
-
onChange: (
|
|
2898
|
-
P(
|
|
2915
|
+
value: M,
|
|
2916
|
+
onChange: (H) => {
|
|
2917
|
+
P(H.target.value), D.phoneNumber && p(($) => ({ ...$, email: !1, phoneNumber: !1 }));
|
|
2899
2918
|
},
|
|
2900
|
-
placeholder:
|
|
2901
|
-
style:
|
|
2902
|
-
disabled:
|
|
2919
|
+
placeholder: S.phoneNumberPlaceholder,
|
|
2920
|
+
style: X("phoneNumber"),
|
|
2921
|
+
disabled: k
|
|
2903
2922
|
}
|
|
2904
2923
|
)
|
|
2905
2924
|
] }),
|
|
2906
|
-
/* @__PURE__ */ s("div", { style:
|
|
2907
|
-
/* @__PURE__ */
|
|
2908
|
-
/* @__PURE__ */ s("label", { style:
|
|
2925
|
+
/* @__PURE__ */ s("div", { style: E.hintText, children: S.contactMethodHint }),
|
|
2926
|
+
/* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
|
|
2927
|
+
/* @__PURE__ */ s("label", { style: E.label, children: S.passwordLabel }),
|
|
2909
2928
|
/* @__PURE__ */ s(
|
|
2910
2929
|
"input",
|
|
2911
2930
|
{
|
|
2912
2931
|
id: "password",
|
|
2913
2932
|
name: "password",
|
|
2914
2933
|
type: "password",
|
|
2915
|
-
value:
|
|
2916
|
-
onChange: (
|
|
2917
|
-
|
|
2934
|
+
value: d,
|
|
2935
|
+
onChange: (H) => {
|
|
2936
|
+
v(H.target.value), D.password && p(($) => ({ ...$, password: !1 }));
|
|
2918
2937
|
},
|
|
2919
|
-
placeholder:
|
|
2920
|
-
style:
|
|
2921
|
-
disabled:
|
|
2938
|
+
placeholder: S.passwordPlaceholder,
|
|
2939
|
+
style: X("password"),
|
|
2940
|
+
disabled: k
|
|
2922
2941
|
}
|
|
2923
2942
|
)
|
|
2924
2943
|
] }),
|
|
2925
|
-
/* @__PURE__ */
|
|
2926
|
-
/* @__PURE__ */ s("label", { style:
|
|
2944
|
+
/* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
|
|
2945
|
+
/* @__PURE__ */ s("label", { style: E.label, children: S.confirmPasswordLabel }),
|
|
2927
2946
|
/* @__PURE__ */ s(
|
|
2928
2947
|
"input",
|
|
2929
2948
|
{
|
|
2930
2949
|
id: "confirmPassword",
|
|
2931
2950
|
name: "confirmPassword",
|
|
2932
2951
|
type: "password",
|
|
2933
|
-
value:
|
|
2934
|
-
onChange: (
|
|
2935
|
-
|
|
2952
|
+
value: N,
|
|
2953
|
+
onChange: (H) => {
|
|
2954
|
+
B(H.target.value), D.confirmPassword && p(($) => ({ ...$, confirmPassword: !1 })), l === S.passwordMismatchError && z("");
|
|
2936
2955
|
},
|
|
2937
|
-
placeholder:
|
|
2938
|
-
style:
|
|
2939
|
-
disabled:
|
|
2956
|
+
placeholder: S.confirmPasswordPlaceholder,
|
|
2957
|
+
style: X("confirmPassword"),
|
|
2958
|
+
disabled: k
|
|
2940
2959
|
}
|
|
2941
2960
|
)
|
|
2942
2961
|
] }),
|
|
2943
|
-
t === "tenant" && /* @__PURE__ */
|
|
2944
|
-
/* @__PURE__ */ s("label", { style:
|
|
2962
|
+
t === "tenant" && /* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
|
|
2963
|
+
/* @__PURE__ */ s("label", { style: E.label, children: S.tenantNameLabel }),
|
|
2945
2964
|
/* @__PURE__ */ s(
|
|
2946
2965
|
"input",
|
|
2947
2966
|
{
|
|
2948
2967
|
id: "tenantName",
|
|
2949
2968
|
name: "tenantName",
|
|
2950
2969
|
type: "text",
|
|
2951
|
-
value:
|
|
2952
|
-
onChange: (
|
|
2953
|
-
|
|
2970
|
+
value: w,
|
|
2971
|
+
onChange: (H) => {
|
|
2972
|
+
R(H.target.value), D.tenantName && p(($) => ({ ...$, tenantName: !1 }));
|
|
2954
2973
|
},
|
|
2955
|
-
placeholder:
|
|
2956
|
-
style:
|
|
2957
|
-
disabled:
|
|
2974
|
+
placeholder: S.tenantNamePlaceholder,
|
|
2975
|
+
style: X("tenantName"),
|
|
2976
|
+
disabled: k
|
|
2958
2977
|
}
|
|
2959
2978
|
)
|
|
2960
2979
|
] }),
|
|
2961
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: !
|
|
2962
|
-
|
|
2980
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !q || k, style: W(), children: k ? S.loadingText : S.submitButton }),
|
|
2981
|
+
l && /* @__PURE__ */ s("div", { style: E.errorText, children: l })
|
|
2963
2982
|
] }),
|
|
2964
|
-
(
|
|
2965
|
-
|
|
2966
|
-
/* @__PURE__ */
|
|
2967
|
-
|
|
2983
|
+
(c || m) && /* @__PURE__ */ u("div", { style: E.linkContainer, children: [
|
|
2984
|
+
m && /* @__PURE__ */ u("div", { children: [
|
|
2985
|
+
/* @__PURE__ */ u("span", { style: E.divider, children: [
|
|
2986
|
+
S.magicLinkText,
|
|
2968
2987
|
" "
|
|
2969
2988
|
] }),
|
|
2970
|
-
/* @__PURE__ */ s("a", { onClick: a, style:
|
|
2989
|
+
/* @__PURE__ */ s("a", { onClick: a, style: E.link, children: S.magicLinkLink })
|
|
2971
2990
|
] }),
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
/* @__PURE__ */
|
|
2975
|
-
|
|
2991
|
+
m && c && /* @__PURE__ */ s("div", { style: E.divider, children: S.dividerBullet }),
|
|
2992
|
+
c && /* @__PURE__ */ u("div", { children: [
|
|
2993
|
+
/* @__PURE__ */ u("span", { style: E.divider, children: [
|
|
2994
|
+
S.loginText,
|
|
2976
2995
|
" "
|
|
2977
2996
|
] }),
|
|
2978
|
-
/* @__PURE__ */ s("a", { onClick: o, style:
|
|
2997
|
+
/* @__PURE__ */ s("a", { onClick: o, style: E.link, children: S.loginLink })
|
|
2979
2998
|
] })
|
|
2980
2999
|
] })
|
|
2981
3000
|
] });
|
|
2982
3001
|
}
|
|
2983
|
-
const
|
|
3002
|
+
const Xt = {
|
|
2984
3003
|
title: "Sign In with Magic Link",
|
|
2985
3004
|
emailLabel: "Email",
|
|
2986
3005
|
emailPlaceholder: "Enter your email",
|
|
@@ -3004,7 +3023,7 @@ const Zt = {
|
|
|
3004
3023
|
tenantNotFoundError: "Tenant not found",
|
|
3005
3024
|
missingTenantOrEmailError: "Missing tenant or email",
|
|
3006
3025
|
dividerBullet: "•"
|
|
3007
|
-
},
|
|
3026
|
+
}, er = {
|
|
3008
3027
|
container: {
|
|
3009
3028
|
maxWidth: "400px",
|
|
3010
3029
|
width: "100%",
|
|
@@ -3127,7 +3146,7 @@ const Zt = {
|
|
|
3127
3146
|
textDecoration: "underline"
|
|
3128
3147
|
}
|
|
3129
3148
|
};
|
|
3130
|
-
function
|
|
3149
|
+
function Gr({
|
|
3131
3150
|
copy: n = {},
|
|
3132
3151
|
styles: e = {},
|
|
3133
3152
|
onSuccess: t,
|
|
@@ -3135,76 +3154,77 @@ function Wr({
|
|
|
3135
3154
|
onLoginClick: i,
|
|
3136
3155
|
onSignupClick: o,
|
|
3137
3156
|
showTraditionalLinks: a = !0,
|
|
3138
|
-
className:
|
|
3139
|
-
verifyToken:
|
|
3157
|
+
className: c,
|
|
3158
|
+
verifyToken: m,
|
|
3140
3159
|
frontendUrl: y
|
|
3141
3160
|
}) {
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3161
|
+
var W;
|
|
3162
|
+
const [f, F] = x(""), [g, T] = x(""), [A, L] = x(""), [M, P] = x(!1), [d, v] = x(!1), [N, B] = x(""), [w, R] = x(""), [k, I] = x({}), [l, z] = x(!1), { sendMagicLink: D, verifyMagicLink: p } = he(), U = ((W = pe()) == null ? void 0 : W.tenant) ?? null, b = { ...Xt, ...n }, h = { ...er, ...e };
|
|
3163
|
+
ne(() => {
|
|
3164
|
+
m && S(m);
|
|
3165
|
+
}, [m]);
|
|
3166
|
+
const S = async (q) => {
|
|
3167
|
+
if (!U || !f) {
|
|
3168
|
+
B(b.missingTenantOrEmailError);
|
|
3149
3169
|
return;
|
|
3150
3170
|
}
|
|
3151
|
-
|
|
3171
|
+
v(!0), B("");
|
|
3152
3172
|
try {
|
|
3153
|
-
const
|
|
3173
|
+
const V = await p({
|
|
3154
3174
|
token: q,
|
|
3155
3175
|
email: f
|
|
3156
3176
|
// tenantId inferred from context automatically
|
|
3157
3177
|
});
|
|
3158
|
-
t == null || t(
|
|
3159
|
-
} catch (
|
|
3160
|
-
const
|
|
3161
|
-
|
|
3178
|
+
t == null || t(V);
|
|
3179
|
+
} catch (V) {
|
|
3180
|
+
const H = V.message || "Failed to verify magic link";
|
|
3181
|
+
B(H), r == null || r(H);
|
|
3162
3182
|
} finally {
|
|
3163
|
-
|
|
3183
|
+
v(!1);
|
|
3164
3184
|
}
|
|
3165
|
-
},
|
|
3185
|
+
}, E = () => {
|
|
3166
3186
|
const q = {};
|
|
3167
|
-
return f.trim() || (q.email = !0),
|
|
3168
|
-
},
|
|
3169
|
-
if (q.preventDefault(), !!
|
|
3170
|
-
if (!(
|
|
3171
|
-
|
|
3187
|
+
return f.trim() || (q.email = !0), l && !g.trim() && (q.name = !0), I(q), Object.keys(q).length === 0;
|
|
3188
|
+
}, K = async (q) => {
|
|
3189
|
+
if (q.preventDefault(), !!E()) {
|
|
3190
|
+
if (!(U != null && U.id)) {
|
|
3191
|
+
B(b.tenantNotFoundError);
|
|
3172
3192
|
return;
|
|
3173
3193
|
}
|
|
3174
|
-
P(!0),
|
|
3194
|
+
P(!0), B(""), R("");
|
|
3175
3195
|
try {
|
|
3176
|
-
const
|
|
3196
|
+
const V = y || (typeof window < "u" ? window.location.origin : ""), H = await D({
|
|
3177
3197
|
email: f,
|
|
3178
|
-
tenantId:
|
|
3179
|
-
frontendUrl:
|
|
3180
|
-
name:
|
|
3181
|
-
lastName:
|
|
3198
|
+
tenantId: U.id,
|
|
3199
|
+
frontendUrl: V,
|
|
3200
|
+
name: l ? g : void 0,
|
|
3201
|
+
lastName: l ? A : void 0
|
|
3182
3202
|
});
|
|
3183
|
-
|
|
3184
|
-
} catch (
|
|
3185
|
-
const
|
|
3186
|
-
|
|
3203
|
+
R(b.successMessage), t == null || t(H);
|
|
3204
|
+
} catch (V) {
|
|
3205
|
+
const H = V.message || b.errorMessage;
|
|
3206
|
+
B(H), r == null || r(H);
|
|
3187
3207
|
} finally {
|
|
3188
3208
|
P(!1);
|
|
3189
3209
|
}
|
|
3190
3210
|
}
|
|
3191
|
-
},
|
|
3192
|
-
...
|
|
3193
|
-
...
|
|
3194
|
-
}),
|
|
3195
|
-
...
|
|
3196
|
-
...
|
|
3197
|
-
...!f ||
|
|
3211
|
+
}, G = (q) => ({
|
|
3212
|
+
...h.input,
|
|
3213
|
+
...k[q] ? h.inputError : {}
|
|
3214
|
+
}), X = () => ({
|
|
3215
|
+
...h.button,
|
|
3216
|
+
...M || d ? h.buttonLoading : {},
|
|
3217
|
+
...!f || M || d ? h.buttonDisabled : {}
|
|
3198
3218
|
});
|
|
3199
|
-
return
|
|
3200
|
-
/* @__PURE__ */ s("h2", { style:
|
|
3201
|
-
/* @__PURE__ */ s("div", { style:
|
|
3202
|
-
] }) : /* @__PURE__ */
|
|
3203
|
-
/* @__PURE__ */ s("h2", { style:
|
|
3204
|
-
/* @__PURE__ */ s("p", { style:
|
|
3205
|
-
/* @__PURE__ */
|
|
3206
|
-
/* @__PURE__ */
|
|
3207
|
-
/* @__PURE__ */ s("label", { style:
|
|
3219
|
+
return d ? /* @__PURE__ */ u("div", { className: c, style: h.container, children: [
|
|
3220
|
+
/* @__PURE__ */ s("h2", { style: h.title, children: b.verifyingText }),
|
|
3221
|
+
/* @__PURE__ */ s("div", { style: h.verifyingContainer, children: /* @__PURE__ */ s("div", { style: h.verifyingText, children: b.verifyingDescription }) })
|
|
3222
|
+
] }) : /* @__PURE__ */ u("div", { className: c, style: h.container, children: [
|
|
3223
|
+
/* @__PURE__ */ s("h2", { style: h.title, children: b.title }),
|
|
3224
|
+
/* @__PURE__ */ s("p", { style: h.description, children: b.description }),
|
|
3225
|
+
/* @__PURE__ */ u("form", { onSubmit: K, style: h.form, children: [
|
|
3226
|
+
/* @__PURE__ */ u("div", { style: h.fieldGroup, children: [
|
|
3227
|
+
/* @__PURE__ */ s("label", { style: h.label, children: b.emailLabel }),
|
|
3208
3228
|
/* @__PURE__ */ s(
|
|
3209
3229
|
"input",
|
|
3210
3230
|
{
|
|
@@ -3213,94 +3233,94 @@ function Wr({
|
|
|
3213
3233
|
type: "email",
|
|
3214
3234
|
value: f,
|
|
3215
3235
|
onChange: (q) => {
|
|
3216
|
-
|
|
3236
|
+
F(q.target.value), k.email && I((V) => ({ ...V, email: !1 }));
|
|
3217
3237
|
},
|
|
3218
|
-
placeholder:
|
|
3219
|
-
style:
|
|
3220
|
-
disabled:
|
|
3238
|
+
placeholder: b.emailPlaceholder,
|
|
3239
|
+
style: G("email"),
|
|
3240
|
+
disabled: M || d
|
|
3221
3241
|
}
|
|
3222
3242
|
)
|
|
3223
3243
|
] }),
|
|
3224
|
-
!
|
|
3244
|
+
!l && /* @__PURE__ */ s("div", { style: h.toggleContainer, children: /* @__PURE__ */ s(
|
|
3225
3245
|
"button",
|
|
3226
3246
|
{
|
|
3227
3247
|
type: "button",
|
|
3228
|
-
onClick: () =>
|
|
3229
|
-
style:
|
|
3230
|
-
children:
|
|
3248
|
+
onClick: () => z(!0),
|
|
3249
|
+
style: h.toggleLink,
|
|
3250
|
+
children: b.showNameToggle
|
|
3231
3251
|
}
|
|
3232
3252
|
) }),
|
|
3233
|
-
|
|
3234
|
-
/* @__PURE__ */
|
|
3235
|
-
/* @__PURE__ */ s("label", { style:
|
|
3253
|
+
l && /* @__PURE__ */ u(_, { children: [
|
|
3254
|
+
/* @__PURE__ */ u("div", { style: h.fieldGroup, children: [
|
|
3255
|
+
/* @__PURE__ */ s("label", { style: h.label, children: b.nameLabel }),
|
|
3236
3256
|
/* @__PURE__ */ s(
|
|
3237
3257
|
"input",
|
|
3238
3258
|
{
|
|
3239
3259
|
id: "name",
|
|
3240
3260
|
name: "name",
|
|
3241
3261
|
type: "text",
|
|
3242
|
-
value:
|
|
3262
|
+
value: g,
|
|
3243
3263
|
onChange: (q) => {
|
|
3244
|
-
|
|
3264
|
+
T(q.target.value), k.name && I((V) => ({ ...V, name: !1 }));
|
|
3245
3265
|
},
|
|
3246
|
-
placeholder:
|
|
3247
|
-
style:
|
|
3248
|
-
disabled:
|
|
3266
|
+
placeholder: b.namePlaceholder,
|
|
3267
|
+
style: G("name"),
|
|
3268
|
+
disabled: M || d
|
|
3249
3269
|
}
|
|
3250
3270
|
)
|
|
3251
3271
|
] }),
|
|
3252
|
-
/* @__PURE__ */
|
|
3253
|
-
/* @__PURE__ */ s("label", { style:
|
|
3272
|
+
/* @__PURE__ */ u("div", { style: h.fieldGroup, children: [
|
|
3273
|
+
/* @__PURE__ */ s("label", { style: h.label, children: b.lastNameLabel }),
|
|
3254
3274
|
/* @__PURE__ */ s(
|
|
3255
3275
|
"input",
|
|
3256
3276
|
{
|
|
3257
3277
|
id: "lastName",
|
|
3258
3278
|
name: "lastName",
|
|
3259
3279
|
type: "text",
|
|
3260
|
-
value:
|
|
3261
|
-
onChange: (q) =>
|
|
3262
|
-
placeholder:
|
|
3263
|
-
style:
|
|
3264
|
-
disabled:
|
|
3280
|
+
value: A,
|
|
3281
|
+
onChange: (q) => L(q.target.value),
|
|
3282
|
+
placeholder: b.lastNamePlaceholder,
|
|
3283
|
+
style: h.input,
|
|
3284
|
+
disabled: M || d
|
|
3265
3285
|
}
|
|
3266
3286
|
)
|
|
3267
3287
|
] }),
|
|
3268
|
-
/* @__PURE__ */ s("div", { style:
|
|
3288
|
+
/* @__PURE__ */ s("div", { style: h.toggleContainer, children: /* @__PURE__ */ s(
|
|
3269
3289
|
"button",
|
|
3270
3290
|
{
|
|
3271
3291
|
type: "button",
|
|
3272
3292
|
onClick: () => {
|
|
3273
|
-
|
|
3293
|
+
z(!1), T(""), L("");
|
|
3274
3294
|
},
|
|
3275
|
-
style:
|
|
3276
|
-
children:
|
|
3295
|
+
style: h.toggleLink,
|
|
3296
|
+
children: b.hideNameToggle
|
|
3277
3297
|
}
|
|
3278
3298
|
) })
|
|
3279
3299
|
] }),
|
|
3280
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: !f ||
|
|
3281
|
-
|
|
3282
|
-
|
|
3300
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !f || M || d, style: X(), children: M ? b.loadingText : b.submitButton }),
|
|
3301
|
+
N && /* @__PURE__ */ s("div", { style: h.errorText, children: N }),
|
|
3302
|
+
w && /* @__PURE__ */ s("div", { style: h.successText, children: w })
|
|
3283
3303
|
] }),
|
|
3284
|
-
a && /* @__PURE__ */
|
|
3285
|
-
/* @__PURE__ */
|
|
3286
|
-
/* @__PURE__ */
|
|
3287
|
-
|
|
3304
|
+
a && /* @__PURE__ */ u("div", { style: h.linkContainer, children: [
|
|
3305
|
+
/* @__PURE__ */ u("div", { children: [
|
|
3306
|
+
/* @__PURE__ */ u("span", { style: h.divider, children: [
|
|
3307
|
+
b.loginText,
|
|
3288
3308
|
" "
|
|
3289
3309
|
] }),
|
|
3290
|
-
/* @__PURE__ */ s("a", { onClick: i, style:
|
|
3310
|
+
/* @__PURE__ */ s("a", { onClick: i, style: h.link, children: b.loginLink })
|
|
3291
3311
|
] }),
|
|
3292
|
-
/* @__PURE__ */ s("div", { style:
|
|
3293
|
-
/* @__PURE__ */
|
|
3294
|
-
/* @__PURE__ */
|
|
3295
|
-
|
|
3312
|
+
/* @__PURE__ */ s("div", { style: h.divider, children: b.dividerBullet }),
|
|
3313
|
+
/* @__PURE__ */ u("div", { children: [
|
|
3314
|
+
/* @__PURE__ */ u("span", { style: h.divider, children: [
|
|
3315
|
+
b.signupText,
|
|
3296
3316
|
" "
|
|
3297
3317
|
] }),
|
|
3298
|
-
/* @__PURE__ */ s("a", { onClick: o, style:
|
|
3318
|
+
/* @__PURE__ */ s("a", { onClick: o, style: h.link, children: b.signupLink })
|
|
3299
3319
|
] })
|
|
3300
3320
|
] })
|
|
3301
3321
|
] });
|
|
3302
3322
|
}
|
|
3303
|
-
const
|
|
3323
|
+
const tr = {
|
|
3304
3324
|
title: "Verifying Magic Link",
|
|
3305
3325
|
verifyingMessage: "Please wait while we verify your magic link...",
|
|
3306
3326
|
successMessage: "Magic link verified successfully! You are now logged in.",
|
|
@@ -3309,7 +3329,7 @@ const Yt = {
|
|
|
3309
3329
|
retryButton: "Try Again",
|
|
3310
3330
|
backToLoginButton: "Back to Login",
|
|
3311
3331
|
missingParamsError: "Missing required parameters: token or email"
|
|
3312
|
-
},
|
|
3332
|
+
}, tt = {
|
|
3313
3333
|
container: {
|
|
3314
3334
|
maxWidth: "400px",
|
|
3315
3335
|
width: "100%",
|
|
@@ -3402,7 +3422,7 @@ const Yt = {
|
|
|
3402
3422
|
backButtonHover: {
|
|
3403
3423
|
backgroundColor: "#e5e7eb"
|
|
3404
3424
|
}
|
|
3405
|
-
},
|
|
3425
|
+
}, rr = () => /* @__PURE__ */ s("div", { style: tt.spinner }), nr = () => /* @__PURE__ */ u(
|
|
3406
3426
|
"svg",
|
|
3407
3427
|
{
|
|
3408
3428
|
width: "48",
|
|
@@ -3419,7 +3439,7 @@ const Yt = {
|
|
|
3419
3439
|
/* @__PURE__ */ s("polyline", { points: "22,4 12,14.01 9,11.01" })
|
|
3420
3440
|
]
|
|
3421
3441
|
}
|
|
3422
|
-
),
|
|
3442
|
+
), sr = () => /* @__PURE__ */ u(
|
|
3423
3443
|
"svg",
|
|
3424
3444
|
{
|
|
3425
3445
|
width: "48",
|
|
@@ -3437,12 +3457,12 @@ const Yt = {
|
|
|
3437
3457
|
/* @__PURE__ */ s("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
|
|
3438
3458
|
]
|
|
3439
3459
|
}
|
|
3440
|
-
),
|
|
3441
|
-
loading: /* @__PURE__ */ s(
|
|
3442
|
-
success: /* @__PURE__ */ s(
|
|
3443
|
-
error: /* @__PURE__ */ s(
|
|
3460
|
+
), ir = {
|
|
3461
|
+
loading: /* @__PURE__ */ s(rr, {}),
|
|
3462
|
+
success: /* @__PURE__ */ s(nr, {}),
|
|
3463
|
+
error: /* @__PURE__ */ s(sr, {})
|
|
3444
3464
|
};
|
|
3445
|
-
function
|
|
3465
|
+
function Kr({
|
|
3446
3466
|
copy: n = {},
|
|
3447
3467
|
styles: e = {},
|
|
3448
3468
|
icons: t = {},
|
|
@@ -3450,102 +3470,102 @@ function Vr({
|
|
|
3450
3470
|
onError: i,
|
|
3451
3471
|
onRetry: o,
|
|
3452
3472
|
onBackToLogin: a,
|
|
3453
|
-
className:
|
|
3454
|
-
token:
|
|
3473
|
+
className: c,
|
|
3474
|
+
token: m,
|
|
3455
3475
|
email: y,
|
|
3456
3476
|
appId: f,
|
|
3457
|
-
tenantSlug:
|
|
3458
|
-
autoRedirectDelay:
|
|
3477
|
+
tenantSlug: F,
|
|
3478
|
+
autoRedirectDelay: g = 3e3
|
|
3459
3479
|
}) {
|
|
3460
|
-
const [
|
|
3480
|
+
const [T, A] = x("verifying"), [L, M] = x(""), { verifyMagicLink: P } = he(), d = { ...tr, ...n }, v = { ...tt, ...e }, N = { ...ir, ...t }, B = () => {
|
|
3461
3481
|
if (typeof window > "u") return {};
|
|
3462
|
-
const
|
|
3482
|
+
const l = new URLSearchParams(window.location.search);
|
|
3463
3483
|
return {
|
|
3464
|
-
token:
|
|
3465
|
-
email: y ||
|
|
3466
|
-
appId: f ||
|
|
3467
|
-
tenantSlug:
|
|
3484
|
+
token: m || l.get("token") || "",
|
|
3485
|
+
email: y || l.get("email") || "",
|
|
3486
|
+
appId: f || l.get("appId") || "",
|
|
3487
|
+
tenantSlug: F || l.get("tenantSlug") || void 0
|
|
3468
3488
|
};
|
|
3469
|
-
},
|
|
3470
|
-
|
|
3489
|
+
}, w = async () => {
|
|
3490
|
+
A("verifying"), M("");
|
|
3471
3491
|
try {
|
|
3472
|
-
const
|
|
3473
|
-
if (!
|
|
3474
|
-
throw new Error(
|
|
3475
|
-
const
|
|
3476
|
-
token:
|
|
3477
|
-
email:
|
|
3478
|
-
tenantSlug:
|
|
3492
|
+
const l = B();
|
|
3493
|
+
if (!l.token || !l.email)
|
|
3494
|
+
throw new Error(d.missingParamsError);
|
|
3495
|
+
const z = await P({
|
|
3496
|
+
token: l.token,
|
|
3497
|
+
email: l.email,
|
|
3498
|
+
tenantSlug: l.tenantSlug
|
|
3479
3499
|
});
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
},
|
|
3483
|
-
} catch (
|
|
3484
|
-
const
|
|
3485
|
-
|
|
3500
|
+
A("success"), r == null || r(z), g > 0 && setTimeout(() => {
|
|
3501
|
+
A("redirecting");
|
|
3502
|
+
}, g);
|
|
3503
|
+
} catch (l) {
|
|
3504
|
+
const z = l.message || d.errorMessage;
|
|
3505
|
+
M(z), A("error"), i == null || i(z);
|
|
3486
3506
|
}
|
|
3487
|
-
},
|
|
3488
|
-
o == null || o(),
|
|
3489
|
-
},
|
|
3507
|
+
}, R = () => {
|
|
3508
|
+
o == null || o(), w();
|
|
3509
|
+
}, k = () => {
|
|
3490
3510
|
a == null || a();
|
|
3491
3511
|
};
|
|
3492
|
-
|
|
3493
|
-
|
|
3512
|
+
ne(() => {
|
|
3513
|
+
w();
|
|
3494
3514
|
}, []);
|
|
3495
|
-
const
|
|
3496
|
-
switch (
|
|
3515
|
+
const I = () => {
|
|
3516
|
+
switch (T) {
|
|
3497
3517
|
case "verifying":
|
|
3498
|
-
return /* @__PURE__ */
|
|
3499
|
-
|
|
3500
|
-
|
|
3518
|
+
return /* @__PURE__ */ u("div", { style: v.message, children: [
|
|
3519
|
+
N.loading,
|
|
3520
|
+
d.verifyingMessage
|
|
3501
3521
|
] });
|
|
3502
3522
|
case "success":
|
|
3503
|
-
return /* @__PURE__ */
|
|
3504
|
-
|
|
3505
|
-
/* @__PURE__ */ s("div", { style:
|
|
3523
|
+
return /* @__PURE__ */ u(_, { children: [
|
|
3524
|
+
N.success,
|
|
3525
|
+
/* @__PURE__ */ s("div", { style: v.successMessage, children: d.successMessage })
|
|
3506
3526
|
] });
|
|
3507
3527
|
case "redirecting":
|
|
3508
|
-
return /* @__PURE__ */
|
|
3509
|
-
|
|
3510
|
-
/* @__PURE__ */ s("div", { style:
|
|
3528
|
+
return /* @__PURE__ */ u(_, { children: [
|
|
3529
|
+
N.loading,
|
|
3530
|
+
/* @__PURE__ */ s("div", { style: v.message, children: d.redirectingMessage })
|
|
3511
3531
|
] });
|
|
3512
3532
|
case "error":
|
|
3513
|
-
return /* @__PURE__ */
|
|
3514
|
-
|
|
3515
|
-
/* @__PURE__ */ s("div", { style:
|
|
3516
|
-
/* @__PURE__ */
|
|
3533
|
+
return /* @__PURE__ */ u(_, { children: [
|
|
3534
|
+
N.error,
|
|
3535
|
+
/* @__PURE__ */ s("div", { style: v.errorMessage, children: L || d.errorMessage }),
|
|
3536
|
+
/* @__PURE__ */ u("div", { style: v.buttonContainer, children: [
|
|
3517
3537
|
/* @__PURE__ */ s(
|
|
3518
3538
|
"button",
|
|
3519
3539
|
{
|
|
3520
|
-
onClick:
|
|
3521
|
-
style:
|
|
3522
|
-
onMouseOver: (
|
|
3523
|
-
Object.assign(
|
|
3540
|
+
onClick: R,
|
|
3541
|
+
style: v.retryButton,
|
|
3542
|
+
onMouseOver: (l) => {
|
|
3543
|
+
Object.assign(l.currentTarget.style, v.retryButtonHover);
|
|
3524
3544
|
},
|
|
3525
|
-
onMouseOut: (
|
|
3526
|
-
const
|
|
3527
|
-
Object.keys(
|
|
3528
|
-
|
|
3545
|
+
onMouseOut: (l) => {
|
|
3546
|
+
const z = v.retryButton || {};
|
|
3547
|
+
Object.keys(v.retryButtonHover || {}).forEach((D) => {
|
|
3548
|
+
l.currentTarget.style[D] = z[D] ?? "";
|
|
3529
3549
|
});
|
|
3530
3550
|
},
|
|
3531
|
-
children:
|
|
3551
|
+
children: d.retryButton
|
|
3532
3552
|
}
|
|
3533
3553
|
),
|
|
3534
3554
|
/* @__PURE__ */ s(
|
|
3535
3555
|
"button",
|
|
3536
3556
|
{
|
|
3537
|
-
onClick:
|
|
3538
|
-
style:
|
|
3539
|
-
onMouseOver: (
|
|
3540
|
-
Object.assign(
|
|
3557
|
+
onClick: k,
|
|
3558
|
+
style: v.backButton,
|
|
3559
|
+
onMouseOver: (l) => {
|
|
3560
|
+
Object.assign(l.currentTarget.style, v.backButtonHover);
|
|
3541
3561
|
},
|
|
3542
|
-
onMouseOut: (
|
|
3543
|
-
const
|
|
3544
|
-
Object.keys(
|
|
3545
|
-
|
|
3562
|
+
onMouseOut: (l) => {
|
|
3563
|
+
const z = v.backButton || {};
|
|
3564
|
+
Object.keys(v.backButtonHover || {}).forEach((D) => {
|
|
3565
|
+
l.currentTarget.style[D] = z[D] ?? "";
|
|
3546
3566
|
});
|
|
3547
3567
|
},
|
|
3548
|
-
children:
|
|
3568
|
+
children: d.backToLoginButton
|
|
3549
3569
|
}
|
|
3550
3570
|
)
|
|
3551
3571
|
] })
|
|
@@ -3554,18 +3574,18 @@ function Vr({
|
|
|
3554
3574
|
return null;
|
|
3555
3575
|
}
|
|
3556
3576
|
};
|
|
3557
|
-
return /* @__PURE__ */
|
|
3577
|
+
return /* @__PURE__ */ u("div", { style: v.container, className: c, children: [
|
|
3558
3578
|
/* @__PURE__ */ s("style", { children: `
|
|
3559
3579
|
@keyframes spin {
|
|
3560
3580
|
0% { transform: rotate(0deg); }
|
|
3561
3581
|
100% { transform: rotate(360deg); }
|
|
3562
3582
|
}
|
|
3563
3583
|
` }),
|
|
3564
|
-
/* @__PURE__ */ s("h1", { style:
|
|
3565
|
-
|
|
3584
|
+
/* @__PURE__ */ s("h1", { style: v.title, children: d.title }),
|
|
3585
|
+
I()
|
|
3566
3586
|
] });
|
|
3567
3587
|
}
|
|
3568
|
-
const
|
|
3588
|
+
const or = {
|
|
3569
3589
|
title: "Reset Password",
|
|
3570
3590
|
subtitle: "Enter your email address and we'll send you a link to reset your password.",
|
|
3571
3591
|
emailLabel: "Email",
|
|
@@ -3591,7 +3611,7 @@ const nr = {
|
|
|
3591
3611
|
haveTokenLink: "I have a token",
|
|
3592
3612
|
tenantNotFoundError: "Tenant not found",
|
|
3593
3613
|
dividerBullet: "•"
|
|
3594
|
-
},
|
|
3614
|
+
}, ar = {
|
|
3595
3615
|
container: {
|
|
3596
3616
|
maxWidth: "400px",
|
|
3597
3617
|
margin: "0 auto",
|
|
@@ -3687,7 +3707,7 @@ const nr = {
|
|
|
3687
3707
|
color: "#6b7280"
|
|
3688
3708
|
}
|
|
3689
3709
|
};
|
|
3690
|
-
function
|
|
3710
|
+
function Qr({
|
|
3691
3711
|
copy: n = {},
|
|
3692
3712
|
styles: e = {},
|
|
3693
3713
|
mode: t = "request",
|
|
@@ -3695,104 +3715,105 @@ function jr({
|
|
|
3695
3715
|
onSuccess: i,
|
|
3696
3716
|
onError: o,
|
|
3697
3717
|
onBackToLogin: a,
|
|
3698
|
-
onModeChange:
|
|
3699
|
-
className:
|
|
3718
|
+
onModeChange: c,
|
|
3719
|
+
className: m
|
|
3700
3720
|
}) {
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3721
|
+
var X;
|
|
3722
|
+
const [y, f] = x(""), [F, g] = x(r), [T, A] = x(""), [L, M] = x(""), [P, d] = x(!1), [v, N] = x(""), [B, w] = x(""), [R, k] = x({}), { requestPasswordReset: I, confirmPasswordReset: l } = he(), z = ((X = pe()) == null ? void 0 : X.tenant) ?? null, D = { ...or, ...n }, p = { ...ar, ...e }, U = () => {
|
|
3723
|
+
const W = {};
|
|
3724
|
+
return y.trim() || (W.email = !0), k(W), Object.keys(W).length === 0;
|
|
3725
|
+
}, b = () => {
|
|
3726
|
+
const W = {};
|
|
3727
|
+
return F.trim() || (W.token = !0), T.trim() || (W.newPassword = !0), L.trim() || (W.confirmPassword = !0), k(W), Object.keys(W).length === 0;
|
|
3728
|
+
}, h = async (W) => {
|
|
3729
|
+
if (W.preventDefault(), !!U()) {
|
|
3730
|
+
if (!(z != null && z.id)) {
|
|
3731
|
+
N(D.tenantNotFoundError);
|
|
3711
3732
|
return;
|
|
3712
3733
|
}
|
|
3713
|
-
|
|
3734
|
+
d(!0), N(""), w("");
|
|
3714
3735
|
try {
|
|
3715
|
-
await
|
|
3736
|
+
await I({ email: y, tenantId: z.id }), w(D.successMessage), i == null || i();
|
|
3716
3737
|
} catch (q) {
|
|
3717
|
-
const
|
|
3718
|
-
|
|
3738
|
+
const V = q.message || D.errorMessage;
|
|
3739
|
+
N(V), o == null || o(V);
|
|
3719
3740
|
} finally {
|
|
3720
|
-
|
|
3741
|
+
d(!1);
|
|
3721
3742
|
}
|
|
3722
3743
|
}
|
|
3723
|
-
},
|
|
3724
|
-
if (
|
|
3725
|
-
if (
|
|
3726
|
-
|
|
3744
|
+
}, S = async (W) => {
|
|
3745
|
+
if (W.preventDefault(), !!b()) {
|
|
3746
|
+
if (T !== L) {
|
|
3747
|
+
N(D.passwordMismatchError), k({ confirmPassword: !0 });
|
|
3727
3748
|
return;
|
|
3728
3749
|
}
|
|
3729
|
-
|
|
3750
|
+
d(!0), N(""), w("");
|
|
3730
3751
|
try {
|
|
3731
|
-
await
|
|
3752
|
+
await l({ token: F, newPassword: T }), w(D.resetSuccessMessage), i == null || i();
|
|
3732
3753
|
} catch (q) {
|
|
3733
|
-
const
|
|
3734
|
-
|
|
3754
|
+
const V = q.message || D.errorMessage;
|
|
3755
|
+
N(V), o == null || o(V);
|
|
3735
3756
|
} finally {
|
|
3736
|
-
|
|
3757
|
+
d(!1);
|
|
3737
3758
|
}
|
|
3738
3759
|
}
|
|
3739
|
-
},
|
|
3740
|
-
...
|
|
3741
|
-
|
|
3742
|
-
}),
|
|
3743
|
-
...
|
|
3744
|
-
...P ?
|
|
3760
|
+
}, E = (W) => ({
|
|
3761
|
+
...p.input,
|
|
3762
|
+
...R[W] ? p.inputError : {}
|
|
3763
|
+
}), K = () => ({
|
|
3764
|
+
...p.button,
|
|
3765
|
+
...P ? p.buttonLoading : {}
|
|
3745
3766
|
});
|
|
3746
3767
|
if (t === "reset") {
|
|
3747
|
-
const
|
|
3748
|
-
return /* @__PURE__ */
|
|
3749
|
-
/* @__PURE__ */ s("h2", { style:
|
|
3750
|
-
/* @__PURE__ */ s("p", { style:
|
|
3751
|
-
/* @__PURE__ */
|
|
3752
|
-
/* @__PURE__ */
|
|
3753
|
-
/* @__PURE__ */ s("label", { style:
|
|
3768
|
+
const W = F && T && L;
|
|
3769
|
+
return /* @__PURE__ */ u("div", { className: m, style: p.container, children: [
|
|
3770
|
+
/* @__PURE__ */ s("h2", { style: p.title, children: D.resetTitle }),
|
|
3771
|
+
/* @__PURE__ */ s("p", { style: p.subtitle, children: D.resetSubtitle }),
|
|
3772
|
+
/* @__PURE__ */ u("form", { onSubmit: S, style: p.form, children: [
|
|
3773
|
+
/* @__PURE__ */ u("div", { style: p.fieldGroup, children: [
|
|
3774
|
+
/* @__PURE__ */ s("label", { style: p.label, children: D.tokenLabel }),
|
|
3754
3775
|
/* @__PURE__ */ s(
|
|
3755
3776
|
"input",
|
|
3756
3777
|
{
|
|
3757
3778
|
type: "text",
|
|
3758
|
-
value:
|
|
3779
|
+
value: F,
|
|
3759
3780
|
onChange: (q) => {
|
|
3760
|
-
|
|
3781
|
+
g(q.target.value), R.token && k((V) => ({ ...V, token: !1 }));
|
|
3761
3782
|
},
|
|
3762
|
-
placeholder:
|
|
3763
|
-
style:
|
|
3783
|
+
placeholder: D.tokenPlaceholder,
|
|
3784
|
+
style: E("token"),
|
|
3764
3785
|
disabled: P
|
|
3765
3786
|
}
|
|
3766
3787
|
)
|
|
3767
3788
|
] }),
|
|
3768
|
-
/* @__PURE__ */
|
|
3769
|
-
/* @__PURE__ */ s("label", { style:
|
|
3789
|
+
/* @__PURE__ */ u("div", { style: p.fieldGroup, children: [
|
|
3790
|
+
/* @__PURE__ */ s("label", { style: p.label, children: D.newPasswordLabel }),
|
|
3770
3791
|
/* @__PURE__ */ s(
|
|
3771
3792
|
"input",
|
|
3772
3793
|
{
|
|
3773
3794
|
type: "password",
|
|
3774
|
-
value:
|
|
3795
|
+
value: T,
|
|
3775
3796
|
onChange: (q) => {
|
|
3776
|
-
|
|
3797
|
+
A(q.target.value), R.newPassword && k((V) => ({ ...V, newPassword: !1 }));
|
|
3777
3798
|
},
|
|
3778
|
-
placeholder:
|
|
3779
|
-
style:
|
|
3799
|
+
placeholder: D.newPasswordPlaceholder,
|
|
3800
|
+
style: E("newPassword"),
|
|
3780
3801
|
disabled: P
|
|
3781
3802
|
}
|
|
3782
3803
|
)
|
|
3783
3804
|
] }),
|
|
3784
|
-
/* @__PURE__ */
|
|
3785
|
-
/* @__PURE__ */ s("label", { style:
|
|
3805
|
+
/* @__PURE__ */ u("div", { style: p.fieldGroup, children: [
|
|
3806
|
+
/* @__PURE__ */ s("label", { style: p.label, children: D.confirmPasswordLabel }),
|
|
3786
3807
|
/* @__PURE__ */ s(
|
|
3787
3808
|
"input",
|
|
3788
3809
|
{
|
|
3789
3810
|
type: "password",
|
|
3790
|
-
value:
|
|
3811
|
+
value: L,
|
|
3791
3812
|
onChange: (q) => {
|
|
3792
|
-
|
|
3813
|
+
M(q.target.value), R.confirmPassword && k((V) => ({ ...V, confirmPassword: !1 })), v === D.passwordMismatchError && N("");
|
|
3793
3814
|
},
|
|
3794
|
-
placeholder:
|
|
3795
|
-
style:
|
|
3815
|
+
placeholder: D.confirmPasswordPlaceholder,
|
|
3816
|
+
style: E("confirmPassword"),
|
|
3796
3817
|
disabled: P
|
|
3797
3818
|
}
|
|
3798
3819
|
)
|
|
@@ -3801,43 +3822,43 @@ function jr({
|
|
|
3801
3822
|
"button",
|
|
3802
3823
|
{
|
|
3803
3824
|
type: "submit",
|
|
3804
|
-
disabled: !
|
|
3825
|
+
disabled: !W || P,
|
|
3805
3826
|
style: {
|
|
3806
|
-
...
|
|
3807
|
-
...!
|
|
3827
|
+
...K(),
|
|
3828
|
+
...!W || P ? p.buttonDisabled : {}
|
|
3808
3829
|
},
|
|
3809
|
-
children: P ?
|
|
3830
|
+
children: P ? D.resetLoadingText : D.resetSubmitButton
|
|
3810
3831
|
}
|
|
3811
3832
|
),
|
|
3812
|
-
|
|
3813
|
-
|
|
3833
|
+
v && /* @__PURE__ */ s("div", { style: p.errorText, children: v }),
|
|
3834
|
+
B && /* @__PURE__ */ s("div", { style: p.successText, children: B })
|
|
3814
3835
|
] }),
|
|
3815
|
-
/* @__PURE__ */
|
|
3816
|
-
/* @__PURE__ */ s("a", { onClick: a, style:
|
|
3817
|
-
|
|
3818
|
-
/* @__PURE__ */ s("span", { style:
|
|
3819
|
-
/* @__PURE__ */ s("a", { onClick: () =>
|
|
3836
|
+
/* @__PURE__ */ u("div", { style: p.linkContainer, children: [
|
|
3837
|
+
/* @__PURE__ */ s("a", { onClick: a, style: p.link, children: D.backToLoginLink }),
|
|
3838
|
+
c && /* @__PURE__ */ u(_, { children: [
|
|
3839
|
+
/* @__PURE__ */ s("span", { style: p.modeSwitchDivider, children: D.dividerBullet }),
|
|
3840
|
+
/* @__PURE__ */ s("a", { onClick: () => c("request"), style: p.link, children: D.requestNewLinkLink })
|
|
3820
3841
|
] })
|
|
3821
3842
|
] })
|
|
3822
3843
|
] });
|
|
3823
3844
|
}
|
|
3824
|
-
const
|
|
3825
|
-
return /* @__PURE__ */
|
|
3826
|
-
/* @__PURE__ */ s("h2", { style:
|
|
3827
|
-
/* @__PURE__ */ s("p", { style:
|
|
3828
|
-
/* @__PURE__ */
|
|
3829
|
-
/* @__PURE__ */
|
|
3830
|
-
/* @__PURE__ */ s("label", { style:
|
|
3845
|
+
const G = y;
|
|
3846
|
+
return /* @__PURE__ */ u("div", { className: m, style: p.container, children: [
|
|
3847
|
+
/* @__PURE__ */ s("h2", { style: p.title, children: D.title }),
|
|
3848
|
+
/* @__PURE__ */ s("p", { style: p.subtitle, children: D.subtitle }),
|
|
3849
|
+
/* @__PURE__ */ u("form", { onSubmit: h, style: p.form, children: [
|
|
3850
|
+
/* @__PURE__ */ u("div", { style: p.fieldGroup, children: [
|
|
3851
|
+
/* @__PURE__ */ s("label", { style: p.label, children: D.emailLabel }),
|
|
3831
3852
|
/* @__PURE__ */ s(
|
|
3832
3853
|
"input",
|
|
3833
3854
|
{
|
|
3834
3855
|
type: "email",
|
|
3835
3856
|
value: y,
|
|
3836
|
-
onChange: (
|
|
3837
|
-
f(
|
|
3857
|
+
onChange: (W) => {
|
|
3858
|
+
f(W.target.value), R.email && k((q) => ({ ...q, email: !1 }));
|
|
3838
3859
|
},
|
|
3839
|
-
placeholder:
|
|
3840
|
-
style:
|
|
3860
|
+
placeholder: D.emailPlaceholder,
|
|
3861
|
+
style: E("email"),
|
|
3841
3862
|
disabled: P
|
|
3842
3863
|
}
|
|
3843
3864
|
)
|
|
@@ -3846,27 +3867,27 @@ function jr({
|
|
|
3846
3867
|
"button",
|
|
3847
3868
|
{
|
|
3848
3869
|
type: "submit",
|
|
3849
|
-
disabled: !
|
|
3870
|
+
disabled: !G || P,
|
|
3850
3871
|
style: {
|
|
3851
|
-
...
|
|
3852
|
-
...!
|
|
3872
|
+
...K(),
|
|
3873
|
+
...!G || P ? p.buttonDisabled : {}
|
|
3853
3874
|
},
|
|
3854
|
-
children: P ?
|
|
3875
|
+
children: P ? D.loadingText : D.submitButton
|
|
3855
3876
|
}
|
|
3856
3877
|
),
|
|
3857
|
-
|
|
3858
|
-
|
|
3878
|
+
v && /* @__PURE__ */ s("div", { style: p.errorText, children: v }),
|
|
3879
|
+
B && /* @__PURE__ */ s("div", { style: p.successText, children: B })
|
|
3859
3880
|
] }),
|
|
3860
|
-
/* @__PURE__ */
|
|
3861
|
-
/* @__PURE__ */ s("a", { onClick: a, style:
|
|
3862
|
-
|
|
3863
|
-
/* @__PURE__ */ s("span", { style:
|
|
3864
|
-
/* @__PURE__ */ s("a", { onClick: () =>
|
|
3881
|
+
/* @__PURE__ */ u("div", { style: p.linkContainer, children: [
|
|
3882
|
+
/* @__PURE__ */ s("a", { onClick: a, style: p.link, children: D.backToLoginLink }),
|
|
3883
|
+
c && /* @__PURE__ */ u(_, { children: [
|
|
3884
|
+
/* @__PURE__ */ s("span", { style: p.modeSwitchDivider, children: D.dividerBullet }),
|
|
3885
|
+
/* @__PURE__ */ s("a", { onClick: () => c("reset"), style: p.link, children: D.haveTokenLink })
|
|
3865
3886
|
] })
|
|
3866
3887
|
] })
|
|
3867
3888
|
] });
|
|
3868
3889
|
}
|
|
3869
|
-
const
|
|
3890
|
+
const lr = () => /* @__PURE__ */ s(
|
|
3870
3891
|
"div",
|
|
3871
3892
|
{
|
|
3872
3893
|
style: {
|
|
@@ -3878,7 +3899,7 @@ const ir = () => /* @__PURE__ */ s(
|
|
|
3878
3899
|
},
|
|
3879
3900
|
children: /* @__PURE__ */ s("div", { children: "Loading..." })
|
|
3880
3901
|
}
|
|
3881
|
-
),
|
|
3902
|
+
), cr = ({ error: n, retry: e }) => /* @__PURE__ */ u(
|
|
3882
3903
|
"div",
|
|
3883
3904
|
{
|
|
3884
3905
|
style: {
|
|
@@ -3912,43 +3933,43 @@ const ir = () => /* @__PURE__ */ s(
|
|
|
3912
3933
|
]
|
|
3913
3934
|
}
|
|
3914
3935
|
);
|
|
3915
|
-
function
|
|
3936
|
+
function Zr({
|
|
3916
3937
|
children: n,
|
|
3917
3938
|
loadingFallback: e,
|
|
3918
3939
|
errorFallback: t,
|
|
3919
3940
|
requireTenant: r = !0
|
|
3920
3941
|
}) {
|
|
3921
|
-
const { isAppLoading: i, appError: o, retryApp: a } =
|
|
3922
|
-
}),
|
|
3923
|
-
o && a(),
|
|
3942
|
+
const { isAppLoading: i, appError: o, retryApp: a } = Ae(), c = pe(), m = $e(), y = Ye(), f = Xe(), F = (c == null ? void 0 : c.isTenantLoading) ?? !1, g = (c == null ? void 0 : c.tenantError) ?? null, T = (c == null ? void 0 : c.tenantSlug) ?? null, A = (c == null ? void 0 : c.retryTenant) ?? (() => {
|
|
3943
|
+
}), L = (m == null ? void 0 : m.isAuthReady) ?? !0, M = (y == null ? void 0 : y.isReady) ?? !0, P = (f == null ? void 0 : f.isReady) ?? !0, d = r && c && T, w = i || d && F || m && !L || y && !M || f && !P, R = o || (d ? g : null), k = () => {
|
|
3944
|
+
o && a(), g && c && A();
|
|
3924
3945
|
};
|
|
3925
|
-
if (
|
|
3926
|
-
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(
|
|
3927
|
-
if (
|
|
3928
|
-
const
|
|
3929
|
-
return /* @__PURE__ */ s(_, { children:
|
|
3946
|
+
if (w)
|
|
3947
|
+
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(lr, {}) });
|
|
3948
|
+
if (R) {
|
|
3949
|
+
const I = typeof t == "function" ? t(R, k) : t || /* @__PURE__ */ s(cr, { error: R, retry: k });
|
|
3950
|
+
return /* @__PURE__ */ s(_, { children: I });
|
|
3930
3951
|
}
|
|
3931
3952
|
return /* @__PURE__ */ s(_, { children: n });
|
|
3932
3953
|
}
|
|
3933
|
-
function
|
|
3934
|
-
const { isAppLoading: e, appError: t, retryApp: r, appInfo: i } =
|
|
3935
|
-
}),
|
|
3954
|
+
function Jr(n = !0) {
|
|
3955
|
+
const { isAppLoading: e, appError: t, retryApp: r, appInfo: i } = Ae(), o = pe(), a = $e(), c = Ye(), m = Xe(), y = (o == null ? void 0 : o.isTenantLoading) ?? !1, f = (o == null ? void 0 : o.tenantError) ?? null, F = (o == null ? void 0 : o.tenant) ?? null, g = (o == null ? void 0 : o.tenantSlug) ?? null, T = (o == null ? void 0 : o.retryTenant) ?? (() => {
|
|
3956
|
+
}), A = (a == null ? void 0 : a.isAuthReady) ?? !0, L = (c == null ? void 0 : c.isReady) ?? !0, M = (m == null ? void 0 : m.isReady) ?? !0, P = n && o && g, B = e || P && y || a && !A || c && !L || m && !M, w = t || (P ? f : null);
|
|
3936
3957
|
return {
|
|
3937
|
-
isLoading:
|
|
3938
|
-
error:
|
|
3939
|
-
isReady: !
|
|
3958
|
+
isLoading: B,
|
|
3959
|
+
error: w,
|
|
3960
|
+
isReady: !B && !w && i !== null && (!P || F !== null),
|
|
3940
3961
|
retry: () => {
|
|
3941
|
-
t && r(), f && o &&
|
|
3962
|
+
t && r(), f && o && T();
|
|
3942
3963
|
},
|
|
3943
3964
|
// Individual states
|
|
3944
3965
|
app: { isLoading: e, error: t, data: i },
|
|
3945
|
-
tenant: o ? { isLoading: y, error: f, data:
|
|
3946
|
-
auth: a ? { isReady:
|
|
3947
|
-
featureFlags:
|
|
3948
|
-
subscription:
|
|
3966
|
+
tenant: o ? { isLoading: y, error: f, data: F } : null,
|
|
3967
|
+
auth: a ? { isReady: A } : null,
|
|
3968
|
+
featureFlags: c ? { isReady: L } : null,
|
|
3969
|
+
subscription: m ? { isReady: M } : null
|
|
3949
3970
|
};
|
|
3950
3971
|
}
|
|
3951
|
-
const
|
|
3972
|
+
const dr = {
|
|
3952
3973
|
wrapper: {
|
|
3953
3974
|
position: "relative"
|
|
3954
3975
|
},
|
|
@@ -3992,7 +4013,7 @@ const ar = {
|
|
|
3992
4013
|
marginLeft: 8
|
|
3993
4014
|
}
|
|
3994
4015
|
};
|
|
3995
|
-
function
|
|
4016
|
+
function Yr({
|
|
3996
4017
|
tenants: n,
|
|
3997
4018
|
currentTenantId: e,
|
|
3998
4019
|
onSelect: t,
|
|
@@ -4000,81 +4021,81 @@ function Kr({
|
|
|
4000
4021
|
className: i = "",
|
|
4001
4022
|
dropdownClassName: o = "",
|
|
4002
4023
|
itemClassName: a = "",
|
|
4003
|
-
renderItem:
|
|
4004
|
-
placeholder:
|
|
4024
|
+
renderItem: c,
|
|
4025
|
+
placeholder: m = "Select tenant",
|
|
4005
4026
|
disabled: y = !1,
|
|
4006
4027
|
showCurrentTenant: f = !0
|
|
4007
4028
|
}) {
|
|
4008
|
-
var
|
|
4009
|
-
const
|
|
4010
|
-
|
|
4029
|
+
var B;
|
|
4030
|
+
const F = { ...dr, ...r }, g = $e(), [T, A] = x(!1), L = Ne(null), M = n ?? (g == null ? void 0 : g.userTenants) ?? [], P = e ?? ((B = g == null ? void 0 : g.currentUser) == null ? void 0 : B.tenantId) ?? null, d = async (w) => {
|
|
4031
|
+
A(!1), t ? t(w) : g != null && g.switchToTenant && await g.switchToTenant(w);
|
|
4011
4032
|
};
|
|
4012
|
-
|
|
4013
|
-
const
|
|
4014
|
-
|
|
4033
|
+
ne(() => {
|
|
4034
|
+
const w = (R) => {
|
|
4035
|
+
L.current && !L.current.contains(R.target) && A(!1);
|
|
4015
4036
|
};
|
|
4016
|
-
return document.addEventListener("mousedown",
|
|
4037
|
+
return document.addEventListener("mousedown", w), () => document.removeEventListener("mousedown", w);
|
|
4017
4038
|
}, []);
|
|
4018
|
-
const
|
|
4019
|
-
if (
|
|
4039
|
+
const v = M.find((w) => w.id === P);
|
|
4040
|
+
if (M.length === 0)
|
|
4020
4041
|
return null;
|
|
4021
|
-
if (
|
|
4022
|
-
return /* @__PURE__ */ s("div", { className: i, children: /* @__PURE__ */ s("span", { children:
|
|
4023
|
-
const
|
|
4024
|
-
|
|
4025
|
-
|
|
4042
|
+
if (M.length === 1 && f)
|
|
4043
|
+
return /* @__PURE__ */ s("div", { className: i, children: /* @__PURE__ */ s("span", { children: M[0].name }) });
|
|
4044
|
+
const N = (w, R) => /* @__PURE__ */ u("span", { style: { fontWeight: R ? "bold" : "normal" }, children: [
|
|
4045
|
+
w.name,
|
|
4046
|
+
w.role && /* @__PURE__ */ u("span", { style: F.itemRole, children: [
|
|
4026
4047
|
"(",
|
|
4027
|
-
|
|
4048
|
+
w.role,
|
|
4028
4049
|
")"
|
|
4029
4050
|
] })
|
|
4030
4051
|
] });
|
|
4031
|
-
return /* @__PURE__ */
|
|
4032
|
-
/* @__PURE__ */
|
|
4052
|
+
return /* @__PURE__ */ u("div", { ref: L, className: i, style: F.wrapper, children: [
|
|
4053
|
+
/* @__PURE__ */ u(
|
|
4033
4054
|
"button",
|
|
4034
4055
|
{
|
|
4035
4056
|
type: "button",
|
|
4036
|
-
onClick: () => !y &&
|
|
4057
|
+
onClick: () => !y && A(!T),
|
|
4037
4058
|
disabled: y,
|
|
4038
4059
|
style: {
|
|
4039
|
-
...
|
|
4040
|
-
...y ?
|
|
4060
|
+
...F.button,
|
|
4061
|
+
...y ? F.buttonDisabled : {}
|
|
4041
4062
|
},
|
|
4042
4063
|
children: [
|
|
4043
|
-
|
|
4044
|
-
/* @__PURE__ */ s("span", { style:
|
|
4064
|
+
v ? v.name : m,
|
|
4065
|
+
/* @__PURE__ */ s("span", { style: F.arrow, children: T ? "▲" : "▼" })
|
|
4045
4066
|
]
|
|
4046
4067
|
}
|
|
4047
4068
|
),
|
|
4048
|
-
|
|
4049
|
-
const
|
|
4069
|
+
T && /* @__PURE__ */ s("div", { className: o, style: F.dropdown, children: M.map((w) => {
|
|
4070
|
+
const R = w.id === P;
|
|
4050
4071
|
return /* @__PURE__ */ s(
|
|
4051
4072
|
"div",
|
|
4052
4073
|
{
|
|
4053
4074
|
className: a,
|
|
4054
|
-
onClick: () =>
|
|
4075
|
+
onClick: () => d(w.id),
|
|
4055
4076
|
style: {
|
|
4056
|
-
...
|
|
4057
|
-
|
|
4077
|
+
...F.item,
|
|
4078
|
+
...R ? F.itemSelected : {}
|
|
4058
4079
|
},
|
|
4059
|
-
onMouseEnter: (
|
|
4060
|
-
|
|
4080
|
+
onMouseEnter: (k) => {
|
|
4081
|
+
R || Object.assign(k.currentTarget.style, F.itemHover);
|
|
4061
4082
|
},
|
|
4062
|
-
onMouseLeave: (
|
|
4063
|
-
if (
|
|
4064
|
-
const
|
|
4065
|
-
Object.keys(
|
|
4066
|
-
|
|
4083
|
+
onMouseLeave: (k) => {
|
|
4084
|
+
if (!R) {
|
|
4085
|
+
const I = F.item || {};
|
|
4086
|
+
Object.keys(F.itemHover || {}).forEach((l) => {
|
|
4087
|
+
k.currentTarget.style[l] = I[l] ?? "";
|
|
4067
4088
|
});
|
|
4068
4089
|
}
|
|
4069
4090
|
},
|
|
4070
|
-
children:
|
|
4091
|
+
children: c ? c(w, R) : N(w, R)
|
|
4071
4092
|
},
|
|
4072
|
-
|
|
4093
|
+
w.id
|
|
4073
4094
|
);
|
|
4074
4095
|
}) })
|
|
4075
4096
|
] });
|
|
4076
4097
|
}
|
|
4077
|
-
class
|
|
4098
|
+
class Xr {
|
|
4078
4099
|
constructor(e, t) {
|
|
4079
4100
|
this.httpService = e, this.sessionManager = t;
|
|
4080
4101
|
}
|
|
@@ -4142,7 +4163,7 @@ class Zr {
|
|
|
4142
4163
|
};
|
|
4143
4164
|
}
|
|
4144
4165
|
}
|
|
4145
|
-
class
|
|
4166
|
+
class en {
|
|
4146
4167
|
constructor(e, t) {
|
|
4147
4168
|
this.httpService = e, this.sessionManager = t;
|
|
4148
4169
|
}
|
|
@@ -4193,7 +4214,7 @@ class Jr {
|
|
|
4193
4214
|
});
|
|
4194
4215
|
}
|
|
4195
4216
|
}
|
|
4196
|
-
class
|
|
4217
|
+
class tn {
|
|
4197
4218
|
constructor(e) {
|
|
4198
4219
|
this.httpService = e;
|
|
4199
4220
|
}
|
|
@@ -4202,7 +4223,7 @@ class Yr {
|
|
|
4202
4223
|
return await this.httpService.get("/health");
|
|
4203
4224
|
}
|
|
4204
4225
|
}
|
|
4205
|
-
class
|
|
4226
|
+
class rn {
|
|
4206
4227
|
// Date string to Date object
|
|
4207
4228
|
static toDate(e) {
|
|
4208
4229
|
return new Date(e);
|
|
@@ -4324,139 +4345,139 @@ class Xr {
|
|
|
4324
4345
|
}), t;
|
|
4325
4346
|
}
|
|
4326
4347
|
}
|
|
4327
|
-
const
|
|
4328
|
-
function
|
|
4348
|
+
const rt = "returnTo", Me = "zone_return_to", Le = "zone_return_to";
|
|
4349
|
+
function nn(n = {}) {
|
|
4329
4350
|
const {
|
|
4330
4351
|
zoneRoots: e = {},
|
|
4331
|
-
returnToParam: t =
|
|
4352
|
+
returnToParam: t = rt,
|
|
4332
4353
|
returnToStorage: r = "url"
|
|
4333
|
-
} = n, i =
|
|
4354
|
+
} = n, i = mt(), [o, a] = yt(), { isAuthenticated: c, currentUser: m } = he(), { tenant: y } = Te(), f = Z(() => ({ ...Oe, ...e }), [e]), F = !!y, g = m == null ? void 0 : m.userType, T = Z(() => {
|
|
4334
4355
|
switch (r) {
|
|
4335
4356
|
case "url":
|
|
4336
4357
|
return o.get(t);
|
|
4337
4358
|
case "session":
|
|
4338
|
-
return sessionStorage.getItem(
|
|
4359
|
+
return sessionStorage.getItem(Me);
|
|
4339
4360
|
case "local":
|
|
4340
|
-
return localStorage.getItem(
|
|
4361
|
+
return localStorage.getItem(Le);
|
|
4341
4362
|
default:
|
|
4342
4363
|
return null;
|
|
4343
4364
|
}
|
|
4344
|
-
}, [r, o, t]),
|
|
4365
|
+
}, [r, o, t]), A = oe(() => {
|
|
4345
4366
|
switch (r) {
|
|
4346
4367
|
case "url": {
|
|
4347
|
-
const
|
|
4348
|
-
|
|
4368
|
+
const d = new URLSearchParams(o);
|
|
4369
|
+
d.delete(t), a(d, { replace: !0 });
|
|
4349
4370
|
break;
|
|
4350
4371
|
}
|
|
4351
4372
|
case "session":
|
|
4352
|
-
sessionStorage.removeItem(
|
|
4373
|
+
sessionStorage.removeItem(Me);
|
|
4353
4374
|
break;
|
|
4354
4375
|
case "local":
|
|
4355
|
-
localStorage.removeItem(
|
|
4376
|
+
localStorage.removeItem(Le);
|
|
4356
4377
|
break;
|
|
4357
4378
|
}
|
|
4358
|
-
}, [r, o, t, a]),
|
|
4359
|
-
(
|
|
4379
|
+
}, [r, o, t, a]), L = oe(
|
|
4380
|
+
(d) => {
|
|
4360
4381
|
switch (r) {
|
|
4361
4382
|
case "url": {
|
|
4362
|
-
const
|
|
4363
|
-
|
|
4383
|
+
const v = new URLSearchParams(o);
|
|
4384
|
+
v.set(t, d), a(v, { replace: !0 });
|
|
4364
4385
|
break;
|
|
4365
4386
|
}
|
|
4366
4387
|
case "session":
|
|
4367
|
-
sessionStorage.setItem(
|
|
4388
|
+
sessionStorage.setItem(Me, d);
|
|
4368
4389
|
break;
|
|
4369
4390
|
case "local":
|
|
4370
|
-
localStorage.setItem(
|
|
4391
|
+
localStorage.setItem(Le, d);
|
|
4371
4392
|
break;
|
|
4372
4393
|
}
|
|
4373
4394
|
},
|
|
4374
4395
|
[r, o, t, a]
|
|
4375
|
-
),
|
|
4376
|
-
(
|
|
4377
|
-
const
|
|
4378
|
-
i(
|
|
4396
|
+
), M = oe(
|
|
4397
|
+
(d) => {
|
|
4398
|
+
const v = f[d] || f.default;
|
|
4399
|
+
i(v);
|
|
4379
4400
|
},
|
|
4380
4401
|
[i, f]
|
|
4381
|
-
), P =
|
|
4402
|
+
), P = oe(() => F ? c ? g === ae.TENANT_ADMIN ? f.tenantAdmin : f.tenantUser : f.tenantGuest : c ? g === ae.TENANT_ADMIN ? f.publicAdmin : f.publicUser : f.publicGuest, [F, c, g, f]);
|
|
4382
4403
|
return {
|
|
4383
|
-
returnToUrl:
|
|
4384
|
-
clearReturnTo:
|
|
4385
|
-
setReturnTo:
|
|
4386
|
-
navigateToZone:
|
|
4404
|
+
returnToUrl: T,
|
|
4405
|
+
clearReturnTo: A,
|
|
4406
|
+
setReturnTo: L,
|
|
4407
|
+
navigateToZone: M,
|
|
4387
4408
|
getSmartRedirect: P
|
|
4388
4409
|
};
|
|
4389
4410
|
}
|
|
4390
|
-
function
|
|
4411
|
+
function sn(n, e, t = rt, r = "url") {
|
|
4391
4412
|
if (!e || r !== "url")
|
|
4392
4413
|
return n;
|
|
4393
4414
|
const i = new URL(n, window.location.origin);
|
|
4394
4415
|
return i.searchParams.set(t, e), i.pathname + i.search;
|
|
4395
4416
|
}
|
|
4396
4417
|
export {
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4418
|
+
$r as AdminZone,
|
|
4419
|
+
rn as ApiMappers,
|
|
4420
|
+
Ve as AppApiService,
|
|
4421
|
+
Zr as AppLoader,
|
|
4422
|
+
br as AppProvider,
|
|
4423
|
+
vt as AuthApiService,
|
|
4424
|
+
xr as AuthProvider,
|
|
4425
|
+
Ur as AuthenticatedZone,
|
|
4426
|
+
et as DEFAULT_ZONE_PRESETS,
|
|
4427
|
+
Oe as DEFAULT_ZONE_ROOTS,
|
|
4428
|
+
Vr as FeatureFlag,
|
|
4429
|
+
It as FeatureFlagApiService,
|
|
4430
|
+
Ar as FeatureFlagProvider,
|
|
4431
|
+
Br as GuestZone,
|
|
4432
|
+
tn as HealthApiService,
|
|
4433
|
+
de as HttpService,
|
|
4434
|
+
Nr as LandingRoute,
|
|
4435
|
+
Wr as LoginForm,
|
|
4436
|
+
Gr as MagicLinkForm,
|
|
4437
|
+
Kr as MagicLinkVerify,
|
|
4438
|
+
Hr as OpenZone,
|
|
4439
|
+
Qr as PasswordRecoveryForm,
|
|
4440
|
+
Xr as PermissionApiService,
|
|
4441
|
+
Ir as Protected,
|
|
4442
|
+
Mr as ProtectedRoute,
|
|
4443
|
+
Dr as PublicZone,
|
|
4444
|
+
We as RoleApiService,
|
|
4445
|
+
Rr as RoutingProvider,
|
|
4446
|
+
se as SessionExpiredError,
|
|
4447
|
+
be as SessionManager,
|
|
4448
|
+
jr as SignupForm,
|
|
4449
|
+
Lt as SubscriptionApiService,
|
|
4450
|
+
zr as SubscriptionGuard,
|
|
4451
|
+
en as SubscriptionPlanApiService,
|
|
4452
|
+
Pr as SubscriptionProvider,
|
|
4453
|
+
ve as TenantApiService,
|
|
4454
|
+
Or as TenantAuthenticatedZone,
|
|
4455
|
+
_r as TenantGuestZone,
|
|
4456
|
+
qr as TenantOpenZone,
|
|
4457
|
+
Sr as TenantProvider,
|
|
4458
|
+
Lr as TenantRoute,
|
|
4459
|
+
Yr as TenantSelector,
|
|
4460
|
+
Fr as TenantZone,
|
|
4461
|
+
bt as TokenRefreshError,
|
|
4462
|
+
wt as TokenRefreshTimeoutError,
|
|
4463
|
+
St as UserApiService,
|
|
4464
|
+
ae as UserType,
|
|
4444
4465
|
Cr as UserZone,
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4466
|
+
ue as ZoneRoute,
|
|
4467
|
+
sn as buildRedirectUrl,
|
|
4468
|
+
vr as useApi,
|
|
4469
|
+
Ae as useApp,
|
|
4470
|
+
Jr as useAppLoaderState,
|
|
4471
|
+
he as useAuth,
|
|
4472
|
+
Mt as useFeatureFlags,
|
|
4473
|
+
Er as useRouting,
|
|
4474
|
+
Ft as useRoutingOptional,
|
|
4475
|
+
kr as useSettings,
|
|
4476
|
+
Nt as useSubscription,
|
|
4477
|
+
Te as useTenant,
|
|
4478
|
+
Je as useTenantInfo,
|
|
4479
|
+
pe as useTenantOptional,
|
|
4480
|
+
Tr as useTenantSettings,
|
|
4481
|
+
nn as useZoneNavigation
|
|
4461
4482
|
};
|
|
4462
4483
|
//# sourceMappingURL=index.es.js.map
|