@skylabs-digital/react-identity-access 2.13.0 → 2.14.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/ZoneRoute.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +1011 -962
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/providers/RoutingProvider.d.ts +56 -0
- package/dist/providers/RoutingProvider.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as s, Fragment as _, jsxs as d } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { useLocation as be, Navigate as
|
|
2
|
+
import { createContext as ue, useMemo as Z, useState as A, useCallback as re, useEffect as X, useContext as oe, useRef as We } from "react";
|
|
3
|
+
import { useLocation as be, Navigate as me, useNavigate as dt, useSearchParams as ut } from "react-router-dom";
|
|
4
4
|
class ie {
|
|
5
5
|
// SessionManager instance
|
|
6
6
|
constructor(e, t = 1e4) {
|
|
@@ -12,44 +12,44 @@ class ie {
|
|
|
12
12
|
getBaseUrl() {
|
|
13
13
|
return this.baseUrl;
|
|
14
14
|
}
|
|
15
|
-
async request(e, t, n,
|
|
16
|
-
return this.executeRequest(e, t, n,
|
|
15
|
+
async request(e, t, n, o) {
|
|
16
|
+
return this.executeRequest(e, t, n, o, !1);
|
|
17
17
|
}
|
|
18
|
-
async executeRequest(e, t, n,
|
|
19
|
-
const a = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, p = (
|
|
18
|
+
async executeRequest(e, t, n, o, i = !1) {
|
|
19
|
+
const a = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, p = (o == null ? void 0 : o.timeout) || this.timeout;
|
|
20
20
|
let f = {
|
|
21
21
|
"Content-Type": "application/json",
|
|
22
|
-
...
|
|
22
|
+
...o == null ? void 0 : o.headers
|
|
23
23
|
};
|
|
24
|
-
if (!(
|
|
24
|
+
if (!(o != null && o.skipAuth) && this.sessionManager)
|
|
25
25
|
try {
|
|
26
|
-
const
|
|
27
|
-
f = { ...f, ...
|
|
28
|
-
} catch (
|
|
29
|
-
console.warn("Failed to inject auth headers:",
|
|
26
|
+
const b = await this.sessionManager.getAuthHeaders();
|
|
27
|
+
f = { ...f, ...b };
|
|
28
|
+
} catch (b) {
|
|
29
|
+
console.warn("Failed to inject auth headers:", b);
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const w = new AbortController(), u = setTimeout(() => w.abort(), p);
|
|
32
32
|
try {
|
|
33
|
-
const
|
|
33
|
+
const b = await fetch(a, {
|
|
34
34
|
method: e,
|
|
35
35
|
headers: f,
|
|
36
36
|
body: n ? JSON.stringify(n) : void 0,
|
|
37
|
-
signal:
|
|
37
|
+
signal: w.signal
|
|
38
38
|
});
|
|
39
|
-
if (clearTimeout(u),
|
|
39
|
+
if (clearTimeout(u), b.status === 401 && !(o != null && o.skipRetry) && !i && this.sessionManager)
|
|
40
40
|
try {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, n,
|
|
41
|
+
const T = this.sessionManager.getTokens();
|
|
42
|
+
if (T != null && T.refreshToken)
|
|
43
|
+
return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, n, o, !0);
|
|
44
44
|
} catch {
|
|
45
|
-
throw new Error(`HTTP ${
|
|
45
|
+
throw new Error(`HTTP ${b.status}: ${b.statusText}`);
|
|
46
46
|
}
|
|
47
|
-
if (!
|
|
48
|
-
throw new Error(`HTTP ${
|
|
49
|
-
const g =
|
|
50
|
-
return !g || !g.includes("application/json") ? {} : await
|
|
51
|
-
} catch (
|
|
52
|
-
throw clearTimeout(u),
|
|
47
|
+
if (!b.ok)
|
|
48
|
+
throw new Error(`HTTP ${b.status}: ${b.statusText}`);
|
|
49
|
+
const g = b.headers.get("content-type");
|
|
50
|
+
return !g || !g.includes("application/json") ? {} : await b.json();
|
|
51
|
+
} catch (b) {
|
|
52
|
+
throw clearTimeout(u), b instanceof Error && b.name === "AbortError" ? new Error(`Request timeout after ${p}ms`) : b;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
async get(e, t) {
|
|
@@ -65,7 +65,7 @@ class ie {
|
|
|
65
65
|
return this.request("DELETE", e, void 0, t);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
class
|
|
68
|
+
class $e {
|
|
69
69
|
constructor(e, t) {
|
|
70
70
|
this.httpService = e, this.sessionManager = t;
|
|
71
71
|
}
|
|
@@ -78,12 +78,12 @@ class Ce {
|
|
|
78
78
|
async getApps(e) {
|
|
79
79
|
const t = await this.sessionManager.getAuthHeaders(), n = new URLSearchParams();
|
|
80
80
|
e != null && e.page && n.append("page", e.page.toString()), e != null && e.limit && n.append("limit", e.limit.toString()), e != null && e.sortBy && n.append("sortBy", e.sortBy), e != null && e.sortOrder && n.append("sortOrder", e.sortOrder);
|
|
81
|
-
const
|
|
81
|
+
const o = `/apps/${n.toString() ? `?${n.toString()}` : ""}`, i = await this.httpService.get(o, {
|
|
82
82
|
headers: t
|
|
83
83
|
});
|
|
84
84
|
return {
|
|
85
|
-
apps:
|
|
86
|
-
meta:
|
|
85
|
+
apps: i.data,
|
|
86
|
+
meta: i.meta
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
async getAppById(e) {
|
|
@@ -110,11 +110,11 @@ class Ce {
|
|
|
110
110
|
)).data;
|
|
111
111
|
}
|
|
112
112
|
async updateSettingsSchema(e, t, n) {
|
|
113
|
-
const
|
|
113
|
+
const o = await this.sessionManager.getAuthHeaders();
|
|
114
114
|
return (await this.httpService.put(
|
|
115
115
|
`/apps/${e}/settings-schema`,
|
|
116
116
|
{ schema: t, defaultSettings: n },
|
|
117
|
-
{ headers:
|
|
117
|
+
{ headers: o }
|
|
118
118
|
)).data;
|
|
119
119
|
}
|
|
120
120
|
async exportConfig(e) {
|
|
@@ -124,30 +124,30 @@ class Ce {
|
|
|
124
124
|
})).data;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
const Re =
|
|
128
|
-
function
|
|
129
|
-
const t =
|
|
127
|
+
const Re = ue(null);
|
|
128
|
+
function un({ config: r, children: e }) {
|
|
129
|
+
const t = Z(
|
|
130
130
|
() => {
|
|
131
|
-
var g,
|
|
131
|
+
var g, T, I;
|
|
132
132
|
return {
|
|
133
133
|
enabled: ((g = r.cache) == null ? void 0 : g.enabled) ?? !0,
|
|
134
|
-
ttl: ((
|
|
134
|
+
ttl: ((T = r.cache) == null ? void 0 : T.ttl) ?? 3e5,
|
|
135
135
|
// 5 minutes default
|
|
136
|
-
storageKey: ((
|
|
136
|
+
storageKey: ((I = r.cache) == null ? void 0 : I.storageKey) ?? `app_cache_${r.appId}`
|
|
137
137
|
};
|
|
138
138
|
},
|
|
139
139
|
[r.cache, r.appId]
|
|
140
|
-
), [n,
|
|
140
|
+
), [n, o] = A(() => {
|
|
141
141
|
if (!t.enabled) return null;
|
|
142
142
|
try {
|
|
143
143
|
const g = localStorage.getItem(t.storageKey);
|
|
144
144
|
if (!g) return null;
|
|
145
|
-
const
|
|
146
|
-
return Date.now() -
|
|
145
|
+
const T = JSON.parse(g);
|
|
146
|
+
return Date.now() - T.timestamp < t.ttl && T.appId === r.appId ? T.data : (localStorage.removeItem(t.storageKey), null);
|
|
147
147
|
} catch {
|
|
148
148
|
return null;
|
|
149
149
|
}
|
|
150
|
-
}), [
|
|
150
|
+
}), [i, a] = A(!n), [p, f] = A(null), w = Z(() => {
|
|
151
151
|
const g = () => {
|
|
152
152
|
u();
|
|
153
153
|
};
|
|
@@ -156,44 +156,44 @@ function dn({ config: r, children: e }) {
|
|
|
156
156
|
baseUrl: r.baseUrl,
|
|
157
157
|
// App info
|
|
158
158
|
appInfo: n,
|
|
159
|
-
isAppLoading:
|
|
159
|
+
isAppLoading: i,
|
|
160
160
|
appError: p,
|
|
161
161
|
retryApp: g
|
|
162
162
|
};
|
|
163
|
-
}, [r, n,
|
|
163
|
+
}, [r, n, i, p]), u = re(
|
|
164
164
|
async (g = !1) => {
|
|
165
165
|
if (!(!g && t.enabled && n))
|
|
166
166
|
try {
|
|
167
167
|
a(!0), f(null);
|
|
168
|
-
const
|
|
169
|
-
if (
|
|
168
|
+
const T = new ie(r.baseUrl), N = await new $e(T, {}).getPublicAppInfo(r.appId);
|
|
169
|
+
if (o(N), t.enabled)
|
|
170
170
|
try {
|
|
171
|
-
const
|
|
172
|
-
data:
|
|
171
|
+
const M = {
|
|
172
|
+
data: N,
|
|
173
173
|
timestamp: Date.now(),
|
|
174
174
|
appId: r.appId
|
|
175
175
|
};
|
|
176
|
-
localStorage.setItem(t.storageKey, JSON.stringify(
|
|
177
|
-
} catch (
|
|
178
|
-
console.warn("Failed to cache app info:",
|
|
176
|
+
localStorage.setItem(t.storageKey, JSON.stringify(M));
|
|
177
|
+
} catch (M) {
|
|
178
|
+
console.warn("Failed to cache app info:", M);
|
|
179
179
|
}
|
|
180
|
-
} catch (
|
|
181
|
-
const
|
|
182
|
-
f(
|
|
180
|
+
} catch (T) {
|
|
181
|
+
const I = T instanceof Error ? T : new Error("Failed to load app information");
|
|
182
|
+
f(I), o(null);
|
|
183
183
|
} finally {
|
|
184
184
|
a(!1);
|
|
185
185
|
}
|
|
186
186
|
},
|
|
187
187
|
[r.baseUrl, r.appId, t, n]
|
|
188
|
-
),
|
|
188
|
+
), b = re(async () => {
|
|
189
189
|
if (!(!t.enabled || !n))
|
|
190
190
|
try {
|
|
191
191
|
const g = localStorage.getItem(t.storageKey);
|
|
192
192
|
if (!g) return;
|
|
193
|
-
const
|
|
194
|
-
if (Date.now() -
|
|
195
|
-
const
|
|
196
|
-
|
|
193
|
+
const T = JSON.parse(g);
|
|
194
|
+
if (Date.now() - T.timestamp > t.ttl * 0.5) {
|
|
195
|
+
const N = new ie(r.baseUrl), P = await new $e(N, {}).getPublicAppInfo(r.appId);
|
|
196
|
+
o(P);
|
|
197
197
|
const h = {
|
|
198
198
|
data: P,
|
|
199
199
|
timestamp: Date.now(),
|
|
@@ -206,8 +206,8 @@ function dn({ config: r, children: e }) {
|
|
|
206
206
|
}
|
|
207
207
|
}, [r, t, n]);
|
|
208
208
|
return X(() => {
|
|
209
|
-
n ?
|
|
210
|
-
}, []), /* @__PURE__ */ s(Re.Provider, { value:
|
|
209
|
+
n ? b() : u();
|
|
210
|
+
}, []), /* @__PURE__ */ s(Re.Provider, { value: w, children: e });
|
|
211
211
|
}
|
|
212
212
|
function ye() {
|
|
213
213
|
const r = oe(Re);
|
|
@@ -215,10 +215,10 @@ function ye() {
|
|
|
215
215
|
throw new Error("useApp must be used within an AppProvider");
|
|
216
216
|
return r;
|
|
217
217
|
}
|
|
218
|
-
function
|
|
218
|
+
function Ve() {
|
|
219
219
|
return oe(Re);
|
|
220
220
|
}
|
|
221
|
-
const
|
|
221
|
+
const hn = ye;
|
|
222
222
|
class Ae {
|
|
223
223
|
constructor(e = {}) {
|
|
224
224
|
this.refreshPromise = null, this.refreshQueue = [], 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.baseUrl = e.baseUrl || "", this.tokenStorage = e.tokenStorage || this.createTokenStorage(this.storageKey);
|
|
@@ -256,13 +256,13 @@ class Ae {
|
|
|
256
256
|
this.tokenStorage.set(t);
|
|
257
257
|
}
|
|
258
258
|
getTokens() {
|
|
259
|
-
const { accessToken: e, refreshToken: t, expiresAt: n, expiresIn:
|
|
259
|
+
const { accessToken: e, refreshToken: t, expiresAt: n, expiresIn: o, tokenType: i } = this.tokenStorage.get() || {};
|
|
260
260
|
return e ? {
|
|
261
261
|
accessToken: e,
|
|
262
262
|
refreshToken: t,
|
|
263
263
|
expiresAt: n,
|
|
264
|
-
expiresIn:
|
|
265
|
-
tokenType:
|
|
264
|
+
expiresIn: o,
|
|
265
|
+
tokenType: i
|
|
266
266
|
} : null;
|
|
267
267
|
}
|
|
268
268
|
clearTokens() {
|
|
@@ -298,10 +298,10 @@ class Ae {
|
|
|
298
298
|
try {
|
|
299
299
|
await this.refreshPromise;
|
|
300
300
|
const t = this.getTokens(), n = t != null && t.accessToken ? { Authorization: `Bearer ${t.accessToken}` } : {};
|
|
301
|
-
return this.refreshQueue.forEach(({ resolve:
|
|
301
|
+
return this.refreshQueue.forEach(({ resolve: o }) => o(n)), this.refreshQueue = [], n;
|
|
302
302
|
} catch (t) {
|
|
303
303
|
const n = t instanceof Error ? t : new Error("Token refresh failed");
|
|
304
|
-
return this.refreshQueue.forEach(({ reject:
|
|
304
|
+
return this.refreshQueue.forEach(({ reject: o }) => o(n)), this.refreshQueue = [], this.clearSession(), this.onRefreshFailed && this.onRefreshFailed(), {};
|
|
305
305
|
} finally {
|
|
306
306
|
this.refreshPromise = null;
|
|
307
307
|
}
|
|
@@ -320,11 +320,11 @@ class Ae {
|
|
|
320
320
|
});
|
|
321
321
|
if (!n.ok)
|
|
322
322
|
throw new Error(`Token refresh failed: ${n.status} ${n.statusText}`);
|
|
323
|
-
const
|
|
323
|
+
const o = await n.json();
|
|
324
324
|
this.setTokens({
|
|
325
|
-
accessToken:
|
|
326
|
-
refreshToken:
|
|
327
|
-
expiresIn:
|
|
325
|
+
accessToken: o.accessToken,
|
|
326
|
+
refreshToken: o.refreshToken || e,
|
|
327
|
+
expiresIn: o.expiresIn
|
|
328
328
|
});
|
|
329
329
|
}
|
|
330
330
|
setUser(e) {
|
|
@@ -352,8 +352,8 @@ class Ae {
|
|
|
352
352
|
if (!(e != null && e.accessToken)) return null;
|
|
353
353
|
const t = e.accessToken.split(".");
|
|
354
354
|
if (t.length !== 3) return null;
|
|
355
|
-
const n = t[1],
|
|
356
|
-
return JSON.parse(
|
|
355
|
+
const n = t[1], o = atob(n.replace(/-/g, "+").replace(/_/g, "/"));
|
|
356
|
+
return JSON.parse(o);
|
|
357
357
|
} catch {
|
|
358
358
|
return null;
|
|
359
359
|
}
|
|
@@ -372,7 +372,7 @@ class Ae {
|
|
|
372
372
|
return e !== null && !this.isTokenExpired(e);
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
|
-
class
|
|
375
|
+
class ht {
|
|
376
376
|
constructor(e) {
|
|
377
377
|
this.httpService = e;
|
|
378
378
|
}
|
|
@@ -428,7 +428,7 @@ class dt {
|
|
|
428
428
|
});
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
|
-
class
|
|
431
|
+
class He {
|
|
432
432
|
constructor(e, t) {
|
|
433
433
|
this.httpService = e, this.sessionManager = t;
|
|
434
434
|
}
|
|
@@ -468,10 +468,10 @@ class De {
|
|
|
468
468
|
async getRolesByApp(e, t) {
|
|
469
469
|
const n = new URLSearchParams();
|
|
470
470
|
t != null && t.page && n.append("page", t.page.toString()), t != null && t.limit && n.append("limit", t.limit.toString()), t != null && t.sortBy && n.append("sortBy", t.sortBy), t != null && t.sortOrder && n.append("sortOrder", t.sortOrder);
|
|
471
|
-
const
|
|
471
|
+
const o = `/roles/app/${e}${n.toString() ? `?${n.toString()}` : ""}`, i = await this.httpService.get(o);
|
|
472
472
|
return {
|
|
473
|
-
roles:
|
|
474
|
-
meta:
|
|
473
|
+
roles: i.data,
|
|
474
|
+
meta: i.meta
|
|
475
475
|
};
|
|
476
476
|
}
|
|
477
477
|
async assignRole(e, t) {
|
|
@@ -493,9 +493,9 @@ class De {
|
|
|
493
493
|
async getUserRoles(e, t) {
|
|
494
494
|
if (!this.sessionManager)
|
|
495
495
|
throw new Error("SessionManager is required for private endpoints");
|
|
496
|
-
const n = await this.sessionManager.getAuthHeaders(),
|
|
497
|
-
t != null && t.page &&
|
|
498
|
-
const
|
|
496
|
+
const n = await this.sessionManager.getAuthHeaders(), o = new URLSearchParams();
|
|
497
|
+
t != null && t.page && o.append("page", t.page.toString()), t != null && t.limit && o.append("limit", t.limit.toString()), t != null && t.sortBy && o.append("sortBy", t.sortBy), t != null && t.sortOrder && o.append("sortOrder", t.sortOrder);
|
|
498
|
+
const i = `/roles/user/${e}${o.toString() ? `?${o.toString()}` : ""}`, a = await this.httpService.get(i, {
|
|
499
499
|
headers: n
|
|
500
500
|
});
|
|
501
501
|
return {
|
|
@@ -504,7 +504,7 @@ class De {
|
|
|
504
504
|
};
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
|
-
class
|
|
507
|
+
class gt {
|
|
508
508
|
constructor(e, t) {
|
|
509
509
|
this.httpService = e, this.sessionManager = t;
|
|
510
510
|
}
|
|
@@ -517,12 +517,12 @@ class ut {
|
|
|
517
517
|
async getUsers(e) {
|
|
518
518
|
const t = await this.sessionManager.getAuthHeaders(), n = new URLSearchParams();
|
|
519
519
|
e != null && e.page && n.append("page", e.page.toString()), e != null && e.limit && n.append("limit", e.limit.toString()), e != null && e.sortBy && n.append("sortBy", e.sortBy), e != null && e.sortOrder && n.append("sortOrder", e.sortOrder);
|
|
520
|
-
const
|
|
520
|
+
const o = `/users/${n.toString() ? `?${n.toString()}` : ""}`, i = await this.httpService.get(o, {
|
|
521
521
|
headers: t
|
|
522
522
|
});
|
|
523
523
|
return {
|
|
524
|
-
users:
|
|
525
|
-
meta:
|
|
524
|
+
users: i.data,
|
|
525
|
+
meta: i.meta
|
|
526
526
|
};
|
|
527
527
|
}
|
|
528
528
|
async getUserById(e) {
|
|
@@ -544,7 +544,7 @@ class ut {
|
|
|
544
544
|
});
|
|
545
545
|
}
|
|
546
546
|
}
|
|
547
|
-
class
|
|
547
|
+
class fe {
|
|
548
548
|
constructor(e, t, n) {
|
|
549
549
|
this.httpService = e, this.appId = t, this.sessionManager = n;
|
|
550
550
|
}
|
|
@@ -561,12 +561,12 @@ class pe {
|
|
|
561
561
|
throw new Error("SessionManager is required for private endpoints");
|
|
562
562
|
const t = await this.sessionManager.getAuthHeaders(), n = new URLSearchParams();
|
|
563
563
|
e != null && e.page && n.append("page", e.page.toString()), e != null && e.limit && n.append("limit", e.limit.toString()), e != null && e.sortBy && n.append("sortBy", e.sortBy), e != null && e.sortOrder && n.append("sortOrder", e.sortOrder);
|
|
564
|
-
const
|
|
564
|
+
const o = `/tenants/${n.toString() ? `?${n.toString()}` : ""}`, i = await this.httpService.get(o, {
|
|
565
565
|
headers: t
|
|
566
566
|
});
|
|
567
567
|
return {
|
|
568
|
-
tenants:
|
|
569
|
-
meta:
|
|
568
|
+
tenants: i.data,
|
|
569
|
+
meta: i.meta
|
|
570
570
|
};
|
|
571
571
|
}
|
|
572
572
|
async getTenantById(e) {
|
|
@@ -622,15 +622,15 @@ class pe {
|
|
|
622
622
|
)).data;
|
|
623
623
|
}
|
|
624
624
|
}
|
|
625
|
-
function
|
|
625
|
+
function pt(r, e) {
|
|
626
626
|
if (r === "localhost" || r.startsWith("127.") || r.startsWith("192.168."))
|
|
627
627
|
return null;
|
|
628
628
|
if (e) {
|
|
629
|
-
const
|
|
630
|
-
if (
|
|
629
|
+
const o = e.toLowerCase(), i = r.toLowerCase();
|
|
630
|
+
if (i === o || i === `www.${o}`)
|
|
631
631
|
return null;
|
|
632
|
-
if (
|
|
633
|
-
const a =
|
|
632
|
+
if (i.endsWith(`.${o}`)) {
|
|
633
|
+
const a = i.slice(0, -(o.length + 1));
|
|
634
634
|
return a === "www" ? null : a;
|
|
635
635
|
}
|
|
636
636
|
return null;
|
|
@@ -638,26 +638,26 @@ function ht(r, e) {
|
|
|
638
638
|
const n = r.split(".");
|
|
639
639
|
return n.length >= 3 && n[0] !== "www" ? n[0] : null;
|
|
640
640
|
}
|
|
641
|
-
function
|
|
642
|
-
const
|
|
643
|
-
return
|
|
641
|
+
function ft(r, e = "tenant", t) {
|
|
642
|
+
const o = new URLSearchParams(r).get(e);
|
|
643
|
+
return o ? (t && t.setItem("tenant", o), o) : t ? t.getItem("tenant") : null;
|
|
644
644
|
}
|
|
645
|
-
function
|
|
646
|
-
const { tenantMode: n, baseDomain:
|
|
647
|
-
return n === "subdomain" ?
|
|
645
|
+
function mt(r, e, t) {
|
|
646
|
+
const { tenantMode: n, baseDomain: o, selectorParam: i } = r;
|
|
647
|
+
return n === "subdomain" ? pt(e.hostname, o) : n === "selector" ? ft(e.search, i, t) : null;
|
|
648
648
|
}
|
|
649
|
-
function
|
|
649
|
+
function yt(r, e, t) {
|
|
650
650
|
if (t)
|
|
651
651
|
return `${r}.${t}`;
|
|
652
652
|
const n = e.split(".");
|
|
653
653
|
return n.length === 2 ? `${r}.${e}` : n.length >= 3 ? (n[0] = r, n.join(".")) : null;
|
|
654
654
|
}
|
|
655
655
|
const de = "_auth";
|
|
656
|
-
function
|
|
656
|
+
function Be(r) {
|
|
657
657
|
const e = JSON.stringify(r);
|
|
658
658
|
return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
659
659
|
}
|
|
660
|
-
function
|
|
660
|
+
function wt(r) {
|
|
661
661
|
try {
|
|
662
662
|
let e = r.replace(/-/g, "+").replace(/_/g, "/");
|
|
663
663
|
for (; e.length % 4; )
|
|
@@ -668,7 +668,7 @@ function mt(r) {
|
|
|
668
668
|
return null;
|
|
669
669
|
}
|
|
670
670
|
}
|
|
671
|
-
function
|
|
671
|
+
function bt() {
|
|
672
672
|
if (typeof window > "u")
|
|
673
673
|
return console.log("[CrossDomainAuth] SSR environment, skipping URL token extraction"), null;
|
|
674
674
|
const e = new URLSearchParams(window.location.search).get(de);
|
|
@@ -677,7 +677,7 @@ function yt() {
|
|
|
677
677
|
searchParams: window.location.search,
|
|
678
678
|
encodedLength: e == null ? void 0 : e.length
|
|
679
679
|
}), !e) return null;
|
|
680
|
-
const t =
|
|
680
|
+
const t = wt(e);
|
|
681
681
|
return console.log("[CrossDomainAuth] Token decode result:", {
|
|
682
682
|
success: !!t,
|
|
683
683
|
hasAccessToken: !!(t != null && t.accessToken),
|
|
@@ -685,7 +685,7 @@ function yt() {
|
|
|
685
685
|
expiresIn: t == null ? void 0 : t.expiresIn
|
|
686
686
|
}), t;
|
|
687
687
|
}
|
|
688
|
-
function
|
|
688
|
+
function St() {
|
|
689
689
|
if (typeof window > "u") return;
|
|
690
690
|
const r = new URL(window.location.href);
|
|
691
691
|
r.searchParams.delete(de), console.log("[CrossDomainAuth] Clearing auth tokens from URL", {
|
|
@@ -693,9 +693,9 @@ function wt() {
|
|
|
693
693
|
newUrl: r.toString()
|
|
694
694
|
}), window.history.replaceState({}, "", r.toString());
|
|
695
695
|
}
|
|
696
|
-
const Ie =
|
|
697
|
-
function
|
|
698
|
-
const { baseUrl: t, appInfo: n, appId:
|
|
696
|
+
const Ie = ue(null);
|
|
697
|
+
function gn({ config: r, children: e }) {
|
|
698
|
+
const { baseUrl: t, appInfo: n, appId: o } = ye(), i = re(() => typeof window > "u" ? null : mt(
|
|
699
699
|
{
|
|
700
700
|
tenantMode: r.tenantMode || "selector",
|
|
701
701
|
baseDomain: r.baseDomain,
|
|
@@ -706,69 +706,69 @@ function hn({ config: r, children: e }) {
|
|
|
706
706
|
search: window.location.search
|
|
707
707
|
},
|
|
708
708
|
window.localStorage
|
|
709
|
-
), [r.tenantMode, r.baseDomain, r.selectorParam]), [a, p] = A(() =>
|
|
709
|
+
), [r.tenantMode, r.baseDomain, r.selectorParam]), [a, p] = A(() => i()), f = Z(
|
|
710
710
|
() => {
|
|
711
|
-
var c,
|
|
711
|
+
var c, H, F;
|
|
712
712
|
return {
|
|
713
713
|
enabled: ((c = r.cache) == null ? void 0 : c.enabled) ?? !0,
|
|
714
|
-
ttl: ((
|
|
714
|
+
ttl: ((H = r.cache) == null ? void 0 : H.ttl) ?? 5 * 60 * 1e3,
|
|
715
715
|
// 5 minutes default
|
|
716
|
-
storageKey: ((
|
|
716
|
+
storageKey: ((F = r.cache) == null ? void 0 : F.storageKey) ?? `tenant_cache_${a || "default"}`
|
|
717
717
|
};
|
|
718
718
|
},
|
|
719
719
|
[r.cache, a]
|
|
720
|
-
), [
|
|
720
|
+
), [w, u] = A(() => {
|
|
721
721
|
if (r.initialTenant) return r.initialTenant;
|
|
722
722
|
if (!f.enabled || !a) return null;
|
|
723
723
|
try {
|
|
724
724
|
const c = localStorage.getItem(f.storageKey);
|
|
725
725
|
if (!c) return null;
|
|
726
|
-
const
|
|
727
|
-
return Date.now() -
|
|
726
|
+
const H = JSON.parse(c);
|
|
727
|
+
return Date.now() - H.timestamp < f.ttl && H.tenantSlug === a ? H.data : (localStorage.removeItem(f.storageKey), null);
|
|
728
728
|
} catch {
|
|
729
729
|
return null;
|
|
730
730
|
}
|
|
731
|
-
}), [
|
|
731
|
+
}), [b, g] = A(!w && !r.initialTenant), [T, I] = A(null), [N, M] = A(null), [P, h] = A(!1), [x, S] = A(null);
|
|
732
732
|
X(() => {
|
|
733
|
-
const c =
|
|
733
|
+
const c = i();
|
|
734
734
|
p(c);
|
|
735
|
-
}, [
|
|
736
|
-
const
|
|
737
|
-
async (c,
|
|
738
|
-
if (!(
|
|
735
|
+
}, [i]);
|
|
736
|
+
const L = (n == null ? void 0 : n.settingsSchema) || null, E = re(
|
|
737
|
+
async (c, H = !1) => {
|
|
738
|
+
if (!(!H && f.enabled && w && w.domain === c))
|
|
739
739
|
try {
|
|
740
|
-
g(!0),
|
|
741
|
-
const
|
|
740
|
+
g(!0), I(null);
|
|
741
|
+
const F = new ie(t), m = await new fe(F, o).getPublicTenantInfo(c);
|
|
742
742
|
if (u(m), f.enabled)
|
|
743
743
|
try {
|
|
744
|
-
const
|
|
744
|
+
const v = {
|
|
745
745
|
data: m,
|
|
746
746
|
timestamp: Date.now(),
|
|
747
747
|
tenantSlug: c
|
|
748
748
|
};
|
|
749
|
-
localStorage.setItem(f.storageKey, JSON.stringify(
|
|
750
|
-
} catch (
|
|
751
|
-
console.warn("Failed to cache tenant info:",
|
|
749
|
+
localStorage.setItem(f.storageKey, JSON.stringify(v));
|
|
750
|
+
} catch (v) {
|
|
751
|
+
console.warn("Failed to cache tenant info:", v);
|
|
752
752
|
}
|
|
753
|
-
} catch (
|
|
754
|
-
const y =
|
|
755
|
-
|
|
753
|
+
} catch (F) {
|
|
754
|
+
const y = F instanceof Error ? F : new Error("Failed to load tenant information");
|
|
755
|
+
I(y), u(null);
|
|
756
756
|
} finally {
|
|
757
757
|
g(!1);
|
|
758
758
|
}
|
|
759
759
|
},
|
|
760
|
-
[t,
|
|
760
|
+
[t, o, f, w]
|
|
761
761
|
), C = re(async () => {
|
|
762
|
-
if (!(!f.enabled || !
|
|
762
|
+
if (!(!f.enabled || !w || !a))
|
|
763
763
|
try {
|
|
764
764
|
const c = localStorage.getItem(f.storageKey);
|
|
765
765
|
if (!c) return;
|
|
766
|
-
const
|
|
767
|
-
if (Date.now() -
|
|
768
|
-
const y = new ie(t),
|
|
769
|
-
u(
|
|
766
|
+
const H = JSON.parse(c);
|
|
767
|
+
if (Date.now() - H.timestamp > f.ttl * 0.5) {
|
|
768
|
+
const y = new ie(t), v = await new fe(y, o).getPublicTenantInfo(a);
|
|
769
|
+
u(v);
|
|
770
770
|
const G = {
|
|
771
|
-
data:
|
|
771
|
+
data: v,
|
|
772
772
|
timestamp: Date.now(),
|
|
773
773
|
tenantSlug: a
|
|
774
774
|
};
|
|
@@ -777,47 +777,47 @@ function hn({ config: r, children: e }) {
|
|
|
777
777
|
} catch (c) {
|
|
778
778
|
console.warn("Background tenant refresh failed:", c);
|
|
779
779
|
}
|
|
780
|
-
}, [t,
|
|
781
|
-
if (
|
|
780
|
+
}, [t, o, f, w, a]), R = re(async () => {
|
|
781
|
+
if (w != null && w.id)
|
|
782
782
|
try {
|
|
783
|
-
h(!0),
|
|
784
|
-
const c = new ie(t),
|
|
785
|
-
|
|
783
|
+
h(!0), S(null);
|
|
784
|
+
const c = new ie(t), F = await new fe(c, w.appId).getTenantSettings(w.id);
|
|
785
|
+
M(F);
|
|
786
786
|
} catch (c) {
|
|
787
|
-
const
|
|
788
|
-
|
|
787
|
+
const H = c instanceof Error ? c : new Error("Failed to load tenant settings");
|
|
788
|
+
S(H), M(null);
|
|
789
789
|
} finally {
|
|
790
790
|
h(!1);
|
|
791
791
|
}
|
|
792
|
-
}, [t,
|
|
792
|
+
}, [t, w]), $ = re(() => {
|
|
793
793
|
R();
|
|
794
794
|
}, [R]), l = re(
|
|
795
795
|
(c) => {
|
|
796
|
-
if (!
|
|
796
|
+
if (!L)
|
|
797
797
|
return { isValid: !0, errors: [] };
|
|
798
|
-
const
|
|
798
|
+
const H = [];
|
|
799
799
|
try {
|
|
800
|
-
return
|
|
801
|
-
var
|
|
802
|
-
const m = c[
|
|
803
|
-
if ((
|
|
804
|
-
|
|
800
|
+
return L.properties && Object.entries(L.properties).forEach(([F, y]) => {
|
|
801
|
+
var v;
|
|
802
|
+
const m = c[F];
|
|
803
|
+
if ((v = L.required) != null && v.includes(F) && m == null) {
|
|
804
|
+
H.push(`Field '${F}' is required`);
|
|
805
805
|
return;
|
|
806
806
|
}
|
|
807
807
|
if (m != null) {
|
|
808
808
|
if (y.type) {
|
|
809
809
|
const G = y.type, J = typeof m;
|
|
810
|
-
G === "string" && J !== "string" ?
|
|
810
|
+
G === "string" && J !== "string" ? H.push(`Field '${F}' must be a string`) : (G === "number" || G === "integer") && J !== "number" ? H.push(`Field '${F}' must be a number`) : G === "boolean" && J !== "boolean" ? H.push(`Field '${F}' must be a boolean`) : G === "array" && !Array.isArray(m) && H.push(`Field '${F}' must be an array`);
|
|
811
811
|
}
|
|
812
|
-
y.minLength !== void 0 && typeof m == "string" && m.length < y.minLength &&
|
|
813
|
-
`Field '${
|
|
814
|
-
), y.maxLength !== void 0 && typeof m == "string" && m.length > y.maxLength &&
|
|
815
|
-
`Field '${
|
|
816
|
-
), y.minimum !== void 0 && typeof m == "number" && m < y.minimum &&
|
|
812
|
+
y.minLength !== void 0 && typeof m == "string" && m.length < y.minLength && H.push(
|
|
813
|
+
`Field '${F}' must be at least ${y.minLength} characters long`
|
|
814
|
+
), y.maxLength !== void 0 && typeof m == "string" && m.length > y.maxLength && H.push(
|
|
815
|
+
`Field '${F}' must be no more than ${y.maxLength} characters long`
|
|
816
|
+
), y.minimum !== void 0 && typeof m == "number" && m < y.minimum && H.push(`Field '${F}' must be at least ${y.minimum}`), y.maximum !== void 0 && typeof m == "number" && m > y.maximum && H.push(`Field '${F}' must be no more than ${y.maximum}`), y.pattern && typeof m == "string" && (new RegExp(y.pattern).test(m) || H.push(`Field '${F}' does not match the required pattern`)), y.enum && !y.enum.includes(m) && H.push(`Field '${F}' must be one of: ${y.enum.join(", ")}`);
|
|
817
817
|
}
|
|
818
818
|
}), {
|
|
819
|
-
isValid:
|
|
820
|
-
errors:
|
|
819
|
+
isValid: H.length === 0,
|
|
820
|
+
errors: H
|
|
821
821
|
};
|
|
822
822
|
} catch {
|
|
823
823
|
return {
|
|
@@ -826,18 +826,18 @@ function hn({ config: r, children: e }) {
|
|
|
826
826
|
};
|
|
827
827
|
}
|
|
828
828
|
},
|
|
829
|
-
[
|
|
829
|
+
[L]
|
|
830
830
|
);
|
|
831
831
|
X(() => {
|
|
832
|
-
!r.initialTenant && a ?
|
|
833
|
-
}, [r.initialTenant, a,
|
|
834
|
-
|
|
835
|
-
}, [
|
|
836
|
-
const
|
|
837
|
-
(c,
|
|
838
|
-
const { mode:
|
|
839
|
-
if (localStorage.setItem("tenant", c),
|
|
840
|
-
const G = window.location.hostname, J =
|
|
832
|
+
!r.initialTenant && a ? w ? C() : E(a) : !r.initialTenant && !a && (u(null), I(null), g(!1));
|
|
833
|
+
}, [r.initialTenant, a, w, E, C]), X(() => {
|
|
834
|
+
w != null && w.id ? R() : (M(null), S(null), h(!1));
|
|
835
|
+
}, [w == null ? void 0 : w.id, R]);
|
|
836
|
+
const D = re(
|
|
837
|
+
(c, H) => {
|
|
838
|
+
const { mode: F = "reload", tokens: y, redirectPath: m } = H || {}, v = r.tenantMode || "selector";
|
|
839
|
+
if (localStorage.setItem("tenant", c), v === "subdomain") {
|
|
840
|
+
const G = window.location.hostname, J = yt(
|
|
841
841
|
c,
|
|
842
842
|
G,
|
|
843
843
|
r.baseDomain
|
|
@@ -850,56 +850,56 @@ function hn({ config: r, children: e }) {
|
|
|
850
850
|
return;
|
|
851
851
|
}
|
|
852
852
|
const q = m || window.location.pathname, O = new URL(`${window.location.protocol}//${J}${q}`);
|
|
853
|
-
new URLSearchParams(window.location.search).forEach((
|
|
854
|
-
|
|
855
|
-
}), y && O.searchParams.set(de,
|
|
856
|
-
} else if (
|
|
853
|
+
new URLSearchParams(window.location.search).forEach((k, K) => {
|
|
854
|
+
K !== de && O.searchParams.set(K, k);
|
|
855
|
+
}), y && O.searchParams.set(de, Be(y)), window.location.href = O.toString();
|
|
856
|
+
} else if (v === "selector") {
|
|
857
857
|
const G = m || window.location.pathname, J = new URLSearchParams(window.location.search);
|
|
858
|
-
if (J.set(r.selectorParam || "tenant", c), J.delete(de), y && J.set(de,
|
|
858
|
+
if (J.set(r.selectorParam || "tenant", c), J.delete(de), y && J.set(de, Be(y)), F === "reload") {
|
|
859
859
|
const q = `${G}?${J.toString()}${window.location.hash}`;
|
|
860
860
|
window.location.href = q;
|
|
861
861
|
} else {
|
|
862
862
|
const q = `${G}?${J.toString()}${window.location.hash}`;
|
|
863
|
-
window.history.pushState({}, "", q), p(c),
|
|
863
|
+
window.history.pushState({}, "", q), p(c), E(c);
|
|
864
864
|
}
|
|
865
865
|
}
|
|
866
866
|
},
|
|
867
|
-
[r.tenantMode, r.selectorParam, r.baseDomain,
|
|
868
|
-
),
|
|
867
|
+
[r.tenantMode, r.selectorParam, r.baseDomain, E]
|
|
868
|
+
), U = Z(() => ({
|
|
869
869
|
// Tenant info
|
|
870
|
-
tenant:
|
|
870
|
+
tenant: w,
|
|
871
871
|
tenantSlug: a,
|
|
872
|
-
isTenantLoading:
|
|
873
|
-
tenantError:
|
|
872
|
+
isTenantLoading: b,
|
|
873
|
+
tenantError: T,
|
|
874
874
|
retryTenant: () => {
|
|
875
|
-
a &&
|
|
875
|
+
a && E(a);
|
|
876
876
|
},
|
|
877
877
|
// Settings
|
|
878
|
-
settings:
|
|
879
|
-
settingsSchema:
|
|
878
|
+
settings: N,
|
|
879
|
+
settingsSchema: L,
|
|
880
880
|
isSettingsLoading: P,
|
|
881
881
|
settingsError: x,
|
|
882
882
|
// Actions
|
|
883
|
-
refreshSettings:
|
|
884
|
-
switchTenant:
|
|
883
|
+
refreshSettings: $,
|
|
884
|
+
switchTenant: D,
|
|
885
885
|
// Validation
|
|
886
886
|
validateSettings: l
|
|
887
887
|
}), [
|
|
888
|
-
b,
|
|
889
|
-
a,
|
|
890
888
|
w,
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
889
|
+
a,
|
|
890
|
+
b,
|
|
891
|
+
T,
|
|
892
|
+
N,
|
|
893
|
+
L,
|
|
894
894
|
P,
|
|
895
895
|
x,
|
|
896
|
-
|
|
897
|
-
|
|
896
|
+
$,
|
|
897
|
+
D,
|
|
898
898
|
l
|
|
899
899
|
]);
|
|
900
|
-
return /* @__PURE__ */ s(Ie.Provider, { value:
|
|
900
|
+
return /* @__PURE__ */ s(Ie.Provider, { value: U, children: e });
|
|
901
901
|
}
|
|
902
|
-
function
|
|
902
|
+
function he() {
|
|
903
903
|
const r = oe(Ie);
|
|
904
904
|
if (!r)
|
|
905
905
|
throw new Error("useTenant must be used within a TenantProvider");
|
|
@@ -908,93 +908,93 @@ function ue() {
|
|
|
908
908
|
function Se() {
|
|
909
909
|
return oe(Ie);
|
|
910
910
|
}
|
|
911
|
-
const
|
|
912
|
-
function
|
|
913
|
-
const { settings: r, settingsSchema: e, isSettingsLoading: t, settingsError: n, validateSettings:
|
|
911
|
+
const pn = he;
|
|
912
|
+
function fn() {
|
|
913
|
+
const { settings: r, settingsSchema: e, isSettingsLoading: t, settingsError: n, validateSettings: o } = he();
|
|
914
914
|
return {
|
|
915
915
|
settings: r,
|
|
916
916
|
settingsSchema: e,
|
|
917
917
|
isLoading: t,
|
|
918
918
|
error: n,
|
|
919
|
-
validateSettings:
|
|
919
|
+
validateSettings: o
|
|
920
920
|
};
|
|
921
921
|
}
|
|
922
|
-
function
|
|
923
|
-
const { tenant: r, tenantSlug: e, isTenantLoading: t, tenantError: n, retryTenant:
|
|
922
|
+
function ge() {
|
|
923
|
+
const { tenant: r, tenantSlug: e, isTenantLoading: t, tenantError: n, retryTenant: o } = he();
|
|
924
924
|
return {
|
|
925
925
|
tenant: r,
|
|
926
926
|
tenantSlug: e,
|
|
927
927
|
isLoading: t,
|
|
928
928
|
error: n,
|
|
929
|
-
retry:
|
|
929
|
+
retry: o
|
|
930
930
|
};
|
|
931
931
|
}
|
|
932
|
-
const Me =
|
|
933
|
-
function
|
|
934
|
-
const { appId: t, baseUrl: n } = ye(), { tenant:
|
|
932
|
+
const Me = ue(null);
|
|
933
|
+
function mn({ config: r = {}, children: e }) {
|
|
934
|
+
const { appId: t, baseUrl: n } = ye(), { tenant: o, tenantSlug: i, switchTenant: a } = he(), [p, f] = A(r.initialRoles || []), [w, u] = A(!r.initialRoles), [b, g] = A(null), [T, I] = A(!1), [N, M] = A(null), [P, h] = A(0), [x, S] = A(() => {
|
|
935
935
|
try {
|
|
936
|
-
const
|
|
937
|
-
return
|
|
936
|
+
const k = localStorage.getItem("userTenants");
|
|
937
|
+
return k ? JSON.parse(k) : [];
|
|
938
938
|
} catch {
|
|
939
939
|
return [];
|
|
940
940
|
}
|
|
941
|
-
}), [
|
|
942
|
-
C.current.done || (C.current.done = !0, C.current.urlTokens =
|
|
941
|
+
}), [L, E] = A(!1), C = We({ done: !1, urlTokens: null });
|
|
942
|
+
C.current.done || (C.current.done = !0, C.current.urlTokens = bt(), C.current.urlTokens && console.log(
|
|
943
943
|
"[AuthProvider] SYNC: URL tokens found, will block isAuthReady until user loaded"
|
|
944
944
|
));
|
|
945
|
-
const [R,
|
|
946
|
-
const
|
|
947
|
-
return console.log("[AuthProvider] SYNC: isLoadingAfterUrlTokens initial:",
|
|
948
|
-
}), l =
|
|
949
|
-
const
|
|
950
|
-
tenantSlug:
|
|
945
|
+
const [R, $] = A(() => {
|
|
946
|
+
const k = C.current.urlTokens !== null;
|
|
947
|
+
return console.log("[AuthProvider] SYNC: isLoadingAfterUrlTokens initial:", k), k;
|
|
948
|
+
}), l = Z(() => {
|
|
949
|
+
const k = new Ae({
|
|
950
|
+
tenantSlug: i,
|
|
951
951
|
onRefreshFailed: r.onRefreshFailed,
|
|
952
952
|
baseUrl: n
|
|
953
953
|
});
|
|
954
|
-
return C.current.urlTokens && (console.log("[AuthProvider] SYNC: Saving URL tokens to session manager"),
|
|
954
|
+
return C.current.urlTokens && (console.log("[AuthProvider] SYNC: Saving URL tokens to session manager"), k.setTokens({
|
|
955
955
|
accessToken: C.current.urlTokens.accessToken,
|
|
956
956
|
refreshToken: C.current.urlTokens.refreshToken,
|
|
957
957
|
expiresIn: C.current.urlTokens.expiresIn
|
|
958
|
-
}), console.log("[AuthProvider] SYNC: Session valid:",
|
|
959
|
-
}, [
|
|
960
|
-
const
|
|
961
|
-
return
|
|
962
|
-
}, [n, l]), c =
|
|
963
|
-
const
|
|
958
|
+
}), console.log("[AuthProvider] SYNC: Session valid:", k.hasValidSession())), k;
|
|
959
|
+
}, [i, n, r.onRefreshFailed]), D = C.current.done && !R, U = Z(() => {
|
|
960
|
+
const k = new ie(n);
|
|
961
|
+
return k.setSessionManager(l), k;
|
|
962
|
+
}, [n, l]), c = Z(() => new ht(new ie(n)), [n]), H = Z(() => new gt(U, l), [U, l]), F = Z(() => new He(new ie(n)), [n]), y = Z(() => b || l.getUser(), [b, l]), m = Z(() => y != null && y.roleId && p.find((k) => k.id === y.roleId) || null, [y, p]), v = Z(() => (m == null ? void 0 : m.permissions) || [], [m]), G = Z(() => l.hasValidSession() && b !== null, [l, b]), J = 5 * 60 * 1e3, q = Z(() => {
|
|
963
|
+
const k = async (B = !1) => {
|
|
964
964
|
try {
|
|
965
965
|
if (!l.hasValidSession())
|
|
966
966
|
return;
|
|
967
967
|
const z = Date.now();
|
|
968
|
-
if (!
|
|
968
|
+
if (!B && z - P < J && b)
|
|
969
969
|
return;
|
|
970
970
|
const W = l.getUserId();
|
|
971
971
|
if (!W) {
|
|
972
972
|
console.warn("[AuthProvider] No userId available in token or storage");
|
|
973
973
|
return;
|
|
974
974
|
}
|
|
975
|
-
|
|
976
|
-
const Q = await
|
|
975
|
+
I(!0), M(null);
|
|
976
|
+
const Q = await H.getUserById(W);
|
|
977
977
|
g(Q), l.setUser(Q), h(Date.now());
|
|
978
978
|
} catch (z) {
|
|
979
979
|
const Y = z instanceof Error ? z : new Error("Failed to load user data");
|
|
980
|
-
|
|
980
|
+
M(Y), console.error("[AuthProvider] Failed to load user data:", Y);
|
|
981
981
|
} finally {
|
|
982
|
-
|
|
982
|
+
I(!1);
|
|
983
983
|
}
|
|
984
|
-
},
|
|
985
|
-
await
|
|
986
|
-
}, ce = async (
|
|
987
|
-
var
|
|
988
|
-
const { username: z, password: Y, tenantSlug: W, redirectPath: Q } =
|
|
989
|
-
let ee =
|
|
990
|
-
W && (ee = (await new
|
|
984
|
+
}, K = async () => {
|
|
985
|
+
await k();
|
|
986
|
+
}, ce = async (B) => {
|
|
987
|
+
var Ce;
|
|
988
|
+
const { username: z, password: Y, tenantSlug: W, redirectPath: Q } = B;
|
|
989
|
+
let ee = o == null ? void 0 : o.id, te = i, ne = l;
|
|
990
|
+
W && (ee = (await new fe(U, t).getPublicTenantInfo(W)).id, te = W);
|
|
991
991
|
const j = await c.login({
|
|
992
992
|
username: z,
|
|
993
993
|
password: Y,
|
|
994
994
|
appId: t,
|
|
995
995
|
tenantId: ee
|
|
996
|
-
}),
|
|
997
|
-
if (
|
|
996
|
+
}), pe = W && W !== i;
|
|
997
|
+
if (pe && (ne = new Ae({
|
|
998
998
|
tenantSlug: te,
|
|
999
999
|
baseUrl: n
|
|
1000
1000
|
})), ne.setTokens({
|
|
@@ -1004,20 +1004,20 @@ function fn({ config: r = {}, children: e }) {
|
|
|
1004
1004
|
}), j.user) {
|
|
1005
1005
|
ne.setUser(j.user), g(j.user);
|
|
1006
1006
|
try {
|
|
1007
|
-
await
|
|
1007
|
+
await k();
|
|
1008
1008
|
} catch (we) {
|
|
1009
1009
|
console.warn("Failed to load complete user data after login:", we);
|
|
1010
1010
|
}
|
|
1011
1011
|
}
|
|
1012
1012
|
if (j.tenants && j.tenants.length > 0) {
|
|
1013
|
-
|
|
1013
|
+
S(j.tenants);
|
|
1014
1014
|
try {
|
|
1015
1015
|
localStorage.setItem("userTenants", JSON.stringify(j.tenants));
|
|
1016
1016
|
} catch {
|
|
1017
1017
|
}
|
|
1018
1018
|
}
|
|
1019
|
-
const ke = ((
|
|
1020
|
-
if (
|
|
1019
|
+
const ke = ((Ce = j.user) == null ? void 0 : Ce.tenantId) !== null;
|
|
1020
|
+
if (E(ke), pe && te && te !== i && a(te, {
|
|
1021
1021
|
tokens: {
|
|
1022
1022
|
accessToken: j.accessToken,
|
|
1023
1023
|
refreshToken: j.refreshToken,
|
|
@@ -1025,7 +1025,7 @@ function fn({ config: r = {}, children: e }) {
|
|
|
1025
1025
|
},
|
|
1026
1026
|
redirectPath: Q
|
|
1027
1027
|
}), !ke && j.tenants && j.tenants.length > 0) {
|
|
1028
|
-
const we =
|
|
1028
|
+
const we = B.autoSwitch !== !1 && r.autoSwitchSingleTenant !== !1;
|
|
1029
1029
|
if (j.tenants.length === 1 && we) {
|
|
1030
1030
|
const Ue = j.tenants[0];
|
|
1031
1031
|
a(Ue.subdomain, {
|
|
@@ -1039,13 +1039,13 @@ function fn({ config: r = {}, children: e }) {
|
|
|
1039
1039
|
} else j.tenants.length > 1 && r.onTenantSelectionRequired && r.onTenantSelectionRequired(j.tenants);
|
|
1040
1040
|
}
|
|
1041
1041
|
return j;
|
|
1042
|
-
}, ve = async (
|
|
1043
|
-
const { email: z, phoneNumber: Y, name: W, password: Q, lastName: ee, tenantId: te } =
|
|
1042
|
+
}, ve = async (B) => {
|
|
1043
|
+
const { email: z, phoneNumber: Y, name: W, password: Q, lastName: ee, tenantId: te } = B;
|
|
1044
1044
|
if (!z && !Y)
|
|
1045
1045
|
throw new Error("Either email or phoneNumber is required");
|
|
1046
1046
|
if (!W || !Q)
|
|
1047
1047
|
throw new Error("Name and password are required");
|
|
1048
|
-
const ne = te ?? (
|
|
1048
|
+
const ne = te ?? (o == null ? void 0 : o.id);
|
|
1049
1049
|
return await c.signup({
|
|
1050
1050
|
email: z,
|
|
1051
1051
|
phoneNumber: Y,
|
|
@@ -1055,8 +1055,8 @@ function fn({ config: r = {}, children: e }) {
|
|
|
1055
1055
|
lastName: ee,
|
|
1056
1056
|
appId: t
|
|
1057
1057
|
});
|
|
1058
|
-
},
|
|
1059
|
-
const { email: z, phoneNumber: Y, name: W, password: Q, tenantName: ee, lastName: te } =
|
|
1058
|
+
}, Ye = async (B) => {
|
|
1059
|
+
const { email: z, phoneNumber: Y, name: W, password: Q, tenantName: ee, lastName: te } = B;
|
|
1060
1060
|
if (!z && !Y)
|
|
1061
1061
|
throw new Error("Either email or phoneNumber is required");
|
|
1062
1062
|
if (!W || !Q || !ee)
|
|
@@ -1070,19 +1070,19 @@ function fn({ config: r = {}, children: e }) {
|
|
|
1070
1070
|
appId: t,
|
|
1071
1071
|
lastName: te
|
|
1072
1072
|
});
|
|
1073
|
-
},
|
|
1074
|
-
const { currentPassword: z, newPassword: Y } =
|
|
1073
|
+
}, Qe = async (B) => {
|
|
1074
|
+
const { currentPassword: z, newPassword: Y } = B, W = await l.getAuthHeaders();
|
|
1075
1075
|
await c.changePassword({ currentPassword: z, newPassword: Y }, W);
|
|
1076
|
-
},
|
|
1077
|
-
const { email: z, tenantId: Y } =
|
|
1076
|
+
}, Xe = async (B) => {
|
|
1077
|
+
const { email: z, tenantId: Y } = B, W = Y ?? (o == null ? void 0 : o.id);
|
|
1078
1078
|
if (!W)
|
|
1079
1079
|
throw new Error("tenantId is required for password reset");
|
|
1080
1080
|
await c.requestPasswordReset({ email: z, tenantId: W });
|
|
1081
|
-
},
|
|
1082
|
-
const { token: z, newPassword: Y } =
|
|
1081
|
+
}, et = async (B) => {
|
|
1082
|
+
const { token: z, newPassword: Y } = B;
|
|
1083
1083
|
await c.confirmPasswordReset({ token: z, newPassword: Y });
|
|
1084
|
-
},
|
|
1085
|
-
const { email: z, frontendUrl: Y, name: W, lastName: Q, tenantId: ee } =
|
|
1084
|
+
}, tt = async (B) => {
|
|
1085
|
+
const { email: z, frontendUrl: Y, name: W, lastName: Q, tenantId: ee } = B, te = ee ?? (o == null ? void 0 : o.id);
|
|
1086
1086
|
if (!te)
|
|
1087
1087
|
throw new Error("tenantId is required for magic link authentication");
|
|
1088
1088
|
return await c.sendMagicLink({
|
|
@@ -1093,16 +1093,16 @@ function fn({ config: r = {}, children: e }) {
|
|
|
1093
1093
|
lastName: Q,
|
|
1094
1094
|
appId: t
|
|
1095
1095
|
});
|
|
1096
|
-
},
|
|
1097
|
-
const { token: z, email: Y, tenantSlug: W } =
|
|
1098
|
-
let Q =
|
|
1099
|
-
W && (Q = (await new
|
|
1096
|
+
}, nt = async (B) => {
|
|
1097
|
+
const { token: z, email: Y, tenantSlug: W } = B;
|
|
1098
|
+
let Q = o == null ? void 0 : o.id, ee = i, te = l;
|
|
1099
|
+
W && (Q = (await new fe(U, t).getPublicTenantInfo(W)).id, ee = W);
|
|
1100
1100
|
const ne = await c.verifyMagicLink({
|
|
1101
1101
|
token: z,
|
|
1102
1102
|
email: Y,
|
|
1103
1103
|
appId: t,
|
|
1104
1104
|
tenantId: Q
|
|
1105
|
-
}), j = W && W !==
|
|
1105
|
+
}), j = W && W !== i;
|
|
1106
1106
|
if (j && (te = new Ae({
|
|
1107
1107
|
tenantSlug: ee,
|
|
1108
1108
|
baseUrl: n
|
|
@@ -1113,113 +1113,113 @@ function fn({ config: r = {}, children: e }) {
|
|
|
1113
1113
|
}), ne.user) {
|
|
1114
1114
|
te.setUser(ne.user), g(ne.user);
|
|
1115
1115
|
try {
|
|
1116
|
-
await
|
|
1117
|
-
} catch (
|
|
1118
|
-
console.warn("Failed to load complete user data after magic link login:",
|
|
1116
|
+
await k();
|
|
1117
|
+
} catch (pe) {
|
|
1118
|
+
console.warn("Failed to load complete user data after magic link login:", pe);
|
|
1119
1119
|
}
|
|
1120
1120
|
}
|
|
1121
|
-
return j && ee && ee !==
|
|
1121
|
+
return j && ee && ee !== i && a(ee, {
|
|
1122
1122
|
tokens: {
|
|
1123
1123
|
accessToken: ne.accessToken,
|
|
1124
1124
|
refreshToken: ne.refreshToken,
|
|
1125
1125
|
expiresIn: ne.expiresIn
|
|
1126
1126
|
}
|
|
1127
1127
|
}), ne;
|
|
1128
|
-
},
|
|
1129
|
-
const
|
|
1130
|
-
if (!(
|
|
1128
|
+
}, rt = async () => {
|
|
1129
|
+
const B = l.getTokens();
|
|
1130
|
+
if (!(B != null && B.refreshToken))
|
|
1131
1131
|
throw new Error("No refresh token available");
|
|
1132
1132
|
const z = await c.refreshToken({
|
|
1133
|
-
refreshToken:
|
|
1133
|
+
refreshToken: B.refreshToken
|
|
1134
1134
|
});
|
|
1135
1135
|
l.setTokens({
|
|
1136
1136
|
accessToken: z.accessToken,
|
|
1137
|
-
refreshToken: z.refreshToken ||
|
|
1137
|
+
refreshToken: z.refreshToken || B.refreshToken,
|
|
1138
1138
|
expiresIn: z.expiresIn
|
|
1139
1139
|
});
|
|
1140
|
-
},
|
|
1141
|
-
l.clearSession(), g(null),
|
|
1140
|
+
}, st = () => {
|
|
1141
|
+
l.clearSession(), g(null), M(null), S([]), E(!1);
|
|
1142
1142
|
try {
|
|
1143
1143
|
localStorage.removeItem("userTenants");
|
|
1144
1144
|
} catch {
|
|
1145
1145
|
}
|
|
1146
|
-
},
|
|
1147
|
-
l.setTokens(
|
|
1148
|
-
},
|
|
1149
|
-
l.clearSession(), g(null),
|
|
1150
|
-
},
|
|
1146
|
+
}, ot = (B) => {
|
|
1147
|
+
l.setTokens(B);
|
|
1148
|
+
}, it = () => l.hasValidSession(), at = () => {
|
|
1149
|
+
l.clearSession(), g(null), M(null);
|
|
1150
|
+
}, lt = async () => {
|
|
1151
1151
|
if (t)
|
|
1152
1152
|
try {
|
|
1153
1153
|
u(!0);
|
|
1154
|
-
const { roles:
|
|
1155
|
-
f(
|
|
1156
|
-
} catch (
|
|
1157
|
-
console.error("Failed to fetch roles:",
|
|
1154
|
+
const { roles: B } = await F.getRolesByApp(t);
|
|
1155
|
+
f(B);
|
|
1156
|
+
} catch (B) {
|
|
1157
|
+
console.error("Failed to fetch roles:", B);
|
|
1158
1158
|
} finally {
|
|
1159
1159
|
u(!1);
|
|
1160
1160
|
}
|
|
1161
|
-
},
|
|
1162
|
-
await
|
|
1163
|
-
}, Te = (
|
|
1164
|
-
if (!
|
|
1161
|
+
}, ct = async () => {
|
|
1162
|
+
await lt();
|
|
1163
|
+
}, Te = (B) => {
|
|
1164
|
+
if (!v || v.length === 0)
|
|
1165
1165
|
return !1;
|
|
1166
|
-
if (typeof
|
|
1167
|
-
return
|
|
1168
|
-
const z = `${
|
|
1169
|
-
return
|
|
1166
|
+
if (typeof B == "string")
|
|
1167
|
+
return v.includes(B);
|
|
1168
|
+
const z = `${B.resource}.${B.action}`;
|
|
1169
|
+
return v.includes(z);
|
|
1170
1170
|
};
|
|
1171
1171
|
return {
|
|
1172
1172
|
// RFC-003: Authentication state
|
|
1173
1173
|
isAuthenticated: G,
|
|
1174
1174
|
sessionManager: l,
|
|
1175
|
-
authenticatedHttpService:
|
|
1175
|
+
authenticatedHttpService: U,
|
|
1176
1176
|
login: ce,
|
|
1177
1177
|
signup: ve,
|
|
1178
|
-
signupTenantAdmin:
|
|
1179
|
-
sendMagicLink:
|
|
1180
|
-
verifyMagicLink:
|
|
1181
|
-
changePassword:
|
|
1182
|
-
requestPasswordReset:
|
|
1183
|
-
confirmPasswordReset:
|
|
1184
|
-
refreshToken:
|
|
1185
|
-
logout:
|
|
1186
|
-
setTokens:
|
|
1187
|
-
hasValidSession:
|
|
1188
|
-
clearSession:
|
|
1189
|
-
currentUser:
|
|
1190
|
-
isUserLoading:
|
|
1191
|
-
userError:
|
|
1192
|
-
loadUserData:
|
|
1193
|
-
refreshUser:
|
|
1194
|
-
isAuthInitializing: !
|
|
1195
|
-
isAuthReady:
|
|
1178
|
+
signupTenantAdmin: Ye,
|
|
1179
|
+
sendMagicLink: tt,
|
|
1180
|
+
verifyMagicLink: nt,
|
|
1181
|
+
changePassword: Qe,
|
|
1182
|
+
requestPasswordReset: Xe,
|
|
1183
|
+
confirmPasswordReset: et,
|
|
1184
|
+
refreshToken: rt,
|
|
1185
|
+
logout: st,
|
|
1186
|
+
setTokens: ot,
|
|
1187
|
+
hasValidSession: it,
|
|
1188
|
+
clearSession: at,
|
|
1189
|
+
currentUser: b,
|
|
1190
|
+
isUserLoading: T,
|
|
1191
|
+
userError: N,
|
|
1192
|
+
loadUserData: k,
|
|
1193
|
+
refreshUser: K,
|
|
1194
|
+
isAuthInitializing: !D,
|
|
1195
|
+
isAuthReady: D,
|
|
1196
1196
|
userRole: m,
|
|
1197
|
-
userPermissions:
|
|
1197
|
+
userPermissions: v,
|
|
1198
1198
|
availableRoles: p,
|
|
1199
|
-
rolesLoading:
|
|
1199
|
+
rolesLoading: w,
|
|
1200
1200
|
hasPermission: Te,
|
|
1201
|
-
hasAnyPermission: (
|
|
1202
|
-
hasAllPermissions: (
|
|
1203
|
-
getUserPermissionStrings: () =>
|
|
1204
|
-
refreshRoles:
|
|
1201
|
+
hasAnyPermission: (B) => B.some((z) => Te(z)),
|
|
1202
|
+
hasAllPermissions: (B) => B.every((z) => Te(z)),
|
|
1203
|
+
getUserPermissionStrings: () => v || [],
|
|
1204
|
+
refreshRoles: ct,
|
|
1205
1205
|
// RFC-004: Multi-tenant user membership
|
|
1206
1206
|
userTenants: x,
|
|
1207
|
-
hasTenantContext:
|
|
1208
|
-
switchToTenant: async (
|
|
1207
|
+
hasTenantContext: L,
|
|
1208
|
+
switchToTenant: async (B, z) => {
|
|
1209
1209
|
const { redirectPath: Y } = z || {}, W = l.getTokens();
|
|
1210
1210
|
if (!(W != null && W.refreshToken))
|
|
1211
1211
|
throw new Error("No refresh token available for tenant switch");
|
|
1212
1212
|
const Q = await c.switchTenant({
|
|
1213
1213
|
refreshToken: W.refreshToken,
|
|
1214
|
-
tenantId:
|
|
1214
|
+
tenantId: B
|
|
1215
1215
|
});
|
|
1216
1216
|
l.setTokens({
|
|
1217
1217
|
accessToken: Q.accessToken,
|
|
1218
1218
|
refreshToken: W.refreshToken,
|
|
1219
1219
|
// Keep the same refresh token
|
|
1220
1220
|
expiresIn: Q.expiresIn
|
|
1221
|
-
}), g(Q.user), l.setUser(Q.user),
|
|
1222
|
-
const ee = x.find((te) => te.id ===
|
|
1221
|
+
}), g(Q.user), l.setUser(Q.user), E(!0);
|
|
1222
|
+
const ee = x.find((te) => te.id === B);
|
|
1223
1223
|
ee && a(ee.subdomain, {
|
|
1224
1224
|
tokens: {
|
|
1225
1225
|
accessToken: Q.accessToken,
|
|
@@ -1230,8 +1230,8 @@ function fn({ config: r = {}, children: e }) {
|
|
|
1230
1230
|
});
|
|
1231
1231
|
},
|
|
1232
1232
|
refreshUserTenants: async () => {
|
|
1233
|
-
const
|
|
1234
|
-
|
|
1233
|
+
const B = await l.getAuthHeaders(), z = await c.getUserTenants(B);
|
|
1234
|
+
S(z);
|
|
1235
1235
|
try {
|
|
1236
1236
|
localStorage.setItem("userTenants", JSON.stringify(z));
|
|
1237
1237
|
} catch {
|
|
@@ -1242,23 +1242,23 @@ function fn({ config: r = {}, children: e }) {
|
|
|
1242
1242
|
}, [
|
|
1243
1243
|
G,
|
|
1244
1244
|
l,
|
|
1245
|
-
|
|
1245
|
+
U,
|
|
1246
1246
|
c,
|
|
1247
|
-
|
|
1248
|
-
|
|
1247
|
+
H,
|
|
1248
|
+
F,
|
|
1249
1249
|
t,
|
|
1250
|
-
i,
|
|
1251
1250
|
o,
|
|
1251
|
+
i,
|
|
1252
1252
|
a,
|
|
1253
1253
|
p,
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
F,
|
|
1257
|
-
x,
|
|
1258
|
-
I,
|
|
1254
|
+
b,
|
|
1255
|
+
T,
|
|
1259
1256
|
N,
|
|
1257
|
+
x,
|
|
1258
|
+
L,
|
|
1259
|
+
D,
|
|
1260
1260
|
m,
|
|
1261
|
-
|
|
1261
|
+
v,
|
|
1262
1262
|
P,
|
|
1263
1263
|
J
|
|
1264
1264
|
]);
|
|
@@ -1266,10 +1266,10 @@ function fn({ config: r = {}, children: e }) {
|
|
|
1266
1266
|
!r.initialRoles && t && (async () => {
|
|
1267
1267
|
try {
|
|
1268
1268
|
u(!0);
|
|
1269
|
-
const
|
|
1269
|
+
const K = new ie(n), ce = new He(K), { roles: ve } = await ce.getRolesByApp(t);
|
|
1270
1270
|
f(ve);
|
|
1271
|
-
} catch (
|
|
1272
|
-
console.error("Failed to fetch roles:",
|
|
1271
|
+
} catch (K) {
|
|
1272
|
+
console.error("Failed to fetch roles:", K);
|
|
1273
1273
|
} finally {
|
|
1274
1274
|
u(!1);
|
|
1275
1275
|
}
|
|
@@ -1277,26 +1277,26 @@ function fn({ config: r = {}, children: e }) {
|
|
|
1277
1277
|
}, [t, n, r.initialRoles]);
|
|
1278
1278
|
const [O, V] = A(!1);
|
|
1279
1279
|
return X(() => {
|
|
1280
|
-
O || (V(!0), C.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"),
|
|
1281
|
-
console.error("[AuthProvider] Failed to load user data:",
|
|
1280
|
+
O || (V(!0), C.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), St(), $(!0), console.log("[AuthProvider] EFFECT: Loading user data (blocking isAuthReady)..."), q.loadUserData().catch((k) => {
|
|
1281
|
+
console.error("[AuthProvider] Failed to load user data:", k);
|
|
1282
1282
|
}).finally(() => {
|
|
1283
|
-
console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"),
|
|
1283
|
+
console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"), $(!1);
|
|
1284
1284
|
})));
|
|
1285
1285
|
}, [q, O]), X(() => {
|
|
1286
|
-
const
|
|
1287
|
-
|
|
1286
|
+
const k = l.getUser();
|
|
1287
|
+
k && l.hasValidSession() && g(k);
|
|
1288
1288
|
}, [l]), X(() => {
|
|
1289
|
-
O && (C.current.urlTokens || !
|
|
1289
|
+
O && (C.current.urlTokens || !b && !T && l.hasValidSession() && (console.log("[AuthProvider] Auto-loading user data..."), q.loadUserData().catch(() => {
|
|
1290
1290
|
})));
|
|
1291
|
-
}, [
|
|
1292
|
-
if (!l.hasValidSession() || !
|
|
1291
|
+
}, [b, T, q, l, O]), X(() => {
|
|
1292
|
+
if (!l.hasValidSession() || !b)
|
|
1293
1293
|
return;
|
|
1294
|
-
const
|
|
1294
|
+
const k = setInterval(() => {
|
|
1295
1295
|
q.loadUserData().catch(() => {
|
|
1296
1296
|
});
|
|
1297
1297
|
}, J);
|
|
1298
|
-
return () => clearInterval(
|
|
1299
|
-
}, [l,
|
|
1298
|
+
return () => clearInterval(k);
|
|
1299
|
+
}, [l, b, q, J]), /* @__PURE__ */ s(Me.Provider, { value: q, children: e });
|
|
1300
1300
|
}
|
|
1301
1301
|
function le() {
|
|
1302
1302
|
const r = oe(Me);
|
|
@@ -1307,7 +1307,7 @@ function le() {
|
|
|
1307
1307
|
function Le() {
|
|
1308
1308
|
return oe(Me);
|
|
1309
1309
|
}
|
|
1310
|
-
class
|
|
1310
|
+
class vt {
|
|
1311
1311
|
constructor(e, t) {
|
|
1312
1312
|
this.httpService = e, this.sessionManager = t;
|
|
1313
1313
|
}
|
|
@@ -1328,12 +1328,12 @@ class bt {
|
|
|
1328
1328
|
throw new Error("SessionManager is required for private endpoints");
|
|
1329
1329
|
const t = await this.sessionManager.getAuthHeaders(), n = new URLSearchParams();
|
|
1330
1330
|
e != null && e.page && n.append("page", e.page.toString()), e != null && e.limit && n.append("limit", e.limit.toString()), e != null && e.sortBy && n.append("sortBy", e.sortBy), e != null && e.sortOrder && n.append("sortOrder", e.sortOrder);
|
|
1331
|
-
const
|
|
1331
|
+
const o = `/feature-flags/${n.toString() ? `?${n.toString()}` : ""}`, i = await this.httpService.get(o, {
|
|
1332
1332
|
headers: t
|
|
1333
1333
|
});
|
|
1334
1334
|
return {
|
|
1335
|
-
featureFlags:
|
|
1336
|
-
meta:
|
|
1335
|
+
featureFlags: i.data,
|
|
1336
|
+
meta: i.meta
|
|
1337
1337
|
};
|
|
1338
1338
|
}
|
|
1339
1339
|
async getFeatureFlagById(e) {
|
|
@@ -1370,8 +1370,8 @@ class bt {
|
|
|
1370
1370
|
throw new Error("Tenant ID and App ID are required");
|
|
1371
1371
|
const n = new URLSearchParams();
|
|
1372
1372
|
n.append("tenantId", e), n.append("appId", t);
|
|
1373
|
-
const
|
|
1374
|
-
return (await this.httpService.get(
|
|
1373
|
+
const o = `/tenant-feature-flags${n.toString() ? `?${n.toString()}` : ""}`;
|
|
1374
|
+
return (await this.httpService.get(o, {
|
|
1375
1375
|
headers: { "X-Tenant-ID": e }
|
|
1376
1376
|
})).data;
|
|
1377
1377
|
}
|
|
@@ -1379,27 +1379,27 @@ class bt {
|
|
|
1379
1379
|
async getTenantFeatureFlag(e, t, n) {
|
|
1380
1380
|
if (!e || !t || !n)
|
|
1381
1381
|
throw new Error("Flag Key, Tenant ID and App ID are required");
|
|
1382
|
-
const
|
|
1383
|
-
|
|
1384
|
-
const
|
|
1385
|
-
return (await this.httpService.get(
|
|
1382
|
+
const o = new URLSearchParams();
|
|
1383
|
+
o.append("tenantId", t), o.append("appId", n);
|
|
1384
|
+
const i = `/tenant-feature-flags/${e}${o.toString() ? `?${o.toString()}` : ""}`;
|
|
1385
|
+
return (await this.httpService.get(i, {
|
|
1386
1386
|
headers: { "X-Tenant-ID": t }
|
|
1387
1387
|
})).data;
|
|
1388
1388
|
}
|
|
1389
1389
|
}
|
|
1390
|
-
const Ee =
|
|
1391
|
-
function
|
|
1392
|
-
const t =
|
|
1393
|
-
const h = new ie(
|
|
1394
|
-
return new
|
|
1395
|
-
}, [
|
|
1390
|
+
const Ee = ue(null);
|
|
1391
|
+
function yn({ config: r = {}, children: e }) {
|
|
1392
|
+
const t = Ve(), n = Se(), o = (t == null ? void 0 : t.baseUrl) ?? "", i = (t == null ? void 0 : t.appId) ?? "", a = (n == null ? void 0 : n.tenant) ?? null, [p, f] = A([]), [w, u] = A(!1), [b, g] = A(null), [T, I] = A(!1), N = Z(() => {
|
|
1393
|
+
const h = new ie(o);
|
|
1394
|
+
return new vt(h);
|
|
1395
|
+
}, [o]), M = async () => {
|
|
1396
1396
|
if (!(a != null && a.id)) {
|
|
1397
1397
|
f([]);
|
|
1398
1398
|
return;
|
|
1399
1399
|
}
|
|
1400
1400
|
u(!0), g(null);
|
|
1401
1401
|
try {
|
|
1402
|
-
const h = await
|
|
1402
|
+
const h = await N.getTenantFeatureFlags(a.id, i);
|
|
1403
1403
|
f(h);
|
|
1404
1404
|
} catch (h) {
|
|
1405
1405
|
const x = h instanceof Error ? h.message : "Failed to fetch feature flags";
|
|
@@ -1409,44 +1409,44 @@ function mn({ config: r = {}, children: e }) {
|
|
|
1409
1409
|
}
|
|
1410
1410
|
};
|
|
1411
1411
|
X(() => {
|
|
1412
|
-
if (!
|
|
1413
|
-
|
|
1414
|
-
const h = r.refreshInterval || 5 * 60 * 1e3, x = setInterval(
|
|
1412
|
+
if (!o || !i) return;
|
|
1413
|
+
M().finally(() => I(!0));
|
|
1414
|
+
const h = r.refreshInterval || 5 * 60 * 1e3, x = setInterval(M, h);
|
|
1415
1415
|
return () => clearInterval(x);
|
|
1416
|
-
}, [a == null ? void 0 : a.id,
|
|
1417
|
-
const P =
|
|
1416
|
+
}, [a == null ? void 0 : a.id, o, i, r.refreshInterval]);
|
|
1417
|
+
const P = Z(() => {
|
|
1418
1418
|
const h = (C) => {
|
|
1419
|
-
const R = p.find((
|
|
1419
|
+
const R = p.find(($) => $.key === C);
|
|
1420
1420
|
return (R == null ? void 0 : R.value) === !0;
|
|
1421
|
-
}, x = (C) => p.find((R) => R.key === C),
|
|
1422
|
-
const R = p.find((
|
|
1421
|
+
}, x = (C) => p.find((R) => R.key === C), S = (C) => {
|
|
1422
|
+
const R = p.find(($) => $.key === C);
|
|
1423
1423
|
return R ? R.value ? "enabled" : "disabled" : "not_found";
|
|
1424
|
-
},
|
|
1425
|
-
await
|
|
1426
|
-
},
|
|
1424
|
+
}, L = async () => {
|
|
1425
|
+
await M();
|
|
1426
|
+
}, E = !!(o && i) && (T || !(a != null && a.id));
|
|
1427
1427
|
return {
|
|
1428
1428
|
featureFlags: p,
|
|
1429
|
-
loading:
|
|
1430
|
-
error:
|
|
1431
|
-
isReady:
|
|
1429
|
+
loading: w,
|
|
1430
|
+
error: b,
|
|
1431
|
+
isReady: E,
|
|
1432
1432
|
isEnabled: h,
|
|
1433
1433
|
getFlag: x,
|
|
1434
|
-
getFlagState:
|
|
1435
|
-
refresh:
|
|
1434
|
+
getFlagState: S,
|
|
1435
|
+
refresh: L
|
|
1436
1436
|
};
|
|
1437
|
-
}, [p, b,
|
|
1437
|
+
}, [p, w, b, o, i, a == null ? void 0 : a.id, T]);
|
|
1438
1438
|
return /* @__PURE__ */ s(Ee.Provider, { value: P, children: e });
|
|
1439
1439
|
}
|
|
1440
|
-
function
|
|
1440
|
+
function Tt() {
|
|
1441
1441
|
const r = oe(Ee);
|
|
1442
1442
|
if (!r)
|
|
1443
1443
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1444
1444
|
return r;
|
|
1445
1445
|
}
|
|
1446
|
-
function
|
|
1446
|
+
function je() {
|
|
1447
1447
|
return oe(Ee);
|
|
1448
1448
|
}
|
|
1449
|
-
class
|
|
1449
|
+
class kt {
|
|
1450
1450
|
constructor(e, t) {
|
|
1451
1451
|
this.httpService = e, this.sessionManager = t;
|
|
1452
1452
|
}
|
|
@@ -1512,42 +1512,42 @@ class vt {
|
|
|
1512
1512
|
)).data;
|
|
1513
1513
|
}
|
|
1514
1514
|
}
|
|
1515
|
-
const Fe =
|
|
1516
|
-
function
|
|
1517
|
-
const t =
|
|
1518
|
-
const P = new ie(
|
|
1519
|
-
return new
|
|
1520
|
-
}, [
|
|
1521
|
-
if (!(
|
|
1515
|
+
const Fe = ue(void 0);
|
|
1516
|
+
function wn({ config: r = {}, children: e }) {
|
|
1517
|
+
const t = Ve(), n = Se(), o = (t == null ? void 0 : t.baseUrl) ?? "", i = (n == null ? void 0 : n.tenant) ?? null, [a, p] = A(null), [f, w] = A(!1), [u, b] = A(null), [g, T] = A(!1), I = Z(() => {
|
|
1518
|
+
const P = new ie(o);
|
|
1519
|
+
return new kt(P);
|
|
1520
|
+
}, [o]), N = async () => {
|
|
1521
|
+
if (!(i != null && i.id)) {
|
|
1522
1522
|
p(null);
|
|
1523
1523
|
return;
|
|
1524
1524
|
}
|
|
1525
|
-
|
|
1525
|
+
w(!0), b(null);
|
|
1526
1526
|
try {
|
|
1527
|
-
const P = await
|
|
1527
|
+
const P = await I.getTenantSubscriptionFeatures(i.id);
|
|
1528
1528
|
p(P);
|
|
1529
1529
|
} catch (P) {
|
|
1530
1530
|
const h = P instanceof Error ? P.message : "Failed to fetch subscription";
|
|
1531
|
-
|
|
1531
|
+
b(h), r.onError && r.onError(P instanceof Error ? P : new Error(h));
|
|
1532
1532
|
} finally {
|
|
1533
|
-
|
|
1533
|
+
w(!1);
|
|
1534
1534
|
}
|
|
1535
1535
|
};
|
|
1536
1536
|
X(() => {
|
|
1537
|
-
if (!
|
|
1538
|
-
const P = r.refreshInterval || 10 * 60 * 1e3, h = setInterval(
|
|
1537
|
+
if (!o || (N().finally(() => T(!0)), !r.refreshInterval)) return;
|
|
1538
|
+
const P = r.refreshInterval || 10 * 60 * 1e3, h = setInterval(N, P);
|
|
1539
1539
|
return () => clearInterval(h);
|
|
1540
|
-
}, [
|
|
1541
|
-
const
|
|
1540
|
+
}, [i == null ? void 0 : i.id, o, r.refreshInterval]);
|
|
1541
|
+
const M = Z(() => {
|
|
1542
1542
|
const P = (a == null ? void 0 : a.features) || [], h = (R) => {
|
|
1543
|
-
const
|
|
1544
|
-
return
|
|
1545
|
-
}, x = (R) => P.find((
|
|
1546
|
-
const l = P.find((
|
|
1547
|
-
return l ? l.value :
|
|
1548
|
-
},
|
|
1549
|
-
await
|
|
1550
|
-
}, C = !!
|
|
1543
|
+
const $ = P.find((l) => l.key === R);
|
|
1544
|
+
return $ ? $.type === "BOOLEAN" || $.type === "boolean" ? $.value === !0 : !!$.value : !1;
|
|
1545
|
+
}, x = (R) => P.find(($) => $.key === R), S = (R, $) => {
|
|
1546
|
+
const l = P.find((D) => D.key === R);
|
|
1547
|
+
return l ? l.value : $;
|
|
1548
|
+
}, L = (R) => !a || !a.isActive ? !1 : R.includes(a.planId), E = async () => {
|
|
1549
|
+
await N();
|
|
1550
|
+
}, C = !!o && (g || !(i != null && i.id));
|
|
1551
1551
|
return {
|
|
1552
1552
|
subscription: a,
|
|
1553
1553
|
features: P,
|
|
@@ -1556,24 +1556,89 @@ function yn({ config: r = {}, children: e }) {
|
|
|
1556
1556
|
isReady: C,
|
|
1557
1557
|
isFeatureEnabled: h,
|
|
1558
1558
|
getFeature: x,
|
|
1559
|
-
getFeatureValue:
|
|
1560
|
-
hasAllowedPlan:
|
|
1561
|
-
refresh:
|
|
1559
|
+
getFeatureValue: S,
|
|
1560
|
+
hasAllowedPlan: L,
|
|
1561
|
+
refresh: E
|
|
1562
1562
|
};
|
|
1563
|
-
}, [a, f, u,
|
|
1564
|
-
return /* @__PURE__ */ s(Fe.Provider, { value:
|
|
1563
|
+
}, [a, f, u, o, i == null ? void 0 : i.id, g]);
|
|
1564
|
+
return /* @__PURE__ */ s(Fe.Provider, { value: M, children: e });
|
|
1565
1565
|
}
|
|
1566
|
-
function
|
|
1566
|
+
function At() {
|
|
1567
1567
|
const r = oe(Fe);
|
|
1568
1568
|
if (r === void 0)
|
|
1569
1569
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1570
1570
|
return r;
|
|
1571
1571
|
}
|
|
1572
|
-
function
|
|
1572
|
+
function Ge() {
|
|
1573
1573
|
return oe(Fe) ?? null;
|
|
1574
1574
|
}
|
|
1575
1575
|
var se = /* @__PURE__ */ ((r) => (r.SUPERUSER = "SUPERUSER", r.TENANT_ADMIN = "TENANT_ADMIN", r.USER = "USER", r))(se || {});
|
|
1576
|
-
const
|
|
1576
|
+
const Ne = {
|
|
1577
|
+
publicGuest: "/",
|
|
1578
|
+
publicUser: "/account",
|
|
1579
|
+
publicAdmin: "/admin",
|
|
1580
|
+
tenantGuest: "/login",
|
|
1581
|
+
tenantUser: "/dashboard",
|
|
1582
|
+
tenantAdmin: "/admin/dashboard",
|
|
1583
|
+
default: "/"
|
|
1584
|
+
}, Ze = {
|
|
1585
|
+
// Public/Landing zones
|
|
1586
|
+
landing: { tenant: "forbidden", auth: "optional" },
|
|
1587
|
+
publicOnly: { tenant: "forbidden", auth: "forbidden" },
|
|
1588
|
+
// Auth zones
|
|
1589
|
+
login: { tenant: "required", auth: "forbidden" },
|
|
1590
|
+
guest: { auth: "forbidden" },
|
|
1591
|
+
authenticated: { auth: "required" },
|
|
1592
|
+
// Tenant zones
|
|
1593
|
+
tenant: { tenant: "required" },
|
|
1594
|
+
tenantOpen: { tenant: "required", auth: "optional" },
|
|
1595
|
+
tenantAuth: { tenant: "required", auth: "required" },
|
|
1596
|
+
// User type zones
|
|
1597
|
+
user: { tenant: "required", auth: "required", userType: se.USER },
|
|
1598
|
+
admin: { tenant: "required", auth: "required", userType: se.TENANT_ADMIN },
|
|
1599
|
+
// Fully open
|
|
1600
|
+
open: { tenant: "optional", auth: "optional" }
|
|
1601
|
+
}, De = ue(null);
|
|
1602
|
+
function bn({ config: r = {}, children: e }) {
|
|
1603
|
+
const t = Z(() => {
|
|
1604
|
+
const n = {
|
|
1605
|
+
...Ne,
|
|
1606
|
+
...r.zoneRoots
|
|
1607
|
+
}, o = {
|
|
1608
|
+
...Ze,
|
|
1609
|
+
...r.presets
|
|
1610
|
+
};
|
|
1611
|
+
return {
|
|
1612
|
+
zoneRoots: n,
|
|
1613
|
+
presets: o,
|
|
1614
|
+
loadingFallback: r.loadingFallback ?? null,
|
|
1615
|
+
accessDeniedFallback: r.accessDeniedFallback ?? null,
|
|
1616
|
+
onAccessDenied: r.onAccessDenied,
|
|
1617
|
+
returnToParam: r.returnToParam ?? "returnTo",
|
|
1618
|
+
returnToStorage: r.returnToStorage ?? "url"
|
|
1619
|
+
};
|
|
1620
|
+
}, [r]);
|
|
1621
|
+
return /* @__PURE__ */ s(De.Provider, { value: t, children: e });
|
|
1622
|
+
}
|
|
1623
|
+
function Sn() {
|
|
1624
|
+
const r = oe(De);
|
|
1625
|
+
if (!r)
|
|
1626
|
+
throw new Error("useRouting must be used within a RoutingProvider");
|
|
1627
|
+
return r;
|
|
1628
|
+
}
|
|
1629
|
+
function xt() {
|
|
1630
|
+
const r = oe(De);
|
|
1631
|
+
return r || {
|
|
1632
|
+
zoneRoots: Ne,
|
|
1633
|
+
presets: Ze,
|
|
1634
|
+
loadingFallback: null,
|
|
1635
|
+
accessDeniedFallback: null,
|
|
1636
|
+
onAccessDenied: void 0,
|
|
1637
|
+
returnToParam: "returnTo",
|
|
1638
|
+
returnToStorage: "url"
|
|
1639
|
+
};
|
|
1640
|
+
}
|
|
1641
|
+
const qe = () => /* @__PURE__ */ d(
|
|
1577
1642
|
"div",
|
|
1578
1643
|
{
|
|
1579
1644
|
style: {
|
|
@@ -1610,7 +1675,7 @@ const He = () => /* @__PURE__ */ d(
|
|
|
1610
1675
|
)
|
|
1611
1676
|
]
|
|
1612
1677
|
}
|
|
1613
|
-
),
|
|
1678
|
+
), Oe = ({
|
|
1614
1679
|
userType: r,
|
|
1615
1680
|
minUserType: e,
|
|
1616
1681
|
missingPermissions: t
|
|
@@ -1651,7 +1716,7 @@ const He = () => /* @__PURE__ */ d(
|
|
|
1651
1716
|
] })
|
|
1652
1717
|
]
|
|
1653
1718
|
}
|
|
1654
|
-
),
|
|
1719
|
+
), Pt = (r, e) => {
|
|
1655
1720
|
const t = {
|
|
1656
1721
|
[se.USER]: 1,
|
|
1657
1722
|
[se.TENANT_ADMIN]: 2,
|
|
@@ -1659,28 +1724,28 @@ const He = () => /* @__PURE__ */ d(
|
|
|
1659
1724
|
};
|
|
1660
1725
|
return t[r] >= t[e];
|
|
1661
1726
|
};
|
|
1662
|
-
function
|
|
1727
|
+
function vn({
|
|
1663
1728
|
children: r,
|
|
1664
1729
|
fallback: e,
|
|
1665
1730
|
minUserType: t,
|
|
1666
1731
|
requiredPermissions: n,
|
|
1667
|
-
requireAllPermissions:
|
|
1732
|
+
requireAllPermissions: o = !1
|
|
1668
1733
|
}) {
|
|
1669
|
-
const { hasValidSession:
|
|
1670
|
-
if (!
|
|
1671
|
-
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(
|
|
1734
|
+
const { hasValidSession: i, sessionManager: a, hasPermission: p, hasAnyPermission: f, hasAllPermissions: w } = le();
|
|
1735
|
+
if (!i())
|
|
1736
|
+
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(qe, {}) });
|
|
1672
1737
|
const u = a.getUser();
|
|
1673
1738
|
if (!u)
|
|
1674
|
-
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(
|
|
1675
|
-
if (t && !
|
|
1676
|
-
return /* @__PURE__ */ s(
|
|
1677
|
-
if (n && n.length > 0 && !(
|
|
1678
|
-
const g = n.filter((
|
|
1679
|
-
return /* @__PURE__ */ s(
|
|
1739
|
+
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(qe, {}) });
|
|
1740
|
+
if (t && !Pt(u.userType, t))
|
|
1741
|
+
return /* @__PURE__ */ s(Oe, { userType: u.userType, minUserType: t });
|
|
1742
|
+
if (n && n.length > 0 && !(o ? w(n) : f(n))) {
|
|
1743
|
+
const g = n.filter((T) => !p(T)).map((T) => typeof T == "string" ? T : T.name);
|
|
1744
|
+
return /* @__PURE__ */ s(Oe, { missingPermissions: g });
|
|
1680
1745
|
}
|
|
1681
1746
|
return /* @__PURE__ */ s(_, { children: r });
|
|
1682
1747
|
}
|
|
1683
|
-
const
|
|
1748
|
+
const Rt = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
1684
1749
|
"div",
|
|
1685
1750
|
{
|
|
1686
1751
|
style: {
|
|
@@ -1716,7 +1781,7 @@ const At = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1716
1781
|
}
|
|
1717
1782
|
)
|
|
1718
1783
|
}
|
|
1719
|
-
),
|
|
1784
|
+
), ze = ({
|
|
1720
1785
|
userType: r,
|
|
1721
1786
|
requiredUserType: e,
|
|
1722
1787
|
missingPermissions: t
|
|
@@ -1767,43 +1832,43 @@ const At = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1767
1832
|
}
|
|
1768
1833
|
)
|
|
1769
1834
|
}
|
|
1770
|
-
),
|
|
1771
|
-
function
|
|
1835
|
+
), It = (r, e) => r === e;
|
|
1836
|
+
function Tn({
|
|
1772
1837
|
children: r,
|
|
1773
1838
|
redirectTo: e = "/login",
|
|
1774
1839
|
requiredUserType: t,
|
|
1775
1840
|
requiredPermissions: n,
|
|
1776
|
-
requireAllPermissions:
|
|
1777
|
-
fallback:
|
|
1841
|
+
requireAllPermissions: o = !1,
|
|
1842
|
+
fallback: i
|
|
1778
1843
|
}) {
|
|
1779
|
-
const { hasValidSession: a, sessionManager: p, hasPermission: f, hasAnyPermission:
|
|
1844
|
+
const { hasValidSession: a, sessionManager: p, hasPermission: f, hasAnyPermission: w, hasAllPermissions: u } = le(), b = be();
|
|
1780
1845
|
if (X(() => {
|
|
1781
1846
|
process.env.NODE_ENV === "development" && console.warn(
|
|
1782
1847
|
"[react-identity-access] ProtectedRoute is deprecated. Use AuthenticatedZone or AdminZone from ZoneRoute instead."
|
|
1783
1848
|
);
|
|
1784
1849
|
}, []), !a())
|
|
1785
|
-
return
|
|
1786
|
-
/* @__PURE__ */ s(
|
|
1787
|
-
/* @__PURE__ */ s(
|
|
1850
|
+
return i ? /* @__PURE__ */ s(_, { children: i }) : /* @__PURE__ */ d(_, { children: [
|
|
1851
|
+
/* @__PURE__ */ s(Rt, { redirectPath: e }),
|
|
1852
|
+
/* @__PURE__ */ s(me, { to: e, state: { from: b.pathname }, replace: !0 })
|
|
1788
1853
|
] });
|
|
1789
1854
|
const g = p.getUser();
|
|
1790
1855
|
if (!g)
|
|
1791
|
-
return /* @__PURE__ */ s(
|
|
1792
|
-
if (t && !
|
|
1856
|
+
return /* @__PURE__ */ s(me, { to: e, state: { from: b.pathname }, replace: !0 });
|
|
1857
|
+
if (t && !It(g.userType, t))
|
|
1793
1858
|
return /* @__PURE__ */ s(
|
|
1794
|
-
|
|
1859
|
+
ze,
|
|
1795
1860
|
{
|
|
1796
1861
|
userType: g.userType,
|
|
1797
1862
|
requiredUserType: t
|
|
1798
1863
|
}
|
|
1799
1864
|
);
|
|
1800
|
-
if (n && n.length > 0 && !(
|
|
1801
|
-
const
|
|
1802
|
-
return /* @__PURE__ */ s(
|
|
1865
|
+
if (n && n.length > 0 && !(o ? u(n) : w(n))) {
|
|
1866
|
+
const I = n.filter((N) => !f(N)).map((N) => typeof N == "string" ? N : N.name);
|
|
1867
|
+
return /* @__PURE__ */ s(ze, { missingPermissions: I });
|
|
1803
1868
|
}
|
|
1804
1869
|
return /* @__PURE__ */ s(_, { children: r });
|
|
1805
1870
|
}
|
|
1806
|
-
const
|
|
1871
|
+
const Mt = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
1807
1872
|
"div",
|
|
1808
1873
|
{
|
|
1809
1874
|
style: {
|
|
@@ -1840,18 +1905,18 @@ const Pt = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1840
1905
|
)
|
|
1841
1906
|
}
|
|
1842
1907
|
);
|
|
1843
|
-
function
|
|
1844
|
-
const { tenant: n, isLoading:
|
|
1908
|
+
function kn({ children: r, redirectTo: e = "/", fallback: t }) {
|
|
1909
|
+
const { tenant: n, isLoading: o, error: i } = ge(), a = be();
|
|
1845
1910
|
return X(() => {
|
|
1846
1911
|
process.env.NODE_ENV === "development" && console.warn(
|
|
1847
1912
|
"[react-identity-access] TenantRoute is deprecated. Use TenantZone from ZoneRoute instead."
|
|
1848
1913
|
);
|
|
1849
|
-
}, []),
|
|
1850
|
-
/* @__PURE__ */ s(
|
|
1851
|
-
/* @__PURE__ */ s(
|
|
1914
|
+
}, []), o || i ? null : n ? /* @__PURE__ */ s(_, { children: r }) : t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ d(_, { children: [
|
|
1915
|
+
/* @__PURE__ */ s(Mt, { redirectPath: e }),
|
|
1916
|
+
/* @__PURE__ */ s(me, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
1852
1917
|
] });
|
|
1853
1918
|
}
|
|
1854
|
-
const
|
|
1919
|
+
const Lt = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
1855
1920
|
"div",
|
|
1856
1921
|
{
|
|
1857
1922
|
style: {
|
|
@@ -1888,144 +1953,125 @@ const Rt = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1888
1953
|
)
|
|
1889
1954
|
}
|
|
1890
1955
|
);
|
|
1891
|
-
function
|
|
1892
|
-
const { tenant: n, isLoading:
|
|
1956
|
+
function An({ children: r, redirectTo: e = "/dashboard", fallback: t }) {
|
|
1957
|
+
const { tenant: n, isLoading: o, error: i } = ge(), a = be();
|
|
1893
1958
|
return X(() => {
|
|
1894
1959
|
process.env.NODE_ENV === "development" && console.warn(
|
|
1895
1960
|
"[react-identity-access] LandingRoute is deprecated. Use PublicZone from ZoneRoute instead."
|
|
1896
1961
|
);
|
|
1897
|
-
}, []),
|
|
1898
|
-
/* @__PURE__ */ s(
|
|
1899
|
-
/* @__PURE__ */ s(
|
|
1962
|
+
}, []), o || i ? null : n ? t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ d(_, { children: [
|
|
1963
|
+
/* @__PURE__ */ s(Lt, { redirectPath: e }),
|
|
1964
|
+
/* @__PURE__ */ s(me, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
1900
1965
|
] }) : /* @__PURE__ */ s(_, { children: r });
|
|
1901
1966
|
}
|
|
1902
|
-
|
|
1903
|
-
publicGuest: "/",
|
|
1904
|
-
publicUser: "/account",
|
|
1905
|
-
publicAdmin: "/admin",
|
|
1906
|
-
tenantGuest: "/login",
|
|
1907
|
-
tenantUser: "/dashboard",
|
|
1908
|
-
tenantAdmin: "/admin/dashboard",
|
|
1909
|
-
default: "/"
|
|
1910
|
-
}, It = {
|
|
1911
|
-
// Public/Landing zones
|
|
1912
|
-
landing: { tenant: "forbidden", auth: "optional" },
|
|
1913
|
-
publicOnly: { tenant: "forbidden", auth: "forbidden" },
|
|
1914
|
-
// Auth zones
|
|
1915
|
-
login: { tenant: "required", auth: "forbidden" },
|
|
1916
|
-
guest: { auth: "forbidden" },
|
|
1917
|
-
authenticated: { auth: "required" },
|
|
1918
|
-
// Tenant zones
|
|
1919
|
-
tenant: { tenant: "required" },
|
|
1920
|
-
tenantOpen: { tenant: "required", auth: "optional" },
|
|
1921
|
-
tenantAuth: { tenant: "required", auth: "required" },
|
|
1922
|
-
// User type zones
|
|
1923
|
-
user: { tenant: "required", auth: "required", userType: se.USER },
|
|
1924
|
-
admin: { tenant: "required", auth: "required", userType: se.TENANT_ADMIN },
|
|
1925
|
-
// Fully open
|
|
1926
|
-
open: { tenant: "optional", auth: "optional" }
|
|
1927
|
-
}, Mt = "returnTo";
|
|
1928
|
-
function Lt(r, e) {
|
|
1967
|
+
function Et(r, e) {
|
|
1929
1968
|
return e ? r ? Array.isArray(e) ? e.includes(r) : r === e : !1 : !0;
|
|
1930
1969
|
}
|
|
1931
|
-
function
|
|
1970
|
+
function _e(r, e) {
|
|
1932
1971
|
return !r || r === "optional" ? "skip" : r === "required" ? e ? "pass" : "fail" : r === "forbidden" ? e ? "fail" : "pass" : "skip";
|
|
1933
1972
|
}
|
|
1934
|
-
function Et(r, e) {
|
|
1935
|
-
return Oe(r.tenant, e.hasTenant) === "fail" ? e.hasTenant ? "has_tenant" : "no_tenant" : Oe(r.auth, e.isAuthenticated) === "fail" ? e.isAuthenticated ? "already_authenticated" : "not_authenticated" : r.userType && e.isAuthenticated && !Lt(e.userType, r.userType) ? "wrong_user_type" : r.permissions && r.permissions.length > 0 && !(r.requireAllPermissions !== !1 ? (o) => o.every((a) => e.permissions.includes(a)) : (o) => o.some((a) => e.permissions.includes(a)))(r.permissions) ? "missing_permissions" : null;
|
|
1936
|
-
}
|
|
1937
1973
|
function Ft(r, e) {
|
|
1974
|
+
return _e(r.tenant, e.hasTenant) === "fail" ? e.hasTenant ? "has_tenant" : "no_tenant" : _e(r.auth, e.isAuthenticated) === "fail" ? e.isAuthenticated ? "already_authenticated" : "not_authenticated" : r.userType && e.isAuthenticated && !Et(e.userType, r.userType) ? "wrong_user_type" : r.permissions && r.permissions.length > 0 && !(r.requireAllPermissions !== !1 ? (i) => i.every((a) => e.permissions.includes(a)) : (i) => i.some((a) => e.permissions.includes(a)))(r.permissions) ? "missing_permissions" : null;
|
|
1975
|
+
}
|
|
1976
|
+
function Nt(r, e) {
|
|
1938
1977
|
return r.hasTenant ? r.isAuthenticated ? r.userType === se.TENANT_ADMIN ? e.tenantAdmin : e.tenantUser : e.tenantGuest : r.isAuthenticated ? r.userType === se.TENANT_ADMIN ? e.publicAdmin : e.publicUser : e.publicGuest;
|
|
1939
1978
|
}
|
|
1940
|
-
function
|
|
1941
|
-
if (!e ||
|
|
1979
|
+
function Dt(r, e, t, n, o) {
|
|
1980
|
+
if (!e || o !== "url")
|
|
1942
1981
|
return r;
|
|
1943
|
-
const
|
|
1944
|
-
return `${r}${a}${n}=${encodeURIComponent(
|
|
1982
|
+
const i = typeof e == "string" ? e : t, a = r.includes("?") ? "&" : "?";
|
|
1983
|
+
return `${r}${a}${n}=${encodeURIComponent(i)}`;
|
|
1945
1984
|
}
|
|
1946
|
-
function
|
|
1985
|
+
function Ct(r, e, t) {
|
|
1947
1986
|
if (!r || t === "url") return;
|
|
1948
|
-
const n = typeof r == "string" ? r : e;
|
|
1949
|
-
sessionStorage.setItem("
|
|
1987
|
+
const n = typeof r == "string" ? r : e, o = "zone_return_to";
|
|
1988
|
+
t === "session" ? sessionStorage.setItem(o, n) : t === "local" && localStorage.setItem(o, n);
|
|
1950
1989
|
}
|
|
1951
1990
|
const ae = ({
|
|
1952
1991
|
children: r,
|
|
1953
1992
|
preset: e,
|
|
1954
1993
|
tenant: t,
|
|
1955
1994
|
auth: n,
|
|
1956
|
-
userType:
|
|
1957
|
-
requiredPermissions:
|
|
1995
|
+
userType: o,
|
|
1996
|
+
requiredPermissions: i,
|
|
1958
1997
|
requireAllPermissions: a = !0,
|
|
1959
1998
|
returnTo: p,
|
|
1960
1999
|
onAccessDenied: f,
|
|
1961
|
-
redirectTo:
|
|
2000
|
+
redirectTo: w,
|
|
1962
2001
|
loadingFallback: u,
|
|
1963
|
-
accessDeniedFallback:
|
|
2002
|
+
accessDeniedFallback: b
|
|
1964
2003
|
}) => {
|
|
1965
|
-
const g = be(), { isAuthenticated:
|
|
2004
|
+
const g = be(), { isAuthenticated: T, isAuthInitializing: I, currentUser: N, userPermissions: M } = le(), { tenant: P, isTenantLoading: h } = he(), x = xt(), S = Z(() => {
|
|
1966
2005
|
if (e)
|
|
1967
|
-
return
|
|
1968
|
-
}, [e]),
|
|
2006
|
+
return x.presets[e];
|
|
2007
|
+
}, [e, x.presets]), L = Z(
|
|
1969
2008
|
() => ({
|
|
1970
|
-
tenant: t ?? (
|
|
1971
|
-
auth: n ?? (
|
|
1972
|
-
userType:
|
|
1973
|
-
permissions:
|
|
2009
|
+
tenant: t ?? (S == null ? void 0 : S.tenant),
|
|
2010
|
+
auth: n ?? (S == null ? void 0 : S.auth),
|
|
2011
|
+
userType: o ?? (S == null ? void 0 : S.userType),
|
|
2012
|
+
permissions: i ?? (S == null ? void 0 : S.requiredPermissions),
|
|
1974
2013
|
requireAllPermissions: a
|
|
1975
2014
|
}),
|
|
1976
|
-
[t, n,
|
|
1977
|
-
),
|
|
2015
|
+
[t, n, o, i, S, a]
|
|
2016
|
+
), E = Z(
|
|
1978
2017
|
() => ({
|
|
1979
2018
|
hasTenant: !!P,
|
|
1980
|
-
isAuthenticated:
|
|
1981
|
-
userType:
|
|
1982
|
-
permissions:
|
|
1983
|
-
isLoading:
|
|
2019
|
+
isAuthenticated: T,
|
|
2020
|
+
userType: N == null ? void 0 : N.userType,
|
|
2021
|
+
permissions: M,
|
|
2022
|
+
isLoading: I || h
|
|
1984
2023
|
}),
|
|
1985
2024
|
[
|
|
1986
2025
|
P,
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
L,
|
|
2026
|
+
T,
|
|
2027
|
+
N == null ? void 0 : N.userType,
|
|
1990
2028
|
M,
|
|
2029
|
+
I,
|
|
1991
2030
|
h
|
|
1992
2031
|
]
|
|
1993
|
-
),
|
|
1994
|
-
type:
|
|
2032
|
+
), C = Z(() => E.isLoading ? null : Ft(L, E), [L, E]), R = Z(() => C ? w || Nt(E, x.zoneRoots) : null, [C, w, E, x.zoneRoots]), $ = Z(() => !C || !R ? null : {
|
|
2033
|
+
type: C,
|
|
1995
2034
|
required: {
|
|
1996
|
-
tenant:
|
|
1997
|
-
auth:
|
|
1998
|
-
userType:
|
|
1999
|
-
permissions:
|
|
2035
|
+
tenant: L.tenant,
|
|
2036
|
+
auth: L.auth,
|
|
2037
|
+
userType: L.userType,
|
|
2038
|
+
permissions: L.permissions
|
|
2000
2039
|
},
|
|
2001
2040
|
current: {
|
|
2002
|
-
hasTenant:
|
|
2003
|
-
isAuthenticated:
|
|
2004
|
-
userType:
|
|
2005
|
-
permissions:
|
|
2041
|
+
hasTenant: E.hasTenant,
|
|
2042
|
+
isAuthenticated: E.isAuthenticated,
|
|
2043
|
+
userType: E.userType,
|
|
2044
|
+
permissions: E.permissions
|
|
2006
2045
|
},
|
|
2007
2046
|
redirectTo: R
|
|
2008
|
-
}, [
|
|
2047
|
+
}, [C, R, L, E]);
|
|
2009
2048
|
if (X(() => {
|
|
2010
|
-
|
|
2011
|
-
}, [
|
|
2012
|
-
|
|
2013
|
-
}, [
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2049
|
+
$ && (f ? f($) : x.onAccessDenied && x.onAccessDenied($));
|
|
2050
|
+
}, [$, f, x]), X(() => {
|
|
2051
|
+
$ && p && Ct(p, g.pathname + g.search, x.returnToStorage);
|
|
2052
|
+
}, [
|
|
2053
|
+
$,
|
|
2054
|
+
p,
|
|
2055
|
+
g.pathname,
|
|
2056
|
+
g.search,
|
|
2057
|
+
x.returnToStorage
|
|
2058
|
+
]), E.isLoading)
|
|
2059
|
+
return /* @__PURE__ */ s(_, { children: u ?? x.loadingFallback ?? null });
|
|
2060
|
+
if ($ && R) {
|
|
2061
|
+
const l = b ?? x.accessDeniedFallback;
|
|
2062
|
+
if (l)
|
|
2063
|
+
return /* @__PURE__ */ s(_, { children: l });
|
|
2064
|
+
const D = Dt(
|
|
2019
2065
|
R,
|
|
2020
2066
|
p,
|
|
2021
2067
|
g.pathname + g.search,
|
|
2022
|
-
|
|
2023
|
-
|
|
2068
|
+
x.returnToParam,
|
|
2069
|
+
x.returnToStorage
|
|
2024
2070
|
);
|
|
2025
|
-
return /* @__PURE__ */ s(
|
|
2071
|
+
return /* @__PURE__ */ s(me, { to: D, replace: !0 });
|
|
2026
2072
|
}
|
|
2027
2073
|
return /* @__PURE__ */ s(_, { children: r });
|
|
2028
|
-
},
|
|
2074
|
+
}, xn = (r) => /* @__PURE__ */ s(ae, { tenant: "required", ...r }), Pn = (r) => /* @__PURE__ */ s(ae, { tenant: "forbidden", ...r }), Rn = (r) => /* @__PURE__ */ s(ae, { auth: "required", ...r }), In = (r) => /* @__PURE__ */ s(ae, { auth: "forbidden", ...r }), Mn = (r) => /* @__PURE__ */ s(ae, { auth: "required", userType: se.TENANT_ADMIN, ...r }), Ln = (r) => /* @__PURE__ */ s(ae, { auth: "required", userType: se.USER, ...r }), En = (r) => /* @__PURE__ */ s(ae, { tenant: "optional", auth: "optional", ...r }), Fn = (r) => /* @__PURE__ */ s(ae, { tenant: "required", auth: "required", ...r }), Nn = (r) => /* @__PURE__ */ s(ae, { tenant: "required", auth: "optional", ...r }), Dn = (r) => /* @__PURE__ */ s(ae, { tenant: "required", auth: "forbidden", ...r }), Ut = () => /* @__PURE__ */ d(
|
|
2029
2075
|
"div",
|
|
2030
2076
|
{
|
|
2031
2077
|
style: {
|
|
@@ -2042,13 +2088,13 @@ const ae = ({
|
|
|
2042
2088
|
]
|
|
2043
2089
|
}
|
|
2044
2090
|
);
|
|
2045
|
-
function
|
|
2091
|
+
function Cn({
|
|
2046
2092
|
children: r,
|
|
2047
|
-
fallback: e = /* @__PURE__ */ s(
|
|
2093
|
+
fallback: e = /* @__PURE__ */ s(Ut, {}),
|
|
2048
2094
|
allowedPlans: t,
|
|
2049
2095
|
requiredFeature: n
|
|
2050
2096
|
}) {
|
|
2051
|
-
const { subscription:
|
|
2097
|
+
const { subscription: o, hasAllowedPlan: i, isFeatureEnabled: a, loading: p } = At();
|
|
2052
2098
|
return p ? /* @__PURE__ */ s(
|
|
2053
2099
|
"div",
|
|
2054
2100
|
{
|
|
@@ -2059,9 +2105,9 @@ function Fn({
|
|
|
2059
2105
|
},
|
|
2060
2106
|
children: "Loading subscription..."
|
|
2061
2107
|
}
|
|
2062
|
-
) :
|
|
2108
|
+
) : o ? o.isActive ? t && t.length > 0 && !i(t) ? /* @__PURE__ */ s(_, { children: e }) : n && !a(n) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: r }) : /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: e });
|
|
2063
2109
|
}
|
|
2064
|
-
const
|
|
2110
|
+
const $t = ({ flagName: r }) => /* @__PURE__ */ d(
|
|
2065
2111
|
"div",
|
|
2066
2112
|
{
|
|
2067
2113
|
style: {
|
|
@@ -2088,9 +2134,9 @@ const Dt = ({ flagName: r }) => /* @__PURE__ */ d(
|
|
|
2088
2134
|
]
|
|
2089
2135
|
}
|
|
2090
2136
|
);
|
|
2091
|
-
function
|
|
2092
|
-
const { isEnabled: n, loading:
|
|
2093
|
-
return
|
|
2137
|
+
function Un({ name: r, children: e, fallback: t }) {
|
|
2138
|
+
const { isEnabled: n, loading: o } = Tt();
|
|
2139
|
+
return o ? /* @__PURE__ */ s(
|
|
2094
2140
|
"div",
|
|
2095
2141
|
{
|
|
2096
2142
|
style: {
|
|
@@ -2103,9 +2149,9 @@ function Nn({ name: r, children: e, fallback: t }) {
|
|
|
2103
2149
|
},
|
|
2104
2150
|
children: "Loading feature flags..."
|
|
2105
2151
|
}
|
|
2106
|
-
) : n(r) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: t || /* @__PURE__ */ s(
|
|
2152
|
+
) : n(r) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: t || /* @__PURE__ */ s($t, { flagName: r }) });
|
|
2107
2153
|
}
|
|
2108
|
-
const
|
|
2154
|
+
const Ht = () => /* @__PURE__ */ d(
|
|
2109
2155
|
"svg",
|
|
2110
2156
|
{
|
|
2111
2157
|
width: "16",
|
|
@@ -2122,7 +2168,7 @@ const $t = () => /* @__PURE__ */ d(
|
|
|
2122
2168
|
/* @__PURE__ */ s("circle", { cx: "12", cy: "12", r: "3" })
|
|
2123
2169
|
]
|
|
2124
2170
|
}
|
|
2125
|
-
),
|
|
2171
|
+
), Bt = () => /* @__PURE__ */ d(
|
|
2126
2172
|
"svg",
|
|
2127
2173
|
{
|
|
2128
2174
|
width: "16",
|
|
@@ -2139,10 +2185,10 @@ const $t = () => /* @__PURE__ */ d(
|
|
|
2139
2185
|
/* @__PURE__ */ s("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
2140
2186
|
]
|
|
2141
2187
|
}
|
|
2142
|
-
),
|
|
2143
|
-
showPassword: /* @__PURE__ */ s(
|
|
2144
|
-
hidePassword: /* @__PURE__ */ s(
|
|
2145
|
-
},
|
|
2188
|
+
), qt = {
|
|
2189
|
+
showPassword: /* @__PURE__ */ s(Ht, {}),
|
|
2190
|
+
hidePassword: /* @__PURE__ */ s(Bt, {})
|
|
2191
|
+
}, Ot = {
|
|
2146
2192
|
title: "Sign In",
|
|
2147
2193
|
usernameLabel: "Email or Phone",
|
|
2148
2194
|
usernamePlaceholder: "Enter your email or phone number",
|
|
@@ -2156,7 +2202,7 @@ const $t = () => /* @__PURE__ */ d(
|
|
|
2156
2202
|
magicLinkLink: "Use Magic Link",
|
|
2157
2203
|
errorMessage: "Invalid credentials",
|
|
2158
2204
|
loadingText: "Signing in..."
|
|
2159
|
-
},
|
|
2205
|
+
}, zt = {
|
|
2160
2206
|
container: {
|
|
2161
2207
|
maxWidth: "400px",
|
|
2162
2208
|
width: "100%",
|
|
@@ -2263,57 +2309,57 @@ const $t = () => /* @__PURE__ */ d(
|
|
|
2263
2309
|
fontSize: "0.875rem"
|
|
2264
2310
|
}
|
|
2265
2311
|
};
|
|
2266
|
-
function
|
|
2312
|
+
function $n({
|
|
2267
2313
|
copy: r = {},
|
|
2268
2314
|
styles: e = {},
|
|
2269
2315
|
icons: t = {},
|
|
2270
2316
|
onSuccess: n,
|
|
2271
|
-
onError:
|
|
2272
|
-
onForgotPassword:
|
|
2317
|
+
onError: o,
|
|
2318
|
+
onForgotPassword: i,
|
|
2273
2319
|
onSignupClick: a,
|
|
2274
2320
|
onMagicLinkClick: p,
|
|
2275
2321
|
showForgotPassword: f = !0,
|
|
2276
|
-
showSignupLink:
|
|
2322
|
+
showSignupLink: w = !0,
|
|
2277
2323
|
showMagicLinkOption: u = !0,
|
|
2278
|
-
className:
|
|
2324
|
+
className: b
|
|
2279
2325
|
}) {
|
|
2280
|
-
const [g,
|
|
2326
|
+
const [g, T] = A(""), [I, N] = A(""), [M, P] = A(!1), [h, x] = A(!1), [S, L] = A(""), [E, C] = A({}), { login: R } = le(), { tenant: $ } = ge(), l = { ...Ot, ...r }, D = { ...zt, ...e }, U = { ...qt, ...t }, c = () => {
|
|
2281
2327
|
const m = {};
|
|
2282
|
-
return g.trim() || (m.username = !0),
|
|
2283
|
-
},
|
|
2328
|
+
return g.trim() || (m.username = !0), I.trim() || (m.password = !0), C(m), Object.keys(m).length === 0;
|
|
2329
|
+
}, H = async (m) => {
|
|
2284
2330
|
if (m.preventDefault(), !!c()) {
|
|
2285
|
-
if (!(
|
|
2286
|
-
|
|
2331
|
+
if (!($ != null && $.id)) {
|
|
2332
|
+
L("Tenant not found");
|
|
2287
2333
|
return;
|
|
2288
2334
|
}
|
|
2289
|
-
x(!0),
|
|
2335
|
+
x(!0), L("");
|
|
2290
2336
|
try {
|
|
2291
|
-
const
|
|
2337
|
+
const v = await R({
|
|
2292
2338
|
username: g,
|
|
2293
|
-
password:
|
|
2339
|
+
password: I
|
|
2294
2340
|
// tenantId inferred from context automatically
|
|
2295
2341
|
});
|
|
2296
|
-
n == null || n(
|
|
2297
|
-
} catch (
|
|
2298
|
-
const G =
|
|
2299
|
-
|
|
2342
|
+
n == null || n(v);
|
|
2343
|
+
} catch (v) {
|
|
2344
|
+
const G = v.message || l.errorMessage;
|
|
2345
|
+
L(G), o == null || o(G);
|
|
2300
2346
|
} finally {
|
|
2301
2347
|
x(!1);
|
|
2302
2348
|
}
|
|
2303
2349
|
}
|
|
2304
|
-
},
|
|
2305
|
-
...
|
|
2306
|
-
...
|
|
2350
|
+
}, F = (m) => ({
|
|
2351
|
+
...D.input,
|
|
2352
|
+
...E[m] ? D.inputError : {}
|
|
2307
2353
|
}), y = () => ({
|
|
2308
|
-
...
|
|
2309
|
-
...h ?
|
|
2310
|
-
...!g || !
|
|
2354
|
+
...D.button,
|
|
2355
|
+
...h ? D.buttonLoading : {},
|
|
2356
|
+
...!g || !I || h ? D.buttonDisabled : {}
|
|
2311
2357
|
});
|
|
2312
|
-
return /* @__PURE__ */ d("div", { className:
|
|
2313
|
-
/* @__PURE__ */ s("h2", { style:
|
|
2314
|
-
/* @__PURE__ */ d("form", { onSubmit:
|
|
2315
|
-
/* @__PURE__ */ d("div", { style:
|
|
2316
|
-
/* @__PURE__ */ s("label", { style:
|
|
2358
|
+
return /* @__PURE__ */ d("div", { className: b, style: D.container, children: [
|
|
2359
|
+
/* @__PURE__ */ s("h2", { style: D.title, children: l.title }),
|
|
2360
|
+
/* @__PURE__ */ d("form", { onSubmit: H, style: D.form, children: [
|
|
2361
|
+
/* @__PURE__ */ d("div", { style: D.fieldGroup, children: [
|
|
2362
|
+
/* @__PURE__ */ s("label", { style: D.label, children: l.usernameLabel }),
|
|
2317
2363
|
/* @__PURE__ */ s(
|
|
2318
2364
|
"input",
|
|
2319
2365
|
{
|
|
@@ -2322,30 +2368,30 @@ function Un({
|
|
|
2322
2368
|
type: "text",
|
|
2323
2369
|
value: g,
|
|
2324
2370
|
onChange: (m) => {
|
|
2325
|
-
|
|
2371
|
+
T(m.target.value), E.username && C((v) => ({ ...v, username: !1 }));
|
|
2326
2372
|
},
|
|
2327
2373
|
placeholder: l.usernamePlaceholder,
|
|
2328
|
-
style:
|
|
2374
|
+
style: F("username"),
|
|
2329
2375
|
disabled: h
|
|
2330
2376
|
}
|
|
2331
2377
|
)
|
|
2332
2378
|
] }),
|
|
2333
|
-
/* @__PURE__ */ d("div", { style:
|
|
2334
|
-
/* @__PURE__ */ s("label", { style:
|
|
2335
|
-
/* @__PURE__ */ d("div", { style:
|
|
2379
|
+
/* @__PURE__ */ d("div", { style: D.fieldGroup, children: [
|
|
2380
|
+
/* @__PURE__ */ s("label", { style: D.label, children: l.passwordLabel }),
|
|
2381
|
+
/* @__PURE__ */ d("div", { style: D.inputContainer, children: [
|
|
2336
2382
|
/* @__PURE__ */ s(
|
|
2337
2383
|
"input",
|
|
2338
2384
|
{
|
|
2339
2385
|
id: "password",
|
|
2340
2386
|
name: "password",
|
|
2341
|
-
type:
|
|
2342
|
-
value:
|
|
2387
|
+
type: M ? "text" : "password",
|
|
2388
|
+
value: I,
|
|
2343
2389
|
onChange: (m) => {
|
|
2344
|
-
|
|
2390
|
+
N(m.target.value), E.password && C((v) => ({ ...v, password: !1 }));
|
|
2345
2391
|
},
|
|
2346
2392
|
placeholder: l.passwordPlaceholder,
|
|
2347
2393
|
style: {
|
|
2348
|
-
...
|
|
2394
|
+
...F("password"),
|
|
2349
2395
|
paddingRight: "2.5rem"
|
|
2350
2396
|
// Make room for the icon
|
|
2351
2397
|
},
|
|
@@ -2356,40 +2402,40 @@ function Un({
|
|
|
2356
2402
|
"button",
|
|
2357
2403
|
{
|
|
2358
2404
|
type: "button",
|
|
2359
|
-
onClick: () => P(!
|
|
2360
|
-
style:
|
|
2405
|
+
onClick: () => P(!M),
|
|
2406
|
+
style: D.passwordToggle,
|
|
2361
2407
|
disabled: h,
|
|
2362
|
-
"aria-label":
|
|
2363
|
-
children:
|
|
2408
|
+
"aria-label": M ? "Hide password" : "Show password",
|
|
2409
|
+
children: M ? U.hidePassword : U.showPassword
|
|
2364
2410
|
}
|
|
2365
2411
|
)
|
|
2366
2412
|
] })
|
|
2367
2413
|
] }),
|
|
2368
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: !g || !
|
|
2369
|
-
|
|
2414
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !g || !I || h, style: y(), children: h ? l.loadingText : l.submitButton }),
|
|
2415
|
+
S && /* @__PURE__ */ s("div", { style: D.errorText, children: S })
|
|
2370
2416
|
] }),
|
|
2371
|
-
(f ||
|
|
2417
|
+
(f || w || u) && /* @__PURE__ */ d("div", { style: D.linkContainer, children: [
|
|
2372
2418
|
u && /* @__PURE__ */ d("div", { children: [
|
|
2373
|
-
/* @__PURE__ */ d("span", { style:
|
|
2419
|
+
/* @__PURE__ */ d("span", { style: D.divider, children: [
|
|
2374
2420
|
l.magicLinkText,
|
|
2375
2421
|
" "
|
|
2376
2422
|
] }),
|
|
2377
|
-
/* @__PURE__ */ s("a", { onClick: p, style:
|
|
2423
|
+
/* @__PURE__ */ s("a", { onClick: p, style: D.link, children: l.magicLinkLink })
|
|
2378
2424
|
] }),
|
|
2379
|
-
u && (f ||
|
|
2380
|
-
f && /* @__PURE__ */ s("a", { onClick:
|
|
2381
|
-
f &&
|
|
2382
|
-
|
|
2383
|
-
/* @__PURE__ */ d("span", { style:
|
|
2425
|
+
u && (f || w) && /* @__PURE__ */ s("div", { style: D.divider, children: "•" }),
|
|
2426
|
+
f && /* @__PURE__ */ s("a", { onClick: i, style: D.link, children: l.forgotPasswordLink }),
|
|
2427
|
+
f && w && /* @__PURE__ */ s("div", { style: D.divider, children: "•" }),
|
|
2428
|
+
w && /* @__PURE__ */ d("div", { children: [
|
|
2429
|
+
/* @__PURE__ */ d("span", { style: D.divider, children: [
|
|
2384
2430
|
l.signupText,
|
|
2385
2431
|
" "
|
|
2386
2432
|
] }),
|
|
2387
|
-
/* @__PURE__ */ s("a", { onClick: a, style:
|
|
2433
|
+
/* @__PURE__ */ s("a", { onClick: a, style: D.link, children: l.signupLink })
|
|
2388
2434
|
] })
|
|
2389
2435
|
] })
|
|
2390
2436
|
] });
|
|
2391
2437
|
}
|
|
2392
|
-
const
|
|
2438
|
+
const _t = {
|
|
2393
2439
|
title: "Create Account",
|
|
2394
2440
|
nameLabel: "First Name",
|
|
2395
2441
|
namePlaceholder: "Enter your first name",
|
|
@@ -2415,7 +2461,7 @@ const zt = {
|
|
|
2415
2461
|
passwordMismatchError: "Passwords do not match",
|
|
2416
2462
|
isAdminLabel: "Create new organization",
|
|
2417
2463
|
isAdminDescription: "Check this if you want to create a new organization"
|
|
2418
|
-
},
|
|
2464
|
+
}, Wt = {
|
|
2419
2465
|
container: {
|
|
2420
2466
|
maxWidth: "400px",
|
|
2421
2467
|
width: "100%",
|
|
@@ -2514,69 +2560,69 @@ const zt = {
|
|
|
2514
2560
|
fontSize: "0.875rem"
|
|
2515
2561
|
}
|
|
2516
2562
|
};
|
|
2517
|
-
function
|
|
2563
|
+
function Hn({
|
|
2518
2564
|
copy: r = {},
|
|
2519
2565
|
styles: e = {},
|
|
2520
2566
|
signupType: t = "user",
|
|
2521
2567
|
onSuccess: n,
|
|
2522
|
-
onError:
|
|
2523
|
-
onLoginClick:
|
|
2568
|
+
onError: o,
|
|
2569
|
+
onLoginClick: i,
|
|
2524
2570
|
onMagicLinkClick: a,
|
|
2525
2571
|
showLoginLink: p = !0,
|
|
2526
2572
|
showMagicLinkOption: f = !0,
|
|
2527
|
-
className:
|
|
2573
|
+
className: w
|
|
2528
2574
|
}) {
|
|
2529
|
-
const [u,
|
|
2530
|
-
const
|
|
2531
|
-
return u.trim() || (
|
|
2532
|
-
}, J = async (
|
|
2533
|
-
if (
|
|
2534
|
-
if (h !==
|
|
2535
|
-
|
|
2575
|
+
const [u, b] = A(""), [g, T] = A(""), [I, N] = A(""), [M, P] = A(""), [h, x] = A(""), [S, L] = A(""), [E, C] = A(""), [R, $] = A(!1), [l, D] = A(""), [U, c] = A({}), { signup: H, signupTenantAdmin: F } = le(), { tenant: y } = ge(), m = { ..._t, ...r }, v = { ...Wt, ...e }, G = () => {
|
|
2576
|
+
const k = {};
|
|
2577
|
+
return u.trim() || (k.name = !0), !I.trim() && !M.trim() && (k.email = !0, k.phoneNumber = !0), h.trim() || (k.password = !0), S.trim() || (k.confirmPassword = !0), t === "tenant" && !E.trim() && (k.tenantName = !0), c(k), Object.keys(k).length === 0;
|
|
2578
|
+
}, J = async (k) => {
|
|
2579
|
+
if (k.preventDefault(), !!G()) {
|
|
2580
|
+
if (h !== S) {
|
|
2581
|
+
D(m.passwordMismatchError), c({ confirmPassword: !0 });
|
|
2536
2582
|
return;
|
|
2537
2583
|
}
|
|
2538
2584
|
if (t === "user" && !(y != null && y.id)) {
|
|
2539
|
-
|
|
2585
|
+
D("Tenant not found");
|
|
2540
2586
|
return;
|
|
2541
2587
|
}
|
|
2542
|
-
|
|
2588
|
+
$(!0), D("");
|
|
2543
2589
|
try {
|
|
2544
|
-
let
|
|
2545
|
-
t === "tenant" ?
|
|
2546
|
-
email:
|
|
2547
|
-
phoneNumber:
|
|
2590
|
+
let K;
|
|
2591
|
+
t === "tenant" ? K = await F({
|
|
2592
|
+
email: I || void 0,
|
|
2593
|
+
phoneNumber: M || void 0,
|
|
2548
2594
|
name: u,
|
|
2549
2595
|
password: h,
|
|
2550
|
-
tenantName:
|
|
2596
|
+
tenantName: E,
|
|
2551
2597
|
lastName: g || void 0
|
|
2552
|
-
}) :
|
|
2553
|
-
email:
|
|
2554
|
-
phoneNumber:
|
|
2598
|
+
}) : K = await H({
|
|
2599
|
+
email: I || void 0,
|
|
2600
|
+
phoneNumber: M || void 0,
|
|
2555
2601
|
name: u,
|
|
2556
2602
|
password: h,
|
|
2557
2603
|
tenantId: y.id,
|
|
2558
2604
|
lastName: g || void 0
|
|
2559
|
-
}), n == null || n(
|
|
2560
|
-
} catch (
|
|
2561
|
-
const ce =
|
|
2562
|
-
|
|
2605
|
+
}), n == null || n(K);
|
|
2606
|
+
} catch (K) {
|
|
2607
|
+
const ce = K.message || m.errorMessage;
|
|
2608
|
+
D(ce), o == null || o(ce);
|
|
2563
2609
|
} finally {
|
|
2564
|
-
|
|
2610
|
+
$(!1);
|
|
2565
2611
|
}
|
|
2566
2612
|
}
|
|
2567
|
-
}, q = (
|
|
2568
|
-
...
|
|
2569
|
-
...
|
|
2613
|
+
}, q = (k) => ({
|
|
2614
|
+
...v.input,
|
|
2615
|
+
...U[k] ? v.inputError : {}
|
|
2570
2616
|
}), O = () => ({
|
|
2571
|
-
...
|
|
2572
|
-
...R ?
|
|
2573
|
-
...!u || !
|
|
2574
|
-
}), V = u && (
|
|
2575
|
-
return /* @__PURE__ */ d("div", { className:
|
|
2576
|
-
/* @__PURE__ */ s("h2", { style:
|
|
2577
|
-
/* @__PURE__ */ d("form", { onSubmit: J, style:
|
|
2578
|
-
/* @__PURE__ */ d("div", { style:
|
|
2579
|
-
/* @__PURE__ */ s("label", { style:
|
|
2617
|
+
...v.button,
|
|
2618
|
+
...R ? v.buttonLoading : {},
|
|
2619
|
+
...!u || !I && !M || !h || !S || R || t === "tenant" && !E ? v.buttonDisabled : {}
|
|
2620
|
+
}), V = u && (I || M) && h && S && (t === "user" || E);
|
|
2621
|
+
return /* @__PURE__ */ d("div", { className: w, style: v.container, children: [
|
|
2622
|
+
/* @__PURE__ */ s("h2", { style: v.title, children: m.title }),
|
|
2623
|
+
/* @__PURE__ */ d("form", { onSubmit: J, style: v.form, children: [
|
|
2624
|
+
/* @__PURE__ */ d("div", { style: v.fieldGroup, children: [
|
|
2625
|
+
/* @__PURE__ */ s("label", { style: v.label, children: m.nameLabel }),
|
|
2580
2626
|
/* @__PURE__ */ s(
|
|
2581
2627
|
"input",
|
|
2582
2628
|
{
|
|
@@ -2584,8 +2630,8 @@ function Cn({
|
|
|
2584
2630
|
name: "name",
|
|
2585
2631
|
type: "text",
|
|
2586
2632
|
value: u,
|
|
2587
|
-
onChange: (
|
|
2588
|
-
|
|
2633
|
+
onChange: (k) => {
|
|
2634
|
+
b(k.target.value), U.name && c((K) => ({ ...K, name: !1 }));
|
|
2589
2635
|
},
|
|
2590
2636
|
placeholder: m.namePlaceholder,
|
|
2591
2637
|
style: q("name"),
|
|
@@ -2593,8 +2639,8 @@ function Cn({
|
|
|
2593
2639
|
}
|
|
2594
2640
|
)
|
|
2595
2641
|
] }),
|
|
2596
|
-
/* @__PURE__ */ d("div", { style:
|
|
2597
|
-
/* @__PURE__ */ s("label", { style:
|
|
2642
|
+
/* @__PURE__ */ d("div", { style: v.fieldGroup, children: [
|
|
2643
|
+
/* @__PURE__ */ s("label", { style: v.label, children: m.lastNameLabel }),
|
|
2598
2644
|
/* @__PURE__ */ s(
|
|
2599
2645
|
"input",
|
|
2600
2646
|
{
|
|
@@ -2602,24 +2648,24 @@ function Cn({
|
|
|
2602
2648
|
name: "lastName",
|
|
2603
2649
|
type: "text",
|
|
2604
2650
|
value: g,
|
|
2605
|
-
onChange: (
|
|
2651
|
+
onChange: (k) => T(k.target.value),
|
|
2606
2652
|
placeholder: m.lastNamePlaceholder,
|
|
2607
|
-
style:
|
|
2653
|
+
style: v.input,
|
|
2608
2654
|
disabled: R
|
|
2609
2655
|
}
|
|
2610
2656
|
)
|
|
2611
2657
|
] }),
|
|
2612
|
-
/* @__PURE__ */ d("div", { style:
|
|
2613
|
-
/* @__PURE__ */ s("label", { style:
|
|
2658
|
+
/* @__PURE__ */ d("div", { style: v.fieldGroup, children: [
|
|
2659
|
+
/* @__PURE__ */ s("label", { style: v.label, children: m.emailLabel }),
|
|
2614
2660
|
/* @__PURE__ */ s(
|
|
2615
2661
|
"input",
|
|
2616
2662
|
{
|
|
2617
2663
|
id: "email",
|
|
2618
2664
|
name: "email",
|
|
2619
2665
|
type: "email",
|
|
2620
|
-
value:
|
|
2621
|
-
onChange: (
|
|
2622
|
-
|
|
2666
|
+
value: I,
|
|
2667
|
+
onChange: (k) => {
|
|
2668
|
+
N(k.target.value), U.email && c((K) => ({ ...K, email: !1, phoneNumber: !1 }));
|
|
2623
2669
|
},
|
|
2624
2670
|
placeholder: m.emailPlaceholder,
|
|
2625
2671
|
style: q("email"),
|
|
@@ -2627,17 +2673,17 @@ function Cn({
|
|
|
2627
2673
|
}
|
|
2628
2674
|
)
|
|
2629
2675
|
] }),
|
|
2630
|
-
/* @__PURE__ */ d("div", { style:
|
|
2631
|
-
/* @__PURE__ */ s("label", { style:
|
|
2676
|
+
/* @__PURE__ */ d("div", { style: v.fieldGroup, children: [
|
|
2677
|
+
/* @__PURE__ */ s("label", { style: v.label, children: m.phoneNumberLabel }),
|
|
2632
2678
|
/* @__PURE__ */ s(
|
|
2633
2679
|
"input",
|
|
2634
2680
|
{
|
|
2635
2681
|
id: "phoneNumber",
|
|
2636
2682
|
name: "phoneNumber",
|
|
2637
2683
|
type: "tel",
|
|
2638
|
-
value:
|
|
2639
|
-
onChange: (
|
|
2640
|
-
P(
|
|
2684
|
+
value: M,
|
|
2685
|
+
onChange: (k) => {
|
|
2686
|
+
P(k.target.value), U.phoneNumber && c((K) => ({ ...K, email: !1, phoneNumber: !1 }));
|
|
2641
2687
|
},
|
|
2642
2688
|
placeholder: m.phoneNumberPlaceholder,
|
|
2643
2689
|
style: q("phoneNumber"),
|
|
@@ -2657,8 +2703,8 @@ function Cn({
|
|
|
2657
2703
|
children: "At least one contact method (email or phone) is required"
|
|
2658
2704
|
}
|
|
2659
2705
|
),
|
|
2660
|
-
/* @__PURE__ */ d("div", { style:
|
|
2661
|
-
/* @__PURE__ */ s("label", { style:
|
|
2706
|
+
/* @__PURE__ */ d("div", { style: v.fieldGroup, children: [
|
|
2707
|
+
/* @__PURE__ */ s("label", { style: v.label, children: m.passwordLabel }),
|
|
2662
2708
|
/* @__PURE__ */ s(
|
|
2663
2709
|
"input",
|
|
2664
2710
|
{
|
|
@@ -2666,8 +2712,8 @@ function Cn({
|
|
|
2666
2712
|
name: "password",
|
|
2667
2713
|
type: "password",
|
|
2668
2714
|
value: h,
|
|
2669
|
-
onChange: (
|
|
2670
|
-
x(
|
|
2715
|
+
onChange: (k) => {
|
|
2716
|
+
x(k.target.value), U.password && c((K) => ({ ...K, password: !1 }));
|
|
2671
2717
|
},
|
|
2672
2718
|
placeholder: m.passwordPlaceholder,
|
|
2673
2719
|
style: q("password"),
|
|
@@ -2675,17 +2721,17 @@ function Cn({
|
|
|
2675
2721
|
}
|
|
2676
2722
|
)
|
|
2677
2723
|
] }),
|
|
2678
|
-
/* @__PURE__ */ d("div", { style:
|
|
2679
|
-
/* @__PURE__ */ s("label", { style:
|
|
2724
|
+
/* @__PURE__ */ d("div", { style: v.fieldGroup, children: [
|
|
2725
|
+
/* @__PURE__ */ s("label", { style: v.label, children: m.confirmPasswordLabel }),
|
|
2680
2726
|
/* @__PURE__ */ s(
|
|
2681
2727
|
"input",
|
|
2682
2728
|
{
|
|
2683
2729
|
id: "confirmPassword",
|
|
2684
2730
|
name: "confirmPassword",
|
|
2685
2731
|
type: "password",
|
|
2686
|
-
value:
|
|
2687
|
-
onChange: (
|
|
2688
|
-
|
|
2732
|
+
value: S,
|
|
2733
|
+
onChange: (k) => {
|
|
2734
|
+
L(k.target.value), U.confirmPassword && c((K) => ({ ...K, confirmPassword: !1 })), l === m.passwordMismatchError && D("");
|
|
2689
2735
|
},
|
|
2690
2736
|
placeholder: m.confirmPasswordPlaceholder,
|
|
2691
2737
|
style: q("confirmPassword"),
|
|
@@ -2693,17 +2739,17 @@ function Cn({
|
|
|
2693
2739
|
}
|
|
2694
2740
|
)
|
|
2695
2741
|
] }),
|
|
2696
|
-
t === "tenant" && /* @__PURE__ */ d("div", { style:
|
|
2697
|
-
/* @__PURE__ */ s("label", { style:
|
|
2742
|
+
t === "tenant" && /* @__PURE__ */ d("div", { style: v.fieldGroup, children: [
|
|
2743
|
+
/* @__PURE__ */ s("label", { style: v.label, children: m.tenantNameLabel }),
|
|
2698
2744
|
/* @__PURE__ */ s(
|
|
2699
2745
|
"input",
|
|
2700
2746
|
{
|
|
2701
2747
|
id: "tenantName",
|
|
2702
2748
|
name: "tenantName",
|
|
2703
2749
|
type: "text",
|
|
2704
|
-
value:
|
|
2705
|
-
onChange: (
|
|
2706
|
-
C(
|
|
2750
|
+
value: E,
|
|
2751
|
+
onChange: (k) => {
|
|
2752
|
+
C(k.target.value), U.tenantName && c((K) => ({ ...K, tenantName: !1 }));
|
|
2707
2753
|
},
|
|
2708
2754
|
placeholder: m.tenantNamePlaceholder,
|
|
2709
2755
|
style: q("tenantName"),
|
|
@@ -2712,28 +2758,28 @@ function Cn({
|
|
|
2712
2758
|
)
|
|
2713
2759
|
] }),
|
|
2714
2760
|
/* @__PURE__ */ s("button", { type: "submit", disabled: !V || R, style: O(), children: R ? m.loadingText : m.submitButton }),
|
|
2715
|
-
l && /* @__PURE__ */ s("div", { style:
|
|
2761
|
+
l && /* @__PURE__ */ s("div", { style: v.errorText, children: l })
|
|
2716
2762
|
] }),
|
|
2717
|
-
(p || f) && /* @__PURE__ */ d("div", { style:
|
|
2763
|
+
(p || f) && /* @__PURE__ */ d("div", { style: v.linkContainer, children: [
|
|
2718
2764
|
f && /* @__PURE__ */ d("div", { children: [
|
|
2719
|
-
/* @__PURE__ */ d("span", { style:
|
|
2765
|
+
/* @__PURE__ */ d("span", { style: v.divider, children: [
|
|
2720
2766
|
m.magicLinkText,
|
|
2721
2767
|
" "
|
|
2722
2768
|
] }),
|
|
2723
|
-
/* @__PURE__ */ s("a", { onClick: a, style:
|
|
2769
|
+
/* @__PURE__ */ s("a", { onClick: a, style: v.link, children: m.magicLinkLink })
|
|
2724
2770
|
] }),
|
|
2725
|
-
f && p && /* @__PURE__ */ s("div", { style:
|
|
2771
|
+
f && p && /* @__PURE__ */ s("div", { style: v.divider, children: "•" }),
|
|
2726
2772
|
p && /* @__PURE__ */ d("div", { children: [
|
|
2727
|
-
/* @__PURE__ */ d("span", { style:
|
|
2773
|
+
/* @__PURE__ */ d("span", { style: v.divider, children: [
|
|
2728
2774
|
m.loginText,
|
|
2729
2775
|
" "
|
|
2730
2776
|
] }),
|
|
2731
|
-
/* @__PURE__ */ s("a", { onClick:
|
|
2777
|
+
/* @__PURE__ */ s("a", { onClick: i, style: v.link, children: m.loginLink })
|
|
2732
2778
|
] })
|
|
2733
2779
|
] })
|
|
2734
2780
|
] });
|
|
2735
2781
|
}
|
|
2736
|
-
const
|
|
2782
|
+
const Vt = {
|
|
2737
2783
|
title: "Sign In with Magic Link",
|
|
2738
2784
|
emailLabel: "Email",
|
|
2739
2785
|
emailPlaceholder: "Enter your email",
|
|
@@ -2751,7 +2797,7 @@ const Wt = {
|
|
|
2751
2797
|
loadingText: "Sending magic link...",
|
|
2752
2798
|
verifyingText: "Verifying magic link...",
|
|
2753
2799
|
description: "Enter your email to receive a magic link. If you don't have an account, we'll create one for you."
|
|
2754
|
-
},
|
|
2800
|
+
}, jt = {
|
|
2755
2801
|
container: {
|
|
2756
2802
|
maxWidth: "400px",
|
|
2757
2803
|
width: "100%",
|
|
@@ -2854,28 +2900,28 @@ const Wt = {
|
|
|
2854
2900
|
fontSize: "0.875rem"
|
|
2855
2901
|
}
|
|
2856
2902
|
};
|
|
2857
|
-
function
|
|
2903
|
+
function Bn({
|
|
2858
2904
|
copy: r = {},
|
|
2859
2905
|
styles: e = {},
|
|
2860
2906
|
onSuccess: t,
|
|
2861
2907
|
onError: n,
|
|
2862
|
-
onLoginClick:
|
|
2863
|
-
onSignupClick:
|
|
2908
|
+
onLoginClick: o,
|
|
2909
|
+
onSignupClick: i,
|
|
2864
2910
|
showTraditionalLinks: a = !0,
|
|
2865
2911
|
className: p,
|
|
2866
2912
|
verifyToken: f,
|
|
2867
|
-
frontendUrl:
|
|
2913
|
+
frontendUrl: w
|
|
2868
2914
|
}) {
|
|
2869
|
-
const [u,
|
|
2915
|
+
const [u, b] = A(""), [g, T] = A(""), [I, N] = A(""), [M, P] = A(!1), [h, x] = A(!1), [S, L] = A(""), [E, C] = A(""), [R, $] = A({}), [l, D] = A(!1), { sendMagicLink: U, verifyMagicLink: c } = le(), { tenant: H } = ge(), F = { ...Vt, ...r }, y = { ...jt, ...e };
|
|
2870
2916
|
X(() => {
|
|
2871
2917
|
f && m(f);
|
|
2872
2918
|
}, [f]);
|
|
2873
2919
|
const m = async (O) => {
|
|
2874
|
-
if (
|
|
2875
|
-
|
|
2920
|
+
if (!H || !u) {
|
|
2921
|
+
L("Missing tenant or email");
|
|
2876
2922
|
return;
|
|
2877
2923
|
}
|
|
2878
|
-
x(!0),
|
|
2924
|
+
x(!0), L("");
|
|
2879
2925
|
try {
|
|
2880
2926
|
const V = await c({
|
|
2881
2927
|
token: O,
|
|
@@ -2884,33 +2930,33 @@ function Dn({
|
|
|
2884
2930
|
});
|
|
2885
2931
|
t == null || t(V);
|
|
2886
2932
|
} catch (V) {
|
|
2887
|
-
const
|
|
2888
|
-
|
|
2933
|
+
const k = V.message || "Failed to verify magic link";
|
|
2934
|
+
L(k), n == null || n(k);
|
|
2889
2935
|
} finally {
|
|
2890
2936
|
x(!1);
|
|
2891
2937
|
}
|
|
2892
|
-
},
|
|
2938
|
+
}, v = () => {
|
|
2893
2939
|
const O = {};
|
|
2894
|
-
return u.trim() || (O.email = !0), l && !g.trim() && (O.name = !0),
|
|
2940
|
+
return u.trim() || (O.email = !0), l && !g.trim() && (O.name = !0), $(O), Object.keys(O).length === 0;
|
|
2895
2941
|
}, G = async (O) => {
|
|
2896
|
-
if (O.preventDefault(), !!
|
|
2897
|
-
if (!(
|
|
2898
|
-
|
|
2942
|
+
if (O.preventDefault(), !!v()) {
|
|
2943
|
+
if (!(H != null && H.id)) {
|
|
2944
|
+
L("Tenant not found");
|
|
2899
2945
|
return;
|
|
2900
2946
|
}
|
|
2901
|
-
P(!0),
|
|
2947
|
+
P(!0), L(""), C("");
|
|
2902
2948
|
try {
|
|
2903
|
-
const V =
|
|
2949
|
+
const V = w || (typeof window < "u" ? window.location.origin : ""), k = await U({
|
|
2904
2950
|
email: u,
|
|
2905
|
-
tenantId:
|
|
2951
|
+
tenantId: H.id,
|
|
2906
2952
|
frontendUrl: V,
|
|
2907
2953
|
name: l ? g : void 0,
|
|
2908
|
-
lastName: l ?
|
|
2954
|
+
lastName: l ? I : void 0
|
|
2909
2955
|
});
|
|
2910
|
-
C(
|
|
2956
|
+
C(F.successMessage), t == null || t(k);
|
|
2911
2957
|
} catch (V) {
|
|
2912
|
-
const
|
|
2913
|
-
|
|
2958
|
+
const k = V.message || F.errorMessage;
|
|
2959
|
+
L(k), n == null || n(k);
|
|
2914
2960
|
} finally {
|
|
2915
2961
|
P(!1);
|
|
2916
2962
|
}
|
|
@@ -2920,18 +2966,18 @@ function Dn({
|
|
|
2920
2966
|
...R[O] ? y.inputError : {}
|
|
2921
2967
|
}), q = () => ({
|
|
2922
2968
|
...y.button,
|
|
2923
|
-
...
|
|
2924
|
-
...!u ||
|
|
2969
|
+
...M || h ? y.buttonLoading : {},
|
|
2970
|
+
...!u || M || h ? y.buttonDisabled : {}
|
|
2925
2971
|
});
|
|
2926
2972
|
return h ? /* @__PURE__ */ d("div", { className: p, style: y.container, children: [
|
|
2927
|
-
/* @__PURE__ */ s("h2", { style: y.title, children:
|
|
2973
|
+
/* @__PURE__ */ s("h2", { style: y.title, children: F.verifyingText }),
|
|
2928
2974
|
/* @__PURE__ */ s("div", { style: { textAlign: "center", padding: "2rem" }, children: /* @__PURE__ */ s("div", { style: { fontSize: "1rem", color: "#6b7280" }, children: "Please wait while we verify your magic link..." }) })
|
|
2929
2975
|
] }) : /* @__PURE__ */ d("div", { className: p, style: y.container, children: [
|
|
2930
|
-
/* @__PURE__ */ s("h2", { style: y.title, children:
|
|
2931
|
-
/* @__PURE__ */ s("p", { style: y.description, children:
|
|
2976
|
+
/* @__PURE__ */ s("h2", { style: y.title, children: F.title }),
|
|
2977
|
+
/* @__PURE__ */ s("p", { style: y.description, children: F.description }),
|
|
2932
2978
|
/* @__PURE__ */ d("form", { onSubmit: G, style: y.form, children: [
|
|
2933
2979
|
/* @__PURE__ */ d("div", { style: y.fieldGroup, children: [
|
|
2934
|
-
/* @__PURE__ */ s("label", { style: y.label, children:
|
|
2980
|
+
/* @__PURE__ */ s("label", { style: y.label, children: F.emailLabel }),
|
|
2935
2981
|
/* @__PURE__ */ s(
|
|
2936
2982
|
"input",
|
|
2937
2983
|
{
|
|
@@ -2940,11 +2986,11 @@ function Dn({
|
|
|
2940
2986
|
type: "email",
|
|
2941
2987
|
value: u,
|
|
2942
2988
|
onChange: (O) => {
|
|
2943
|
-
|
|
2989
|
+
b(O.target.value), R.email && $((V) => ({ ...V, email: !1 }));
|
|
2944
2990
|
},
|
|
2945
|
-
placeholder:
|
|
2991
|
+
placeholder: F.emailPlaceholder,
|
|
2946
2992
|
style: J("email"),
|
|
2947
|
-
disabled:
|
|
2993
|
+
disabled: M || h
|
|
2948
2994
|
}
|
|
2949
2995
|
)
|
|
2950
2996
|
] }),
|
|
@@ -2952,7 +2998,7 @@ function Dn({
|
|
|
2952
2998
|
"button",
|
|
2953
2999
|
{
|
|
2954
3000
|
type: "button",
|
|
2955
|
-
onClick: () =>
|
|
3001
|
+
onClick: () => D(!0),
|
|
2956
3002
|
style: {
|
|
2957
3003
|
background: "none",
|
|
2958
3004
|
border: "none",
|
|
@@ -2966,7 +3012,7 @@ function Dn({
|
|
|
2966
3012
|
) }),
|
|
2967
3013
|
l && /* @__PURE__ */ d(_, { children: [
|
|
2968
3014
|
/* @__PURE__ */ d("div", { style: y.fieldGroup, children: [
|
|
2969
|
-
/* @__PURE__ */ s("label", { style: y.label, children:
|
|
3015
|
+
/* @__PURE__ */ s("label", { style: y.label, children: F.nameLabel }),
|
|
2970
3016
|
/* @__PURE__ */ s(
|
|
2971
3017
|
"input",
|
|
2972
3018
|
{
|
|
@@ -2975,27 +3021,27 @@ function Dn({
|
|
|
2975
3021
|
type: "text",
|
|
2976
3022
|
value: g,
|
|
2977
3023
|
onChange: (O) => {
|
|
2978
|
-
|
|
3024
|
+
T(O.target.value), R.name && $((V) => ({ ...V, name: !1 }));
|
|
2979
3025
|
},
|
|
2980
|
-
placeholder:
|
|
3026
|
+
placeholder: F.namePlaceholder,
|
|
2981
3027
|
style: J("name"),
|
|
2982
|
-
disabled:
|
|
3028
|
+
disabled: M || h
|
|
2983
3029
|
}
|
|
2984
3030
|
)
|
|
2985
3031
|
] }),
|
|
2986
3032
|
/* @__PURE__ */ d("div", { style: y.fieldGroup, children: [
|
|
2987
|
-
/* @__PURE__ */ s("label", { style: y.label, children:
|
|
3033
|
+
/* @__PURE__ */ s("label", { style: y.label, children: F.lastNameLabel }),
|
|
2988
3034
|
/* @__PURE__ */ s(
|
|
2989
3035
|
"input",
|
|
2990
3036
|
{
|
|
2991
3037
|
id: "lastName",
|
|
2992
3038
|
name: "lastName",
|
|
2993
3039
|
type: "text",
|
|
2994
|
-
value:
|
|
2995
|
-
onChange: (O) =>
|
|
2996
|
-
placeholder:
|
|
3040
|
+
value: I,
|
|
3041
|
+
onChange: (O) => N(O.target.value),
|
|
3042
|
+
placeholder: F.lastNamePlaceholder,
|
|
2997
3043
|
style: y.input,
|
|
2998
|
-
disabled:
|
|
3044
|
+
disabled: M || h
|
|
2999
3045
|
}
|
|
3000
3046
|
)
|
|
3001
3047
|
] }),
|
|
@@ -3004,7 +3050,7 @@ function Dn({
|
|
|
3004
3050
|
{
|
|
3005
3051
|
type: "button",
|
|
3006
3052
|
onClick: () => {
|
|
3007
|
-
|
|
3053
|
+
D(!1), T(""), N("");
|
|
3008
3054
|
},
|
|
3009
3055
|
style: {
|
|
3010
3056
|
background: "none",
|
|
@@ -3018,30 +3064,30 @@ function Dn({
|
|
|
3018
3064
|
}
|
|
3019
3065
|
) })
|
|
3020
3066
|
] }),
|
|
3021
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: !u ||
|
|
3022
|
-
|
|
3023
|
-
|
|
3067
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !u || M || h, style: q(), children: M ? F.loadingText : F.submitButton }),
|
|
3068
|
+
S && /* @__PURE__ */ s("div", { style: y.errorText, children: S }),
|
|
3069
|
+
E && /* @__PURE__ */ s("div", { style: y.successText, children: E })
|
|
3024
3070
|
] }),
|
|
3025
3071
|
a && /* @__PURE__ */ d("div", { style: y.linkContainer, children: [
|
|
3026
3072
|
/* @__PURE__ */ d("div", { children: [
|
|
3027
3073
|
/* @__PURE__ */ d("span", { style: y.divider, children: [
|
|
3028
|
-
|
|
3074
|
+
F.loginText,
|
|
3029
3075
|
" "
|
|
3030
3076
|
] }),
|
|
3031
|
-
/* @__PURE__ */ s("a", { onClick:
|
|
3077
|
+
/* @__PURE__ */ s("a", { onClick: o, style: y.link, children: F.loginLink })
|
|
3032
3078
|
] }),
|
|
3033
3079
|
/* @__PURE__ */ s("div", { style: y.divider, children: "•" }),
|
|
3034
3080
|
/* @__PURE__ */ d("div", { children: [
|
|
3035
3081
|
/* @__PURE__ */ d("span", { style: y.divider, children: [
|
|
3036
|
-
|
|
3082
|
+
F.signupText,
|
|
3037
3083
|
" "
|
|
3038
3084
|
] }),
|
|
3039
|
-
/* @__PURE__ */ s("a", { onClick:
|
|
3085
|
+
/* @__PURE__ */ s("a", { onClick: i, style: y.link, children: F.signupLink })
|
|
3040
3086
|
] })
|
|
3041
3087
|
] })
|
|
3042
3088
|
] });
|
|
3043
3089
|
}
|
|
3044
|
-
const
|
|
3090
|
+
const Gt = {
|
|
3045
3091
|
title: "Verifying Magic Link",
|
|
3046
3092
|
verifyingMessage: "Please wait while we verify your magic link...",
|
|
3047
3093
|
successMessage: "Magic link verified successfully! You are now logged in.",
|
|
@@ -3049,7 +3095,7 @@ const jt = {
|
|
|
3049
3095
|
redirectingMessage: "Redirecting you to the dashboard...",
|
|
3050
3096
|
retryButton: "Try Again",
|
|
3051
3097
|
backToLoginButton: "Back to Login"
|
|
3052
|
-
},
|
|
3098
|
+
}, Ke = {
|
|
3053
3099
|
container: {
|
|
3054
3100
|
maxWidth: "400px",
|
|
3055
3101
|
width: "100%",
|
|
@@ -3136,7 +3182,7 @@ const jt = {
|
|
|
3136
3182
|
cursor: "pointer",
|
|
3137
3183
|
transition: "all 0.15s ease-in-out"
|
|
3138
3184
|
}
|
|
3139
|
-
},
|
|
3185
|
+
}, Zt = () => /* @__PURE__ */ s("div", { style: Ke.spinner }), Kt = () => /* @__PURE__ */ d(
|
|
3140
3186
|
"svg",
|
|
3141
3187
|
{
|
|
3142
3188
|
width: "48",
|
|
@@ -3153,7 +3199,7 @@ const jt = {
|
|
|
3153
3199
|
/* @__PURE__ */ s("polyline", { points: "22,4 12,14.01 9,11.01" })
|
|
3154
3200
|
]
|
|
3155
3201
|
}
|
|
3156
|
-
),
|
|
3202
|
+
), Jt = () => /* @__PURE__ */ d(
|
|
3157
3203
|
"svg",
|
|
3158
3204
|
{
|
|
3159
3205
|
width: "48",
|
|
@@ -3171,82 +3217,82 @@ const jt = {
|
|
|
3171
3217
|
/* @__PURE__ */ s("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
|
|
3172
3218
|
]
|
|
3173
3219
|
}
|
|
3174
|
-
),
|
|
3175
|
-
loading: /* @__PURE__ */ s(
|
|
3176
|
-
success: /* @__PURE__ */ s(
|
|
3177
|
-
error: /* @__PURE__ */ s(
|
|
3220
|
+
), Yt = {
|
|
3221
|
+
loading: /* @__PURE__ */ s(Zt, {}),
|
|
3222
|
+
success: /* @__PURE__ */ s(Kt, {}),
|
|
3223
|
+
error: /* @__PURE__ */ s(Jt, {})
|
|
3178
3224
|
};
|
|
3179
|
-
function
|
|
3225
|
+
function qn({
|
|
3180
3226
|
copy: r = {},
|
|
3181
3227
|
styles: e = {},
|
|
3182
3228
|
icons: t = {},
|
|
3183
3229
|
onSuccess: n,
|
|
3184
|
-
onError:
|
|
3185
|
-
onRetry:
|
|
3230
|
+
onError: o,
|
|
3231
|
+
onRetry: i,
|
|
3186
3232
|
onBackToLogin: a,
|
|
3187
3233
|
className: p,
|
|
3188
3234
|
token: f,
|
|
3189
|
-
email:
|
|
3235
|
+
email: w,
|
|
3190
3236
|
appId: u,
|
|
3191
|
-
tenantSlug:
|
|
3237
|
+
tenantSlug: b,
|
|
3192
3238
|
autoRedirectDelay: g = 3e3
|
|
3193
3239
|
}) {
|
|
3194
|
-
const [
|
|
3240
|
+
const [T, I] = A("verifying"), [N, M] = A(""), { verifyMagicLink: P } = le(), h = { ...Gt, ...r }, x = { ...Ke, ...e }, S = { ...Yt, ...t }, L = () => {
|
|
3195
3241
|
if (typeof window > "u") return {};
|
|
3196
3242
|
const l = new URLSearchParams(window.location.search);
|
|
3197
3243
|
return {
|
|
3198
3244
|
token: f || l.get("token") || "",
|
|
3199
|
-
email:
|
|
3245
|
+
email: w || l.get("email") || "",
|
|
3200
3246
|
appId: u || l.get("appId") || "",
|
|
3201
|
-
tenantSlug:
|
|
3247
|
+
tenantSlug: b || l.get("tenantSlug") || void 0
|
|
3202
3248
|
};
|
|
3203
|
-
},
|
|
3204
|
-
|
|
3249
|
+
}, E = async () => {
|
|
3250
|
+
I("verifying"), M("");
|
|
3205
3251
|
try {
|
|
3206
|
-
const l =
|
|
3252
|
+
const l = L();
|
|
3207
3253
|
if (!l.token || !l.email)
|
|
3208
3254
|
throw new Error("Missing required parameters: token or email");
|
|
3209
|
-
const
|
|
3255
|
+
const D = await P({
|
|
3210
3256
|
token: l.token,
|
|
3211
3257
|
email: l.email,
|
|
3212
3258
|
tenantSlug: l.tenantSlug
|
|
3213
3259
|
});
|
|
3214
|
-
|
|
3215
|
-
|
|
3260
|
+
I("success"), n == null || n(D), g > 0 && setTimeout(() => {
|
|
3261
|
+
I("redirecting");
|
|
3216
3262
|
}, g);
|
|
3217
3263
|
} catch (l) {
|
|
3218
|
-
const
|
|
3219
|
-
|
|
3264
|
+
const D = l.message || h.errorMessage;
|
|
3265
|
+
M(D), I("error"), o == null || o(D);
|
|
3220
3266
|
}
|
|
3221
3267
|
}, C = () => {
|
|
3222
|
-
|
|
3268
|
+
i == null || i(), E();
|
|
3223
3269
|
}, R = () => {
|
|
3224
3270
|
a == null || a();
|
|
3225
3271
|
};
|
|
3226
3272
|
X(() => {
|
|
3227
|
-
|
|
3273
|
+
E();
|
|
3228
3274
|
}, []);
|
|
3229
|
-
const
|
|
3230
|
-
switch (
|
|
3275
|
+
const $ = () => {
|
|
3276
|
+
switch (T) {
|
|
3231
3277
|
case "verifying":
|
|
3232
3278
|
return /* @__PURE__ */ d("div", { style: x.message, children: [
|
|
3233
|
-
|
|
3279
|
+
S.loading,
|
|
3234
3280
|
h.verifyingMessage
|
|
3235
3281
|
] });
|
|
3236
3282
|
case "success":
|
|
3237
3283
|
return /* @__PURE__ */ d(_, { children: [
|
|
3238
|
-
|
|
3284
|
+
S.success,
|
|
3239
3285
|
/* @__PURE__ */ s("div", { style: x.successMessage, children: h.successMessage })
|
|
3240
3286
|
] });
|
|
3241
3287
|
case "redirecting":
|
|
3242
3288
|
return /* @__PURE__ */ d(_, { children: [
|
|
3243
|
-
|
|
3289
|
+
S.loading,
|
|
3244
3290
|
/* @__PURE__ */ s("div", { style: x.message, children: h.redirectingMessage })
|
|
3245
3291
|
] });
|
|
3246
3292
|
case "error":
|
|
3247
3293
|
return /* @__PURE__ */ d(_, { children: [
|
|
3248
|
-
|
|
3249
|
-
/* @__PURE__ */ s("div", { style: x.errorMessage, children:
|
|
3294
|
+
S.error,
|
|
3295
|
+
/* @__PURE__ */ s("div", { style: x.errorMessage, children: N || h.errorMessage }),
|
|
3250
3296
|
/* @__PURE__ */ d("div", { style: x.buttonContainer, children: [
|
|
3251
3297
|
/* @__PURE__ */ s(
|
|
3252
3298
|
"button",
|
|
@@ -3290,10 +3336,10 @@ function $n({
|
|
|
3290
3336
|
}
|
|
3291
3337
|
` }),
|
|
3292
3338
|
/* @__PURE__ */ s("h1", { style: x.title, children: h.title }),
|
|
3293
|
-
|
|
3339
|
+
$()
|
|
3294
3340
|
] });
|
|
3295
3341
|
}
|
|
3296
|
-
const
|
|
3342
|
+
const Qt = {
|
|
3297
3343
|
title: "Reset Password",
|
|
3298
3344
|
subtitle: "Enter your email address and we'll send you a link to reset your password.",
|
|
3299
3345
|
emailLabel: "Email",
|
|
@@ -3315,7 +3361,7 @@ const Yt = {
|
|
|
3315
3361
|
resetLoadingText: "Resetting...",
|
|
3316
3362
|
resetSuccessMessage: "Password reset successfully!",
|
|
3317
3363
|
passwordMismatchError: "Passwords do not match"
|
|
3318
|
-
},
|
|
3364
|
+
}, Xt = {
|
|
3319
3365
|
container: {
|
|
3320
3366
|
maxWidth: "400px",
|
|
3321
3367
|
margin: "0 auto",
|
|
@@ -3407,56 +3453,56 @@ const Yt = {
|
|
|
3407
3453
|
cursor: "pointer"
|
|
3408
3454
|
}
|
|
3409
3455
|
};
|
|
3410
|
-
function
|
|
3456
|
+
function On({
|
|
3411
3457
|
copy: r = {},
|
|
3412
3458
|
styles: e = {},
|
|
3413
3459
|
mode: t = "request",
|
|
3414
3460
|
token: n = "",
|
|
3415
|
-
onSuccess:
|
|
3416
|
-
onError:
|
|
3461
|
+
onSuccess: o,
|
|
3462
|
+
onError: i,
|
|
3417
3463
|
onBackToLogin: a,
|
|
3418
3464
|
onModeChange: p,
|
|
3419
3465
|
className: f
|
|
3420
3466
|
}) {
|
|
3421
|
-
const [
|
|
3467
|
+
const [w, u] = A(""), [b, g] = A(n), [T, I] = A(""), [N, M] = A(""), [P, h] = A(!1), [x, S] = A(""), [L, E] = A(""), [C, R] = A({}), { requestPasswordReset: $, confirmPasswordReset: l } = le(), { tenant: D } = ge(), U = { ...Qt, ...r }, c = { ...Xt, ...e }, H = () => {
|
|
3422
3468
|
const q = {};
|
|
3423
|
-
return
|
|
3424
|
-
},
|
|
3469
|
+
return w.trim() || (q.email = !0), R(q), Object.keys(q).length === 0;
|
|
3470
|
+
}, F = () => {
|
|
3425
3471
|
const q = {};
|
|
3426
|
-
return
|
|
3472
|
+
return b.trim() || (q.token = !0), T.trim() || (q.newPassword = !0), N.trim() || (q.confirmPassword = !0), R(q), Object.keys(q).length === 0;
|
|
3427
3473
|
}, y = async (q) => {
|
|
3428
|
-
if (q.preventDefault(),
|
|
3429
|
-
if (!(
|
|
3430
|
-
|
|
3474
|
+
if (q.preventDefault(), !!H()) {
|
|
3475
|
+
if (!(D != null && D.id)) {
|
|
3476
|
+
S("Tenant not found");
|
|
3431
3477
|
return;
|
|
3432
3478
|
}
|
|
3433
|
-
h(!0),
|
|
3479
|
+
h(!0), S(""), E("");
|
|
3434
3480
|
try {
|
|
3435
|
-
await
|
|
3481
|
+
await $({ email: w, tenantId: D.id }), E(U.successMessage), o == null || o();
|
|
3436
3482
|
} catch (O) {
|
|
3437
|
-
const V = O.message ||
|
|
3438
|
-
|
|
3483
|
+
const V = O.message || U.errorMessage;
|
|
3484
|
+
S(V), i == null || i(V);
|
|
3439
3485
|
} finally {
|
|
3440
3486
|
h(!1);
|
|
3441
3487
|
}
|
|
3442
3488
|
}
|
|
3443
3489
|
}, m = async (q) => {
|
|
3444
|
-
if (q.preventDefault(), !!
|
|
3445
|
-
if (
|
|
3446
|
-
|
|
3490
|
+
if (q.preventDefault(), !!F()) {
|
|
3491
|
+
if (T !== N) {
|
|
3492
|
+
S(U.passwordMismatchError), R({ confirmPassword: !0 });
|
|
3447
3493
|
return;
|
|
3448
3494
|
}
|
|
3449
|
-
h(!0),
|
|
3495
|
+
h(!0), S(""), E("");
|
|
3450
3496
|
try {
|
|
3451
|
-
await l({ token:
|
|
3497
|
+
await l({ token: b, newPassword: T }), E(U.resetSuccessMessage), o == null || o();
|
|
3452
3498
|
} catch (O) {
|
|
3453
|
-
const V = O.message ||
|
|
3454
|
-
|
|
3499
|
+
const V = O.message || U.errorMessage;
|
|
3500
|
+
S(V), i == null || i(V);
|
|
3455
3501
|
} finally {
|
|
3456
3502
|
h(!1);
|
|
3457
3503
|
}
|
|
3458
3504
|
}
|
|
3459
|
-
},
|
|
3505
|
+
}, v = (q) => ({
|
|
3460
3506
|
...c.input,
|
|
3461
3507
|
...C[q] ? c.inputError : {}
|
|
3462
3508
|
}), G = () => ({
|
|
@@ -3464,55 +3510,55 @@ function Hn({
|
|
|
3464
3510
|
...P ? c.buttonLoading : {}
|
|
3465
3511
|
});
|
|
3466
3512
|
if (t === "reset") {
|
|
3467
|
-
const q =
|
|
3513
|
+
const q = b && T && N;
|
|
3468
3514
|
return /* @__PURE__ */ d("div", { className: f, style: c.container, children: [
|
|
3469
|
-
/* @__PURE__ */ s("h2", { style: c.title, children:
|
|
3470
|
-
/* @__PURE__ */ s("p", { style: c.subtitle, children:
|
|
3515
|
+
/* @__PURE__ */ s("h2", { style: c.title, children: U.resetTitle }),
|
|
3516
|
+
/* @__PURE__ */ s("p", { style: c.subtitle, children: U.resetSubtitle }),
|
|
3471
3517
|
/* @__PURE__ */ d("form", { onSubmit: m, style: c.form, children: [
|
|
3472
3518
|
/* @__PURE__ */ d("div", { style: c.fieldGroup, children: [
|
|
3473
|
-
/* @__PURE__ */ s("label", { style: c.label, children:
|
|
3519
|
+
/* @__PURE__ */ s("label", { style: c.label, children: U.tokenLabel }),
|
|
3474
3520
|
/* @__PURE__ */ s(
|
|
3475
3521
|
"input",
|
|
3476
3522
|
{
|
|
3477
3523
|
type: "text",
|
|
3478
|
-
value:
|
|
3524
|
+
value: b,
|
|
3479
3525
|
onChange: (O) => {
|
|
3480
3526
|
g(O.target.value), C.token && R((V) => ({ ...V, token: !1 }));
|
|
3481
3527
|
},
|
|
3482
|
-
placeholder:
|
|
3483
|
-
style:
|
|
3528
|
+
placeholder: U.tokenPlaceholder,
|
|
3529
|
+
style: v("token"),
|
|
3484
3530
|
disabled: P
|
|
3485
3531
|
}
|
|
3486
3532
|
)
|
|
3487
3533
|
] }),
|
|
3488
3534
|
/* @__PURE__ */ d("div", { style: c.fieldGroup, children: [
|
|
3489
|
-
/* @__PURE__ */ s("label", { style: c.label, children:
|
|
3535
|
+
/* @__PURE__ */ s("label", { style: c.label, children: U.newPasswordLabel }),
|
|
3490
3536
|
/* @__PURE__ */ s(
|
|
3491
3537
|
"input",
|
|
3492
3538
|
{
|
|
3493
3539
|
type: "password",
|
|
3494
|
-
value:
|
|
3540
|
+
value: T,
|
|
3495
3541
|
onChange: (O) => {
|
|
3496
|
-
|
|
3542
|
+
I(O.target.value), C.newPassword && R((V) => ({ ...V, newPassword: !1 }));
|
|
3497
3543
|
},
|
|
3498
|
-
placeholder:
|
|
3499
|
-
style:
|
|
3544
|
+
placeholder: U.newPasswordPlaceholder,
|
|
3545
|
+
style: v("newPassword"),
|
|
3500
3546
|
disabled: P
|
|
3501
3547
|
}
|
|
3502
3548
|
)
|
|
3503
3549
|
] }),
|
|
3504
3550
|
/* @__PURE__ */ d("div", { style: c.fieldGroup, children: [
|
|
3505
|
-
/* @__PURE__ */ s("label", { style: c.label, children:
|
|
3551
|
+
/* @__PURE__ */ s("label", { style: c.label, children: U.confirmPasswordLabel }),
|
|
3506
3552
|
/* @__PURE__ */ s(
|
|
3507
3553
|
"input",
|
|
3508
3554
|
{
|
|
3509
3555
|
type: "password",
|
|
3510
|
-
value:
|
|
3556
|
+
value: N,
|
|
3511
3557
|
onChange: (O) => {
|
|
3512
|
-
|
|
3558
|
+
M(O.target.value), C.confirmPassword && R((V) => ({ ...V, confirmPassword: !1 })), x === U.passwordMismatchError && S("");
|
|
3513
3559
|
},
|
|
3514
|
-
placeholder:
|
|
3515
|
-
style:
|
|
3560
|
+
placeholder: U.confirmPasswordPlaceholder,
|
|
3561
|
+
style: v("confirmPassword"),
|
|
3516
3562
|
disabled: P
|
|
3517
3563
|
}
|
|
3518
3564
|
)
|
|
@@ -3526,14 +3572,14 @@ function Hn({
|
|
|
3526
3572
|
...G(),
|
|
3527
3573
|
...!q || P ? c.buttonDisabled : {}
|
|
3528
3574
|
},
|
|
3529
|
-
children: P ?
|
|
3575
|
+
children: P ? U.resetLoadingText : U.resetSubmitButton
|
|
3530
3576
|
}
|
|
3531
3577
|
),
|
|
3532
3578
|
x && /* @__PURE__ */ s("div", { style: c.errorText, children: x }),
|
|
3533
|
-
|
|
3579
|
+
L && /* @__PURE__ */ s("div", { style: c.successText, children: L })
|
|
3534
3580
|
] }),
|
|
3535
3581
|
/* @__PURE__ */ d("div", { style: c.linkContainer, children: [
|
|
3536
|
-
/* @__PURE__ */ s("a", { onClick: a, style: c.link, children:
|
|
3582
|
+
/* @__PURE__ */ s("a", { onClick: a, style: c.link, children: U.backToLoginLink }),
|
|
3537
3583
|
p && /* @__PURE__ */ d(_, { children: [
|
|
3538
3584
|
/* @__PURE__ */ s("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3539
3585
|
/* @__PURE__ */ s("a", { onClick: () => p("request"), style: c.link, children: "Request New Link" })
|
|
@@ -3541,23 +3587,23 @@ function Hn({
|
|
|
3541
3587
|
] })
|
|
3542
3588
|
] });
|
|
3543
3589
|
}
|
|
3544
|
-
const J =
|
|
3590
|
+
const J = w;
|
|
3545
3591
|
return /* @__PURE__ */ d("div", { className: f, style: c.container, children: [
|
|
3546
|
-
/* @__PURE__ */ s("h2", { style: c.title, children:
|
|
3547
|
-
/* @__PURE__ */ s("p", { style: c.subtitle, children:
|
|
3592
|
+
/* @__PURE__ */ s("h2", { style: c.title, children: U.title }),
|
|
3593
|
+
/* @__PURE__ */ s("p", { style: c.subtitle, children: U.subtitle }),
|
|
3548
3594
|
/* @__PURE__ */ d("form", { onSubmit: y, style: c.form, children: [
|
|
3549
3595
|
/* @__PURE__ */ d("div", { style: c.fieldGroup, children: [
|
|
3550
|
-
/* @__PURE__ */ s("label", { style: c.label, children:
|
|
3596
|
+
/* @__PURE__ */ s("label", { style: c.label, children: U.emailLabel }),
|
|
3551
3597
|
/* @__PURE__ */ s(
|
|
3552
3598
|
"input",
|
|
3553
3599
|
{
|
|
3554
3600
|
type: "email",
|
|
3555
|
-
value:
|
|
3601
|
+
value: w,
|
|
3556
3602
|
onChange: (q) => {
|
|
3557
3603
|
u(q.target.value), C.email && R((O) => ({ ...O, email: !1 }));
|
|
3558
3604
|
},
|
|
3559
|
-
placeholder:
|
|
3560
|
-
style:
|
|
3605
|
+
placeholder: U.emailPlaceholder,
|
|
3606
|
+
style: v("email"),
|
|
3561
3607
|
disabled: P
|
|
3562
3608
|
}
|
|
3563
3609
|
)
|
|
@@ -3571,14 +3617,14 @@ function Hn({
|
|
|
3571
3617
|
...G(),
|
|
3572
3618
|
...!J || P ? c.buttonDisabled : {}
|
|
3573
3619
|
},
|
|
3574
|
-
children: P ?
|
|
3620
|
+
children: P ? U.loadingText : U.submitButton
|
|
3575
3621
|
}
|
|
3576
3622
|
),
|
|
3577
3623
|
x && /* @__PURE__ */ s("div", { style: c.errorText, children: x }),
|
|
3578
|
-
|
|
3624
|
+
L && /* @__PURE__ */ s("div", { style: c.successText, children: L })
|
|
3579
3625
|
] }),
|
|
3580
3626
|
/* @__PURE__ */ d("div", { style: c.linkContainer, children: [
|
|
3581
|
-
/* @__PURE__ */ s("a", { onClick: a, style: c.link, children:
|
|
3627
|
+
/* @__PURE__ */ s("a", { onClick: a, style: c.link, children: U.backToLoginLink }),
|
|
3582
3628
|
p && /* @__PURE__ */ d(_, { children: [
|
|
3583
3629
|
/* @__PURE__ */ s("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3584
3630
|
/* @__PURE__ */ s("a", { onClick: () => p("reset"), style: c.link, children: "I have a token" })
|
|
@@ -3586,7 +3632,7 @@ function Hn({
|
|
|
3586
3632
|
] })
|
|
3587
3633
|
] });
|
|
3588
3634
|
}
|
|
3589
|
-
const
|
|
3635
|
+
const en = () => /* @__PURE__ */ s(
|
|
3590
3636
|
"div",
|
|
3591
3637
|
{
|
|
3592
3638
|
style: {
|
|
@@ -3598,7 +3644,7 @@ const Xt = () => /* @__PURE__ */ s(
|
|
|
3598
3644
|
},
|
|
3599
3645
|
children: /* @__PURE__ */ s("div", { children: "Loading..." })
|
|
3600
3646
|
}
|
|
3601
|
-
),
|
|
3647
|
+
), tn = ({ error: r, retry: e }) => /* @__PURE__ */ d(
|
|
3602
3648
|
"div",
|
|
3603
3649
|
{
|
|
3604
3650
|
style: {
|
|
@@ -3632,83 +3678,83 @@ const Xt = () => /* @__PURE__ */ s(
|
|
|
3632
3678
|
]
|
|
3633
3679
|
}
|
|
3634
3680
|
);
|
|
3635
|
-
function
|
|
3681
|
+
function zn({
|
|
3636
3682
|
children: r,
|
|
3637
3683
|
loadingFallback: e,
|
|
3638
3684
|
errorFallback: t,
|
|
3639
3685
|
requireTenant: n = !0
|
|
3640
3686
|
}) {
|
|
3641
|
-
const { isAppLoading:
|
|
3642
|
-
}),
|
|
3643
|
-
|
|
3687
|
+
const { isAppLoading: o, appError: i, retryApp: a } = ye(), p = Se(), f = Le(), w = je(), u = Ge(), b = (p == null ? void 0 : p.isTenantLoading) ?? !1, g = (p == null ? void 0 : p.tenantError) ?? null, T = (p == null ? void 0 : p.tenantSlug) ?? null, I = (p == null ? void 0 : p.retryTenant) ?? (() => {
|
|
3688
|
+
}), N = (f == null ? void 0 : f.isAuthReady) ?? !0, M = (w == null ? void 0 : w.isReady) ?? !0, P = (u == null ? void 0 : u.isReady) ?? !0, h = n && p && T, E = o || h && b || f && !N || w && !M || u && !P, C = i || (h ? g : null), R = () => {
|
|
3689
|
+
i && a(), g && p && I();
|
|
3644
3690
|
};
|
|
3645
|
-
if (
|
|
3646
|
-
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(
|
|
3691
|
+
if (E)
|
|
3692
|
+
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(en, {}) });
|
|
3647
3693
|
if (C) {
|
|
3648
|
-
const
|
|
3649
|
-
return /* @__PURE__ */ s(_, { children:
|
|
3694
|
+
const $ = typeof t == "function" ? t(C, R) : t || /* @__PURE__ */ s(tn, { error: C, retry: R });
|
|
3695
|
+
return /* @__PURE__ */ s(_, { children: $ });
|
|
3650
3696
|
}
|
|
3651
3697
|
return /* @__PURE__ */ s(_, { children: r });
|
|
3652
3698
|
}
|
|
3653
|
-
function
|
|
3654
|
-
const { isAppLoading: e, appError: t, retryApp: n, appInfo:
|
|
3655
|
-
}),
|
|
3699
|
+
function _n(r = !0) {
|
|
3700
|
+
const { isAppLoading: e, appError: t, retryApp: n, appInfo: o } = ye(), i = Se(), a = Le(), p = je(), f = Ge(), w = (i == null ? void 0 : i.isTenantLoading) ?? !1, u = (i == null ? void 0 : i.tenantError) ?? null, b = (i == null ? void 0 : i.tenant) ?? null, g = (i == null ? void 0 : i.tenantSlug) ?? null, T = (i == null ? void 0 : i.retryTenant) ?? (() => {
|
|
3701
|
+
}), I = (a == null ? void 0 : a.isAuthReady) ?? !0, N = (p == null ? void 0 : p.isReady) ?? !0, M = (f == null ? void 0 : f.isReady) ?? !0, P = r && i && g, L = e || P && w || a && !I || p && !N || f && !M, E = t || (P ? u : null);
|
|
3656
3702
|
return {
|
|
3657
|
-
isLoading:
|
|
3658
|
-
error:
|
|
3659
|
-
isReady: !
|
|
3703
|
+
isLoading: L,
|
|
3704
|
+
error: E,
|
|
3705
|
+
isReady: !L && !E && o !== null && (!P || b !== null),
|
|
3660
3706
|
retry: () => {
|
|
3661
|
-
t && n(), u &&
|
|
3707
|
+
t && n(), u && i && T();
|
|
3662
3708
|
},
|
|
3663
3709
|
// Individual states
|
|
3664
|
-
app: { isLoading: e, error: t, data:
|
|
3665
|
-
tenant:
|
|
3666
|
-
auth: a ? { isReady:
|
|
3667
|
-
featureFlags: p ? { isReady:
|
|
3668
|
-
subscription: f ? { isReady:
|
|
3710
|
+
app: { isLoading: e, error: t, data: o },
|
|
3711
|
+
tenant: i ? { isLoading: w, error: u, data: b } : null,
|
|
3712
|
+
auth: a ? { isReady: I } : null,
|
|
3713
|
+
featureFlags: p ? { isReady: N } : null,
|
|
3714
|
+
subscription: f ? { isReady: M } : null
|
|
3669
3715
|
};
|
|
3670
3716
|
}
|
|
3671
|
-
function
|
|
3717
|
+
function Wn({
|
|
3672
3718
|
tenants: r,
|
|
3673
3719
|
currentTenantId: e,
|
|
3674
3720
|
onSelect: t,
|
|
3675
3721
|
className: n = "",
|
|
3676
|
-
dropdownClassName:
|
|
3677
|
-
itemClassName:
|
|
3722
|
+
dropdownClassName: o = "",
|
|
3723
|
+
itemClassName: i = "",
|
|
3678
3724
|
renderItem: a,
|
|
3679
3725
|
placeholder: p = "Select tenant",
|
|
3680
3726
|
disabled: f = !1,
|
|
3681
|
-
showCurrentTenant:
|
|
3727
|
+
showCurrentTenant: w = !0
|
|
3682
3728
|
}) {
|
|
3683
3729
|
var x;
|
|
3684
|
-
const u = Le(), [
|
|
3685
|
-
g(!1), t ? t(
|
|
3730
|
+
const u = Le(), [b, g] = A(!1), T = We(null), I = r ?? (u == null ? void 0 : u.userTenants) ?? [], N = e ?? ((x = u == null ? void 0 : u.currentUser) == null ? void 0 : x.tenantId) ?? null, M = async (S) => {
|
|
3731
|
+
g(!1), t ? t(S) : u != null && u.switchToTenant && await u.switchToTenant(S);
|
|
3686
3732
|
};
|
|
3687
3733
|
X(() => {
|
|
3688
|
-
const
|
|
3689
|
-
|
|
3734
|
+
const S = (L) => {
|
|
3735
|
+
T.current && !T.current.contains(L.target) && g(!1);
|
|
3690
3736
|
};
|
|
3691
|
-
return document.addEventListener("mousedown",
|
|
3737
|
+
return document.addEventListener("mousedown", S), () => document.removeEventListener("mousedown", S);
|
|
3692
3738
|
}, []);
|
|
3693
|
-
const P =
|
|
3694
|
-
if (
|
|
3739
|
+
const P = I.find((S) => S.id === N);
|
|
3740
|
+
if (I.length === 0)
|
|
3695
3741
|
return null;
|
|
3696
|
-
if (
|
|
3697
|
-
return /* @__PURE__ */ s("div", { className: n, children: /* @__PURE__ */ s("span", { children:
|
|
3698
|
-
const h = (
|
|
3699
|
-
|
|
3700
|
-
|
|
3742
|
+
if (I.length === 1 && w)
|
|
3743
|
+
return /* @__PURE__ */ s("div", { className: n, children: /* @__PURE__ */ s("span", { children: I[0].name }) });
|
|
3744
|
+
const h = (S, L) => /* @__PURE__ */ d("span", { style: { fontWeight: L ? "bold" : "normal" }, children: [
|
|
3745
|
+
S.name,
|
|
3746
|
+
S.role && /* @__PURE__ */ d("span", { style: { opacity: 0.7, marginLeft: 8 }, children: [
|
|
3701
3747
|
"(",
|
|
3702
|
-
|
|
3748
|
+
S.role,
|
|
3703
3749
|
")"
|
|
3704
3750
|
] })
|
|
3705
3751
|
] });
|
|
3706
|
-
return /* @__PURE__ */ d("div", { ref:
|
|
3752
|
+
return /* @__PURE__ */ d("div", { ref: T, className: n, style: { position: "relative" }, children: [
|
|
3707
3753
|
/* @__PURE__ */ d(
|
|
3708
3754
|
"button",
|
|
3709
3755
|
{
|
|
3710
3756
|
type: "button",
|
|
3711
|
-
onClick: () => !f && g(!
|
|
3757
|
+
onClick: () => !f && g(!b),
|
|
3712
3758
|
disabled: f,
|
|
3713
3759
|
style: {
|
|
3714
3760
|
cursor: f ? "not-allowed" : "pointer",
|
|
@@ -3716,14 +3762,14 @@ function On({
|
|
|
3716
3762
|
},
|
|
3717
3763
|
children: [
|
|
3718
3764
|
P ? P.name : p,
|
|
3719
|
-
/* @__PURE__ */ s("span", { style: { marginLeft: 8 }, children:
|
|
3765
|
+
/* @__PURE__ */ s("span", { style: { marginLeft: 8 }, children: b ? "▲" : "▼" })
|
|
3720
3766
|
]
|
|
3721
3767
|
}
|
|
3722
3768
|
),
|
|
3723
|
-
|
|
3769
|
+
b && /* @__PURE__ */ s(
|
|
3724
3770
|
"div",
|
|
3725
3771
|
{
|
|
3726
|
-
className:
|
|
3772
|
+
className: o,
|
|
3727
3773
|
style: {
|
|
3728
3774
|
position: "absolute",
|
|
3729
3775
|
top: "100%",
|
|
@@ -3737,34 +3783,34 @@ function On({
|
|
|
3737
3783
|
maxHeight: 300,
|
|
3738
3784
|
overflowY: "auto"
|
|
3739
3785
|
},
|
|
3740
|
-
children:
|
|
3741
|
-
const
|
|
3786
|
+
children: I.map((S) => {
|
|
3787
|
+
const L = S.id === N;
|
|
3742
3788
|
return /* @__PURE__ */ s(
|
|
3743
3789
|
"div",
|
|
3744
3790
|
{
|
|
3745
|
-
className:
|
|
3746
|
-
onClick: () =>
|
|
3791
|
+
className: i,
|
|
3792
|
+
onClick: () => M(S.id),
|
|
3747
3793
|
style: {
|
|
3748
3794
|
padding: "8px 12px",
|
|
3749
3795
|
cursor: "pointer",
|
|
3750
|
-
backgroundColor:
|
|
3796
|
+
backgroundColor: L ? "#f0f0f0" : "transparent"
|
|
3751
3797
|
},
|
|
3752
|
-
onMouseEnter: (
|
|
3753
|
-
|
|
3798
|
+
onMouseEnter: (E) => {
|
|
3799
|
+
L || (E.target.style.backgroundColor = "#f5f5f5");
|
|
3754
3800
|
},
|
|
3755
|
-
onMouseLeave: (
|
|
3756
|
-
|
|
3801
|
+
onMouseLeave: (E) => {
|
|
3802
|
+
L || (E.target.style.backgroundColor = "transparent");
|
|
3757
3803
|
},
|
|
3758
|
-
children: a ? a(
|
|
3804
|
+
children: a ? a(S, L) : h(S, L)
|
|
3759
3805
|
},
|
|
3760
|
-
|
|
3806
|
+
S.id
|
|
3761
3807
|
);
|
|
3762
3808
|
})
|
|
3763
3809
|
}
|
|
3764
3810
|
)
|
|
3765
3811
|
] });
|
|
3766
3812
|
}
|
|
3767
|
-
class
|
|
3813
|
+
class Vn {
|
|
3768
3814
|
constructor(e, t) {
|
|
3769
3815
|
this.httpService = e, this.sessionManager = t;
|
|
3770
3816
|
}
|
|
@@ -3785,12 +3831,12 @@ class zn {
|
|
|
3785
3831
|
throw new Error("SessionManager is required for private endpoints");
|
|
3786
3832
|
const t = await this.sessionManager.getAuthHeaders(), n = new URLSearchParams();
|
|
3787
3833
|
e != null && e.page && n.append("page", e.page.toString()), e != null && e.limit && n.append("limit", e.limit.toString()), e != null && e.sortBy && n.append("sortBy", e.sortBy), e != null && e.sortOrder && n.append("sortOrder", e.sortOrder);
|
|
3788
|
-
const
|
|
3834
|
+
const o = `/permissions/${n.toString() ? `?${n.toString()}` : ""}`, i = await this.httpService.get(o, {
|
|
3789
3835
|
headers: t
|
|
3790
3836
|
});
|
|
3791
3837
|
return {
|
|
3792
|
-
permissions:
|
|
3793
|
-
meta:
|
|
3838
|
+
permissions: i.data,
|
|
3839
|
+
meta: i.meta
|
|
3794
3840
|
};
|
|
3795
3841
|
}
|
|
3796
3842
|
async getPermissionById(e) {
|
|
@@ -3825,14 +3871,14 @@ class zn {
|
|
|
3825
3871
|
async getAppPermissions(e, t) {
|
|
3826
3872
|
const n = new URLSearchParams();
|
|
3827
3873
|
t != null && t.page && n.append("page", t.page.toString()), t != null && t.limit && n.append("limit", t.limit.toString()), t != null && t.sortBy && n.append("sortBy", t.sortBy), t != null && t.sortOrder && n.append("sortOrder", t.sortOrder);
|
|
3828
|
-
const
|
|
3874
|
+
const o = `/permissions/apps/${e}${n.toString() ? `?${n.toString()}` : ""}`, i = await this.httpService.get(o);
|
|
3829
3875
|
return {
|
|
3830
|
-
permissions:
|
|
3831
|
-
meta:
|
|
3876
|
+
permissions: i.data,
|
|
3877
|
+
meta: i.meta
|
|
3832
3878
|
};
|
|
3833
3879
|
}
|
|
3834
3880
|
}
|
|
3835
|
-
class
|
|
3881
|
+
class jn {
|
|
3836
3882
|
constructor(e, t) {
|
|
3837
3883
|
this.httpService = e, this.sessionManager = t;
|
|
3838
3884
|
}
|
|
@@ -3849,12 +3895,12 @@ class _n {
|
|
|
3849
3895
|
async getSubscriptionPlans(e) {
|
|
3850
3896
|
const t = await this.sessionManager.getAuthHeaders(), n = new URLSearchParams();
|
|
3851
3897
|
e != null && e.page && n.append("page", e.page.toString()), e != null && e.limit && n.append("limit", e.limit.toString()), e != null && e.sortBy && n.append("sortBy", e.sortBy), e != null && e.sortOrder && n.append("sortOrder", e.sortOrder), e != null && e.appId && n.append("appId", e.appId);
|
|
3852
|
-
const
|
|
3898
|
+
const o = `/subscription-plans/${n.toString() ? `?${n.toString()}` : ""}`, i = await this.httpService.get(o, {
|
|
3853
3899
|
headers: t
|
|
3854
3900
|
});
|
|
3855
3901
|
return {
|
|
3856
|
-
plans:
|
|
3857
|
-
meta:
|
|
3902
|
+
plans: i.data,
|
|
3903
|
+
meta: i.meta
|
|
3858
3904
|
};
|
|
3859
3905
|
}
|
|
3860
3906
|
async getSubscriptionPlanById(e) {
|
|
@@ -3883,7 +3929,7 @@ class _n {
|
|
|
3883
3929
|
});
|
|
3884
3930
|
}
|
|
3885
3931
|
}
|
|
3886
|
-
class
|
|
3932
|
+
class Gn {
|
|
3887
3933
|
constructor(e) {
|
|
3888
3934
|
this.httpService = e;
|
|
3889
3935
|
}
|
|
@@ -3892,7 +3938,7 @@ class Wn {
|
|
|
3892
3938
|
return await this.httpService.get("/health");
|
|
3893
3939
|
}
|
|
3894
3940
|
}
|
|
3895
|
-
class
|
|
3941
|
+
class Zn {
|
|
3896
3942
|
// Date string to Date object
|
|
3897
3943
|
static toDate(e) {
|
|
3898
3944
|
return new Date(e);
|
|
@@ -4009,21 +4055,21 @@ class Vn {
|
|
|
4009
4055
|
// Transform query parameters for API calls
|
|
4010
4056
|
static transformQueryParams(e) {
|
|
4011
4057
|
const t = new URLSearchParams();
|
|
4012
|
-
return Object.entries(e).forEach(([n,
|
|
4013
|
-
|
|
4058
|
+
return Object.entries(e).forEach(([n, o]) => {
|
|
4059
|
+
o != null && o !== "" && t.append(n, String(o));
|
|
4014
4060
|
}), t;
|
|
4015
4061
|
}
|
|
4016
4062
|
}
|
|
4017
|
-
const
|
|
4018
|
-
function
|
|
4063
|
+
const Je = "returnTo", xe = "zone_return_to", Pe = "zone_return_to";
|
|
4064
|
+
function Kn(r = {}) {
|
|
4019
4065
|
const {
|
|
4020
4066
|
zoneRoots: e = {},
|
|
4021
|
-
returnToParam: t =
|
|
4067
|
+
returnToParam: t = Je,
|
|
4022
4068
|
returnToStorage: n = "url"
|
|
4023
|
-
} = r,
|
|
4069
|
+
} = r, o = dt(), [i, a] = ut(), { isAuthenticated: p, currentUser: f } = le(), { tenant: w } = he(), u = Z(() => ({ ...Ne, ...e }), [e]), b = !!w, g = f == null ? void 0 : f.userType, T = Z(() => {
|
|
4024
4070
|
switch (n) {
|
|
4025
4071
|
case "url":
|
|
4026
|
-
return
|
|
4072
|
+
return i.get(t);
|
|
4027
4073
|
case "session":
|
|
4028
4074
|
return sessionStorage.getItem(xe);
|
|
4029
4075
|
case "local":
|
|
@@ -4031,10 +4077,10 @@ function jn(r = {}) {
|
|
|
4031
4077
|
default:
|
|
4032
4078
|
return null;
|
|
4033
4079
|
}
|
|
4034
|
-
}, [n,
|
|
4080
|
+
}, [n, i, t]), I = re(() => {
|
|
4035
4081
|
switch (n) {
|
|
4036
4082
|
case "url": {
|
|
4037
|
-
const h = new URLSearchParams(
|
|
4083
|
+
const h = new URLSearchParams(i);
|
|
4038
4084
|
h.delete(t), a(h, { replace: !0 });
|
|
4039
4085
|
break;
|
|
4040
4086
|
}
|
|
@@ -4045,11 +4091,11 @@ function jn(r = {}) {
|
|
|
4045
4091
|
localStorage.removeItem(Pe);
|
|
4046
4092
|
break;
|
|
4047
4093
|
}
|
|
4048
|
-
}, [n,
|
|
4094
|
+
}, [n, i, t, a]), N = re(
|
|
4049
4095
|
(h) => {
|
|
4050
4096
|
switch (n) {
|
|
4051
4097
|
case "url": {
|
|
4052
|
-
const x = new URLSearchParams(
|
|
4098
|
+
const x = new URLSearchParams(i);
|
|
4053
4099
|
x.set(t, h), a(x, { replace: !0 });
|
|
4054
4100
|
break;
|
|
4055
4101
|
}
|
|
@@ -4061,86 +4107,89 @@ function jn(r = {}) {
|
|
|
4061
4107
|
break;
|
|
4062
4108
|
}
|
|
4063
4109
|
},
|
|
4064
|
-
[n,
|
|
4065
|
-
),
|
|
4110
|
+
[n, i, t, a]
|
|
4111
|
+
), M = re(
|
|
4066
4112
|
(h) => {
|
|
4067
4113
|
const x = u[h] || u.default;
|
|
4068
|
-
|
|
4114
|
+
o(x);
|
|
4069
4115
|
},
|
|
4070
|
-
[
|
|
4071
|
-
), P = re(() =>
|
|
4116
|
+
[o, u]
|
|
4117
|
+
), P = re(() => b ? p ? g === se.TENANT_ADMIN ? u.tenantAdmin : u.tenantUser : u.tenantGuest : p ? g === se.TENANT_ADMIN ? u.publicAdmin : u.publicUser : u.publicGuest, [b, p, g, u]);
|
|
4072
4118
|
return {
|
|
4073
|
-
returnToUrl:
|
|
4074
|
-
clearReturnTo:
|
|
4075
|
-
setReturnTo:
|
|
4076
|
-
navigateToZone:
|
|
4119
|
+
returnToUrl: T,
|
|
4120
|
+
clearReturnTo: I,
|
|
4121
|
+
setReturnTo: N,
|
|
4122
|
+
navigateToZone: M,
|
|
4077
4123
|
getSmartRedirect: P
|
|
4078
4124
|
};
|
|
4079
4125
|
}
|
|
4080
|
-
function
|
|
4126
|
+
function Jn(r, e, t = Je, n = "url") {
|
|
4081
4127
|
if (!e || n !== "url")
|
|
4082
4128
|
return r;
|
|
4083
|
-
const
|
|
4084
|
-
return
|
|
4129
|
+
const o = new URL(r, window.location.origin);
|
|
4130
|
+
return o.searchParams.set(t, e), o.pathname + o.search;
|
|
4085
4131
|
}
|
|
4086
4132
|
export {
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4133
|
+
Mn as AdminZone,
|
|
4134
|
+
Zn as ApiMappers,
|
|
4135
|
+
$e as AppApiService,
|
|
4136
|
+
zn as AppLoader,
|
|
4137
|
+
un as AppProvider,
|
|
4138
|
+
ht as AuthApiService,
|
|
4139
|
+
mn as AuthProvider,
|
|
4140
|
+
Rn as AuthenticatedZone,
|
|
4141
|
+
Ze as DEFAULT_ZONE_PRESETS,
|
|
4142
|
+
Ne as DEFAULT_ZONE_ROOTS,
|
|
4143
|
+
Un as FeatureFlag,
|
|
4144
|
+
vt as FeatureFlagApiService,
|
|
4145
|
+
yn as FeatureFlagProvider,
|
|
4146
|
+
In as GuestZone,
|
|
4147
|
+
Gn as HealthApiService,
|
|
4102
4148
|
ie as HttpService,
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4149
|
+
An as LandingRoute,
|
|
4150
|
+
$n as LoginForm,
|
|
4151
|
+
Bn as MagicLinkForm,
|
|
4152
|
+
qn as MagicLinkVerify,
|
|
4153
|
+
En as OpenZone,
|
|
4154
|
+
On as PasswordRecoveryForm,
|
|
4155
|
+
Vn as PermissionApiService,
|
|
4156
|
+
vn as Protected,
|
|
4157
|
+
Tn as ProtectedRoute,
|
|
4158
|
+
Pn as PublicZone,
|
|
4159
|
+
He as RoleApiService,
|
|
4160
|
+
bn as RoutingProvider,
|
|
4114
4161
|
Ae as SessionManager,
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4162
|
+
Hn as SignupForm,
|
|
4163
|
+
kt as SubscriptionApiService,
|
|
4164
|
+
Cn as SubscriptionGuard,
|
|
4165
|
+
jn as SubscriptionPlanApiService,
|
|
4166
|
+
wn as SubscriptionProvider,
|
|
4167
|
+
fe as TenantApiService,
|
|
4168
|
+
Fn as TenantAuthenticatedZone,
|
|
4169
|
+
Dn as TenantGuestZone,
|
|
4170
|
+
Nn as TenantOpenZone,
|
|
4171
|
+
gn as TenantProvider,
|
|
4172
|
+
kn as TenantRoute,
|
|
4173
|
+
Wn as TenantSelector,
|
|
4174
|
+
xn as TenantZone,
|
|
4175
|
+
gt as UserApiService,
|
|
4129
4176
|
se as UserType,
|
|
4130
|
-
|
|
4177
|
+
Ln as UserZone,
|
|
4131
4178
|
ae as ZoneRoute,
|
|
4132
|
-
|
|
4133
|
-
|
|
4179
|
+
Jn as buildRedirectUrl,
|
|
4180
|
+
hn as useApi,
|
|
4134
4181
|
ye as useApp,
|
|
4135
|
-
|
|
4182
|
+
_n as useAppLoaderState,
|
|
4136
4183
|
le as useAuth,
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4184
|
+
Tt as useFeatureFlags,
|
|
4185
|
+
Sn as useRouting,
|
|
4186
|
+
xt as useRoutingOptional,
|
|
4187
|
+
fn as useSettings,
|
|
4188
|
+
At as useSubscription,
|
|
4189
|
+
he as useTenant,
|
|
4190
|
+
ge as useTenantInfo,
|
|
4142
4191
|
Se as useTenantOptional,
|
|
4143
|
-
|
|
4144
|
-
|
|
4192
|
+
pn as useTenantSettings,
|
|
4193
|
+
Kn as useZoneNavigation
|
|
4145
4194
|
};
|
|
4146
4195
|
//# sourceMappingURL=index.es.js.map
|