@skylabs-digital/react-identity-access 2.3.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +971 -926
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/providers/AuthProvider.d.ts.map +1 -1
- package/dist/utils/crossDomainAuth.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as n, Fragment as
|
|
2
|
-
import { createContext as he, useMemo as X, useState as
|
|
1
|
+
import { jsx as n, Fragment as q, jsxs as l } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as he, useMemo as X, useState as v, useCallback as ne, useEffect as te, useContext as ce, useRef as qe } from "react";
|
|
3
3
|
import { useLocation as be, Navigate as pe } from "react-router-dom";
|
|
4
4
|
class re {
|
|
5
5
|
// SessionManager instance
|
|
@@ -16,7 +16,7 @@ class re {
|
|
|
16
16
|
return this.executeRequest(e, t, r, s, !1);
|
|
17
17
|
}
|
|
18
18
|
async executeRequest(e, t, r, s, o = !1) {
|
|
19
|
-
const
|
|
19
|
+
const h = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, w = (s == null ? void 0 : s.timeout) || this.timeout;
|
|
20
20
|
let k = {
|
|
21
21
|
"Content-Type": "application/json",
|
|
22
22
|
...s == null ? void 0 : s.headers
|
|
@@ -28,15 +28,15 @@ class re {
|
|
|
28
28
|
} catch (m) {
|
|
29
29
|
console.warn("Failed to inject auth headers:", m);
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const b = new AbortController(), P = setTimeout(() => b.abort(), w);
|
|
32
32
|
try {
|
|
33
|
-
const m = await fetch(
|
|
33
|
+
const m = await fetch(h, {
|
|
34
34
|
method: e,
|
|
35
35
|
headers: k,
|
|
36
36
|
body: r ? JSON.stringify(r) : void 0,
|
|
37
|
-
signal:
|
|
37
|
+
signal: b.signal
|
|
38
38
|
});
|
|
39
|
-
if (clearTimeout(
|
|
39
|
+
if (clearTimeout(P), m.status === 401 && !(s != null && s.skipRetry) && !o && this.sessionManager)
|
|
40
40
|
try {
|
|
41
41
|
const u = this.sessionManager.getTokens();
|
|
42
42
|
if (u != null && u.refreshToken)
|
|
@@ -46,10 +46,10 @@ class re {
|
|
|
46
46
|
}
|
|
47
47
|
if (!m.ok)
|
|
48
48
|
throw new Error(`HTTP ${m.status}: ${m.statusText}`);
|
|
49
|
-
const
|
|
50
|
-
return !
|
|
49
|
+
const p = m.headers.get("content-type");
|
|
50
|
+
return !p || !p.includes("application/json") ? {} : await m.json();
|
|
51
51
|
} catch (m) {
|
|
52
|
-
throw clearTimeout(
|
|
52
|
+
throw clearTimeout(P), m instanceof Error && m.name === "AbortError" ? new Error(`Request timeout after ${w}ms`) : m;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
async get(e, t) {
|
|
@@ -125,31 +125,31 @@ class ve {
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
const Pe = he(null);
|
|
128
|
-
function
|
|
128
|
+
function Ct({ config: i, children: e }) {
|
|
129
129
|
const t = X(
|
|
130
130
|
() => {
|
|
131
|
-
var
|
|
131
|
+
var p, u, y;
|
|
132
132
|
return {
|
|
133
|
-
enabled: ((
|
|
133
|
+
enabled: ((p = i.cache) == null ? void 0 : p.enabled) ?? !0,
|
|
134
134
|
ttl: ((u = i.cache) == null ? void 0 : u.ttl) ?? 3e5,
|
|
135
135
|
// 5 minutes default
|
|
136
136
|
storageKey: ((y = i.cache) == null ? void 0 : y.storageKey) ?? `app_cache_${i.appId}`
|
|
137
137
|
};
|
|
138
138
|
},
|
|
139
139
|
[i.cache, i.appId]
|
|
140
|
-
), [r, s] =
|
|
140
|
+
), [r, s] = v(() => {
|
|
141
141
|
if (!t.enabled) return null;
|
|
142
142
|
try {
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
145
|
-
const u = JSON.parse(
|
|
143
|
+
const p = localStorage.getItem(t.storageKey);
|
|
144
|
+
if (!p) return null;
|
|
145
|
+
const u = JSON.parse(p);
|
|
146
146
|
return Date.now() - u.timestamp < t.ttl && u.appId === i.appId ? u.data : (localStorage.removeItem(t.storageKey), null);
|
|
147
147
|
} catch {
|
|
148
148
|
return null;
|
|
149
149
|
}
|
|
150
|
-
}), [o,
|
|
151
|
-
const
|
|
152
|
-
|
|
150
|
+
}), [o, h] = v(!r), [w, k] = v(null), b = X(() => {
|
|
151
|
+
const p = () => {
|
|
152
|
+
P();
|
|
153
153
|
};
|
|
154
154
|
return {
|
|
155
155
|
appId: i.appId,
|
|
@@ -157,57 +157,57 @@ function Et({ config: i, children: e }) {
|
|
|
157
157
|
// App info
|
|
158
158
|
appInfo: r,
|
|
159
159
|
isAppLoading: o,
|
|
160
|
-
appError:
|
|
161
|
-
retryApp:
|
|
160
|
+
appError: w,
|
|
161
|
+
retryApp: p
|
|
162
162
|
};
|
|
163
|
-
}, [i, r, o,
|
|
164
|
-
async (
|
|
165
|
-
if (!(!
|
|
163
|
+
}, [i, r, o, w]), P = ne(
|
|
164
|
+
async (p = !1) => {
|
|
165
|
+
if (!(!p && t.enabled && r))
|
|
166
166
|
try {
|
|
167
|
-
|
|
168
|
-
const u = new re(i.baseUrl),
|
|
169
|
-
if (s(
|
|
167
|
+
h(!0), k(null);
|
|
168
|
+
const u = new re(i.baseUrl), L = await new ve(u, {}).getPublicAppInfo(i.appId);
|
|
169
|
+
if (s(L), t.enabled)
|
|
170
170
|
try {
|
|
171
|
-
const
|
|
172
|
-
data:
|
|
171
|
+
const R = {
|
|
172
|
+
data: L,
|
|
173
173
|
timestamp: Date.now(),
|
|
174
174
|
appId: i.appId
|
|
175
175
|
};
|
|
176
|
-
localStorage.setItem(t.storageKey, JSON.stringify(
|
|
177
|
-
} catch (
|
|
178
|
-
console.warn("Failed to cache app info:",
|
|
176
|
+
localStorage.setItem(t.storageKey, JSON.stringify(R));
|
|
177
|
+
} catch (R) {
|
|
178
|
+
console.warn("Failed to cache app info:", R);
|
|
179
179
|
}
|
|
180
180
|
} catch (u) {
|
|
181
181
|
const y = u instanceof Error ? u : new Error("Failed to load app information");
|
|
182
182
|
k(y), s(null);
|
|
183
183
|
} finally {
|
|
184
|
-
|
|
184
|
+
h(!1);
|
|
185
185
|
}
|
|
186
186
|
},
|
|
187
187
|
[i.baseUrl, i.appId, t, r]
|
|
188
188
|
), m = ne(async () => {
|
|
189
189
|
if (!(!t.enabled || !r))
|
|
190
190
|
try {
|
|
191
|
-
const
|
|
192
|
-
if (!
|
|
193
|
-
const u = JSON.parse(
|
|
191
|
+
const p = localStorage.getItem(t.storageKey);
|
|
192
|
+
if (!p) return;
|
|
193
|
+
const u = JSON.parse(p);
|
|
194
194
|
if (Date.now() - u.timestamp > t.ttl * 0.5) {
|
|
195
|
-
const
|
|
196
|
-
s(
|
|
197
|
-
const
|
|
198
|
-
data:
|
|
195
|
+
const L = new re(i.baseUrl), z = await new ve(L, {}).getPublicAppInfo(i.appId);
|
|
196
|
+
s(z);
|
|
197
|
+
const M = {
|
|
198
|
+
data: z,
|
|
199
199
|
timestamp: Date.now(),
|
|
200
200
|
appId: i.appId
|
|
201
201
|
};
|
|
202
|
-
localStorage.setItem(t.storageKey, JSON.stringify(
|
|
202
|
+
localStorage.setItem(t.storageKey, JSON.stringify(M));
|
|
203
203
|
}
|
|
204
|
-
} catch (
|
|
205
|
-
console.warn("Background app refresh failed:",
|
|
204
|
+
} catch (p) {
|
|
205
|
+
console.warn("Background app refresh failed:", p);
|
|
206
206
|
}
|
|
207
207
|
}, [i, t, r]);
|
|
208
208
|
return te(() => {
|
|
209
|
-
r ? m() :
|
|
210
|
-
}, []), /* @__PURE__ */ n(Pe.Provider, { value:
|
|
209
|
+
r ? m() : P();
|
|
210
|
+
}, []), /* @__PURE__ */ n(Pe.Provider, { value: b, children: e });
|
|
211
211
|
}
|
|
212
212
|
function oe() {
|
|
213
213
|
const i = ce(Pe);
|
|
@@ -215,7 +215,7 @@ function oe() {
|
|
|
215
215
|
throw new Error("useApp must be used within an AppProvider");
|
|
216
216
|
return i;
|
|
217
217
|
}
|
|
218
|
-
const
|
|
218
|
+
const Ft = oe;
|
|
219
219
|
class we {
|
|
220
220
|
constructor(e = {}) {
|
|
221
221
|
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);
|
|
@@ -369,7 +369,7 @@ class we {
|
|
|
369
369
|
return e !== null && !this.isTokenExpired(e);
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
|
-
class
|
|
372
|
+
class ze {
|
|
373
373
|
constructor(e) {
|
|
374
374
|
this.httpService = e;
|
|
375
375
|
}
|
|
@@ -414,7 +414,7 @@ class Ue {
|
|
|
414
414
|
});
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
|
-
class
|
|
417
|
+
class ke {
|
|
418
418
|
constructor(e, t) {
|
|
419
419
|
this.httpService = e, this.sessionManager = t;
|
|
420
420
|
}
|
|
@@ -481,16 +481,16 @@ class xe {
|
|
|
481
481
|
throw new Error("SessionManager is required for private endpoints");
|
|
482
482
|
const r = await this.sessionManager.getAuthHeaders(), s = new URLSearchParams();
|
|
483
483
|
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);
|
|
484
|
-
const o = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`,
|
|
484
|
+
const o = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, h = await this.httpService.get(o, {
|
|
485
485
|
headers: r
|
|
486
486
|
});
|
|
487
487
|
return {
|
|
488
|
-
roles:
|
|
489
|
-
meta:
|
|
488
|
+
roles: h.data,
|
|
489
|
+
meta: h.meta
|
|
490
490
|
};
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
|
-
class
|
|
493
|
+
class Oe {
|
|
494
494
|
constructor(e, t) {
|
|
495
495
|
this.httpService = e, this.sessionManager = t;
|
|
496
496
|
}
|
|
@@ -608,7 +608,7 @@ class ue {
|
|
|
608
608
|
)).data;
|
|
609
609
|
}
|
|
610
610
|
}
|
|
611
|
-
function
|
|
611
|
+
function We(i, e) {
|
|
612
612
|
if (i === "localhost" || i.startsWith("127.") || i.startsWith("192.168."))
|
|
613
613
|
return null;
|
|
614
614
|
if (e) {
|
|
@@ -616,34 +616,34 @@ function ze(i, e) {
|
|
|
616
616
|
if (o === s || o === `www.${s}`)
|
|
617
617
|
return null;
|
|
618
618
|
if (o.endsWith(`.${s}`)) {
|
|
619
|
-
const
|
|
620
|
-
return
|
|
619
|
+
const h = o.slice(0, -(s.length + 1));
|
|
620
|
+
return h === "www" ? null : h;
|
|
621
621
|
}
|
|
622
622
|
return null;
|
|
623
623
|
}
|
|
624
624
|
const r = i.split(".");
|
|
625
625
|
return r.length >= 3 && r[0] !== "www" ? r[0] : null;
|
|
626
626
|
}
|
|
627
|
-
function
|
|
627
|
+
function Ve(i, e = "tenant", t) {
|
|
628
628
|
const s = new URLSearchParams(i).get(e);
|
|
629
629
|
return s ? (t && t.setItem("tenant", s), s) : t ? t.getItem("tenant") : null;
|
|
630
630
|
}
|
|
631
|
-
function
|
|
631
|
+
function je(i, e, t) {
|
|
632
632
|
const { tenantMode: r, baseDomain: s, selectorParam: o } = i;
|
|
633
|
-
return r === "subdomain" ?
|
|
633
|
+
return r === "subdomain" ? We(e.hostname, s) : r === "selector" ? Ve(e.search, o, t) : null;
|
|
634
634
|
}
|
|
635
|
-
function
|
|
635
|
+
function _e(i, e, t) {
|
|
636
636
|
if (t)
|
|
637
637
|
return `${i}.${t}`;
|
|
638
638
|
const r = e.split(".");
|
|
639
639
|
return r.length === 2 ? `${i}.${e}` : r.length >= 3 ? (r[0] = i, r.join(".")) : null;
|
|
640
640
|
}
|
|
641
641
|
const fe = "_auth";
|
|
642
|
-
function
|
|
642
|
+
function Ge(i) {
|
|
643
643
|
const e = JSON.stringify(i);
|
|
644
644
|
return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
645
645
|
}
|
|
646
|
-
function
|
|
646
|
+
function Ke(i) {
|
|
647
647
|
try {
|
|
648
648
|
let e = i.replace(/-/g, "+").replace(/_/g, "/");
|
|
649
649
|
for (; e.length % 4; )
|
|
@@ -654,19 +654,34 @@ function _e(i) {
|
|
|
654
654
|
return null;
|
|
655
655
|
}
|
|
656
656
|
}
|
|
657
|
-
function
|
|
658
|
-
if (typeof window > "u")
|
|
657
|
+
function Je() {
|
|
658
|
+
if (typeof window > "u")
|
|
659
|
+
return console.log("[CrossDomainAuth] SSR environment, skipping URL token extraction"), null;
|
|
659
660
|
const e = new URLSearchParams(window.location.search).get(fe);
|
|
660
|
-
|
|
661
|
+
if (console.log("[CrossDomainAuth] extractAuthTokensFromUrl called", {
|
|
662
|
+
hasAuthParam: !!e,
|
|
663
|
+
searchParams: window.location.search,
|
|
664
|
+
encodedLength: e == null ? void 0 : e.length
|
|
665
|
+
}), !e) return null;
|
|
666
|
+
const t = Ke(e);
|
|
667
|
+
return console.log("[CrossDomainAuth] Token decode result:", {
|
|
668
|
+
success: !!t,
|
|
669
|
+
hasAccessToken: !!(t != null && t.accessToken),
|
|
670
|
+
hasRefreshToken: !!(t != null && t.refreshToken),
|
|
671
|
+
expiresIn: t == null ? void 0 : t.expiresIn
|
|
672
|
+
}), t;
|
|
661
673
|
}
|
|
662
|
-
function
|
|
674
|
+
function Ye() {
|
|
663
675
|
if (typeof window > "u") return;
|
|
664
676
|
const i = new URL(window.location.href);
|
|
665
|
-
i.searchParams.delete(fe),
|
|
677
|
+
i.searchParams.delete(fe), console.log("[CrossDomainAuth] Clearing auth tokens from URL", {
|
|
678
|
+
oldUrl: window.location.href,
|
|
679
|
+
newUrl: i.toString()
|
|
680
|
+
}), window.history.replaceState({}, "", i.toString());
|
|
666
681
|
}
|
|
667
682
|
const Se = he(null);
|
|
668
|
-
function
|
|
669
|
-
const { baseUrl: t, appInfo: r, appId: s } = oe(), o = ne(() => typeof window > "u" ? null :
|
|
683
|
+
function $t({ config: i, children: e }) {
|
|
684
|
+
const { baseUrl: t, appInfo: r, appId: s } = oe(), o = ne(() => typeof window > "u" ? null : je(
|
|
670
685
|
{
|
|
671
686
|
tenantMode: i.tenantMode || "selector",
|
|
672
687
|
baseDomain: i.baseDomain,
|
|
@@ -677,118 +692,118 @@ function Ct({ config: i, children: e }) {
|
|
|
677
692
|
search: window.location.search
|
|
678
693
|
},
|
|
679
694
|
window.localStorage
|
|
680
|
-
), [i.tenantMode, i.baseDomain, i.selectorParam]), [
|
|
695
|
+
), [i.tenantMode, i.baseDomain, i.selectorParam]), [h, w] = v(() => o()), k = X(
|
|
681
696
|
() => {
|
|
682
|
-
var
|
|
697
|
+
var c, I, S;
|
|
683
698
|
return {
|
|
684
|
-
enabled: ((
|
|
685
|
-
ttl: ((
|
|
699
|
+
enabled: ((c = i.cache) == null ? void 0 : c.enabled) ?? !0,
|
|
700
|
+
ttl: ((I = i.cache) == null ? void 0 : I.ttl) ?? 5 * 60 * 1e3,
|
|
686
701
|
// 5 minutes default
|
|
687
|
-
storageKey: ((
|
|
702
|
+
storageKey: ((S = i.cache) == null ? void 0 : S.storageKey) ?? `tenant_cache_${h || "default"}`
|
|
688
703
|
};
|
|
689
704
|
},
|
|
690
|
-
[i.cache,
|
|
691
|
-
), [
|
|
705
|
+
[i.cache, h]
|
|
706
|
+
), [b, P] = v(() => {
|
|
692
707
|
if (i.initialTenant) return i.initialTenant;
|
|
693
|
-
if (!k.enabled || !
|
|
708
|
+
if (!k.enabled || !h) return null;
|
|
694
709
|
try {
|
|
695
|
-
const
|
|
696
|
-
if (!
|
|
697
|
-
const
|
|
698
|
-
return Date.now() -
|
|
710
|
+
const c = localStorage.getItem(k.storageKey);
|
|
711
|
+
if (!c) return null;
|
|
712
|
+
const I = JSON.parse(c);
|
|
713
|
+
return Date.now() - I.timestamp < k.ttl && I.tenantSlug === h ? I.data : (localStorage.removeItem(k.storageKey), null);
|
|
699
714
|
} catch {
|
|
700
715
|
return null;
|
|
701
716
|
}
|
|
702
|
-
}), [m,
|
|
717
|
+
}), [m, p] = v(!b && !i.initialTenant), [u, y] = v(null), [L, R] = v(null), [z, M] = v(!1), [A, d] = v(null);
|
|
703
718
|
te(() => {
|
|
704
|
-
const
|
|
705
|
-
|
|
719
|
+
const c = o();
|
|
720
|
+
w(c);
|
|
706
721
|
}, [o]);
|
|
707
|
-
const
|
|
708
|
-
async (
|
|
709
|
-
if (!(!
|
|
722
|
+
const C = (r == null ? void 0 : r.settingsSchema) || null, F = ne(
|
|
723
|
+
async (c, I = !1) => {
|
|
724
|
+
if (!(!I && k.enabled && b && b.domain === c))
|
|
710
725
|
try {
|
|
711
|
-
|
|
712
|
-
const
|
|
713
|
-
if (
|
|
726
|
+
p(!0), y(null);
|
|
727
|
+
const S = new re(t), a = await new ue(S, s).getPublicTenantInfo(c);
|
|
728
|
+
if (P(a), k.enabled)
|
|
714
729
|
try {
|
|
715
|
-
const
|
|
716
|
-
data:
|
|
730
|
+
const f = {
|
|
731
|
+
data: a,
|
|
717
732
|
timestamp: Date.now(),
|
|
718
|
-
tenantSlug:
|
|
733
|
+
tenantSlug: c
|
|
719
734
|
};
|
|
720
|
-
localStorage.setItem(k.storageKey, JSON.stringify(
|
|
721
|
-
} catch (
|
|
722
|
-
console.warn("Failed to cache tenant info:",
|
|
735
|
+
localStorage.setItem(k.storageKey, JSON.stringify(f));
|
|
736
|
+
} catch (f) {
|
|
737
|
+
console.warn("Failed to cache tenant info:", f);
|
|
723
738
|
}
|
|
724
|
-
} catch (
|
|
725
|
-
const
|
|
726
|
-
y(
|
|
739
|
+
} catch (S) {
|
|
740
|
+
const g = S instanceof Error ? S : new Error("Failed to load tenant information");
|
|
741
|
+
y(g), P(null);
|
|
727
742
|
} finally {
|
|
728
|
-
|
|
743
|
+
p(!1);
|
|
729
744
|
}
|
|
730
745
|
},
|
|
731
|
-
[t, s, k,
|
|
746
|
+
[t, s, k, b]
|
|
732
747
|
), G = ne(async () => {
|
|
733
|
-
if (!(!k.enabled || !
|
|
748
|
+
if (!(!k.enabled || !b || !h))
|
|
734
749
|
try {
|
|
735
|
-
const
|
|
736
|
-
if (!
|
|
737
|
-
const
|
|
738
|
-
if (Date.now() -
|
|
739
|
-
const
|
|
740
|
-
|
|
741
|
-
const
|
|
742
|
-
data:
|
|
750
|
+
const c = localStorage.getItem(k.storageKey);
|
|
751
|
+
if (!c) return;
|
|
752
|
+
const I = JSON.parse(c);
|
|
753
|
+
if (Date.now() - I.timestamp > k.ttl * 0.5) {
|
|
754
|
+
const g = new re(t), f = await new ue(g, s).getPublicTenantInfo(h);
|
|
755
|
+
P(f);
|
|
756
|
+
const O = {
|
|
757
|
+
data: f,
|
|
743
758
|
timestamp: Date.now(),
|
|
744
|
-
tenantSlug:
|
|
759
|
+
tenantSlug: h
|
|
745
760
|
};
|
|
746
|
-
localStorage.setItem(k.storageKey, JSON.stringify(
|
|
761
|
+
localStorage.setItem(k.storageKey, JSON.stringify(O));
|
|
747
762
|
}
|
|
748
|
-
} catch (
|
|
749
|
-
console.warn("Background tenant refresh failed:",
|
|
763
|
+
} catch (c) {
|
|
764
|
+
console.warn("Background tenant refresh failed:", c);
|
|
750
765
|
}
|
|
751
|
-
}, [t, s, k,
|
|
752
|
-
if (
|
|
766
|
+
}, [t, s, k, b, h]), U = ne(async () => {
|
|
767
|
+
if (b != null && b.id)
|
|
753
768
|
try {
|
|
754
|
-
|
|
755
|
-
const
|
|
756
|
-
|
|
757
|
-
} catch (
|
|
758
|
-
const
|
|
759
|
-
|
|
769
|
+
M(!0), d(null);
|
|
770
|
+
const c = new re(t), S = await new ue(c, b.appId).getTenantSettings(b.id);
|
|
771
|
+
R(S);
|
|
772
|
+
} catch (c) {
|
|
773
|
+
const I = c instanceof Error ? c : new Error("Failed to load tenant settings");
|
|
774
|
+
d(I), R(null);
|
|
760
775
|
} finally {
|
|
761
|
-
|
|
776
|
+
M(!1);
|
|
762
777
|
}
|
|
763
|
-
}, [t,
|
|
764
|
-
|
|
765
|
-
}, [
|
|
766
|
-
(
|
|
767
|
-
if (!
|
|
778
|
+
}, [t, b]), _ = ne(() => {
|
|
779
|
+
U();
|
|
780
|
+
}, [U]), x = ne(
|
|
781
|
+
(c) => {
|
|
782
|
+
if (!C)
|
|
768
783
|
return { isValid: !0, errors: [] };
|
|
769
|
-
const
|
|
784
|
+
const I = [];
|
|
770
785
|
try {
|
|
771
|
-
return
|
|
772
|
-
var
|
|
773
|
-
const
|
|
774
|
-
if ((
|
|
775
|
-
|
|
786
|
+
return C.properties && Object.entries(C.properties).forEach(([S, g]) => {
|
|
787
|
+
var f;
|
|
788
|
+
const a = c[S];
|
|
789
|
+
if ((f = C.required) != null && f.includes(S) && a == null) {
|
|
790
|
+
I.push(`Field '${S}' is required`);
|
|
776
791
|
return;
|
|
777
792
|
}
|
|
778
|
-
if (
|
|
779
|
-
if (
|
|
780
|
-
const
|
|
781
|
-
|
|
793
|
+
if (a != null) {
|
|
794
|
+
if (g.type) {
|
|
795
|
+
const O = g.type, K = typeof a;
|
|
796
|
+
O === "string" && K !== "string" ? I.push(`Field '${S}' must be a string`) : (O === "number" || O === "integer") && K !== "number" ? I.push(`Field '${S}' must be a number`) : O === "boolean" && K !== "boolean" ? I.push(`Field '${S}' must be a boolean`) : O === "array" && !Array.isArray(a) && I.push(`Field '${S}' must be an array`);
|
|
782
797
|
}
|
|
783
|
-
|
|
784
|
-
`Field '${
|
|
785
|
-
),
|
|
786
|
-
`Field '${
|
|
787
|
-
),
|
|
798
|
+
g.minLength !== void 0 && typeof a == "string" && a.length < g.minLength && I.push(
|
|
799
|
+
`Field '${S}' must be at least ${g.minLength} characters long`
|
|
800
|
+
), g.maxLength !== void 0 && typeof a == "string" && a.length > g.maxLength && I.push(
|
|
801
|
+
`Field '${S}' must be no more than ${g.maxLength} characters long`
|
|
802
|
+
), g.minimum !== void 0 && typeof a == "number" && a < g.minimum && I.push(`Field '${S}' must be at least ${g.minimum}`), g.maximum !== void 0 && typeof a == "number" && a > g.maximum && I.push(`Field '${S}' must be no more than ${g.maximum}`), g.pattern && typeof a == "string" && (new RegExp(g.pattern).test(a) || I.push(`Field '${S}' does not match the required pattern`)), g.enum && !g.enum.includes(a) && I.push(`Field '${S}' must be one of: ${g.enum.join(", ")}`);
|
|
788
803
|
}
|
|
789
804
|
}), {
|
|
790
|
-
isValid:
|
|
791
|
-
errors:
|
|
805
|
+
isValid: I.length === 0,
|
|
806
|
+
errors: I
|
|
792
807
|
};
|
|
793
808
|
} catch {
|
|
794
809
|
return {
|
|
@@ -797,78 +812,78 @@ function Ct({ config: i, children: e }) {
|
|
|
797
812
|
};
|
|
798
813
|
}
|
|
799
814
|
},
|
|
800
|
-
[
|
|
815
|
+
[C]
|
|
801
816
|
);
|
|
802
817
|
te(() => {
|
|
803
|
-
!i.initialTenant &&
|
|
804
|
-
}, [i.initialTenant,
|
|
805
|
-
|
|
806
|
-
}, [
|
|
807
|
-
const
|
|
808
|
-
(
|
|
809
|
-
const { mode:
|
|
810
|
-
if (localStorage.setItem("tenant",
|
|
811
|
-
const
|
|
812
|
-
|
|
813
|
-
|
|
818
|
+
!i.initialTenant && h ? b ? G() : F(h) : !i.initialTenant && !h && (P(null), y(null), p(!1));
|
|
819
|
+
}, [i.initialTenant, h, b, F, G]), te(() => {
|
|
820
|
+
b != null && b.id ? U() : (R(null), d(null), M(!1));
|
|
821
|
+
}, [b == null ? void 0 : b.id, U]);
|
|
822
|
+
const T = ne(
|
|
823
|
+
(c, I) => {
|
|
824
|
+
const { mode: S = "reload", tokens: g, redirectPath: a } = I || {}, f = i.tenantMode || "selector";
|
|
825
|
+
if (localStorage.setItem("tenant", c), f === "subdomain") {
|
|
826
|
+
const O = window.location.hostname, K = _e(
|
|
827
|
+
c,
|
|
828
|
+
O,
|
|
814
829
|
i.baseDomain
|
|
815
830
|
);
|
|
816
|
-
if (!
|
|
831
|
+
if (!K) {
|
|
817
832
|
console.warn(
|
|
818
833
|
"[TenantProvider] Cannot switch subdomain, invalid hostname:",
|
|
819
|
-
|
|
834
|
+
O
|
|
820
835
|
);
|
|
821
836
|
return;
|
|
822
837
|
}
|
|
823
|
-
const H =
|
|
824
|
-
new URLSearchParams(window.location.search).forEach((
|
|
825
|
-
|
|
826
|
-
}),
|
|
827
|
-
} else if (
|
|
828
|
-
const
|
|
829
|
-
if (
|
|
830
|
-
const H = `${
|
|
838
|
+
const H = a || window.location.pathname, N = new URL(`${window.location.protocol}//${K}${H}`);
|
|
839
|
+
new URLSearchParams(window.location.search).forEach(($, J) => {
|
|
840
|
+
J !== fe && N.searchParams.set(J, $);
|
|
841
|
+
}), g && N.searchParams.set(fe, Ge(g)), window.location.href = N.toString();
|
|
842
|
+
} else if (f === "selector") {
|
|
843
|
+
const O = a || window.location.pathname, K = new URLSearchParams(window.location.search);
|
|
844
|
+
if (K.set(i.selectorParam || "tenant", c), S === "reload") {
|
|
845
|
+
const H = `${O}?${K.toString()}${window.location.hash}`;
|
|
831
846
|
window.location.href = H;
|
|
832
847
|
} else {
|
|
833
|
-
const H = `${
|
|
834
|
-
window.history.pushState({}, "", H),
|
|
848
|
+
const H = `${O}?${K.toString()}${window.location.hash}`;
|
|
849
|
+
window.history.pushState({}, "", H), w(c), F(c);
|
|
835
850
|
}
|
|
836
851
|
}
|
|
837
852
|
},
|
|
838
|
-
[i.tenantMode, i.selectorParam, i.baseDomain,
|
|
839
|
-
),
|
|
853
|
+
[i.tenantMode, i.selectorParam, i.baseDomain, F]
|
|
854
|
+
), E = X(() => ({
|
|
840
855
|
// Tenant info
|
|
841
|
-
tenant:
|
|
842
|
-
tenantSlug:
|
|
856
|
+
tenant: b,
|
|
857
|
+
tenantSlug: h,
|
|
843
858
|
isTenantLoading: m,
|
|
844
859
|
tenantError: u,
|
|
845
860
|
retryTenant: () => {
|
|
846
|
-
|
|
861
|
+
h && F(h);
|
|
847
862
|
},
|
|
848
863
|
// Settings
|
|
849
|
-
settings:
|
|
850
|
-
settingsSchema:
|
|
851
|
-
isSettingsLoading:
|
|
852
|
-
settingsError:
|
|
864
|
+
settings: L,
|
|
865
|
+
settingsSchema: C,
|
|
866
|
+
isSettingsLoading: z,
|
|
867
|
+
settingsError: A,
|
|
853
868
|
// Actions
|
|
854
869
|
refreshSettings: _,
|
|
855
|
-
switchTenant:
|
|
870
|
+
switchTenant: T,
|
|
856
871
|
// Validation
|
|
857
|
-
validateSettings:
|
|
872
|
+
validateSettings: x
|
|
858
873
|
}), [
|
|
859
|
-
|
|
860
|
-
|
|
874
|
+
b,
|
|
875
|
+
h,
|
|
861
876
|
m,
|
|
862
877
|
u,
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
878
|
+
L,
|
|
879
|
+
C,
|
|
880
|
+
z,
|
|
881
|
+
A,
|
|
867
882
|
_,
|
|
868
|
-
|
|
869
|
-
|
|
883
|
+
T,
|
|
884
|
+
x
|
|
870
885
|
]);
|
|
871
|
-
return /* @__PURE__ */ n(Se.Provider, { value:
|
|
886
|
+
return /* @__PURE__ */ n(Se.Provider, { value: E, children: e });
|
|
872
887
|
}
|
|
873
888
|
function me() {
|
|
874
889
|
const i = ce(Se);
|
|
@@ -879,8 +894,8 @@ function me() {
|
|
|
879
894
|
function Me() {
|
|
880
895
|
return ce(Se);
|
|
881
896
|
}
|
|
882
|
-
const
|
|
883
|
-
function
|
|
897
|
+
const Dt = me;
|
|
898
|
+
function Ht() {
|
|
884
899
|
const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } = me();
|
|
885
900
|
return {
|
|
886
901
|
settings: i,
|
|
@@ -901,162 +916,180 @@ function se() {
|
|
|
901
916
|
};
|
|
902
917
|
}
|
|
903
918
|
const Ie = he(null);
|
|
904
|
-
function
|
|
905
|
-
const { appId: t, baseUrl: r } = oe(), { tenant: s, tenantSlug: o, switchTenant:
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
const
|
|
919
|
+
function Nt({ config: i = {}, children: e }) {
|
|
920
|
+
const { appId: t, baseUrl: r } = oe(), { tenant: s, tenantSlug: o, switchTenant: h } = me(), [w, k] = v(i.initialRoles || []), [b, P] = v(!i.initialRoles), [m, p] = v(null), [u, y] = v(!1), [L, R] = v(null), [z, M] = v(0), A = qe({
|
|
921
|
+
processed: !1,
|
|
922
|
+
tokens: null
|
|
923
|
+
});
|
|
924
|
+
A.current.processed || (A.current.processed = !0, A.current.tokens = Je(), console.log("[AuthProvider] SYNC: URL tokens extracted on init", {
|
|
925
|
+
found: !!A.current.tokens,
|
|
926
|
+
url: typeof window < "u" ? window.location.href : "SSR"
|
|
927
|
+
}));
|
|
928
|
+
const d = X(() => {
|
|
929
|
+
const a = new we({
|
|
930
|
+
tenantSlug: o,
|
|
931
|
+
// SessionManager will generate storageKey internally
|
|
932
|
+
onRefreshFailed: i.onRefreshFailed,
|
|
933
|
+
baseUrl: r
|
|
934
|
+
});
|
|
935
|
+
return A.current.tokens && (console.log("[AuthProvider] SYNC: Saving URL tokens to session manager"), a.setTokens({
|
|
936
|
+
accessToken: A.current.tokens.accessToken,
|
|
937
|
+
refreshToken: A.current.tokens.refreshToken,
|
|
938
|
+
expiresIn: A.current.tokens.expiresIn
|
|
939
|
+
}), console.log(
|
|
940
|
+
"[AuthProvider] SYNC: Session valid after saving tokens:",
|
|
941
|
+
a.hasValidSession()
|
|
942
|
+
)), a;
|
|
943
|
+
}, [o, r, i.onRefreshFailed]), C = X(() => {
|
|
944
|
+
const a = new re(r);
|
|
945
|
+
return a.setSessionManager(d), a;
|
|
946
|
+
}, [r, d]), F = X(() => new ze(new re(r)), [r]), G = X(() => new Oe(C, d), [C, d]), U = X(() => new ke(new re(r)), [r]), _ = X(() => m || d.getUser(), [m, d]), x = X(() => _ != null && _.roleId && w.find((a) => a.id === _.roleId) || null, [_, w]), T = X(() => (x == null ? void 0 : x.permissions) || [], [x]), E = X(() => d.hasValidSession() && m !== null, [d, m]), c = 5 * 60 * 1e3, I = X(() => {
|
|
947
|
+
const a = async (D = !1) => {
|
|
915
948
|
try {
|
|
916
949
|
if (!d.hasValidSession())
|
|
917
950
|
return;
|
|
918
951
|
const B = Date.now();
|
|
919
|
-
if (!D && B -
|
|
952
|
+
if (!D && B - z < c && m)
|
|
920
953
|
return;
|
|
921
|
-
const
|
|
922
|
-
if (!
|
|
954
|
+
const V = d.getUserId();
|
|
955
|
+
if (!V) {
|
|
923
956
|
console.warn("[AuthProvider] No userId available in token or storage");
|
|
924
957
|
return;
|
|
925
958
|
}
|
|
926
|
-
y(!0),
|
|
927
|
-
const Z = await
|
|
928
|
-
|
|
959
|
+
y(!0), R(null);
|
|
960
|
+
const Z = await G.getUserById(V);
|
|
961
|
+
p(Z), d.setUser(Z), M(Date.now());
|
|
929
962
|
} catch (B) {
|
|
930
|
-
const
|
|
931
|
-
|
|
963
|
+
const Y = B instanceof Error ? B : new Error("Failed to load user data");
|
|
964
|
+
R(Y), console.error("[AuthProvider] Failed to load user data:", Y);
|
|
932
965
|
} finally {
|
|
933
966
|
y(!1);
|
|
934
967
|
}
|
|
935
|
-
},
|
|
936
|
-
await
|
|
937
|
-
},
|
|
938
|
-
const { username: B, password:
|
|
968
|
+
}, f = async () => {
|
|
969
|
+
await a();
|
|
970
|
+
}, O = async (D) => {
|
|
971
|
+
const { username: B, password: Y, tenantSlug: V } = D;
|
|
939
972
|
let Z = s == null ? void 0 : s.id, Q = o, ee = d;
|
|
940
|
-
|
|
941
|
-
const
|
|
973
|
+
V && (Z = (await new ue(C, t).getPublicTenantInfo(V)).id, Q = V);
|
|
974
|
+
const j = await F.login({
|
|
942
975
|
username: B,
|
|
943
|
-
password:
|
|
976
|
+
password: Y,
|
|
944
977
|
appId: t,
|
|
945
978
|
tenantId: Z
|
|
946
|
-
}), le =
|
|
979
|
+
}), le = V && V !== o;
|
|
947
980
|
if (le && (ee = new we({
|
|
948
981
|
tenantSlug: Q,
|
|
949
982
|
baseUrl: r
|
|
950
983
|
})), ee.setTokens({
|
|
951
|
-
accessToken:
|
|
952
|
-
refreshToken:
|
|
953
|
-
expiresIn:
|
|
954
|
-
}),
|
|
955
|
-
ee.setUser(
|
|
984
|
+
accessToken: j.accessToken,
|
|
985
|
+
refreshToken: j.refreshToken,
|
|
986
|
+
expiresIn: j.expiresIn
|
|
987
|
+
}), j.user) {
|
|
988
|
+
ee.setUser(j.user), p(j.user);
|
|
956
989
|
try {
|
|
957
|
-
await
|
|
990
|
+
await a();
|
|
958
991
|
} catch (de) {
|
|
959
992
|
console.warn("Failed to load complete user data after login:", de);
|
|
960
993
|
}
|
|
961
994
|
}
|
|
962
|
-
return le && Q && Q !== o &&
|
|
995
|
+
return le && Q && Q !== o && h(Q, {
|
|
963
996
|
tokens: {
|
|
964
|
-
accessToken:
|
|
965
|
-
refreshToken:
|
|
966
|
-
expiresIn:
|
|
997
|
+
accessToken: j.accessToken,
|
|
998
|
+
refreshToken: j.refreshToken,
|
|
999
|
+
expiresIn: j.expiresIn
|
|
967
1000
|
}
|
|
968
|
-
}),
|
|
969
|
-
},
|
|
970
|
-
const { email: B, phoneNumber:
|
|
971
|
-
if (!B && !
|
|
1001
|
+
}), j;
|
|
1002
|
+
}, K = async (D) => {
|
|
1003
|
+
const { email: B, phoneNumber: Y, name: V, password: Z, lastName: Q, tenantId: ee } = D;
|
|
1004
|
+
if (!B && !Y)
|
|
972
1005
|
throw new Error("Either email or phoneNumber is required");
|
|
973
|
-
if (!
|
|
1006
|
+
if (!V || !Z)
|
|
974
1007
|
throw new Error("Name and password are required");
|
|
975
|
-
const
|
|
976
|
-
return await
|
|
1008
|
+
const j = ee ?? (s == null ? void 0 : s.id);
|
|
1009
|
+
return await F.signup({
|
|
977
1010
|
email: B,
|
|
978
|
-
phoneNumber:
|
|
979
|
-
name:
|
|
1011
|
+
phoneNumber: Y,
|
|
1012
|
+
name: V,
|
|
980
1013
|
password: Z,
|
|
981
|
-
tenantId:
|
|
1014
|
+
tenantId: j,
|
|
982
1015
|
lastName: Q,
|
|
983
1016
|
appId: t
|
|
984
1017
|
});
|
|
985
|
-
},
|
|
986
|
-
const { email: B, phoneNumber:
|
|
987
|
-
if (!B && !
|
|
1018
|
+
}, H = async (D) => {
|
|
1019
|
+
const { email: B, phoneNumber: Y, name: V, password: Z, tenantName: Q, lastName: ee } = D;
|
|
1020
|
+
if (!B && !Y)
|
|
988
1021
|
throw new Error("Either email or phoneNumber is required");
|
|
989
|
-
if (!
|
|
1022
|
+
if (!V || !Z || !Q)
|
|
990
1023
|
throw new Error("Name, password, and tenantName are required");
|
|
991
|
-
return await
|
|
1024
|
+
return await F.signupTenantAdmin({
|
|
992
1025
|
email: B,
|
|
993
|
-
phoneNumber:
|
|
994
|
-
name:
|
|
1026
|
+
phoneNumber: Y,
|
|
1027
|
+
name: V,
|
|
995
1028
|
password: Z,
|
|
996
1029
|
tenantName: Q,
|
|
997
1030
|
appId: t,
|
|
998
1031
|
lastName: ee
|
|
999
1032
|
});
|
|
1000
|
-
}, Y = async (D) => {
|
|
1001
|
-
const { currentPassword: B, newPassword: J } = D, W = await d.getAuthHeaders();
|
|
1002
|
-
await E.changePassword({ currentPassword: B, newPassword: J }, W);
|
|
1003
|
-
}, H = async (D) => {
|
|
1004
|
-
const { email: B, tenantId: J } = D, W = J ?? (s == null ? void 0 : s.id);
|
|
1005
|
-
if (!W)
|
|
1006
|
-
throw new Error("tenantId is required for password reset");
|
|
1007
|
-
await E.requestPasswordReset({ email: B, tenantId: W });
|
|
1008
1033
|
}, N = async (D) => {
|
|
1009
|
-
const {
|
|
1010
|
-
await
|
|
1011
|
-
},
|
|
1012
|
-
const { email: B,
|
|
1034
|
+
const { currentPassword: B, newPassword: Y } = D, V = await d.getAuthHeaders();
|
|
1035
|
+
await F.changePassword({ currentPassword: B, newPassword: Y }, V);
|
|
1036
|
+
}, W = async (D) => {
|
|
1037
|
+
const { email: B, tenantId: Y } = D, V = Y ?? (s == null ? void 0 : s.id);
|
|
1038
|
+
if (!V)
|
|
1039
|
+
throw new Error("tenantId is required for password reset");
|
|
1040
|
+
await F.requestPasswordReset({ email: B, tenantId: V });
|
|
1041
|
+
}, $ = async (D) => {
|
|
1042
|
+
const { token: B, newPassword: Y } = D;
|
|
1043
|
+
await F.confirmPasswordReset({ token: B, newPassword: Y });
|
|
1044
|
+
}, J = async (D) => {
|
|
1045
|
+
const { email: B, frontendUrl: Y, name: V, lastName: Z, tenantId: Q } = D, ee = Q ?? (s == null ? void 0 : s.id);
|
|
1013
1046
|
if (!ee)
|
|
1014
1047
|
throw new Error("tenantId is required for magic link authentication");
|
|
1015
|
-
return await
|
|
1048
|
+
return await F.sendMagicLink({
|
|
1016
1049
|
email: B,
|
|
1017
1050
|
tenantId: ee,
|
|
1018
|
-
frontendUrl:
|
|
1019
|
-
name:
|
|
1051
|
+
frontendUrl: Y,
|
|
1052
|
+
name: V,
|
|
1020
1053
|
lastName: Z,
|
|
1021
1054
|
appId: t
|
|
1022
1055
|
});
|
|
1023
|
-
},
|
|
1024
|
-
const { token: B, email:
|
|
1056
|
+
}, ge = async (D) => {
|
|
1057
|
+
const { token: B, email: Y, tenantSlug: V } = D;
|
|
1025
1058
|
let Z = s == null ? void 0 : s.id, Q = o, ee = d;
|
|
1026
|
-
|
|
1027
|
-
const
|
|
1059
|
+
V && (Z = (await new ue(C, t).getPublicTenantInfo(V)).id, Q = V);
|
|
1060
|
+
const j = await F.verifyMagicLink({
|
|
1028
1061
|
token: B,
|
|
1029
|
-
email:
|
|
1062
|
+
email: Y,
|
|
1030
1063
|
appId: t,
|
|
1031
1064
|
tenantId: Z
|
|
1032
|
-
}), le =
|
|
1065
|
+
}), le = V && V !== o;
|
|
1033
1066
|
if (le && (ee = new we({
|
|
1034
1067
|
tenantSlug: Q,
|
|
1035
1068
|
baseUrl: r
|
|
1036
1069
|
})), ee.setTokens({
|
|
1037
|
-
accessToken:
|
|
1038
|
-
refreshToken:
|
|
1039
|
-
expiresIn:
|
|
1040
|
-
}),
|
|
1041
|
-
ee.setUser(
|
|
1070
|
+
accessToken: j.accessToken,
|
|
1071
|
+
refreshToken: j.refreshToken,
|
|
1072
|
+
expiresIn: j.expiresIn
|
|
1073
|
+
}), j.user) {
|
|
1074
|
+
ee.setUser(j.user), p(j.user);
|
|
1042
1075
|
try {
|
|
1043
|
-
await
|
|
1076
|
+
await a();
|
|
1044
1077
|
} catch (de) {
|
|
1045
1078
|
console.warn("Failed to load complete user data after magic link login:", de);
|
|
1046
1079
|
}
|
|
1047
1080
|
}
|
|
1048
|
-
return le && Q && Q !== o &&
|
|
1081
|
+
return le && Q && Q !== o && h(Q, {
|
|
1049
1082
|
tokens: {
|
|
1050
|
-
accessToken:
|
|
1051
|
-
refreshToken:
|
|
1052
|
-
expiresIn:
|
|
1083
|
+
accessToken: j.accessToken,
|
|
1084
|
+
refreshToken: j.refreshToken,
|
|
1085
|
+
expiresIn: j.expiresIn
|
|
1053
1086
|
}
|
|
1054
|
-
}),
|
|
1055
|
-
},
|
|
1087
|
+
}), j;
|
|
1088
|
+
}, Ce = async () => {
|
|
1056
1089
|
const D = d.getTokens();
|
|
1057
1090
|
if (!(D != null && D.refreshToken))
|
|
1058
1091
|
throw new Error("No refresh token available");
|
|
1059
|
-
const B = await
|
|
1092
|
+
const B = await F.refreshToken({
|
|
1060
1093
|
refreshToken: D.refreshToken
|
|
1061
1094
|
});
|
|
1062
1095
|
d.setTokens({
|
|
@@ -1064,124 +1097,136 @@ function Dt({ config: i = {}, children: e }) {
|
|
|
1064
1097
|
refreshToken: B.refreshToken || D.refreshToken,
|
|
1065
1098
|
expiresIn: B.expiresIn
|
|
1066
1099
|
});
|
|
1067
|
-
},
|
|
1068
|
-
d.clearSession(),
|
|
1069
|
-
},
|
|
1100
|
+
}, Fe = () => {
|
|
1101
|
+
d.clearSession(), p(null), R(null);
|
|
1102
|
+
}, $e = (D) => {
|
|
1070
1103
|
d.setTokens(D);
|
|
1071
|
-
},
|
|
1072
|
-
d.clearSession(),
|
|
1073
|
-
},
|
|
1104
|
+
}, De = () => d.hasValidSession(), He = () => {
|
|
1105
|
+
d.clearSession(), p(null), R(null);
|
|
1106
|
+
}, Ne = async () => {
|
|
1074
1107
|
if (t)
|
|
1075
1108
|
try {
|
|
1076
|
-
|
|
1077
|
-
const { roles: D } = await
|
|
1109
|
+
P(!0);
|
|
1110
|
+
const { roles: D } = await U.getRolesByApp(t);
|
|
1078
1111
|
k(D);
|
|
1079
1112
|
} catch (D) {
|
|
1080
1113
|
console.error("Failed to fetch roles:", D);
|
|
1081
1114
|
} finally {
|
|
1082
|
-
|
|
1115
|
+
P(!1);
|
|
1083
1116
|
}
|
|
1084
|
-
},
|
|
1085
|
-
await
|
|
1117
|
+
}, Ue = async () => {
|
|
1118
|
+
await Ne();
|
|
1086
1119
|
}, ye = (D) => {
|
|
1087
|
-
if (!
|
|
1120
|
+
if (!T || T.length === 0)
|
|
1088
1121
|
return !1;
|
|
1089
1122
|
if (typeof D == "string")
|
|
1090
|
-
return
|
|
1123
|
+
return T.includes(D);
|
|
1091
1124
|
const B = `${D.resource}.${D.action}`;
|
|
1092
|
-
return
|
|
1125
|
+
return T.includes(B);
|
|
1093
1126
|
};
|
|
1094
1127
|
return {
|
|
1095
1128
|
// RFC-003: Authentication state
|
|
1096
|
-
isAuthenticated:
|
|
1129
|
+
isAuthenticated: E,
|
|
1097
1130
|
sessionManager: d,
|
|
1098
|
-
authenticatedHttpService:
|
|
1099
|
-
login:
|
|
1100
|
-
signup:
|
|
1101
|
-
signupTenantAdmin:
|
|
1102
|
-
sendMagicLink:
|
|
1103
|
-
verifyMagicLink:
|
|
1104
|
-
changePassword:
|
|
1105
|
-
requestPasswordReset:
|
|
1106
|
-
confirmPasswordReset:
|
|
1107
|
-
refreshToken:
|
|
1108
|
-
logout:
|
|
1109
|
-
setTokens:
|
|
1110
|
-
hasValidSession:
|
|
1111
|
-
clearSession:
|
|
1131
|
+
authenticatedHttpService: C,
|
|
1132
|
+
login: O,
|
|
1133
|
+
signup: K,
|
|
1134
|
+
signupTenantAdmin: H,
|
|
1135
|
+
sendMagicLink: J,
|
|
1136
|
+
verifyMagicLink: ge,
|
|
1137
|
+
changePassword: N,
|
|
1138
|
+
requestPasswordReset: W,
|
|
1139
|
+
confirmPasswordReset: $,
|
|
1140
|
+
refreshToken: Ce,
|
|
1141
|
+
logout: Fe,
|
|
1142
|
+
setTokens: $e,
|
|
1143
|
+
hasValidSession: De,
|
|
1144
|
+
clearSession: He,
|
|
1112
1145
|
currentUser: m,
|
|
1113
1146
|
isUserLoading: u,
|
|
1114
|
-
userError:
|
|
1115
|
-
loadUserData:
|
|
1116
|
-
refreshUser:
|
|
1117
|
-
userRole:
|
|
1118
|
-
userPermissions:
|
|
1119
|
-
availableRoles:
|
|
1120
|
-
rolesLoading:
|
|
1147
|
+
userError: L,
|
|
1148
|
+
loadUserData: a,
|
|
1149
|
+
refreshUser: f,
|
|
1150
|
+
userRole: x,
|
|
1151
|
+
userPermissions: T,
|
|
1152
|
+
availableRoles: w,
|
|
1153
|
+
rolesLoading: b,
|
|
1121
1154
|
hasPermission: ye,
|
|
1122
1155
|
hasAnyPermission: (D) => D.some((B) => ye(B)),
|
|
1123
1156
|
hasAllPermissions: (D) => D.every((B) => ye(B)),
|
|
1124
|
-
getUserPermissionStrings: () =>
|
|
1125
|
-
refreshRoles:
|
|
1157
|
+
getUserPermissionStrings: () => T || [],
|
|
1158
|
+
refreshRoles: Ue
|
|
1126
1159
|
};
|
|
1127
1160
|
}, [
|
|
1128
|
-
M,
|
|
1129
|
-
d,
|
|
1130
|
-
P,
|
|
1131
1161
|
E,
|
|
1132
|
-
|
|
1162
|
+
d,
|
|
1163
|
+
C,
|
|
1164
|
+
F,
|
|
1133
1165
|
G,
|
|
1166
|
+
U,
|
|
1134
1167
|
t,
|
|
1135
1168
|
s,
|
|
1136
1169
|
o,
|
|
1137
|
-
|
|
1138
|
-
|
|
1170
|
+
h,
|
|
1171
|
+
w,
|
|
1139
1172
|
m,
|
|
1140
1173
|
u,
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1174
|
+
L,
|
|
1175
|
+
x,
|
|
1176
|
+
T,
|
|
1177
|
+
z,
|
|
1178
|
+
c
|
|
1146
1179
|
]);
|
|
1147
1180
|
te(() => {
|
|
1148
1181
|
!i.initialRoles && t && (async () => {
|
|
1149
1182
|
try {
|
|
1150
|
-
|
|
1151
|
-
const
|
|
1152
|
-
k(
|
|
1153
|
-
} catch (
|
|
1154
|
-
console.error("Failed to fetch roles:",
|
|
1183
|
+
P(!0);
|
|
1184
|
+
const f = new re(r), O = new ke(f), { roles: K } = await O.getRolesByApp(t);
|
|
1185
|
+
k(K);
|
|
1186
|
+
} catch (f) {
|
|
1187
|
+
console.error("Failed to fetch roles:", f);
|
|
1155
1188
|
} finally {
|
|
1156
|
-
|
|
1189
|
+
P(!1);
|
|
1157
1190
|
}
|
|
1158
1191
|
})();
|
|
1159
1192
|
}, [t, r, i.initialRoles]);
|
|
1160
|
-
const
|
|
1193
|
+
const [S, g] = v(!1);
|
|
1161
1194
|
return te(() => {
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
const c = d.getUser();
|
|
1172
|
-
c && d.hasValidSession() && f(c);
|
|
1195
|
+
S || (g(!0), A.current.tokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), Ye(), console.log("[AuthProvider] EFFECT: Loading user data after URL token consumption..."), I.loadUserData().catch((a) => {
|
|
1196
|
+
console.error(
|
|
1197
|
+
"[AuthProvider] Failed to load user data after URL token consumption:",
|
|
1198
|
+
a
|
|
1199
|
+
);
|
|
1200
|
+
})));
|
|
1201
|
+
}, [I, S]), te(() => {
|
|
1202
|
+
const a = d.getUser();
|
|
1203
|
+
a && d.hasValidSession() && p(a);
|
|
1173
1204
|
}, [d]), te(() => {
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1205
|
+
if (console.log("[AuthProvider] Auto-load effect running", {
|
|
1206
|
+
hasCurrentUser: !!m,
|
|
1207
|
+
isUserLoading: u,
|
|
1208
|
+
hasValidSession: d.hasValidSession(),
|
|
1209
|
+
urlTokensCleanedUp: S,
|
|
1210
|
+
hadUrlTokens: !!A.current.tokens
|
|
1211
|
+
}), !S) {
|
|
1212
|
+
console.log("[AuthProvider] Waiting for URL tokens cleanup before auto-load");
|
|
1213
|
+
return;
|
|
1214
|
+
}
|
|
1215
|
+
if (A.current.tokens) {
|
|
1216
|
+
console.log("[AuthProvider] URL tokens present, skipping auto-load (already handled)");
|
|
1217
|
+
return;
|
|
1218
|
+
}
|
|
1219
|
+
!m && !u && (console.log("[AuthProvider] Auto-loading user data..."), I.loadUserData().catch(() => {
|
|
1220
|
+
}));
|
|
1221
|
+
}, [m, u, I, d, S]), te(() => {
|
|
1177
1222
|
if (!d.hasValidSession() || !m)
|
|
1178
1223
|
return;
|
|
1179
|
-
const
|
|
1180
|
-
|
|
1224
|
+
const a = setInterval(() => {
|
|
1225
|
+
I.loadUserData().catch(() => {
|
|
1181
1226
|
});
|
|
1182
|
-
},
|
|
1183
|
-
return () => clearInterval(
|
|
1184
|
-
}, [d, m,
|
|
1227
|
+
}, c);
|
|
1228
|
+
return () => clearInterval(a);
|
|
1229
|
+
}, [d, m, I, c]), /* @__PURE__ */ n(Ie.Provider, { value: I, children: e });
|
|
1185
1230
|
}
|
|
1186
1231
|
function ae() {
|
|
1187
1232
|
const i = ce(Ie);
|
|
@@ -1189,7 +1234,7 @@ function ae() {
|
|
|
1189
1234
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
1190
1235
|
return i;
|
|
1191
1236
|
}
|
|
1192
|
-
class
|
|
1237
|
+
class Qe {
|
|
1193
1238
|
constructor(e, t) {
|
|
1194
1239
|
this.httpService = e, this.sessionManager = t;
|
|
1195
1240
|
}
|
|
@@ -1270,57 +1315,57 @@ class Je {
|
|
|
1270
1315
|
}
|
|
1271
1316
|
}
|
|
1272
1317
|
const Le = he(null);
|
|
1273
|
-
function
|
|
1274
|
-
const { baseUrl: t, appId: r } = oe(), { tenant: s } = se(), [o,
|
|
1318
|
+
function Ut({ config: i = {}, children: e }) {
|
|
1319
|
+
const { baseUrl: t, appId: r } = oe(), { tenant: s } = se(), [o, h] = v([]), [w, k] = v(!1), [b, P] = v(null), m = X(() => {
|
|
1275
1320
|
const y = new re(t);
|
|
1276
|
-
return new
|
|
1277
|
-
}, [t]),
|
|
1321
|
+
return new Qe(y);
|
|
1322
|
+
}, [t]), p = async () => {
|
|
1278
1323
|
if (!(s != null && s.id)) {
|
|
1279
|
-
|
|
1324
|
+
h([]);
|
|
1280
1325
|
return;
|
|
1281
1326
|
}
|
|
1282
|
-
k(!0),
|
|
1327
|
+
k(!0), P(null);
|
|
1283
1328
|
try {
|
|
1284
1329
|
const y = await m.getTenantFeatureFlags(s.id, r);
|
|
1285
|
-
|
|
1330
|
+
h(y);
|
|
1286
1331
|
} catch (y) {
|
|
1287
|
-
const
|
|
1288
|
-
|
|
1332
|
+
const L = y instanceof Error ? y.message : "Failed to fetch feature flags";
|
|
1333
|
+
P(L), i.onError && i.onError(y instanceof Error ? y : new Error(L));
|
|
1289
1334
|
} finally {
|
|
1290
1335
|
k(!1);
|
|
1291
1336
|
}
|
|
1292
1337
|
};
|
|
1293
1338
|
te(() => {
|
|
1294
|
-
|
|
1295
|
-
const y = i.refreshInterval || 5 * 60 * 1e3,
|
|
1296
|
-
return () => clearInterval(
|
|
1339
|
+
p();
|
|
1340
|
+
const y = i.refreshInterval || 5 * 60 * 1e3, L = setInterval(p, y);
|
|
1341
|
+
return () => clearInterval(L);
|
|
1297
1342
|
}, [s == null ? void 0 : s.id, i.refreshInterval]);
|
|
1298
1343
|
const u = X(() => ({
|
|
1299
1344
|
featureFlags: o,
|
|
1300
|
-
loading:
|
|
1301
|
-
error:
|
|
1302
|
-
isEnabled: (
|
|
1303
|
-
const
|
|
1304
|
-
return (
|
|
1345
|
+
loading: w,
|
|
1346
|
+
error: b,
|
|
1347
|
+
isEnabled: (M) => {
|
|
1348
|
+
const A = o.find((d) => d.key === M);
|
|
1349
|
+
return (A == null ? void 0 : A.value) === !0;
|
|
1305
1350
|
},
|
|
1306
|
-
getFlag: (
|
|
1307
|
-
getFlagState: (
|
|
1308
|
-
const
|
|
1309
|
-
return
|
|
1351
|
+
getFlag: (M) => o.find((A) => A.key === M),
|
|
1352
|
+
getFlagState: (M) => {
|
|
1353
|
+
const A = o.find((d) => d.key === M);
|
|
1354
|
+
return A ? A.value ? "enabled" : "disabled" : "not_found";
|
|
1310
1355
|
},
|
|
1311
1356
|
refresh: async () => {
|
|
1312
|
-
await
|
|
1357
|
+
await p();
|
|
1313
1358
|
}
|
|
1314
|
-
}), [o,
|
|
1359
|
+
}), [o, w, b]);
|
|
1315
1360
|
return /* @__PURE__ */ n(Le.Provider, { value: u, children: e });
|
|
1316
1361
|
}
|
|
1317
|
-
function
|
|
1362
|
+
function Xe() {
|
|
1318
1363
|
const i = ce(Le);
|
|
1319
1364
|
if (!i)
|
|
1320
1365
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1321
1366
|
return i;
|
|
1322
1367
|
}
|
|
1323
|
-
class
|
|
1368
|
+
class Ze {
|
|
1324
1369
|
constructor(e, t) {
|
|
1325
1370
|
this.httpService = e, this.sessionManager = t;
|
|
1326
1371
|
}
|
|
@@ -1386,25 +1431,25 @@ class Qe {
|
|
|
1386
1431
|
)).data;
|
|
1387
1432
|
}
|
|
1388
1433
|
}
|
|
1389
|
-
const
|
|
1390
|
-
function
|
|
1391
|
-
const { baseUrl: t } = oe(), { tenant: r } = se(), [s, o] =
|
|
1434
|
+
const Re = he(void 0);
|
|
1435
|
+
function Bt({ config: i = {}, children: e }) {
|
|
1436
|
+
const { baseUrl: t } = oe(), { tenant: r } = se(), [s, o] = v(null), [h, w] = v(!1), [k, b] = v(null), P = X(() => {
|
|
1392
1437
|
const u = new re(t);
|
|
1393
|
-
return new
|
|
1438
|
+
return new Ze(u);
|
|
1394
1439
|
}, [t]), m = async () => {
|
|
1395
1440
|
if (!(r != null && r.id)) {
|
|
1396
1441
|
o(null);
|
|
1397
1442
|
return;
|
|
1398
1443
|
}
|
|
1399
|
-
|
|
1444
|
+
w(!0), b(null);
|
|
1400
1445
|
try {
|
|
1401
|
-
const u = await
|
|
1446
|
+
const u = await P.getTenantSubscriptionFeatures(r.id);
|
|
1402
1447
|
o(u);
|
|
1403
1448
|
} catch (u) {
|
|
1404
1449
|
const y = u instanceof Error ? u.message : "Failed to fetch subscription";
|
|
1405
|
-
|
|
1450
|
+
b(y), i.onError && i.onError(u instanceof Error ? u : new Error(y));
|
|
1406
1451
|
} finally {
|
|
1407
|
-
|
|
1452
|
+
w(!1);
|
|
1408
1453
|
}
|
|
1409
1454
|
};
|
|
1410
1455
|
te(() => {
|
|
@@ -1412,38 +1457,38 @@ function Nt({ config: i = {}, children: e }) {
|
|
|
1412
1457
|
const u = i.refreshInterval || 10 * 60 * 1e3, y = setInterval(m, u);
|
|
1413
1458
|
return () => clearInterval(y);
|
|
1414
1459
|
}, [r == null ? void 0 : r.id, i.refreshInterval]);
|
|
1415
|
-
const
|
|
1460
|
+
const p = X(() => {
|
|
1416
1461
|
const u = (s == null ? void 0 : s.features) || [];
|
|
1417
1462
|
return {
|
|
1418
1463
|
subscription: s,
|
|
1419
1464
|
features: u,
|
|
1420
|
-
loading:
|
|
1465
|
+
loading: h,
|
|
1421
1466
|
error: k,
|
|
1422
|
-
isFeatureEnabled: (
|
|
1423
|
-
const
|
|
1424
|
-
return
|
|
1467
|
+
isFeatureEnabled: (A) => {
|
|
1468
|
+
const d = u.find((C) => C.key === A);
|
|
1469
|
+
return d ? d.type === "BOOLEAN" || d.type === "boolean" ? d.value === !0 : !!d.value : !1;
|
|
1425
1470
|
},
|
|
1426
|
-
getFeature: (
|
|
1427
|
-
getFeatureValue: (
|
|
1428
|
-
const
|
|
1429
|
-
return
|
|
1471
|
+
getFeature: (A) => u.find((d) => d.key === A),
|
|
1472
|
+
getFeatureValue: (A, d) => {
|
|
1473
|
+
const C = u.find((F) => F.key === A);
|
|
1474
|
+
return C ? C.value : d;
|
|
1430
1475
|
},
|
|
1431
|
-
hasAllowedPlan: (
|
|
1476
|
+
hasAllowedPlan: (A) => !s || !s.isActive ? !1 : A.includes(s.planId),
|
|
1432
1477
|
refresh: async () => {
|
|
1433
1478
|
await m();
|
|
1434
1479
|
}
|
|
1435
1480
|
};
|
|
1436
|
-
}, [s,
|
|
1437
|
-
return /* @__PURE__ */ n(
|
|
1481
|
+
}, [s, h, k]);
|
|
1482
|
+
return /* @__PURE__ */ n(Re.Provider, { value: p, children: e });
|
|
1438
1483
|
}
|
|
1439
|
-
function
|
|
1440
|
-
const i = ce(
|
|
1484
|
+
function et() {
|
|
1485
|
+
const i = ce(Re);
|
|
1441
1486
|
if (i === void 0)
|
|
1442
1487
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1443
1488
|
return i;
|
|
1444
1489
|
}
|
|
1445
1490
|
var ie = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(ie || {});
|
|
1446
|
-
const
|
|
1491
|
+
const xe = () => /* @__PURE__ */ l(
|
|
1447
1492
|
"div",
|
|
1448
1493
|
{
|
|
1449
1494
|
style: {
|
|
@@ -1480,7 +1525,7 @@ const ke = () => /* @__PURE__ */ l(
|
|
|
1480
1525
|
)
|
|
1481
1526
|
]
|
|
1482
1527
|
}
|
|
1483
|
-
),
|
|
1528
|
+
), Ae = ({
|
|
1484
1529
|
userType: i,
|
|
1485
1530
|
minUserType: e,
|
|
1486
1531
|
missingPermissions: t
|
|
@@ -1502,7 +1547,7 @@ const ke = () => /* @__PURE__ */ l(
|
|
|
1502
1547
|
children: [
|
|
1503
1548
|
/* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
|
|
1504
1549
|
/* @__PURE__ */ n("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
|
|
1505
|
-
e && i ? /* @__PURE__ */ l(
|
|
1550
|
+
e && i ? /* @__PURE__ */ l(q, { children: [
|
|
1506
1551
|
/* @__PURE__ */ l("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
|
|
1507
1552
|
"This content requires ",
|
|
1508
1553
|
/* @__PURE__ */ n("strong", { children: e }),
|
|
@@ -1512,7 +1557,7 @@ const ke = () => /* @__PURE__ */ l(
|
|
|
1512
1557
|
"Your current access level: ",
|
|
1513
1558
|
/* @__PURE__ */ n("strong", { children: i })
|
|
1514
1559
|
] })
|
|
1515
|
-
] }) : /* @__PURE__ */ l(
|
|
1560
|
+
] }) : /* @__PURE__ */ l(q, { children: [
|
|
1516
1561
|
/* @__PURE__ */ n("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
|
|
1517
1562
|
t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1518
1563
|
"Required permissions: ",
|
|
@@ -1521,7 +1566,7 @@ const ke = () => /* @__PURE__ */ l(
|
|
|
1521
1566
|
] })
|
|
1522
1567
|
]
|
|
1523
1568
|
}
|
|
1524
|
-
),
|
|
1569
|
+
), tt = (i, e) => {
|
|
1525
1570
|
const t = {
|
|
1526
1571
|
[ie.USER]: 1,
|
|
1527
1572
|
[ie.TENANT_ADMIN]: 2,
|
|
@@ -1529,28 +1574,28 @@ const ke = () => /* @__PURE__ */ l(
|
|
|
1529
1574
|
};
|
|
1530
1575
|
return t[i] >= t[e];
|
|
1531
1576
|
};
|
|
1532
|
-
function
|
|
1577
|
+
function qt({
|
|
1533
1578
|
children: i,
|
|
1534
1579
|
fallback: e,
|
|
1535
1580
|
minUserType: t,
|
|
1536
1581
|
requiredPermissions: r,
|
|
1537
1582
|
requireAllPermissions: s = !1
|
|
1538
1583
|
}) {
|
|
1539
|
-
const { hasValidSession: o, sessionManager:
|
|
1584
|
+
const { hasValidSession: o, sessionManager: h, hasPermission: w, hasAnyPermission: k, hasAllPermissions: b } = ae();
|
|
1540
1585
|
if (!o())
|
|
1541
|
-
return /* @__PURE__ */ n(
|
|
1542
|
-
const
|
|
1543
|
-
if (!
|
|
1544
|
-
return /* @__PURE__ */ n(
|
|
1545
|
-
if (t && !
|
|
1546
|
-
return /* @__PURE__ */ n(
|
|
1547
|
-
if (r && r.length > 0 && !(s ?
|
|
1548
|
-
const
|
|
1549
|
-
return /* @__PURE__ */ n(
|
|
1550
|
-
}
|
|
1551
|
-
return /* @__PURE__ */ n(
|
|
1586
|
+
return /* @__PURE__ */ n(q, { children: e || /* @__PURE__ */ n(xe, {}) });
|
|
1587
|
+
const P = h.getUser();
|
|
1588
|
+
if (!P)
|
|
1589
|
+
return /* @__PURE__ */ n(q, { children: e || /* @__PURE__ */ n(xe, {}) });
|
|
1590
|
+
if (t && !tt(P.userType, t))
|
|
1591
|
+
return /* @__PURE__ */ n(Ae, { userType: P.userType, minUserType: t });
|
|
1592
|
+
if (r && r.length > 0 && !(s ? b(r) : k(r))) {
|
|
1593
|
+
const p = r.filter((u) => !w(u)).map((u) => typeof u == "string" ? u : u.name);
|
|
1594
|
+
return /* @__PURE__ */ n(Ae, { missingPermissions: p });
|
|
1595
|
+
}
|
|
1596
|
+
return /* @__PURE__ */ n(q, { children: i });
|
|
1552
1597
|
}
|
|
1553
|
-
const
|
|
1598
|
+
const rt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1554
1599
|
"div",
|
|
1555
1600
|
{
|
|
1556
1601
|
style: {
|
|
@@ -1586,7 +1631,7 @@ const et = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1586
1631
|
}
|
|
1587
1632
|
)
|
|
1588
1633
|
}
|
|
1589
|
-
),
|
|
1634
|
+
), Te = ({
|
|
1590
1635
|
userType: i,
|
|
1591
1636
|
minUserType: e,
|
|
1592
1637
|
missingPermissions: t
|
|
@@ -1616,7 +1661,7 @@ const et = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1616
1661
|
children: [
|
|
1617
1662
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
|
|
1618
1663
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
|
|
1619
|
-
e && i ? /* @__PURE__ */ l(
|
|
1664
|
+
e && i ? /* @__PURE__ */ l(q, { children: [
|
|
1620
1665
|
/* @__PURE__ */ l("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
|
|
1621
1666
|
"This page requires ",
|
|
1622
1667
|
/* @__PURE__ */ n("strong", { children: e }),
|
|
@@ -1626,7 +1671,7 @@ const et = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1626
1671
|
"Your current access level: ",
|
|
1627
1672
|
/* @__PURE__ */ n("strong", { children: i })
|
|
1628
1673
|
] })
|
|
1629
|
-
] }) : /* @__PURE__ */ l(
|
|
1674
|
+
] }) : /* @__PURE__ */ l(q, { children: [
|
|
1630
1675
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
|
|
1631
1676
|
t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1632
1677
|
"Required permissions: ",
|
|
@@ -1637,7 +1682,7 @@ const et = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1637
1682
|
}
|
|
1638
1683
|
)
|
|
1639
1684
|
}
|
|
1640
|
-
),
|
|
1685
|
+
), nt = (i, e) => {
|
|
1641
1686
|
const t = {
|
|
1642
1687
|
[ie.USER]: 1,
|
|
1643
1688
|
[ie.TENANT_ADMIN]: 2,
|
|
@@ -1645,7 +1690,7 @@ const et = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1645
1690
|
};
|
|
1646
1691
|
return t[i] >= t[e];
|
|
1647
1692
|
};
|
|
1648
|
-
function
|
|
1693
|
+
function zt({
|
|
1649
1694
|
children: i,
|
|
1650
1695
|
redirectTo: e = "/login",
|
|
1651
1696
|
minUserType: t,
|
|
@@ -1653,24 +1698,24 @@ function Ut({
|
|
|
1653
1698
|
requireAllPermissions: s = !1,
|
|
1654
1699
|
fallback: o
|
|
1655
1700
|
}) {
|
|
1656
|
-
const { hasValidSession:
|
|
1657
|
-
if (!
|
|
1658
|
-
return o ? /* @__PURE__ */ n(
|
|
1659
|
-
/* @__PURE__ */ n(
|
|
1701
|
+
const { hasValidSession: h, sessionManager: w, hasPermission: k, hasAnyPermission: b, hasAllPermissions: P } = ae(), m = be();
|
|
1702
|
+
if (!h())
|
|
1703
|
+
return o ? /* @__PURE__ */ n(q, { children: o }) : /* @__PURE__ */ l(q, { children: [
|
|
1704
|
+
/* @__PURE__ */ n(rt, { redirectPath: e }),
|
|
1660
1705
|
/* @__PURE__ */ n(pe, { to: e, state: { from: m.pathname }, replace: !0 })
|
|
1661
1706
|
] });
|
|
1662
|
-
const
|
|
1663
|
-
if (!
|
|
1707
|
+
const p = w.getUser();
|
|
1708
|
+
if (!p)
|
|
1664
1709
|
return /* @__PURE__ */ n(pe, { to: e, state: { from: m.pathname }, replace: !0 });
|
|
1665
|
-
if (t && !
|
|
1666
|
-
return /* @__PURE__ */ n(
|
|
1667
|
-
if (r && r.length > 0 && !(s ?
|
|
1668
|
-
const y = r.filter((
|
|
1669
|
-
return /* @__PURE__ */ n(
|
|
1710
|
+
if (t && !nt(p.userType, t))
|
|
1711
|
+
return /* @__PURE__ */ n(Te, { userType: p.userType, minUserType: t });
|
|
1712
|
+
if (r && r.length > 0 && !(s ? P(r) : b(r))) {
|
|
1713
|
+
const y = r.filter((L) => !k(L)).map((L) => typeof L == "string" ? L : L.name);
|
|
1714
|
+
return /* @__PURE__ */ n(Te, { missingPermissions: y });
|
|
1670
1715
|
}
|
|
1671
|
-
return /* @__PURE__ */ n(
|
|
1716
|
+
return /* @__PURE__ */ n(q, { children: i });
|
|
1672
1717
|
}
|
|
1673
|
-
const
|
|
1718
|
+
const st = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1674
1719
|
"div",
|
|
1675
1720
|
{
|
|
1676
1721
|
style: {
|
|
@@ -1707,14 +1752,14 @@ const rt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1707
1752
|
)
|
|
1708
1753
|
}
|
|
1709
1754
|
);
|
|
1710
|
-
function
|
|
1711
|
-
const { tenant: r, isLoading: s, error: o } = se(),
|
|
1712
|
-
return s || o ? null : r ? /* @__PURE__ */ n(
|
|
1713
|
-
/* @__PURE__ */ n(
|
|
1714
|
-
/* @__PURE__ */ n(pe, { to: e, state: { from:
|
|
1755
|
+
function Ot({ children: i, redirectTo: e = "/", fallback: t }) {
|
|
1756
|
+
const { tenant: r, isLoading: s, error: o } = se(), h = be();
|
|
1757
|
+
return s || o ? null : r ? /* @__PURE__ */ n(q, { children: i }) : t ? /* @__PURE__ */ n(q, { children: t }) : /* @__PURE__ */ l(q, { children: [
|
|
1758
|
+
/* @__PURE__ */ n(st, { redirectPath: e }),
|
|
1759
|
+
/* @__PURE__ */ n(pe, { to: e, state: { from: h.pathname }, replace: !0 })
|
|
1715
1760
|
] });
|
|
1716
1761
|
}
|
|
1717
|
-
const
|
|
1762
|
+
const it = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1718
1763
|
"div",
|
|
1719
1764
|
{
|
|
1720
1765
|
style: {
|
|
@@ -1751,14 +1796,14 @@ const nt = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1751
1796
|
)
|
|
1752
1797
|
}
|
|
1753
1798
|
);
|
|
1754
|
-
function
|
|
1755
|
-
const { tenant: r, isLoading: s, error: o } = se(),
|
|
1756
|
-
return s || o ? null : r ? t ? /* @__PURE__ */ n(
|
|
1757
|
-
/* @__PURE__ */ n(
|
|
1758
|
-
/* @__PURE__ */ n(pe, { to: e, state: { from:
|
|
1759
|
-
] }) : /* @__PURE__ */ n(
|
|
1799
|
+
function Wt({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
|
|
1800
|
+
const { tenant: r, isLoading: s, error: o } = se(), h = be();
|
|
1801
|
+
return s || o ? null : r ? t ? /* @__PURE__ */ n(q, { children: t }) : /* @__PURE__ */ l(q, { children: [
|
|
1802
|
+
/* @__PURE__ */ n(it, { redirectPath: e }),
|
|
1803
|
+
/* @__PURE__ */ n(pe, { to: e, state: { from: h.pathname }, replace: !0 })
|
|
1804
|
+
] }) : /* @__PURE__ */ n(q, { children: i });
|
|
1760
1805
|
}
|
|
1761
|
-
const
|
|
1806
|
+
const ot = () => /* @__PURE__ */ l(
|
|
1762
1807
|
"div",
|
|
1763
1808
|
{
|
|
1764
1809
|
style: {
|
|
@@ -1775,14 +1820,14 @@ const st = () => /* @__PURE__ */ l(
|
|
|
1775
1820
|
]
|
|
1776
1821
|
}
|
|
1777
1822
|
);
|
|
1778
|
-
function
|
|
1823
|
+
function Vt({
|
|
1779
1824
|
children: i,
|
|
1780
|
-
fallback: e = /* @__PURE__ */ n(
|
|
1825
|
+
fallback: e = /* @__PURE__ */ n(ot, {}),
|
|
1781
1826
|
allowedPlans: t,
|
|
1782
1827
|
requiredFeature: r
|
|
1783
1828
|
}) {
|
|
1784
|
-
const { subscription: s, hasAllowedPlan: o, isFeatureEnabled:
|
|
1785
|
-
return
|
|
1829
|
+
const { subscription: s, hasAllowedPlan: o, isFeatureEnabled: h, loading: w } = et();
|
|
1830
|
+
return w ? /* @__PURE__ */ n(
|
|
1786
1831
|
"div",
|
|
1787
1832
|
{
|
|
1788
1833
|
style: {
|
|
@@ -1792,9 +1837,9 @@ function Ot({
|
|
|
1792
1837
|
},
|
|
1793
1838
|
children: "Loading subscription..."
|
|
1794
1839
|
}
|
|
1795
|
-
) : s ? s.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ n(
|
|
1840
|
+
) : s ? s.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ n(q, { children: e }) : r && !h(r) ? /* @__PURE__ */ n(q, { children: e }) : /* @__PURE__ */ n(q, { children: i }) : /* @__PURE__ */ n(q, { children: e }) : /* @__PURE__ */ n(q, { children: e });
|
|
1796
1841
|
}
|
|
1797
|
-
const
|
|
1842
|
+
const at = ({ flagName: i }) => /* @__PURE__ */ l(
|
|
1798
1843
|
"div",
|
|
1799
1844
|
{
|
|
1800
1845
|
style: {
|
|
@@ -1821,8 +1866,8 @@ const it = ({ flagName: i }) => /* @__PURE__ */ l(
|
|
|
1821
1866
|
]
|
|
1822
1867
|
}
|
|
1823
1868
|
);
|
|
1824
|
-
function
|
|
1825
|
-
const { isEnabled: r, loading: s } =
|
|
1869
|
+
function jt({ name: i, children: e, fallback: t }) {
|
|
1870
|
+
const { isEnabled: r, loading: s } = Xe();
|
|
1826
1871
|
return s ? /* @__PURE__ */ n(
|
|
1827
1872
|
"div",
|
|
1828
1873
|
{
|
|
@@ -1836,9 +1881,9 @@ function Wt({ name: i, children: e, fallback: t }) {
|
|
|
1836
1881
|
},
|
|
1837
1882
|
children: "Loading feature flags..."
|
|
1838
1883
|
}
|
|
1839
|
-
) : r(i) ? /* @__PURE__ */ n(
|
|
1884
|
+
) : r(i) ? /* @__PURE__ */ n(q, { children: e }) : /* @__PURE__ */ n(q, { children: t || /* @__PURE__ */ n(at, { flagName: i }) });
|
|
1840
1885
|
}
|
|
1841
|
-
const
|
|
1886
|
+
const lt = () => /* @__PURE__ */ l(
|
|
1842
1887
|
"svg",
|
|
1843
1888
|
{
|
|
1844
1889
|
width: "16",
|
|
@@ -1855,7 +1900,7 @@ const ot = () => /* @__PURE__ */ l(
|
|
|
1855
1900
|
/* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "3" })
|
|
1856
1901
|
]
|
|
1857
1902
|
}
|
|
1858
|
-
),
|
|
1903
|
+
), ct = () => /* @__PURE__ */ l(
|
|
1859
1904
|
"svg",
|
|
1860
1905
|
{
|
|
1861
1906
|
width: "16",
|
|
@@ -1872,10 +1917,10 @@ const ot = () => /* @__PURE__ */ l(
|
|
|
1872
1917
|
/* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
1873
1918
|
]
|
|
1874
1919
|
}
|
|
1875
|
-
),
|
|
1876
|
-
showPassword: /* @__PURE__ */ n(
|
|
1877
|
-
hidePassword: /* @__PURE__ */ n(
|
|
1878
|
-
},
|
|
1920
|
+
), dt = {
|
|
1921
|
+
showPassword: /* @__PURE__ */ n(lt, {}),
|
|
1922
|
+
hidePassword: /* @__PURE__ */ n(ct, {})
|
|
1923
|
+
}, ut = {
|
|
1879
1924
|
title: "Sign In",
|
|
1880
1925
|
usernameLabel: "Email or Phone",
|
|
1881
1926
|
usernamePlaceholder: "Enter your email or phone number",
|
|
@@ -1889,7 +1934,7 @@ const ot = () => /* @__PURE__ */ l(
|
|
|
1889
1934
|
magicLinkLink: "Use Magic Link",
|
|
1890
1935
|
errorMessage: "Invalid credentials",
|
|
1891
1936
|
loadingText: "Signing in..."
|
|
1892
|
-
},
|
|
1937
|
+
}, ht = {
|
|
1893
1938
|
container: {
|
|
1894
1939
|
maxWidth: "400px",
|
|
1895
1940
|
width: "100%",
|
|
@@ -1996,133 +2041,133 @@ const ot = () => /* @__PURE__ */ l(
|
|
|
1996
2041
|
fontSize: "0.875rem"
|
|
1997
2042
|
}
|
|
1998
2043
|
};
|
|
1999
|
-
function
|
|
2044
|
+
function _t({
|
|
2000
2045
|
copy: i = {},
|
|
2001
2046
|
styles: e = {},
|
|
2002
2047
|
icons: t = {},
|
|
2003
2048
|
onSuccess: r,
|
|
2004
2049
|
onError: s,
|
|
2005
2050
|
onForgotPassword: o,
|
|
2006
|
-
onSignupClick:
|
|
2007
|
-
onMagicLinkClick:
|
|
2051
|
+
onSignupClick: h,
|
|
2052
|
+
onMagicLinkClick: w,
|
|
2008
2053
|
showForgotPassword: k = !0,
|
|
2009
|
-
showSignupLink:
|
|
2010
|
-
showMagicLinkOption:
|
|
2054
|
+
showSignupLink: b = !0,
|
|
2055
|
+
showMagicLinkOption: P = !0,
|
|
2011
2056
|
className: m
|
|
2012
2057
|
}) {
|
|
2013
|
-
const [
|
|
2014
|
-
const
|
|
2015
|
-
return
|
|
2016
|
-
},
|
|
2017
|
-
if (
|
|
2058
|
+
const [p, u] = v(""), [y, L] = v(""), [R, z] = v(!1), [M, A] = v(!1), [d, C] = v(""), [F, G] = v({}), { login: U } = ae(), { tenant: _ } = se(), x = { ...ut, ...i }, T = { ...ht, ...e }, E = { ...dt, ...t }, c = () => {
|
|
2059
|
+
const a = {};
|
|
2060
|
+
return p.trim() || (a.username = !0), y.trim() || (a.password = !0), G(a), Object.keys(a).length === 0;
|
|
2061
|
+
}, I = async (a) => {
|
|
2062
|
+
if (a.preventDefault(), !!c()) {
|
|
2018
2063
|
if (!(_ != null && _.id)) {
|
|
2019
|
-
|
|
2064
|
+
C("Tenant not found");
|
|
2020
2065
|
return;
|
|
2021
2066
|
}
|
|
2022
|
-
|
|
2067
|
+
A(!0), C("");
|
|
2023
2068
|
try {
|
|
2024
|
-
const
|
|
2025
|
-
username:
|
|
2069
|
+
const f = await U({
|
|
2070
|
+
username: p,
|
|
2026
2071
|
password: y
|
|
2027
2072
|
// tenantId inferred from context automatically
|
|
2028
2073
|
});
|
|
2029
|
-
r == null || r(
|
|
2030
|
-
} catch (
|
|
2031
|
-
const
|
|
2032
|
-
|
|
2074
|
+
r == null || r(f);
|
|
2075
|
+
} catch (f) {
|
|
2076
|
+
const O = f.message || x.errorMessage;
|
|
2077
|
+
C(O), s == null || s(O);
|
|
2033
2078
|
} finally {
|
|
2034
|
-
|
|
2079
|
+
A(!1);
|
|
2035
2080
|
}
|
|
2036
2081
|
}
|
|
2037
|
-
},
|
|
2038
|
-
...
|
|
2039
|
-
...
|
|
2040
|
-
}),
|
|
2041
|
-
...
|
|
2042
|
-
...
|
|
2043
|
-
...!
|
|
2082
|
+
}, S = (a) => ({
|
|
2083
|
+
...T.input,
|
|
2084
|
+
...F[a] ? T.inputError : {}
|
|
2085
|
+
}), g = () => ({
|
|
2086
|
+
...T.button,
|
|
2087
|
+
...M ? T.buttonLoading : {},
|
|
2088
|
+
...!p || !y || M ? T.buttonDisabled : {}
|
|
2044
2089
|
});
|
|
2045
|
-
return /* @__PURE__ */ l("div", { className: m, style:
|
|
2046
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2047
|
-
/* @__PURE__ */ l("form", { onSubmit:
|
|
2048
|
-
/* @__PURE__ */ l("div", { style:
|
|
2049
|
-
/* @__PURE__ */ n("label", { style:
|
|
2090
|
+
return /* @__PURE__ */ l("div", { className: m, style: T.container, children: [
|
|
2091
|
+
/* @__PURE__ */ n("h2", { style: T.title, children: x.title }),
|
|
2092
|
+
/* @__PURE__ */ l("form", { onSubmit: I, style: T.form, children: [
|
|
2093
|
+
/* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
|
|
2094
|
+
/* @__PURE__ */ n("label", { style: T.label, children: x.usernameLabel }),
|
|
2050
2095
|
/* @__PURE__ */ n(
|
|
2051
2096
|
"input",
|
|
2052
2097
|
{
|
|
2053
2098
|
id: "username",
|
|
2054
2099
|
name: "username",
|
|
2055
2100
|
type: "text",
|
|
2056
|
-
value:
|
|
2057
|
-
onChange: (
|
|
2058
|
-
u(
|
|
2101
|
+
value: p,
|
|
2102
|
+
onChange: (a) => {
|
|
2103
|
+
u(a.target.value), F.username && G((f) => ({ ...f, username: !1 }));
|
|
2059
2104
|
},
|
|
2060
|
-
placeholder:
|
|
2061
|
-
style:
|
|
2062
|
-
disabled:
|
|
2105
|
+
placeholder: x.usernamePlaceholder,
|
|
2106
|
+
style: S("username"),
|
|
2107
|
+
disabled: M
|
|
2063
2108
|
}
|
|
2064
2109
|
)
|
|
2065
2110
|
] }),
|
|
2066
|
-
/* @__PURE__ */ l("div", { style:
|
|
2067
|
-
/* @__PURE__ */ n("label", { style:
|
|
2068
|
-
/* @__PURE__ */ l("div", { style:
|
|
2111
|
+
/* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
|
|
2112
|
+
/* @__PURE__ */ n("label", { style: T.label, children: x.passwordLabel }),
|
|
2113
|
+
/* @__PURE__ */ l("div", { style: T.inputContainer, children: [
|
|
2069
2114
|
/* @__PURE__ */ n(
|
|
2070
2115
|
"input",
|
|
2071
2116
|
{
|
|
2072
2117
|
id: "password",
|
|
2073
2118
|
name: "password",
|
|
2074
|
-
type:
|
|
2119
|
+
type: R ? "text" : "password",
|
|
2075
2120
|
value: y,
|
|
2076
|
-
onChange: (
|
|
2077
|
-
|
|
2121
|
+
onChange: (a) => {
|
|
2122
|
+
L(a.target.value), F.password && G((f) => ({ ...f, password: !1 }));
|
|
2078
2123
|
},
|
|
2079
|
-
placeholder:
|
|
2124
|
+
placeholder: x.passwordPlaceholder,
|
|
2080
2125
|
style: {
|
|
2081
|
-
...
|
|
2126
|
+
...S("password"),
|
|
2082
2127
|
paddingRight: "2.5rem"
|
|
2083
2128
|
// Make room for the icon
|
|
2084
2129
|
},
|
|
2085
|
-
disabled:
|
|
2130
|
+
disabled: M
|
|
2086
2131
|
}
|
|
2087
2132
|
),
|
|
2088
2133
|
/* @__PURE__ */ n(
|
|
2089
2134
|
"button",
|
|
2090
2135
|
{
|
|
2091
2136
|
type: "button",
|
|
2092
|
-
onClick: () =>
|
|
2093
|
-
style:
|
|
2094
|
-
disabled:
|
|
2095
|
-
"aria-label":
|
|
2096
|
-
children:
|
|
2137
|
+
onClick: () => z(!R),
|
|
2138
|
+
style: T.passwordToggle,
|
|
2139
|
+
disabled: M,
|
|
2140
|
+
"aria-label": R ? "Hide password" : "Show password",
|
|
2141
|
+
children: R ? E.hidePassword : E.showPassword
|
|
2097
2142
|
}
|
|
2098
2143
|
)
|
|
2099
2144
|
] })
|
|
2100
2145
|
] }),
|
|
2101
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !
|
|
2102
|
-
|
|
2146
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !p || !y || M, style: g(), children: M ? x.loadingText : x.submitButton }),
|
|
2147
|
+
d && /* @__PURE__ */ n("div", { style: T.errorText, children: d })
|
|
2103
2148
|
] }),
|
|
2104
|
-
(k ||
|
|
2105
|
-
|
|
2106
|
-
/* @__PURE__ */ l("span", { style:
|
|
2107
|
-
|
|
2149
|
+
(k || b || P) && /* @__PURE__ */ l("div", { style: T.linkContainer, children: [
|
|
2150
|
+
P && /* @__PURE__ */ l("div", { children: [
|
|
2151
|
+
/* @__PURE__ */ l("span", { style: T.divider, children: [
|
|
2152
|
+
x.magicLinkText,
|
|
2108
2153
|
" "
|
|
2109
2154
|
] }),
|
|
2110
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
2155
|
+
/* @__PURE__ */ n("a", { onClick: w, style: T.link, children: x.magicLinkLink })
|
|
2111
2156
|
] }),
|
|
2112
|
-
|
|
2113
|
-
k && /* @__PURE__ */ n("a", { onClick: o, style:
|
|
2114
|
-
k &&
|
|
2115
|
-
|
|
2116
|
-
/* @__PURE__ */ l("span", { style:
|
|
2117
|
-
|
|
2157
|
+
P && (k || b) && /* @__PURE__ */ n("div", { style: T.divider, children: "•" }),
|
|
2158
|
+
k && /* @__PURE__ */ n("a", { onClick: o, style: T.link, children: x.forgotPasswordLink }),
|
|
2159
|
+
k && b && /* @__PURE__ */ n("div", { style: T.divider, children: "•" }),
|
|
2160
|
+
b && /* @__PURE__ */ l("div", { children: [
|
|
2161
|
+
/* @__PURE__ */ l("span", { style: T.divider, children: [
|
|
2162
|
+
x.signupText,
|
|
2118
2163
|
" "
|
|
2119
2164
|
] }),
|
|
2120
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
2165
|
+
/* @__PURE__ */ n("a", { onClick: h, style: T.link, children: x.signupLink })
|
|
2121
2166
|
] })
|
|
2122
2167
|
] })
|
|
2123
2168
|
] });
|
|
2124
2169
|
}
|
|
2125
|
-
const
|
|
2170
|
+
const gt = {
|
|
2126
2171
|
title: "Create Account",
|
|
2127
2172
|
nameLabel: "First Name",
|
|
2128
2173
|
namePlaceholder: "Enter your first name",
|
|
@@ -2148,7 +2193,7 @@ const ut = {
|
|
|
2148
2193
|
passwordMismatchError: "Passwords do not match",
|
|
2149
2194
|
isAdminLabel: "Create new organization",
|
|
2150
2195
|
isAdminDescription: "Check this if you want to create a new organization"
|
|
2151
|
-
},
|
|
2196
|
+
}, pt = {
|
|
2152
2197
|
container: {
|
|
2153
2198
|
maxWidth: "400px",
|
|
2154
2199
|
width: "100%",
|
|
@@ -2247,103 +2292,103 @@ const ut = {
|
|
|
2247
2292
|
fontSize: "0.875rem"
|
|
2248
2293
|
}
|
|
2249
2294
|
};
|
|
2250
|
-
function
|
|
2295
|
+
function Gt({
|
|
2251
2296
|
copy: i = {},
|
|
2252
2297
|
styles: e = {},
|
|
2253
2298
|
signupType: t = "user",
|
|
2254
2299
|
onSuccess: r,
|
|
2255
2300
|
onError: s,
|
|
2256
2301
|
onLoginClick: o,
|
|
2257
|
-
onMagicLinkClick:
|
|
2258
|
-
showLoginLink:
|
|
2302
|
+
onMagicLinkClick: h,
|
|
2303
|
+
showLoginLink: w = !0,
|
|
2259
2304
|
showMagicLinkOption: k = !0,
|
|
2260
|
-
className:
|
|
2305
|
+
className: b
|
|
2261
2306
|
}) {
|
|
2262
|
-
const [
|
|
2263
|
-
const
|
|
2264
|
-
return
|
|
2265
|
-
},
|
|
2266
|
-
if (
|
|
2267
|
-
if (
|
|
2268
|
-
|
|
2307
|
+
const [P, m] = v(""), [p, u] = v(""), [y, L] = v(""), [R, z] = v(""), [M, A] = v(""), [d, C] = v(""), [F, G] = v(""), [U, _] = v(!1), [x, T] = v(""), [E, c] = v({}), { signup: I, signupTenantAdmin: S } = ae(), { tenant: g } = se(), a = { ...gt, ...i }, f = { ...pt, ...e }, O = () => {
|
|
2308
|
+
const $ = {};
|
|
2309
|
+
return P.trim() || ($.name = !0), !y.trim() && !R.trim() && ($.email = !0, $.phoneNumber = !0), M.trim() || ($.password = !0), d.trim() || ($.confirmPassword = !0), t === "tenant" && !F.trim() && ($.tenantName = !0), c($), Object.keys($).length === 0;
|
|
2310
|
+
}, K = async ($) => {
|
|
2311
|
+
if ($.preventDefault(), !!O()) {
|
|
2312
|
+
if (M !== d) {
|
|
2313
|
+
T(a.passwordMismatchError), c({ confirmPassword: !0 });
|
|
2269
2314
|
return;
|
|
2270
2315
|
}
|
|
2271
|
-
if (t === "user" && !(
|
|
2272
|
-
|
|
2316
|
+
if (t === "user" && !(g != null && g.id)) {
|
|
2317
|
+
T("Tenant not found");
|
|
2273
2318
|
return;
|
|
2274
2319
|
}
|
|
2275
|
-
_(!0),
|
|
2320
|
+
_(!0), T("");
|
|
2276
2321
|
try {
|
|
2277
|
-
let
|
|
2278
|
-
t === "tenant" ?
|
|
2322
|
+
let J;
|
|
2323
|
+
t === "tenant" ? J = await S({
|
|
2279
2324
|
email: y || void 0,
|
|
2280
|
-
phoneNumber:
|
|
2281
|
-
name:
|
|
2282
|
-
password:
|
|
2283
|
-
tenantName:
|
|
2284
|
-
lastName:
|
|
2285
|
-
}) :
|
|
2325
|
+
phoneNumber: R || void 0,
|
|
2326
|
+
name: P,
|
|
2327
|
+
password: M,
|
|
2328
|
+
tenantName: F,
|
|
2329
|
+
lastName: p || void 0
|
|
2330
|
+
}) : J = await I({
|
|
2286
2331
|
email: y || void 0,
|
|
2287
|
-
phoneNumber:
|
|
2288
|
-
name:
|
|
2289
|
-
password:
|
|
2290
|
-
tenantId:
|
|
2291
|
-
lastName:
|
|
2292
|
-
}), r == null || r(
|
|
2293
|
-
} catch (
|
|
2294
|
-
const ge =
|
|
2295
|
-
|
|
2332
|
+
phoneNumber: R || void 0,
|
|
2333
|
+
name: P,
|
|
2334
|
+
password: M,
|
|
2335
|
+
tenantId: g.id,
|
|
2336
|
+
lastName: p || void 0
|
|
2337
|
+
}), r == null || r(J);
|
|
2338
|
+
} catch (J) {
|
|
2339
|
+
const ge = J.message || a.errorMessage;
|
|
2340
|
+
T(ge), s == null || s(ge);
|
|
2296
2341
|
} finally {
|
|
2297
2342
|
_(!1);
|
|
2298
2343
|
}
|
|
2299
2344
|
}
|
|
2300
|
-
}, H = (
|
|
2301
|
-
...
|
|
2302
|
-
...
|
|
2345
|
+
}, H = ($) => ({
|
|
2346
|
+
...f.input,
|
|
2347
|
+
...E[$] ? f.inputError : {}
|
|
2303
2348
|
}), N = () => ({
|
|
2304
|
-
...
|
|
2305
|
-
|
|
2306
|
-
...!
|
|
2307
|
-
}),
|
|
2308
|
-
return /* @__PURE__ */ l("div", { className:
|
|
2309
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2310
|
-
/* @__PURE__ */ l("form", { onSubmit:
|
|
2311
|
-
/* @__PURE__ */ l("div", { style:
|
|
2312
|
-
/* @__PURE__ */ n("label", { style:
|
|
2349
|
+
...f.button,
|
|
2350
|
+
...U ? f.buttonLoading : {},
|
|
2351
|
+
...!P || !y && !R || !M || !d || U || t === "tenant" && !F ? f.buttonDisabled : {}
|
|
2352
|
+
}), W = P && (y || R) && M && d && (t === "user" || F);
|
|
2353
|
+
return /* @__PURE__ */ l("div", { className: b, style: f.container, children: [
|
|
2354
|
+
/* @__PURE__ */ n("h2", { style: f.title, children: a.title }),
|
|
2355
|
+
/* @__PURE__ */ l("form", { onSubmit: K, style: f.form, children: [
|
|
2356
|
+
/* @__PURE__ */ l("div", { style: f.fieldGroup, children: [
|
|
2357
|
+
/* @__PURE__ */ n("label", { style: f.label, children: a.nameLabel }),
|
|
2313
2358
|
/* @__PURE__ */ n(
|
|
2314
2359
|
"input",
|
|
2315
2360
|
{
|
|
2316
2361
|
id: "name",
|
|
2317
2362
|
name: "name",
|
|
2318
2363
|
type: "text",
|
|
2319
|
-
value:
|
|
2320
|
-
onChange: (
|
|
2321
|
-
m(
|
|
2364
|
+
value: P,
|
|
2365
|
+
onChange: ($) => {
|
|
2366
|
+
m($.target.value), E.name && c((J) => ({ ...J, name: !1 }));
|
|
2322
2367
|
},
|
|
2323
|
-
placeholder:
|
|
2368
|
+
placeholder: a.namePlaceholder,
|
|
2324
2369
|
style: H("name"),
|
|
2325
|
-
disabled:
|
|
2370
|
+
disabled: U
|
|
2326
2371
|
}
|
|
2327
2372
|
)
|
|
2328
2373
|
] }),
|
|
2329
|
-
/* @__PURE__ */ l("div", { style:
|
|
2330
|
-
/* @__PURE__ */ n("label", { style:
|
|
2374
|
+
/* @__PURE__ */ l("div", { style: f.fieldGroup, children: [
|
|
2375
|
+
/* @__PURE__ */ n("label", { style: f.label, children: a.lastNameLabel }),
|
|
2331
2376
|
/* @__PURE__ */ n(
|
|
2332
2377
|
"input",
|
|
2333
2378
|
{
|
|
2334
2379
|
id: "lastName",
|
|
2335
2380
|
name: "lastName",
|
|
2336
2381
|
type: "text",
|
|
2337
|
-
value:
|
|
2338
|
-
onChange: (
|
|
2339
|
-
placeholder:
|
|
2340
|
-
style:
|
|
2341
|
-
disabled:
|
|
2382
|
+
value: p,
|
|
2383
|
+
onChange: ($) => u($.target.value),
|
|
2384
|
+
placeholder: a.lastNamePlaceholder,
|
|
2385
|
+
style: f.input,
|
|
2386
|
+
disabled: U
|
|
2342
2387
|
}
|
|
2343
2388
|
)
|
|
2344
2389
|
] }),
|
|
2345
|
-
/* @__PURE__ */ l("div", { style:
|
|
2346
|
-
/* @__PURE__ */ n("label", { style:
|
|
2390
|
+
/* @__PURE__ */ l("div", { style: f.fieldGroup, children: [
|
|
2391
|
+
/* @__PURE__ */ n("label", { style: f.label, children: a.emailLabel }),
|
|
2347
2392
|
/* @__PURE__ */ n(
|
|
2348
2393
|
"input",
|
|
2349
2394
|
{
|
|
@@ -2351,30 +2396,30 @@ function Vt({
|
|
|
2351
2396
|
name: "email",
|
|
2352
2397
|
type: "email",
|
|
2353
2398
|
value: y,
|
|
2354
|
-
onChange: (
|
|
2355
|
-
|
|
2399
|
+
onChange: ($) => {
|
|
2400
|
+
L($.target.value), E.email && c((J) => ({ ...J, email: !1, phoneNumber: !1 }));
|
|
2356
2401
|
},
|
|
2357
|
-
placeholder:
|
|
2402
|
+
placeholder: a.emailPlaceholder,
|
|
2358
2403
|
style: H("email"),
|
|
2359
|
-
disabled:
|
|
2404
|
+
disabled: U
|
|
2360
2405
|
}
|
|
2361
2406
|
)
|
|
2362
2407
|
] }),
|
|
2363
|
-
/* @__PURE__ */ l("div", { style:
|
|
2364
|
-
/* @__PURE__ */ n("label", { style:
|
|
2408
|
+
/* @__PURE__ */ l("div", { style: f.fieldGroup, children: [
|
|
2409
|
+
/* @__PURE__ */ n("label", { style: f.label, children: a.phoneNumberLabel }),
|
|
2365
2410
|
/* @__PURE__ */ n(
|
|
2366
2411
|
"input",
|
|
2367
2412
|
{
|
|
2368
2413
|
id: "phoneNumber",
|
|
2369
2414
|
name: "phoneNumber",
|
|
2370
2415
|
type: "tel",
|
|
2371
|
-
value:
|
|
2372
|
-
onChange: (
|
|
2373
|
-
|
|
2416
|
+
value: R,
|
|
2417
|
+
onChange: ($) => {
|
|
2418
|
+
z($.target.value), E.phoneNumber && c((J) => ({ ...J, email: !1, phoneNumber: !1 }));
|
|
2374
2419
|
},
|
|
2375
|
-
placeholder:
|
|
2420
|
+
placeholder: a.phoneNumberPlaceholder,
|
|
2376
2421
|
style: H("phoneNumber"),
|
|
2377
|
-
disabled:
|
|
2422
|
+
disabled: U
|
|
2378
2423
|
}
|
|
2379
2424
|
)
|
|
2380
2425
|
] }),
|
|
@@ -2390,83 +2435,83 @@ function Vt({
|
|
|
2390
2435
|
children: "At least one contact method (email or phone) is required"
|
|
2391
2436
|
}
|
|
2392
2437
|
),
|
|
2393
|
-
/* @__PURE__ */ l("div", { style:
|
|
2394
|
-
/* @__PURE__ */ n("label", { style:
|
|
2438
|
+
/* @__PURE__ */ l("div", { style: f.fieldGroup, children: [
|
|
2439
|
+
/* @__PURE__ */ n("label", { style: f.label, children: a.passwordLabel }),
|
|
2395
2440
|
/* @__PURE__ */ n(
|
|
2396
2441
|
"input",
|
|
2397
2442
|
{
|
|
2398
2443
|
id: "password",
|
|
2399
2444
|
name: "password",
|
|
2400
2445
|
type: "password",
|
|
2401
|
-
value:
|
|
2402
|
-
onChange: (
|
|
2403
|
-
|
|
2446
|
+
value: M,
|
|
2447
|
+
onChange: ($) => {
|
|
2448
|
+
A($.target.value), E.password && c((J) => ({ ...J, password: !1 }));
|
|
2404
2449
|
},
|
|
2405
|
-
placeholder:
|
|
2450
|
+
placeholder: a.passwordPlaceholder,
|
|
2406
2451
|
style: H("password"),
|
|
2407
|
-
disabled:
|
|
2452
|
+
disabled: U
|
|
2408
2453
|
}
|
|
2409
2454
|
)
|
|
2410
2455
|
] }),
|
|
2411
|
-
/* @__PURE__ */ l("div", { style:
|
|
2412
|
-
/* @__PURE__ */ n("label", { style:
|
|
2456
|
+
/* @__PURE__ */ l("div", { style: f.fieldGroup, children: [
|
|
2457
|
+
/* @__PURE__ */ n("label", { style: f.label, children: a.confirmPasswordLabel }),
|
|
2413
2458
|
/* @__PURE__ */ n(
|
|
2414
2459
|
"input",
|
|
2415
2460
|
{
|
|
2416
2461
|
id: "confirmPassword",
|
|
2417
2462
|
name: "confirmPassword",
|
|
2418
2463
|
type: "password",
|
|
2419
|
-
value:
|
|
2420
|
-
onChange: (
|
|
2421
|
-
|
|
2464
|
+
value: d,
|
|
2465
|
+
onChange: ($) => {
|
|
2466
|
+
C($.target.value), E.confirmPassword && c((J) => ({ ...J, confirmPassword: !1 })), x === a.passwordMismatchError && T("");
|
|
2422
2467
|
},
|
|
2423
|
-
placeholder:
|
|
2468
|
+
placeholder: a.confirmPasswordPlaceholder,
|
|
2424
2469
|
style: H("confirmPassword"),
|
|
2425
|
-
disabled:
|
|
2470
|
+
disabled: U
|
|
2426
2471
|
}
|
|
2427
2472
|
)
|
|
2428
2473
|
] }),
|
|
2429
|
-
t === "tenant" && /* @__PURE__ */ l("div", { style:
|
|
2430
|
-
/* @__PURE__ */ n("label", { style:
|
|
2474
|
+
t === "tenant" && /* @__PURE__ */ l("div", { style: f.fieldGroup, children: [
|
|
2475
|
+
/* @__PURE__ */ n("label", { style: f.label, children: a.tenantNameLabel }),
|
|
2431
2476
|
/* @__PURE__ */ n(
|
|
2432
2477
|
"input",
|
|
2433
2478
|
{
|
|
2434
2479
|
id: "tenantName",
|
|
2435
2480
|
name: "tenantName",
|
|
2436
2481
|
type: "text",
|
|
2437
|
-
value:
|
|
2438
|
-
onChange: (
|
|
2439
|
-
G(
|
|
2482
|
+
value: F,
|
|
2483
|
+
onChange: ($) => {
|
|
2484
|
+
G($.target.value), E.tenantName && c((J) => ({ ...J, tenantName: !1 }));
|
|
2440
2485
|
},
|
|
2441
|
-
placeholder:
|
|
2486
|
+
placeholder: a.tenantNamePlaceholder,
|
|
2442
2487
|
style: H("tenantName"),
|
|
2443
|
-
disabled:
|
|
2488
|
+
disabled: U
|
|
2444
2489
|
}
|
|
2445
2490
|
)
|
|
2446
2491
|
] }),
|
|
2447
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !
|
|
2448
|
-
|
|
2492
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !W || U, style: N(), children: U ? a.loadingText : a.submitButton }),
|
|
2493
|
+
x && /* @__PURE__ */ n("div", { style: f.errorText, children: x })
|
|
2449
2494
|
] }),
|
|
2450
|
-
(
|
|
2495
|
+
(w || k) && /* @__PURE__ */ l("div", { style: f.linkContainer, children: [
|
|
2451
2496
|
k && /* @__PURE__ */ l("div", { children: [
|
|
2452
|
-
/* @__PURE__ */ l("span", { style:
|
|
2453
|
-
|
|
2497
|
+
/* @__PURE__ */ l("span", { style: f.divider, children: [
|
|
2498
|
+
a.magicLinkText,
|
|
2454
2499
|
" "
|
|
2455
2500
|
] }),
|
|
2456
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
2501
|
+
/* @__PURE__ */ n("a", { onClick: h, style: f.link, children: a.magicLinkLink })
|
|
2457
2502
|
] }),
|
|
2458
|
-
k &&
|
|
2459
|
-
|
|
2460
|
-
/* @__PURE__ */ l("span", { style:
|
|
2461
|
-
|
|
2503
|
+
k && w && /* @__PURE__ */ n("div", { style: f.divider, children: "•" }),
|
|
2504
|
+
w && /* @__PURE__ */ l("div", { children: [
|
|
2505
|
+
/* @__PURE__ */ l("span", { style: f.divider, children: [
|
|
2506
|
+
a.loginText,
|
|
2462
2507
|
" "
|
|
2463
2508
|
] }),
|
|
2464
|
-
/* @__PURE__ */ n("a", { onClick: o, style:
|
|
2509
|
+
/* @__PURE__ */ n("a", { onClick: o, style: f.link, children: a.loginLink })
|
|
2465
2510
|
] })
|
|
2466
2511
|
] })
|
|
2467
2512
|
] });
|
|
2468
2513
|
}
|
|
2469
|
-
const
|
|
2514
|
+
const ft = {
|
|
2470
2515
|
title: "Sign In with Magic Link",
|
|
2471
2516
|
emailLabel: "Email",
|
|
2472
2517
|
emailPlaceholder: "Enter your email",
|
|
@@ -2484,7 +2529,7 @@ const gt = {
|
|
|
2484
2529
|
loadingText: "Sending magic link...",
|
|
2485
2530
|
verifyingText: "Verifying magic link...",
|
|
2486
2531
|
description: "Enter your email to receive a magic link. If you don't have an account, we'll create one for you."
|
|
2487
|
-
},
|
|
2532
|
+
}, mt = {
|
|
2488
2533
|
container: {
|
|
2489
2534
|
maxWidth: "400px",
|
|
2490
2535
|
width: "100%",
|
|
@@ -2587,105 +2632,105 @@ const gt = {
|
|
|
2587
2632
|
fontSize: "0.875rem"
|
|
2588
2633
|
}
|
|
2589
2634
|
};
|
|
2590
|
-
function
|
|
2635
|
+
function Kt({
|
|
2591
2636
|
copy: i = {},
|
|
2592
2637
|
styles: e = {},
|
|
2593
2638
|
onSuccess: t,
|
|
2594
2639
|
onError: r,
|
|
2595
2640
|
onLoginClick: s,
|
|
2596
2641
|
onSignupClick: o,
|
|
2597
|
-
showTraditionalLinks:
|
|
2598
|
-
className:
|
|
2642
|
+
showTraditionalLinks: h = !0,
|
|
2643
|
+
className: w,
|
|
2599
2644
|
verifyToken: k,
|
|
2600
|
-
frontendUrl:
|
|
2645
|
+
frontendUrl: b
|
|
2601
2646
|
}) {
|
|
2602
|
-
const [
|
|
2647
|
+
const [P, m] = v(""), [p, u] = v(""), [y, L] = v(""), [R, z] = v(!1), [M, A] = v(!1), [d, C] = v(""), [F, G] = v(""), [U, _] = v({}), [x, T] = v(!1), { sendMagicLink: E, verifyMagicLink: c } = ae(), { tenant: I } = se(), S = { ...ft, ...i }, g = { ...mt, ...e };
|
|
2603
2648
|
te(() => {
|
|
2604
|
-
k &&
|
|
2649
|
+
k && a(k);
|
|
2605
2650
|
}, [k]);
|
|
2606
|
-
const
|
|
2607
|
-
if (!
|
|
2608
|
-
|
|
2651
|
+
const a = async (N) => {
|
|
2652
|
+
if (!I || !P) {
|
|
2653
|
+
C("Missing tenant or email");
|
|
2609
2654
|
return;
|
|
2610
2655
|
}
|
|
2611
|
-
|
|
2656
|
+
A(!0), C("");
|
|
2612
2657
|
try {
|
|
2613
|
-
const
|
|
2658
|
+
const W = await c({
|
|
2614
2659
|
token: N,
|
|
2615
|
-
email:
|
|
2660
|
+
email: P
|
|
2616
2661
|
// tenantId inferred from context automatically
|
|
2617
2662
|
});
|
|
2618
|
-
t == null || t(
|
|
2619
|
-
} catch (
|
|
2620
|
-
const
|
|
2621
|
-
|
|
2663
|
+
t == null || t(W);
|
|
2664
|
+
} catch (W) {
|
|
2665
|
+
const $ = W.message || "Failed to verify magic link";
|
|
2666
|
+
C($), r == null || r($);
|
|
2622
2667
|
} finally {
|
|
2623
|
-
|
|
2668
|
+
A(!1);
|
|
2624
2669
|
}
|
|
2625
|
-
},
|
|
2670
|
+
}, f = () => {
|
|
2626
2671
|
const N = {};
|
|
2627
|
-
return
|
|
2628
|
-
},
|
|
2629
|
-
if (N.preventDefault(), !!
|
|
2630
|
-
if (!(
|
|
2631
|
-
|
|
2672
|
+
return P.trim() || (N.email = !0), x && !p.trim() && (N.name = !0), _(N), Object.keys(N).length === 0;
|
|
2673
|
+
}, O = async (N) => {
|
|
2674
|
+
if (N.preventDefault(), !!f()) {
|
|
2675
|
+
if (!(I != null && I.id)) {
|
|
2676
|
+
C("Tenant not found");
|
|
2632
2677
|
return;
|
|
2633
2678
|
}
|
|
2634
|
-
|
|
2679
|
+
z(!0), C(""), G("");
|
|
2635
2680
|
try {
|
|
2636
|
-
const
|
|
2637
|
-
email:
|
|
2638
|
-
tenantId:
|
|
2639
|
-
frontendUrl:
|
|
2640
|
-
name:
|
|
2641
|
-
lastName:
|
|
2681
|
+
const W = b || (typeof window < "u" ? window.location.origin : ""), $ = await E({
|
|
2682
|
+
email: P,
|
|
2683
|
+
tenantId: I.id,
|
|
2684
|
+
frontendUrl: W,
|
|
2685
|
+
name: x ? p : void 0,
|
|
2686
|
+
lastName: x ? y : void 0
|
|
2642
2687
|
});
|
|
2643
|
-
G(
|
|
2644
|
-
} catch (
|
|
2645
|
-
const
|
|
2646
|
-
|
|
2688
|
+
G(S.successMessage), t == null || t($);
|
|
2689
|
+
} catch (W) {
|
|
2690
|
+
const $ = W.message || S.errorMessage;
|
|
2691
|
+
C($), r == null || r($);
|
|
2647
2692
|
} finally {
|
|
2648
|
-
|
|
2693
|
+
z(!1);
|
|
2649
2694
|
}
|
|
2650
2695
|
}
|
|
2651
|
-
},
|
|
2652
|
-
...
|
|
2653
|
-
|
|
2696
|
+
}, K = (N) => ({
|
|
2697
|
+
...g.input,
|
|
2698
|
+
...U[N] ? g.inputError : {}
|
|
2654
2699
|
}), H = () => ({
|
|
2655
|
-
...
|
|
2656
|
-
...
|
|
2657
|
-
...!
|
|
2700
|
+
...g.button,
|
|
2701
|
+
...R || M ? g.buttonLoading : {},
|
|
2702
|
+
...!P || R || M ? g.buttonDisabled : {}
|
|
2658
2703
|
});
|
|
2659
|
-
return
|
|
2660
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2704
|
+
return M ? /* @__PURE__ */ l("div", { className: w, style: g.container, children: [
|
|
2705
|
+
/* @__PURE__ */ n("h2", { style: g.title, children: S.verifyingText }),
|
|
2661
2706
|
/* @__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..." }) })
|
|
2662
|
-
] }) : /* @__PURE__ */ l("div", { className:
|
|
2663
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2664
|
-
/* @__PURE__ */ n("p", { style:
|
|
2665
|
-
/* @__PURE__ */ l("form", { onSubmit:
|
|
2666
|
-
/* @__PURE__ */ l("div", { style:
|
|
2667
|
-
/* @__PURE__ */ n("label", { style:
|
|
2707
|
+
] }) : /* @__PURE__ */ l("div", { className: w, style: g.container, children: [
|
|
2708
|
+
/* @__PURE__ */ n("h2", { style: g.title, children: S.title }),
|
|
2709
|
+
/* @__PURE__ */ n("p", { style: g.description, children: S.description }),
|
|
2710
|
+
/* @__PURE__ */ l("form", { onSubmit: O, style: g.form, children: [
|
|
2711
|
+
/* @__PURE__ */ l("div", { style: g.fieldGroup, children: [
|
|
2712
|
+
/* @__PURE__ */ n("label", { style: g.label, children: S.emailLabel }),
|
|
2668
2713
|
/* @__PURE__ */ n(
|
|
2669
2714
|
"input",
|
|
2670
2715
|
{
|
|
2671
2716
|
id: "email",
|
|
2672
2717
|
name: "email",
|
|
2673
2718
|
type: "email",
|
|
2674
|
-
value:
|
|
2719
|
+
value: P,
|
|
2675
2720
|
onChange: (N) => {
|
|
2676
|
-
m(N.target.value),
|
|
2721
|
+
m(N.target.value), U.email && _((W) => ({ ...W, email: !1 }));
|
|
2677
2722
|
},
|
|
2678
|
-
placeholder:
|
|
2679
|
-
style:
|
|
2680
|
-
disabled:
|
|
2723
|
+
placeholder: S.emailPlaceholder,
|
|
2724
|
+
style: K("email"),
|
|
2725
|
+
disabled: R || M
|
|
2681
2726
|
}
|
|
2682
2727
|
)
|
|
2683
2728
|
] }),
|
|
2684
|
-
!
|
|
2729
|
+
!x && /* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
|
|
2685
2730
|
"button",
|
|
2686
2731
|
{
|
|
2687
2732
|
type: "button",
|
|
2688
|
-
onClick: () =>
|
|
2733
|
+
onClick: () => T(!0),
|
|
2689
2734
|
style: {
|
|
2690
2735
|
background: "none",
|
|
2691
2736
|
border: "none",
|
|
@@ -2697,27 +2742,27 @@ function _t({
|
|
|
2697
2742
|
children: "New user? Add your name"
|
|
2698
2743
|
}
|
|
2699
2744
|
) }),
|
|
2700
|
-
|
|
2701
|
-
/* @__PURE__ */ l("div", { style:
|
|
2702
|
-
/* @__PURE__ */ n("label", { style:
|
|
2745
|
+
x && /* @__PURE__ */ l(q, { children: [
|
|
2746
|
+
/* @__PURE__ */ l("div", { style: g.fieldGroup, children: [
|
|
2747
|
+
/* @__PURE__ */ n("label", { style: g.label, children: S.nameLabel }),
|
|
2703
2748
|
/* @__PURE__ */ n(
|
|
2704
2749
|
"input",
|
|
2705
2750
|
{
|
|
2706
2751
|
id: "name",
|
|
2707
2752
|
name: "name",
|
|
2708
2753
|
type: "text",
|
|
2709
|
-
value:
|
|
2754
|
+
value: p,
|
|
2710
2755
|
onChange: (N) => {
|
|
2711
|
-
u(N.target.value),
|
|
2756
|
+
u(N.target.value), U.name && _((W) => ({ ...W, name: !1 }));
|
|
2712
2757
|
},
|
|
2713
|
-
placeholder:
|
|
2714
|
-
style:
|
|
2715
|
-
disabled:
|
|
2758
|
+
placeholder: S.namePlaceholder,
|
|
2759
|
+
style: K("name"),
|
|
2760
|
+
disabled: R || M
|
|
2716
2761
|
}
|
|
2717
2762
|
)
|
|
2718
2763
|
] }),
|
|
2719
|
-
/* @__PURE__ */ l("div", { style:
|
|
2720
|
-
/* @__PURE__ */ n("label", { style:
|
|
2764
|
+
/* @__PURE__ */ l("div", { style: g.fieldGroup, children: [
|
|
2765
|
+
/* @__PURE__ */ n("label", { style: g.label, children: S.lastNameLabel }),
|
|
2721
2766
|
/* @__PURE__ */ n(
|
|
2722
2767
|
"input",
|
|
2723
2768
|
{
|
|
@@ -2725,10 +2770,10 @@ function _t({
|
|
|
2725
2770
|
name: "lastName",
|
|
2726
2771
|
type: "text",
|
|
2727
2772
|
value: y,
|
|
2728
|
-
onChange: (N) =>
|
|
2729
|
-
placeholder:
|
|
2730
|
-
style:
|
|
2731
|
-
disabled:
|
|
2773
|
+
onChange: (N) => L(N.target.value),
|
|
2774
|
+
placeholder: S.lastNamePlaceholder,
|
|
2775
|
+
style: g.input,
|
|
2776
|
+
disabled: R || M
|
|
2732
2777
|
}
|
|
2733
2778
|
)
|
|
2734
2779
|
] }),
|
|
@@ -2737,7 +2782,7 @@ function _t({
|
|
|
2737
2782
|
{
|
|
2738
2783
|
type: "button",
|
|
2739
2784
|
onClick: () => {
|
|
2740
|
-
|
|
2785
|
+
T(!1), u(""), L("");
|
|
2741
2786
|
},
|
|
2742
2787
|
style: {
|
|
2743
2788
|
background: "none",
|
|
@@ -2751,30 +2796,30 @@ function _t({
|
|
|
2751
2796
|
}
|
|
2752
2797
|
) })
|
|
2753
2798
|
] }),
|
|
2754
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !
|
|
2755
|
-
|
|
2756
|
-
|
|
2799
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !P || R || M, style: H(), children: R ? S.loadingText : S.submitButton }),
|
|
2800
|
+
d && /* @__PURE__ */ n("div", { style: g.errorText, children: d }),
|
|
2801
|
+
F && /* @__PURE__ */ n("div", { style: g.successText, children: F })
|
|
2757
2802
|
] }),
|
|
2758
|
-
|
|
2803
|
+
h && /* @__PURE__ */ l("div", { style: g.linkContainer, children: [
|
|
2759
2804
|
/* @__PURE__ */ l("div", { children: [
|
|
2760
|
-
/* @__PURE__ */ l("span", { style:
|
|
2761
|
-
|
|
2805
|
+
/* @__PURE__ */ l("span", { style: g.divider, children: [
|
|
2806
|
+
S.loginText,
|
|
2762
2807
|
" "
|
|
2763
2808
|
] }),
|
|
2764
|
-
/* @__PURE__ */ n("a", { onClick: s, style:
|
|
2809
|
+
/* @__PURE__ */ n("a", { onClick: s, style: g.link, children: S.loginLink })
|
|
2765
2810
|
] }),
|
|
2766
|
-
/* @__PURE__ */ n("div", { style:
|
|
2811
|
+
/* @__PURE__ */ n("div", { style: g.divider, children: "•" }),
|
|
2767
2812
|
/* @__PURE__ */ l("div", { children: [
|
|
2768
|
-
/* @__PURE__ */ l("span", { style:
|
|
2769
|
-
|
|
2813
|
+
/* @__PURE__ */ l("span", { style: g.divider, children: [
|
|
2814
|
+
S.signupText,
|
|
2770
2815
|
" "
|
|
2771
2816
|
] }),
|
|
2772
|
-
/* @__PURE__ */ n("a", { onClick: o, style:
|
|
2817
|
+
/* @__PURE__ */ n("a", { onClick: o, style: g.link, children: S.signupLink })
|
|
2773
2818
|
] })
|
|
2774
2819
|
] })
|
|
2775
2820
|
] });
|
|
2776
2821
|
}
|
|
2777
|
-
const
|
|
2822
|
+
const yt = {
|
|
2778
2823
|
title: "Verifying Magic Link",
|
|
2779
2824
|
verifyingMessage: "Please wait while we verify your magic link...",
|
|
2780
2825
|
successMessage: "Magic link verified successfully! You are now logged in.",
|
|
@@ -2782,7 +2827,7 @@ const ft = {
|
|
|
2782
2827
|
redirectingMessage: "Redirecting you to the dashboard...",
|
|
2783
2828
|
retryButton: "Try Again",
|
|
2784
2829
|
backToLoginButton: "Back to Login"
|
|
2785
|
-
},
|
|
2830
|
+
}, Ee = {
|
|
2786
2831
|
container: {
|
|
2787
2832
|
maxWidth: "400px",
|
|
2788
2833
|
width: "100%",
|
|
@@ -2869,7 +2914,7 @@ const ft = {
|
|
|
2869
2914
|
cursor: "pointer",
|
|
2870
2915
|
transition: "all 0.15s ease-in-out"
|
|
2871
2916
|
}
|
|
2872
|
-
},
|
|
2917
|
+
}, wt = () => /* @__PURE__ */ n("div", { style: Ee.spinner }), bt = () => /* @__PURE__ */ l(
|
|
2873
2918
|
"svg",
|
|
2874
2919
|
{
|
|
2875
2920
|
width: "48",
|
|
@@ -2886,7 +2931,7 @@ const ft = {
|
|
|
2886
2931
|
/* @__PURE__ */ n("polyline", { points: "22,4 12,14.01 9,11.01" })
|
|
2887
2932
|
]
|
|
2888
2933
|
}
|
|
2889
|
-
),
|
|
2934
|
+
), St = () => /* @__PURE__ */ l(
|
|
2890
2935
|
"svg",
|
|
2891
2936
|
{
|
|
2892
2937
|
width: "48",
|
|
@@ -2904,109 +2949,109 @@ const ft = {
|
|
|
2904
2949
|
/* @__PURE__ */ n("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
|
|
2905
2950
|
]
|
|
2906
2951
|
}
|
|
2907
|
-
),
|
|
2908
|
-
loading: /* @__PURE__ */ n(
|
|
2909
|
-
success: /* @__PURE__ */ n(
|
|
2910
|
-
error: /* @__PURE__ */ n(
|
|
2952
|
+
), vt = {
|
|
2953
|
+
loading: /* @__PURE__ */ n(wt, {}),
|
|
2954
|
+
success: /* @__PURE__ */ n(bt, {}),
|
|
2955
|
+
error: /* @__PURE__ */ n(St, {})
|
|
2911
2956
|
};
|
|
2912
|
-
function
|
|
2957
|
+
function Jt({
|
|
2913
2958
|
copy: i = {},
|
|
2914
2959
|
styles: e = {},
|
|
2915
2960
|
icons: t = {},
|
|
2916
2961
|
onSuccess: r,
|
|
2917
2962
|
onError: s,
|
|
2918
2963
|
onRetry: o,
|
|
2919
|
-
onBackToLogin:
|
|
2920
|
-
className:
|
|
2964
|
+
onBackToLogin: h,
|
|
2965
|
+
className: w,
|
|
2921
2966
|
token: k,
|
|
2922
|
-
email:
|
|
2923
|
-
appId:
|
|
2967
|
+
email: b,
|
|
2968
|
+
appId: P,
|
|
2924
2969
|
tenantSlug: m,
|
|
2925
|
-
autoRedirectDelay:
|
|
2970
|
+
autoRedirectDelay: p = 3e3
|
|
2926
2971
|
}) {
|
|
2927
|
-
const [u, y] =
|
|
2972
|
+
const [u, y] = v("verifying"), [L, R] = v(""), { verifyMagicLink: z } = ae(), M = { ...yt, ...i }, A = { ...Ee, ...e }, d = { ...vt, ...t }, C = () => {
|
|
2928
2973
|
if (typeof window > "u") return {};
|
|
2929
|
-
const
|
|
2974
|
+
const x = new URLSearchParams(window.location.search);
|
|
2930
2975
|
return {
|
|
2931
|
-
token: k ||
|
|
2932
|
-
email:
|
|
2933
|
-
appId:
|
|
2934
|
-
tenantSlug: m ||
|
|
2976
|
+
token: k || x.get("token") || "",
|
|
2977
|
+
email: b || x.get("email") || "",
|
|
2978
|
+
appId: P || x.get("appId") || "",
|
|
2979
|
+
tenantSlug: m || x.get("tenantSlug") || void 0
|
|
2935
2980
|
};
|
|
2936
|
-
},
|
|
2937
|
-
y("verifying"),
|
|
2981
|
+
}, F = async () => {
|
|
2982
|
+
y("verifying"), R("");
|
|
2938
2983
|
try {
|
|
2939
|
-
const
|
|
2940
|
-
if (!
|
|
2984
|
+
const x = C();
|
|
2985
|
+
if (!x.token || !x.email)
|
|
2941
2986
|
throw new Error("Missing required parameters: token or email");
|
|
2942
|
-
const
|
|
2943
|
-
token:
|
|
2944
|
-
email:
|
|
2945
|
-
tenantSlug:
|
|
2987
|
+
const T = await z({
|
|
2988
|
+
token: x.token,
|
|
2989
|
+
email: x.email,
|
|
2990
|
+
tenantSlug: x.tenantSlug
|
|
2946
2991
|
});
|
|
2947
|
-
y("success"), r == null || r(
|
|
2992
|
+
y("success"), r == null || r(T), p > 0 && setTimeout(() => {
|
|
2948
2993
|
y("redirecting");
|
|
2949
|
-
},
|
|
2950
|
-
} catch (
|
|
2951
|
-
const
|
|
2952
|
-
|
|
2994
|
+
}, p);
|
|
2995
|
+
} catch (x) {
|
|
2996
|
+
const T = x.message || M.errorMessage;
|
|
2997
|
+
R(T), y("error"), s == null || s(T);
|
|
2953
2998
|
}
|
|
2954
2999
|
}, G = () => {
|
|
2955
|
-
o == null || o(),
|
|
2956
|
-
},
|
|
2957
|
-
|
|
3000
|
+
o == null || o(), F();
|
|
3001
|
+
}, U = () => {
|
|
3002
|
+
h == null || h();
|
|
2958
3003
|
};
|
|
2959
3004
|
te(() => {
|
|
2960
|
-
|
|
3005
|
+
F();
|
|
2961
3006
|
}, []);
|
|
2962
3007
|
const _ = () => {
|
|
2963
3008
|
switch (u) {
|
|
2964
3009
|
case "verifying":
|
|
2965
|
-
return /* @__PURE__ */ l("div", { style:
|
|
2966
|
-
|
|
2967
|
-
|
|
3010
|
+
return /* @__PURE__ */ l("div", { style: A.message, children: [
|
|
3011
|
+
d.loading,
|
|
3012
|
+
M.verifyingMessage
|
|
2968
3013
|
] });
|
|
2969
3014
|
case "success":
|
|
2970
|
-
return /* @__PURE__ */ l(
|
|
2971
|
-
|
|
2972
|
-
/* @__PURE__ */ n("div", { style:
|
|
3015
|
+
return /* @__PURE__ */ l(q, { children: [
|
|
3016
|
+
d.success,
|
|
3017
|
+
/* @__PURE__ */ n("div", { style: A.successMessage, children: M.successMessage })
|
|
2973
3018
|
] });
|
|
2974
3019
|
case "redirecting":
|
|
2975
|
-
return /* @__PURE__ */ l(
|
|
2976
|
-
|
|
2977
|
-
/* @__PURE__ */ n("div", { style:
|
|
3020
|
+
return /* @__PURE__ */ l(q, { children: [
|
|
3021
|
+
d.loading,
|
|
3022
|
+
/* @__PURE__ */ n("div", { style: A.message, children: M.redirectingMessage })
|
|
2978
3023
|
] });
|
|
2979
3024
|
case "error":
|
|
2980
|
-
return /* @__PURE__ */ l(
|
|
2981
|
-
|
|
2982
|
-
/* @__PURE__ */ n("div", { style:
|
|
2983
|
-
/* @__PURE__ */ l("div", { style:
|
|
3025
|
+
return /* @__PURE__ */ l(q, { children: [
|
|
3026
|
+
d.error,
|
|
3027
|
+
/* @__PURE__ */ n("div", { style: A.errorMessage, children: L || M.errorMessage }),
|
|
3028
|
+
/* @__PURE__ */ l("div", { style: A.buttonContainer, children: [
|
|
2984
3029
|
/* @__PURE__ */ n(
|
|
2985
3030
|
"button",
|
|
2986
3031
|
{
|
|
2987
3032
|
onClick: G,
|
|
2988
|
-
style:
|
|
2989
|
-
onMouseOver: (
|
|
2990
|
-
|
|
3033
|
+
style: A.retryButton,
|
|
3034
|
+
onMouseOver: (x) => {
|
|
3035
|
+
x.currentTarget.style.backgroundColor = "#2563eb";
|
|
2991
3036
|
},
|
|
2992
|
-
onMouseOut: (
|
|
2993
|
-
|
|
3037
|
+
onMouseOut: (x) => {
|
|
3038
|
+
x.currentTarget.style.backgroundColor = "#3b82f6";
|
|
2994
3039
|
},
|
|
2995
|
-
children:
|
|
3040
|
+
children: M.retryButton
|
|
2996
3041
|
}
|
|
2997
3042
|
),
|
|
2998
3043
|
/* @__PURE__ */ n(
|
|
2999
3044
|
"button",
|
|
3000
3045
|
{
|
|
3001
|
-
onClick:
|
|
3002
|
-
style:
|
|
3003
|
-
onMouseOver: (
|
|
3004
|
-
|
|
3046
|
+
onClick: U,
|
|
3047
|
+
style: A.backButton,
|
|
3048
|
+
onMouseOver: (x) => {
|
|
3049
|
+
x.currentTarget.style.backgroundColor = "#e5e7eb";
|
|
3005
3050
|
},
|
|
3006
|
-
onMouseOut: (
|
|
3007
|
-
|
|
3051
|
+
onMouseOut: (x) => {
|
|
3052
|
+
x.currentTarget.style.backgroundColor = "#f3f4f6";
|
|
3008
3053
|
},
|
|
3009
|
-
children:
|
|
3054
|
+
children: M.backToLoginButton
|
|
3010
3055
|
}
|
|
3011
3056
|
)
|
|
3012
3057
|
] })
|
|
@@ -3015,18 +3060,18 @@ function Gt({
|
|
|
3015
3060
|
return null;
|
|
3016
3061
|
}
|
|
3017
3062
|
};
|
|
3018
|
-
return /* @__PURE__ */ l("div", { style:
|
|
3063
|
+
return /* @__PURE__ */ l("div", { style: A.container, className: w, children: [
|
|
3019
3064
|
/* @__PURE__ */ n("style", { children: `
|
|
3020
3065
|
@keyframes spin {
|
|
3021
3066
|
0% { transform: rotate(0deg); }
|
|
3022
3067
|
100% { transform: rotate(360deg); }
|
|
3023
3068
|
}
|
|
3024
3069
|
` }),
|
|
3025
|
-
/* @__PURE__ */ n("h1", { style:
|
|
3070
|
+
/* @__PURE__ */ n("h1", { style: A.title, children: M.title }),
|
|
3026
3071
|
_()
|
|
3027
3072
|
] });
|
|
3028
3073
|
}
|
|
3029
|
-
const
|
|
3074
|
+
const kt = {
|
|
3030
3075
|
title: "Reset Password",
|
|
3031
3076
|
subtitle: "Enter your email address and we'll send you a link to reset your password.",
|
|
3032
3077
|
emailLabel: "Email",
|
|
@@ -3048,7 +3093,7 @@ const St = {
|
|
|
3048
3093
|
resetLoadingText: "Resetting...",
|
|
3049
3094
|
resetSuccessMessage: "Password reset successfully!",
|
|
3050
3095
|
passwordMismatchError: "Passwords do not match"
|
|
3051
|
-
},
|
|
3096
|
+
}, xt = {
|
|
3052
3097
|
container: {
|
|
3053
3098
|
maxWidth: "400px",
|
|
3054
3099
|
margin: "0 auto",
|
|
@@ -3140,113 +3185,113 @@ const St = {
|
|
|
3140
3185
|
cursor: "pointer"
|
|
3141
3186
|
}
|
|
3142
3187
|
};
|
|
3143
|
-
function
|
|
3188
|
+
function Yt({
|
|
3144
3189
|
copy: i = {},
|
|
3145
3190
|
styles: e = {},
|
|
3146
3191
|
mode: t = "request",
|
|
3147
3192
|
token: r = "",
|
|
3148
3193
|
onSuccess: s,
|
|
3149
3194
|
onError: o,
|
|
3150
|
-
onBackToLogin:
|
|
3151
|
-
onModeChange:
|
|
3195
|
+
onBackToLogin: h,
|
|
3196
|
+
onModeChange: w,
|
|
3152
3197
|
className: k
|
|
3153
3198
|
}) {
|
|
3154
|
-
const [
|
|
3199
|
+
const [b, P] = v(""), [m, p] = v(r), [u, y] = v(""), [L, R] = v(""), [z, M] = v(!1), [A, d] = v(""), [C, F] = v(""), [G, U] = v({}), { requestPasswordReset: _, confirmPasswordReset: x } = ae(), { tenant: T } = se(), E = { ...kt, ...i }, c = { ...xt, ...e }, I = () => {
|
|
3155
3200
|
const H = {};
|
|
3156
|
-
return
|
|
3157
|
-
},
|
|
3201
|
+
return b.trim() || (H.email = !0), U(H), Object.keys(H).length === 0;
|
|
3202
|
+
}, S = () => {
|
|
3158
3203
|
const H = {};
|
|
3159
|
-
return m.trim() || (H.token = !0), u.trim() || (H.newPassword = !0),
|
|
3160
|
-
},
|
|
3161
|
-
if (H.preventDefault(), !!
|
|
3162
|
-
if (!(
|
|
3163
|
-
|
|
3204
|
+
return m.trim() || (H.token = !0), u.trim() || (H.newPassword = !0), L.trim() || (H.confirmPassword = !0), U(H), Object.keys(H).length === 0;
|
|
3205
|
+
}, g = async (H) => {
|
|
3206
|
+
if (H.preventDefault(), !!I()) {
|
|
3207
|
+
if (!(T != null && T.id)) {
|
|
3208
|
+
d("Tenant not found");
|
|
3164
3209
|
return;
|
|
3165
3210
|
}
|
|
3166
|
-
|
|
3211
|
+
M(!0), d(""), F("");
|
|
3167
3212
|
try {
|
|
3168
|
-
await _({ email:
|
|
3213
|
+
await _({ email: b, tenantId: T.id }), F(E.successMessage), s == null || s();
|
|
3169
3214
|
} catch (N) {
|
|
3170
|
-
const
|
|
3171
|
-
|
|
3215
|
+
const W = N.message || E.errorMessage;
|
|
3216
|
+
d(W), o == null || o(W);
|
|
3172
3217
|
} finally {
|
|
3173
|
-
|
|
3218
|
+
M(!1);
|
|
3174
3219
|
}
|
|
3175
3220
|
}
|
|
3176
|
-
},
|
|
3177
|
-
if (H.preventDefault(), !!
|
|
3178
|
-
if (u !==
|
|
3179
|
-
|
|
3221
|
+
}, a = async (H) => {
|
|
3222
|
+
if (H.preventDefault(), !!S()) {
|
|
3223
|
+
if (u !== L) {
|
|
3224
|
+
d(E.passwordMismatchError), U({ confirmPassword: !0 });
|
|
3180
3225
|
return;
|
|
3181
3226
|
}
|
|
3182
|
-
|
|
3227
|
+
M(!0), d(""), F("");
|
|
3183
3228
|
try {
|
|
3184
|
-
await
|
|
3229
|
+
await x({ token: m, newPassword: u }), F(E.resetSuccessMessage), s == null || s();
|
|
3185
3230
|
} catch (N) {
|
|
3186
|
-
const
|
|
3187
|
-
|
|
3231
|
+
const W = N.message || E.errorMessage;
|
|
3232
|
+
d(W), o == null || o(W);
|
|
3188
3233
|
} finally {
|
|
3189
|
-
|
|
3234
|
+
M(!1);
|
|
3190
3235
|
}
|
|
3191
3236
|
}
|
|
3192
|
-
},
|
|
3193
|
-
...
|
|
3194
|
-
...G[H] ?
|
|
3195
|
-
}),
|
|
3196
|
-
...
|
|
3197
|
-
...
|
|
3237
|
+
}, f = (H) => ({
|
|
3238
|
+
...c.input,
|
|
3239
|
+
...G[H] ? c.inputError : {}
|
|
3240
|
+
}), O = () => ({
|
|
3241
|
+
...c.button,
|
|
3242
|
+
...z ? c.buttonLoading : {}
|
|
3198
3243
|
});
|
|
3199
3244
|
if (t === "reset") {
|
|
3200
|
-
const H = m && u &&
|
|
3201
|
-
return /* @__PURE__ */ l("div", { className: k, style:
|
|
3202
|
-
/* @__PURE__ */ n("h2", { style:
|
|
3203
|
-
/* @__PURE__ */ n("p", { style:
|
|
3204
|
-
/* @__PURE__ */ l("form", { onSubmit:
|
|
3205
|
-
/* @__PURE__ */ l("div", { style:
|
|
3206
|
-
/* @__PURE__ */ n("label", { style:
|
|
3245
|
+
const H = m && u && L;
|
|
3246
|
+
return /* @__PURE__ */ l("div", { className: k, style: c.container, children: [
|
|
3247
|
+
/* @__PURE__ */ n("h2", { style: c.title, children: E.resetTitle }),
|
|
3248
|
+
/* @__PURE__ */ n("p", { style: c.subtitle, children: E.resetSubtitle }),
|
|
3249
|
+
/* @__PURE__ */ l("form", { onSubmit: a, style: c.form, children: [
|
|
3250
|
+
/* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
|
|
3251
|
+
/* @__PURE__ */ n("label", { style: c.label, children: E.tokenLabel }),
|
|
3207
3252
|
/* @__PURE__ */ n(
|
|
3208
3253
|
"input",
|
|
3209
3254
|
{
|
|
3210
3255
|
type: "text",
|
|
3211
3256
|
value: m,
|
|
3212
3257
|
onChange: (N) => {
|
|
3213
|
-
|
|
3258
|
+
p(N.target.value), G.token && U((W) => ({ ...W, token: !1 }));
|
|
3214
3259
|
},
|
|
3215
|
-
placeholder:
|
|
3216
|
-
style:
|
|
3217
|
-
disabled:
|
|
3260
|
+
placeholder: E.tokenPlaceholder,
|
|
3261
|
+
style: f("token"),
|
|
3262
|
+
disabled: z
|
|
3218
3263
|
}
|
|
3219
3264
|
)
|
|
3220
3265
|
] }),
|
|
3221
|
-
/* @__PURE__ */ l("div", { style:
|
|
3222
|
-
/* @__PURE__ */ n("label", { style:
|
|
3266
|
+
/* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
|
|
3267
|
+
/* @__PURE__ */ n("label", { style: c.label, children: E.newPasswordLabel }),
|
|
3223
3268
|
/* @__PURE__ */ n(
|
|
3224
3269
|
"input",
|
|
3225
3270
|
{
|
|
3226
3271
|
type: "password",
|
|
3227
3272
|
value: u,
|
|
3228
3273
|
onChange: (N) => {
|
|
3229
|
-
y(N.target.value), G.newPassword &&
|
|
3274
|
+
y(N.target.value), G.newPassword && U((W) => ({ ...W, newPassword: !1 }));
|
|
3230
3275
|
},
|
|
3231
|
-
placeholder:
|
|
3232
|
-
style:
|
|
3233
|
-
disabled:
|
|
3276
|
+
placeholder: E.newPasswordPlaceholder,
|
|
3277
|
+
style: f("newPassword"),
|
|
3278
|
+
disabled: z
|
|
3234
3279
|
}
|
|
3235
3280
|
)
|
|
3236
3281
|
] }),
|
|
3237
|
-
/* @__PURE__ */ l("div", { style:
|
|
3238
|
-
/* @__PURE__ */ n("label", { style:
|
|
3282
|
+
/* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
|
|
3283
|
+
/* @__PURE__ */ n("label", { style: c.label, children: E.confirmPasswordLabel }),
|
|
3239
3284
|
/* @__PURE__ */ n(
|
|
3240
3285
|
"input",
|
|
3241
3286
|
{
|
|
3242
3287
|
type: "password",
|
|
3243
|
-
value:
|
|
3288
|
+
value: L,
|
|
3244
3289
|
onChange: (N) => {
|
|
3245
|
-
|
|
3290
|
+
R(N.target.value), G.confirmPassword && U((W) => ({ ...W, confirmPassword: !1 })), A === E.passwordMismatchError && d("");
|
|
3246
3291
|
},
|
|
3247
|
-
placeholder:
|
|
3248
|
-
style:
|
|
3249
|
-
disabled:
|
|
3292
|
+
placeholder: E.confirmPasswordPlaceholder,
|
|
3293
|
+
style: f("confirmPassword"),
|
|
3294
|
+
disabled: z
|
|
3250
3295
|
}
|
|
3251
3296
|
)
|
|
3252
3297
|
] }),
|
|
@@ -3254,44 +3299,44 @@ function Kt({
|
|
|
3254
3299
|
"button",
|
|
3255
3300
|
{
|
|
3256
3301
|
type: "submit",
|
|
3257
|
-
disabled: !H ||
|
|
3302
|
+
disabled: !H || z,
|
|
3258
3303
|
style: {
|
|
3259
|
-
...
|
|
3260
|
-
...!H ||
|
|
3304
|
+
...O(),
|
|
3305
|
+
...!H || z ? c.buttonDisabled : {}
|
|
3261
3306
|
},
|
|
3262
|
-
children:
|
|
3307
|
+
children: z ? E.resetLoadingText : E.resetSubmitButton
|
|
3263
3308
|
}
|
|
3264
3309
|
),
|
|
3265
|
-
|
|
3266
|
-
|
|
3310
|
+
A && /* @__PURE__ */ n("div", { style: c.errorText, children: A }),
|
|
3311
|
+
C && /* @__PURE__ */ n("div", { style: c.successText, children: C })
|
|
3267
3312
|
] }),
|
|
3268
|
-
/* @__PURE__ */ l("div", { style:
|
|
3269
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
3270
|
-
|
|
3313
|
+
/* @__PURE__ */ l("div", { style: c.linkContainer, children: [
|
|
3314
|
+
/* @__PURE__ */ n("a", { onClick: h, style: c.link, children: E.backToLoginLink }),
|
|
3315
|
+
w && /* @__PURE__ */ l(q, { children: [
|
|
3271
3316
|
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3272
|
-
/* @__PURE__ */ n("a", { onClick: () =>
|
|
3317
|
+
/* @__PURE__ */ n("a", { onClick: () => w("request"), style: c.link, children: "Request New Link" })
|
|
3273
3318
|
] })
|
|
3274
3319
|
] })
|
|
3275
3320
|
] });
|
|
3276
3321
|
}
|
|
3277
|
-
const
|
|
3278
|
-
return /* @__PURE__ */ l("div", { className: k, style:
|
|
3279
|
-
/* @__PURE__ */ n("h2", { style:
|
|
3280
|
-
/* @__PURE__ */ n("p", { style:
|
|
3281
|
-
/* @__PURE__ */ l("form", { onSubmit:
|
|
3282
|
-
/* @__PURE__ */ l("div", { style:
|
|
3283
|
-
/* @__PURE__ */ n("label", { style:
|
|
3322
|
+
const K = b;
|
|
3323
|
+
return /* @__PURE__ */ l("div", { className: k, style: c.container, children: [
|
|
3324
|
+
/* @__PURE__ */ n("h2", { style: c.title, children: E.title }),
|
|
3325
|
+
/* @__PURE__ */ n("p", { style: c.subtitle, children: E.subtitle }),
|
|
3326
|
+
/* @__PURE__ */ l("form", { onSubmit: g, style: c.form, children: [
|
|
3327
|
+
/* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
|
|
3328
|
+
/* @__PURE__ */ n("label", { style: c.label, children: E.emailLabel }),
|
|
3284
3329
|
/* @__PURE__ */ n(
|
|
3285
3330
|
"input",
|
|
3286
3331
|
{
|
|
3287
3332
|
type: "email",
|
|
3288
|
-
value:
|
|
3333
|
+
value: b,
|
|
3289
3334
|
onChange: (H) => {
|
|
3290
|
-
|
|
3335
|
+
P(H.target.value), G.email && U((N) => ({ ...N, email: !1 }));
|
|
3291
3336
|
},
|
|
3292
|
-
placeholder:
|
|
3293
|
-
style:
|
|
3294
|
-
disabled:
|
|
3337
|
+
placeholder: E.emailPlaceholder,
|
|
3338
|
+
style: f("email"),
|
|
3339
|
+
disabled: z
|
|
3295
3340
|
}
|
|
3296
3341
|
)
|
|
3297
3342
|
] }),
|
|
@@ -3299,27 +3344,27 @@ function Kt({
|
|
|
3299
3344
|
"button",
|
|
3300
3345
|
{
|
|
3301
3346
|
type: "submit",
|
|
3302
|
-
disabled: !
|
|
3347
|
+
disabled: !K || z,
|
|
3303
3348
|
style: {
|
|
3304
|
-
...
|
|
3305
|
-
...!
|
|
3349
|
+
...O(),
|
|
3350
|
+
...!K || z ? c.buttonDisabled : {}
|
|
3306
3351
|
},
|
|
3307
|
-
children:
|
|
3352
|
+
children: z ? E.loadingText : E.submitButton
|
|
3308
3353
|
}
|
|
3309
3354
|
),
|
|
3310
|
-
|
|
3311
|
-
|
|
3355
|
+
A && /* @__PURE__ */ n("div", { style: c.errorText, children: A }),
|
|
3356
|
+
C && /* @__PURE__ */ n("div", { style: c.successText, children: C })
|
|
3312
3357
|
] }),
|
|
3313
|
-
/* @__PURE__ */ l("div", { style:
|
|
3314
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
3315
|
-
|
|
3358
|
+
/* @__PURE__ */ l("div", { style: c.linkContainer, children: [
|
|
3359
|
+
/* @__PURE__ */ n("a", { onClick: h, style: c.link, children: E.backToLoginLink }),
|
|
3360
|
+
w && /* @__PURE__ */ l(q, { children: [
|
|
3316
3361
|
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3317
|
-
/* @__PURE__ */ n("a", { onClick: () =>
|
|
3362
|
+
/* @__PURE__ */ n("a", { onClick: () => w("reset"), style: c.link, children: "I have a token" })
|
|
3318
3363
|
] })
|
|
3319
3364
|
] })
|
|
3320
3365
|
] });
|
|
3321
3366
|
}
|
|
3322
|
-
const
|
|
3367
|
+
const At = () => /* @__PURE__ */ n(
|
|
3323
3368
|
"div",
|
|
3324
3369
|
{
|
|
3325
3370
|
style: {
|
|
@@ -3331,7 +3376,7 @@ const xt = () => /* @__PURE__ */ n(
|
|
|
3331
3376
|
},
|
|
3332
3377
|
children: /* @__PURE__ */ n("div", { children: "Loading..." })
|
|
3333
3378
|
}
|
|
3334
|
-
),
|
|
3379
|
+
), Tt = ({ error: i, retry: e }) => /* @__PURE__ */ l(
|
|
3335
3380
|
"div",
|
|
3336
3381
|
{
|
|
3337
3382
|
style: {
|
|
@@ -3365,40 +3410,40 @@ const xt = () => /* @__PURE__ */ n(
|
|
|
3365
3410
|
]
|
|
3366
3411
|
}
|
|
3367
3412
|
);
|
|
3368
|
-
function
|
|
3413
|
+
function Qt({
|
|
3369
3414
|
children: i,
|
|
3370
3415
|
loadingFallback: e,
|
|
3371
3416
|
errorFallback: t,
|
|
3372
3417
|
requireTenant: r = !0
|
|
3373
3418
|
}) {
|
|
3374
|
-
const { isAppLoading: s, appError: o, retryApp:
|
|
3375
|
-
}),
|
|
3376
|
-
o &&
|
|
3419
|
+
const { isAppLoading: s, appError: o, retryApp: h } = oe(), w = Me(), k = (w == null ? void 0 : w.isTenantLoading) ?? !1, b = (w == null ? void 0 : w.tenantError) ?? null, P = (w == null ? void 0 : w.tenantSlug) ?? null, m = (w == null ? void 0 : w.retryTenant) ?? (() => {
|
|
3420
|
+
}), p = r && w && P, u = s || p && k, y = o || (p ? b : null), L = () => {
|
|
3421
|
+
o && h(), b && w && m();
|
|
3377
3422
|
};
|
|
3378
3423
|
if (u)
|
|
3379
|
-
return /* @__PURE__ */ n(
|
|
3424
|
+
return /* @__PURE__ */ n(q, { children: e || /* @__PURE__ */ n(At, {}) });
|
|
3380
3425
|
if (y) {
|
|
3381
|
-
const
|
|
3382
|
-
return /* @__PURE__ */ n(
|
|
3426
|
+
const R = typeof t == "function" ? t(y, L) : t || /* @__PURE__ */ n(Tt, { error: y, retry: L });
|
|
3427
|
+
return /* @__PURE__ */ n(q, { children: R });
|
|
3383
3428
|
}
|
|
3384
|
-
return /* @__PURE__ */ n(
|
|
3429
|
+
return /* @__PURE__ */ n(q, { children: i });
|
|
3385
3430
|
}
|
|
3386
|
-
function
|
|
3387
|
-
const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = oe(), o = Me(),
|
|
3388
|
-
}), m = i && o &&
|
|
3431
|
+
function Xt(i = !0) {
|
|
3432
|
+
const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = oe(), o = Me(), h = (o == null ? void 0 : o.isTenantLoading) ?? !1, w = (o == null ? void 0 : o.tenantError) ?? null, k = (o == null ? void 0 : o.tenant) ?? null, b = (o == null ? void 0 : o.tenantSlug) ?? null, P = (o == null ? void 0 : o.retryTenant) ?? (() => {
|
|
3433
|
+
}), m = i && o && b, p = e || m && h, u = t || (m ? w : null);
|
|
3389
3434
|
return {
|
|
3390
|
-
isLoading:
|
|
3435
|
+
isLoading: p,
|
|
3391
3436
|
error: u,
|
|
3392
|
-
isReady: !
|
|
3437
|
+
isReady: !p && !u && s !== null && (!m || k !== null),
|
|
3393
3438
|
retry: () => {
|
|
3394
|
-
t && r(),
|
|
3439
|
+
t && r(), w && o && P();
|
|
3395
3440
|
},
|
|
3396
3441
|
// Individual states
|
|
3397
3442
|
app: { isLoading: e, error: t, data: s },
|
|
3398
|
-
tenant: o ? { isLoading:
|
|
3443
|
+
tenant: o ? { isLoading: h, error: w, data: k } : null
|
|
3399
3444
|
};
|
|
3400
3445
|
}
|
|
3401
|
-
class
|
|
3446
|
+
class Zt {
|
|
3402
3447
|
constructor(e, t) {
|
|
3403
3448
|
this.httpService = e, this.sessionManager = t;
|
|
3404
3449
|
}
|
|
@@ -3466,7 +3511,7 @@ class Qt {
|
|
|
3466
3511
|
};
|
|
3467
3512
|
}
|
|
3468
3513
|
}
|
|
3469
|
-
class
|
|
3514
|
+
class er {
|
|
3470
3515
|
constructor(e, t) {
|
|
3471
3516
|
this.httpService = e, this.sessionManager = t;
|
|
3472
3517
|
}
|
|
@@ -3517,7 +3562,7 @@ class Xt {
|
|
|
3517
3562
|
});
|
|
3518
3563
|
}
|
|
3519
3564
|
}
|
|
3520
|
-
class
|
|
3565
|
+
class tr {
|
|
3521
3566
|
constructor(e) {
|
|
3522
3567
|
this.httpService = e;
|
|
3523
3568
|
}
|
|
@@ -3526,7 +3571,7 @@ class Zt {
|
|
|
3526
3571
|
return await this.httpService.get("/health");
|
|
3527
3572
|
}
|
|
3528
3573
|
}
|
|
3529
|
-
class
|
|
3574
|
+
class rr {
|
|
3530
3575
|
// Date string to Date object
|
|
3531
3576
|
static toDate(e) {
|
|
3532
3577
|
return new Date(e);
|
|
@@ -3649,47 +3694,47 @@ class er {
|
|
|
3649
3694
|
}
|
|
3650
3695
|
}
|
|
3651
3696
|
export {
|
|
3652
|
-
|
|
3697
|
+
rr as ApiMappers,
|
|
3653
3698
|
ve as AppApiService,
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3699
|
+
Qt as AppLoader,
|
|
3700
|
+
Ct as AppProvider,
|
|
3701
|
+
ze as AuthApiService,
|
|
3702
|
+
Nt as AuthProvider,
|
|
3703
|
+
jt as FeatureFlag,
|
|
3704
|
+
Qe as FeatureFlagApiService,
|
|
3705
|
+
Ut as FeatureFlagProvider,
|
|
3706
|
+
tr as HealthApiService,
|
|
3662
3707
|
re as HttpService,
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3708
|
+
Wt as LandingRoute,
|
|
3709
|
+
_t as LoginForm,
|
|
3710
|
+
Kt as MagicLinkForm,
|
|
3711
|
+
Jt as MagicLinkVerify,
|
|
3712
|
+
Yt as PasswordRecoveryForm,
|
|
3713
|
+
Zt as PermissionApiService,
|
|
3714
|
+
qt as Protected,
|
|
3715
|
+
zt as ProtectedRoute,
|
|
3716
|
+
ke as RoleApiService,
|
|
3672
3717
|
we as SessionManager,
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3718
|
+
Gt as SignupForm,
|
|
3719
|
+
Ze as SubscriptionApiService,
|
|
3720
|
+
Vt as SubscriptionGuard,
|
|
3721
|
+
er as SubscriptionPlanApiService,
|
|
3722
|
+
Bt as SubscriptionProvider,
|
|
3678
3723
|
ue as TenantApiService,
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3724
|
+
$t as TenantProvider,
|
|
3725
|
+
Ot as TenantRoute,
|
|
3726
|
+
Oe as UserApiService,
|
|
3682
3727
|
ie as UserType,
|
|
3683
|
-
|
|
3728
|
+
Ft as useApi,
|
|
3684
3729
|
oe as useApp,
|
|
3685
|
-
|
|
3730
|
+
Xt as useAppLoaderState,
|
|
3686
3731
|
ae as useAuth,
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3732
|
+
Xe as useFeatureFlags,
|
|
3733
|
+
Ht as useSettings,
|
|
3734
|
+
et as useSubscription,
|
|
3690
3735
|
me as useTenant,
|
|
3691
3736
|
se as useTenantInfo,
|
|
3692
3737
|
Me as useTenantOptional,
|
|
3693
|
-
|
|
3738
|
+
Dt as useTenantSettings
|
|
3694
3739
|
};
|
|
3695
3740
|
//# sourceMappingURL=index.es.js.map
|