@skylabs-digital/react-identity-access 2.12.0 → 2.13.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/LandingRoute.d.ts +13 -0
- package/dist/components/LandingRoute.d.ts.map +1 -1
- package/dist/components/ProtectedRoute.d.ts +20 -0
- package/dist/components/ProtectedRoute.d.ts.map +1 -1
- package/dist/components/TenantRoute.d.ts +13 -0
- package/dist/components/TenantRoute.d.ts.map +1 -1
- package/dist/components/ZoneRoute.d.ts +28 -0
- package/dist/components/ZoneRoute.d.ts.map +1 -0
- package/dist/hooks/useZoneNavigation.d.ts +17 -0
- package/dist/hooks/useZoneNavigation.d.ts.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +1642 -1420
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/types/zoneRouting.d.ts +122 -0
- package/dist/types/zoneRouting.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { useLocation as
|
|
4
|
-
class
|
|
1
|
+
import { jsx as s, Fragment as _, jsxs as d } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as me, useMemo as K, useState as A, useCallback as re, useEffect as X, useContext as oe, useRef as ze } from "react";
|
|
3
|
+
import { useLocation as be, Navigate as fe, useNavigate as lt, useSearchParams as ct } from "react-router-dom";
|
|
4
|
+
class ie {
|
|
5
5
|
// SessionManager instance
|
|
6
6
|
constructor(e, t = 1e4) {
|
|
7
7
|
this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
|
|
@@ -12,60 +12,60 @@ class ne {
|
|
|
12
12
|
getBaseUrl() {
|
|
13
13
|
return this.baseUrl;
|
|
14
14
|
}
|
|
15
|
-
async request(e, t,
|
|
16
|
-
return this.executeRequest(e, t,
|
|
15
|
+
async request(e, t, n, i) {
|
|
16
|
+
return this.executeRequest(e, t, n, i, !1);
|
|
17
17
|
}
|
|
18
|
-
async executeRequest(e, t,
|
|
19
|
-
const a = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`,
|
|
20
|
-
let
|
|
18
|
+
async executeRequest(e, t, n, i, o = !1) {
|
|
19
|
+
const a = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, p = (i == null ? void 0 : i.timeout) || this.timeout;
|
|
20
|
+
let f = {
|
|
21
21
|
"Content-Type": "application/json",
|
|
22
|
-
...
|
|
22
|
+
...i == null ? void 0 : i.headers
|
|
23
23
|
};
|
|
24
|
-
if (!(
|
|
24
|
+
if (!(i != null && i.skipAuth) && this.sessionManager)
|
|
25
25
|
try {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
} catch (
|
|
29
|
-
console.warn("Failed to inject auth headers:",
|
|
26
|
+
const w = await this.sessionManager.getAuthHeaders();
|
|
27
|
+
f = { ...f, ...w };
|
|
28
|
+
} catch (w) {
|
|
29
|
+
console.warn("Failed to inject auth headers:", w);
|
|
30
30
|
}
|
|
31
|
-
const b = new AbortController(),
|
|
31
|
+
const b = new AbortController(), u = setTimeout(() => b.abort(), p);
|
|
32
32
|
try {
|
|
33
|
-
const
|
|
33
|
+
const w = await fetch(a, {
|
|
34
34
|
method: e,
|
|
35
|
-
headers:
|
|
36
|
-
body:
|
|
35
|
+
headers: f,
|
|
36
|
+
body: n ? JSON.stringify(n) : void 0,
|
|
37
37
|
signal: b.signal
|
|
38
38
|
});
|
|
39
|
-
if (clearTimeout(
|
|
39
|
+
if (clearTimeout(u), w.status === 401 && !(i != null && i.skipRetry) && !o && this.sessionManager)
|
|
40
40
|
try {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t,
|
|
41
|
+
const v = this.sessionManager.getTokens();
|
|
42
|
+
if (v != null && v.refreshToken)
|
|
43
|
+
return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, n, i, !0);
|
|
44
44
|
} catch {
|
|
45
|
-
throw new Error(`HTTP ${
|
|
45
|
+
throw new Error(`HTTP ${w.status}: ${w.statusText}`);
|
|
46
46
|
}
|
|
47
|
-
if (!
|
|
48
|
-
throw new Error(`HTTP ${
|
|
49
|
-
const
|
|
50
|
-
return !
|
|
51
|
-
} catch (
|
|
52
|
-
throw clearTimeout(
|
|
47
|
+
if (!w.ok)
|
|
48
|
+
throw new Error(`HTTP ${w.status}: ${w.statusText}`);
|
|
49
|
+
const g = w.headers.get("content-type");
|
|
50
|
+
return !g || !g.includes("application/json") ? {} : await w.json();
|
|
51
|
+
} catch (w) {
|
|
52
|
+
throw clearTimeout(u), w instanceof Error && w.name === "AbortError" ? new Error(`Request timeout after ${p}ms`) : w;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
async get(e, t) {
|
|
56
56
|
return this.request("GET", e, void 0, t);
|
|
57
57
|
}
|
|
58
|
-
async post(e, t,
|
|
59
|
-
return this.request("POST", e, t,
|
|
58
|
+
async post(e, t, n) {
|
|
59
|
+
return this.request("POST", e, t, n);
|
|
60
60
|
}
|
|
61
|
-
async put(e, t,
|
|
62
|
-
return this.request("PUT", e, t,
|
|
61
|
+
async put(e, t, n) {
|
|
62
|
+
return this.request("PUT", e, t, n);
|
|
63
63
|
}
|
|
64
64
|
async delete(e, t) {
|
|
65
65
|
return this.request("DELETE", e, void 0, t);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
class
|
|
68
|
+
class Ce {
|
|
69
69
|
constructor(e, t) {
|
|
70
70
|
this.httpService = e, this.sessionManager = t;
|
|
71
71
|
}
|
|
@@ -76,9 +76,9 @@ class Fe {
|
|
|
76
76
|
})).data;
|
|
77
77
|
}
|
|
78
78
|
async getApps(e) {
|
|
79
|
-
const t = await this.sessionManager.getAuthHeaders(),
|
|
80
|
-
e != null && e.page &&
|
|
81
|
-
const
|
|
79
|
+
const t = await this.sessionManager.getAuthHeaders(), n = new URLSearchParams();
|
|
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 i = `/apps/${n.toString() ? `?${n.toString()}` : ""}`, o = await this.httpService.get(i, {
|
|
82
82
|
headers: t
|
|
83
83
|
});
|
|
84
84
|
return {
|
|
@@ -93,28 +93,28 @@ class Fe {
|
|
|
93
93
|
})).data;
|
|
94
94
|
}
|
|
95
95
|
async updateApp(e, t) {
|
|
96
|
-
const
|
|
96
|
+
const n = await this.sessionManager.getAuthHeaders();
|
|
97
97
|
return (await this.httpService.put(`/apps/${e}`, t, {
|
|
98
|
-
headers:
|
|
98
|
+
headers: n
|
|
99
99
|
})).data;
|
|
100
100
|
}
|
|
101
101
|
async getPublicAppInfo(e) {
|
|
102
102
|
return (await this.httpService.get(`/apps/${e}/public`)).data;
|
|
103
103
|
}
|
|
104
104
|
async setDefaultSubscriptionPlan(e, t) {
|
|
105
|
-
const
|
|
105
|
+
const n = await this.sessionManager.getAuthHeaders();
|
|
106
106
|
return (await this.httpService.put(
|
|
107
107
|
`/apps/${e}/default-subscription-plan`,
|
|
108
108
|
{ planId: t },
|
|
109
|
-
{ headers:
|
|
109
|
+
{ headers: n }
|
|
110
110
|
)).data;
|
|
111
111
|
}
|
|
112
|
-
async updateSettingsSchema(e, t,
|
|
113
|
-
const
|
|
112
|
+
async updateSettingsSchema(e, t, n) {
|
|
113
|
+
const i = await this.sessionManager.getAuthHeaders();
|
|
114
114
|
return (await this.httpService.put(
|
|
115
115
|
`/apps/${e}/settings-schema`,
|
|
116
|
-
{ schema: t, defaultSettings:
|
|
117
|
-
{ headers:
|
|
116
|
+
{ schema: t, defaultSettings: n },
|
|
117
|
+
{ headers: i }
|
|
118
118
|
)).data;
|
|
119
119
|
}
|
|
120
120
|
async exportConfig(e) {
|
|
@@ -124,102 +124,102 @@ class Fe {
|
|
|
124
124
|
})).data;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
const
|
|
128
|
-
function
|
|
129
|
-
const t =
|
|
127
|
+
const Re = me(null);
|
|
128
|
+
function dn({ config: r, children: e }) {
|
|
129
|
+
const t = K(
|
|
130
130
|
() => {
|
|
131
|
-
var
|
|
131
|
+
var g, v, M;
|
|
132
132
|
return {
|
|
133
|
-
enabled: ((
|
|
134
|
-
ttl: ((
|
|
133
|
+
enabled: ((g = r.cache) == null ? void 0 : g.enabled) ?? !0,
|
|
134
|
+
ttl: ((v = r.cache) == null ? void 0 : v.ttl) ?? 3e5,
|
|
135
135
|
// 5 minutes default
|
|
136
|
-
storageKey: ((
|
|
136
|
+
storageKey: ((M = r.cache) == null ? void 0 : M.storageKey) ?? `app_cache_${r.appId}`
|
|
137
137
|
};
|
|
138
138
|
},
|
|
139
|
-
[
|
|
140
|
-
), [
|
|
139
|
+
[r.cache, r.appId]
|
|
140
|
+
), [n, i] = A(() => {
|
|
141
141
|
if (!t.enabled) return null;
|
|
142
142
|
try {
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
145
|
-
const
|
|
146
|
-
return Date.now() -
|
|
143
|
+
const g = localStorage.getItem(t.storageKey);
|
|
144
|
+
if (!g) return null;
|
|
145
|
+
const v = JSON.parse(g);
|
|
146
|
+
return Date.now() - v.timestamp < t.ttl && v.appId === r.appId ? v.data : (localStorage.removeItem(t.storageKey), null);
|
|
147
147
|
} catch {
|
|
148
148
|
return null;
|
|
149
149
|
}
|
|
150
|
-
}), [o, a] =
|
|
151
|
-
const
|
|
152
|
-
|
|
150
|
+
}), [o, a] = A(!n), [p, f] = A(null), b = K(() => {
|
|
151
|
+
const g = () => {
|
|
152
|
+
u();
|
|
153
153
|
};
|
|
154
154
|
return {
|
|
155
|
-
appId:
|
|
156
|
-
baseUrl:
|
|
155
|
+
appId: r.appId,
|
|
156
|
+
baseUrl: r.baseUrl,
|
|
157
157
|
// App info
|
|
158
|
-
appInfo:
|
|
158
|
+
appInfo: n,
|
|
159
159
|
isAppLoading: o,
|
|
160
|
-
appError:
|
|
161
|
-
retryApp:
|
|
160
|
+
appError: p,
|
|
161
|
+
retryApp: g
|
|
162
162
|
};
|
|
163
|
-
}, [
|
|
164
|
-
async (
|
|
165
|
-
if (!(!
|
|
163
|
+
}, [r, n, o, p]), u = re(
|
|
164
|
+
async (g = !1) => {
|
|
165
|
+
if (!(!g && t.enabled && n))
|
|
166
166
|
try {
|
|
167
|
-
a(!0),
|
|
168
|
-
const
|
|
169
|
-
if (
|
|
167
|
+
a(!0), f(null);
|
|
168
|
+
const v = new ie(r.baseUrl), F = await new Ce(v, {}).getPublicAppInfo(r.appId);
|
|
169
|
+
if (i(F), t.enabled)
|
|
170
170
|
try {
|
|
171
|
-
const
|
|
172
|
-
data:
|
|
171
|
+
const L = {
|
|
172
|
+
data: F,
|
|
173
173
|
timestamp: Date.now(),
|
|
174
|
-
appId:
|
|
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(L));
|
|
177
|
+
} catch (L) {
|
|
178
|
+
console.warn("Failed to cache app info:", L);
|
|
179
179
|
}
|
|
180
|
-
} catch (
|
|
181
|
-
const
|
|
182
|
-
|
|
180
|
+
} catch (v) {
|
|
181
|
+
const M = v instanceof Error ? v : new Error("Failed to load app information");
|
|
182
|
+
f(M), i(null);
|
|
183
183
|
} finally {
|
|
184
184
|
a(!1);
|
|
185
185
|
}
|
|
186
186
|
},
|
|
187
|
-
[
|
|
188
|
-
),
|
|
189
|
-
if (!(!t.enabled || !
|
|
187
|
+
[r.baseUrl, r.appId, t, n]
|
|
188
|
+
), w = re(async () => {
|
|
189
|
+
if (!(!t.enabled || !n))
|
|
190
190
|
try {
|
|
191
|
-
const
|
|
192
|
-
if (!
|
|
193
|
-
const
|
|
194
|
-
if (Date.now() -
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
const
|
|
198
|
-
data:
|
|
191
|
+
const g = localStorage.getItem(t.storageKey);
|
|
192
|
+
if (!g) return;
|
|
193
|
+
const v = JSON.parse(g);
|
|
194
|
+
if (Date.now() - v.timestamp > t.ttl * 0.5) {
|
|
195
|
+
const F = new ie(r.baseUrl), P = await new Ce(F, {}).getPublicAppInfo(r.appId);
|
|
196
|
+
i(P);
|
|
197
|
+
const h = {
|
|
198
|
+
data: P,
|
|
199
199
|
timestamp: Date.now(),
|
|
200
|
-
appId:
|
|
200
|
+
appId: r.appId
|
|
201
201
|
};
|
|
202
|
-
localStorage.setItem(t.storageKey, JSON.stringify(
|
|
202
|
+
localStorage.setItem(t.storageKey, JSON.stringify(h));
|
|
203
203
|
}
|
|
204
|
-
} catch (
|
|
205
|
-
console.warn("Background app refresh failed:",
|
|
204
|
+
} catch (g) {
|
|
205
|
+
console.warn("Background app refresh failed:", g);
|
|
206
206
|
}
|
|
207
|
-
}, [
|
|
208
|
-
return
|
|
209
|
-
|
|
210
|
-
}, []), /* @__PURE__ */
|
|
207
|
+
}, [r, t, n]);
|
|
208
|
+
return X(() => {
|
|
209
|
+
n ? w() : u();
|
|
210
|
+
}, []), /* @__PURE__ */ s(Re.Provider, { value: b, children: e });
|
|
211
211
|
}
|
|
212
|
-
function
|
|
213
|
-
const
|
|
214
|
-
if (!
|
|
212
|
+
function ye() {
|
|
213
|
+
const r = oe(Re);
|
|
214
|
+
if (!r)
|
|
215
215
|
throw new Error("useApp must be used within an AppProvider");
|
|
216
|
-
return
|
|
216
|
+
return r;
|
|
217
217
|
}
|
|
218
|
-
function
|
|
219
|
-
return
|
|
218
|
+
function _e() {
|
|
219
|
+
return oe(Re);
|
|
220
220
|
}
|
|
221
|
-
const
|
|
222
|
-
class
|
|
221
|
+
const un = ye;
|
|
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);
|
|
225
225
|
}
|
|
@@ -256,12 +256,12 @@ class ke {
|
|
|
256
256
|
this.tokenStorage.set(t);
|
|
257
257
|
}
|
|
258
258
|
getTokens() {
|
|
259
|
-
const { accessToken: e, refreshToken: t, expiresAt:
|
|
259
|
+
const { accessToken: e, refreshToken: t, expiresAt: n, expiresIn: i, tokenType: o } = this.tokenStorage.get() || {};
|
|
260
260
|
return e ? {
|
|
261
261
|
accessToken: e,
|
|
262
262
|
refreshToken: t,
|
|
263
|
-
expiresAt:
|
|
264
|
-
expiresIn:
|
|
263
|
+
expiresAt: n,
|
|
264
|
+
expiresIn: i,
|
|
265
265
|
tokenType: o
|
|
266
266
|
} : null;
|
|
267
267
|
}
|
|
@@ -291,17 +291,17 @@ class ke {
|
|
|
291
291
|
if (!e.refreshToken)
|
|
292
292
|
return this.clearSession(), this.onRefreshFailed && this.onRefreshFailed(), {};
|
|
293
293
|
if (this.refreshPromise)
|
|
294
|
-
return new Promise((t,
|
|
295
|
-
this.refreshQueue.push({ resolve: t, reject:
|
|
294
|
+
return new Promise((t, n) => {
|
|
295
|
+
this.refreshQueue.push({ resolve: t, reject: n });
|
|
296
296
|
});
|
|
297
297
|
this.refreshPromise = this.performTokenRefresh(e.refreshToken);
|
|
298
298
|
try {
|
|
299
299
|
await this.refreshPromise;
|
|
300
|
-
const t = this.getTokens(),
|
|
301
|
-
return this.refreshQueue.forEach(({ resolve:
|
|
300
|
+
const t = this.getTokens(), n = t != null && t.accessToken ? { Authorization: `Bearer ${t.accessToken}` } : {};
|
|
301
|
+
return this.refreshQueue.forEach(({ resolve: i }) => i(n)), this.refreshQueue = [], n;
|
|
302
302
|
} catch (t) {
|
|
303
|
-
const
|
|
304
|
-
return this.refreshQueue.forEach(({ reject:
|
|
303
|
+
const n = t instanceof Error ? t : new Error("Token refresh failed");
|
|
304
|
+
return this.refreshQueue.forEach(({ reject: i }) => i(n)), this.refreshQueue = [], this.clearSession(), this.onRefreshFailed && this.onRefreshFailed(), {};
|
|
305
305
|
} finally {
|
|
306
306
|
this.refreshPromise = null;
|
|
307
307
|
}
|
|
@@ -309,7 +309,7 @@ class ke {
|
|
|
309
309
|
async performTokenRefresh(e) {
|
|
310
310
|
if (!this.baseUrl)
|
|
311
311
|
throw new Error("Base URL not configured for token refresh");
|
|
312
|
-
const t = `${this.baseUrl}/auth/refresh`,
|
|
312
|
+
const t = `${this.baseUrl}/auth/refresh`, n = await fetch(t, {
|
|
313
313
|
method: "POST",
|
|
314
314
|
headers: {
|
|
315
315
|
"Content-Type": "application/json"
|
|
@@ -318,13 +318,13 @@ class ke {
|
|
|
318
318
|
refreshToken: e
|
|
319
319
|
})
|
|
320
320
|
});
|
|
321
|
-
if (!
|
|
322
|
-
throw new Error(`Token refresh failed: ${
|
|
323
|
-
const
|
|
321
|
+
if (!n.ok)
|
|
322
|
+
throw new Error(`Token refresh failed: ${n.status} ${n.statusText}`);
|
|
323
|
+
const i = await n.json();
|
|
324
324
|
this.setTokens({
|
|
325
|
-
accessToken:
|
|
326
|
-
refreshToken:
|
|
327
|
-
expiresIn:
|
|
325
|
+
accessToken: i.accessToken,
|
|
326
|
+
refreshToken: i.refreshToken || e,
|
|
327
|
+
expiresIn: i.expiresIn
|
|
328
328
|
});
|
|
329
329
|
}
|
|
330
330
|
setUser(e) {
|
|
@@ -352,8 +352,8 @@ class ke {
|
|
|
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
|
|
356
|
-
return JSON.parse(
|
|
355
|
+
const n = t[1], i = atob(n.replace(/-/g, "+").replace(/_/g, "/"));
|
|
356
|
+
return JSON.parse(i);
|
|
357
357
|
} catch {
|
|
358
358
|
return null;
|
|
359
359
|
}
|
|
@@ -372,7 +372,7 @@ class ke {
|
|
|
372
372
|
return e !== null && !this.isTokenExpired(e);
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
|
-
class
|
|
375
|
+
class dt {
|
|
376
376
|
constructor(e) {
|
|
377
377
|
this.httpService = e;
|
|
378
378
|
}
|
|
@@ -428,7 +428,7 @@ class rt {
|
|
|
428
428
|
});
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
|
-
class
|
|
431
|
+
class De {
|
|
432
432
|
constructor(e, t) {
|
|
433
433
|
this.httpService = e, this.sessionManager = t;
|
|
434
434
|
}
|
|
@@ -451,9 +451,9 @@ class Ce {
|
|
|
451
451
|
async updateRole(e, t) {
|
|
452
452
|
if (!this.sessionManager)
|
|
453
453
|
throw new Error("SessionManager is required for private endpoints");
|
|
454
|
-
const
|
|
454
|
+
const n = await this.sessionManager.getAuthHeaders();
|
|
455
455
|
return (await this.httpService.put(`/roles/${e}`, t, {
|
|
456
|
-
headers:
|
|
456
|
+
headers: n
|
|
457
457
|
})).data;
|
|
458
458
|
}
|
|
459
459
|
async deleteRole(e) {
|
|
@@ -466,9 +466,9 @@ class Ce {
|
|
|
466
466
|
}
|
|
467
467
|
// Public endpoint - no auth required
|
|
468
468
|
async getRolesByApp(e, t) {
|
|
469
|
-
const
|
|
470
|
-
t != null && t.page &&
|
|
471
|
-
const
|
|
469
|
+
const n = new URLSearchParams();
|
|
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 i = `/roles/app/${e}${n.toString() ? `?${n.toString()}` : ""}`, o = await this.httpService.get(i);
|
|
472
472
|
return {
|
|
473
473
|
roles: o.data,
|
|
474
474
|
meta: o.meta
|
|
@@ -477,26 +477,26 @@ class Ce {
|
|
|
477
477
|
async assignRole(e, t) {
|
|
478
478
|
if (!this.sessionManager)
|
|
479
479
|
throw new Error("SessionManager is required for private endpoints");
|
|
480
|
-
const
|
|
480
|
+
const n = await this.sessionManager.getAuthHeaders();
|
|
481
481
|
await this.httpService.post(`/roles/${e}/assign`, t, {
|
|
482
|
-
headers:
|
|
482
|
+
headers: n
|
|
483
483
|
});
|
|
484
484
|
}
|
|
485
485
|
async revokeRole(e, t) {
|
|
486
486
|
if (!this.sessionManager)
|
|
487
487
|
throw new Error("SessionManager is required for private endpoints");
|
|
488
|
-
const
|
|
488
|
+
const n = await this.sessionManager.getAuthHeaders();
|
|
489
489
|
await this.httpService.post(`/roles/${e}/revoke`, t, {
|
|
490
|
-
headers:
|
|
490
|
+
headers: n
|
|
491
491
|
});
|
|
492
492
|
}
|
|
493
493
|
async getUserRoles(e, t) {
|
|
494
494
|
if (!this.sessionManager)
|
|
495
495
|
throw new Error("SessionManager is required for private endpoints");
|
|
496
|
-
const
|
|
497
|
-
t != null && t.page &&
|
|
498
|
-
const o = `/roles/user/${e}${
|
|
499
|
-
headers:
|
|
496
|
+
const n = await this.sessionManager.getAuthHeaders(), i = new URLSearchParams();
|
|
497
|
+
t != null && t.page && i.append("page", t.page.toString()), t != null && t.limit && i.append("limit", t.limit.toString()), t != null && t.sortBy && i.append("sortBy", t.sortBy), t != null && t.sortOrder && i.append("sortOrder", t.sortOrder);
|
|
498
|
+
const o = `/roles/user/${e}${i.toString() ? `?${i.toString()}` : ""}`, a = await this.httpService.get(o, {
|
|
499
|
+
headers: n
|
|
500
500
|
});
|
|
501
501
|
return {
|
|
502
502
|
roles: a.data,
|
|
@@ -504,7 +504,7 @@ class Ce {
|
|
|
504
504
|
};
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
|
-
class
|
|
507
|
+
class ut {
|
|
508
508
|
constructor(e, t) {
|
|
509
509
|
this.httpService = e, this.sessionManager = t;
|
|
510
510
|
}
|
|
@@ -515,9 +515,9 @@ class nt {
|
|
|
515
515
|
})).data;
|
|
516
516
|
}
|
|
517
517
|
async getUsers(e) {
|
|
518
|
-
const t = await this.sessionManager.getAuthHeaders(),
|
|
519
|
-
e != null && e.page &&
|
|
520
|
-
const
|
|
518
|
+
const t = await this.sessionManager.getAuthHeaders(), n = new URLSearchParams();
|
|
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 i = `/users/${n.toString() ? `?${n.toString()}` : ""}`, o = await this.httpService.get(i, {
|
|
521
521
|
headers: t
|
|
522
522
|
});
|
|
523
523
|
return {
|
|
@@ -532,9 +532,9 @@ class nt {
|
|
|
532
532
|
})).data;
|
|
533
533
|
}
|
|
534
534
|
async updateUser(e, t) {
|
|
535
|
-
const
|
|
535
|
+
const n = await this.sessionManager.getAuthHeaders();
|
|
536
536
|
return (await this.httpService.put(`/users/${e}`, t, {
|
|
537
|
-
headers:
|
|
537
|
+
headers: n
|
|
538
538
|
})).data;
|
|
539
539
|
}
|
|
540
540
|
async deleteUser(e) {
|
|
@@ -544,9 +544,9 @@ class nt {
|
|
|
544
544
|
});
|
|
545
545
|
}
|
|
546
546
|
}
|
|
547
|
-
class
|
|
548
|
-
constructor(e, t,
|
|
549
|
-
this.httpService = e, this.appId = t, this.sessionManager =
|
|
547
|
+
class pe {
|
|
548
|
+
constructor(e, t, n) {
|
|
549
|
+
this.httpService = e, this.appId = t, this.sessionManager = n;
|
|
550
550
|
}
|
|
551
551
|
async createTenant(e) {
|
|
552
552
|
if (!this.sessionManager)
|
|
@@ -559,9 +559,9 @@ class ue {
|
|
|
559
559
|
async getTenants(e) {
|
|
560
560
|
if (!this.sessionManager)
|
|
561
561
|
throw new Error("SessionManager is required for private endpoints");
|
|
562
|
-
const t = await this.sessionManager.getAuthHeaders(),
|
|
563
|
-
e != null && e.page &&
|
|
564
|
-
const
|
|
562
|
+
const t = await this.sessionManager.getAuthHeaders(), n = new URLSearchParams();
|
|
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 i = `/tenants/${n.toString() ? `?${n.toString()}` : ""}`, o = await this.httpService.get(i, {
|
|
565
565
|
headers: t
|
|
566
566
|
});
|
|
567
567
|
return {
|
|
@@ -580,20 +580,20 @@ class ue {
|
|
|
580
580
|
async updateTenant(e, t) {
|
|
581
581
|
if (!this.sessionManager)
|
|
582
582
|
throw new Error("SessionManager is required for private endpoints");
|
|
583
|
-
const
|
|
583
|
+
const n = await this.sessionManager.getAuthHeaders();
|
|
584
584
|
return (await this.httpService.put(`/tenants/${e}`, t, {
|
|
585
|
-
headers:
|
|
585
|
+
headers: n
|
|
586
586
|
})).data;
|
|
587
587
|
}
|
|
588
588
|
async adminUpdateTenant(e, t) {
|
|
589
589
|
if (!this.sessionManager)
|
|
590
590
|
throw new Error("SessionManager is required for private endpoints");
|
|
591
|
-
const
|
|
591
|
+
const n = await this.sessionManager.getAuthHeaders();
|
|
592
592
|
return (await this.httpService.put(
|
|
593
593
|
`/tenants/${e}/admin-update`,
|
|
594
594
|
t,
|
|
595
595
|
{
|
|
596
|
-
headers:
|
|
596
|
+
headers: n
|
|
597
597
|
}
|
|
598
598
|
)).data;
|
|
599
599
|
}
|
|
@@ -612,72 +612,72 @@ class ue {
|
|
|
612
612
|
async updateTenantSettings(e, t) {
|
|
613
613
|
if (!this.sessionManager)
|
|
614
614
|
throw new Error("SessionManager is required for private endpoints");
|
|
615
|
-
const
|
|
615
|
+
const n = await this.sessionManager.getAuthHeaders();
|
|
616
616
|
return (await this.httpService.put(
|
|
617
617
|
`/tenants/${e}/settings`,
|
|
618
618
|
t,
|
|
619
619
|
{
|
|
620
|
-
headers:
|
|
620
|
+
headers: n
|
|
621
621
|
}
|
|
622
622
|
)).data;
|
|
623
623
|
}
|
|
624
624
|
}
|
|
625
|
-
function
|
|
626
|
-
if (
|
|
625
|
+
function ht(r, e) {
|
|
626
|
+
if (r === "localhost" || r.startsWith("127.") || r.startsWith("192.168."))
|
|
627
627
|
return null;
|
|
628
628
|
if (e) {
|
|
629
|
-
const
|
|
630
|
-
if (o ===
|
|
629
|
+
const i = e.toLowerCase(), o = r.toLowerCase();
|
|
630
|
+
if (o === i || o === `www.${i}`)
|
|
631
631
|
return null;
|
|
632
|
-
if (o.endsWith(`.${
|
|
633
|
-
const a = o.slice(0, -(
|
|
632
|
+
if (o.endsWith(`.${i}`)) {
|
|
633
|
+
const a = o.slice(0, -(i.length + 1));
|
|
634
634
|
return a === "www" ? null : a;
|
|
635
635
|
}
|
|
636
636
|
return null;
|
|
637
637
|
}
|
|
638
|
-
const
|
|
639
|
-
return
|
|
638
|
+
const n = r.split(".");
|
|
639
|
+
return n.length >= 3 && n[0] !== "www" ? n[0] : null;
|
|
640
640
|
}
|
|
641
|
-
function
|
|
642
|
-
const
|
|
643
|
-
return
|
|
641
|
+
function gt(r, e = "tenant", t) {
|
|
642
|
+
const i = new URLSearchParams(r).get(e);
|
|
643
|
+
return i ? (t && t.setItem("tenant", i), i) : t ? t.getItem("tenant") : null;
|
|
644
644
|
}
|
|
645
|
-
function
|
|
646
|
-
const { tenantMode:
|
|
647
|
-
return
|
|
645
|
+
function pt(r, e, t) {
|
|
646
|
+
const { tenantMode: n, baseDomain: i, selectorParam: o } = r;
|
|
647
|
+
return n === "subdomain" ? ht(e.hostname, i) : n === "selector" ? gt(e.search, o, t) : null;
|
|
648
648
|
}
|
|
649
|
-
function
|
|
649
|
+
function ft(r, e, t) {
|
|
650
650
|
if (t)
|
|
651
|
-
return `${
|
|
652
|
-
const
|
|
653
|
-
return
|
|
651
|
+
return `${r}.${t}`;
|
|
652
|
+
const n = e.split(".");
|
|
653
|
+
return n.length === 2 ? `${r}.${e}` : n.length >= 3 ? (n[0] = r, n.join(".")) : null;
|
|
654
654
|
}
|
|
655
|
-
const
|
|
656
|
-
function
|
|
657
|
-
const e = JSON.stringify(
|
|
655
|
+
const de = "_auth";
|
|
656
|
+
function $e(r) {
|
|
657
|
+
const e = JSON.stringify(r);
|
|
658
658
|
return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
659
659
|
}
|
|
660
|
-
function
|
|
660
|
+
function mt(r) {
|
|
661
661
|
try {
|
|
662
|
-
let e =
|
|
662
|
+
let e = r.replace(/-/g, "+").replace(/_/g, "/");
|
|
663
663
|
for (; e.length % 4; )
|
|
664
664
|
e += "=";
|
|
665
|
-
const t = atob(e),
|
|
666
|
-
return typeof
|
|
665
|
+
const t = atob(e), n = JSON.parse(t);
|
|
666
|
+
return typeof n.accessToken == "string" && typeof n.refreshToken == "string" && typeof n.expiresIn == "number" ? n : null;
|
|
667
667
|
} catch {
|
|
668
668
|
return null;
|
|
669
669
|
}
|
|
670
670
|
}
|
|
671
|
-
function
|
|
671
|
+
function yt() {
|
|
672
672
|
if (typeof window > "u")
|
|
673
673
|
return console.log("[CrossDomainAuth] SSR environment, skipping URL token extraction"), null;
|
|
674
|
-
const e = new URLSearchParams(window.location.search).get(
|
|
674
|
+
const e = new URLSearchParams(window.location.search).get(de);
|
|
675
675
|
if (console.log("[CrossDomainAuth] extractAuthTokensFromUrl called", {
|
|
676
676
|
hasAuthParam: !!e,
|
|
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 = mt(e);
|
|
681
681
|
return console.log("[CrossDomainAuth] Token decode result:", {
|
|
682
682
|
success: !!t,
|
|
683
683
|
hasAccessToken: !!(t != null && t.accessToken),
|
|
@@ -685,139 +685,139 @@ function ct() {
|
|
|
685
685
|
expiresIn: t == null ? void 0 : t.expiresIn
|
|
686
686
|
}), t;
|
|
687
687
|
}
|
|
688
|
-
function
|
|
688
|
+
function wt() {
|
|
689
689
|
if (typeof window > "u") return;
|
|
690
|
-
const
|
|
691
|
-
|
|
690
|
+
const r = new URL(window.location.href);
|
|
691
|
+
r.searchParams.delete(de), console.log("[CrossDomainAuth] Clearing auth tokens from URL", {
|
|
692
692
|
oldUrl: window.location.href,
|
|
693
|
-
newUrl:
|
|
694
|
-
}), window.history.replaceState({}, "",
|
|
693
|
+
newUrl: r.toString()
|
|
694
|
+
}), window.history.replaceState({}, "", r.toString());
|
|
695
695
|
}
|
|
696
|
-
const
|
|
697
|
-
function
|
|
698
|
-
const { baseUrl: t, appInfo:
|
|
696
|
+
const Ie = me(null);
|
|
697
|
+
function hn({ config: r, children: e }) {
|
|
698
|
+
const { baseUrl: t, appInfo: n, appId: i } = ye(), o = re(() => typeof window > "u" ? null : pt(
|
|
699
699
|
{
|
|
700
|
-
tenantMode:
|
|
701
|
-
baseDomain:
|
|
702
|
-
selectorParam:
|
|
700
|
+
tenantMode: r.tenantMode || "selector",
|
|
701
|
+
baseDomain: r.baseDomain,
|
|
702
|
+
selectorParam: r.selectorParam
|
|
703
703
|
},
|
|
704
704
|
{
|
|
705
705
|
hostname: window.location.hostname,
|
|
706
706
|
search: window.location.search
|
|
707
707
|
},
|
|
708
708
|
window.localStorage
|
|
709
|
-
), [
|
|
709
|
+
), [r.tenantMode, r.baseDomain, r.selectorParam]), [a, p] = A(() => o()), f = K(
|
|
710
710
|
() => {
|
|
711
|
-
var
|
|
711
|
+
var c, $, E;
|
|
712
712
|
return {
|
|
713
|
-
enabled: ((
|
|
714
|
-
ttl: ((
|
|
713
|
+
enabled: ((c = r.cache) == null ? void 0 : c.enabled) ?? !0,
|
|
714
|
+
ttl: (($ = r.cache) == null ? void 0 : $.ttl) ?? 5 * 60 * 1e3,
|
|
715
715
|
// 5 minutes default
|
|
716
|
-
storageKey: ((
|
|
716
|
+
storageKey: ((E = r.cache) == null ? void 0 : E.storageKey) ?? `tenant_cache_${a || "default"}`
|
|
717
717
|
};
|
|
718
718
|
},
|
|
719
|
-
[
|
|
720
|
-
), [b,
|
|
721
|
-
if (
|
|
722
|
-
if (!
|
|
719
|
+
[r.cache, a]
|
|
720
|
+
), [b, u] = A(() => {
|
|
721
|
+
if (r.initialTenant) return r.initialTenant;
|
|
722
|
+
if (!f.enabled || !a) return null;
|
|
723
723
|
try {
|
|
724
|
-
const
|
|
725
|
-
if (!
|
|
726
|
-
const
|
|
727
|
-
return Date.now() -
|
|
724
|
+
const c = localStorage.getItem(f.storageKey);
|
|
725
|
+
if (!c) return null;
|
|
726
|
+
const $ = JSON.parse(c);
|
|
727
|
+
return Date.now() - $.timestamp < f.ttl && $.tenantSlug === a ? $.data : (localStorage.removeItem(f.storageKey), null);
|
|
728
728
|
} catch {
|
|
729
729
|
return null;
|
|
730
730
|
}
|
|
731
|
-
}), [
|
|
732
|
-
|
|
733
|
-
const
|
|
734
|
-
|
|
731
|
+
}), [w, g] = A(!b && !r.initialTenant), [v, M] = A(null), [F, L] = A(null), [P, h] = A(!1), [x, k] = A(null);
|
|
732
|
+
X(() => {
|
|
733
|
+
const c = o();
|
|
734
|
+
p(c);
|
|
735
735
|
}, [o]);
|
|
736
|
-
const
|
|
737
|
-
async (
|
|
738
|
-
if (!(
|
|
736
|
+
const I = (n == null ? void 0 : n.settingsSchema) || null, U = re(
|
|
737
|
+
async (c, $ = !1) => {
|
|
738
|
+
if (!(!$ && f.enabled && b && b.domain === c))
|
|
739
739
|
try {
|
|
740
|
-
|
|
741
|
-
const
|
|
742
|
-
if (
|
|
740
|
+
g(!0), M(null);
|
|
741
|
+
const E = new ie(t), m = await new pe(E, i).getPublicTenantInfo(c);
|
|
742
|
+
if (u(m), f.enabled)
|
|
743
743
|
try {
|
|
744
|
-
const
|
|
745
|
-
data:
|
|
744
|
+
const S = {
|
|
745
|
+
data: m,
|
|
746
746
|
timestamp: Date.now(),
|
|
747
|
-
tenantSlug:
|
|
747
|
+
tenantSlug: c
|
|
748
748
|
};
|
|
749
|
-
localStorage.setItem(
|
|
750
|
-
} catch (
|
|
751
|
-
console.warn("Failed to cache tenant info:",
|
|
749
|
+
localStorage.setItem(f.storageKey, JSON.stringify(S));
|
|
750
|
+
} catch (S) {
|
|
751
|
+
console.warn("Failed to cache tenant info:", S);
|
|
752
752
|
}
|
|
753
|
-
} catch (
|
|
754
|
-
const
|
|
755
|
-
|
|
753
|
+
} catch (E) {
|
|
754
|
+
const y = E instanceof Error ? E : new Error("Failed to load tenant information");
|
|
755
|
+
M(y), u(null);
|
|
756
756
|
} finally {
|
|
757
|
-
|
|
757
|
+
g(!1);
|
|
758
758
|
}
|
|
759
759
|
},
|
|
760
|
-
[t,
|
|
761
|
-
),
|
|
762
|
-
if (!(!
|
|
760
|
+
[t, i, f, b]
|
|
761
|
+
), C = re(async () => {
|
|
762
|
+
if (!(!f.enabled || !b || !a))
|
|
763
763
|
try {
|
|
764
|
-
const
|
|
765
|
-
if (!
|
|
766
|
-
const
|
|
767
|
-
if (Date.now() -
|
|
768
|
-
const
|
|
769
|
-
|
|
770
|
-
const
|
|
771
|
-
data:
|
|
764
|
+
const c = localStorage.getItem(f.storageKey);
|
|
765
|
+
if (!c) return;
|
|
766
|
+
const $ = JSON.parse(c);
|
|
767
|
+
if (Date.now() - $.timestamp > f.ttl * 0.5) {
|
|
768
|
+
const y = new ie(t), S = await new pe(y, i).getPublicTenantInfo(a);
|
|
769
|
+
u(S);
|
|
770
|
+
const G = {
|
|
771
|
+
data: S,
|
|
772
772
|
timestamp: Date.now(),
|
|
773
773
|
tenantSlug: a
|
|
774
774
|
};
|
|
775
|
-
localStorage.setItem(
|
|
775
|
+
localStorage.setItem(f.storageKey, JSON.stringify(G));
|
|
776
776
|
}
|
|
777
|
-
} catch (
|
|
778
|
-
console.warn("Background tenant refresh failed:",
|
|
777
|
+
} catch (c) {
|
|
778
|
+
console.warn("Background tenant refresh failed:", c);
|
|
779
779
|
}
|
|
780
|
-
}, [t,
|
|
780
|
+
}, [t, i, f, b, a]), R = re(async () => {
|
|
781
781
|
if (b != null && b.id)
|
|
782
782
|
try {
|
|
783
|
-
|
|
784
|
-
const
|
|
785
|
-
|
|
786
|
-
} catch (
|
|
787
|
-
const
|
|
788
|
-
|
|
783
|
+
h(!0), k(null);
|
|
784
|
+
const c = new ie(t), E = await new pe(c, b.appId).getTenantSettings(b.id);
|
|
785
|
+
L(E);
|
|
786
|
+
} catch (c) {
|
|
787
|
+
const $ = c instanceof Error ? c : new Error("Failed to load tenant settings");
|
|
788
|
+
k($), L(null);
|
|
789
789
|
} finally {
|
|
790
|
-
|
|
790
|
+
h(!1);
|
|
791
791
|
}
|
|
792
|
-
}, [t, b]),
|
|
793
|
-
|
|
794
|
-
}, [
|
|
795
|
-
(
|
|
796
|
-
if (!
|
|
792
|
+
}, [t, b]), B = re(() => {
|
|
793
|
+
R();
|
|
794
|
+
}, [R]), l = re(
|
|
795
|
+
(c) => {
|
|
796
|
+
if (!I)
|
|
797
797
|
return { isValid: !0, errors: [] };
|
|
798
|
-
const
|
|
798
|
+
const $ = [];
|
|
799
799
|
try {
|
|
800
|
-
return
|
|
801
|
-
var
|
|
802
|
-
const
|
|
803
|
-
if ((
|
|
804
|
-
|
|
800
|
+
return I.properties && Object.entries(I.properties).forEach(([E, y]) => {
|
|
801
|
+
var S;
|
|
802
|
+
const m = c[E];
|
|
803
|
+
if ((S = I.required) != null && S.includes(E) && m == null) {
|
|
804
|
+
$.push(`Field '${E}' is required`);
|
|
805
805
|
return;
|
|
806
806
|
}
|
|
807
|
-
if (
|
|
808
|
-
if (
|
|
809
|
-
const
|
|
810
|
-
|
|
807
|
+
if (m != null) {
|
|
808
|
+
if (y.type) {
|
|
809
|
+
const G = y.type, J = typeof m;
|
|
810
|
+
G === "string" && J !== "string" ? $.push(`Field '${E}' must be a string`) : (G === "number" || G === "integer") && J !== "number" ? $.push(`Field '${E}' must be a number`) : G === "boolean" && J !== "boolean" ? $.push(`Field '${E}' must be a boolean`) : G === "array" && !Array.isArray(m) && $.push(`Field '${E}' must be an array`);
|
|
811
811
|
}
|
|
812
|
-
|
|
813
|
-
`Field '${
|
|
814
|
-
),
|
|
815
|
-
`Field '${
|
|
816
|
-
),
|
|
812
|
+
y.minLength !== void 0 && typeof m == "string" && m.length < y.minLength && $.push(
|
|
813
|
+
`Field '${E}' must be at least ${y.minLength} characters long`
|
|
814
|
+
), y.maxLength !== void 0 && typeof m == "string" && m.length > y.maxLength && $.push(
|
|
815
|
+
`Field '${E}' must be no more than ${y.maxLength} characters long`
|
|
816
|
+
), y.minimum !== void 0 && typeof m == "number" && m < y.minimum && $.push(`Field '${E}' must be at least ${y.minimum}`), y.maximum !== void 0 && typeof m == "number" && m > y.maximum && $.push(`Field '${E}' must be no more than ${y.maximum}`), y.pattern && typeof m == "string" && (new RegExp(y.pattern).test(m) || $.push(`Field '${E}' does not match the required pattern`)), y.enum && !y.enum.includes(m) && $.push(`Field '${E}' must be one of: ${y.enum.join(", ")}`);
|
|
817
817
|
}
|
|
818
818
|
}), {
|
|
819
|
-
isValid:
|
|
820
|
-
errors:
|
|
819
|
+
isValid: $.length === 0,
|
|
820
|
+
errors: $
|
|
821
821
|
};
|
|
822
822
|
} catch {
|
|
823
823
|
return {
|
|
@@ -826,401 +826,401 @@ function Yt({ config: i, children: e }) {
|
|
|
826
826
|
};
|
|
827
827
|
}
|
|
828
828
|
},
|
|
829
|
-
[
|
|
829
|
+
[I]
|
|
830
830
|
);
|
|
831
|
-
|
|
832
|
-
!
|
|
833
|
-
}, [
|
|
834
|
-
b != null && b.id ?
|
|
835
|
-
}, [b == null ? void 0 : b.id,
|
|
836
|
-
const
|
|
837
|
-
(
|
|
838
|
-
const { mode:
|
|
839
|
-
if (localStorage.setItem("tenant",
|
|
840
|
-
const
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
831
|
+
X(() => {
|
|
832
|
+
!r.initialTenant && a ? b ? C() : U(a) : !r.initialTenant && !a && (u(null), M(null), g(!1));
|
|
833
|
+
}, [r.initialTenant, a, b, U, C]), X(() => {
|
|
834
|
+
b != null && b.id ? R() : (L(null), k(null), h(!1));
|
|
835
|
+
}, [b == null ? void 0 : b.id, R]);
|
|
836
|
+
const N = re(
|
|
837
|
+
(c, $) => {
|
|
838
|
+
const { mode: E = "reload", tokens: y, redirectPath: m } = $ || {}, S = r.tenantMode || "selector";
|
|
839
|
+
if (localStorage.setItem("tenant", c), S === "subdomain") {
|
|
840
|
+
const G = window.location.hostname, J = ft(
|
|
841
|
+
c,
|
|
842
|
+
G,
|
|
843
|
+
r.baseDomain
|
|
844
844
|
);
|
|
845
|
-
if (!
|
|
845
|
+
if (!J) {
|
|
846
846
|
console.warn(
|
|
847
847
|
"[TenantProvider] Cannot switch subdomain, invalid hostname:",
|
|
848
|
-
|
|
848
|
+
G
|
|
849
849
|
);
|
|
850
850
|
return;
|
|
851
851
|
}
|
|
852
|
-
const
|
|
853
|
-
new URLSearchParams(window.location.search).forEach((
|
|
854
|
-
|
|
855
|
-
}),
|
|
856
|
-
} else if (
|
|
857
|
-
const
|
|
858
|
-
if (
|
|
859
|
-
const
|
|
860
|
-
window.location.href =
|
|
852
|
+
const q = m || window.location.pathname, O = new URL(`${window.location.protocol}//${J}${q}`);
|
|
853
|
+
new URLSearchParams(window.location.search).forEach((T, Z) => {
|
|
854
|
+
Z !== de && O.searchParams.set(Z, T);
|
|
855
|
+
}), y && O.searchParams.set(de, $e(y)), window.location.href = O.toString();
|
|
856
|
+
} else if (S === "selector") {
|
|
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, $e(y)), E === "reload") {
|
|
859
|
+
const q = `${G}?${J.toString()}${window.location.hash}`;
|
|
860
|
+
window.location.href = q;
|
|
861
861
|
} else {
|
|
862
|
-
const
|
|
863
|
-
window.history.pushState({}, "",
|
|
862
|
+
const q = `${G}?${J.toString()}${window.location.hash}`;
|
|
863
|
+
window.history.pushState({}, "", q), p(c), U(c);
|
|
864
864
|
}
|
|
865
865
|
}
|
|
866
866
|
},
|
|
867
|
-
[
|
|
868
|
-
),
|
|
867
|
+
[r.tenantMode, r.selectorParam, r.baseDomain, U]
|
|
868
|
+
), D = K(() => ({
|
|
869
869
|
// Tenant info
|
|
870
870
|
tenant: b,
|
|
871
871
|
tenantSlug: a,
|
|
872
|
-
isTenantLoading:
|
|
873
|
-
tenantError:
|
|
872
|
+
isTenantLoading: w,
|
|
873
|
+
tenantError: v,
|
|
874
874
|
retryTenant: () => {
|
|
875
875
|
a && U(a);
|
|
876
876
|
},
|
|
877
877
|
// Settings
|
|
878
|
-
settings:
|
|
879
|
-
settingsSchema:
|
|
880
|
-
isSettingsLoading:
|
|
881
|
-
settingsError:
|
|
878
|
+
settings: F,
|
|
879
|
+
settingsSchema: I,
|
|
880
|
+
isSettingsLoading: P,
|
|
881
|
+
settingsError: x,
|
|
882
882
|
// Actions
|
|
883
|
-
refreshSettings:
|
|
884
|
-
switchTenant:
|
|
883
|
+
refreshSettings: B,
|
|
884
|
+
switchTenant: N,
|
|
885
885
|
// Validation
|
|
886
|
-
validateSettings:
|
|
886
|
+
validateSettings: l
|
|
887
887
|
}), [
|
|
888
888
|
b,
|
|
889
889
|
a,
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
890
|
+
w,
|
|
891
|
+
v,
|
|
892
|
+
F,
|
|
893
|
+
I,
|
|
894
|
+
P,
|
|
894
895
|
x,
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
c
|
|
896
|
+
B,
|
|
897
|
+
N,
|
|
898
|
+
l
|
|
899
899
|
]);
|
|
900
|
-
return /* @__PURE__ */
|
|
900
|
+
return /* @__PURE__ */ s(Ie.Provider, { value: D, children: e });
|
|
901
901
|
}
|
|
902
|
-
function
|
|
903
|
-
const
|
|
904
|
-
if (!
|
|
902
|
+
function ue() {
|
|
903
|
+
const r = oe(Ie);
|
|
904
|
+
if (!r)
|
|
905
905
|
throw new Error("useTenant must be used within a TenantProvider");
|
|
906
|
-
return
|
|
906
|
+
return r;
|
|
907
907
|
}
|
|
908
|
-
function
|
|
909
|
-
return
|
|
908
|
+
function Se() {
|
|
909
|
+
return oe(Ie);
|
|
910
910
|
}
|
|
911
|
-
const
|
|
912
|
-
function
|
|
913
|
-
const { settings:
|
|
911
|
+
const gn = ue;
|
|
912
|
+
function pn() {
|
|
913
|
+
const { settings: r, settingsSchema: e, isSettingsLoading: t, settingsError: n, validateSettings: i } = ue();
|
|
914
914
|
return {
|
|
915
|
-
settings:
|
|
915
|
+
settings: r,
|
|
916
916
|
settingsSchema: e,
|
|
917
917
|
isLoading: t,
|
|
918
|
-
error:
|
|
919
|
-
validateSettings:
|
|
918
|
+
error: n,
|
|
919
|
+
validateSettings: i
|
|
920
920
|
};
|
|
921
921
|
}
|
|
922
|
-
function
|
|
923
|
-
const { tenant:
|
|
922
|
+
function he() {
|
|
923
|
+
const { tenant: r, tenantSlug: e, isTenantLoading: t, tenantError: n, retryTenant: i } = ue();
|
|
924
924
|
return {
|
|
925
|
-
tenant:
|
|
925
|
+
tenant: r,
|
|
926
926
|
tenantSlug: e,
|
|
927
927
|
isLoading: t,
|
|
928
|
-
error:
|
|
929
|
-
retry:
|
|
928
|
+
error: n,
|
|
929
|
+
retry: i
|
|
930
930
|
};
|
|
931
931
|
}
|
|
932
|
-
const
|
|
933
|
-
function
|
|
934
|
-
const { appId: t, baseUrl:
|
|
932
|
+
const Me = me(null);
|
|
933
|
+
function fn({ config: r = {}, children: e }) {
|
|
934
|
+
const { appId: t, baseUrl: n } = ye(), { tenant: i, tenantSlug: o, switchTenant: a } = ue(), [p, f] = A(r.initialRoles || []), [b, u] = A(!r.initialRoles), [w, g] = A(null), [v, M] = A(!1), [F, L] = A(null), [P, h] = A(0), [x, k] = A(() => {
|
|
935
935
|
try {
|
|
936
|
-
const
|
|
937
|
-
return
|
|
936
|
+
const T = localStorage.getItem("userTenants");
|
|
937
|
+
return T ? JSON.parse(T) : [];
|
|
938
938
|
} catch {
|
|
939
939
|
return [];
|
|
940
940
|
}
|
|
941
|
-
}), [
|
|
942
|
-
|
|
941
|
+
}), [I, U] = A(!1), C = ze({ done: !1, urlTokens: null });
|
|
942
|
+
C.current.done || (C.current.done = !0, C.current.urlTokens = yt(), C.current.urlTokens && console.log(
|
|
943
943
|
"[AuthProvider] SYNC: URL tokens found, will block isAuthReady until user loaded"
|
|
944
944
|
));
|
|
945
|
-
const [
|
|
946
|
-
const
|
|
947
|
-
return console.log("[AuthProvider] SYNC: isLoadingAfterUrlTokens initial:",
|
|
948
|
-
}),
|
|
949
|
-
const
|
|
945
|
+
const [R, B] = A(() => {
|
|
946
|
+
const T = C.current.urlTokens !== null;
|
|
947
|
+
return console.log("[AuthProvider] SYNC: isLoadingAfterUrlTokens initial:", T), T;
|
|
948
|
+
}), l = K(() => {
|
|
949
|
+
const T = new Ae({
|
|
950
950
|
tenantSlug: o,
|
|
951
|
-
onRefreshFailed:
|
|
952
|
-
baseUrl:
|
|
951
|
+
onRefreshFailed: r.onRefreshFailed,
|
|
952
|
+
baseUrl: n
|
|
953
953
|
});
|
|
954
|
-
return
|
|
955
|
-
accessToken:
|
|
956
|
-
refreshToken:
|
|
957
|
-
expiresIn:
|
|
958
|
-
}), console.log("[AuthProvider] SYNC: Session valid:",
|
|
959
|
-
}, [o,
|
|
960
|
-
const
|
|
961
|
-
return
|
|
962
|
-
}, [
|
|
963
|
-
const
|
|
954
|
+
return C.current.urlTokens && (console.log("[AuthProvider] SYNC: Saving URL tokens to session manager"), T.setTokens({
|
|
955
|
+
accessToken: C.current.urlTokens.accessToken,
|
|
956
|
+
refreshToken: C.current.urlTokens.refreshToken,
|
|
957
|
+
expiresIn: C.current.urlTokens.expiresIn
|
|
958
|
+
}), console.log("[AuthProvider] SYNC: Session valid:", T.hasValidSession())), T;
|
|
959
|
+
}, [o, n, r.onRefreshFailed]), N = C.current.done && !R, D = K(() => {
|
|
960
|
+
const T = new ie(n);
|
|
961
|
+
return T.setSessionManager(l), T;
|
|
962
|
+
}, [n, l]), c = K(() => new dt(new ie(n)), [n]), $ = K(() => new ut(D, l), [D, l]), E = K(() => new De(new ie(n)), [n]), y = K(() => w || l.getUser(), [w, l]), m = K(() => y != null && y.roleId && p.find((T) => T.id === y.roleId) || null, [y, p]), S = K(() => (m == null ? void 0 : m.permissions) || [], [m]), G = K(() => l.hasValidSession() && w !== null, [l, w]), J = 5 * 60 * 1e3, q = K(() => {
|
|
963
|
+
const T = async (H = !1) => {
|
|
964
964
|
try {
|
|
965
|
-
if (!
|
|
965
|
+
if (!l.hasValidSession())
|
|
966
966
|
return;
|
|
967
967
|
const z = Date.now();
|
|
968
|
-
if (!
|
|
968
|
+
if (!H && z - P < J && w)
|
|
969
969
|
return;
|
|
970
|
-
const W =
|
|
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
|
|
977
|
-
|
|
975
|
+
M(!0), L(null);
|
|
976
|
+
const Q = await $.getUserById(W);
|
|
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
|
+
L(Y), console.error("[AuthProvider] Failed to load user data:", Y);
|
|
981
981
|
} finally {
|
|
982
|
-
|
|
982
|
+
M(!1);
|
|
983
983
|
}
|
|
984
|
-
},
|
|
985
|
-
await
|
|
986
|
-
},
|
|
987
|
-
var
|
|
988
|
-
const { username: z, password: Y, tenantSlug: W, redirectPath: Q } =
|
|
989
|
-
let
|
|
990
|
-
W && (
|
|
991
|
-
const
|
|
984
|
+
}, Z = async () => {
|
|
985
|
+
await T();
|
|
986
|
+
}, ce = async (H) => {
|
|
987
|
+
var Ne;
|
|
988
|
+
const { username: z, password: Y, tenantSlug: W, redirectPath: Q } = H;
|
|
989
|
+
let ee = i == null ? void 0 : i.id, te = o, ne = l;
|
|
990
|
+
W && (ee = (await new pe(D, t).getPublicTenantInfo(W)).id, te = W);
|
|
991
|
+
const j = await c.login({
|
|
992
992
|
username: z,
|
|
993
993
|
password: Y,
|
|
994
994
|
appId: t,
|
|
995
|
-
tenantId:
|
|
996
|
-
}),
|
|
997
|
-
if (
|
|
998
|
-
tenantSlug:
|
|
999
|
-
baseUrl:
|
|
1000
|
-
})),
|
|
1001
|
-
accessToken:
|
|
1002
|
-
refreshToken:
|
|
1003
|
-
expiresIn:
|
|
1004
|
-
}),
|
|
1005
|
-
|
|
995
|
+
tenantId: ee
|
|
996
|
+
}), ge = W && W !== o;
|
|
997
|
+
if (ge && (ne = new Ae({
|
|
998
|
+
tenantSlug: te,
|
|
999
|
+
baseUrl: n
|
|
1000
|
+
})), ne.setTokens({
|
|
1001
|
+
accessToken: j.accessToken,
|
|
1002
|
+
refreshToken: j.refreshToken,
|
|
1003
|
+
expiresIn: j.expiresIn
|
|
1004
|
+
}), j.user) {
|
|
1005
|
+
ne.setUser(j.user), g(j.user);
|
|
1006
1006
|
try {
|
|
1007
|
-
await
|
|
1008
|
-
} catch (
|
|
1009
|
-
console.warn("Failed to load complete user data after login:",
|
|
1007
|
+
await T();
|
|
1008
|
+
} catch (we) {
|
|
1009
|
+
console.warn("Failed to load complete user data after login:", we);
|
|
1010
1010
|
}
|
|
1011
1011
|
}
|
|
1012
|
-
if (
|
|
1013
|
-
|
|
1012
|
+
if (j.tenants && j.tenants.length > 0) {
|
|
1013
|
+
k(j.tenants);
|
|
1014
1014
|
try {
|
|
1015
|
-
localStorage.setItem("userTenants", JSON.stringify(
|
|
1015
|
+
localStorage.setItem("userTenants", JSON.stringify(j.tenants));
|
|
1016
1016
|
} catch {
|
|
1017
1017
|
}
|
|
1018
1018
|
}
|
|
1019
|
-
const
|
|
1020
|
-
if (U(
|
|
1019
|
+
const ke = ((Ne = j.user) == null ? void 0 : Ne.tenantId) !== null;
|
|
1020
|
+
if (U(ke), ge && te && te !== o && a(te, {
|
|
1021
1021
|
tokens: {
|
|
1022
|
-
accessToken:
|
|
1023
|
-
refreshToken:
|
|
1024
|
-
expiresIn:
|
|
1022
|
+
accessToken: j.accessToken,
|
|
1023
|
+
refreshToken: j.refreshToken,
|
|
1024
|
+
expiresIn: j.expiresIn
|
|
1025
1025
|
},
|
|
1026
1026
|
redirectPath: Q
|
|
1027
|
-
}), !
|
|
1028
|
-
const
|
|
1029
|
-
if (
|
|
1030
|
-
const
|
|
1031
|
-
a(
|
|
1027
|
+
}), !ke && j.tenants && j.tenants.length > 0) {
|
|
1028
|
+
const we = H.autoSwitch !== !1 && r.autoSwitchSingleTenant !== !1;
|
|
1029
|
+
if (j.tenants.length === 1 && we) {
|
|
1030
|
+
const Ue = j.tenants[0];
|
|
1031
|
+
a(Ue.subdomain, {
|
|
1032
1032
|
tokens: {
|
|
1033
|
-
accessToken:
|
|
1034
|
-
refreshToken:
|
|
1035
|
-
expiresIn:
|
|
1033
|
+
accessToken: j.accessToken,
|
|
1034
|
+
refreshToken: j.refreshToken,
|
|
1035
|
+
expiresIn: j.expiresIn
|
|
1036
1036
|
},
|
|
1037
1037
|
redirectPath: Q
|
|
1038
1038
|
});
|
|
1039
|
-
} else
|
|
1039
|
+
} else j.tenants.length > 1 && r.onTenantSelectionRequired && r.onTenantSelectionRequired(j.tenants);
|
|
1040
1040
|
}
|
|
1041
|
-
return
|
|
1042
|
-
},
|
|
1043
|
-
const { email: z, phoneNumber: Y, name: W, password: Q, lastName:
|
|
1041
|
+
return j;
|
|
1042
|
+
}, ve = async (H) => {
|
|
1043
|
+
const { email: z, phoneNumber: Y, name: W, password: Q, lastName: ee, tenantId: te } = H;
|
|
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
|
|
1049
|
-
return await
|
|
1048
|
+
const ne = te ?? (i == null ? void 0 : i.id);
|
|
1049
|
+
return await c.signup({
|
|
1050
1050
|
email: z,
|
|
1051
1051
|
phoneNumber: Y,
|
|
1052
1052
|
name: W,
|
|
1053
1053
|
password: Q,
|
|
1054
|
-
tenantId:
|
|
1055
|
-
lastName:
|
|
1054
|
+
tenantId: ne,
|
|
1055
|
+
lastName: ee,
|
|
1056
1056
|
appId: t
|
|
1057
1057
|
});
|
|
1058
|
-
},
|
|
1059
|
-
const { email: z, phoneNumber: Y, name: W, password: Q, tenantName:
|
|
1058
|
+
}, Ke = async (H) => {
|
|
1059
|
+
const { email: z, phoneNumber: Y, name: W, password: Q, tenantName: ee, lastName: te } = H;
|
|
1060
1060
|
if (!z && !Y)
|
|
1061
1061
|
throw new Error("Either email or phoneNumber is required");
|
|
1062
|
-
if (!W || !Q || !
|
|
1062
|
+
if (!W || !Q || !ee)
|
|
1063
1063
|
throw new Error("Name, password, and tenantName are required");
|
|
1064
|
-
return await
|
|
1064
|
+
return await c.signupTenantAdmin({
|
|
1065
1065
|
email: z,
|
|
1066
1066
|
phoneNumber: Y,
|
|
1067
1067
|
name: W,
|
|
1068
1068
|
password: Q,
|
|
1069
|
-
tenantName:
|
|
1069
|
+
tenantName: ee,
|
|
1070
1070
|
appId: t,
|
|
1071
|
-
lastName:
|
|
1071
|
+
lastName: te
|
|
1072
1072
|
});
|
|
1073
|
-
},
|
|
1074
|
-
const { currentPassword: z, newPassword: Y } =
|
|
1075
|
-
await
|
|
1076
|
-
},
|
|
1077
|
-
const { email: z, tenantId: Y } =
|
|
1073
|
+
}, Je = async (H) => {
|
|
1074
|
+
const { currentPassword: z, newPassword: Y } = H, W = await l.getAuthHeaders();
|
|
1075
|
+
await c.changePassword({ currentPassword: z, newPassword: Y }, W);
|
|
1076
|
+
}, Ye = async (H) => {
|
|
1077
|
+
const { email: z, tenantId: Y } = H, W = Y ?? (i == null ? void 0 : i.id);
|
|
1078
1078
|
if (!W)
|
|
1079
1079
|
throw new Error("tenantId is required for password reset");
|
|
1080
|
-
await
|
|
1081
|
-
},
|
|
1082
|
-
const { token: z, newPassword: Y } =
|
|
1083
|
-
await
|
|
1084
|
-
},
|
|
1085
|
-
const { email: z, frontendUrl: Y, name: W, lastName: Q, tenantId:
|
|
1086
|
-
if (!
|
|
1080
|
+
await c.requestPasswordReset({ email: z, tenantId: W });
|
|
1081
|
+
}, Qe = async (H) => {
|
|
1082
|
+
const { token: z, newPassword: Y } = H;
|
|
1083
|
+
await c.confirmPasswordReset({ token: z, newPassword: Y });
|
|
1084
|
+
}, Xe = async (H) => {
|
|
1085
|
+
const { email: z, frontendUrl: Y, name: W, lastName: Q, tenantId: ee } = H, te = ee ?? (i == null ? void 0 : i.id);
|
|
1086
|
+
if (!te)
|
|
1087
1087
|
throw new Error("tenantId is required for magic link authentication");
|
|
1088
|
-
return await
|
|
1088
|
+
return await c.sendMagicLink({
|
|
1089
1089
|
email: z,
|
|
1090
|
-
tenantId:
|
|
1090
|
+
tenantId: te,
|
|
1091
1091
|
frontendUrl: Y,
|
|
1092
1092
|
name: W,
|
|
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
|
|
1100
|
-
const
|
|
1096
|
+
}, et = async (H) => {
|
|
1097
|
+
const { token: z, email: Y, tenantSlug: W } = H;
|
|
1098
|
+
let Q = i == null ? void 0 : i.id, ee = o, te = l;
|
|
1099
|
+
W && (Q = (await new pe(D, t).getPublicTenantInfo(W)).id, ee = W);
|
|
1100
|
+
const ne = await c.verifyMagicLink({
|
|
1101
1101
|
token: z,
|
|
1102
1102
|
email: Y,
|
|
1103
1103
|
appId: t,
|
|
1104
1104
|
tenantId: Q
|
|
1105
|
-
}),
|
|
1106
|
-
if (
|
|
1107
|
-
tenantSlug:
|
|
1108
|
-
baseUrl:
|
|
1109
|
-
})),
|
|
1110
|
-
accessToken:
|
|
1111
|
-
refreshToken:
|
|
1112
|
-
expiresIn:
|
|
1113
|
-
}),
|
|
1114
|
-
|
|
1105
|
+
}), j = W && W !== o;
|
|
1106
|
+
if (j && (te = new Ae({
|
|
1107
|
+
tenantSlug: ee,
|
|
1108
|
+
baseUrl: n
|
|
1109
|
+
})), te.setTokens({
|
|
1110
|
+
accessToken: ne.accessToken,
|
|
1111
|
+
refreshToken: ne.refreshToken,
|
|
1112
|
+
expiresIn: ne.expiresIn
|
|
1113
|
+
}), ne.user) {
|
|
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 T();
|
|
1117
|
+
} catch (ge) {
|
|
1118
|
+
console.warn("Failed to load complete user data after magic link login:", ge);
|
|
1119
1119
|
}
|
|
1120
1120
|
}
|
|
1121
|
-
return
|
|
1121
|
+
return j && ee && ee !== o && a(ee, {
|
|
1122
1122
|
tokens: {
|
|
1123
|
-
accessToken:
|
|
1124
|
-
refreshToken:
|
|
1125
|
-
expiresIn:
|
|
1123
|
+
accessToken: ne.accessToken,
|
|
1124
|
+
refreshToken: ne.refreshToken,
|
|
1125
|
+
expiresIn: ne.expiresIn
|
|
1126
1126
|
}
|
|
1127
|
-
}),
|
|
1128
|
-
},
|
|
1129
|
-
const
|
|
1130
|
-
if (!(
|
|
1127
|
+
}), ne;
|
|
1128
|
+
}, tt = async () => {
|
|
1129
|
+
const H = l.getTokens();
|
|
1130
|
+
if (!(H != null && H.refreshToken))
|
|
1131
1131
|
throw new Error("No refresh token available");
|
|
1132
|
-
const z = await
|
|
1133
|
-
refreshToken:
|
|
1132
|
+
const z = await c.refreshToken({
|
|
1133
|
+
refreshToken: H.refreshToken
|
|
1134
1134
|
});
|
|
1135
|
-
|
|
1135
|
+
l.setTokens({
|
|
1136
1136
|
accessToken: z.accessToken,
|
|
1137
|
-
refreshToken: z.refreshToken ||
|
|
1137
|
+
refreshToken: z.refreshToken || H.refreshToken,
|
|
1138
1138
|
expiresIn: z.expiresIn
|
|
1139
1139
|
});
|
|
1140
|
-
},
|
|
1141
|
-
|
|
1140
|
+
}, nt = () => {
|
|
1141
|
+
l.clearSession(), g(null), L(null), k([]), U(!1);
|
|
1142
1142
|
try {
|
|
1143
1143
|
localStorage.removeItem("userTenants");
|
|
1144
1144
|
} catch {
|
|
1145
1145
|
}
|
|
1146
|
-
},
|
|
1147
|
-
|
|
1148
|
-
},
|
|
1149
|
-
|
|
1150
|
-
},
|
|
1146
|
+
}, rt = (H) => {
|
|
1147
|
+
l.setTokens(H);
|
|
1148
|
+
}, st = () => l.hasValidSession(), it = () => {
|
|
1149
|
+
l.clearSession(), g(null), L(null);
|
|
1150
|
+
}, ot = async () => {
|
|
1151
1151
|
if (t)
|
|
1152
1152
|
try {
|
|
1153
|
-
|
|
1154
|
-
const { roles:
|
|
1155
|
-
|
|
1156
|
-
} catch (
|
|
1157
|
-
console.error("Failed to fetch roles:",
|
|
1153
|
+
u(!0);
|
|
1154
|
+
const { roles: H } = await E.getRolesByApp(t);
|
|
1155
|
+
f(H);
|
|
1156
|
+
} catch (H) {
|
|
1157
|
+
console.error("Failed to fetch roles:", H);
|
|
1158
1158
|
} finally {
|
|
1159
|
-
|
|
1159
|
+
u(!1);
|
|
1160
1160
|
}
|
|
1161
|
-
},
|
|
1162
|
-
await
|
|
1163
|
-
},
|
|
1164
|
-
if (!
|
|
1161
|
+
}, at = async () => {
|
|
1162
|
+
await ot();
|
|
1163
|
+
}, Te = (H) => {
|
|
1164
|
+
if (!S || S.length === 0)
|
|
1165
1165
|
return !1;
|
|
1166
|
-
if (typeof
|
|
1167
|
-
return
|
|
1168
|
-
const z = `${
|
|
1169
|
-
return
|
|
1166
|
+
if (typeof H == "string")
|
|
1167
|
+
return S.includes(H);
|
|
1168
|
+
const z = `${H.resource}.${H.action}`;
|
|
1169
|
+
return S.includes(z);
|
|
1170
1170
|
};
|
|
1171
1171
|
return {
|
|
1172
1172
|
// RFC-003: Authentication state
|
|
1173
|
-
isAuthenticated:
|
|
1174
|
-
sessionManager:
|
|
1175
|
-
authenticatedHttpService:
|
|
1176
|
-
login:
|
|
1177
|
-
signup:
|
|
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:
|
|
1196
|
-
userRole:
|
|
1197
|
-
userPermissions:
|
|
1198
|
-
availableRoles:
|
|
1173
|
+
isAuthenticated: G,
|
|
1174
|
+
sessionManager: l,
|
|
1175
|
+
authenticatedHttpService: D,
|
|
1176
|
+
login: ce,
|
|
1177
|
+
signup: ve,
|
|
1178
|
+
signupTenantAdmin: Ke,
|
|
1179
|
+
sendMagicLink: Xe,
|
|
1180
|
+
verifyMagicLink: et,
|
|
1181
|
+
changePassword: Je,
|
|
1182
|
+
requestPasswordReset: Ye,
|
|
1183
|
+
confirmPasswordReset: Qe,
|
|
1184
|
+
refreshToken: tt,
|
|
1185
|
+
logout: nt,
|
|
1186
|
+
setTokens: rt,
|
|
1187
|
+
hasValidSession: st,
|
|
1188
|
+
clearSession: it,
|
|
1189
|
+
currentUser: w,
|
|
1190
|
+
isUserLoading: v,
|
|
1191
|
+
userError: F,
|
|
1192
|
+
loadUserData: T,
|
|
1193
|
+
refreshUser: Z,
|
|
1194
|
+
isAuthInitializing: !N,
|
|
1195
|
+
isAuthReady: N,
|
|
1196
|
+
userRole: m,
|
|
1197
|
+
userPermissions: S,
|
|
1198
|
+
availableRoles: p,
|
|
1199
1199
|
rolesLoading: b,
|
|
1200
|
-
hasPermission:
|
|
1201
|
-
hasAnyPermission: (
|
|
1202
|
-
hasAllPermissions: (
|
|
1203
|
-
getUserPermissionStrings: () =>
|
|
1204
|
-
refreshRoles:
|
|
1200
|
+
hasPermission: Te,
|
|
1201
|
+
hasAnyPermission: (H) => H.some((z) => Te(z)),
|
|
1202
|
+
hasAllPermissions: (H) => H.every((z) => Te(z)),
|
|
1203
|
+
getUserPermissionStrings: () => S || [],
|
|
1204
|
+
refreshRoles: at,
|
|
1205
1205
|
// RFC-004: Multi-tenant user membership
|
|
1206
|
-
userTenants:
|
|
1207
|
-
hasTenantContext:
|
|
1208
|
-
switchToTenant: async (
|
|
1209
|
-
const { redirectPath: Y } = z || {}, W =
|
|
1206
|
+
userTenants: x,
|
|
1207
|
+
hasTenantContext: I,
|
|
1208
|
+
switchToTenant: async (H, z) => {
|
|
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
|
-
const Q = await
|
|
1212
|
+
const Q = await c.switchTenant({
|
|
1213
1213
|
refreshToken: W.refreshToken,
|
|
1214
|
-
tenantId:
|
|
1214
|
+
tenantId: H
|
|
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
|
-
}),
|
|
1222
|
-
const
|
|
1223
|
-
|
|
1221
|
+
}), g(Q.user), l.setUser(Q.user), U(!0);
|
|
1222
|
+
const ee = x.find((te) => te.id === H);
|
|
1223
|
+
ee && a(ee.subdomain, {
|
|
1224
1224
|
tokens: {
|
|
1225
1225
|
accessToken: Q.accessToken,
|
|
1226
1226
|
refreshToken: W.refreshToken,
|
|
@@ -1230,8 +1230,8 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1230
1230
|
});
|
|
1231
1231
|
},
|
|
1232
1232
|
refreshUserTenants: async () => {
|
|
1233
|
-
const
|
|
1234
|
-
|
|
1233
|
+
const H = await l.getAuthHeaders(), z = await c.getUserTenants(H);
|
|
1234
|
+
k(z);
|
|
1235
1235
|
try {
|
|
1236
1236
|
localStorage.setItem("userTenants", JSON.stringify(z));
|
|
1237
1237
|
} catch {
|
|
@@ -1240,74 +1240,74 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1240
1240
|
}
|
|
1241
1241
|
};
|
|
1242
1242
|
}, [
|
|
1243
|
-
|
|
1244
|
-
c,
|
|
1245
|
-
F,
|
|
1243
|
+
G,
|
|
1246
1244
|
l,
|
|
1247
|
-
|
|
1248
|
-
|
|
1245
|
+
D,
|
|
1246
|
+
c,
|
|
1247
|
+
$,
|
|
1248
|
+
E,
|
|
1249
1249
|
t,
|
|
1250
|
-
|
|
1250
|
+
i,
|
|
1251
1251
|
o,
|
|
1252
1252
|
a,
|
|
1253
|
-
|
|
1254
|
-
S,
|
|
1255
|
-
T,
|
|
1256
|
-
C,
|
|
1257
|
-
$,
|
|
1258
|
-
E,
|
|
1259
|
-
L,
|
|
1260
|
-
u,
|
|
1253
|
+
p,
|
|
1261
1254
|
w,
|
|
1255
|
+
v,
|
|
1256
|
+
F,
|
|
1262
1257
|
x,
|
|
1263
|
-
|
|
1258
|
+
I,
|
|
1259
|
+
N,
|
|
1260
|
+
m,
|
|
1261
|
+
S,
|
|
1262
|
+
P,
|
|
1263
|
+
J
|
|
1264
1264
|
]);
|
|
1265
|
-
|
|
1266
|
-
!
|
|
1265
|
+
X(() => {
|
|
1266
|
+
!r.initialRoles && t && (async () => {
|
|
1267
1267
|
try {
|
|
1268
|
-
|
|
1269
|
-
const
|
|
1270
|
-
|
|
1271
|
-
} catch (
|
|
1272
|
-
console.error("Failed to fetch roles:",
|
|
1268
|
+
u(!0);
|
|
1269
|
+
const Z = new ie(n), ce = new De(Z), { roles: ve } = await ce.getRolesByApp(t);
|
|
1270
|
+
f(ve);
|
|
1271
|
+
} catch (Z) {
|
|
1272
|
+
console.error("Failed to fetch roles:", Z);
|
|
1273
1273
|
} finally {
|
|
1274
|
-
|
|
1274
|
+
u(!1);
|
|
1275
1275
|
}
|
|
1276
1276
|
})();
|
|
1277
|
-
}, [t,
|
|
1278
|
-
const [
|
|
1279
|
-
return
|
|
1280
|
-
|
|
1281
|
-
console.error("[AuthProvider] Failed to load user data:",
|
|
1277
|
+
}, [t, n, r.initialRoles]);
|
|
1278
|
+
const [O, V] = A(!1);
|
|
1279
|
+
return X(() => {
|
|
1280
|
+
O || (V(!0), C.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), wt(), B(!0), console.log("[AuthProvider] EFFECT: Loading user data (blocking isAuthReady)..."), q.loadUserData().catch((T) => {
|
|
1281
|
+
console.error("[AuthProvider] Failed to load user data:", T);
|
|
1282
1282
|
}).finally(() => {
|
|
1283
|
-
console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"),
|
|
1283
|
+
console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"), B(!1);
|
|
1284
1284
|
})));
|
|
1285
|
-
}, [
|
|
1286
|
-
const
|
|
1287
|
-
|
|
1288
|
-
}, [
|
|
1289
|
-
|
|
1285
|
+
}, [q, O]), X(() => {
|
|
1286
|
+
const T = l.getUser();
|
|
1287
|
+
T && l.hasValidSession() && g(T);
|
|
1288
|
+
}, [l]), X(() => {
|
|
1289
|
+
O && (C.current.urlTokens || !w && !v && l.hasValidSession() && (console.log("[AuthProvider] Auto-loading user data..."), q.loadUserData().catch(() => {
|
|
1290
1290
|
})));
|
|
1291
|
-
}, [
|
|
1292
|
-
if (!
|
|
1291
|
+
}, [w, v, q, l, O]), X(() => {
|
|
1292
|
+
if (!l.hasValidSession() || !w)
|
|
1293
1293
|
return;
|
|
1294
|
-
const
|
|
1295
|
-
|
|
1294
|
+
const T = setInterval(() => {
|
|
1295
|
+
q.loadUserData().catch(() => {
|
|
1296
1296
|
});
|
|
1297
|
-
},
|
|
1298
|
-
return () => clearInterval(
|
|
1299
|
-
}, [
|
|
1297
|
+
}, J);
|
|
1298
|
+
return () => clearInterval(T);
|
|
1299
|
+
}, [l, w, q, J]), /* @__PURE__ */ s(Me.Provider, { value: q, children: e });
|
|
1300
1300
|
}
|
|
1301
|
-
function
|
|
1302
|
-
const
|
|
1303
|
-
if (!
|
|
1301
|
+
function le() {
|
|
1302
|
+
const r = oe(Me);
|
|
1303
|
+
if (!r)
|
|
1304
1304
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
1305
|
-
return
|
|
1305
|
+
return r;
|
|
1306
1306
|
}
|
|
1307
|
-
function
|
|
1308
|
-
return
|
|
1307
|
+
function Le() {
|
|
1308
|
+
return oe(Me);
|
|
1309
1309
|
}
|
|
1310
|
-
class
|
|
1310
|
+
class bt {
|
|
1311
1311
|
constructor(e, t) {
|
|
1312
1312
|
this.httpService = e, this.sessionManager = t;
|
|
1313
1313
|
}
|
|
@@ -1326,9 +1326,9 @@ class ut {
|
|
|
1326
1326
|
async getFeatureFlags(e) {
|
|
1327
1327
|
if (!this.sessionManager)
|
|
1328
1328
|
throw new Error("SessionManager is required for private endpoints");
|
|
1329
|
-
const t = await this.sessionManager.getAuthHeaders(),
|
|
1330
|
-
e != null && e.page &&
|
|
1331
|
-
const
|
|
1329
|
+
const t = await this.sessionManager.getAuthHeaders(), n = new URLSearchParams();
|
|
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 i = `/feature-flags/${n.toString() ? `?${n.toString()}` : ""}`, o = await this.httpService.get(i, {
|
|
1332
1332
|
headers: t
|
|
1333
1333
|
});
|
|
1334
1334
|
return {
|
|
@@ -1347,12 +1347,12 @@ class ut {
|
|
|
1347
1347
|
async updateFeatureFlag(e, t) {
|
|
1348
1348
|
if (!this.sessionManager)
|
|
1349
1349
|
throw new Error("SessionManager is required for private endpoints");
|
|
1350
|
-
const
|
|
1350
|
+
const n = await this.sessionManager.getAuthHeaders();
|
|
1351
1351
|
return (await this.httpService.put(
|
|
1352
1352
|
`/feature-flags/${e}`,
|
|
1353
1353
|
t,
|
|
1354
1354
|
{
|
|
1355
|
-
headers:
|
|
1355
|
+
headers: n
|
|
1356
1356
|
}
|
|
1357
1357
|
)).data;
|
|
1358
1358
|
}
|
|
@@ -1368,85 +1368,85 @@ class ut {
|
|
|
1368
1368
|
async getTenantFeatureFlags(e, t) {
|
|
1369
1369
|
if (!e || !t)
|
|
1370
1370
|
throw new Error("Tenant ID and App ID are required");
|
|
1371
|
-
const
|
|
1372
|
-
|
|
1373
|
-
const
|
|
1374
|
-
return (await this.httpService.get(
|
|
1371
|
+
const n = new URLSearchParams();
|
|
1372
|
+
n.append("tenantId", e), n.append("appId", t);
|
|
1373
|
+
const i = `/tenant-feature-flags${n.toString() ? `?${n.toString()}` : ""}`;
|
|
1374
|
+
return (await this.httpService.get(i, {
|
|
1375
1375
|
headers: { "X-Tenant-ID": e }
|
|
1376
1376
|
})).data;
|
|
1377
1377
|
}
|
|
1378
1378
|
// Public endpoint - no auth required
|
|
1379
|
-
async getTenantFeatureFlag(e, t,
|
|
1380
|
-
if (!e || !t || !
|
|
1379
|
+
async getTenantFeatureFlag(e, t, n) {
|
|
1380
|
+
if (!e || !t || !n)
|
|
1381
1381
|
throw new Error("Flag Key, Tenant ID and App ID are required");
|
|
1382
|
-
const
|
|
1383
|
-
|
|
1384
|
-
const o = `/tenant-feature-flags/${e}${
|
|
1382
|
+
const i = new URLSearchParams();
|
|
1383
|
+
i.append("tenantId", t), i.append("appId", n);
|
|
1384
|
+
const o = `/tenant-feature-flags/${e}${i.toString() ? `?${i.toString()}` : ""}`;
|
|
1385
1385
|
return (await this.httpService.get(o, {
|
|
1386
1386
|
headers: { "X-Tenant-ID": t }
|
|
1387
1387
|
})).data;
|
|
1388
1388
|
}
|
|
1389
1389
|
}
|
|
1390
|
-
const
|
|
1391
|
-
function
|
|
1392
|
-
const t =
|
|
1393
|
-
const
|
|
1394
|
-
return new
|
|
1395
|
-
}, [
|
|
1390
|
+
const Ee = me(null);
|
|
1391
|
+
function mn({ config: r = {}, children: e }) {
|
|
1392
|
+
const t = _e(), n = Se(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (n == null ? void 0 : n.tenant) ?? null, [p, f] = A([]), [b, u] = A(!1), [w, g] = A(null), [v, M] = A(!1), F = K(() => {
|
|
1393
|
+
const h = new ie(i);
|
|
1394
|
+
return new bt(h);
|
|
1395
|
+
}, [i]), L = 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
|
|
1403
|
-
|
|
1404
|
-
} catch (
|
|
1405
|
-
const
|
|
1406
|
-
|
|
1402
|
+
const h = await F.getTenantFeatureFlags(a.id, o);
|
|
1403
|
+
f(h);
|
|
1404
|
+
} catch (h) {
|
|
1405
|
+
const x = h instanceof Error ? h.message : "Failed to fetch feature flags";
|
|
1406
|
+
g(x), r.onError && r.onError(h instanceof Error ? h : new Error(x));
|
|
1407
1407
|
} finally {
|
|
1408
|
-
|
|
1408
|
+
u(!1);
|
|
1409
1409
|
}
|
|
1410
1410
|
};
|
|
1411
|
-
|
|
1412
|
-
if (!
|
|
1413
|
-
|
|
1414
|
-
const
|
|
1415
|
-
return () => clearInterval(
|
|
1416
|
-
}, [a == null ? void 0 : a.id,
|
|
1417
|
-
const
|
|
1418
|
-
const
|
|
1419
|
-
const
|
|
1420
|
-
return (
|
|
1421
|
-
},
|
|
1422
|
-
const
|
|
1423
|
-
return
|
|
1424
|
-
},
|
|
1425
|
-
await
|
|
1426
|
-
}, U = !!(
|
|
1411
|
+
X(() => {
|
|
1412
|
+
if (!i || !o) return;
|
|
1413
|
+
L().finally(() => M(!0));
|
|
1414
|
+
const h = r.refreshInterval || 5 * 60 * 1e3, x = setInterval(L, h);
|
|
1415
|
+
return () => clearInterval(x);
|
|
1416
|
+
}, [a == null ? void 0 : a.id, i, o, r.refreshInterval]);
|
|
1417
|
+
const P = K(() => {
|
|
1418
|
+
const h = (C) => {
|
|
1419
|
+
const R = p.find((B) => B.key === C);
|
|
1420
|
+
return (R == null ? void 0 : R.value) === !0;
|
|
1421
|
+
}, x = (C) => p.find((R) => R.key === C), k = (C) => {
|
|
1422
|
+
const R = p.find((B) => B.key === C);
|
|
1423
|
+
return R ? R.value ? "enabled" : "disabled" : "not_found";
|
|
1424
|
+
}, I = async () => {
|
|
1425
|
+
await L();
|
|
1426
|
+
}, U = !!(i && o) && (v || !(a != null && a.id));
|
|
1427
1427
|
return {
|
|
1428
|
-
featureFlags:
|
|
1428
|
+
featureFlags: p,
|
|
1429
1429
|
loading: b,
|
|
1430
|
-
error:
|
|
1430
|
+
error: w,
|
|
1431
1431
|
isReady: U,
|
|
1432
|
-
isEnabled:
|
|
1433
|
-
getFlag:
|
|
1434
|
-
getFlagState:
|
|
1435
|
-
refresh:
|
|
1432
|
+
isEnabled: h,
|
|
1433
|
+
getFlag: x,
|
|
1434
|
+
getFlagState: k,
|
|
1435
|
+
refresh: I
|
|
1436
1436
|
};
|
|
1437
|
-
}, [
|
|
1438
|
-
return /* @__PURE__ */
|
|
1437
|
+
}, [p, b, w, i, o, a == null ? void 0 : a.id, v]);
|
|
1438
|
+
return /* @__PURE__ */ s(Ee.Provider, { value: P, children: e });
|
|
1439
1439
|
}
|
|
1440
|
-
function
|
|
1441
|
-
const
|
|
1442
|
-
if (!
|
|
1440
|
+
function St() {
|
|
1441
|
+
const r = oe(Ee);
|
|
1442
|
+
if (!r)
|
|
1443
1443
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1444
|
-
return
|
|
1444
|
+
return r;
|
|
1445
1445
|
}
|
|
1446
|
-
function
|
|
1447
|
-
return
|
|
1446
|
+
function We() {
|
|
1447
|
+
return oe(Ee);
|
|
1448
1448
|
}
|
|
1449
|
-
class
|
|
1449
|
+
class vt {
|
|
1450
1450
|
constructor(e, t) {
|
|
1451
1451
|
this.httpService = e, this.sessionManager = t;
|
|
1452
1452
|
}
|
|
@@ -1476,23 +1476,23 @@ class gt {
|
|
|
1476
1476
|
async updateSubscription(e, t) {
|
|
1477
1477
|
if (!this.sessionManager)
|
|
1478
1478
|
throw new Error("SessionManager is required for private endpoints");
|
|
1479
|
-
const
|
|
1479
|
+
const n = await this.sessionManager.getAuthHeaders();
|
|
1480
1480
|
return (await this.httpService.put(
|
|
1481
1481
|
`/subscriptions/${e}`,
|
|
1482
1482
|
t,
|
|
1483
1483
|
{
|
|
1484
|
-
headers:
|
|
1484
|
+
headers: n
|
|
1485
1485
|
}
|
|
1486
1486
|
)).data;
|
|
1487
1487
|
}
|
|
1488
1488
|
async changeSubscriptionPlan(e, t) {
|
|
1489
1489
|
if (!this.sessionManager)
|
|
1490
1490
|
throw new Error("SessionManager is required for private endpoints");
|
|
1491
|
-
const
|
|
1491
|
+
const n = await this.sessionManager.getAuthHeaders();
|
|
1492
1492
|
return (await this.httpService.put(
|
|
1493
1493
|
`/subscriptions/${e}/plan`,
|
|
1494
1494
|
{ planId: t },
|
|
1495
|
-
{ headers:
|
|
1495
|
+
{ headers: n }
|
|
1496
1496
|
)).data;
|
|
1497
1497
|
}
|
|
1498
1498
|
// Public endpoint - no auth required
|
|
@@ -1504,76 +1504,76 @@ class gt {
|
|
|
1504
1504
|
async processPayment(e, t) {
|
|
1505
1505
|
if (!this.sessionManager)
|
|
1506
1506
|
throw new Error("SessionManager is required for private endpoints");
|
|
1507
|
-
const
|
|
1507
|
+
const n = await this.sessionManager.getAuthHeaders();
|
|
1508
1508
|
return (await this.httpService.post(
|
|
1509
1509
|
`/subscriptions/${e}/process-payment`,
|
|
1510
1510
|
t,
|
|
1511
|
-
{ headers:
|
|
1511
|
+
{ headers: n }
|
|
1512
1512
|
)).data;
|
|
1513
1513
|
}
|
|
1514
1514
|
}
|
|
1515
|
-
const
|
|
1516
|
-
function
|
|
1517
|
-
const t =
|
|
1518
|
-
const
|
|
1519
|
-
return new
|
|
1520
|
-
}, [
|
|
1515
|
+
const Fe = me(void 0);
|
|
1516
|
+
function yn({ config: r = {}, children: e }) {
|
|
1517
|
+
const t = _e(), n = Se(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (n == null ? void 0 : n.tenant) ?? null, [a, p] = A(null), [f, b] = A(!1), [u, w] = A(null), [g, v] = A(!1), M = K(() => {
|
|
1518
|
+
const P = new ie(i);
|
|
1519
|
+
return new vt(P);
|
|
1520
|
+
}, [i]), F = async () => {
|
|
1521
1521
|
if (!(o != null && o.id)) {
|
|
1522
|
-
|
|
1522
|
+
p(null);
|
|
1523
1523
|
return;
|
|
1524
1524
|
}
|
|
1525
|
-
b(!0),
|
|
1525
|
+
b(!0), w(null);
|
|
1526
1526
|
try {
|
|
1527
|
-
const
|
|
1528
|
-
|
|
1529
|
-
} catch (
|
|
1530
|
-
const
|
|
1531
|
-
|
|
1527
|
+
const P = await M.getTenantSubscriptionFeatures(o.id);
|
|
1528
|
+
p(P);
|
|
1529
|
+
} catch (P) {
|
|
1530
|
+
const h = P instanceof Error ? P.message : "Failed to fetch subscription";
|
|
1531
|
+
w(h), r.onError && r.onError(P instanceof Error ? P : new Error(h));
|
|
1532
1532
|
} finally {
|
|
1533
1533
|
b(!1);
|
|
1534
1534
|
}
|
|
1535
1535
|
};
|
|
1536
|
-
|
|
1537
|
-
if (!
|
|
1538
|
-
const
|
|
1539
|
-
return () => clearInterval(
|
|
1540
|
-
}, [o == null ? void 0 : o.id,
|
|
1541
|
-
const
|
|
1542
|
-
const
|
|
1543
|
-
const
|
|
1544
|
-
return
|
|
1545
|
-
},
|
|
1546
|
-
const
|
|
1547
|
-
return
|
|
1548
|
-
},
|
|
1549
|
-
await
|
|
1550
|
-
},
|
|
1536
|
+
X(() => {
|
|
1537
|
+
if (!i || (F().finally(() => v(!0)), !r.refreshInterval)) return;
|
|
1538
|
+
const P = r.refreshInterval || 10 * 60 * 1e3, h = setInterval(F, P);
|
|
1539
|
+
return () => clearInterval(h);
|
|
1540
|
+
}, [o == null ? void 0 : o.id, i, r.refreshInterval]);
|
|
1541
|
+
const L = K(() => {
|
|
1542
|
+
const P = (a == null ? void 0 : a.features) || [], h = (R) => {
|
|
1543
|
+
const B = P.find((l) => l.key === R);
|
|
1544
|
+
return B ? B.type === "BOOLEAN" || B.type === "boolean" ? B.value === !0 : !!B.value : !1;
|
|
1545
|
+
}, x = (R) => P.find((B) => B.key === R), k = (R, B) => {
|
|
1546
|
+
const l = P.find((N) => N.key === R);
|
|
1547
|
+
return l ? l.value : B;
|
|
1548
|
+
}, I = (R) => !a || !a.isActive ? !1 : R.includes(a.planId), U = async () => {
|
|
1549
|
+
await F();
|
|
1550
|
+
}, C = !!i && (g || !(o != null && o.id));
|
|
1551
1551
|
return {
|
|
1552
1552
|
subscription: a,
|
|
1553
|
-
features:
|
|
1554
|
-
loading:
|
|
1555
|
-
error:
|
|
1556
|
-
isReady:
|
|
1557
|
-
isFeatureEnabled:
|
|
1558
|
-
getFeature:
|
|
1559
|
-
getFeatureValue:
|
|
1560
|
-
hasAllowedPlan:
|
|
1553
|
+
features: P,
|
|
1554
|
+
loading: f,
|
|
1555
|
+
error: u,
|
|
1556
|
+
isReady: C,
|
|
1557
|
+
isFeatureEnabled: h,
|
|
1558
|
+
getFeature: x,
|
|
1559
|
+
getFeatureValue: k,
|
|
1560
|
+
hasAllowedPlan: I,
|
|
1561
1561
|
refresh: U
|
|
1562
1562
|
};
|
|
1563
|
-
}, [a,
|
|
1564
|
-
return /* @__PURE__ */
|
|
1563
|
+
}, [a, f, u, i, o == null ? void 0 : o.id, g]);
|
|
1564
|
+
return /* @__PURE__ */ s(Fe.Provider, { value: L, children: e });
|
|
1565
1565
|
}
|
|
1566
|
-
function
|
|
1567
|
-
const
|
|
1568
|
-
if (
|
|
1566
|
+
function Tt() {
|
|
1567
|
+
const r = oe(Fe);
|
|
1568
|
+
if (r === void 0)
|
|
1569
1569
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1570
|
-
return
|
|
1570
|
+
return r;
|
|
1571
1571
|
}
|
|
1572
|
-
function
|
|
1573
|
-
return
|
|
1572
|
+
function Ve() {
|
|
1573
|
+
return oe(Fe) ?? null;
|
|
1574
1574
|
}
|
|
1575
|
-
var
|
|
1576
|
-
const
|
|
1575
|
+
var se = /* @__PURE__ */ ((r) => (r.SUPERUSER = "SUPERUSER", r.TENANT_ADMIN = "TENANT_ADMIN", r.USER = "USER", r))(se || {});
|
|
1576
|
+
const He = () => /* @__PURE__ */ d(
|
|
1577
1577
|
"div",
|
|
1578
1578
|
{
|
|
1579
1579
|
style: {
|
|
@@ -1589,10 +1589,10 @@ const $e = () => /* @__PURE__ */ d(
|
|
|
1589
1589
|
margin: "20px 0"
|
|
1590
1590
|
},
|
|
1591
1591
|
children: [
|
|
1592
|
-
/* @__PURE__ */
|
|
1593
|
-
/* @__PURE__ */
|
|
1594
|
-
/* @__PURE__ */
|
|
1595
|
-
/* @__PURE__ */
|
|
1592
|
+
/* @__PURE__ */ s("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "🔒" }),
|
|
1593
|
+
/* @__PURE__ */ s("h3", { style: { color: "#495057", marginBottom: "10px" }, children: "Access Required" }),
|
|
1594
|
+
/* @__PURE__ */ s("p", { style: { color: "#6c757d", fontSize: "14px", marginBottom: "15px" }, children: "You need to be signed in to view this content." }),
|
|
1595
|
+
/* @__PURE__ */ s(
|
|
1596
1596
|
"button",
|
|
1597
1597
|
{
|
|
1598
1598
|
style: {
|
|
@@ -1610,8 +1610,8 @@ const $e = () => /* @__PURE__ */ d(
|
|
|
1610
1610
|
)
|
|
1611
1611
|
]
|
|
1612
1612
|
}
|
|
1613
|
-
),
|
|
1614
|
-
userType:
|
|
1613
|
+
), Be = ({
|
|
1614
|
+
userType: r,
|
|
1615
1615
|
minUserType: e,
|
|
1616
1616
|
missingPermissions: t
|
|
1617
1617
|
}) => /* @__PURE__ */ d(
|
|
@@ -1630,57 +1630,57 @@ const $e = () => /* @__PURE__ */ d(
|
|
|
1630
1630
|
margin: "20px 0"
|
|
1631
1631
|
},
|
|
1632
1632
|
children: [
|
|
1633
|
-
/* @__PURE__ */
|
|
1634
|
-
/* @__PURE__ */
|
|
1635
|
-
e &&
|
|
1633
|
+
/* @__PURE__ */ s("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
|
|
1634
|
+
/* @__PURE__ */ s("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
|
|
1635
|
+
e && r ? /* @__PURE__ */ d(_, { children: [
|
|
1636
1636
|
/* @__PURE__ */ d("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
|
|
1637
1637
|
"This content requires ",
|
|
1638
|
-
/* @__PURE__ */
|
|
1638
|
+
/* @__PURE__ */ s("strong", { children: e }),
|
|
1639
1639
|
" access level or higher."
|
|
1640
1640
|
] }),
|
|
1641
1641
|
/* @__PURE__ */ d("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1642
1642
|
"Your current access level: ",
|
|
1643
|
-
/* @__PURE__ */
|
|
1643
|
+
/* @__PURE__ */ s("strong", { children: r })
|
|
1644
1644
|
] })
|
|
1645
|
-
] }) : /* @__PURE__ */ d(
|
|
1646
|
-
/* @__PURE__ */
|
|
1645
|
+
] }) : /* @__PURE__ */ d(_, { children: [
|
|
1646
|
+
/* @__PURE__ */ s("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
|
|
1647
1647
|
t && t.length > 0 && /* @__PURE__ */ d("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1648
1648
|
"Required permissions: ",
|
|
1649
|
-
/* @__PURE__ */
|
|
1649
|
+
/* @__PURE__ */ s("strong", { children: t.join(", ") })
|
|
1650
1650
|
] })
|
|
1651
1651
|
] })
|
|
1652
1652
|
]
|
|
1653
1653
|
}
|
|
1654
|
-
),
|
|
1654
|
+
), kt = (r, e) => {
|
|
1655
1655
|
const t = {
|
|
1656
|
-
[
|
|
1657
|
-
[
|
|
1658
|
-
[
|
|
1656
|
+
[se.USER]: 1,
|
|
1657
|
+
[se.TENANT_ADMIN]: 2,
|
|
1658
|
+
[se.SUPERUSER]: 3
|
|
1659
1659
|
};
|
|
1660
|
-
return t[
|
|
1660
|
+
return t[r] >= t[e];
|
|
1661
1661
|
};
|
|
1662
|
-
function
|
|
1663
|
-
children:
|
|
1662
|
+
function wn({
|
|
1663
|
+
children: r,
|
|
1664
1664
|
fallback: e,
|
|
1665
1665
|
minUserType: t,
|
|
1666
|
-
requiredPermissions:
|
|
1667
|
-
requireAllPermissions:
|
|
1666
|
+
requiredPermissions: n,
|
|
1667
|
+
requireAllPermissions: i = !1
|
|
1668
1668
|
}) {
|
|
1669
|
-
const { hasValidSession: o, sessionManager: a, hasPermission:
|
|
1669
|
+
const { hasValidSession: o, sessionManager: a, hasPermission: p, hasAnyPermission: f, hasAllPermissions: b } = le();
|
|
1670
1670
|
if (!o())
|
|
1671
|
-
return /* @__PURE__ */
|
|
1672
|
-
const
|
|
1673
|
-
if (!
|
|
1674
|
-
return /* @__PURE__ */
|
|
1675
|
-
if (t && !
|
|
1676
|
-
return /* @__PURE__ */
|
|
1677
|
-
if (
|
|
1678
|
-
const
|
|
1679
|
-
return /* @__PURE__ */
|
|
1680
|
-
}
|
|
1681
|
-
return /* @__PURE__ */
|
|
1671
|
+
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(He, {}) });
|
|
1672
|
+
const u = a.getUser();
|
|
1673
|
+
if (!u)
|
|
1674
|
+
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(He, {}) });
|
|
1675
|
+
if (t && !kt(u.userType, t))
|
|
1676
|
+
return /* @__PURE__ */ s(Be, { userType: u.userType, minUserType: t });
|
|
1677
|
+
if (n && n.length > 0 && !(i ? b(n) : f(n))) {
|
|
1678
|
+
const g = n.filter((v) => !p(v)).map((v) => typeof v == "string" ? v : v.name);
|
|
1679
|
+
return /* @__PURE__ */ s(Be, { missingPermissions: g });
|
|
1680
|
+
}
|
|
1681
|
+
return /* @__PURE__ */ s(_, { children: r });
|
|
1682
1682
|
}
|
|
1683
|
-
const
|
|
1683
|
+
const At = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
1684
1684
|
"div",
|
|
1685
1685
|
{
|
|
1686
1686
|
style: {
|
|
@@ -1704,23 +1704,23 @@ const mt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1704
1704
|
maxWidth: "400px"
|
|
1705
1705
|
},
|
|
1706
1706
|
children: [
|
|
1707
|
-
/* @__PURE__ */
|
|
1708
|
-
/* @__PURE__ */
|
|
1709
|
-
/* @__PURE__ */
|
|
1707
|
+
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
|
|
1708
|
+
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
|
|
1709
|
+
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
|
|
1710
1710
|
/* @__PURE__ */ d("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1711
1711
|
"Redirecting to ",
|
|
1712
|
-
|
|
1712
|
+
r,
|
|
1713
1713
|
"..."
|
|
1714
1714
|
] })
|
|
1715
1715
|
]
|
|
1716
1716
|
}
|
|
1717
1717
|
)
|
|
1718
1718
|
}
|
|
1719
|
-
),
|
|
1720
|
-
userType:
|
|
1719
|
+
), qe = ({
|
|
1720
|
+
userType: r,
|
|
1721
1721
|
requiredUserType: e,
|
|
1722
1722
|
missingPermissions: t
|
|
1723
|
-
}) => /* @__PURE__ */
|
|
1723
|
+
}) => /* @__PURE__ */ s(
|
|
1724
1724
|
"div",
|
|
1725
1725
|
{
|
|
1726
1726
|
style: {
|
|
@@ -1744,62 +1744,66 @@ const mt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1744
1744
|
maxWidth: "400px"
|
|
1745
1745
|
},
|
|
1746
1746
|
children: [
|
|
1747
|
-
/* @__PURE__ */
|
|
1748
|
-
/* @__PURE__ */
|
|
1749
|
-
e &&
|
|
1747
|
+
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
|
|
1748
|
+
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
|
|
1749
|
+
e && r ? /* @__PURE__ */ d(_, { children: [
|
|
1750
1750
|
/* @__PURE__ */ d("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
|
|
1751
1751
|
"This page requires ",
|
|
1752
|
-
/* @__PURE__ */
|
|
1752
|
+
/* @__PURE__ */ s("strong", { children: e }),
|
|
1753
1753
|
" access."
|
|
1754
1754
|
] }),
|
|
1755
1755
|
/* @__PURE__ */ d("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1756
1756
|
"Your current user type: ",
|
|
1757
|
-
/* @__PURE__ */
|
|
1757
|
+
/* @__PURE__ */ s("strong", { children: r })
|
|
1758
1758
|
] })
|
|
1759
|
-
] }) : /* @__PURE__ */ d(
|
|
1760
|
-
/* @__PURE__ */
|
|
1759
|
+
] }) : /* @__PURE__ */ d(_, { children: [
|
|
1760
|
+
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
|
|
1761
1761
|
t && t.length > 0 && /* @__PURE__ */ d("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1762
1762
|
"Required permissions: ",
|
|
1763
|
-
/* @__PURE__ */
|
|
1763
|
+
/* @__PURE__ */ s("strong", { children: t.join(", ") })
|
|
1764
1764
|
] })
|
|
1765
1765
|
] })
|
|
1766
1766
|
]
|
|
1767
1767
|
}
|
|
1768
1768
|
)
|
|
1769
1769
|
}
|
|
1770
|
-
),
|
|
1771
|
-
function
|
|
1772
|
-
children:
|
|
1770
|
+
), xt = (r, e) => r === e;
|
|
1771
|
+
function bn({
|
|
1772
|
+
children: r,
|
|
1773
1773
|
redirectTo: e = "/login",
|
|
1774
1774
|
requiredUserType: t,
|
|
1775
|
-
requiredPermissions:
|
|
1776
|
-
requireAllPermissions:
|
|
1775
|
+
requiredPermissions: n,
|
|
1776
|
+
requireAllPermissions: i = !1,
|
|
1777
1777
|
fallback: o
|
|
1778
1778
|
}) {
|
|
1779
|
-
const { hasValidSession: a, sessionManager:
|
|
1780
|
-
if (
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1779
|
+
const { hasValidSession: a, sessionManager: p, hasPermission: f, hasAnyPermission: b, hasAllPermissions: u } = le(), w = be();
|
|
1780
|
+
if (X(() => {
|
|
1781
|
+
process.env.NODE_ENV === "development" && console.warn(
|
|
1782
|
+
"[react-identity-access] ProtectedRoute is deprecated. Use AuthenticatedZone or AdminZone from ZoneRoute instead."
|
|
1783
|
+
);
|
|
1784
|
+
}, []), !a())
|
|
1785
|
+
return o ? /* @__PURE__ */ s(_, { children: o }) : /* @__PURE__ */ d(_, { children: [
|
|
1786
|
+
/* @__PURE__ */ s(At, { redirectPath: e }),
|
|
1787
|
+
/* @__PURE__ */ s(fe, { to: e, state: { from: w.pathname }, replace: !0 })
|
|
1784
1788
|
] });
|
|
1785
|
-
const
|
|
1786
|
-
if (!
|
|
1787
|
-
return /* @__PURE__ */
|
|
1788
|
-
if (t && !
|
|
1789
|
-
return /* @__PURE__ */
|
|
1790
|
-
|
|
1789
|
+
const g = p.getUser();
|
|
1790
|
+
if (!g)
|
|
1791
|
+
return /* @__PURE__ */ s(fe, { to: e, state: { from: w.pathname }, replace: !0 });
|
|
1792
|
+
if (t && !xt(g.userType, t))
|
|
1793
|
+
return /* @__PURE__ */ s(
|
|
1794
|
+
qe,
|
|
1791
1795
|
{
|
|
1792
|
-
userType:
|
|
1796
|
+
userType: g.userType,
|
|
1793
1797
|
requiredUserType: t
|
|
1794
1798
|
}
|
|
1795
1799
|
);
|
|
1796
|
-
if (
|
|
1797
|
-
const
|
|
1798
|
-
return /* @__PURE__ */
|
|
1800
|
+
if (n && n.length > 0 && !(i ? u(n) : b(n))) {
|
|
1801
|
+
const M = n.filter((F) => !f(F)).map((F) => typeof F == "string" ? F : F.name);
|
|
1802
|
+
return /* @__PURE__ */ s(qe, { missingPermissions: M });
|
|
1799
1803
|
}
|
|
1800
|
-
return /* @__PURE__ */
|
|
1804
|
+
return /* @__PURE__ */ s(_, { children: r });
|
|
1801
1805
|
}
|
|
1802
|
-
const
|
|
1806
|
+
const Pt = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
1803
1807
|
"div",
|
|
1804
1808
|
{
|
|
1805
1809
|
style: {
|
|
@@ -1823,12 +1827,12 @@ const wt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1823
1827
|
maxWidth: "400px"
|
|
1824
1828
|
},
|
|
1825
1829
|
children: [
|
|
1826
|
-
/* @__PURE__ */
|
|
1827
|
-
/* @__PURE__ */
|
|
1828
|
-
/* @__PURE__ */
|
|
1830
|
+
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
|
|
1831
|
+
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
|
|
1832
|
+
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
|
|
1829
1833
|
/* @__PURE__ */ d("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1830
1834
|
"Redirecting to ",
|
|
1831
|
-
|
|
1835
|
+
r,
|
|
1832
1836
|
"..."
|
|
1833
1837
|
] })
|
|
1834
1838
|
]
|
|
@@ -1836,14 +1840,18 @@ const wt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1836
1840
|
)
|
|
1837
1841
|
}
|
|
1838
1842
|
);
|
|
1839
|
-
function
|
|
1840
|
-
const { tenant:
|
|
1841
|
-
return
|
|
1842
|
-
|
|
1843
|
-
|
|
1843
|
+
function Sn({ children: r, redirectTo: e = "/", fallback: t }) {
|
|
1844
|
+
const { tenant: n, isLoading: i, error: o } = he(), a = be();
|
|
1845
|
+
return X(() => {
|
|
1846
|
+
process.env.NODE_ENV === "development" && console.warn(
|
|
1847
|
+
"[react-identity-access] TenantRoute is deprecated. Use TenantZone from ZoneRoute instead."
|
|
1848
|
+
);
|
|
1849
|
+
}, []), i || o ? null : n ? /* @__PURE__ */ s(_, { children: r }) : t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ d(_, { children: [
|
|
1850
|
+
/* @__PURE__ */ s(Pt, { redirectPath: e }),
|
|
1851
|
+
/* @__PURE__ */ s(fe, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
1844
1852
|
] });
|
|
1845
1853
|
}
|
|
1846
|
-
const
|
|
1854
|
+
const Rt = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
1847
1855
|
"div",
|
|
1848
1856
|
{
|
|
1849
1857
|
style: {
|
|
@@ -1867,12 +1875,12 @@ const bt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1867
1875
|
maxWidth: "400px"
|
|
1868
1876
|
},
|
|
1869
1877
|
children: [
|
|
1870
|
-
/* @__PURE__ */
|
|
1871
|
-
/* @__PURE__ */
|
|
1872
|
-
/* @__PURE__ */
|
|
1878
|
+
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
|
|
1879
|
+
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
|
|
1880
|
+
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
|
|
1873
1881
|
/* @__PURE__ */ d("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1874
1882
|
"Redirecting to ",
|
|
1875
|
-
|
|
1883
|
+
r,
|
|
1876
1884
|
"..."
|
|
1877
1885
|
] })
|
|
1878
1886
|
]
|
|
@@ -1880,14 +1888,144 @@ const bt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1880
1888
|
)
|
|
1881
1889
|
}
|
|
1882
1890
|
);
|
|
1883
|
-
function
|
|
1884
|
-
const { tenant:
|
|
1885
|
-
return
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1891
|
+
function vn({ children: r, redirectTo: e = "/dashboard", fallback: t }) {
|
|
1892
|
+
const { tenant: n, isLoading: i, error: o } = he(), a = be();
|
|
1893
|
+
return X(() => {
|
|
1894
|
+
process.env.NODE_ENV === "development" && console.warn(
|
|
1895
|
+
"[react-identity-access] LandingRoute is deprecated. Use PublicZone from ZoneRoute instead."
|
|
1896
|
+
);
|
|
1897
|
+
}, []), i || o ? null : n ? t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ d(_, { children: [
|
|
1898
|
+
/* @__PURE__ */ s(Rt, { redirectPath: e }),
|
|
1899
|
+
/* @__PURE__ */ s(fe, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
1900
|
+
] }) : /* @__PURE__ */ s(_, { children: r });
|
|
1889
1901
|
}
|
|
1890
|
-
const
|
|
1902
|
+
const je = {
|
|
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) {
|
|
1929
|
+
return e ? r ? Array.isArray(e) ? e.includes(r) : r === e : !1 : !0;
|
|
1930
|
+
}
|
|
1931
|
+
function Oe(r, e) {
|
|
1932
|
+
return !r || r === "optional" ? "skip" : r === "required" ? e ? "pass" : "fail" : r === "forbidden" ? e ? "fail" : "pass" : "skip";
|
|
1933
|
+
}
|
|
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
|
+
function Ft(r, e) {
|
|
1938
|
+
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
|
+
}
|
|
1940
|
+
function Nt(r, e, t, n, i) {
|
|
1941
|
+
if (!e || i !== "url")
|
|
1942
|
+
return r;
|
|
1943
|
+
const o = typeof e == "string" ? e : t, a = r.includes("?") ? "&" : "?";
|
|
1944
|
+
return `${r}${a}${n}=${encodeURIComponent(o)}`;
|
|
1945
|
+
}
|
|
1946
|
+
function Ut(r, e, t) {
|
|
1947
|
+
if (!r || t === "url") return;
|
|
1948
|
+
const n = typeof r == "string" ? r : e;
|
|
1949
|
+
sessionStorage.setItem("zone_return_to", n);
|
|
1950
|
+
}
|
|
1951
|
+
const ae = ({
|
|
1952
|
+
children: r,
|
|
1953
|
+
preset: e,
|
|
1954
|
+
tenant: t,
|
|
1955
|
+
auth: n,
|
|
1956
|
+
userType: i,
|
|
1957
|
+
requiredPermissions: o,
|
|
1958
|
+
requireAllPermissions: a = !0,
|
|
1959
|
+
returnTo: p,
|
|
1960
|
+
onAccessDenied: f,
|
|
1961
|
+
redirectTo: b,
|
|
1962
|
+
loadingFallback: u,
|
|
1963
|
+
accessDeniedFallback: w
|
|
1964
|
+
}) => {
|
|
1965
|
+
const g = be(), { isAuthenticated: v, isAuthInitializing: M, currentUser: F, userPermissions: L } = le(), { tenant: P, isTenantLoading: h } = ue(), x = K(() => {
|
|
1966
|
+
if (e)
|
|
1967
|
+
return It[e];
|
|
1968
|
+
}, [e]), k = K(
|
|
1969
|
+
() => ({
|
|
1970
|
+
tenant: t ?? (x == null ? void 0 : x.tenant),
|
|
1971
|
+
auth: n ?? (x == null ? void 0 : x.auth),
|
|
1972
|
+
userType: i ?? (x == null ? void 0 : x.userType),
|
|
1973
|
+
permissions: o ?? (x == null ? void 0 : x.requiredPermissions),
|
|
1974
|
+
requireAllPermissions: a
|
|
1975
|
+
}),
|
|
1976
|
+
[t, n, i, o, x, a]
|
|
1977
|
+
), I = K(
|
|
1978
|
+
() => ({
|
|
1979
|
+
hasTenant: !!P,
|
|
1980
|
+
isAuthenticated: v,
|
|
1981
|
+
userType: F == null ? void 0 : F.userType,
|
|
1982
|
+
permissions: L,
|
|
1983
|
+
isLoading: M || h
|
|
1984
|
+
}),
|
|
1985
|
+
[
|
|
1986
|
+
P,
|
|
1987
|
+
v,
|
|
1988
|
+
F == null ? void 0 : F.userType,
|
|
1989
|
+
L,
|
|
1990
|
+
M,
|
|
1991
|
+
h
|
|
1992
|
+
]
|
|
1993
|
+
), U = K(() => I.isLoading ? null : Et(k, I), [k, I]), C = je, R = K(() => U ? b || Ft(I, C) : null, [U, b, I, C]), B = K(() => !U || !R ? null : {
|
|
1994
|
+
type: U,
|
|
1995
|
+
required: {
|
|
1996
|
+
tenant: k.tenant,
|
|
1997
|
+
auth: k.auth,
|
|
1998
|
+
userType: k.userType,
|
|
1999
|
+
permissions: k.permissions
|
|
2000
|
+
},
|
|
2001
|
+
current: {
|
|
2002
|
+
hasTenant: I.hasTenant,
|
|
2003
|
+
isAuthenticated: I.isAuthenticated,
|
|
2004
|
+
userType: I.userType,
|
|
2005
|
+
permissions: I.permissions
|
|
2006
|
+
},
|
|
2007
|
+
redirectTo: R
|
|
2008
|
+
}, [U, R, k, I]);
|
|
2009
|
+
if (X(() => {
|
|
2010
|
+
B && f && f(B);
|
|
2011
|
+
}, [B, f]), X(() => {
|
|
2012
|
+
B && p && Ut(p, g.pathname + g.search, "session");
|
|
2013
|
+
}, [B, p, g.pathname, g.search]), I.isLoading)
|
|
2014
|
+
return /* @__PURE__ */ s(_, { children: u || null });
|
|
2015
|
+
if (B && R) {
|
|
2016
|
+
if (w)
|
|
2017
|
+
return /* @__PURE__ */ s(_, { children: w });
|
|
2018
|
+
const l = Nt(
|
|
2019
|
+
R,
|
|
2020
|
+
p,
|
|
2021
|
+
g.pathname + g.search,
|
|
2022
|
+
Mt,
|
|
2023
|
+
"url"
|
|
2024
|
+
);
|
|
2025
|
+
return /* @__PURE__ */ s(fe, { to: l, replace: !0 });
|
|
2026
|
+
}
|
|
2027
|
+
return /* @__PURE__ */ s(_, { children: r });
|
|
2028
|
+
}, Tn = (r) => /* @__PURE__ */ s(ae, { tenant: "required", ...r }), kn = (r) => /* @__PURE__ */ s(ae, { tenant: "forbidden", ...r }), An = (r) => /* @__PURE__ */ s(ae, { auth: "required", ...r }), xn = (r) => /* @__PURE__ */ s(ae, { auth: "forbidden", ...r }), Pn = (r) => /* @__PURE__ */ s(ae, { auth: "required", userType: se.TENANT_ADMIN, ...r }), Rn = (r) => /* @__PURE__ */ s(ae, { auth: "required", userType: se.USER, ...r }), In = (r) => /* @__PURE__ */ s(ae, { tenant: "optional", auth: "optional", ...r }), Mn = (r) => /* @__PURE__ */ s(ae, { tenant: "required", auth: "required", ...r }), Ln = (r) => /* @__PURE__ */ s(ae, { tenant: "required", auth: "optional", ...r }), En = (r) => /* @__PURE__ */ s(ae, { tenant: "required", auth: "forbidden", ...r }), Ct = () => /* @__PURE__ */ d(
|
|
1891
2029
|
"div",
|
|
1892
2030
|
{
|
|
1893
2031
|
style: {
|
|
@@ -1899,19 +2037,19 @@ const St = () => /* @__PURE__ */ d(
|
|
|
1899
2037
|
color: "#dc2626"
|
|
1900
2038
|
},
|
|
1901
2039
|
children: [
|
|
1902
|
-
/* @__PURE__ */
|
|
1903
|
-
/* @__PURE__ */
|
|
2040
|
+
/* @__PURE__ */ s("h3", { style: { margin: "0 0 1rem 0" }, children: "🔒 Subscription Required" }),
|
|
2041
|
+
/* @__PURE__ */ s("p", { style: { margin: 0 }, children: "This feature requires a higher subscription plan. Please upgrade your plan to access this content." })
|
|
1904
2042
|
]
|
|
1905
2043
|
}
|
|
1906
2044
|
);
|
|
1907
|
-
function
|
|
1908
|
-
children:
|
|
1909
|
-
fallback: e = /* @__PURE__ */
|
|
2045
|
+
function Fn({
|
|
2046
|
+
children: r,
|
|
2047
|
+
fallback: e = /* @__PURE__ */ s(Ct, {}),
|
|
1910
2048
|
allowedPlans: t,
|
|
1911
|
-
requiredFeature:
|
|
2049
|
+
requiredFeature: n
|
|
1912
2050
|
}) {
|
|
1913
|
-
const { subscription:
|
|
1914
|
-
return
|
|
2051
|
+
const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: p } = Tt();
|
|
2052
|
+
return p ? /* @__PURE__ */ s(
|
|
1915
2053
|
"div",
|
|
1916
2054
|
{
|
|
1917
2055
|
style: {
|
|
@@ -1921,9 +2059,9 @@ function or({
|
|
|
1921
2059
|
},
|
|
1922
2060
|
children: "Loading subscription..."
|
|
1923
2061
|
}
|
|
1924
|
-
) :
|
|
2062
|
+
) : i ? i.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ s(_, { children: e }) : n && !a(n) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: r }) : /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: e });
|
|
1925
2063
|
}
|
|
1926
|
-
const
|
|
2064
|
+
const Dt = ({ flagName: r }) => /* @__PURE__ */ d(
|
|
1927
2065
|
"div",
|
|
1928
2066
|
{
|
|
1929
2067
|
style: {
|
|
@@ -1940,19 +2078,19 @@ const vt = ({ flagName: i }) => /* @__PURE__ */ d(
|
|
|
1940
2078
|
color: "#6c757d"
|
|
1941
2079
|
},
|
|
1942
2080
|
children: [
|
|
1943
|
-
/* @__PURE__ */
|
|
1944
|
-
/* @__PURE__ */
|
|
2081
|
+
/* @__PURE__ */ s("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
|
|
2082
|
+
/* @__PURE__ */ s("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
|
|
1945
2083
|
/* @__PURE__ */ d("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
|
|
1946
2084
|
'Feature flag "',
|
|
1947
|
-
|
|
2085
|
+
r,
|
|
1948
2086
|
'" is disabled'
|
|
1949
2087
|
] })
|
|
1950
2088
|
]
|
|
1951
2089
|
}
|
|
1952
2090
|
);
|
|
1953
|
-
function
|
|
1954
|
-
const { isEnabled:
|
|
1955
|
-
return
|
|
2091
|
+
function Nn({ name: r, children: e, fallback: t }) {
|
|
2092
|
+
const { isEnabled: n, loading: i } = St();
|
|
2093
|
+
return i ? /* @__PURE__ */ s(
|
|
1956
2094
|
"div",
|
|
1957
2095
|
{
|
|
1958
2096
|
style: {
|
|
@@ -1965,9 +2103,9 @@ function ar({ name: i, children: e, fallback: t }) {
|
|
|
1965
2103
|
},
|
|
1966
2104
|
children: "Loading feature flags..."
|
|
1967
2105
|
}
|
|
1968
|
-
) : r
|
|
2106
|
+
) : n(r) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: t || /* @__PURE__ */ s(Dt, { flagName: r }) });
|
|
1969
2107
|
}
|
|
1970
|
-
const
|
|
2108
|
+
const $t = () => /* @__PURE__ */ d(
|
|
1971
2109
|
"svg",
|
|
1972
2110
|
{
|
|
1973
2111
|
width: "16",
|
|
@@ -1980,11 +2118,11 @@ const kt = () => /* @__PURE__ */ d(
|
|
|
1980
2118
|
strokeLinejoin: "round",
|
|
1981
2119
|
style: { flexShrink: 0 },
|
|
1982
2120
|
children: [
|
|
1983
|
-
/* @__PURE__ */
|
|
1984
|
-
/* @__PURE__ */
|
|
2121
|
+
/* @__PURE__ */ s("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
|
|
2122
|
+
/* @__PURE__ */ s("circle", { cx: "12", cy: "12", r: "3" })
|
|
1985
2123
|
]
|
|
1986
2124
|
}
|
|
1987
|
-
),
|
|
2125
|
+
), Ht = () => /* @__PURE__ */ d(
|
|
1988
2126
|
"svg",
|
|
1989
2127
|
{
|
|
1990
2128
|
width: "16",
|
|
@@ -1997,14 +2135,14 @@ const kt = () => /* @__PURE__ */ d(
|
|
|
1997
2135
|
strokeLinejoin: "round",
|
|
1998
2136
|
style: { flexShrink: 0 },
|
|
1999
2137
|
children: [
|
|
2000
|
-
/* @__PURE__ */
|
|
2001
|
-
/* @__PURE__ */
|
|
2138
|
+
/* @__PURE__ */ s("path", { d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24" }),
|
|
2139
|
+
/* @__PURE__ */ s("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
2002
2140
|
]
|
|
2003
2141
|
}
|
|
2004
|
-
),
|
|
2005
|
-
showPassword: /* @__PURE__ */
|
|
2006
|
-
hidePassword: /* @__PURE__ */
|
|
2007
|
-
},
|
|
2142
|
+
), Bt = {
|
|
2143
|
+
showPassword: /* @__PURE__ */ s($t, {}),
|
|
2144
|
+
hidePassword: /* @__PURE__ */ s(Ht, {})
|
|
2145
|
+
}, qt = {
|
|
2008
2146
|
title: "Sign In",
|
|
2009
2147
|
usernameLabel: "Email or Phone",
|
|
2010
2148
|
usernamePlaceholder: "Enter your email or phone number",
|
|
@@ -2018,7 +2156,7 @@ const kt = () => /* @__PURE__ */ d(
|
|
|
2018
2156
|
magicLinkLink: "Use Magic Link",
|
|
2019
2157
|
errorMessage: "Invalid credentials",
|
|
2020
2158
|
loadingText: "Signing in..."
|
|
2021
|
-
},
|
|
2159
|
+
}, Ot = {
|
|
2022
2160
|
container: {
|
|
2023
2161
|
maxWidth: "400px",
|
|
2024
2162
|
width: "100%",
|
|
@@ -2125,133 +2263,133 @@ const kt = () => /* @__PURE__ */ d(
|
|
|
2125
2263
|
fontSize: "0.875rem"
|
|
2126
2264
|
}
|
|
2127
2265
|
};
|
|
2128
|
-
function
|
|
2129
|
-
copy:
|
|
2266
|
+
function Un({
|
|
2267
|
+
copy: r = {},
|
|
2130
2268
|
styles: e = {},
|
|
2131
2269
|
icons: t = {},
|
|
2132
|
-
onSuccess:
|
|
2133
|
-
onError:
|
|
2270
|
+
onSuccess: n,
|
|
2271
|
+
onError: i,
|
|
2134
2272
|
onForgotPassword: o,
|
|
2135
2273
|
onSignupClick: a,
|
|
2136
|
-
onMagicLinkClick:
|
|
2137
|
-
showForgotPassword:
|
|
2274
|
+
onMagicLinkClick: p,
|
|
2275
|
+
showForgotPassword: f = !0,
|
|
2138
2276
|
showSignupLink: b = !0,
|
|
2139
|
-
showMagicLinkOption:
|
|
2140
|
-
className:
|
|
2277
|
+
showMagicLinkOption: u = !0,
|
|
2278
|
+
className: w
|
|
2141
2279
|
}) {
|
|
2142
|
-
const [
|
|
2143
|
-
const
|
|
2144
|
-
return
|
|
2145
|
-
},
|
|
2146
|
-
if (
|
|
2147
|
-
if (!(
|
|
2148
|
-
|
|
2280
|
+
const [g, v] = A(""), [M, F] = A(""), [L, P] = A(!1), [h, x] = A(!1), [k, I] = A(""), [U, C] = A({}), { login: R } = le(), { tenant: B } = he(), l = { ...qt, ...r }, N = { ...Ot, ...e }, D = { ...Bt, ...t }, c = () => {
|
|
2281
|
+
const m = {};
|
|
2282
|
+
return g.trim() || (m.username = !0), M.trim() || (m.password = !0), C(m), Object.keys(m).length === 0;
|
|
2283
|
+
}, $ = async (m) => {
|
|
2284
|
+
if (m.preventDefault(), !!c()) {
|
|
2285
|
+
if (!(B != null && B.id)) {
|
|
2286
|
+
I("Tenant not found");
|
|
2149
2287
|
return;
|
|
2150
2288
|
}
|
|
2151
|
-
|
|
2289
|
+
x(!0), I("");
|
|
2152
2290
|
try {
|
|
2153
|
-
const
|
|
2154
|
-
username:
|
|
2155
|
-
password:
|
|
2291
|
+
const S = await R({
|
|
2292
|
+
username: g,
|
|
2293
|
+
password: M
|
|
2156
2294
|
// tenantId inferred from context automatically
|
|
2157
2295
|
});
|
|
2158
|
-
|
|
2159
|
-
} catch (
|
|
2160
|
-
const
|
|
2161
|
-
|
|
2296
|
+
n == null || n(S);
|
|
2297
|
+
} catch (S) {
|
|
2298
|
+
const G = S.message || l.errorMessage;
|
|
2299
|
+
I(G), i == null || i(G);
|
|
2162
2300
|
} finally {
|
|
2163
|
-
|
|
2301
|
+
x(!1);
|
|
2164
2302
|
}
|
|
2165
2303
|
}
|
|
2166
|
-
},
|
|
2167
|
-
...
|
|
2168
|
-
...U[
|
|
2169
|
-
}),
|
|
2170
|
-
...
|
|
2171
|
-
...
|
|
2172
|
-
...!
|
|
2304
|
+
}, E = (m) => ({
|
|
2305
|
+
...N.input,
|
|
2306
|
+
...U[m] ? N.inputError : {}
|
|
2307
|
+
}), y = () => ({
|
|
2308
|
+
...N.button,
|
|
2309
|
+
...h ? N.buttonLoading : {},
|
|
2310
|
+
...!g || !M || h ? N.buttonDisabled : {}
|
|
2173
2311
|
});
|
|
2174
|
-
return /* @__PURE__ */ d("div", { className:
|
|
2175
|
-
/* @__PURE__ */
|
|
2176
|
-
/* @__PURE__ */ d("form", { onSubmit:
|
|
2177
|
-
/* @__PURE__ */ d("div", { style:
|
|
2178
|
-
/* @__PURE__ */
|
|
2179
|
-
/* @__PURE__ */
|
|
2312
|
+
return /* @__PURE__ */ d("div", { className: w, style: N.container, children: [
|
|
2313
|
+
/* @__PURE__ */ s("h2", { style: N.title, children: l.title }),
|
|
2314
|
+
/* @__PURE__ */ d("form", { onSubmit: $, style: N.form, children: [
|
|
2315
|
+
/* @__PURE__ */ d("div", { style: N.fieldGroup, children: [
|
|
2316
|
+
/* @__PURE__ */ s("label", { style: N.label, children: l.usernameLabel }),
|
|
2317
|
+
/* @__PURE__ */ s(
|
|
2180
2318
|
"input",
|
|
2181
2319
|
{
|
|
2182
2320
|
id: "username",
|
|
2183
2321
|
name: "username",
|
|
2184
2322
|
type: "text",
|
|
2185
|
-
value:
|
|
2186
|
-
onChange: (
|
|
2187
|
-
|
|
2323
|
+
value: g,
|
|
2324
|
+
onChange: (m) => {
|
|
2325
|
+
v(m.target.value), U.username && C((S) => ({ ...S, username: !1 }));
|
|
2188
2326
|
},
|
|
2189
|
-
placeholder:
|
|
2190
|
-
style:
|
|
2191
|
-
disabled:
|
|
2327
|
+
placeholder: l.usernamePlaceholder,
|
|
2328
|
+
style: E("username"),
|
|
2329
|
+
disabled: h
|
|
2192
2330
|
}
|
|
2193
2331
|
)
|
|
2194
2332
|
] }),
|
|
2195
|
-
/* @__PURE__ */ d("div", { style:
|
|
2196
|
-
/* @__PURE__ */
|
|
2197
|
-
/* @__PURE__ */ d("div", { style:
|
|
2198
|
-
/* @__PURE__ */
|
|
2333
|
+
/* @__PURE__ */ d("div", { style: N.fieldGroup, children: [
|
|
2334
|
+
/* @__PURE__ */ s("label", { style: N.label, children: l.passwordLabel }),
|
|
2335
|
+
/* @__PURE__ */ d("div", { style: N.inputContainer, children: [
|
|
2336
|
+
/* @__PURE__ */ s(
|
|
2199
2337
|
"input",
|
|
2200
2338
|
{
|
|
2201
2339
|
id: "password",
|
|
2202
2340
|
name: "password",
|
|
2203
|
-
type:
|
|
2204
|
-
value:
|
|
2205
|
-
onChange: (
|
|
2206
|
-
|
|
2341
|
+
type: L ? "text" : "password",
|
|
2342
|
+
value: M,
|
|
2343
|
+
onChange: (m) => {
|
|
2344
|
+
F(m.target.value), U.password && C((S) => ({ ...S, password: !1 }));
|
|
2207
2345
|
},
|
|
2208
|
-
placeholder:
|
|
2346
|
+
placeholder: l.passwordPlaceholder,
|
|
2209
2347
|
style: {
|
|
2210
|
-
...
|
|
2348
|
+
...E("password"),
|
|
2211
2349
|
paddingRight: "2.5rem"
|
|
2212
2350
|
// Make room for the icon
|
|
2213
2351
|
},
|
|
2214
|
-
disabled:
|
|
2352
|
+
disabled: h
|
|
2215
2353
|
}
|
|
2216
2354
|
),
|
|
2217
|
-
/* @__PURE__ */
|
|
2355
|
+
/* @__PURE__ */ s(
|
|
2218
2356
|
"button",
|
|
2219
2357
|
{
|
|
2220
2358
|
type: "button",
|
|
2221
|
-
onClick: () =>
|
|
2222
|
-
style:
|
|
2223
|
-
disabled:
|
|
2224
|
-
"aria-label":
|
|
2225
|
-
children:
|
|
2359
|
+
onClick: () => P(!L),
|
|
2360
|
+
style: N.passwordToggle,
|
|
2361
|
+
disabled: h,
|
|
2362
|
+
"aria-label": L ? "Hide password" : "Show password",
|
|
2363
|
+
children: L ? D.hidePassword : D.showPassword
|
|
2226
2364
|
}
|
|
2227
2365
|
)
|
|
2228
2366
|
] })
|
|
2229
2367
|
] }),
|
|
2230
|
-
/* @__PURE__ */
|
|
2231
|
-
|
|
2368
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !g || !M || h, style: y(), children: h ? l.loadingText : l.submitButton }),
|
|
2369
|
+
k && /* @__PURE__ */ s("div", { style: N.errorText, children: k })
|
|
2232
2370
|
] }),
|
|
2233
|
-
(
|
|
2234
|
-
|
|
2235
|
-
/* @__PURE__ */ d("span", { style:
|
|
2236
|
-
|
|
2371
|
+
(f || b || u) && /* @__PURE__ */ d("div", { style: N.linkContainer, children: [
|
|
2372
|
+
u && /* @__PURE__ */ d("div", { children: [
|
|
2373
|
+
/* @__PURE__ */ d("span", { style: N.divider, children: [
|
|
2374
|
+
l.magicLinkText,
|
|
2237
2375
|
" "
|
|
2238
2376
|
] }),
|
|
2239
|
-
/* @__PURE__ */
|
|
2377
|
+
/* @__PURE__ */ s("a", { onClick: p, style: N.link, children: l.magicLinkLink })
|
|
2240
2378
|
] }),
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2379
|
+
u && (f || b) && /* @__PURE__ */ s("div", { style: N.divider, children: "•" }),
|
|
2380
|
+
f && /* @__PURE__ */ s("a", { onClick: o, style: N.link, children: l.forgotPasswordLink }),
|
|
2381
|
+
f && b && /* @__PURE__ */ s("div", { style: N.divider, children: "•" }),
|
|
2244
2382
|
b && /* @__PURE__ */ d("div", { children: [
|
|
2245
|
-
/* @__PURE__ */ d("span", { style:
|
|
2246
|
-
|
|
2383
|
+
/* @__PURE__ */ d("span", { style: N.divider, children: [
|
|
2384
|
+
l.signupText,
|
|
2247
2385
|
" "
|
|
2248
2386
|
] }),
|
|
2249
|
-
/* @__PURE__ */
|
|
2387
|
+
/* @__PURE__ */ s("a", { onClick: a, style: N.link, children: l.signupLink })
|
|
2250
2388
|
] })
|
|
2251
2389
|
] })
|
|
2252
2390
|
] });
|
|
2253
2391
|
}
|
|
2254
|
-
const
|
|
2392
|
+
const zt = {
|
|
2255
2393
|
title: "Create Account",
|
|
2256
2394
|
nameLabel: "First Name",
|
|
2257
2395
|
namePlaceholder: "Enter your first name",
|
|
@@ -2277,7 +2415,7 @@ const Mt = {
|
|
|
2277
2415
|
passwordMismatchError: "Passwords do not match",
|
|
2278
2416
|
isAdminLabel: "Create new organization",
|
|
2279
2417
|
isAdminDescription: "Check this if you want to create a new organization"
|
|
2280
|
-
},
|
|
2418
|
+
}, _t = {
|
|
2281
2419
|
container: {
|
|
2282
2420
|
maxWidth: "400px",
|
|
2283
2421
|
width: "100%",
|
|
@@ -2376,138 +2514,138 @@ const Mt = {
|
|
|
2376
2514
|
fontSize: "0.875rem"
|
|
2377
2515
|
}
|
|
2378
2516
|
};
|
|
2379
|
-
function
|
|
2380
|
-
copy:
|
|
2517
|
+
function Cn({
|
|
2518
|
+
copy: r = {},
|
|
2381
2519
|
styles: e = {},
|
|
2382
2520
|
signupType: t = "user",
|
|
2383
|
-
onSuccess:
|
|
2384
|
-
onError:
|
|
2521
|
+
onSuccess: n,
|
|
2522
|
+
onError: i,
|
|
2385
2523
|
onLoginClick: o,
|
|
2386
2524
|
onMagicLinkClick: a,
|
|
2387
|
-
showLoginLink:
|
|
2388
|
-
showMagicLinkOption:
|
|
2525
|
+
showLoginLink: p = !0,
|
|
2526
|
+
showMagicLinkOption: f = !0,
|
|
2389
2527
|
className: b
|
|
2390
2528
|
}) {
|
|
2391
|
-
const [
|
|
2392
|
-
const
|
|
2393
|
-
return
|
|
2394
|
-
},
|
|
2395
|
-
if (
|
|
2396
|
-
if (
|
|
2397
|
-
|
|
2529
|
+
const [u, w] = A(""), [g, v] = A(""), [M, F] = A(""), [L, P] = A(""), [h, x] = A(""), [k, I] = A(""), [U, C] = A(""), [R, B] = A(!1), [l, N] = A(""), [D, c] = A({}), { signup: $, signupTenantAdmin: E } = le(), { tenant: y } = he(), m = { ...zt, ...r }, S = { ..._t, ...e }, G = () => {
|
|
2530
|
+
const T = {};
|
|
2531
|
+
return u.trim() || (T.name = !0), !M.trim() && !L.trim() && (T.email = !0, T.phoneNumber = !0), h.trim() || (T.password = !0), k.trim() || (T.confirmPassword = !0), t === "tenant" && !U.trim() && (T.tenantName = !0), c(T), Object.keys(T).length === 0;
|
|
2532
|
+
}, J = async (T) => {
|
|
2533
|
+
if (T.preventDefault(), !!G()) {
|
|
2534
|
+
if (h !== k) {
|
|
2535
|
+
N(m.passwordMismatchError), c({ confirmPassword: !0 });
|
|
2398
2536
|
return;
|
|
2399
2537
|
}
|
|
2400
|
-
if (t === "user" && !(
|
|
2401
|
-
|
|
2538
|
+
if (t === "user" && !(y != null && y.id)) {
|
|
2539
|
+
N("Tenant not found");
|
|
2402
2540
|
return;
|
|
2403
2541
|
}
|
|
2404
|
-
|
|
2542
|
+
B(!0), N("");
|
|
2405
2543
|
try {
|
|
2406
|
-
let
|
|
2407
|
-
t === "tenant" ?
|
|
2408
|
-
email:
|
|
2409
|
-
phoneNumber:
|
|
2410
|
-
name:
|
|
2411
|
-
password:
|
|
2544
|
+
let Z;
|
|
2545
|
+
t === "tenant" ? Z = await E({
|
|
2546
|
+
email: M || void 0,
|
|
2547
|
+
phoneNumber: L || void 0,
|
|
2548
|
+
name: u,
|
|
2549
|
+
password: h,
|
|
2412
2550
|
tenantName: U,
|
|
2413
|
-
lastName:
|
|
2414
|
-
}) :
|
|
2415
|
-
email:
|
|
2416
|
-
phoneNumber:
|
|
2417
|
-
name:
|
|
2418
|
-
password:
|
|
2419
|
-
tenantId:
|
|
2420
|
-
lastName:
|
|
2421
|
-
}),
|
|
2422
|
-
} catch (
|
|
2423
|
-
const
|
|
2424
|
-
|
|
2551
|
+
lastName: g || void 0
|
|
2552
|
+
}) : Z = await $({
|
|
2553
|
+
email: M || void 0,
|
|
2554
|
+
phoneNumber: L || void 0,
|
|
2555
|
+
name: u,
|
|
2556
|
+
password: h,
|
|
2557
|
+
tenantId: y.id,
|
|
2558
|
+
lastName: g || void 0
|
|
2559
|
+
}), n == null || n(Z);
|
|
2560
|
+
} catch (Z) {
|
|
2561
|
+
const ce = Z.message || m.errorMessage;
|
|
2562
|
+
N(ce), i == null || i(ce);
|
|
2425
2563
|
} finally {
|
|
2426
|
-
|
|
2564
|
+
B(!1);
|
|
2427
2565
|
}
|
|
2428
2566
|
}
|
|
2429
|
-
},
|
|
2430
|
-
...
|
|
2431
|
-
...
|
|
2432
|
-
}),
|
|
2433
|
-
...
|
|
2434
|
-
...
|
|
2435
|
-
...!
|
|
2436
|
-
}), V =
|
|
2437
|
-
return /* @__PURE__ */ d("div", { className: b, style:
|
|
2438
|
-
/* @__PURE__ */
|
|
2439
|
-
/* @__PURE__ */ d("form", { onSubmit:
|
|
2440
|
-
/* @__PURE__ */ d("div", { style:
|
|
2441
|
-
/* @__PURE__ */
|
|
2442
|
-
/* @__PURE__ */
|
|
2567
|
+
}, q = (T) => ({
|
|
2568
|
+
...S.input,
|
|
2569
|
+
...D[T] ? S.inputError : {}
|
|
2570
|
+
}), O = () => ({
|
|
2571
|
+
...S.button,
|
|
2572
|
+
...R ? S.buttonLoading : {},
|
|
2573
|
+
...!u || !M && !L || !h || !k || R || t === "tenant" && !U ? S.buttonDisabled : {}
|
|
2574
|
+
}), V = u && (M || L) && h && k && (t === "user" || U);
|
|
2575
|
+
return /* @__PURE__ */ d("div", { className: b, style: S.container, children: [
|
|
2576
|
+
/* @__PURE__ */ s("h2", { style: S.title, children: m.title }),
|
|
2577
|
+
/* @__PURE__ */ d("form", { onSubmit: J, style: S.form, children: [
|
|
2578
|
+
/* @__PURE__ */ d("div", { style: S.fieldGroup, children: [
|
|
2579
|
+
/* @__PURE__ */ s("label", { style: S.label, children: m.nameLabel }),
|
|
2580
|
+
/* @__PURE__ */ s(
|
|
2443
2581
|
"input",
|
|
2444
2582
|
{
|
|
2445
2583
|
id: "name",
|
|
2446
2584
|
name: "name",
|
|
2447
2585
|
type: "text",
|
|
2448
|
-
value:
|
|
2449
|
-
onChange: (
|
|
2450
|
-
|
|
2586
|
+
value: u,
|
|
2587
|
+
onChange: (T) => {
|
|
2588
|
+
w(T.target.value), D.name && c((Z) => ({ ...Z, name: !1 }));
|
|
2451
2589
|
},
|
|
2452
|
-
placeholder:
|
|
2453
|
-
style:
|
|
2454
|
-
disabled:
|
|
2590
|
+
placeholder: m.namePlaceholder,
|
|
2591
|
+
style: q("name"),
|
|
2592
|
+
disabled: R
|
|
2455
2593
|
}
|
|
2456
2594
|
)
|
|
2457
2595
|
] }),
|
|
2458
|
-
/* @__PURE__ */ d("div", { style:
|
|
2459
|
-
/* @__PURE__ */
|
|
2460
|
-
/* @__PURE__ */
|
|
2596
|
+
/* @__PURE__ */ d("div", { style: S.fieldGroup, children: [
|
|
2597
|
+
/* @__PURE__ */ s("label", { style: S.label, children: m.lastNameLabel }),
|
|
2598
|
+
/* @__PURE__ */ s(
|
|
2461
2599
|
"input",
|
|
2462
2600
|
{
|
|
2463
2601
|
id: "lastName",
|
|
2464
2602
|
name: "lastName",
|
|
2465
2603
|
type: "text",
|
|
2466
|
-
value:
|
|
2467
|
-
onChange: (
|
|
2468
|
-
placeholder:
|
|
2469
|
-
style:
|
|
2470
|
-
disabled:
|
|
2604
|
+
value: g,
|
|
2605
|
+
onChange: (T) => v(T.target.value),
|
|
2606
|
+
placeholder: m.lastNamePlaceholder,
|
|
2607
|
+
style: S.input,
|
|
2608
|
+
disabled: R
|
|
2471
2609
|
}
|
|
2472
2610
|
)
|
|
2473
2611
|
] }),
|
|
2474
|
-
/* @__PURE__ */ d("div", { style:
|
|
2475
|
-
/* @__PURE__ */
|
|
2476
|
-
/* @__PURE__ */
|
|
2612
|
+
/* @__PURE__ */ d("div", { style: S.fieldGroup, children: [
|
|
2613
|
+
/* @__PURE__ */ s("label", { style: S.label, children: m.emailLabel }),
|
|
2614
|
+
/* @__PURE__ */ s(
|
|
2477
2615
|
"input",
|
|
2478
2616
|
{
|
|
2479
2617
|
id: "email",
|
|
2480
2618
|
name: "email",
|
|
2481
2619
|
type: "email",
|
|
2482
|
-
value:
|
|
2483
|
-
onChange: (
|
|
2484
|
-
|
|
2620
|
+
value: M,
|
|
2621
|
+
onChange: (T) => {
|
|
2622
|
+
F(T.target.value), D.email && c((Z) => ({ ...Z, email: !1, phoneNumber: !1 }));
|
|
2485
2623
|
},
|
|
2486
|
-
placeholder:
|
|
2487
|
-
style:
|
|
2488
|
-
disabled:
|
|
2624
|
+
placeholder: m.emailPlaceholder,
|
|
2625
|
+
style: q("email"),
|
|
2626
|
+
disabled: R
|
|
2489
2627
|
}
|
|
2490
2628
|
)
|
|
2491
2629
|
] }),
|
|
2492
|
-
/* @__PURE__ */ d("div", { style:
|
|
2493
|
-
/* @__PURE__ */
|
|
2494
|
-
/* @__PURE__ */
|
|
2630
|
+
/* @__PURE__ */ d("div", { style: S.fieldGroup, children: [
|
|
2631
|
+
/* @__PURE__ */ s("label", { style: S.label, children: m.phoneNumberLabel }),
|
|
2632
|
+
/* @__PURE__ */ s(
|
|
2495
2633
|
"input",
|
|
2496
2634
|
{
|
|
2497
2635
|
id: "phoneNumber",
|
|
2498
2636
|
name: "phoneNumber",
|
|
2499
2637
|
type: "tel",
|
|
2500
|
-
value:
|
|
2501
|
-
onChange: (
|
|
2502
|
-
|
|
2638
|
+
value: L,
|
|
2639
|
+
onChange: (T) => {
|
|
2640
|
+
P(T.target.value), D.phoneNumber && c((Z) => ({ ...Z, email: !1, phoneNumber: !1 }));
|
|
2503
2641
|
},
|
|
2504
|
-
placeholder:
|
|
2505
|
-
style:
|
|
2506
|
-
disabled:
|
|
2642
|
+
placeholder: m.phoneNumberPlaceholder,
|
|
2643
|
+
style: q("phoneNumber"),
|
|
2644
|
+
disabled: R
|
|
2507
2645
|
}
|
|
2508
2646
|
)
|
|
2509
2647
|
] }),
|
|
2510
|
-
/* @__PURE__ */
|
|
2648
|
+
/* @__PURE__ */ s(
|
|
2511
2649
|
"div",
|
|
2512
2650
|
{
|
|
2513
2651
|
style: {
|
|
@@ -2519,83 +2657,83 @@ function cr({
|
|
|
2519
2657
|
children: "At least one contact method (email or phone) is required"
|
|
2520
2658
|
}
|
|
2521
2659
|
),
|
|
2522
|
-
/* @__PURE__ */ d("div", { style:
|
|
2523
|
-
/* @__PURE__ */
|
|
2524
|
-
/* @__PURE__ */
|
|
2660
|
+
/* @__PURE__ */ d("div", { style: S.fieldGroup, children: [
|
|
2661
|
+
/* @__PURE__ */ s("label", { style: S.label, children: m.passwordLabel }),
|
|
2662
|
+
/* @__PURE__ */ s(
|
|
2525
2663
|
"input",
|
|
2526
2664
|
{
|
|
2527
2665
|
id: "password",
|
|
2528
2666
|
name: "password",
|
|
2529
2667
|
type: "password",
|
|
2530
|
-
value:
|
|
2531
|
-
onChange: (
|
|
2532
|
-
|
|
2668
|
+
value: h,
|
|
2669
|
+
onChange: (T) => {
|
|
2670
|
+
x(T.target.value), D.password && c((Z) => ({ ...Z, password: !1 }));
|
|
2533
2671
|
},
|
|
2534
|
-
placeholder:
|
|
2535
|
-
style:
|
|
2536
|
-
disabled:
|
|
2672
|
+
placeholder: m.passwordPlaceholder,
|
|
2673
|
+
style: q("password"),
|
|
2674
|
+
disabled: R
|
|
2537
2675
|
}
|
|
2538
2676
|
)
|
|
2539
2677
|
] }),
|
|
2540
|
-
/* @__PURE__ */ d("div", { style:
|
|
2541
|
-
/* @__PURE__ */
|
|
2542
|
-
/* @__PURE__ */
|
|
2678
|
+
/* @__PURE__ */ d("div", { style: S.fieldGroup, children: [
|
|
2679
|
+
/* @__PURE__ */ s("label", { style: S.label, children: m.confirmPasswordLabel }),
|
|
2680
|
+
/* @__PURE__ */ s(
|
|
2543
2681
|
"input",
|
|
2544
2682
|
{
|
|
2545
2683
|
id: "confirmPassword",
|
|
2546
2684
|
name: "confirmPassword",
|
|
2547
2685
|
type: "password",
|
|
2548
|
-
value:
|
|
2549
|
-
onChange: (
|
|
2550
|
-
|
|
2686
|
+
value: k,
|
|
2687
|
+
onChange: (T) => {
|
|
2688
|
+
I(T.target.value), D.confirmPassword && c((Z) => ({ ...Z, confirmPassword: !1 })), l === m.passwordMismatchError && N("");
|
|
2551
2689
|
},
|
|
2552
|
-
placeholder:
|
|
2553
|
-
style:
|
|
2554
|
-
disabled:
|
|
2690
|
+
placeholder: m.confirmPasswordPlaceholder,
|
|
2691
|
+
style: q("confirmPassword"),
|
|
2692
|
+
disabled: R
|
|
2555
2693
|
}
|
|
2556
2694
|
)
|
|
2557
2695
|
] }),
|
|
2558
|
-
t === "tenant" && /* @__PURE__ */ d("div", { style:
|
|
2559
|
-
/* @__PURE__ */
|
|
2560
|
-
/* @__PURE__ */
|
|
2696
|
+
t === "tenant" && /* @__PURE__ */ d("div", { style: S.fieldGroup, children: [
|
|
2697
|
+
/* @__PURE__ */ s("label", { style: S.label, children: m.tenantNameLabel }),
|
|
2698
|
+
/* @__PURE__ */ s(
|
|
2561
2699
|
"input",
|
|
2562
2700
|
{
|
|
2563
2701
|
id: "tenantName",
|
|
2564
2702
|
name: "tenantName",
|
|
2565
2703
|
type: "text",
|
|
2566
2704
|
value: U,
|
|
2567
|
-
onChange: (
|
|
2568
|
-
|
|
2705
|
+
onChange: (T) => {
|
|
2706
|
+
C(T.target.value), D.tenantName && c((Z) => ({ ...Z, tenantName: !1 }));
|
|
2569
2707
|
},
|
|
2570
|
-
placeholder:
|
|
2571
|
-
style:
|
|
2572
|
-
disabled:
|
|
2708
|
+
placeholder: m.tenantNamePlaceholder,
|
|
2709
|
+
style: q("tenantName"),
|
|
2710
|
+
disabled: R
|
|
2573
2711
|
}
|
|
2574
2712
|
)
|
|
2575
2713
|
] }),
|
|
2576
|
-
/* @__PURE__ */
|
|
2577
|
-
|
|
2714
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !V || R, style: O(), children: R ? m.loadingText : m.submitButton }),
|
|
2715
|
+
l && /* @__PURE__ */ s("div", { style: S.errorText, children: l })
|
|
2578
2716
|
] }),
|
|
2579
|
-
(
|
|
2580
|
-
|
|
2581
|
-
/* @__PURE__ */ d("span", { style:
|
|
2582
|
-
|
|
2717
|
+
(p || f) && /* @__PURE__ */ d("div", { style: S.linkContainer, children: [
|
|
2718
|
+
f && /* @__PURE__ */ d("div", { children: [
|
|
2719
|
+
/* @__PURE__ */ d("span", { style: S.divider, children: [
|
|
2720
|
+
m.magicLinkText,
|
|
2583
2721
|
" "
|
|
2584
2722
|
] }),
|
|
2585
|
-
/* @__PURE__ */
|
|
2723
|
+
/* @__PURE__ */ s("a", { onClick: a, style: S.link, children: m.magicLinkLink })
|
|
2586
2724
|
] }),
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
/* @__PURE__ */ d("span", { style:
|
|
2590
|
-
|
|
2725
|
+
f && p && /* @__PURE__ */ s("div", { style: S.divider, children: "•" }),
|
|
2726
|
+
p && /* @__PURE__ */ d("div", { children: [
|
|
2727
|
+
/* @__PURE__ */ d("span", { style: S.divider, children: [
|
|
2728
|
+
m.loginText,
|
|
2591
2729
|
" "
|
|
2592
2730
|
] }),
|
|
2593
|
-
/* @__PURE__ */
|
|
2731
|
+
/* @__PURE__ */ s("a", { onClick: o, style: S.link, children: m.loginLink })
|
|
2594
2732
|
] })
|
|
2595
2733
|
] })
|
|
2596
2734
|
] });
|
|
2597
2735
|
}
|
|
2598
|
-
const
|
|
2736
|
+
const Wt = {
|
|
2599
2737
|
title: "Sign In with Magic Link",
|
|
2600
2738
|
emailLabel: "Email",
|
|
2601
2739
|
emailPlaceholder: "Enter your email",
|
|
@@ -2613,7 +2751,7 @@ const Rt = {
|
|
|
2613
2751
|
loadingText: "Sending magic link...",
|
|
2614
2752
|
verifyingText: "Verifying magic link...",
|
|
2615
2753
|
description: "Enter your email to receive a magic link. If you don't have an account, we'll create one for you."
|
|
2616
|
-
},
|
|
2754
|
+
}, Vt = {
|
|
2617
2755
|
container: {
|
|
2618
2756
|
maxWidth: "400px",
|
|
2619
2757
|
width: "100%",
|
|
@@ -2716,105 +2854,105 @@ const Rt = {
|
|
|
2716
2854
|
fontSize: "0.875rem"
|
|
2717
2855
|
}
|
|
2718
2856
|
};
|
|
2719
|
-
function
|
|
2720
|
-
copy:
|
|
2857
|
+
function Dn({
|
|
2858
|
+
copy: r = {},
|
|
2721
2859
|
styles: e = {},
|
|
2722
2860
|
onSuccess: t,
|
|
2723
|
-
onError:
|
|
2724
|
-
onLoginClick:
|
|
2861
|
+
onError: n,
|
|
2862
|
+
onLoginClick: i,
|
|
2725
2863
|
onSignupClick: o,
|
|
2726
2864
|
showTraditionalLinks: a = !0,
|
|
2727
|
-
className:
|
|
2728
|
-
verifyToken:
|
|
2865
|
+
className: p,
|
|
2866
|
+
verifyToken: f,
|
|
2729
2867
|
frontendUrl: b
|
|
2730
2868
|
}) {
|
|
2731
|
-
const [
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
}, [
|
|
2735
|
-
const
|
|
2736
|
-
if (
|
|
2737
|
-
|
|
2869
|
+
const [u, w] = A(""), [g, v] = A(""), [M, F] = A(""), [L, P] = A(!1), [h, x] = A(!1), [k, I] = A(""), [U, C] = A(""), [R, B] = A({}), [l, N] = A(!1), { sendMagicLink: D, verifyMagicLink: c } = le(), { tenant: $ } = he(), E = { ...Wt, ...r }, y = { ...Vt, ...e };
|
|
2870
|
+
X(() => {
|
|
2871
|
+
f && m(f);
|
|
2872
|
+
}, [f]);
|
|
2873
|
+
const m = async (O) => {
|
|
2874
|
+
if (!$ || !u) {
|
|
2875
|
+
I("Missing tenant or email");
|
|
2738
2876
|
return;
|
|
2739
2877
|
}
|
|
2740
|
-
|
|
2878
|
+
x(!0), I("");
|
|
2741
2879
|
try {
|
|
2742
|
-
const V = await
|
|
2743
|
-
token:
|
|
2744
|
-
email:
|
|
2880
|
+
const V = await c({
|
|
2881
|
+
token: O,
|
|
2882
|
+
email: u
|
|
2745
2883
|
// tenantId inferred from context automatically
|
|
2746
2884
|
});
|
|
2747
2885
|
t == null || t(V);
|
|
2748
2886
|
} catch (V) {
|
|
2749
|
-
const
|
|
2750
|
-
|
|
2887
|
+
const T = V.message || "Failed to verify magic link";
|
|
2888
|
+
I(T), n == null || n(T);
|
|
2751
2889
|
} finally {
|
|
2752
|
-
|
|
2890
|
+
x(!1);
|
|
2753
2891
|
}
|
|
2754
|
-
},
|
|
2755
|
-
const
|
|
2756
|
-
return
|
|
2757
|
-
},
|
|
2758
|
-
if (
|
|
2759
|
-
if (!(
|
|
2760
|
-
|
|
2892
|
+
}, S = () => {
|
|
2893
|
+
const O = {};
|
|
2894
|
+
return u.trim() || (O.email = !0), l && !g.trim() && (O.name = !0), B(O), Object.keys(O).length === 0;
|
|
2895
|
+
}, G = async (O) => {
|
|
2896
|
+
if (O.preventDefault(), !!S()) {
|
|
2897
|
+
if (!($ != null && $.id)) {
|
|
2898
|
+
I("Tenant not found");
|
|
2761
2899
|
return;
|
|
2762
2900
|
}
|
|
2763
|
-
|
|
2901
|
+
P(!0), I(""), C("");
|
|
2764
2902
|
try {
|
|
2765
|
-
const V = b || (typeof window < "u" ? window.location.origin : ""),
|
|
2766
|
-
email:
|
|
2767
|
-
tenantId:
|
|
2903
|
+
const V = b || (typeof window < "u" ? window.location.origin : ""), T = await D({
|
|
2904
|
+
email: u,
|
|
2905
|
+
tenantId: $.id,
|
|
2768
2906
|
frontendUrl: V,
|
|
2769
|
-
name:
|
|
2770
|
-
lastName:
|
|
2907
|
+
name: l ? g : void 0,
|
|
2908
|
+
lastName: l ? M : void 0
|
|
2771
2909
|
});
|
|
2772
|
-
|
|
2910
|
+
C(E.successMessage), t == null || t(T);
|
|
2773
2911
|
} catch (V) {
|
|
2774
|
-
const
|
|
2775
|
-
|
|
2912
|
+
const T = V.message || E.errorMessage;
|
|
2913
|
+
I(T), n == null || n(T);
|
|
2776
2914
|
} finally {
|
|
2777
|
-
|
|
2915
|
+
P(!1);
|
|
2778
2916
|
}
|
|
2779
2917
|
}
|
|
2780
|
-
},
|
|
2781
|
-
...
|
|
2782
|
-
...
|
|
2783
|
-
}),
|
|
2784
|
-
...
|
|
2785
|
-
...
|
|
2786
|
-
...!
|
|
2918
|
+
}, J = (O) => ({
|
|
2919
|
+
...y.input,
|
|
2920
|
+
...R[O] ? y.inputError : {}
|
|
2921
|
+
}), q = () => ({
|
|
2922
|
+
...y.button,
|
|
2923
|
+
...L || h ? y.buttonLoading : {},
|
|
2924
|
+
...!u || L || h ? y.buttonDisabled : {}
|
|
2787
2925
|
});
|
|
2788
|
-
return
|
|
2789
|
-
/* @__PURE__ */
|
|
2790
|
-
/* @__PURE__ */
|
|
2791
|
-
] }) : /* @__PURE__ */ d("div", { className:
|
|
2792
|
-
/* @__PURE__ */
|
|
2793
|
-
/* @__PURE__ */
|
|
2794
|
-
/* @__PURE__ */ d("form", { onSubmit:
|
|
2795
|
-
/* @__PURE__ */ d("div", { style:
|
|
2796
|
-
/* @__PURE__ */
|
|
2797
|
-
/* @__PURE__ */
|
|
2926
|
+
return h ? /* @__PURE__ */ d("div", { className: p, style: y.container, children: [
|
|
2927
|
+
/* @__PURE__ */ s("h2", { style: y.title, children: E.verifyingText }),
|
|
2928
|
+
/* @__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
|
+
] }) : /* @__PURE__ */ d("div", { className: p, style: y.container, children: [
|
|
2930
|
+
/* @__PURE__ */ s("h2", { style: y.title, children: E.title }),
|
|
2931
|
+
/* @__PURE__ */ s("p", { style: y.description, children: E.description }),
|
|
2932
|
+
/* @__PURE__ */ d("form", { onSubmit: G, style: y.form, children: [
|
|
2933
|
+
/* @__PURE__ */ d("div", { style: y.fieldGroup, children: [
|
|
2934
|
+
/* @__PURE__ */ s("label", { style: y.label, children: E.emailLabel }),
|
|
2935
|
+
/* @__PURE__ */ s(
|
|
2798
2936
|
"input",
|
|
2799
2937
|
{
|
|
2800
2938
|
id: "email",
|
|
2801
2939
|
name: "email",
|
|
2802
2940
|
type: "email",
|
|
2803
|
-
value:
|
|
2804
|
-
onChange: (
|
|
2805
|
-
|
|
2941
|
+
value: u,
|
|
2942
|
+
onChange: (O) => {
|
|
2943
|
+
w(O.target.value), R.email && B((V) => ({ ...V, email: !1 }));
|
|
2806
2944
|
},
|
|
2807
|
-
placeholder:
|
|
2808
|
-
style:
|
|
2809
|
-
disabled:
|
|
2945
|
+
placeholder: E.emailPlaceholder,
|
|
2946
|
+
style: J("email"),
|
|
2947
|
+
disabled: L || h
|
|
2810
2948
|
}
|
|
2811
2949
|
)
|
|
2812
2950
|
] }),
|
|
2813
|
-
!
|
|
2951
|
+
!l && /* @__PURE__ */ s("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ s(
|
|
2814
2952
|
"button",
|
|
2815
2953
|
{
|
|
2816
2954
|
type: "button",
|
|
2817
|
-
onClick: () =>
|
|
2955
|
+
onClick: () => N(!0),
|
|
2818
2956
|
style: {
|
|
2819
2957
|
background: "none",
|
|
2820
2958
|
border: "none",
|
|
@@ -2826,47 +2964,47 @@ function dr({
|
|
|
2826
2964
|
children: "New user? Add your name"
|
|
2827
2965
|
}
|
|
2828
2966
|
) }),
|
|
2829
|
-
|
|
2830
|
-
/* @__PURE__ */ d("div", { style:
|
|
2831
|
-
/* @__PURE__ */
|
|
2832
|
-
/* @__PURE__ */
|
|
2967
|
+
l && /* @__PURE__ */ d(_, { children: [
|
|
2968
|
+
/* @__PURE__ */ d("div", { style: y.fieldGroup, children: [
|
|
2969
|
+
/* @__PURE__ */ s("label", { style: y.label, children: E.nameLabel }),
|
|
2970
|
+
/* @__PURE__ */ s(
|
|
2833
2971
|
"input",
|
|
2834
2972
|
{
|
|
2835
2973
|
id: "name",
|
|
2836
2974
|
name: "name",
|
|
2837
2975
|
type: "text",
|
|
2838
|
-
value:
|
|
2839
|
-
onChange: (
|
|
2840
|
-
|
|
2976
|
+
value: g,
|
|
2977
|
+
onChange: (O) => {
|
|
2978
|
+
v(O.target.value), R.name && B((V) => ({ ...V, name: !1 }));
|
|
2841
2979
|
},
|
|
2842
|
-
placeholder:
|
|
2843
|
-
style:
|
|
2844
|
-
disabled:
|
|
2980
|
+
placeholder: E.namePlaceholder,
|
|
2981
|
+
style: J("name"),
|
|
2982
|
+
disabled: L || h
|
|
2845
2983
|
}
|
|
2846
2984
|
)
|
|
2847
2985
|
] }),
|
|
2848
|
-
/* @__PURE__ */ d("div", { style:
|
|
2849
|
-
/* @__PURE__ */
|
|
2850
|
-
/* @__PURE__ */
|
|
2986
|
+
/* @__PURE__ */ d("div", { style: y.fieldGroup, children: [
|
|
2987
|
+
/* @__PURE__ */ s("label", { style: y.label, children: E.lastNameLabel }),
|
|
2988
|
+
/* @__PURE__ */ s(
|
|
2851
2989
|
"input",
|
|
2852
2990
|
{
|
|
2853
2991
|
id: "lastName",
|
|
2854
2992
|
name: "lastName",
|
|
2855
2993
|
type: "text",
|
|
2856
|
-
value:
|
|
2857
|
-
onChange: (
|
|
2858
|
-
placeholder:
|
|
2859
|
-
style:
|
|
2860
|
-
disabled:
|
|
2994
|
+
value: M,
|
|
2995
|
+
onChange: (O) => F(O.target.value),
|
|
2996
|
+
placeholder: E.lastNamePlaceholder,
|
|
2997
|
+
style: y.input,
|
|
2998
|
+
disabled: L || h
|
|
2861
2999
|
}
|
|
2862
3000
|
)
|
|
2863
3001
|
] }),
|
|
2864
|
-
/* @__PURE__ */
|
|
3002
|
+
/* @__PURE__ */ s("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ s(
|
|
2865
3003
|
"button",
|
|
2866
3004
|
{
|
|
2867
3005
|
type: "button",
|
|
2868
3006
|
onClick: () => {
|
|
2869
|
-
|
|
3007
|
+
N(!1), v(""), F("");
|
|
2870
3008
|
},
|
|
2871
3009
|
style: {
|
|
2872
3010
|
background: "none",
|
|
@@ -2880,30 +3018,30 @@ function dr({
|
|
|
2880
3018
|
}
|
|
2881
3019
|
) })
|
|
2882
3020
|
] }),
|
|
2883
|
-
/* @__PURE__ */
|
|
2884
|
-
|
|
2885
|
-
U && /* @__PURE__ */
|
|
3021
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !u || L || h, style: q(), children: L ? E.loadingText : E.submitButton }),
|
|
3022
|
+
k && /* @__PURE__ */ s("div", { style: y.errorText, children: k }),
|
|
3023
|
+
U && /* @__PURE__ */ s("div", { style: y.successText, children: U })
|
|
2886
3024
|
] }),
|
|
2887
|
-
a && /* @__PURE__ */ d("div", { style:
|
|
3025
|
+
a && /* @__PURE__ */ d("div", { style: y.linkContainer, children: [
|
|
2888
3026
|
/* @__PURE__ */ d("div", { children: [
|
|
2889
|
-
/* @__PURE__ */ d("span", { style:
|
|
2890
|
-
|
|
3027
|
+
/* @__PURE__ */ d("span", { style: y.divider, children: [
|
|
3028
|
+
E.loginText,
|
|
2891
3029
|
" "
|
|
2892
3030
|
] }),
|
|
2893
|
-
/* @__PURE__ */
|
|
3031
|
+
/* @__PURE__ */ s("a", { onClick: i, style: y.link, children: E.loginLink })
|
|
2894
3032
|
] }),
|
|
2895
|
-
/* @__PURE__ */
|
|
3033
|
+
/* @__PURE__ */ s("div", { style: y.divider, children: "•" }),
|
|
2896
3034
|
/* @__PURE__ */ d("div", { children: [
|
|
2897
|
-
/* @__PURE__ */ d("span", { style:
|
|
2898
|
-
|
|
3035
|
+
/* @__PURE__ */ d("span", { style: y.divider, children: [
|
|
3036
|
+
E.signupText,
|
|
2899
3037
|
" "
|
|
2900
3038
|
] }),
|
|
2901
|
-
/* @__PURE__ */
|
|
3039
|
+
/* @__PURE__ */ s("a", { onClick: o, style: y.link, children: E.signupLink })
|
|
2902
3040
|
] })
|
|
2903
3041
|
] })
|
|
2904
3042
|
] });
|
|
2905
3043
|
}
|
|
2906
|
-
const
|
|
3044
|
+
const jt = {
|
|
2907
3045
|
title: "Verifying Magic Link",
|
|
2908
3046
|
verifyingMessage: "Please wait while we verify your magic link...",
|
|
2909
3047
|
successMessage: "Magic link verified successfully! You are now logged in.",
|
|
@@ -2911,7 +3049,7 @@ const Et = {
|
|
|
2911
3049
|
redirectingMessage: "Redirecting you to the dashboard...",
|
|
2912
3050
|
retryButton: "Try Again",
|
|
2913
3051
|
backToLoginButton: "Back to Login"
|
|
2914
|
-
},
|
|
3052
|
+
}, Ge = {
|
|
2915
3053
|
container: {
|
|
2916
3054
|
maxWidth: "400px",
|
|
2917
3055
|
width: "100%",
|
|
@@ -2998,7 +3136,7 @@ const Et = {
|
|
|
2998
3136
|
cursor: "pointer",
|
|
2999
3137
|
transition: "all 0.15s ease-in-out"
|
|
3000
3138
|
}
|
|
3001
|
-
},
|
|
3139
|
+
}, Gt = () => /* @__PURE__ */ s("div", { style: Ge.spinner }), Zt = () => /* @__PURE__ */ d(
|
|
3002
3140
|
"svg",
|
|
3003
3141
|
{
|
|
3004
3142
|
width: "48",
|
|
@@ -3011,11 +3149,11 @@ const Et = {
|
|
|
3011
3149
|
strokeLinejoin: "round",
|
|
3012
3150
|
style: { margin: "0 auto 1rem auto", display: "block" },
|
|
3013
3151
|
children: [
|
|
3014
|
-
/* @__PURE__ */
|
|
3015
|
-
/* @__PURE__ */
|
|
3152
|
+
/* @__PURE__ */ s("path", { d: "M22 11.08V12a10 10 0 1 1-5.93-9.14" }),
|
|
3153
|
+
/* @__PURE__ */ s("polyline", { points: "22,4 12,14.01 9,11.01" })
|
|
3016
3154
|
]
|
|
3017
3155
|
}
|
|
3018
|
-
),
|
|
3156
|
+
), Kt = () => /* @__PURE__ */ d(
|
|
3019
3157
|
"svg",
|
|
3020
3158
|
{
|
|
3021
3159
|
width: "48",
|
|
@@ -3028,114 +3166,114 @@ const Et = {
|
|
|
3028
3166
|
strokeLinejoin: "round",
|
|
3029
3167
|
style: { margin: "0 auto 1rem auto", display: "block" },
|
|
3030
3168
|
children: [
|
|
3031
|
-
/* @__PURE__ */
|
|
3032
|
-
/* @__PURE__ */
|
|
3033
|
-
/* @__PURE__ */
|
|
3169
|
+
/* @__PURE__ */ s("circle", { cx: "12", cy: "12", r: "10" }),
|
|
3170
|
+
/* @__PURE__ */ s("line", { x1: "15", y1: "9", x2: "9", y2: "15" }),
|
|
3171
|
+
/* @__PURE__ */ s("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
|
|
3034
3172
|
]
|
|
3035
3173
|
}
|
|
3036
|
-
),
|
|
3037
|
-
loading: /* @__PURE__ */
|
|
3038
|
-
success: /* @__PURE__ */
|
|
3039
|
-
error: /* @__PURE__ */
|
|
3174
|
+
), Jt = {
|
|
3175
|
+
loading: /* @__PURE__ */ s(Gt, {}),
|
|
3176
|
+
success: /* @__PURE__ */ s(Zt, {}),
|
|
3177
|
+
error: /* @__PURE__ */ s(Kt, {})
|
|
3040
3178
|
};
|
|
3041
|
-
function
|
|
3042
|
-
copy:
|
|
3179
|
+
function $n({
|
|
3180
|
+
copy: r = {},
|
|
3043
3181
|
styles: e = {},
|
|
3044
3182
|
icons: t = {},
|
|
3045
|
-
onSuccess:
|
|
3046
|
-
onError:
|
|
3183
|
+
onSuccess: n,
|
|
3184
|
+
onError: i,
|
|
3047
3185
|
onRetry: o,
|
|
3048
3186
|
onBackToLogin: a,
|
|
3049
|
-
className:
|
|
3050
|
-
token:
|
|
3187
|
+
className: p,
|
|
3188
|
+
token: f,
|
|
3051
3189
|
email: b,
|
|
3052
|
-
appId:
|
|
3053
|
-
tenantSlug:
|
|
3054
|
-
autoRedirectDelay:
|
|
3190
|
+
appId: u,
|
|
3191
|
+
tenantSlug: w,
|
|
3192
|
+
autoRedirectDelay: g = 3e3
|
|
3055
3193
|
}) {
|
|
3056
|
-
const [
|
|
3194
|
+
const [v, M] = A("verifying"), [F, L] = A(""), { verifyMagicLink: P } = le(), h = { ...jt, ...r }, x = { ...Ge, ...e }, k = { ...Jt, ...t }, I = () => {
|
|
3057
3195
|
if (typeof window > "u") return {};
|
|
3058
|
-
const
|
|
3196
|
+
const l = new URLSearchParams(window.location.search);
|
|
3059
3197
|
return {
|
|
3060
|
-
token:
|
|
3061
|
-
email: b ||
|
|
3062
|
-
appId:
|
|
3063
|
-
tenantSlug:
|
|
3198
|
+
token: f || l.get("token") || "",
|
|
3199
|
+
email: b || l.get("email") || "",
|
|
3200
|
+
appId: u || l.get("appId") || "",
|
|
3201
|
+
tenantSlug: w || l.get("tenantSlug") || void 0
|
|
3064
3202
|
};
|
|
3065
3203
|
}, U = async () => {
|
|
3066
|
-
|
|
3204
|
+
M("verifying"), L("");
|
|
3067
3205
|
try {
|
|
3068
|
-
const
|
|
3069
|
-
if (!
|
|
3206
|
+
const l = I();
|
|
3207
|
+
if (!l.token || !l.email)
|
|
3070
3208
|
throw new Error("Missing required parameters: token or email");
|
|
3071
|
-
const
|
|
3072
|
-
token:
|
|
3073
|
-
email:
|
|
3074
|
-
tenantSlug:
|
|
3209
|
+
const N = await P({
|
|
3210
|
+
token: l.token,
|
|
3211
|
+
email: l.email,
|
|
3212
|
+
tenantSlug: l.tenantSlug
|
|
3075
3213
|
});
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
},
|
|
3079
|
-
} catch (
|
|
3080
|
-
const
|
|
3081
|
-
|
|
3214
|
+
M("success"), n == null || n(N), g > 0 && setTimeout(() => {
|
|
3215
|
+
M("redirecting");
|
|
3216
|
+
}, g);
|
|
3217
|
+
} catch (l) {
|
|
3218
|
+
const N = l.message || h.errorMessage;
|
|
3219
|
+
L(N), M("error"), i == null || i(N);
|
|
3082
3220
|
}
|
|
3083
|
-
},
|
|
3221
|
+
}, C = () => {
|
|
3084
3222
|
o == null || o(), U();
|
|
3085
|
-
},
|
|
3223
|
+
}, R = () => {
|
|
3086
3224
|
a == null || a();
|
|
3087
3225
|
};
|
|
3088
|
-
|
|
3226
|
+
X(() => {
|
|
3089
3227
|
U();
|
|
3090
3228
|
}, []);
|
|
3091
|
-
const
|
|
3092
|
-
switch (
|
|
3229
|
+
const B = () => {
|
|
3230
|
+
switch (v) {
|
|
3093
3231
|
case "verifying":
|
|
3094
|
-
return /* @__PURE__ */ d("div", { style:
|
|
3095
|
-
|
|
3096
|
-
|
|
3232
|
+
return /* @__PURE__ */ d("div", { style: x.message, children: [
|
|
3233
|
+
k.loading,
|
|
3234
|
+
h.verifyingMessage
|
|
3097
3235
|
] });
|
|
3098
3236
|
case "success":
|
|
3099
|
-
return /* @__PURE__ */ d(
|
|
3100
|
-
|
|
3101
|
-
/* @__PURE__ */
|
|
3237
|
+
return /* @__PURE__ */ d(_, { children: [
|
|
3238
|
+
k.success,
|
|
3239
|
+
/* @__PURE__ */ s("div", { style: x.successMessage, children: h.successMessage })
|
|
3102
3240
|
] });
|
|
3103
3241
|
case "redirecting":
|
|
3104
|
-
return /* @__PURE__ */ d(
|
|
3105
|
-
|
|
3106
|
-
/* @__PURE__ */
|
|
3242
|
+
return /* @__PURE__ */ d(_, { children: [
|
|
3243
|
+
k.loading,
|
|
3244
|
+
/* @__PURE__ */ s("div", { style: x.message, children: h.redirectingMessage })
|
|
3107
3245
|
] });
|
|
3108
3246
|
case "error":
|
|
3109
|
-
return /* @__PURE__ */ d(
|
|
3110
|
-
|
|
3111
|
-
/* @__PURE__ */
|
|
3112
|
-
/* @__PURE__ */ d("div", { style:
|
|
3113
|
-
/* @__PURE__ */
|
|
3247
|
+
return /* @__PURE__ */ d(_, { children: [
|
|
3248
|
+
k.error,
|
|
3249
|
+
/* @__PURE__ */ s("div", { style: x.errorMessage, children: F || h.errorMessage }),
|
|
3250
|
+
/* @__PURE__ */ d("div", { style: x.buttonContainer, children: [
|
|
3251
|
+
/* @__PURE__ */ s(
|
|
3114
3252
|
"button",
|
|
3115
3253
|
{
|
|
3116
|
-
onClick:
|
|
3117
|
-
style:
|
|
3118
|
-
onMouseOver: (
|
|
3119
|
-
|
|
3254
|
+
onClick: C,
|
|
3255
|
+
style: x.retryButton,
|
|
3256
|
+
onMouseOver: (l) => {
|
|
3257
|
+
l.currentTarget.style.backgroundColor = "#2563eb";
|
|
3120
3258
|
},
|
|
3121
|
-
onMouseOut: (
|
|
3122
|
-
|
|
3259
|
+
onMouseOut: (l) => {
|
|
3260
|
+
l.currentTarget.style.backgroundColor = "#3b82f6";
|
|
3123
3261
|
},
|
|
3124
|
-
children:
|
|
3262
|
+
children: h.retryButton
|
|
3125
3263
|
}
|
|
3126
3264
|
),
|
|
3127
|
-
/* @__PURE__ */
|
|
3265
|
+
/* @__PURE__ */ s(
|
|
3128
3266
|
"button",
|
|
3129
3267
|
{
|
|
3130
|
-
onClick:
|
|
3131
|
-
style:
|
|
3132
|
-
onMouseOver: (
|
|
3133
|
-
|
|
3268
|
+
onClick: R,
|
|
3269
|
+
style: x.backButton,
|
|
3270
|
+
onMouseOver: (l) => {
|
|
3271
|
+
l.currentTarget.style.backgroundColor = "#e5e7eb";
|
|
3134
3272
|
},
|
|
3135
|
-
onMouseOut: (
|
|
3136
|
-
|
|
3273
|
+
onMouseOut: (l) => {
|
|
3274
|
+
l.currentTarget.style.backgroundColor = "#f3f4f6";
|
|
3137
3275
|
},
|
|
3138
|
-
children:
|
|
3276
|
+
children: h.backToLoginButton
|
|
3139
3277
|
}
|
|
3140
3278
|
)
|
|
3141
3279
|
] })
|
|
@@ -3144,18 +3282,18 @@ function ur({
|
|
|
3144
3282
|
return null;
|
|
3145
3283
|
}
|
|
3146
3284
|
};
|
|
3147
|
-
return /* @__PURE__ */ d("div", { style:
|
|
3148
|
-
/* @__PURE__ */
|
|
3285
|
+
return /* @__PURE__ */ d("div", { style: x.container, className: p, children: [
|
|
3286
|
+
/* @__PURE__ */ s("style", { children: `
|
|
3149
3287
|
@keyframes spin {
|
|
3150
3288
|
0% { transform: rotate(0deg); }
|
|
3151
3289
|
100% { transform: rotate(360deg); }
|
|
3152
3290
|
}
|
|
3153
3291
|
` }),
|
|
3154
|
-
/* @__PURE__ */
|
|
3155
|
-
|
|
3292
|
+
/* @__PURE__ */ s("h1", { style: x.title, children: h.title }),
|
|
3293
|
+
B()
|
|
3156
3294
|
] });
|
|
3157
3295
|
}
|
|
3158
|
-
const
|
|
3296
|
+
const Yt = {
|
|
3159
3297
|
title: "Reset Password",
|
|
3160
3298
|
subtitle: "Enter your email address and we'll send you a link to reset your password.",
|
|
3161
3299
|
emailLabel: "Email",
|
|
@@ -3177,7 +3315,7 @@ const Ht = {
|
|
|
3177
3315
|
resetLoadingText: "Resetting...",
|
|
3178
3316
|
resetSuccessMessage: "Password reset successfully!",
|
|
3179
3317
|
passwordMismatchError: "Passwords do not match"
|
|
3180
|
-
},
|
|
3318
|
+
}, Qt = {
|
|
3181
3319
|
container: {
|
|
3182
3320
|
maxWidth: "400px",
|
|
3183
3321
|
margin: "0 auto",
|
|
@@ -3269,186 +3407,186 @@ const Ht = {
|
|
|
3269
3407
|
cursor: "pointer"
|
|
3270
3408
|
}
|
|
3271
3409
|
};
|
|
3272
|
-
function
|
|
3273
|
-
copy:
|
|
3410
|
+
function Hn({
|
|
3411
|
+
copy: r = {},
|
|
3274
3412
|
styles: e = {},
|
|
3275
3413
|
mode: t = "request",
|
|
3276
|
-
token:
|
|
3277
|
-
onSuccess:
|
|
3414
|
+
token: n = "",
|
|
3415
|
+
onSuccess: i,
|
|
3278
3416
|
onError: o,
|
|
3279
3417
|
onBackToLogin: a,
|
|
3280
|
-
onModeChange:
|
|
3281
|
-
className:
|
|
3418
|
+
onModeChange: p,
|
|
3419
|
+
className: f
|
|
3282
3420
|
}) {
|
|
3283
|
-
const [b,
|
|
3284
|
-
const
|
|
3285
|
-
return b.trim() || (
|
|
3286
|
-
},
|
|
3287
|
-
const
|
|
3288
|
-
return
|
|
3289
|
-
},
|
|
3290
|
-
if (
|
|
3291
|
-
if (!(
|
|
3292
|
-
|
|
3421
|
+
const [b, u] = A(""), [w, g] = A(n), [v, M] = A(""), [F, L] = A(""), [P, h] = A(!1), [x, k] = A(""), [I, U] = A(""), [C, R] = A({}), { requestPasswordReset: B, confirmPasswordReset: l } = le(), { tenant: N } = he(), D = { ...Yt, ...r }, c = { ...Qt, ...e }, $ = () => {
|
|
3422
|
+
const q = {};
|
|
3423
|
+
return b.trim() || (q.email = !0), R(q), Object.keys(q).length === 0;
|
|
3424
|
+
}, E = () => {
|
|
3425
|
+
const q = {};
|
|
3426
|
+
return w.trim() || (q.token = !0), v.trim() || (q.newPassword = !0), F.trim() || (q.confirmPassword = !0), R(q), Object.keys(q).length === 0;
|
|
3427
|
+
}, y = async (q) => {
|
|
3428
|
+
if (q.preventDefault(), !!$()) {
|
|
3429
|
+
if (!(N != null && N.id)) {
|
|
3430
|
+
k("Tenant not found");
|
|
3293
3431
|
return;
|
|
3294
3432
|
}
|
|
3295
|
-
|
|
3433
|
+
h(!0), k(""), U("");
|
|
3296
3434
|
try {
|
|
3297
|
-
await
|
|
3298
|
-
} catch (
|
|
3299
|
-
const V =
|
|
3300
|
-
|
|
3435
|
+
await B({ email: b, tenantId: N.id }), U(D.successMessage), i == null || i();
|
|
3436
|
+
} catch (O) {
|
|
3437
|
+
const V = O.message || D.errorMessage;
|
|
3438
|
+
k(V), o == null || o(V);
|
|
3301
3439
|
} finally {
|
|
3302
|
-
|
|
3440
|
+
h(!1);
|
|
3303
3441
|
}
|
|
3304
3442
|
}
|
|
3305
|
-
},
|
|
3306
|
-
if (
|
|
3307
|
-
if (
|
|
3308
|
-
|
|
3443
|
+
}, m = async (q) => {
|
|
3444
|
+
if (q.preventDefault(), !!E()) {
|
|
3445
|
+
if (v !== F) {
|
|
3446
|
+
k(D.passwordMismatchError), R({ confirmPassword: !0 });
|
|
3309
3447
|
return;
|
|
3310
3448
|
}
|
|
3311
|
-
|
|
3449
|
+
h(!0), k(""), U("");
|
|
3312
3450
|
try {
|
|
3313
|
-
await
|
|
3314
|
-
} catch (
|
|
3315
|
-
const V =
|
|
3316
|
-
|
|
3451
|
+
await l({ token: w, newPassword: v }), U(D.resetSuccessMessage), i == null || i();
|
|
3452
|
+
} catch (O) {
|
|
3453
|
+
const V = O.message || D.errorMessage;
|
|
3454
|
+
k(V), o == null || o(V);
|
|
3317
3455
|
} finally {
|
|
3318
|
-
|
|
3456
|
+
h(!1);
|
|
3319
3457
|
}
|
|
3320
3458
|
}
|
|
3321
|
-
},
|
|
3322
|
-
...
|
|
3323
|
-
...
|
|
3324
|
-
}),
|
|
3325
|
-
...
|
|
3326
|
-
...
|
|
3459
|
+
}, S = (q) => ({
|
|
3460
|
+
...c.input,
|
|
3461
|
+
...C[q] ? c.inputError : {}
|
|
3462
|
+
}), G = () => ({
|
|
3463
|
+
...c.button,
|
|
3464
|
+
...P ? c.buttonLoading : {}
|
|
3327
3465
|
});
|
|
3328
3466
|
if (t === "reset") {
|
|
3329
|
-
const
|
|
3330
|
-
return /* @__PURE__ */ d("div", { className:
|
|
3331
|
-
/* @__PURE__ */
|
|
3332
|
-
/* @__PURE__ */
|
|
3333
|
-
/* @__PURE__ */ d("form", { onSubmit:
|
|
3334
|
-
/* @__PURE__ */ d("div", { style:
|
|
3335
|
-
/* @__PURE__ */
|
|
3336
|
-
/* @__PURE__ */
|
|
3467
|
+
const q = w && v && F;
|
|
3468
|
+
return /* @__PURE__ */ d("div", { className: f, style: c.container, children: [
|
|
3469
|
+
/* @__PURE__ */ s("h2", { style: c.title, children: D.resetTitle }),
|
|
3470
|
+
/* @__PURE__ */ s("p", { style: c.subtitle, children: D.resetSubtitle }),
|
|
3471
|
+
/* @__PURE__ */ d("form", { onSubmit: m, style: c.form, children: [
|
|
3472
|
+
/* @__PURE__ */ d("div", { style: c.fieldGroup, children: [
|
|
3473
|
+
/* @__PURE__ */ s("label", { style: c.label, children: D.tokenLabel }),
|
|
3474
|
+
/* @__PURE__ */ s(
|
|
3337
3475
|
"input",
|
|
3338
3476
|
{
|
|
3339
3477
|
type: "text",
|
|
3340
|
-
value:
|
|
3341
|
-
onChange: (
|
|
3342
|
-
|
|
3478
|
+
value: w,
|
|
3479
|
+
onChange: (O) => {
|
|
3480
|
+
g(O.target.value), C.token && R((V) => ({ ...V, token: !1 }));
|
|
3343
3481
|
},
|
|
3344
|
-
placeholder:
|
|
3345
|
-
style:
|
|
3346
|
-
disabled:
|
|
3482
|
+
placeholder: D.tokenPlaceholder,
|
|
3483
|
+
style: S("token"),
|
|
3484
|
+
disabled: P
|
|
3347
3485
|
}
|
|
3348
3486
|
)
|
|
3349
3487
|
] }),
|
|
3350
|
-
/* @__PURE__ */ d("div", { style:
|
|
3351
|
-
/* @__PURE__ */
|
|
3352
|
-
/* @__PURE__ */
|
|
3488
|
+
/* @__PURE__ */ d("div", { style: c.fieldGroup, children: [
|
|
3489
|
+
/* @__PURE__ */ s("label", { style: c.label, children: D.newPasswordLabel }),
|
|
3490
|
+
/* @__PURE__ */ s(
|
|
3353
3491
|
"input",
|
|
3354
3492
|
{
|
|
3355
3493
|
type: "password",
|
|
3356
|
-
value:
|
|
3357
|
-
onChange: (
|
|
3358
|
-
|
|
3494
|
+
value: v,
|
|
3495
|
+
onChange: (O) => {
|
|
3496
|
+
M(O.target.value), C.newPassword && R((V) => ({ ...V, newPassword: !1 }));
|
|
3359
3497
|
},
|
|
3360
|
-
placeholder:
|
|
3361
|
-
style:
|
|
3362
|
-
disabled:
|
|
3498
|
+
placeholder: D.newPasswordPlaceholder,
|
|
3499
|
+
style: S("newPassword"),
|
|
3500
|
+
disabled: P
|
|
3363
3501
|
}
|
|
3364
3502
|
)
|
|
3365
3503
|
] }),
|
|
3366
|
-
/* @__PURE__ */ d("div", { style:
|
|
3367
|
-
/* @__PURE__ */
|
|
3368
|
-
/* @__PURE__ */
|
|
3504
|
+
/* @__PURE__ */ d("div", { style: c.fieldGroup, children: [
|
|
3505
|
+
/* @__PURE__ */ s("label", { style: c.label, children: D.confirmPasswordLabel }),
|
|
3506
|
+
/* @__PURE__ */ s(
|
|
3369
3507
|
"input",
|
|
3370
3508
|
{
|
|
3371
3509
|
type: "password",
|
|
3372
|
-
value:
|
|
3373
|
-
onChange: (
|
|
3374
|
-
|
|
3510
|
+
value: F,
|
|
3511
|
+
onChange: (O) => {
|
|
3512
|
+
L(O.target.value), C.confirmPassword && R((V) => ({ ...V, confirmPassword: !1 })), x === D.passwordMismatchError && k("");
|
|
3375
3513
|
},
|
|
3376
|
-
placeholder:
|
|
3377
|
-
style:
|
|
3378
|
-
disabled:
|
|
3514
|
+
placeholder: D.confirmPasswordPlaceholder,
|
|
3515
|
+
style: S("confirmPassword"),
|
|
3516
|
+
disabled: P
|
|
3379
3517
|
}
|
|
3380
3518
|
)
|
|
3381
3519
|
] }),
|
|
3382
|
-
/* @__PURE__ */
|
|
3520
|
+
/* @__PURE__ */ s(
|
|
3383
3521
|
"button",
|
|
3384
3522
|
{
|
|
3385
3523
|
type: "submit",
|
|
3386
|
-
disabled: !
|
|
3524
|
+
disabled: !q || P,
|
|
3387
3525
|
style: {
|
|
3388
|
-
...
|
|
3389
|
-
...!
|
|
3526
|
+
...G(),
|
|
3527
|
+
...!q || P ? c.buttonDisabled : {}
|
|
3390
3528
|
},
|
|
3391
|
-
children:
|
|
3529
|
+
children: P ? D.resetLoadingText : D.resetSubmitButton
|
|
3392
3530
|
}
|
|
3393
3531
|
),
|
|
3394
|
-
|
|
3395
|
-
|
|
3532
|
+
x && /* @__PURE__ */ s("div", { style: c.errorText, children: x }),
|
|
3533
|
+
I && /* @__PURE__ */ s("div", { style: c.successText, children: I })
|
|
3396
3534
|
] }),
|
|
3397
|
-
/* @__PURE__ */ d("div", { style:
|
|
3398
|
-
/* @__PURE__ */
|
|
3399
|
-
|
|
3400
|
-
/* @__PURE__ */
|
|
3401
|
-
/* @__PURE__ */
|
|
3535
|
+
/* @__PURE__ */ d("div", { style: c.linkContainer, children: [
|
|
3536
|
+
/* @__PURE__ */ s("a", { onClick: a, style: c.link, children: D.backToLoginLink }),
|
|
3537
|
+
p && /* @__PURE__ */ d(_, { children: [
|
|
3538
|
+
/* @__PURE__ */ s("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3539
|
+
/* @__PURE__ */ s("a", { onClick: () => p("request"), style: c.link, children: "Request New Link" })
|
|
3402
3540
|
] })
|
|
3403
3541
|
] })
|
|
3404
3542
|
] });
|
|
3405
3543
|
}
|
|
3406
|
-
const
|
|
3407
|
-
return /* @__PURE__ */ d("div", { className:
|
|
3408
|
-
/* @__PURE__ */
|
|
3409
|
-
/* @__PURE__ */
|
|
3410
|
-
/* @__PURE__ */ d("form", { onSubmit:
|
|
3411
|
-
/* @__PURE__ */ d("div", { style:
|
|
3412
|
-
/* @__PURE__ */
|
|
3413
|
-
/* @__PURE__ */
|
|
3544
|
+
const J = b;
|
|
3545
|
+
return /* @__PURE__ */ d("div", { className: f, style: c.container, children: [
|
|
3546
|
+
/* @__PURE__ */ s("h2", { style: c.title, children: D.title }),
|
|
3547
|
+
/* @__PURE__ */ s("p", { style: c.subtitle, children: D.subtitle }),
|
|
3548
|
+
/* @__PURE__ */ d("form", { onSubmit: y, style: c.form, children: [
|
|
3549
|
+
/* @__PURE__ */ d("div", { style: c.fieldGroup, children: [
|
|
3550
|
+
/* @__PURE__ */ s("label", { style: c.label, children: D.emailLabel }),
|
|
3551
|
+
/* @__PURE__ */ s(
|
|
3414
3552
|
"input",
|
|
3415
3553
|
{
|
|
3416
3554
|
type: "email",
|
|
3417
3555
|
value: b,
|
|
3418
|
-
onChange: (
|
|
3419
|
-
|
|
3556
|
+
onChange: (q) => {
|
|
3557
|
+
u(q.target.value), C.email && R((O) => ({ ...O, email: !1 }));
|
|
3420
3558
|
},
|
|
3421
|
-
placeholder:
|
|
3422
|
-
style:
|
|
3423
|
-
disabled:
|
|
3559
|
+
placeholder: D.emailPlaceholder,
|
|
3560
|
+
style: S("email"),
|
|
3561
|
+
disabled: P
|
|
3424
3562
|
}
|
|
3425
3563
|
)
|
|
3426
3564
|
] }),
|
|
3427
|
-
/* @__PURE__ */
|
|
3565
|
+
/* @__PURE__ */ s(
|
|
3428
3566
|
"button",
|
|
3429
3567
|
{
|
|
3430
3568
|
type: "submit",
|
|
3431
|
-
disabled: !
|
|
3569
|
+
disabled: !J || P,
|
|
3432
3570
|
style: {
|
|
3433
|
-
...
|
|
3434
|
-
...!
|
|
3571
|
+
...G(),
|
|
3572
|
+
...!J || P ? c.buttonDisabled : {}
|
|
3435
3573
|
},
|
|
3436
|
-
children:
|
|
3574
|
+
children: P ? D.loadingText : D.submitButton
|
|
3437
3575
|
}
|
|
3438
3576
|
),
|
|
3439
|
-
|
|
3440
|
-
|
|
3577
|
+
x && /* @__PURE__ */ s("div", { style: c.errorText, children: x }),
|
|
3578
|
+
I && /* @__PURE__ */ s("div", { style: c.successText, children: I })
|
|
3441
3579
|
] }),
|
|
3442
|
-
/* @__PURE__ */ d("div", { style:
|
|
3443
|
-
/* @__PURE__ */
|
|
3444
|
-
|
|
3445
|
-
/* @__PURE__ */
|
|
3446
|
-
/* @__PURE__ */
|
|
3580
|
+
/* @__PURE__ */ d("div", { style: c.linkContainer, children: [
|
|
3581
|
+
/* @__PURE__ */ s("a", { onClick: a, style: c.link, children: D.backToLoginLink }),
|
|
3582
|
+
p && /* @__PURE__ */ d(_, { children: [
|
|
3583
|
+
/* @__PURE__ */ s("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3584
|
+
/* @__PURE__ */ s("a", { onClick: () => p("reset"), style: c.link, children: "I have a token" })
|
|
3447
3585
|
] })
|
|
3448
3586
|
] })
|
|
3449
3587
|
] });
|
|
3450
3588
|
}
|
|
3451
|
-
const
|
|
3589
|
+
const Xt = () => /* @__PURE__ */ s(
|
|
3452
3590
|
"div",
|
|
3453
3591
|
{
|
|
3454
3592
|
style: {
|
|
@@ -3458,9 +3596,9 @@ const Ut = () => /* @__PURE__ */ n(
|
|
|
3458
3596
|
height: "100vh",
|
|
3459
3597
|
fontFamily: "system-ui, sans-serif"
|
|
3460
3598
|
},
|
|
3461
|
-
children: /* @__PURE__ */
|
|
3599
|
+
children: /* @__PURE__ */ s("div", { children: "Loading..." })
|
|
3462
3600
|
}
|
|
3463
|
-
),
|
|
3601
|
+
), en = ({ error: r, retry: e }) => /* @__PURE__ */ d(
|
|
3464
3602
|
"div",
|
|
3465
3603
|
{
|
|
3466
3604
|
style: {
|
|
@@ -3474,9 +3612,9 @@ const Ut = () => /* @__PURE__ */ n(
|
|
|
3474
3612
|
padding: "20px"
|
|
3475
3613
|
},
|
|
3476
3614
|
children: [
|
|
3477
|
-
/* @__PURE__ */
|
|
3478
|
-
/* @__PURE__ */
|
|
3479
|
-
/* @__PURE__ */
|
|
3615
|
+
/* @__PURE__ */ s("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Error" }),
|
|
3616
|
+
/* @__PURE__ */ s("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: r.message || "Unable to load application" }),
|
|
3617
|
+
/* @__PURE__ */ s(
|
|
3480
3618
|
"button",
|
|
3481
3619
|
{
|
|
3482
3620
|
onClick: e,
|
|
@@ -3494,98 +3632,98 @@ const Ut = () => /* @__PURE__ */ n(
|
|
|
3494
3632
|
]
|
|
3495
3633
|
}
|
|
3496
3634
|
);
|
|
3497
|
-
function
|
|
3498
|
-
children:
|
|
3635
|
+
function Bn({
|
|
3636
|
+
children: r,
|
|
3499
3637
|
loadingFallback: e,
|
|
3500
3638
|
errorFallback: t,
|
|
3501
|
-
requireTenant:
|
|
3639
|
+
requireTenant: n = !0
|
|
3502
3640
|
}) {
|
|
3503
|
-
const { isAppLoading:
|
|
3504
|
-
}),
|
|
3505
|
-
o && a(),
|
|
3641
|
+
const { isAppLoading: i, appError: o, retryApp: a } = ye(), p = Se(), f = Le(), b = We(), u = Ve(), w = (p == null ? void 0 : p.isTenantLoading) ?? !1, g = (p == null ? void 0 : p.tenantError) ?? null, v = (p == null ? void 0 : p.tenantSlug) ?? null, M = (p == null ? void 0 : p.retryTenant) ?? (() => {
|
|
3642
|
+
}), F = (f == null ? void 0 : f.isAuthReady) ?? !0, L = (b == null ? void 0 : b.isReady) ?? !0, P = (u == null ? void 0 : u.isReady) ?? !0, h = n && p && v, U = i || h && w || f && !F || b && !L || u && !P, C = o || (h ? g : null), R = () => {
|
|
3643
|
+
o && a(), g && p && M();
|
|
3506
3644
|
};
|
|
3507
3645
|
if (U)
|
|
3508
|
-
return /* @__PURE__ */
|
|
3509
|
-
if (
|
|
3510
|
-
const
|
|
3511
|
-
return /* @__PURE__ */
|
|
3646
|
+
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(Xt, {}) });
|
|
3647
|
+
if (C) {
|
|
3648
|
+
const B = typeof t == "function" ? t(C, R) : t || /* @__PURE__ */ s(en, { error: C, retry: R });
|
|
3649
|
+
return /* @__PURE__ */ s(_, { children: B });
|
|
3512
3650
|
}
|
|
3513
|
-
return /* @__PURE__ */
|
|
3651
|
+
return /* @__PURE__ */ s(_, { children: r });
|
|
3514
3652
|
}
|
|
3515
|
-
function
|
|
3516
|
-
const { isAppLoading: e, appError: t, retryApp:
|
|
3517
|
-
}),
|
|
3653
|
+
function qn(r = !0) {
|
|
3654
|
+
const { isAppLoading: e, appError: t, retryApp: n, appInfo: i } = ye(), o = Se(), a = Le(), p = We(), f = Ve(), b = (o == null ? void 0 : o.isTenantLoading) ?? !1, u = (o == null ? void 0 : o.tenantError) ?? null, w = (o == null ? void 0 : o.tenant) ?? null, g = (o == null ? void 0 : o.tenantSlug) ?? null, v = (o == null ? void 0 : o.retryTenant) ?? (() => {
|
|
3655
|
+
}), M = (a == null ? void 0 : a.isAuthReady) ?? !0, F = (p == null ? void 0 : p.isReady) ?? !0, L = (f == null ? void 0 : f.isReady) ?? !0, P = r && o && g, I = e || P && b || a && !M || p && !F || f && !L, U = t || (P ? u : null);
|
|
3518
3656
|
return {
|
|
3519
|
-
isLoading:
|
|
3657
|
+
isLoading: I,
|
|
3520
3658
|
error: U,
|
|
3521
|
-
isReady: !
|
|
3659
|
+
isReady: !I && !U && i !== null && (!P || w !== null),
|
|
3522
3660
|
retry: () => {
|
|
3523
|
-
t &&
|
|
3661
|
+
t && n(), u && o && v();
|
|
3524
3662
|
},
|
|
3525
3663
|
// Individual states
|
|
3526
|
-
app: { isLoading: e, error: t, data:
|
|
3527
|
-
tenant: o ? { isLoading: b, error:
|
|
3528
|
-
auth: a ? { isReady:
|
|
3529
|
-
featureFlags:
|
|
3530
|
-
subscription:
|
|
3664
|
+
app: { isLoading: e, error: t, data: i },
|
|
3665
|
+
tenant: o ? { isLoading: b, error: u, data: w } : null,
|
|
3666
|
+
auth: a ? { isReady: M } : null,
|
|
3667
|
+
featureFlags: p ? { isReady: F } : null,
|
|
3668
|
+
subscription: f ? { isReady: L } : null
|
|
3531
3669
|
};
|
|
3532
3670
|
}
|
|
3533
|
-
function
|
|
3534
|
-
tenants:
|
|
3671
|
+
function On({
|
|
3672
|
+
tenants: r,
|
|
3535
3673
|
currentTenantId: e,
|
|
3536
3674
|
onSelect: t,
|
|
3537
|
-
className:
|
|
3538
|
-
dropdownClassName:
|
|
3675
|
+
className: n = "",
|
|
3676
|
+
dropdownClassName: i = "",
|
|
3539
3677
|
itemClassName: o = "",
|
|
3540
3678
|
renderItem: a,
|
|
3541
|
-
placeholder:
|
|
3542
|
-
disabled:
|
|
3679
|
+
placeholder: p = "Select tenant",
|
|
3680
|
+
disabled: f = !1,
|
|
3543
3681
|
showCurrentTenant: b = !0
|
|
3544
3682
|
}) {
|
|
3545
|
-
var
|
|
3546
|
-
const
|
|
3547
|
-
|
|
3683
|
+
var x;
|
|
3684
|
+
const u = Le(), [w, g] = A(!1), v = ze(null), M = r ?? (u == null ? void 0 : u.userTenants) ?? [], F = e ?? ((x = u == null ? void 0 : u.currentUser) == null ? void 0 : x.tenantId) ?? null, L = async (k) => {
|
|
3685
|
+
g(!1), t ? t(k) : u != null && u.switchToTenant && await u.switchToTenant(k);
|
|
3548
3686
|
};
|
|
3549
|
-
|
|
3550
|
-
const
|
|
3551
|
-
|
|
3687
|
+
X(() => {
|
|
3688
|
+
const k = (I) => {
|
|
3689
|
+
v.current && !v.current.contains(I.target) && g(!1);
|
|
3552
3690
|
};
|
|
3553
|
-
return document.addEventListener("mousedown",
|
|
3691
|
+
return document.addEventListener("mousedown", k), () => document.removeEventListener("mousedown", k);
|
|
3554
3692
|
}, []);
|
|
3555
|
-
const
|
|
3556
|
-
if (
|
|
3693
|
+
const P = M.find((k) => k.id === F);
|
|
3694
|
+
if (M.length === 0)
|
|
3557
3695
|
return null;
|
|
3558
|
-
if (
|
|
3559
|
-
return /* @__PURE__ */
|
|
3560
|
-
const
|
|
3561
|
-
|
|
3562
|
-
|
|
3696
|
+
if (M.length === 1 && b)
|
|
3697
|
+
return /* @__PURE__ */ s("div", { className: n, children: /* @__PURE__ */ s("span", { children: M[0].name }) });
|
|
3698
|
+
const h = (k, I) => /* @__PURE__ */ d("span", { style: { fontWeight: I ? "bold" : "normal" }, children: [
|
|
3699
|
+
k.name,
|
|
3700
|
+
k.role && /* @__PURE__ */ d("span", { style: { opacity: 0.7, marginLeft: 8 }, children: [
|
|
3563
3701
|
"(",
|
|
3564
|
-
|
|
3702
|
+
k.role,
|
|
3565
3703
|
")"
|
|
3566
3704
|
] })
|
|
3567
3705
|
] });
|
|
3568
|
-
return /* @__PURE__ */ d("div", { ref:
|
|
3706
|
+
return /* @__PURE__ */ d("div", { ref: v, className: n, style: { position: "relative" }, children: [
|
|
3569
3707
|
/* @__PURE__ */ d(
|
|
3570
3708
|
"button",
|
|
3571
3709
|
{
|
|
3572
3710
|
type: "button",
|
|
3573
|
-
onClick: () => !
|
|
3574
|
-
disabled:
|
|
3711
|
+
onClick: () => !f && g(!w),
|
|
3712
|
+
disabled: f,
|
|
3575
3713
|
style: {
|
|
3576
|
-
cursor:
|
|
3577
|
-
opacity:
|
|
3714
|
+
cursor: f ? "not-allowed" : "pointer",
|
|
3715
|
+
opacity: f ? 0.6 : 1
|
|
3578
3716
|
},
|
|
3579
3717
|
children: [
|
|
3580
|
-
|
|
3581
|
-
/* @__PURE__ */
|
|
3718
|
+
P ? P.name : p,
|
|
3719
|
+
/* @__PURE__ */ s("span", { style: { marginLeft: 8 }, children: w ? "▲" : "▼" })
|
|
3582
3720
|
]
|
|
3583
3721
|
}
|
|
3584
3722
|
),
|
|
3585
|
-
|
|
3723
|
+
w && /* @__PURE__ */ s(
|
|
3586
3724
|
"div",
|
|
3587
3725
|
{
|
|
3588
|
-
className:
|
|
3726
|
+
className: i,
|
|
3589
3727
|
style: {
|
|
3590
3728
|
position: "absolute",
|
|
3591
3729
|
top: "100%",
|
|
@@ -3599,34 +3737,34 @@ function fr({
|
|
|
3599
3737
|
maxHeight: 300,
|
|
3600
3738
|
overflowY: "auto"
|
|
3601
3739
|
},
|
|
3602
|
-
children:
|
|
3603
|
-
const
|
|
3604
|
-
return /* @__PURE__ */
|
|
3740
|
+
children: M.map((k) => {
|
|
3741
|
+
const I = k.id === F;
|
|
3742
|
+
return /* @__PURE__ */ s(
|
|
3605
3743
|
"div",
|
|
3606
3744
|
{
|
|
3607
3745
|
className: o,
|
|
3608
|
-
onClick: () =>
|
|
3746
|
+
onClick: () => L(k.id),
|
|
3609
3747
|
style: {
|
|
3610
3748
|
padding: "8px 12px",
|
|
3611
3749
|
cursor: "pointer",
|
|
3612
|
-
backgroundColor:
|
|
3750
|
+
backgroundColor: I ? "#f0f0f0" : "transparent"
|
|
3613
3751
|
},
|
|
3614
3752
|
onMouseEnter: (U) => {
|
|
3615
|
-
|
|
3753
|
+
I || (U.target.style.backgroundColor = "#f5f5f5");
|
|
3616
3754
|
},
|
|
3617
3755
|
onMouseLeave: (U) => {
|
|
3618
|
-
|
|
3756
|
+
I || (U.target.style.backgroundColor = "transparent");
|
|
3619
3757
|
},
|
|
3620
|
-
children: a ? a(
|
|
3758
|
+
children: a ? a(k, I) : h(k, I)
|
|
3621
3759
|
},
|
|
3622
|
-
|
|
3760
|
+
k.id
|
|
3623
3761
|
);
|
|
3624
3762
|
})
|
|
3625
3763
|
}
|
|
3626
3764
|
)
|
|
3627
3765
|
] });
|
|
3628
3766
|
}
|
|
3629
|
-
class
|
|
3767
|
+
class zn {
|
|
3630
3768
|
constructor(e, t) {
|
|
3631
3769
|
this.httpService = e, this.sessionManager = t;
|
|
3632
3770
|
}
|
|
@@ -3645,9 +3783,9 @@ class mr {
|
|
|
3645
3783
|
async getPermissions(e) {
|
|
3646
3784
|
if (!this.sessionManager)
|
|
3647
3785
|
throw new Error("SessionManager is required for private endpoints");
|
|
3648
|
-
const t = await this.sessionManager.getAuthHeaders(),
|
|
3649
|
-
e != null && e.page &&
|
|
3650
|
-
const
|
|
3786
|
+
const t = await this.sessionManager.getAuthHeaders(), n = new URLSearchParams();
|
|
3787
|
+
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 i = `/permissions/${n.toString() ? `?${n.toString()}` : ""}`, o = await this.httpService.get(i, {
|
|
3651
3789
|
headers: t
|
|
3652
3790
|
});
|
|
3653
3791
|
return {
|
|
@@ -3666,12 +3804,12 @@ class mr {
|
|
|
3666
3804
|
async updatePermission(e, t) {
|
|
3667
3805
|
if (!this.sessionManager)
|
|
3668
3806
|
throw new Error("SessionManager is required for private endpoints");
|
|
3669
|
-
const
|
|
3807
|
+
const n = await this.sessionManager.getAuthHeaders();
|
|
3670
3808
|
return (await this.httpService.put(
|
|
3671
3809
|
`/permissions/${e}`,
|
|
3672
3810
|
t,
|
|
3673
3811
|
{
|
|
3674
|
-
headers:
|
|
3812
|
+
headers: n
|
|
3675
3813
|
}
|
|
3676
3814
|
)).data;
|
|
3677
3815
|
}
|
|
@@ -3685,16 +3823,16 @@ class mr {
|
|
|
3685
3823
|
}
|
|
3686
3824
|
// Public endpoint - no auth required
|
|
3687
3825
|
async getAppPermissions(e, t) {
|
|
3688
|
-
const
|
|
3689
|
-
t != null && t.page &&
|
|
3690
|
-
const
|
|
3826
|
+
const n = new URLSearchParams();
|
|
3827
|
+
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 i = `/permissions/apps/${e}${n.toString() ? `?${n.toString()}` : ""}`, o = await this.httpService.get(i);
|
|
3691
3829
|
return {
|
|
3692
3830
|
permissions: o.data,
|
|
3693
3831
|
meta: o.meta
|
|
3694
3832
|
};
|
|
3695
3833
|
}
|
|
3696
3834
|
}
|
|
3697
|
-
class
|
|
3835
|
+
class _n {
|
|
3698
3836
|
constructor(e, t) {
|
|
3699
3837
|
this.httpService = e, this.sessionManager = t;
|
|
3700
3838
|
}
|
|
@@ -3709,9 +3847,9 @@ class yr {
|
|
|
3709
3847
|
)).data;
|
|
3710
3848
|
}
|
|
3711
3849
|
async getSubscriptionPlans(e) {
|
|
3712
|
-
const t = await this.sessionManager.getAuthHeaders(),
|
|
3713
|
-
e != null && e.page &&
|
|
3714
|
-
const
|
|
3850
|
+
const t = await this.sessionManager.getAuthHeaders(), n = new URLSearchParams();
|
|
3851
|
+
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 i = `/subscription-plans/${n.toString() ? `?${n.toString()}` : ""}`, o = await this.httpService.get(i, {
|
|
3715
3853
|
headers: t
|
|
3716
3854
|
});
|
|
3717
3855
|
return {
|
|
@@ -3729,12 +3867,12 @@ class yr {
|
|
|
3729
3867
|
)).data;
|
|
3730
3868
|
}
|
|
3731
3869
|
async updateSubscriptionPlan(e, t) {
|
|
3732
|
-
const
|
|
3870
|
+
const n = await this.sessionManager.getAuthHeaders();
|
|
3733
3871
|
return (await this.httpService.put(
|
|
3734
3872
|
`/subscription-plans/${e}`,
|
|
3735
3873
|
t,
|
|
3736
3874
|
{
|
|
3737
|
-
headers:
|
|
3875
|
+
headers: n
|
|
3738
3876
|
}
|
|
3739
3877
|
)).data;
|
|
3740
3878
|
}
|
|
@@ -3745,7 +3883,7 @@ class yr {
|
|
|
3745
3883
|
});
|
|
3746
3884
|
}
|
|
3747
3885
|
}
|
|
3748
|
-
class
|
|
3886
|
+
class Wn {
|
|
3749
3887
|
constructor(e) {
|
|
3750
3888
|
this.httpService = e;
|
|
3751
3889
|
}
|
|
@@ -3754,7 +3892,7 @@ class wr {
|
|
|
3754
3892
|
return await this.httpService.get("/health");
|
|
3755
3893
|
}
|
|
3756
3894
|
}
|
|
3757
|
-
class
|
|
3895
|
+
class Vn {
|
|
3758
3896
|
// Date string to Date object
|
|
3759
3897
|
static toDate(e) {
|
|
3760
3898
|
return new Date(e);
|
|
@@ -3871,54 +4009,138 @@ class br {
|
|
|
3871
4009
|
// Transform query parameters for API calls
|
|
3872
4010
|
static transformQueryParams(e) {
|
|
3873
4011
|
const t = new URLSearchParams();
|
|
3874
|
-
return Object.entries(e).forEach(([
|
|
3875
|
-
|
|
4012
|
+
return Object.entries(e).forEach(([n, i]) => {
|
|
4013
|
+
i != null && i !== "" && t.append(n, String(i));
|
|
3876
4014
|
}), t;
|
|
3877
4015
|
}
|
|
3878
4016
|
}
|
|
4017
|
+
const Ze = "returnTo", xe = "zone_return_to", Pe = "zone_return_to";
|
|
4018
|
+
function jn(r = {}) {
|
|
4019
|
+
const {
|
|
4020
|
+
zoneRoots: e = {},
|
|
4021
|
+
returnToParam: t = Ze,
|
|
4022
|
+
returnToStorage: n = "url"
|
|
4023
|
+
} = r, i = lt(), [o, a] = ct(), { isAuthenticated: p, currentUser: f } = le(), { tenant: b } = ue(), u = K(() => ({ ...je, ...e }), [e]), w = !!b, g = f == null ? void 0 : f.userType, v = K(() => {
|
|
4024
|
+
switch (n) {
|
|
4025
|
+
case "url":
|
|
4026
|
+
return o.get(t);
|
|
4027
|
+
case "session":
|
|
4028
|
+
return sessionStorage.getItem(xe);
|
|
4029
|
+
case "local":
|
|
4030
|
+
return localStorage.getItem(Pe);
|
|
4031
|
+
default:
|
|
4032
|
+
return null;
|
|
4033
|
+
}
|
|
4034
|
+
}, [n, o, t]), M = re(() => {
|
|
4035
|
+
switch (n) {
|
|
4036
|
+
case "url": {
|
|
4037
|
+
const h = new URLSearchParams(o);
|
|
4038
|
+
h.delete(t), a(h, { replace: !0 });
|
|
4039
|
+
break;
|
|
4040
|
+
}
|
|
4041
|
+
case "session":
|
|
4042
|
+
sessionStorage.removeItem(xe);
|
|
4043
|
+
break;
|
|
4044
|
+
case "local":
|
|
4045
|
+
localStorage.removeItem(Pe);
|
|
4046
|
+
break;
|
|
4047
|
+
}
|
|
4048
|
+
}, [n, o, t, a]), F = re(
|
|
4049
|
+
(h) => {
|
|
4050
|
+
switch (n) {
|
|
4051
|
+
case "url": {
|
|
4052
|
+
const x = new URLSearchParams(o);
|
|
4053
|
+
x.set(t, h), a(x, { replace: !0 });
|
|
4054
|
+
break;
|
|
4055
|
+
}
|
|
4056
|
+
case "session":
|
|
4057
|
+
sessionStorage.setItem(xe, h);
|
|
4058
|
+
break;
|
|
4059
|
+
case "local":
|
|
4060
|
+
localStorage.setItem(Pe, h);
|
|
4061
|
+
break;
|
|
4062
|
+
}
|
|
4063
|
+
},
|
|
4064
|
+
[n, o, t, a]
|
|
4065
|
+
), L = re(
|
|
4066
|
+
(h) => {
|
|
4067
|
+
const x = u[h] || u.default;
|
|
4068
|
+
i(x);
|
|
4069
|
+
},
|
|
4070
|
+
[i, u]
|
|
4071
|
+
), P = re(() => w ? p ? g === se.TENANT_ADMIN ? u.tenantAdmin : u.tenantUser : u.tenantGuest : p ? g === se.TENANT_ADMIN ? u.publicAdmin : u.publicUser : u.publicGuest, [w, p, g, u]);
|
|
4072
|
+
return {
|
|
4073
|
+
returnToUrl: v,
|
|
4074
|
+
clearReturnTo: M,
|
|
4075
|
+
setReturnTo: F,
|
|
4076
|
+
navigateToZone: L,
|
|
4077
|
+
getSmartRedirect: P
|
|
4078
|
+
};
|
|
4079
|
+
}
|
|
4080
|
+
function Gn(r, e, t = Ze, n = "url") {
|
|
4081
|
+
if (!e || n !== "url")
|
|
4082
|
+
return r;
|
|
4083
|
+
const i = new URL(r, window.location.origin);
|
|
4084
|
+
return i.searchParams.set(t, e), i.pathname + i.search;
|
|
4085
|
+
}
|
|
3879
4086
|
export {
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
4087
|
+
Pn as AdminZone,
|
|
4088
|
+
Vn as ApiMappers,
|
|
4089
|
+
Ce as AppApiService,
|
|
4090
|
+
Bn as AppLoader,
|
|
4091
|
+
dn as AppProvider,
|
|
4092
|
+
dt as AuthApiService,
|
|
4093
|
+
fn as AuthProvider,
|
|
4094
|
+
An as AuthenticatedZone,
|
|
4095
|
+
It as DEFAULT_ZONE_PRESETS,
|
|
4096
|
+
je as DEFAULT_ZONE_ROOTS,
|
|
4097
|
+
Nn as FeatureFlag,
|
|
4098
|
+
bt as FeatureFlagApiService,
|
|
4099
|
+
mn as FeatureFlagProvider,
|
|
4100
|
+
xn as GuestZone,
|
|
4101
|
+
Wn as HealthApiService,
|
|
4102
|
+
ie as HttpService,
|
|
4103
|
+
vn as LandingRoute,
|
|
4104
|
+
Un as LoginForm,
|
|
4105
|
+
Dn as MagicLinkForm,
|
|
4106
|
+
$n as MagicLinkVerify,
|
|
4107
|
+
In as OpenZone,
|
|
4108
|
+
Hn as PasswordRecoveryForm,
|
|
4109
|
+
zn as PermissionApiService,
|
|
4110
|
+
wn as Protected,
|
|
4111
|
+
bn as ProtectedRoute,
|
|
4112
|
+
kn as PublicZone,
|
|
4113
|
+
De as RoleApiService,
|
|
4114
|
+
Ae as SessionManager,
|
|
4115
|
+
Cn as SignupForm,
|
|
4116
|
+
vt as SubscriptionApiService,
|
|
4117
|
+
Fn as SubscriptionGuard,
|
|
4118
|
+
_n as SubscriptionPlanApiService,
|
|
4119
|
+
yn as SubscriptionProvider,
|
|
4120
|
+
pe as TenantApiService,
|
|
4121
|
+
Mn as TenantAuthenticatedZone,
|
|
4122
|
+
En as TenantGuestZone,
|
|
4123
|
+
Ln as TenantOpenZone,
|
|
4124
|
+
hn as TenantProvider,
|
|
4125
|
+
Sn as TenantRoute,
|
|
4126
|
+
On as TenantSelector,
|
|
4127
|
+
Tn as TenantZone,
|
|
4128
|
+
ut as UserApiService,
|
|
4129
|
+
se as UserType,
|
|
4130
|
+
Rn as UserZone,
|
|
4131
|
+
ae as ZoneRoute,
|
|
4132
|
+
Gn as buildRedirectUrl,
|
|
4133
|
+
un as useApi,
|
|
4134
|
+
ye as useApp,
|
|
4135
|
+
qn as useAppLoaderState,
|
|
4136
|
+
le as useAuth,
|
|
4137
|
+
St as useFeatureFlags,
|
|
4138
|
+
pn as useSettings,
|
|
4139
|
+
Tt as useSubscription,
|
|
4140
|
+
ue as useTenant,
|
|
4141
|
+
he as useTenantInfo,
|
|
4142
|
+
Se as useTenantOptional,
|
|
4143
|
+
gn as useTenantSettings,
|
|
4144
|
+
jn as useZoneNavigation
|
|
3923
4145
|
};
|
|
3924
4146
|
//# sourceMappingURL=index.es.js.map
|