@skylabs-digital/react-identity-access 1.5.0 → 2.0.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/README.md +203 -42
- package/dist/components/LoginForm.d.ts +7 -3
- package/dist/components/LoginForm.d.ts.map +1 -1
- package/dist/components/MagicLinkForm.d.ts +53 -0
- package/dist/components/MagicLinkForm.d.ts.map +1 -0
- package/dist/components/MagicLinkVerify.d.ts +45 -0
- package/dist/components/MagicLinkVerify.d.ts.map +1 -0
- package/dist/components/SignupForm.d.ts +9 -1
- package/dist/components/SignupForm.d.ts.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +1810 -900
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/providers/AppProvider.d.ts +5 -0
- package/dist/providers/AppProvider.d.ts.map +1 -1
- package/dist/providers/AuthProvider.d.ts +15 -7
- package/dist/providers/AuthProvider.d.ts.map +1 -1
- package/dist/providers/TenantProvider.d.ts +6 -0
- package/dist/providers/TenantProvider.d.ts.map +1 -1
- package/dist/services/AuthApiService.d.ts +6 -3
- package/dist/services/AuthApiService.d.ts.map +1 -1
- package/dist/services/SessionManager.d.ts +22 -0
- package/dist/services/SessionManager.d.ts.map +1 -1
- package/dist/types/api.d.ts +40 -8
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/authParams.d.ts +49 -0
- package/dist/types/authParams.d.ts.map +1 -0
- package/package.json +7 -4
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 n, Fragment as N, jsxs as l } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as de, useMemo as Q, useState as v, useCallback as ne, useEffect as te, useContext as ue } from "react";
|
|
3
|
+
import { useLocation as we, Navigate as pe } from "react-router-dom";
|
|
4
|
+
class re {
|
|
5
5
|
// SessionManager instance
|
|
6
6
|
constructor(e, t = 1e4) {
|
|
7
7
|
this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
|
|
@@ -12,44 +12,44 @@ class G {
|
|
|
12
12
|
getBaseUrl() {
|
|
13
13
|
return this.baseUrl;
|
|
14
14
|
}
|
|
15
|
-
async request(e, t, r,
|
|
16
|
-
return this.executeRequest(e, t, r,
|
|
15
|
+
async request(e, t, r, s) {
|
|
16
|
+
return this.executeRequest(e, t, r, s, !1);
|
|
17
17
|
}
|
|
18
|
-
async executeRequest(e, t, r,
|
|
19
|
-
const
|
|
20
|
-
let
|
|
18
|
+
async executeRequest(e, t, r, s, a = !1) {
|
|
19
|
+
const p = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, I = (s == null ? void 0 : s.timeout) || this.timeout;
|
|
20
|
+
let A = {
|
|
21
21
|
"Content-Type": "application/json",
|
|
22
|
-
...
|
|
22
|
+
...s == null ? void 0 : s.headers
|
|
23
23
|
};
|
|
24
|
-
if (!(
|
|
24
|
+
if (!(s != null && s.skipAuth) && this.sessionManager)
|
|
25
25
|
try {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
} catch (
|
|
29
|
-
console.warn("Failed to inject auth headers:",
|
|
26
|
+
const b = await this.sessionManager.getAuthHeaders();
|
|
27
|
+
A = { ...A, ...b };
|
|
28
|
+
} catch (b) {
|
|
29
|
+
console.warn("Failed to inject auth headers:", b);
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const x = new AbortController(), P = setTimeout(() => x.abort(), I);
|
|
32
32
|
try {
|
|
33
|
-
const
|
|
33
|
+
const b = await fetch(p, {
|
|
34
34
|
method: e,
|
|
35
|
-
headers:
|
|
35
|
+
headers: A,
|
|
36
36
|
body: r ? JSON.stringify(r) : void 0,
|
|
37
|
-
signal:
|
|
37
|
+
signal: x.signal
|
|
38
38
|
});
|
|
39
|
-
if (clearTimeout(
|
|
39
|
+
if (clearTimeout(P), b.status === 401 && !(s != null && s.skipRetry) && !a && this.sessionManager)
|
|
40
40
|
try {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, r,
|
|
41
|
+
const h = this.sessionManager.getTokens();
|
|
42
|
+
if (h != null && h.refreshToken)
|
|
43
|
+
return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, r, s, !0);
|
|
44
44
|
} catch {
|
|
45
|
-
throw new Error(`HTTP ${
|
|
45
|
+
throw new Error(`HTTP ${b.status}: ${b.statusText}`);
|
|
46
46
|
}
|
|
47
|
-
if (!
|
|
48
|
-
throw new Error(`HTTP ${
|
|
49
|
-
const
|
|
50
|
-
return !
|
|
51
|
-
} catch (
|
|
52
|
-
throw clearTimeout(
|
|
47
|
+
if (!b.ok)
|
|
48
|
+
throw new Error(`HTTP ${b.status}: ${b.statusText}`);
|
|
49
|
+
const m = b.headers.get("content-type");
|
|
50
|
+
return !m || !m.includes("application/json") ? {} : await b.json();
|
|
51
|
+
} catch (b) {
|
|
52
|
+
throw clearTimeout(P), b instanceof Error && b.name === "AbortError" ? new Error(`Request timeout after ${I}ms`) : b;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
async get(e, t) {
|
|
@@ -65,7 +65,7 @@ class G {
|
|
|
65
65
|
return this.request("DELETE", e, void 0, t);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
class
|
|
68
|
+
class be {
|
|
69
69
|
constructor(e, t) {
|
|
70
70
|
this.httpService = e, this.sessionManager = t;
|
|
71
71
|
}
|
|
@@ -78,12 +78,12 @@ class Se {
|
|
|
78
78
|
async getApps(e) {
|
|
79
79
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
80
80
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
81
|
-
const
|
|
81
|
+
const s = `/apps/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
|
|
82
82
|
headers: t
|
|
83
83
|
});
|
|
84
84
|
return {
|
|
85
|
-
apps:
|
|
86
|
-
meta:
|
|
85
|
+
apps: a.data,
|
|
86
|
+
meta: a.meta
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
async getAppById(e) {
|
|
@@ -110,11 +110,11 @@ class Se {
|
|
|
110
110
|
)).data;
|
|
111
111
|
}
|
|
112
112
|
async updateSettingsSchema(e, t, r) {
|
|
113
|
-
const
|
|
113
|
+
const s = await this.sessionManager.getAuthHeaders();
|
|
114
114
|
return (await this.httpService.put(
|
|
115
115
|
`/apps/${e}/settings-schema`,
|
|
116
116
|
{ schema: t, defaultSettings: r },
|
|
117
|
-
{ headers:
|
|
117
|
+
{ headers: s }
|
|
118
118
|
)).data;
|
|
119
119
|
}
|
|
120
120
|
async exportConfig(e) {
|
|
@@ -124,7 +124,7 @@ class Se {
|
|
|
124
124
|
})).data;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
const
|
|
127
|
+
const Ae = de(null), De = () => /* @__PURE__ */ n(
|
|
128
128
|
"div",
|
|
129
129
|
{
|
|
130
130
|
style: {
|
|
@@ -134,9 +134,9 @@ const pe = te(null), ve = () => /* @__PURE__ */ s(
|
|
|
134
134
|
height: "100vh",
|
|
135
135
|
fontFamily: "system-ui, sans-serif"
|
|
136
136
|
},
|
|
137
|
-
children: /* @__PURE__ */
|
|
137
|
+
children: /* @__PURE__ */ n("div", { children: "Loading application..." })
|
|
138
138
|
}
|
|
139
|
-
),
|
|
139
|
+
), He = ({ error: i, retry: e }) => /* @__PURE__ */ l(
|
|
140
140
|
"div",
|
|
141
141
|
{
|
|
142
142
|
style: {
|
|
@@ -150,9 +150,9 @@ const pe = te(null), ve = () => /* @__PURE__ */ s(
|
|
|
150
150
|
padding: "20px"
|
|
151
151
|
},
|
|
152
152
|
children: [
|
|
153
|
-
/* @__PURE__ */
|
|
154
|
-
/* @__PURE__ */
|
|
155
|
-
/* @__PURE__ */
|
|
153
|
+
/* @__PURE__ */ n("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Application Error" }),
|
|
154
|
+
/* @__PURE__ */ n("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load application" }),
|
|
155
|
+
/* @__PURE__ */ n(
|
|
156
156
|
"button",
|
|
157
157
|
{
|
|
158
158
|
onClick: e,
|
|
@@ -170,55 +170,113 @@ const pe = te(null), ve = () => /* @__PURE__ */ s(
|
|
|
170
170
|
]
|
|
171
171
|
}
|
|
172
172
|
);
|
|
173
|
-
function
|
|
174
|
-
const
|
|
175
|
-
|
|
173
|
+
function St({ config: i, children: e }) {
|
|
174
|
+
const t = Q(
|
|
175
|
+
() => {
|
|
176
|
+
var m, h, S;
|
|
177
|
+
return {
|
|
178
|
+
enabled: ((m = i.cache) == null ? void 0 : m.enabled) ?? !0,
|
|
179
|
+
ttl: ((h = i.cache) == null ? void 0 : h.ttl) ?? 3e5,
|
|
180
|
+
// 5 minutes default
|
|
181
|
+
storageKey: ((S = i.cache) == null ? void 0 : S.storageKey) ?? `app_cache_${i.appId}`
|
|
182
|
+
};
|
|
183
|
+
},
|
|
184
|
+
[i.cache, i.appId]
|
|
185
|
+
), [r, s] = v(() => {
|
|
186
|
+
if (!t.enabled) return null;
|
|
187
|
+
try {
|
|
188
|
+
const m = localStorage.getItem(t.storageKey);
|
|
189
|
+
if (!m) return null;
|
|
190
|
+
const h = JSON.parse(m);
|
|
191
|
+
return Date.now() - h.timestamp < t.ttl && h.appId === i.appId ? h.data : (localStorage.removeItem(t.storageKey), null);
|
|
192
|
+
} catch {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
}), [a, p] = v(!r), [I, A] = v(null), x = Q(() => {
|
|
196
|
+
const m = () => {
|
|
176
197
|
P();
|
|
177
198
|
};
|
|
178
199
|
return {
|
|
179
200
|
appId: i.appId,
|
|
180
201
|
baseUrl: i.baseUrl,
|
|
181
202
|
// App info
|
|
182
|
-
appInfo:
|
|
183
|
-
isAppLoading:
|
|
184
|
-
appError:
|
|
185
|
-
retryApp:
|
|
203
|
+
appInfo: r,
|
|
204
|
+
isAppLoading: a,
|
|
205
|
+
appError: I,
|
|
206
|
+
retryApp: m
|
|
186
207
|
};
|
|
187
|
-
}, [i,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
+
}, [i, r, a, I]), P = ne(
|
|
209
|
+
async (m = !1) => {
|
|
210
|
+
if (!(!m && t.enabled && r))
|
|
211
|
+
try {
|
|
212
|
+
p(!0), A(null);
|
|
213
|
+
const h = new re(i.baseUrl), L = await new be(h, {}).getPublicAppInfo(i.appId);
|
|
214
|
+
if (s(L), t.enabled)
|
|
215
|
+
try {
|
|
216
|
+
const C = {
|
|
217
|
+
data: L,
|
|
218
|
+
timestamp: Date.now(),
|
|
219
|
+
appId: i.appId
|
|
220
|
+
};
|
|
221
|
+
localStorage.setItem(t.storageKey, JSON.stringify(C));
|
|
222
|
+
} catch (C) {
|
|
223
|
+
console.warn("Failed to cache app info:", C);
|
|
224
|
+
}
|
|
225
|
+
} catch (h) {
|
|
226
|
+
const S = h instanceof Error ? h : new Error("Failed to load app information");
|
|
227
|
+
A(S), s(null);
|
|
228
|
+
} finally {
|
|
229
|
+
p(!1);
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
[i.baseUrl, i.appId, t, r]
|
|
233
|
+
), b = ne(async () => {
|
|
234
|
+
if (!(!t.enabled || !r))
|
|
235
|
+
try {
|
|
236
|
+
const m = localStorage.getItem(t.storageKey);
|
|
237
|
+
if (!m) return;
|
|
238
|
+
const h = JSON.parse(m);
|
|
239
|
+
if (Date.now() - h.timestamp > t.ttl * 0.5) {
|
|
240
|
+
const L = new re(i.baseUrl), q = await new be(L, {}).getPublicAppInfo(i.appId);
|
|
241
|
+
s(q);
|
|
242
|
+
const k = {
|
|
243
|
+
data: q,
|
|
244
|
+
timestamp: Date.now(),
|
|
245
|
+
appId: i.appId
|
|
246
|
+
};
|
|
247
|
+
localStorage.setItem(t.storageKey, JSON.stringify(k));
|
|
248
|
+
}
|
|
249
|
+
} catch (m) {
|
|
250
|
+
console.warn("Background app refresh failed:", m);
|
|
251
|
+
}
|
|
252
|
+
}, [i, t, r]);
|
|
253
|
+
if (te(() => {
|
|
254
|
+
r ? b() : P();
|
|
255
|
+
}, []), a)
|
|
256
|
+
return /* @__PURE__ */ n(N, { children: i.loadingFallback || /* @__PURE__ */ n(De, {}) });
|
|
257
|
+
if (I) {
|
|
258
|
+
const m = typeof i.errorFallback == "function" ? i.errorFallback(I, () => P()) : i.errorFallback || /* @__PURE__ */ n(He, { error: I, retry: () => P() });
|
|
259
|
+
return /* @__PURE__ */ n(N, { children: m });
|
|
260
|
+
}
|
|
261
|
+
return /* @__PURE__ */ n(Ae.Provider, { value: x, children: e });
|
|
208
262
|
}
|
|
209
|
-
function
|
|
210
|
-
const i =
|
|
263
|
+
function he() {
|
|
264
|
+
const i = ue(Ae);
|
|
211
265
|
if (!i)
|
|
212
266
|
throw new Error("useApp must be used within an AppProvider");
|
|
213
267
|
return i;
|
|
214
268
|
}
|
|
215
|
-
const
|
|
216
|
-
class
|
|
269
|
+
const vt = he;
|
|
270
|
+
class ye {
|
|
217
271
|
constructor(e = {}) {
|
|
218
|
-
this.refreshPromise = null, this.refreshQueue = [], 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 ||
|
|
272
|
+
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);
|
|
273
|
+
}
|
|
274
|
+
// Helper to create a TokenStorage for a specific key
|
|
275
|
+
createTokenStorage(e) {
|
|
276
|
+
return {
|
|
219
277
|
get: () => {
|
|
220
278
|
try {
|
|
221
|
-
const t = localStorage.getItem(
|
|
279
|
+
const t = localStorage.getItem(e);
|
|
222
280
|
return t ? JSON.parse(t) : null;
|
|
223
281
|
} catch {
|
|
224
282
|
return null;
|
|
@@ -226,13 +284,13 @@ class Ae {
|
|
|
226
284
|
},
|
|
227
285
|
set: (t) => {
|
|
228
286
|
try {
|
|
229
|
-
localStorage.setItem(
|
|
287
|
+
localStorage.setItem(e, JSON.stringify(t));
|
|
230
288
|
} catch {
|
|
231
289
|
}
|
|
232
290
|
},
|
|
233
291
|
clear: () => {
|
|
234
292
|
try {
|
|
235
|
-
localStorage.removeItem(
|
|
293
|
+
localStorage.removeItem(e);
|
|
236
294
|
} catch {
|
|
237
295
|
}
|
|
238
296
|
}
|
|
@@ -281,10 +339,10 @@ class Ae {
|
|
|
281
339
|
try {
|
|
282
340
|
await this.refreshPromise;
|
|
283
341
|
const t = this.getTokens(), r = t != null && t.accessToken ? { Authorization: `Bearer ${t.accessToken}` } : {};
|
|
284
|
-
return this.refreshQueue.forEach(({ resolve:
|
|
342
|
+
return this.refreshQueue.forEach(({ resolve: s }) => s(r)), this.refreshQueue = [], r;
|
|
285
343
|
} catch (t) {
|
|
286
344
|
const r = t instanceof Error ? t : new Error("Token refresh failed");
|
|
287
|
-
return this.refreshQueue.forEach(({ reject:
|
|
345
|
+
return this.refreshQueue.forEach(({ reject: s }) => s(r)), this.refreshQueue = [], this.clearSession(), this.onRefreshFailed && this.onRefreshFailed(), {};
|
|
288
346
|
} finally {
|
|
289
347
|
this.refreshPromise = null;
|
|
290
348
|
}
|
|
@@ -303,11 +361,11 @@ class Ae {
|
|
|
303
361
|
});
|
|
304
362
|
if (!r.ok)
|
|
305
363
|
throw new Error(`Token refresh failed: ${r.status} ${r.statusText}`);
|
|
306
|
-
const
|
|
364
|
+
const s = await r.json();
|
|
307
365
|
this.setTokens({
|
|
308
|
-
accessToken:
|
|
309
|
-
refreshToken:
|
|
310
|
-
expiresIn:
|
|
366
|
+
accessToken: s.accessToken,
|
|
367
|
+
refreshToken: s.refreshToken || e,
|
|
368
|
+
expiresIn: s.expiresIn
|
|
311
369
|
});
|
|
312
370
|
}
|
|
313
371
|
setUser(e) {
|
|
@@ -325,12 +383,37 @@ class Ae {
|
|
|
325
383
|
clearSession() {
|
|
326
384
|
this.clearTokens(), this.clearUser();
|
|
327
385
|
}
|
|
386
|
+
/**
|
|
387
|
+
* Decode JWT token and extract payload
|
|
388
|
+
* Returns null if token is invalid or cannot be decoded
|
|
389
|
+
*/
|
|
390
|
+
getTokenPayload() {
|
|
391
|
+
try {
|
|
392
|
+
const e = this.getTokens();
|
|
393
|
+
if (!(e != null && e.accessToken)) return null;
|
|
394
|
+
const t = e.accessToken.split(".");
|
|
395
|
+
if (t.length !== 3) return null;
|
|
396
|
+
const r = t[1], s = atob(r.replace(/-/g, "+").replace(/_/g, "/"));
|
|
397
|
+
return JSON.parse(s);
|
|
398
|
+
} catch {
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Get userId from token (source of truth) or fallback to stored user
|
|
404
|
+
*/
|
|
405
|
+
getUserId() {
|
|
406
|
+
const e = this.getTokenPayload();
|
|
407
|
+
if (e != null && e.userId) return e.userId;
|
|
408
|
+
const t = this.getUser();
|
|
409
|
+
return (t == null ? void 0 : t.id) || null;
|
|
410
|
+
}
|
|
328
411
|
hasValidSession() {
|
|
329
412
|
const e = this.getTokens();
|
|
330
413
|
return e !== null && !this.isTokenExpired(e);
|
|
331
414
|
}
|
|
332
415
|
}
|
|
333
|
-
class
|
|
416
|
+
class Ne {
|
|
334
417
|
constructor(e) {
|
|
335
418
|
this.httpService = e;
|
|
336
419
|
}
|
|
@@ -354,6 +437,18 @@ class Pe {
|
|
|
354
437
|
async requestPasswordReset(e) {
|
|
355
438
|
await this.httpService.post("/auth/password-reset/request", e);
|
|
356
439
|
}
|
|
440
|
+
async sendMagicLink(e) {
|
|
441
|
+
return await this.httpService.post(
|
|
442
|
+
"/auth/magic-link/send",
|
|
443
|
+
e
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
async verifyMagicLink(e) {
|
|
447
|
+
return await this.httpService.post(
|
|
448
|
+
"/auth/magic-link/verify",
|
|
449
|
+
e
|
|
450
|
+
);
|
|
451
|
+
}
|
|
357
452
|
async confirmPasswordReset(e) {
|
|
358
453
|
await this.httpService.post("/auth/password-reset/confirm", e);
|
|
359
454
|
}
|
|
@@ -364,7 +459,7 @@ class Pe {
|
|
|
364
459
|
});
|
|
365
460
|
}
|
|
366
461
|
}
|
|
367
|
-
class
|
|
462
|
+
class Se {
|
|
368
463
|
constructor(e, t) {
|
|
369
464
|
this.httpService = e, this.sessionManager = t;
|
|
370
465
|
}
|
|
@@ -404,10 +499,10 @@ class ce {
|
|
|
404
499
|
async getRolesByApp(e, t) {
|
|
405
500
|
const r = new URLSearchParams();
|
|
406
501
|
t != null && t.page && r.append("page", t.page.toString()), t != null && t.limit && r.append("limit", t.limit.toString()), t != null && t.sortBy && r.append("sortBy", t.sortBy), t != null && t.sortOrder && r.append("sortOrder", t.sortOrder);
|
|
407
|
-
const
|
|
502
|
+
const s = `/roles/app/${e}${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s);
|
|
408
503
|
return {
|
|
409
|
-
roles:
|
|
410
|
-
meta:
|
|
504
|
+
roles: a.data,
|
|
505
|
+
meta: a.meta
|
|
411
506
|
};
|
|
412
507
|
}
|
|
413
508
|
async assignRole(e, t) {
|
|
@@ -429,18 +524,18 @@ class ce {
|
|
|
429
524
|
async getUserRoles(e, t) {
|
|
430
525
|
if (!this.sessionManager)
|
|
431
526
|
throw new Error("SessionManager is required for private endpoints");
|
|
432
|
-
const r = await this.sessionManager.getAuthHeaders(),
|
|
433
|
-
t != null && t.page &&
|
|
434
|
-
const
|
|
527
|
+
const r = await this.sessionManager.getAuthHeaders(), s = new URLSearchParams();
|
|
528
|
+
t != null && t.page && s.append("page", t.page.toString()), t != null && t.limit && s.append("limit", t.limit.toString()), t != null && t.sortBy && s.append("sortBy", t.sortBy), t != null && t.sortOrder && s.append("sortOrder", t.sortOrder);
|
|
529
|
+
const a = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, p = await this.httpService.get(a, {
|
|
435
530
|
headers: r
|
|
436
531
|
});
|
|
437
532
|
return {
|
|
438
|
-
roles:
|
|
439
|
-
meta:
|
|
533
|
+
roles: p.data,
|
|
534
|
+
meta: p.meta
|
|
440
535
|
};
|
|
441
536
|
}
|
|
442
537
|
}
|
|
443
|
-
class
|
|
538
|
+
class Be {
|
|
444
539
|
constructor(e, t) {
|
|
445
540
|
this.httpService = e, this.sessionManager = t;
|
|
446
541
|
}
|
|
@@ -453,12 +548,12 @@ class ke {
|
|
|
453
548
|
async getUsers(e) {
|
|
454
549
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
455
550
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
456
|
-
const
|
|
551
|
+
const s = `/users/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
|
|
457
552
|
headers: t
|
|
458
553
|
});
|
|
459
554
|
return {
|
|
460
|
-
users:
|
|
461
|
-
meta:
|
|
555
|
+
users: a.data,
|
|
556
|
+
meta: a.meta
|
|
462
557
|
};
|
|
463
558
|
}
|
|
464
559
|
async getUserById(e) {
|
|
@@ -480,7 +575,7 @@ class ke {
|
|
|
480
575
|
});
|
|
481
576
|
}
|
|
482
577
|
}
|
|
483
|
-
class
|
|
578
|
+
class ce {
|
|
484
579
|
constructor(e, t, r) {
|
|
485
580
|
this.httpService = e, this.appId = t, this.sessionManager = r;
|
|
486
581
|
}
|
|
@@ -497,12 +592,12 @@ class de {
|
|
|
497
592
|
throw new Error("SessionManager is required for private endpoints");
|
|
498
593
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
499
594
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
500
|
-
const
|
|
595
|
+
const s = `/tenants/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
|
|
501
596
|
headers: t
|
|
502
597
|
});
|
|
503
598
|
return {
|
|
504
|
-
tenants:
|
|
505
|
-
meta:
|
|
599
|
+
tenants: a.data,
|
|
600
|
+
meta: a.meta
|
|
506
601
|
};
|
|
507
602
|
}
|
|
508
603
|
async getTenantById(e) {
|
|
@@ -558,7 +653,7 @@ class de {
|
|
|
558
653
|
)).data;
|
|
559
654
|
}
|
|
560
655
|
}
|
|
561
|
-
const
|
|
656
|
+
const Pe = de(null), Ue = () => /* @__PURE__ */ n(
|
|
562
657
|
"div",
|
|
563
658
|
{
|
|
564
659
|
style: {
|
|
@@ -568,9 +663,9 @@ const fe = te(null), Te = () => /* @__PURE__ */ s(
|
|
|
568
663
|
height: "100vh",
|
|
569
664
|
fontFamily: "system-ui, sans-serif"
|
|
570
665
|
},
|
|
571
|
-
children: /* @__PURE__ */
|
|
666
|
+
children: /* @__PURE__ */ n("div", { children: "Loading tenant..." })
|
|
572
667
|
}
|
|
573
|
-
),
|
|
668
|
+
), qe = ({ error: i, retry: e }) => /* @__PURE__ */ l(
|
|
574
669
|
"div",
|
|
575
670
|
{
|
|
576
671
|
style: {
|
|
@@ -584,9 +679,9 @@ const fe = te(null), Te = () => /* @__PURE__ */ s(
|
|
|
584
679
|
padding: "20px"
|
|
585
680
|
},
|
|
586
681
|
children: [
|
|
587
|
-
/* @__PURE__ */
|
|
588
|
-
/* @__PURE__ */
|
|
589
|
-
/* @__PURE__ */
|
|
682
|
+
/* @__PURE__ */ n("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Tenant Error" }),
|
|
683
|
+
/* @__PURE__ */ n("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load tenant" }),
|
|
684
|
+
/* @__PURE__ */ n(
|
|
590
685
|
"button",
|
|
591
686
|
{
|
|
592
687
|
onClick: e,
|
|
@@ -604,77 +699,134 @@ const fe = te(null), Te = () => /* @__PURE__ */ s(
|
|
|
604
699
|
]
|
|
605
700
|
}
|
|
606
701
|
);
|
|
607
|
-
function
|
|
608
|
-
const { baseUrl: t, appInfo: r, appId:
|
|
609
|
-
const
|
|
702
|
+
function xt({ config: i, children: e }) {
|
|
703
|
+
const { baseUrl: t, appInfo: r, appId: s } = he(), a = ne(() => {
|
|
704
|
+
const o = i.tenantMode || "selector", g = "tenant";
|
|
610
705
|
if (typeof window > "u") return null;
|
|
611
|
-
if (
|
|
612
|
-
const
|
|
613
|
-
if (
|
|
614
|
-
const
|
|
615
|
-
return localStorage.setItem(
|
|
706
|
+
if (o === "subdomain") {
|
|
707
|
+
const d = window.location.hostname.split(".");
|
|
708
|
+
if (d.length >= 3) {
|
|
709
|
+
const c = d[0];
|
|
710
|
+
return localStorage.setItem(g, c), c;
|
|
616
711
|
}
|
|
617
|
-
return localStorage.getItem(
|
|
618
|
-
} else if (
|
|
619
|
-
const
|
|
620
|
-
return
|
|
712
|
+
return localStorage.getItem(g);
|
|
713
|
+
} else if (o === "selector") {
|
|
714
|
+
const d = new URLSearchParams(window.location.search).get(i.selectorParam || "tenant");
|
|
715
|
+
return d ? (localStorage.setItem(g, d), d) : localStorage.getItem(g);
|
|
621
716
|
}
|
|
622
717
|
return null;
|
|
623
|
-
}, [i.tenantMode, i.selectorParam]),
|
|
624
|
-
|
|
718
|
+
}, [i.tenantMode, i.selectorParam]), [p, I] = v(() => a()), A = Q(
|
|
719
|
+
() => {
|
|
720
|
+
var o, g, f;
|
|
721
|
+
return {
|
|
722
|
+
enabled: ((o = i.cache) == null ? void 0 : o.enabled) ?? !0,
|
|
723
|
+
ttl: ((g = i.cache) == null ? void 0 : g.ttl) ?? 5 * 60 * 1e3,
|
|
724
|
+
// 5 minutes default
|
|
725
|
+
storageKey: ((f = i.cache) == null ? void 0 : f.storageKey) ?? `tenant_cache_${p || "default"}`
|
|
726
|
+
};
|
|
727
|
+
},
|
|
728
|
+
[i.cache, p]
|
|
729
|
+
), [x, P] = v(() => {
|
|
730
|
+
if (i.initialTenant) return i.initialTenant;
|
|
731
|
+
if (!A.enabled || !p) return null;
|
|
732
|
+
try {
|
|
733
|
+
const o = localStorage.getItem(A.storageKey);
|
|
734
|
+
if (!o) return null;
|
|
735
|
+
const g = JSON.parse(o);
|
|
736
|
+
return Date.now() - g.timestamp < A.ttl && g.tenantSlug === p ? g.data : (localStorage.removeItem(A.storageKey), null);
|
|
737
|
+
} catch {
|
|
738
|
+
return null;
|
|
739
|
+
}
|
|
740
|
+
}), [b, m] = v(!x && !i.initialTenant), [h, S] = v(null), [L, C] = v(null), [q, k] = v(!1), [u, T] = v(null);
|
|
741
|
+
te(() => {
|
|
742
|
+
const o = a();
|
|
743
|
+
I(o);
|
|
744
|
+
}, [a]);
|
|
745
|
+
const R = (r == null ? void 0 : r.settingsSchema) || null, H = ne(
|
|
746
|
+
async (o, g = !1) => {
|
|
747
|
+
if (!(!g && A.enabled && x && x.domain === o))
|
|
748
|
+
try {
|
|
749
|
+
m(!0), S(null);
|
|
750
|
+
const f = new re(t), c = await new ce(f, s).getPublicTenantInfo(o);
|
|
751
|
+
if (P(c), A.enabled)
|
|
752
|
+
try {
|
|
753
|
+
const y = {
|
|
754
|
+
data: c,
|
|
755
|
+
timestamp: Date.now(),
|
|
756
|
+
tenantSlug: o
|
|
757
|
+
};
|
|
758
|
+
localStorage.setItem(A.storageKey, JSON.stringify(y));
|
|
759
|
+
} catch (y) {
|
|
760
|
+
console.warn("Failed to cache tenant info:", y);
|
|
761
|
+
}
|
|
762
|
+
} catch (f) {
|
|
763
|
+
const d = f instanceof Error ? f : new Error("Failed to load tenant information");
|
|
764
|
+
S(d), P(null);
|
|
765
|
+
} finally {
|
|
766
|
+
m(!1);
|
|
767
|
+
}
|
|
768
|
+
},
|
|
769
|
+
[t, s, A, x]
|
|
770
|
+
), G = ne(async () => {
|
|
771
|
+
if (!(!A.enabled || !x || !p))
|
|
625
772
|
try {
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
773
|
+
const o = localStorage.getItem(A.storageKey);
|
|
774
|
+
if (!o) return;
|
|
775
|
+
const g = JSON.parse(o);
|
|
776
|
+
if (Date.now() - g.timestamp > A.ttl * 0.5) {
|
|
777
|
+
const d = new re(t), y = await new ce(d, s).getPublicTenantInfo(p);
|
|
778
|
+
P(y);
|
|
779
|
+
const W = {
|
|
780
|
+
data: y,
|
|
781
|
+
timestamp: Date.now(),
|
|
782
|
+
tenantSlug: p
|
|
783
|
+
};
|
|
784
|
+
localStorage.setItem(A.storageKey, JSON.stringify(W));
|
|
785
|
+
}
|
|
786
|
+
} catch (o) {
|
|
787
|
+
console.warn("Background tenant refresh failed:", o);
|
|
634
788
|
}
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
), R = Z(async () => {
|
|
638
|
-
if (o != null && o.id)
|
|
789
|
+
}, [t, s, A, x, p]), F = ne(async () => {
|
|
790
|
+
if (x != null && x.id)
|
|
639
791
|
try {
|
|
640
|
-
|
|
641
|
-
const
|
|
642
|
-
|
|
643
|
-
} catch (
|
|
644
|
-
const
|
|
645
|
-
|
|
792
|
+
k(!0), T(null);
|
|
793
|
+
const o = new re(t), f = await new ce(o, x.appId).getTenantSettings(x.id);
|
|
794
|
+
C(f);
|
|
795
|
+
} catch (o) {
|
|
796
|
+
const g = o instanceof Error ? o : new Error("Failed to load tenant settings");
|
|
797
|
+
T(g), C(null);
|
|
646
798
|
} finally {
|
|
647
|
-
|
|
799
|
+
k(!1);
|
|
648
800
|
}
|
|
649
|
-
}, [t,
|
|
650
|
-
|
|
651
|
-
}, [
|
|
652
|
-
(
|
|
653
|
-
if (!
|
|
801
|
+
}, [t, x]), V = ne(() => {
|
|
802
|
+
F();
|
|
803
|
+
}, [F]), w = ne(
|
|
804
|
+
(o) => {
|
|
805
|
+
if (!R)
|
|
654
806
|
return { isValid: !0, errors: [] };
|
|
655
|
-
const
|
|
807
|
+
const g = [];
|
|
656
808
|
try {
|
|
657
|
-
return
|
|
658
|
-
var
|
|
659
|
-
const
|
|
660
|
-
if ((
|
|
661
|
-
|
|
809
|
+
return R.properties && Object.entries(R.properties).forEach(([f, d]) => {
|
|
810
|
+
var y;
|
|
811
|
+
const c = o[f];
|
|
812
|
+
if ((y = R.required) != null && y.includes(f) && c == null) {
|
|
813
|
+
g.push(`Field '${f}' is required`);
|
|
662
814
|
return;
|
|
663
815
|
}
|
|
664
|
-
if (
|
|
665
|
-
if (
|
|
666
|
-
const
|
|
667
|
-
|
|
816
|
+
if (c != null) {
|
|
817
|
+
if (d.type) {
|
|
818
|
+
const W = d.type, ee = typeof c;
|
|
819
|
+
W === "string" && ee !== "string" ? g.push(`Field '${f}' must be a string`) : (W === "number" || W === "integer") && ee !== "number" ? g.push(`Field '${f}' must be a number`) : W === "boolean" && ee !== "boolean" ? g.push(`Field '${f}' must be a boolean`) : W === "array" && !Array.isArray(c) && g.push(`Field '${f}' must be an array`);
|
|
668
820
|
}
|
|
669
|
-
|
|
670
|
-
`Field '${
|
|
671
|
-
),
|
|
672
|
-
`Field '${
|
|
673
|
-
),
|
|
821
|
+
d.minLength !== void 0 && typeof c == "string" && c.length < d.minLength && g.push(
|
|
822
|
+
`Field '${f}' must be at least ${d.minLength} characters long`
|
|
823
|
+
), d.maxLength !== void 0 && typeof c == "string" && c.length > d.maxLength && g.push(
|
|
824
|
+
`Field '${f}' must be no more than ${d.maxLength} characters long`
|
|
825
|
+
), d.minimum !== void 0 && typeof c == "number" && c < d.minimum && g.push(`Field '${f}' must be at least ${d.minimum}`), d.maximum !== void 0 && typeof c == "number" && c > d.maximum && g.push(`Field '${f}' must be no more than ${d.maximum}`), d.pattern && typeof c == "string" && (new RegExp(d.pattern).test(c) || g.push(`Field '${f}' does not match the required pattern`)), d.enum && !d.enum.includes(c) && g.push(`Field '${f}' must be one of: ${d.enum.join(", ")}`);
|
|
674
826
|
}
|
|
675
827
|
}), {
|
|
676
|
-
isValid:
|
|
677
|
-
errors:
|
|
828
|
+
isValid: g.length === 0,
|
|
829
|
+
errors: g
|
|
678
830
|
};
|
|
679
831
|
} catch {
|
|
680
832
|
return {
|
|
@@ -683,276 +835,378 @@ function rt({ config: i, children: e }) {
|
|
|
683
835
|
};
|
|
684
836
|
}
|
|
685
837
|
},
|
|
686
|
-
[
|
|
838
|
+
[R]
|
|
687
839
|
);
|
|
688
|
-
|
|
689
|
-
!i.initialTenant &&
|
|
690
|
-
}, [i.initialTenant,
|
|
691
|
-
|
|
692
|
-
}, [
|
|
693
|
-
const
|
|
840
|
+
te(() => {
|
|
841
|
+
!i.initialTenant && p ? x ? G() : H(p) : !i.initialTenant && !p && (P(null), S(null), m(!1));
|
|
842
|
+
}, [i.initialTenant, p, x, H, G]), te(() => {
|
|
843
|
+
x != null && x.id ? F() : (C(null), T(null), k(!1));
|
|
844
|
+
}, [x == null ? void 0 : x.id, F]);
|
|
845
|
+
const M = ne(
|
|
846
|
+
(o, g = "reload") => {
|
|
847
|
+
const f = i.tenantMode || "selector";
|
|
848
|
+
if (console.log("[TenantProvider] Switching tenant:", {
|
|
849
|
+
targetTenantSlug: o,
|
|
850
|
+
currentTenantSlug: p,
|
|
851
|
+
tenantMode: f,
|
|
852
|
+
mode: g
|
|
853
|
+
}), localStorage.setItem("tenant", o), f === "subdomain") {
|
|
854
|
+
const d = window.location.hostname, c = d.split(".");
|
|
855
|
+
if (c.length >= 2) {
|
|
856
|
+
c[0] = o;
|
|
857
|
+
const y = c.join("."), W = `${window.location.protocol}//${y}${window.location.pathname}${window.location.search}`;
|
|
858
|
+
console.log("[TenantProvider] Redirecting to:", W), window.location.href = W;
|
|
859
|
+
} else
|
|
860
|
+
console.warn(
|
|
861
|
+
"[TenantProvider] Cannot switch subdomain, invalid hostname:",
|
|
862
|
+
d
|
|
863
|
+
);
|
|
864
|
+
} else if (f === "selector") {
|
|
865
|
+
const d = new URLSearchParams(window.location.search);
|
|
866
|
+
if (d.set(i.selectorParam || "tenant", o), g === "reload") {
|
|
867
|
+
const c = `${window.location.pathname}?${d.toString()}${window.location.hash}`;
|
|
868
|
+
console.log("[TenantProvider] Reloading with new tenant:", c), window.location.href = c;
|
|
869
|
+
} else {
|
|
870
|
+
const c = `${window.location.pathname}?${d.toString()}${window.location.hash}`;
|
|
871
|
+
console.log("[TenantProvider] Navigating without reload:", c), window.history.pushState({}, "", c), I(o), H(o);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
},
|
|
875
|
+
[i.tenantMode, i.selectorParam, H, p]
|
|
876
|
+
), E = Q(() => ({
|
|
694
877
|
// Tenant info
|
|
695
|
-
tenant:
|
|
696
|
-
tenantSlug:
|
|
697
|
-
isTenantLoading:
|
|
698
|
-
tenantError:
|
|
878
|
+
tenant: x,
|
|
879
|
+
tenantSlug: p,
|
|
880
|
+
isTenantLoading: b,
|
|
881
|
+
tenantError: h,
|
|
699
882
|
retryTenant: () => {
|
|
700
|
-
|
|
883
|
+
p && H(p);
|
|
701
884
|
},
|
|
702
885
|
// Settings
|
|
703
|
-
settings:
|
|
704
|
-
settingsSchema:
|
|
705
|
-
isSettingsLoading:
|
|
706
|
-
settingsError:
|
|
886
|
+
settings: L,
|
|
887
|
+
settingsSchema: R,
|
|
888
|
+
isSettingsLoading: q,
|
|
889
|
+
settingsError: u,
|
|
707
890
|
// Actions
|
|
708
|
-
refreshSettings:
|
|
891
|
+
refreshSettings: V,
|
|
892
|
+
switchTenant: M,
|
|
709
893
|
// Validation
|
|
710
|
-
validateSettings:
|
|
894
|
+
validateSettings: w
|
|
711
895
|
}), [
|
|
712
|
-
|
|
713
|
-
y,
|
|
714
|
-
T,
|
|
715
|
-
P,
|
|
716
|
-
h,
|
|
717
|
-
S,
|
|
896
|
+
x,
|
|
718
897
|
p,
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
898
|
+
b,
|
|
899
|
+
h,
|
|
900
|
+
L,
|
|
901
|
+
R,
|
|
902
|
+
q,
|
|
903
|
+
u,
|
|
904
|
+
V,
|
|
905
|
+
M,
|
|
906
|
+
w
|
|
722
907
|
]);
|
|
723
|
-
if (
|
|
724
|
-
return /* @__PURE__ */
|
|
725
|
-
if (
|
|
726
|
-
const
|
|
727
|
-
return /* @__PURE__ */
|
|
908
|
+
if (b)
|
|
909
|
+
return /* @__PURE__ */ n(N, { children: i.loadingFallback || /* @__PURE__ */ n(Ue, {}) });
|
|
910
|
+
if (h) {
|
|
911
|
+
const o = typeof i.errorFallback == "function" ? i.errorFallback(h, () => H(p || "")) : i.errorFallback || /* @__PURE__ */ n(qe, { error: h, retry: () => H(p || "") });
|
|
912
|
+
return /* @__PURE__ */ n(N, { children: o });
|
|
728
913
|
}
|
|
729
|
-
return /* @__PURE__ */
|
|
914
|
+
return /* @__PURE__ */ n(Pe.Provider, { value: E, children: e });
|
|
730
915
|
}
|
|
731
|
-
function
|
|
732
|
-
const i =
|
|
916
|
+
function fe() {
|
|
917
|
+
const i = ue(Pe);
|
|
733
918
|
if (!i)
|
|
734
919
|
throw new Error("useTenant must be used within a TenantProvider");
|
|
735
920
|
return i;
|
|
736
921
|
}
|
|
737
|
-
const
|
|
738
|
-
function
|
|
739
|
-
const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings:
|
|
922
|
+
const kt = fe;
|
|
923
|
+
function At() {
|
|
924
|
+
const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } = fe();
|
|
740
925
|
return {
|
|
741
926
|
settings: i,
|
|
742
927
|
settingsSchema: e,
|
|
743
928
|
isLoading: t,
|
|
744
929
|
error: r,
|
|
745
|
-
validateSettings:
|
|
930
|
+
validateSettings: s
|
|
746
931
|
};
|
|
747
932
|
}
|
|
748
|
-
function
|
|
749
|
-
const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant:
|
|
933
|
+
function se() {
|
|
934
|
+
const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } = fe();
|
|
750
935
|
return {
|
|
751
936
|
tenant: i,
|
|
752
937
|
tenantSlug: e,
|
|
753
938
|
isLoading: t,
|
|
754
939
|
error: r,
|
|
755
|
-
retry:
|
|
940
|
+
retry: s
|
|
756
941
|
};
|
|
757
942
|
}
|
|
758
|
-
const
|
|
759
|
-
function
|
|
760
|
-
const { appId: t, baseUrl: r } =
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
943
|
+
const Te = de(null);
|
|
944
|
+
function Pt({ config: i = {}, children: e }) {
|
|
945
|
+
const { appId: t, baseUrl: r } = he(), { tenant: s, tenantSlug: a, switchTenant: p } = fe(), [I, A] = v(i.initialRoles || []), [x, P] = v(!i.initialRoles), [b, m] = v(null), [h, S] = v(!1), [L, C] = v(null), [q, k] = v(0), u = Q(() => new ye({
|
|
946
|
+
tenantSlug: a,
|
|
947
|
+
// SessionManager will generate storageKey internally
|
|
948
|
+
onRefreshFailed: i.onRefreshFailed,
|
|
949
|
+
baseUrl: r
|
|
950
|
+
}), [a, r, i.onRefreshFailed]), T = Q(() => {
|
|
951
|
+
const g = new re(r);
|
|
952
|
+
return g.setSessionManager(u), g;
|
|
953
|
+
}, [r, u]), R = Q(() => new Ne(new re(r)), [r]), H = Q(() => new Be(T, u), [T, u]), G = Q(() => new Se(new re(r)), [r]), F = Q(() => b || u.getUser(), [b, u]), V = Q(() => F != null && F.roleId && I.find((g) => g.id === F.roleId) || null, [F, I]), w = Q(() => (V == null ? void 0 : V.permissions) || [], [V]), M = Q(() => u.hasValidSession() && b !== null, [u, b]), E = 5 * 60 * 1e3, o = Q(() => {
|
|
954
|
+
const g = async ($ = !1) => {
|
|
955
|
+
try {
|
|
956
|
+
if (!u.hasValidSession())
|
|
957
|
+
return;
|
|
958
|
+
const U = Date.now();
|
|
959
|
+
if (!$ && U - q < E && b)
|
|
960
|
+
return;
|
|
961
|
+
const j = u.getUserId();
|
|
962
|
+
if (!j) {
|
|
963
|
+
console.warn("[AuthProvider] No userId available in token or storage");
|
|
964
|
+
return;
|
|
774
965
|
}
|
|
775
|
-
|
|
776
|
-
|
|
966
|
+
S(!0), C(null);
|
|
967
|
+
const X = await H.getUserById(j);
|
|
968
|
+
m(X), u.setUser(X), k(Date.now());
|
|
969
|
+
} catch (U) {
|
|
970
|
+
const K = U instanceof Error ? U : new Error("Failed to load user data");
|
|
971
|
+
C(K), console.error("[AuthProvider] Failed to load user data:", K);
|
|
972
|
+
} finally {
|
|
973
|
+
S(!1);
|
|
974
|
+
}
|
|
975
|
+
}, f = async () => {
|
|
976
|
+
await g();
|
|
977
|
+
}, d = async ($) => {
|
|
978
|
+
const { username: U, password: K, tenantSlug: j } = $;
|
|
979
|
+
let X = s == null ? void 0 : s.id, Y = a, Z = u;
|
|
980
|
+
j && (X = (await new ce(T, t).getPublicTenantInfo(j)).id, Y = j);
|
|
981
|
+
const J = await R.login({
|
|
982
|
+
username: U,
|
|
983
|
+
password: K,
|
|
984
|
+
appId: t,
|
|
985
|
+
tenantId: X
|
|
986
|
+
}), ae = j && j !== a;
|
|
987
|
+
if (ae && (Z = new ye({
|
|
988
|
+
tenantSlug: Y,
|
|
989
|
+
baseUrl: r
|
|
990
|
+
})), Z.setTokens({
|
|
991
|
+
accessToken: J.accessToken,
|
|
992
|
+
refreshToken: J.refreshToken,
|
|
993
|
+
expiresIn: J.expiresIn
|
|
994
|
+
}), J.user) {
|
|
995
|
+
Z.setUser(J.user), m(J.user);
|
|
777
996
|
try {
|
|
778
|
-
|
|
779
|
-
} catch {
|
|
997
|
+
await g();
|
|
998
|
+
} catch (le) {
|
|
999
|
+
console.warn("Failed to load complete user data after login:", le);
|
|
780
1000
|
}
|
|
781
1001
|
}
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
const V = await y.login({
|
|
814
|
-
email: v,
|
|
815
|
-
password: $,
|
|
816
|
-
tenantId: J
|
|
1002
|
+
return ae && Y && Y !== a && p(Y), J;
|
|
1003
|
+
}, c = async ($) => {
|
|
1004
|
+
const { email: U, phoneNumber: K, name: j, password: X, lastName: Y, tenantId: Z } = $;
|
|
1005
|
+
if (!U && !K)
|
|
1006
|
+
throw new Error("Either email or phoneNumber is required");
|
|
1007
|
+
if (!j || !X)
|
|
1008
|
+
throw new Error("Name and password are required");
|
|
1009
|
+
const J = Z ?? (s == null ? void 0 : s.id);
|
|
1010
|
+
return await R.signup({
|
|
1011
|
+
email: U,
|
|
1012
|
+
phoneNumber: K,
|
|
1013
|
+
name: j,
|
|
1014
|
+
password: X,
|
|
1015
|
+
tenantId: J,
|
|
1016
|
+
lastName: Y,
|
|
1017
|
+
appId: t
|
|
1018
|
+
});
|
|
1019
|
+
}, y = async ($) => {
|
|
1020
|
+
const { email: U, phoneNumber: K, name: j, password: X, tenantName: Y, lastName: Z } = $;
|
|
1021
|
+
if (!U && !K)
|
|
1022
|
+
throw new Error("Either email or phoneNumber is required");
|
|
1023
|
+
if (!j || !X || !Y)
|
|
1024
|
+
throw new Error("Name, password, and tenantName are required");
|
|
1025
|
+
return await R.signupTenantAdmin({
|
|
1026
|
+
email: U,
|
|
1027
|
+
phoneNumber: K,
|
|
1028
|
+
name: j,
|
|
1029
|
+
password: X,
|
|
1030
|
+
tenantName: Y,
|
|
1031
|
+
appId: t,
|
|
1032
|
+
lastName: Z
|
|
817
1033
|
});
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
1034
|
+
}, W = async ($) => {
|
|
1035
|
+
const { currentPassword: U, newPassword: K } = $, j = await u.getAuthHeaders();
|
|
1036
|
+
await R.changePassword({ currentPassword: U, newPassword: K }, j);
|
|
1037
|
+
}, ee = async ($) => {
|
|
1038
|
+
const { email: U, tenantId: K } = $, j = K ?? (s == null ? void 0 : s.id);
|
|
1039
|
+
if (!j)
|
|
1040
|
+
throw new Error("tenantId is required for password reset");
|
|
1041
|
+
await R.requestPasswordReset({ email: U, tenantId: j });
|
|
1042
|
+
}, z = async ($) => {
|
|
1043
|
+
const { token: U, newPassword: K } = $;
|
|
1044
|
+
await R.confirmPasswordReset({ token: U, newPassword: K });
|
|
1045
|
+
}, B = async ($) => {
|
|
1046
|
+
const { email: U, frontendUrl: K, name: j, lastName: X, tenantId: Y } = $, Z = Y ?? (s == null ? void 0 : s.id);
|
|
1047
|
+
if (!Z)
|
|
1048
|
+
throw new Error("tenantId is required for magic link authentication");
|
|
1049
|
+
return await R.sendMagicLink({
|
|
1050
|
+
email: U,
|
|
1051
|
+
tenantId: Z,
|
|
1052
|
+
frontendUrl: K,
|
|
1053
|
+
name: j,
|
|
1054
|
+
lastName: X,
|
|
1055
|
+
appId: t
|
|
1056
|
+
});
|
|
1057
|
+
}, O = async ($) => {
|
|
1058
|
+
const { token: U, email: K, tenantSlug: j } = $;
|
|
1059
|
+
let X = s == null ? void 0 : s.id, Y = a, Z = u;
|
|
1060
|
+
j && (X = (await new ce(T, t).getPublicTenantInfo(j)).id, Y = j);
|
|
1061
|
+
const J = await R.verifyMagicLink({
|
|
1062
|
+
token: U,
|
|
1063
|
+
email: K,
|
|
1064
|
+
appId: t,
|
|
1065
|
+
tenantId: X
|
|
1066
|
+
}), ae = j && j !== a;
|
|
1067
|
+
if (ae && (Z = new ye({
|
|
1068
|
+
tenantSlug: Y,
|
|
1069
|
+
baseUrl: r
|
|
1070
|
+
})), Z.setTokens({
|
|
1071
|
+
accessToken: J.accessToken,
|
|
1072
|
+
refreshToken: J.refreshToken,
|
|
1073
|
+
expiresIn: J.expiresIn
|
|
1074
|
+
}), J.user) {
|
|
1075
|
+
Z.setUser(J.user), m(J.user);
|
|
824
1076
|
try {
|
|
825
|
-
await
|
|
826
|
-
} catch (
|
|
827
|
-
console.warn("Failed to load complete user data after login:",
|
|
1077
|
+
await g();
|
|
1078
|
+
} catch (le) {
|
|
1079
|
+
console.warn("Failed to load complete user data after magic link login:", le);
|
|
828
1080
|
}
|
|
829
1081
|
}
|
|
830
|
-
return
|
|
831
|
-
},
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
password: J,
|
|
835
|
-
tenantId: V,
|
|
836
|
-
lastName: ee
|
|
837
|
-
}), l = async (v, $, J, V, ee) => await y.signupTenantAdmin({
|
|
838
|
-
email: v,
|
|
839
|
-
name: $,
|
|
840
|
-
password: J,
|
|
841
|
-
tenantName: V,
|
|
842
|
-
appId: t,
|
|
843
|
-
lastName: ee
|
|
844
|
-
}), W = async (v, $) => {
|
|
845
|
-
const J = await f.getAuthHeaders();
|
|
846
|
-
await y.changePassword({ currentPassword: v, newPassword: $ }, J);
|
|
847
|
-
}, I = async (v, $) => {
|
|
848
|
-
await y.requestPasswordReset({ email: v, tenantId: $ });
|
|
849
|
-
}, N = async (v, $) => {
|
|
850
|
-
await y.confirmPasswordReset({ token: v, newPassword: $ });
|
|
851
|
-
}, _ = async () => {
|
|
852
|
-
const v = f.getTokens();
|
|
853
|
-
if (!(v != null && v.refreshToken))
|
|
1082
|
+
return ae && Y && Y !== a && p(Y), J;
|
|
1083
|
+
}, D = async () => {
|
|
1084
|
+
const $ = u.getTokens();
|
|
1085
|
+
if (!($ != null && $.refreshToken))
|
|
854
1086
|
throw new Error("No refresh token available");
|
|
855
|
-
const
|
|
856
|
-
refreshToken:
|
|
1087
|
+
const U = await R.refreshToken({
|
|
1088
|
+
refreshToken: $.refreshToken
|
|
857
1089
|
});
|
|
858
|
-
|
|
859
|
-
accessToken:
|
|
860
|
-
refreshToken:
|
|
861
|
-
expiresIn:
|
|
1090
|
+
u.setTokens({
|
|
1091
|
+
accessToken: U.accessToken,
|
|
1092
|
+
refreshToken: U.refreshToken || $.refreshToken,
|
|
1093
|
+
expiresIn: U.expiresIn
|
|
862
1094
|
});
|
|
863
|
-
},
|
|
864
|
-
|
|
865
|
-
},
|
|
866
|
-
|
|
867
|
-
},
|
|
868
|
-
|
|
869
|
-
},
|
|
1095
|
+
}, _ = () => {
|
|
1096
|
+
u.clearSession(), m(null), C(null);
|
|
1097
|
+
}, ge = ($) => {
|
|
1098
|
+
u.setTokens($);
|
|
1099
|
+
}, Re = () => u.hasValidSession(), Ce = () => {
|
|
1100
|
+
u.clearSession(), m(null), C(null);
|
|
1101
|
+
}, Le = async () => {
|
|
870
1102
|
if (t)
|
|
871
1103
|
try {
|
|
872
1104
|
P(!0);
|
|
873
|
-
const { roles:
|
|
874
|
-
|
|
875
|
-
} catch (
|
|
876
|
-
console.error("Failed to fetch roles:",
|
|
1105
|
+
const { roles: $ } = await G.getRolesByApp(t);
|
|
1106
|
+
A($);
|
|
1107
|
+
} catch ($) {
|
|
1108
|
+
console.error("Failed to fetch roles:", $);
|
|
877
1109
|
} finally {
|
|
878
1110
|
P(!1);
|
|
879
1111
|
}
|
|
880
|
-
},
|
|
881
|
-
await
|
|
882
|
-
},
|
|
883
|
-
if (!
|
|
1112
|
+
}, Fe = async () => {
|
|
1113
|
+
await Le();
|
|
1114
|
+
}, me = ($) => {
|
|
1115
|
+
if (!w || w.length === 0)
|
|
884
1116
|
return !1;
|
|
885
|
-
if (typeof
|
|
886
|
-
return
|
|
887
|
-
const
|
|
888
|
-
return
|
|
1117
|
+
if (typeof $ == "string")
|
|
1118
|
+
return w.includes($);
|
|
1119
|
+
const U = `${$.resource}.${$.action}`;
|
|
1120
|
+
return w.includes(U);
|
|
889
1121
|
};
|
|
890
1122
|
return {
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
1123
|
+
// RFC-003: Authentication state
|
|
1124
|
+
isAuthenticated: M,
|
|
1125
|
+
sessionManager: u,
|
|
1126
|
+
authenticatedHttpService: T,
|
|
1127
|
+
login: d,
|
|
1128
|
+
signup: c,
|
|
1129
|
+
signupTenantAdmin: y,
|
|
1130
|
+
sendMagicLink: B,
|
|
1131
|
+
verifyMagicLink: O,
|
|
896
1132
|
changePassword: W,
|
|
897
|
-
requestPasswordReset:
|
|
898
|
-
confirmPasswordReset:
|
|
899
|
-
refreshToken:
|
|
900
|
-
logout:
|
|
901
|
-
setTokens:
|
|
902
|
-
hasValidSession:
|
|
903
|
-
clearSession:
|
|
904
|
-
currentUser:
|
|
905
|
-
isUserLoading:
|
|
906
|
-
userError:
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
1133
|
+
requestPasswordReset: ee,
|
|
1134
|
+
confirmPasswordReset: z,
|
|
1135
|
+
refreshToken: D,
|
|
1136
|
+
logout: _,
|
|
1137
|
+
setTokens: ge,
|
|
1138
|
+
hasValidSession: Re,
|
|
1139
|
+
clearSession: Ce,
|
|
1140
|
+
currentUser: b,
|
|
1141
|
+
isUserLoading: h,
|
|
1142
|
+
userError: L,
|
|
1143
|
+
loadUserData: g,
|
|
1144
|
+
refreshUser: f,
|
|
1145
|
+
userRole: V,
|
|
1146
|
+
userPermissions: w,
|
|
1147
|
+
availableRoles: I,
|
|
1148
|
+
rolesLoading: x,
|
|
1149
|
+
hasPermission: me,
|
|
1150
|
+
hasAnyPermission: ($) => $.some((U) => me(U)),
|
|
1151
|
+
hasAllPermissions: ($) => $.every((U) => me(U)),
|
|
1152
|
+
getUserPermissionStrings: () => w || [],
|
|
1153
|
+
refreshRoles: Fe
|
|
917
1154
|
};
|
|
918
1155
|
}, [
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
1156
|
+
M,
|
|
1157
|
+
u,
|
|
1158
|
+
T,
|
|
1159
|
+
R,
|
|
1160
|
+
H,
|
|
1161
|
+
G,
|
|
924
1162
|
t,
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
1163
|
+
s,
|
|
1164
|
+
a,
|
|
1165
|
+
p,
|
|
1166
|
+
I,
|
|
1167
|
+
b,
|
|
1168
|
+
h,
|
|
1169
|
+
L,
|
|
1170
|
+
V,
|
|
1171
|
+
w,
|
|
1172
|
+
q,
|
|
930
1173
|
E
|
|
931
1174
|
]);
|
|
932
|
-
return
|
|
1175
|
+
return te(() => {
|
|
933
1176
|
!i.initialRoles && t && (async () => {
|
|
934
1177
|
try {
|
|
935
1178
|
P(!0);
|
|
936
|
-
const
|
|
937
|
-
|
|
938
|
-
} catch (
|
|
939
|
-
console.error("Failed to fetch roles:",
|
|
1179
|
+
const f = new re(r), d = new Se(f), { roles: c } = await d.getRolesByApp(t);
|
|
1180
|
+
A(c);
|
|
1181
|
+
} catch (f) {
|
|
1182
|
+
console.error("Failed to fetch roles:", f);
|
|
940
1183
|
} finally {
|
|
941
1184
|
P(!1);
|
|
942
1185
|
}
|
|
943
1186
|
})();
|
|
944
|
-
}, [t, r, i.initialRoles]),
|
|
945
|
-
const
|
|
946
|
-
|
|
947
|
-
}, [
|
|
1187
|
+
}, [t, r, i.initialRoles]), te(() => {
|
|
1188
|
+
const g = u.getUser();
|
|
1189
|
+
g && u.hasValidSession() && m(g);
|
|
1190
|
+
}, [u]), te(() => {
|
|
1191
|
+
!b && !h && o.loadUserData().catch(() => {
|
|
1192
|
+
});
|
|
1193
|
+
}, [b, h, o]), te(() => {
|
|
1194
|
+
if (!u.hasValidSession() || !b)
|
|
1195
|
+
return;
|
|
1196
|
+
const g = setInterval(() => {
|
|
1197
|
+
o.loadUserData().catch(() => {
|
|
1198
|
+
});
|
|
1199
|
+
}, E);
|
|
1200
|
+
return () => clearInterval(g);
|
|
1201
|
+
}, [u, b, o, E]), /* @__PURE__ */ n(Te.Provider, { value: o, children: e });
|
|
948
1202
|
}
|
|
949
|
-
function
|
|
950
|
-
const i =
|
|
1203
|
+
function oe() {
|
|
1204
|
+
const i = ue(Te);
|
|
951
1205
|
if (!i)
|
|
952
1206
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
953
1207
|
return i;
|
|
954
1208
|
}
|
|
955
|
-
class
|
|
1209
|
+
class ze {
|
|
956
1210
|
constructor(e, t) {
|
|
957
1211
|
this.httpService = e, this.sessionManager = t;
|
|
958
1212
|
}
|
|
@@ -973,12 +1227,12 @@ class Ee {
|
|
|
973
1227
|
throw new Error("SessionManager is required for private endpoints");
|
|
974
1228
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
975
1229
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
976
|
-
const
|
|
1230
|
+
const s = `/feature-flags/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
|
|
977
1231
|
headers: t
|
|
978
1232
|
});
|
|
979
1233
|
return {
|
|
980
|
-
featureFlags:
|
|
981
|
-
meta:
|
|
1234
|
+
featureFlags: a.data,
|
|
1235
|
+
meta: a.meta
|
|
982
1236
|
};
|
|
983
1237
|
}
|
|
984
1238
|
async getFeatureFlagById(e) {
|
|
@@ -1015,8 +1269,8 @@ class Ee {
|
|
|
1015
1269
|
throw new Error("Tenant ID and App ID are required");
|
|
1016
1270
|
const r = new URLSearchParams();
|
|
1017
1271
|
r.append("tenantId", e), r.append("appId", t);
|
|
1018
|
-
const
|
|
1019
|
-
return (await this.httpService.get(
|
|
1272
|
+
const s = `/tenant-feature-flags${r.toString() ? `?${r.toString()}` : ""}`;
|
|
1273
|
+
return (await this.httpService.get(s, {
|
|
1020
1274
|
headers: { "X-Tenant-ID": e }
|
|
1021
1275
|
})).data;
|
|
1022
1276
|
}
|
|
@@ -1024,66 +1278,66 @@ class Ee {
|
|
|
1024
1278
|
async getTenantFeatureFlag(e, t, r) {
|
|
1025
1279
|
if (!e || !t || !r)
|
|
1026
1280
|
throw new Error("Flag Key, Tenant ID and App ID are required");
|
|
1027
|
-
const
|
|
1028
|
-
|
|
1029
|
-
const
|
|
1030
|
-
return (await this.httpService.get(
|
|
1281
|
+
const s = new URLSearchParams();
|
|
1282
|
+
s.append("tenantId", t), s.append("appId", r);
|
|
1283
|
+
const a = `/tenant-feature-flags/${e}${s.toString() ? `?${s.toString()}` : ""}`;
|
|
1284
|
+
return (await this.httpService.get(a, {
|
|
1031
1285
|
headers: { "X-Tenant-ID": t }
|
|
1032
1286
|
})).data;
|
|
1033
1287
|
}
|
|
1034
1288
|
}
|
|
1035
|
-
const
|
|
1036
|
-
function
|
|
1037
|
-
const { baseUrl: t, appId: r } =
|
|
1038
|
-
const
|
|
1039
|
-
return new
|
|
1040
|
-
}, [t]),
|
|
1041
|
-
if (!(
|
|
1042
|
-
|
|
1289
|
+
const Me = de(null);
|
|
1290
|
+
function Tt({ config: i = {}, children: e }) {
|
|
1291
|
+
const { baseUrl: t, appId: r } = he(), { tenant: s } = se(), [a, p] = v([]), [I, A] = v(!1), [x, P] = v(null), b = Q(() => {
|
|
1292
|
+
const S = new re(t);
|
|
1293
|
+
return new ze(S);
|
|
1294
|
+
}, [t]), m = async () => {
|
|
1295
|
+
if (!(s != null && s.id)) {
|
|
1296
|
+
p([]);
|
|
1043
1297
|
return;
|
|
1044
1298
|
}
|
|
1045
|
-
|
|
1299
|
+
A(!0), P(null);
|
|
1046
1300
|
try {
|
|
1047
|
-
const
|
|
1048
|
-
|
|
1049
|
-
} catch (
|
|
1050
|
-
const
|
|
1051
|
-
|
|
1301
|
+
const S = await b.getTenantFeatureFlags(s.id, r);
|
|
1302
|
+
p(S);
|
|
1303
|
+
} catch (S) {
|
|
1304
|
+
const L = S instanceof Error ? S.message : "Failed to fetch feature flags";
|
|
1305
|
+
P(L), i.onError && i.onError(S instanceof Error ? S : new Error(L));
|
|
1052
1306
|
} finally {
|
|
1053
|
-
|
|
1307
|
+
A(!1);
|
|
1054
1308
|
}
|
|
1055
1309
|
};
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
const
|
|
1059
|
-
return () => clearInterval(
|
|
1060
|
-
}, [
|
|
1061
|
-
const
|
|
1062
|
-
featureFlags:
|
|
1063
|
-
loading:
|
|
1064
|
-
error:
|
|
1065
|
-
isEnabled: (
|
|
1066
|
-
const
|
|
1067
|
-
return (
|
|
1310
|
+
te(() => {
|
|
1311
|
+
m();
|
|
1312
|
+
const S = i.refreshInterval || 5 * 60 * 1e3, L = setInterval(m, S);
|
|
1313
|
+
return () => clearInterval(L);
|
|
1314
|
+
}, [s == null ? void 0 : s.id, i.refreshInterval]);
|
|
1315
|
+
const h = Q(() => ({
|
|
1316
|
+
featureFlags: a,
|
|
1317
|
+
loading: I,
|
|
1318
|
+
error: x,
|
|
1319
|
+
isEnabled: (k) => {
|
|
1320
|
+
const u = a.find((T) => T.key === k);
|
|
1321
|
+
return (u == null ? void 0 : u.value) === !0;
|
|
1068
1322
|
},
|
|
1069
|
-
getFlag: (
|
|
1070
|
-
getFlagState: (
|
|
1071
|
-
const
|
|
1072
|
-
return
|
|
1323
|
+
getFlag: (k) => a.find((u) => u.key === k),
|
|
1324
|
+
getFlagState: (k) => {
|
|
1325
|
+
const u = a.find((T) => T.key === k);
|
|
1326
|
+
return u ? u.value ? "enabled" : "disabled" : "not_found";
|
|
1073
1327
|
},
|
|
1074
1328
|
refresh: async () => {
|
|
1075
|
-
await
|
|
1329
|
+
await m();
|
|
1076
1330
|
}
|
|
1077
|
-
}), [
|
|
1078
|
-
return /* @__PURE__ */
|
|
1331
|
+
}), [a, I, x]);
|
|
1332
|
+
return /* @__PURE__ */ n(Me.Provider, { value: h, children: e });
|
|
1079
1333
|
}
|
|
1080
|
-
function
|
|
1081
|
-
const i =
|
|
1334
|
+
function Oe() {
|
|
1335
|
+
const i = ue(Me);
|
|
1082
1336
|
if (!i)
|
|
1083
1337
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1084
1338
|
return i;
|
|
1085
1339
|
}
|
|
1086
|
-
class
|
|
1340
|
+
class je {
|
|
1087
1341
|
constructor(e, t) {
|
|
1088
1342
|
this.httpService = e, this.sessionManager = t;
|
|
1089
1343
|
}
|
|
@@ -1149,64 +1403,64 @@ class Fe {
|
|
|
1149
1403
|
)).data;
|
|
1150
1404
|
}
|
|
1151
1405
|
}
|
|
1152
|
-
const
|
|
1153
|
-
function
|
|
1154
|
-
const { baseUrl: t } =
|
|
1155
|
-
const
|
|
1156
|
-
return new
|
|
1157
|
-
}, [t]),
|
|
1406
|
+
const Ie = de(void 0);
|
|
1407
|
+
function Mt({ config: i = {}, children: e }) {
|
|
1408
|
+
const { baseUrl: t } = he(), { tenant: r } = se(), [s, a] = v(null), [p, I] = v(!1), [A, x] = v(null), P = Q(() => {
|
|
1409
|
+
const h = new re(t);
|
|
1410
|
+
return new je(h);
|
|
1411
|
+
}, [t]), b = async () => {
|
|
1158
1412
|
if (!(r != null && r.id)) {
|
|
1159
|
-
|
|
1413
|
+
a(null);
|
|
1160
1414
|
return;
|
|
1161
1415
|
}
|
|
1162
|
-
|
|
1416
|
+
I(!0), x(null);
|
|
1163
1417
|
try {
|
|
1164
|
-
const
|
|
1165
|
-
|
|
1166
|
-
} catch (
|
|
1167
|
-
const
|
|
1168
|
-
|
|
1418
|
+
const h = await P.getTenantSubscriptionFeatures(r.id);
|
|
1419
|
+
a(h);
|
|
1420
|
+
} catch (h) {
|
|
1421
|
+
const S = h instanceof Error ? h.message : "Failed to fetch subscription";
|
|
1422
|
+
x(S), i.onError && i.onError(h instanceof Error ? h : new Error(S));
|
|
1169
1423
|
} finally {
|
|
1170
|
-
|
|
1424
|
+
I(!1);
|
|
1171
1425
|
}
|
|
1172
1426
|
};
|
|
1173
|
-
|
|
1174
|
-
if (
|
|
1175
|
-
const
|
|
1176
|
-
return () => clearInterval(
|
|
1427
|
+
te(() => {
|
|
1428
|
+
if (b(), !i.refreshInterval) return;
|
|
1429
|
+
const h = i.refreshInterval || 10 * 60 * 1e3, S = setInterval(b, h);
|
|
1430
|
+
return () => clearInterval(S);
|
|
1177
1431
|
}, [r == null ? void 0 : r.id, i.refreshInterval]);
|
|
1178
|
-
const
|
|
1179
|
-
const
|
|
1432
|
+
const m = Q(() => {
|
|
1433
|
+
const h = (s == null ? void 0 : s.features) || [];
|
|
1180
1434
|
return {
|
|
1181
|
-
subscription:
|
|
1182
|
-
features:
|
|
1183
|
-
loading:
|
|
1184
|
-
error:
|
|
1185
|
-
isFeatureEnabled: (
|
|
1186
|
-
const
|
|
1187
|
-
return
|
|
1435
|
+
subscription: s,
|
|
1436
|
+
features: h,
|
|
1437
|
+
loading: p,
|
|
1438
|
+
error: A,
|
|
1439
|
+
isFeatureEnabled: (u) => {
|
|
1440
|
+
const T = h.find((R) => R.key === u);
|
|
1441
|
+
return T ? T.type === "BOOLEAN" || T.type === "boolean" ? T.value === !0 : !!T.value : !1;
|
|
1188
1442
|
},
|
|
1189
|
-
getFeature: (
|
|
1190
|
-
getFeatureValue: (
|
|
1191
|
-
const R =
|
|
1192
|
-
return R ? R.value :
|
|
1443
|
+
getFeature: (u) => h.find((T) => T.key === u),
|
|
1444
|
+
getFeatureValue: (u, T) => {
|
|
1445
|
+
const R = h.find((H) => H.key === u);
|
|
1446
|
+
return R ? R.value : T;
|
|
1193
1447
|
},
|
|
1194
|
-
hasAllowedPlan: (
|
|
1448
|
+
hasAllowedPlan: (u) => !s || !s.isActive ? !1 : u.includes(s.planId),
|
|
1195
1449
|
refresh: async () => {
|
|
1196
|
-
await
|
|
1450
|
+
await b();
|
|
1197
1451
|
}
|
|
1198
1452
|
};
|
|
1199
|
-
}, [
|
|
1200
|
-
return /* @__PURE__ */
|
|
1453
|
+
}, [s, p, A]);
|
|
1454
|
+
return /* @__PURE__ */ n(Ie.Provider, { value: m, children: e });
|
|
1201
1455
|
}
|
|
1202
|
-
function
|
|
1203
|
-
const i =
|
|
1456
|
+
function Ve() {
|
|
1457
|
+
const i = ue(Ie);
|
|
1204
1458
|
if (i === void 0)
|
|
1205
1459
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1206
1460
|
return i;
|
|
1207
1461
|
}
|
|
1208
|
-
var
|
|
1209
|
-
const
|
|
1462
|
+
var ie = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(ie || {});
|
|
1463
|
+
const ve = () => /* @__PURE__ */ l(
|
|
1210
1464
|
"div",
|
|
1211
1465
|
{
|
|
1212
1466
|
style: {
|
|
@@ -1222,10 +1476,10 @@ const ue = () => /* @__PURE__ */ c(
|
|
|
1222
1476
|
margin: "20px 0"
|
|
1223
1477
|
},
|
|
1224
1478
|
children: [
|
|
1225
|
-
/* @__PURE__ */
|
|
1226
|
-
/* @__PURE__ */
|
|
1227
|
-
/* @__PURE__ */
|
|
1228
|
-
/* @__PURE__ */
|
|
1479
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "🔒" }),
|
|
1480
|
+
/* @__PURE__ */ n("h3", { style: { color: "#495057", marginBottom: "10px" }, children: "Access Required" }),
|
|
1481
|
+
/* @__PURE__ */ n("p", { style: { color: "#6c757d", fontSize: "14px", marginBottom: "15px" }, children: "You need to be signed in to view this content." }),
|
|
1482
|
+
/* @__PURE__ */ n(
|
|
1229
1483
|
"button",
|
|
1230
1484
|
{
|
|
1231
1485
|
style: {
|
|
@@ -1243,11 +1497,11 @@ const ue = () => /* @__PURE__ */ c(
|
|
|
1243
1497
|
)
|
|
1244
1498
|
]
|
|
1245
1499
|
}
|
|
1246
|
-
),
|
|
1500
|
+
), xe = ({
|
|
1247
1501
|
userType: i,
|
|
1248
1502
|
minUserType: e,
|
|
1249
1503
|
missingPermissions: t
|
|
1250
|
-
}) => /* @__PURE__ */
|
|
1504
|
+
}) => /* @__PURE__ */ l(
|
|
1251
1505
|
"div",
|
|
1252
1506
|
{
|
|
1253
1507
|
style: {
|
|
@@ -1263,57 +1517,57 @@ const ue = () => /* @__PURE__ */ c(
|
|
|
1263
1517
|
margin: "20px 0"
|
|
1264
1518
|
},
|
|
1265
1519
|
children: [
|
|
1266
|
-
/* @__PURE__ */
|
|
1267
|
-
/* @__PURE__ */
|
|
1268
|
-
e && i ? /* @__PURE__ */
|
|
1269
|
-
/* @__PURE__ */
|
|
1520
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
|
|
1521
|
+
/* @__PURE__ */ n("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
|
|
1522
|
+
e && i ? /* @__PURE__ */ l(N, { children: [
|
|
1523
|
+
/* @__PURE__ */ l("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
|
|
1270
1524
|
"This content requires ",
|
|
1271
|
-
/* @__PURE__ */
|
|
1525
|
+
/* @__PURE__ */ n("strong", { children: e }),
|
|
1272
1526
|
" access level or higher."
|
|
1273
1527
|
] }),
|
|
1274
|
-
/* @__PURE__ */
|
|
1528
|
+
/* @__PURE__ */ l("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1275
1529
|
"Your current access level: ",
|
|
1276
|
-
/* @__PURE__ */
|
|
1530
|
+
/* @__PURE__ */ n("strong", { children: i })
|
|
1277
1531
|
] })
|
|
1278
|
-
] }) : /* @__PURE__ */
|
|
1279
|
-
/* @__PURE__ */
|
|
1280
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1532
|
+
] }) : /* @__PURE__ */ l(N, { children: [
|
|
1533
|
+
/* @__PURE__ */ n("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
|
|
1534
|
+
t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1281
1535
|
"Required permissions: ",
|
|
1282
|
-
/* @__PURE__ */
|
|
1536
|
+
/* @__PURE__ */ n("strong", { children: t.join(", ") })
|
|
1283
1537
|
] })
|
|
1284
1538
|
] })
|
|
1285
1539
|
]
|
|
1286
1540
|
}
|
|
1287
|
-
),
|
|
1541
|
+
), We = (i, e) => {
|
|
1288
1542
|
const t = {
|
|
1289
|
-
[
|
|
1290
|
-
[
|
|
1291
|
-
[
|
|
1543
|
+
[ie.USER]: 1,
|
|
1544
|
+
[ie.TENANT_ADMIN]: 2,
|
|
1545
|
+
[ie.SUPERUSER]: 3
|
|
1292
1546
|
};
|
|
1293
1547
|
return t[i] >= t[e];
|
|
1294
1548
|
};
|
|
1295
|
-
function
|
|
1549
|
+
function It({
|
|
1296
1550
|
children: i,
|
|
1297
1551
|
fallback: e,
|
|
1298
1552
|
minUserType: t,
|
|
1299
1553
|
requiredPermissions: r,
|
|
1300
|
-
requireAllPermissions:
|
|
1554
|
+
requireAllPermissions: s = !1
|
|
1301
1555
|
}) {
|
|
1302
|
-
const { hasValidSession:
|
|
1303
|
-
if (!
|
|
1304
|
-
return /* @__PURE__ */
|
|
1305
|
-
const
|
|
1306
|
-
if (!
|
|
1307
|
-
return /* @__PURE__ */
|
|
1308
|
-
if (t && !
|
|
1309
|
-
return /* @__PURE__ */
|
|
1310
|
-
if (r && r.length > 0 && !(
|
|
1311
|
-
const
|
|
1312
|
-
return /* @__PURE__ */
|
|
1313
|
-
}
|
|
1314
|
-
return /* @__PURE__ */
|
|
1556
|
+
const { hasValidSession: a, sessionManager: p, hasPermission: I, hasAnyPermission: A, hasAllPermissions: x } = oe();
|
|
1557
|
+
if (!a())
|
|
1558
|
+
return /* @__PURE__ */ n(N, { children: e || /* @__PURE__ */ n(ve, {}) });
|
|
1559
|
+
const P = p.getUser();
|
|
1560
|
+
if (!P)
|
|
1561
|
+
return /* @__PURE__ */ n(N, { children: e || /* @__PURE__ */ n(ve, {}) });
|
|
1562
|
+
if (t && !We(P.userType, t))
|
|
1563
|
+
return /* @__PURE__ */ n(xe, { userType: P.userType, minUserType: t });
|
|
1564
|
+
if (r && r.length > 0 && !(s ? x(r) : A(r))) {
|
|
1565
|
+
const m = r.filter((h) => !I(h)).map((h) => typeof h == "string" ? h : h.name);
|
|
1566
|
+
return /* @__PURE__ */ n(xe, { missingPermissions: m });
|
|
1567
|
+
}
|
|
1568
|
+
return /* @__PURE__ */ n(N, { children: i });
|
|
1315
1569
|
}
|
|
1316
|
-
const
|
|
1570
|
+
const Ge = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1317
1571
|
"div",
|
|
1318
1572
|
{
|
|
1319
1573
|
style: {
|
|
@@ -1326,7 +1580,7 @@ const Ce = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
|
1326
1580
|
backgroundColor: "#f9fafb",
|
|
1327
1581
|
textAlign: "center"
|
|
1328
1582
|
},
|
|
1329
|
-
children: /* @__PURE__ */
|
|
1583
|
+
children: /* @__PURE__ */ l(
|
|
1330
1584
|
"div",
|
|
1331
1585
|
{
|
|
1332
1586
|
style: {
|
|
@@ -1337,10 +1591,10 @@ const Ce = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
|
1337
1591
|
maxWidth: "400px"
|
|
1338
1592
|
},
|
|
1339
1593
|
children: [
|
|
1340
|
-
/* @__PURE__ */
|
|
1341
|
-
/* @__PURE__ */
|
|
1342
|
-
/* @__PURE__ */
|
|
1343
|
-
/* @__PURE__ */
|
|
1594
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
|
|
1595
|
+
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
|
|
1596
|
+
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
|
|
1597
|
+
/* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1344
1598
|
"Redirecting to ",
|
|
1345
1599
|
i,
|
|
1346
1600
|
"..."
|
|
@@ -1349,11 +1603,11 @@ const Ce = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
|
1349
1603
|
}
|
|
1350
1604
|
)
|
|
1351
1605
|
}
|
|
1352
|
-
),
|
|
1606
|
+
), ke = ({
|
|
1353
1607
|
userType: i,
|
|
1354
1608
|
minUserType: e,
|
|
1355
1609
|
missingPermissions: t
|
|
1356
|
-
}) => /* @__PURE__ */
|
|
1610
|
+
}) => /* @__PURE__ */ n(
|
|
1357
1611
|
"div",
|
|
1358
1612
|
{
|
|
1359
1613
|
style: {
|
|
@@ -1366,7 +1620,7 @@ const Ce = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
|
1366
1620
|
backgroundColor: "#f9fafb",
|
|
1367
1621
|
textAlign: "center"
|
|
1368
1622
|
},
|
|
1369
|
-
children: /* @__PURE__ */
|
|
1623
|
+
children: /* @__PURE__ */ l(
|
|
1370
1624
|
"div",
|
|
1371
1625
|
{
|
|
1372
1626
|
style: {
|
|
@@ -1377,63 +1631,63 @@ const Ce = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
|
1377
1631
|
maxWidth: "400px"
|
|
1378
1632
|
},
|
|
1379
1633
|
children: [
|
|
1380
|
-
/* @__PURE__ */
|
|
1381
|
-
/* @__PURE__ */
|
|
1382
|
-
e && i ? /* @__PURE__ */
|
|
1383
|
-
/* @__PURE__ */
|
|
1634
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
|
|
1635
|
+
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
|
|
1636
|
+
e && i ? /* @__PURE__ */ l(N, { children: [
|
|
1637
|
+
/* @__PURE__ */ l("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
|
|
1384
1638
|
"This page requires ",
|
|
1385
|
-
/* @__PURE__ */
|
|
1639
|
+
/* @__PURE__ */ n("strong", { children: e }),
|
|
1386
1640
|
" access level or higher."
|
|
1387
1641
|
] }),
|
|
1388
|
-
/* @__PURE__ */
|
|
1642
|
+
/* @__PURE__ */ l("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1389
1643
|
"Your current access level: ",
|
|
1390
|
-
/* @__PURE__ */
|
|
1644
|
+
/* @__PURE__ */ n("strong", { children: i })
|
|
1391
1645
|
] })
|
|
1392
|
-
] }) : /* @__PURE__ */
|
|
1393
|
-
/* @__PURE__ */
|
|
1394
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1646
|
+
] }) : /* @__PURE__ */ l(N, { children: [
|
|
1647
|
+
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
|
|
1648
|
+
t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1395
1649
|
"Required permissions: ",
|
|
1396
|
-
/* @__PURE__ */
|
|
1650
|
+
/* @__PURE__ */ n("strong", { children: t.join(", ") })
|
|
1397
1651
|
] })
|
|
1398
1652
|
] })
|
|
1399
1653
|
]
|
|
1400
1654
|
}
|
|
1401
1655
|
)
|
|
1402
1656
|
}
|
|
1403
|
-
),
|
|
1657
|
+
), Ke = (i, e) => {
|
|
1404
1658
|
const t = {
|
|
1405
|
-
[
|
|
1406
|
-
[
|
|
1407
|
-
[
|
|
1659
|
+
[ie.USER]: 1,
|
|
1660
|
+
[ie.TENANT_ADMIN]: 2,
|
|
1661
|
+
[ie.SUPERUSER]: 3
|
|
1408
1662
|
};
|
|
1409
1663
|
return t[i] >= t[e];
|
|
1410
1664
|
};
|
|
1411
|
-
function
|
|
1665
|
+
function Et({
|
|
1412
1666
|
children: i,
|
|
1413
1667
|
redirectTo: e = "/login",
|
|
1414
1668
|
minUserType: t,
|
|
1415
1669
|
requiredPermissions: r,
|
|
1416
|
-
requireAllPermissions:
|
|
1417
|
-
fallback:
|
|
1670
|
+
requireAllPermissions: s = !1,
|
|
1671
|
+
fallback: a
|
|
1418
1672
|
}) {
|
|
1419
|
-
const { hasValidSession:
|
|
1420
|
-
if (!
|
|
1421
|
-
return
|
|
1422
|
-
/* @__PURE__ */
|
|
1423
|
-
/* @__PURE__ */
|
|
1673
|
+
const { hasValidSession: p, sessionManager: I, hasPermission: A, hasAnyPermission: x, hasAllPermissions: P } = oe(), b = we();
|
|
1674
|
+
if (!p())
|
|
1675
|
+
return a ? /* @__PURE__ */ n(N, { children: a }) : /* @__PURE__ */ l(N, { children: [
|
|
1676
|
+
/* @__PURE__ */ n(Ge, { redirectPath: e }),
|
|
1677
|
+
/* @__PURE__ */ n(pe, { to: e, state: { from: b.pathname }, replace: !0 })
|
|
1424
1678
|
] });
|
|
1425
|
-
const
|
|
1426
|
-
if (!
|
|
1427
|
-
return /* @__PURE__ */
|
|
1428
|
-
if (t &&
|
|
1429
|
-
return /* @__PURE__ */
|
|
1430
|
-
if (r && r.length > 0 && !(
|
|
1431
|
-
const
|
|
1432
|
-
return /* @__PURE__ */
|
|
1433
|
-
}
|
|
1434
|
-
return /* @__PURE__ */
|
|
1679
|
+
const m = I.getUser();
|
|
1680
|
+
if (!m)
|
|
1681
|
+
return /* @__PURE__ */ n(pe, { to: e, state: { from: b.pathname }, replace: !0 });
|
|
1682
|
+
if (t && !Ke(m.userType, t))
|
|
1683
|
+
return /* @__PURE__ */ n(ke, { userType: m.userType, minUserType: t });
|
|
1684
|
+
if (r && r.length > 0 && !(s ? P(r) : x(r))) {
|
|
1685
|
+
const S = r.filter((L) => !A(L)).map((L) => typeof L == "string" ? L : L.name);
|
|
1686
|
+
return /* @__PURE__ */ n(ke, { missingPermissions: S });
|
|
1687
|
+
}
|
|
1688
|
+
return /* @__PURE__ */ n(N, { children: i });
|
|
1435
1689
|
}
|
|
1436
|
-
const
|
|
1690
|
+
const _e = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1437
1691
|
"div",
|
|
1438
1692
|
{
|
|
1439
1693
|
style: {
|
|
@@ -1446,7 +1700,7 @@ const Le = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
|
1446
1700
|
backgroundColor: "#f9fafb",
|
|
1447
1701
|
textAlign: "center"
|
|
1448
1702
|
},
|
|
1449
|
-
children: /* @__PURE__ */
|
|
1703
|
+
children: /* @__PURE__ */ l(
|
|
1450
1704
|
"div",
|
|
1451
1705
|
{
|
|
1452
1706
|
style: {
|
|
@@ -1457,10 +1711,10 @@ const Le = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
|
1457
1711
|
maxWidth: "400px"
|
|
1458
1712
|
},
|
|
1459
1713
|
children: [
|
|
1460
|
-
/* @__PURE__ */
|
|
1461
|
-
/* @__PURE__ */
|
|
1462
|
-
/* @__PURE__ */
|
|
1463
|
-
/* @__PURE__ */
|
|
1714
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
|
|
1715
|
+
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
|
|
1716
|
+
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
|
|
1717
|
+
/* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1464
1718
|
"Redirecting to ",
|
|
1465
1719
|
i,
|
|
1466
1720
|
"..."
|
|
@@ -1470,14 +1724,14 @@ const Le = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
|
1470
1724
|
)
|
|
1471
1725
|
}
|
|
1472
1726
|
);
|
|
1473
|
-
function
|
|
1474
|
-
const { tenant: r, isLoading:
|
|
1475
|
-
return
|
|
1476
|
-
/* @__PURE__ */
|
|
1477
|
-
/* @__PURE__ */
|
|
1727
|
+
function Rt({ children: i, redirectTo: e = "/", fallback: t }) {
|
|
1728
|
+
const { tenant: r, isLoading: s, error: a } = se(), p = we();
|
|
1729
|
+
return s || a ? null : r ? /* @__PURE__ */ n(N, { children: i }) : t ? /* @__PURE__ */ n(N, { children: t }) : /* @__PURE__ */ l(N, { children: [
|
|
1730
|
+
/* @__PURE__ */ n(_e, { redirectPath: e }),
|
|
1731
|
+
/* @__PURE__ */ n(pe, { to: e, state: { from: p.pathname }, replace: !0 })
|
|
1478
1732
|
] });
|
|
1479
1733
|
}
|
|
1480
|
-
const
|
|
1734
|
+
const Je = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1481
1735
|
"div",
|
|
1482
1736
|
{
|
|
1483
1737
|
style: {
|
|
@@ -1490,7 +1744,7 @@ const De = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
|
1490
1744
|
backgroundColor: "#f9fafb",
|
|
1491
1745
|
textAlign: "center"
|
|
1492
1746
|
},
|
|
1493
|
-
children: /* @__PURE__ */
|
|
1747
|
+
children: /* @__PURE__ */ l(
|
|
1494
1748
|
"div",
|
|
1495
1749
|
{
|
|
1496
1750
|
style: {
|
|
@@ -1501,10 +1755,10 @@ const De = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
|
1501
1755
|
maxWidth: "400px"
|
|
1502
1756
|
},
|
|
1503
1757
|
children: [
|
|
1504
|
-
/* @__PURE__ */
|
|
1505
|
-
/* @__PURE__ */
|
|
1506
|
-
/* @__PURE__ */
|
|
1507
|
-
/* @__PURE__ */
|
|
1758
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
|
|
1759
|
+
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
|
|
1760
|
+
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
|
|
1761
|
+
/* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1508
1762
|
"Redirecting to ",
|
|
1509
1763
|
i,
|
|
1510
1764
|
"..."
|
|
@@ -1514,14 +1768,14 @@ const De = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
|
1514
1768
|
)
|
|
1515
1769
|
}
|
|
1516
1770
|
);
|
|
1517
|
-
function
|
|
1518
|
-
const { tenant: r, isLoading:
|
|
1519
|
-
return
|
|
1520
|
-
/* @__PURE__ */
|
|
1521
|
-
/* @__PURE__ */
|
|
1522
|
-
] }) : /* @__PURE__ */
|
|
1771
|
+
function Ct({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
|
|
1772
|
+
const { tenant: r, isLoading: s, error: a } = se(), p = we();
|
|
1773
|
+
return s || a ? null : r ? t ? /* @__PURE__ */ n(N, { children: t }) : /* @__PURE__ */ l(N, { children: [
|
|
1774
|
+
/* @__PURE__ */ n(Je, { redirectPath: e }),
|
|
1775
|
+
/* @__PURE__ */ n(pe, { to: e, state: { from: p.pathname }, replace: !0 })
|
|
1776
|
+
] }) : /* @__PURE__ */ n(N, { children: i });
|
|
1523
1777
|
}
|
|
1524
|
-
const
|
|
1778
|
+
const Ye = () => /* @__PURE__ */ l(
|
|
1525
1779
|
"div",
|
|
1526
1780
|
{
|
|
1527
1781
|
style: {
|
|
@@ -1533,19 +1787,19 @@ const Be = () => /* @__PURE__ */ c(
|
|
|
1533
1787
|
color: "#dc2626"
|
|
1534
1788
|
},
|
|
1535
1789
|
children: [
|
|
1536
|
-
/* @__PURE__ */
|
|
1537
|
-
/* @__PURE__ */
|
|
1790
|
+
/* @__PURE__ */ n("h3", { style: { margin: "0 0 1rem 0" }, children: "🔒 Subscription Required" }),
|
|
1791
|
+
/* @__PURE__ */ n("p", { style: { margin: 0 }, children: "This feature requires a higher subscription plan. Please upgrade your plan to access this content." })
|
|
1538
1792
|
]
|
|
1539
1793
|
}
|
|
1540
1794
|
);
|
|
1541
|
-
function
|
|
1795
|
+
function Lt({
|
|
1542
1796
|
children: i,
|
|
1543
|
-
fallback: e = /* @__PURE__ */
|
|
1797
|
+
fallback: e = /* @__PURE__ */ n(Ye, {}),
|
|
1544
1798
|
allowedPlans: t,
|
|
1545
1799
|
requiredFeature: r
|
|
1546
1800
|
}) {
|
|
1547
|
-
const { subscription:
|
|
1548
|
-
return
|
|
1801
|
+
const { subscription: s, hasAllowedPlan: a, isFeatureEnabled: p, loading: I } = Ve();
|
|
1802
|
+
return I ? /* @__PURE__ */ n(
|
|
1549
1803
|
"div",
|
|
1550
1804
|
{
|
|
1551
1805
|
style: {
|
|
@@ -1555,9 +1809,9 @@ function ht({
|
|
|
1555
1809
|
},
|
|
1556
1810
|
children: "Loading subscription..."
|
|
1557
1811
|
}
|
|
1558
|
-
) :
|
|
1812
|
+
) : s ? s.isActive ? t && t.length > 0 && !a(t) ? /* @__PURE__ */ n(N, { children: e }) : r && !p(r) ? /* @__PURE__ */ n(N, { children: e }) : /* @__PURE__ */ n(N, { children: i }) : /* @__PURE__ */ n(N, { children: e }) : /* @__PURE__ */ n(N, { children: e });
|
|
1559
1813
|
}
|
|
1560
|
-
const
|
|
1814
|
+
const Qe = ({ flagName: i }) => /* @__PURE__ */ l(
|
|
1561
1815
|
"div",
|
|
1562
1816
|
{
|
|
1563
1817
|
style: {
|
|
@@ -1574,9 +1828,9 @@ const qe = ({ flagName: i }) => /* @__PURE__ */ c(
|
|
|
1574
1828
|
color: "#6c757d"
|
|
1575
1829
|
},
|
|
1576
1830
|
children: [
|
|
1577
|
-
/* @__PURE__ */
|
|
1578
|
-
/* @__PURE__ */
|
|
1579
|
-
/* @__PURE__ */
|
|
1831
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
|
|
1832
|
+
/* @__PURE__ */ n("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
|
|
1833
|
+
/* @__PURE__ */ l("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
|
|
1580
1834
|
'Feature flag "',
|
|
1581
1835
|
i,
|
|
1582
1836
|
'" is disabled'
|
|
@@ -1584,9 +1838,9 @@ const qe = ({ flagName: i }) => /* @__PURE__ */ c(
|
|
|
1584
1838
|
]
|
|
1585
1839
|
}
|
|
1586
1840
|
);
|
|
1587
|
-
function
|
|
1588
|
-
const { isEnabled: r, loading:
|
|
1589
|
-
return
|
|
1841
|
+
function Ft({ name: i, children: e, fallback: t }) {
|
|
1842
|
+
const { isEnabled: r, loading: s } = Oe();
|
|
1843
|
+
return s ? /* @__PURE__ */ n(
|
|
1590
1844
|
"div",
|
|
1591
1845
|
{
|
|
1592
1846
|
style: {
|
|
@@ -1599,9 +1853,9 @@ function gt({ name: i, children: e, fallback: t }) {
|
|
|
1599
1853
|
},
|
|
1600
1854
|
children: "Loading feature flags..."
|
|
1601
1855
|
}
|
|
1602
|
-
) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */
|
|
1856
|
+
) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */ n(N, { children: e }) : /* @__PURE__ */ n(N, { children: t || /* @__PURE__ */ n(Qe, { flagName: i }) }));
|
|
1603
1857
|
}
|
|
1604
|
-
const
|
|
1858
|
+
const Xe = () => /* @__PURE__ */ l(
|
|
1605
1859
|
"svg",
|
|
1606
1860
|
{
|
|
1607
1861
|
width: "16",
|
|
@@ -1614,11 +1868,11 @@ const Ue = () => /* @__PURE__ */ c(
|
|
|
1614
1868
|
strokeLinejoin: "round",
|
|
1615
1869
|
style: { flexShrink: 0 },
|
|
1616
1870
|
children: [
|
|
1617
|
-
/* @__PURE__ */
|
|
1618
|
-
/* @__PURE__ */
|
|
1871
|
+
/* @__PURE__ */ n("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
|
|
1872
|
+
/* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "3" })
|
|
1619
1873
|
]
|
|
1620
1874
|
}
|
|
1621
|
-
),
|
|
1875
|
+
), Ze = () => /* @__PURE__ */ l(
|
|
1622
1876
|
"svg",
|
|
1623
1877
|
{
|
|
1624
1878
|
width: "16",
|
|
@@ -1631,26 +1885,28 @@ const Ue = () => /* @__PURE__ */ c(
|
|
|
1631
1885
|
strokeLinejoin: "round",
|
|
1632
1886
|
style: { flexShrink: 0 },
|
|
1633
1887
|
children: [
|
|
1634
|
-
/* @__PURE__ */
|
|
1635
|
-
/* @__PURE__ */
|
|
1888
|
+
/* @__PURE__ */ n("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" }),
|
|
1889
|
+
/* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
1636
1890
|
]
|
|
1637
1891
|
}
|
|
1638
|
-
),
|
|
1639
|
-
showPassword: /* @__PURE__ */
|
|
1640
|
-
hidePassword: /* @__PURE__ */
|
|
1641
|
-
},
|
|
1892
|
+
), et = {
|
|
1893
|
+
showPassword: /* @__PURE__ */ n(Xe, {}),
|
|
1894
|
+
hidePassword: /* @__PURE__ */ n(Ze, {})
|
|
1895
|
+
}, tt = {
|
|
1642
1896
|
title: "Sign In",
|
|
1643
|
-
|
|
1644
|
-
|
|
1897
|
+
usernameLabel: "Email or Phone",
|
|
1898
|
+
usernamePlaceholder: "Enter your email or phone number",
|
|
1645
1899
|
passwordLabel: "Password",
|
|
1646
1900
|
passwordPlaceholder: "Enter your password",
|
|
1647
1901
|
submitButton: "Sign In",
|
|
1648
1902
|
forgotPasswordLink: "Forgot your password?",
|
|
1649
1903
|
signupLink: "Sign up here",
|
|
1650
1904
|
signupText: "Don't have an account?",
|
|
1651
|
-
|
|
1905
|
+
magicLinkText: "Prefer passwordless?",
|
|
1906
|
+
magicLinkLink: "Use Magic Link",
|
|
1907
|
+
errorMessage: "Invalid credentials",
|
|
1652
1908
|
loadingText: "Signing in..."
|
|
1653
|
-
},
|
|
1909
|
+
}, rt = {
|
|
1654
1910
|
container: {
|
|
1655
1911
|
maxWidth: "400px",
|
|
1656
1912
|
width: "100%",
|
|
@@ -1757,124 +2013,142 @@ const Ue = () => /* @__PURE__ */ c(
|
|
|
1757
2013
|
fontSize: "0.875rem"
|
|
1758
2014
|
}
|
|
1759
2015
|
};
|
|
1760
|
-
function
|
|
2016
|
+
function $t({
|
|
1761
2017
|
copy: i = {},
|
|
1762
2018
|
styles: e = {},
|
|
1763
2019
|
icons: t = {},
|
|
1764
2020
|
onSuccess: r,
|
|
1765
|
-
onError:
|
|
1766
|
-
onForgotPassword:
|
|
1767
|
-
onSignupClick:
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
2021
|
+
onError: s,
|
|
2022
|
+
onForgotPassword: a,
|
|
2023
|
+
onSignupClick: p,
|
|
2024
|
+
onMagicLinkClick: I,
|
|
2025
|
+
showForgotPassword: A = !0,
|
|
2026
|
+
showSignupLink: x = !0,
|
|
2027
|
+
showMagicLinkOption: P = !0,
|
|
2028
|
+
className: b
|
|
1771
2029
|
}) {
|
|
1772
|
-
const [
|
|
1773
|
-
const
|
|
1774
|
-
return
|
|
1775
|
-
},
|
|
1776
|
-
if (
|
|
1777
|
-
if (!(
|
|
1778
|
-
|
|
2030
|
+
const [m, h] = v(""), [S, L] = v(""), [C, q] = v(!1), [k, u] = v(!1), [T, R] = v(""), [H, G] = v({}), { login: F } = oe(), { tenant: V } = se(), w = { ...tt, ...i }, M = { ...rt, ...e }, E = { ...et, ...t }, o = () => {
|
|
2031
|
+
const c = {};
|
|
2032
|
+
return m.trim() || (c.username = !0), S.trim() || (c.password = !0), G(c), Object.keys(c).length === 0;
|
|
2033
|
+
}, g = async (c) => {
|
|
2034
|
+
if (c.preventDefault(), !!o()) {
|
|
2035
|
+
if (!(V != null && V.id)) {
|
|
2036
|
+
R("Tenant not found");
|
|
1779
2037
|
return;
|
|
1780
2038
|
}
|
|
1781
|
-
|
|
2039
|
+
u(!0), R("");
|
|
1782
2040
|
try {
|
|
1783
|
-
const
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
2041
|
+
const y = await F({
|
|
2042
|
+
username: m,
|
|
2043
|
+
password: S
|
|
2044
|
+
// tenantId inferred from context automatically
|
|
2045
|
+
});
|
|
2046
|
+
r == null || r(y);
|
|
2047
|
+
} catch (y) {
|
|
2048
|
+
const W = y.message || w.errorMessage;
|
|
2049
|
+
R(W), s == null || s(W);
|
|
1788
2050
|
} finally {
|
|
1789
|
-
|
|
2051
|
+
u(!1);
|
|
1790
2052
|
}
|
|
1791
2053
|
}
|
|
1792
|
-
},
|
|
1793
|
-
...
|
|
1794
|
-
...
|
|
1795
|
-
}),
|
|
1796
|
-
...
|
|
1797
|
-
...
|
|
1798
|
-
...!
|
|
2054
|
+
}, f = (c) => ({
|
|
2055
|
+
...M.input,
|
|
2056
|
+
...H[c] ? M.inputError : {}
|
|
2057
|
+
}), d = () => ({
|
|
2058
|
+
...M.button,
|
|
2059
|
+
...k ? M.buttonLoading : {},
|
|
2060
|
+
...!m || !S || k ? M.buttonDisabled : {}
|
|
1799
2061
|
});
|
|
1800
|
-
return /* @__PURE__ */
|
|
1801
|
-
/* @__PURE__ */
|
|
1802
|
-
/* @__PURE__ */
|
|
1803
|
-
/* @__PURE__ */
|
|
1804
|
-
/* @__PURE__ */
|
|
1805
|
-
/* @__PURE__ */
|
|
2062
|
+
return /* @__PURE__ */ l("div", { className: b, style: M.container, children: [
|
|
2063
|
+
/* @__PURE__ */ n("h2", { style: M.title, children: w.title }),
|
|
2064
|
+
/* @__PURE__ */ l("form", { onSubmit: g, style: M.form, children: [
|
|
2065
|
+
/* @__PURE__ */ l("div", { style: M.fieldGroup, children: [
|
|
2066
|
+
/* @__PURE__ */ n("label", { style: M.label, children: w.usernameLabel }),
|
|
2067
|
+
/* @__PURE__ */ n(
|
|
1806
2068
|
"input",
|
|
1807
2069
|
{
|
|
1808
|
-
id: "
|
|
1809
|
-
name: "
|
|
1810
|
-
type: "
|
|
1811
|
-
value:
|
|
1812
|
-
onChange: (
|
|
1813
|
-
h(
|
|
2070
|
+
id: "username",
|
|
2071
|
+
name: "username",
|
|
2072
|
+
type: "text",
|
|
2073
|
+
value: m,
|
|
2074
|
+
onChange: (c) => {
|
|
2075
|
+
h(c.target.value), H.username && G((y) => ({ ...y, username: !1 }));
|
|
1814
2076
|
},
|
|
1815
|
-
placeholder:
|
|
1816
|
-
style:
|
|
1817
|
-
disabled:
|
|
2077
|
+
placeholder: w.usernamePlaceholder,
|
|
2078
|
+
style: f("username"),
|
|
2079
|
+
disabled: k
|
|
1818
2080
|
}
|
|
1819
2081
|
)
|
|
1820
2082
|
] }),
|
|
1821
|
-
/* @__PURE__ */
|
|
1822
|
-
/* @__PURE__ */
|
|
1823
|
-
/* @__PURE__ */
|
|
1824
|
-
/* @__PURE__ */
|
|
2083
|
+
/* @__PURE__ */ l("div", { style: M.fieldGroup, children: [
|
|
2084
|
+
/* @__PURE__ */ n("label", { style: M.label, children: w.passwordLabel }),
|
|
2085
|
+
/* @__PURE__ */ l("div", { style: M.inputContainer, children: [
|
|
2086
|
+
/* @__PURE__ */ n(
|
|
1825
2087
|
"input",
|
|
1826
2088
|
{
|
|
1827
2089
|
id: "password",
|
|
1828
2090
|
name: "password",
|
|
1829
|
-
type:
|
|
1830
|
-
value:
|
|
1831
|
-
onChange: (
|
|
1832
|
-
|
|
2091
|
+
type: C ? "text" : "password",
|
|
2092
|
+
value: S,
|
|
2093
|
+
onChange: (c) => {
|
|
2094
|
+
L(c.target.value), H.password && G((y) => ({ ...y, password: !1 }));
|
|
1833
2095
|
},
|
|
1834
|
-
placeholder:
|
|
2096
|
+
placeholder: w.passwordPlaceholder,
|
|
1835
2097
|
style: {
|
|
1836
|
-
...
|
|
2098
|
+
...f("password"),
|
|
1837
2099
|
paddingRight: "2.5rem"
|
|
1838
2100
|
// Make room for the icon
|
|
1839
2101
|
},
|
|
1840
|
-
disabled:
|
|
2102
|
+
disabled: k
|
|
1841
2103
|
}
|
|
1842
2104
|
),
|
|
1843
|
-
/* @__PURE__ */
|
|
2105
|
+
/* @__PURE__ */ n(
|
|
1844
2106
|
"button",
|
|
1845
2107
|
{
|
|
1846
2108
|
type: "button",
|
|
1847
|
-
onClick: () =>
|
|
1848
|
-
style:
|
|
1849
|
-
disabled:
|
|
1850
|
-
"aria-label":
|
|
1851
|
-
children:
|
|
2109
|
+
onClick: () => q(!C),
|
|
2110
|
+
style: M.passwordToggle,
|
|
2111
|
+
disabled: k,
|
|
2112
|
+
"aria-label": C ? "Hide password" : "Show password",
|
|
2113
|
+
children: C ? E.hidePassword : E.showPassword
|
|
1852
2114
|
}
|
|
1853
2115
|
)
|
|
1854
2116
|
] })
|
|
1855
2117
|
] }),
|
|
1856
|
-
/* @__PURE__ */
|
|
1857
|
-
|
|
2118
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !m || !S || k, style: d(), children: k ? w.loadingText : w.submitButton }),
|
|
2119
|
+
T && /* @__PURE__ */ n("div", { style: M.errorText, children: T })
|
|
1858
2120
|
] }),
|
|
1859
|
-
(
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
/* @__PURE__ */ c("span", { style: d.divider, children: [
|
|
1864
|
-
B.signupText,
|
|
2121
|
+
(A || x || P) && /* @__PURE__ */ l("div", { style: M.linkContainer, children: [
|
|
2122
|
+
P && /* @__PURE__ */ l("div", { children: [
|
|
2123
|
+
/* @__PURE__ */ l("span", { style: M.divider, children: [
|
|
2124
|
+
w.magicLinkText,
|
|
1865
2125
|
" "
|
|
1866
2126
|
] }),
|
|
1867
|
-
/* @__PURE__ */
|
|
2127
|
+
/* @__PURE__ */ n("a", { onClick: I, style: M.link, children: w.magicLinkLink })
|
|
2128
|
+
] }),
|
|
2129
|
+
P && (A || x) && /* @__PURE__ */ n("div", { style: M.divider, children: "•" }),
|
|
2130
|
+
A && /* @__PURE__ */ n("a", { onClick: a, style: M.link, children: w.forgotPasswordLink }),
|
|
2131
|
+
A && x && /* @__PURE__ */ n("div", { style: M.divider, children: "•" }),
|
|
2132
|
+
x && /* @__PURE__ */ l("div", { children: [
|
|
2133
|
+
/* @__PURE__ */ l("span", { style: M.divider, children: [
|
|
2134
|
+
w.signupText,
|
|
2135
|
+
" "
|
|
2136
|
+
] }),
|
|
2137
|
+
/* @__PURE__ */ n("a", { onClick: p, style: M.link, children: w.signupLink })
|
|
1868
2138
|
] })
|
|
1869
2139
|
] })
|
|
1870
2140
|
] });
|
|
1871
2141
|
}
|
|
1872
|
-
const
|
|
2142
|
+
const nt = {
|
|
1873
2143
|
title: "Create Account",
|
|
1874
|
-
nameLabel: "
|
|
1875
|
-
namePlaceholder: "Enter your
|
|
2144
|
+
nameLabel: "First Name",
|
|
2145
|
+
namePlaceholder: "Enter your first name",
|
|
2146
|
+
lastNameLabel: "Last Name",
|
|
2147
|
+
lastNamePlaceholder: "Enter your last name",
|
|
1876
2148
|
emailLabel: "Email",
|
|
1877
2149
|
emailPlaceholder: "Enter your email",
|
|
2150
|
+
phoneNumberLabel: "Phone Number",
|
|
2151
|
+
phoneNumberPlaceholder: "Enter your phone number",
|
|
1878
2152
|
passwordLabel: "Password",
|
|
1879
2153
|
passwordPlaceholder: "Enter your password",
|
|
1880
2154
|
confirmPasswordLabel: "Confirm Password",
|
|
@@ -1884,12 +2158,14 @@ const Ve = {
|
|
|
1884
2158
|
submitButton: "Create Account",
|
|
1885
2159
|
loginLink: "Sign in here",
|
|
1886
2160
|
loginText: "Already have an account?",
|
|
2161
|
+
magicLinkText: "Prefer passwordless?",
|
|
2162
|
+
magicLinkLink: "Use Magic Link",
|
|
1887
2163
|
errorMessage: "Failed to create account",
|
|
1888
2164
|
loadingText: "Creating account...",
|
|
1889
2165
|
passwordMismatchError: "Passwords do not match",
|
|
1890
2166
|
isAdminLabel: "Create new organization",
|
|
1891
2167
|
isAdminDescription: "Check this if you want to create a new organization"
|
|
1892
|
-
},
|
|
2168
|
+
}, st = {
|
|
1893
2169
|
container: {
|
|
1894
2170
|
maxWidth: "400px",
|
|
1895
2171
|
width: "100%",
|
|
@@ -1988,154 +2264,786 @@ const Ve = {
|
|
|
1988
2264
|
fontSize: "0.875rem"
|
|
1989
2265
|
}
|
|
1990
2266
|
};
|
|
1991
|
-
function
|
|
2267
|
+
function Dt({
|
|
1992
2268
|
copy: i = {},
|
|
1993
2269
|
styles: e = {},
|
|
1994
2270
|
signupType: t = "user",
|
|
1995
2271
|
onSuccess: r,
|
|
1996
|
-
onError:
|
|
1997
|
-
onLoginClick:
|
|
1998
|
-
|
|
1999
|
-
|
|
2272
|
+
onError: s,
|
|
2273
|
+
onLoginClick: a,
|
|
2274
|
+
onMagicLinkClick: p,
|
|
2275
|
+
showLoginLink: I = !0,
|
|
2276
|
+
showMagicLinkOption: A = !0,
|
|
2277
|
+
className: x
|
|
2000
2278
|
}) {
|
|
2001
|
-
const [
|
|
2002
|
-
const
|
|
2003
|
-
return
|
|
2004
|
-
},
|
|
2005
|
-
if (
|
|
2006
|
-
if (
|
|
2007
|
-
|
|
2279
|
+
const [P, b] = v(""), [m, h] = v(""), [S, L] = v(""), [C, q] = v(""), [k, u] = v(""), [T, R] = v(""), [H, G] = v(""), [F, V] = v(!1), [w, M] = v(""), [E, o] = v({}), { signup: g, signupTenantAdmin: f } = oe(), { tenant: d } = se(), c = { ...nt, ...i }, y = { ...st, ...e }, W = () => {
|
|
2280
|
+
const D = {};
|
|
2281
|
+
return P.trim() || (D.name = !0), !S.trim() && !C.trim() && (D.email = !0, D.phoneNumber = !0), k.trim() || (D.password = !0), T.trim() || (D.confirmPassword = !0), t === "tenant" && !H.trim() && (D.tenantName = !0), o(D), Object.keys(D).length === 0;
|
|
2282
|
+
}, ee = async (D) => {
|
|
2283
|
+
if (D.preventDefault(), !!W()) {
|
|
2284
|
+
if (k !== T) {
|
|
2285
|
+
M(c.passwordMismatchError), o({ confirmPassword: !0 });
|
|
2008
2286
|
return;
|
|
2009
2287
|
}
|
|
2010
|
-
if (t === "user" && !(
|
|
2011
|
-
|
|
2288
|
+
if (t === "user" && !(d != null && d.id)) {
|
|
2289
|
+
M("Tenant not found");
|
|
2012
2290
|
return;
|
|
2013
2291
|
}
|
|
2014
|
-
|
|
2292
|
+
V(!0), M("");
|
|
2015
2293
|
try {
|
|
2016
|
-
let
|
|
2017
|
-
t === "tenant" ?
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2294
|
+
let _;
|
|
2295
|
+
t === "tenant" ? _ = await f({
|
|
2296
|
+
email: S || void 0,
|
|
2297
|
+
phoneNumber: C || void 0,
|
|
2298
|
+
name: P,
|
|
2299
|
+
password: k,
|
|
2300
|
+
tenantName: H,
|
|
2301
|
+
lastName: m || void 0
|
|
2302
|
+
}) : _ = await g({
|
|
2303
|
+
email: S || void 0,
|
|
2304
|
+
phoneNumber: C || void 0,
|
|
2305
|
+
name: P,
|
|
2306
|
+
password: k,
|
|
2307
|
+
tenantId: d.id,
|
|
2308
|
+
lastName: m || void 0
|
|
2309
|
+
}), r == null || r(_);
|
|
2310
|
+
} catch (_) {
|
|
2311
|
+
const ge = _.message || c.errorMessage;
|
|
2312
|
+
M(ge), s == null || s(ge);
|
|
2021
2313
|
} finally {
|
|
2022
|
-
|
|
2314
|
+
V(!1);
|
|
2023
2315
|
}
|
|
2024
2316
|
}
|
|
2025
|
-
},
|
|
2026
|
-
...
|
|
2027
|
-
...D
|
|
2028
|
-
}),
|
|
2029
|
-
...
|
|
2030
|
-
...
|
|
2031
|
-
...!
|
|
2032
|
-
}),
|
|
2033
|
-
return /* @__PURE__ */
|
|
2034
|
-
/* @__PURE__ */
|
|
2035
|
-
/* @__PURE__ */
|
|
2036
|
-
/* @__PURE__ */
|
|
2037
|
-
/* @__PURE__ */
|
|
2038
|
-
/* @__PURE__ */
|
|
2317
|
+
}, z = (D) => ({
|
|
2318
|
+
...y.input,
|
|
2319
|
+
...E[D] ? y.inputError : {}
|
|
2320
|
+
}), B = () => ({
|
|
2321
|
+
...y.button,
|
|
2322
|
+
...F ? y.buttonLoading : {},
|
|
2323
|
+
...!P || !S && !C || !k || !T || F || t === "tenant" && !H ? y.buttonDisabled : {}
|
|
2324
|
+
}), O = P && (S || C) && k && T && (t === "user" || H);
|
|
2325
|
+
return /* @__PURE__ */ l("div", { className: x, style: y.container, children: [
|
|
2326
|
+
/* @__PURE__ */ n("h2", { style: y.title, children: c.title }),
|
|
2327
|
+
/* @__PURE__ */ l("form", { onSubmit: ee, style: y.form, children: [
|
|
2328
|
+
/* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
|
|
2329
|
+
/* @__PURE__ */ n("label", { style: y.label, children: c.nameLabel }),
|
|
2330
|
+
/* @__PURE__ */ n(
|
|
2039
2331
|
"input",
|
|
2040
2332
|
{
|
|
2041
2333
|
id: "name",
|
|
2042
2334
|
name: "name",
|
|
2043
2335
|
type: "text",
|
|
2044
|
-
value:
|
|
2045
|
-
onChange: (
|
|
2046
|
-
|
|
2336
|
+
value: P,
|
|
2337
|
+
onChange: (D) => {
|
|
2338
|
+
b(D.target.value), E.name && o((_) => ({ ..._, name: !1 }));
|
|
2047
2339
|
},
|
|
2048
|
-
placeholder:
|
|
2049
|
-
style:
|
|
2050
|
-
disabled:
|
|
2340
|
+
placeholder: c.namePlaceholder,
|
|
2341
|
+
style: z("name"),
|
|
2342
|
+
disabled: F
|
|
2051
2343
|
}
|
|
2052
2344
|
)
|
|
2053
2345
|
] }),
|
|
2054
|
-
/* @__PURE__ */
|
|
2055
|
-
/* @__PURE__ */
|
|
2056
|
-
/* @__PURE__ */
|
|
2346
|
+
/* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
|
|
2347
|
+
/* @__PURE__ */ n("label", { style: y.label, children: c.lastNameLabel }),
|
|
2348
|
+
/* @__PURE__ */ n(
|
|
2349
|
+
"input",
|
|
2350
|
+
{
|
|
2351
|
+
id: "lastName",
|
|
2352
|
+
name: "lastName",
|
|
2353
|
+
type: "text",
|
|
2354
|
+
value: m,
|
|
2355
|
+
onChange: (D) => h(D.target.value),
|
|
2356
|
+
placeholder: c.lastNamePlaceholder,
|
|
2357
|
+
style: y.input,
|
|
2358
|
+
disabled: F
|
|
2359
|
+
}
|
|
2360
|
+
)
|
|
2361
|
+
] }),
|
|
2362
|
+
/* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
|
|
2363
|
+
/* @__PURE__ */ n("label", { style: y.label, children: c.emailLabel }),
|
|
2364
|
+
/* @__PURE__ */ n(
|
|
2057
2365
|
"input",
|
|
2058
2366
|
{
|
|
2059
2367
|
id: "email",
|
|
2060
2368
|
name: "email",
|
|
2061
2369
|
type: "email",
|
|
2062
|
-
value:
|
|
2063
|
-
onChange: (
|
|
2064
|
-
|
|
2370
|
+
value: S,
|
|
2371
|
+
onChange: (D) => {
|
|
2372
|
+
L(D.target.value), E.email && o((_) => ({ ..._, email: !1, phoneNumber: !1 }));
|
|
2373
|
+
},
|
|
2374
|
+
placeholder: c.emailPlaceholder,
|
|
2375
|
+
style: z("email"),
|
|
2376
|
+
disabled: F
|
|
2377
|
+
}
|
|
2378
|
+
)
|
|
2379
|
+
] }),
|
|
2380
|
+
/* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
|
|
2381
|
+
/* @__PURE__ */ n("label", { style: y.label, children: c.phoneNumberLabel }),
|
|
2382
|
+
/* @__PURE__ */ n(
|
|
2383
|
+
"input",
|
|
2384
|
+
{
|
|
2385
|
+
id: "phoneNumber",
|
|
2386
|
+
name: "phoneNumber",
|
|
2387
|
+
type: "tel",
|
|
2388
|
+
value: C,
|
|
2389
|
+
onChange: (D) => {
|
|
2390
|
+
q(D.target.value), E.phoneNumber && o((_) => ({ ..._, email: !1, phoneNumber: !1 }));
|
|
2065
2391
|
},
|
|
2066
|
-
placeholder:
|
|
2067
|
-
style:
|
|
2068
|
-
disabled:
|
|
2392
|
+
placeholder: c.phoneNumberPlaceholder,
|
|
2393
|
+
style: z("phoneNumber"),
|
|
2394
|
+
disabled: F
|
|
2069
2395
|
}
|
|
2070
2396
|
)
|
|
2071
2397
|
] }),
|
|
2072
|
-
/* @__PURE__ */
|
|
2073
|
-
|
|
2074
|
-
|
|
2398
|
+
/* @__PURE__ */ n(
|
|
2399
|
+
"div",
|
|
2400
|
+
{
|
|
2401
|
+
style: {
|
|
2402
|
+
fontSize: "0.875rem",
|
|
2403
|
+
color: "#6b7280",
|
|
2404
|
+
textAlign: "center",
|
|
2405
|
+
margin: "0.5rem 0"
|
|
2406
|
+
},
|
|
2407
|
+
children: "At least one contact method (email or phone) is required"
|
|
2408
|
+
}
|
|
2409
|
+
),
|
|
2410
|
+
/* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
|
|
2411
|
+
/* @__PURE__ */ n("label", { style: y.label, children: c.passwordLabel }),
|
|
2412
|
+
/* @__PURE__ */ n(
|
|
2075
2413
|
"input",
|
|
2076
2414
|
{
|
|
2077
2415
|
id: "password",
|
|
2078
2416
|
name: "password",
|
|
2079
2417
|
type: "password",
|
|
2080
|
-
value:
|
|
2081
|
-
onChange: (
|
|
2082
|
-
|
|
2418
|
+
value: k,
|
|
2419
|
+
onChange: (D) => {
|
|
2420
|
+
u(D.target.value), E.password && o((_) => ({ ..._, password: !1 }));
|
|
2083
2421
|
},
|
|
2084
|
-
placeholder:
|
|
2085
|
-
style:
|
|
2086
|
-
disabled:
|
|
2422
|
+
placeholder: c.passwordPlaceholder,
|
|
2423
|
+
style: z("password"),
|
|
2424
|
+
disabled: F
|
|
2087
2425
|
}
|
|
2088
2426
|
)
|
|
2089
2427
|
] }),
|
|
2090
|
-
/* @__PURE__ */
|
|
2091
|
-
/* @__PURE__ */
|
|
2092
|
-
/* @__PURE__ */
|
|
2428
|
+
/* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
|
|
2429
|
+
/* @__PURE__ */ n("label", { style: y.label, children: c.confirmPasswordLabel }),
|
|
2430
|
+
/* @__PURE__ */ n(
|
|
2093
2431
|
"input",
|
|
2094
2432
|
{
|
|
2095
2433
|
id: "confirmPassword",
|
|
2096
2434
|
name: "confirmPassword",
|
|
2097
2435
|
type: "password",
|
|
2098
|
-
value:
|
|
2099
|
-
onChange: (
|
|
2100
|
-
|
|
2436
|
+
value: T,
|
|
2437
|
+
onChange: (D) => {
|
|
2438
|
+
R(D.target.value), E.confirmPassword && o((_) => ({ ..._, confirmPassword: !1 })), w === c.passwordMismatchError && M("");
|
|
2101
2439
|
},
|
|
2102
|
-
placeholder:
|
|
2103
|
-
style:
|
|
2104
|
-
disabled:
|
|
2440
|
+
placeholder: c.confirmPasswordPlaceholder,
|
|
2441
|
+
style: z("confirmPassword"),
|
|
2442
|
+
disabled: F
|
|
2105
2443
|
}
|
|
2106
2444
|
)
|
|
2107
2445
|
] }),
|
|
2108
|
-
t === "tenant" && /* @__PURE__ */
|
|
2109
|
-
/* @__PURE__ */
|
|
2110
|
-
/* @__PURE__ */
|
|
2446
|
+
t === "tenant" && /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
|
|
2447
|
+
/* @__PURE__ */ n("label", { style: y.label, children: c.tenantNameLabel }),
|
|
2448
|
+
/* @__PURE__ */ n(
|
|
2111
2449
|
"input",
|
|
2112
2450
|
{
|
|
2113
2451
|
id: "tenantName",
|
|
2114
2452
|
name: "tenantName",
|
|
2115
2453
|
type: "text",
|
|
2116
|
-
value:
|
|
2117
|
-
onChange: (
|
|
2118
|
-
|
|
2454
|
+
value: H,
|
|
2455
|
+
onChange: (D) => {
|
|
2456
|
+
G(D.target.value), E.tenantName && o((_) => ({ ..._, tenantName: !1 }));
|
|
2457
|
+
},
|
|
2458
|
+
placeholder: c.tenantNamePlaceholder,
|
|
2459
|
+
style: z("tenantName"),
|
|
2460
|
+
disabled: F
|
|
2461
|
+
}
|
|
2462
|
+
)
|
|
2463
|
+
] }),
|
|
2464
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !O || F, style: B(), children: F ? c.loadingText : c.submitButton }),
|
|
2465
|
+
w && /* @__PURE__ */ n("div", { style: y.errorText, children: w })
|
|
2466
|
+
] }),
|
|
2467
|
+
(I || A) && /* @__PURE__ */ l("div", { style: y.linkContainer, children: [
|
|
2468
|
+
A && /* @__PURE__ */ l("div", { children: [
|
|
2469
|
+
/* @__PURE__ */ l("span", { style: y.divider, children: [
|
|
2470
|
+
c.magicLinkText,
|
|
2471
|
+
" "
|
|
2472
|
+
] }),
|
|
2473
|
+
/* @__PURE__ */ n("a", { onClick: p, style: y.link, children: c.magicLinkLink })
|
|
2474
|
+
] }),
|
|
2475
|
+
A && I && /* @__PURE__ */ n("div", { style: y.divider, children: "•" }),
|
|
2476
|
+
I && /* @__PURE__ */ l("div", { children: [
|
|
2477
|
+
/* @__PURE__ */ l("span", { style: y.divider, children: [
|
|
2478
|
+
c.loginText,
|
|
2479
|
+
" "
|
|
2480
|
+
] }),
|
|
2481
|
+
/* @__PURE__ */ n("a", { onClick: a, style: y.link, children: c.loginLink })
|
|
2482
|
+
] })
|
|
2483
|
+
] })
|
|
2484
|
+
] });
|
|
2485
|
+
}
|
|
2486
|
+
const it = {
|
|
2487
|
+
title: "Sign In with Magic Link",
|
|
2488
|
+
emailLabel: "Email",
|
|
2489
|
+
emailPlaceholder: "Enter your email",
|
|
2490
|
+
nameLabel: "Name",
|
|
2491
|
+
namePlaceholder: "Enter your name",
|
|
2492
|
+
lastNameLabel: "Last Name",
|
|
2493
|
+
lastNamePlaceholder: "Enter your last name",
|
|
2494
|
+
submitButton: "Send Magic Link",
|
|
2495
|
+
loginLink: "Sign in with password",
|
|
2496
|
+
signupLink: "Sign up with password",
|
|
2497
|
+
loginText: "Already have an account?",
|
|
2498
|
+
signupText: "Prefer traditional signup?",
|
|
2499
|
+
successMessage: "Magic link sent! Check your email and click the link to sign in.",
|
|
2500
|
+
errorMessage: "Failed to send magic link. Please try again.",
|
|
2501
|
+
loadingText: "Sending magic link...",
|
|
2502
|
+
verifyingText: "Verifying magic link...",
|
|
2503
|
+
description: "Enter your email to receive a magic link. If you don't have an account, we'll create one for you."
|
|
2504
|
+
}, ot = {
|
|
2505
|
+
container: {
|
|
2506
|
+
maxWidth: "400px",
|
|
2507
|
+
width: "100%",
|
|
2508
|
+
margin: "0 auto",
|
|
2509
|
+
padding: "2rem",
|
|
2510
|
+
backgroundColor: "#ffffff",
|
|
2511
|
+
borderRadius: "8px",
|
|
2512
|
+
boxShadow: "0 2px 10px rgba(0, 0, 0, 0.1)"
|
|
2513
|
+
},
|
|
2514
|
+
title: {
|
|
2515
|
+
fontSize: "1.5rem",
|
|
2516
|
+
fontWeight: "bold",
|
|
2517
|
+
textAlign: "center",
|
|
2518
|
+
marginBottom: "1rem",
|
|
2519
|
+
color: "#333333"
|
|
2520
|
+
},
|
|
2521
|
+
description: {
|
|
2522
|
+
fontSize: "0.875rem",
|
|
2523
|
+
color: "#6b7280",
|
|
2524
|
+
textAlign: "center",
|
|
2525
|
+
marginBottom: "1.5rem",
|
|
2526
|
+
lineHeight: "1.5"
|
|
2527
|
+
},
|
|
2528
|
+
form: {
|
|
2529
|
+
display: "flex",
|
|
2530
|
+
flexDirection: "column",
|
|
2531
|
+
gap: "1rem"
|
|
2532
|
+
},
|
|
2533
|
+
fieldGroup: {
|
|
2534
|
+
display: "flex",
|
|
2535
|
+
flexDirection: "column",
|
|
2536
|
+
gap: "0.5rem"
|
|
2537
|
+
},
|
|
2538
|
+
label: {
|
|
2539
|
+
fontSize: "0.875rem",
|
|
2540
|
+
fontWeight: "500",
|
|
2541
|
+
color: "#374151"
|
|
2542
|
+
},
|
|
2543
|
+
input: {
|
|
2544
|
+
padding: "0.75rem",
|
|
2545
|
+
border: "1px solid #d1d5db",
|
|
2546
|
+
borderRadius: "6px",
|
|
2547
|
+
fontSize: "1rem",
|
|
2548
|
+
transition: "border-color 0.15s ease-in-out",
|
|
2549
|
+
outline: "none",
|
|
2550
|
+
width: "100%"
|
|
2551
|
+
},
|
|
2552
|
+
inputError: {
|
|
2553
|
+
borderColor: "#ef4444",
|
|
2554
|
+
boxShadow: "0 0 0 3px rgba(239, 68, 68, 0.1)"
|
|
2555
|
+
},
|
|
2556
|
+
button: {
|
|
2557
|
+
padding: "0.75rem 1rem",
|
|
2558
|
+
backgroundColor: "#3b82f6",
|
|
2559
|
+
color: "white",
|
|
2560
|
+
border: "none",
|
|
2561
|
+
borderRadius: "6px",
|
|
2562
|
+
fontSize: "1rem",
|
|
2563
|
+
fontWeight: "500",
|
|
2564
|
+
cursor: "pointer",
|
|
2565
|
+
transition: "background-color 0.15s ease-in-out",
|
|
2566
|
+
marginTop: "0.5rem"
|
|
2567
|
+
},
|
|
2568
|
+
buttonDisabled: {
|
|
2569
|
+
backgroundColor: "#9ca3af",
|
|
2570
|
+
cursor: "not-allowed"
|
|
2571
|
+
},
|
|
2572
|
+
buttonLoading: {
|
|
2573
|
+
backgroundColor: "#6b7280"
|
|
2574
|
+
},
|
|
2575
|
+
errorText: {
|
|
2576
|
+
color: "#ef4444",
|
|
2577
|
+
fontSize: "0.875rem",
|
|
2578
|
+
textAlign: "center",
|
|
2579
|
+
marginTop: "0.5rem"
|
|
2580
|
+
},
|
|
2581
|
+
successText: {
|
|
2582
|
+
color: "#10b981",
|
|
2583
|
+
fontSize: "0.875rem",
|
|
2584
|
+
textAlign: "center",
|
|
2585
|
+
marginTop: "0.5rem",
|
|
2586
|
+
padding: "0.75rem",
|
|
2587
|
+
backgroundColor: "#f0fdf4",
|
|
2588
|
+
borderRadius: "6px",
|
|
2589
|
+
border: "1px solid #bbf7d0"
|
|
2590
|
+
},
|
|
2591
|
+
linkContainer: {
|
|
2592
|
+
textAlign: "center",
|
|
2593
|
+
marginTop: "1rem"
|
|
2594
|
+
},
|
|
2595
|
+
link: {
|
|
2596
|
+
color: "#3b82f6",
|
|
2597
|
+
textDecoration: "none",
|
|
2598
|
+
fontSize: "0.875rem",
|
|
2599
|
+
cursor: "pointer"
|
|
2600
|
+
},
|
|
2601
|
+
divider: {
|
|
2602
|
+
margin: "0.5rem 0",
|
|
2603
|
+
color: "#6b7280",
|
|
2604
|
+
fontSize: "0.875rem"
|
|
2605
|
+
}
|
|
2606
|
+
};
|
|
2607
|
+
function Ht({
|
|
2608
|
+
copy: i = {},
|
|
2609
|
+
styles: e = {},
|
|
2610
|
+
onSuccess: t,
|
|
2611
|
+
onError: r,
|
|
2612
|
+
onLoginClick: s,
|
|
2613
|
+
onSignupClick: a,
|
|
2614
|
+
showTraditionalLinks: p = !0,
|
|
2615
|
+
className: I,
|
|
2616
|
+
verifyToken: A,
|
|
2617
|
+
frontendUrl: x
|
|
2618
|
+
}) {
|
|
2619
|
+
const [P, b] = v(""), [m, h] = v(""), [S, L] = v(""), [C, q] = v(!1), [k, u] = v(!1), [T, R] = v(""), [H, G] = v(""), [F, V] = v({}), [w, M] = v(!1), { sendMagicLink: E, verifyMagicLink: o } = oe(), { tenant: g } = se(), f = { ...it, ...i }, d = { ...ot, ...e };
|
|
2620
|
+
te(() => {
|
|
2621
|
+
A && c(A);
|
|
2622
|
+
}, [A]);
|
|
2623
|
+
const c = async (B) => {
|
|
2624
|
+
if (!g || !P) {
|
|
2625
|
+
R("Missing tenant or email");
|
|
2626
|
+
return;
|
|
2627
|
+
}
|
|
2628
|
+
u(!0), R("");
|
|
2629
|
+
try {
|
|
2630
|
+
const O = await o({
|
|
2631
|
+
token: B,
|
|
2632
|
+
email: P
|
|
2633
|
+
// tenantId inferred from context automatically
|
|
2634
|
+
});
|
|
2635
|
+
t == null || t(O);
|
|
2636
|
+
} catch (O) {
|
|
2637
|
+
const D = O.message || "Failed to verify magic link";
|
|
2638
|
+
R(D), r == null || r(D);
|
|
2639
|
+
} finally {
|
|
2640
|
+
u(!1);
|
|
2641
|
+
}
|
|
2642
|
+
}, y = () => {
|
|
2643
|
+
const B = {};
|
|
2644
|
+
return P.trim() || (B.email = !0), w && !m.trim() && (B.name = !0), V(B), Object.keys(B).length === 0;
|
|
2645
|
+
}, W = async (B) => {
|
|
2646
|
+
if (B.preventDefault(), !!y()) {
|
|
2647
|
+
if (!(g != null && g.id)) {
|
|
2648
|
+
R("Tenant not found");
|
|
2649
|
+
return;
|
|
2650
|
+
}
|
|
2651
|
+
q(!0), R(""), G("");
|
|
2652
|
+
try {
|
|
2653
|
+
const O = x || (typeof window < "u" ? window.location.origin : ""), D = await E({
|
|
2654
|
+
email: P,
|
|
2655
|
+
tenantId: g.id,
|
|
2656
|
+
frontendUrl: O,
|
|
2657
|
+
name: w ? m : void 0,
|
|
2658
|
+
lastName: w ? S : void 0
|
|
2659
|
+
});
|
|
2660
|
+
G(f.successMessage), t == null || t(D);
|
|
2661
|
+
} catch (O) {
|
|
2662
|
+
const D = O.message || f.errorMessage;
|
|
2663
|
+
R(D), r == null || r(D);
|
|
2664
|
+
} finally {
|
|
2665
|
+
q(!1);
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
}, ee = (B) => ({
|
|
2669
|
+
...d.input,
|
|
2670
|
+
...F[B] ? d.inputError : {}
|
|
2671
|
+
}), z = () => ({
|
|
2672
|
+
...d.button,
|
|
2673
|
+
...C || k ? d.buttonLoading : {},
|
|
2674
|
+
...!P || C || k ? d.buttonDisabled : {}
|
|
2675
|
+
});
|
|
2676
|
+
return k ? /* @__PURE__ */ l("div", { className: I, style: d.container, children: [
|
|
2677
|
+
/* @__PURE__ */ n("h2", { style: d.title, children: f.verifyingText }),
|
|
2678
|
+
/* @__PURE__ */ n("div", { style: { textAlign: "center", padding: "2rem" }, children: /* @__PURE__ */ n("div", { style: { fontSize: "1rem", color: "#6b7280" }, children: "Please wait while we verify your magic link..." }) })
|
|
2679
|
+
] }) : /* @__PURE__ */ l("div", { className: I, style: d.container, children: [
|
|
2680
|
+
/* @__PURE__ */ n("h2", { style: d.title, children: f.title }),
|
|
2681
|
+
/* @__PURE__ */ n("p", { style: d.description, children: f.description }),
|
|
2682
|
+
/* @__PURE__ */ l("form", { onSubmit: W, style: d.form, children: [
|
|
2683
|
+
/* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
|
|
2684
|
+
/* @__PURE__ */ n("label", { style: d.label, children: f.emailLabel }),
|
|
2685
|
+
/* @__PURE__ */ n(
|
|
2686
|
+
"input",
|
|
2687
|
+
{
|
|
2688
|
+
id: "email",
|
|
2689
|
+
name: "email",
|
|
2690
|
+
type: "email",
|
|
2691
|
+
value: P,
|
|
2692
|
+
onChange: (B) => {
|
|
2693
|
+
b(B.target.value), F.email && V((O) => ({ ...O, email: !1 }));
|
|
2119
2694
|
},
|
|
2120
|
-
placeholder:
|
|
2121
|
-
style:
|
|
2122
|
-
disabled:
|
|
2695
|
+
placeholder: f.emailPlaceholder,
|
|
2696
|
+
style: ee("email"),
|
|
2697
|
+
disabled: C || k
|
|
2123
2698
|
}
|
|
2124
2699
|
)
|
|
2125
2700
|
] }),
|
|
2126
|
-
/* @__PURE__ */
|
|
2127
|
-
|
|
2701
|
+
!w && /* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
|
|
2702
|
+
"button",
|
|
2703
|
+
{
|
|
2704
|
+
type: "button",
|
|
2705
|
+
onClick: () => M(!0),
|
|
2706
|
+
style: {
|
|
2707
|
+
background: "none",
|
|
2708
|
+
border: "none",
|
|
2709
|
+
color: "#3b82f6",
|
|
2710
|
+
fontSize: "0.875rem",
|
|
2711
|
+
cursor: "pointer",
|
|
2712
|
+
textDecoration: "underline"
|
|
2713
|
+
},
|
|
2714
|
+
children: "New user? Add your name"
|
|
2715
|
+
}
|
|
2716
|
+
) }),
|
|
2717
|
+
w && /* @__PURE__ */ l(N, { children: [
|
|
2718
|
+
/* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
|
|
2719
|
+
/* @__PURE__ */ n("label", { style: d.label, children: f.nameLabel }),
|
|
2720
|
+
/* @__PURE__ */ n(
|
|
2721
|
+
"input",
|
|
2722
|
+
{
|
|
2723
|
+
id: "name",
|
|
2724
|
+
name: "name",
|
|
2725
|
+
type: "text",
|
|
2726
|
+
value: m,
|
|
2727
|
+
onChange: (B) => {
|
|
2728
|
+
h(B.target.value), F.name && V((O) => ({ ...O, name: !1 }));
|
|
2729
|
+
},
|
|
2730
|
+
placeholder: f.namePlaceholder,
|
|
2731
|
+
style: ee("name"),
|
|
2732
|
+
disabled: C || k
|
|
2733
|
+
}
|
|
2734
|
+
)
|
|
2735
|
+
] }),
|
|
2736
|
+
/* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
|
|
2737
|
+
/* @__PURE__ */ n("label", { style: d.label, children: f.lastNameLabel }),
|
|
2738
|
+
/* @__PURE__ */ n(
|
|
2739
|
+
"input",
|
|
2740
|
+
{
|
|
2741
|
+
id: "lastName",
|
|
2742
|
+
name: "lastName",
|
|
2743
|
+
type: "text",
|
|
2744
|
+
value: S,
|
|
2745
|
+
onChange: (B) => L(B.target.value),
|
|
2746
|
+
placeholder: f.lastNamePlaceholder,
|
|
2747
|
+
style: d.input,
|
|
2748
|
+
disabled: C || k
|
|
2749
|
+
}
|
|
2750
|
+
)
|
|
2751
|
+
] }),
|
|
2752
|
+
/* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
|
|
2753
|
+
"button",
|
|
2754
|
+
{
|
|
2755
|
+
type: "button",
|
|
2756
|
+
onClick: () => {
|
|
2757
|
+
M(!1), h(""), L("");
|
|
2758
|
+
},
|
|
2759
|
+
style: {
|
|
2760
|
+
background: "none",
|
|
2761
|
+
border: "none",
|
|
2762
|
+
color: "#6b7280",
|
|
2763
|
+
fontSize: "0.875rem",
|
|
2764
|
+
cursor: "pointer",
|
|
2765
|
+
textDecoration: "underline"
|
|
2766
|
+
},
|
|
2767
|
+
children: "Existing user? Hide name fields"
|
|
2768
|
+
}
|
|
2769
|
+
) })
|
|
2770
|
+
] }),
|
|
2771
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !P || C || k, style: z(), children: C ? f.loadingText : f.submitButton }),
|
|
2772
|
+
T && /* @__PURE__ */ n("div", { style: d.errorText, children: T }),
|
|
2773
|
+
H && /* @__PURE__ */ n("div", { style: d.successText, children: H })
|
|
2128
2774
|
] }),
|
|
2129
|
-
|
|
2130
|
-
/* @__PURE__ */
|
|
2131
|
-
|
|
2132
|
-
|
|
2775
|
+
p && /* @__PURE__ */ l("div", { style: d.linkContainer, children: [
|
|
2776
|
+
/* @__PURE__ */ l("div", { children: [
|
|
2777
|
+
/* @__PURE__ */ l("span", { style: d.divider, children: [
|
|
2778
|
+
f.loginText,
|
|
2779
|
+
" "
|
|
2780
|
+
] }),
|
|
2781
|
+
/* @__PURE__ */ n("a", { onClick: s, style: d.link, children: f.loginLink })
|
|
2133
2782
|
] }),
|
|
2134
|
-
/* @__PURE__ */
|
|
2783
|
+
/* @__PURE__ */ n("div", { style: d.divider, children: "•" }),
|
|
2784
|
+
/* @__PURE__ */ l("div", { children: [
|
|
2785
|
+
/* @__PURE__ */ l("span", { style: d.divider, children: [
|
|
2786
|
+
f.signupText,
|
|
2787
|
+
" "
|
|
2788
|
+
] }),
|
|
2789
|
+
/* @__PURE__ */ n("a", { onClick: a, style: d.link, children: f.signupLink })
|
|
2790
|
+
] })
|
|
2135
2791
|
] })
|
|
2136
2792
|
] });
|
|
2137
2793
|
}
|
|
2138
|
-
const
|
|
2794
|
+
const at = {
|
|
2795
|
+
title: "Verifying Magic Link",
|
|
2796
|
+
verifyingMessage: "Please wait while we verify your magic link...",
|
|
2797
|
+
successMessage: "Magic link verified successfully! You are now logged in.",
|
|
2798
|
+
errorMessage: "Failed to verify magic link. The link may be expired or invalid.",
|
|
2799
|
+
redirectingMessage: "Redirecting you to the dashboard...",
|
|
2800
|
+
retryButton: "Try Again",
|
|
2801
|
+
backToLoginButton: "Back to Login"
|
|
2802
|
+
}, Ee = {
|
|
2803
|
+
container: {
|
|
2804
|
+
maxWidth: "400px",
|
|
2805
|
+
width: "100%",
|
|
2806
|
+
margin: "0 auto",
|
|
2807
|
+
padding: "2rem",
|
|
2808
|
+
backgroundColor: "#ffffff",
|
|
2809
|
+
borderRadius: "8px",
|
|
2810
|
+
boxShadow: "0 2px 10px rgba(0, 0, 0, 0.1)"
|
|
2811
|
+
},
|
|
2812
|
+
card: {
|
|
2813
|
+
// Not used in new design, keeping for compatibility
|
|
2814
|
+
backgroundColor: "transparent",
|
|
2815
|
+
padding: "0",
|
|
2816
|
+
borderRadius: "0",
|
|
2817
|
+
boxShadow: "none",
|
|
2818
|
+
maxWidth: "100%",
|
|
2819
|
+
width: "100%",
|
|
2820
|
+
textAlign: "center"
|
|
2821
|
+
},
|
|
2822
|
+
title: {
|
|
2823
|
+
fontSize: "1.5rem",
|
|
2824
|
+
fontWeight: "bold",
|
|
2825
|
+
textAlign: "center",
|
|
2826
|
+
marginBottom: "1.5rem",
|
|
2827
|
+
color: "#333333"
|
|
2828
|
+
},
|
|
2829
|
+
message: {
|
|
2830
|
+
fontSize: "1rem",
|
|
2831
|
+
color: "#6b7280",
|
|
2832
|
+
marginBottom: "1.5rem",
|
|
2833
|
+
lineHeight: "1.5",
|
|
2834
|
+
textAlign: "center"
|
|
2835
|
+
},
|
|
2836
|
+
successMessage: {
|
|
2837
|
+
fontSize: "1rem",
|
|
2838
|
+
color: "#059669",
|
|
2839
|
+
marginBottom: "1.5rem",
|
|
2840
|
+
lineHeight: "1.5",
|
|
2841
|
+
textAlign: "center"
|
|
2842
|
+
},
|
|
2843
|
+
errorMessage: {
|
|
2844
|
+
fontSize: "0.875rem",
|
|
2845
|
+
color: "#ef4444",
|
|
2846
|
+
textAlign: "center",
|
|
2847
|
+
marginBottom: "1rem",
|
|
2848
|
+
lineHeight: "1.5"
|
|
2849
|
+
},
|
|
2850
|
+
spinner: {
|
|
2851
|
+
display: "inline-block",
|
|
2852
|
+
width: "20px",
|
|
2853
|
+
height: "20px",
|
|
2854
|
+
border: "2px solid #e5e7eb",
|
|
2855
|
+
borderTop: "2px solid #3b82f6",
|
|
2856
|
+
borderRadius: "50%",
|
|
2857
|
+
animation: "spin 1s linear infinite",
|
|
2858
|
+
marginRight: "0.5rem"
|
|
2859
|
+
},
|
|
2860
|
+
buttonContainer: {
|
|
2861
|
+
display: "flex",
|
|
2862
|
+
gap: "0.75rem",
|
|
2863
|
+
justifyContent: "center",
|
|
2864
|
+
flexWrap: "wrap",
|
|
2865
|
+
marginTop: "1rem"
|
|
2866
|
+
},
|
|
2867
|
+
retryButton: {
|
|
2868
|
+
padding: "0.75rem 1rem",
|
|
2869
|
+
backgroundColor: "#3b82f6",
|
|
2870
|
+
color: "white",
|
|
2871
|
+
border: "none",
|
|
2872
|
+
borderRadius: "6px",
|
|
2873
|
+
fontSize: "1rem",
|
|
2874
|
+
fontWeight: "500",
|
|
2875
|
+
cursor: "pointer",
|
|
2876
|
+
transition: "background-color 0.15s ease-in-out"
|
|
2877
|
+
},
|
|
2878
|
+
backButton: {
|
|
2879
|
+
padding: "0.75rem 1rem",
|
|
2880
|
+
backgroundColor: "#f3f4f6",
|
|
2881
|
+
color: "#374151",
|
|
2882
|
+
border: "1px solid #d1d5db",
|
|
2883
|
+
borderRadius: "6px",
|
|
2884
|
+
fontSize: "1rem",
|
|
2885
|
+
fontWeight: "500",
|
|
2886
|
+
cursor: "pointer",
|
|
2887
|
+
transition: "all 0.15s ease-in-out"
|
|
2888
|
+
}
|
|
2889
|
+
}, lt = () => /* @__PURE__ */ n("div", { style: Ee.spinner }), ct = () => /* @__PURE__ */ l(
|
|
2890
|
+
"svg",
|
|
2891
|
+
{
|
|
2892
|
+
width: "48",
|
|
2893
|
+
height: "48",
|
|
2894
|
+
viewBox: "0 0 24 24",
|
|
2895
|
+
fill: "none",
|
|
2896
|
+
stroke: "#059669",
|
|
2897
|
+
strokeWidth: "2",
|
|
2898
|
+
strokeLinecap: "round",
|
|
2899
|
+
strokeLinejoin: "round",
|
|
2900
|
+
style: { margin: "0 auto 1rem auto", display: "block" },
|
|
2901
|
+
children: [
|
|
2902
|
+
/* @__PURE__ */ n("path", { d: "M22 11.08V12a10 10 0 1 1-5.93-9.14" }),
|
|
2903
|
+
/* @__PURE__ */ n("polyline", { points: "22,4 12,14.01 9,11.01" })
|
|
2904
|
+
]
|
|
2905
|
+
}
|
|
2906
|
+
), dt = () => /* @__PURE__ */ l(
|
|
2907
|
+
"svg",
|
|
2908
|
+
{
|
|
2909
|
+
width: "48",
|
|
2910
|
+
height: "48",
|
|
2911
|
+
viewBox: "0 0 24 24",
|
|
2912
|
+
fill: "none",
|
|
2913
|
+
stroke: "#ef4444",
|
|
2914
|
+
strokeWidth: "2",
|
|
2915
|
+
strokeLinecap: "round",
|
|
2916
|
+
strokeLinejoin: "round",
|
|
2917
|
+
style: { margin: "0 auto 1rem auto", display: "block" },
|
|
2918
|
+
children: [
|
|
2919
|
+
/* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "10" }),
|
|
2920
|
+
/* @__PURE__ */ n("line", { x1: "15", y1: "9", x2: "9", y2: "15" }),
|
|
2921
|
+
/* @__PURE__ */ n("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
|
|
2922
|
+
]
|
|
2923
|
+
}
|
|
2924
|
+
), ut = {
|
|
2925
|
+
loading: /* @__PURE__ */ n(lt, {}),
|
|
2926
|
+
success: /* @__PURE__ */ n(ct, {}),
|
|
2927
|
+
error: /* @__PURE__ */ n(dt, {})
|
|
2928
|
+
};
|
|
2929
|
+
function Nt({
|
|
2930
|
+
copy: i = {},
|
|
2931
|
+
styles: e = {},
|
|
2932
|
+
icons: t = {},
|
|
2933
|
+
onSuccess: r,
|
|
2934
|
+
onError: s,
|
|
2935
|
+
onRetry: a,
|
|
2936
|
+
onBackToLogin: p,
|
|
2937
|
+
className: I,
|
|
2938
|
+
token: A,
|
|
2939
|
+
email: x,
|
|
2940
|
+
appId: P,
|
|
2941
|
+
tenantSlug: b,
|
|
2942
|
+
autoRedirectDelay: m = 3e3
|
|
2943
|
+
}) {
|
|
2944
|
+
const [h, S] = v("verifying"), [L, C] = v(""), { verifyMagicLink: q } = oe(), k = { ...at, ...i }, u = { ...Ee, ...e }, T = { ...ut, ...t }, R = () => {
|
|
2945
|
+
if (typeof window > "u") return {};
|
|
2946
|
+
const w = new URLSearchParams(window.location.search);
|
|
2947
|
+
return {
|
|
2948
|
+
token: A || w.get("token") || "",
|
|
2949
|
+
email: x || w.get("email") || "",
|
|
2950
|
+
appId: P || w.get("appId") || "",
|
|
2951
|
+
tenantSlug: b || w.get("tenantSlug") || void 0
|
|
2952
|
+
};
|
|
2953
|
+
}, H = async () => {
|
|
2954
|
+
S("verifying"), C("");
|
|
2955
|
+
try {
|
|
2956
|
+
const w = R();
|
|
2957
|
+
if (!w.token || !w.email)
|
|
2958
|
+
throw new Error("Missing required parameters: token or email");
|
|
2959
|
+
const M = await q({
|
|
2960
|
+
token: w.token,
|
|
2961
|
+
email: w.email,
|
|
2962
|
+
tenantSlug: w.tenantSlug
|
|
2963
|
+
});
|
|
2964
|
+
S("success"), r == null || r(M), m > 0 && setTimeout(() => {
|
|
2965
|
+
S("redirecting");
|
|
2966
|
+
}, m);
|
|
2967
|
+
} catch (w) {
|
|
2968
|
+
const M = w.message || k.errorMessage;
|
|
2969
|
+
C(M), S("error"), s == null || s(M);
|
|
2970
|
+
}
|
|
2971
|
+
}, G = () => {
|
|
2972
|
+
a == null || a(), H();
|
|
2973
|
+
}, F = () => {
|
|
2974
|
+
p == null || p();
|
|
2975
|
+
};
|
|
2976
|
+
te(() => {
|
|
2977
|
+
H();
|
|
2978
|
+
}, []);
|
|
2979
|
+
const V = () => {
|
|
2980
|
+
switch (h) {
|
|
2981
|
+
case "verifying":
|
|
2982
|
+
return /* @__PURE__ */ l("div", { style: u.message, children: [
|
|
2983
|
+
T.loading,
|
|
2984
|
+
k.verifyingMessage
|
|
2985
|
+
] });
|
|
2986
|
+
case "success":
|
|
2987
|
+
return /* @__PURE__ */ l(N, { children: [
|
|
2988
|
+
T.success,
|
|
2989
|
+
/* @__PURE__ */ n("div", { style: u.successMessage, children: k.successMessage })
|
|
2990
|
+
] });
|
|
2991
|
+
case "redirecting":
|
|
2992
|
+
return /* @__PURE__ */ l(N, { children: [
|
|
2993
|
+
T.loading,
|
|
2994
|
+
/* @__PURE__ */ n("div", { style: u.message, children: k.redirectingMessage })
|
|
2995
|
+
] });
|
|
2996
|
+
case "error":
|
|
2997
|
+
return /* @__PURE__ */ l(N, { children: [
|
|
2998
|
+
T.error,
|
|
2999
|
+
/* @__PURE__ */ n("div", { style: u.errorMessage, children: L || k.errorMessage }),
|
|
3000
|
+
/* @__PURE__ */ l("div", { style: u.buttonContainer, children: [
|
|
3001
|
+
/* @__PURE__ */ n(
|
|
3002
|
+
"button",
|
|
3003
|
+
{
|
|
3004
|
+
onClick: G,
|
|
3005
|
+
style: u.retryButton,
|
|
3006
|
+
onMouseOver: (w) => {
|
|
3007
|
+
w.currentTarget.style.backgroundColor = "#2563eb";
|
|
3008
|
+
},
|
|
3009
|
+
onMouseOut: (w) => {
|
|
3010
|
+
w.currentTarget.style.backgroundColor = "#3b82f6";
|
|
3011
|
+
},
|
|
3012
|
+
children: k.retryButton
|
|
3013
|
+
}
|
|
3014
|
+
),
|
|
3015
|
+
/* @__PURE__ */ n(
|
|
3016
|
+
"button",
|
|
3017
|
+
{
|
|
3018
|
+
onClick: F,
|
|
3019
|
+
style: u.backButton,
|
|
3020
|
+
onMouseOver: (w) => {
|
|
3021
|
+
w.currentTarget.style.backgroundColor = "#e5e7eb";
|
|
3022
|
+
},
|
|
3023
|
+
onMouseOut: (w) => {
|
|
3024
|
+
w.currentTarget.style.backgroundColor = "#f3f4f6";
|
|
3025
|
+
},
|
|
3026
|
+
children: k.backToLoginButton
|
|
3027
|
+
}
|
|
3028
|
+
)
|
|
3029
|
+
] })
|
|
3030
|
+
] });
|
|
3031
|
+
default:
|
|
3032
|
+
return null;
|
|
3033
|
+
}
|
|
3034
|
+
};
|
|
3035
|
+
return /* @__PURE__ */ l("div", { style: u.container, className: I, children: [
|
|
3036
|
+
/* @__PURE__ */ n("style", { children: `
|
|
3037
|
+
@keyframes spin {
|
|
3038
|
+
0% { transform: rotate(0deg); }
|
|
3039
|
+
100% { transform: rotate(360deg); }
|
|
3040
|
+
}
|
|
3041
|
+
` }),
|
|
3042
|
+
/* @__PURE__ */ n("h1", { style: u.title, children: k.title }),
|
|
3043
|
+
V()
|
|
3044
|
+
] });
|
|
3045
|
+
}
|
|
3046
|
+
const ht = {
|
|
2139
3047
|
title: "Reset Password",
|
|
2140
3048
|
subtitle: "Enter your email address and we'll send you a link to reset your password.",
|
|
2141
3049
|
emailLabel: "Email",
|
|
@@ -2157,7 +3065,7 @@ const Ge = {
|
|
|
2157
3065
|
resetLoadingText: "Resetting...",
|
|
2158
3066
|
resetSuccessMessage: "Password reset successfully!",
|
|
2159
3067
|
passwordMismatchError: "Passwords do not match"
|
|
2160
|
-
},
|
|
3068
|
+
}, gt = {
|
|
2161
3069
|
container: {
|
|
2162
3070
|
maxWidth: "400px",
|
|
2163
3071
|
margin: "0 auto",
|
|
@@ -2249,186 +3157,186 @@ const Ge = {
|
|
|
2249
3157
|
cursor: "pointer"
|
|
2250
3158
|
}
|
|
2251
3159
|
};
|
|
2252
|
-
function
|
|
3160
|
+
function Bt({
|
|
2253
3161
|
copy: i = {},
|
|
2254
3162
|
styles: e = {},
|
|
2255
3163
|
mode: t = "request",
|
|
2256
3164
|
token: r = "",
|
|
2257
|
-
onSuccess:
|
|
2258
|
-
onError:
|
|
2259
|
-
onBackToLogin:
|
|
2260
|
-
onModeChange:
|
|
2261
|
-
className:
|
|
3165
|
+
onSuccess: s,
|
|
3166
|
+
onError: a,
|
|
3167
|
+
onBackToLogin: p,
|
|
3168
|
+
onModeChange: I,
|
|
3169
|
+
className: A
|
|
2262
3170
|
}) {
|
|
2263
|
-
const [
|
|
2264
|
-
const
|
|
2265
|
-
return
|
|
2266
|
-
},
|
|
2267
|
-
const
|
|
2268
|
-
return
|
|
2269
|
-
},
|
|
2270
|
-
if (
|
|
2271
|
-
if (!(
|
|
2272
|
-
|
|
3171
|
+
const [x, P] = v(""), [b, m] = v(r), [h, S] = v(""), [L, C] = v(""), [q, k] = v(!1), [u, T] = v(""), [R, H] = v(""), [G, F] = v({}), { requestPasswordReset: V, confirmPasswordReset: w } = oe(), { tenant: M } = se(), E = { ...ht, ...i }, o = { ...gt, ...e }, g = () => {
|
|
3172
|
+
const z = {};
|
|
3173
|
+
return x.trim() || (z.email = !0), F(z), Object.keys(z).length === 0;
|
|
3174
|
+
}, f = () => {
|
|
3175
|
+
const z = {};
|
|
3176
|
+
return b.trim() || (z.token = !0), h.trim() || (z.newPassword = !0), L.trim() || (z.confirmPassword = !0), F(z), Object.keys(z).length === 0;
|
|
3177
|
+
}, d = async (z) => {
|
|
3178
|
+
if (z.preventDefault(), !!g()) {
|
|
3179
|
+
if (!(M != null && M.id)) {
|
|
3180
|
+
T("Tenant not found");
|
|
2273
3181
|
return;
|
|
2274
3182
|
}
|
|
2275
|
-
|
|
3183
|
+
k(!0), T(""), H("");
|
|
2276
3184
|
try {
|
|
2277
|
-
await
|
|
2278
|
-
} catch (
|
|
2279
|
-
const
|
|
2280
|
-
|
|
3185
|
+
await V({ email: x, tenantId: M.id }), H(E.successMessage), s == null || s();
|
|
3186
|
+
} catch (B) {
|
|
3187
|
+
const O = B.message || E.errorMessage;
|
|
3188
|
+
T(O), a == null || a(O);
|
|
2281
3189
|
} finally {
|
|
2282
|
-
|
|
3190
|
+
k(!1);
|
|
2283
3191
|
}
|
|
2284
3192
|
}
|
|
2285
|
-
},
|
|
2286
|
-
if (
|
|
2287
|
-
if (
|
|
2288
|
-
|
|
3193
|
+
}, c = async (z) => {
|
|
3194
|
+
if (z.preventDefault(), !!f()) {
|
|
3195
|
+
if (h !== L) {
|
|
3196
|
+
T(E.passwordMismatchError), F({ confirmPassword: !0 });
|
|
2289
3197
|
return;
|
|
2290
3198
|
}
|
|
2291
|
-
|
|
3199
|
+
k(!0), T(""), H("");
|
|
2292
3200
|
try {
|
|
2293
|
-
await w(
|
|
2294
|
-
} catch (
|
|
2295
|
-
const
|
|
2296
|
-
|
|
3201
|
+
await w({ token: b, newPassword: h }), H(E.resetSuccessMessage), s == null || s();
|
|
3202
|
+
} catch (B) {
|
|
3203
|
+
const O = B.message || E.errorMessage;
|
|
3204
|
+
T(O), a == null || a(O);
|
|
2297
3205
|
} finally {
|
|
2298
|
-
|
|
3206
|
+
k(!1);
|
|
2299
3207
|
}
|
|
2300
3208
|
}
|
|
2301
|
-
},
|
|
2302
|
-
...
|
|
2303
|
-
...
|
|
2304
|
-
}),
|
|
2305
|
-
...
|
|
2306
|
-
...
|
|
3209
|
+
}, y = (z) => ({
|
|
3210
|
+
...o.input,
|
|
3211
|
+
...G[z] ? o.inputError : {}
|
|
3212
|
+
}), W = () => ({
|
|
3213
|
+
...o.button,
|
|
3214
|
+
...q ? o.buttonLoading : {}
|
|
2307
3215
|
});
|
|
2308
3216
|
if (t === "reset") {
|
|
2309
|
-
const
|
|
2310
|
-
return /* @__PURE__ */
|
|
2311
|
-
/* @__PURE__ */
|
|
2312
|
-
/* @__PURE__ */
|
|
2313
|
-
/* @__PURE__ */
|
|
2314
|
-
/* @__PURE__ */
|
|
2315
|
-
/* @__PURE__ */
|
|
2316
|
-
/* @__PURE__ */
|
|
3217
|
+
const z = b && h && L;
|
|
3218
|
+
return /* @__PURE__ */ l("div", { className: A, style: o.container, children: [
|
|
3219
|
+
/* @__PURE__ */ n("h2", { style: o.title, children: E.resetTitle }),
|
|
3220
|
+
/* @__PURE__ */ n("p", { style: o.subtitle, children: E.resetSubtitle }),
|
|
3221
|
+
/* @__PURE__ */ l("form", { onSubmit: c, style: o.form, children: [
|
|
3222
|
+
/* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
|
|
3223
|
+
/* @__PURE__ */ n("label", { style: o.label, children: E.tokenLabel }),
|
|
3224
|
+
/* @__PURE__ */ n(
|
|
2317
3225
|
"input",
|
|
2318
3226
|
{
|
|
2319
3227
|
type: "text",
|
|
2320
|
-
value:
|
|
2321
|
-
onChange: (
|
|
2322
|
-
|
|
3228
|
+
value: b,
|
|
3229
|
+
onChange: (B) => {
|
|
3230
|
+
m(B.target.value), G.token && F((O) => ({ ...O, token: !1 }));
|
|
2323
3231
|
},
|
|
2324
|
-
placeholder:
|
|
2325
|
-
style:
|
|
2326
|
-
disabled:
|
|
3232
|
+
placeholder: E.tokenPlaceholder,
|
|
3233
|
+
style: y("token"),
|
|
3234
|
+
disabled: q
|
|
2327
3235
|
}
|
|
2328
3236
|
)
|
|
2329
3237
|
] }),
|
|
2330
|
-
/* @__PURE__ */
|
|
2331
|
-
/* @__PURE__ */
|
|
2332
|
-
/* @__PURE__ */
|
|
3238
|
+
/* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
|
|
3239
|
+
/* @__PURE__ */ n("label", { style: o.label, children: E.newPasswordLabel }),
|
|
3240
|
+
/* @__PURE__ */ n(
|
|
2333
3241
|
"input",
|
|
2334
3242
|
{
|
|
2335
3243
|
type: "password",
|
|
2336
|
-
value:
|
|
2337
|
-
onChange: (
|
|
2338
|
-
|
|
3244
|
+
value: h,
|
|
3245
|
+
onChange: (B) => {
|
|
3246
|
+
S(B.target.value), G.newPassword && F((O) => ({ ...O, newPassword: !1 }));
|
|
2339
3247
|
},
|
|
2340
|
-
placeholder:
|
|
2341
|
-
style:
|
|
2342
|
-
disabled:
|
|
3248
|
+
placeholder: E.newPasswordPlaceholder,
|
|
3249
|
+
style: y("newPassword"),
|
|
3250
|
+
disabled: q
|
|
2343
3251
|
}
|
|
2344
3252
|
)
|
|
2345
3253
|
] }),
|
|
2346
|
-
/* @__PURE__ */
|
|
2347
|
-
/* @__PURE__ */
|
|
2348
|
-
/* @__PURE__ */
|
|
3254
|
+
/* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
|
|
3255
|
+
/* @__PURE__ */ n("label", { style: o.label, children: E.confirmPasswordLabel }),
|
|
3256
|
+
/* @__PURE__ */ n(
|
|
2349
3257
|
"input",
|
|
2350
3258
|
{
|
|
2351
3259
|
type: "password",
|
|
2352
|
-
value:
|
|
2353
|
-
onChange: (
|
|
2354
|
-
|
|
3260
|
+
value: L,
|
|
3261
|
+
onChange: (B) => {
|
|
3262
|
+
C(B.target.value), G.confirmPassword && F((O) => ({ ...O, confirmPassword: !1 })), u === E.passwordMismatchError && T("");
|
|
2355
3263
|
},
|
|
2356
|
-
placeholder:
|
|
2357
|
-
style:
|
|
2358
|
-
disabled:
|
|
3264
|
+
placeholder: E.confirmPasswordPlaceholder,
|
|
3265
|
+
style: y("confirmPassword"),
|
|
3266
|
+
disabled: q
|
|
2359
3267
|
}
|
|
2360
3268
|
)
|
|
2361
3269
|
] }),
|
|
2362
|
-
/* @__PURE__ */
|
|
3270
|
+
/* @__PURE__ */ n(
|
|
2363
3271
|
"button",
|
|
2364
3272
|
{
|
|
2365
3273
|
type: "submit",
|
|
2366
|
-
disabled: !
|
|
3274
|
+
disabled: !z || q,
|
|
2367
3275
|
style: {
|
|
2368
|
-
...
|
|
2369
|
-
...!
|
|
3276
|
+
...W(),
|
|
3277
|
+
...!z || q ? o.buttonDisabled : {}
|
|
2370
3278
|
},
|
|
2371
|
-
children:
|
|
3279
|
+
children: q ? E.resetLoadingText : E.resetSubmitButton
|
|
2372
3280
|
}
|
|
2373
3281
|
),
|
|
2374
|
-
|
|
2375
|
-
R && /* @__PURE__ */
|
|
3282
|
+
u && /* @__PURE__ */ n("div", { style: o.errorText, children: u }),
|
|
3283
|
+
R && /* @__PURE__ */ n("div", { style: o.successText, children: R })
|
|
2376
3284
|
] }),
|
|
2377
|
-
/* @__PURE__ */
|
|
2378
|
-
/* @__PURE__ */
|
|
2379
|
-
|
|
2380
|
-
/* @__PURE__ */
|
|
2381
|
-
/* @__PURE__ */
|
|
3285
|
+
/* @__PURE__ */ l("div", { style: o.linkContainer, children: [
|
|
3286
|
+
/* @__PURE__ */ n("a", { onClick: p, style: o.link, children: E.backToLoginLink }),
|
|
3287
|
+
I && /* @__PURE__ */ l(N, { children: [
|
|
3288
|
+
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3289
|
+
/* @__PURE__ */ n("a", { onClick: () => I("request"), style: o.link, children: "Request New Link" })
|
|
2382
3290
|
] })
|
|
2383
3291
|
] })
|
|
2384
3292
|
] });
|
|
2385
3293
|
}
|
|
2386
|
-
const
|
|
2387
|
-
return /* @__PURE__ */
|
|
2388
|
-
/* @__PURE__ */
|
|
2389
|
-
/* @__PURE__ */
|
|
2390
|
-
/* @__PURE__ */
|
|
2391
|
-
/* @__PURE__ */
|
|
2392
|
-
/* @__PURE__ */
|
|
2393
|
-
/* @__PURE__ */
|
|
3294
|
+
const ee = x;
|
|
3295
|
+
return /* @__PURE__ */ l("div", { className: A, style: o.container, children: [
|
|
3296
|
+
/* @__PURE__ */ n("h2", { style: o.title, children: E.title }),
|
|
3297
|
+
/* @__PURE__ */ n("p", { style: o.subtitle, children: E.subtitle }),
|
|
3298
|
+
/* @__PURE__ */ l("form", { onSubmit: d, style: o.form, children: [
|
|
3299
|
+
/* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
|
|
3300
|
+
/* @__PURE__ */ n("label", { style: o.label, children: E.emailLabel }),
|
|
3301
|
+
/* @__PURE__ */ n(
|
|
2394
3302
|
"input",
|
|
2395
3303
|
{
|
|
2396
3304
|
type: "email",
|
|
2397
|
-
value:
|
|
2398
|
-
onChange: (
|
|
2399
|
-
|
|
3305
|
+
value: x,
|
|
3306
|
+
onChange: (z) => {
|
|
3307
|
+
P(z.target.value), G.email && F((B) => ({ ...B, email: !1 }));
|
|
2400
3308
|
},
|
|
2401
|
-
placeholder:
|
|
2402
|
-
style:
|
|
2403
|
-
disabled:
|
|
3309
|
+
placeholder: E.emailPlaceholder,
|
|
3310
|
+
style: y("email"),
|
|
3311
|
+
disabled: q
|
|
2404
3312
|
}
|
|
2405
3313
|
)
|
|
2406
3314
|
] }),
|
|
2407
|
-
/* @__PURE__ */
|
|
3315
|
+
/* @__PURE__ */ n(
|
|
2408
3316
|
"button",
|
|
2409
3317
|
{
|
|
2410
3318
|
type: "submit",
|
|
2411
|
-
disabled: !
|
|
3319
|
+
disabled: !ee || q,
|
|
2412
3320
|
style: {
|
|
2413
|
-
...
|
|
2414
|
-
...!
|
|
3321
|
+
...W(),
|
|
3322
|
+
...!ee || q ? o.buttonDisabled : {}
|
|
2415
3323
|
},
|
|
2416
|
-
children:
|
|
3324
|
+
children: q ? E.loadingText : E.submitButton
|
|
2417
3325
|
}
|
|
2418
3326
|
),
|
|
2419
|
-
|
|
2420
|
-
R && /* @__PURE__ */
|
|
3327
|
+
u && /* @__PURE__ */ n("div", { style: o.errorText, children: u }),
|
|
3328
|
+
R && /* @__PURE__ */ n("div", { style: o.successText, children: R })
|
|
2421
3329
|
] }),
|
|
2422
|
-
/* @__PURE__ */
|
|
2423
|
-
/* @__PURE__ */
|
|
2424
|
-
|
|
2425
|
-
/* @__PURE__ */
|
|
2426
|
-
/* @__PURE__ */
|
|
3330
|
+
/* @__PURE__ */ l("div", { style: o.linkContainer, children: [
|
|
3331
|
+
/* @__PURE__ */ n("a", { onClick: p, style: o.link, children: E.backToLoginLink }),
|
|
3332
|
+
I && /* @__PURE__ */ l(N, { children: [
|
|
3333
|
+
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3334
|
+
/* @__PURE__ */ n("a", { onClick: () => I("reset"), style: o.link, children: "I have a token" })
|
|
2427
3335
|
] })
|
|
2428
3336
|
] })
|
|
2429
3337
|
] });
|
|
2430
3338
|
}
|
|
2431
|
-
class
|
|
3339
|
+
class Ut {
|
|
2432
3340
|
constructor(e, t) {
|
|
2433
3341
|
this.httpService = e, this.sessionManager = t;
|
|
2434
3342
|
}
|
|
@@ -2449,12 +3357,12 @@ class wt {
|
|
|
2449
3357
|
throw new Error("SessionManager is required for private endpoints");
|
|
2450
3358
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
2451
3359
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
2452
|
-
const
|
|
3360
|
+
const s = `/permissions/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
|
|
2453
3361
|
headers: t
|
|
2454
3362
|
});
|
|
2455
3363
|
return {
|
|
2456
|
-
permissions:
|
|
2457
|
-
meta:
|
|
3364
|
+
permissions: a.data,
|
|
3365
|
+
meta: a.meta
|
|
2458
3366
|
};
|
|
2459
3367
|
}
|
|
2460
3368
|
async getPermissionById(e) {
|
|
@@ -2489,14 +3397,14 @@ class wt {
|
|
|
2489
3397
|
async getAppPermissions(e, t) {
|
|
2490
3398
|
const r = new URLSearchParams();
|
|
2491
3399
|
t != null && t.page && r.append("page", t.page.toString()), t != null && t.limit && r.append("limit", t.limit.toString()), t != null && t.sortBy && r.append("sortBy", t.sortBy), t != null && t.sortOrder && r.append("sortOrder", t.sortOrder);
|
|
2492
|
-
const
|
|
3400
|
+
const s = `/permissions/apps/${e}${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s);
|
|
2493
3401
|
return {
|
|
2494
|
-
permissions:
|
|
2495
|
-
meta:
|
|
3402
|
+
permissions: a.data,
|
|
3403
|
+
meta: a.meta
|
|
2496
3404
|
};
|
|
2497
3405
|
}
|
|
2498
3406
|
}
|
|
2499
|
-
class
|
|
3407
|
+
class qt {
|
|
2500
3408
|
constructor(e, t) {
|
|
2501
3409
|
this.httpService = e, this.sessionManager = t;
|
|
2502
3410
|
}
|
|
@@ -2513,12 +3421,12 @@ class mt {
|
|
|
2513
3421
|
async getSubscriptionPlans(e) {
|
|
2514
3422
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
2515
3423
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder), e != null && e.appId && r.append("appId", e.appId);
|
|
2516
|
-
const
|
|
3424
|
+
const s = `/subscription-plans/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
|
|
2517
3425
|
headers: t
|
|
2518
3426
|
});
|
|
2519
3427
|
return {
|
|
2520
|
-
plans:
|
|
2521
|
-
meta:
|
|
3428
|
+
plans: a.data,
|
|
3429
|
+
meta: a.meta
|
|
2522
3430
|
};
|
|
2523
3431
|
}
|
|
2524
3432
|
async getSubscriptionPlanById(e) {
|
|
@@ -2547,7 +3455,7 @@ class mt {
|
|
|
2547
3455
|
});
|
|
2548
3456
|
}
|
|
2549
3457
|
}
|
|
2550
|
-
class
|
|
3458
|
+
class zt {
|
|
2551
3459
|
constructor(e) {
|
|
2552
3460
|
this.httpService = e;
|
|
2553
3461
|
}
|
|
@@ -2556,7 +3464,7 @@ class bt {
|
|
|
2556
3464
|
return await this.httpService.get("/health");
|
|
2557
3465
|
}
|
|
2558
3466
|
}
|
|
2559
|
-
class
|
|
3467
|
+
class Ot {
|
|
2560
3468
|
// Date string to Date object
|
|
2561
3469
|
static toDate(e) {
|
|
2562
3470
|
return new Date(e);
|
|
@@ -2673,48 +3581,50 @@ class St {
|
|
|
2673
3581
|
// Transform query parameters for API calls
|
|
2674
3582
|
static transformQueryParams(e) {
|
|
2675
3583
|
const t = new URLSearchParams();
|
|
2676
|
-
return Object.entries(e).forEach(([r,
|
|
2677
|
-
|
|
3584
|
+
return Object.entries(e).forEach(([r, s]) => {
|
|
3585
|
+
s != null && s !== "" && t.append(r, String(s));
|
|
2678
3586
|
}), t;
|
|
2679
3587
|
}
|
|
2680
3588
|
}
|
|
2681
3589
|
export {
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
3590
|
+
Ot as ApiMappers,
|
|
3591
|
+
be as AppApiService,
|
|
3592
|
+
St as AppProvider,
|
|
3593
|
+
Ne as AuthApiService,
|
|
3594
|
+
Pt as AuthProvider,
|
|
3595
|
+
Ft as FeatureFlag,
|
|
3596
|
+
ze as FeatureFlagApiService,
|
|
3597
|
+
Tt as FeatureFlagProvider,
|
|
3598
|
+
zt as HealthApiService,
|
|
3599
|
+
re as HttpService,
|
|
3600
|
+
Ct as LandingRoute,
|
|
3601
|
+
$t as LoginForm,
|
|
3602
|
+
Ht as MagicLinkForm,
|
|
3603
|
+
Nt as MagicLinkVerify,
|
|
3604
|
+
Bt as PasswordRecoveryForm,
|
|
3605
|
+
Ut as PermissionApiService,
|
|
3606
|
+
It as Protected,
|
|
3607
|
+
Et as ProtectedRoute,
|
|
3608
|
+
Se as RoleApiService,
|
|
3609
|
+
ye as SessionManager,
|
|
3610
|
+
Dt as SignupForm,
|
|
3611
|
+
je as SubscriptionApiService,
|
|
3612
|
+
Lt as SubscriptionGuard,
|
|
3613
|
+
qt as SubscriptionPlanApiService,
|
|
3614
|
+
Mt as SubscriptionProvider,
|
|
3615
|
+
ce as TenantApiService,
|
|
3616
|
+
xt as TenantProvider,
|
|
3617
|
+
Rt as TenantRoute,
|
|
3618
|
+
Be as UserApiService,
|
|
3619
|
+
ie as UserType,
|
|
3620
|
+
vt as useApi,
|
|
3621
|
+
he as useApp,
|
|
3622
|
+
oe as useAuth,
|
|
3623
|
+
Oe as useFeatureFlags,
|
|
3624
|
+
At as useSettings,
|
|
3625
|
+
Ve as useSubscription,
|
|
3626
|
+
fe as useTenant,
|
|
3627
|
+
se as useTenantInfo,
|
|
3628
|
+
kt as useTenantSettings
|
|
2719
3629
|
};
|
|
2720
3630
|
//# sourceMappingURL=index.es.js.map
|