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