@skylabs-digital/react-identity-access 2.31.0 → 2.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +878 -848
- 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 +1 -0
- package/dist/providers/AuthProvider.d.ts.map +1 -1
- package/dist/services/SessionManager.d.ts +11 -1
- package/dist/services/SessionManager.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
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { useLocation as
|
|
4
|
-
class
|
|
1
|
+
import { jsx as s, Fragment as z, jsxs as u } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as me, useMemo as K, useState as x, useCallback as ie, useEffect as te, useContext as ae, useRef as Me } from "react";
|
|
3
|
+
import { useLocation as Te, Navigate as be, useNavigate as gt, useSearchParams as mt } from "react-router-dom";
|
|
4
|
+
class ce {
|
|
5
5
|
constructor(e, t = 1e4) {
|
|
6
6
|
this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
|
|
7
7
|
}
|
|
@@ -13,19 +13,19 @@ class de {
|
|
|
13
13
|
}
|
|
14
14
|
async executeRequest(e, t, r, i) {
|
|
15
15
|
const o = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, a = (i == null ? void 0 : i.timeout) || this.timeout;
|
|
16
|
-
let
|
|
16
|
+
let h = {
|
|
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 c = await this.sessionManager.getValidAccessToken();
|
|
22
|
-
|
|
22
|
+
h = { ...h, Authorization: `Bearer ${c}` };
|
|
23
23
|
}
|
|
24
24
|
const f = new AbortController(), y = setTimeout(() => f.abort(), a);
|
|
25
25
|
try {
|
|
26
26
|
const c = await fetch(o, {
|
|
27
27
|
method: e,
|
|
28
|
-
headers:
|
|
28
|
+
headers: h,
|
|
29
29
|
body: r ? JSON.stringify(r) : void 0,
|
|
30
30
|
signal: f.signal
|
|
31
31
|
});
|
|
@@ -50,7 +50,7 @@ class de {
|
|
|
50
50
|
return this.executeRequest("DELETE", e, void 0, t);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
class
|
|
53
|
+
class _e {
|
|
54
54
|
constructor(e, t) {
|
|
55
55
|
this.httpService = e, this.sessionManager = t;
|
|
56
56
|
}
|
|
@@ -109,9 +109,9 @@ class Ve {
|
|
|
109
109
|
})).data;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
const
|
|
113
|
-
function
|
|
114
|
-
const t =
|
|
112
|
+
const Ne = me(null);
|
|
113
|
+
function wr({ config: n, children: e }) {
|
|
114
|
+
const t = K(
|
|
115
115
|
() => {
|
|
116
116
|
var m, T, A;
|
|
117
117
|
return {
|
|
@@ -132,7 +132,7 @@ function br({ config: n, children: e }) {
|
|
|
132
132
|
} catch {
|
|
133
133
|
return null;
|
|
134
134
|
}
|
|
135
|
-
}), [o, a] = x(!r), [
|
|
135
|
+
}), [o, a] = x(!r), [h, f] = x(null), y = K(() => {
|
|
136
136
|
const m = () => {
|
|
137
137
|
c();
|
|
138
138
|
};
|
|
@@ -142,15 +142,15 @@ function br({ config: n, children: e }) {
|
|
|
142
142
|
// App info
|
|
143
143
|
appInfo: r,
|
|
144
144
|
isAppLoading: o,
|
|
145
|
-
appError:
|
|
145
|
+
appError: h,
|
|
146
146
|
retryApp: m
|
|
147
147
|
};
|
|
148
|
-
}, [n, r, o,
|
|
148
|
+
}, [n, r, o, h]), c = ie(
|
|
149
149
|
async (m = !1) => {
|
|
150
150
|
if (!(!m && t.enabled && r))
|
|
151
151
|
try {
|
|
152
152
|
a(!0), f(null);
|
|
153
|
-
const T = new
|
|
153
|
+
const T = new ce(n.baseUrl), N = await new _e(T, {}).getPublicAppInfo(n.appId);
|
|
154
154
|
if (i(N), t.enabled)
|
|
155
155
|
try {
|
|
156
156
|
const M = {
|
|
@@ -170,41 +170,41 @@ function br({ config: n, children: e }) {
|
|
|
170
170
|
}
|
|
171
171
|
},
|
|
172
172
|
[n.baseUrl, n.appId, t, r]
|
|
173
|
-
), L =
|
|
173
|
+
), L = ie(async () => {
|
|
174
174
|
if (!(!t.enabled || !r))
|
|
175
175
|
try {
|
|
176
176
|
const m = localStorage.getItem(t.storageKey);
|
|
177
177
|
if (!m) return;
|
|
178
178
|
const T = JSON.parse(m);
|
|
179
179
|
if (Date.now() - T.timestamp > t.ttl * 0.5) {
|
|
180
|
-
const N = new
|
|
180
|
+
const N = new ce(n.baseUrl), P = await new _e(N, {}).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
189
|
} catch (m) {
|
|
190
190
|
process.env.NODE_ENV === "development" && console.warn("[AppProvider] Background app refresh failed:", m);
|
|
191
191
|
}
|
|
192
192
|
}, [n, t, r]);
|
|
193
|
-
return
|
|
193
|
+
return te(() => {
|
|
194
194
|
r ? L() : c();
|
|
195
|
-
}, []), /* @__PURE__ */ s(
|
|
195
|
+
}, []), /* @__PURE__ */ s(Ne.Provider, { value: y, children: e });
|
|
196
196
|
}
|
|
197
|
-
function
|
|
198
|
-
const n =
|
|
197
|
+
function ke() {
|
|
198
|
+
const n = ae(Ne);
|
|
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 Fe() {
|
|
204
|
+
return ae(Ne);
|
|
205
205
|
}
|
|
206
|
-
const
|
|
207
|
-
class
|
|
206
|
+
const br = ke;
|
|
207
|
+
class ne extends Error {
|
|
208
208
|
constructor(e, t) {
|
|
209
209
|
const r = {
|
|
210
210
|
token_expired: "Refresh token has expired",
|
|
@@ -214,21 +214,21 @@ class se extends Error {
|
|
|
214
214
|
super(t || r[e]), this.name = "SessionExpiredError", this.reason = e;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
class
|
|
217
|
+
class yt 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 wt 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"}`
|
|
226
226
|
), this.name = "TokenRefreshError", this.attempts = e, this.lastError = t;
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
|
-
const
|
|
229
|
+
const se = class se {
|
|
230
230
|
constructor(e = {}) {
|
|
231
|
-
this.refreshPromise = null, this.refreshQueue = [], this.proactiveTimerId = null, this.backgroundRetryTimerId = null, this.isDestroyed = !1, this.sessionGeneration = 0, this.consecutiveBackgroundFailures = 0,
|
|
231
|
+
this.refreshPromise = null, this.refreshQueue = [], this.proactiveTimerId = null, this.backgroundRetryTimerId = null, this.isDestroyed = !1, this.sessionGeneration = 0, this.consecutiveBackgroundFailures = 0, 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.enableCookieSession = e.enableCookieSession ?? !1, this.proactiveRefreshMargin = e.proactiveRefreshMargin ?? 6e4, this.refreshQueueTimeout = e.refreshQueueTimeout ?? 1e4, this.maxRefreshRetries = e.maxRefreshRetries ?? 3, this.retryBackoffBase = e.retryBackoffBase ?? 1e3, this.tokenStorage = e.tokenStorage || this.createTokenStorage(this.storageKey), this.scheduleProactiveRefresh();
|
|
232
232
|
}
|
|
233
233
|
/**
|
|
234
234
|
* Get or create a SessionManager instance for the given config.
|
|
@@ -236,24 +236,24 @@ const ie = class ie {
|
|
|
236
236
|
* Mutable config (callbacks, baseUrl) is updated on the existing instance.
|
|
237
237
|
*/
|
|
238
238
|
static getInstance(e = {}) {
|
|
239
|
-
const t =
|
|
239
|
+
const t = se.resolveStorageKey(e), r = se.instances.get(t);
|
|
240
240
|
if (r)
|
|
241
241
|
return r.updateConfig(e), r;
|
|
242
|
-
const i = new
|
|
243
|
-
return
|
|
242
|
+
const i = new se(e);
|
|
243
|
+
return se.instances.set(t, i), i;
|
|
244
244
|
}
|
|
245
245
|
/** Reset all singleton instances. For testing only. */
|
|
246
246
|
static resetAllInstances() {
|
|
247
|
-
for (const e of
|
|
247
|
+
for (const e of se.instances.values())
|
|
248
248
|
e.destroy();
|
|
249
|
-
|
|
249
|
+
se.instances.clear();
|
|
250
250
|
}
|
|
251
251
|
static resolveStorageKey(e) {
|
|
252
|
-
return e.storageKey
|
|
252
|
+
return e.storageKey || "auth_tokens";
|
|
253
253
|
}
|
|
254
254
|
/** Update mutable config (callbacks, baseUrl) on an existing instance. */
|
|
255
255
|
updateConfig(e) {
|
|
256
|
-
e.onSessionExpired !== void 0 && (this.onSessionExpired = e.onSessionExpired), e.onRefreshFailed !== void 0 && (this.onRefreshFailed = e.onRefreshFailed), e.baseUrl && (this.baseUrl = e.baseUrl);
|
|
256
|
+
e.onSessionExpired !== void 0 && (this.onSessionExpired = e.onSessionExpired), e.onRefreshFailed !== void 0 && (this.onRefreshFailed = e.onRefreshFailed), e.baseUrl && (this.baseUrl = e.baseUrl), e.enableCookieSession !== void 0 && (this.enableCookieSession = e.enableCookieSession);
|
|
257
257
|
}
|
|
258
258
|
// --- Storage helpers ---
|
|
259
259
|
createTokenStorage(e) {
|
|
@@ -310,7 +310,7 @@ const ie = class ie {
|
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
setTokens(e) {
|
|
313
|
-
const t = e.expiresAt || (e.expiresIn ? Date.now() + e.expiresIn * 1e3 : void 0) ||
|
|
313
|
+
const t = e.expiresAt || (e.expiresIn ? Date.now() + e.expiresIn * 1e3 : void 0) || se.extractJwtExpiry(e.accessToken), r = {
|
|
314
314
|
...e,
|
|
315
315
|
expiresAt: t
|
|
316
316
|
}, i = this.tokenStorage.get() || {};
|
|
@@ -320,7 +320,7 @@ const ie = class ie {
|
|
|
320
320
|
const { accessToken: e, refreshToken: t, expiresAt: r, expiresIn: i, tokenType: o } = this.tokenStorage.get() || {};
|
|
321
321
|
if (!e)
|
|
322
322
|
return null;
|
|
323
|
-
const a = r ||
|
|
323
|
+
const a = r || se.extractJwtExpiry(e);
|
|
324
324
|
return {
|
|
325
325
|
accessToken: e,
|
|
326
326
|
refreshToken: t,
|
|
@@ -369,13 +369,13 @@ const ie = class ie {
|
|
|
369
369
|
this.startRefreshAndResolveQueue(e.refreshToken).then(() => {
|
|
370
370
|
this.consecutiveBackgroundFailures = 0;
|
|
371
371
|
}).catch((r) => {
|
|
372
|
-
if (!(r instanceof
|
|
372
|
+
if (!(r instanceof ne)) {
|
|
373
373
|
if (this.sessionGeneration === t) {
|
|
374
|
-
if (this.consecutiveBackgroundFailures++, this.consecutiveBackgroundFailures >=
|
|
374
|
+
if (this.consecutiveBackgroundFailures++, this.consecutiveBackgroundFailures >= se.MAX_BACKGROUND_FAILURES) {
|
|
375
375
|
process.env.NODE_ENV === "development" && console.error(
|
|
376
376
|
`[SessionManager] Background refresh failed ${this.consecutiveBackgroundFailures} consecutive times — expiring session`
|
|
377
377
|
), this.consecutiveBackgroundFailures = 0, this.handleSessionExpired(
|
|
378
|
-
new
|
|
378
|
+
new ne("token_invalid", "Background refresh failed repeatedly")
|
|
379
379
|
);
|
|
380
380
|
return;
|
|
381
381
|
}
|
|
@@ -401,6 +401,35 @@ const ie = class ie {
|
|
|
401
401
|
return !1;
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
|
+
/**
|
|
405
|
+
* Attempt to restore a session using a backend-set HttpOnly cookie.
|
|
406
|
+
* Sends a refresh request with credentials: 'include' but without a refresh token in the body.
|
|
407
|
+
* If the backend responds with tokens (cookie carried the refresh token), stores them and returns true.
|
|
408
|
+
* If it fails (no cookie, expired, etc.), returns false — this is a normal outcome, not an error.
|
|
409
|
+
*
|
|
410
|
+
* Only works when enableCookieSession is true.
|
|
411
|
+
*/
|
|
412
|
+
async attemptCookieSessionRestore() {
|
|
413
|
+
if (!this.enableCookieSession || !this.baseUrl) return !1;
|
|
414
|
+
const e = `${this.baseUrl}/auth/refresh`;
|
|
415
|
+
try {
|
|
416
|
+
const t = await fetch(e, {
|
|
417
|
+
method: "POST",
|
|
418
|
+
headers: { "Content-Type": "application/json" },
|
|
419
|
+
body: JSON.stringify({}),
|
|
420
|
+
credentials: "include"
|
|
421
|
+
});
|
|
422
|
+
if (!t.ok) return !1;
|
|
423
|
+
const r = await t.json();
|
|
424
|
+
return r.accessToken ? (this.setTokens({
|
|
425
|
+
accessToken: r.accessToken,
|
|
426
|
+
refreshToken: r.refreshToken || "",
|
|
427
|
+
expiresIn: r.expiresIn
|
|
428
|
+
}), !0) : !1;
|
|
429
|
+
} catch {
|
|
430
|
+
return !1;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
404
433
|
// --- Core: getValidAccessToken with queue + timeout ---
|
|
405
434
|
/**
|
|
406
435
|
* Get a valid access token. If the token needs refresh, handles the refresh
|
|
@@ -413,13 +442,13 @@ const ie = class ie {
|
|
|
413
442
|
async getValidAccessToken() {
|
|
414
443
|
const e = this.getTokens();
|
|
415
444
|
if (!(e != null && e.accessToken)) {
|
|
416
|
-
const t = new
|
|
445
|
+
const t = new ne("token_invalid", "No tokens available");
|
|
417
446
|
throw this.handleSessionExpired(t), t;
|
|
418
447
|
}
|
|
419
448
|
if (!this.shouldRefreshToken(e) && !this.isTokenExpired(e))
|
|
420
449
|
return e.accessToken;
|
|
421
450
|
if (!e.refreshToken) {
|
|
422
|
-
const t = new
|
|
451
|
+
const t = new ne("token_invalid", "No refresh token available");
|
|
423
452
|
throw this.handleSessionExpired(t), t;
|
|
424
453
|
}
|
|
425
454
|
return this.refreshPromise ? this.enqueueForToken() : this.startRefreshAndResolveQueue(e.refreshToken);
|
|
@@ -431,14 +460,14 @@ const ie = class ie {
|
|
|
431
460
|
try {
|
|
432
461
|
return { Authorization: `Bearer ${await this.getValidAccessToken()}` };
|
|
433
462
|
} catch (e) {
|
|
434
|
-
return e instanceof
|
|
463
|
+
return e instanceof ne && this.onRefreshFailed && this.onRefreshFailed(), {};
|
|
435
464
|
}
|
|
436
465
|
}
|
|
437
466
|
enqueueForToken() {
|
|
438
467
|
return new Promise((e, t) => {
|
|
439
468
|
const r = setTimeout(() => {
|
|
440
469
|
const i = this.refreshQueue.findIndex((o) => o.timeoutId === r);
|
|
441
|
-
i !== -1 && this.refreshQueue.splice(i, 1), t(new
|
|
470
|
+
i !== -1 && this.refreshQueue.splice(i, 1), t(new yt(this.refreshQueueTimeout));
|
|
442
471
|
}, this.refreshQueueTimeout);
|
|
443
472
|
this.refreshQueue.push({ resolve: e, reject: t, timeoutId: r });
|
|
444
473
|
});
|
|
@@ -451,7 +480,7 @@ const ie = class ie {
|
|
|
451
480
|
return this.resolveQueue(r), r;
|
|
452
481
|
} catch (t) {
|
|
453
482
|
const r = t instanceof Error ? t : new Error("Token refresh failed");
|
|
454
|
-
throw r instanceof
|
|
483
|
+
throw r instanceof ne ? (this.rejectQueue(r), this.handleSessionExpired(r)) : this.rejectQueue(r), r;
|
|
455
484
|
} finally {
|
|
456
485
|
this.refreshPromise = null;
|
|
457
486
|
}
|
|
@@ -474,21 +503,21 @@ const ie = class ie {
|
|
|
474
503
|
const r = this.sessionGeneration;
|
|
475
504
|
for (let i = 0; i <= this.maxRefreshRetries; i++) {
|
|
476
505
|
if (this.sessionGeneration !== r)
|
|
477
|
-
throw new
|
|
506
|
+
throw new ne("token_invalid", "Session cleared during refresh");
|
|
478
507
|
try {
|
|
479
508
|
await this.performTokenRefresh(e, r);
|
|
480
509
|
return;
|
|
481
510
|
} catch (o) {
|
|
482
511
|
const a = o instanceof Error ? o : new Error(String(o));
|
|
483
|
-
if (a instanceof
|
|
512
|
+
if (a instanceof ne)
|
|
484
513
|
throw a;
|
|
485
514
|
if (t = a, i < this.maxRefreshRetries) {
|
|
486
|
-
const
|
|
487
|
-
await this.sleep(
|
|
515
|
+
const h = this.retryBackoffBase * Math.pow(2, i);
|
|
516
|
+
await this.sleep(h);
|
|
488
517
|
}
|
|
489
518
|
}
|
|
490
519
|
}
|
|
491
|
-
throw new
|
|
520
|
+
throw new wt(this.maxRefreshRetries + 1, t);
|
|
492
521
|
}
|
|
493
522
|
/**
|
|
494
523
|
* Single refresh attempt with error classification.
|
|
@@ -507,14 +536,15 @@ const ie = class ie {
|
|
|
507
536
|
const r = this.getTokens();
|
|
508
537
|
if (r != null && r.accessToken && !this.isTokenExpired(r) && !this.shouldRefreshToken(r))
|
|
509
538
|
return;
|
|
510
|
-
const i = (r == null ? void 0 : r.refreshToken) || e, o = `${this.baseUrl}/auth/refresh`, a =
|
|
511
|
-
a && (
|
|
539
|
+
const i = (r == null ? void 0 : r.refreshToken) || e, o = `${this.baseUrl}/auth/refresh`, a = se.extractJwtClaim(i, "deviceId"), h = { refreshToken: i };
|
|
540
|
+
a && (h.deviceId = a);
|
|
512
541
|
let f;
|
|
513
542
|
try {
|
|
514
543
|
f = await fetch(o, {
|
|
515
544
|
method: "POST",
|
|
516
545
|
headers: { "Content-Type": "application/json" },
|
|
517
|
-
body: JSON.stringify(
|
|
546
|
+
body: JSON.stringify(h),
|
|
547
|
+
...this.enableCookieSession && { credentials: "include" }
|
|
518
548
|
});
|
|
519
549
|
} catch (c) {
|
|
520
550
|
throw c instanceof Error ? c : new Error("Network error during token refresh");
|
|
@@ -527,10 +557,10 @@ const ie = class ie {
|
|
|
527
557
|
} catch {
|
|
528
558
|
c = f.statusText.toLowerCase();
|
|
529
559
|
}
|
|
530
|
-
throw f.status === 401 ? c.includes("expired") ? new
|
|
560
|
+
throw f.status === 401 ? c.includes("expired") ? new ne("token_expired") : c.includes("invalid") ? new ne("token_invalid") : new ne("token_invalid", `Unauthorized: ${c}`) : f.status === 400 ? c.includes("inactive") ? new ne("user_inactive") : c.includes("expired") || c.includes("invalid") ? new ne("token_invalid", c) : c.includes("reuse") || c.includes("revoked") ? new ne("token_invalid", c) : new Error(`Token refresh failed (400): ${c}`) : new Error(`Token refresh failed: ${f.status} ${c}`);
|
|
531
561
|
}
|
|
532
562
|
if (this.sessionGeneration !== t)
|
|
533
|
-
throw new
|
|
563
|
+
throw new ne("token_invalid", "Session cleared during refresh");
|
|
534
564
|
const y = await f.json();
|
|
535
565
|
this.setTokens({
|
|
536
566
|
accessToken: y.accessToken,
|
|
@@ -558,7 +588,7 @@ const ie = class ie {
|
|
|
558
588
|
// --- Session lifecycle ---
|
|
559
589
|
clearSession() {
|
|
560
590
|
this.sessionGeneration++, this.cancelProactiveTimer(), this.clearTokens();
|
|
561
|
-
const e = new
|
|
591
|
+
const e = new ne("token_invalid", "Session cleared");
|
|
562
592
|
this.rejectQueue(e);
|
|
563
593
|
}
|
|
564
594
|
/**
|
|
@@ -566,8 +596,8 @@ const ie = class ie {
|
|
|
566
596
|
* Cancels all timers and rejects pending queue entries.
|
|
567
597
|
*/
|
|
568
598
|
destroy() {
|
|
569
|
-
this.isDestroyed = !0,
|
|
570
|
-
const e = new
|
|
599
|
+
this.isDestroyed = !0, se.instances.delete(this.storageKey), this.cancelProactiveTimer();
|
|
600
|
+
const e = new ne("token_invalid", "SessionManager destroyed");
|
|
571
601
|
this.rejectQueue(e);
|
|
572
602
|
}
|
|
573
603
|
// --- JWT helpers ---
|
|
@@ -605,10 +635,10 @@ const ie = class ie {
|
|
|
605
635
|
return new Promise((t) => setTimeout(t, e));
|
|
606
636
|
}
|
|
607
637
|
};
|
|
608
|
-
|
|
609
|
-
let
|
|
610
|
-
const
|
|
611
|
-
class
|
|
638
|
+
se.instances = /* @__PURE__ */ new Map(), se.MAX_BACKGROUND_FAILURES = 3;
|
|
639
|
+
let Le = se;
|
|
640
|
+
const Re = /* @__PURE__ */ new Map();
|
|
641
|
+
class bt {
|
|
612
642
|
constructor(e) {
|
|
613
643
|
this.httpService = e;
|
|
614
644
|
}
|
|
@@ -649,12 +679,12 @@ class vt {
|
|
|
649
679
|
);
|
|
650
680
|
}
|
|
651
681
|
async verifyMagicLink(e) {
|
|
652
|
-
const t = e.token, r =
|
|
682
|
+
const t = e.token, r = Re.get(t);
|
|
653
683
|
if (r) return r;
|
|
654
684
|
const i = this.httpService.post("/auth/magic-link/verify", e).finally(() => {
|
|
655
|
-
|
|
685
|
+
Re.delete(t);
|
|
656
686
|
});
|
|
657
|
-
return
|
|
687
|
+
return Re.set(t, i), i;
|
|
658
688
|
}
|
|
659
689
|
async confirmPasswordReset(e) {
|
|
660
690
|
await this.httpService.post("/auth/password-reset/confirm", e);
|
|
@@ -666,7 +696,7 @@ class vt {
|
|
|
666
696
|
});
|
|
667
697
|
}
|
|
668
698
|
}
|
|
669
|
-
class
|
|
699
|
+
class Ve {
|
|
670
700
|
constructor(e, t) {
|
|
671
701
|
this.httpService = e, this.sessionManager = t;
|
|
672
702
|
}
|
|
@@ -742,7 +772,7 @@ class We {
|
|
|
742
772
|
};
|
|
743
773
|
}
|
|
744
774
|
}
|
|
745
|
-
class
|
|
775
|
+
class vt {
|
|
746
776
|
constructor(e, t) {
|
|
747
777
|
this.httpService = e, this.sessionManager = t;
|
|
748
778
|
}
|
|
@@ -782,7 +812,7 @@ class St {
|
|
|
782
812
|
});
|
|
783
813
|
}
|
|
784
814
|
}
|
|
785
|
-
class
|
|
815
|
+
class we {
|
|
786
816
|
constructor(e, t, r) {
|
|
787
817
|
this.httpService = e, this.appId = t, this.sessionManager = r;
|
|
788
818
|
}
|
|
@@ -860,7 +890,7 @@ class ve {
|
|
|
860
890
|
)).data;
|
|
861
891
|
}
|
|
862
892
|
}
|
|
863
|
-
function
|
|
893
|
+
function St(n, e) {
|
|
864
894
|
if (n === "localhost" || n.startsWith("127.") || n.startsWith("192.168."))
|
|
865
895
|
return null;
|
|
866
896
|
if (e) {
|
|
@@ -876,26 +906,26 @@ function Tt(n, e) {
|
|
|
876
906
|
const r = n.split(".");
|
|
877
907
|
return r.length >= 3 && r[0] !== "www" ? r[0] : null;
|
|
878
908
|
}
|
|
879
|
-
function
|
|
909
|
+
function Tt(n, e = "tenant", t) {
|
|
880
910
|
const i = new URLSearchParams(n).get(e);
|
|
881
911
|
return i ? (t && t.setItem("tenant", i), i) : t ? t.getItem("tenant") : null;
|
|
882
912
|
}
|
|
883
|
-
function
|
|
913
|
+
function kt(n, e, t) {
|
|
884
914
|
const { tenantMode: r, baseDomain: i, selectorParam: o, fixedTenantSlug: a } = n;
|
|
885
|
-
return r === "fixed" ? a || null : r === "subdomain" ?
|
|
915
|
+
return r === "fixed" ? a || null : r === "subdomain" ? St(e.hostname, i) : r === "selector" ? Tt(e.search, o, t) : null;
|
|
886
916
|
}
|
|
887
|
-
function
|
|
917
|
+
function xt(n, e, t) {
|
|
888
918
|
if (t)
|
|
889
919
|
return `${n}.${t}`;
|
|
890
920
|
const r = e.split(".");
|
|
891
921
|
return r.length === 2 ? `${n}.${e}` : r.length >= 3 ? (r[0] = n, r.join(".")) : null;
|
|
892
922
|
}
|
|
893
|
-
const
|
|
894
|
-
function
|
|
923
|
+
const ge = "_auth";
|
|
924
|
+
function We(n) {
|
|
895
925
|
const e = JSON.stringify(n);
|
|
896
926
|
return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
897
927
|
}
|
|
898
|
-
function
|
|
928
|
+
function At(n) {
|
|
899
929
|
try {
|
|
900
930
|
let e = n.replace(/-/g, "+").replace(/_/g, "/");
|
|
901
931
|
for (; e.length % 4; )
|
|
@@ -906,20 +936,20 @@ function Pt(n) {
|
|
|
906
936
|
return null;
|
|
907
937
|
}
|
|
908
938
|
}
|
|
909
|
-
function
|
|
939
|
+
function Pt() {
|
|
910
940
|
if (typeof window > "u")
|
|
911
941
|
return null;
|
|
912
|
-
const e = new URLSearchParams(window.location.search).get(
|
|
913
|
-
return e ?
|
|
942
|
+
const e = new URLSearchParams(window.location.search).get(ge);
|
|
943
|
+
return e ? At(e) : null;
|
|
914
944
|
}
|
|
915
|
-
function
|
|
945
|
+
function Rt() {
|
|
916
946
|
if (typeof window > "u") return;
|
|
917
947
|
const n = new URL(window.location.href);
|
|
918
|
-
n.searchParams.delete(
|
|
948
|
+
n.searchParams.delete(ge), window.history.replaceState({}, "", n.toString());
|
|
919
949
|
}
|
|
920
|
-
const
|
|
921
|
-
function
|
|
922
|
-
const { baseUrl: t, appInfo: r, appId: i } =
|
|
950
|
+
const De = me(null);
|
|
951
|
+
function vr({ config: n, children: e }) {
|
|
952
|
+
const { baseUrl: t, appInfo: r, appId: i } = ke(), o = ie(() => typeof window > "u" ? null : kt(
|
|
923
953
|
{
|
|
924
954
|
tenantMode: n.tenantMode || "selector",
|
|
925
955
|
baseDomain: n.baseDomain,
|
|
@@ -931,12 +961,12 @@ function Sr({ config: n, children: e }) {
|
|
|
931
961
|
search: window.location.search
|
|
932
962
|
},
|
|
933
963
|
window.localStorage
|
|
934
|
-
), [n.tenantMode, n.baseDomain, n.selectorParam, n.fixedTenantSlug]), [a,
|
|
964
|
+
), [n.tenantMode, n.baseDomain, n.selectorParam, n.fixedTenantSlug]), [a, h] = x(() => o()), f = K(
|
|
935
965
|
() => {
|
|
936
|
-
var g,
|
|
966
|
+
var g, C, b;
|
|
937
967
|
return {
|
|
938
968
|
enabled: ((g = n.cache) == null ? void 0 : g.enabled) ?? !0,
|
|
939
|
-
ttl: ((
|
|
969
|
+
ttl: ((C = n.cache) == null ? void 0 : C.ttl) ?? 5 * 60 * 1e3,
|
|
940
970
|
// 5 minutes default
|
|
941
971
|
storageKey: ((b = n.cache) == null ? void 0 : b.storageKey) ?? `tenant_cache_${a || "default"}`
|
|
942
972
|
};
|
|
@@ -948,23 +978,23 @@ function Sr({ config: n, children: e }) {
|
|
|
948
978
|
try {
|
|
949
979
|
const g = localStorage.getItem(f.storageKey);
|
|
950
980
|
if (!g) return null;
|
|
951
|
-
const
|
|
952
|
-
return Date.now() -
|
|
981
|
+
const C = JSON.parse(g);
|
|
982
|
+
return Date.now() - C.timestamp < f.ttl && C.tenantSlug === a ? C.data : (localStorage.removeItem(f.storageKey), null);
|
|
953
983
|
} catch {
|
|
954
984
|
return null;
|
|
955
985
|
}
|
|
956
|
-
}), [L, m] = x(!y && !n.initialTenant), [T, A] = x(null), [N, M] = x(null), [P,
|
|
957
|
-
|
|
986
|
+
}), [L, m] = x(!y && !n.initialTenant), [T, A] = x(null), [N, M] = x(null), [P, d] = x(!1), [v, F] = x(null);
|
|
987
|
+
te(() => {
|
|
958
988
|
if (n.tenantMode === "fixed") return;
|
|
959
989
|
const g = o();
|
|
960
|
-
|
|
990
|
+
h(g);
|
|
961
991
|
}, [o, n.tenantMode]);
|
|
962
|
-
const
|
|
963
|
-
async (g,
|
|
964
|
-
if (!(!
|
|
992
|
+
const U = (r == null ? void 0 : r.settingsSchema) || null, w = ie(
|
|
993
|
+
async (g, C = !1) => {
|
|
994
|
+
if (!(!C && f.enabled && y && y.domain === g))
|
|
965
995
|
try {
|
|
966
996
|
m(!0), A(null);
|
|
967
|
-
const b = new
|
|
997
|
+
const b = new ce(t), S = await new we(b, i).getPublicTenantInfo(g);
|
|
968
998
|
if (c(S), f.enabled)
|
|
969
999
|
try {
|
|
970
1000
|
const E = {
|
|
@@ -984,66 +1014,66 @@ function Sr({ config: n, children: e }) {
|
|
|
984
1014
|
}
|
|
985
1015
|
},
|
|
986
1016
|
[t, i, f, y]
|
|
987
|
-
), R =
|
|
1017
|
+
), R = ie(async () => {
|
|
988
1018
|
if (!(!f.enabled || !y || !a))
|
|
989
1019
|
try {
|
|
990
1020
|
const g = localStorage.getItem(f.storageKey);
|
|
991
1021
|
if (!g) return;
|
|
992
|
-
const
|
|
993
|
-
if (Date.now() -
|
|
994
|
-
const p = new
|
|
1022
|
+
const C = JSON.parse(g);
|
|
1023
|
+
if (Date.now() - C.timestamp > f.ttl * 0.5) {
|
|
1024
|
+
const p = new ce(t), E = await new we(p, i).getPublicTenantInfo(a);
|
|
995
1025
|
c(E);
|
|
996
|
-
const
|
|
1026
|
+
const Q = {
|
|
997
1027
|
data: E,
|
|
998
1028
|
timestamp: Date.now(),
|
|
999
1029
|
tenantSlug: a
|
|
1000
1030
|
};
|
|
1001
|
-
localStorage.setItem(f.storageKey, JSON.stringify(
|
|
1031
|
+
localStorage.setItem(f.storageKey, JSON.stringify(Q));
|
|
1002
1032
|
}
|
|
1003
1033
|
} catch (g) {
|
|
1004
1034
|
process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Background tenant refresh failed:", g);
|
|
1005
1035
|
}
|
|
1006
|
-
}, [t, i, f, y, a]), k =
|
|
1036
|
+
}, [t, i, f, y, a]), k = ie(async () => {
|
|
1007
1037
|
if (y != null && y.id)
|
|
1008
1038
|
try {
|
|
1009
|
-
|
|
1010
|
-
const g = new
|
|
1039
|
+
d(!0), F(null);
|
|
1040
|
+
const g = new ce(t), b = await new we(g, y.appId).getTenantSettings(y.id);
|
|
1011
1041
|
M(b);
|
|
1012
1042
|
} catch (g) {
|
|
1013
|
-
const
|
|
1014
|
-
F(
|
|
1043
|
+
const C = g instanceof Error ? g : new Error("Failed to load tenant settings");
|
|
1044
|
+
F(C), M(null);
|
|
1015
1045
|
} finally {
|
|
1016
|
-
|
|
1046
|
+
d(!1);
|
|
1017
1047
|
}
|
|
1018
|
-
}, [t, y]), I =
|
|
1048
|
+
}, [t, y]), I = ie(() => {
|
|
1019
1049
|
k();
|
|
1020
|
-
}, [k]), l =
|
|
1050
|
+
}, [k]), l = ie(
|
|
1021
1051
|
(g) => {
|
|
1022
|
-
if (!
|
|
1052
|
+
if (!U)
|
|
1023
1053
|
return { isValid: !0, errors: [] };
|
|
1024
|
-
const
|
|
1054
|
+
const C = [];
|
|
1025
1055
|
try {
|
|
1026
|
-
return
|
|
1056
|
+
return U.properties && Object.entries(U.properties).forEach(([b, p]) => {
|
|
1027
1057
|
var E;
|
|
1028
1058
|
const S = g[b];
|
|
1029
|
-
if ((E =
|
|
1030
|
-
|
|
1059
|
+
if ((E = U.required) != null && E.includes(b) && S == null) {
|
|
1060
|
+
C.push(`Field '${b}' is required`);
|
|
1031
1061
|
return;
|
|
1032
1062
|
}
|
|
1033
1063
|
if (S != null) {
|
|
1034
1064
|
if (p.type) {
|
|
1035
|
-
const
|
|
1036
|
-
|
|
1065
|
+
const Q = p.type, J = typeof S;
|
|
1066
|
+
Q === "string" && J !== "string" ? C.push(`Field '${b}' must be a string`) : (Q === "number" || Q === "integer") && J !== "number" ? C.push(`Field '${b}' must be a number`) : Q === "boolean" && J !== "boolean" ? C.push(`Field '${b}' must be a boolean`) : Q === "array" && !Array.isArray(S) && C.push(`Field '${b}' must be an array`);
|
|
1037
1067
|
}
|
|
1038
|
-
p.minLength !== void 0 && typeof S == "string" && S.length < p.minLength &&
|
|
1068
|
+
p.minLength !== void 0 && typeof S == "string" && S.length < p.minLength && C.push(
|
|
1039
1069
|
`Field '${b}' must be at least ${p.minLength} characters long`
|
|
1040
|
-
), p.maxLength !== void 0 && typeof S == "string" && S.length > p.maxLength &&
|
|
1070
|
+
), p.maxLength !== void 0 && typeof S == "string" && S.length > p.maxLength && C.push(
|
|
1041
1071
|
`Field '${b}' must be no more than ${p.maxLength} characters long`
|
|
1042
|
-
), p.minimum !== void 0 && typeof S == "number" && S < p.minimum &&
|
|
1072
|
+
), p.minimum !== void 0 && typeof S == "number" && S < p.minimum && C.push(`Field '${b}' must be at least ${p.minimum}`), p.maximum !== void 0 && typeof S == "number" && S > p.maximum && C.push(`Field '${b}' must be no more than ${p.maximum}`), p.pattern && typeof S == "string" && (new RegExp(p.pattern).test(S) || C.push(`Field '${b}' does not match the required pattern`)), p.enum && !p.enum.includes(S) && C.push(`Field '${b}' must be one of: ${p.enum.join(", ")}`);
|
|
1043
1073
|
}
|
|
1044
1074
|
}), {
|
|
1045
|
-
isValid:
|
|
1046
|
-
errors:
|
|
1075
|
+
isValid: C.length === 0,
|
|
1076
|
+
errors: C
|
|
1047
1077
|
};
|
|
1048
1078
|
} catch {
|
|
1049
1079
|
return {
|
|
@@ -1052,16 +1082,16 @@ function Sr({ config: n, children: e }) {
|
|
|
1052
1082
|
};
|
|
1053
1083
|
}
|
|
1054
1084
|
},
|
|
1055
|
-
[
|
|
1085
|
+
[U]
|
|
1056
1086
|
);
|
|
1057
|
-
|
|
1087
|
+
te(() => {
|
|
1058
1088
|
!n.initialTenant && a ? y ? R() : w(a) : !n.initialTenant && !a && (c(null), A(null), m(!1));
|
|
1059
|
-
}, [n.initialTenant, a, y, w, R]),
|
|
1060
|
-
y != null && y.id ? k() : (M(null), F(null),
|
|
1089
|
+
}, [n.initialTenant, a, y, w, R]), te(() => {
|
|
1090
|
+
y != null && y.id ? k() : (M(null), F(null), d(!1));
|
|
1061
1091
|
}, [y == null ? void 0 : y.id, k]);
|
|
1062
|
-
const
|
|
1063
|
-
(g,
|
|
1064
|
-
const { mode: b = "reload", tokens: p, redirectPath: S } =
|
|
1092
|
+
const _ = ie(
|
|
1093
|
+
(g, C) => {
|
|
1094
|
+
const { mode: b = "reload", tokens: p, redirectPath: S } = C || {}, E = n.tenantMode || "selector";
|
|
1065
1095
|
if (E === "fixed") {
|
|
1066
1096
|
process.env.NODE_ENV === "development" && console.warn(
|
|
1067
1097
|
"[TenantProvider] switchTenant is a no-op in fixed mode. Tenant is always:",
|
|
@@ -1070,35 +1100,35 @@ function Sr({ config: n, children: e }) {
|
|
|
1070
1100
|
return;
|
|
1071
1101
|
}
|
|
1072
1102
|
if (localStorage.setItem("tenant", g), E === "subdomain") {
|
|
1073
|
-
const
|
|
1103
|
+
const Q = window.location.hostname, J = xt(
|
|
1074
1104
|
g,
|
|
1075
|
-
|
|
1105
|
+
Q,
|
|
1076
1106
|
n.baseDomain
|
|
1077
1107
|
);
|
|
1078
|
-
if (!
|
|
1108
|
+
if (!J) {
|
|
1079
1109
|
process.env.NODE_ENV === "development" && console.warn(
|
|
1080
1110
|
"[TenantProvider] Cannot switch subdomain, invalid hostname:",
|
|
1081
|
-
|
|
1111
|
+
Q
|
|
1082
1112
|
);
|
|
1083
1113
|
return;
|
|
1084
1114
|
}
|
|
1085
|
-
const
|
|
1115
|
+
const ee = S || window.location.pathname, W = new URL(`${window.location.protocol}//${J}${ee}`);
|
|
1086
1116
|
new URLSearchParams(window.location.search).forEach((V, H) => {
|
|
1087
|
-
H !==
|
|
1088
|
-
}), p && W.searchParams.set(
|
|
1117
|
+
H !== ge && W.searchParams.set(H, V);
|
|
1118
|
+
}), p && W.searchParams.set(ge, We(p)), window.location.href = W.toString();
|
|
1089
1119
|
} else if (E === "selector") {
|
|
1090
|
-
const
|
|
1091
|
-
if (
|
|
1092
|
-
const
|
|
1093
|
-
window.location.href =
|
|
1120
|
+
const Q = S || window.location.pathname, J = new URLSearchParams(window.location.search);
|
|
1121
|
+
if (J.set(n.selectorParam || "tenant", g), J.delete(ge), p && J.set(ge, We(p)), b === "reload") {
|
|
1122
|
+
const ee = `${Q}?${J.toString()}${window.location.hash}`;
|
|
1123
|
+
window.location.href = ee;
|
|
1094
1124
|
} else {
|
|
1095
|
-
const
|
|
1096
|
-
window.history.pushState({}, "",
|
|
1125
|
+
const ee = `${Q}?${J.toString()}${window.location.hash}`;
|
|
1126
|
+
window.history.pushState({}, "", ee), h(g), w(g);
|
|
1097
1127
|
}
|
|
1098
1128
|
}
|
|
1099
1129
|
},
|
|
1100
1130
|
[n.tenantMode, n.selectorParam, n.baseDomain, w]
|
|
1101
|
-
), D =
|
|
1131
|
+
), D = K(() => ({
|
|
1102
1132
|
// Tenant info
|
|
1103
1133
|
tenant: y,
|
|
1104
1134
|
tenantSlug: a,
|
|
@@ -1109,12 +1139,12 @@ function Sr({ config: n, children: e }) {
|
|
|
1109
1139
|
},
|
|
1110
1140
|
// Settings
|
|
1111
1141
|
settings: N,
|
|
1112
|
-
settingsSchema:
|
|
1142
|
+
settingsSchema: U,
|
|
1113
1143
|
isSettingsLoading: P,
|
|
1114
1144
|
settingsError: v,
|
|
1115
1145
|
// Actions
|
|
1116
1146
|
refreshSettings: I,
|
|
1117
|
-
switchTenant:
|
|
1147
|
+
switchTenant: _,
|
|
1118
1148
|
// Validation
|
|
1119
1149
|
validateSettings: l
|
|
1120
1150
|
}), [
|
|
@@ -1123,27 +1153,27 @@ function Sr({ config: n, children: e }) {
|
|
|
1123
1153
|
L,
|
|
1124
1154
|
T,
|
|
1125
1155
|
N,
|
|
1126
|
-
|
|
1156
|
+
U,
|
|
1127
1157
|
P,
|
|
1128
1158
|
v,
|
|
1129
1159
|
I,
|
|
1130
|
-
|
|
1160
|
+
_,
|
|
1131
1161
|
l
|
|
1132
1162
|
]);
|
|
1133
|
-
return /* @__PURE__ */ s(
|
|
1163
|
+
return /* @__PURE__ */ s(De.Provider, { value: D, children: e });
|
|
1134
1164
|
}
|
|
1135
|
-
function
|
|
1136
|
-
const n =
|
|
1165
|
+
function ve() {
|
|
1166
|
+
const n = ae(De);
|
|
1137
1167
|
if (!n)
|
|
1138
1168
|
throw new Error("useTenant must be used within a TenantProvider");
|
|
1139
1169
|
return n;
|
|
1140
1170
|
}
|
|
1141
|
-
function
|
|
1142
|
-
return
|
|
1171
|
+
function he() {
|
|
1172
|
+
return ae(De);
|
|
1143
1173
|
}
|
|
1144
|
-
const
|
|
1145
|
-
function
|
|
1146
|
-
const { settings: n, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: i } =
|
|
1174
|
+
const Sr = ve;
|
|
1175
|
+
function Tr() {
|
|
1176
|
+
const { settings: n, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: i } = ve();
|
|
1147
1177
|
return {
|
|
1148
1178
|
settings: n,
|
|
1149
1179
|
settingsSchema: e,
|
|
@@ -1152,8 +1182,8 @@ function kr() {
|
|
|
1152
1182
|
validateSettings: i
|
|
1153
1183
|
};
|
|
1154
1184
|
}
|
|
1155
|
-
function
|
|
1156
|
-
const { tenant: n, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: i } =
|
|
1185
|
+
function Ke() {
|
|
1186
|
+
const { tenant: n, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: i } = ve();
|
|
1157
1187
|
return {
|
|
1158
1188
|
tenant: n,
|
|
1159
1189
|
tenantSlug: e,
|
|
@@ -1162,319 +1192,318 @@ function Ze() {
|
|
|
1162
1192
|
retry: i
|
|
1163
1193
|
};
|
|
1164
1194
|
}
|
|
1165
|
-
const
|
|
1166
|
-
function
|
|
1167
|
-
const t =
|
|
1195
|
+
const Ce = me(null);
|
|
1196
|
+
function kr({ config: n = {}, children: e }) {
|
|
1197
|
+
const t = Fe(), r = he(), 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, h = (r == null ? void 0 : r.tenantSlug) ?? null, f = (r == null ? void 0 : r.switchTenant) ?? (() => {
|
|
1168
1198
|
});
|
|
1169
1199
|
if (!i)
|
|
1170
1200
|
throw new Error(
|
|
1171
1201
|
"[AuthProvider] baseUrl is required. Provide it via AppProvider or AuthConfig.baseUrl."
|
|
1172
1202
|
);
|
|
1173
|
-
const [y, c] = x(n.initialRoles || []), [L, m] = x(!n.initialRoles), [T, A] = x(null), [N, M] = x(!1), [P,
|
|
1203
|
+
const [y, c] = x(n.initialRoles || []), [L, m] = x(!n.initialRoles), [T, A] = x(null), [N, M] = x(!1), [P, d] = x(null), [v, F] = x(() => {
|
|
1174
1204
|
try {
|
|
1175
|
-
const
|
|
1176
|
-
return
|
|
1205
|
+
const B = localStorage.getItem("userTenants");
|
|
1206
|
+
return B ? JSON.parse(B) : [];
|
|
1177
1207
|
} catch {
|
|
1178
1208
|
return [];
|
|
1179
1209
|
}
|
|
1180
|
-
}), [
|
|
1181
|
-
R.current.done || (R.current.done = !0, R.current.urlTokens =
|
|
1182
|
-
const [k, I] = x(() => R.current.urlTokens !== null), l =
|
|
1183
|
-
const
|
|
1184
|
-
tenantSlug: d,
|
|
1210
|
+
}), [U, w] = x(!1), R = Me({ done: !1, urlTokens: null });
|
|
1211
|
+
R.current.done || (R.current.done = !0, R.current.urlTokens = Pt());
|
|
1212
|
+
const [k, I] = x(() => R.current.urlTokens !== null), l = K(() => {
|
|
1213
|
+
const B = Le.getInstance({
|
|
1185
1214
|
baseUrl: i,
|
|
1215
|
+
enableCookieSession: n.enableCookieSession,
|
|
1186
1216
|
refreshQueueTimeout: n.refreshQueueTimeout,
|
|
1187
1217
|
proactiveRefreshMargin: n.proactiveRefreshMargin,
|
|
1188
|
-
onSessionExpired: (
|
|
1189
|
-
A(null),
|
|
1218
|
+
onSessionExpired: (le) => {
|
|
1219
|
+
A(null), d(null), F([]), w(!1);
|
|
1190
1220
|
try {
|
|
1191
1221
|
localStorage.removeItem("userTenants");
|
|
1192
1222
|
} catch {
|
|
1193
1223
|
}
|
|
1194
|
-
n.onSessionExpired ? n.onSessionExpired(
|
|
1224
|
+
n.onSessionExpired ? n.onSessionExpired(le) : n.onRefreshFailed && n.onRefreshFailed();
|
|
1195
1225
|
}
|
|
1196
1226
|
});
|
|
1197
|
-
return R.current.urlTokens &&
|
|
1227
|
+
return R.current.urlTokens && B.setTokens({
|
|
1198
1228
|
accessToken: R.current.urlTokens.accessToken,
|
|
1199
1229
|
refreshToken: R.current.urlTokens.refreshToken,
|
|
1200
1230
|
expiresIn: R.current.urlTokens.expiresIn
|
|
1201
|
-
}),
|
|
1202
|
-
}, [
|
|
1231
|
+
}), B;
|
|
1232
|
+
}, [
|
|
1233
|
+
i,
|
|
1234
|
+
n.enableCookieSession,
|
|
1235
|
+
n.refreshQueueTimeout,
|
|
1236
|
+
n.proactiveRefreshMargin
|
|
1237
|
+
]), [_, D] = x(() => {
|
|
1203
1238
|
if (R.current.urlTokens) return !1;
|
|
1204
|
-
const
|
|
1205
|
-
return
|
|
1206
|
-
}), g = R.current.done && !k && !
|
|
1207
|
-
const
|
|
1208
|
-
return
|
|
1209
|
-
}, [i, l]), b =
|
|
1210
|
-
}), q =
|
|
1211
|
-
const
|
|
1239
|
+
const B = l.getTokens();
|
|
1240
|
+
return B ? l.hasValidSession() || !!B.refreshToken : !!n.enableCookieSession;
|
|
1241
|
+
}), g = R.current.done && !k && !_, C = K(() => {
|
|
1242
|
+
const B = new ce(i);
|
|
1243
|
+
return B.setSessionManager(l), B;
|
|
1244
|
+
}, [i, l]), b = K(() => new bt(new ce(i)), [i]), p = K(() => new vt(C, l), [C, l]), S = K(() => new Ve(new ce(i)), [i]), E = K(() => T || l.getUser(), [T, l]), Q = K(() => E != null && E.roleId && y.find((B) => B.id === E.roleId) || null, [E, y]), J = K(() => (Q == null ? void 0 : Q.permissions) || [], [Q]), ee = K(() => l.hasValidSession() && T !== null, [l, T]), W = Me(async () => {
|
|
1245
|
+
}), q = K(() => {
|
|
1246
|
+
const B = async ($ = !1) => {
|
|
1212
1247
|
try {
|
|
1213
|
-
if (!l.hasValidSession() ||
|
|
1248
|
+
if (!l.hasValidSession() || !$ && T)
|
|
1214
1249
|
return;
|
|
1215
1250
|
const O = l.getUserId();
|
|
1216
1251
|
if (!O) {
|
|
1217
1252
|
process.env.NODE_ENV === "development" && console.warn("[AuthProvider] No userId available in token or storage");
|
|
1218
1253
|
return;
|
|
1219
1254
|
}
|
|
1220
|
-
M(!0),
|
|
1255
|
+
M(!0), d(null);
|
|
1221
1256
|
const Z = await p.getUserById(O);
|
|
1222
1257
|
A(Z), l.setUser(Z);
|
|
1223
1258
|
} catch (O) {
|
|
1224
1259
|
const Z = O instanceof Error ? O : new Error("Failed to load user data");
|
|
1225
|
-
|
|
1260
|
+
d(Z), process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to load user data:", Z);
|
|
1226
1261
|
} finally {
|
|
1227
1262
|
M(!1);
|
|
1228
1263
|
}
|
|
1229
|
-
},
|
|
1230
|
-
await
|
|
1231
|
-
},
|
|
1232
|
-
var
|
|
1233
|
-
const { username: O, password: Z, tenantSlug: j, redirectPath:
|
|
1234
|
-
let
|
|
1235
|
-
j && (
|
|
1236
|
-
const
|
|
1264
|
+
}, le = async () => {
|
|
1265
|
+
await B();
|
|
1266
|
+
}, pe = async ($) => {
|
|
1267
|
+
var qe;
|
|
1268
|
+
const { username: O, password: Z, tenantSlug: j, redirectPath: X } = $;
|
|
1269
|
+
let re = a == null ? void 0 : a.id, Y = h;
|
|
1270
|
+
j && (re = (await new we(C, o).getPublicTenantInfo(j)).id, Y = j);
|
|
1271
|
+
const G = await b.login({
|
|
1237
1272
|
username: O,
|
|
1238
1273
|
password: Z,
|
|
1239
1274
|
appId: o,
|
|
1240
|
-
tenantId:
|
|
1241
|
-
}),
|
|
1242
|
-
if (
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
expiresIn: Q.expiresIn
|
|
1249
|
-
}), Q.user) {
|
|
1250
|
-
re.setUser(Q.user), A(Q.user);
|
|
1275
|
+
tenantId: re
|
|
1276
|
+
}), ye = j && j !== h;
|
|
1277
|
+
if (l.setTokens({
|
|
1278
|
+
accessToken: G.accessToken,
|
|
1279
|
+
refreshToken: G.refreshToken,
|
|
1280
|
+
expiresIn: G.expiresIn
|
|
1281
|
+
}), G.user) {
|
|
1282
|
+
l.setUser(G.user), A(G.user);
|
|
1251
1283
|
try {
|
|
1252
|
-
await
|
|
1253
|
-
} catch (
|
|
1254
|
-
process.env.NODE_ENV === "development" && console.warn("[AuthProvider] Failed to load complete user data after login:",
|
|
1284
|
+
await B();
|
|
1285
|
+
} catch (Se) {
|
|
1286
|
+
process.env.NODE_ENV === "development" && console.warn("[AuthProvider] Failed to load complete user data after login:", Se);
|
|
1255
1287
|
}
|
|
1256
1288
|
}
|
|
1257
|
-
if (
|
|
1258
|
-
F(
|
|
1289
|
+
if (G.tenants && G.tenants.length > 0) {
|
|
1290
|
+
F(G.tenants);
|
|
1259
1291
|
try {
|
|
1260
|
-
localStorage.setItem("userTenants", JSON.stringify(
|
|
1292
|
+
localStorage.setItem("userTenants", JSON.stringify(G.tenants));
|
|
1261
1293
|
} catch {
|
|
1262
1294
|
}
|
|
1263
1295
|
}
|
|
1264
|
-
const
|
|
1265
|
-
w(
|
|
1266
|
-
const
|
|
1267
|
-
accessToken:
|
|
1268
|
-
refreshToken:
|
|
1269
|
-
expiresIn:
|
|
1296
|
+
const Ae = ((qe = G.user) == null ? void 0 : qe.tenantId) !== null;
|
|
1297
|
+
w(Ae);
|
|
1298
|
+
const Pe = {
|
|
1299
|
+
accessToken: G.accessToken,
|
|
1300
|
+
refreshToken: G.refreshToken,
|
|
1301
|
+
expiresIn: G.expiresIn
|
|
1270
1302
|
};
|
|
1271
|
-
if (
|
|
1272
|
-
return f(
|
|
1273
|
-
if (
|
|
1274
|
-
return f(
|
|
1275
|
-
if (!
|
|
1276
|
-
const
|
|
1277
|
-
if (
|
|
1278
|
-
const ze =
|
|
1279
|
-
return f(ze.subdomain, { tokens:
|
|
1280
|
-
} else
|
|
1303
|
+
if (ye && Y)
|
|
1304
|
+
return f(Y, { tokens: Pe, redirectPath: X }), G;
|
|
1305
|
+
if (X && X !== window.location.pathname)
|
|
1306
|
+
return f(Y || h || "", { tokens: Pe, redirectPath: X }), G;
|
|
1307
|
+
if (!Ae && G.tenants && G.tenants.length > 0) {
|
|
1308
|
+
const Se = $.autoSwitch !== !1 && n.autoSwitchSingleTenant !== !1;
|
|
1309
|
+
if (G.tenants.length === 1 && Se) {
|
|
1310
|
+
const ze = G.tenants[0];
|
|
1311
|
+
return f(ze.subdomain, { tokens: Pe, redirectPath: X }), G;
|
|
1312
|
+
} else G.tenants.length > 1 && n.onTenantSelectionRequired && n.onTenantSelectionRequired(G.tenants);
|
|
1281
1313
|
}
|
|
1282
|
-
return
|
|
1283
|
-
},
|
|
1284
|
-
const { email: O, phoneNumber: Z, name: j, password:
|
|
1314
|
+
return G;
|
|
1315
|
+
}, fe = async ($) => {
|
|
1316
|
+
const { email: O, phoneNumber: Z, name: j, password: X, lastName: re, tenantId: Y } = $;
|
|
1285
1317
|
if (!O && !Z)
|
|
1286
1318
|
throw new Error("Either email or phoneNumber is required");
|
|
1287
|
-
if (!j || !
|
|
1319
|
+
if (!j || !X)
|
|
1288
1320
|
throw new Error("Name and password are required");
|
|
1289
|
-
const
|
|
1321
|
+
const G = Y ?? (a == null ? void 0 : a.id);
|
|
1290
1322
|
return await b.signup({
|
|
1291
1323
|
email: O,
|
|
1292
1324
|
phoneNumber: Z,
|
|
1293
1325
|
name: j,
|
|
1294
|
-
password:
|
|
1295
|
-
tenantId:
|
|
1296
|
-
lastName:
|
|
1326
|
+
password: X,
|
|
1327
|
+
tenantId: G,
|
|
1328
|
+
lastName: re,
|
|
1297
1329
|
appId: o
|
|
1298
1330
|
});
|
|
1299
|
-
},
|
|
1300
|
-
const { email: O, phoneNumber: Z, name: j, password:
|
|
1331
|
+
}, rt = async ($) => {
|
|
1332
|
+
const { email: O, phoneNumber: Z, name: j, password: X, tenantName: re, lastName: Y } = $;
|
|
1301
1333
|
if (!O && !Z)
|
|
1302
1334
|
throw new Error("Either email or phoneNumber is required");
|
|
1303
|
-
if (!j || !
|
|
1335
|
+
if (!j || !X || !re)
|
|
1304
1336
|
throw new Error("Name, password, and tenantName are required");
|
|
1305
1337
|
return await b.signupTenantAdmin({
|
|
1306
1338
|
email: O,
|
|
1307
1339
|
phoneNumber: Z,
|
|
1308
1340
|
name: j,
|
|
1309
|
-
password:
|
|
1310
|
-
tenantName:
|
|
1341
|
+
password: X,
|
|
1342
|
+
tenantName: re,
|
|
1311
1343
|
appId: o,
|
|
1312
|
-
lastName:
|
|
1344
|
+
lastName: Y
|
|
1313
1345
|
});
|
|
1314
|
-
},
|
|
1315
|
-
const { currentPassword: O, newPassword: Z } =
|
|
1346
|
+
}, nt = async ($) => {
|
|
1347
|
+
const { currentPassword: O, newPassword: Z } = $, j = await l.getAuthHeaders();
|
|
1316
1348
|
await b.changePassword({ currentPassword: O, newPassword: Z }, j);
|
|
1317
|
-
},
|
|
1318
|
-
const { email: O, tenantId: Z } =
|
|
1349
|
+
}, st = async ($) => {
|
|
1350
|
+
const { email: O, tenantId: Z } = $, j = Z ?? (a == null ? void 0 : a.id);
|
|
1319
1351
|
if (!j)
|
|
1320
1352
|
throw new Error("tenantId is required for password reset");
|
|
1321
1353
|
await b.requestPasswordReset({ email: O, tenantId: j });
|
|
1322
|
-
},
|
|
1323
|
-
const { token: O, newPassword: Z } =
|
|
1354
|
+
}, it = async ($) => {
|
|
1355
|
+
const { token: O, newPassword: Z } = $;
|
|
1324
1356
|
await b.confirmPasswordReset({ token: O, newPassword: Z });
|
|
1325
|
-
},
|
|
1326
|
-
const { email: O, frontendUrl: Z, name: j, lastName:
|
|
1327
|
-
if (!
|
|
1357
|
+
}, ot = async ($) => {
|
|
1358
|
+
const { email: O, frontendUrl: Z, name: j, lastName: X, tenantId: re } = $, Y = re ?? (a == null ? void 0 : a.id);
|
|
1359
|
+
if (!Y)
|
|
1328
1360
|
throw new Error("tenantId is required for magic link authentication");
|
|
1329
1361
|
return await b.sendMagicLink({
|
|
1330
1362
|
email: O,
|
|
1331
|
-
tenantId:
|
|
1363
|
+
tenantId: Y,
|
|
1332
1364
|
frontendUrl: Z,
|
|
1333
1365
|
name: j,
|
|
1334
|
-
lastName:
|
|
1366
|
+
lastName: X,
|
|
1335
1367
|
appId: o
|
|
1336
1368
|
});
|
|
1337
|
-
},
|
|
1338
|
-
const { token: O, email: Z, tenantSlug: j } =
|
|
1339
|
-
let
|
|
1340
|
-
j && (
|
|
1341
|
-
const
|
|
1369
|
+
}, at = async ($) => {
|
|
1370
|
+
const { token: O, email: Z, tenantSlug: j } = $;
|
|
1371
|
+
let X = a == null ? void 0 : a.id, re = h;
|
|
1372
|
+
j && (X = (await new we(C, o).getPublicTenantInfo(j)).id, re = j);
|
|
1373
|
+
const Y = await b.verifyMagicLink({
|
|
1342
1374
|
token: O,
|
|
1343
1375
|
email: Z,
|
|
1344
1376
|
appId: o,
|
|
1345
|
-
tenantId:
|
|
1346
|
-
}),
|
|
1347
|
-
if (
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
expiresIn: re.expiresIn
|
|
1354
|
-
}), re.user) {
|
|
1355
|
-
te.setUser(re.user), A(re.user);
|
|
1377
|
+
tenantId: X
|
|
1378
|
+
}), G = j && j !== h;
|
|
1379
|
+
if (l.setTokens({
|
|
1380
|
+
accessToken: Y.accessToken,
|
|
1381
|
+
refreshToken: Y.refreshToken,
|
|
1382
|
+
expiresIn: Y.expiresIn
|
|
1383
|
+
}), Y.user) {
|
|
1384
|
+
l.setUser(Y.user), A(Y.user);
|
|
1356
1385
|
try {
|
|
1357
|
-
await
|
|
1358
|
-
} catch (
|
|
1386
|
+
await B();
|
|
1387
|
+
} catch (ye) {
|
|
1359
1388
|
process.env.NODE_ENV === "development" && console.warn(
|
|
1360
1389
|
"[AuthProvider] Failed to load complete user data after magic link:",
|
|
1361
|
-
|
|
1390
|
+
ye
|
|
1362
1391
|
);
|
|
1363
1392
|
}
|
|
1364
1393
|
}
|
|
1365
|
-
return
|
|
1394
|
+
return G && re && re !== h && f(re, {
|
|
1366
1395
|
tokens: {
|
|
1367
|
-
accessToken:
|
|
1368
|
-
refreshToken:
|
|
1369
|
-
expiresIn:
|
|
1396
|
+
accessToken: Y.accessToken,
|
|
1397
|
+
refreshToken: Y.refreshToken,
|
|
1398
|
+
expiresIn: Y.expiresIn
|
|
1370
1399
|
}
|
|
1371
|
-
}),
|
|
1372
|
-
},
|
|
1373
|
-
const
|
|
1374
|
-
if (!(
|
|
1400
|
+
}), Y;
|
|
1401
|
+
}, lt = async () => {
|
|
1402
|
+
const $ = l.getTokens();
|
|
1403
|
+
if (!($ != null && $.refreshToken))
|
|
1375
1404
|
throw new Error("No refresh token available");
|
|
1376
1405
|
const O = await b.refreshToken({
|
|
1377
|
-
refreshToken:
|
|
1406
|
+
refreshToken: $.refreshToken
|
|
1378
1407
|
});
|
|
1379
1408
|
l.setTokens({
|
|
1380
1409
|
accessToken: O.accessToken,
|
|
1381
|
-
refreshToken: O.refreshToken ||
|
|
1410
|
+
refreshToken: O.refreshToken || $.refreshToken,
|
|
1382
1411
|
expiresIn: O.expiresIn
|
|
1383
1412
|
});
|
|
1384
|
-
},
|
|
1385
|
-
l.clearSession(), A(null),
|
|
1413
|
+
}, ct = () => {
|
|
1414
|
+
l.clearSession(), A(null), d(null), F([]), w(!1);
|
|
1386
1415
|
try {
|
|
1387
1416
|
localStorage.removeItem("userTenants");
|
|
1388
1417
|
} catch {
|
|
1389
1418
|
}
|
|
1390
|
-
},
|
|
1391
|
-
l.setTokens(
|
|
1392
|
-
},
|
|
1393
|
-
l.clearSession(), A(null),
|
|
1394
|
-
},
|
|
1419
|
+
}, dt = ($) => {
|
|
1420
|
+
l.setTokens($);
|
|
1421
|
+
}, ut = () => l.hasValidSession(), ht = () => {
|
|
1422
|
+
l.clearSession(), A(null), d(null);
|
|
1423
|
+
}, pt = async () => {
|
|
1395
1424
|
if (o)
|
|
1396
1425
|
try {
|
|
1397
1426
|
m(!0);
|
|
1398
|
-
const { roles:
|
|
1399
|
-
c(
|
|
1400
|
-
} catch (
|
|
1401
|
-
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:",
|
|
1427
|
+
const { roles: $ } = await S.getRolesByApp(o);
|
|
1428
|
+
c($);
|
|
1429
|
+
} catch ($) {
|
|
1430
|
+
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:", $);
|
|
1402
1431
|
} finally {
|
|
1403
1432
|
m(!1);
|
|
1404
1433
|
}
|
|
1405
|
-
},
|
|
1406
|
-
await
|
|
1407
|
-
},
|
|
1408
|
-
if (!
|
|
1434
|
+
}, ft = async () => {
|
|
1435
|
+
await pt();
|
|
1436
|
+
}, xe = ($) => {
|
|
1437
|
+
if (!J || J.length === 0)
|
|
1409
1438
|
return !1;
|
|
1410
|
-
if (typeof
|
|
1411
|
-
return
|
|
1412
|
-
const O = `${
|
|
1413
|
-
return
|
|
1439
|
+
if (typeof $ == "string")
|
|
1440
|
+
return J.includes($);
|
|
1441
|
+
const O = `${$.resource}.${$.action}`;
|
|
1442
|
+
return J.includes(O);
|
|
1414
1443
|
};
|
|
1415
1444
|
return {
|
|
1416
1445
|
// RFC-003: Authentication state
|
|
1417
|
-
isAuthenticated:
|
|
1446
|
+
isAuthenticated: ee,
|
|
1418
1447
|
sessionManager: l,
|
|
1419
|
-
authenticatedHttpService:
|
|
1420
|
-
login:
|
|
1421
|
-
signup:
|
|
1422
|
-
signupTenantAdmin:
|
|
1423
|
-
sendMagicLink:
|
|
1424
|
-
verifyMagicLink:
|
|
1425
|
-
changePassword:
|
|
1426
|
-
requestPasswordReset:
|
|
1427
|
-
confirmPasswordReset:
|
|
1428
|
-
refreshToken:
|
|
1429
|
-
logout:
|
|
1430
|
-
setTokens:
|
|
1431
|
-
hasValidSession:
|
|
1432
|
-
clearSession:
|
|
1448
|
+
authenticatedHttpService: C,
|
|
1449
|
+
login: pe,
|
|
1450
|
+
signup: fe,
|
|
1451
|
+
signupTenantAdmin: rt,
|
|
1452
|
+
sendMagicLink: ot,
|
|
1453
|
+
verifyMagicLink: at,
|
|
1454
|
+
changePassword: nt,
|
|
1455
|
+
requestPasswordReset: st,
|
|
1456
|
+
confirmPasswordReset: it,
|
|
1457
|
+
refreshToken: lt,
|
|
1458
|
+
logout: ct,
|
|
1459
|
+
setTokens: dt,
|
|
1460
|
+
hasValidSession: ut,
|
|
1461
|
+
clearSession: ht,
|
|
1433
1462
|
currentUser: T,
|
|
1434
1463
|
isUserLoading: N,
|
|
1435
1464
|
userError: P,
|
|
1436
|
-
loadUserData:
|
|
1437
|
-
refreshUser:
|
|
1465
|
+
loadUserData: B,
|
|
1466
|
+
refreshUser: le,
|
|
1438
1467
|
isAuthInitializing: !g,
|
|
1439
1468
|
isAuthReady: g,
|
|
1440
|
-
userRole:
|
|
1441
|
-
userPermissions:
|
|
1469
|
+
userRole: Q,
|
|
1470
|
+
userPermissions: J,
|
|
1442
1471
|
availableRoles: y,
|
|
1443
1472
|
rolesLoading: L,
|
|
1444
|
-
hasPermission:
|
|
1445
|
-
hasAnyPermission: (
|
|
1446
|
-
hasAllPermissions: (
|
|
1447
|
-
getUserPermissionStrings: () =>
|
|
1448
|
-
refreshRoles:
|
|
1473
|
+
hasPermission: xe,
|
|
1474
|
+
hasAnyPermission: ($) => $.some((O) => xe(O)),
|
|
1475
|
+
hasAllPermissions: ($) => $.every((O) => xe(O)),
|
|
1476
|
+
getUserPermissionStrings: () => J || [],
|
|
1477
|
+
refreshRoles: ft,
|
|
1449
1478
|
// RFC-004: Multi-tenant user membership
|
|
1450
1479
|
userTenants: v,
|
|
1451
|
-
hasTenantContext:
|
|
1452
|
-
switchToTenant: async (
|
|
1480
|
+
hasTenantContext: U,
|
|
1481
|
+
switchToTenant: async ($, O) => {
|
|
1453
1482
|
const { redirectPath: Z } = O || {}, j = l.getTokens();
|
|
1454
1483
|
if (!(j != null && j.refreshToken))
|
|
1455
1484
|
throw new Error("No refresh token available for tenant switch");
|
|
1456
|
-
const
|
|
1485
|
+
const X = await b.switchTenant({
|
|
1457
1486
|
refreshToken: j.refreshToken,
|
|
1458
|
-
tenantId:
|
|
1487
|
+
tenantId: $
|
|
1459
1488
|
});
|
|
1460
1489
|
l.setTokens({
|
|
1461
|
-
accessToken:
|
|
1490
|
+
accessToken: X.accessToken,
|
|
1462
1491
|
refreshToken: j.refreshToken,
|
|
1463
1492
|
// Keep the same refresh token
|
|
1464
|
-
expiresIn:
|
|
1465
|
-
}), A(
|
|
1466
|
-
const
|
|
1467
|
-
|
|
1493
|
+
expiresIn: X.expiresIn
|
|
1494
|
+
}), A(X.user), l.setUser(X.user), w(!0);
|
|
1495
|
+
const re = v.find((Y) => Y.id === $);
|
|
1496
|
+
re && f(re.subdomain, {
|
|
1468
1497
|
tokens: {
|
|
1469
|
-
accessToken:
|
|
1498
|
+
accessToken: X.accessToken,
|
|
1470
1499
|
refreshToken: j.refreshToken,
|
|
1471
|
-
expiresIn:
|
|
1500
|
+
expiresIn: X.expiresIn
|
|
1472
1501
|
},
|
|
1473
1502
|
redirectPath: Z
|
|
1474
1503
|
});
|
|
1475
1504
|
},
|
|
1476
1505
|
refreshUserTenants: async () => {
|
|
1477
|
-
const
|
|
1506
|
+
const $ = await l.getAuthHeaders(), O = await b.getUserTenants($);
|
|
1478
1507
|
F(O);
|
|
1479
1508
|
try {
|
|
1480
1509
|
localStorage.setItem("userTenants", JSON.stringify(O));
|
|
@@ -1484,73 +1513,74 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1484
1513
|
}
|
|
1485
1514
|
};
|
|
1486
1515
|
}, [
|
|
1487
|
-
|
|
1516
|
+
ee,
|
|
1488
1517
|
l,
|
|
1489
|
-
|
|
1518
|
+
C,
|
|
1490
1519
|
b,
|
|
1491
1520
|
p,
|
|
1492
1521
|
S,
|
|
1493
1522
|
o,
|
|
1494
1523
|
a,
|
|
1495
|
-
|
|
1524
|
+
h,
|
|
1496
1525
|
f,
|
|
1497
1526
|
y,
|
|
1498
1527
|
T,
|
|
1499
1528
|
N,
|
|
1500
1529
|
P,
|
|
1501
1530
|
v,
|
|
1502
|
-
|
|
1531
|
+
U,
|
|
1503
1532
|
g,
|
|
1504
|
-
|
|
1505
|
-
|
|
1533
|
+
Q,
|
|
1534
|
+
J
|
|
1506
1535
|
]);
|
|
1507
|
-
W.current = q.loadUserData,
|
|
1536
|
+
W.current = q.loadUserData, te(() => {
|
|
1508
1537
|
!n.initialRoles && o && (async () => {
|
|
1509
1538
|
try {
|
|
1510
1539
|
m(!0);
|
|
1511
|
-
const
|
|
1512
|
-
c(
|
|
1513
|
-
} catch (
|
|
1514
|
-
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:",
|
|
1540
|
+
const le = new ce(i), pe = new Ve(le), { roles: fe } = await pe.getRolesByApp(o);
|
|
1541
|
+
c(fe);
|
|
1542
|
+
} catch (le) {
|
|
1543
|
+
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:", le);
|
|
1515
1544
|
} finally {
|
|
1516
1545
|
m(!1);
|
|
1517
1546
|
}
|
|
1518
1547
|
})();
|
|
1519
1548
|
}, [o, i, n.initialRoles]);
|
|
1520
1549
|
const [V, H] = x(!1);
|
|
1521
|
-
return
|
|
1522
|
-
V || (H(!0), R.current.urlTokens && (
|
|
1523
|
-
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to load user data after URL tokens:",
|
|
1550
|
+
return te(() => {
|
|
1551
|
+
V || (H(!0), R.current.urlTokens && (Rt(), I(!0), q.loadUserData().catch((B) => {
|
|
1552
|
+
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to load user data after URL tokens:", B);
|
|
1524
1553
|
}).finally(() => {
|
|
1525
1554
|
I(!1);
|
|
1526
1555
|
})));
|
|
1527
|
-
}, [q, V]),
|
|
1528
|
-
let
|
|
1556
|
+
}, [q, V]), te(() => {
|
|
1557
|
+
let B = !1;
|
|
1529
1558
|
return (async () => {
|
|
1530
|
-
var
|
|
1531
|
-
if (!l.hasValidSession() && ((
|
|
1532
|
-
|
|
1533
|
-
|
|
1559
|
+
var fe;
|
|
1560
|
+
if (!l.hasValidSession() && ((fe = l.getTokens()) != null && fe.refreshToken) && await l.waitForPendingRefresh(), B || !l.hasValidSession() && !l.getTokens() && n.enableCookieSession && (await l.attemptCookieSessionRestore(), B))
|
|
1561
|
+
return;
|
|
1562
|
+
const pe = l.getUser();
|
|
1563
|
+
pe && l.hasValidSession() && A(pe), D(!1);
|
|
1534
1564
|
})(), () => {
|
|
1535
|
-
|
|
1565
|
+
B = !0;
|
|
1536
1566
|
};
|
|
1537
|
-
}, [l]),
|
|
1567
|
+
}, [l, n.enableCookieSession]), te(() => {
|
|
1538
1568
|
V && (R.current.urlTokens || (!T && !N && !P && l.hasValidSession() ? W.current().catch(() => {
|
|
1539
1569
|
}).finally(() => {
|
|
1540
1570
|
D(!1);
|
|
1541
1571
|
}) : D(!1)));
|
|
1542
|
-
}, [T, N, P, l, V]), /* @__PURE__ */ s(
|
|
1572
|
+
}, [T, N, P, l, V]), /* @__PURE__ */ s(Ce.Provider, { value: q, children: e });
|
|
1543
1573
|
}
|
|
1544
|
-
function
|
|
1545
|
-
const n =
|
|
1574
|
+
function ue() {
|
|
1575
|
+
const n = ae(Ce);
|
|
1546
1576
|
if (!n)
|
|
1547
1577
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
1548
1578
|
return n;
|
|
1549
1579
|
}
|
|
1550
|
-
function
|
|
1551
|
-
return
|
|
1580
|
+
function Ue() {
|
|
1581
|
+
return ae(Ce);
|
|
1552
1582
|
}
|
|
1553
|
-
class
|
|
1583
|
+
class Et {
|
|
1554
1584
|
constructor(e, t) {
|
|
1555
1585
|
this.httpService = e, this.sessionManager = t;
|
|
1556
1586
|
}
|
|
@@ -1630,11 +1660,11 @@ class It {
|
|
|
1630
1660
|
})).data;
|
|
1631
1661
|
}
|
|
1632
1662
|
}
|
|
1633
|
-
const
|
|
1634
|
-
function
|
|
1635
|
-
const t =
|
|
1636
|
-
const
|
|
1637
|
-
return new
|
|
1663
|
+
const Be = me(null);
|
|
1664
|
+
function xr({ config: n = {}, children: e }) {
|
|
1665
|
+
const t = Fe(), r = he(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (r == null ? void 0 : r.tenant) ?? null, [h, f] = x([]), [y, c] = x(!1), [L, m] = x(null), [T, A] = x(!1), N = K(() => {
|
|
1666
|
+
const d = new ce(i);
|
|
1667
|
+
return new Et(d);
|
|
1638
1668
|
}, [i]), M = async () => {
|
|
1639
1669
|
if (!(a != null && a.id)) {
|
|
1640
1670
|
f([]);
|
|
@@ -1642,54 +1672,54 @@ function Ar({ config: n = {}, children: e }) {
|
|
|
1642
1672
|
}
|
|
1643
1673
|
c(!0), m(null);
|
|
1644
1674
|
try {
|
|
1645
|
-
const
|
|
1646
|
-
f(
|
|
1647
|
-
} catch (
|
|
1648
|
-
const v =
|
|
1649
|
-
m(v), n.onError && n.onError(
|
|
1675
|
+
const d = await N.getTenantFeatureFlags(a.id, o);
|
|
1676
|
+
f(d);
|
|
1677
|
+
} catch (d) {
|
|
1678
|
+
const v = d instanceof Error ? d.message : "Failed to fetch feature flags";
|
|
1679
|
+
m(v), n.onError && n.onError(d instanceof Error ? d : new Error(v));
|
|
1650
1680
|
} finally {
|
|
1651
1681
|
c(!1);
|
|
1652
1682
|
}
|
|
1653
1683
|
};
|
|
1654
|
-
|
|
1684
|
+
te(() => {
|
|
1655
1685
|
if (!i || !o) return;
|
|
1656
1686
|
M().finally(() => A(!0));
|
|
1657
|
-
const
|
|
1687
|
+
const d = n.refreshInterval || 5 * 60 * 1e3, v = setInterval(M, d);
|
|
1658
1688
|
return () => clearInterval(v);
|
|
1659
1689
|
}, [a == null ? void 0 : a.id, i, o, n.refreshInterval]);
|
|
1660
|
-
const P =
|
|
1661
|
-
const
|
|
1662
|
-
const k =
|
|
1690
|
+
const P = K(() => {
|
|
1691
|
+
const d = (R) => {
|
|
1692
|
+
const k = h.find((I) => I.key === R);
|
|
1663
1693
|
return (k == null ? void 0 : k.value) === !0;
|
|
1664
|
-
}, v = (R) =>
|
|
1665
|
-
const k =
|
|
1694
|
+
}, v = (R) => h.find((k) => k.key === R), F = (R) => {
|
|
1695
|
+
const k = h.find((I) => I.key === R);
|
|
1666
1696
|
return k ? k.value ? "enabled" : "disabled" : "not_found";
|
|
1667
|
-
},
|
|
1697
|
+
}, U = async () => {
|
|
1668
1698
|
await M();
|
|
1669
1699
|
}, w = !!(i && o) && (T || !(a != null && a.id));
|
|
1670
1700
|
return {
|
|
1671
|
-
featureFlags:
|
|
1701
|
+
featureFlags: h,
|
|
1672
1702
|
loading: y,
|
|
1673
1703
|
error: L,
|
|
1674
1704
|
isReady: w,
|
|
1675
|
-
isEnabled:
|
|
1705
|
+
isEnabled: d,
|
|
1676
1706
|
getFlag: v,
|
|
1677
1707
|
getFlagState: F,
|
|
1678
|
-
refresh:
|
|
1708
|
+
refresh: U
|
|
1679
1709
|
};
|
|
1680
|
-
}, [
|
|
1681
|
-
return /* @__PURE__ */ s(
|
|
1710
|
+
}, [h, y, L, i, o, a == null ? void 0 : a.id, T]);
|
|
1711
|
+
return /* @__PURE__ */ s(Be.Provider, { value: P, children: e });
|
|
1682
1712
|
}
|
|
1683
|
-
function
|
|
1684
|
-
const n =
|
|
1713
|
+
function It() {
|
|
1714
|
+
const n = ae(Be);
|
|
1685
1715
|
if (!n)
|
|
1686
1716
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1687
1717
|
return n;
|
|
1688
1718
|
}
|
|
1689
|
-
function
|
|
1690
|
-
return
|
|
1719
|
+
function Ze() {
|
|
1720
|
+
return ae(Be);
|
|
1691
1721
|
}
|
|
1692
|
-
class
|
|
1722
|
+
class Mt {
|
|
1693
1723
|
constructor(e, t) {
|
|
1694
1724
|
this.httpService = e, this.sessionManager = t;
|
|
1695
1725
|
}
|
|
@@ -1755,40 +1785,40 @@ class Lt {
|
|
|
1755
1785
|
)).data;
|
|
1756
1786
|
}
|
|
1757
1787
|
}
|
|
1758
|
-
const
|
|
1759
|
-
function
|
|
1760
|
-
const t =
|
|
1761
|
-
const P = new
|
|
1762
|
-
return new
|
|
1788
|
+
const $e = me(void 0);
|
|
1789
|
+
function Ar({ config: n = {}, children: e }) {
|
|
1790
|
+
const t = Fe(), r = he(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a, h] = x(null), [f, y] = x(!1), [c, L] = x(null), [m, T] = x(!1), A = K(() => {
|
|
1791
|
+
const P = new ce(i);
|
|
1792
|
+
return new Mt(P);
|
|
1763
1793
|
}, [i]), N = async () => {
|
|
1764
1794
|
if (!(o != null && o.id)) {
|
|
1765
|
-
|
|
1795
|
+
h(null);
|
|
1766
1796
|
return;
|
|
1767
1797
|
}
|
|
1768
1798
|
y(!0), L(null);
|
|
1769
1799
|
try {
|
|
1770
1800
|
const P = await A.getTenantSubscriptionFeatures(o.id);
|
|
1771
|
-
|
|
1801
|
+
h(P);
|
|
1772
1802
|
} catch (P) {
|
|
1773
|
-
const
|
|
1774
|
-
L(
|
|
1803
|
+
const d = P instanceof Error ? P.message : "Failed to fetch subscription";
|
|
1804
|
+
L(d), n.onError && n.onError(P instanceof Error ? P : new Error(d));
|
|
1775
1805
|
} finally {
|
|
1776
1806
|
y(!1);
|
|
1777
1807
|
}
|
|
1778
1808
|
};
|
|
1779
|
-
|
|
1809
|
+
te(() => {
|
|
1780
1810
|
if (!i || (N().finally(() => T(!0)), !n.refreshInterval)) return;
|
|
1781
|
-
const P = n.refreshInterval || 10 * 60 * 1e3,
|
|
1782
|
-
return () => clearInterval(
|
|
1811
|
+
const P = n.refreshInterval || 10 * 60 * 1e3, d = setInterval(N, P);
|
|
1812
|
+
return () => clearInterval(d);
|
|
1783
1813
|
}, [o == null ? void 0 : o.id, i, n.refreshInterval]);
|
|
1784
|
-
const M =
|
|
1785
|
-
const P = (a == null ? void 0 : a.features) || [],
|
|
1814
|
+
const M = K(() => {
|
|
1815
|
+
const P = (a == null ? void 0 : a.features) || [], d = (k) => {
|
|
1786
1816
|
const I = P.find((l) => l.key === k);
|
|
1787
1817
|
return I ? I.type === "BOOLEAN" || I.type === "boolean" ? I.value === !0 : !!I.value : !1;
|
|
1788
1818
|
}, v = (k) => P.find((I) => I.key === k), F = (k, I) => {
|
|
1789
|
-
const l = P.find((
|
|
1819
|
+
const l = P.find((_) => _.key === k);
|
|
1790
1820
|
return l ? l.value : I;
|
|
1791
|
-
},
|
|
1821
|
+
}, U = (k) => !a || !a.isActive ? !1 : k.includes(a.planId), w = async () => {
|
|
1792
1822
|
await N();
|
|
1793
1823
|
}, R = !!i && (m || !(o != null && o.id));
|
|
1794
1824
|
return {
|
|
@@ -1797,26 +1827,26 @@ function Pr({ config: n = {}, children: e }) {
|
|
|
1797
1827
|
loading: f,
|
|
1798
1828
|
error: c,
|
|
1799
1829
|
isReady: R,
|
|
1800
|
-
isFeatureEnabled:
|
|
1830
|
+
isFeatureEnabled: d,
|
|
1801
1831
|
getFeature: v,
|
|
1802
1832
|
getFeatureValue: F,
|
|
1803
|
-
hasAllowedPlan:
|
|
1833
|
+
hasAllowedPlan: U,
|
|
1804
1834
|
refresh: w
|
|
1805
1835
|
};
|
|
1806
1836
|
}, [a, f, c, i, o == null ? void 0 : o.id, m]);
|
|
1807
|
-
return /* @__PURE__ */ s(
|
|
1837
|
+
return /* @__PURE__ */ s($e.Provider, { value: M, children: e });
|
|
1808
1838
|
}
|
|
1809
|
-
function
|
|
1810
|
-
const n =
|
|
1839
|
+
function Lt() {
|
|
1840
|
+
const n = ae($e);
|
|
1811
1841
|
if (n === void 0)
|
|
1812
1842
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1813
1843
|
return n;
|
|
1814
1844
|
}
|
|
1815
|
-
function
|
|
1816
|
-
return
|
|
1845
|
+
function Ye() {
|
|
1846
|
+
return ae($e) ?? null;
|
|
1817
1847
|
}
|
|
1818
|
-
var
|
|
1819
|
-
const
|
|
1848
|
+
var oe = /* @__PURE__ */ ((n) => (n.SUPERUSER = "SUPERUSER", n.TENANT_ADMIN = "TENANT_ADMIN", n.USER = "USER", n))(oe || {});
|
|
1849
|
+
const He = {
|
|
1820
1850
|
publicGuest: "/",
|
|
1821
1851
|
publicUser: "/account",
|
|
1822
1852
|
publicAdmin: "/admin",
|
|
@@ -1824,7 +1854,7 @@ const Oe = {
|
|
|
1824
1854
|
tenantUser: "/dashboard",
|
|
1825
1855
|
tenantAdmin: "/admin/dashboard",
|
|
1826
1856
|
default: "/"
|
|
1827
|
-
},
|
|
1857
|
+
}, Xe = {
|
|
1828
1858
|
// Public/Landing zones
|
|
1829
1859
|
landing: { tenant: "forbidden", auth: "optional" },
|
|
1830
1860
|
publicOnly: { tenant: "forbidden", auth: "forbidden" },
|
|
@@ -1837,18 +1867,18 @@ const Oe = {
|
|
|
1837
1867
|
tenantOpen: { tenant: "required", auth: "optional" },
|
|
1838
1868
|
tenantAuth: { tenant: "required", auth: "required" },
|
|
1839
1869
|
// User type zones
|
|
1840
|
-
user: { tenant: "required", auth: "required", userType:
|
|
1841
|
-
admin: { tenant: "required", auth: "required", userType:
|
|
1870
|
+
user: { tenant: "required", auth: "required", userType: oe.USER },
|
|
1871
|
+
admin: { tenant: "required", auth: "required", userType: oe.TENANT_ADMIN },
|
|
1842
1872
|
// Fully open
|
|
1843
1873
|
open: { tenant: "optional", auth: "optional" }
|
|
1844
|
-
},
|
|
1845
|
-
function
|
|
1846
|
-
const t =
|
|
1874
|
+
}, Oe = me(null);
|
|
1875
|
+
function Pr({ config: n = {}, children: e }) {
|
|
1876
|
+
const t = K(() => {
|
|
1847
1877
|
const r = {
|
|
1848
|
-
...
|
|
1878
|
+
...He,
|
|
1849
1879
|
...n.zoneRoots
|
|
1850
1880
|
}, i = {
|
|
1851
|
-
...
|
|
1881
|
+
...Xe,
|
|
1852
1882
|
...n.presets
|
|
1853
1883
|
};
|
|
1854
1884
|
return {
|
|
@@ -1861,19 +1891,19 @@ function Rr({ config: n = {}, children: e }) {
|
|
|
1861
1891
|
returnToStorage: n.returnToStorage ?? "url"
|
|
1862
1892
|
};
|
|
1863
1893
|
}, [n]);
|
|
1864
|
-
return /* @__PURE__ */ s(
|
|
1894
|
+
return /* @__PURE__ */ s(Oe.Provider, { value: t, children: e });
|
|
1865
1895
|
}
|
|
1866
|
-
function
|
|
1867
|
-
const n =
|
|
1896
|
+
function Rr() {
|
|
1897
|
+
const n = ae(Oe);
|
|
1868
1898
|
if (!n)
|
|
1869
1899
|
throw new Error("useRouting must be used within a RoutingProvider");
|
|
1870
1900
|
return n;
|
|
1871
1901
|
}
|
|
1872
|
-
function
|
|
1873
|
-
const n =
|
|
1902
|
+
function Nt() {
|
|
1903
|
+
const n = ae(Oe);
|
|
1874
1904
|
return n || {
|
|
1875
|
-
zoneRoots:
|
|
1876
|
-
presets:
|
|
1905
|
+
zoneRoots: He,
|
|
1906
|
+
presets: Xe,
|
|
1877
1907
|
loadingFallback: null,
|
|
1878
1908
|
accessDeniedFallback: null,
|
|
1879
1909
|
onAccessDenied: void 0,
|
|
@@ -1881,7 +1911,7 @@ function Ft() {
|
|
|
1881
1911
|
returnToStorage: "url"
|
|
1882
1912
|
};
|
|
1883
1913
|
}
|
|
1884
|
-
const
|
|
1914
|
+
const je = () => /* @__PURE__ */ u(
|
|
1885
1915
|
"div",
|
|
1886
1916
|
{
|
|
1887
1917
|
style: {
|
|
@@ -1918,11 +1948,11 @@ const Ge = () => /* @__PURE__ */ h(
|
|
|
1918
1948
|
)
|
|
1919
1949
|
]
|
|
1920
1950
|
}
|
|
1921
|
-
),
|
|
1951
|
+
), Ge = ({
|
|
1922
1952
|
userType: n,
|
|
1923
1953
|
minUserType: e,
|
|
1924
1954
|
missingPermissions: t
|
|
1925
|
-
}) => /* @__PURE__ */
|
|
1955
|
+
}) => /* @__PURE__ */ u(
|
|
1926
1956
|
"div",
|
|
1927
1957
|
{
|
|
1928
1958
|
style: {
|
|
@@ -1940,55 +1970,55 @@ const Ge = () => /* @__PURE__ */ h(
|
|
|
1940
1970
|
children: [
|
|
1941
1971
|
/* @__PURE__ */ s("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
|
|
1942
1972
|
/* @__PURE__ */ s("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
|
|
1943
|
-
e && n ? /* @__PURE__ */
|
|
1944
|
-
/* @__PURE__ */
|
|
1973
|
+
e && n ? /* @__PURE__ */ u(z, { children: [
|
|
1974
|
+
/* @__PURE__ */ u("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
|
|
1945
1975
|
"This content requires ",
|
|
1946
1976
|
/* @__PURE__ */ s("strong", { children: e }),
|
|
1947
1977
|
" access level or higher."
|
|
1948
1978
|
] }),
|
|
1949
|
-
/* @__PURE__ */
|
|
1979
|
+
/* @__PURE__ */ u("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1950
1980
|
"Your current access level: ",
|
|
1951
1981
|
/* @__PURE__ */ s("strong", { children: n })
|
|
1952
1982
|
] })
|
|
1953
|
-
] }) : /* @__PURE__ */
|
|
1983
|
+
] }) : /* @__PURE__ */ u(z, { children: [
|
|
1954
1984
|
/* @__PURE__ */ s("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
|
|
1955
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1985
|
+
t && t.length > 0 && /* @__PURE__ */ u("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1956
1986
|
"Required permissions: ",
|
|
1957
1987
|
/* @__PURE__ */ s("strong", { children: t.join(", ") })
|
|
1958
1988
|
] })
|
|
1959
1989
|
] })
|
|
1960
1990
|
]
|
|
1961
1991
|
}
|
|
1962
|
-
),
|
|
1992
|
+
), Ft = (n, e) => {
|
|
1963
1993
|
const t = {
|
|
1964
|
-
[
|
|
1965
|
-
[
|
|
1966
|
-
[
|
|
1994
|
+
[oe.USER]: 1,
|
|
1995
|
+
[oe.TENANT_ADMIN]: 2,
|
|
1996
|
+
[oe.SUPERUSER]: 3
|
|
1967
1997
|
};
|
|
1968
1998
|
return t[n] >= t[e];
|
|
1969
1999
|
};
|
|
1970
|
-
function
|
|
2000
|
+
function Er({
|
|
1971
2001
|
children: n,
|
|
1972
2002
|
fallback: e,
|
|
1973
2003
|
minUserType: t,
|
|
1974
2004
|
requiredPermissions: r,
|
|
1975
2005
|
requireAllPermissions: i = !1
|
|
1976
2006
|
}) {
|
|
1977
|
-
const { hasValidSession: o, sessionManager: a, hasPermission:
|
|
2007
|
+
const { hasValidSession: o, sessionManager: a, hasPermission: h, hasAnyPermission: f, hasAllPermissions: y } = ue();
|
|
1978
2008
|
if (!o())
|
|
1979
|
-
return /* @__PURE__ */ s(
|
|
2009
|
+
return /* @__PURE__ */ s(z, { children: e || /* @__PURE__ */ s(je, {}) });
|
|
1980
2010
|
const c = a.getUser();
|
|
1981
2011
|
if (!c)
|
|
1982
|
-
return /* @__PURE__ */ s(
|
|
1983
|
-
if (t && !
|
|
1984
|
-
return /* @__PURE__ */ s(
|
|
2012
|
+
return /* @__PURE__ */ s(z, { children: e || /* @__PURE__ */ s(je, {}) });
|
|
2013
|
+
if (t && !Ft(c.userType, t))
|
|
2014
|
+
return /* @__PURE__ */ s(Ge, { userType: c.userType, minUserType: t });
|
|
1985
2015
|
if (r && r.length > 0 && !(i ? y(r) : f(r))) {
|
|
1986
|
-
const m = r.filter((T) => !
|
|
1987
|
-
return /* @__PURE__ */ s(
|
|
2016
|
+
const m = r.filter((T) => !h(T)).map((T) => typeof T == "string" ? T : T.name);
|
|
2017
|
+
return /* @__PURE__ */ s(Ge, { missingPermissions: m });
|
|
1988
2018
|
}
|
|
1989
|
-
return /* @__PURE__ */ s(
|
|
2019
|
+
return /* @__PURE__ */ s(z, { children: n });
|
|
1990
2020
|
}
|
|
1991
|
-
const
|
|
2021
|
+
const Dt = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
1992
2022
|
"div",
|
|
1993
2023
|
{
|
|
1994
2024
|
style: {
|
|
@@ -2001,7 +2031,7 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2001
2031
|
backgroundColor: "#f9fafb",
|
|
2002
2032
|
textAlign: "center"
|
|
2003
2033
|
},
|
|
2004
|
-
children: /* @__PURE__ */
|
|
2034
|
+
children: /* @__PURE__ */ u(
|
|
2005
2035
|
"div",
|
|
2006
2036
|
{
|
|
2007
2037
|
style: {
|
|
@@ -2015,7 +2045,7 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2015
2045
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
|
|
2016
2046
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
|
|
2017
2047
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
|
|
2018
|
-
/* @__PURE__ */
|
|
2048
|
+
/* @__PURE__ */ u("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
2019
2049
|
"Redirecting to ",
|
|
2020
2050
|
n,
|
|
2021
2051
|
"..."
|
|
@@ -2024,7 +2054,7 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2024
2054
|
}
|
|
2025
2055
|
)
|
|
2026
2056
|
}
|
|
2027
|
-
),
|
|
2057
|
+
), Je = ({
|
|
2028
2058
|
userType: n,
|
|
2029
2059
|
requiredUserType: e,
|
|
2030
2060
|
missingPermissions: t
|
|
@@ -2041,7 +2071,7 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2041
2071
|
backgroundColor: "#f9fafb",
|
|
2042
2072
|
textAlign: "center"
|
|
2043
2073
|
},
|
|
2044
|
-
children: /* @__PURE__ */
|
|
2074
|
+
children: /* @__PURE__ */ u(
|
|
2045
2075
|
"div",
|
|
2046
2076
|
{
|
|
2047
2077
|
style: {
|
|
@@ -2054,19 +2084,19 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2054
2084
|
children: [
|
|
2055
2085
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
|
|
2056
2086
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
|
|
2057
|
-
e && n ? /* @__PURE__ */
|
|
2058
|
-
/* @__PURE__ */
|
|
2087
|
+
e && n ? /* @__PURE__ */ u(z, { children: [
|
|
2088
|
+
/* @__PURE__ */ u("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
|
|
2059
2089
|
"This page requires ",
|
|
2060
2090
|
/* @__PURE__ */ s("strong", { children: e }),
|
|
2061
2091
|
" access."
|
|
2062
2092
|
] }),
|
|
2063
|
-
/* @__PURE__ */
|
|
2093
|
+
/* @__PURE__ */ u("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
2064
2094
|
"Your current user type: ",
|
|
2065
2095
|
/* @__PURE__ */ s("strong", { children: n })
|
|
2066
2096
|
] })
|
|
2067
|
-
] }) : /* @__PURE__ */
|
|
2097
|
+
] }) : /* @__PURE__ */ u(z, { children: [
|
|
2068
2098
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
|
|
2069
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
2099
|
+
t && t.length > 0 && /* @__PURE__ */ u("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
2070
2100
|
"Required permissions: ",
|
|
2071
2101
|
/* @__PURE__ */ s("strong", { children: t.join(", ") })
|
|
2072
2102
|
] })
|
|
@@ -2075,8 +2105,8 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2075
2105
|
}
|
|
2076
2106
|
)
|
|
2077
2107
|
}
|
|
2078
|
-
),
|
|
2079
|
-
function
|
|
2108
|
+
), Ct = (n, e) => n === e;
|
|
2109
|
+
function Ir({
|
|
2080
2110
|
children: n,
|
|
2081
2111
|
redirectTo: e = "/login",
|
|
2082
2112
|
requiredUserType: t,
|
|
@@ -2084,22 +2114,22 @@ function Mr({
|
|
|
2084
2114
|
requireAllPermissions: i = !1,
|
|
2085
2115
|
fallback: o
|
|
2086
2116
|
}) {
|
|
2087
|
-
const { hasValidSession: a, sessionManager:
|
|
2088
|
-
if (
|
|
2117
|
+
const { hasValidSession: a, sessionManager: h, hasPermission: f, hasAnyPermission: y, hasAllPermissions: c } = ue(), L = Te();
|
|
2118
|
+
if (te(() => {
|
|
2089
2119
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2090
2120
|
"[react-identity-access] ProtectedRoute is deprecated. Use AuthenticatedZone or AdminZone from ZoneRoute instead."
|
|
2091
2121
|
);
|
|
2092
2122
|
}, []), !a())
|
|
2093
|
-
return o ? /* @__PURE__ */ s(
|
|
2094
|
-
/* @__PURE__ */ s(
|
|
2095
|
-
/* @__PURE__ */ s(
|
|
2123
|
+
return o ? /* @__PURE__ */ s(z, { children: o }) : /* @__PURE__ */ u(z, { children: [
|
|
2124
|
+
/* @__PURE__ */ s(Dt, { redirectPath: e }),
|
|
2125
|
+
/* @__PURE__ */ s(be, { to: e, state: { from: L.pathname }, replace: !0 })
|
|
2096
2126
|
] });
|
|
2097
|
-
const m =
|
|
2127
|
+
const m = h.getUser();
|
|
2098
2128
|
if (!m)
|
|
2099
|
-
return /* @__PURE__ */ s(
|
|
2100
|
-
if (t && !
|
|
2129
|
+
return /* @__PURE__ */ s(be, { to: e, state: { from: L.pathname }, replace: !0 });
|
|
2130
|
+
if (t && !Ct(m.userType, t))
|
|
2101
2131
|
return /* @__PURE__ */ s(
|
|
2102
|
-
|
|
2132
|
+
Je,
|
|
2103
2133
|
{
|
|
2104
2134
|
userType: m.userType,
|
|
2105
2135
|
requiredUserType: t
|
|
@@ -2107,11 +2137,11 @@ function Mr({
|
|
|
2107
2137
|
);
|
|
2108
2138
|
if (r && r.length > 0 && !(i ? c(r) : y(r))) {
|
|
2109
2139
|
const A = r.filter((N) => !f(N)).map((N) => typeof N == "string" ? N : N.name);
|
|
2110
|
-
return /* @__PURE__ */ s(
|
|
2140
|
+
return /* @__PURE__ */ s(Je, { missingPermissions: A });
|
|
2111
2141
|
}
|
|
2112
|
-
return /* @__PURE__ */ s(
|
|
2142
|
+
return /* @__PURE__ */ s(z, { children: n });
|
|
2113
2143
|
}
|
|
2114
|
-
const
|
|
2144
|
+
const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
2115
2145
|
"div",
|
|
2116
2146
|
{
|
|
2117
2147
|
style: {
|
|
@@ -2124,7 +2154,7 @@ const $t = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2124
2154
|
backgroundColor: "#f9fafb",
|
|
2125
2155
|
textAlign: "center"
|
|
2126
2156
|
},
|
|
2127
|
-
children: /* @__PURE__ */
|
|
2157
|
+
children: /* @__PURE__ */ u(
|
|
2128
2158
|
"div",
|
|
2129
2159
|
{
|
|
2130
2160
|
style: {
|
|
@@ -2138,7 +2168,7 @@ const $t = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2138
2168
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
|
|
2139
2169
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
|
|
2140
2170
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
|
|
2141
|
-
/* @__PURE__ */
|
|
2171
|
+
/* @__PURE__ */ u("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
2142
2172
|
"Redirecting to ",
|
|
2143
2173
|
n,
|
|
2144
2174
|
"..."
|
|
@@ -2148,18 +2178,18 @@ const $t = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2148
2178
|
)
|
|
2149
2179
|
}
|
|
2150
2180
|
);
|
|
2151
|
-
function
|
|
2152
|
-
const { tenant: r, isLoading: i, error: o } =
|
|
2153
|
-
return
|
|
2181
|
+
function Mr({ children: n, redirectTo: e = "/", fallback: t }) {
|
|
2182
|
+
const { tenant: r, isLoading: i, error: o } = Ke(), a = Te();
|
|
2183
|
+
return te(() => {
|
|
2154
2184
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2155
2185
|
"[react-identity-access] TenantRoute is deprecated. Use TenantZone from ZoneRoute instead."
|
|
2156
2186
|
);
|
|
2157
|
-
}, []), i || o ? null : r ? /* @__PURE__ */ s(
|
|
2158
|
-
/* @__PURE__ */ s(
|
|
2159
|
-
/* @__PURE__ */ s(
|
|
2187
|
+
}, []), i || o ? null : r ? /* @__PURE__ */ s(z, { children: n }) : t ? /* @__PURE__ */ s(z, { children: t }) : /* @__PURE__ */ u(z, { children: [
|
|
2188
|
+
/* @__PURE__ */ s(Ut, { redirectPath: e }),
|
|
2189
|
+
/* @__PURE__ */ s(be, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
2160
2190
|
] });
|
|
2161
2191
|
}
|
|
2162
|
-
const
|
|
2192
|
+
const Bt = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
2163
2193
|
"div",
|
|
2164
2194
|
{
|
|
2165
2195
|
style: {
|
|
@@ -2172,7 +2202,7 @@ const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2172
2202
|
backgroundColor: "#f9fafb",
|
|
2173
2203
|
textAlign: "center"
|
|
2174
2204
|
},
|
|
2175
|
-
children: /* @__PURE__ */
|
|
2205
|
+
children: /* @__PURE__ */ u(
|
|
2176
2206
|
"div",
|
|
2177
2207
|
{
|
|
2178
2208
|
style: {
|
|
@@ -2186,7 +2216,7 @@ const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2186
2216
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
|
|
2187
2217
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
|
|
2188
2218
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
|
|
2189
|
-
/* @__PURE__ */
|
|
2219
|
+
/* @__PURE__ */ u("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
2190
2220
|
"Redirecting to ",
|
|
2191
2221
|
n,
|
|
2192
2222
|
"..."
|
|
@@ -2196,30 +2226,30 @@ const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2196
2226
|
)
|
|
2197
2227
|
}
|
|
2198
2228
|
);
|
|
2199
|
-
function
|
|
2200
|
-
const { tenant: r, isLoading: i, error: o } =
|
|
2201
|
-
return
|
|
2229
|
+
function Lr({ children: n, redirectTo: e = "/dashboard", fallback: t }) {
|
|
2230
|
+
const { tenant: r, isLoading: i, error: o } = Ke(), a = Te();
|
|
2231
|
+
return te(() => {
|
|
2202
2232
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2203
2233
|
"[react-identity-access] LandingRoute is deprecated. Use PublicZone from ZoneRoute instead."
|
|
2204
2234
|
);
|
|
2205
|
-
}, []), i || o ? null : r ? t ? /* @__PURE__ */ s(
|
|
2206
|
-
/* @__PURE__ */ s(
|
|
2207
|
-
/* @__PURE__ */ s(
|
|
2208
|
-
] }) : /* @__PURE__ */ s(
|
|
2235
|
+
}, []), i || o ? null : r ? t ? /* @__PURE__ */ s(z, { children: t }) : /* @__PURE__ */ u(z, { children: [
|
|
2236
|
+
/* @__PURE__ */ s(Bt, { redirectPath: e }),
|
|
2237
|
+
/* @__PURE__ */ s(be, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
2238
|
+
] }) : /* @__PURE__ */ s(z, { children: n });
|
|
2209
2239
|
}
|
|
2210
|
-
function
|
|
2240
|
+
function $t(n, e) {
|
|
2211
2241
|
return e ? n ? Array.isArray(e) ? e.includes(n) : n === e : !1 : !0;
|
|
2212
2242
|
}
|
|
2213
|
-
function
|
|
2243
|
+
function Qe(n, e) {
|
|
2214
2244
|
return !n || n === "optional" ? "skip" : n === "required" ? e ? "pass" : "fail" : n === "forbidden" ? e ? "fail" : "pass" : "skip";
|
|
2215
2245
|
}
|
|
2216
|
-
function
|
|
2217
|
-
return
|
|
2246
|
+
function Ht(n, e) {
|
|
2247
|
+
return Qe(n.tenant, e.hasTenant) === "fail" ? e.hasTenant ? "has_tenant" : "no_tenant" : Qe(n.auth, e.isAuthenticated) === "fail" ? e.isAuthenticated ? "already_authenticated" : "not_authenticated" : n.userType && e.isAuthenticated && !$t(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;
|
|
2218
2248
|
}
|
|
2219
|
-
function
|
|
2220
|
-
return n.hasTenant ? n.isAuthenticated ? n.userType ===
|
|
2249
|
+
function Ot(n, e) {
|
|
2250
|
+
return n.hasTenant ? n.isAuthenticated ? n.userType === oe.TENANT_ADMIN ? e.tenantAdmin : e.tenantUser : e.tenantGuest : n.isAuthenticated ? n.userType === oe.TENANT_ADMIN ? e.publicAdmin : e.publicUser : e.publicGuest;
|
|
2221
2251
|
}
|
|
2222
|
-
function
|
|
2252
|
+
function qt(n, e, t, r, i) {
|
|
2223
2253
|
if (!e || i !== "url")
|
|
2224
2254
|
return n;
|
|
2225
2255
|
const o = typeof e == "string" ? e : t, a = n.includes("?") ? "&" : "?";
|
|
@@ -2230,7 +2260,7 @@ function zt(n, e, t) {
|
|
|
2230
2260
|
const r = typeof n == "string" ? n : e, i = "zone_return_to";
|
|
2231
2261
|
t === "session" ? sessionStorage.setItem(i, r) : t === "local" && localStorage.setItem(i, r);
|
|
2232
2262
|
}
|
|
2233
|
-
const
|
|
2263
|
+
const de = ({
|
|
2234
2264
|
children: n,
|
|
2235
2265
|
preset: e,
|
|
2236
2266
|
tenant: t,
|
|
@@ -2238,16 +2268,16 @@ const ue = ({
|
|
|
2238
2268
|
userType: i,
|
|
2239
2269
|
requiredPermissions: o,
|
|
2240
2270
|
requireAllPermissions: a = !0,
|
|
2241
|
-
returnTo:
|
|
2271
|
+
returnTo: h,
|
|
2242
2272
|
onAccessDenied: f,
|
|
2243
2273
|
redirectTo: y,
|
|
2244
2274
|
loadingFallback: c,
|
|
2245
2275
|
accessDeniedFallback: L
|
|
2246
2276
|
}) => {
|
|
2247
|
-
const m =
|
|
2277
|
+
const m = Te(), { isAuthenticated: T, isAuthInitializing: A, currentUser: N, userPermissions: M } = ue(), { tenant: P, isTenantLoading: d } = ve(), v = Nt(), F = K(() => {
|
|
2248
2278
|
if (e)
|
|
2249
2279
|
return v.presets[e];
|
|
2250
|
-
}, [e, v.presets]),
|
|
2280
|
+
}, [e, v.presets]), U = K(
|
|
2251
2281
|
() => ({
|
|
2252
2282
|
tenant: t ?? (F == null ? void 0 : F.tenant),
|
|
2253
2283
|
auth: r ?? (F == null ? void 0 : F.auth),
|
|
@@ -2256,13 +2286,13 @@ const ue = ({
|
|
|
2256
2286
|
requireAllPermissions: a
|
|
2257
2287
|
}),
|
|
2258
2288
|
[t, r, i, o, F, a]
|
|
2259
|
-
), w =
|
|
2289
|
+
), w = K(
|
|
2260
2290
|
() => ({
|
|
2261
2291
|
hasTenant: !!P,
|
|
2262
2292
|
isAuthenticated: T,
|
|
2263
2293
|
userType: N == null ? void 0 : N.userType,
|
|
2264
2294
|
permissions: M,
|
|
2265
|
-
isLoading: A ||
|
|
2295
|
+
isLoading: A || d
|
|
2266
2296
|
}),
|
|
2267
2297
|
[
|
|
2268
2298
|
P,
|
|
@@ -2270,15 +2300,15 @@ const ue = ({
|
|
|
2270
2300
|
N == null ? void 0 : N.userType,
|
|
2271
2301
|
M,
|
|
2272
2302
|
A,
|
|
2273
|
-
|
|
2303
|
+
d
|
|
2274
2304
|
]
|
|
2275
|
-
), R =
|
|
2305
|
+
), R = K(() => w.isLoading ? null : Ht(U, w), [U, w]), k = K(() => R ? y || Ot(w, v.zoneRoots) : null, [R, y, w, v.zoneRoots]), I = K(() => !R || !k ? null : {
|
|
2276
2306
|
type: R,
|
|
2277
2307
|
required: {
|
|
2278
|
-
tenant:
|
|
2279
|
-
auth:
|
|
2280
|
-
userType:
|
|
2281
|
-
permissions:
|
|
2308
|
+
tenant: U.tenant,
|
|
2309
|
+
auth: U.auth,
|
|
2310
|
+
userType: U.userType,
|
|
2311
|
+
permissions: U.permissions
|
|
2282
2312
|
},
|
|
2283
2313
|
current: {
|
|
2284
2314
|
hasTenant: w.hasTenant,
|
|
@@ -2287,34 +2317,34 @@ const ue = ({
|
|
|
2287
2317
|
permissions: w.permissions
|
|
2288
2318
|
},
|
|
2289
2319
|
redirectTo: k
|
|
2290
|
-
}, [R, k,
|
|
2291
|
-
if (
|
|
2320
|
+
}, [R, k, U, w]);
|
|
2321
|
+
if (te(() => {
|
|
2292
2322
|
I && (f ? f(I) : v.onAccessDenied && v.onAccessDenied(I));
|
|
2293
|
-
}, [I, f, v]),
|
|
2294
|
-
I &&
|
|
2323
|
+
}, [I, f, v]), te(() => {
|
|
2324
|
+
I && h && zt(h, m.pathname + m.search, v.returnToStorage);
|
|
2295
2325
|
}, [
|
|
2296
2326
|
I,
|
|
2297
|
-
|
|
2327
|
+
h,
|
|
2298
2328
|
m.pathname,
|
|
2299
2329
|
m.search,
|
|
2300
2330
|
v.returnToStorage
|
|
2301
2331
|
]), w.isLoading)
|
|
2302
|
-
return /* @__PURE__ */ s(
|
|
2332
|
+
return /* @__PURE__ */ s(z, { children: c ?? v.loadingFallback ?? null });
|
|
2303
2333
|
if (I && k) {
|
|
2304
2334
|
const l = L ?? v.accessDeniedFallback;
|
|
2305
2335
|
if (l)
|
|
2306
|
-
return /* @__PURE__ */ s(
|
|
2307
|
-
const
|
|
2336
|
+
return /* @__PURE__ */ s(z, { children: l });
|
|
2337
|
+
const _ = qt(
|
|
2308
2338
|
k,
|
|
2309
|
-
|
|
2339
|
+
h,
|
|
2310
2340
|
m.pathname + m.search,
|
|
2311
2341
|
v.returnToParam,
|
|
2312
2342
|
v.returnToStorage
|
|
2313
2343
|
);
|
|
2314
|
-
return /* @__PURE__ */ s(
|
|
2344
|
+
return /* @__PURE__ */ s(be, { to: _, replace: !0 });
|
|
2315
2345
|
}
|
|
2316
|
-
return /* @__PURE__ */ s(
|
|
2317
|
-
},
|
|
2346
|
+
return /* @__PURE__ */ s(z, { children: n });
|
|
2347
|
+
}, Nr = (n) => /* @__PURE__ */ s(de, { tenant: "required", ...n }), Fr = (n) => /* @__PURE__ */ s(de, { tenant: "forbidden", ...n }), Dr = (n) => /* @__PURE__ */ s(de, { auth: "required", ...n }), Cr = (n) => /* @__PURE__ */ s(de, { auth: "forbidden", ...n }), Ur = (n) => /* @__PURE__ */ s(de, { auth: "required", userType: oe.TENANT_ADMIN, ...n }), Br = (n) => /* @__PURE__ */ s(de, { auth: "required", userType: oe.USER, ...n }), $r = (n) => /* @__PURE__ */ s(de, { tenant: "optional", auth: "optional", ...n }), Hr = (n) => /* @__PURE__ */ s(de, { tenant: "required", auth: "required", ...n }), Or = (n) => /* @__PURE__ */ s(de, { tenant: "required", auth: "optional", ...n }), qr = (n) => /* @__PURE__ */ s(de, { tenant: "required", auth: "forbidden", ...n }), _t = () => /* @__PURE__ */ u(
|
|
2318
2348
|
"div",
|
|
2319
2349
|
{
|
|
2320
2350
|
style: {
|
|
@@ -2333,12 +2363,12 @@ const ue = ({
|
|
|
2333
2363
|
);
|
|
2334
2364
|
function zr({
|
|
2335
2365
|
children: n,
|
|
2336
|
-
fallback: e = /* @__PURE__ */ s(
|
|
2366
|
+
fallback: e = /* @__PURE__ */ s(_t, {}),
|
|
2337
2367
|
allowedPlans: t,
|
|
2338
2368
|
requiredFeature: r
|
|
2339
2369
|
}) {
|
|
2340
|
-
const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading:
|
|
2341
|
-
return
|
|
2370
|
+
const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: h } = Lt();
|
|
2371
|
+
return h ? /* @__PURE__ */ s(
|
|
2342
2372
|
"div",
|
|
2343
2373
|
{
|
|
2344
2374
|
style: {
|
|
@@ -2348,9 +2378,9 @@ function zr({
|
|
|
2348
2378
|
},
|
|
2349
2379
|
children: "Loading subscription..."
|
|
2350
2380
|
}
|
|
2351
|
-
) : i ? i.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ s(
|
|
2381
|
+
) : i ? i.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ s(z, { children: e }) : r && !a(r) ? /* @__PURE__ */ s(z, { children: e }) : /* @__PURE__ */ s(z, { children: n }) : /* @__PURE__ */ s(z, { children: e }) : /* @__PURE__ */ s(z, { children: e });
|
|
2352
2382
|
}
|
|
2353
|
-
const
|
|
2383
|
+
const Vt = ({ flagName: n }) => /* @__PURE__ */ u(
|
|
2354
2384
|
"div",
|
|
2355
2385
|
{
|
|
2356
2386
|
style: {
|
|
@@ -2369,7 +2399,7 @@ const Wt = ({ flagName: n }) => /* @__PURE__ */ h(
|
|
|
2369
2399
|
children: [
|
|
2370
2400
|
/* @__PURE__ */ s("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
|
|
2371
2401
|
/* @__PURE__ */ s("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
|
|
2372
|
-
/* @__PURE__ */
|
|
2402
|
+
/* @__PURE__ */ u("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
|
|
2373
2403
|
'Feature flag "',
|
|
2374
2404
|
n,
|
|
2375
2405
|
'" is disabled'
|
|
@@ -2377,8 +2407,8 @@ const Wt = ({ flagName: n }) => /* @__PURE__ */ h(
|
|
|
2377
2407
|
]
|
|
2378
2408
|
}
|
|
2379
2409
|
);
|
|
2380
|
-
function
|
|
2381
|
-
const { isEnabled: r, loading: i } =
|
|
2410
|
+
function _r({ name: n, children: e, fallback: t }) {
|
|
2411
|
+
const { isEnabled: r, loading: i } = It();
|
|
2382
2412
|
return i ? /* @__PURE__ */ s(
|
|
2383
2413
|
"div",
|
|
2384
2414
|
{
|
|
@@ -2392,9 +2422,9 @@ function Vr({ name: n, children: e, fallback: t }) {
|
|
|
2392
2422
|
},
|
|
2393
2423
|
children: "Loading feature flags..."
|
|
2394
2424
|
}
|
|
2395
|
-
) : r(n) ? /* @__PURE__ */ s(
|
|
2425
|
+
) : r(n) ? /* @__PURE__ */ s(z, { children: e }) : /* @__PURE__ */ s(z, { children: t || /* @__PURE__ */ s(Vt, { flagName: n }) });
|
|
2396
2426
|
}
|
|
2397
|
-
const
|
|
2427
|
+
const Wt = () => /* @__PURE__ */ u(
|
|
2398
2428
|
"svg",
|
|
2399
2429
|
{
|
|
2400
2430
|
width: "16",
|
|
@@ -2411,7 +2441,7 @@ const jt = () => /* @__PURE__ */ h(
|
|
|
2411
2441
|
/* @__PURE__ */ s("circle", { cx: "12", cy: "12", r: "3" })
|
|
2412
2442
|
]
|
|
2413
2443
|
}
|
|
2414
|
-
),
|
|
2444
|
+
), jt = () => /* @__PURE__ */ u(
|
|
2415
2445
|
"svg",
|
|
2416
2446
|
{
|
|
2417
2447
|
width: "16",
|
|
@@ -2428,10 +2458,10 @@ const jt = () => /* @__PURE__ */ h(
|
|
|
2428
2458
|
/* @__PURE__ */ s("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
2429
2459
|
]
|
|
2430
2460
|
}
|
|
2431
|
-
),
|
|
2432
|
-
showPassword: /* @__PURE__ */ s(
|
|
2433
|
-
hidePassword: /* @__PURE__ */ s(
|
|
2434
|
-
},
|
|
2461
|
+
), Gt = {
|
|
2462
|
+
showPassword: /* @__PURE__ */ s(Wt, {}),
|
|
2463
|
+
hidePassword: /* @__PURE__ */ s(jt, {})
|
|
2464
|
+
}, Jt = {
|
|
2435
2465
|
title: "Sign In",
|
|
2436
2466
|
usernameLabel: "Email or Phone",
|
|
2437
2467
|
usernamePlaceholder: "Enter your email or phone number",
|
|
@@ -2449,7 +2479,7 @@ const jt = () => /* @__PURE__ */ h(
|
|
|
2449
2479
|
dividerBullet: "•",
|
|
2450
2480
|
showPasswordAriaLabel: "Show password",
|
|
2451
2481
|
hidePasswordAriaLabel: "Hide password"
|
|
2452
|
-
},
|
|
2482
|
+
}, Qt = {
|
|
2453
2483
|
container: {
|
|
2454
2484
|
maxWidth: "400px",
|
|
2455
2485
|
width: "100%",
|
|
@@ -2559,7 +2589,7 @@ const jt = () => /* @__PURE__ */ h(
|
|
|
2559
2589
|
paddingRight: "2.5rem"
|
|
2560
2590
|
}
|
|
2561
2591
|
};
|
|
2562
|
-
function
|
|
2592
|
+
function Vr({
|
|
2563
2593
|
copy: n = {},
|
|
2564
2594
|
styles: e = {},
|
|
2565
2595
|
icons: t = {},
|
|
@@ -2567,18 +2597,18 @@ function Wr({
|
|
|
2567
2597
|
onError: i,
|
|
2568
2598
|
onForgotPassword: o,
|
|
2569
2599
|
onSignupClick: a,
|
|
2570
|
-
onMagicLinkClick:
|
|
2600
|
+
onMagicLinkClick: h,
|
|
2571
2601
|
showForgotPassword: f = !0,
|
|
2572
2602
|
showSignupLink: y = !0,
|
|
2573
2603
|
showMagicLinkOption: c = !0,
|
|
2574
2604
|
className: L
|
|
2575
2605
|
}) {
|
|
2576
|
-
const [m, T] = x(""), [A, N] = x(""), [M, P] = x(!1), [
|
|
2606
|
+
const [m, T] = x(""), [A, N] = x(""), [M, P] = x(!1), [d, v] = x(!1), [F, U] = x(""), [w, R] = x({}), { login: k } = ue(), I = { ...Jt, ...n }, l = { ...Qt, ...e }, _ = { ...Gt, ...t }, D = () => {
|
|
2577
2607
|
const p = {};
|
|
2578
2608
|
return m.trim() || (p.username = !0), A.trim() || (p.password = !0), R(p), Object.keys(p).length === 0;
|
|
2579
2609
|
}, g = async (p) => {
|
|
2580
2610
|
if (p.preventDefault(), !!D()) {
|
|
2581
|
-
v(!0),
|
|
2611
|
+
v(!0), U("");
|
|
2582
2612
|
try {
|
|
2583
2613
|
const S = await k({
|
|
2584
2614
|
username: m,
|
|
@@ -2588,23 +2618,23 @@ function Wr({
|
|
|
2588
2618
|
r == null || r(S);
|
|
2589
2619
|
} catch (S) {
|
|
2590
2620
|
const E = S.message || I.errorMessage;
|
|
2591
|
-
|
|
2621
|
+
U(E), i == null || i(E);
|
|
2592
2622
|
} finally {
|
|
2593
2623
|
v(!1);
|
|
2594
2624
|
}
|
|
2595
2625
|
}
|
|
2596
|
-
},
|
|
2626
|
+
}, C = (p) => ({
|
|
2597
2627
|
...l.input,
|
|
2598
2628
|
...w[p] ? l.inputError : {}
|
|
2599
2629
|
}), b = () => ({
|
|
2600
2630
|
...l.button,
|
|
2601
|
-
...
|
|
2602
|
-
...!m || !A ||
|
|
2631
|
+
...d ? l.buttonLoading : {},
|
|
2632
|
+
...!m || !A || d ? l.buttonDisabled : {}
|
|
2603
2633
|
});
|
|
2604
|
-
return /* @__PURE__ */
|
|
2634
|
+
return /* @__PURE__ */ u("div", { className: L, style: l.container, children: [
|
|
2605
2635
|
/* @__PURE__ */ s("h2", { style: l.title, children: I.title }),
|
|
2606
|
-
/* @__PURE__ */
|
|
2607
|
-
/* @__PURE__ */
|
|
2636
|
+
/* @__PURE__ */ u("form", { onSubmit: g, style: l.form, children: [
|
|
2637
|
+
/* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
|
|
2608
2638
|
/* @__PURE__ */ s("label", { style: l.label, children: I.usernameLabel }),
|
|
2609
2639
|
/* @__PURE__ */ s(
|
|
2610
2640
|
"input",
|
|
@@ -2617,14 +2647,14 @@ function Wr({
|
|
|
2617
2647
|
T(p.target.value), w.username && R((S) => ({ ...S, username: !1 }));
|
|
2618
2648
|
},
|
|
2619
2649
|
placeholder: I.usernamePlaceholder,
|
|
2620
|
-
style:
|
|
2621
|
-
disabled:
|
|
2650
|
+
style: C("username"),
|
|
2651
|
+
disabled: d
|
|
2622
2652
|
}
|
|
2623
2653
|
)
|
|
2624
2654
|
] }),
|
|
2625
|
-
/* @__PURE__ */
|
|
2655
|
+
/* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
|
|
2626
2656
|
/* @__PURE__ */ s("label", { style: l.label, children: I.passwordLabel }),
|
|
2627
|
-
/* @__PURE__ */
|
|
2657
|
+
/* @__PURE__ */ u("div", { style: l.inputContainer, children: [
|
|
2628
2658
|
/* @__PURE__ */ s(
|
|
2629
2659
|
"input",
|
|
2630
2660
|
{
|
|
@@ -2637,10 +2667,10 @@ function Wr({
|
|
|
2637
2667
|
},
|
|
2638
2668
|
placeholder: I.passwordPlaceholder,
|
|
2639
2669
|
style: {
|
|
2640
|
-
...
|
|
2670
|
+
...C("password"),
|
|
2641
2671
|
...l.inputWithIcon
|
|
2642
2672
|
},
|
|
2643
|
-
disabled:
|
|
2673
|
+
disabled: d
|
|
2644
2674
|
}
|
|
2645
2675
|
),
|
|
2646
2676
|
/* @__PURE__ */ s(
|
|
@@ -2649,29 +2679,29 @@ function Wr({
|
|
|
2649
2679
|
type: "button",
|
|
2650
2680
|
onClick: () => P(!M),
|
|
2651
2681
|
style: l.passwordToggle,
|
|
2652
|
-
disabled:
|
|
2682
|
+
disabled: d,
|
|
2653
2683
|
"aria-label": M ? I.hidePasswordAriaLabel : I.showPasswordAriaLabel,
|
|
2654
|
-
children: M ?
|
|
2684
|
+
children: M ? _.hidePassword : _.showPassword
|
|
2655
2685
|
}
|
|
2656
2686
|
)
|
|
2657
2687
|
] })
|
|
2658
2688
|
] }),
|
|
2659
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: !m || !A ||
|
|
2689
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !m || !A || d, style: b(), children: d ? I.loadingText : I.submitButton }),
|
|
2660
2690
|
F && /* @__PURE__ */ s("div", { style: l.errorText, children: F })
|
|
2661
2691
|
] }),
|
|
2662
|
-
(f || y || c) && /* @__PURE__ */
|
|
2663
|
-
c && /* @__PURE__ */
|
|
2664
|
-
/* @__PURE__ */
|
|
2692
|
+
(f || y || c) && /* @__PURE__ */ u("div", { style: l.linkContainer, children: [
|
|
2693
|
+
c && /* @__PURE__ */ u("div", { children: [
|
|
2694
|
+
/* @__PURE__ */ u("span", { style: l.divider, children: [
|
|
2665
2695
|
I.magicLinkText,
|
|
2666
2696
|
" "
|
|
2667
2697
|
] }),
|
|
2668
|
-
/* @__PURE__ */ s("a", { onClick:
|
|
2698
|
+
/* @__PURE__ */ s("a", { onClick: h, style: l.link, children: I.magicLinkLink })
|
|
2669
2699
|
] }),
|
|
2670
2700
|
c && (f || y) && /* @__PURE__ */ s("div", { style: l.divider, children: I.dividerBullet }),
|
|
2671
2701
|
f && /* @__PURE__ */ s("a", { onClick: o, style: l.link, children: I.forgotPasswordLink }),
|
|
2672
2702
|
f && y && /* @__PURE__ */ s("div", { style: l.divider, children: I.dividerBullet }),
|
|
2673
|
-
y && /* @__PURE__ */
|
|
2674
|
-
/* @__PURE__ */
|
|
2703
|
+
y && /* @__PURE__ */ u("div", { children: [
|
|
2704
|
+
/* @__PURE__ */ u("span", { style: l.divider, children: [
|
|
2675
2705
|
I.signupText,
|
|
2676
2706
|
" "
|
|
2677
2707
|
] }),
|
|
@@ -2680,7 +2710,7 @@ function Wr({
|
|
|
2680
2710
|
] })
|
|
2681
2711
|
] });
|
|
2682
2712
|
}
|
|
2683
|
-
const
|
|
2713
|
+
const Kt = {
|
|
2684
2714
|
title: "Create Account",
|
|
2685
2715
|
nameLabel: "First Name",
|
|
2686
2716
|
namePlaceholder: "Enter your first name",
|
|
@@ -2709,7 +2739,7 @@ const Zt = {
|
|
|
2709
2739
|
contactMethodHint: "At least one contact method (email or phone) is required",
|
|
2710
2740
|
tenantNotFoundError: "Tenant not found",
|
|
2711
2741
|
dividerBullet: "•"
|
|
2712
|
-
},
|
|
2742
|
+
}, Zt = {
|
|
2713
2743
|
container: {
|
|
2714
2744
|
maxWidth: "400px",
|
|
2715
2745
|
width: "100%",
|
|
@@ -2814,7 +2844,7 @@ const Zt = {
|
|
|
2814
2844
|
margin: "0.5rem 0"
|
|
2815
2845
|
}
|
|
2816
2846
|
};
|
|
2817
|
-
function
|
|
2847
|
+
function Wr({
|
|
2818
2848
|
copy: n = {},
|
|
2819
2849
|
styles: e = {},
|
|
2820
2850
|
signupType: t = "user",
|
|
@@ -2822,61 +2852,61 @@ function jr({
|
|
|
2822
2852
|
onError: i,
|
|
2823
2853
|
onLoginClick: o,
|
|
2824
2854
|
onMagicLinkClick: a,
|
|
2825
|
-
showLoginLink:
|
|
2855
|
+
showLoginLink: h = !0,
|
|
2826
2856
|
showMagicLinkOption: f = !0,
|
|
2827
2857
|
className: y
|
|
2828
2858
|
}) {
|
|
2829
2859
|
var V;
|
|
2830
|
-
const [c, L] = x(""), [m, T] = x(""), [A, N] = x(""), [M, P] = x(""), [
|
|
2860
|
+
const [c, L] = x(""), [m, T] = x(""), [A, N] = x(""), [M, P] = x(""), [d, v] = x(""), [F, U] = x(""), [w, R] = x(""), [k, I] = x(!1), [l, _] = x(""), [D, g] = x({}), { signup: C, signupTenantAdmin: b } = ue(), p = ((V = he()) == null ? void 0 : V.tenant) ?? null, S = { ...Kt, ...n }, E = { ...Zt, ...e }, Q = () => {
|
|
2831
2861
|
const H = {};
|
|
2832
|
-
return c.trim() || (H.name = !0), !A.trim() && !M.trim() && (H.email = !0, H.phoneNumber = !0),
|
|
2833
|
-
},
|
|
2834
|
-
if (H.preventDefault(), !!
|
|
2835
|
-
if (
|
|
2836
|
-
|
|
2862
|
+
return c.trim() || (H.name = !0), !A.trim() && !M.trim() && (H.email = !0, H.phoneNumber = !0), d.trim() || (H.password = !0), F.trim() || (H.confirmPassword = !0), t === "tenant" && !w.trim() && (H.tenantName = !0), g(H), Object.keys(H).length === 0;
|
|
2863
|
+
}, J = async (H) => {
|
|
2864
|
+
if (H.preventDefault(), !!Q()) {
|
|
2865
|
+
if (d !== F) {
|
|
2866
|
+
_(S.passwordMismatchError), g({ confirmPassword: !0 });
|
|
2837
2867
|
return;
|
|
2838
2868
|
}
|
|
2839
2869
|
if (t === "user" && !(p != null && p.id)) {
|
|
2840
|
-
|
|
2870
|
+
_(S.tenantNotFoundError);
|
|
2841
2871
|
return;
|
|
2842
2872
|
}
|
|
2843
|
-
I(!0),
|
|
2873
|
+
I(!0), _("");
|
|
2844
2874
|
try {
|
|
2845
|
-
let
|
|
2846
|
-
t === "tenant" ?
|
|
2875
|
+
let B;
|
|
2876
|
+
t === "tenant" ? B = await b({
|
|
2847
2877
|
email: A || void 0,
|
|
2848
2878
|
phoneNumber: M || void 0,
|
|
2849
2879
|
name: c,
|
|
2850
|
-
password:
|
|
2880
|
+
password: d,
|
|
2851
2881
|
tenantName: w,
|
|
2852
2882
|
lastName: m || void 0
|
|
2853
|
-
}) :
|
|
2883
|
+
}) : B = await C({
|
|
2854
2884
|
email: A || void 0,
|
|
2855
2885
|
phoneNumber: M || void 0,
|
|
2856
2886
|
name: c,
|
|
2857
|
-
password:
|
|
2887
|
+
password: d,
|
|
2858
2888
|
tenantId: p.id,
|
|
2859
2889
|
lastName: m || void 0
|
|
2860
|
-
}), r == null || r(
|
|
2861
|
-
} catch (
|
|
2862
|
-
const
|
|
2863
|
-
|
|
2890
|
+
}), r == null || r(B);
|
|
2891
|
+
} catch (B) {
|
|
2892
|
+
const le = B.message || S.errorMessage;
|
|
2893
|
+
_(le), i == null || i(le);
|
|
2864
2894
|
} finally {
|
|
2865
2895
|
I(!1);
|
|
2866
2896
|
}
|
|
2867
2897
|
}
|
|
2868
|
-
},
|
|
2898
|
+
}, ee = (H) => ({
|
|
2869
2899
|
...E.input,
|
|
2870
2900
|
...D[H] ? E.inputError : {}
|
|
2871
2901
|
}), W = () => ({
|
|
2872
2902
|
...E.button,
|
|
2873
2903
|
...k ? E.buttonLoading : {},
|
|
2874
|
-
...!c || !A && !M || !
|
|
2875
|
-
}), q = c && (A || M) &&
|
|
2876
|
-
return /* @__PURE__ */
|
|
2904
|
+
...!c || !A && !M || !d || !F || k || t === "tenant" && !w ? E.buttonDisabled : {}
|
|
2905
|
+
}), q = c && (A || M) && d && F && (t === "user" || w);
|
|
2906
|
+
return /* @__PURE__ */ u("div", { className: y, style: E.container, children: [
|
|
2877
2907
|
/* @__PURE__ */ s("h2", { style: E.title, children: S.title }),
|
|
2878
|
-
/* @__PURE__ */
|
|
2879
|
-
/* @__PURE__ */
|
|
2908
|
+
/* @__PURE__ */ u("form", { onSubmit: J, style: E.form, children: [
|
|
2909
|
+
/* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
|
|
2880
2910
|
/* @__PURE__ */ s("label", { style: E.label, children: S.nameLabel }),
|
|
2881
2911
|
/* @__PURE__ */ s(
|
|
2882
2912
|
"input",
|
|
@@ -2886,15 +2916,15 @@ function jr({
|
|
|
2886
2916
|
type: "text",
|
|
2887
2917
|
value: c,
|
|
2888
2918
|
onChange: (H) => {
|
|
2889
|
-
L(H.target.value), D.name && g((
|
|
2919
|
+
L(H.target.value), D.name && g((B) => ({ ...B, name: !1 }));
|
|
2890
2920
|
},
|
|
2891
2921
|
placeholder: S.namePlaceholder,
|
|
2892
|
-
style:
|
|
2922
|
+
style: ee("name"),
|
|
2893
2923
|
disabled: k
|
|
2894
2924
|
}
|
|
2895
2925
|
)
|
|
2896
2926
|
] }),
|
|
2897
|
-
/* @__PURE__ */
|
|
2927
|
+
/* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
|
|
2898
2928
|
/* @__PURE__ */ s("label", { style: E.label, children: S.lastNameLabel }),
|
|
2899
2929
|
/* @__PURE__ */ s(
|
|
2900
2930
|
"input",
|
|
@@ -2910,7 +2940,7 @@ function jr({
|
|
|
2910
2940
|
}
|
|
2911
2941
|
)
|
|
2912
2942
|
] }),
|
|
2913
|
-
/* @__PURE__ */
|
|
2943
|
+
/* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
|
|
2914
2944
|
/* @__PURE__ */ s("label", { style: E.label, children: S.emailLabel }),
|
|
2915
2945
|
/* @__PURE__ */ s(
|
|
2916
2946
|
"input",
|
|
@@ -2920,15 +2950,15 @@ function jr({
|
|
|
2920
2950
|
type: "email",
|
|
2921
2951
|
value: A,
|
|
2922
2952
|
onChange: (H) => {
|
|
2923
|
-
N(H.target.value), D.email && g((
|
|
2953
|
+
N(H.target.value), D.email && g((B) => ({ ...B, email: !1, phoneNumber: !1 }));
|
|
2924
2954
|
},
|
|
2925
2955
|
placeholder: S.emailPlaceholder,
|
|
2926
|
-
style:
|
|
2956
|
+
style: ee("email"),
|
|
2927
2957
|
disabled: k
|
|
2928
2958
|
}
|
|
2929
2959
|
)
|
|
2930
2960
|
] }),
|
|
2931
|
-
/* @__PURE__ */
|
|
2961
|
+
/* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
|
|
2932
2962
|
/* @__PURE__ */ s("label", { style: E.label, children: S.phoneNumberLabel }),
|
|
2933
2963
|
/* @__PURE__ */ s(
|
|
2934
2964
|
"input",
|
|
@@ -2938,16 +2968,16 @@ function jr({
|
|
|
2938
2968
|
type: "tel",
|
|
2939
2969
|
value: M,
|
|
2940
2970
|
onChange: (H) => {
|
|
2941
|
-
P(H.target.value), D.phoneNumber && g((
|
|
2971
|
+
P(H.target.value), D.phoneNumber && g((B) => ({ ...B, email: !1, phoneNumber: !1 }));
|
|
2942
2972
|
},
|
|
2943
2973
|
placeholder: S.phoneNumberPlaceholder,
|
|
2944
|
-
style:
|
|
2974
|
+
style: ee("phoneNumber"),
|
|
2945
2975
|
disabled: k
|
|
2946
2976
|
}
|
|
2947
2977
|
)
|
|
2948
2978
|
] }),
|
|
2949
2979
|
/* @__PURE__ */ s("div", { style: E.hintText, children: S.contactMethodHint }),
|
|
2950
|
-
/* @__PURE__ */
|
|
2980
|
+
/* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
|
|
2951
2981
|
/* @__PURE__ */ s("label", { style: E.label, children: S.passwordLabel }),
|
|
2952
2982
|
/* @__PURE__ */ s(
|
|
2953
2983
|
"input",
|
|
@@ -2955,17 +2985,17 @@ function jr({
|
|
|
2955
2985
|
id: "password",
|
|
2956
2986
|
name: "password",
|
|
2957
2987
|
type: "password",
|
|
2958
|
-
value:
|
|
2988
|
+
value: d,
|
|
2959
2989
|
onChange: (H) => {
|
|
2960
|
-
v(H.target.value), D.password && g((
|
|
2990
|
+
v(H.target.value), D.password && g((B) => ({ ...B, password: !1 }));
|
|
2961
2991
|
},
|
|
2962
2992
|
placeholder: S.passwordPlaceholder,
|
|
2963
|
-
style:
|
|
2993
|
+
style: ee("password"),
|
|
2964
2994
|
disabled: k
|
|
2965
2995
|
}
|
|
2966
2996
|
)
|
|
2967
2997
|
] }),
|
|
2968
|
-
/* @__PURE__ */
|
|
2998
|
+
/* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
|
|
2969
2999
|
/* @__PURE__ */ s("label", { style: E.label, children: S.confirmPasswordLabel }),
|
|
2970
3000
|
/* @__PURE__ */ s(
|
|
2971
3001
|
"input",
|
|
@@ -2975,15 +3005,15 @@ function jr({
|
|
|
2975
3005
|
type: "password",
|
|
2976
3006
|
value: F,
|
|
2977
3007
|
onChange: (H) => {
|
|
2978
|
-
|
|
3008
|
+
U(H.target.value), D.confirmPassword && g((B) => ({ ...B, confirmPassword: !1 })), l === S.passwordMismatchError && _("");
|
|
2979
3009
|
},
|
|
2980
3010
|
placeholder: S.confirmPasswordPlaceholder,
|
|
2981
|
-
style:
|
|
3011
|
+
style: ee("confirmPassword"),
|
|
2982
3012
|
disabled: k
|
|
2983
3013
|
}
|
|
2984
3014
|
)
|
|
2985
3015
|
] }),
|
|
2986
|
-
t === "tenant" && /* @__PURE__ */
|
|
3016
|
+
t === "tenant" && /* @__PURE__ */ u("div", { style: E.fieldGroup, children: [
|
|
2987
3017
|
/* @__PURE__ */ s("label", { style: E.label, children: S.tenantNameLabel }),
|
|
2988
3018
|
/* @__PURE__ */ s(
|
|
2989
3019
|
"input",
|
|
@@ -2993,10 +3023,10 @@ function jr({
|
|
|
2993
3023
|
type: "text",
|
|
2994
3024
|
value: w,
|
|
2995
3025
|
onChange: (H) => {
|
|
2996
|
-
R(H.target.value), D.tenantName && g((
|
|
3026
|
+
R(H.target.value), D.tenantName && g((B) => ({ ...B, tenantName: !1 }));
|
|
2997
3027
|
},
|
|
2998
3028
|
placeholder: S.tenantNamePlaceholder,
|
|
2999
|
-
style:
|
|
3029
|
+
style: ee("tenantName"),
|
|
3000
3030
|
disabled: k
|
|
3001
3031
|
}
|
|
3002
3032
|
)
|
|
@@ -3004,17 +3034,17 @@ function jr({
|
|
|
3004
3034
|
/* @__PURE__ */ s("button", { type: "submit", disabled: !q || k, style: W(), children: k ? S.loadingText : S.submitButton }),
|
|
3005
3035
|
l && /* @__PURE__ */ s("div", { style: E.errorText, children: l })
|
|
3006
3036
|
] }),
|
|
3007
|
-
(
|
|
3008
|
-
f && /* @__PURE__ */
|
|
3009
|
-
/* @__PURE__ */
|
|
3037
|
+
(h || f) && /* @__PURE__ */ u("div", { style: E.linkContainer, children: [
|
|
3038
|
+
f && /* @__PURE__ */ u("div", { children: [
|
|
3039
|
+
/* @__PURE__ */ u("span", { style: E.divider, children: [
|
|
3010
3040
|
S.magicLinkText,
|
|
3011
3041
|
" "
|
|
3012
3042
|
] }),
|
|
3013
3043
|
/* @__PURE__ */ s("a", { onClick: a, style: E.link, children: S.magicLinkLink })
|
|
3014
3044
|
] }),
|
|
3015
|
-
f &&
|
|
3016
|
-
|
|
3017
|
-
/* @__PURE__ */
|
|
3045
|
+
f && h && /* @__PURE__ */ s("div", { style: E.divider, children: S.dividerBullet }),
|
|
3046
|
+
h && /* @__PURE__ */ u("div", { children: [
|
|
3047
|
+
/* @__PURE__ */ u("span", { style: E.divider, children: [
|
|
3018
3048
|
S.loginText,
|
|
3019
3049
|
" "
|
|
3020
3050
|
] }),
|
|
@@ -3023,7 +3053,7 @@ function jr({
|
|
|
3023
3053
|
] })
|
|
3024
3054
|
] });
|
|
3025
3055
|
}
|
|
3026
|
-
const
|
|
3056
|
+
const Yt = {
|
|
3027
3057
|
title: "Sign In with Magic Link",
|
|
3028
3058
|
emailLabel: "Email",
|
|
3029
3059
|
emailPlaceholder: "Enter your email",
|
|
@@ -3047,7 +3077,7 @@ const Xt = {
|
|
|
3047
3077
|
tenantNotFoundError: "Tenant not found",
|
|
3048
3078
|
missingTenantOrEmailError: "Missing tenant or email",
|
|
3049
3079
|
dividerBullet: "•"
|
|
3050
|
-
},
|
|
3080
|
+
}, Xt = {
|
|
3051
3081
|
container: {
|
|
3052
3082
|
maxWidth: "400px",
|
|
3053
3083
|
width: "100%",
|
|
@@ -3170,7 +3200,7 @@ const Xt = {
|
|
|
3170
3200
|
textDecoration: "underline"
|
|
3171
3201
|
}
|
|
3172
3202
|
};
|
|
3173
|
-
function
|
|
3203
|
+
function jr({
|
|
3174
3204
|
copy: n = {},
|
|
3175
3205
|
styles: e = {},
|
|
3176
3206
|
onSuccess: t,
|
|
@@ -3178,21 +3208,21 @@ function Gr({
|
|
|
3178
3208
|
onLoginClick: i,
|
|
3179
3209
|
onSignupClick: o,
|
|
3180
3210
|
showTraditionalLinks: a = !0,
|
|
3181
|
-
className:
|
|
3211
|
+
className: h,
|
|
3182
3212
|
verifyToken: f,
|
|
3183
3213
|
frontendUrl: y
|
|
3184
3214
|
}) {
|
|
3185
3215
|
var W;
|
|
3186
|
-
const [c, L] = x(""), [m, T] = x(""), [A, N] = x(""), [M, P] = x(!1), [
|
|
3187
|
-
|
|
3216
|
+
const [c, L] = x(""), [m, T] = x(""), [A, N] = x(""), [M, P] = x(!1), [d, v] = x(!1), [F, U] = x(""), [w, R] = x(""), [k, I] = x({}), [l, _] = x(!1), { sendMagicLink: D, verifyMagicLink: g } = ue(), C = ((W = he()) == null ? void 0 : W.tenant) ?? null, b = { ...Yt, ...n }, p = { ...Xt, ...e };
|
|
3217
|
+
te(() => {
|
|
3188
3218
|
f && S(f);
|
|
3189
3219
|
}, [f]);
|
|
3190
3220
|
const S = async (q) => {
|
|
3191
|
-
if (!
|
|
3192
|
-
|
|
3221
|
+
if (!C || !c) {
|
|
3222
|
+
U(b.missingTenantOrEmailError);
|
|
3193
3223
|
return;
|
|
3194
3224
|
}
|
|
3195
|
-
v(!0),
|
|
3225
|
+
v(!0), U("");
|
|
3196
3226
|
try {
|
|
3197
3227
|
const V = await g({
|
|
3198
3228
|
token: q,
|
|
@@ -3202,24 +3232,24 @@ function Gr({
|
|
|
3202
3232
|
t == null || t(V);
|
|
3203
3233
|
} catch (V) {
|
|
3204
3234
|
const H = V.message || "Failed to verify magic link";
|
|
3205
|
-
|
|
3235
|
+
U(H), r == null || r(H);
|
|
3206
3236
|
} finally {
|
|
3207
3237
|
v(!1);
|
|
3208
3238
|
}
|
|
3209
3239
|
}, E = () => {
|
|
3210
3240
|
const q = {};
|
|
3211
3241
|
return c.trim() || (q.email = !0), l && !m.trim() && (q.name = !0), I(q), Object.keys(q).length === 0;
|
|
3212
|
-
},
|
|
3242
|
+
}, Q = async (q) => {
|
|
3213
3243
|
if (q.preventDefault(), !!E()) {
|
|
3214
|
-
if (!(
|
|
3215
|
-
|
|
3244
|
+
if (!(C != null && C.id)) {
|
|
3245
|
+
U(b.tenantNotFoundError);
|
|
3216
3246
|
return;
|
|
3217
3247
|
}
|
|
3218
|
-
P(!0),
|
|
3248
|
+
P(!0), U(""), R("");
|
|
3219
3249
|
try {
|
|
3220
3250
|
const V = y || (typeof window < "u" ? window.location.origin : ""), H = await D({
|
|
3221
3251
|
email: c,
|
|
3222
|
-
tenantId:
|
|
3252
|
+
tenantId: C.id,
|
|
3223
3253
|
frontendUrl: V,
|
|
3224
3254
|
name: l ? m : void 0,
|
|
3225
3255
|
lastName: l ? A : void 0
|
|
@@ -3227,27 +3257,27 @@ function Gr({
|
|
|
3227
3257
|
R(b.successMessage), t == null || t(H);
|
|
3228
3258
|
} catch (V) {
|
|
3229
3259
|
const H = V.message || b.errorMessage;
|
|
3230
|
-
|
|
3260
|
+
U(H), r == null || r(H);
|
|
3231
3261
|
} finally {
|
|
3232
3262
|
P(!1);
|
|
3233
3263
|
}
|
|
3234
3264
|
}
|
|
3235
|
-
},
|
|
3265
|
+
}, J = (q) => ({
|
|
3236
3266
|
...p.input,
|
|
3237
3267
|
...k[q] ? p.inputError : {}
|
|
3238
|
-
}),
|
|
3268
|
+
}), ee = () => ({
|
|
3239
3269
|
...p.button,
|
|
3240
|
-
...M ||
|
|
3241
|
-
...!c || M ||
|
|
3270
|
+
...M || d ? p.buttonLoading : {},
|
|
3271
|
+
...!c || M || d ? p.buttonDisabled : {}
|
|
3242
3272
|
});
|
|
3243
|
-
return
|
|
3273
|
+
return d ? /* @__PURE__ */ u("div", { className: h, style: p.container, children: [
|
|
3244
3274
|
/* @__PURE__ */ s("h2", { style: p.title, children: b.verifyingText }),
|
|
3245
3275
|
/* @__PURE__ */ s("div", { style: p.verifyingContainer, children: /* @__PURE__ */ s("div", { style: p.verifyingText, children: b.verifyingDescription }) })
|
|
3246
|
-
] }) : /* @__PURE__ */
|
|
3276
|
+
] }) : /* @__PURE__ */ u("div", { className: h, style: p.container, children: [
|
|
3247
3277
|
/* @__PURE__ */ s("h2", { style: p.title, children: b.title }),
|
|
3248
3278
|
/* @__PURE__ */ s("p", { style: p.description, children: b.description }),
|
|
3249
|
-
/* @__PURE__ */
|
|
3250
|
-
/* @__PURE__ */
|
|
3279
|
+
/* @__PURE__ */ u("form", { onSubmit: Q, style: p.form, children: [
|
|
3280
|
+
/* @__PURE__ */ u("div", { style: p.fieldGroup, children: [
|
|
3251
3281
|
/* @__PURE__ */ s("label", { style: p.label, children: b.emailLabel }),
|
|
3252
3282
|
/* @__PURE__ */ s(
|
|
3253
3283
|
"input",
|
|
@@ -3260,8 +3290,8 @@ function Gr({
|
|
|
3260
3290
|
L(q.target.value), k.email && I((V) => ({ ...V, email: !1 }));
|
|
3261
3291
|
},
|
|
3262
3292
|
placeholder: b.emailPlaceholder,
|
|
3263
|
-
style:
|
|
3264
|
-
disabled: M ||
|
|
3293
|
+
style: J("email"),
|
|
3294
|
+
disabled: M || d
|
|
3265
3295
|
}
|
|
3266
3296
|
)
|
|
3267
3297
|
] }),
|
|
@@ -3269,13 +3299,13 @@ function Gr({
|
|
|
3269
3299
|
"button",
|
|
3270
3300
|
{
|
|
3271
3301
|
type: "button",
|
|
3272
|
-
onClick: () =>
|
|
3302
|
+
onClick: () => _(!0),
|
|
3273
3303
|
style: p.toggleLink,
|
|
3274
3304
|
children: b.showNameToggle
|
|
3275
3305
|
}
|
|
3276
3306
|
) }),
|
|
3277
|
-
l && /* @__PURE__ */
|
|
3278
|
-
/* @__PURE__ */
|
|
3307
|
+
l && /* @__PURE__ */ u(z, { children: [
|
|
3308
|
+
/* @__PURE__ */ u("div", { style: p.fieldGroup, children: [
|
|
3279
3309
|
/* @__PURE__ */ s("label", { style: p.label, children: b.nameLabel }),
|
|
3280
3310
|
/* @__PURE__ */ s(
|
|
3281
3311
|
"input",
|
|
@@ -3288,12 +3318,12 @@ function Gr({
|
|
|
3288
3318
|
T(q.target.value), k.name && I((V) => ({ ...V, name: !1 }));
|
|
3289
3319
|
},
|
|
3290
3320
|
placeholder: b.namePlaceholder,
|
|
3291
|
-
style:
|
|
3292
|
-
disabled: M ||
|
|
3321
|
+
style: J("name"),
|
|
3322
|
+
disabled: M || d
|
|
3293
3323
|
}
|
|
3294
3324
|
)
|
|
3295
3325
|
] }),
|
|
3296
|
-
/* @__PURE__ */
|
|
3326
|
+
/* @__PURE__ */ u("div", { style: p.fieldGroup, children: [
|
|
3297
3327
|
/* @__PURE__ */ s("label", { style: p.label, children: b.lastNameLabel }),
|
|
3298
3328
|
/* @__PURE__ */ s(
|
|
3299
3329
|
"input",
|
|
@@ -3305,7 +3335,7 @@ function Gr({
|
|
|
3305
3335
|
onChange: (q) => N(q.target.value),
|
|
3306
3336
|
placeholder: b.lastNamePlaceholder,
|
|
3307
3337
|
style: p.input,
|
|
3308
|
-
disabled: M ||
|
|
3338
|
+
disabled: M || d
|
|
3309
3339
|
}
|
|
3310
3340
|
)
|
|
3311
3341
|
] }),
|
|
@@ -3314,28 +3344,28 @@ function Gr({
|
|
|
3314
3344
|
{
|
|
3315
3345
|
type: "button",
|
|
3316
3346
|
onClick: () => {
|
|
3317
|
-
|
|
3347
|
+
_(!1), T(""), N("");
|
|
3318
3348
|
},
|
|
3319
3349
|
style: p.toggleLink,
|
|
3320
3350
|
children: b.hideNameToggle
|
|
3321
3351
|
}
|
|
3322
3352
|
) })
|
|
3323
3353
|
] }),
|
|
3324
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: !c || M ||
|
|
3354
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !c || M || d, style: ee(), children: M ? b.loadingText : b.submitButton }),
|
|
3325
3355
|
F && /* @__PURE__ */ s("div", { style: p.errorText, children: F }),
|
|
3326
3356
|
w && /* @__PURE__ */ s("div", { style: p.successText, children: w })
|
|
3327
3357
|
] }),
|
|
3328
|
-
a && /* @__PURE__ */
|
|
3329
|
-
/* @__PURE__ */
|
|
3330
|
-
/* @__PURE__ */
|
|
3358
|
+
a && /* @__PURE__ */ u("div", { style: p.linkContainer, children: [
|
|
3359
|
+
/* @__PURE__ */ u("div", { children: [
|
|
3360
|
+
/* @__PURE__ */ u("span", { style: p.divider, children: [
|
|
3331
3361
|
b.loginText,
|
|
3332
3362
|
" "
|
|
3333
3363
|
] }),
|
|
3334
3364
|
/* @__PURE__ */ s("a", { onClick: i, style: p.link, children: b.loginLink })
|
|
3335
3365
|
] }),
|
|
3336
3366
|
/* @__PURE__ */ s("div", { style: p.divider, children: b.dividerBullet }),
|
|
3337
|
-
/* @__PURE__ */
|
|
3338
|
-
/* @__PURE__ */
|
|
3367
|
+
/* @__PURE__ */ u("div", { children: [
|
|
3368
|
+
/* @__PURE__ */ u("span", { style: p.divider, children: [
|
|
3339
3369
|
b.signupText,
|
|
3340
3370
|
" "
|
|
3341
3371
|
] }),
|
|
@@ -3344,7 +3374,7 @@ function Gr({
|
|
|
3344
3374
|
] })
|
|
3345
3375
|
] });
|
|
3346
3376
|
}
|
|
3347
|
-
const
|
|
3377
|
+
const er = {
|
|
3348
3378
|
title: "Verifying Magic Link",
|
|
3349
3379
|
verifyingMessage: "Please wait while we verify your magic link...",
|
|
3350
3380
|
successMessage: "Magic link verified successfully! You are now logged in.",
|
|
@@ -3353,7 +3383,7 @@ const tr = {
|
|
|
3353
3383
|
retryButton: "Try Again",
|
|
3354
3384
|
backToLoginButton: "Back to Login",
|
|
3355
3385
|
missingParamsError: "Missing required parameters: token or email"
|
|
3356
|
-
},
|
|
3386
|
+
}, et = {
|
|
3357
3387
|
container: {
|
|
3358
3388
|
maxWidth: "400px",
|
|
3359
3389
|
width: "100%",
|
|
@@ -3446,7 +3476,7 @@ const tr = {
|
|
|
3446
3476
|
backButtonHover: {
|
|
3447
3477
|
backgroundColor: "#e5e7eb"
|
|
3448
3478
|
}
|
|
3449
|
-
},
|
|
3479
|
+
}, tr = () => /* @__PURE__ */ s("div", { style: et.spinner }), rr = () => /* @__PURE__ */ u(
|
|
3450
3480
|
"svg",
|
|
3451
3481
|
{
|
|
3452
3482
|
width: "48",
|
|
@@ -3463,7 +3493,7 @@ const tr = {
|
|
|
3463
3493
|
/* @__PURE__ */ s("polyline", { points: "22,4 12,14.01 9,11.01" })
|
|
3464
3494
|
]
|
|
3465
3495
|
}
|
|
3466
|
-
),
|
|
3496
|
+
), nr = () => /* @__PURE__ */ u(
|
|
3467
3497
|
"svg",
|
|
3468
3498
|
{
|
|
3469
3499
|
width: "48",
|
|
@@ -3481,12 +3511,12 @@ const tr = {
|
|
|
3481
3511
|
/* @__PURE__ */ s("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
|
|
3482
3512
|
]
|
|
3483
3513
|
}
|
|
3484
|
-
),
|
|
3485
|
-
loading: /* @__PURE__ */ s(
|
|
3486
|
-
success: /* @__PURE__ */ s(
|
|
3487
|
-
error: /* @__PURE__ */ s(
|
|
3514
|
+
), sr = {
|
|
3515
|
+
loading: /* @__PURE__ */ s(tr, {}),
|
|
3516
|
+
success: /* @__PURE__ */ s(rr, {}),
|
|
3517
|
+
error: /* @__PURE__ */ s(nr, {})
|
|
3488
3518
|
};
|
|
3489
|
-
function
|
|
3519
|
+
function Gr({
|
|
3490
3520
|
copy: n = {},
|
|
3491
3521
|
styles: e = {},
|
|
3492
3522
|
icons: t = {},
|
|
@@ -3494,14 +3524,14 @@ function Kr({
|
|
|
3494
3524
|
onError: i,
|
|
3495
3525
|
onRetry: o,
|
|
3496
3526
|
onBackToLogin: a,
|
|
3497
|
-
className:
|
|
3527
|
+
className: h,
|
|
3498
3528
|
token: f,
|
|
3499
3529
|
email: y,
|
|
3500
3530
|
appId: c,
|
|
3501
3531
|
tenantSlug: L,
|
|
3502
3532
|
autoRedirectDelay: m = 3e3
|
|
3503
3533
|
}) {
|
|
3504
|
-
const [T, A] = x("verifying"), [N, M] = x(""), { verifyMagicLink: P } =
|
|
3534
|
+
const [T, A] = x("verifying"), [N, M] = x(""), { verifyMagicLink: P } = ue(), d = { ...er, ...n }, v = { ...et, ...e }, F = { ...sr, ...t }, U = () => {
|
|
3505
3535
|
if (typeof window > "u") return {};
|
|
3506
3536
|
const l = new URLSearchParams(window.location.search);
|
|
3507
3537
|
return {
|
|
@@ -3513,51 +3543,51 @@ function Kr({
|
|
|
3513
3543
|
}, w = async () => {
|
|
3514
3544
|
A("verifying"), M("");
|
|
3515
3545
|
try {
|
|
3516
|
-
const l =
|
|
3546
|
+
const l = U();
|
|
3517
3547
|
if (!l.token || !l.email)
|
|
3518
|
-
throw new Error(
|
|
3519
|
-
const
|
|
3548
|
+
throw new Error(d.missingParamsError);
|
|
3549
|
+
const _ = await P({
|
|
3520
3550
|
token: l.token,
|
|
3521
3551
|
email: l.email,
|
|
3522
3552
|
tenantSlug: l.tenantSlug
|
|
3523
3553
|
});
|
|
3524
|
-
A("success"), r == null || r(
|
|
3554
|
+
A("success"), r == null || r(_), m > 0 && setTimeout(() => {
|
|
3525
3555
|
A("redirecting");
|
|
3526
3556
|
}, m);
|
|
3527
3557
|
} catch (l) {
|
|
3528
|
-
const
|
|
3529
|
-
M(
|
|
3558
|
+
const _ = l.message || d.errorMessage;
|
|
3559
|
+
M(_), A("error"), i == null || i(_);
|
|
3530
3560
|
}
|
|
3531
3561
|
}, R = () => {
|
|
3532
3562
|
o == null || o(), w();
|
|
3533
3563
|
}, k = () => {
|
|
3534
3564
|
a == null || a();
|
|
3535
3565
|
};
|
|
3536
|
-
|
|
3566
|
+
te(() => {
|
|
3537
3567
|
w();
|
|
3538
3568
|
}, []);
|
|
3539
3569
|
const I = () => {
|
|
3540
3570
|
switch (T) {
|
|
3541
3571
|
case "verifying":
|
|
3542
|
-
return /* @__PURE__ */
|
|
3572
|
+
return /* @__PURE__ */ u("div", { style: v.message, children: [
|
|
3543
3573
|
F.loading,
|
|
3544
|
-
|
|
3574
|
+
d.verifyingMessage
|
|
3545
3575
|
] });
|
|
3546
3576
|
case "success":
|
|
3547
|
-
return /* @__PURE__ */
|
|
3577
|
+
return /* @__PURE__ */ u(z, { children: [
|
|
3548
3578
|
F.success,
|
|
3549
|
-
/* @__PURE__ */ s("div", { style: v.successMessage, children:
|
|
3579
|
+
/* @__PURE__ */ s("div", { style: v.successMessage, children: d.successMessage })
|
|
3550
3580
|
] });
|
|
3551
3581
|
case "redirecting":
|
|
3552
|
-
return /* @__PURE__ */
|
|
3582
|
+
return /* @__PURE__ */ u(z, { children: [
|
|
3553
3583
|
F.loading,
|
|
3554
|
-
/* @__PURE__ */ s("div", { style: v.message, children:
|
|
3584
|
+
/* @__PURE__ */ s("div", { style: v.message, children: d.redirectingMessage })
|
|
3555
3585
|
] });
|
|
3556
3586
|
case "error":
|
|
3557
|
-
return /* @__PURE__ */
|
|
3587
|
+
return /* @__PURE__ */ u(z, { children: [
|
|
3558
3588
|
F.error,
|
|
3559
|
-
/* @__PURE__ */ s("div", { style: v.errorMessage, children: N ||
|
|
3560
|
-
/* @__PURE__ */
|
|
3589
|
+
/* @__PURE__ */ s("div", { style: v.errorMessage, children: N || d.errorMessage }),
|
|
3590
|
+
/* @__PURE__ */ u("div", { style: v.buttonContainer, children: [
|
|
3561
3591
|
/* @__PURE__ */ s(
|
|
3562
3592
|
"button",
|
|
3563
3593
|
{
|
|
@@ -3567,12 +3597,12 @@ function Kr({
|
|
|
3567
3597
|
Object.assign(l.currentTarget.style, v.retryButtonHover);
|
|
3568
3598
|
},
|
|
3569
3599
|
onMouseOut: (l) => {
|
|
3570
|
-
const
|
|
3600
|
+
const _ = v.retryButton || {};
|
|
3571
3601
|
Object.keys(v.retryButtonHover || {}).forEach((D) => {
|
|
3572
|
-
l.currentTarget.style[D] =
|
|
3602
|
+
l.currentTarget.style[D] = _[D] ?? "";
|
|
3573
3603
|
});
|
|
3574
3604
|
},
|
|
3575
|
-
children:
|
|
3605
|
+
children: d.retryButton
|
|
3576
3606
|
}
|
|
3577
3607
|
),
|
|
3578
3608
|
/* @__PURE__ */ s(
|
|
@@ -3584,12 +3614,12 @@ function Kr({
|
|
|
3584
3614
|
Object.assign(l.currentTarget.style, v.backButtonHover);
|
|
3585
3615
|
},
|
|
3586
3616
|
onMouseOut: (l) => {
|
|
3587
|
-
const
|
|
3617
|
+
const _ = v.backButton || {};
|
|
3588
3618
|
Object.keys(v.backButtonHover || {}).forEach((D) => {
|
|
3589
|
-
l.currentTarget.style[D] =
|
|
3619
|
+
l.currentTarget.style[D] = _[D] ?? "";
|
|
3590
3620
|
});
|
|
3591
3621
|
},
|
|
3592
|
-
children:
|
|
3622
|
+
children: d.backToLoginButton
|
|
3593
3623
|
}
|
|
3594
3624
|
)
|
|
3595
3625
|
] })
|
|
@@ -3598,18 +3628,18 @@ function Kr({
|
|
|
3598
3628
|
return null;
|
|
3599
3629
|
}
|
|
3600
3630
|
};
|
|
3601
|
-
return /* @__PURE__ */
|
|
3631
|
+
return /* @__PURE__ */ u("div", { style: v.container, className: h, children: [
|
|
3602
3632
|
/* @__PURE__ */ s("style", { children: `
|
|
3603
3633
|
@keyframes spin {
|
|
3604
3634
|
0% { transform: rotate(0deg); }
|
|
3605
3635
|
100% { transform: rotate(360deg); }
|
|
3606
3636
|
}
|
|
3607
3637
|
` }),
|
|
3608
|
-
/* @__PURE__ */ s("h1", { style: v.title, children:
|
|
3638
|
+
/* @__PURE__ */ s("h1", { style: v.title, children: d.title }),
|
|
3609
3639
|
I()
|
|
3610
3640
|
] });
|
|
3611
3641
|
}
|
|
3612
|
-
const
|
|
3642
|
+
const ir = {
|
|
3613
3643
|
title: "Reset Password",
|
|
3614
3644
|
subtitle: "Enter your email address and we'll send you a link to reset your password.",
|
|
3615
3645
|
emailLabel: "Email",
|
|
@@ -3635,7 +3665,7 @@ const or = {
|
|
|
3635
3665
|
haveTokenLink: "I have a token",
|
|
3636
3666
|
tenantNotFoundError: "Tenant not found",
|
|
3637
3667
|
dividerBullet: "•"
|
|
3638
|
-
},
|
|
3668
|
+
}, or = {
|
|
3639
3669
|
container: {
|
|
3640
3670
|
maxWidth: "400px",
|
|
3641
3671
|
margin: "0 auto",
|
|
@@ -3731,7 +3761,7 @@ const or = {
|
|
|
3731
3761
|
color: "#6b7280"
|
|
3732
3762
|
}
|
|
3733
3763
|
};
|
|
3734
|
-
function
|
|
3764
|
+
function Jr({
|
|
3735
3765
|
copy: n = {},
|
|
3736
3766
|
styles: e = {},
|
|
3737
3767
|
mode: t = "request",
|
|
@@ -3739,30 +3769,30 @@ function Qr({
|
|
|
3739
3769
|
onSuccess: i,
|
|
3740
3770
|
onError: o,
|
|
3741
3771
|
onBackToLogin: a,
|
|
3742
|
-
onModeChange:
|
|
3772
|
+
onModeChange: h,
|
|
3743
3773
|
className: f
|
|
3744
3774
|
}) {
|
|
3745
|
-
var
|
|
3746
|
-
const [y, c] = x(""), [L, m] = x(r), [T, A] = x(""), [N, M] = x(""), [P,
|
|
3775
|
+
var ee;
|
|
3776
|
+
const [y, c] = x(""), [L, m] = x(r), [T, A] = x(""), [N, M] = x(""), [P, d] = x(!1), [v, F] = x(""), [U, w] = x(""), [R, k] = x({}), { requestPasswordReset: I, confirmPasswordReset: l } = ue(), _ = ((ee = he()) == null ? void 0 : ee.tenant) ?? null, D = { ...ir, ...n }, g = { ...or, ...e }, C = () => {
|
|
3747
3777
|
const W = {};
|
|
3748
3778
|
return y.trim() || (W.email = !0), k(W), Object.keys(W).length === 0;
|
|
3749
3779
|
}, b = () => {
|
|
3750
3780
|
const W = {};
|
|
3751
3781
|
return L.trim() || (W.token = !0), T.trim() || (W.newPassword = !0), N.trim() || (W.confirmPassword = !0), k(W), Object.keys(W).length === 0;
|
|
3752
3782
|
}, p = async (W) => {
|
|
3753
|
-
if (W.preventDefault(), !!
|
|
3754
|
-
if (!(
|
|
3783
|
+
if (W.preventDefault(), !!C()) {
|
|
3784
|
+
if (!(_ != null && _.id)) {
|
|
3755
3785
|
F(D.tenantNotFoundError);
|
|
3756
3786
|
return;
|
|
3757
3787
|
}
|
|
3758
|
-
|
|
3788
|
+
d(!0), F(""), w("");
|
|
3759
3789
|
try {
|
|
3760
|
-
await I({ email: y, tenantId:
|
|
3790
|
+
await I({ email: y, tenantId: _.id }), w(D.successMessage), i == null || i();
|
|
3761
3791
|
} catch (q) {
|
|
3762
3792
|
const V = q.message || D.errorMessage;
|
|
3763
3793
|
F(V), o == null || o(V);
|
|
3764
3794
|
} finally {
|
|
3765
|
-
|
|
3795
|
+
d(!1);
|
|
3766
3796
|
}
|
|
3767
3797
|
}
|
|
3768
3798
|
}, S = async (W) => {
|
|
@@ -3771,30 +3801,30 @@ function Qr({
|
|
|
3771
3801
|
F(D.passwordMismatchError), k({ confirmPassword: !0 });
|
|
3772
3802
|
return;
|
|
3773
3803
|
}
|
|
3774
|
-
|
|
3804
|
+
d(!0), F(""), w("");
|
|
3775
3805
|
try {
|
|
3776
3806
|
await l({ token: L, newPassword: T }), w(D.resetSuccessMessage), i == null || i();
|
|
3777
3807
|
} catch (q) {
|
|
3778
3808
|
const V = q.message || D.errorMessage;
|
|
3779
3809
|
F(V), o == null || o(V);
|
|
3780
3810
|
} finally {
|
|
3781
|
-
|
|
3811
|
+
d(!1);
|
|
3782
3812
|
}
|
|
3783
3813
|
}
|
|
3784
3814
|
}, E = (W) => ({
|
|
3785
3815
|
...g.input,
|
|
3786
3816
|
...R[W] ? g.inputError : {}
|
|
3787
|
-
}),
|
|
3817
|
+
}), Q = () => ({
|
|
3788
3818
|
...g.button,
|
|
3789
3819
|
...P ? g.buttonLoading : {}
|
|
3790
3820
|
});
|
|
3791
3821
|
if (t === "reset") {
|
|
3792
3822
|
const W = L && T && N;
|
|
3793
|
-
return /* @__PURE__ */
|
|
3823
|
+
return /* @__PURE__ */ u("div", { className: f, style: g.container, children: [
|
|
3794
3824
|
/* @__PURE__ */ s("h2", { style: g.title, children: D.resetTitle }),
|
|
3795
3825
|
/* @__PURE__ */ s("p", { style: g.subtitle, children: D.resetSubtitle }),
|
|
3796
|
-
/* @__PURE__ */
|
|
3797
|
-
/* @__PURE__ */
|
|
3826
|
+
/* @__PURE__ */ u("form", { onSubmit: S, style: g.form, children: [
|
|
3827
|
+
/* @__PURE__ */ u("div", { style: g.fieldGroup, children: [
|
|
3798
3828
|
/* @__PURE__ */ s("label", { style: g.label, children: D.tokenLabel }),
|
|
3799
3829
|
/* @__PURE__ */ s(
|
|
3800
3830
|
"input",
|
|
@@ -3810,7 +3840,7 @@ function Qr({
|
|
|
3810
3840
|
}
|
|
3811
3841
|
)
|
|
3812
3842
|
] }),
|
|
3813
|
-
/* @__PURE__ */
|
|
3843
|
+
/* @__PURE__ */ u("div", { style: g.fieldGroup, children: [
|
|
3814
3844
|
/* @__PURE__ */ s("label", { style: g.label, children: D.newPasswordLabel }),
|
|
3815
3845
|
/* @__PURE__ */ s(
|
|
3816
3846
|
"input",
|
|
@@ -3826,7 +3856,7 @@ function Qr({
|
|
|
3826
3856
|
}
|
|
3827
3857
|
)
|
|
3828
3858
|
] }),
|
|
3829
|
-
/* @__PURE__ */
|
|
3859
|
+
/* @__PURE__ */ u("div", { style: g.fieldGroup, children: [
|
|
3830
3860
|
/* @__PURE__ */ s("label", { style: g.label, children: D.confirmPasswordLabel }),
|
|
3831
3861
|
/* @__PURE__ */ s(
|
|
3832
3862
|
"input",
|
|
@@ -3848,30 +3878,30 @@ function Qr({
|
|
|
3848
3878
|
type: "submit",
|
|
3849
3879
|
disabled: !W || P,
|
|
3850
3880
|
style: {
|
|
3851
|
-
...
|
|
3881
|
+
...Q(),
|
|
3852
3882
|
...!W || P ? g.buttonDisabled : {}
|
|
3853
3883
|
},
|
|
3854
3884
|
children: P ? D.resetLoadingText : D.resetSubmitButton
|
|
3855
3885
|
}
|
|
3856
3886
|
),
|
|
3857
3887
|
v && /* @__PURE__ */ s("div", { style: g.errorText, children: v }),
|
|
3858
|
-
|
|
3888
|
+
U && /* @__PURE__ */ s("div", { style: g.successText, children: U })
|
|
3859
3889
|
] }),
|
|
3860
|
-
/* @__PURE__ */
|
|
3890
|
+
/* @__PURE__ */ u("div", { style: g.linkContainer, children: [
|
|
3861
3891
|
/* @__PURE__ */ s("a", { onClick: a, style: g.link, children: D.backToLoginLink }),
|
|
3862
|
-
|
|
3892
|
+
h && /* @__PURE__ */ u(z, { children: [
|
|
3863
3893
|
/* @__PURE__ */ s("span", { style: g.modeSwitchDivider, children: D.dividerBullet }),
|
|
3864
|
-
/* @__PURE__ */ s("a", { onClick: () =>
|
|
3894
|
+
/* @__PURE__ */ s("a", { onClick: () => h("request"), style: g.link, children: D.requestNewLinkLink })
|
|
3865
3895
|
] })
|
|
3866
3896
|
] })
|
|
3867
3897
|
] });
|
|
3868
3898
|
}
|
|
3869
|
-
const
|
|
3870
|
-
return /* @__PURE__ */
|
|
3899
|
+
const J = y;
|
|
3900
|
+
return /* @__PURE__ */ u("div", { className: f, style: g.container, children: [
|
|
3871
3901
|
/* @__PURE__ */ s("h2", { style: g.title, children: D.title }),
|
|
3872
3902
|
/* @__PURE__ */ s("p", { style: g.subtitle, children: D.subtitle }),
|
|
3873
|
-
/* @__PURE__ */
|
|
3874
|
-
/* @__PURE__ */
|
|
3903
|
+
/* @__PURE__ */ u("form", { onSubmit: p, style: g.form, children: [
|
|
3904
|
+
/* @__PURE__ */ u("div", { style: g.fieldGroup, children: [
|
|
3875
3905
|
/* @__PURE__ */ s("label", { style: g.label, children: D.emailLabel }),
|
|
3876
3906
|
/* @__PURE__ */ s(
|
|
3877
3907
|
"input",
|
|
@@ -3891,27 +3921,27 @@ function Qr({
|
|
|
3891
3921
|
"button",
|
|
3892
3922
|
{
|
|
3893
3923
|
type: "submit",
|
|
3894
|
-
disabled: !
|
|
3924
|
+
disabled: !J || P,
|
|
3895
3925
|
style: {
|
|
3896
|
-
...
|
|
3897
|
-
...!
|
|
3926
|
+
...Q(),
|
|
3927
|
+
...!J || P ? g.buttonDisabled : {}
|
|
3898
3928
|
},
|
|
3899
3929
|
children: P ? D.loadingText : D.submitButton
|
|
3900
3930
|
}
|
|
3901
3931
|
),
|
|
3902
3932
|
v && /* @__PURE__ */ s("div", { style: g.errorText, children: v }),
|
|
3903
|
-
|
|
3933
|
+
U && /* @__PURE__ */ s("div", { style: g.successText, children: U })
|
|
3904
3934
|
] }),
|
|
3905
|
-
/* @__PURE__ */
|
|
3935
|
+
/* @__PURE__ */ u("div", { style: g.linkContainer, children: [
|
|
3906
3936
|
/* @__PURE__ */ s("a", { onClick: a, style: g.link, children: D.backToLoginLink }),
|
|
3907
|
-
|
|
3937
|
+
h && /* @__PURE__ */ u(z, { children: [
|
|
3908
3938
|
/* @__PURE__ */ s("span", { style: g.modeSwitchDivider, children: D.dividerBullet }),
|
|
3909
|
-
/* @__PURE__ */ s("a", { onClick: () =>
|
|
3939
|
+
/* @__PURE__ */ s("a", { onClick: () => h("reset"), style: g.link, children: D.haveTokenLink })
|
|
3910
3940
|
] })
|
|
3911
3941
|
] })
|
|
3912
3942
|
] });
|
|
3913
3943
|
}
|
|
3914
|
-
const
|
|
3944
|
+
const ar = () => /* @__PURE__ */ s(
|
|
3915
3945
|
"div",
|
|
3916
3946
|
{
|
|
3917
3947
|
style: {
|
|
@@ -3923,7 +3953,7 @@ const lr = () => /* @__PURE__ */ s(
|
|
|
3923
3953
|
},
|
|
3924
3954
|
children: /* @__PURE__ */ s("div", { children: "Loading..." })
|
|
3925
3955
|
}
|
|
3926
|
-
),
|
|
3956
|
+
), lr = ({ error: n, retry: e }) => /* @__PURE__ */ u(
|
|
3927
3957
|
"div",
|
|
3928
3958
|
{
|
|
3929
3959
|
style: {
|
|
@@ -3957,31 +3987,31 @@ const lr = () => /* @__PURE__ */ s(
|
|
|
3957
3987
|
]
|
|
3958
3988
|
}
|
|
3959
3989
|
);
|
|
3960
|
-
function
|
|
3990
|
+
function Qr({
|
|
3961
3991
|
children: n,
|
|
3962
3992
|
loadingFallback: e,
|
|
3963
3993
|
errorFallback: t,
|
|
3964
3994
|
requireTenant: r = !0
|
|
3965
3995
|
}) {
|
|
3966
|
-
const { isAppLoading: i, appError: o, retryApp: a } =
|
|
3967
|
-
}), N = (f == null ? void 0 : f.isAuthReady) ?? !0, M = (y == null ? void 0 : y.isReady) ?? !0, P = (c == null ? void 0 : c.isReady) ?? !0,
|
|
3968
|
-
o && a(), m &&
|
|
3996
|
+
const { isAppLoading: i, appError: o, retryApp: a } = ke(), h = he(), f = Ue(), y = Ze(), c = Ye(), L = (h == null ? void 0 : h.isTenantLoading) ?? !1, m = (h == null ? void 0 : h.tenantError) ?? null, T = (h == null ? void 0 : h.tenantSlug) ?? null, A = (h == null ? void 0 : h.retryTenant) ?? (() => {
|
|
3997
|
+
}), N = (f == null ? void 0 : f.isAuthReady) ?? !0, M = (y == null ? void 0 : y.isReady) ?? !0, P = (c == null ? void 0 : c.isReady) ?? !0, d = r && h && T, w = i || d && L || f && !N || y && !M || c && !P, R = o || (d ? m : null), k = () => {
|
|
3998
|
+
o && a(), m && h && A();
|
|
3969
3999
|
};
|
|
3970
4000
|
if (w)
|
|
3971
|
-
return /* @__PURE__ */ s(
|
|
4001
|
+
return /* @__PURE__ */ s(z, { children: e || /* @__PURE__ */ s(ar, {}) });
|
|
3972
4002
|
if (R) {
|
|
3973
|
-
const I = typeof t == "function" ? t(R, k) : t || /* @__PURE__ */ s(
|
|
3974
|
-
return /* @__PURE__ */ s(
|
|
4003
|
+
const I = typeof t == "function" ? t(R, k) : t || /* @__PURE__ */ s(lr, { error: R, retry: k });
|
|
4004
|
+
return /* @__PURE__ */ s(z, { children: I });
|
|
3975
4005
|
}
|
|
3976
|
-
return /* @__PURE__ */ s(
|
|
4006
|
+
return /* @__PURE__ */ s(z, { children: n });
|
|
3977
4007
|
}
|
|
3978
|
-
function
|
|
3979
|
-
const { isAppLoading: e, appError: t, retryApp: r, appInfo: i } =
|
|
3980
|
-
}), A = (a == null ? void 0 : a.isAuthReady) ?? !0, N = (
|
|
4008
|
+
function Kr(n = !0) {
|
|
4009
|
+
const { isAppLoading: e, appError: t, retryApp: r, appInfo: i } = ke(), o = he(), a = Ue(), h = Ze(), f = Ye(), y = (o == null ? void 0 : o.isTenantLoading) ?? !1, c = (o == null ? void 0 : o.tenantError) ?? null, L = (o == null ? void 0 : o.tenant) ?? null, m = (o == null ? void 0 : o.tenantSlug) ?? null, T = (o == null ? void 0 : o.retryTenant) ?? (() => {
|
|
4010
|
+
}), A = (a == null ? void 0 : a.isAuthReady) ?? !0, N = (h == null ? void 0 : h.isReady) ?? !0, M = (f == null ? void 0 : f.isReady) ?? !0, P = n && o && m, U = e || P && y || a && !A || h && !N || f && !M, w = t || (P ? c : null);
|
|
3981
4011
|
return {
|
|
3982
|
-
isLoading:
|
|
4012
|
+
isLoading: U,
|
|
3983
4013
|
error: w,
|
|
3984
|
-
isReady: !
|
|
4014
|
+
isReady: !U && !w && i !== null && (!P || L !== null),
|
|
3985
4015
|
retry: () => {
|
|
3986
4016
|
t && r(), c && o && T();
|
|
3987
4017
|
},
|
|
@@ -3989,11 +4019,11 @@ function Zr(n = !0) {
|
|
|
3989
4019
|
app: { isLoading: e, error: t, data: i },
|
|
3990
4020
|
tenant: o ? { isLoading: y, error: c, data: L } : null,
|
|
3991
4021
|
auth: a ? { isReady: A } : null,
|
|
3992
|
-
featureFlags:
|
|
4022
|
+
featureFlags: h ? { isReady: N } : null,
|
|
3993
4023
|
subscription: f ? { isReady: M } : null
|
|
3994
4024
|
};
|
|
3995
4025
|
}
|
|
3996
|
-
const
|
|
4026
|
+
const cr = {
|
|
3997
4027
|
wrapper: {
|
|
3998
4028
|
position: "relative"
|
|
3999
4029
|
},
|
|
@@ -4037,7 +4067,7 @@ const dr = {
|
|
|
4037
4067
|
marginLeft: 8
|
|
4038
4068
|
}
|
|
4039
4069
|
};
|
|
4040
|
-
function
|
|
4070
|
+
function Zr({
|
|
4041
4071
|
tenants: n,
|
|
4042
4072
|
currentTenantId: e,
|
|
4043
4073
|
onSelect: t,
|
|
@@ -4045,16 +4075,16 @@ function Yr({
|
|
|
4045
4075
|
className: i = "",
|
|
4046
4076
|
dropdownClassName: o = "",
|
|
4047
4077
|
itemClassName: a = "",
|
|
4048
|
-
renderItem:
|
|
4078
|
+
renderItem: h,
|
|
4049
4079
|
placeholder: f = "Select tenant",
|
|
4050
4080
|
disabled: y = !1,
|
|
4051
4081
|
showCurrentTenant: c = !0
|
|
4052
4082
|
}) {
|
|
4053
|
-
var
|
|
4054
|
-
const L = { ...
|
|
4083
|
+
var U;
|
|
4084
|
+
const L = { ...cr, ...r }, m = Ue(), [T, A] = x(!1), N = Me(null), M = n ?? (m == null ? void 0 : m.userTenants) ?? [], P = e ?? ((U = m == null ? void 0 : m.currentUser) == null ? void 0 : U.tenantId) ?? null, d = async (w) => {
|
|
4055
4085
|
A(!1), t ? t(w) : m != null && m.switchToTenant && await m.switchToTenant(w);
|
|
4056
4086
|
};
|
|
4057
|
-
|
|
4087
|
+
te(() => {
|
|
4058
4088
|
const w = (R) => {
|
|
4059
4089
|
N.current && !N.current.contains(R.target) && A(!1);
|
|
4060
4090
|
};
|
|
@@ -4065,16 +4095,16 @@ function Yr({
|
|
|
4065
4095
|
return null;
|
|
4066
4096
|
if (M.length === 1 && c)
|
|
4067
4097
|
return /* @__PURE__ */ s("div", { className: i, children: /* @__PURE__ */ s("span", { children: M[0].name }) });
|
|
4068
|
-
const F = (w, R) => /* @__PURE__ */
|
|
4098
|
+
const F = (w, R) => /* @__PURE__ */ u("span", { style: { fontWeight: R ? "bold" : "normal" }, children: [
|
|
4069
4099
|
w.name,
|
|
4070
|
-
w.role && /* @__PURE__ */
|
|
4100
|
+
w.role && /* @__PURE__ */ u("span", { style: L.itemRole, children: [
|
|
4071
4101
|
"(",
|
|
4072
4102
|
w.role,
|
|
4073
4103
|
")"
|
|
4074
4104
|
] })
|
|
4075
4105
|
] });
|
|
4076
|
-
return /* @__PURE__ */
|
|
4077
|
-
/* @__PURE__ */
|
|
4106
|
+
return /* @__PURE__ */ u("div", { ref: N, className: i, style: L.wrapper, children: [
|
|
4107
|
+
/* @__PURE__ */ u(
|
|
4078
4108
|
"button",
|
|
4079
4109
|
{
|
|
4080
4110
|
type: "button",
|
|
@@ -4096,7 +4126,7 @@ function Yr({
|
|
|
4096
4126
|
"div",
|
|
4097
4127
|
{
|
|
4098
4128
|
className: a,
|
|
4099
|
-
onClick: () =>
|
|
4129
|
+
onClick: () => d(w.id),
|
|
4100
4130
|
style: {
|
|
4101
4131
|
...L.item,
|
|
4102
4132
|
...R ? L.itemSelected : {}
|
|
@@ -4112,14 +4142,14 @@ function Yr({
|
|
|
4112
4142
|
});
|
|
4113
4143
|
}
|
|
4114
4144
|
},
|
|
4115
|
-
children:
|
|
4145
|
+
children: h ? h(w, R) : F(w, R)
|
|
4116
4146
|
},
|
|
4117
4147
|
w.id
|
|
4118
4148
|
);
|
|
4119
4149
|
}) })
|
|
4120
4150
|
] });
|
|
4121
4151
|
}
|
|
4122
|
-
class
|
|
4152
|
+
class Yr {
|
|
4123
4153
|
constructor(e, t) {
|
|
4124
4154
|
this.httpService = e, this.sessionManager = t;
|
|
4125
4155
|
}
|
|
@@ -4187,7 +4217,7 @@ class Xr {
|
|
|
4187
4217
|
};
|
|
4188
4218
|
}
|
|
4189
4219
|
}
|
|
4190
|
-
class
|
|
4220
|
+
class Xr {
|
|
4191
4221
|
constructor(e, t) {
|
|
4192
4222
|
this.httpService = e, this.sessionManager = t;
|
|
4193
4223
|
}
|
|
@@ -4238,7 +4268,7 @@ class en {
|
|
|
4238
4268
|
});
|
|
4239
4269
|
}
|
|
4240
4270
|
}
|
|
4241
|
-
class
|
|
4271
|
+
class en {
|
|
4242
4272
|
constructor(e) {
|
|
4243
4273
|
this.httpService = e;
|
|
4244
4274
|
}
|
|
@@ -4247,7 +4277,7 @@ class tn {
|
|
|
4247
4277
|
return await this.httpService.get("/health");
|
|
4248
4278
|
}
|
|
4249
4279
|
}
|
|
4250
|
-
class
|
|
4280
|
+
class tn {
|
|
4251
4281
|
// Date string to Date object
|
|
4252
4282
|
static toDate(e) {
|
|
4253
4283
|
return new Date(e);
|
|
@@ -4369,61 +4399,61 @@ class rn {
|
|
|
4369
4399
|
}), t;
|
|
4370
4400
|
}
|
|
4371
4401
|
}
|
|
4372
|
-
const
|
|
4373
|
-
function
|
|
4402
|
+
const tt = "returnTo", Ee = "zone_return_to", Ie = "zone_return_to";
|
|
4403
|
+
function rn(n = {}) {
|
|
4374
4404
|
const {
|
|
4375
4405
|
zoneRoots: e = {},
|
|
4376
|
-
returnToParam: t =
|
|
4406
|
+
returnToParam: t = tt,
|
|
4377
4407
|
returnToStorage: r = "url"
|
|
4378
|
-
} = n, i =
|
|
4408
|
+
} = n, i = gt(), [o, a] = mt(), { isAuthenticated: h, currentUser: f } = ue(), { tenant: y } = ve(), c = K(() => ({ ...He, ...e }), [e]), L = !!y, m = f == null ? void 0 : f.userType, T = K(() => {
|
|
4379
4409
|
switch (r) {
|
|
4380
4410
|
case "url":
|
|
4381
4411
|
return o.get(t);
|
|
4382
4412
|
case "session":
|
|
4383
|
-
return sessionStorage.getItem(
|
|
4413
|
+
return sessionStorage.getItem(Ee);
|
|
4384
4414
|
case "local":
|
|
4385
|
-
return localStorage.getItem(
|
|
4415
|
+
return localStorage.getItem(Ie);
|
|
4386
4416
|
default:
|
|
4387
4417
|
return null;
|
|
4388
4418
|
}
|
|
4389
|
-
}, [r, o, t]), A =
|
|
4419
|
+
}, [r, o, t]), A = ie(() => {
|
|
4390
4420
|
switch (r) {
|
|
4391
4421
|
case "url": {
|
|
4392
|
-
const
|
|
4393
|
-
|
|
4422
|
+
const d = new URLSearchParams(o);
|
|
4423
|
+
d.delete(t), a(d, { replace: !0 });
|
|
4394
4424
|
break;
|
|
4395
4425
|
}
|
|
4396
4426
|
case "session":
|
|
4397
|
-
sessionStorage.removeItem(
|
|
4427
|
+
sessionStorage.removeItem(Ee);
|
|
4398
4428
|
break;
|
|
4399
4429
|
case "local":
|
|
4400
|
-
localStorage.removeItem(
|
|
4430
|
+
localStorage.removeItem(Ie);
|
|
4401
4431
|
break;
|
|
4402
4432
|
}
|
|
4403
|
-
}, [r, o, t, a]), N =
|
|
4404
|
-
(
|
|
4433
|
+
}, [r, o, t, a]), N = ie(
|
|
4434
|
+
(d) => {
|
|
4405
4435
|
switch (r) {
|
|
4406
4436
|
case "url": {
|
|
4407
4437
|
const v = new URLSearchParams(o);
|
|
4408
|
-
v.set(t,
|
|
4438
|
+
v.set(t, d), a(v, { replace: !0 });
|
|
4409
4439
|
break;
|
|
4410
4440
|
}
|
|
4411
4441
|
case "session":
|
|
4412
|
-
sessionStorage.setItem(
|
|
4442
|
+
sessionStorage.setItem(Ee, d);
|
|
4413
4443
|
break;
|
|
4414
4444
|
case "local":
|
|
4415
|
-
localStorage.setItem(
|
|
4445
|
+
localStorage.setItem(Ie, d);
|
|
4416
4446
|
break;
|
|
4417
4447
|
}
|
|
4418
4448
|
},
|
|
4419
4449
|
[r, o, t, a]
|
|
4420
|
-
), M =
|
|
4421
|
-
(
|
|
4422
|
-
const v = c[
|
|
4450
|
+
), M = ie(
|
|
4451
|
+
(d) => {
|
|
4452
|
+
const v = c[d] || c.default;
|
|
4423
4453
|
i(v);
|
|
4424
4454
|
},
|
|
4425
4455
|
[i, c]
|
|
4426
|
-
), P =
|
|
4456
|
+
), P = ie(() => L ? h ? m === oe.TENANT_ADMIN ? c.tenantAdmin : c.tenantUser : c.tenantGuest : h ? m === oe.TENANT_ADMIN ? c.publicAdmin : c.publicUser : c.publicGuest, [L, h, m, c]);
|
|
4427
4457
|
return {
|
|
4428
4458
|
returnToUrl: T,
|
|
4429
4459
|
clearReturnTo: A,
|
|
@@ -4432,76 +4462,76 @@ function nn(n = {}) {
|
|
|
4432
4462
|
getSmartRedirect: P
|
|
4433
4463
|
};
|
|
4434
4464
|
}
|
|
4435
|
-
function
|
|
4465
|
+
function nn(n, e, t = tt, r = "url") {
|
|
4436
4466
|
if (!e || r !== "url")
|
|
4437
4467
|
return n;
|
|
4438
4468
|
const i = new URL(n, window.location.origin);
|
|
4439
4469
|
return i.searchParams.set(t, e), i.pathname + i.search;
|
|
4440
4470
|
}
|
|
4441
4471
|
export {
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4472
|
+
Ur as AdminZone,
|
|
4473
|
+
tn as ApiMappers,
|
|
4474
|
+
_e as AppApiService,
|
|
4475
|
+
Qr as AppLoader,
|
|
4476
|
+
wr as AppProvider,
|
|
4477
|
+
bt as AuthApiService,
|
|
4478
|
+
kr as AuthProvider,
|
|
4479
|
+
Dr as AuthenticatedZone,
|
|
4480
|
+
Xe as DEFAULT_ZONE_PRESETS,
|
|
4481
|
+
He as DEFAULT_ZONE_ROOTS,
|
|
4482
|
+
_r as FeatureFlag,
|
|
4483
|
+
Et as FeatureFlagApiService,
|
|
4484
|
+
xr as FeatureFlagProvider,
|
|
4485
|
+
Cr as GuestZone,
|
|
4486
|
+
en as HealthApiService,
|
|
4487
|
+
ce as HttpService,
|
|
4488
|
+
Lr as LandingRoute,
|
|
4489
|
+
Vr as LoginForm,
|
|
4490
|
+
jr as MagicLinkForm,
|
|
4491
|
+
Gr as MagicLinkVerify,
|
|
4492
|
+
$r as OpenZone,
|
|
4493
|
+
Jr as PasswordRecoveryForm,
|
|
4494
|
+
Yr as PermissionApiService,
|
|
4495
|
+
Er as Protected,
|
|
4496
|
+
Ir as ProtectedRoute,
|
|
4497
|
+
Fr as PublicZone,
|
|
4498
|
+
Ve as RoleApiService,
|
|
4499
|
+
Pr as RoutingProvider,
|
|
4500
|
+
ne as SessionExpiredError,
|
|
4501
|
+
Le as SessionManager,
|
|
4502
|
+
Wr as SignupForm,
|
|
4503
|
+
Mt as SubscriptionApiService,
|
|
4474
4504
|
zr as SubscriptionGuard,
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4505
|
+
Xr as SubscriptionPlanApiService,
|
|
4506
|
+
Ar as SubscriptionProvider,
|
|
4507
|
+
we as TenantApiService,
|
|
4508
|
+
Hr as TenantAuthenticatedZone,
|
|
4509
|
+
qr as TenantGuestZone,
|
|
4510
|
+
Or as TenantOpenZone,
|
|
4511
|
+
vr as TenantProvider,
|
|
4512
|
+
Mr as TenantRoute,
|
|
4513
|
+
Zr as TenantSelector,
|
|
4514
|
+
Nr as TenantZone,
|
|
4515
|
+
wt as TokenRefreshError,
|
|
4516
|
+
yt as TokenRefreshTimeoutError,
|
|
4517
|
+
vt as UserApiService,
|
|
4518
|
+
oe as UserType,
|
|
4519
|
+
Br as UserZone,
|
|
4520
|
+
de as ZoneRoute,
|
|
4521
|
+
nn as buildRedirectUrl,
|
|
4522
|
+
br as useApi,
|
|
4523
|
+
ke as useApp,
|
|
4524
|
+
Kr as useAppLoaderState,
|
|
4525
|
+
ue as useAuth,
|
|
4526
|
+
It as useFeatureFlags,
|
|
4527
|
+
Rr as useRouting,
|
|
4528
|
+
Nt as useRoutingOptional,
|
|
4529
|
+
Tr as useSettings,
|
|
4530
|
+
Lt as useSubscription,
|
|
4531
|
+
ve as useTenant,
|
|
4532
|
+
Ke as useTenantInfo,
|
|
4533
|
+
he as useTenantOptional,
|
|
4534
|
+
Sr as useTenantSettings,
|
|
4535
|
+
rn as useZoneNavigation
|
|
4506
4536
|
};
|
|
4507
4537
|
//# sourceMappingURL=index.es.js.map
|