@skylabs-digital/react-identity-access 2.22.0 → 2.24.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 +1306 -1316
- 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.map +1 -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 _, jsxs as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { useLocation as
|
|
4
|
-
class
|
|
1
|
+
import { jsx as s, Fragment as _, jsxs as u } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as pe, useMemo as K, useState as k, useCallback as se, useEffect as re, useContext as ae, useRef as Me } from "react";
|
|
3
|
+
import { useLocation as ke, Navigate as Se, useNavigate as ft, useSearchParams as pt } from "react-router-dom";
|
|
4
|
+
class le {
|
|
5
5
|
constructor(e, t = 1e4) {
|
|
6
6
|
this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
|
|
7
7
|
}
|
|
@@ -21,20 +21,20 @@ class ce {
|
|
|
21
21
|
const c = await this.sessionManager.getValidAccessToken();
|
|
22
22
|
f = { ...f, Authorization: `Bearer ${c}` };
|
|
23
23
|
}
|
|
24
|
-
const
|
|
24
|
+
const m = new AbortController(), b = setTimeout(() => m.abort(), a);
|
|
25
25
|
try {
|
|
26
26
|
const c = await fetch(o, {
|
|
27
27
|
method: e,
|
|
28
28
|
headers: f,
|
|
29
29
|
body: r ? JSON.stringify(r) : void 0,
|
|
30
|
-
signal:
|
|
30
|
+
signal: m.signal
|
|
31
31
|
});
|
|
32
|
-
if (clearTimeout(
|
|
32
|
+
if (clearTimeout(b), !c.ok)
|
|
33
33
|
throw new Error(`HTTP ${c.status}: ${c.statusText}`);
|
|
34
|
-
const
|
|
35
|
-
return !
|
|
34
|
+
const L = c.headers.get("content-type");
|
|
35
|
+
return !L || !L.includes("application/json") ? {} : await c.json();
|
|
36
36
|
} catch (c) {
|
|
37
|
-
throw clearTimeout(
|
|
37
|
+
throw clearTimeout(b), c instanceof Error && c.name === "AbortError" ? new Error(`Request timeout after ${a}ms`) : c;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
async get(e, t) {
|
|
@@ -50,7 +50,7 @@ class ce {
|
|
|
50
50
|
return this.executeRequest("DELETE", e, void 0, t);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
class
|
|
53
|
+
class Oe {
|
|
54
54
|
constructor(e, t) {
|
|
55
55
|
this.httpService = e, this.sessionManager = t;
|
|
56
56
|
}
|
|
@@ -109,30 +109,30 @@ class ze {
|
|
|
109
109
|
})).data;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
const
|
|
113
|
-
function
|
|
114
|
-
const t =
|
|
112
|
+
const Le = pe(null);
|
|
113
|
+
function gr({ config: n, children: e }) {
|
|
114
|
+
const t = K(
|
|
115
115
|
() => {
|
|
116
|
-
var p,
|
|
116
|
+
var p, R, I;
|
|
117
117
|
return {
|
|
118
118
|
enabled: ((p = n.cache) == null ? void 0 : p.enabled) ?? !0,
|
|
119
|
-
ttl: ((
|
|
119
|
+
ttl: ((R = n.cache) == null ? void 0 : R.ttl) ?? 3e5,
|
|
120
120
|
// 5 minutes default
|
|
121
|
-
storageKey: ((
|
|
121
|
+
storageKey: ((I = n.cache) == null ? void 0 : I.storageKey) ?? `app_cache_${n.appId}`
|
|
122
122
|
};
|
|
123
123
|
},
|
|
124
124
|
[n.cache, n.appId]
|
|
125
|
-
), [r, i] =
|
|
125
|
+
), [r, i] = k(() => {
|
|
126
126
|
if (!t.enabled) return null;
|
|
127
127
|
try {
|
|
128
128
|
const p = localStorage.getItem(t.storageKey);
|
|
129
129
|
if (!p) return null;
|
|
130
|
-
const
|
|
131
|
-
return Date.now() -
|
|
130
|
+
const R = JSON.parse(p);
|
|
131
|
+
return Date.now() - R.timestamp < t.ttl && R.appId === n.appId ? R.data : (localStorage.removeItem(t.storageKey), null);
|
|
132
132
|
} catch {
|
|
133
133
|
return null;
|
|
134
134
|
}
|
|
135
|
-
}), [o, a] =
|
|
135
|
+
}), [o, a] = k(!r), [f, m] = k(null), b = K(() => {
|
|
136
136
|
const p = () => {
|
|
137
137
|
c();
|
|
138
138
|
};
|
|
@@ -145,16 +145,16 @@ function yr({ config: n, children: e }) {
|
|
|
145
145
|
appError: f,
|
|
146
146
|
retryApp: p
|
|
147
147
|
};
|
|
148
|
-
}, [n, r, o, f]), c =
|
|
148
|
+
}, [n, r, o, f]), c = se(
|
|
149
149
|
async (p = !1) => {
|
|
150
150
|
if (!(!p && t.enabled && r))
|
|
151
151
|
try {
|
|
152
|
-
a(!0),
|
|
153
|
-
const
|
|
154
|
-
if (i(
|
|
152
|
+
a(!0), m(null);
|
|
153
|
+
const R = new le(n.baseUrl), M = await new Oe(R, {}).getPublicAppInfo(n.appId);
|
|
154
|
+
if (i(M), t.enabled)
|
|
155
155
|
try {
|
|
156
156
|
const E = {
|
|
157
|
-
data:
|
|
157
|
+
data: M,
|
|
158
158
|
timestamp: Date.now(),
|
|
159
159
|
appId: n.appId
|
|
160
160
|
};
|
|
@@ -162,49 +162,49 @@ function yr({ config: n, children: e }) {
|
|
|
162
162
|
} catch (E) {
|
|
163
163
|
console.warn("Failed to cache app info:", E);
|
|
164
164
|
}
|
|
165
|
-
} catch (
|
|
166
|
-
const
|
|
167
|
-
|
|
165
|
+
} catch (R) {
|
|
166
|
+
const I = R instanceof Error ? R : new Error("Failed to load app information");
|
|
167
|
+
m(I), i(null);
|
|
168
168
|
} finally {
|
|
169
169
|
a(!1);
|
|
170
170
|
}
|
|
171
171
|
},
|
|
172
172
|
[n.baseUrl, n.appId, t, r]
|
|
173
|
-
),
|
|
173
|
+
), L = se(async () => {
|
|
174
174
|
if (!(!t.enabled || !r))
|
|
175
175
|
try {
|
|
176
176
|
const p = localStorage.getItem(t.storageKey);
|
|
177
177
|
if (!p) return;
|
|
178
|
-
const
|
|
179
|
-
if (Date.now() -
|
|
180
|
-
const
|
|
181
|
-
i(
|
|
182
|
-
const
|
|
183
|
-
data:
|
|
178
|
+
const R = JSON.parse(p);
|
|
179
|
+
if (Date.now() - R.timestamp > t.ttl * 0.5) {
|
|
180
|
+
const M = new le(n.baseUrl), x = await new Oe(M, {}).getPublicAppInfo(n.appId);
|
|
181
|
+
i(x);
|
|
182
|
+
const h = {
|
|
183
|
+
data: x,
|
|
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(h));
|
|
188
188
|
}
|
|
189
189
|
} catch (p) {
|
|
190
190
|
console.warn("Background app refresh failed:", p);
|
|
191
191
|
}
|
|
192
192
|
}, [n, t, r]);
|
|
193
|
-
return
|
|
194
|
-
r ?
|
|
195
|
-
}, []), /* @__PURE__ */ s(
|
|
193
|
+
return re(() => {
|
|
194
|
+
r ? L() : c();
|
|
195
|
+
}, []), /* @__PURE__ */ s(Le.Provider, { value: b, children: e });
|
|
196
196
|
}
|
|
197
|
-
function
|
|
198
|
-
const n =
|
|
197
|
+
function ve() {
|
|
198
|
+
const n = ae(Le);
|
|
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 Qe() {
|
|
204
|
+
return ae(Le);
|
|
205
205
|
}
|
|
206
|
-
const
|
|
207
|
-
class
|
|
206
|
+
const mr = ve;
|
|
207
|
+
class ne extends Error {
|
|
208
208
|
constructor(e, t) {
|
|
209
209
|
const r = {
|
|
210
210
|
token_expired: "Refresh token has expired",
|
|
@@ -214,19 +214,19 @@ class se extends Error {
|
|
|
214
214
|
super(t || r[e]), this.name = "SessionExpiredError", this.reason = e;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
class
|
|
217
|
+
class gt 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 mt 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 ie = class ie {
|
|
230
230
|
constructor(e = {}) {
|
|
231
231
|
this.refreshPromise = null, this.refreshQueue = [], this.proactiveTimerId = null, this.backgroundRetryTimerId = null, this.isDestroyed = !1, this.sessionGeneration = 0, e.tenantSlug !== void 0 ? this.storageKey = e.tenantSlug ? `auth_tokens_${e.tenantSlug}` : "auth_tokens" : this.storageKey = e.storageKey || "auth_tokens", this.autoRefresh = e.autoRefresh ?? !0, this.refreshThreshold = e.refreshThreshold || 3e5, this.onRefreshFailed = e.onRefreshFailed, this.onSessionExpired = e.onSessionExpired, this.baseUrl = e.baseUrl || "", this.proactiveRefreshMargin = e.proactiveRefreshMargin ?? 6e4, this.refreshQueueTimeout = e.refreshQueueTimeout ?? 1e4, this.maxRefreshRetries = e.maxRefreshRetries ?? 3, this.retryBackoffBase = e.retryBackoffBase ?? 1e3, this.tokenStorage = e.tokenStorage || this.createTokenStorage(this.storageKey), this.scheduleProactiveRefresh();
|
|
232
232
|
}
|
|
@@ -236,17 +236,17 @@ const oe = class oe {
|
|
|
236
236
|
* Mutable config (callbacks, baseUrl) is updated on the existing instance.
|
|
237
237
|
*/
|
|
238
238
|
static getInstance(e = {}) {
|
|
239
|
-
const t =
|
|
239
|
+
const t = ie.resolveStorageKey(e), r = ie.instances.get(t);
|
|
240
240
|
if (r)
|
|
241
241
|
return r.updateConfig(e), r;
|
|
242
|
-
const i = new
|
|
243
|
-
return
|
|
242
|
+
const i = new ie(e);
|
|
243
|
+
return ie.instances.set(t, i), i;
|
|
244
244
|
}
|
|
245
245
|
/** Reset all singleton instances. For testing only. */
|
|
246
246
|
static resetAllInstances() {
|
|
247
|
-
for (const e of
|
|
247
|
+
for (const e of ie.instances.values())
|
|
248
248
|
e.destroy();
|
|
249
|
-
|
|
249
|
+
ie.instances.clear();
|
|
250
250
|
}
|
|
251
251
|
static resolveStorageKey(e) {
|
|
252
252
|
return e.storageKey ? e.storageKey : e.tenantSlug !== void 0 && e.tenantSlug ? `auth_tokens_${e.tenantSlug}` : "auth_tokens";
|
|
@@ -296,17 +296,17 @@ const oe = class oe {
|
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
298
|
setTokens(e) {
|
|
299
|
-
const t = e.expiresAt || (e.expiresIn ? Date.now() + e.expiresIn * 1e3 : void 0) ||
|
|
299
|
+
const t = e.expiresAt || (e.expiresIn ? Date.now() + e.expiresIn * 1e3 : void 0) || ie.extractJwtExpiry(e.accessToken), r = {
|
|
300
300
|
...e,
|
|
301
301
|
expiresAt: t
|
|
302
|
-
};
|
|
303
|
-
this.tokenStorage.set(r), this.scheduleProactiveRefresh();
|
|
302
|
+
}, i = this.tokenStorage.get() || {};
|
|
303
|
+
this.tokenStorage.set({ ...i, ...r }), this.scheduleProactiveRefresh();
|
|
304
304
|
}
|
|
305
305
|
getTokens() {
|
|
306
306
|
const { accessToken: e, refreshToken: t, expiresAt: r, expiresIn: i, tokenType: o } = this.tokenStorage.get() || {};
|
|
307
307
|
if (!e)
|
|
308
308
|
return null;
|
|
309
|
-
const a = r ||
|
|
309
|
+
const a = r || ie.extractJwtExpiry(e);
|
|
310
310
|
return {
|
|
311
311
|
accessToken: e,
|
|
312
312
|
refreshToken: t,
|
|
@@ -354,7 +354,7 @@ const oe = class oe {
|
|
|
354
354
|
const t = this.sessionGeneration;
|
|
355
355
|
this.startRefreshAndResolveQueue(e.refreshToken).then(() => {
|
|
356
356
|
}).catch((r) => {
|
|
357
|
-
r instanceof
|
|
357
|
+
r instanceof ne || this.sessionGeneration === t && (console.warn(
|
|
358
358
|
"[SessionManager] Background refresh failed, retrying in 30s:",
|
|
359
359
|
r.message
|
|
360
360
|
), this.backgroundRetryTimerId = setTimeout(() => {
|
|
@@ -386,13 +386,13 @@ const oe = class oe {
|
|
|
386
386
|
async getValidAccessToken() {
|
|
387
387
|
const e = this.getTokens();
|
|
388
388
|
if (!(e != null && e.accessToken)) {
|
|
389
|
-
const t = new
|
|
389
|
+
const t = new ne("token_invalid", "No tokens available");
|
|
390
390
|
throw this.handleSessionExpired(t), t;
|
|
391
391
|
}
|
|
392
392
|
if (!this.shouldRefreshToken(e) && !this.isTokenExpired(e))
|
|
393
393
|
return e.accessToken;
|
|
394
394
|
if (!e.refreshToken) {
|
|
395
|
-
const t = new
|
|
395
|
+
const t = new ne("token_invalid", "No refresh token available");
|
|
396
396
|
throw this.handleSessionExpired(t), t;
|
|
397
397
|
}
|
|
398
398
|
return this.refreshPromise ? this.enqueueForToken() : this.startRefreshAndResolveQueue(e.refreshToken);
|
|
@@ -404,14 +404,14 @@ const oe = class oe {
|
|
|
404
404
|
try {
|
|
405
405
|
return { Authorization: `Bearer ${await this.getValidAccessToken()}` };
|
|
406
406
|
} catch (e) {
|
|
407
|
-
return e instanceof
|
|
407
|
+
return e instanceof ne && this.onRefreshFailed && this.onRefreshFailed(), {};
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
410
|
enqueueForToken() {
|
|
411
411
|
return new Promise((e, t) => {
|
|
412
412
|
const r = setTimeout(() => {
|
|
413
413
|
const i = this.refreshQueue.findIndex((o) => o.timeoutId === r);
|
|
414
|
-
i !== -1 && this.refreshQueue.splice(i, 1), t(new
|
|
414
|
+
i !== -1 && this.refreshQueue.splice(i, 1), t(new gt(this.refreshQueueTimeout));
|
|
415
415
|
}, this.refreshQueueTimeout);
|
|
416
416
|
this.refreshQueue.push({ resolve: e, reject: t, timeoutId: r });
|
|
417
417
|
});
|
|
@@ -424,7 +424,7 @@ const oe = class oe {
|
|
|
424
424
|
return this.resolveQueue(r), r;
|
|
425
425
|
} catch (t) {
|
|
426
426
|
const r = t instanceof Error ? t : new Error("Token refresh failed");
|
|
427
|
-
throw r instanceof
|
|
427
|
+
throw r instanceof ne ? (this.rejectQueue(r), this.handleSessionExpired(r)) : this.rejectQueue(r), r;
|
|
428
428
|
} finally {
|
|
429
429
|
this.refreshPromise = null;
|
|
430
430
|
}
|
|
@@ -447,13 +447,13 @@ const oe = class oe {
|
|
|
447
447
|
const r = this.sessionGeneration;
|
|
448
448
|
for (let i = 0; i <= this.maxRefreshRetries; i++) {
|
|
449
449
|
if (this.sessionGeneration !== r)
|
|
450
|
-
throw new
|
|
450
|
+
throw new ne("token_invalid", "Session cleared during refresh");
|
|
451
451
|
try {
|
|
452
|
-
await this.performTokenRefresh(e);
|
|
452
|
+
await this.performTokenRefresh(e, r);
|
|
453
453
|
return;
|
|
454
454
|
} catch (o) {
|
|
455
455
|
const a = o instanceof Error ? o : new Error(String(o));
|
|
456
|
-
if (a instanceof
|
|
456
|
+
if (a instanceof ne)
|
|
457
457
|
throw a;
|
|
458
458
|
if (t = a, i < this.maxRefreshRetries) {
|
|
459
459
|
const f = this.retryBackoffBase * Math.pow(2, i);
|
|
@@ -461,42 +461,44 @@ const oe = class oe {
|
|
|
461
461
|
}
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
|
-
throw new
|
|
464
|
+
throw new mt(this.maxRefreshRetries + 1, t);
|
|
465
465
|
}
|
|
466
466
|
/**
|
|
467
467
|
* Single refresh attempt with error classification.
|
|
468
468
|
* Throws SessionExpiredError for fatal errors (no retry).
|
|
469
469
|
* Throws generic Error for transient errors (will be retried).
|
|
470
470
|
*/
|
|
471
|
-
async performTokenRefresh(e) {
|
|
471
|
+
async performTokenRefresh(e, t) {
|
|
472
472
|
if (!this.baseUrl)
|
|
473
473
|
throw new Error("Base URL not configured for token refresh");
|
|
474
|
-
const
|
|
475
|
-
let
|
|
474
|
+
const r = `${this.baseUrl}/auth/refresh`;
|
|
475
|
+
let i;
|
|
476
476
|
try {
|
|
477
|
-
|
|
477
|
+
i = await fetch(r, {
|
|
478
478
|
method: "POST",
|
|
479
479
|
headers: { "Content-Type": "application/json" },
|
|
480
480
|
body: JSON.stringify({ refreshToken: e })
|
|
481
481
|
});
|
|
482
|
-
} catch (
|
|
483
|
-
throw
|
|
482
|
+
} catch (a) {
|
|
483
|
+
throw a instanceof Error ? a : new Error("Network error during token refresh");
|
|
484
484
|
}
|
|
485
|
-
if (!
|
|
486
|
-
let
|
|
485
|
+
if (!i.ok) {
|
|
486
|
+
let a = "";
|
|
487
487
|
try {
|
|
488
|
-
const
|
|
489
|
-
|
|
488
|
+
const f = await i.json();
|
|
489
|
+
a = (f.message || f.error || "").toLowerCase();
|
|
490
490
|
} catch {
|
|
491
|
-
|
|
491
|
+
a = i.statusText.toLowerCase();
|
|
492
492
|
}
|
|
493
|
-
throw
|
|
493
|
+
throw i.status === 401 ? a.includes("expired") ? new ne("token_expired") : a.includes("invalid") ? new ne("token_invalid") : new ne("token_invalid", `Unauthorized: ${a}`) : i.status === 400 ? a.includes("inactive") ? new ne("user_inactive") : a.includes("expired") || a.includes("invalid") ? new ne("token_invalid", a) : new Error(`Token refresh failed (400): ${a}`) : new Error(`Token refresh failed: ${i.status} ${a}`);
|
|
494
494
|
}
|
|
495
|
-
|
|
495
|
+
if (this.sessionGeneration !== t)
|
|
496
|
+
throw new ne("token_invalid", "Session cleared during refresh");
|
|
497
|
+
const o = await i.json();
|
|
496
498
|
this.setTokens({
|
|
497
|
-
accessToken:
|
|
498
|
-
refreshToken:
|
|
499
|
-
expiresIn:
|
|
499
|
+
accessToken: o.accessToken,
|
|
500
|
+
refreshToken: o.refreshToken || e,
|
|
501
|
+
expiresIn: o.expiresIn
|
|
500
502
|
});
|
|
501
503
|
}
|
|
502
504
|
// --- Session expiry handler ---
|
|
@@ -518,8 +520,8 @@ const oe = class oe {
|
|
|
518
520
|
}
|
|
519
521
|
// --- Session lifecycle ---
|
|
520
522
|
clearSession() {
|
|
521
|
-
this.sessionGeneration++, this.cancelProactiveTimer(), this.clearTokens()
|
|
522
|
-
const e = new
|
|
523
|
+
this.sessionGeneration++, this.cancelProactiveTimer(), this.clearTokens();
|
|
524
|
+
const e = new ne("token_invalid", "Session cleared");
|
|
523
525
|
this.rejectQueue(e);
|
|
524
526
|
}
|
|
525
527
|
/**
|
|
@@ -527,8 +529,8 @@ const oe = class oe {
|
|
|
527
529
|
* Cancels all timers and rejects pending queue entries.
|
|
528
530
|
*/
|
|
529
531
|
destroy() {
|
|
530
|
-
this.isDestroyed = !0,
|
|
531
|
-
const e = new
|
|
532
|
+
this.isDestroyed = !0, ie.instances.delete(this.storageKey), this.cancelProactiveTimer();
|
|
533
|
+
const e = new ne("token_invalid", "SessionManager destroyed");
|
|
532
534
|
this.rejectQueue(e);
|
|
533
535
|
}
|
|
534
536
|
// --- JWT helpers ---
|
|
@@ -566,9 +568,9 @@ const oe = class oe {
|
|
|
566
568
|
return new Promise((t) => setTimeout(t, e));
|
|
567
569
|
}
|
|
568
570
|
};
|
|
569
|
-
|
|
570
|
-
let
|
|
571
|
-
class
|
|
571
|
+
ie.instances = /* @__PURE__ */ new Map();
|
|
572
|
+
let we = ie;
|
|
573
|
+
class yt {
|
|
572
574
|
constructor(e) {
|
|
573
575
|
this.httpService = e;
|
|
574
576
|
}
|
|
@@ -624,7 +626,7 @@ class bt {
|
|
|
624
626
|
});
|
|
625
627
|
}
|
|
626
628
|
}
|
|
627
|
-
class
|
|
629
|
+
class ze {
|
|
628
630
|
constructor(e, t) {
|
|
629
631
|
this.httpService = e, this.sessionManager = t;
|
|
630
632
|
}
|
|
@@ -700,7 +702,7 @@ class _e {
|
|
|
700
702
|
};
|
|
701
703
|
}
|
|
702
704
|
}
|
|
703
|
-
class
|
|
705
|
+
class wt {
|
|
704
706
|
constructor(e, t) {
|
|
705
707
|
this.httpService = e, this.sessionManager = t;
|
|
706
708
|
}
|
|
@@ -740,7 +742,7 @@ class St {
|
|
|
740
742
|
});
|
|
741
743
|
}
|
|
742
744
|
}
|
|
743
|
-
class
|
|
745
|
+
class be {
|
|
744
746
|
constructor(e, t, r) {
|
|
745
747
|
this.httpService = e, this.appId = t, this.sessionManager = r;
|
|
746
748
|
}
|
|
@@ -818,7 +820,7 @@ class ve {
|
|
|
818
820
|
)).data;
|
|
819
821
|
}
|
|
820
822
|
}
|
|
821
|
-
function
|
|
823
|
+
function bt(n, e) {
|
|
822
824
|
if (n === "localhost" || n.startsWith("127.") || n.startsWith("192.168."))
|
|
823
825
|
return null;
|
|
824
826
|
if (e) {
|
|
@@ -834,26 +836,26 @@ function vt(n, e) {
|
|
|
834
836
|
const r = n.split(".");
|
|
835
837
|
return r.length >= 3 && r[0] !== "www" ? r[0] : null;
|
|
836
838
|
}
|
|
837
|
-
function
|
|
839
|
+
function St(n, e = "tenant", t) {
|
|
838
840
|
const i = new URLSearchParams(n).get(e);
|
|
839
841
|
return i ? (t && t.setItem("tenant", i), i) : t ? t.getItem("tenant") : null;
|
|
840
842
|
}
|
|
841
|
-
function
|
|
843
|
+
function vt(n, e, t) {
|
|
842
844
|
const { tenantMode: r, baseDomain: i, selectorParam: o, fixedTenantSlug: a } = n;
|
|
843
|
-
return r === "fixed" ? a || null : r === "subdomain" ?
|
|
845
|
+
return r === "fixed" ? a || null : r === "subdomain" ? bt(e.hostname, i) : r === "selector" ? St(e.search, o, t) : null;
|
|
844
846
|
}
|
|
845
|
-
function
|
|
847
|
+
function Tt(n, e, t) {
|
|
846
848
|
if (t)
|
|
847
849
|
return `${n}.${t}`;
|
|
848
850
|
const r = e.split(".");
|
|
849
851
|
return r.length === 2 ? `${n}.${e}` : r.length >= 3 ? (r[0] = n, r.join(".")) : null;
|
|
850
852
|
}
|
|
851
|
-
const
|
|
852
|
-
function
|
|
853
|
+
const fe = "_auth";
|
|
854
|
+
function _e(n) {
|
|
853
855
|
const e = JSON.stringify(n);
|
|
854
856
|
return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
855
857
|
}
|
|
856
|
-
function
|
|
858
|
+
function kt(n) {
|
|
857
859
|
try {
|
|
858
860
|
let e = n.replace(/-/g, "+").replace(/_/g, "/");
|
|
859
861
|
for (; e.length % 4; )
|
|
@@ -864,16 +866,16 @@ function At(n) {
|
|
|
864
866
|
return null;
|
|
865
867
|
}
|
|
866
868
|
}
|
|
867
|
-
function
|
|
869
|
+
function xt() {
|
|
868
870
|
if (typeof window > "u")
|
|
869
871
|
return console.log("[CrossDomainAuth] SSR environment, skipping URL token extraction"), null;
|
|
870
|
-
const e = new URLSearchParams(window.location.search).get(
|
|
872
|
+
const e = new URLSearchParams(window.location.search).get(fe);
|
|
871
873
|
if (console.log("[CrossDomainAuth] extractAuthTokensFromUrl called", {
|
|
872
874
|
hasAuthParam: !!e,
|
|
873
875
|
searchParams: window.location.search,
|
|
874
876
|
encodedLength: e == null ? void 0 : e.length
|
|
875
877
|
}), !e) return null;
|
|
876
|
-
const t =
|
|
878
|
+
const t = kt(e);
|
|
877
879
|
return console.log("[CrossDomainAuth] Token decode result:", {
|
|
878
880
|
success: !!t,
|
|
879
881
|
hasAccessToken: !!(t != null && t.accessToken),
|
|
@@ -881,17 +883,17 @@ function Pt() {
|
|
|
881
883
|
expiresIn: t == null ? void 0 : t.expiresIn
|
|
882
884
|
}), t;
|
|
883
885
|
}
|
|
884
|
-
function
|
|
886
|
+
function At() {
|
|
885
887
|
if (typeof window > "u") return;
|
|
886
888
|
const n = new URL(window.location.href);
|
|
887
|
-
n.searchParams.delete(
|
|
889
|
+
n.searchParams.delete(fe), console.log("[CrossDomainAuth] Clearing auth tokens from URL", {
|
|
888
890
|
oldUrl: window.location.href,
|
|
889
891
|
newUrl: n.toString()
|
|
890
892
|
}), window.history.replaceState({}, "", n.toString());
|
|
891
893
|
}
|
|
892
|
-
const
|
|
893
|
-
function
|
|
894
|
-
const { baseUrl: t, appInfo: r, appId: i } =
|
|
894
|
+
const Fe = pe(null);
|
|
895
|
+
function yr({ config: n, children: e }) {
|
|
896
|
+
const { baseUrl: t, appInfo: r, appId: i } = ve(), o = se(() => typeof window > "u" ? null : vt(
|
|
895
897
|
{
|
|
896
898
|
tenantMode: n.tenantMode || "selector",
|
|
897
899
|
baseDomain: n.baseDomain,
|
|
@@ -903,119 +905,119 @@ function br({ config: n, children: e }) {
|
|
|
903
905
|
search: window.location.search
|
|
904
906
|
},
|
|
905
907
|
window.localStorage
|
|
906
|
-
), [n.tenantMode, n.baseDomain, n.selectorParam, n.fixedTenantSlug]), [a, f] =
|
|
908
|
+
), [n.tenantMode, n.baseDomain, n.selectorParam, n.fixedTenantSlug]), [a, f] = k(() => o()), m = K(
|
|
907
909
|
() => {
|
|
908
|
-
var
|
|
910
|
+
var d, U, F;
|
|
909
911
|
return {
|
|
910
|
-
enabled: ((
|
|
911
|
-
ttl: ((
|
|
912
|
+
enabled: ((d = n.cache) == null ? void 0 : d.enabled) ?? !0,
|
|
913
|
+
ttl: ((U = n.cache) == null ? void 0 : U.ttl) ?? 5 * 60 * 1e3,
|
|
912
914
|
// 5 minutes default
|
|
913
|
-
storageKey: ((
|
|
915
|
+
storageKey: ((F = n.cache) == null ? void 0 : F.storageKey) ?? `tenant_cache_${a || "default"}`
|
|
914
916
|
};
|
|
915
917
|
},
|
|
916
918
|
[n.cache, a]
|
|
917
|
-
), [
|
|
919
|
+
), [b, c] = k(() => {
|
|
918
920
|
if (n.initialTenant) return n.initialTenant;
|
|
919
|
-
if (!
|
|
921
|
+
if (!m.enabled || !a) return null;
|
|
920
922
|
try {
|
|
921
|
-
const
|
|
922
|
-
if (!
|
|
923
|
-
const
|
|
924
|
-
return Date.now() -
|
|
923
|
+
const d = localStorage.getItem(m.storageKey);
|
|
924
|
+
if (!d) return null;
|
|
925
|
+
const U = JSON.parse(d);
|
|
926
|
+
return Date.now() - U.timestamp < m.ttl && U.tenantSlug === a ? U.data : (localStorage.removeItem(m.storageKey), null);
|
|
925
927
|
} catch {
|
|
926
928
|
return null;
|
|
927
929
|
}
|
|
928
|
-
}), [
|
|
929
|
-
|
|
930
|
+
}), [L, p] = k(!b && !n.initialTenant), [R, I] = k(null), [M, E] = k(null), [x, h] = k(!1), [A, w] = k(null);
|
|
931
|
+
re(() => {
|
|
930
932
|
if (n.tenantMode === "fixed") return;
|
|
931
|
-
const
|
|
932
|
-
f(
|
|
933
|
+
const d = o();
|
|
934
|
+
f(d);
|
|
933
935
|
}, [o, n.tenantMode]);
|
|
934
|
-
const
|
|
935
|
-
async (
|
|
936
|
-
if (!(!
|
|
936
|
+
const v = (r == null ? void 0 : r.settingsSchema) || null, N = se(
|
|
937
|
+
async (d, U = !1) => {
|
|
938
|
+
if (!(!U && m.enabled && b && b.domain === d))
|
|
937
939
|
try {
|
|
938
|
-
p(!0),
|
|
939
|
-
const
|
|
940
|
-
if (c(
|
|
940
|
+
p(!0), I(null);
|
|
941
|
+
const F = new le(t), g = await new be(F, i).getPublicTenantInfo(d);
|
|
942
|
+
if (c(g), m.enabled)
|
|
941
943
|
try {
|
|
942
|
-
const
|
|
943
|
-
data:
|
|
944
|
+
const S = {
|
|
945
|
+
data: g,
|
|
944
946
|
timestamp: Date.now(),
|
|
945
|
-
tenantSlug:
|
|
947
|
+
tenantSlug: d
|
|
946
948
|
};
|
|
947
|
-
localStorage.setItem(
|
|
948
|
-
} catch (
|
|
949
|
-
console.warn("Failed to cache tenant info:",
|
|
949
|
+
localStorage.setItem(m.storageKey, JSON.stringify(S));
|
|
950
|
+
} catch (S) {
|
|
951
|
+
console.warn("Failed to cache tenant info:", S);
|
|
950
952
|
}
|
|
951
|
-
} catch (
|
|
952
|
-
const
|
|
953
|
-
|
|
953
|
+
} catch (F) {
|
|
954
|
+
const y = F instanceof Error ? F : new Error("Failed to load tenant information");
|
|
955
|
+
I(y), c(null);
|
|
954
956
|
} finally {
|
|
955
957
|
p(!1);
|
|
956
958
|
}
|
|
957
959
|
},
|
|
958
|
-
[t, i,
|
|
959
|
-
),
|
|
960
|
-
if (!(!
|
|
960
|
+
[t, i, m, b]
|
|
961
|
+
), B = se(async () => {
|
|
962
|
+
if (!(!m.enabled || !b || !a))
|
|
961
963
|
try {
|
|
962
|
-
const
|
|
963
|
-
if (!
|
|
964
|
-
const
|
|
965
|
-
if (Date.now() -
|
|
966
|
-
const
|
|
967
|
-
c(
|
|
968
|
-
const
|
|
969
|
-
data:
|
|
964
|
+
const d = localStorage.getItem(m.storageKey);
|
|
965
|
+
if (!d) return;
|
|
966
|
+
const U = JSON.parse(d);
|
|
967
|
+
if (Date.now() - U.timestamp > m.ttl * 0.5) {
|
|
968
|
+
const y = new le(t), S = await new be(y, i).getPublicTenantInfo(a);
|
|
969
|
+
c(S);
|
|
970
|
+
const Q = {
|
|
971
|
+
data: S,
|
|
970
972
|
timestamp: Date.now(),
|
|
971
973
|
tenantSlug: a
|
|
972
974
|
};
|
|
973
|
-
localStorage.setItem(
|
|
975
|
+
localStorage.setItem(m.storageKey, JSON.stringify(Q));
|
|
974
976
|
}
|
|
975
|
-
} catch (
|
|
976
|
-
console.warn("Background tenant refresh failed:",
|
|
977
|
+
} catch (d) {
|
|
978
|
+
console.warn("Background tenant refresh failed:", d);
|
|
977
979
|
}
|
|
978
|
-
}, [t, i,
|
|
979
|
-
if (
|
|
980
|
+
}, [t, i, m, b, a]), l = se(async () => {
|
|
981
|
+
if (b != null && b.id)
|
|
980
982
|
try {
|
|
981
|
-
|
|
982
|
-
const
|
|
983
|
-
E(
|
|
984
|
-
} catch (
|
|
985
|
-
const
|
|
986
|
-
|
|
983
|
+
h(!0), w(null);
|
|
984
|
+
const d = new le(t), F = await new be(d, b.appId).getTenantSettings(b.id);
|
|
985
|
+
E(F);
|
|
986
|
+
} catch (d) {
|
|
987
|
+
const U = d instanceof Error ? d : new Error("Failed to load tenant settings");
|
|
988
|
+
w(U), E(null);
|
|
987
989
|
} finally {
|
|
988
|
-
|
|
990
|
+
h(!1);
|
|
989
991
|
}
|
|
990
|
-
}, [t,
|
|
991
|
-
|
|
992
|
-
}, [
|
|
993
|
-
(
|
|
994
|
-
if (!
|
|
992
|
+
}, [t, b]), H = se(() => {
|
|
993
|
+
l();
|
|
994
|
+
}, [l]), P = se(
|
|
995
|
+
(d) => {
|
|
996
|
+
if (!v)
|
|
995
997
|
return { isValid: !0, errors: [] };
|
|
996
|
-
const
|
|
998
|
+
const U = [];
|
|
997
999
|
try {
|
|
998
|
-
return
|
|
999
|
-
var
|
|
1000
|
-
const
|
|
1001
|
-
if ((
|
|
1002
|
-
|
|
1000
|
+
return v.properties && Object.entries(v.properties).forEach(([F, y]) => {
|
|
1001
|
+
var S;
|
|
1002
|
+
const g = d[F];
|
|
1003
|
+
if ((S = v.required) != null && S.includes(F) && g == null) {
|
|
1004
|
+
U.push(`Field '${F}' is required`);
|
|
1003
1005
|
return;
|
|
1004
1006
|
}
|
|
1005
|
-
if (
|
|
1006
|
-
if (
|
|
1007
|
-
const
|
|
1008
|
-
|
|
1007
|
+
if (g != null) {
|
|
1008
|
+
if (y.type) {
|
|
1009
|
+
const Q = y.type, J = typeof g;
|
|
1010
|
+
Q === "string" && J !== "string" ? U.push(`Field '${F}' must be a string`) : (Q === "number" || Q === "integer") && J !== "number" ? U.push(`Field '${F}' must be a number`) : Q === "boolean" && J !== "boolean" ? U.push(`Field '${F}' must be a boolean`) : Q === "array" && !Array.isArray(g) && U.push(`Field '${F}' must be an array`);
|
|
1009
1011
|
}
|
|
1010
|
-
|
|
1011
|
-
`Field '${
|
|
1012
|
-
),
|
|
1013
|
-
`Field '${
|
|
1014
|
-
),
|
|
1012
|
+
y.minLength !== void 0 && typeof g == "string" && g.length < y.minLength && U.push(
|
|
1013
|
+
`Field '${F}' must be at least ${y.minLength} characters long`
|
|
1014
|
+
), y.maxLength !== void 0 && typeof g == "string" && g.length > y.maxLength && U.push(
|
|
1015
|
+
`Field '${F}' must be no more than ${y.maxLength} characters long`
|
|
1016
|
+
), y.minimum !== void 0 && typeof g == "number" && g < y.minimum && U.push(`Field '${F}' must be at least ${y.minimum}`), y.maximum !== void 0 && typeof g == "number" && g > y.maximum && U.push(`Field '${F}' must be no more than ${y.maximum}`), y.pattern && typeof g == "string" && (new RegExp(y.pattern).test(g) || U.push(`Field '${F}' does not match the required pattern`)), y.enum && !y.enum.includes(g) && U.push(`Field '${F}' must be one of: ${y.enum.join(", ")}`);
|
|
1015
1017
|
}
|
|
1016
1018
|
}), {
|
|
1017
|
-
isValid:
|
|
1018
|
-
errors:
|
|
1019
|
+
isValid: U.length === 0,
|
|
1020
|
+
errors: U
|
|
1019
1021
|
};
|
|
1020
1022
|
} catch {
|
|
1021
1023
|
return {
|
|
@@ -1024,98 +1026,98 @@ function br({ config: n, children: e }) {
|
|
|
1024
1026
|
};
|
|
1025
1027
|
}
|
|
1026
1028
|
},
|
|
1027
|
-
[
|
|
1029
|
+
[v]
|
|
1028
1030
|
);
|
|
1029
|
-
|
|
1030
|
-
!n.initialTenant && a ?
|
|
1031
|
-
}, [n.initialTenant, a,
|
|
1032
|
-
|
|
1033
|
-
}, [
|
|
1034
|
-
const
|
|
1035
|
-
(
|
|
1036
|
-
const { mode:
|
|
1037
|
-
if (
|
|
1031
|
+
re(() => {
|
|
1032
|
+
!n.initialTenant && a ? b ? B() : N(a) : !n.initialTenant && !a && (c(null), I(null), p(!1));
|
|
1033
|
+
}, [n.initialTenant, a, b, N, B]), re(() => {
|
|
1034
|
+
b != null && b.id ? l() : (E(null), w(null), h(!1));
|
|
1035
|
+
}, [b == null ? void 0 : b.id, l]);
|
|
1036
|
+
const D = se(
|
|
1037
|
+
(d, U) => {
|
|
1038
|
+
const { mode: F = "reload", tokens: y, redirectPath: g } = U || {}, S = n.tenantMode || "selector";
|
|
1039
|
+
if (S === "fixed") {
|
|
1038
1040
|
console.warn(
|
|
1039
1041
|
"[TenantProvider] switchTenant is a no-op in fixed mode. Tenant is always:",
|
|
1040
1042
|
n.fixedTenantSlug
|
|
1041
|
-
),
|
|
1043
|
+
), g && (window.location.href = g);
|
|
1042
1044
|
return;
|
|
1043
1045
|
}
|
|
1044
|
-
if (localStorage.setItem("tenant",
|
|
1045
|
-
const
|
|
1046
|
-
|
|
1047
|
-
|
|
1046
|
+
if (localStorage.setItem("tenant", d), S === "subdomain") {
|
|
1047
|
+
const Q = window.location.hostname, J = Tt(
|
|
1048
|
+
d,
|
|
1049
|
+
Q,
|
|
1048
1050
|
n.baseDomain
|
|
1049
1051
|
);
|
|
1050
|
-
if (!
|
|
1052
|
+
if (!J) {
|
|
1051
1053
|
console.warn(
|
|
1052
1054
|
"[TenantProvider] Cannot switch subdomain, invalid hostname:",
|
|
1053
|
-
|
|
1055
|
+
Q
|
|
1054
1056
|
);
|
|
1055
1057
|
return;
|
|
1056
1058
|
}
|
|
1057
|
-
const
|
|
1058
|
-
new URLSearchParams(window.location.search).forEach((
|
|
1059
|
-
|
|
1060
|
-
}),
|
|
1061
|
-
} else if (
|
|
1062
|
-
const
|
|
1063
|
-
if (
|
|
1064
|
-
const
|
|
1065
|
-
window.location.href =
|
|
1059
|
+
const q = g || window.location.pathname, O = new URL(`${window.location.protocol}//${J}${q}`);
|
|
1060
|
+
new URLSearchParams(window.location.search).forEach((T, V) => {
|
|
1061
|
+
V !== fe && O.searchParams.set(V, T);
|
|
1062
|
+
}), y && O.searchParams.set(fe, _e(y)), window.location.href = O.toString();
|
|
1063
|
+
} else if (S === "selector") {
|
|
1064
|
+
const Q = g || window.location.pathname, J = new URLSearchParams(window.location.search);
|
|
1065
|
+
if (J.set(n.selectorParam || "tenant", d), J.delete(fe), y && J.set(fe, _e(y)), F === "reload") {
|
|
1066
|
+
const q = `${Q}?${J.toString()}${window.location.hash}`;
|
|
1067
|
+
window.location.href = q;
|
|
1066
1068
|
} else {
|
|
1067
|
-
const
|
|
1068
|
-
window.history.pushState({}, "",
|
|
1069
|
+
const q = `${Q}?${J.toString()}${window.location.hash}`;
|
|
1070
|
+
window.history.pushState({}, "", q), f(d), N(d);
|
|
1069
1071
|
}
|
|
1070
1072
|
}
|
|
1071
1073
|
},
|
|
1072
|
-
[n.tenantMode, n.selectorParam, n.baseDomain,
|
|
1073
|
-
),
|
|
1074
|
+
[n.tenantMode, n.selectorParam, n.baseDomain, N]
|
|
1075
|
+
), C = K(() => ({
|
|
1074
1076
|
// Tenant info
|
|
1075
|
-
tenant:
|
|
1077
|
+
tenant: b,
|
|
1076
1078
|
tenantSlug: a,
|
|
1077
|
-
isTenantLoading:
|
|
1078
|
-
tenantError:
|
|
1079
|
+
isTenantLoading: L,
|
|
1080
|
+
tenantError: R,
|
|
1079
1081
|
retryTenant: () => {
|
|
1080
|
-
a &&
|
|
1082
|
+
a && N(a);
|
|
1081
1083
|
},
|
|
1082
1084
|
// Settings
|
|
1083
|
-
settings:
|
|
1084
|
-
settingsSchema:
|
|
1085
|
-
isSettingsLoading:
|
|
1086
|
-
settingsError:
|
|
1085
|
+
settings: M,
|
|
1086
|
+
settingsSchema: v,
|
|
1087
|
+
isSettingsLoading: x,
|
|
1088
|
+
settingsError: A,
|
|
1087
1089
|
// Actions
|
|
1088
|
-
refreshSettings:
|
|
1089
|
-
switchTenant:
|
|
1090
|
+
refreshSettings: H,
|
|
1091
|
+
switchTenant: D,
|
|
1090
1092
|
// Validation
|
|
1091
|
-
validateSettings:
|
|
1093
|
+
validateSettings: P
|
|
1092
1094
|
}), [
|
|
1093
|
-
|
|
1095
|
+
b,
|
|
1094
1096
|
a,
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
F,
|
|
1097
|
+
L,
|
|
1098
|
+
R,
|
|
1098
1099
|
M,
|
|
1100
|
+
v,
|
|
1101
|
+
x,
|
|
1099
1102
|
A,
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
l
|
|
1103
|
+
H,
|
|
1104
|
+
D,
|
|
1105
|
+
P
|
|
1104
1106
|
]);
|
|
1105
|
-
return /* @__PURE__ */ s(
|
|
1107
|
+
return /* @__PURE__ */ s(Fe.Provider, { value: C, children: e });
|
|
1106
1108
|
}
|
|
1107
|
-
function
|
|
1108
|
-
const n =
|
|
1109
|
+
function ge() {
|
|
1110
|
+
const n = ae(Fe);
|
|
1109
1111
|
if (!n)
|
|
1110
1112
|
throw new Error("useTenant must be used within a TenantProvider");
|
|
1111
1113
|
return n;
|
|
1112
1114
|
}
|
|
1113
|
-
function
|
|
1114
|
-
return
|
|
1115
|
+
function xe() {
|
|
1116
|
+
return ae(Fe);
|
|
1115
1117
|
}
|
|
1116
|
-
const
|
|
1117
|
-
function
|
|
1118
|
-
const { settings: n, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: i } =
|
|
1118
|
+
const wr = ge;
|
|
1119
|
+
function br() {
|
|
1120
|
+
const { settings: n, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: i } = ge();
|
|
1119
1121
|
return {
|
|
1120
1122
|
settings: n,
|
|
1121
1123
|
settingsSchema: e,
|
|
@@ -1124,8 +1126,8 @@ function vr() {
|
|
|
1124
1126
|
validateSettings: i
|
|
1125
1127
|
};
|
|
1126
1128
|
}
|
|
1127
|
-
function
|
|
1128
|
-
const { tenant: n, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: i } =
|
|
1129
|
+
function me() {
|
|
1130
|
+
const { tenant: n, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: i } = ge();
|
|
1129
1131
|
return {
|
|
1130
1132
|
tenant: n,
|
|
1131
1133
|
tenantSlug: e,
|
|
@@ -1134,318 +1136,316 @@ function we() {
|
|
|
1134
1136
|
retry: i
|
|
1135
1137
|
};
|
|
1136
1138
|
}
|
|
1137
|
-
const Ne =
|
|
1138
|
-
function
|
|
1139
|
-
const { appId: t, baseUrl: r } =
|
|
1139
|
+
const Ne = pe(null);
|
|
1140
|
+
function Sr({ config: n = {}, children: e }) {
|
|
1141
|
+
const { appId: t, baseUrl: r } = ve(), { tenant: i, tenantSlug: o, switchTenant: a } = ge(), [f, m] = k(n.initialRoles || []), [b, c] = k(!n.initialRoles), [L, p] = k(null), [R, I] = k(!1), [M, E] = k(null), [x, h] = k(() => {
|
|
1140
1142
|
try {
|
|
1141
|
-
const
|
|
1142
|
-
return
|
|
1143
|
+
const T = localStorage.getItem("userTenants");
|
|
1144
|
+
return T ? JSON.parse(T) : [];
|
|
1143
1145
|
} catch {
|
|
1144
1146
|
return [];
|
|
1145
1147
|
}
|
|
1146
|
-
}), [
|
|
1147
|
-
|
|
1148
|
+
}), [A, w] = k(!1), v = Me({ done: !1, urlTokens: null });
|
|
1149
|
+
v.current.done || (v.current.done = !0, v.current.urlTokens = xt(), v.current.urlTokens && console.log(
|
|
1148
1150
|
"[AuthProvider] SYNC: URL tokens found, will block isAuthReady until user loaded"
|
|
1149
1151
|
));
|
|
1150
|
-
const [
|
|
1151
|
-
const
|
|
1152
|
-
return console.log("[AuthProvider] SYNC: isLoadingAfterUrlTokens initial:",
|
|
1153
|
-
}), l =
|
|
1154
|
-
const
|
|
1152
|
+
const [N, B] = k(() => {
|
|
1153
|
+
const T = v.current.urlTokens !== null;
|
|
1154
|
+
return console.log("[AuthProvider] SYNC: isLoadingAfterUrlTokens initial:", T), T;
|
|
1155
|
+
}), l = K(() => {
|
|
1156
|
+
const T = we.getInstance({
|
|
1155
1157
|
tenantSlug: o,
|
|
1156
1158
|
baseUrl: r,
|
|
1157
1159
|
refreshQueueTimeout: n.refreshQueueTimeout,
|
|
1158
1160
|
proactiveRefreshMargin: n.proactiveRefreshMargin,
|
|
1159
|
-
onSessionExpired: (
|
|
1160
|
-
p(null), E(null),
|
|
1161
|
+
onSessionExpired: (V) => {
|
|
1162
|
+
p(null), E(null), h([]), w(!1);
|
|
1161
1163
|
try {
|
|
1162
1164
|
localStorage.removeItem("userTenants");
|
|
1163
1165
|
} catch {
|
|
1164
1166
|
}
|
|
1165
|
-
n.onSessionExpired ? n.onSessionExpired(
|
|
1167
|
+
n.onSessionExpired ? n.onSessionExpired(V) : n.onRefreshFailed && n.onRefreshFailed();
|
|
1166
1168
|
}
|
|
1167
1169
|
});
|
|
1168
|
-
return
|
|
1169
|
-
accessToken:
|
|
1170
|
-
refreshToken:
|
|
1171
|
-
expiresIn:
|
|
1172
|
-
}), console.log("[AuthProvider] SYNC: Session valid:",
|
|
1173
|
-
}, [o, r, n.refreshQueueTimeout, n.proactiveRefreshMargin]), [
|
|
1174
|
-
if (
|
|
1175
|
-
const
|
|
1176
|
-
return
|
|
1177
|
-
}),
|
|
1178
|
-
const
|
|
1179
|
-
return
|
|
1180
|
-
}, [r, l]),
|
|
1181
|
-
|
|
1170
|
+
return v.current.urlTokens && (console.log("[AuthProvider] SYNC: Saving URL tokens to session manager"), T.setTokens({
|
|
1171
|
+
accessToken: v.current.urlTokens.accessToken,
|
|
1172
|
+
refreshToken: v.current.urlTokens.refreshToken,
|
|
1173
|
+
expiresIn: v.current.urlTokens.expiresIn
|
|
1174
|
+
}), console.log("[AuthProvider] SYNC: Session valid:", T.hasValidSession())), T;
|
|
1175
|
+
}, [o, r, n.refreshQueueTimeout, n.proactiveRefreshMargin]), [H, P] = k(() => {
|
|
1176
|
+
if (v.current.urlTokens) return !1;
|
|
1177
|
+
const T = l.getTokens();
|
|
1178
|
+
return T ? l.hasValidSession() || !!T.refreshToken : !1;
|
|
1179
|
+
}), D = v.current.done && !N && !H, C = K(() => {
|
|
1180
|
+
const T = new le(r);
|
|
1181
|
+
return T.setSessionManager(l), T;
|
|
1182
|
+
}, [r, l]), d = K(() => new yt(new le(r)), [r]), U = K(() => new wt(C, l), [C, l]), F = K(() => new ze(new le(r)), [r]), y = K(() => L || l.getUser(), [L, l]), g = K(() => y != null && y.roleId && f.find((T) => T.id === y.roleId) || null, [y, f]), S = K(() => (g == null ? void 0 : g.permissions) || [], [g]), Q = K(() => l.hasValidSession() && L !== null, [l, L]), J = Me(async () => {
|
|
1183
|
+
}), q = K(() => {
|
|
1184
|
+
const T = async ($ = !1) => {
|
|
1182
1185
|
try {
|
|
1183
|
-
if (!l.hasValidSession())
|
|
1184
|
-
return;
|
|
1185
|
-
const z = Date.now();
|
|
1186
|
-
if (!H && z - A < q && I)
|
|
1186
|
+
if (!l.hasValidSession() || !$ && L)
|
|
1187
1187
|
return;
|
|
1188
|
-
const
|
|
1189
|
-
if (!
|
|
1188
|
+
const z = l.getUserId();
|
|
1189
|
+
if (!z) {
|
|
1190
1190
|
console.warn("[AuthProvider] No userId available in token or storage");
|
|
1191
1191
|
return;
|
|
1192
1192
|
}
|
|
1193
|
-
|
|
1194
|
-
const
|
|
1195
|
-
p(
|
|
1193
|
+
I(!0), E(null);
|
|
1194
|
+
const Z = await U.getUserById(z);
|
|
1195
|
+
p(Z), l.setUser(Z);
|
|
1196
1196
|
} catch (z) {
|
|
1197
|
-
const
|
|
1198
|
-
E(
|
|
1197
|
+
const Z = z instanceof Error ? z : new Error("Failed to load user data");
|
|
1198
|
+
E(Z), console.error("[AuthProvider] Failed to load user data:", Z);
|
|
1199
1199
|
} finally {
|
|
1200
|
-
|
|
1200
|
+
I(!1);
|
|
1201
1201
|
}
|
|
1202
|
-
},
|
|
1203
|
-
await
|
|
1204
|
-
},
|
|
1205
|
-
var
|
|
1206
|
-
const { username: z, password:
|
|
1207
|
-
let
|
|
1208
|
-
|
|
1209
|
-
const
|
|
1202
|
+
}, V = async () => {
|
|
1203
|
+
await T();
|
|
1204
|
+
}, de = async ($) => {
|
|
1205
|
+
var Be;
|
|
1206
|
+
const { username: z, password: Z, tenantSlug: W, redirectPath: Y } = $;
|
|
1207
|
+
let X = i == null ? void 0 : i.id, ee = o, te = l;
|
|
1208
|
+
W && (X = (await new be(C, t).getPublicTenantInfo(W)).id, ee = W);
|
|
1209
|
+
const G = await d.login({
|
|
1210
1210
|
username: z,
|
|
1211
|
-
password:
|
|
1211
|
+
password: Z,
|
|
1212
1212
|
appId: t,
|
|
1213
|
-
tenantId:
|
|
1214
|
-
}),
|
|
1215
|
-
if (
|
|
1216
|
-
tenantSlug:
|
|
1213
|
+
tenantId: X
|
|
1214
|
+
}), ye = W && W !== o;
|
|
1215
|
+
if (ye && (te = new we({
|
|
1216
|
+
tenantSlug: ee,
|
|
1217
1217
|
baseUrl: r
|
|
1218
|
-
})),
|
|
1219
|
-
accessToken:
|
|
1220
|
-
refreshToken:
|
|
1221
|
-
expiresIn:
|
|
1222
|
-
}),
|
|
1223
|
-
|
|
1218
|
+
})), te.setTokens({
|
|
1219
|
+
accessToken: G.accessToken,
|
|
1220
|
+
refreshToken: G.refreshToken,
|
|
1221
|
+
expiresIn: G.expiresIn
|
|
1222
|
+
}), G.user) {
|
|
1223
|
+
te.setUser(G.user), p(G.user);
|
|
1224
1224
|
try {
|
|
1225
|
-
await
|
|
1226
|
-
} catch (
|
|
1227
|
-
console.warn("Failed to load complete user data after login:",
|
|
1225
|
+
await T();
|
|
1226
|
+
} catch (Te) {
|
|
1227
|
+
console.warn("Failed to load complete user data after login:", Te);
|
|
1228
1228
|
}
|
|
1229
1229
|
}
|
|
1230
|
-
if (
|
|
1231
|
-
|
|
1230
|
+
if (G.tenants && G.tenants.length > 0) {
|
|
1231
|
+
h(G.tenants);
|
|
1232
1232
|
try {
|
|
1233
|
-
localStorage.setItem("userTenants", JSON.stringify(
|
|
1233
|
+
localStorage.setItem("userTenants", JSON.stringify(G.tenants));
|
|
1234
1234
|
} catch {
|
|
1235
1235
|
}
|
|
1236
1236
|
}
|
|
1237
|
-
const
|
|
1238
|
-
|
|
1239
|
-
const
|
|
1240
|
-
accessToken:
|
|
1241
|
-
refreshToken:
|
|
1242
|
-
expiresIn:
|
|
1237
|
+
const Pe = ((Be = G.user) == null ? void 0 : Be.tenantId) !== null;
|
|
1238
|
+
w(Pe);
|
|
1239
|
+
const Re = {
|
|
1240
|
+
accessToken: G.accessToken,
|
|
1241
|
+
refreshToken: G.refreshToken,
|
|
1242
|
+
expiresIn: G.expiresIn
|
|
1243
1243
|
};
|
|
1244
|
-
if (
|
|
1245
|
-
return a(
|
|
1246
|
-
if (
|
|
1247
|
-
return a(
|
|
1248
|
-
if (!
|
|
1249
|
-
const
|
|
1250
|
-
if (
|
|
1251
|
-
const
|
|
1252
|
-
return a(
|
|
1253
|
-
} else
|
|
1244
|
+
if (ye && ee)
|
|
1245
|
+
return a(ee, { tokens: Re, redirectPath: Y }), G;
|
|
1246
|
+
if (Y && Y !== window.location.pathname)
|
|
1247
|
+
return a(ee || o || "", { tokens: Re, redirectPath: Y }), G;
|
|
1248
|
+
if (!Pe && G.tenants && G.tenants.length > 0) {
|
|
1249
|
+
const Te = $.autoSwitch !== !1 && n.autoSwitchSingleTenant !== !1;
|
|
1250
|
+
if (G.tenants.length === 1 && Te) {
|
|
1251
|
+
const qe = G.tenants[0];
|
|
1252
|
+
return a(qe.subdomain, { tokens: Re, redirectPath: Y }), G;
|
|
1253
|
+
} else G.tenants.length > 1 && n.onTenantSelectionRequired && n.onTenantSelectionRequired(G.tenants);
|
|
1254
1254
|
}
|
|
1255
|
-
return
|
|
1256
|
-
},
|
|
1257
|
-
const { email: z, phoneNumber:
|
|
1258
|
-
if (!z && !
|
|
1255
|
+
return G;
|
|
1256
|
+
}, he = async ($) => {
|
|
1257
|
+
const { email: z, phoneNumber: Z, name: W, password: Y, lastName: X, tenantId: ee } = $;
|
|
1258
|
+
if (!z && !Z)
|
|
1259
1259
|
throw new Error("Either email or phoneNumber is required");
|
|
1260
|
-
if (!
|
|
1260
|
+
if (!W || !Y)
|
|
1261
1261
|
throw new Error("Name and password are required");
|
|
1262
|
-
const
|
|
1263
|
-
return await
|
|
1262
|
+
const te = ee ?? (i == null ? void 0 : i.id);
|
|
1263
|
+
return await d.signup({
|
|
1264
1264
|
email: z,
|
|
1265
|
-
phoneNumber:
|
|
1266
|
-
name:
|
|
1267
|
-
password:
|
|
1268
|
-
tenantId:
|
|
1269
|
-
lastName:
|
|
1265
|
+
phoneNumber: Z,
|
|
1266
|
+
name: W,
|
|
1267
|
+
password: Y,
|
|
1268
|
+
tenantId: te,
|
|
1269
|
+
lastName: X,
|
|
1270
1270
|
appId: t
|
|
1271
1271
|
});
|
|
1272
|
-
},
|
|
1273
|
-
const { email: z, phoneNumber:
|
|
1274
|
-
if (!z && !
|
|
1272
|
+
}, et = async ($) => {
|
|
1273
|
+
const { email: z, phoneNumber: Z, name: W, password: Y, tenantName: X, lastName: ee } = $;
|
|
1274
|
+
if (!z && !Z)
|
|
1275
1275
|
throw new Error("Either email or phoneNumber is required");
|
|
1276
|
-
if (!
|
|
1276
|
+
if (!W || !Y || !X)
|
|
1277
1277
|
throw new Error("Name, password, and tenantName are required");
|
|
1278
|
-
return await
|
|
1278
|
+
return await d.signupTenantAdmin({
|
|
1279
1279
|
email: z,
|
|
1280
|
-
phoneNumber:
|
|
1281
|
-
name:
|
|
1282
|
-
password:
|
|
1283
|
-
tenantName:
|
|
1280
|
+
phoneNumber: Z,
|
|
1281
|
+
name: W,
|
|
1282
|
+
password: Y,
|
|
1283
|
+
tenantName: X,
|
|
1284
1284
|
appId: t,
|
|
1285
|
-
lastName:
|
|
1285
|
+
lastName: ee
|
|
1286
1286
|
});
|
|
1287
|
-
},
|
|
1288
|
-
const { currentPassword: z, newPassword:
|
|
1289
|
-
await
|
|
1290
|
-
},
|
|
1291
|
-
const { email: z, tenantId:
|
|
1292
|
-
if (!
|
|
1287
|
+
}, tt = async ($) => {
|
|
1288
|
+
const { currentPassword: z, newPassword: Z } = $, W = await l.getAuthHeaders();
|
|
1289
|
+
await d.changePassword({ currentPassword: z, newPassword: Z }, W);
|
|
1290
|
+
}, rt = async ($) => {
|
|
1291
|
+
const { email: z, tenantId: Z } = $, W = Z ?? (i == null ? void 0 : i.id);
|
|
1292
|
+
if (!W)
|
|
1293
1293
|
throw new Error("tenantId is required for password reset");
|
|
1294
|
-
await
|
|
1295
|
-
},
|
|
1296
|
-
const { token: z, newPassword:
|
|
1297
|
-
await
|
|
1298
|
-
},
|
|
1299
|
-
const { email: z, frontendUrl:
|
|
1300
|
-
if (!
|
|
1294
|
+
await d.requestPasswordReset({ email: z, tenantId: W });
|
|
1295
|
+
}, nt = async ($) => {
|
|
1296
|
+
const { token: z, newPassword: Z } = $;
|
|
1297
|
+
await d.confirmPasswordReset({ token: z, newPassword: Z });
|
|
1298
|
+
}, st = async ($) => {
|
|
1299
|
+
const { email: z, frontendUrl: Z, name: W, lastName: Y, tenantId: X } = $, ee = X ?? (i == null ? void 0 : i.id);
|
|
1300
|
+
if (!ee)
|
|
1301
1301
|
throw new Error("tenantId is required for magic link authentication");
|
|
1302
|
-
return await
|
|
1302
|
+
return await d.sendMagicLink({
|
|
1303
1303
|
email: z,
|
|
1304
|
-
tenantId:
|
|
1305
|
-
frontendUrl:
|
|
1306
|
-
name:
|
|
1307
|
-
lastName:
|
|
1304
|
+
tenantId: ee,
|
|
1305
|
+
frontendUrl: Z,
|
|
1306
|
+
name: W,
|
|
1307
|
+
lastName: Y,
|
|
1308
1308
|
appId: t
|
|
1309
1309
|
});
|
|
1310
|
-
},
|
|
1311
|
-
const { token: z, email:
|
|
1312
|
-
let
|
|
1313
|
-
|
|
1314
|
-
const
|
|
1310
|
+
}, it = async ($) => {
|
|
1311
|
+
const { token: z, email: Z, tenantSlug: W } = $;
|
|
1312
|
+
let Y = i == null ? void 0 : i.id, X = o, ee = l;
|
|
1313
|
+
W && (Y = (await new be(C, t).getPublicTenantInfo(W)).id, X = W);
|
|
1314
|
+
const te = await d.verifyMagicLink({
|
|
1315
1315
|
token: z,
|
|
1316
|
-
email:
|
|
1316
|
+
email: Z,
|
|
1317
1317
|
appId: t,
|
|
1318
|
-
tenantId:
|
|
1319
|
-
}),
|
|
1320
|
-
if (
|
|
1321
|
-
tenantSlug:
|
|
1318
|
+
tenantId: Y
|
|
1319
|
+
}), G = W && W !== o;
|
|
1320
|
+
if (G && (ee = new we({
|
|
1321
|
+
tenantSlug: X,
|
|
1322
1322
|
baseUrl: r
|
|
1323
|
-
})),
|
|
1324
|
-
accessToken:
|
|
1325
|
-
refreshToken:
|
|
1326
|
-
expiresIn:
|
|
1327
|
-
}),
|
|
1328
|
-
|
|
1323
|
+
})), ee.setTokens({
|
|
1324
|
+
accessToken: te.accessToken,
|
|
1325
|
+
refreshToken: te.refreshToken,
|
|
1326
|
+
expiresIn: te.expiresIn
|
|
1327
|
+
}), te.user) {
|
|
1328
|
+
ee.setUser(te.user), p(te.user);
|
|
1329
1329
|
try {
|
|
1330
|
-
await
|
|
1331
|
-
} catch (
|
|
1332
|
-
console.warn("Failed to load complete user data after magic link login:",
|
|
1330
|
+
await T();
|
|
1331
|
+
} catch (ye) {
|
|
1332
|
+
console.warn("Failed to load complete user data after magic link login:", ye);
|
|
1333
1333
|
}
|
|
1334
1334
|
}
|
|
1335
|
-
return
|
|
1335
|
+
return G && X && X !== o && a(X, {
|
|
1336
1336
|
tokens: {
|
|
1337
|
-
accessToken:
|
|
1338
|
-
refreshToken:
|
|
1339
|
-
expiresIn:
|
|
1337
|
+
accessToken: te.accessToken,
|
|
1338
|
+
refreshToken: te.refreshToken,
|
|
1339
|
+
expiresIn: te.expiresIn
|
|
1340
1340
|
}
|
|
1341
|
-
}),
|
|
1342
|
-
},
|
|
1343
|
-
const
|
|
1344
|
-
if (!(
|
|
1341
|
+
}), te;
|
|
1342
|
+
}, ot = async () => {
|
|
1343
|
+
const $ = l.getTokens();
|
|
1344
|
+
if (!($ != null && $.refreshToken))
|
|
1345
1345
|
throw new Error("No refresh token available");
|
|
1346
|
-
const z = await
|
|
1347
|
-
refreshToken:
|
|
1346
|
+
const z = await d.refreshToken({
|
|
1347
|
+
refreshToken: $.refreshToken
|
|
1348
1348
|
});
|
|
1349
1349
|
l.setTokens({
|
|
1350
1350
|
accessToken: z.accessToken,
|
|
1351
|
-
refreshToken: z.refreshToken ||
|
|
1351
|
+
refreshToken: z.refreshToken || $.refreshToken,
|
|
1352
1352
|
expiresIn: z.expiresIn
|
|
1353
1353
|
});
|
|
1354
|
-
},
|
|
1355
|
-
l.clearSession(), p(null), E(null),
|
|
1354
|
+
}, at = () => {
|
|
1355
|
+
l.clearSession(), p(null), E(null), h([]), w(!1);
|
|
1356
1356
|
try {
|
|
1357
1357
|
localStorage.removeItem("userTenants");
|
|
1358
1358
|
} catch {
|
|
1359
1359
|
}
|
|
1360
|
-
},
|
|
1361
|
-
l.setTokens(
|
|
1362
|
-
},
|
|
1360
|
+
}, lt = ($) => {
|
|
1361
|
+
l.setTokens($);
|
|
1362
|
+
}, ct = () => l.hasValidSession(), dt = () => {
|
|
1363
1363
|
l.clearSession(), p(null), E(null);
|
|
1364
|
-
},
|
|
1364
|
+
}, ut = async () => {
|
|
1365
1365
|
if (t)
|
|
1366
1366
|
try {
|
|
1367
1367
|
c(!0);
|
|
1368
|
-
const { roles:
|
|
1369
|
-
|
|
1370
|
-
} catch (
|
|
1371
|
-
console.error("Failed to fetch roles:",
|
|
1368
|
+
const { roles: $ } = await F.getRolesByApp(t);
|
|
1369
|
+
m($);
|
|
1370
|
+
} catch ($) {
|
|
1371
|
+
console.error("Failed to fetch roles:", $);
|
|
1372
1372
|
} finally {
|
|
1373
1373
|
c(!1);
|
|
1374
1374
|
}
|
|
1375
|
-
},
|
|
1376
|
-
await
|
|
1377
|
-
},
|
|
1378
|
-
if (!
|
|
1375
|
+
}, ht = async () => {
|
|
1376
|
+
await ut();
|
|
1377
|
+
}, Ae = ($) => {
|
|
1378
|
+
if (!S || S.length === 0)
|
|
1379
1379
|
return !1;
|
|
1380
|
-
if (typeof
|
|
1381
|
-
return
|
|
1382
|
-
const z = `${
|
|
1383
|
-
return
|
|
1380
|
+
if (typeof $ == "string")
|
|
1381
|
+
return S.includes($);
|
|
1382
|
+
const z = `${$.resource}.${$.action}`;
|
|
1383
|
+
return S.includes(z);
|
|
1384
1384
|
};
|
|
1385
1385
|
return {
|
|
1386
1386
|
// RFC-003: Authentication state
|
|
1387
|
-
isAuthenticated:
|
|
1387
|
+
isAuthenticated: Q,
|
|
1388
1388
|
sessionManager: l,
|
|
1389
1389
|
authenticatedHttpService: C,
|
|
1390
|
-
login:
|
|
1391
|
-
signup:
|
|
1392
|
-
signupTenantAdmin:
|
|
1393
|
-
sendMagicLink:
|
|
1394
|
-
verifyMagicLink:
|
|
1395
|
-
changePassword:
|
|
1396
|
-
requestPasswordReset:
|
|
1397
|
-
confirmPasswordReset:
|
|
1398
|
-
refreshToken:
|
|
1399
|
-
logout:
|
|
1400
|
-
setTokens:
|
|
1401
|
-
hasValidSession:
|
|
1402
|
-
clearSession:
|
|
1403
|
-
currentUser:
|
|
1404
|
-
isUserLoading:
|
|
1405
|
-
userError:
|
|
1406
|
-
loadUserData:
|
|
1407
|
-
refreshUser:
|
|
1408
|
-
isAuthInitializing: !
|
|
1409
|
-
isAuthReady:
|
|
1410
|
-
userRole:
|
|
1411
|
-
userPermissions:
|
|
1390
|
+
login: de,
|
|
1391
|
+
signup: he,
|
|
1392
|
+
signupTenantAdmin: et,
|
|
1393
|
+
sendMagicLink: st,
|
|
1394
|
+
verifyMagicLink: it,
|
|
1395
|
+
changePassword: tt,
|
|
1396
|
+
requestPasswordReset: rt,
|
|
1397
|
+
confirmPasswordReset: nt,
|
|
1398
|
+
refreshToken: ot,
|
|
1399
|
+
logout: at,
|
|
1400
|
+
setTokens: lt,
|
|
1401
|
+
hasValidSession: ct,
|
|
1402
|
+
clearSession: dt,
|
|
1403
|
+
currentUser: L,
|
|
1404
|
+
isUserLoading: R,
|
|
1405
|
+
userError: M,
|
|
1406
|
+
loadUserData: T,
|
|
1407
|
+
refreshUser: V,
|
|
1408
|
+
isAuthInitializing: !D,
|
|
1409
|
+
isAuthReady: D,
|
|
1410
|
+
userRole: g,
|
|
1411
|
+
userPermissions: S,
|
|
1412
1412
|
availableRoles: f,
|
|
1413
|
-
rolesLoading:
|
|
1414
|
-
hasPermission:
|
|
1415
|
-
hasAnyPermission: (
|
|
1416
|
-
hasAllPermissions: (
|
|
1417
|
-
getUserPermissionStrings: () =>
|
|
1418
|
-
refreshRoles:
|
|
1413
|
+
rolesLoading: b,
|
|
1414
|
+
hasPermission: Ae,
|
|
1415
|
+
hasAnyPermission: ($) => $.some((z) => Ae(z)),
|
|
1416
|
+
hasAllPermissions: ($) => $.every((z) => Ae(z)),
|
|
1417
|
+
getUserPermissionStrings: () => S || [],
|
|
1418
|
+
refreshRoles: ht,
|
|
1419
1419
|
// RFC-004: Multi-tenant user membership
|
|
1420
|
-
userTenants:
|
|
1421
|
-
hasTenantContext:
|
|
1422
|
-
switchToTenant: async (
|
|
1423
|
-
const { redirectPath:
|
|
1424
|
-
if (!(
|
|
1420
|
+
userTenants: x,
|
|
1421
|
+
hasTenantContext: A,
|
|
1422
|
+
switchToTenant: async ($, z) => {
|
|
1423
|
+
const { redirectPath: Z } = z || {}, W = l.getTokens();
|
|
1424
|
+
if (!(W != null && W.refreshToken))
|
|
1425
1425
|
throw new Error("No refresh token available for tenant switch");
|
|
1426
|
-
const
|
|
1427
|
-
refreshToken:
|
|
1428
|
-
tenantId:
|
|
1426
|
+
const Y = await d.switchTenant({
|
|
1427
|
+
refreshToken: W.refreshToken,
|
|
1428
|
+
tenantId: $
|
|
1429
1429
|
});
|
|
1430
1430
|
l.setTokens({
|
|
1431
|
-
accessToken:
|
|
1432
|
-
refreshToken:
|
|
1431
|
+
accessToken: Y.accessToken,
|
|
1432
|
+
refreshToken: W.refreshToken,
|
|
1433
1433
|
// Keep the same refresh token
|
|
1434
|
-
expiresIn:
|
|
1435
|
-
}), p(
|
|
1436
|
-
const
|
|
1437
|
-
|
|
1434
|
+
expiresIn: Y.expiresIn
|
|
1435
|
+
}), p(Y.user), l.setUser(Y.user), w(!0);
|
|
1436
|
+
const X = x.find((ee) => ee.id === $);
|
|
1437
|
+
X && a(X.subdomain, {
|
|
1438
1438
|
tokens: {
|
|
1439
|
-
accessToken:
|
|
1440
|
-
refreshToken:
|
|
1441
|
-
expiresIn:
|
|
1439
|
+
accessToken: Y.accessToken,
|
|
1440
|
+
refreshToken: W.refreshToken,
|
|
1441
|
+
expiresIn: Y.expiresIn
|
|
1442
1442
|
},
|
|
1443
|
-
redirectPath:
|
|
1443
|
+
redirectPath: Z
|
|
1444
1444
|
});
|
|
1445
1445
|
},
|
|
1446
1446
|
refreshUserTenants: async () => {
|
|
1447
|
-
const
|
|
1448
|
-
|
|
1447
|
+
const $ = await l.getAuthHeaders(), z = await d.getUserTenants($);
|
|
1448
|
+
h(z);
|
|
1449
1449
|
try {
|
|
1450
1450
|
localStorage.setItem("userTenants", JSON.stringify(z));
|
|
1451
1451
|
} catch {
|
|
@@ -1454,83 +1454,73 @@ function Tr({ config: n = {}, children: e }) {
|
|
|
1454
1454
|
}
|
|
1455
1455
|
};
|
|
1456
1456
|
}, [
|
|
1457
|
-
|
|
1457
|
+
Q,
|
|
1458
1458
|
l,
|
|
1459
1459
|
C,
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1460
|
+
d,
|
|
1461
|
+
U,
|
|
1462
|
+
F,
|
|
1463
1463
|
t,
|
|
1464
1464
|
i,
|
|
1465
1465
|
o,
|
|
1466
1466
|
a,
|
|
1467
1467
|
f,
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
F,
|
|
1471
|
-
k,
|
|
1468
|
+
L,
|
|
1469
|
+
R,
|
|
1472
1470
|
M,
|
|
1473
|
-
|
|
1474
|
-
G,
|
|
1475
|
-
Q,
|
|
1471
|
+
x,
|
|
1476
1472
|
A,
|
|
1477
|
-
|
|
1473
|
+
D,
|
|
1474
|
+
g,
|
|
1475
|
+
S
|
|
1478
1476
|
]);
|
|
1479
|
-
|
|
1477
|
+
J.current = q.loadUserData, re(() => {
|
|
1480
1478
|
!n.initialRoles && t && (async () => {
|
|
1481
1479
|
try {
|
|
1482
1480
|
c(!0);
|
|
1483
|
-
const
|
|
1484
|
-
|
|
1485
|
-
} catch (
|
|
1486
|
-
console.error("Failed to fetch roles:",
|
|
1481
|
+
const V = new le(r), de = new ze(V), { roles: he } = await de.getRolesByApp(t);
|
|
1482
|
+
m(he);
|
|
1483
|
+
} catch (V) {
|
|
1484
|
+
console.error("Failed to fetch roles:", V);
|
|
1487
1485
|
} finally {
|
|
1488
1486
|
c(!1);
|
|
1489
1487
|
}
|
|
1490
1488
|
})();
|
|
1491
1489
|
}, [t, r, n.initialRoles]);
|
|
1492
|
-
const [
|
|
1493
|
-
return
|
|
1494
|
-
|
|
1495
|
-
console.error("[AuthProvider] Failed to load user data:",
|
|
1490
|
+
const [O, j] = k(!1);
|
|
1491
|
+
return re(() => {
|
|
1492
|
+
O || (j(!0), v.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), At(), B(!0), console.log("[AuthProvider] EFFECT: Loading user data (blocking isAuthReady)..."), q.loadUserData().catch((T) => {
|
|
1493
|
+
console.error("[AuthProvider] Failed to load user data:", T);
|
|
1496
1494
|
}).finally(() => {
|
|
1497
|
-
console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"),
|
|
1495
|
+
console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"), B(!1);
|
|
1498
1496
|
})));
|
|
1499
|
-
}, [
|
|
1500
|
-
let
|
|
1497
|
+
}, [q, O]), re(() => {
|
|
1498
|
+
let T = !1;
|
|
1501
1499
|
return (async () => {
|
|
1502
|
-
var
|
|
1503
|
-
if (!l.hasValidSession() && ((
|
|
1504
|
-
const
|
|
1505
|
-
|
|
1500
|
+
var he;
|
|
1501
|
+
if (!l.hasValidSession() && ((he = l.getTokens()) != null && he.refreshToken) && await l.waitForPendingRefresh(), T) return;
|
|
1502
|
+
const de = l.getUser();
|
|
1503
|
+
de && l.hasValidSession() && p(de), P(!1);
|
|
1506
1504
|
})(), () => {
|
|
1507
|
-
|
|
1505
|
+
T = !0;
|
|
1508
1506
|
};
|
|
1509
|
-
}, [l]),
|
|
1510
|
-
|
|
1507
|
+
}, [l]), re(() => {
|
|
1508
|
+
O && (v.current.urlTokens || (!L && !R && !M && l.hasValidSession() ? (console.log("[AuthProvider] Auto-loading user data..."), J.current().catch(() => {
|
|
1511
1509
|
}).finally(() => {
|
|
1512
|
-
|
|
1513
|
-
})) :
|
|
1514
|
-
}, [
|
|
1515
|
-
if (!l.hasValidSession() || !I)
|
|
1516
|
-
return;
|
|
1517
|
-
const V = setInterval(() => {
|
|
1518
|
-
W.loadUserData().catch(() => {
|
|
1519
|
-
});
|
|
1520
|
-
}, q);
|
|
1521
|
-
return () => clearInterval(V);
|
|
1522
|
-
}, [l, I, W, q]), /* @__PURE__ */ s(Ne.Provider, { value: W, children: e });
|
|
1510
|
+
P(!1);
|
|
1511
|
+
})) : P(!1)));
|
|
1512
|
+
}, [L, R, M, l, O]), /* @__PURE__ */ s(Ne.Provider, { value: q, children: e });
|
|
1523
1513
|
}
|
|
1524
1514
|
function ue() {
|
|
1525
|
-
const n =
|
|
1515
|
+
const n = ae(Ne);
|
|
1526
1516
|
if (!n)
|
|
1527
1517
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
1528
1518
|
return n;
|
|
1529
1519
|
}
|
|
1530
|
-
function
|
|
1531
|
-
return
|
|
1520
|
+
function De() {
|
|
1521
|
+
return ae(Ne);
|
|
1532
1522
|
}
|
|
1533
|
-
class
|
|
1523
|
+
class Pt {
|
|
1534
1524
|
constructor(e, t) {
|
|
1535
1525
|
this.httpService = e, this.sessionManager = t;
|
|
1536
1526
|
}
|
|
@@ -1610,66 +1600,66 @@ class It {
|
|
|
1610
1600
|
})).data;
|
|
1611
1601
|
}
|
|
1612
1602
|
}
|
|
1613
|
-
const
|
|
1614
|
-
function
|
|
1615
|
-
const t =
|
|
1616
|
-
const
|
|
1617
|
-
return new
|
|
1603
|
+
const Ce = pe(null);
|
|
1604
|
+
function vr({ config: n = {}, children: e }) {
|
|
1605
|
+
const t = Qe(), r = xe(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (r == null ? void 0 : r.tenant) ?? null, [f, m] = k([]), [b, c] = k(!1), [L, p] = k(null), [R, I] = k(!1), M = K(() => {
|
|
1606
|
+
const h = new le(i);
|
|
1607
|
+
return new Pt(h);
|
|
1618
1608
|
}, [i]), E = async () => {
|
|
1619
1609
|
if (!(a != null && a.id)) {
|
|
1620
|
-
|
|
1610
|
+
m([]);
|
|
1621
1611
|
return;
|
|
1622
1612
|
}
|
|
1623
1613
|
c(!0), p(null);
|
|
1624
1614
|
try {
|
|
1625
|
-
const
|
|
1626
|
-
|
|
1627
|
-
} catch (
|
|
1628
|
-
const
|
|
1629
|
-
p(
|
|
1615
|
+
const h = await M.getTenantFeatureFlags(a.id, o);
|
|
1616
|
+
m(h);
|
|
1617
|
+
} catch (h) {
|
|
1618
|
+
const A = h instanceof Error ? h.message : "Failed to fetch feature flags";
|
|
1619
|
+
p(A), n.onError && n.onError(h instanceof Error ? h : new Error(A));
|
|
1630
1620
|
} finally {
|
|
1631
1621
|
c(!1);
|
|
1632
1622
|
}
|
|
1633
1623
|
};
|
|
1634
|
-
|
|
1624
|
+
re(() => {
|
|
1635
1625
|
if (!i || !o) return;
|
|
1636
|
-
E().finally(() =>
|
|
1637
|
-
const
|
|
1638
|
-
return () => clearInterval(
|
|
1626
|
+
E().finally(() => I(!0));
|
|
1627
|
+
const h = n.refreshInterval || 5 * 60 * 1e3, A = setInterval(E, h);
|
|
1628
|
+
return () => clearInterval(A);
|
|
1639
1629
|
}, [a == null ? void 0 : a.id, i, o, n.refreshInterval]);
|
|
1640
|
-
const
|
|
1641
|
-
const
|
|
1642
|
-
const
|
|
1643
|
-
return (
|
|
1644
|
-
},
|
|
1645
|
-
const
|
|
1646
|
-
return
|
|
1647
|
-
},
|
|
1630
|
+
const x = K(() => {
|
|
1631
|
+
const h = (B) => {
|
|
1632
|
+
const l = f.find((H) => H.key === B);
|
|
1633
|
+
return (l == null ? void 0 : l.value) === !0;
|
|
1634
|
+
}, A = (B) => f.find((l) => l.key === B), w = (B) => {
|
|
1635
|
+
const l = f.find((H) => H.key === B);
|
|
1636
|
+
return l ? l.value ? "enabled" : "disabled" : "not_found";
|
|
1637
|
+
}, v = async () => {
|
|
1648
1638
|
await E();
|
|
1649
|
-
},
|
|
1639
|
+
}, N = !!(i && o) && (R || !(a != null && a.id));
|
|
1650
1640
|
return {
|
|
1651
1641
|
featureFlags: f,
|
|
1652
|
-
loading:
|
|
1653
|
-
error:
|
|
1654
|
-
isReady:
|
|
1655
|
-
isEnabled:
|
|
1656
|
-
getFlag:
|
|
1657
|
-
getFlagState:
|
|
1658
|
-
refresh:
|
|
1642
|
+
loading: b,
|
|
1643
|
+
error: L,
|
|
1644
|
+
isReady: N,
|
|
1645
|
+
isEnabled: h,
|
|
1646
|
+
getFlag: A,
|
|
1647
|
+
getFlagState: w,
|
|
1648
|
+
refresh: v
|
|
1659
1649
|
};
|
|
1660
|
-
}, [f,
|
|
1661
|
-
return /* @__PURE__ */ s(
|
|
1650
|
+
}, [f, b, L, i, o, a == null ? void 0 : a.id, R]);
|
|
1651
|
+
return /* @__PURE__ */ s(Ce.Provider, { value: x, children: e });
|
|
1662
1652
|
}
|
|
1663
|
-
function
|
|
1664
|
-
const n =
|
|
1653
|
+
function Rt() {
|
|
1654
|
+
const n = ae(Ce);
|
|
1665
1655
|
if (!n)
|
|
1666
1656
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1667
1657
|
return n;
|
|
1668
1658
|
}
|
|
1669
|
-
function
|
|
1670
|
-
return
|
|
1659
|
+
function Ke() {
|
|
1660
|
+
return ae(Ce);
|
|
1671
1661
|
}
|
|
1672
|
-
class
|
|
1662
|
+
class It {
|
|
1673
1663
|
constructor(e, t) {
|
|
1674
1664
|
this.httpService = e, this.sessionManager = t;
|
|
1675
1665
|
}
|
|
@@ -1735,68 +1725,68 @@ class Mt {
|
|
|
1735
1725
|
)).data;
|
|
1736
1726
|
}
|
|
1737
1727
|
}
|
|
1738
|
-
const
|
|
1739
|
-
function
|
|
1740
|
-
const t =
|
|
1741
|
-
const
|
|
1742
|
-
return new
|
|
1743
|
-
}, [i]),
|
|
1728
|
+
const Ue = pe(void 0);
|
|
1729
|
+
function Tr({ config: n = {}, children: e }) {
|
|
1730
|
+
const t = Qe(), r = xe(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a, f] = k(null), [m, b] = k(!1), [c, L] = k(null), [p, R] = k(!1), I = K(() => {
|
|
1731
|
+
const x = new le(i);
|
|
1732
|
+
return new It(x);
|
|
1733
|
+
}, [i]), M = async () => {
|
|
1744
1734
|
if (!(o != null && o.id)) {
|
|
1745
1735
|
f(null);
|
|
1746
1736
|
return;
|
|
1747
1737
|
}
|
|
1748
|
-
|
|
1738
|
+
b(!0), L(null);
|
|
1749
1739
|
try {
|
|
1750
|
-
const
|
|
1751
|
-
f(
|
|
1752
|
-
} catch (
|
|
1753
|
-
const
|
|
1754
|
-
|
|
1740
|
+
const x = await I.getTenantSubscriptionFeatures(o.id);
|
|
1741
|
+
f(x);
|
|
1742
|
+
} catch (x) {
|
|
1743
|
+
const h = x instanceof Error ? x.message : "Failed to fetch subscription";
|
|
1744
|
+
L(h), n.onError && n.onError(x instanceof Error ? x : new Error(h));
|
|
1755
1745
|
} finally {
|
|
1756
|
-
|
|
1746
|
+
b(!1);
|
|
1757
1747
|
}
|
|
1758
1748
|
};
|
|
1759
|
-
|
|
1760
|
-
if (!i || (
|
|
1761
|
-
const
|
|
1762
|
-
return () => clearInterval(
|
|
1749
|
+
re(() => {
|
|
1750
|
+
if (!i || (M().finally(() => R(!0)), !n.refreshInterval)) return;
|
|
1751
|
+
const x = n.refreshInterval || 10 * 60 * 1e3, h = setInterval(M, x);
|
|
1752
|
+
return () => clearInterval(h);
|
|
1763
1753
|
}, [o == null ? void 0 : o.id, i, n.refreshInterval]);
|
|
1764
|
-
const E =
|
|
1765
|
-
const
|
|
1766
|
-
const
|
|
1767
|
-
return
|
|
1768
|
-
},
|
|
1769
|
-
const
|
|
1770
|
-
return
|
|
1771
|
-
},
|
|
1772
|
-
await
|
|
1773
|
-
},
|
|
1754
|
+
const E = K(() => {
|
|
1755
|
+
const x = (a == null ? void 0 : a.features) || [], h = (l) => {
|
|
1756
|
+
const H = x.find((P) => P.key === l);
|
|
1757
|
+
return H ? H.type === "BOOLEAN" || H.type === "boolean" ? H.value === !0 : !!H.value : !1;
|
|
1758
|
+
}, A = (l) => x.find((H) => H.key === l), w = (l, H) => {
|
|
1759
|
+
const P = x.find((D) => D.key === l);
|
|
1760
|
+
return P ? P.value : H;
|
|
1761
|
+
}, v = (l) => !a || !a.isActive ? !1 : l.includes(a.planId), N = async () => {
|
|
1762
|
+
await M();
|
|
1763
|
+
}, B = !!i && (p || !(o != null && o.id));
|
|
1774
1764
|
return {
|
|
1775
1765
|
subscription: a,
|
|
1776
|
-
features:
|
|
1777
|
-
loading:
|
|
1766
|
+
features: x,
|
|
1767
|
+
loading: m,
|
|
1778
1768
|
error: c,
|
|
1779
|
-
isReady:
|
|
1780
|
-
isFeatureEnabled:
|
|
1781
|
-
getFeature:
|
|
1782
|
-
getFeatureValue:
|
|
1783
|
-
hasAllowedPlan:
|
|
1784
|
-
refresh:
|
|
1769
|
+
isReady: B,
|
|
1770
|
+
isFeatureEnabled: h,
|
|
1771
|
+
getFeature: A,
|
|
1772
|
+
getFeatureValue: w,
|
|
1773
|
+
hasAllowedPlan: v,
|
|
1774
|
+
refresh: N
|
|
1785
1775
|
};
|
|
1786
|
-
}, [a,
|
|
1787
|
-
return /* @__PURE__ */ s(
|
|
1776
|
+
}, [a, m, c, i, o == null ? void 0 : o.id, p]);
|
|
1777
|
+
return /* @__PURE__ */ s(Ue.Provider, { value: E, children: e });
|
|
1788
1778
|
}
|
|
1789
|
-
function
|
|
1790
|
-
const n =
|
|
1779
|
+
function Et() {
|
|
1780
|
+
const n = ae(Ue);
|
|
1791
1781
|
if (n === void 0)
|
|
1792
1782
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1793
1783
|
return n;
|
|
1794
1784
|
}
|
|
1795
|
-
function
|
|
1796
|
-
return
|
|
1785
|
+
function Ze() {
|
|
1786
|
+
return ae(Ue) ?? null;
|
|
1797
1787
|
}
|
|
1798
|
-
var
|
|
1799
|
-
const
|
|
1788
|
+
var oe = /* @__PURE__ */ ((n) => (n.SUPERUSER = "SUPERUSER", n.TENANT_ADMIN = "TENANT_ADMIN", n.USER = "USER", n))(oe || {});
|
|
1789
|
+
const $e = {
|
|
1800
1790
|
publicGuest: "/",
|
|
1801
1791
|
publicUser: "/account",
|
|
1802
1792
|
publicAdmin: "/admin",
|
|
@@ -1804,7 +1794,7 @@ const He = {
|
|
|
1804
1794
|
tenantUser: "/dashboard",
|
|
1805
1795
|
tenantAdmin: "/admin/dashboard",
|
|
1806
1796
|
default: "/"
|
|
1807
|
-
},
|
|
1797
|
+
}, Je = {
|
|
1808
1798
|
// Public/Landing zones
|
|
1809
1799
|
landing: { tenant: "forbidden", auth: "optional" },
|
|
1810
1800
|
publicOnly: { tenant: "forbidden", auth: "forbidden" },
|
|
@@ -1817,18 +1807,18 @@ const He = {
|
|
|
1817
1807
|
tenantOpen: { tenant: "required", auth: "optional" },
|
|
1818
1808
|
tenantAuth: { tenant: "required", auth: "required" },
|
|
1819
1809
|
// User type zones
|
|
1820
|
-
user: { tenant: "required", auth: "required", userType:
|
|
1821
|
-
admin: { tenant: "required", auth: "required", userType:
|
|
1810
|
+
user: { tenant: "required", auth: "required", userType: oe.USER },
|
|
1811
|
+
admin: { tenant: "required", auth: "required", userType: oe.TENANT_ADMIN },
|
|
1822
1812
|
// Fully open
|
|
1823
1813
|
open: { tenant: "optional", auth: "optional" }
|
|
1824
|
-
},
|
|
1825
|
-
function
|
|
1826
|
-
const t =
|
|
1814
|
+
}, He = pe(null);
|
|
1815
|
+
function kr({ config: n = {}, children: e }) {
|
|
1816
|
+
const t = K(() => {
|
|
1827
1817
|
const r = {
|
|
1828
|
-
|
|
1818
|
+
...$e,
|
|
1829
1819
|
...n.zoneRoots
|
|
1830
1820
|
}, i = {
|
|
1831
|
-
...
|
|
1821
|
+
...Je,
|
|
1832
1822
|
...n.presets
|
|
1833
1823
|
};
|
|
1834
1824
|
return {
|
|
@@ -1841,19 +1831,19 @@ function Ar({ config: n = {}, children: e }) {
|
|
|
1841
1831
|
returnToStorage: n.returnToStorage ?? "url"
|
|
1842
1832
|
};
|
|
1843
1833
|
}, [n]);
|
|
1844
|
-
return /* @__PURE__ */ s(
|
|
1834
|
+
return /* @__PURE__ */ s(He.Provider, { value: t, children: e });
|
|
1845
1835
|
}
|
|
1846
|
-
function
|
|
1847
|
-
const n =
|
|
1836
|
+
function xr() {
|
|
1837
|
+
const n = ae(He);
|
|
1848
1838
|
if (!n)
|
|
1849
1839
|
throw new Error("useRouting must be used within a RoutingProvider");
|
|
1850
1840
|
return n;
|
|
1851
1841
|
}
|
|
1852
|
-
function
|
|
1853
|
-
const n =
|
|
1842
|
+
function Mt() {
|
|
1843
|
+
const n = ae(He);
|
|
1854
1844
|
return n || {
|
|
1855
|
-
zoneRoots:
|
|
1856
|
-
presets:
|
|
1845
|
+
zoneRoots: $e,
|
|
1846
|
+
presets: Je,
|
|
1857
1847
|
loadingFallback: null,
|
|
1858
1848
|
accessDeniedFallback: null,
|
|
1859
1849
|
onAccessDenied: void 0,
|
|
@@ -1861,7 +1851,7 @@ function Ft() {
|
|
|
1861
1851
|
returnToStorage: "url"
|
|
1862
1852
|
};
|
|
1863
1853
|
}
|
|
1864
|
-
const
|
|
1854
|
+
const We = () => /* @__PURE__ */ u(
|
|
1865
1855
|
"div",
|
|
1866
1856
|
{
|
|
1867
1857
|
style: {
|
|
@@ -1898,11 +1888,11 @@ const Ve = () => /* @__PURE__ */ d(
|
|
|
1898
1888
|
)
|
|
1899
1889
|
]
|
|
1900
1890
|
}
|
|
1901
|
-
),
|
|
1891
|
+
), Ve = ({
|
|
1902
1892
|
userType: n,
|
|
1903
1893
|
minUserType: e,
|
|
1904
1894
|
missingPermissions: t
|
|
1905
|
-
}) => /* @__PURE__ */
|
|
1895
|
+
}) => /* @__PURE__ */ u(
|
|
1906
1896
|
"div",
|
|
1907
1897
|
{
|
|
1908
1898
|
style: {
|
|
@@ -1920,55 +1910,55 @@ const Ve = () => /* @__PURE__ */ d(
|
|
|
1920
1910
|
children: [
|
|
1921
1911
|
/* @__PURE__ */ s("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
|
|
1922
1912
|
/* @__PURE__ */ s("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
|
|
1923
|
-
e && n ? /* @__PURE__ */
|
|
1924
|
-
/* @__PURE__ */
|
|
1913
|
+
e && n ? /* @__PURE__ */ u(_, { children: [
|
|
1914
|
+
/* @__PURE__ */ u("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
|
|
1925
1915
|
"This content requires ",
|
|
1926
1916
|
/* @__PURE__ */ s("strong", { children: e }),
|
|
1927
1917
|
" access level or higher."
|
|
1928
1918
|
] }),
|
|
1929
|
-
/* @__PURE__ */
|
|
1919
|
+
/* @__PURE__ */ u("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1930
1920
|
"Your current access level: ",
|
|
1931
1921
|
/* @__PURE__ */ s("strong", { children: n })
|
|
1932
1922
|
] })
|
|
1933
|
-
] }) : /* @__PURE__ */
|
|
1923
|
+
] }) : /* @__PURE__ */ u(_, { children: [
|
|
1934
1924
|
/* @__PURE__ */ s("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
|
|
1935
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1925
|
+
t && t.length > 0 && /* @__PURE__ */ u("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1936
1926
|
"Required permissions: ",
|
|
1937
1927
|
/* @__PURE__ */ s("strong", { children: t.join(", ") })
|
|
1938
1928
|
] })
|
|
1939
1929
|
] })
|
|
1940
1930
|
]
|
|
1941
1931
|
}
|
|
1942
|
-
),
|
|
1932
|
+
), Lt = (n, e) => {
|
|
1943
1933
|
const t = {
|
|
1944
|
-
[
|
|
1945
|
-
[
|
|
1946
|
-
[
|
|
1934
|
+
[oe.USER]: 1,
|
|
1935
|
+
[oe.TENANT_ADMIN]: 2,
|
|
1936
|
+
[oe.SUPERUSER]: 3
|
|
1947
1937
|
};
|
|
1948
1938
|
return t[n] >= t[e];
|
|
1949
1939
|
};
|
|
1950
|
-
function
|
|
1940
|
+
function Ar({
|
|
1951
1941
|
children: n,
|
|
1952
1942
|
fallback: e,
|
|
1953
1943
|
minUserType: t,
|
|
1954
1944
|
requiredPermissions: r,
|
|
1955
1945
|
requireAllPermissions: i = !1
|
|
1956
1946
|
}) {
|
|
1957
|
-
const { hasValidSession: o, sessionManager: a, hasPermission: f, hasAnyPermission:
|
|
1947
|
+
const { hasValidSession: o, sessionManager: a, hasPermission: f, hasAnyPermission: m, hasAllPermissions: b } = ue();
|
|
1958
1948
|
if (!o())
|
|
1959
|
-
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(
|
|
1949
|
+
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(We, {}) });
|
|
1960
1950
|
const c = a.getUser();
|
|
1961
1951
|
if (!c)
|
|
1962
|
-
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(
|
|
1963
|
-
if (t && !
|
|
1964
|
-
return /* @__PURE__ */ s(
|
|
1965
|
-
if (r && r.length > 0 && !(i ?
|
|
1966
|
-
const p = r.filter((
|
|
1967
|
-
return /* @__PURE__ */ s(
|
|
1952
|
+
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(We, {}) });
|
|
1953
|
+
if (t && !Lt(c.userType, t))
|
|
1954
|
+
return /* @__PURE__ */ s(Ve, { userType: c.userType, minUserType: t });
|
|
1955
|
+
if (r && r.length > 0 && !(i ? b(r) : m(r))) {
|
|
1956
|
+
const p = r.filter((R) => !f(R)).map((R) => typeof R == "string" ? R : R.name);
|
|
1957
|
+
return /* @__PURE__ */ s(Ve, { missingPermissions: p });
|
|
1968
1958
|
}
|
|
1969
1959
|
return /* @__PURE__ */ s(_, { children: n });
|
|
1970
1960
|
}
|
|
1971
|
-
const
|
|
1961
|
+
const Ft = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
1972
1962
|
"div",
|
|
1973
1963
|
{
|
|
1974
1964
|
style: {
|
|
@@ -1981,7 +1971,7 @@ const Nt = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
1981
1971
|
backgroundColor: "#f9fafb",
|
|
1982
1972
|
textAlign: "center"
|
|
1983
1973
|
},
|
|
1984
|
-
children: /* @__PURE__ */
|
|
1974
|
+
children: /* @__PURE__ */ u(
|
|
1985
1975
|
"div",
|
|
1986
1976
|
{
|
|
1987
1977
|
style: {
|
|
@@ -1995,7 +1985,7 @@ const Nt = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
1995
1985
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
|
|
1996
1986
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
|
|
1997
1987
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
|
|
1998
|
-
/* @__PURE__ */
|
|
1988
|
+
/* @__PURE__ */ u("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1999
1989
|
"Redirecting to ",
|
|
2000
1990
|
n,
|
|
2001
1991
|
"..."
|
|
@@ -2004,7 +1994,7 @@ const Nt = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2004
1994
|
}
|
|
2005
1995
|
)
|
|
2006
1996
|
}
|
|
2007
|
-
),
|
|
1997
|
+
), je = ({
|
|
2008
1998
|
userType: n,
|
|
2009
1999
|
requiredUserType: e,
|
|
2010
2000
|
missingPermissions: t
|
|
@@ -2021,7 +2011,7 @@ const Nt = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2021
2011
|
backgroundColor: "#f9fafb",
|
|
2022
2012
|
textAlign: "center"
|
|
2023
2013
|
},
|
|
2024
|
-
children: /* @__PURE__ */
|
|
2014
|
+
children: /* @__PURE__ */ u(
|
|
2025
2015
|
"div",
|
|
2026
2016
|
{
|
|
2027
2017
|
style: {
|
|
@@ -2034,19 +2024,19 @@ const Nt = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2034
2024
|
children: [
|
|
2035
2025
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
|
|
2036
2026
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
|
|
2037
|
-
e && n ? /* @__PURE__ */
|
|
2038
|
-
/* @__PURE__ */
|
|
2027
|
+
e && n ? /* @__PURE__ */ u(_, { children: [
|
|
2028
|
+
/* @__PURE__ */ u("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
|
|
2039
2029
|
"This page requires ",
|
|
2040
2030
|
/* @__PURE__ */ s("strong", { children: e }),
|
|
2041
2031
|
" access."
|
|
2042
2032
|
] }),
|
|
2043
|
-
/* @__PURE__ */
|
|
2033
|
+
/* @__PURE__ */ u("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
2044
2034
|
"Your current user type: ",
|
|
2045
2035
|
/* @__PURE__ */ s("strong", { children: n })
|
|
2046
2036
|
] })
|
|
2047
|
-
] }) : /* @__PURE__ */
|
|
2037
|
+
] }) : /* @__PURE__ */ u(_, { children: [
|
|
2048
2038
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
|
|
2049
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
2039
|
+
t && t.length > 0 && /* @__PURE__ */ u("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
2050
2040
|
"Required permissions: ",
|
|
2051
2041
|
/* @__PURE__ */ s("strong", { children: t.join(", ") })
|
|
2052
2042
|
] })
|
|
@@ -2055,8 +2045,8 @@ const Nt = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2055
2045
|
}
|
|
2056
2046
|
)
|
|
2057
2047
|
}
|
|
2058
|
-
),
|
|
2059
|
-
function
|
|
2048
|
+
), Nt = (n, e) => n === e;
|
|
2049
|
+
function Pr({
|
|
2060
2050
|
children: n,
|
|
2061
2051
|
redirectTo: e = "/login",
|
|
2062
2052
|
requiredUserType: t,
|
|
@@ -2064,34 +2054,34 @@ function Ir({
|
|
|
2064
2054
|
requireAllPermissions: i = !1,
|
|
2065
2055
|
fallback: o
|
|
2066
2056
|
}) {
|
|
2067
|
-
const { hasValidSession: a, sessionManager: f, hasPermission:
|
|
2068
|
-
if (
|
|
2057
|
+
const { hasValidSession: a, sessionManager: f, hasPermission: m, hasAnyPermission: b, hasAllPermissions: c } = ue(), L = ke();
|
|
2058
|
+
if (re(() => {
|
|
2069
2059
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2070
2060
|
"[react-identity-access] ProtectedRoute is deprecated. Use AuthenticatedZone or AdminZone from ZoneRoute instead."
|
|
2071
2061
|
);
|
|
2072
2062
|
}, []), !a())
|
|
2073
|
-
return o ? /* @__PURE__ */ s(_, { children: o }) : /* @__PURE__ */
|
|
2074
|
-
/* @__PURE__ */ s(
|
|
2075
|
-
/* @__PURE__ */ s(
|
|
2063
|
+
return o ? /* @__PURE__ */ s(_, { children: o }) : /* @__PURE__ */ u(_, { children: [
|
|
2064
|
+
/* @__PURE__ */ s(Ft, { redirectPath: e }),
|
|
2065
|
+
/* @__PURE__ */ s(Se, { to: e, state: { from: L.pathname }, replace: !0 })
|
|
2076
2066
|
] });
|
|
2077
2067
|
const p = f.getUser();
|
|
2078
2068
|
if (!p)
|
|
2079
|
-
return /* @__PURE__ */ s(
|
|
2080
|
-
if (t && !
|
|
2069
|
+
return /* @__PURE__ */ s(Se, { to: e, state: { from: L.pathname }, replace: !0 });
|
|
2070
|
+
if (t && !Nt(p.userType, t))
|
|
2081
2071
|
return /* @__PURE__ */ s(
|
|
2082
|
-
|
|
2072
|
+
je,
|
|
2083
2073
|
{
|
|
2084
2074
|
userType: p.userType,
|
|
2085
2075
|
requiredUserType: t
|
|
2086
2076
|
}
|
|
2087
2077
|
);
|
|
2088
|
-
if (r && r.length > 0 && !(i ? c(r) :
|
|
2089
|
-
const
|
|
2090
|
-
return /* @__PURE__ */ s(
|
|
2078
|
+
if (r && r.length > 0 && !(i ? c(r) : b(r))) {
|
|
2079
|
+
const I = r.filter((M) => !m(M)).map((M) => typeof M == "string" ? M : M.name);
|
|
2080
|
+
return /* @__PURE__ */ s(je, { missingPermissions: I });
|
|
2091
2081
|
}
|
|
2092
2082
|
return /* @__PURE__ */ s(_, { children: n });
|
|
2093
2083
|
}
|
|
2094
|
-
const
|
|
2084
|
+
const Dt = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
2095
2085
|
"div",
|
|
2096
2086
|
{
|
|
2097
2087
|
style: {
|
|
@@ -2104,7 +2094,7 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2104
2094
|
backgroundColor: "#f9fafb",
|
|
2105
2095
|
textAlign: "center"
|
|
2106
2096
|
},
|
|
2107
|
-
children: /* @__PURE__ */
|
|
2097
|
+
children: /* @__PURE__ */ u(
|
|
2108
2098
|
"div",
|
|
2109
2099
|
{
|
|
2110
2100
|
style: {
|
|
@@ -2118,7 +2108,7 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2118
2108
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
|
|
2119
2109
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
|
|
2120
2110
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
|
|
2121
|
-
/* @__PURE__ */
|
|
2111
|
+
/* @__PURE__ */ u("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
2122
2112
|
"Redirecting to ",
|
|
2123
2113
|
n,
|
|
2124
2114
|
"..."
|
|
@@ -2128,18 +2118,18 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2128
2118
|
)
|
|
2129
2119
|
}
|
|
2130
2120
|
);
|
|
2131
|
-
function
|
|
2132
|
-
const { tenant: r, isLoading: i, error: o } =
|
|
2133
|
-
return
|
|
2121
|
+
function Rr({ children: n, redirectTo: e = "/", fallback: t }) {
|
|
2122
|
+
const { tenant: r, isLoading: i, error: o } = me(), a = ke();
|
|
2123
|
+
return re(() => {
|
|
2134
2124
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2135
2125
|
"[react-identity-access] TenantRoute is deprecated. Use TenantZone from ZoneRoute instead."
|
|
2136
2126
|
);
|
|
2137
|
-
}, []), i || o ? null : r ? /* @__PURE__ */ s(_, { children: n }) : t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */
|
|
2138
|
-
/* @__PURE__ */ s(
|
|
2139
|
-
/* @__PURE__ */ s(
|
|
2127
|
+
}, []), i || o ? null : r ? /* @__PURE__ */ s(_, { children: n }) : t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ u(_, { children: [
|
|
2128
|
+
/* @__PURE__ */ s(Dt, { redirectPath: e }),
|
|
2129
|
+
/* @__PURE__ */ s(Se, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
2140
2130
|
] });
|
|
2141
2131
|
}
|
|
2142
|
-
const
|
|
2132
|
+
const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
2143
2133
|
"div",
|
|
2144
2134
|
{
|
|
2145
2135
|
style: {
|
|
@@ -2152,7 +2142,7 @@ const $t = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2152
2142
|
backgroundColor: "#f9fafb",
|
|
2153
2143
|
textAlign: "center"
|
|
2154
2144
|
},
|
|
2155
|
-
children: /* @__PURE__ */
|
|
2145
|
+
children: /* @__PURE__ */ u(
|
|
2156
2146
|
"div",
|
|
2157
2147
|
{
|
|
2158
2148
|
style: {
|
|
@@ -2166,7 +2156,7 @@ const $t = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2166
2156
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
|
|
2167
2157
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
|
|
2168
2158
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
|
|
2169
|
-
/* @__PURE__ */
|
|
2159
|
+
/* @__PURE__ */ u("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
2170
2160
|
"Redirecting to ",
|
|
2171
2161
|
n,
|
|
2172
2162
|
"..."
|
|
@@ -2176,41 +2166,41 @@ const $t = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2176
2166
|
)
|
|
2177
2167
|
}
|
|
2178
2168
|
);
|
|
2179
|
-
function
|
|
2180
|
-
const { tenant: r, isLoading: i, error: o } =
|
|
2181
|
-
return
|
|
2169
|
+
function Ir({ children: n, redirectTo: e = "/dashboard", fallback: t }) {
|
|
2170
|
+
const { tenant: r, isLoading: i, error: o } = me(), a = ke();
|
|
2171
|
+
return re(() => {
|
|
2182
2172
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2183
2173
|
"[react-identity-access] LandingRoute is deprecated. Use PublicZone from ZoneRoute instead."
|
|
2184
2174
|
);
|
|
2185
|
-
}, []), i || o ? null : r ? t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */
|
|
2186
|
-
/* @__PURE__ */ s(
|
|
2187
|
-
/* @__PURE__ */ s(
|
|
2175
|
+
}, []), i || o ? null : r ? t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ u(_, { children: [
|
|
2176
|
+
/* @__PURE__ */ s(Ct, { redirectPath: e }),
|
|
2177
|
+
/* @__PURE__ */ s(Se, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
2188
2178
|
] }) : /* @__PURE__ */ s(_, { children: n });
|
|
2189
2179
|
}
|
|
2190
|
-
function
|
|
2180
|
+
function Ut(n, e) {
|
|
2191
2181
|
return e ? n ? Array.isArray(e) ? e.includes(n) : n === e : !1 : !0;
|
|
2192
2182
|
}
|
|
2193
|
-
function
|
|
2183
|
+
function Ge(n, e) {
|
|
2194
2184
|
return !n || n === "optional" ? "skip" : n === "required" ? e ? "pass" : "fail" : n === "forbidden" ? e ? "fail" : "pass" : "skip";
|
|
2195
2185
|
}
|
|
2196
|
-
function
|
|
2197
|
-
return
|
|
2186
|
+
function $t(n, e) {
|
|
2187
|
+
return Ge(n.tenant, e.hasTenant) === "fail" ? e.hasTenant ? "has_tenant" : "no_tenant" : Ge(n.auth, e.isAuthenticated) === "fail" ? e.isAuthenticated ? "already_authenticated" : "not_authenticated" : n.userType && e.isAuthenticated && !Ut(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;
|
|
2198
2188
|
}
|
|
2199
|
-
function
|
|
2200
|
-
return n.hasTenant ? n.isAuthenticated ? n.userType ===
|
|
2189
|
+
function Ht(n, e) {
|
|
2190
|
+
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;
|
|
2201
2191
|
}
|
|
2202
|
-
function
|
|
2192
|
+
function Bt(n, e, t, r, i) {
|
|
2203
2193
|
if (!e || i !== "url")
|
|
2204
2194
|
return n;
|
|
2205
2195
|
const o = typeof e == "string" ? e : t, a = n.includes("?") ? "&" : "?";
|
|
2206
2196
|
return `${n}${a}${r}=${encodeURIComponent(o)}`;
|
|
2207
2197
|
}
|
|
2208
|
-
function
|
|
2198
|
+
function qt(n, e, t) {
|
|
2209
2199
|
if (!n || t === "url") return;
|
|
2210
2200
|
const r = typeof n == "string" ? n : e, i = "zone_return_to";
|
|
2211
2201
|
t === "session" ? sessionStorage.setItem(i, r) : t === "local" && localStorage.setItem(i, r);
|
|
2212
2202
|
}
|
|
2213
|
-
const
|
|
2203
|
+
const ce = ({
|
|
2214
2204
|
children: n,
|
|
2215
2205
|
preset: e,
|
|
2216
2206
|
tenant: t,
|
|
@@ -2219,82 +2209,82 @@ const de = ({
|
|
|
2219
2209
|
requiredPermissions: o,
|
|
2220
2210
|
requireAllPermissions: a = !0,
|
|
2221
2211
|
returnTo: f,
|
|
2222
|
-
onAccessDenied:
|
|
2223
|
-
redirectTo:
|
|
2212
|
+
onAccessDenied: m,
|
|
2213
|
+
redirectTo: b,
|
|
2224
2214
|
loadingFallback: c,
|
|
2225
|
-
accessDeniedFallback:
|
|
2215
|
+
accessDeniedFallback: L
|
|
2226
2216
|
}) => {
|
|
2227
|
-
const p =
|
|
2217
|
+
const p = ke(), { isAuthenticated: R, isAuthInitializing: I, currentUser: M, userPermissions: E } = ue(), { tenant: x, isTenantLoading: h } = ge(), A = Mt(), w = K(() => {
|
|
2228
2218
|
if (e)
|
|
2229
|
-
return
|
|
2230
|
-
}, [e,
|
|
2219
|
+
return A.presets[e];
|
|
2220
|
+
}, [e, A.presets]), v = K(
|
|
2231
2221
|
() => ({
|
|
2232
|
-
tenant: t ?? (
|
|
2233
|
-
auth: r ?? (
|
|
2234
|
-
userType: i ?? (
|
|
2235
|
-
permissions: o ?? (
|
|
2222
|
+
tenant: t ?? (w == null ? void 0 : w.tenant),
|
|
2223
|
+
auth: r ?? (w == null ? void 0 : w.auth),
|
|
2224
|
+
userType: i ?? (w == null ? void 0 : w.userType),
|
|
2225
|
+
permissions: o ?? (w == null ? void 0 : w.requiredPermissions),
|
|
2236
2226
|
requireAllPermissions: a
|
|
2237
2227
|
}),
|
|
2238
|
-
[t, r, i, o,
|
|
2239
|
-
),
|
|
2228
|
+
[t, r, i, o, w, a]
|
|
2229
|
+
), N = K(
|
|
2240
2230
|
() => ({
|
|
2241
|
-
hasTenant: !!
|
|
2242
|
-
isAuthenticated:
|
|
2243
|
-
userType:
|
|
2231
|
+
hasTenant: !!x,
|
|
2232
|
+
isAuthenticated: R,
|
|
2233
|
+
userType: M == null ? void 0 : M.userType,
|
|
2244
2234
|
permissions: E,
|
|
2245
|
-
isLoading:
|
|
2235
|
+
isLoading: I || h
|
|
2246
2236
|
}),
|
|
2247
2237
|
[
|
|
2248
|
-
A,
|
|
2249
2238
|
x,
|
|
2250
|
-
F == null ? void 0 : F.userType,
|
|
2251
|
-
E,
|
|
2252
2239
|
R,
|
|
2253
|
-
|
|
2240
|
+
M == null ? void 0 : M.userType,
|
|
2241
|
+
E,
|
|
2242
|
+
I,
|
|
2243
|
+
h
|
|
2254
2244
|
]
|
|
2255
|
-
),
|
|
2256
|
-
type:
|
|
2245
|
+
), B = K(() => N.isLoading ? null : $t(v, N), [v, N]), l = K(() => B ? b || Ht(N, A.zoneRoots) : null, [B, b, N, A.zoneRoots]), H = K(() => !B || !l ? null : {
|
|
2246
|
+
type: B,
|
|
2257
2247
|
required: {
|
|
2258
|
-
tenant:
|
|
2259
|
-
auth:
|
|
2260
|
-
userType:
|
|
2261
|
-
permissions:
|
|
2248
|
+
tenant: v.tenant,
|
|
2249
|
+
auth: v.auth,
|
|
2250
|
+
userType: v.userType,
|
|
2251
|
+
permissions: v.permissions
|
|
2262
2252
|
},
|
|
2263
2253
|
current: {
|
|
2264
|
-
hasTenant:
|
|
2265
|
-
isAuthenticated:
|
|
2266
|
-
userType:
|
|
2267
|
-
permissions:
|
|
2254
|
+
hasTenant: N.hasTenant,
|
|
2255
|
+
isAuthenticated: N.isAuthenticated,
|
|
2256
|
+
userType: N.userType,
|
|
2257
|
+
permissions: N.permissions
|
|
2268
2258
|
},
|
|
2269
|
-
redirectTo:
|
|
2270
|
-
}, [
|
|
2271
|
-
if (
|
|
2272
|
-
|
|
2273
|
-
}, [
|
|
2274
|
-
|
|
2259
|
+
redirectTo: l
|
|
2260
|
+
}, [B, l, v, N]);
|
|
2261
|
+
if (re(() => {
|
|
2262
|
+
H && (m ? m(H) : A.onAccessDenied && A.onAccessDenied(H));
|
|
2263
|
+
}, [H, m, A]), re(() => {
|
|
2264
|
+
H && f && qt(f, p.pathname + p.search, A.returnToStorage);
|
|
2275
2265
|
}, [
|
|
2276
|
-
|
|
2266
|
+
H,
|
|
2277
2267
|
f,
|
|
2278
2268
|
p.pathname,
|
|
2279
2269
|
p.search,
|
|
2280
|
-
|
|
2281
|
-
]),
|
|
2282
|
-
return /* @__PURE__ */ s(_, { children: c ??
|
|
2283
|
-
if (
|
|
2284
|
-
const
|
|
2285
|
-
if (
|
|
2286
|
-
return /* @__PURE__ */ s(_, { children:
|
|
2287
|
-
const
|
|
2288
|
-
|
|
2270
|
+
A.returnToStorage
|
|
2271
|
+
]), N.isLoading)
|
|
2272
|
+
return /* @__PURE__ */ s(_, { children: c ?? A.loadingFallback ?? null });
|
|
2273
|
+
if (H && l) {
|
|
2274
|
+
const P = L ?? A.accessDeniedFallback;
|
|
2275
|
+
if (P)
|
|
2276
|
+
return /* @__PURE__ */ s(_, { children: P });
|
|
2277
|
+
const D = Bt(
|
|
2278
|
+
l,
|
|
2289
2279
|
f,
|
|
2290
2280
|
p.pathname + p.search,
|
|
2291
|
-
|
|
2292
|
-
|
|
2281
|
+
A.returnToParam,
|
|
2282
|
+
A.returnToStorage
|
|
2293
2283
|
);
|
|
2294
|
-
return /* @__PURE__ */ s(
|
|
2284
|
+
return /* @__PURE__ */ s(Se, { to: D, replace: !0 });
|
|
2295
2285
|
}
|
|
2296
2286
|
return /* @__PURE__ */ s(_, { children: n });
|
|
2297
|
-
},
|
|
2287
|
+
}, Er = (n) => /* @__PURE__ */ s(ce, { tenant: "required", ...n }), Mr = (n) => /* @__PURE__ */ s(ce, { tenant: "forbidden", ...n }), Lr = (n) => /* @__PURE__ */ s(ce, { auth: "required", ...n }), Fr = (n) => /* @__PURE__ */ s(ce, { auth: "forbidden", ...n }), Nr = (n) => /* @__PURE__ */ s(ce, { auth: "required", userType: oe.TENANT_ADMIN, ...n }), Dr = (n) => /* @__PURE__ */ s(ce, { auth: "required", userType: oe.USER, ...n }), Cr = (n) => /* @__PURE__ */ s(ce, { tenant: "optional", auth: "optional", ...n }), Ur = (n) => /* @__PURE__ */ s(ce, { tenant: "required", auth: "required", ...n }), $r = (n) => /* @__PURE__ */ s(ce, { tenant: "required", auth: "optional", ...n }), Hr = (n) => /* @__PURE__ */ s(ce, { tenant: "required", auth: "forbidden", ...n }), Ot = () => /* @__PURE__ */ u(
|
|
2298
2288
|
"div",
|
|
2299
2289
|
{
|
|
2300
2290
|
style: {
|
|
@@ -2311,13 +2301,13 @@ const de = ({
|
|
|
2311
2301
|
]
|
|
2312
2302
|
}
|
|
2313
2303
|
);
|
|
2314
|
-
function
|
|
2304
|
+
function Br({
|
|
2315
2305
|
children: n,
|
|
2316
|
-
fallback: e = /* @__PURE__ */ s(
|
|
2306
|
+
fallback: e = /* @__PURE__ */ s(Ot, {}),
|
|
2317
2307
|
allowedPlans: t,
|
|
2318
2308
|
requiredFeature: r
|
|
2319
2309
|
}) {
|
|
2320
|
-
const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: f } =
|
|
2310
|
+
const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: f } = Et();
|
|
2321
2311
|
return f ? /* @__PURE__ */ s(
|
|
2322
2312
|
"div",
|
|
2323
2313
|
{
|
|
@@ -2330,7 +2320,7 @@ function Or({
|
|
|
2330
2320
|
}
|
|
2331
2321
|
) : i ? i.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ s(_, { children: e }) : r && !a(r) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: n }) : /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: e });
|
|
2332
2322
|
}
|
|
2333
|
-
const
|
|
2323
|
+
const zt = ({ flagName: n }) => /* @__PURE__ */ u(
|
|
2334
2324
|
"div",
|
|
2335
2325
|
{
|
|
2336
2326
|
style: {
|
|
@@ -2349,7 +2339,7 @@ const Wt = ({ flagName: n }) => /* @__PURE__ */ d(
|
|
|
2349
2339
|
children: [
|
|
2350
2340
|
/* @__PURE__ */ s("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
|
|
2351
2341
|
/* @__PURE__ */ s("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
|
|
2352
|
-
/* @__PURE__ */
|
|
2342
|
+
/* @__PURE__ */ u("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
|
|
2353
2343
|
'Feature flag "',
|
|
2354
2344
|
n,
|
|
2355
2345
|
'" is disabled'
|
|
@@ -2357,8 +2347,8 @@ const Wt = ({ flagName: n }) => /* @__PURE__ */ d(
|
|
|
2357
2347
|
]
|
|
2358
2348
|
}
|
|
2359
2349
|
);
|
|
2360
|
-
function
|
|
2361
|
-
const { isEnabled: r, loading: i } =
|
|
2350
|
+
function qr({ name: n, children: e, fallback: t }) {
|
|
2351
|
+
const { isEnabled: r, loading: i } = Rt();
|
|
2362
2352
|
return i ? /* @__PURE__ */ s(
|
|
2363
2353
|
"div",
|
|
2364
2354
|
{
|
|
@@ -2372,9 +2362,9 @@ function zr({ name: n, children: e, fallback: t }) {
|
|
|
2372
2362
|
},
|
|
2373
2363
|
children: "Loading feature flags..."
|
|
2374
2364
|
}
|
|
2375
|
-
) : r(n) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: t || /* @__PURE__ */ s(
|
|
2365
|
+
) : r(n) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: t || /* @__PURE__ */ s(zt, { flagName: n }) });
|
|
2376
2366
|
}
|
|
2377
|
-
const
|
|
2367
|
+
const _t = () => /* @__PURE__ */ u(
|
|
2378
2368
|
"svg",
|
|
2379
2369
|
{
|
|
2380
2370
|
width: "16",
|
|
@@ -2391,7 +2381,7 @@ const Vt = () => /* @__PURE__ */ d(
|
|
|
2391
2381
|
/* @__PURE__ */ s("circle", { cx: "12", cy: "12", r: "3" })
|
|
2392
2382
|
]
|
|
2393
2383
|
}
|
|
2394
|
-
),
|
|
2384
|
+
), Wt = () => /* @__PURE__ */ u(
|
|
2395
2385
|
"svg",
|
|
2396
2386
|
{
|
|
2397
2387
|
width: "16",
|
|
@@ -2408,10 +2398,10 @@ const Vt = () => /* @__PURE__ */ d(
|
|
|
2408
2398
|
/* @__PURE__ */ s("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
2409
2399
|
]
|
|
2410
2400
|
}
|
|
2411
|
-
),
|
|
2412
|
-
showPassword: /* @__PURE__ */ s(
|
|
2413
|
-
hidePassword: /* @__PURE__ */ s(
|
|
2414
|
-
},
|
|
2401
|
+
), Vt = {
|
|
2402
|
+
showPassword: /* @__PURE__ */ s(_t, {}),
|
|
2403
|
+
hidePassword: /* @__PURE__ */ s(Wt, {})
|
|
2404
|
+
}, jt = {
|
|
2415
2405
|
title: "Sign In",
|
|
2416
2406
|
usernameLabel: "Email or Phone",
|
|
2417
2407
|
usernamePlaceholder: "Enter your email or phone number",
|
|
@@ -2425,7 +2415,7 @@ const Vt = () => /* @__PURE__ */ d(
|
|
|
2425
2415
|
magicLinkLink: "Use Magic Link",
|
|
2426
2416
|
errorMessage: "Invalid credentials",
|
|
2427
2417
|
loadingText: "Signing in..."
|
|
2428
|
-
},
|
|
2418
|
+
}, Gt = {
|
|
2429
2419
|
container: {
|
|
2430
2420
|
maxWidth: "400px",
|
|
2431
2421
|
width: "100%",
|
|
@@ -2532,7 +2522,7 @@ const Vt = () => /* @__PURE__ */ d(
|
|
|
2532
2522
|
fontSize: "0.875rem"
|
|
2533
2523
|
}
|
|
2534
2524
|
};
|
|
2535
|
-
function
|
|
2525
|
+
function Or({
|
|
2536
2526
|
copy: n = {},
|
|
2537
2527
|
styles: e = {},
|
|
2538
2528
|
icons: t = {},
|
|
@@ -2541,48 +2531,48 @@ function _r({
|
|
|
2541
2531
|
onForgotPassword: o,
|
|
2542
2532
|
onSignupClick: a,
|
|
2543
2533
|
onMagicLinkClick: f,
|
|
2544
|
-
showForgotPassword:
|
|
2545
|
-
showSignupLink:
|
|
2534
|
+
showForgotPassword: m = !0,
|
|
2535
|
+
showSignupLink: b = !0,
|
|
2546
2536
|
showMagicLinkOption: c = !0,
|
|
2547
|
-
className:
|
|
2537
|
+
className: L
|
|
2548
2538
|
}) {
|
|
2549
|
-
const [p,
|
|
2550
|
-
const
|
|
2551
|
-
return p.trim() || (
|
|
2552
|
-
},
|
|
2553
|
-
if (
|
|
2554
|
-
if (!(
|
|
2555
|
-
|
|
2539
|
+
const [p, R] = k(""), [I, M] = k(""), [E, x] = k(!1), [h, A] = k(!1), [w, v] = k(""), [N, B] = k({}), { login: l } = ue(), { tenant: H } = me(), P = { ...jt, ...n }, D = { ...Gt, ...e }, C = { ...Vt, ...t }, d = () => {
|
|
2540
|
+
const g = {};
|
|
2541
|
+
return p.trim() || (g.username = !0), I.trim() || (g.password = !0), B(g), Object.keys(g).length === 0;
|
|
2542
|
+
}, U = async (g) => {
|
|
2543
|
+
if (g.preventDefault(), !!d()) {
|
|
2544
|
+
if (!(H != null && H.id)) {
|
|
2545
|
+
v("Tenant not found");
|
|
2556
2546
|
return;
|
|
2557
2547
|
}
|
|
2558
|
-
|
|
2548
|
+
A(!0), v("");
|
|
2559
2549
|
try {
|
|
2560
|
-
const
|
|
2550
|
+
const S = await l({
|
|
2561
2551
|
username: p,
|
|
2562
|
-
password:
|
|
2552
|
+
password: I
|
|
2563
2553
|
// tenantId inferred from context automatically
|
|
2564
2554
|
});
|
|
2565
|
-
r == null || r(
|
|
2566
|
-
} catch (
|
|
2567
|
-
const
|
|
2568
|
-
|
|
2555
|
+
r == null || r(S);
|
|
2556
|
+
} catch (S) {
|
|
2557
|
+
const Q = S.message || P.errorMessage;
|
|
2558
|
+
v(Q), i == null || i(Q);
|
|
2569
2559
|
} finally {
|
|
2570
|
-
|
|
2560
|
+
A(!1);
|
|
2571
2561
|
}
|
|
2572
2562
|
}
|
|
2573
|
-
},
|
|
2574
|
-
...
|
|
2575
|
-
...
|
|
2576
|
-
}),
|
|
2577
|
-
...
|
|
2578
|
-
...
|
|
2579
|
-
...!p || !
|
|
2563
|
+
}, F = (g) => ({
|
|
2564
|
+
...D.input,
|
|
2565
|
+
...N[g] ? D.inputError : {}
|
|
2566
|
+
}), y = () => ({
|
|
2567
|
+
...D.button,
|
|
2568
|
+
...h ? D.buttonLoading : {},
|
|
2569
|
+
...!p || !I || h ? D.buttonDisabled : {}
|
|
2580
2570
|
});
|
|
2581
|
-
return /* @__PURE__ */
|
|
2582
|
-
/* @__PURE__ */ s("h2", { style:
|
|
2583
|
-
/* @__PURE__ */
|
|
2584
|
-
/* @__PURE__ */
|
|
2585
|
-
/* @__PURE__ */ s("label", { style:
|
|
2571
|
+
return /* @__PURE__ */ u("div", { className: L, style: D.container, children: [
|
|
2572
|
+
/* @__PURE__ */ s("h2", { style: D.title, children: P.title }),
|
|
2573
|
+
/* @__PURE__ */ u("form", { onSubmit: U, style: D.form, children: [
|
|
2574
|
+
/* @__PURE__ */ u("div", { style: D.fieldGroup, children: [
|
|
2575
|
+
/* @__PURE__ */ s("label", { style: D.label, children: P.usernameLabel }),
|
|
2586
2576
|
/* @__PURE__ */ s(
|
|
2587
2577
|
"input",
|
|
2588
2578
|
{
|
|
@@ -2590,75 +2580,75 @@ function _r({
|
|
|
2590
2580
|
name: "username",
|
|
2591
2581
|
type: "text",
|
|
2592
2582
|
value: p,
|
|
2593
|
-
onChange: (
|
|
2594
|
-
|
|
2583
|
+
onChange: (g) => {
|
|
2584
|
+
R(g.target.value), N.username && B((S) => ({ ...S, username: !1 }));
|
|
2595
2585
|
},
|
|
2596
|
-
placeholder:
|
|
2597
|
-
style:
|
|
2598
|
-
disabled:
|
|
2586
|
+
placeholder: P.usernamePlaceholder,
|
|
2587
|
+
style: F("username"),
|
|
2588
|
+
disabled: h
|
|
2599
2589
|
}
|
|
2600
2590
|
)
|
|
2601
2591
|
] }),
|
|
2602
|
-
/* @__PURE__ */
|
|
2603
|
-
/* @__PURE__ */ s("label", { style:
|
|
2604
|
-
/* @__PURE__ */
|
|
2592
|
+
/* @__PURE__ */ u("div", { style: D.fieldGroup, children: [
|
|
2593
|
+
/* @__PURE__ */ s("label", { style: D.label, children: P.passwordLabel }),
|
|
2594
|
+
/* @__PURE__ */ u("div", { style: D.inputContainer, children: [
|
|
2605
2595
|
/* @__PURE__ */ s(
|
|
2606
2596
|
"input",
|
|
2607
2597
|
{
|
|
2608
2598
|
id: "password",
|
|
2609
2599
|
name: "password",
|
|
2610
2600
|
type: E ? "text" : "password",
|
|
2611
|
-
value:
|
|
2612
|
-
onChange: (
|
|
2613
|
-
|
|
2601
|
+
value: I,
|
|
2602
|
+
onChange: (g) => {
|
|
2603
|
+
M(g.target.value), N.password && B((S) => ({ ...S, password: !1 }));
|
|
2614
2604
|
},
|
|
2615
|
-
placeholder:
|
|
2605
|
+
placeholder: P.passwordPlaceholder,
|
|
2616
2606
|
style: {
|
|
2617
|
-
...
|
|
2607
|
+
...F("password"),
|
|
2618
2608
|
paddingRight: "2.5rem"
|
|
2619
2609
|
// Make room for the icon
|
|
2620
2610
|
},
|
|
2621
|
-
disabled:
|
|
2611
|
+
disabled: h
|
|
2622
2612
|
}
|
|
2623
2613
|
),
|
|
2624
2614
|
/* @__PURE__ */ s(
|
|
2625
2615
|
"button",
|
|
2626
2616
|
{
|
|
2627
2617
|
type: "button",
|
|
2628
|
-
onClick: () =>
|
|
2629
|
-
style:
|
|
2630
|
-
disabled:
|
|
2618
|
+
onClick: () => x(!E),
|
|
2619
|
+
style: D.passwordToggle,
|
|
2620
|
+
disabled: h,
|
|
2631
2621
|
"aria-label": E ? "Hide password" : "Show password",
|
|
2632
|
-
children: E ?
|
|
2622
|
+
children: E ? C.hidePassword : C.showPassword
|
|
2633
2623
|
}
|
|
2634
2624
|
)
|
|
2635
2625
|
] })
|
|
2636
2626
|
] }),
|
|
2637
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: !p || !
|
|
2638
|
-
|
|
2627
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !p || !I || h, style: y(), children: h ? P.loadingText : P.submitButton }),
|
|
2628
|
+
w && /* @__PURE__ */ s("div", { style: D.errorText, children: w })
|
|
2639
2629
|
] }),
|
|
2640
|
-
(
|
|
2641
|
-
c && /* @__PURE__ */
|
|
2642
|
-
/* @__PURE__ */
|
|
2643
|
-
|
|
2630
|
+
(m || b || c) && /* @__PURE__ */ u("div", { style: D.linkContainer, children: [
|
|
2631
|
+
c && /* @__PURE__ */ u("div", { children: [
|
|
2632
|
+
/* @__PURE__ */ u("span", { style: D.divider, children: [
|
|
2633
|
+
P.magicLinkText,
|
|
2644
2634
|
" "
|
|
2645
2635
|
] }),
|
|
2646
|
-
/* @__PURE__ */ s("a", { onClick: f, style:
|
|
2636
|
+
/* @__PURE__ */ s("a", { onClick: f, style: D.link, children: P.magicLinkLink })
|
|
2647
2637
|
] }),
|
|
2648
|
-
c && (
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
/* @__PURE__ */
|
|
2653
|
-
|
|
2638
|
+
c && (m || b) && /* @__PURE__ */ s("div", { style: D.divider, children: "•" }),
|
|
2639
|
+
m && /* @__PURE__ */ s("a", { onClick: o, style: D.link, children: P.forgotPasswordLink }),
|
|
2640
|
+
m && b && /* @__PURE__ */ s("div", { style: D.divider, children: "•" }),
|
|
2641
|
+
b && /* @__PURE__ */ u("div", { children: [
|
|
2642
|
+
/* @__PURE__ */ u("span", { style: D.divider, children: [
|
|
2643
|
+
P.signupText,
|
|
2654
2644
|
" "
|
|
2655
2645
|
] }),
|
|
2656
|
-
/* @__PURE__ */ s("a", { onClick: a, style:
|
|
2646
|
+
/* @__PURE__ */ s("a", { onClick: a, style: D.link, children: P.signupLink })
|
|
2657
2647
|
] })
|
|
2658
2648
|
] })
|
|
2659
2649
|
] });
|
|
2660
2650
|
}
|
|
2661
|
-
const
|
|
2651
|
+
const Qt = {
|
|
2662
2652
|
title: "Create Account",
|
|
2663
2653
|
nameLabel: "First Name",
|
|
2664
2654
|
namePlaceholder: "Enter your first name",
|
|
@@ -2684,7 +2674,7 @@ const Zt = {
|
|
|
2684
2674
|
passwordMismatchError: "Passwords do not match",
|
|
2685
2675
|
isAdminLabel: "Create new organization",
|
|
2686
2676
|
isAdminDescription: "Check this if you want to create a new organization"
|
|
2687
|
-
},
|
|
2677
|
+
}, Kt = {
|
|
2688
2678
|
container: {
|
|
2689
2679
|
maxWidth: "400px",
|
|
2690
2680
|
width: "100%",
|
|
@@ -2783,7 +2773,7 @@ const Zt = {
|
|
|
2783
2773
|
fontSize: "0.875rem"
|
|
2784
2774
|
}
|
|
2785
2775
|
};
|
|
2786
|
-
function
|
|
2776
|
+
function zr({
|
|
2787
2777
|
copy: n = {},
|
|
2788
2778
|
styles: e = {},
|
|
2789
2779
|
signupType: t = "user",
|
|
@@ -2792,60 +2782,60 @@ function Wr({
|
|
|
2792
2782
|
onLoginClick: o,
|
|
2793
2783
|
onMagicLinkClick: a,
|
|
2794
2784
|
showLoginLink: f = !0,
|
|
2795
|
-
showMagicLinkOption:
|
|
2796
|
-
className:
|
|
2785
|
+
showMagicLinkOption: m = !0,
|
|
2786
|
+
className: b
|
|
2797
2787
|
}) {
|
|
2798
|
-
const [c,
|
|
2799
|
-
const
|
|
2800
|
-
return c.trim() || (
|
|
2801
|
-
},
|
|
2802
|
-
if (
|
|
2803
|
-
if (
|
|
2804
|
-
|
|
2788
|
+
const [c, L] = k(""), [p, R] = k(""), [I, M] = k(""), [E, x] = k(""), [h, A] = k(""), [w, v] = k(""), [N, B] = k(""), [l, H] = k(!1), [P, D] = k(""), [C, d] = k({}), { signup: U, signupTenantAdmin: F } = ue(), { tenant: y } = me(), g = { ...Qt, ...n }, S = { ...Kt, ...e }, Q = () => {
|
|
2789
|
+
const T = {};
|
|
2790
|
+
return c.trim() || (T.name = !0), !I.trim() && !E.trim() && (T.email = !0, T.phoneNumber = !0), h.trim() || (T.password = !0), w.trim() || (T.confirmPassword = !0), t === "tenant" && !N.trim() && (T.tenantName = !0), d(T), Object.keys(T).length === 0;
|
|
2791
|
+
}, J = async (T) => {
|
|
2792
|
+
if (T.preventDefault(), !!Q()) {
|
|
2793
|
+
if (h !== w) {
|
|
2794
|
+
D(g.passwordMismatchError), d({ confirmPassword: !0 });
|
|
2805
2795
|
return;
|
|
2806
2796
|
}
|
|
2807
|
-
if (t === "user" && !(
|
|
2808
|
-
|
|
2797
|
+
if (t === "user" && !(y != null && y.id)) {
|
|
2798
|
+
D("Tenant not found");
|
|
2809
2799
|
return;
|
|
2810
2800
|
}
|
|
2811
|
-
|
|
2801
|
+
H(!0), D("");
|
|
2812
2802
|
try {
|
|
2813
|
-
let
|
|
2814
|
-
t === "tenant" ?
|
|
2815
|
-
email:
|
|
2803
|
+
let V;
|
|
2804
|
+
t === "tenant" ? V = await F({
|
|
2805
|
+
email: I || void 0,
|
|
2816
2806
|
phoneNumber: E || void 0,
|
|
2817
2807
|
name: c,
|
|
2818
|
-
password:
|
|
2819
|
-
tenantName:
|
|
2808
|
+
password: h,
|
|
2809
|
+
tenantName: N,
|
|
2820
2810
|
lastName: p || void 0
|
|
2821
|
-
}) :
|
|
2822
|
-
email:
|
|
2811
|
+
}) : V = await U({
|
|
2812
|
+
email: I || void 0,
|
|
2823
2813
|
phoneNumber: E || void 0,
|
|
2824
2814
|
name: c,
|
|
2825
|
-
password:
|
|
2826
|
-
tenantId:
|
|
2815
|
+
password: h,
|
|
2816
|
+
tenantId: y.id,
|
|
2827
2817
|
lastName: p || void 0
|
|
2828
|
-
}), r == null || r(
|
|
2829
|
-
} catch (
|
|
2830
|
-
const
|
|
2831
|
-
|
|
2818
|
+
}), r == null || r(V);
|
|
2819
|
+
} catch (V) {
|
|
2820
|
+
const de = V.message || g.errorMessage;
|
|
2821
|
+
D(de), i == null || i(de);
|
|
2832
2822
|
} finally {
|
|
2833
|
-
|
|
2823
|
+
H(!1);
|
|
2834
2824
|
}
|
|
2835
2825
|
}
|
|
2836
|
-
},
|
|
2837
|
-
...
|
|
2838
|
-
|
|
2839
|
-
}),
|
|
2840
|
-
...
|
|
2841
|
-
...
|
|
2842
|
-
...!c || !
|
|
2843
|
-
}),
|
|
2844
|
-
return /* @__PURE__ */
|
|
2845
|
-
/* @__PURE__ */ s("h2", { style:
|
|
2846
|
-
/* @__PURE__ */
|
|
2847
|
-
/* @__PURE__ */
|
|
2848
|
-
/* @__PURE__ */ s("label", { style:
|
|
2826
|
+
}, q = (T) => ({
|
|
2827
|
+
...S.input,
|
|
2828
|
+
...C[T] ? S.inputError : {}
|
|
2829
|
+
}), O = () => ({
|
|
2830
|
+
...S.button,
|
|
2831
|
+
...l ? S.buttonLoading : {},
|
|
2832
|
+
...!c || !I && !E || !h || !w || l || t === "tenant" && !N ? S.buttonDisabled : {}
|
|
2833
|
+
}), j = c && (I || E) && h && w && (t === "user" || N);
|
|
2834
|
+
return /* @__PURE__ */ u("div", { className: b, style: S.container, children: [
|
|
2835
|
+
/* @__PURE__ */ s("h2", { style: S.title, children: g.title }),
|
|
2836
|
+
/* @__PURE__ */ u("form", { onSubmit: J, style: S.form, children: [
|
|
2837
|
+
/* @__PURE__ */ u("div", { style: S.fieldGroup, children: [
|
|
2838
|
+
/* @__PURE__ */ s("label", { style: S.label, children: g.nameLabel }),
|
|
2849
2839
|
/* @__PURE__ */ s(
|
|
2850
2840
|
"input",
|
|
2851
2841
|
{
|
|
@@ -2853,17 +2843,17 @@ function Wr({
|
|
|
2853
2843
|
name: "name",
|
|
2854
2844
|
type: "text",
|
|
2855
2845
|
value: c,
|
|
2856
|
-
onChange: (
|
|
2857
|
-
|
|
2846
|
+
onChange: (T) => {
|
|
2847
|
+
L(T.target.value), C.name && d((V) => ({ ...V, name: !1 }));
|
|
2858
2848
|
},
|
|
2859
|
-
placeholder:
|
|
2860
|
-
style:
|
|
2861
|
-
disabled:
|
|
2849
|
+
placeholder: g.namePlaceholder,
|
|
2850
|
+
style: q("name"),
|
|
2851
|
+
disabled: l
|
|
2862
2852
|
}
|
|
2863
2853
|
)
|
|
2864
2854
|
] }),
|
|
2865
|
-
/* @__PURE__ */
|
|
2866
|
-
/* @__PURE__ */ s("label", { style:
|
|
2855
|
+
/* @__PURE__ */ u("div", { style: S.fieldGroup, children: [
|
|
2856
|
+
/* @__PURE__ */ s("label", { style: S.label, children: g.lastNameLabel }),
|
|
2867
2857
|
/* @__PURE__ */ s(
|
|
2868
2858
|
"input",
|
|
2869
2859
|
{
|
|
@@ -2871,33 +2861,33 @@ function Wr({
|
|
|
2871
2861
|
name: "lastName",
|
|
2872
2862
|
type: "text",
|
|
2873
2863
|
value: p,
|
|
2874
|
-
onChange: (
|
|
2875
|
-
placeholder:
|
|
2876
|
-
style:
|
|
2877
|
-
disabled:
|
|
2864
|
+
onChange: (T) => R(T.target.value),
|
|
2865
|
+
placeholder: g.lastNamePlaceholder,
|
|
2866
|
+
style: S.input,
|
|
2867
|
+
disabled: l
|
|
2878
2868
|
}
|
|
2879
2869
|
)
|
|
2880
2870
|
] }),
|
|
2881
|
-
/* @__PURE__ */
|
|
2882
|
-
/* @__PURE__ */ s("label", { style:
|
|
2871
|
+
/* @__PURE__ */ u("div", { style: S.fieldGroup, children: [
|
|
2872
|
+
/* @__PURE__ */ s("label", { style: S.label, children: g.emailLabel }),
|
|
2883
2873
|
/* @__PURE__ */ s(
|
|
2884
2874
|
"input",
|
|
2885
2875
|
{
|
|
2886
2876
|
id: "email",
|
|
2887
2877
|
name: "email",
|
|
2888
2878
|
type: "email",
|
|
2889
|
-
value:
|
|
2890
|
-
onChange: (
|
|
2891
|
-
|
|
2879
|
+
value: I,
|
|
2880
|
+
onChange: (T) => {
|
|
2881
|
+
M(T.target.value), C.email && d((V) => ({ ...V, email: !1, phoneNumber: !1 }));
|
|
2892
2882
|
},
|
|
2893
|
-
placeholder:
|
|
2894
|
-
style:
|
|
2895
|
-
disabled:
|
|
2883
|
+
placeholder: g.emailPlaceholder,
|
|
2884
|
+
style: q("email"),
|
|
2885
|
+
disabled: l
|
|
2896
2886
|
}
|
|
2897
2887
|
)
|
|
2898
2888
|
] }),
|
|
2899
|
-
/* @__PURE__ */
|
|
2900
|
-
/* @__PURE__ */ s("label", { style:
|
|
2889
|
+
/* @__PURE__ */ u("div", { style: S.fieldGroup, children: [
|
|
2890
|
+
/* @__PURE__ */ s("label", { style: S.label, children: g.phoneNumberLabel }),
|
|
2901
2891
|
/* @__PURE__ */ s(
|
|
2902
2892
|
"input",
|
|
2903
2893
|
{
|
|
@@ -2905,12 +2895,12 @@ function Wr({
|
|
|
2905
2895
|
name: "phoneNumber",
|
|
2906
2896
|
type: "tel",
|
|
2907
2897
|
value: E,
|
|
2908
|
-
onChange: (
|
|
2909
|
-
|
|
2898
|
+
onChange: (T) => {
|
|
2899
|
+
x(T.target.value), C.phoneNumber && d((V) => ({ ...V, email: !1, phoneNumber: !1 }));
|
|
2910
2900
|
},
|
|
2911
|
-
placeholder:
|
|
2912
|
-
style:
|
|
2913
|
-
disabled:
|
|
2901
|
+
placeholder: g.phoneNumberPlaceholder,
|
|
2902
|
+
style: q("phoneNumber"),
|
|
2903
|
+
disabled: l
|
|
2914
2904
|
}
|
|
2915
2905
|
)
|
|
2916
2906
|
] }),
|
|
@@ -2926,83 +2916,83 @@ function Wr({
|
|
|
2926
2916
|
children: "At least one contact method (email or phone) is required"
|
|
2927
2917
|
}
|
|
2928
2918
|
),
|
|
2929
|
-
/* @__PURE__ */
|
|
2930
|
-
/* @__PURE__ */ s("label", { style:
|
|
2919
|
+
/* @__PURE__ */ u("div", { style: S.fieldGroup, children: [
|
|
2920
|
+
/* @__PURE__ */ s("label", { style: S.label, children: g.passwordLabel }),
|
|
2931
2921
|
/* @__PURE__ */ s(
|
|
2932
2922
|
"input",
|
|
2933
2923
|
{
|
|
2934
2924
|
id: "password",
|
|
2935
2925
|
name: "password",
|
|
2936
2926
|
type: "password",
|
|
2937
|
-
value:
|
|
2938
|
-
onChange: (
|
|
2939
|
-
|
|
2927
|
+
value: h,
|
|
2928
|
+
onChange: (T) => {
|
|
2929
|
+
A(T.target.value), C.password && d((V) => ({ ...V, password: !1 }));
|
|
2940
2930
|
},
|
|
2941
|
-
placeholder:
|
|
2942
|
-
style:
|
|
2943
|
-
disabled:
|
|
2931
|
+
placeholder: g.passwordPlaceholder,
|
|
2932
|
+
style: q("password"),
|
|
2933
|
+
disabled: l
|
|
2944
2934
|
}
|
|
2945
2935
|
)
|
|
2946
2936
|
] }),
|
|
2947
|
-
/* @__PURE__ */
|
|
2948
|
-
/* @__PURE__ */ s("label", { style:
|
|
2937
|
+
/* @__PURE__ */ u("div", { style: S.fieldGroup, children: [
|
|
2938
|
+
/* @__PURE__ */ s("label", { style: S.label, children: g.confirmPasswordLabel }),
|
|
2949
2939
|
/* @__PURE__ */ s(
|
|
2950
2940
|
"input",
|
|
2951
2941
|
{
|
|
2952
2942
|
id: "confirmPassword",
|
|
2953
2943
|
name: "confirmPassword",
|
|
2954
2944
|
type: "password",
|
|
2955
|
-
value:
|
|
2956
|
-
onChange: (
|
|
2957
|
-
|
|
2945
|
+
value: w,
|
|
2946
|
+
onChange: (T) => {
|
|
2947
|
+
v(T.target.value), C.confirmPassword && d((V) => ({ ...V, confirmPassword: !1 })), P === g.passwordMismatchError && D("");
|
|
2958
2948
|
},
|
|
2959
|
-
placeholder:
|
|
2960
|
-
style:
|
|
2961
|
-
disabled:
|
|
2949
|
+
placeholder: g.confirmPasswordPlaceholder,
|
|
2950
|
+
style: q("confirmPassword"),
|
|
2951
|
+
disabled: l
|
|
2962
2952
|
}
|
|
2963
2953
|
)
|
|
2964
2954
|
] }),
|
|
2965
|
-
t === "tenant" && /* @__PURE__ */
|
|
2966
|
-
/* @__PURE__ */ s("label", { style:
|
|
2955
|
+
t === "tenant" && /* @__PURE__ */ u("div", { style: S.fieldGroup, children: [
|
|
2956
|
+
/* @__PURE__ */ s("label", { style: S.label, children: g.tenantNameLabel }),
|
|
2967
2957
|
/* @__PURE__ */ s(
|
|
2968
2958
|
"input",
|
|
2969
2959
|
{
|
|
2970
2960
|
id: "tenantName",
|
|
2971
2961
|
name: "tenantName",
|
|
2972
2962
|
type: "text",
|
|
2973
|
-
value:
|
|
2974
|
-
onChange: (
|
|
2975
|
-
|
|
2963
|
+
value: N,
|
|
2964
|
+
onChange: (T) => {
|
|
2965
|
+
B(T.target.value), C.tenantName && d((V) => ({ ...V, tenantName: !1 }));
|
|
2976
2966
|
},
|
|
2977
|
-
placeholder:
|
|
2978
|
-
style:
|
|
2979
|
-
disabled:
|
|
2967
|
+
placeholder: g.tenantNamePlaceholder,
|
|
2968
|
+
style: q("tenantName"),
|
|
2969
|
+
disabled: l
|
|
2980
2970
|
}
|
|
2981
2971
|
)
|
|
2982
2972
|
] }),
|
|
2983
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: !
|
|
2984
|
-
|
|
2973
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !j || l, style: O(), children: l ? g.loadingText : g.submitButton }),
|
|
2974
|
+
P && /* @__PURE__ */ s("div", { style: S.errorText, children: P })
|
|
2985
2975
|
] }),
|
|
2986
|
-
(f ||
|
|
2987
|
-
|
|
2988
|
-
/* @__PURE__ */
|
|
2989
|
-
|
|
2976
|
+
(f || m) && /* @__PURE__ */ u("div", { style: S.linkContainer, children: [
|
|
2977
|
+
m && /* @__PURE__ */ u("div", { children: [
|
|
2978
|
+
/* @__PURE__ */ u("span", { style: S.divider, children: [
|
|
2979
|
+
g.magicLinkText,
|
|
2990
2980
|
" "
|
|
2991
2981
|
] }),
|
|
2992
|
-
/* @__PURE__ */ s("a", { onClick: a, style:
|
|
2982
|
+
/* @__PURE__ */ s("a", { onClick: a, style: S.link, children: g.magicLinkLink })
|
|
2993
2983
|
] }),
|
|
2994
|
-
|
|
2995
|
-
f && /* @__PURE__ */
|
|
2996
|
-
/* @__PURE__ */
|
|
2997
|
-
|
|
2984
|
+
m && f && /* @__PURE__ */ s("div", { style: S.divider, children: "•" }),
|
|
2985
|
+
f && /* @__PURE__ */ u("div", { children: [
|
|
2986
|
+
/* @__PURE__ */ u("span", { style: S.divider, children: [
|
|
2987
|
+
g.loginText,
|
|
2998
2988
|
" "
|
|
2999
2989
|
] }),
|
|
3000
|
-
/* @__PURE__ */ s("a", { onClick: o, style:
|
|
2990
|
+
/* @__PURE__ */ s("a", { onClick: o, style: S.link, children: g.loginLink })
|
|
3001
2991
|
] })
|
|
3002
2992
|
] })
|
|
3003
2993
|
] });
|
|
3004
2994
|
}
|
|
3005
|
-
const
|
|
2995
|
+
const Zt = {
|
|
3006
2996
|
title: "Sign In with Magic Link",
|
|
3007
2997
|
emailLabel: "Email",
|
|
3008
2998
|
emailPlaceholder: "Enter your email",
|
|
@@ -3020,7 +3010,7 @@ const Yt = {
|
|
|
3020
3010
|
loadingText: "Sending magic link...",
|
|
3021
3011
|
verifyingText: "Verifying magic link...",
|
|
3022
3012
|
description: "Enter your email to receive a magic link. If you don't have an account, we'll create one for you."
|
|
3023
|
-
},
|
|
3013
|
+
}, Jt = {
|
|
3024
3014
|
container: {
|
|
3025
3015
|
maxWidth: "400px",
|
|
3026
3016
|
width: "100%",
|
|
@@ -3123,7 +3113,7 @@ const Yt = {
|
|
|
3123
3113
|
fontSize: "0.875rem"
|
|
3124
3114
|
}
|
|
3125
3115
|
};
|
|
3126
|
-
function
|
|
3116
|
+
function _r({
|
|
3127
3117
|
copy: n = {},
|
|
3128
3118
|
styles: e = {},
|
|
3129
3119
|
onSuccess: t,
|
|
@@ -3132,75 +3122,75 @@ function Vr({
|
|
|
3132
3122
|
onSignupClick: o,
|
|
3133
3123
|
showTraditionalLinks: a = !0,
|
|
3134
3124
|
className: f,
|
|
3135
|
-
verifyToken:
|
|
3136
|
-
frontendUrl:
|
|
3125
|
+
verifyToken: m,
|
|
3126
|
+
frontendUrl: b
|
|
3137
3127
|
}) {
|
|
3138
|
-
const [c,
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
}, [
|
|
3142
|
-
const
|
|
3143
|
-
if (!
|
|
3144
|
-
|
|
3128
|
+
const [c, L] = k(""), [p, R] = k(""), [I, M] = k(""), [E, x] = k(!1), [h, A] = k(!1), [w, v] = k(""), [N, B] = k(""), [l, H] = k({}), [P, D] = k(!1), { sendMagicLink: C, verifyMagicLink: d } = ue(), { tenant: U } = me(), F = { ...Zt, ...n }, y = { ...Jt, ...e };
|
|
3129
|
+
re(() => {
|
|
3130
|
+
m && g(m);
|
|
3131
|
+
}, [m]);
|
|
3132
|
+
const g = async (O) => {
|
|
3133
|
+
if (!U || !c) {
|
|
3134
|
+
v("Missing tenant or email");
|
|
3145
3135
|
return;
|
|
3146
3136
|
}
|
|
3147
|
-
|
|
3137
|
+
A(!0), v("");
|
|
3148
3138
|
try {
|
|
3149
|
-
const
|
|
3150
|
-
token:
|
|
3139
|
+
const j = await d({
|
|
3140
|
+
token: O,
|
|
3151
3141
|
email: c
|
|
3152
3142
|
// tenantId inferred from context automatically
|
|
3153
3143
|
});
|
|
3154
|
-
t == null || t(
|
|
3155
|
-
} catch (
|
|
3156
|
-
const
|
|
3157
|
-
|
|
3144
|
+
t == null || t(j);
|
|
3145
|
+
} catch (j) {
|
|
3146
|
+
const T = j.message || "Failed to verify magic link";
|
|
3147
|
+
v(T), r == null || r(T);
|
|
3158
3148
|
} finally {
|
|
3159
|
-
|
|
3149
|
+
A(!1);
|
|
3160
3150
|
}
|
|
3161
|
-
},
|
|
3162
|
-
const
|
|
3163
|
-
return c.trim() || (
|
|
3164
|
-
},
|
|
3165
|
-
if (
|
|
3166
|
-
if (!(
|
|
3167
|
-
|
|
3151
|
+
}, S = () => {
|
|
3152
|
+
const O = {};
|
|
3153
|
+
return c.trim() || (O.email = !0), P && !p.trim() && (O.name = !0), H(O), Object.keys(O).length === 0;
|
|
3154
|
+
}, Q = async (O) => {
|
|
3155
|
+
if (O.preventDefault(), !!S()) {
|
|
3156
|
+
if (!(U != null && U.id)) {
|
|
3157
|
+
v("Tenant not found");
|
|
3168
3158
|
return;
|
|
3169
3159
|
}
|
|
3170
|
-
|
|
3160
|
+
x(!0), v(""), B("");
|
|
3171
3161
|
try {
|
|
3172
|
-
const
|
|
3162
|
+
const j = b || (typeof window < "u" ? window.location.origin : ""), T = await C({
|
|
3173
3163
|
email: c,
|
|
3174
|
-
tenantId:
|
|
3175
|
-
frontendUrl:
|
|
3176
|
-
name:
|
|
3177
|
-
lastName:
|
|
3164
|
+
tenantId: U.id,
|
|
3165
|
+
frontendUrl: j,
|
|
3166
|
+
name: P ? p : void 0,
|
|
3167
|
+
lastName: P ? I : void 0
|
|
3178
3168
|
});
|
|
3179
|
-
|
|
3180
|
-
} catch (
|
|
3181
|
-
const
|
|
3182
|
-
|
|
3169
|
+
B(F.successMessage), t == null || t(T);
|
|
3170
|
+
} catch (j) {
|
|
3171
|
+
const T = j.message || F.errorMessage;
|
|
3172
|
+
v(T), r == null || r(T);
|
|
3183
3173
|
} finally {
|
|
3184
|
-
|
|
3174
|
+
x(!1);
|
|
3185
3175
|
}
|
|
3186
3176
|
}
|
|
3187
|
-
},
|
|
3188
|
-
...
|
|
3189
|
-
...
|
|
3190
|
-
}),
|
|
3191
|
-
...
|
|
3192
|
-
...E ||
|
|
3193
|
-
...!c || E ||
|
|
3177
|
+
}, J = (O) => ({
|
|
3178
|
+
...y.input,
|
|
3179
|
+
...l[O] ? y.inputError : {}
|
|
3180
|
+
}), q = () => ({
|
|
3181
|
+
...y.button,
|
|
3182
|
+
...E || h ? y.buttonLoading : {},
|
|
3183
|
+
...!c || E || h ? y.buttonDisabled : {}
|
|
3194
3184
|
});
|
|
3195
|
-
return
|
|
3196
|
-
/* @__PURE__ */ s("h2", { style:
|
|
3185
|
+
return h ? /* @__PURE__ */ u("div", { className: f, style: y.container, children: [
|
|
3186
|
+
/* @__PURE__ */ s("h2", { style: y.title, children: F.verifyingText }),
|
|
3197
3187
|
/* @__PURE__ */ s("div", { style: { textAlign: "center", padding: "2rem" }, children: /* @__PURE__ */ s("div", { style: { fontSize: "1rem", color: "#6b7280" }, children: "Please wait while we verify your magic link..." }) })
|
|
3198
|
-
] }) : /* @__PURE__ */
|
|
3199
|
-
/* @__PURE__ */ s("h2", { style:
|
|
3200
|
-
/* @__PURE__ */ s("p", { style:
|
|
3201
|
-
/* @__PURE__ */
|
|
3202
|
-
/* @__PURE__ */
|
|
3203
|
-
/* @__PURE__ */ s("label", { style:
|
|
3188
|
+
] }) : /* @__PURE__ */ u("div", { className: f, style: y.container, children: [
|
|
3189
|
+
/* @__PURE__ */ s("h2", { style: y.title, children: F.title }),
|
|
3190
|
+
/* @__PURE__ */ s("p", { style: y.description, children: F.description }),
|
|
3191
|
+
/* @__PURE__ */ u("form", { onSubmit: Q, style: y.form, children: [
|
|
3192
|
+
/* @__PURE__ */ u("div", { style: y.fieldGroup, children: [
|
|
3193
|
+
/* @__PURE__ */ s("label", { style: y.label, children: F.emailLabel }),
|
|
3204
3194
|
/* @__PURE__ */ s(
|
|
3205
3195
|
"input",
|
|
3206
3196
|
{
|
|
@@ -3208,20 +3198,20 @@ function Vr({
|
|
|
3208
3198
|
name: "email",
|
|
3209
3199
|
type: "email",
|
|
3210
3200
|
value: c,
|
|
3211
|
-
onChange: (
|
|
3212
|
-
|
|
3201
|
+
onChange: (O) => {
|
|
3202
|
+
L(O.target.value), l.email && H((j) => ({ ...j, email: !1 }));
|
|
3213
3203
|
},
|
|
3214
|
-
placeholder:
|
|
3215
|
-
style:
|
|
3216
|
-
disabled: E ||
|
|
3204
|
+
placeholder: F.emailPlaceholder,
|
|
3205
|
+
style: J("email"),
|
|
3206
|
+
disabled: E || h
|
|
3217
3207
|
}
|
|
3218
3208
|
)
|
|
3219
3209
|
] }),
|
|
3220
|
-
!
|
|
3210
|
+
!P && /* @__PURE__ */ s("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ s(
|
|
3221
3211
|
"button",
|
|
3222
3212
|
{
|
|
3223
3213
|
type: "button",
|
|
3224
|
-
onClick: () =>
|
|
3214
|
+
onClick: () => D(!0),
|
|
3225
3215
|
style: {
|
|
3226
3216
|
background: "none",
|
|
3227
3217
|
border: "none",
|
|
@@ -3233,9 +3223,9 @@ function Vr({
|
|
|
3233
3223
|
children: "New user? Add your name"
|
|
3234
3224
|
}
|
|
3235
3225
|
) }),
|
|
3236
|
-
|
|
3237
|
-
/* @__PURE__ */
|
|
3238
|
-
/* @__PURE__ */ s("label", { style:
|
|
3226
|
+
P && /* @__PURE__ */ u(_, { children: [
|
|
3227
|
+
/* @__PURE__ */ u("div", { style: y.fieldGroup, children: [
|
|
3228
|
+
/* @__PURE__ */ s("label", { style: y.label, children: F.nameLabel }),
|
|
3239
3229
|
/* @__PURE__ */ s(
|
|
3240
3230
|
"input",
|
|
3241
3231
|
{
|
|
@@ -3243,28 +3233,28 @@ function Vr({
|
|
|
3243
3233
|
name: "name",
|
|
3244
3234
|
type: "text",
|
|
3245
3235
|
value: p,
|
|
3246
|
-
onChange: (
|
|
3247
|
-
|
|
3236
|
+
onChange: (O) => {
|
|
3237
|
+
R(O.target.value), l.name && H((j) => ({ ...j, name: !1 }));
|
|
3248
3238
|
},
|
|
3249
|
-
placeholder:
|
|
3250
|
-
style:
|
|
3251
|
-
disabled: E ||
|
|
3239
|
+
placeholder: F.namePlaceholder,
|
|
3240
|
+
style: J("name"),
|
|
3241
|
+
disabled: E || h
|
|
3252
3242
|
}
|
|
3253
3243
|
)
|
|
3254
3244
|
] }),
|
|
3255
|
-
/* @__PURE__ */
|
|
3256
|
-
/* @__PURE__ */ s("label", { style:
|
|
3245
|
+
/* @__PURE__ */ u("div", { style: y.fieldGroup, children: [
|
|
3246
|
+
/* @__PURE__ */ s("label", { style: y.label, children: F.lastNameLabel }),
|
|
3257
3247
|
/* @__PURE__ */ s(
|
|
3258
3248
|
"input",
|
|
3259
3249
|
{
|
|
3260
3250
|
id: "lastName",
|
|
3261
3251
|
name: "lastName",
|
|
3262
3252
|
type: "text",
|
|
3263
|
-
value:
|
|
3264
|
-
onChange: (
|
|
3265
|
-
placeholder:
|
|
3266
|
-
style:
|
|
3267
|
-
disabled: E ||
|
|
3253
|
+
value: I,
|
|
3254
|
+
onChange: (O) => M(O.target.value),
|
|
3255
|
+
placeholder: F.lastNamePlaceholder,
|
|
3256
|
+
style: y.input,
|
|
3257
|
+
disabled: E || h
|
|
3268
3258
|
}
|
|
3269
3259
|
)
|
|
3270
3260
|
] }),
|
|
@@ -3273,7 +3263,7 @@ function Vr({
|
|
|
3273
3263
|
{
|
|
3274
3264
|
type: "button",
|
|
3275
3265
|
onClick: () => {
|
|
3276
|
-
|
|
3266
|
+
D(!1), R(""), M("");
|
|
3277
3267
|
},
|
|
3278
3268
|
style: {
|
|
3279
3269
|
background: "none",
|
|
@@ -3287,30 +3277,30 @@ function Vr({
|
|
|
3287
3277
|
}
|
|
3288
3278
|
) })
|
|
3289
3279
|
] }),
|
|
3290
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: !c || E ||
|
|
3291
|
-
|
|
3292
|
-
|
|
3280
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !c || E || h, style: q(), children: E ? F.loadingText : F.submitButton }),
|
|
3281
|
+
w && /* @__PURE__ */ s("div", { style: y.errorText, children: w }),
|
|
3282
|
+
N && /* @__PURE__ */ s("div", { style: y.successText, children: N })
|
|
3293
3283
|
] }),
|
|
3294
|
-
a && /* @__PURE__ */
|
|
3295
|
-
/* @__PURE__ */
|
|
3296
|
-
/* @__PURE__ */
|
|
3297
|
-
|
|
3284
|
+
a && /* @__PURE__ */ u("div", { style: y.linkContainer, children: [
|
|
3285
|
+
/* @__PURE__ */ u("div", { children: [
|
|
3286
|
+
/* @__PURE__ */ u("span", { style: y.divider, children: [
|
|
3287
|
+
F.loginText,
|
|
3298
3288
|
" "
|
|
3299
3289
|
] }),
|
|
3300
|
-
/* @__PURE__ */ s("a", { onClick: i, style:
|
|
3290
|
+
/* @__PURE__ */ s("a", { onClick: i, style: y.link, children: F.loginLink })
|
|
3301
3291
|
] }),
|
|
3302
|
-
/* @__PURE__ */ s("div", { style:
|
|
3303
|
-
/* @__PURE__ */
|
|
3304
|
-
/* @__PURE__ */
|
|
3305
|
-
|
|
3292
|
+
/* @__PURE__ */ s("div", { style: y.divider, children: "•" }),
|
|
3293
|
+
/* @__PURE__ */ u("div", { children: [
|
|
3294
|
+
/* @__PURE__ */ u("span", { style: y.divider, children: [
|
|
3295
|
+
F.signupText,
|
|
3306
3296
|
" "
|
|
3307
3297
|
] }),
|
|
3308
|
-
/* @__PURE__ */ s("a", { onClick: o, style:
|
|
3298
|
+
/* @__PURE__ */ s("a", { onClick: o, style: y.link, children: F.signupLink })
|
|
3309
3299
|
] })
|
|
3310
3300
|
] })
|
|
3311
3301
|
] });
|
|
3312
3302
|
}
|
|
3313
|
-
const
|
|
3303
|
+
const Yt = {
|
|
3314
3304
|
title: "Verifying Magic Link",
|
|
3315
3305
|
verifyingMessage: "Please wait while we verify your magic link...",
|
|
3316
3306
|
successMessage: "Magic link verified successfully! You are now logged in.",
|
|
@@ -3318,7 +3308,7 @@ const er = {
|
|
|
3318
3308
|
redirectingMessage: "Redirecting you to the dashboard...",
|
|
3319
3309
|
retryButton: "Try Again",
|
|
3320
3310
|
backToLoginButton: "Back to Login"
|
|
3321
|
-
},
|
|
3311
|
+
}, Ye = {
|
|
3322
3312
|
container: {
|
|
3323
3313
|
maxWidth: "400px",
|
|
3324
3314
|
width: "100%",
|
|
@@ -3405,7 +3395,7 @@ const er = {
|
|
|
3405
3395
|
cursor: "pointer",
|
|
3406
3396
|
transition: "all 0.15s ease-in-out"
|
|
3407
3397
|
}
|
|
3408
|
-
},
|
|
3398
|
+
}, Xt = () => /* @__PURE__ */ s("div", { style: Ye.spinner }), er = () => /* @__PURE__ */ u(
|
|
3409
3399
|
"svg",
|
|
3410
3400
|
{
|
|
3411
3401
|
width: "48",
|
|
@@ -3422,7 +3412,7 @@ const er = {
|
|
|
3422
3412
|
/* @__PURE__ */ s("polyline", { points: "22,4 12,14.01 9,11.01" })
|
|
3423
3413
|
]
|
|
3424
3414
|
}
|
|
3425
|
-
),
|
|
3415
|
+
), tr = () => /* @__PURE__ */ u(
|
|
3426
3416
|
"svg",
|
|
3427
3417
|
{
|
|
3428
3418
|
width: "48",
|
|
@@ -3440,12 +3430,12 @@ const er = {
|
|
|
3440
3430
|
/* @__PURE__ */ s("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
|
|
3441
3431
|
]
|
|
3442
3432
|
}
|
|
3443
|
-
),
|
|
3444
|
-
loading: /* @__PURE__ */ s(
|
|
3445
|
-
success: /* @__PURE__ */ s(
|
|
3446
|
-
error: /* @__PURE__ */ s(
|
|
3433
|
+
), rr = {
|
|
3434
|
+
loading: /* @__PURE__ */ s(Xt, {}),
|
|
3435
|
+
success: /* @__PURE__ */ s(er, {}),
|
|
3436
|
+
error: /* @__PURE__ */ s(tr, {})
|
|
3447
3437
|
};
|
|
3448
|
-
function
|
|
3438
|
+
function Wr({
|
|
3449
3439
|
copy: n = {},
|
|
3450
3440
|
styles: e = {},
|
|
3451
3441
|
icons: t = {},
|
|
@@ -3454,95 +3444,95 @@ function jr({
|
|
|
3454
3444
|
onRetry: o,
|
|
3455
3445
|
onBackToLogin: a,
|
|
3456
3446
|
className: f,
|
|
3457
|
-
token:
|
|
3458
|
-
email:
|
|
3447
|
+
token: m,
|
|
3448
|
+
email: b,
|
|
3459
3449
|
appId: c,
|
|
3460
|
-
tenantSlug:
|
|
3450
|
+
tenantSlug: L,
|
|
3461
3451
|
autoRedirectDelay: p = 3e3
|
|
3462
3452
|
}) {
|
|
3463
|
-
const [
|
|
3453
|
+
const [R, I] = k("verifying"), [M, E] = k(""), { verifyMagicLink: x } = ue(), h = { ...Yt, ...n }, A = { ...Ye, ...e }, w = { ...rr, ...t }, v = () => {
|
|
3464
3454
|
if (typeof window > "u") return {};
|
|
3465
|
-
const
|
|
3455
|
+
const P = new URLSearchParams(window.location.search);
|
|
3466
3456
|
return {
|
|
3467
|
-
token:
|
|
3468
|
-
email:
|
|
3469
|
-
appId: c ||
|
|
3470
|
-
tenantSlug:
|
|
3457
|
+
token: m || P.get("token") || "",
|
|
3458
|
+
email: b || P.get("email") || "",
|
|
3459
|
+
appId: c || P.get("appId") || "",
|
|
3460
|
+
tenantSlug: L || P.get("tenantSlug") || void 0
|
|
3471
3461
|
};
|
|
3472
|
-
},
|
|
3473
|
-
|
|
3462
|
+
}, N = async () => {
|
|
3463
|
+
I("verifying"), E("");
|
|
3474
3464
|
try {
|
|
3475
|
-
const
|
|
3476
|
-
if (!
|
|
3465
|
+
const P = v();
|
|
3466
|
+
if (!P.token || !P.email)
|
|
3477
3467
|
throw new Error("Missing required parameters: token or email");
|
|
3478
|
-
const
|
|
3479
|
-
token:
|
|
3480
|
-
email:
|
|
3481
|
-
tenantSlug:
|
|
3468
|
+
const D = await x({
|
|
3469
|
+
token: P.token,
|
|
3470
|
+
email: P.email,
|
|
3471
|
+
tenantSlug: P.tenantSlug
|
|
3482
3472
|
});
|
|
3483
|
-
|
|
3484
|
-
|
|
3473
|
+
I("success"), r == null || r(D), p > 0 && setTimeout(() => {
|
|
3474
|
+
I("redirecting");
|
|
3485
3475
|
}, p);
|
|
3486
|
-
} catch (
|
|
3487
|
-
const
|
|
3488
|
-
E(
|
|
3476
|
+
} catch (P) {
|
|
3477
|
+
const D = P.message || h.errorMessage;
|
|
3478
|
+
E(D), I("error"), i == null || i(D);
|
|
3489
3479
|
}
|
|
3490
|
-
},
|
|
3491
|
-
o == null || o(),
|
|
3492
|
-
},
|
|
3480
|
+
}, B = () => {
|
|
3481
|
+
o == null || o(), N();
|
|
3482
|
+
}, l = () => {
|
|
3493
3483
|
a == null || a();
|
|
3494
3484
|
};
|
|
3495
|
-
|
|
3496
|
-
|
|
3485
|
+
re(() => {
|
|
3486
|
+
N();
|
|
3497
3487
|
}, []);
|
|
3498
|
-
const
|
|
3499
|
-
switch (
|
|
3488
|
+
const H = () => {
|
|
3489
|
+
switch (R) {
|
|
3500
3490
|
case "verifying":
|
|
3501
|
-
return /* @__PURE__ */
|
|
3502
|
-
|
|
3503
|
-
|
|
3491
|
+
return /* @__PURE__ */ u("div", { style: A.message, children: [
|
|
3492
|
+
w.loading,
|
|
3493
|
+
h.verifyingMessage
|
|
3504
3494
|
] });
|
|
3505
3495
|
case "success":
|
|
3506
|
-
return /* @__PURE__ */
|
|
3507
|
-
|
|
3508
|
-
/* @__PURE__ */ s("div", { style:
|
|
3496
|
+
return /* @__PURE__ */ u(_, { children: [
|
|
3497
|
+
w.success,
|
|
3498
|
+
/* @__PURE__ */ s("div", { style: A.successMessage, children: h.successMessage })
|
|
3509
3499
|
] });
|
|
3510
3500
|
case "redirecting":
|
|
3511
|
-
return /* @__PURE__ */
|
|
3512
|
-
|
|
3513
|
-
/* @__PURE__ */ s("div", { style:
|
|
3501
|
+
return /* @__PURE__ */ u(_, { children: [
|
|
3502
|
+
w.loading,
|
|
3503
|
+
/* @__PURE__ */ s("div", { style: A.message, children: h.redirectingMessage })
|
|
3514
3504
|
] });
|
|
3515
3505
|
case "error":
|
|
3516
|
-
return /* @__PURE__ */
|
|
3517
|
-
|
|
3518
|
-
/* @__PURE__ */ s("div", { style:
|
|
3519
|
-
/* @__PURE__ */
|
|
3506
|
+
return /* @__PURE__ */ u(_, { children: [
|
|
3507
|
+
w.error,
|
|
3508
|
+
/* @__PURE__ */ s("div", { style: A.errorMessage, children: M || h.errorMessage }),
|
|
3509
|
+
/* @__PURE__ */ u("div", { style: A.buttonContainer, children: [
|
|
3520
3510
|
/* @__PURE__ */ s(
|
|
3521
3511
|
"button",
|
|
3522
3512
|
{
|
|
3523
|
-
onClick:
|
|
3524
|
-
style:
|
|
3525
|
-
onMouseOver: (
|
|
3526
|
-
|
|
3513
|
+
onClick: B,
|
|
3514
|
+
style: A.retryButton,
|
|
3515
|
+
onMouseOver: (P) => {
|
|
3516
|
+
P.currentTarget.style.backgroundColor = "#2563eb";
|
|
3527
3517
|
},
|
|
3528
|
-
onMouseOut: (
|
|
3529
|
-
|
|
3518
|
+
onMouseOut: (P) => {
|
|
3519
|
+
P.currentTarget.style.backgroundColor = "#3b82f6";
|
|
3530
3520
|
},
|
|
3531
|
-
children:
|
|
3521
|
+
children: h.retryButton
|
|
3532
3522
|
}
|
|
3533
3523
|
),
|
|
3534
3524
|
/* @__PURE__ */ s(
|
|
3535
3525
|
"button",
|
|
3536
3526
|
{
|
|
3537
|
-
onClick:
|
|
3538
|
-
style:
|
|
3539
|
-
onMouseOver: (
|
|
3540
|
-
|
|
3527
|
+
onClick: l,
|
|
3528
|
+
style: A.backButton,
|
|
3529
|
+
onMouseOver: (P) => {
|
|
3530
|
+
P.currentTarget.style.backgroundColor = "#e5e7eb";
|
|
3541
3531
|
},
|
|
3542
|
-
onMouseOut: (
|
|
3543
|
-
|
|
3532
|
+
onMouseOut: (P) => {
|
|
3533
|
+
P.currentTarget.style.backgroundColor = "#f3f4f6";
|
|
3544
3534
|
},
|
|
3545
|
-
children:
|
|
3535
|
+
children: h.backToLoginButton
|
|
3546
3536
|
}
|
|
3547
3537
|
)
|
|
3548
3538
|
] })
|
|
@@ -3551,18 +3541,18 @@ function jr({
|
|
|
3551
3541
|
return null;
|
|
3552
3542
|
}
|
|
3553
3543
|
};
|
|
3554
|
-
return /* @__PURE__ */
|
|
3544
|
+
return /* @__PURE__ */ u("div", { style: A.container, className: f, children: [
|
|
3555
3545
|
/* @__PURE__ */ s("style", { children: `
|
|
3556
3546
|
@keyframes spin {
|
|
3557
3547
|
0% { transform: rotate(0deg); }
|
|
3558
3548
|
100% { transform: rotate(360deg); }
|
|
3559
3549
|
}
|
|
3560
3550
|
` }),
|
|
3561
|
-
/* @__PURE__ */ s("h1", { style:
|
|
3562
|
-
|
|
3551
|
+
/* @__PURE__ */ s("h1", { style: A.title, children: h.title }),
|
|
3552
|
+
H()
|
|
3563
3553
|
] });
|
|
3564
3554
|
}
|
|
3565
|
-
const
|
|
3555
|
+
const nr = {
|
|
3566
3556
|
title: "Reset Password",
|
|
3567
3557
|
subtitle: "Enter your email address and we'll send you a link to reset your password.",
|
|
3568
3558
|
emailLabel: "Email",
|
|
@@ -3584,7 +3574,7 @@ const ir = {
|
|
|
3584
3574
|
resetLoadingText: "Resetting...",
|
|
3585
3575
|
resetSuccessMessage: "Password reset successfully!",
|
|
3586
3576
|
passwordMismatchError: "Passwords do not match"
|
|
3587
|
-
},
|
|
3577
|
+
}, sr = {
|
|
3588
3578
|
container: {
|
|
3589
3579
|
maxWidth: "400px",
|
|
3590
3580
|
margin: "0 auto",
|
|
@@ -3676,7 +3666,7 @@ const ir = {
|
|
|
3676
3666
|
cursor: "pointer"
|
|
3677
3667
|
}
|
|
3678
3668
|
};
|
|
3679
|
-
function
|
|
3669
|
+
function Vr({
|
|
3680
3670
|
copy: n = {},
|
|
3681
3671
|
styles: e = {},
|
|
3682
3672
|
mode: t = "request",
|
|
@@ -3685,104 +3675,104 @@ function Gr({
|
|
|
3685
3675
|
onError: o,
|
|
3686
3676
|
onBackToLogin: a,
|
|
3687
3677
|
onModeChange: f,
|
|
3688
|
-
className:
|
|
3678
|
+
className: m
|
|
3689
3679
|
}) {
|
|
3690
|
-
const [
|
|
3691
|
-
const
|
|
3692
|
-
return
|
|
3693
|
-
},
|
|
3694
|
-
const
|
|
3695
|
-
return
|
|
3696
|
-
},
|
|
3697
|
-
if (
|
|
3698
|
-
if (!(
|
|
3699
|
-
|
|
3680
|
+
const [b, c] = k(""), [L, p] = k(r), [R, I] = k(""), [M, E] = k(""), [x, h] = k(!1), [A, w] = k(""), [v, N] = k(""), [B, l] = k({}), { requestPasswordReset: H, confirmPasswordReset: P } = ue(), { tenant: D } = me(), C = { ...nr, ...n }, d = { ...sr, ...e }, U = () => {
|
|
3681
|
+
const q = {};
|
|
3682
|
+
return b.trim() || (q.email = !0), l(q), Object.keys(q).length === 0;
|
|
3683
|
+
}, F = () => {
|
|
3684
|
+
const q = {};
|
|
3685
|
+
return L.trim() || (q.token = !0), R.trim() || (q.newPassword = !0), M.trim() || (q.confirmPassword = !0), l(q), Object.keys(q).length === 0;
|
|
3686
|
+
}, y = async (q) => {
|
|
3687
|
+
if (q.preventDefault(), !!U()) {
|
|
3688
|
+
if (!(D != null && D.id)) {
|
|
3689
|
+
w("Tenant not found");
|
|
3700
3690
|
return;
|
|
3701
3691
|
}
|
|
3702
|
-
|
|
3692
|
+
h(!0), w(""), N("");
|
|
3703
3693
|
try {
|
|
3704
|
-
await
|
|
3705
|
-
} catch (
|
|
3706
|
-
const
|
|
3707
|
-
|
|
3694
|
+
await H({ email: b, tenantId: D.id }), N(C.successMessage), i == null || i();
|
|
3695
|
+
} catch (O) {
|
|
3696
|
+
const j = O.message || C.errorMessage;
|
|
3697
|
+
w(j), o == null || o(j);
|
|
3708
3698
|
} finally {
|
|
3709
|
-
|
|
3699
|
+
h(!1);
|
|
3710
3700
|
}
|
|
3711
3701
|
}
|
|
3712
|
-
},
|
|
3713
|
-
if (
|
|
3714
|
-
if (
|
|
3715
|
-
|
|
3702
|
+
}, g = async (q) => {
|
|
3703
|
+
if (q.preventDefault(), !!F()) {
|
|
3704
|
+
if (R !== M) {
|
|
3705
|
+
w(C.passwordMismatchError), l({ confirmPassword: !0 });
|
|
3716
3706
|
return;
|
|
3717
3707
|
}
|
|
3718
|
-
|
|
3708
|
+
h(!0), w(""), N("");
|
|
3719
3709
|
try {
|
|
3720
|
-
await
|
|
3721
|
-
} catch (
|
|
3722
|
-
const
|
|
3723
|
-
|
|
3710
|
+
await P({ token: L, newPassword: R }), N(C.resetSuccessMessage), i == null || i();
|
|
3711
|
+
} catch (O) {
|
|
3712
|
+
const j = O.message || C.errorMessage;
|
|
3713
|
+
w(j), o == null || o(j);
|
|
3724
3714
|
} finally {
|
|
3725
|
-
|
|
3715
|
+
h(!1);
|
|
3726
3716
|
}
|
|
3727
3717
|
}
|
|
3728
|
-
},
|
|
3729
|
-
...
|
|
3730
|
-
...
|
|
3731
|
-
}),
|
|
3732
|
-
...
|
|
3733
|
-
...
|
|
3718
|
+
}, S = (q) => ({
|
|
3719
|
+
...d.input,
|
|
3720
|
+
...B[q] ? d.inputError : {}
|
|
3721
|
+
}), Q = () => ({
|
|
3722
|
+
...d.button,
|
|
3723
|
+
...x ? d.buttonLoading : {}
|
|
3734
3724
|
});
|
|
3735
3725
|
if (t === "reset") {
|
|
3736
|
-
const
|
|
3737
|
-
return /* @__PURE__ */
|
|
3738
|
-
/* @__PURE__ */ s("h2", { style:
|
|
3739
|
-
/* @__PURE__ */ s("p", { style:
|
|
3740
|
-
/* @__PURE__ */
|
|
3741
|
-
/* @__PURE__ */
|
|
3742
|
-
/* @__PURE__ */ s("label", { style:
|
|
3726
|
+
const q = L && R && M;
|
|
3727
|
+
return /* @__PURE__ */ u("div", { className: m, style: d.container, children: [
|
|
3728
|
+
/* @__PURE__ */ s("h2", { style: d.title, children: C.resetTitle }),
|
|
3729
|
+
/* @__PURE__ */ s("p", { style: d.subtitle, children: C.resetSubtitle }),
|
|
3730
|
+
/* @__PURE__ */ u("form", { onSubmit: g, style: d.form, children: [
|
|
3731
|
+
/* @__PURE__ */ u("div", { style: d.fieldGroup, children: [
|
|
3732
|
+
/* @__PURE__ */ s("label", { style: d.label, children: C.tokenLabel }),
|
|
3743
3733
|
/* @__PURE__ */ s(
|
|
3744
3734
|
"input",
|
|
3745
3735
|
{
|
|
3746
3736
|
type: "text",
|
|
3747
|
-
value:
|
|
3748
|
-
onChange: (
|
|
3749
|
-
p(
|
|
3737
|
+
value: L,
|
|
3738
|
+
onChange: (O) => {
|
|
3739
|
+
p(O.target.value), B.token && l((j) => ({ ...j, token: !1 }));
|
|
3750
3740
|
},
|
|
3751
|
-
placeholder:
|
|
3752
|
-
style:
|
|
3753
|
-
disabled:
|
|
3741
|
+
placeholder: C.tokenPlaceholder,
|
|
3742
|
+
style: S("token"),
|
|
3743
|
+
disabled: x
|
|
3754
3744
|
}
|
|
3755
3745
|
)
|
|
3756
3746
|
] }),
|
|
3757
|
-
/* @__PURE__ */
|
|
3758
|
-
/* @__PURE__ */ s("label", { style:
|
|
3747
|
+
/* @__PURE__ */ u("div", { style: d.fieldGroup, children: [
|
|
3748
|
+
/* @__PURE__ */ s("label", { style: d.label, children: C.newPasswordLabel }),
|
|
3759
3749
|
/* @__PURE__ */ s(
|
|
3760
3750
|
"input",
|
|
3761
3751
|
{
|
|
3762
3752
|
type: "password",
|
|
3763
|
-
value:
|
|
3764
|
-
onChange: (
|
|
3765
|
-
|
|
3753
|
+
value: R,
|
|
3754
|
+
onChange: (O) => {
|
|
3755
|
+
I(O.target.value), B.newPassword && l((j) => ({ ...j, newPassword: !1 }));
|
|
3766
3756
|
},
|
|
3767
|
-
placeholder:
|
|
3768
|
-
style:
|
|
3769
|
-
disabled:
|
|
3757
|
+
placeholder: C.newPasswordPlaceholder,
|
|
3758
|
+
style: S("newPassword"),
|
|
3759
|
+
disabled: x
|
|
3770
3760
|
}
|
|
3771
3761
|
)
|
|
3772
3762
|
] }),
|
|
3773
|
-
/* @__PURE__ */
|
|
3774
|
-
/* @__PURE__ */ s("label", { style:
|
|
3763
|
+
/* @__PURE__ */ u("div", { style: d.fieldGroup, children: [
|
|
3764
|
+
/* @__PURE__ */ s("label", { style: d.label, children: C.confirmPasswordLabel }),
|
|
3775
3765
|
/* @__PURE__ */ s(
|
|
3776
3766
|
"input",
|
|
3777
3767
|
{
|
|
3778
3768
|
type: "password",
|
|
3779
|
-
value:
|
|
3780
|
-
onChange: (
|
|
3781
|
-
E(
|
|
3769
|
+
value: M,
|
|
3770
|
+
onChange: (O) => {
|
|
3771
|
+
E(O.target.value), B.confirmPassword && l((j) => ({ ...j, confirmPassword: !1 })), A === C.passwordMismatchError && w("");
|
|
3782
3772
|
},
|
|
3783
|
-
placeholder:
|
|
3784
|
-
style:
|
|
3785
|
-
disabled:
|
|
3773
|
+
placeholder: C.confirmPasswordPlaceholder,
|
|
3774
|
+
style: S("confirmPassword"),
|
|
3775
|
+
disabled: x
|
|
3786
3776
|
}
|
|
3787
3777
|
)
|
|
3788
3778
|
] }),
|
|
@@ -3790,44 +3780,44 @@ function Gr({
|
|
|
3790
3780
|
"button",
|
|
3791
3781
|
{
|
|
3792
3782
|
type: "submit",
|
|
3793
|
-
disabled: !
|
|
3783
|
+
disabled: !q || x,
|
|
3794
3784
|
style: {
|
|
3795
|
-
...
|
|
3796
|
-
...!
|
|
3785
|
+
...Q(),
|
|
3786
|
+
...!q || x ? d.buttonDisabled : {}
|
|
3797
3787
|
},
|
|
3798
|
-
children:
|
|
3788
|
+
children: x ? C.resetLoadingText : C.resetSubmitButton
|
|
3799
3789
|
}
|
|
3800
3790
|
),
|
|
3801
|
-
|
|
3802
|
-
|
|
3791
|
+
A && /* @__PURE__ */ s("div", { style: d.errorText, children: A }),
|
|
3792
|
+
v && /* @__PURE__ */ s("div", { style: d.successText, children: v })
|
|
3803
3793
|
] }),
|
|
3804
|
-
/* @__PURE__ */
|
|
3805
|
-
/* @__PURE__ */ s("a", { onClick: a, style:
|
|
3806
|
-
f && /* @__PURE__ */
|
|
3794
|
+
/* @__PURE__ */ u("div", { style: d.linkContainer, children: [
|
|
3795
|
+
/* @__PURE__ */ s("a", { onClick: a, style: d.link, children: C.backToLoginLink }),
|
|
3796
|
+
f && /* @__PURE__ */ u(_, { children: [
|
|
3807
3797
|
/* @__PURE__ */ s("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3808
|
-
/* @__PURE__ */ s("a", { onClick: () => f("request"), style:
|
|
3798
|
+
/* @__PURE__ */ s("a", { onClick: () => f("request"), style: d.link, children: "Request New Link" })
|
|
3809
3799
|
] })
|
|
3810
3800
|
] })
|
|
3811
3801
|
] });
|
|
3812
3802
|
}
|
|
3813
|
-
const
|
|
3814
|
-
return /* @__PURE__ */
|
|
3815
|
-
/* @__PURE__ */ s("h2", { style:
|
|
3816
|
-
/* @__PURE__ */ s("p", { style:
|
|
3817
|
-
/* @__PURE__ */
|
|
3818
|
-
/* @__PURE__ */
|
|
3819
|
-
/* @__PURE__ */ s("label", { style:
|
|
3803
|
+
const J = b;
|
|
3804
|
+
return /* @__PURE__ */ u("div", { className: m, style: d.container, children: [
|
|
3805
|
+
/* @__PURE__ */ s("h2", { style: d.title, children: C.title }),
|
|
3806
|
+
/* @__PURE__ */ s("p", { style: d.subtitle, children: C.subtitle }),
|
|
3807
|
+
/* @__PURE__ */ u("form", { onSubmit: y, style: d.form, children: [
|
|
3808
|
+
/* @__PURE__ */ u("div", { style: d.fieldGroup, children: [
|
|
3809
|
+
/* @__PURE__ */ s("label", { style: d.label, children: C.emailLabel }),
|
|
3820
3810
|
/* @__PURE__ */ s(
|
|
3821
3811
|
"input",
|
|
3822
3812
|
{
|
|
3823
3813
|
type: "email",
|
|
3824
|
-
value:
|
|
3825
|
-
onChange: (
|
|
3826
|
-
c(
|
|
3814
|
+
value: b,
|
|
3815
|
+
onChange: (q) => {
|
|
3816
|
+
c(q.target.value), B.email && l((O) => ({ ...O, email: !1 }));
|
|
3827
3817
|
},
|
|
3828
|
-
placeholder:
|
|
3829
|
-
style:
|
|
3830
|
-
disabled:
|
|
3818
|
+
placeholder: C.emailPlaceholder,
|
|
3819
|
+
style: S("email"),
|
|
3820
|
+
disabled: x
|
|
3831
3821
|
}
|
|
3832
3822
|
)
|
|
3833
3823
|
] }),
|
|
@@ -3835,27 +3825,27 @@ function Gr({
|
|
|
3835
3825
|
"button",
|
|
3836
3826
|
{
|
|
3837
3827
|
type: "submit",
|
|
3838
|
-
disabled: !
|
|
3828
|
+
disabled: !J || x,
|
|
3839
3829
|
style: {
|
|
3840
|
-
...
|
|
3841
|
-
...!
|
|
3830
|
+
...Q(),
|
|
3831
|
+
...!J || x ? d.buttonDisabled : {}
|
|
3842
3832
|
},
|
|
3843
|
-
children:
|
|
3833
|
+
children: x ? C.loadingText : C.submitButton
|
|
3844
3834
|
}
|
|
3845
3835
|
),
|
|
3846
|
-
|
|
3847
|
-
|
|
3836
|
+
A && /* @__PURE__ */ s("div", { style: d.errorText, children: A }),
|
|
3837
|
+
v && /* @__PURE__ */ s("div", { style: d.successText, children: v })
|
|
3848
3838
|
] }),
|
|
3849
|
-
/* @__PURE__ */
|
|
3850
|
-
/* @__PURE__ */ s("a", { onClick: a, style:
|
|
3851
|
-
f && /* @__PURE__ */
|
|
3839
|
+
/* @__PURE__ */ u("div", { style: d.linkContainer, children: [
|
|
3840
|
+
/* @__PURE__ */ s("a", { onClick: a, style: d.link, children: C.backToLoginLink }),
|
|
3841
|
+
f && /* @__PURE__ */ u(_, { children: [
|
|
3852
3842
|
/* @__PURE__ */ s("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3853
|
-
/* @__PURE__ */ s("a", { onClick: () => f("reset"), style:
|
|
3843
|
+
/* @__PURE__ */ s("a", { onClick: () => f("reset"), style: d.link, children: "I have a token" })
|
|
3854
3844
|
] })
|
|
3855
3845
|
] })
|
|
3856
3846
|
] });
|
|
3857
3847
|
}
|
|
3858
|
-
const
|
|
3848
|
+
const ir = () => /* @__PURE__ */ s(
|
|
3859
3849
|
"div",
|
|
3860
3850
|
{
|
|
3861
3851
|
style: {
|
|
@@ -3867,7 +3857,7 @@ const ar = () => /* @__PURE__ */ s(
|
|
|
3867
3857
|
},
|
|
3868
3858
|
children: /* @__PURE__ */ s("div", { children: "Loading..." })
|
|
3869
3859
|
}
|
|
3870
|
-
),
|
|
3860
|
+
), or = ({ error: n, retry: e }) => /* @__PURE__ */ u(
|
|
3871
3861
|
"div",
|
|
3872
3862
|
{
|
|
3873
3863
|
style: {
|
|
@@ -3901,43 +3891,43 @@ const ar = () => /* @__PURE__ */ s(
|
|
|
3901
3891
|
]
|
|
3902
3892
|
}
|
|
3903
3893
|
);
|
|
3904
|
-
function
|
|
3894
|
+
function jr({
|
|
3905
3895
|
children: n,
|
|
3906
3896
|
loadingFallback: e,
|
|
3907
3897
|
errorFallback: t,
|
|
3908
3898
|
requireTenant: r = !0
|
|
3909
3899
|
}) {
|
|
3910
|
-
const { isAppLoading: i, appError: o, retryApp: a } =
|
|
3911
|
-
}),
|
|
3912
|
-
o && a(), p && f &&
|
|
3900
|
+
const { isAppLoading: i, appError: o, retryApp: a } = ve(), f = xe(), m = De(), b = Ke(), c = Ze(), L = (f == null ? void 0 : f.isTenantLoading) ?? !1, p = (f == null ? void 0 : f.tenantError) ?? null, R = (f == null ? void 0 : f.tenantSlug) ?? null, I = (f == null ? void 0 : f.retryTenant) ?? (() => {
|
|
3901
|
+
}), M = (m == null ? void 0 : m.isAuthReady) ?? !0, E = (b == null ? void 0 : b.isReady) ?? !0, x = (c == null ? void 0 : c.isReady) ?? !0, h = r && f && R, N = i || h && L || m && !M || b && !E || c && !x, B = o || (h ? p : null), l = () => {
|
|
3902
|
+
o && a(), p && f && I();
|
|
3913
3903
|
};
|
|
3914
|
-
if (
|
|
3915
|
-
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(
|
|
3916
|
-
if (
|
|
3917
|
-
const
|
|
3918
|
-
return /* @__PURE__ */ s(_, { children:
|
|
3904
|
+
if (N)
|
|
3905
|
+
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(ir, {}) });
|
|
3906
|
+
if (B) {
|
|
3907
|
+
const H = typeof t == "function" ? t(B, l) : t || /* @__PURE__ */ s(or, { error: B, retry: l });
|
|
3908
|
+
return /* @__PURE__ */ s(_, { children: H });
|
|
3919
3909
|
}
|
|
3920
3910
|
return /* @__PURE__ */ s(_, { children: n });
|
|
3921
3911
|
}
|
|
3922
|
-
function
|
|
3923
|
-
const { isAppLoading: e, appError: t, retryApp: r, appInfo: i } =
|
|
3924
|
-
}),
|
|
3912
|
+
function Gr(n = !0) {
|
|
3913
|
+
const { isAppLoading: e, appError: t, retryApp: r, appInfo: i } = ve(), o = xe(), a = De(), f = Ke(), m = Ze(), b = (o == null ? void 0 : o.isTenantLoading) ?? !1, c = (o == null ? void 0 : o.tenantError) ?? null, L = (o == null ? void 0 : o.tenant) ?? null, p = (o == null ? void 0 : o.tenantSlug) ?? null, R = (o == null ? void 0 : o.retryTenant) ?? (() => {
|
|
3914
|
+
}), I = (a == null ? void 0 : a.isAuthReady) ?? !0, M = (f == null ? void 0 : f.isReady) ?? !0, E = (m == null ? void 0 : m.isReady) ?? !0, x = n && o && p, v = e || x && b || a && !I || f && !M || m && !E, N = t || (x ? c : null);
|
|
3925
3915
|
return {
|
|
3926
|
-
isLoading:
|
|
3927
|
-
error:
|
|
3928
|
-
isReady: !
|
|
3916
|
+
isLoading: v,
|
|
3917
|
+
error: N,
|
|
3918
|
+
isReady: !v && !N && i !== null && (!x || L !== null),
|
|
3929
3919
|
retry: () => {
|
|
3930
|
-
t && r(), c && o &&
|
|
3920
|
+
t && r(), c && o && R();
|
|
3931
3921
|
},
|
|
3932
3922
|
// Individual states
|
|
3933
3923
|
app: { isLoading: e, error: t, data: i },
|
|
3934
|
-
tenant: o ? { isLoading:
|
|
3935
|
-
auth: a ? { isReady:
|
|
3936
|
-
featureFlags: f ? { isReady:
|
|
3937
|
-
subscription:
|
|
3924
|
+
tenant: o ? { isLoading: b, error: c, data: L } : null,
|
|
3925
|
+
auth: a ? { isReady: I } : null,
|
|
3926
|
+
featureFlags: f ? { isReady: M } : null,
|
|
3927
|
+
subscription: m ? { isReady: E } : null
|
|
3938
3928
|
};
|
|
3939
3929
|
}
|
|
3940
|
-
function
|
|
3930
|
+
function Qr({
|
|
3941
3931
|
tenants: n,
|
|
3942
3932
|
currentTenantId: e,
|
|
3943
3933
|
onSelect: t,
|
|
@@ -3946,50 +3936,50 @@ function Zr({
|
|
|
3946
3936
|
itemClassName: o = "",
|
|
3947
3937
|
renderItem: a,
|
|
3948
3938
|
placeholder: f = "Select tenant",
|
|
3949
|
-
disabled:
|
|
3950
|
-
showCurrentTenant:
|
|
3939
|
+
disabled: m = !1,
|
|
3940
|
+
showCurrentTenant: b = !0
|
|
3951
3941
|
}) {
|
|
3952
|
-
var
|
|
3953
|
-
const c =
|
|
3954
|
-
p(!1), t ? t(
|
|
3942
|
+
var A;
|
|
3943
|
+
const c = De(), [L, p] = k(!1), R = Me(null), I = n ?? (c == null ? void 0 : c.userTenants) ?? [], M = e ?? ((A = c == null ? void 0 : c.currentUser) == null ? void 0 : A.tenantId) ?? null, E = async (w) => {
|
|
3944
|
+
p(!1), t ? t(w) : c != null && c.switchToTenant && await c.switchToTenant(w);
|
|
3955
3945
|
};
|
|
3956
|
-
|
|
3957
|
-
const
|
|
3958
|
-
|
|
3946
|
+
re(() => {
|
|
3947
|
+
const w = (v) => {
|
|
3948
|
+
R.current && !R.current.contains(v.target) && p(!1);
|
|
3959
3949
|
};
|
|
3960
|
-
return document.addEventListener("mousedown",
|
|
3950
|
+
return document.addEventListener("mousedown", w), () => document.removeEventListener("mousedown", w);
|
|
3961
3951
|
}, []);
|
|
3962
|
-
const
|
|
3963
|
-
if (
|
|
3952
|
+
const x = I.find((w) => w.id === M);
|
|
3953
|
+
if (I.length === 0)
|
|
3964
3954
|
return null;
|
|
3965
|
-
if (
|
|
3966
|
-
return /* @__PURE__ */ s("div", { className: r, children: /* @__PURE__ */ s("span", { children:
|
|
3967
|
-
const
|
|
3968
|
-
|
|
3969
|
-
|
|
3955
|
+
if (I.length === 1 && b)
|
|
3956
|
+
return /* @__PURE__ */ s("div", { className: r, children: /* @__PURE__ */ s("span", { children: I[0].name }) });
|
|
3957
|
+
const h = (w, v) => /* @__PURE__ */ u("span", { style: { fontWeight: v ? "bold" : "normal" }, children: [
|
|
3958
|
+
w.name,
|
|
3959
|
+
w.role && /* @__PURE__ */ u("span", { style: { opacity: 0.7, marginLeft: 8 }, children: [
|
|
3970
3960
|
"(",
|
|
3971
|
-
|
|
3961
|
+
w.role,
|
|
3972
3962
|
")"
|
|
3973
3963
|
] })
|
|
3974
3964
|
] });
|
|
3975
|
-
return /* @__PURE__ */
|
|
3976
|
-
/* @__PURE__ */
|
|
3965
|
+
return /* @__PURE__ */ u("div", { ref: R, className: r, style: { position: "relative" }, children: [
|
|
3966
|
+
/* @__PURE__ */ u(
|
|
3977
3967
|
"button",
|
|
3978
3968
|
{
|
|
3979
3969
|
type: "button",
|
|
3980
|
-
onClick: () => !
|
|
3981
|
-
disabled:
|
|
3970
|
+
onClick: () => !m && p(!L),
|
|
3971
|
+
disabled: m,
|
|
3982
3972
|
style: {
|
|
3983
|
-
cursor:
|
|
3984
|
-
opacity:
|
|
3973
|
+
cursor: m ? "not-allowed" : "pointer",
|
|
3974
|
+
opacity: m ? 0.6 : 1
|
|
3985
3975
|
},
|
|
3986
3976
|
children: [
|
|
3987
|
-
|
|
3988
|
-
/* @__PURE__ */ s("span", { style: { marginLeft: 8 }, children:
|
|
3977
|
+
x ? x.name : f,
|
|
3978
|
+
/* @__PURE__ */ s("span", { style: { marginLeft: 8 }, children: L ? "▲" : "▼" })
|
|
3989
3979
|
]
|
|
3990
3980
|
}
|
|
3991
3981
|
),
|
|
3992
|
-
|
|
3982
|
+
L && /* @__PURE__ */ s(
|
|
3993
3983
|
"div",
|
|
3994
3984
|
{
|
|
3995
3985
|
className: i,
|
|
@@ -4006,34 +3996,34 @@ function Zr({
|
|
|
4006
3996
|
maxHeight: 300,
|
|
4007
3997
|
overflowY: "auto"
|
|
4008
3998
|
},
|
|
4009
|
-
children:
|
|
4010
|
-
const
|
|
3999
|
+
children: I.map((w) => {
|
|
4000
|
+
const v = w.id === M;
|
|
4011
4001
|
return /* @__PURE__ */ s(
|
|
4012
4002
|
"div",
|
|
4013
4003
|
{
|
|
4014
4004
|
className: o,
|
|
4015
|
-
onClick: () => E(
|
|
4005
|
+
onClick: () => E(w.id),
|
|
4016
4006
|
style: {
|
|
4017
4007
|
padding: "8px 12px",
|
|
4018
4008
|
cursor: "pointer",
|
|
4019
|
-
backgroundColor:
|
|
4009
|
+
backgroundColor: v ? "#f0f0f0" : "transparent"
|
|
4020
4010
|
},
|
|
4021
|
-
onMouseEnter: (
|
|
4022
|
-
|
|
4011
|
+
onMouseEnter: (N) => {
|
|
4012
|
+
v || (N.target.style.backgroundColor = "#f5f5f5");
|
|
4023
4013
|
},
|
|
4024
|
-
onMouseLeave: (
|
|
4025
|
-
|
|
4014
|
+
onMouseLeave: (N) => {
|
|
4015
|
+
v || (N.target.style.backgroundColor = "transparent");
|
|
4026
4016
|
},
|
|
4027
|
-
children: a ? a(
|
|
4017
|
+
children: a ? a(w, v) : h(w, v)
|
|
4028
4018
|
},
|
|
4029
|
-
|
|
4019
|
+
w.id
|
|
4030
4020
|
);
|
|
4031
4021
|
})
|
|
4032
4022
|
}
|
|
4033
4023
|
)
|
|
4034
4024
|
] });
|
|
4035
4025
|
}
|
|
4036
|
-
class
|
|
4026
|
+
class Kr {
|
|
4037
4027
|
constructor(e, t) {
|
|
4038
4028
|
this.httpService = e, this.sessionManager = t;
|
|
4039
4029
|
}
|
|
@@ -4101,7 +4091,7 @@ class Jr {
|
|
|
4101
4091
|
};
|
|
4102
4092
|
}
|
|
4103
4093
|
}
|
|
4104
|
-
class
|
|
4094
|
+
class Zr {
|
|
4105
4095
|
constructor(e, t) {
|
|
4106
4096
|
this.httpService = e, this.sessionManager = t;
|
|
4107
4097
|
}
|
|
@@ -4152,7 +4142,7 @@ class Yr {
|
|
|
4152
4142
|
});
|
|
4153
4143
|
}
|
|
4154
4144
|
}
|
|
4155
|
-
class
|
|
4145
|
+
class Jr {
|
|
4156
4146
|
constructor(e) {
|
|
4157
4147
|
this.httpService = e;
|
|
4158
4148
|
}
|
|
@@ -4161,7 +4151,7 @@ class Xr {
|
|
|
4161
4151
|
return await this.httpService.get("/health");
|
|
4162
4152
|
}
|
|
4163
4153
|
}
|
|
4164
|
-
class
|
|
4154
|
+
class Yr {
|
|
4165
4155
|
// Date string to Date object
|
|
4166
4156
|
static toDate(e) {
|
|
4167
4157
|
return new Date(e);
|
|
@@ -4283,139 +4273,139 @@ class en {
|
|
|
4283
4273
|
}), t;
|
|
4284
4274
|
}
|
|
4285
4275
|
}
|
|
4286
|
-
const
|
|
4287
|
-
function
|
|
4276
|
+
const Xe = "returnTo", Ie = "zone_return_to", Ee = "zone_return_to";
|
|
4277
|
+
function Xr(n = {}) {
|
|
4288
4278
|
const {
|
|
4289
4279
|
zoneRoots: e = {},
|
|
4290
|
-
returnToParam: t =
|
|
4280
|
+
returnToParam: t = Xe,
|
|
4291
4281
|
returnToStorage: r = "url"
|
|
4292
|
-
} = n, i =
|
|
4282
|
+
} = n, i = ft(), [o, a] = pt(), { isAuthenticated: f, currentUser: m } = ue(), { tenant: b } = ge(), c = K(() => ({ ...$e, ...e }), [e]), L = !!b, p = m == null ? void 0 : m.userType, R = K(() => {
|
|
4293
4283
|
switch (r) {
|
|
4294
4284
|
case "url":
|
|
4295
4285
|
return o.get(t);
|
|
4296
4286
|
case "session":
|
|
4297
|
-
return sessionStorage.getItem(
|
|
4287
|
+
return sessionStorage.getItem(Ie);
|
|
4298
4288
|
case "local":
|
|
4299
|
-
return localStorage.getItem(
|
|
4289
|
+
return localStorage.getItem(Ee);
|
|
4300
4290
|
default:
|
|
4301
4291
|
return null;
|
|
4302
4292
|
}
|
|
4303
|
-
}, [r, o, t]),
|
|
4293
|
+
}, [r, o, t]), I = se(() => {
|
|
4304
4294
|
switch (r) {
|
|
4305
4295
|
case "url": {
|
|
4306
|
-
const
|
|
4307
|
-
|
|
4296
|
+
const h = new URLSearchParams(o);
|
|
4297
|
+
h.delete(t), a(h, { replace: !0 });
|
|
4308
4298
|
break;
|
|
4309
4299
|
}
|
|
4310
4300
|
case "session":
|
|
4311
|
-
sessionStorage.removeItem(
|
|
4301
|
+
sessionStorage.removeItem(Ie);
|
|
4312
4302
|
break;
|
|
4313
4303
|
case "local":
|
|
4314
|
-
localStorage.removeItem(
|
|
4304
|
+
localStorage.removeItem(Ee);
|
|
4315
4305
|
break;
|
|
4316
4306
|
}
|
|
4317
|
-
}, [r, o, t, a]),
|
|
4318
|
-
(
|
|
4307
|
+
}, [r, o, t, a]), M = se(
|
|
4308
|
+
(h) => {
|
|
4319
4309
|
switch (r) {
|
|
4320
4310
|
case "url": {
|
|
4321
|
-
const
|
|
4322
|
-
|
|
4311
|
+
const A = new URLSearchParams(o);
|
|
4312
|
+
A.set(t, h), a(A, { replace: !0 });
|
|
4323
4313
|
break;
|
|
4324
4314
|
}
|
|
4325
4315
|
case "session":
|
|
4326
|
-
sessionStorage.setItem(
|
|
4316
|
+
sessionStorage.setItem(Ie, h);
|
|
4327
4317
|
break;
|
|
4328
4318
|
case "local":
|
|
4329
|
-
localStorage.setItem(
|
|
4319
|
+
localStorage.setItem(Ee, h);
|
|
4330
4320
|
break;
|
|
4331
4321
|
}
|
|
4332
4322
|
},
|
|
4333
4323
|
[r, o, t, a]
|
|
4334
|
-
), E =
|
|
4335
|
-
(
|
|
4336
|
-
const
|
|
4337
|
-
i(
|
|
4324
|
+
), E = se(
|
|
4325
|
+
(h) => {
|
|
4326
|
+
const A = c[h] || c.default;
|
|
4327
|
+
i(A);
|
|
4338
4328
|
},
|
|
4339
4329
|
[i, c]
|
|
4340
|
-
),
|
|
4330
|
+
), x = se(() => L ? f ? p === oe.TENANT_ADMIN ? c.tenantAdmin : c.tenantUser : c.tenantGuest : f ? p === oe.TENANT_ADMIN ? c.publicAdmin : c.publicUser : c.publicGuest, [L, f, p, c]);
|
|
4341
4331
|
return {
|
|
4342
|
-
returnToUrl:
|
|
4343
|
-
clearReturnTo:
|
|
4344
|
-
setReturnTo:
|
|
4332
|
+
returnToUrl: R,
|
|
4333
|
+
clearReturnTo: I,
|
|
4334
|
+
setReturnTo: M,
|
|
4345
4335
|
navigateToZone: E,
|
|
4346
|
-
getSmartRedirect:
|
|
4336
|
+
getSmartRedirect: x
|
|
4347
4337
|
};
|
|
4348
4338
|
}
|
|
4349
|
-
function
|
|
4339
|
+
function en(n, e, t = Xe, r = "url") {
|
|
4350
4340
|
if (!e || r !== "url")
|
|
4351
4341
|
return n;
|
|
4352
4342
|
const i = new URL(n, window.location.origin);
|
|
4353
4343
|
return i.searchParams.set(t, e), i.pathname + i.search;
|
|
4354
4344
|
}
|
|
4355
4345
|
export {
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4346
|
+
Nr as AdminZone,
|
|
4347
|
+
Yr as ApiMappers,
|
|
4348
|
+
Oe as AppApiService,
|
|
4349
|
+
jr as AppLoader,
|
|
4350
|
+
gr as AppProvider,
|
|
4351
|
+
yt as AuthApiService,
|
|
4352
|
+
Sr as AuthProvider,
|
|
4353
|
+
Lr as AuthenticatedZone,
|
|
4354
|
+
Je as DEFAULT_ZONE_PRESETS,
|
|
4355
|
+
$e as DEFAULT_ZONE_ROOTS,
|
|
4356
|
+
qr as FeatureFlag,
|
|
4357
|
+
Pt as FeatureFlagApiService,
|
|
4358
|
+
vr as FeatureFlagProvider,
|
|
4359
|
+
Fr as GuestZone,
|
|
4360
|
+
Jr as HealthApiService,
|
|
4361
|
+
le as HttpService,
|
|
4362
|
+
Ir as LandingRoute,
|
|
4363
|
+
Or as LoginForm,
|
|
4364
|
+
_r as MagicLinkForm,
|
|
4365
|
+
Wr as MagicLinkVerify,
|
|
4366
|
+
Cr as OpenZone,
|
|
4367
|
+
Vr as PasswordRecoveryForm,
|
|
4368
|
+
Kr as PermissionApiService,
|
|
4369
|
+
Ar as Protected,
|
|
4370
|
+
Pr as ProtectedRoute,
|
|
4371
|
+
Mr as PublicZone,
|
|
4372
|
+
ze as RoleApiService,
|
|
4373
|
+
kr as RoutingProvider,
|
|
4374
|
+
ne as SessionExpiredError,
|
|
4375
|
+
we as SessionManager,
|
|
4376
|
+
zr as SignupForm,
|
|
4377
|
+
It as SubscriptionApiService,
|
|
4378
|
+
Br as SubscriptionGuard,
|
|
4379
|
+
Zr as SubscriptionPlanApiService,
|
|
4380
|
+
Tr as SubscriptionProvider,
|
|
4381
|
+
be as TenantApiService,
|
|
4382
|
+
Ur as TenantAuthenticatedZone,
|
|
4383
|
+
Hr as TenantGuestZone,
|
|
4384
|
+
$r as TenantOpenZone,
|
|
4385
|
+
yr as TenantProvider,
|
|
4386
|
+
Rr as TenantRoute,
|
|
4387
|
+
Qr as TenantSelector,
|
|
4388
|
+
Er as TenantZone,
|
|
4389
|
+
mt as TokenRefreshError,
|
|
4390
|
+
gt as TokenRefreshTimeoutError,
|
|
4391
|
+
wt as UserApiService,
|
|
4392
|
+
oe as UserType,
|
|
4393
|
+
Dr as UserZone,
|
|
4394
|
+
ce as ZoneRoute,
|
|
4395
|
+
en as buildRedirectUrl,
|
|
4396
|
+
mr as useApi,
|
|
4397
|
+
ve as useApp,
|
|
4398
|
+
Gr as useAppLoaderState,
|
|
4409
4399
|
ue as useAuth,
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4400
|
+
Rt as useFeatureFlags,
|
|
4401
|
+
xr as useRouting,
|
|
4402
|
+
Mt as useRoutingOptional,
|
|
4403
|
+
br as useSettings,
|
|
4404
|
+
Et as useSubscription,
|
|
4405
|
+
ge as useTenant,
|
|
4406
|
+
me as useTenantInfo,
|
|
4407
|
+
xe as useTenantOptional,
|
|
4408
|
+
wr as useTenantSettings,
|
|
4409
|
+
Xr as useZoneNavigation
|
|
4420
4410
|
};
|
|
4421
4411
|
//# sourceMappingURL=index.es.js.map
|