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