@skylabs-digital/react-identity-access 2.16.0 → 2.17.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 +1111 -1109
- 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/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as s, Fragment as _, jsxs as
|
|
2
|
-
import { createContext as ue, useMemo as
|
|
3
|
-
import { useLocation as
|
|
4
|
-
class
|
|
1
|
+
import { jsx as s, Fragment as _, jsxs as c } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as ue, useMemo as J, useState as x, useCallback as se, useEffect as ee, useContext as oe, useRef as Ge } from "react";
|
|
3
|
+
import { useLocation as Se, Navigate as ye, useNavigate as gt, useSearchParams as pt } from "react-router-dom";
|
|
4
|
+
class ae {
|
|
5
5
|
// SessionManager instance
|
|
6
6
|
constructor(e, t = 1e4) {
|
|
7
7
|
this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
|
|
@@ -23,33 +23,33 @@ class oe {
|
|
|
23
23
|
};
|
|
24
24
|
if (!(i != null && i.skipAuth) && this.sessionManager)
|
|
25
25
|
try {
|
|
26
|
-
const
|
|
27
|
-
f = { ...f, ...
|
|
28
|
-
} catch (
|
|
29
|
-
console.warn("Failed to inject auth headers:",
|
|
26
|
+
const m = await this.sessionManager.getAuthHeaders();
|
|
27
|
+
f = { ...f, ...m };
|
|
28
|
+
} catch (m) {
|
|
29
|
+
console.warn("Failed to inject auth headers:", m);
|
|
30
30
|
}
|
|
31
|
-
const w = new AbortController(),
|
|
31
|
+
const w = new AbortController(), d = setTimeout(() => w.abort(), p);
|
|
32
32
|
try {
|
|
33
|
-
const
|
|
33
|
+
const m = await fetch(a, {
|
|
34
34
|
method: e,
|
|
35
35
|
headers: f,
|
|
36
36
|
body: n ? JSON.stringify(n) : void 0,
|
|
37
37
|
signal: w.signal
|
|
38
38
|
});
|
|
39
|
-
if (clearTimeout(
|
|
39
|
+
if (clearTimeout(d), m.status === 401 && !(i != null && i.skipRetry) && !o && this.sessionManager)
|
|
40
40
|
try {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
41
|
+
const v = this.sessionManager.getTokens();
|
|
42
|
+
if (v != null && v.refreshToken)
|
|
43
43
|
return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, n, i, !0);
|
|
44
44
|
} catch {
|
|
45
|
-
throw new Error(`HTTP ${
|
|
45
|
+
throw new Error(`HTTP ${m.status}: ${m.statusText}`);
|
|
46
46
|
}
|
|
47
|
-
if (!
|
|
48
|
-
throw new Error(`HTTP ${
|
|
49
|
-
const
|
|
50
|
-
return !
|
|
51
|
-
} catch (
|
|
52
|
-
throw clearTimeout(
|
|
47
|
+
if (!m.ok)
|
|
48
|
+
throw new Error(`HTTP ${m.status}: ${m.statusText}`);
|
|
49
|
+
const h = m.headers.get("content-type");
|
|
50
|
+
return !h || !h.includes("application/json") ? {} : await m.json();
|
|
51
|
+
} catch (m) {
|
|
52
|
+
throw clearTimeout(d), m instanceof Error && m.name === "AbortError" ? new Error(`Request timeout after ${p}ms`) : m;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
async get(e, t) {
|
|
@@ -65,7 +65,7 @@ class oe {
|
|
|
65
65
|
return this.request("DELETE", e, void 0, t);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
class
|
|
68
|
+
class qe {
|
|
69
69
|
constructor(e, t) {
|
|
70
70
|
this.httpService = e, this.sessionManager = t;
|
|
71
71
|
}
|
|
@@ -124,14 +124,14 @@ class He {
|
|
|
124
124
|
})).data;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
const
|
|
128
|
-
function
|
|
129
|
-
const t =
|
|
127
|
+
const Le = ue(null);
|
|
128
|
+
function pn({ config: r, children: e }) {
|
|
129
|
+
const t = J(
|
|
130
130
|
() => {
|
|
131
|
-
var
|
|
131
|
+
var h, v, I;
|
|
132
132
|
return {
|
|
133
|
-
enabled: ((
|
|
134
|
-
ttl: ((
|
|
133
|
+
enabled: ((h = r.cache) == null ? void 0 : h.enabled) ?? !0,
|
|
134
|
+
ttl: ((v = r.cache) == null ? void 0 : v.ttl) ?? 3e5,
|
|
135
135
|
// 5 minutes default
|
|
136
136
|
storageKey: ((I = r.cache) == null ? void 0 : I.storageKey) ?? `app_cache_${r.appId}`
|
|
137
137
|
};
|
|
@@ -140,16 +140,16 @@ function hn({ config: r, children: e }) {
|
|
|
140
140
|
), [n, i] = x(() => {
|
|
141
141
|
if (!t.enabled) return null;
|
|
142
142
|
try {
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
145
|
-
const
|
|
146
|
-
return Date.now() -
|
|
143
|
+
const h = localStorage.getItem(t.storageKey);
|
|
144
|
+
if (!h) return null;
|
|
145
|
+
const v = JSON.parse(h);
|
|
146
|
+
return Date.now() - v.timestamp < t.ttl && v.appId === r.appId ? v.data : (localStorage.removeItem(t.storageKey), null);
|
|
147
147
|
} catch {
|
|
148
148
|
return null;
|
|
149
149
|
}
|
|
150
|
-
}), [o, a] = x(!n), [p, f] = x(null), w =
|
|
151
|
-
const
|
|
152
|
-
|
|
150
|
+
}), [o, a] = x(!n), [p, f] = x(null), w = J(() => {
|
|
151
|
+
const h = () => {
|
|
152
|
+
d();
|
|
153
153
|
};
|
|
154
154
|
return {
|
|
155
155
|
appId: r.appId,
|
|
@@ -158,18 +158,18 @@ function hn({ config: r, children: e }) {
|
|
|
158
158
|
appInfo: n,
|
|
159
159
|
isAppLoading: o,
|
|
160
160
|
appError: p,
|
|
161
|
-
retryApp:
|
|
161
|
+
retryApp: h
|
|
162
162
|
};
|
|
163
|
-
}, [r, n, o, p]),
|
|
164
|
-
async (
|
|
165
|
-
if (!(!
|
|
163
|
+
}, [r, n, o, p]), d = se(
|
|
164
|
+
async (h = !1) => {
|
|
165
|
+
if (!(!h && t.enabled && n))
|
|
166
166
|
try {
|
|
167
167
|
a(!0), f(null);
|
|
168
|
-
const
|
|
169
|
-
if (i(
|
|
168
|
+
const v = new ae(r.baseUrl), F = await new qe(v, {}).getPublicAppInfo(r.appId);
|
|
169
|
+
if (i(F), t.enabled)
|
|
170
170
|
try {
|
|
171
171
|
const M = {
|
|
172
|
-
data:
|
|
172
|
+
data: F,
|
|
173
173
|
timestamp: Date.now(),
|
|
174
174
|
appId: r.appId
|
|
175
175
|
};
|
|
@@ -177,49 +177,49 @@ function hn({ config: r, children: e }) {
|
|
|
177
177
|
} catch (M) {
|
|
178
178
|
console.warn("Failed to cache app info:", M);
|
|
179
179
|
}
|
|
180
|
-
} catch (
|
|
181
|
-
const I =
|
|
180
|
+
} catch (v) {
|
|
181
|
+
const I = v instanceof Error ? v : new Error("Failed to load app information");
|
|
182
182
|
f(I), i(null);
|
|
183
183
|
} finally {
|
|
184
184
|
a(!1);
|
|
185
185
|
}
|
|
186
186
|
},
|
|
187
187
|
[r.baseUrl, r.appId, t, n]
|
|
188
|
-
),
|
|
188
|
+
), m = se(async () => {
|
|
189
189
|
if (!(!t.enabled || !n))
|
|
190
190
|
try {
|
|
191
|
-
const
|
|
192
|
-
if (!
|
|
193
|
-
const
|
|
194
|
-
if (Date.now() -
|
|
195
|
-
const
|
|
191
|
+
const h = localStorage.getItem(t.storageKey);
|
|
192
|
+
if (!h) return;
|
|
193
|
+
const v = JSON.parse(h);
|
|
194
|
+
if (Date.now() - v.timestamp > t.ttl * 0.5) {
|
|
195
|
+
const F = new ae(r.baseUrl), P = await new qe(F, {}).getPublicAppInfo(r.appId);
|
|
196
196
|
i(P);
|
|
197
|
-
const
|
|
197
|
+
const u = {
|
|
198
198
|
data: P,
|
|
199
199
|
timestamp: Date.now(),
|
|
200
200
|
appId: r.appId
|
|
201
201
|
};
|
|
202
|
-
localStorage.setItem(t.storageKey, JSON.stringify(
|
|
202
|
+
localStorage.setItem(t.storageKey, JSON.stringify(u));
|
|
203
203
|
}
|
|
204
|
-
} catch (
|
|
205
|
-
console.warn("Background app refresh failed:",
|
|
204
|
+
} catch (h) {
|
|
205
|
+
console.warn("Background app refresh failed:", h);
|
|
206
206
|
}
|
|
207
207
|
}, [r, t, n]);
|
|
208
|
-
return
|
|
209
|
-
n ?
|
|
210
|
-
}, []), /* @__PURE__ */ s(
|
|
208
|
+
return ee(() => {
|
|
209
|
+
n ? m() : d();
|
|
210
|
+
}, []), /* @__PURE__ */ s(Le.Provider, { value: w, children: e });
|
|
211
211
|
}
|
|
212
|
-
function
|
|
213
|
-
const r =
|
|
212
|
+
function we() {
|
|
213
|
+
const r = oe(Le);
|
|
214
214
|
if (!r)
|
|
215
215
|
throw new Error("useApp must be used within an AppProvider");
|
|
216
216
|
return r;
|
|
217
217
|
}
|
|
218
|
-
function
|
|
219
|
-
return
|
|
218
|
+
function Ze() {
|
|
219
|
+
return oe(Le);
|
|
220
220
|
}
|
|
221
|
-
const
|
|
222
|
-
class
|
|
221
|
+
const fn = we;
|
|
222
|
+
class Re {
|
|
223
223
|
constructor(e = {}) {
|
|
224
224
|
this.refreshPromise = null, this.refreshQueue = [], e.tenantSlug !== void 0 ? this.storageKey = e.tenantSlug ? `auth_tokens_${e.tenantSlug}` : "auth_tokens" : this.storageKey = e.storageKey || "auth_tokens", this.autoRefresh = e.autoRefresh ?? !0, this.refreshThreshold = e.refreshThreshold || 3e5, this.onRefreshFailed = e.onRefreshFailed, this.baseUrl = e.baseUrl || "", this.tokenStorage = e.tokenStorage || this.createTokenStorage(this.storageKey);
|
|
225
225
|
}
|
|
@@ -372,7 +372,7 @@ class Ae {
|
|
|
372
372
|
return e !== null && !this.isTokenExpired(e);
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
|
-
class
|
|
375
|
+
class ft {
|
|
376
376
|
constructor(e) {
|
|
377
377
|
this.httpService = e;
|
|
378
378
|
}
|
|
@@ -428,7 +428,7 @@ class gt {
|
|
|
428
428
|
});
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
|
-
class
|
|
431
|
+
class Oe {
|
|
432
432
|
constructor(e, t) {
|
|
433
433
|
this.httpService = e, this.sessionManager = t;
|
|
434
434
|
}
|
|
@@ -504,7 +504,7 @@ class Be {
|
|
|
504
504
|
};
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
|
-
class
|
|
507
|
+
class mt {
|
|
508
508
|
constructor(e, t) {
|
|
509
509
|
this.httpService = e, this.sessionManager = t;
|
|
510
510
|
}
|
|
@@ -544,7 +544,7 @@ class pt {
|
|
|
544
544
|
});
|
|
545
545
|
}
|
|
546
546
|
}
|
|
547
|
-
class
|
|
547
|
+
class me {
|
|
548
548
|
constructor(e, t, n) {
|
|
549
549
|
this.httpService = e, this.appId = t, this.sessionManager = n;
|
|
550
550
|
}
|
|
@@ -622,7 +622,7 @@ class fe {
|
|
|
622
622
|
)).data;
|
|
623
623
|
}
|
|
624
624
|
}
|
|
625
|
-
function
|
|
625
|
+
function yt(r, e) {
|
|
626
626
|
if (r === "localhost" || r.startsWith("127.") || r.startsWith("192.168."))
|
|
627
627
|
return null;
|
|
628
628
|
if (e) {
|
|
@@ -638,26 +638,26 @@ function ft(r, e) {
|
|
|
638
638
|
const n = r.split(".");
|
|
639
639
|
return n.length >= 3 && n[0] !== "www" ? n[0] : null;
|
|
640
640
|
}
|
|
641
|
-
function
|
|
641
|
+
function wt(r, e = "tenant", t) {
|
|
642
642
|
const i = new URLSearchParams(r).get(e);
|
|
643
643
|
return i ? (t && t.setItem("tenant", i), i) : t ? t.getItem("tenant") : null;
|
|
644
644
|
}
|
|
645
|
-
function
|
|
645
|
+
function bt(r, e, t) {
|
|
646
646
|
const { tenantMode: n, baseDomain: i, selectorParam: o, fixedTenantSlug: a } = r;
|
|
647
|
-
return n === "fixed" ? a || null : n === "subdomain" ?
|
|
647
|
+
return n === "fixed" ? a || null : n === "subdomain" ? yt(e.hostname, i) : n === "selector" ? wt(e.search, o, t) : null;
|
|
648
648
|
}
|
|
649
|
-
function
|
|
649
|
+
function St(r, e, t) {
|
|
650
650
|
if (t)
|
|
651
651
|
return `${r}.${t}`;
|
|
652
652
|
const n = e.split(".");
|
|
653
653
|
return n.length === 2 ? `${r}.${e}` : n.length >= 3 ? (n[0] = r, n.join(".")) : null;
|
|
654
654
|
}
|
|
655
655
|
const de = "_auth";
|
|
656
|
-
function
|
|
656
|
+
function ze(r) {
|
|
657
657
|
const e = JSON.stringify(r);
|
|
658
658
|
return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
659
659
|
}
|
|
660
|
-
function
|
|
660
|
+
function vt(r) {
|
|
661
661
|
try {
|
|
662
662
|
let e = r.replace(/-/g, "+").replace(/_/g, "/");
|
|
663
663
|
for (; e.length % 4; )
|
|
@@ -668,7 +668,7 @@ function bt(r) {
|
|
|
668
668
|
return null;
|
|
669
669
|
}
|
|
670
670
|
}
|
|
671
|
-
function
|
|
671
|
+
function Tt() {
|
|
672
672
|
if (typeof window > "u")
|
|
673
673
|
return console.log("[CrossDomainAuth] SSR environment, skipping URL token extraction"), null;
|
|
674
674
|
const e = new URLSearchParams(window.location.search).get(de);
|
|
@@ -677,7 +677,7 @@ function St() {
|
|
|
677
677
|
searchParams: window.location.search,
|
|
678
678
|
encodedLength: e == null ? void 0 : e.length
|
|
679
679
|
}), !e) return null;
|
|
680
|
-
const t =
|
|
680
|
+
const t = vt(e);
|
|
681
681
|
return console.log("[CrossDomainAuth] Token decode result:", {
|
|
682
682
|
success: !!t,
|
|
683
683
|
hasAccessToken: !!(t != null && t.accessToken),
|
|
@@ -685,7 +685,7 @@ function St() {
|
|
|
685
685
|
expiresIn: t == null ? void 0 : t.expiresIn
|
|
686
686
|
}), t;
|
|
687
687
|
}
|
|
688
|
-
function
|
|
688
|
+
function kt() {
|
|
689
689
|
if (typeof window > "u") return;
|
|
690
690
|
const r = new URL(window.location.href);
|
|
691
691
|
r.searchParams.delete(de), console.log("[CrossDomainAuth] Clearing auth tokens from URL", {
|
|
@@ -693,9 +693,9 @@ function vt() {
|
|
|
693
693
|
newUrl: r.toString()
|
|
694
694
|
}), window.history.replaceState({}, "", r.toString());
|
|
695
695
|
}
|
|
696
|
-
const
|
|
697
|
-
function
|
|
698
|
-
const { baseUrl: t, appInfo: n, appId: i } =
|
|
696
|
+
const Ee = ue(null);
|
|
697
|
+
function mn({ config: r, children: e }) {
|
|
698
|
+
const { baseUrl: t, appInfo: n, appId: i } = we(), o = se(() => typeof window > "u" ? null : bt(
|
|
699
699
|
{
|
|
700
700
|
tenantMode: r.tenantMode || "selector",
|
|
701
701
|
baseDomain: r.baseDomain,
|
|
@@ -707,119 +707,119 @@ function pn({ config: r, children: e }) {
|
|
|
707
707
|
search: window.location.search
|
|
708
708
|
},
|
|
709
709
|
window.localStorage
|
|
710
|
-
), [r.tenantMode, r.baseDomain, r.selectorParam, r.fixedTenantSlug]), [a, p] = x(() => o()), f =
|
|
710
|
+
), [r.tenantMode, r.baseDomain, r.selectorParam, r.fixedTenantSlug]), [a, p] = x(() => o()), f = J(
|
|
711
711
|
() => {
|
|
712
|
-
var
|
|
712
|
+
var g, C, T;
|
|
713
713
|
return {
|
|
714
|
-
enabled: ((
|
|
715
|
-
ttl: ((
|
|
714
|
+
enabled: ((g = r.cache) == null ? void 0 : g.enabled) ?? !0,
|
|
715
|
+
ttl: ((C = r.cache) == null ? void 0 : C.ttl) ?? 5 * 60 * 1e3,
|
|
716
716
|
// 5 minutes default
|
|
717
|
-
storageKey: ((
|
|
717
|
+
storageKey: ((T = r.cache) == null ? void 0 : T.storageKey) ?? `tenant_cache_${a || "default"}`
|
|
718
718
|
};
|
|
719
719
|
},
|
|
720
720
|
[r.cache, a]
|
|
721
|
-
), [w,
|
|
721
|
+
), [w, d] = x(() => {
|
|
722
722
|
if (r.initialTenant) return r.initialTenant;
|
|
723
723
|
if (!f.enabled || !a) return null;
|
|
724
724
|
try {
|
|
725
|
-
const
|
|
726
|
-
if (!
|
|
727
|
-
const
|
|
728
|
-
return Date.now() -
|
|
725
|
+
const g = localStorage.getItem(f.storageKey);
|
|
726
|
+
if (!g) return null;
|
|
727
|
+
const C = JSON.parse(g);
|
|
728
|
+
return Date.now() - C.timestamp < f.ttl && C.tenantSlug === a ? C.data : (localStorage.removeItem(f.storageKey), null);
|
|
729
729
|
} catch {
|
|
730
730
|
return null;
|
|
731
731
|
}
|
|
732
|
-
}), [
|
|
733
|
-
|
|
732
|
+
}), [m, h] = x(!w && !r.initialTenant), [v, I] = x(null), [F, M] = x(null), [P, u] = x(!1), [A, b] = x(null);
|
|
733
|
+
ee(() => {
|
|
734
734
|
if (r.tenantMode === "fixed") return;
|
|
735
|
-
const
|
|
736
|
-
p(
|
|
735
|
+
const g = o();
|
|
736
|
+
p(g);
|
|
737
737
|
}, [o, r.tenantMode]);
|
|
738
|
-
const L = (n == null ? void 0 : n.settingsSchema) || null, E =
|
|
739
|
-
async (
|
|
740
|
-
if (!(!
|
|
738
|
+
const L = (n == null ? void 0 : n.settingsSchema) || null, E = se(
|
|
739
|
+
async (g, C = !1) => {
|
|
740
|
+
if (!(!C && f.enabled && w && w.domain === g))
|
|
741
741
|
try {
|
|
742
|
-
|
|
743
|
-
const
|
|
744
|
-
if (
|
|
742
|
+
h(!0), I(null);
|
|
743
|
+
const T = new ae(t), y = await new me(T, i).getPublicTenantInfo(g);
|
|
744
|
+
if (d(y), f.enabled)
|
|
745
745
|
try {
|
|
746
|
-
const
|
|
747
|
-
data:
|
|
746
|
+
const k = {
|
|
747
|
+
data: y,
|
|
748
748
|
timestamp: Date.now(),
|
|
749
|
-
tenantSlug:
|
|
749
|
+
tenantSlug: g
|
|
750
750
|
};
|
|
751
|
-
localStorage.setItem(f.storageKey, JSON.stringify(
|
|
752
|
-
} catch (
|
|
753
|
-
console.warn("Failed to cache tenant info:",
|
|
751
|
+
localStorage.setItem(f.storageKey, JSON.stringify(k));
|
|
752
|
+
} catch (k) {
|
|
753
|
+
console.warn("Failed to cache tenant info:", k);
|
|
754
754
|
}
|
|
755
|
-
} catch (
|
|
756
|
-
const
|
|
757
|
-
I(
|
|
755
|
+
} catch (T) {
|
|
756
|
+
const S = T instanceof Error ? T : new Error("Failed to load tenant information");
|
|
757
|
+
I(S), d(null);
|
|
758
758
|
} finally {
|
|
759
|
-
|
|
759
|
+
h(!1);
|
|
760
760
|
}
|
|
761
761
|
},
|
|
762
762
|
[t, i, f, w]
|
|
763
|
-
),
|
|
763
|
+
), N = se(async () => {
|
|
764
764
|
if (!(!f.enabled || !w || !a))
|
|
765
765
|
try {
|
|
766
|
-
const
|
|
767
|
-
if (!
|
|
768
|
-
const
|
|
769
|
-
if (Date.now() -
|
|
770
|
-
const
|
|
771
|
-
|
|
772
|
-
const
|
|
773
|
-
data:
|
|
766
|
+
const g = localStorage.getItem(f.storageKey);
|
|
767
|
+
if (!g) return;
|
|
768
|
+
const C = JSON.parse(g);
|
|
769
|
+
if (Date.now() - C.timestamp > f.ttl * 0.5) {
|
|
770
|
+
const S = new ae(t), k = await new me(S, i).getPublicTenantInfo(a);
|
|
771
|
+
d(k);
|
|
772
|
+
const j = {
|
|
773
|
+
data: k,
|
|
774
774
|
timestamp: Date.now(),
|
|
775
775
|
tenantSlug: a
|
|
776
776
|
};
|
|
777
|
-
localStorage.setItem(f.storageKey, JSON.stringify(
|
|
777
|
+
localStorage.setItem(f.storageKey, JSON.stringify(j));
|
|
778
778
|
}
|
|
779
|
-
} catch (
|
|
780
|
-
console.warn("Background tenant refresh failed:",
|
|
779
|
+
} catch (g) {
|
|
780
|
+
console.warn("Background tenant refresh failed:", g);
|
|
781
781
|
}
|
|
782
|
-
}, [t, i, f, w, a]), R =
|
|
782
|
+
}, [t, i, f, w, a]), R = se(async () => {
|
|
783
783
|
if (w != null && w.id)
|
|
784
784
|
try {
|
|
785
|
-
|
|
786
|
-
const
|
|
787
|
-
M(
|
|
788
|
-
} catch (
|
|
789
|
-
const
|
|
790
|
-
|
|
785
|
+
u(!0), b(null);
|
|
786
|
+
const g = new ae(t), T = await new me(g, w.appId).getTenantSettings(w.id);
|
|
787
|
+
M(T);
|
|
788
|
+
} catch (g) {
|
|
789
|
+
const C = g instanceof Error ? g : new Error("Failed to load tenant settings");
|
|
790
|
+
b(C), M(null);
|
|
791
791
|
} finally {
|
|
792
|
-
|
|
792
|
+
u(!1);
|
|
793
793
|
}
|
|
794
|
-
}, [t, w]),
|
|
794
|
+
}, [t, w]), U = se(() => {
|
|
795
795
|
R();
|
|
796
|
-
}, [R]), l =
|
|
797
|
-
(
|
|
796
|
+
}, [R]), l = se(
|
|
797
|
+
(g) => {
|
|
798
798
|
if (!L)
|
|
799
799
|
return { isValid: !0, errors: [] };
|
|
800
|
-
const
|
|
800
|
+
const C = [];
|
|
801
801
|
try {
|
|
802
|
-
return L.properties && Object.entries(L.properties).forEach(([
|
|
803
|
-
var
|
|
804
|
-
const
|
|
805
|
-
if ((
|
|
806
|
-
|
|
802
|
+
return L.properties && Object.entries(L.properties).forEach(([T, S]) => {
|
|
803
|
+
var k;
|
|
804
|
+
const y = g[T];
|
|
805
|
+
if ((k = L.required) != null && k.includes(T) && y == null) {
|
|
806
|
+
C.push(`Field '${T}' is required`);
|
|
807
807
|
return;
|
|
808
808
|
}
|
|
809
|
-
if (
|
|
810
|
-
if (
|
|
811
|
-
const
|
|
812
|
-
|
|
809
|
+
if (y != null) {
|
|
810
|
+
if (S.type) {
|
|
811
|
+
const j = S.type, Z = typeof y;
|
|
812
|
+
j === "string" && Z !== "string" ? C.push(`Field '${T}' must be a string`) : (j === "number" || j === "integer") && Z !== "number" ? C.push(`Field '${T}' must be a number`) : j === "boolean" && Z !== "boolean" ? C.push(`Field '${T}' must be a boolean`) : j === "array" && !Array.isArray(y) && C.push(`Field '${T}' must be an array`);
|
|
813
813
|
}
|
|
814
|
-
|
|
815
|
-
`Field '${
|
|
816
|
-
),
|
|
817
|
-
`Field '${
|
|
818
|
-
),
|
|
814
|
+
S.minLength !== void 0 && typeof y == "string" && y.length < S.minLength && C.push(
|
|
815
|
+
`Field '${T}' must be at least ${S.minLength} characters long`
|
|
816
|
+
), S.maxLength !== void 0 && typeof y == "string" && y.length > S.maxLength && C.push(
|
|
817
|
+
`Field '${T}' must be no more than ${S.maxLength} characters long`
|
|
818
|
+
), S.minimum !== void 0 && typeof y == "number" && y < S.minimum && C.push(`Field '${T}' must be at least ${S.minimum}`), S.maximum !== void 0 && typeof y == "number" && y > S.maximum && C.push(`Field '${T}' must be no more than ${S.maximum}`), S.pattern && typeof y == "string" && (new RegExp(S.pattern).test(y) || C.push(`Field '${T}' does not match the required pattern`)), S.enum && !S.enum.includes(y) && C.push(`Field '${T}' must be one of: ${S.enum.join(", ")}`);
|
|
819
819
|
}
|
|
820
820
|
}), {
|
|
821
|
-
isValid:
|
|
822
|
-
errors:
|
|
821
|
+
isValid: C.length === 0,
|
|
822
|
+
errors: C
|
|
823
823
|
};
|
|
824
824
|
} catch {
|
|
825
825
|
return {
|
|
@@ -830,95 +830,95 @@ function pn({ config: r, children: e }) {
|
|
|
830
830
|
},
|
|
831
831
|
[L]
|
|
832
832
|
);
|
|
833
|
-
|
|
834
|
-
!r.initialTenant && a ? w ?
|
|
835
|
-
}, [r.initialTenant, a, w, E,
|
|
836
|
-
w != null && w.id ? R() : (M(null),
|
|
833
|
+
ee(() => {
|
|
834
|
+
!r.initialTenant && a ? w ? N() : E(a) : !r.initialTenant && !a && (d(null), I(null), h(!1));
|
|
835
|
+
}, [r.initialTenant, a, w, E, N]), ee(() => {
|
|
836
|
+
w != null && w.id ? R() : (M(null), b(null), u(!1));
|
|
837
837
|
}, [w == null ? void 0 : w.id, R]);
|
|
838
|
-
const D =
|
|
839
|
-
(
|
|
840
|
-
const { mode:
|
|
841
|
-
if (
|
|
838
|
+
const D = se(
|
|
839
|
+
(g, C) => {
|
|
840
|
+
const { mode: T = "reload", tokens: S, redirectPath: y } = C || {}, k = r.tenantMode || "selector";
|
|
841
|
+
if (k === "fixed") {
|
|
842
842
|
console.warn(
|
|
843
843
|
"[TenantProvider] switchTenant is a no-op in fixed mode. Tenant is always:",
|
|
844
844
|
r.fixedTenantSlug
|
|
845
|
-
),
|
|
845
|
+
), y && (window.location.href = y);
|
|
846
846
|
return;
|
|
847
847
|
}
|
|
848
|
-
if (localStorage.setItem("tenant",
|
|
849
|
-
const
|
|
850
|
-
|
|
851
|
-
|
|
848
|
+
if (localStorage.setItem("tenant", g), k === "subdomain") {
|
|
849
|
+
const j = window.location.hostname, Z = St(
|
|
850
|
+
g,
|
|
851
|
+
j,
|
|
852
852
|
r.baseDomain
|
|
853
853
|
);
|
|
854
|
-
if (!
|
|
854
|
+
if (!Z) {
|
|
855
855
|
console.warn(
|
|
856
856
|
"[TenantProvider] Cannot switch subdomain, invalid hostname:",
|
|
857
|
-
|
|
857
|
+
j
|
|
858
858
|
);
|
|
859
859
|
return;
|
|
860
860
|
}
|
|
861
|
-
const
|
|
862
|
-
new URLSearchParams(window.location.search).forEach((
|
|
863
|
-
|
|
864
|
-
}),
|
|
865
|
-
} else if (
|
|
866
|
-
const
|
|
867
|
-
if (
|
|
868
|
-
const
|
|
869
|
-
window.location.href =
|
|
861
|
+
const O = y || window.location.pathname, q = new URL(`${window.location.protocol}//${Z}${O}`);
|
|
862
|
+
new URLSearchParams(window.location.search).forEach((B, X) => {
|
|
863
|
+
X !== de && q.searchParams.set(X, B);
|
|
864
|
+
}), S && q.searchParams.set(de, ze(S)), window.location.href = q.toString();
|
|
865
|
+
} else if (k === "selector") {
|
|
866
|
+
const j = y || window.location.pathname, Z = new URLSearchParams(window.location.search);
|
|
867
|
+
if (Z.set(r.selectorParam || "tenant", g), Z.delete(de), S && Z.set(de, ze(S)), T === "reload") {
|
|
868
|
+
const O = `${j}?${Z.toString()}${window.location.hash}`;
|
|
869
|
+
window.location.href = O;
|
|
870
870
|
} else {
|
|
871
|
-
const
|
|
872
|
-
window.history.pushState({}, "",
|
|
871
|
+
const O = `${j}?${Z.toString()}${window.location.hash}`;
|
|
872
|
+
window.history.pushState({}, "", O), p(g), E(g);
|
|
873
873
|
}
|
|
874
874
|
}
|
|
875
875
|
},
|
|
876
876
|
[r.tenantMode, r.selectorParam, r.baseDomain, E]
|
|
877
|
-
),
|
|
877
|
+
), $ = J(() => ({
|
|
878
878
|
// Tenant info
|
|
879
879
|
tenant: w,
|
|
880
880
|
tenantSlug: a,
|
|
881
|
-
isTenantLoading:
|
|
882
|
-
tenantError:
|
|
881
|
+
isTenantLoading: m,
|
|
882
|
+
tenantError: v,
|
|
883
883
|
retryTenant: () => {
|
|
884
884
|
a && E(a);
|
|
885
885
|
},
|
|
886
886
|
// Settings
|
|
887
|
-
settings:
|
|
887
|
+
settings: F,
|
|
888
888
|
settingsSchema: L,
|
|
889
889
|
isSettingsLoading: P,
|
|
890
890
|
settingsError: A,
|
|
891
891
|
// Actions
|
|
892
|
-
refreshSettings:
|
|
892
|
+
refreshSettings: U,
|
|
893
893
|
switchTenant: D,
|
|
894
894
|
// Validation
|
|
895
895
|
validateSettings: l
|
|
896
896
|
}), [
|
|
897
897
|
w,
|
|
898
898
|
a,
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
899
|
+
m,
|
|
900
|
+
v,
|
|
901
|
+
F,
|
|
902
902
|
L,
|
|
903
903
|
P,
|
|
904
904
|
A,
|
|
905
|
-
|
|
905
|
+
U,
|
|
906
906
|
D,
|
|
907
907
|
l
|
|
908
908
|
]);
|
|
909
|
-
return /* @__PURE__ */ s(
|
|
909
|
+
return /* @__PURE__ */ s(Ee.Provider, { value: $, children: e });
|
|
910
910
|
}
|
|
911
911
|
function he() {
|
|
912
|
-
const r =
|
|
912
|
+
const r = oe(Ee);
|
|
913
913
|
if (!r)
|
|
914
914
|
throw new Error("useTenant must be used within a TenantProvider");
|
|
915
915
|
return r;
|
|
916
916
|
}
|
|
917
|
-
function
|
|
918
|
-
return
|
|
917
|
+
function ve() {
|
|
918
|
+
return oe(Ee);
|
|
919
919
|
}
|
|
920
|
-
const
|
|
921
|
-
function
|
|
920
|
+
const yn = he;
|
|
921
|
+
function wn() {
|
|
922
922
|
const { settings: r, settingsSchema: e, isSettingsLoading: t, settingsError: n, validateSettings: i } = he();
|
|
923
923
|
return {
|
|
924
924
|
settings: r,
|
|
@@ -938,305 +938,305 @@ function ge() {
|
|
|
938
938
|
retry: i
|
|
939
939
|
};
|
|
940
940
|
}
|
|
941
|
-
const
|
|
942
|
-
function
|
|
943
|
-
const { appId: t, baseUrl: n } =
|
|
941
|
+
const Fe = ue(null);
|
|
942
|
+
function bn({ config: r = {}, children: e }) {
|
|
943
|
+
const { appId: t, baseUrl: n } = we(), { tenant: i, tenantSlug: o, switchTenant: a } = he(), [p, f] = x(r.initialRoles || []), [w, d] = x(!r.initialRoles), [m, h] = x(null), [v, I] = x(!1), [F, M] = x(null), [P, u] = x(0), [A, b] = x(() => {
|
|
944
944
|
try {
|
|
945
|
-
const
|
|
946
|
-
return
|
|
945
|
+
const G = localStorage.getItem("userTenants");
|
|
946
|
+
return G ? JSON.parse(G) : [];
|
|
947
947
|
} catch {
|
|
948
948
|
return [];
|
|
949
949
|
}
|
|
950
|
-
}), [L, E] = x(!1),
|
|
951
|
-
|
|
950
|
+
}), [L, E] = x(!1), N = Ge({ done: !1, urlTokens: null });
|
|
951
|
+
N.current.done || (N.current.done = !0, N.current.urlTokens = Tt(), N.current.urlTokens && console.log(
|
|
952
952
|
"[AuthProvider] SYNC: URL tokens found, will block isAuthReady until user loaded"
|
|
953
953
|
));
|
|
954
|
-
const [R,
|
|
955
|
-
const
|
|
956
|
-
return console.log("[AuthProvider] SYNC: isLoadingAfterUrlTokens initial:",
|
|
957
|
-
}), l =
|
|
958
|
-
const
|
|
954
|
+
const [R, U] = x(() => {
|
|
955
|
+
const G = N.current.urlTokens !== null;
|
|
956
|
+
return console.log("[AuthProvider] SYNC: isLoadingAfterUrlTokens initial:", G), G;
|
|
957
|
+
}), l = J(() => {
|
|
958
|
+
const G = new Re({
|
|
959
959
|
tenantSlug: o,
|
|
960
960
|
onRefreshFailed: r.onRefreshFailed,
|
|
961
961
|
baseUrl: n
|
|
962
962
|
});
|
|
963
|
-
return
|
|
964
|
-
accessToken:
|
|
965
|
-
refreshToken:
|
|
966
|
-
expiresIn:
|
|
967
|
-
}), console.log("[AuthProvider] SYNC: Session valid:",
|
|
968
|
-
}, [o, n, r.onRefreshFailed]), D =
|
|
969
|
-
const
|
|
970
|
-
return
|
|
971
|
-
}, [n, l]),
|
|
972
|
-
const
|
|
963
|
+
return N.current.urlTokens && (console.log("[AuthProvider] SYNC: Saving URL tokens to session manager"), G.setTokens({
|
|
964
|
+
accessToken: N.current.urlTokens.accessToken,
|
|
965
|
+
refreshToken: N.current.urlTokens.refreshToken,
|
|
966
|
+
expiresIn: N.current.urlTokens.expiresIn
|
|
967
|
+
}), console.log("[AuthProvider] SYNC: Session valid:", G.hasValidSession())), G;
|
|
968
|
+
}, [o, n, r.onRefreshFailed]), [D, $] = x(() => N.current.urlTokens ? !1 : l.hasValidSession()), g = N.current.done && !R && !D, C = J(() => {
|
|
969
|
+
const G = new ae(n);
|
|
970
|
+
return G.setSessionManager(l), G;
|
|
971
|
+
}, [n, l]), T = J(() => new ft(new ae(n)), [n]), S = J(() => new mt(C, l), [C, l]), y = J(() => new Oe(new ae(n)), [n]), k = J(() => m || l.getUser(), [m, l]), j = J(() => k != null && k.roleId && p.find((G) => G.id === k.roleId) || null, [k, p]), Z = J(() => (j == null ? void 0 : j.permissions) || [], [j]), O = J(() => l.hasValidSession() && m !== null, [l, m]), q = 5 * 60 * 1e3, W = J(() => {
|
|
972
|
+
const G = async (H = !1) => {
|
|
973
973
|
try {
|
|
974
974
|
if (!l.hasValidSession())
|
|
975
975
|
return;
|
|
976
976
|
const z = Date.now();
|
|
977
|
-
if (!
|
|
977
|
+
if (!H && z - P < q && m)
|
|
978
978
|
return;
|
|
979
|
-
const
|
|
980
|
-
if (!
|
|
979
|
+
const V = l.getUserId();
|
|
980
|
+
if (!V) {
|
|
981
981
|
console.warn("[AuthProvider] No userId available in token or storage");
|
|
982
982
|
return;
|
|
983
983
|
}
|
|
984
984
|
I(!0), M(null);
|
|
985
|
-
const
|
|
986
|
-
|
|
985
|
+
const Y = await S.getUserById(V);
|
|
986
|
+
h(Y), l.setUser(Y), u(Date.now());
|
|
987
987
|
} catch (z) {
|
|
988
988
|
const Q = z instanceof Error ? z : new Error("Failed to load user data");
|
|
989
989
|
M(Q), console.error("[AuthProvider] Failed to load user data:", Q);
|
|
990
990
|
} finally {
|
|
991
991
|
I(!1);
|
|
992
992
|
}
|
|
993
|
-
},
|
|
994
|
-
await
|
|
995
|
-
},
|
|
996
|
-
var
|
|
997
|
-
const { username: z, password: Q, tenantSlug:
|
|
998
|
-
let
|
|
999
|
-
|
|
1000
|
-
const
|
|
993
|
+
}, pe = async () => {
|
|
994
|
+
await G();
|
|
995
|
+
}, Te = async (H) => {
|
|
996
|
+
var He;
|
|
997
|
+
const { username: z, password: Q, tenantSlug: V, redirectPath: Y } = H;
|
|
998
|
+
let te = i == null ? void 0 : i.id, ne = o, re = l;
|
|
999
|
+
V && (te = (await new me(C, t).getPublicTenantInfo(V)).id, ne = V);
|
|
1000
|
+
const K = await T.login({
|
|
1001
1001
|
username: z,
|
|
1002
1002
|
password: Q,
|
|
1003
1003
|
appId: t,
|
|
1004
|
-
tenantId:
|
|
1005
|
-
}),
|
|
1006
|
-
if (
|
|
1007
|
-
tenantSlug:
|
|
1004
|
+
tenantId: te
|
|
1005
|
+
}), fe = V && V !== o;
|
|
1006
|
+
if (fe && (re = new Re({
|
|
1007
|
+
tenantSlug: ne,
|
|
1008
1008
|
baseUrl: n
|
|
1009
|
-
})),
|
|
1010
|
-
accessToken:
|
|
1011
|
-
refreshToken:
|
|
1012
|
-
expiresIn:
|
|
1013
|
-
}),
|
|
1014
|
-
|
|
1009
|
+
})), re.setTokens({
|
|
1010
|
+
accessToken: K.accessToken,
|
|
1011
|
+
refreshToken: K.refreshToken,
|
|
1012
|
+
expiresIn: K.expiresIn
|
|
1013
|
+
}), K.user) {
|
|
1014
|
+
re.setUser(K.user), h(K.user);
|
|
1015
1015
|
try {
|
|
1016
|
-
await
|
|
1017
|
-
} catch (
|
|
1018
|
-
console.warn("Failed to load complete user data after login:",
|
|
1016
|
+
await G();
|
|
1017
|
+
} catch (be) {
|
|
1018
|
+
console.warn("Failed to load complete user data after login:", be);
|
|
1019
1019
|
}
|
|
1020
1020
|
}
|
|
1021
|
-
if (
|
|
1022
|
-
|
|
1021
|
+
if (K.tenants && K.tenants.length > 0) {
|
|
1022
|
+
b(K.tenants);
|
|
1023
1023
|
try {
|
|
1024
|
-
localStorage.setItem("userTenants", JSON.stringify(
|
|
1024
|
+
localStorage.setItem("userTenants", JSON.stringify(K.tenants));
|
|
1025
1025
|
} catch {
|
|
1026
1026
|
}
|
|
1027
1027
|
}
|
|
1028
|
-
const
|
|
1029
|
-
E(
|
|
1030
|
-
const
|
|
1031
|
-
accessToken:
|
|
1032
|
-
refreshToken:
|
|
1033
|
-
expiresIn:
|
|
1028
|
+
const Ae = ((He = K.user) == null ? void 0 : He.tenantId) !== null;
|
|
1029
|
+
E(Ae);
|
|
1030
|
+
const Pe = {
|
|
1031
|
+
accessToken: K.accessToken,
|
|
1032
|
+
refreshToken: K.refreshToken,
|
|
1033
|
+
expiresIn: K.expiresIn
|
|
1034
1034
|
};
|
|
1035
|
-
if (
|
|
1036
|
-
return a(
|
|
1037
|
-
if (
|
|
1038
|
-
return a(
|
|
1039
|
-
if (!
|
|
1040
|
-
const
|
|
1041
|
-
if (
|
|
1042
|
-
const
|
|
1043
|
-
return a(
|
|
1044
|
-
} else
|
|
1035
|
+
if (fe && ne)
|
|
1036
|
+
return a(ne, { tokens: Pe, redirectPath: Y }), K;
|
|
1037
|
+
if (Y && Y !== window.location.pathname)
|
|
1038
|
+
return a(ne || o || "", { tokens: Pe, redirectPath: Y }), K;
|
|
1039
|
+
if (!Ae && K.tenants && K.tenants.length > 0) {
|
|
1040
|
+
const be = H.autoSwitch !== !1 && r.autoSwitchSingleTenant !== !1;
|
|
1041
|
+
if (K.tenants.length === 1 && be) {
|
|
1042
|
+
const Be = K.tenants[0];
|
|
1043
|
+
return a(Be.subdomain, { tokens: Pe, redirectPath: Y }), K;
|
|
1044
|
+
} else K.tenants.length > 1 && r.onTenantSelectionRequired && r.onTenantSelectionRequired(K.tenants);
|
|
1045
1045
|
}
|
|
1046
|
-
return
|
|
1047
|
-
},
|
|
1048
|
-
const { email: z, phoneNumber: Q, name:
|
|
1046
|
+
return K;
|
|
1047
|
+
}, ke = async (H) => {
|
|
1048
|
+
const { email: z, phoneNumber: Q, name: V, password: Y, lastName: te, tenantId: ne } = H;
|
|
1049
1049
|
if (!z && !Q)
|
|
1050
1050
|
throw new Error("Either email or phoneNumber is required");
|
|
1051
|
-
if (!
|
|
1051
|
+
if (!V || !Y)
|
|
1052
1052
|
throw new Error("Name and password are required");
|
|
1053
|
-
const
|
|
1054
|
-
return await
|
|
1053
|
+
const re = ne ?? (i == null ? void 0 : i.id);
|
|
1054
|
+
return await T.signup({
|
|
1055
1055
|
email: z,
|
|
1056
1056
|
phoneNumber: Q,
|
|
1057
|
-
name:
|
|
1058
|
-
password:
|
|
1059
|
-
tenantId:
|
|
1060
|
-
lastName:
|
|
1057
|
+
name: V,
|
|
1058
|
+
password: Y,
|
|
1059
|
+
tenantId: re,
|
|
1060
|
+
lastName: te,
|
|
1061
1061
|
appId: t
|
|
1062
1062
|
});
|
|
1063
|
-
},
|
|
1064
|
-
const { email: z, phoneNumber: Q, name:
|
|
1063
|
+
}, et = async (H) => {
|
|
1064
|
+
const { email: z, phoneNumber: Q, name: V, password: Y, tenantName: te, lastName: ne } = H;
|
|
1065
1065
|
if (!z && !Q)
|
|
1066
1066
|
throw new Error("Either email or phoneNumber is required");
|
|
1067
|
-
if (!
|
|
1067
|
+
if (!V || !Y || !te)
|
|
1068
1068
|
throw new Error("Name, password, and tenantName are required");
|
|
1069
|
-
return await
|
|
1069
|
+
return await T.signupTenantAdmin({
|
|
1070
1070
|
email: z,
|
|
1071
1071
|
phoneNumber: Q,
|
|
1072
|
-
name:
|
|
1073
|
-
password:
|
|
1074
|
-
tenantName:
|
|
1072
|
+
name: V,
|
|
1073
|
+
password: Y,
|
|
1074
|
+
tenantName: te,
|
|
1075
1075
|
appId: t,
|
|
1076
|
-
lastName:
|
|
1076
|
+
lastName: ne
|
|
1077
1077
|
});
|
|
1078
|
-
},
|
|
1079
|
-
const { currentPassword: z, newPassword: Q } =
|
|
1080
|
-
await
|
|
1081
|
-
},
|
|
1082
|
-
const { email: z, tenantId: Q } =
|
|
1083
|
-
if (!
|
|
1078
|
+
}, tt = async (H) => {
|
|
1079
|
+
const { currentPassword: z, newPassword: Q } = H, V = await l.getAuthHeaders();
|
|
1080
|
+
await T.changePassword({ currentPassword: z, newPassword: Q }, V);
|
|
1081
|
+
}, nt = async (H) => {
|
|
1082
|
+
const { email: z, tenantId: Q } = H, V = Q ?? (i == null ? void 0 : i.id);
|
|
1083
|
+
if (!V)
|
|
1084
1084
|
throw new Error("tenantId is required for password reset");
|
|
1085
|
-
await
|
|
1086
|
-
},
|
|
1087
|
-
const { token: z, newPassword: Q } =
|
|
1088
|
-
await
|
|
1089
|
-
},
|
|
1090
|
-
const { email: z, frontendUrl: Q, name:
|
|
1091
|
-
if (!
|
|
1085
|
+
await T.requestPasswordReset({ email: z, tenantId: V });
|
|
1086
|
+
}, rt = async (H) => {
|
|
1087
|
+
const { token: z, newPassword: Q } = H;
|
|
1088
|
+
await T.confirmPasswordReset({ token: z, newPassword: Q });
|
|
1089
|
+
}, st = async (H) => {
|
|
1090
|
+
const { email: z, frontendUrl: Q, name: V, lastName: Y, tenantId: te } = H, ne = te ?? (i == null ? void 0 : i.id);
|
|
1091
|
+
if (!ne)
|
|
1092
1092
|
throw new Error("tenantId is required for magic link authentication");
|
|
1093
|
-
return await
|
|
1093
|
+
return await T.sendMagicLink({
|
|
1094
1094
|
email: z,
|
|
1095
|
-
tenantId:
|
|
1095
|
+
tenantId: ne,
|
|
1096
1096
|
frontendUrl: Q,
|
|
1097
|
-
name:
|
|
1098
|
-
lastName:
|
|
1097
|
+
name: V,
|
|
1098
|
+
lastName: Y,
|
|
1099
1099
|
appId: t
|
|
1100
1100
|
});
|
|
1101
|
-
},
|
|
1102
|
-
const { token: z, email: Q, tenantSlug:
|
|
1103
|
-
let
|
|
1104
|
-
|
|
1105
|
-
const
|
|
1101
|
+
}, it = async (H) => {
|
|
1102
|
+
const { token: z, email: Q, tenantSlug: V } = H;
|
|
1103
|
+
let Y = i == null ? void 0 : i.id, te = o, ne = l;
|
|
1104
|
+
V && (Y = (await new me(C, t).getPublicTenantInfo(V)).id, te = V);
|
|
1105
|
+
const re = await T.verifyMagicLink({
|
|
1106
1106
|
token: z,
|
|
1107
1107
|
email: Q,
|
|
1108
1108
|
appId: t,
|
|
1109
|
-
tenantId:
|
|
1110
|
-
}),
|
|
1111
|
-
if (
|
|
1112
|
-
tenantSlug:
|
|
1109
|
+
tenantId: Y
|
|
1110
|
+
}), K = V && V !== o;
|
|
1111
|
+
if (K && (ne = new Re({
|
|
1112
|
+
tenantSlug: te,
|
|
1113
1113
|
baseUrl: n
|
|
1114
|
-
})),
|
|
1115
|
-
accessToken:
|
|
1116
|
-
refreshToken:
|
|
1117
|
-
expiresIn:
|
|
1118
|
-
}),
|
|
1119
|
-
|
|
1114
|
+
})), ne.setTokens({
|
|
1115
|
+
accessToken: re.accessToken,
|
|
1116
|
+
refreshToken: re.refreshToken,
|
|
1117
|
+
expiresIn: re.expiresIn
|
|
1118
|
+
}), re.user) {
|
|
1119
|
+
ne.setUser(re.user), h(re.user);
|
|
1120
1120
|
try {
|
|
1121
|
-
await
|
|
1122
|
-
} catch (
|
|
1123
|
-
console.warn("Failed to load complete user data after magic link login:",
|
|
1121
|
+
await G();
|
|
1122
|
+
} catch (fe) {
|
|
1123
|
+
console.warn("Failed to load complete user data after magic link login:", fe);
|
|
1124
1124
|
}
|
|
1125
1125
|
}
|
|
1126
|
-
return
|
|
1126
|
+
return K && te && te !== o && a(te, {
|
|
1127
1127
|
tokens: {
|
|
1128
|
-
accessToken:
|
|
1129
|
-
refreshToken:
|
|
1130
|
-
expiresIn:
|
|
1128
|
+
accessToken: re.accessToken,
|
|
1129
|
+
refreshToken: re.refreshToken,
|
|
1130
|
+
expiresIn: re.expiresIn
|
|
1131
1131
|
}
|
|
1132
|
-
}),
|
|
1133
|
-
},
|
|
1134
|
-
const
|
|
1135
|
-
if (!(
|
|
1132
|
+
}), re;
|
|
1133
|
+
}, ot = async () => {
|
|
1134
|
+
const H = l.getTokens();
|
|
1135
|
+
if (!(H != null && H.refreshToken))
|
|
1136
1136
|
throw new Error("No refresh token available");
|
|
1137
|
-
const z = await
|
|
1138
|
-
refreshToken:
|
|
1137
|
+
const z = await T.refreshToken({
|
|
1138
|
+
refreshToken: H.refreshToken
|
|
1139
1139
|
});
|
|
1140
1140
|
l.setTokens({
|
|
1141
1141
|
accessToken: z.accessToken,
|
|
1142
|
-
refreshToken: z.refreshToken ||
|
|
1142
|
+
refreshToken: z.refreshToken || H.refreshToken,
|
|
1143
1143
|
expiresIn: z.expiresIn
|
|
1144
1144
|
});
|
|
1145
|
-
},
|
|
1146
|
-
l.clearSession(),
|
|
1145
|
+
}, at = () => {
|
|
1146
|
+
l.clearSession(), h(null), M(null), b([]), E(!1);
|
|
1147
1147
|
try {
|
|
1148
1148
|
localStorage.removeItem("userTenants");
|
|
1149
1149
|
} catch {
|
|
1150
1150
|
}
|
|
1151
|
-
},
|
|
1152
|
-
l.setTokens(
|
|
1153
|
-
},
|
|
1154
|
-
l.clearSession(),
|
|
1155
|
-
},
|
|
1151
|
+
}, lt = (H) => {
|
|
1152
|
+
l.setTokens(H);
|
|
1153
|
+
}, ct = () => l.hasValidSession(), dt = () => {
|
|
1154
|
+
l.clearSession(), h(null), M(null);
|
|
1155
|
+
}, ut = async () => {
|
|
1156
1156
|
if (t)
|
|
1157
1157
|
try {
|
|
1158
|
-
|
|
1159
|
-
const { roles:
|
|
1160
|
-
f(
|
|
1161
|
-
} catch (
|
|
1162
|
-
console.error("Failed to fetch roles:",
|
|
1158
|
+
d(!0);
|
|
1159
|
+
const { roles: H } = await y.getRolesByApp(t);
|
|
1160
|
+
f(H);
|
|
1161
|
+
} catch (H) {
|
|
1162
|
+
console.error("Failed to fetch roles:", H);
|
|
1163
1163
|
} finally {
|
|
1164
|
-
|
|
1164
|
+
d(!1);
|
|
1165
1165
|
}
|
|
1166
|
-
},
|
|
1167
|
-
await
|
|
1168
|
-
},
|
|
1169
|
-
if (!
|
|
1166
|
+
}, ht = async () => {
|
|
1167
|
+
await ut();
|
|
1168
|
+
}, xe = (H) => {
|
|
1169
|
+
if (!Z || Z.length === 0)
|
|
1170
1170
|
return !1;
|
|
1171
|
-
if (typeof
|
|
1172
|
-
return
|
|
1173
|
-
const z = `${
|
|
1174
|
-
return
|
|
1171
|
+
if (typeof H == "string")
|
|
1172
|
+
return Z.includes(H);
|
|
1173
|
+
const z = `${H.resource}.${H.action}`;
|
|
1174
|
+
return Z.includes(z);
|
|
1175
1175
|
};
|
|
1176
1176
|
return {
|
|
1177
1177
|
// RFC-003: Authentication state
|
|
1178
|
-
isAuthenticated:
|
|
1178
|
+
isAuthenticated: O,
|
|
1179
1179
|
sessionManager: l,
|
|
1180
|
-
authenticatedHttpService:
|
|
1181
|
-
login:
|
|
1182
|
-
signup:
|
|
1183
|
-
signupTenantAdmin:
|
|
1184
|
-
sendMagicLink:
|
|
1185
|
-
verifyMagicLink:
|
|
1186
|
-
changePassword:
|
|
1187
|
-
requestPasswordReset:
|
|
1188
|
-
confirmPasswordReset:
|
|
1189
|
-
refreshToken:
|
|
1190
|
-
logout:
|
|
1191
|
-
setTokens:
|
|
1192
|
-
hasValidSession:
|
|
1193
|
-
clearSession:
|
|
1194
|
-
currentUser:
|
|
1195
|
-
isUserLoading:
|
|
1196
|
-
userError:
|
|
1197
|
-
loadUserData:
|
|
1198
|
-
refreshUser:
|
|
1199
|
-
isAuthInitializing: !
|
|
1200
|
-
isAuthReady:
|
|
1201
|
-
userRole:
|
|
1202
|
-
userPermissions:
|
|
1180
|
+
authenticatedHttpService: C,
|
|
1181
|
+
login: Te,
|
|
1182
|
+
signup: ke,
|
|
1183
|
+
signupTenantAdmin: et,
|
|
1184
|
+
sendMagicLink: st,
|
|
1185
|
+
verifyMagicLink: it,
|
|
1186
|
+
changePassword: tt,
|
|
1187
|
+
requestPasswordReset: nt,
|
|
1188
|
+
confirmPasswordReset: rt,
|
|
1189
|
+
refreshToken: ot,
|
|
1190
|
+
logout: at,
|
|
1191
|
+
setTokens: lt,
|
|
1192
|
+
hasValidSession: ct,
|
|
1193
|
+
clearSession: dt,
|
|
1194
|
+
currentUser: m,
|
|
1195
|
+
isUserLoading: v,
|
|
1196
|
+
userError: F,
|
|
1197
|
+
loadUserData: G,
|
|
1198
|
+
refreshUser: pe,
|
|
1199
|
+
isAuthInitializing: !g,
|
|
1200
|
+
isAuthReady: g,
|
|
1201
|
+
userRole: j,
|
|
1202
|
+
userPermissions: Z,
|
|
1203
1203
|
availableRoles: p,
|
|
1204
1204
|
rolesLoading: w,
|
|
1205
|
-
hasPermission:
|
|
1206
|
-
hasAnyPermission: (
|
|
1207
|
-
hasAllPermissions: (
|
|
1208
|
-
getUserPermissionStrings: () =>
|
|
1209
|
-
refreshRoles:
|
|
1205
|
+
hasPermission: xe,
|
|
1206
|
+
hasAnyPermission: (H) => H.some((z) => xe(z)),
|
|
1207
|
+
hasAllPermissions: (H) => H.every((z) => xe(z)),
|
|
1208
|
+
getUserPermissionStrings: () => Z || [],
|
|
1209
|
+
refreshRoles: ht,
|
|
1210
1210
|
// RFC-004: Multi-tenant user membership
|
|
1211
1211
|
userTenants: A,
|
|
1212
1212
|
hasTenantContext: L,
|
|
1213
|
-
switchToTenant: async (
|
|
1214
|
-
const { redirectPath: Q } = z || {},
|
|
1215
|
-
if (!(
|
|
1213
|
+
switchToTenant: async (H, z) => {
|
|
1214
|
+
const { redirectPath: Q } = z || {}, V = l.getTokens();
|
|
1215
|
+
if (!(V != null && V.refreshToken))
|
|
1216
1216
|
throw new Error("No refresh token available for tenant switch");
|
|
1217
|
-
const
|
|
1218
|
-
refreshToken:
|
|
1219
|
-
tenantId:
|
|
1217
|
+
const Y = await T.switchTenant({
|
|
1218
|
+
refreshToken: V.refreshToken,
|
|
1219
|
+
tenantId: H
|
|
1220
1220
|
});
|
|
1221
1221
|
l.setTokens({
|
|
1222
|
-
accessToken:
|
|
1223
|
-
refreshToken:
|
|
1222
|
+
accessToken: Y.accessToken,
|
|
1223
|
+
refreshToken: V.refreshToken,
|
|
1224
1224
|
// Keep the same refresh token
|
|
1225
|
-
expiresIn:
|
|
1226
|
-
}),
|
|
1227
|
-
const
|
|
1228
|
-
|
|
1225
|
+
expiresIn: Y.expiresIn
|
|
1226
|
+
}), h(Y.user), l.setUser(Y.user), E(!0);
|
|
1227
|
+
const te = A.find((ne) => ne.id === H);
|
|
1228
|
+
te && a(te.subdomain, {
|
|
1229
1229
|
tokens: {
|
|
1230
|
-
accessToken:
|
|
1231
|
-
refreshToken:
|
|
1232
|
-
expiresIn:
|
|
1230
|
+
accessToken: Y.accessToken,
|
|
1231
|
+
refreshToken: V.refreshToken,
|
|
1232
|
+
expiresIn: Y.expiresIn
|
|
1233
1233
|
},
|
|
1234
1234
|
redirectPath: Q
|
|
1235
1235
|
});
|
|
1236
1236
|
},
|
|
1237
1237
|
refreshUserTenants: async () => {
|
|
1238
|
-
const
|
|
1239
|
-
|
|
1238
|
+
const H = await l.getAuthHeaders(), z = await T.getUserTenants(H);
|
|
1239
|
+
b(z);
|
|
1240
1240
|
try {
|
|
1241
1241
|
localStorage.setItem("userTenants", JSON.stringify(z));
|
|
1242
1242
|
} catch {
|
|
@@ -1245,74 +1245,76 @@ function yn({ config: r = {}, children: e }) {
|
|
|
1245
1245
|
}
|
|
1246
1246
|
};
|
|
1247
1247
|
}, [
|
|
1248
|
-
|
|
1248
|
+
O,
|
|
1249
1249
|
l,
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1250
|
+
C,
|
|
1251
|
+
T,
|
|
1252
|
+
S,
|
|
1253
|
+
y,
|
|
1254
1254
|
t,
|
|
1255
1255
|
i,
|
|
1256
1256
|
o,
|
|
1257
1257
|
a,
|
|
1258
1258
|
p,
|
|
1259
|
-
b,
|
|
1260
|
-
T,
|
|
1261
|
-
N,
|
|
1262
|
-
A,
|
|
1263
|
-
L,
|
|
1264
|
-
D,
|
|
1265
1259
|
m,
|
|
1266
1260
|
v,
|
|
1261
|
+
F,
|
|
1262
|
+
A,
|
|
1263
|
+
L,
|
|
1264
|
+
g,
|
|
1265
|
+
j,
|
|
1266
|
+
Z,
|
|
1267
1267
|
P,
|
|
1268
|
-
|
|
1268
|
+
q
|
|
1269
1269
|
]);
|
|
1270
|
-
|
|
1270
|
+
ee(() => {
|
|
1271
1271
|
!r.initialRoles && t && (async () => {
|
|
1272
1272
|
try {
|
|
1273
|
-
|
|
1274
|
-
const
|
|
1275
|
-
f(
|
|
1276
|
-
} catch (
|
|
1277
|
-
console.error("Failed to fetch roles:",
|
|
1273
|
+
d(!0);
|
|
1274
|
+
const pe = new ae(n), Te = new Oe(pe), { roles: ke } = await Te.getRolesByApp(t);
|
|
1275
|
+
f(ke);
|
|
1276
|
+
} catch (pe) {
|
|
1277
|
+
console.error("Failed to fetch roles:", pe);
|
|
1278
1278
|
} finally {
|
|
1279
|
-
|
|
1279
|
+
d(!1);
|
|
1280
1280
|
}
|
|
1281
1281
|
})();
|
|
1282
1282
|
}, [t, n, r.initialRoles]);
|
|
1283
|
-
const [
|
|
1284
|
-
return
|
|
1285
|
-
|
|
1286
|
-
console.error("[AuthProvider] Failed to load user data:",
|
|
1283
|
+
const [B, X] = x(!1);
|
|
1284
|
+
return ee(() => {
|
|
1285
|
+
B || (X(!0), N.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), kt(), U(!0), console.log("[AuthProvider] EFFECT: Loading user data (blocking isAuthReady)..."), W.loadUserData().catch((G) => {
|
|
1286
|
+
console.error("[AuthProvider] Failed to load user data:", G);
|
|
1287
1287
|
}).finally(() => {
|
|
1288
|
-
console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"),
|
|
1288
|
+
console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"), U(!1);
|
|
1289
1289
|
})));
|
|
1290
|
-
}, [
|
|
1291
|
-
const
|
|
1292
|
-
|
|
1293
|
-
}, [l]),
|
|
1294
|
-
|
|
1295
|
-
}))
|
|
1296
|
-
|
|
1297
|
-
|
|
1290
|
+
}, [W, B]), ee(() => {
|
|
1291
|
+
const G = l.getUser();
|
|
1292
|
+
G && l.hasValidSession() ? (h(G), $(!1)) : l.hasValidSession() || $(!1);
|
|
1293
|
+
}, [l]), ee(() => {
|
|
1294
|
+
B && (N.current.urlTokens || (!m && !v && l.hasValidSession() ? (console.log("[AuthProvider] Auto-loading user data..."), W.loadUserData().catch(() => {
|
|
1295
|
+
}).finally(() => {
|
|
1296
|
+
$(!1);
|
|
1297
|
+
})) : m && $(!1)));
|
|
1298
|
+
}, [m, v, W, l, B]), ee(() => {
|
|
1299
|
+
if (!l.hasValidSession() || !m)
|
|
1298
1300
|
return;
|
|
1299
|
-
const
|
|
1300
|
-
|
|
1301
|
+
const G = setInterval(() => {
|
|
1302
|
+
W.loadUserData().catch(() => {
|
|
1301
1303
|
});
|
|
1302
|
-
},
|
|
1303
|
-
return () => clearInterval(
|
|
1304
|
-
}, [l,
|
|
1304
|
+
}, q);
|
|
1305
|
+
return () => clearInterval(G);
|
|
1306
|
+
}, [l, m, W, q]), /* @__PURE__ */ s(Fe.Provider, { value: W, children: e });
|
|
1305
1307
|
}
|
|
1306
|
-
function
|
|
1307
|
-
const r =
|
|
1308
|
+
function ce() {
|
|
1309
|
+
const r = oe(Fe);
|
|
1308
1310
|
if (!r)
|
|
1309
1311
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
1310
1312
|
return r;
|
|
1311
1313
|
}
|
|
1312
|
-
function
|
|
1313
|
-
return
|
|
1314
|
+
function Ne() {
|
|
1315
|
+
return oe(Fe);
|
|
1314
1316
|
}
|
|
1315
|
-
class
|
|
1317
|
+
class xt {
|
|
1316
1318
|
constructor(e, t) {
|
|
1317
1319
|
this.httpService = e, this.sessionManager = t;
|
|
1318
1320
|
}
|
|
@@ -1392,66 +1394,66 @@ class Tt {
|
|
|
1392
1394
|
})).data;
|
|
1393
1395
|
}
|
|
1394
1396
|
}
|
|
1395
|
-
const
|
|
1396
|
-
function
|
|
1397
|
-
const t =
|
|
1398
|
-
const
|
|
1399
|
-
return new
|
|
1397
|
+
const De = ue(null);
|
|
1398
|
+
function Sn({ config: r = {}, children: e }) {
|
|
1399
|
+
const t = Ze(), n = ve(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (n == null ? void 0 : n.tenant) ?? null, [p, f] = x([]), [w, d] = x(!1), [m, h] = x(null), [v, I] = x(!1), F = J(() => {
|
|
1400
|
+
const u = new ae(i);
|
|
1401
|
+
return new xt(u);
|
|
1400
1402
|
}, [i]), M = async () => {
|
|
1401
1403
|
if (!(a != null && a.id)) {
|
|
1402
1404
|
f([]);
|
|
1403
1405
|
return;
|
|
1404
1406
|
}
|
|
1405
|
-
|
|
1407
|
+
d(!0), h(null);
|
|
1406
1408
|
try {
|
|
1407
|
-
const
|
|
1408
|
-
f(
|
|
1409
|
-
} catch (
|
|
1410
|
-
const A =
|
|
1411
|
-
|
|
1409
|
+
const u = await F.getTenantFeatureFlags(a.id, o);
|
|
1410
|
+
f(u);
|
|
1411
|
+
} catch (u) {
|
|
1412
|
+
const A = u instanceof Error ? u.message : "Failed to fetch feature flags";
|
|
1413
|
+
h(A), r.onError && r.onError(u instanceof Error ? u : new Error(A));
|
|
1412
1414
|
} finally {
|
|
1413
|
-
|
|
1415
|
+
d(!1);
|
|
1414
1416
|
}
|
|
1415
1417
|
};
|
|
1416
|
-
|
|
1418
|
+
ee(() => {
|
|
1417
1419
|
if (!i || !o) return;
|
|
1418
1420
|
M().finally(() => I(!0));
|
|
1419
|
-
const
|
|
1421
|
+
const u = r.refreshInterval || 5 * 60 * 1e3, A = setInterval(M, u);
|
|
1420
1422
|
return () => clearInterval(A);
|
|
1421
1423
|
}, [a == null ? void 0 : a.id, i, o, r.refreshInterval]);
|
|
1422
|
-
const P =
|
|
1423
|
-
const
|
|
1424
|
-
const R = p.find((
|
|
1424
|
+
const P = J(() => {
|
|
1425
|
+
const u = (N) => {
|
|
1426
|
+
const R = p.find((U) => U.key === N);
|
|
1425
1427
|
return (R == null ? void 0 : R.value) === !0;
|
|
1426
|
-
}, A = (
|
|
1427
|
-
const R = p.find((
|
|
1428
|
+
}, A = (N) => p.find((R) => R.key === N), b = (N) => {
|
|
1429
|
+
const R = p.find((U) => U.key === N);
|
|
1428
1430
|
return R ? R.value ? "enabled" : "disabled" : "not_found";
|
|
1429
1431
|
}, L = async () => {
|
|
1430
1432
|
await M();
|
|
1431
|
-
}, E = !!(i && o) && (
|
|
1433
|
+
}, E = !!(i && o) && (v || !(a != null && a.id));
|
|
1432
1434
|
return {
|
|
1433
1435
|
featureFlags: p,
|
|
1434
1436
|
loading: w,
|
|
1435
|
-
error:
|
|
1437
|
+
error: m,
|
|
1436
1438
|
isReady: E,
|
|
1437
|
-
isEnabled:
|
|
1439
|
+
isEnabled: u,
|
|
1438
1440
|
getFlag: A,
|
|
1439
|
-
getFlagState:
|
|
1441
|
+
getFlagState: b,
|
|
1440
1442
|
refresh: L
|
|
1441
1443
|
};
|
|
1442
|
-
}, [p, w,
|
|
1443
|
-
return /* @__PURE__ */ s(
|
|
1444
|
+
}, [p, w, m, i, o, a == null ? void 0 : a.id, v]);
|
|
1445
|
+
return /* @__PURE__ */ s(De.Provider, { value: P, children: e });
|
|
1444
1446
|
}
|
|
1445
|
-
function
|
|
1446
|
-
const r =
|
|
1447
|
+
function At() {
|
|
1448
|
+
const r = oe(De);
|
|
1447
1449
|
if (!r)
|
|
1448
1450
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1449
1451
|
return r;
|
|
1450
1452
|
}
|
|
1451
|
-
function
|
|
1452
|
-
return
|
|
1453
|
+
function Ke() {
|
|
1454
|
+
return oe(De);
|
|
1453
1455
|
}
|
|
1454
|
-
class
|
|
1456
|
+
class Pt {
|
|
1455
1457
|
constructor(e, t) {
|
|
1456
1458
|
this.httpService = e, this.sessionManager = t;
|
|
1457
1459
|
}
|
|
@@ -1517,68 +1519,68 @@ class xt {
|
|
|
1517
1519
|
)).data;
|
|
1518
1520
|
}
|
|
1519
1521
|
}
|
|
1520
|
-
const
|
|
1521
|
-
function
|
|
1522
|
-
const t =
|
|
1523
|
-
const P = new
|
|
1524
|
-
return new
|
|
1525
|
-
}, [i]),
|
|
1522
|
+
const Ce = ue(void 0);
|
|
1523
|
+
function vn({ config: r = {}, children: e }) {
|
|
1524
|
+
const t = Ze(), n = ve(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (n == null ? void 0 : n.tenant) ?? null, [a, p] = x(null), [f, w] = x(!1), [d, m] = x(null), [h, v] = x(!1), I = J(() => {
|
|
1525
|
+
const P = new ae(i);
|
|
1526
|
+
return new Pt(P);
|
|
1527
|
+
}, [i]), F = async () => {
|
|
1526
1528
|
if (!(o != null && o.id)) {
|
|
1527
1529
|
p(null);
|
|
1528
1530
|
return;
|
|
1529
1531
|
}
|
|
1530
|
-
w(!0),
|
|
1532
|
+
w(!0), m(null);
|
|
1531
1533
|
try {
|
|
1532
1534
|
const P = await I.getTenantSubscriptionFeatures(o.id);
|
|
1533
1535
|
p(P);
|
|
1534
1536
|
} catch (P) {
|
|
1535
|
-
const
|
|
1536
|
-
|
|
1537
|
+
const u = P instanceof Error ? P.message : "Failed to fetch subscription";
|
|
1538
|
+
m(u), r.onError && r.onError(P instanceof Error ? P : new Error(u));
|
|
1537
1539
|
} finally {
|
|
1538
1540
|
w(!1);
|
|
1539
1541
|
}
|
|
1540
1542
|
};
|
|
1541
|
-
|
|
1542
|
-
if (!i || (
|
|
1543
|
-
const P = r.refreshInterval || 10 * 60 * 1e3,
|
|
1544
|
-
return () => clearInterval(
|
|
1543
|
+
ee(() => {
|
|
1544
|
+
if (!i || (F().finally(() => v(!0)), !r.refreshInterval)) return;
|
|
1545
|
+
const P = r.refreshInterval || 10 * 60 * 1e3, u = setInterval(F, P);
|
|
1546
|
+
return () => clearInterval(u);
|
|
1545
1547
|
}, [o == null ? void 0 : o.id, i, r.refreshInterval]);
|
|
1546
|
-
const M =
|
|
1547
|
-
const P = (a == null ? void 0 : a.features) || [],
|
|
1548
|
-
const
|
|
1549
|
-
return
|
|
1550
|
-
}, A = (R) => P.find((
|
|
1548
|
+
const M = J(() => {
|
|
1549
|
+
const P = (a == null ? void 0 : a.features) || [], u = (R) => {
|
|
1550
|
+
const U = P.find((l) => l.key === R);
|
|
1551
|
+
return U ? U.type === "BOOLEAN" || U.type === "boolean" ? U.value === !0 : !!U.value : !1;
|
|
1552
|
+
}, A = (R) => P.find((U) => U.key === R), b = (R, U) => {
|
|
1551
1553
|
const l = P.find((D) => D.key === R);
|
|
1552
|
-
return l ? l.value :
|
|
1554
|
+
return l ? l.value : U;
|
|
1553
1555
|
}, L = (R) => !a || !a.isActive ? !1 : R.includes(a.planId), E = async () => {
|
|
1554
|
-
await
|
|
1555
|
-
},
|
|
1556
|
+
await F();
|
|
1557
|
+
}, N = !!i && (h || !(o != null && o.id));
|
|
1556
1558
|
return {
|
|
1557
1559
|
subscription: a,
|
|
1558
1560
|
features: P,
|
|
1559
1561
|
loading: f,
|
|
1560
|
-
error:
|
|
1561
|
-
isReady:
|
|
1562
|
-
isFeatureEnabled:
|
|
1562
|
+
error: d,
|
|
1563
|
+
isReady: N,
|
|
1564
|
+
isFeatureEnabled: u,
|
|
1563
1565
|
getFeature: A,
|
|
1564
|
-
getFeatureValue:
|
|
1566
|
+
getFeatureValue: b,
|
|
1565
1567
|
hasAllowedPlan: L,
|
|
1566
1568
|
refresh: E
|
|
1567
1569
|
};
|
|
1568
|
-
}, [a, f,
|
|
1569
|
-
return /* @__PURE__ */ s(
|
|
1570
|
+
}, [a, f, d, i, o == null ? void 0 : o.id, h]);
|
|
1571
|
+
return /* @__PURE__ */ s(Ce.Provider, { value: M, children: e });
|
|
1570
1572
|
}
|
|
1571
|
-
function
|
|
1572
|
-
const r =
|
|
1573
|
+
function Rt() {
|
|
1574
|
+
const r = oe(Ce);
|
|
1573
1575
|
if (r === void 0)
|
|
1574
1576
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1575
1577
|
return r;
|
|
1576
1578
|
}
|
|
1577
|
-
function
|
|
1578
|
-
return
|
|
1579
|
+
function Je() {
|
|
1580
|
+
return oe(Ce) ?? null;
|
|
1579
1581
|
}
|
|
1580
|
-
var
|
|
1581
|
-
const
|
|
1582
|
+
var ie = /* @__PURE__ */ ((r) => (r.SUPERUSER = "SUPERUSER", r.TENANT_ADMIN = "TENANT_ADMIN", r.USER = "USER", r))(ie || {});
|
|
1583
|
+
const Ue = {
|
|
1582
1584
|
publicGuest: "/",
|
|
1583
1585
|
publicUser: "/account",
|
|
1584
1586
|
publicAdmin: "/admin",
|
|
@@ -1586,7 +1588,7 @@ const De = {
|
|
|
1586
1588
|
tenantUser: "/dashboard",
|
|
1587
1589
|
tenantAdmin: "/admin/dashboard",
|
|
1588
1590
|
default: "/"
|
|
1589
|
-
},
|
|
1591
|
+
}, Ye = {
|
|
1590
1592
|
// Public/Landing zones
|
|
1591
1593
|
landing: { tenant: "forbidden", auth: "optional" },
|
|
1592
1594
|
publicOnly: { tenant: "forbidden", auth: "forbidden" },
|
|
@@ -1599,18 +1601,18 @@ const De = {
|
|
|
1599
1601
|
tenantOpen: { tenant: "required", auth: "optional" },
|
|
1600
1602
|
tenantAuth: { tenant: "required", auth: "required" },
|
|
1601
1603
|
// User type zones
|
|
1602
|
-
user: { tenant: "required", auth: "required", userType:
|
|
1603
|
-
admin: { tenant: "required", auth: "required", userType:
|
|
1604
|
+
user: { tenant: "required", auth: "required", userType: ie.USER },
|
|
1605
|
+
admin: { tenant: "required", auth: "required", userType: ie.TENANT_ADMIN },
|
|
1604
1606
|
// Fully open
|
|
1605
1607
|
open: { tenant: "optional", auth: "optional" }
|
|
1606
|
-
},
|
|
1607
|
-
function
|
|
1608
|
-
const t =
|
|
1608
|
+
}, $e = ue(null);
|
|
1609
|
+
function Tn({ config: r = {}, children: e }) {
|
|
1610
|
+
const t = J(() => {
|
|
1609
1611
|
const n = {
|
|
1610
|
-
...
|
|
1612
|
+
...Ue,
|
|
1611
1613
|
...r.zoneRoots
|
|
1612
1614
|
}, i = {
|
|
1613
|
-
...
|
|
1615
|
+
...Ye,
|
|
1614
1616
|
...r.presets
|
|
1615
1617
|
};
|
|
1616
1618
|
return {
|
|
@@ -1623,19 +1625,19 @@ function Sn({ config: r = {}, children: e }) {
|
|
|
1623
1625
|
returnToStorage: r.returnToStorage ?? "url"
|
|
1624
1626
|
};
|
|
1625
1627
|
}, [r]);
|
|
1626
|
-
return /* @__PURE__ */ s(
|
|
1628
|
+
return /* @__PURE__ */ s($e.Provider, { value: t, children: e });
|
|
1627
1629
|
}
|
|
1628
|
-
function
|
|
1629
|
-
const r =
|
|
1630
|
+
function kn() {
|
|
1631
|
+
const r = oe($e);
|
|
1630
1632
|
if (!r)
|
|
1631
1633
|
throw new Error("useRouting must be used within a RoutingProvider");
|
|
1632
1634
|
return r;
|
|
1633
1635
|
}
|
|
1634
|
-
function
|
|
1635
|
-
const r =
|
|
1636
|
+
function It() {
|
|
1637
|
+
const r = oe($e);
|
|
1636
1638
|
return r || {
|
|
1637
|
-
zoneRoots:
|
|
1638
|
-
presets:
|
|
1639
|
+
zoneRoots: Ue,
|
|
1640
|
+
presets: Ye,
|
|
1639
1641
|
loadingFallback: null,
|
|
1640
1642
|
accessDeniedFallback: null,
|
|
1641
1643
|
onAccessDenied: void 0,
|
|
@@ -1643,7 +1645,7 @@ function Pt() {
|
|
|
1643
1645
|
returnToStorage: "url"
|
|
1644
1646
|
};
|
|
1645
1647
|
}
|
|
1646
|
-
const
|
|
1648
|
+
const _e = () => /* @__PURE__ */ c(
|
|
1647
1649
|
"div",
|
|
1648
1650
|
{
|
|
1649
1651
|
style: {
|
|
@@ -1680,11 +1682,11 @@ const Oe = () => /* @__PURE__ */ d(
|
|
|
1680
1682
|
)
|
|
1681
1683
|
]
|
|
1682
1684
|
}
|
|
1683
|
-
),
|
|
1685
|
+
), We = ({
|
|
1684
1686
|
userType: r,
|
|
1685
1687
|
minUserType: e,
|
|
1686
1688
|
missingPermissions: t
|
|
1687
|
-
}) => /* @__PURE__ */
|
|
1689
|
+
}) => /* @__PURE__ */ c(
|
|
1688
1690
|
"div",
|
|
1689
1691
|
{
|
|
1690
1692
|
style: {
|
|
@@ -1702,55 +1704,55 @@ const Oe = () => /* @__PURE__ */ d(
|
|
|
1702
1704
|
children: [
|
|
1703
1705
|
/* @__PURE__ */ s("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
|
|
1704
1706
|
/* @__PURE__ */ s("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
|
|
1705
|
-
e && r ? /* @__PURE__ */
|
|
1706
|
-
/* @__PURE__ */
|
|
1707
|
+
e && r ? /* @__PURE__ */ c(_, { children: [
|
|
1708
|
+
/* @__PURE__ */ c("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
|
|
1707
1709
|
"This content requires ",
|
|
1708
1710
|
/* @__PURE__ */ s("strong", { children: e }),
|
|
1709
1711
|
" access level or higher."
|
|
1710
1712
|
] }),
|
|
1711
|
-
/* @__PURE__ */
|
|
1713
|
+
/* @__PURE__ */ c("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1712
1714
|
"Your current access level: ",
|
|
1713
1715
|
/* @__PURE__ */ s("strong", { children: r })
|
|
1714
1716
|
] })
|
|
1715
|
-
] }) : /* @__PURE__ */
|
|
1717
|
+
] }) : /* @__PURE__ */ c(_, { children: [
|
|
1716
1718
|
/* @__PURE__ */ s("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
|
|
1717
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1719
|
+
t && t.length > 0 && /* @__PURE__ */ c("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1718
1720
|
"Required permissions: ",
|
|
1719
1721
|
/* @__PURE__ */ s("strong", { children: t.join(", ") })
|
|
1720
1722
|
] })
|
|
1721
1723
|
] })
|
|
1722
1724
|
]
|
|
1723
1725
|
}
|
|
1724
|
-
),
|
|
1726
|
+
), Mt = (r, e) => {
|
|
1725
1727
|
const t = {
|
|
1726
|
-
[
|
|
1727
|
-
[
|
|
1728
|
-
[
|
|
1728
|
+
[ie.USER]: 1,
|
|
1729
|
+
[ie.TENANT_ADMIN]: 2,
|
|
1730
|
+
[ie.SUPERUSER]: 3
|
|
1729
1731
|
};
|
|
1730
1732
|
return t[r] >= t[e];
|
|
1731
1733
|
};
|
|
1732
|
-
function
|
|
1734
|
+
function xn({
|
|
1733
1735
|
children: r,
|
|
1734
1736
|
fallback: e,
|
|
1735
1737
|
minUserType: t,
|
|
1736
1738
|
requiredPermissions: n,
|
|
1737
1739
|
requireAllPermissions: i = !1
|
|
1738
1740
|
}) {
|
|
1739
|
-
const { hasValidSession: o, sessionManager: a, hasPermission: p, hasAnyPermission: f, hasAllPermissions: w } =
|
|
1741
|
+
const { hasValidSession: o, sessionManager: a, hasPermission: p, hasAnyPermission: f, hasAllPermissions: w } = ce();
|
|
1740
1742
|
if (!o())
|
|
1741
|
-
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(
|
|
1742
|
-
const
|
|
1743
|
-
if (!
|
|
1744
|
-
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(
|
|
1745
|
-
if (t && !
|
|
1746
|
-
return /* @__PURE__ */ s(
|
|
1743
|
+
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(_e, {}) });
|
|
1744
|
+
const d = a.getUser();
|
|
1745
|
+
if (!d)
|
|
1746
|
+
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(_e, {}) });
|
|
1747
|
+
if (t && !Mt(d.userType, t))
|
|
1748
|
+
return /* @__PURE__ */ s(We, { userType: d.userType, minUserType: t });
|
|
1747
1749
|
if (n && n.length > 0 && !(i ? w(n) : f(n))) {
|
|
1748
|
-
const
|
|
1749
|
-
return /* @__PURE__ */ s(
|
|
1750
|
+
const h = n.filter((v) => !p(v)).map((v) => typeof v == "string" ? v : v.name);
|
|
1751
|
+
return /* @__PURE__ */ s(We, { missingPermissions: h });
|
|
1750
1752
|
}
|
|
1751
1753
|
return /* @__PURE__ */ s(_, { children: r });
|
|
1752
1754
|
}
|
|
1753
|
-
const
|
|
1755
|
+
const Lt = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
1754
1756
|
"div",
|
|
1755
1757
|
{
|
|
1756
1758
|
style: {
|
|
@@ -1763,7 +1765,7 @@ const It = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1763
1765
|
backgroundColor: "#f9fafb",
|
|
1764
1766
|
textAlign: "center"
|
|
1765
1767
|
},
|
|
1766
|
-
children: /* @__PURE__ */
|
|
1768
|
+
children: /* @__PURE__ */ c(
|
|
1767
1769
|
"div",
|
|
1768
1770
|
{
|
|
1769
1771
|
style: {
|
|
@@ -1777,7 +1779,7 @@ const It = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1777
1779
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
|
|
1778
1780
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
|
|
1779
1781
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
|
|
1780
|
-
/* @__PURE__ */
|
|
1782
|
+
/* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1781
1783
|
"Redirecting to ",
|
|
1782
1784
|
r,
|
|
1783
1785
|
"..."
|
|
@@ -1786,7 +1788,7 @@ const It = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1786
1788
|
}
|
|
1787
1789
|
)
|
|
1788
1790
|
}
|
|
1789
|
-
),
|
|
1791
|
+
), Ve = ({
|
|
1790
1792
|
userType: r,
|
|
1791
1793
|
requiredUserType: e,
|
|
1792
1794
|
missingPermissions: t
|
|
@@ -1803,7 +1805,7 @@ const It = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1803
1805
|
backgroundColor: "#f9fafb",
|
|
1804
1806
|
textAlign: "center"
|
|
1805
1807
|
},
|
|
1806
|
-
children: /* @__PURE__ */
|
|
1808
|
+
children: /* @__PURE__ */ c(
|
|
1807
1809
|
"div",
|
|
1808
1810
|
{
|
|
1809
1811
|
style: {
|
|
@@ -1816,19 +1818,19 @@ const It = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1816
1818
|
children: [
|
|
1817
1819
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
|
|
1818
1820
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
|
|
1819
|
-
e && r ? /* @__PURE__ */
|
|
1820
|
-
/* @__PURE__ */
|
|
1821
|
+
e && r ? /* @__PURE__ */ c(_, { children: [
|
|
1822
|
+
/* @__PURE__ */ c("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
|
|
1821
1823
|
"This page requires ",
|
|
1822
1824
|
/* @__PURE__ */ s("strong", { children: e }),
|
|
1823
1825
|
" access."
|
|
1824
1826
|
] }),
|
|
1825
|
-
/* @__PURE__ */
|
|
1827
|
+
/* @__PURE__ */ c("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1826
1828
|
"Your current user type: ",
|
|
1827
1829
|
/* @__PURE__ */ s("strong", { children: r })
|
|
1828
1830
|
] })
|
|
1829
|
-
] }) : /* @__PURE__ */
|
|
1831
|
+
] }) : /* @__PURE__ */ c(_, { children: [
|
|
1830
1832
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
|
|
1831
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1833
|
+
t && t.length > 0 && /* @__PURE__ */ c("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1832
1834
|
"Required permissions: ",
|
|
1833
1835
|
/* @__PURE__ */ s("strong", { children: t.join(", ") })
|
|
1834
1836
|
] })
|
|
@@ -1837,8 +1839,8 @@ const It = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1837
1839
|
}
|
|
1838
1840
|
)
|
|
1839
1841
|
}
|
|
1840
|
-
),
|
|
1841
|
-
function
|
|
1842
|
+
), Et = (r, e) => r === e;
|
|
1843
|
+
function An({
|
|
1842
1844
|
children: r,
|
|
1843
1845
|
redirectTo: e = "/login",
|
|
1844
1846
|
requiredUserType: t,
|
|
@@ -1846,34 +1848,34 @@ function kn({
|
|
|
1846
1848
|
requireAllPermissions: i = !1,
|
|
1847
1849
|
fallback: o
|
|
1848
1850
|
}) {
|
|
1849
|
-
const { hasValidSession: a, sessionManager: p, hasPermission: f, hasAnyPermission: w, hasAllPermissions:
|
|
1850
|
-
if (
|
|
1851
|
+
const { hasValidSession: a, sessionManager: p, hasPermission: f, hasAnyPermission: w, hasAllPermissions: d } = ce(), m = Se();
|
|
1852
|
+
if (ee(() => {
|
|
1851
1853
|
process.env.NODE_ENV === "development" && console.warn(
|
|
1852
1854
|
"[react-identity-access] ProtectedRoute is deprecated. Use AuthenticatedZone or AdminZone from ZoneRoute instead."
|
|
1853
1855
|
);
|
|
1854
1856
|
}, []), !a())
|
|
1855
|
-
return o ? /* @__PURE__ */ s(_, { children: o }) : /* @__PURE__ */
|
|
1856
|
-
/* @__PURE__ */ s(
|
|
1857
|
-
/* @__PURE__ */ s(
|
|
1857
|
+
return o ? /* @__PURE__ */ s(_, { children: o }) : /* @__PURE__ */ c(_, { children: [
|
|
1858
|
+
/* @__PURE__ */ s(Lt, { redirectPath: e }),
|
|
1859
|
+
/* @__PURE__ */ s(ye, { to: e, state: { from: m.pathname }, replace: !0 })
|
|
1858
1860
|
] });
|
|
1859
|
-
const
|
|
1860
|
-
if (!
|
|
1861
|
-
return /* @__PURE__ */ s(
|
|
1862
|
-
if (t && !
|
|
1861
|
+
const h = p.getUser();
|
|
1862
|
+
if (!h)
|
|
1863
|
+
return /* @__PURE__ */ s(ye, { to: e, state: { from: m.pathname }, replace: !0 });
|
|
1864
|
+
if (t && !Et(h.userType, t))
|
|
1863
1865
|
return /* @__PURE__ */ s(
|
|
1864
|
-
|
|
1866
|
+
Ve,
|
|
1865
1867
|
{
|
|
1866
|
-
userType:
|
|
1868
|
+
userType: h.userType,
|
|
1867
1869
|
requiredUserType: t
|
|
1868
1870
|
}
|
|
1869
1871
|
);
|
|
1870
|
-
if (n && n.length > 0 && !(i ?
|
|
1871
|
-
const I = n.filter((
|
|
1872
|
-
return /* @__PURE__ */ s(
|
|
1872
|
+
if (n && n.length > 0 && !(i ? d(n) : w(n))) {
|
|
1873
|
+
const I = n.filter((F) => !f(F)).map((F) => typeof F == "string" ? F : F.name);
|
|
1874
|
+
return /* @__PURE__ */ s(Ve, { missingPermissions: I });
|
|
1873
1875
|
}
|
|
1874
1876
|
return /* @__PURE__ */ s(_, { children: r });
|
|
1875
1877
|
}
|
|
1876
|
-
const
|
|
1878
|
+
const Ft = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
1877
1879
|
"div",
|
|
1878
1880
|
{
|
|
1879
1881
|
style: {
|
|
@@ -1886,7 +1888,7 @@ const Lt = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1886
1888
|
backgroundColor: "#f9fafb",
|
|
1887
1889
|
textAlign: "center"
|
|
1888
1890
|
},
|
|
1889
|
-
children: /* @__PURE__ */
|
|
1891
|
+
children: /* @__PURE__ */ c(
|
|
1890
1892
|
"div",
|
|
1891
1893
|
{
|
|
1892
1894
|
style: {
|
|
@@ -1900,7 +1902,7 @@ const Lt = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1900
1902
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
|
|
1901
1903
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
|
|
1902
1904
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
|
|
1903
|
-
/* @__PURE__ */
|
|
1905
|
+
/* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1904
1906
|
"Redirecting to ",
|
|
1905
1907
|
r,
|
|
1906
1908
|
"..."
|
|
@@ -1910,18 +1912,18 @@ const Lt = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1910
1912
|
)
|
|
1911
1913
|
}
|
|
1912
1914
|
);
|
|
1913
|
-
function
|
|
1914
|
-
const { tenant: n, isLoading: i, error: o } = ge(), a =
|
|
1915
|
-
return
|
|
1915
|
+
function Pn({ children: r, redirectTo: e = "/", fallback: t }) {
|
|
1916
|
+
const { tenant: n, isLoading: i, error: o } = ge(), a = Se();
|
|
1917
|
+
return ee(() => {
|
|
1916
1918
|
process.env.NODE_ENV === "development" && console.warn(
|
|
1917
1919
|
"[react-identity-access] TenantRoute is deprecated. Use TenantZone from ZoneRoute instead."
|
|
1918
1920
|
);
|
|
1919
|
-
}, []), i || o ? null : n ? /* @__PURE__ */ s(_, { children: r }) : t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */
|
|
1920
|
-
/* @__PURE__ */ s(
|
|
1921
|
-
/* @__PURE__ */ s(
|
|
1921
|
+
}, []), i || o ? null : n ? /* @__PURE__ */ s(_, { children: r }) : t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ c(_, { children: [
|
|
1922
|
+
/* @__PURE__ */ s(Ft, { redirectPath: e }),
|
|
1923
|
+
/* @__PURE__ */ s(ye, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
1922
1924
|
] });
|
|
1923
1925
|
}
|
|
1924
|
-
const
|
|
1926
|
+
const Nt = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
1925
1927
|
"div",
|
|
1926
1928
|
{
|
|
1927
1929
|
style: {
|
|
@@ -1934,7 +1936,7 @@ const Et = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1934
1936
|
backgroundColor: "#f9fafb",
|
|
1935
1937
|
textAlign: "center"
|
|
1936
1938
|
},
|
|
1937
|
-
children: /* @__PURE__ */
|
|
1939
|
+
children: /* @__PURE__ */ c(
|
|
1938
1940
|
"div",
|
|
1939
1941
|
{
|
|
1940
1942
|
style: {
|
|
@@ -1948,7 +1950,7 @@ const Et = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1948
1950
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
|
|
1949
1951
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
|
|
1950
1952
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
|
|
1951
|
-
/* @__PURE__ */
|
|
1953
|
+
/* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1952
1954
|
"Redirecting to ",
|
|
1953
1955
|
r,
|
|
1954
1956
|
"..."
|
|
@@ -1958,41 +1960,41 @@ const Et = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1958
1960
|
)
|
|
1959
1961
|
}
|
|
1960
1962
|
);
|
|
1961
|
-
function
|
|
1962
|
-
const { tenant: n, isLoading: i, error: o } = ge(), a =
|
|
1963
|
-
return
|
|
1963
|
+
function Rn({ children: r, redirectTo: e = "/dashboard", fallback: t }) {
|
|
1964
|
+
const { tenant: n, isLoading: i, error: o } = ge(), a = Se();
|
|
1965
|
+
return ee(() => {
|
|
1964
1966
|
process.env.NODE_ENV === "development" && console.warn(
|
|
1965
1967
|
"[react-identity-access] LandingRoute is deprecated. Use PublicZone from ZoneRoute instead."
|
|
1966
1968
|
);
|
|
1967
|
-
}, []), i || o ? null : n ? t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */
|
|
1968
|
-
/* @__PURE__ */ s(
|
|
1969
|
-
/* @__PURE__ */ s(
|
|
1969
|
+
}, []), i || o ? null : n ? t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ c(_, { children: [
|
|
1970
|
+
/* @__PURE__ */ s(Nt, { redirectPath: e }),
|
|
1971
|
+
/* @__PURE__ */ s(ye, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
1970
1972
|
] }) : /* @__PURE__ */ s(_, { children: r });
|
|
1971
1973
|
}
|
|
1972
|
-
function
|
|
1974
|
+
function Dt(r, e) {
|
|
1973
1975
|
return e ? r ? Array.isArray(e) ? e.includes(r) : r === e : !1 : !0;
|
|
1974
1976
|
}
|
|
1975
|
-
function
|
|
1977
|
+
function je(r, e) {
|
|
1976
1978
|
return !r || r === "optional" ? "skip" : r === "required" ? e ? "pass" : "fail" : r === "forbidden" ? e ? "fail" : "pass" : "skip";
|
|
1977
1979
|
}
|
|
1978
|
-
function
|
|
1979
|
-
return
|
|
1980
|
+
function Ct(r, e) {
|
|
1981
|
+
return je(r.tenant, e.hasTenant) === "fail" ? e.hasTenant ? "has_tenant" : "no_tenant" : je(r.auth, e.isAuthenticated) === "fail" ? e.isAuthenticated ? "already_authenticated" : "not_authenticated" : r.userType && e.isAuthenticated && !Dt(e.userType, r.userType) ? "wrong_user_type" : r.permissions && r.permissions.length > 0 && !(r.requireAllPermissions !== !1 ? (o) => o.every((a) => e.permissions.includes(a)) : (o) => o.some((a) => e.permissions.includes(a)))(r.permissions) ? "missing_permissions" : null;
|
|
1980
1982
|
}
|
|
1981
|
-
function
|
|
1982
|
-
return r.hasTenant ? r.isAuthenticated ? r.userType ===
|
|
1983
|
+
function Ut(r, e) {
|
|
1984
|
+
return r.hasTenant ? r.isAuthenticated ? r.userType === ie.TENANT_ADMIN ? e.tenantAdmin : e.tenantUser : e.tenantGuest : r.isAuthenticated ? r.userType === ie.TENANT_ADMIN ? e.publicAdmin : e.publicUser : e.publicGuest;
|
|
1983
1985
|
}
|
|
1984
|
-
function
|
|
1986
|
+
function $t(r, e, t, n, i) {
|
|
1985
1987
|
if (!e || i !== "url")
|
|
1986
1988
|
return r;
|
|
1987
1989
|
const o = typeof e == "string" ? e : t, a = r.includes("?") ? "&" : "?";
|
|
1988
1990
|
return `${r}${a}${n}=${encodeURIComponent(o)}`;
|
|
1989
1991
|
}
|
|
1990
|
-
function
|
|
1992
|
+
function Ht(r, e, t) {
|
|
1991
1993
|
if (!r || t === "url") return;
|
|
1992
1994
|
const n = typeof r == "string" ? r : e, i = "zone_return_to";
|
|
1993
1995
|
t === "session" ? sessionStorage.setItem(i, n) : t === "local" && localStorage.setItem(i, n);
|
|
1994
1996
|
}
|
|
1995
|
-
const
|
|
1997
|
+
const le = ({
|
|
1996
1998
|
children: r,
|
|
1997
1999
|
preset: e,
|
|
1998
2000
|
tenant: t,
|
|
@@ -2003,39 +2005,39 @@ const ae = ({
|
|
|
2003
2005
|
returnTo: p,
|
|
2004
2006
|
onAccessDenied: f,
|
|
2005
2007
|
redirectTo: w,
|
|
2006
|
-
loadingFallback:
|
|
2007
|
-
accessDeniedFallback:
|
|
2008
|
+
loadingFallback: d,
|
|
2009
|
+
accessDeniedFallback: m
|
|
2008
2010
|
}) => {
|
|
2009
|
-
const
|
|
2011
|
+
const h = Se(), { isAuthenticated: v, isAuthInitializing: I, currentUser: F, userPermissions: M } = ce(), { tenant: P, isTenantLoading: u } = he(), A = It(), b = J(() => {
|
|
2010
2012
|
if (e)
|
|
2011
2013
|
return A.presets[e];
|
|
2012
|
-
}, [e, A.presets]), L =
|
|
2014
|
+
}, [e, A.presets]), L = J(
|
|
2013
2015
|
() => ({
|
|
2014
|
-
tenant: t ?? (
|
|
2015
|
-
auth: n ?? (
|
|
2016
|
-
userType: i ?? (
|
|
2017
|
-
permissions: o ?? (
|
|
2016
|
+
tenant: t ?? (b == null ? void 0 : b.tenant),
|
|
2017
|
+
auth: n ?? (b == null ? void 0 : b.auth),
|
|
2018
|
+
userType: i ?? (b == null ? void 0 : b.userType),
|
|
2019
|
+
permissions: o ?? (b == null ? void 0 : b.requiredPermissions),
|
|
2018
2020
|
requireAllPermissions: a
|
|
2019
2021
|
}),
|
|
2020
|
-
[t, n, i, o,
|
|
2021
|
-
), E =
|
|
2022
|
+
[t, n, i, o, b, a]
|
|
2023
|
+
), E = J(
|
|
2022
2024
|
() => ({
|
|
2023
2025
|
hasTenant: !!P,
|
|
2024
|
-
isAuthenticated:
|
|
2025
|
-
userType:
|
|
2026
|
+
isAuthenticated: v,
|
|
2027
|
+
userType: F == null ? void 0 : F.userType,
|
|
2026
2028
|
permissions: M,
|
|
2027
|
-
isLoading: I ||
|
|
2029
|
+
isLoading: I || u
|
|
2028
2030
|
}),
|
|
2029
2031
|
[
|
|
2030
2032
|
P,
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
+
v,
|
|
2034
|
+
F == null ? void 0 : F.userType,
|
|
2033
2035
|
M,
|
|
2034
2036
|
I,
|
|
2035
|
-
|
|
2037
|
+
u
|
|
2036
2038
|
]
|
|
2037
|
-
),
|
|
2038
|
-
type:
|
|
2039
|
+
), N = J(() => E.isLoading ? null : Ct(L, E), [L, E]), R = J(() => N ? w || Ut(E, A.zoneRoots) : null, [N, w, E, A.zoneRoots]), U = J(() => !N || !R ? null : {
|
|
2040
|
+
type: N,
|
|
2039
2041
|
required: {
|
|
2040
2042
|
tenant: L.tenant,
|
|
2041
2043
|
auth: L.auth,
|
|
@@ -2049,34 +2051,34 @@ const ae = ({
|
|
|
2049
2051
|
permissions: E.permissions
|
|
2050
2052
|
},
|
|
2051
2053
|
redirectTo: R
|
|
2052
|
-
}, [
|
|
2053
|
-
if (
|
|
2054
|
-
|
|
2055
|
-
}, [
|
|
2056
|
-
|
|
2054
|
+
}, [N, R, L, E]);
|
|
2055
|
+
if (ee(() => {
|
|
2056
|
+
U && (f ? f(U) : A.onAccessDenied && A.onAccessDenied(U));
|
|
2057
|
+
}, [U, f, A]), ee(() => {
|
|
2058
|
+
U && p && Ht(p, h.pathname + h.search, A.returnToStorage);
|
|
2057
2059
|
}, [
|
|
2058
|
-
|
|
2060
|
+
U,
|
|
2059
2061
|
p,
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
+
h.pathname,
|
|
2063
|
+
h.search,
|
|
2062
2064
|
A.returnToStorage
|
|
2063
2065
|
]), E.isLoading)
|
|
2064
|
-
return /* @__PURE__ */ s(_, { children:
|
|
2065
|
-
if (
|
|
2066
|
-
const l =
|
|
2066
|
+
return /* @__PURE__ */ s(_, { children: d ?? A.loadingFallback ?? null });
|
|
2067
|
+
if (U && R) {
|
|
2068
|
+
const l = m ?? A.accessDeniedFallback;
|
|
2067
2069
|
if (l)
|
|
2068
2070
|
return /* @__PURE__ */ s(_, { children: l });
|
|
2069
|
-
const D =
|
|
2071
|
+
const D = $t(
|
|
2070
2072
|
R,
|
|
2071
2073
|
p,
|
|
2072
|
-
|
|
2074
|
+
h.pathname + h.search,
|
|
2073
2075
|
A.returnToParam,
|
|
2074
2076
|
A.returnToStorage
|
|
2075
2077
|
);
|
|
2076
|
-
return /* @__PURE__ */ s(
|
|
2078
|
+
return /* @__PURE__ */ s(ye, { to: D, replace: !0 });
|
|
2077
2079
|
}
|
|
2078
2080
|
return /* @__PURE__ */ s(_, { children: r });
|
|
2079
|
-
},
|
|
2081
|
+
}, In = (r) => /* @__PURE__ */ s(le, { tenant: "required", ...r }), Mn = (r) => /* @__PURE__ */ s(le, { tenant: "forbidden", ...r }), Ln = (r) => /* @__PURE__ */ s(le, { auth: "required", ...r }), En = (r) => /* @__PURE__ */ s(le, { auth: "forbidden", ...r }), Fn = (r) => /* @__PURE__ */ s(le, { auth: "required", userType: ie.TENANT_ADMIN, ...r }), Nn = (r) => /* @__PURE__ */ s(le, { auth: "required", userType: ie.USER, ...r }), Dn = (r) => /* @__PURE__ */ s(le, { tenant: "optional", auth: "optional", ...r }), Cn = (r) => /* @__PURE__ */ s(le, { tenant: "required", auth: "required", ...r }), Un = (r) => /* @__PURE__ */ s(le, { tenant: "required", auth: "optional", ...r }), $n = (r) => /* @__PURE__ */ s(le, { tenant: "required", auth: "forbidden", ...r }), Bt = () => /* @__PURE__ */ c(
|
|
2080
2082
|
"div",
|
|
2081
2083
|
{
|
|
2082
2084
|
style: {
|
|
@@ -2093,13 +2095,13 @@ const ae = ({
|
|
|
2093
2095
|
]
|
|
2094
2096
|
}
|
|
2095
2097
|
);
|
|
2096
|
-
function
|
|
2098
|
+
function Hn({
|
|
2097
2099
|
children: r,
|
|
2098
|
-
fallback: e = /* @__PURE__ */ s(
|
|
2100
|
+
fallback: e = /* @__PURE__ */ s(Bt, {}),
|
|
2099
2101
|
allowedPlans: t,
|
|
2100
2102
|
requiredFeature: n
|
|
2101
2103
|
}) {
|
|
2102
|
-
const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: p } =
|
|
2104
|
+
const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: p } = Rt();
|
|
2103
2105
|
return p ? /* @__PURE__ */ s(
|
|
2104
2106
|
"div",
|
|
2105
2107
|
{
|
|
@@ -2112,7 +2114,7 @@ function Un({
|
|
|
2112
2114
|
}
|
|
2113
2115
|
) : i ? i.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ s(_, { children: e }) : n && !a(n) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: r }) : /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: e });
|
|
2114
2116
|
}
|
|
2115
|
-
const
|
|
2117
|
+
const qt = ({ flagName: r }) => /* @__PURE__ */ c(
|
|
2116
2118
|
"div",
|
|
2117
2119
|
{
|
|
2118
2120
|
style: {
|
|
@@ -2131,7 +2133,7 @@ const Ht = ({ flagName: r }) => /* @__PURE__ */ d(
|
|
|
2131
2133
|
children: [
|
|
2132
2134
|
/* @__PURE__ */ s("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
|
|
2133
2135
|
/* @__PURE__ */ s("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
|
|
2134
|
-
/* @__PURE__ */
|
|
2136
|
+
/* @__PURE__ */ c("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
|
|
2135
2137
|
'Feature flag "',
|
|
2136
2138
|
r,
|
|
2137
2139
|
'" is disabled'
|
|
@@ -2139,8 +2141,8 @@ const Ht = ({ flagName: r }) => /* @__PURE__ */ d(
|
|
|
2139
2141
|
]
|
|
2140
2142
|
}
|
|
2141
2143
|
);
|
|
2142
|
-
function
|
|
2143
|
-
const { isEnabled: n, loading: i } =
|
|
2144
|
+
function Bn({ name: r, children: e, fallback: t }) {
|
|
2145
|
+
const { isEnabled: n, loading: i } = At();
|
|
2144
2146
|
return i ? /* @__PURE__ */ s(
|
|
2145
2147
|
"div",
|
|
2146
2148
|
{
|
|
@@ -2154,9 +2156,9 @@ function $n({ name: r, children: e, fallback: t }) {
|
|
|
2154
2156
|
},
|
|
2155
2157
|
children: "Loading feature flags..."
|
|
2156
2158
|
}
|
|
2157
|
-
) : n(r) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: t || /* @__PURE__ */ s(
|
|
2159
|
+
) : n(r) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: t || /* @__PURE__ */ s(qt, { flagName: r }) });
|
|
2158
2160
|
}
|
|
2159
|
-
const
|
|
2161
|
+
const Ot = () => /* @__PURE__ */ c(
|
|
2160
2162
|
"svg",
|
|
2161
2163
|
{
|
|
2162
2164
|
width: "16",
|
|
@@ -2173,7 +2175,7 @@ const Bt = () => /* @__PURE__ */ d(
|
|
|
2173
2175
|
/* @__PURE__ */ s("circle", { cx: "12", cy: "12", r: "3" })
|
|
2174
2176
|
]
|
|
2175
2177
|
}
|
|
2176
|
-
),
|
|
2178
|
+
), zt = () => /* @__PURE__ */ c(
|
|
2177
2179
|
"svg",
|
|
2178
2180
|
{
|
|
2179
2181
|
width: "16",
|
|
@@ -2190,10 +2192,10 @@ const Bt = () => /* @__PURE__ */ d(
|
|
|
2190
2192
|
/* @__PURE__ */ s("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
2191
2193
|
]
|
|
2192
2194
|
}
|
|
2193
|
-
),
|
|
2194
|
-
showPassword: /* @__PURE__ */ s(
|
|
2195
|
-
hidePassword: /* @__PURE__ */ s(
|
|
2196
|
-
},
|
|
2195
|
+
), _t = {
|
|
2196
|
+
showPassword: /* @__PURE__ */ s(Ot, {}),
|
|
2197
|
+
hidePassword: /* @__PURE__ */ s(zt, {})
|
|
2198
|
+
}, Wt = {
|
|
2197
2199
|
title: "Sign In",
|
|
2198
2200
|
usernameLabel: "Email or Phone",
|
|
2199
2201
|
usernamePlaceholder: "Enter your email or phone number",
|
|
@@ -2207,7 +2209,7 @@ const Bt = () => /* @__PURE__ */ d(
|
|
|
2207
2209
|
magicLinkLink: "Use Magic Link",
|
|
2208
2210
|
errorMessage: "Invalid credentials",
|
|
2209
2211
|
loadingText: "Signing in..."
|
|
2210
|
-
},
|
|
2212
|
+
}, Vt = {
|
|
2211
2213
|
container: {
|
|
2212
2214
|
maxWidth: "400px",
|
|
2213
2215
|
width: "100%",
|
|
@@ -2314,7 +2316,7 @@ const Bt = () => /* @__PURE__ */ d(
|
|
|
2314
2316
|
fontSize: "0.875rem"
|
|
2315
2317
|
}
|
|
2316
2318
|
};
|
|
2317
|
-
function
|
|
2319
|
+
function qn({
|
|
2318
2320
|
copy: r = {},
|
|
2319
2321
|
styles: e = {},
|
|
2320
2322
|
icons: t = {},
|
|
@@ -2325,45 +2327,45 @@ function Hn({
|
|
|
2325
2327
|
onMagicLinkClick: p,
|
|
2326
2328
|
showForgotPassword: f = !0,
|
|
2327
2329
|
showSignupLink: w = !0,
|
|
2328
|
-
showMagicLinkOption:
|
|
2329
|
-
className:
|
|
2330
|
+
showMagicLinkOption: d = !0,
|
|
2331
|
+
className: m
|
|
2330
2332
|
}) {
|
|
2331
|
-
const [
|
|
2332
|
-
const
|
|
2333
|
-
return
|
|
2334
|
-
},
|
|
2335
|
-
if (
|
|
2336
|
-
if (!(
|
|
2333
|
+
const [h, v] = x(""), [I, F] = x(""), [M, P] = x(!1), [u, A] = x(!1), [b, L] = x(""), [E, N] = x({}), { login: R } = ce(), { tenant: U } = ge(), l = { ...Wt, ...r }, D = { ...Vt, ...e }, $ = { ..._t, ...t }, g = () => {
|
|
2334
|
+
const y = {};
|
|
2335
|
+
return h.trim() || (y.username = !0), I.trim() || (y.password = !0), N(y), Object.keys(y).length === 0;
|
|
2336
|
+
}, C = async (y) => {
|
|
2337
|
+
if (y.preventDefault(), !!g()) {
|
|
2338
|
+
if (!(U != null && U.id)) {
|
|
2337
2339
|
L("Tenant not found");
|
|
2338
2340
|
return;
|
|
2339
2341
|
}
|
|
2340
2342
|
A(!0), L("");
|
|
2341
2343
|
try {
|
|
2342
|
-
const
|
|
2343
|
-
username:
|
|
2344
|
+
const k = await R({
|
|
2345
|
+
username: h,
|
|
2344
2346
|
password: I
|
|
2345
2347
|
// tenantId inferred from context automatically
|
|
2346
2348
|
});
|
|
2347
|
-
n == null || n(
|
|
2348
|
-
} catch (
|
|
2349
|
-
const
|
|
2350
|
-
L(
|
|
2349
|
+
n == null || n(k);
|
|
2350
|
+
} catch (k) {
|
|
2351
|
+
const j = k.message || l.errorMessage;
|
|
2352
|
+
L(j), i == null || i(j);
|
|
2351
2353
|
} finally {
|
|
2352
2354
|
A(!1);
|
|
2353
2355
|
}
|
|
2354
2356
|
}
|
|
2355
|
-
},
|
|
2357
|
+
}, T = (y) => ({
|
|
2356
2358
|
...D.input,
|
|
2357
|
-
...E[
|
|
2358
|
-
}),
|
|
2359
|
+
...E[y] ? D.inputError : {}
|
|
2360
|
+
}), S = () => ({
|
|
2359
2361
|
...D.button,
|
|
2360
|
-
...
|
|
2361
|
-
...!
|
|
2362
|
+
...u ? D.buttonLoading : {},
|
|
2363
|
+
...!h || !I || u ? D.buttonDisabled : {}
|
|
2362
2364
|
});
|
|
2363
|
-
return /* @__PURE__ */
|
|
2365
|
+
return /* @__PURE__ */ c("div", { className: m, style: D.container, children: [
|
|
2364
2366
|
/* @__PURE__ */ s("h2", { style: D.title, children: l.title }),
|
|
2365
|
-
/* @__PURE__ */
|
|
2366
|
-
/* @__PURE__ */
|
|
2367
|
+
/* @__PURE__ */ c("form", { onSubmit: C, style: D.form, children: [
|
|
2368
|
+
/* @__PURE__ */ c("div", { style: D.fieldGroup, children: [
|
|
2367
2369
|
/* @__PURE__ */ s("label", { style: D.label, children: l.usernameLabel }),
|
|
2368
2370
|
/* @__PURE__ */ s(
|
|
2369
2371
|
"input",
|
|
@@ -2371,19 +2373,19 @@ function Hn({
|
|
|
2371
2373
|
id: "username",
|
|
2372
2374
|
name: "username",
|
|
2373
2375
|
type: "text",
|
|
2374
|
-
value:
|
|
2375
|
-
onChange: (
|
|
2376
|
-
|
|
2376
|
+
value: h,
|
|
2377
|
+
onChange: (y) => {
|
|
2378
|
+
v(y.target.value), E.username && N((k) => ({ ...k, username: !1 }));
|
|
2377
2379
|
},
|
|
2378
2380
|
placeholder: l.usernamePlaceholder,
|
|
2379
|
-
style:
|
|
2380
|
-
disabled:
|
|
2381
|
+
style: T("username"),
|
|
2382
|
+
disabled: u
|
|
2381
2383
|
}
|
|
2382
2384
|
)
|
|
2383
2385
|
] }),
|
|
2384
|
-
/* @__PURE__ */
|
|
2386
|
+
/* @__PURE__ */ c("div", { style: D.fieldGroup, children: [
|
|
2385
2387
|
/* @__PURE__ */ s("label", { style: D.label, children: l.passwordLabel }),
|
|
2386
|
-
/* @__PURE__ */
|
|
2388
|
+
/* @__PURE__ */ c("div", { style: D.inputContainer, children: [
|
|
2387
2389
|
/* @__PURE__ */ s(
|
|
2388
2390
|
"input",
|
|
2389
2391
|
{
|
|
@@ -2391,16 +2393,16 @@ function Hn({
|
|
|
2391
2393
|
name: "password",
|
|
2392
2394
|
type: M ? "text" : "password",
|
|
2393
2395
|
value: I,
|
|
2394
|
-
onChange: (
|
|
2395
|
-
|
|
2396
|
+
onChange: (y) => {
|
|
2397
|
+
F(y.target.value), E.password && N((k) => ({ ...k, password: !1 }));
|
|
2396
2398
|
},
|
|
2397
2399
|
placeholder: l.passwordPlaceholder,
|
|
2398
2400
|
style: {
|
|
2399
|
-
...
|
|
2401
|
+
...T("password"),
|
|
2400
2402
|
paddingRight: "2.5rem"
|
|
2401
2403
|
// Make room for the icon
|
|
2402
2404
|
},
|
|
2403
|
-
disabled:
|
|
2405
|
+
disabled: u
|
|
2404
2406
|
}
|
|
2405
2407
|
),
|
|
2406
2408
|
/* @__PURE__ */ s(
|
|
@@ -2409,29 +2411,29 @@ function Hn({
|
|
|
2409
2411
|
type: "button",
|
|
2410
2412
|
onClick: () => P(!M),
|
|
2411
2413
|
style: D.passwordToggle,
|
|
2412
|
-
disabled:
|
|
2414
|
+
disabled: u,
|
|
2413
2415
|
"aria-label": M ? "Hide password" : "Show password",
|
|
2414
|
-
children: M ?
|
|
2416
|
+
children: M ? $.hidePassword : $.showPassword
|
|
2415
2417
|
}
|
|
2416
2418
|
)
|
|
2417
2419
|
] })
|
|
2418
2420
|
] }),
|
|
2419
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: !
|
|
2420
|
-
|
|
2421
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !h || !I || u, style: S(), children: u ? l.loadingText : l.submitButton }),
|
|
2422
|
+
b && /* @__PURE__ */ s("div", { style: D.errorText, children: b })
|
|
2421
2423
|
] }),
|
|
2422
|
-
(f || w ||
|
|
2423
|
-
|
|
2424
|
-
/* @__PURE__ */
|
|
2424
|
+
(f || w || d) && /* @__PURE__ */ c("div", { style: D.linkContainer, children: [
|
|
2425
|
+
d && /* @__PURE__ */ c("div", { children: [
|
|
2426
|
+
/* @__PURE__ */ c("span", { style: D.divider, children: [
|
|
2425
2427
|
l.magicLinkText,
|
|
2426
2428
|
" "
|
|
2427
2429
|
] }),
|
|
2428
2430
|
/* @__PURE__ */ s("a", { onClick: p, style: D.link, children: l.magicLinkLink })
|
|
2429
2431
|
] }),
|
|
2430
|
-
|
|
2432
|
+
d && (f || w) && /* @__PURE__ */ s("div", { style: D.divider, children: "•" }),
|
|
2431
2433
|
f && /* @__PURE__ */ s("a", { onClick: o, style: D.link, children: l.forgotPasswordLink }),
|
|
2432
2434
|
f && w && /* @__PURE__ */ s("div", { style: D.divider, children: "•" }),
|
|
2433
|
-
w && /* @__PURE__ */
|
|
2434
|
-
/* @__PURE__ */
|
|
2435
|
+
w && /* @__PURE__ */ c("div", { children: [
|
|
2436
|
+
/* @__PURE__ */ c("span", { style: D.divider, children: [
|
|
2435
2437
|
l.signupText,
|
|
2436
2438
|
" "
|
|
2437
2439
|
] }),
|
|
@@ -2440,7 +2442,7 @@ function Hn({
|
|
|
2440
2442
|
] })
|
|
2441
2443
|
] });
|
|
2442
2444
|
}
|
|
2443
|
-
const
|
|
2445
|
+
const jt = {
|
|
2444
2446
|
title: "Create Account",
|
|
2445
2447
|
nameLabel: "First Name",
|
|
2446
2448
|
namePlaceholder: "Enter your first name",
|
|
@@ -2466,7 +2468,7 @@ const Wt = {
|
|
|
2466
2468
|
passwordMismatchError: "Passwords do not match",
|
|
2467
2469
|
isAdminLabel: "Create new organization",
|
|
2468
2470
|
isAdminDescription: "Check this if you want to create a new organization"
|
|
2469
|
-
},
|
|
2471
|
+
}, Gt = {
|
|
2470
2472
|
container: {
|
|
2471
2473
|
maxWidth: "400px",
|
|
2472
2474
|
width: "100%",
|
|
@@ -2565,7 +2567,7 @@ const Wt = {
|
|
|
2565
2567
|
fontSize: "0.875rem"
|
|
2566
2568
|
}
|
|
2567
2569
|
};
|
|
2568
|
-
function
|
|
2570
|
+
function On({
|
|
2569
2571
|
copy: r = {},
|
|
2570
2572
|
styles: e = {},
|
|
2571
2573
|
signupType: t = "user",
|
|
@@ -2577,91 +2579,91 @@ function Bn({
|
|
|
2577
2579
|
showMagicLinkOption: f = !0,
|
|
2578
2580
|
className: w
|
|
2579
2581
|
}) {
|
|
2580
|
-
const [
|
|
2581
|
-
const
|
|
2582
|
-
return
|
|
2583
|
-
},
|
|
2584
|
-
if (
|
|
2585
|
-
if (
|
|
2586
|
-
D(
|
|
2582
|
+
const [d, m] = x(""), [h, v] = x(""), [I, F] = x(""), [M, P] = x(""), [u, A] = x(""), [b, L] = x(""), [E, N] = x(""), [R, U] = x(!1), [l, D] = x(""), [$, g] = x({}), { signup: C, signupTenantAdmin: T } = ce(), { tenant: S } = ge(), y = { ...jt, ...r }, k = { ...Gt, ...e }, j = () => {
|
|
2583
|
+
const B = {};
|
|
2584
|
+
return d.trim() || (B.name = !0), !I.trim() && !M.trim() && (B.email = !0, B.phoneNumber = !0), u.trim() || (B.password = !0), b.trim() || (B.confirmPassword = !0), t === "tenant" && !E.trim() && (B.tenantName = !0), g(B), Object.keys(B).length === 0;
|
|
2585
|
+
}, Z = async (B) => {
|
|
2586
|
+
if (B.preventDefault(), !!j()) {
|
|
2587
|
+
if (u !== b) {
|
|
2588
|
+
D(y.passwordMismatchError), g({ confirmPassword: !0 });
|
|
2587
2589
|
return;
|
|
2588
2590
|
}
|
|
2589
|
-
if (t === "user" && !(
|
|
2591
|
+
if (t === "user" && !(S != null && S.id)) {
|
|
2590
2592
|
D("Tenant not found");
|
|
2591
2593
|
return;
|
|
2592
2594
|
}
|
|
2593
|
-
|
|
2595
|
+
U(!0), D("");
|
|
2594
2596
|
try {
|
|
2595
|
-
let
|
|
2596
|
-
t === "tenant" ?
|
|
2597
|
+
let X;
|
|
2598
|
+
t === "tenant" ? X = await T({
|
|
2597
2599
|
email: I || void 0,
|
|
2598
2600
|
phoneNumber: M || void 0,
|
|
2599
|
-
name:
|
|
2600
|
-
password:
|
|
2601
|
+
name: d,
|
|
2602
|
+
password: u,
|
|
2601
2603
|
tenantName: E,
|
|
2602
|
-
lastName:
|
|
2603
|
-
}) :
|
|
2604
|
+
lastName: h || void 0
|
|
2605
|
+
}) : X = await C({
|
|
2604
2606
|
email: I || void 0,
|
|
2605
2607
|
phoneNumber: M || void 0,
|
|
2606
|
-
name:
|
|
2607
|
-
password:
|
|
2608
|
-
tenantId:
|
|
2609
|
-
lastName:
|
|
2610
|
-
}), n == null || n(
|
|
2611
|
-
} catch (
|
|
2612
|
-
const
|
|
2613
|
-
D(
|
|
2608
|
+
name: d,
|
|
2609
|
+
password: u,
|
|
2610
|
+
tenantId: S.id,
|
|
2611
|
+
lastName: h || void 0
|
|
2612
|
+
}), n == null || n(X);
|
|
2613
|
+
} catch (X) {
|
|
2614
|
+
const G = X.message || y.errorMessage;
|
|
2615
|
+
D(G), i == null || i(G);
|
|
2614
2616
|
} finally {
|
|
2615
|
-
|
|
2617
|
+
U(!1);
|
|
2616
2618
|
}
|
|
2617
2619
|
}
|
|
2618
|
-
},
|
|
2619
|
-
...
|
|
2620
|
-
|
|
2621
|
-
}),
|
|
2622
|
-
...
|
|
2623
|
-
...R ?
|
|
2624
|
-
...!
|
|
2625
|
-
}),
|
|
2626
|
-
return /* @__PURE__ */
|
|
2627
|
-
/* @__PURE__ */ s("h2", { style:
|
|
2628
|
-
/* @__PURE__ */
|
|
2629
|
-
/* @__PURE__ */
|
|
2630
|
-
/* @__PURE__ */ s("label", { style:
|
|
2620
|
+
}, O = (B) => ({
|
|
2621
|
+
...k.input,
|
|
2622
|
+
...$[B] ? k.inputError : {}
|
|
2623
|
+
}), q = () => ({
|
|
2624
|
+
...k.button,
|
|
2625
|
+
...R ? k.buttonLoading : {},
|
|
2626
|
+
...!d || !I && !M || !u || !b || R || t === "tenant" && !E ? k.buttonDisabled : {}
|
|
2627
|
+
}), W = d && (I || M) && u && b && (t === "user" || E);
|
|
2628
|
+
return /* @__PURE__ */ c("div", { className: w, style: k.container, children: [
|
|
2629
|
+
/* @__PURE__ */ s("h2", { style: k.title, children: y.title }),
|
|
2630
|
+
/* @__PURE__ */ c("form", { onSubmit: Z, style: k.form, children: [
|
|
2631
|
+
/* @__PURE__ */ c("div", { style: k.fieldGroup, children: [
|
|
2632
|
+
/* @__PURE__ */ s("label", { style: k.label, children: y.nameLabel }),
|
|
2631
2633
|
/* @__PURE__ */ s(
|
|
2632
2634
|
"input",
|
|
2633
2635
|
{
|
|
2634
2636
|
id: "name",
|
|
2635
2637
|
name: "name",
|
|
2636
2638
|
type: "text",
|
|
2637
|
-
value:
|
|
2638
|
-
onChange: (
|
|
2639
|
-
|
|
2639
|
+
value: d,
|
|
2640
|
+
onChange: (B) => {
|
|
2641
|
+
m(B.target.value), $.name && g((X) => ({ ...X, name: !1 }));
|
|
2640
2642
|
},
|
|
2641
|
-
placeholder:
|
|
2642
|
-
style:
|
|
2643
|
+
placeholder: y.namePlaceholder,
|
|
2644
|
+
style: O("name"),
|
|
2643
2645
|
disabled: R
|
|
2644
2646
|
}
|
|
2645
2647
|
)
|
|
2646
2648
|
] }),
|
|
2647
|
-
/* @__PURE__ */
|
|
2648
|
-
/* @__PURE__ */ s("label", { style:
|
|
2649
|
+
/* @__PURE__ */ c("div", { style: k.fieldGroup, children: [
|
|
2650
|
+
/* @__PURE__ */ s("label", { style: k.label, children: y.lastNameLabel }),
|
|
2649
2651
|
/* @__PURE__ */ s(
|
|
2650
2652
|
"input",
|
|
2651
2653
|
{
|
|
2652
2654
|
id: "lastName",
|
|
2653
2655
|
name: "lastName",
|
|
2654
2656
|
type: "text",
|
|
2655
|
-
value:
|
|
2656
|
-
onChange: (
|
|
2657
|
-
placeholder:
|
|
2658
|
-
style:
|
|
2657
|
+
value: h,
|
|
2658
|
+
onChange: (B) => v(B.target.value),
|
|
2659
|
+
placeholder: y.lastNamePlaceholder,
|
|
2660
|
+
style: k.input,
|
|
2659
2661
|
disabled: R
|
|
2660
2662
|
}
|
|
2661
2663
|
)
|
|
2662
2664
|
] }),
|
|
2663
|
-
/* @__PURE__ */
|
|
2664
|
-
/* @__PURE__ */ s("label", { style:
|
|
2665
|
+
/* @__PURE__ */ c("div", { style: k.fieldGroup, children: [
|
|
2666
|
+
/* @__PURE__ */ s("label", { style: k.label, children: y.emailLabel }),
|
|
2665
2667
|
/* @__PURE__ */ s(
|
|
2666
2668
|
"input",
|
|
2667
2669
|
{
|
|
@@ -2669,17 +2671,17 @@ function Bn({
|
|
|
2669
2671
|
name: "email",
|
|
2670
2672
|
type: "email",
|
|
2671
2673
|
value: I,
|
|
2672
|
-
onChange: (
|
|
2673
|
-
|
|
2674
|
+
onChange: (B) => {
|
|
2675
|
+
F(B.target.value), $.email && g((X) => ({ ...X, email: !1, phoneNumber: !1 }));
|
|
2674
2676
|
},
|
|
2675
|
-
placeholder:
|
|
2676
|
-
style:
|
|
2677
|
+
placeholder: y.emailPlaceholder,
|
|
2678
|
+
style: O("email"),
|
|
2677
2679
|
disabled: R
|
|
2678
2680
|
}
|
|
2679
2681
|
)
|
|
2680
2682
|
] }),
|
|
2681
|
-
/* @__PURE__ */
|
|
2682
|
-
/* @__PURE__ */ s("label", { style:
|
|
2683
|
+
/* @__PURE__ */ c("div", { style: k.fieldGroup, children: [
|
|
2684
|
+
/* @__PURE__ */ s("label", { style: k.label, children: y.phoneNumberLabel }),
|
|
2683
2685
|
/* @__PURE__ */ s(
|
|
2684
2686
|
"input",
|
|
2685
2687
|
{
|
|
@@ -2687,11 +2689,11 @@ function Bn({
|
|
|
2687
2689
|
name: "phoneNumber",
|
|
2688
2690
|
type: "tel",
|
|
2689
2691
|
value: M,
|
|
2690
|
-
onChange: (
|
|
2691
|
-
P(
|
|
2692
|
+
onChange: (B) => {
|
|
2693
|
+
P(B.target.value), $.phoneNumber && g((X) => ({ ...X, email: !1, phoneNumber: !1 }));
|
|
2692
2694
|
},
|
|
2693
|
-
placeholder:
|
|
2694
|
-
style:
|
|
2695
|
+
placeholder: y.phoneNumberPlaceholder,
|
|
2696
|
+
style: O("phoneNumber"),
|
|
2695
2697
|
disabled: R
|
|
2696
2698
|
}
|
|
2697
2699
|
)
|
|
@@ -2708,44 +2710,44 @@ function Bn({
|
|
|
2708
2710
|
children: "At least one contact method (email or phone) is required"
|
|
2709
2711
|
}
|
|
2710
2712
|
),
|
|
2711
|
-
/* @__PURE__ */
|
|
2712
|
-
/* @__PURE__ */ s("label", { style:
|
|
2713
|
+
/* @__PURE__ */ c("div", { style: k.fieldGroup, children: [
|
|
2714
|
+
/* @__PURE__ */ s("label", { style: k.label, children: y.passwordLabel }),
|
|
2713
2715
|
/* @__PURE__ */ s(
|
|
2714
2716
|
"input",
|
|
2715
2717
|
{
|
|
2716
2718
|
id: "password",
|
|
2717
2719
|
name: "password",
|
|
2718
2720
|
type: "password",
|
|
2719
|
-
value:
|
|
2720
|
-
onChange: (
|
|
2721
|
-
A(
|
|
2721
|
+
value: u,
|
|
2722
|
+
onChange: (B) => {
|
|
2723
|
+
A(B.target.value), $.password && g((X) => ({ ...X, password: !1 }));
|
|
2722
2724
|
},
|
|
2723
|
-
placeholder:
|
|
2724
|
-
style:
|
|
2725
|
+
placeholder: y.passwordPlaceholder,
|
|
2726
|
+
style: O("password"),
|
|
2725
2727
|
disabled: R
|
|
2726
2728
|
}
|
|
2727
2729
|
)
|
|
2728
2730
|
] }),
|
|
2729
|
-
/* @__PURE__ */
|
|
2730
|
-
/* @__PURE__ */ s("label", { style:
|
|
2731
|
+
/* @__PURE__ */ c("div", { style: k.fieldGroup, children: [
|
|
2732
|
+
/* @__PURE__ */ s("label", { style: k.label, children: y.confirmPasswordLabel }),
|
|
2731
2733
|
/* @__PURE__ */ s(
|
|
2732
2734
|
"input",
|
|
2733
2735
|
{
|
|
2734
2736
|
id: "confirmPassword",
|
|
2735
2737
|
name: "confirmPassword",
|
|
2736
2738
|
type: "password",
|
|
2737
|
-
value:
|
|
2738
|
-
onChange: (
|
|
2739
|
-
L(
|
|
2739
|
+
value: b,
|
|
2740
|
+
onChange: (B) => {
|
|
2741
|
+
L(B.target.value), $.confirmPassword && g((X) => ({ ...X, confirmPassword: !1 })), l === y.passwordMismatchError && D("");
|
|
2740
2742
|
},
|
|
2741
|
-
placeholder:
|
|
2742
|
-
style:
|
|
2743
|
+
placeholder: y.confirmPasswordPlaceholder,
|
|
2744
|
+
style: O("confirmPassword"),
|
|
2743
2745
|
disabled: R
|
|
2744
2746
|
}
|
|
2745
2747
|
)
|
|
2746
2748
|
] }),
|
|
2747
|
-
t === "tenant" && /* @__PURE__ */
|
|
2748
|
-
/* @__PURE__ */ s("label", { style:
|
|
2749
|
+
t === "tenant" && /* @__PURE__ */ c("div", { style: k.fieldGroup, children: [
|
|
2750
|
+
/* @__PURE__ */ s("label", { style: k.label, children: y.tenantNameLabel }),
|
|
2749
2751
|
/* @__PURE__ */ s(
|
|
2750
2752
|
"input",
|
|
2751
2753
|
{
|
|
@@ -2753,38 +2755,38 @@ function Bn({
|
|
|
2753
2755
|
name: "tenantName",
|
|
2754
2756
|
type: "text",
|
|
2755
2757
|
value: E,
|
|
2756
|
-
onChange: (
|
|
2757
|
-
|
|
2758
|
+
onChange: (B) => {
|
|
2759
|
+
N(B.target.value), $.tenantName && g((X) => ({ ...X, tenantName: !1 }));
|
|
2758
2760
|
},
|
|
2759
|
-
placeholder:
|
|
2760
|
-
style:
|
|
2761
|
+
placeholder: y.tenantNamePlaceholder,
|
|
2762
|
+
style: O("tenantName"),
|
|
2761
2763
|
disabled: R
|
|
2762
2764
|
}
|
|
2763
2765
|
)
|
|
2764
2766
|
] }),
|
|
2765
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: !
|
|
2766
|
-
l && /* @__PURE__ */ s("div", { style:
|
|
2767
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !W || R, style: q(), children: R ? y.loadingText : y.submitButton }),
|
|
2768
|
+
l && /* @__PURE__ */ s("div", { style: k.errorText, children: l })
|
|
2767
2769
|
] }),
|
|
2768
|
-
(p || f) && /* @__PURE__ */
|
|
2769
|
-
f && /* @__PURE__ */
|
|
2770
|
-
/* @__PURE__ */
|
|
2771
|
-
|
|
2770
|
+
(p || f) && /* @__PURE__ */ c("div", { style: k.linkContainer, children: [
|
|
2771
|
+
f && /* @__PURE__ */ c("div", { children: [
|
|
2772
|
+
/* @__PURE__ */ c("span", { style: k.divider, children: [
|
|
2773
|
+
y.magicLinkText,
|
|
2772
2774
|
" "
|
|
2773
2775
|
] }),
|
|
2774
|
-
/* @__PURE__ */ s("a", { onClick: a, style:
|
|
2776
|
+
/* @__PURE__ */ s("a", { onClick: a, style: k.link, children: y.magicLinkLink })
|
|
2775
2777
|
] }),
|
|
2776
|
-
f && p && /* @__PURE__ */ s("div", { style:
|
|
2777
|
-
p && /* @__PURE__ */
|
|
2778
|
-
/* @__PURE__ */
|
|
2779
|
-
|
|
2778
|
+
f && p && /* @__PURE__ */ s("div", { style: k.divider, children: "•" }),
|
|
2779
|
+
p && /* @__PURE__ */ c("div", { children: [
|
|
2780
|
+
/* @__PURE__ */ c("span", { style: k.divider, children: [
|
|
2781
|
+
y.loginText,
|
|
2780
2782
|
" "
|
|
2781
2783
|
] }),
|
|
2782
|
-
/* @__PURE__ */ s("a", { onClick: o, style:
|
|
2784
|
+
/* @__PURE__ */ s("a", { onClick: o, style: k.link, children: y.loginLink })
|
|
2783
2785
|
] })
|
|
2784
2786
|
] })
|
|
2785
2787
|
] });
|
|
2786
2788
|
}
|
|
2787
|
-
const
|
|
2789
|
+
const Zt = {
|
|
2788
2790
|
title: "Sign In with Magic Link",
|
|
2789
2791
|
emailLabel: "Email",
|
|
2790
2792
|
emailPlaceholder: "Enter your email",
|
|
@@ -2802,7 +2804,7 @@ const jt = {
|
|
|
2802
2804
|
loadingText: "Sending magic link...",
|
|
2803
2805
|
verifyingText: "Verifying magic link...",
|
|
2804
2806
|
description: "Enter your email to receive a magic link. If you don't have an account, we'll create one for you."
|
|
2805
|
-
},
|
|
2807
|
+
}, Kt = {
|
|
2806
2808
|
container: {
|
|
2807
2809
|
maxWidth: "400px",
|
|
2808
2810
|
width: "100%",
|
|
@@ -2905,7 +2907,7 @@ const jt = {
|
|
|
2905
2907
|
fontSize: "0.875rem"
|
|
2906
2908
|
}
|
|
2907
2909
|
};
|
|
2908
|
-
function
|
|
2910
|
+
function zn({
|
|
2909
2911
|
copy: r = {},
|
|
2910
2912
|
styles: e = {},
|
|
2911
2913
|
onSuccess: t,
|
|
@@ -2917,85 +2919,85 @@ function qn({
|
|
|
2917
2919
|
verifyToken: f,
|
|
2918
2920
|
frontendUrl: w
|
|
2919
2921
|
}) {
|
|
2920
|
-
const [
|
|
2921
|
-
|
|
2922
|
-
f &&
|
|
2922
|
+
const [d, m] = x(""), [h, v] = x(""), [I, F] = x(""), [M, P] = x(!1), [u, A] = x(!1), [b, L] = x(""), [E, N] = x(""), [R, U] = x({}), [l, D] = x(!1), { sendMagicLink: $, verifyMagicLink: g } = ce(), { tenant: C } = ge(), T = { ...Zt, ...r }, S = { ...Kt, ...e };
|
|
2923
|
+
ee(() => {
|
|
2924
|
+
f && y(f);
|
|
2923
2925
|
}, [f]);
|
|
2924
|
-
const
|
|
2925
|
-
if (!
|
|
2926
|
+
const y = async (q) => {
|
|
2927
|
+
if (!C || !d) {
|
|
2926
2928
|
L("Missing tenant or email");
|
|
2927
2929
|
return;
|
|
2928
2930
|
}
|
|
2929
2931
|
A(!0), L("");
|
|
2930
2932
|
try {
|
|
2931
|
-
const
|
|
2932
|
-
token:
|
|
2933
|
-
email:
|
|
2933
|
+
const W = await g({
|
|
2934
|
+
token: q,
|
|
2935
|
+
email: d
|
|
2934
2936
|
// tenantId inferred from context automatically
|
|
2935
2937
|
});
|
|
2936
|
-
t == null || t(
|
|
2937
|
-
} catch (
|
|
2938
|
-
const
|
|
2939
|
-
L(
|
|
2938
|
+
t == null || t(W);
|
|
2939
|
+
} catch (W) {
|
|
2940
|
+
const B = W.message || "Failed to verify magic link";
|
|
2941
|
+
L(B), n == null || n(B);
|
|
2940
2942
|
} finally {
|
|
2941
2943
|
A(!1);
|
|
2942
2944
|
}
|
|
2943
|
-
},
|
|
2944
|
-
const
|
|
2945
|
-
return
|
|
2946
|
-
},
|
|
2947
|
-
if (
|
|
2948
|
-
if (!(
|
|
2945
|
+
}, k = () => {
|
|
2946
|
+
const q = {};
|
|
2947
|
+
return d.trim() || (q.email = !0), l && !h.trim() && (q.name = !0), U(q), Object.keys(q).length === 0;
|
|
2948
|
+
}, j = async (q) => {
|
|
2949
|
+
if (q.preventDefault(), !!k()) {
|
|
2950
|
+
if (!(C != null && C.id)) {
|
|
2949
2951
|
L("Tenant not found");
|
|
2950
2952
|
return;
|
|
2951
2953
|
}
|
|
2952
|
-
P(!0), L(""),
|
|
2954
|
+
P(!0), L(""), N("");
|
|
2953
2955
|
try {
|
|
2954
|
-
const
|
|
2955
|
-
email:
|
|
2956
|
-
tenantId:
|
|
2957
|
-
frontendUrl:
|
|
2958
|
-
name: l ?
|
|
2956
|
+
const W = w || (typeof window < "u" ? window.location.origin : ""), B = await $({
|
|
2957
|
+
email: d,
|
|
2958
|
+
tenantId: C.id,
|
|
2959
|
+
frontendUrl: W,
|
|
2960
|
+
name: l ? h : void 0,
|
|
2959
2961
|
lastName: l ? I : void 0
|
|
2960
2962
|
});
|
|
2961
|
-
|
|
2962
|
-
} catch (
|
|
2963
|
-
const
|
|
2964
|
-
L(
|
|
2963
|
+
N(T.successMessage), t == null || t(B);
|
|
2964
|
+
} catch (W) {
|
|
2965
|
+
const B = W.message || T.errorMessage;
|
|
2966
|
+
L(B), n == null || n(B);
|
|
2965
2967
|
} finally {
|
|
2966
2968
|
P(!1);
|
|
2967
2969
|
}
|
|
2968
2970
|
}
|
|
2969
|
-
},
|
|
2970
|
-
...
|
|
2971
|
-
...R[
|
|
2972
|
-
}),
|
|
2973
|
-
...
|
|
2974
|
-
...M ||
|
|
2975
|
-
...!
|
|
2971
|
+
}, Z = (q) => ({
|
|
2972
|
+
...S.input,
|
|
2973
|
+
...R[q] ? S.inputError : {}
|
|
2974
|
+
}), O = () => ({
|
|
2975
|
+
...S.button,
|
|
2976
|
+
...M || u ? S.buttonLoading : {},
|
|
2977
|
+
...!d || M || u ? S.buttonDisabled : {}
|
|
2976
2978
|
});
|
|
2977
|
-
return
|
|
2978
|
-
/* @__PURE__ */ s("h2", { style:
|
|
2979
|
+
return u ? /* @__PURE__ */ c("div", { className: p, style: S.container, children: [
|
|
2980
|
+
/* @__PURE__ */ s("h2", { style: S.title, children: T.verifyingText }),
|
|
2979
2981
|
/* @__PURE__ */ s("div", { style: { textAlign: "center", padding: "2rem" }, children: /* @__PURE__ */ s("div", { style: { fontSize: "1rem", color: "#6b7280" }, children: "Please wait while we verify your magic link..." }) })
|
|
2980
|
-
] }) : /* @__PURE__ */
|
|
2981
|
-
/* @__PURE__ */ s("h2", { style:
|
|
2982
|
-
/* @__PURE__ */ s("p", { style:
|
|
2983
|
-
/* @__PURE__ */
|
|
2984
|
-
/* @__PURE__ */
|
|
2985
|
-
/* @__PURE__ */ s("label", { style:
|
|
2982
|
+
] }) : /* @__PURE__ */ c("div", { className: p, style: S.container, children: [
|
|
2983
|
+
/* @__PURE__ */ s("h2", { style: S.title, children: T.title }),
|
|
2984
|
+
/* @__PURE__ */ s("p", { style: S.description, children: T.description }),
|
|
2985
|
+
/* @__PURE__ */ c("form", { onSubmit: j, style: S.form, children: [
|
|
2986
|
+
/* @__PURE__ */ c("div", { style: S.fieldGroup, children: [
|
|
2987
|
+
/* @__PURE__ */ s("label", { style: S.label, children: T.emailLabel }),
|
|
2986
2988
|
/* @__PURE__ */ s(
|
|
2987
2989
|
"input",
|
|
2988
2990
|
{
|
|
2989
2991
|
id: "email",
|
|
2990
2992
|
name: "email",
|
|
2991
2993
|
type: "email",
|
|
2992
|
-
value:
|
|
2993
|
-
onChange: (
|
|
2994
|
-
|
|
2994
|
+
value: d,
|
|
2995
|
+
onChange: (q) => {
|
|
2996
|
+
m(q.target.value), R.email && U((W) => ({ ...W, email: !1 }));
|
|
2995
2997
|
},
|
|
2996
|
-
placeholder:
|
|
2997
|
-
style:
|
|
2998
|
-
disabled: M ||
|
|
2998
|
+
placeholder: T.emailPlaceholder,
|
|
2999
|
+
style: Z("email"),
|
|
3000
|
+
disabled: M || u
|
|
2999
3001
|
}
|
|
3000
3002
|
)
|
|
3001
3003
|
] }),
|
|
@@ -3015,27 +3017,27 @@ function qn({
|
|
|
3015
3017
|
children: "New user? Add your name"
|
|
3016
3018
|
}
|
|
3017
3019
|
) }),
|
|
3018
|
-
l && /* @__PURE__ */
|
|
3019
|
-
/* @__PURE__ */
|
|
3020
|
-
/* @__PURE__ */ s("label", { style:
|
|
3020
|
+
l && /* @__PURE__ */ c(_, { children: [
|
|
3021
|
+
/* @__PURE__ */ c("div", { style: S.fieldGroup, children: [
|
|
3022
|
+
/* @__PURE__ */ s("label", { style: S.label, children: T.nameLabel }),
|
|
3021
3023
|
/* @__PURE__ */ s(
|
|
3022
3024
|
"input",
|
|
3023
3025
|
{
|
|
3024
3026
|
id: "name",
|
|
3025
3027
|
name: "name",
|
|
3026
3028
|
type: "text",
|
|
3027
|
-
value:
|
|
3028
|
-
onChange: (
|
|
3029
|
-
|
|
3029
|
+
value: h,
|
|
3030
|
+
onChange: (q) => {
|
|
3031
|
+
v(q.target.value), R.name && U((W) => ({ ...W, name: !1 }));
|
|
3030
3032
|
},
|
|
3031
|
-
placeholder:
|
|
3032
|
-
style:
|
|
3033
|
-
disabled: M ||
|
|
3033
|
+
placeholder: T.namePlaceholder,
|
|
3034
|
+
style: Z("name"),
|
|
3035
|
+
disabled: M || u
|
|
3034
3036
|
}
|
|
3035
3037
|
)
|
|
3036
3038
|
] }),
|
|
3037
|
-
/* @__PURE__ */
|
|
3038
|
-
/* @__PURE__ */ s("label", { style:
|
|
3039
|
+
/* @__PURE__ */ c("div", { style: S.fieldGroup, children: [
|
|
3040
|
+
/* @__PURE__ */ s("label", { style: S.label, children: T.lastNameLabel }),
|
|
3039
3041
|
/* @__PURE__ */ s(
|
|
3040
3042
|
"input",
|
|
3041
3043
|
{
|
|
@@ -3043,10 +3045,10 @@ function qn({
|
|
|
3043
3045
|
name: "lastName",
|
|
3044
3046
|
type: "text",
|
|
3045
3047
|
value: I,
|
|
3046
|
-
onChange: (
|
|
3047
|
-
placeholder:
|
|
3048
|
-
style:
|
|
3049
|
-
disabled: M ||
|
|
3048
|
+
onChange: (q) => F(q.target.value),
|
|
3049
|
+
placeholder: T.lastNamePlaceholder,
|
|
3050
|
+
style: S.input,
|
|
3051
|
+
disabled: M || u
|
|
3050
3052
|
}
|
|
3051
3053
|
)
|
|
3052
3054
|
] }),
|
|
@@ -3055,7 +3057,7 @@ function qn({
|
|
|
3055
3057
|
{
|
|
3056
3058
|
type: "button",
|
|
3057
3059
|
onClick: () => {
|
|
3058
|
-
D(!1),
|
|
3060
|
+
D(!1), v(""), F("");
|
|
3059
3061
|
},
|
|
3060
3062
|
style: {
|
|
3061
3063
|
background: "none",
|
|
@@ -3069,30 +3071,30 @@ function qn({
|
|
|
3069
3071
|
}
|
|
3070
3072
|
) })
|
|
3071
3073
|
] }),
|
|
3072
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: !
|
|
3073
|
-
|
|
3074
|
-
E && /* @__PURE__ */ s("div", { style:
|
|
3074
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !d || M || u, style: O(), children: M ? T.loadingText : T.submitButton }),
|
|
3075
|
+
b && /* @__PURE__ */ s("div", { style: S.errorText, children: b }),
|
|
3076
|
+
E && /* @__PURE__ */ s("div", { style: S.successText, children: E })
|
|
3075
3077
|
] }),
|
|
3076
|
-
a && /* @__PURE__ */
|
|
3077
|
-
/* @__PURE__ */
|
|
3078
|
-
/* @__PURE__ */
|
|
3079
|
-
|
|
3078
|
+
a && /* @__PURE__ */ c("div", { style: S.linkContainer, children: [
|
|
3079
|
+
/* @__PURE__ */ c("div", { children: [
|
|
3080
|
+
/* @__PURE__ */ c("span", { style: S.divider, children: [
|
|
3081
|
+
T.loginText,
|
|
3080
3082
|
" "
|
|
3081
3083
|
] }),
|
|
3082
|
-
/* @__PURE__ */ s("a", { onClick: i, style:
|
|
3084
|
+
/* @__PURE__ */ s("a", { onClick: i, style: S.link, children: T.loginLink })
|
|
3083
3085
|
] }),
|
|
3084
|
-
/* @__PURE__ */ s("div", { style:
|
|
3085
|
-
/* @__PURE__ */
|
|
3086
|
-
/* @__PURE__ */
|
|
3087
|
-
|
|
3086
|
+
/* @__PURE__ */ s("div", { style: S.divider, children: "•" }),
|
|
3087
|
+
/* @__PURE__ */ c("div", { children: [
|
|
3088
|
+
/* @__PURE__ */ c("span", { style: S.divider, children: [
|
|
3089
|
+
T.signupText,
|
|
3088
3090
|
" "
|
|
3089
3091
|
] }),
|
|
3090
|
-
/* @__PURE__ */ s("a", { onClick: o, style:
|
|
3092
|
+
/* @__PURE__ */ s("a", { onClick: o, style: S.link, children: T.signupLink })
|
|
3091
3093
|
] })
|
|
3092
3094
|
] })
|
|
3093
3095
|
] });
|
|
3094
3096
|
}
|
|
3095
|
-
const
|
|
3097
|
+
const Jt = {
|
|
3096
3098
|
title: "Verifying Magic Link",
|
|
3097
3099
|
verifyingMessage: "Please wait while we verify your magic link...",
|
|
3098
3100
|
successMessage: "Magic link verified successfully! You are now logged in.",
|
|
@@ -3100,7 +3102,7 @@ const Zt = {
|
|
|
3100
3102
|
redirectingMessage: "Redirecting you to the dashboard...",
|
|
3101
3103
|
retryButton: "Try Again",
|
|
3102
3104
|
backToLoginButton: "Back to Login"
|
|
3103
|
-
},
|
|
3105
|
+
}, Qe = {
|
|
3104
3106
|
container: {
|
|
3105
3107
|
maxWidth: "400px",
|
|
3106
3108
|
width: "100%",
|
|
@@ -3187,7 +3189,7 @@ const Zt = {
|
|
|
3187
3189
|
cursor: "pointer",
|
|
3188
3190
|
transition: "all 0.15s ease-in-out"
|
|
3189
3191
|
}
|
|
3190
|
-
},
|
|
3192
|
+
}, Yt = () => /* @__PURE__ */ s("div", { style: Qe.spinner }), Qt = () => /* @__PURE__ */ c(
|
|
3191
3193
|
"svg",
|
|
3192
3194
|
{
|
|
3193
3195
|
width: "48",
|
|
@@ -3204,7 +3206,7 @@ const Zt = {
|
|
|
3204
3206
|
/* @__PURE__ */ s("polyline", { points: "22,4 12,14.01 9,11.01" })
|
|
3205
3207
|
]
|
|
3206
3208
|
}
|
|
3207
|
-
),
|
|
3209
|
+
), Xt = () => /* @__PURE__ */ c(
|
|
3208
3210
|
"svg",
|
|
3209
3211
|
{
|
|
3210
3212
|
width: "48",
|
|
@@ -3222,12 +3224,12 @@ const Zt = {
|
|
|
3222
3224
|
/* @__PURE__ */ s("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
|
|
3223
3225
|
]
|
|
3224
3226
|
}
|
|
3225
|
-
),
|
|
3226
|
-
loading: /* @__PURE__ */ s(
|
|
3227
|
-
success: /* @__PURE__ */ s(
|
|
3228
|
-
error: /* @__PURE__ */ s(
|
|
3227
|
+
), en = {
|
|
3228
|
+
loading: /* @__PURE__ */ s(Yt, {}),
|
|
3229
|
+
success: /* @__PURE__ */ s(Qt, {}),
|
|
3230
|
+
error: /* @__PURE__ */ s(Xt, {})
|
|
3229
3231
|
};
|
|
3230
|
-
function
|
|
3232
|
+
function _n({
|
|
3231
3233
|
copy: r = {},
|
|
3232
3234
|
styles: e = {},
|
|
3233
3235
|
icons: t = {},
|
|
@@ -3238,18 +3240,18 @@ function On({
|
|
|
3238
3240
|
className: p,
|
|
3239
3241
|
token: f,
|
|
3240
3242
|
email: w,
|
|
3241
|
-
appId:
|
|
3242
|
-
tenantSlug:
|
|
3243
|
-
autoRedirectDelay:
|
|
3243
|
+
appId: d,
|
|
3244
|
+
tenantSlug: m,
|
|
3245
|
+
autoRedirectDelay: h = 3e3
|
|
3244
3246
|
}) {
|
|
3245
|
-
const [
|
|
3247
|
+
const [v, I] = x("verifying"), [F, M] = x(""), { verifyMagicLink: P } = ce(), u = { ...Jt, ...r }, A = { ...Qe, ...e }, b = { ...en, ...t }, L = () => {
|
|
3246
3248
|
if (typeof window > "u") return {};
|
|
3247
3249
|
const l = new URLSearchParams(window.location.search);
|
|
3248
3250
|
return {
|
|
3249
3251
|
token: f || l.get("token") || "",
|
|
3250
3252
|
email: w || l.get("email") || "",
|
|
3251
|
-
appId:
|
|
3252
|
-
tenantSlug:
|
|
3253
|
+
appId: d || l.get("appId") || "",
|
|
3254
|
+
tenantSlug: m || l.get("tenantSlug") || void 0
|
|
3253
3255
|
};
|
|
3254
3256
|
}, E = async () => {
|
|
3255
3257
|
I("verifying"), M("");
|
|
@@ -3262,47 +3264,47 @@ function On({
|
|
|
3262
3264
|
email: l.email,
|
|
3263
3265
|
tenantSlug: l.tenantSlug
|
|
3264
3266
|
});
|
|
3265
|
-
I("success"), n == null || n(D),
|
|
3267
|
+
I("success"), n == null || n(D), h > 0 && setTimeout(() => {
|
|
3266
3268
|
I("redirecting");
|
|
3267
|
-
},
|
|
3269
|
+
}, h);
|
|
3268
3270
|
} catch (l) {
|
|
3269
|
-
const D = l.message ||
|
|
3271
|
+
const D = l.message || u.errorMessage;
|
|
3270
3272
|
M(D), I("error"), i == null || i(D);
|
|
3271
3273
|
}
|
|
3272
|
-
},
|
|
3274
|
+
}, N = () => {
|
|
3273
3275
|
o == null || o(), E();
|
|
3274
3276
|
}, R = () => {
|
|
3275
3277
|
a == null || a();
|
|
3276
3278
|
};
|
|
3277
|
-
|
|
3279
|
+
ee(() => {
|
|
3278
3280
|
E();
|
|
3279
3281
|
}, []);
|
|
3280
|
-
const
|
|
3281
|
-
switch (
|
|
3282
|
+
const U = () => {
|
|
3283
|
+
switch (v) {
|
|
3282
3284
|
case "verifying":
|
|
3283
|
-
return /* @__PURE__ */
|
|
3284
|
-
|
|
3285
|
-
|
|
3285
|
+
return /* @__PURE__ */ c("div", { style: A.message, children: [
|
|
3286
|
+
b.loading,
|
|
3287
|
+
u.verifyingMessage
|
|
3286
3288
|
] });
|
|
3287
3289
|
case "success":
|
|
3288
|
-
return /* @__PURE__ */
|
|
3289
|
-
|
|
3290
|
-
/* @__PURE__ */ s("div", { style: A.successMessage, children:
|
|
3290
|
+
return /* @__PURE__ */ c(_, { children: [
|
|
3291
|
+
b.success,
|
|
3292
|
+
/* @__PURE__ */ s("div", { style: A.successMessage, children: u.successMessage })
|
|
3291
3293
|
] });
|
|
3292
3294
|
case "redirecting":
|
|
3293
|
-
return /* @__PURE__ */
|
|
3294
|
-
|
|
3295
|
-
/* @__PURE__ */ s("div", { style: A.message, children:
|
|
3295
|
+
return /* @__PURE__ */ c(_, { children: [
|
|
3296
|
+
b.loading,
|
|
3297
|
+
/* @__PURE__ */ s("div", { style: A.message, children: u.redirectingMessage })
|
|
3296
3298
|
] });
|
|
3297
3299
|
case "error":
|
|
3298
|
-
return /* @__PURE__ */
|
|
3299
|
-
|
|
3300
|
-
/* @__PURE__ */ s("div", { style: A.errorMessage, children:
|
|
3301
|
-
/* @__PURE__ */
|
|
3300
|
+
return /* @__PURE__ */ c(_, { children: [
|
|
3301
|
+
b.error,
|
|
3302
|
+
/* @__PURE__ */ s("div", { style: A.errorMessage, children: F || u.errorMessage }),
|
|
3303
|
+
/* @__PURE__ */ c("div", { style: A.buttonContainer, children: [
|
|
3302
3304
|
/* @__PURE__ */ s(
|
|
3303
3305
|
"button",
|
|
3304
3306
|
{
|
|
3305
|
-
onClick:
|
|
3307
|
+
onClick: N,
|
|
3306
3308
|
style: A.retryButton,
|
|
3307
3309
|
onMouseOver: (l) => {
|
|
3308
3310
|
l.currentTarget.style.backgroundColor = "#2563eb";
|
|
@@ -3310,7 +3312,7 @@ function On({
|
|
|
3310
3312
|
onMouseOut: (l) => {
|
|
3311
3313
|
l.currentTarget.style.backgroundColor = "#3b82f6";
|
|
3312
3314
|
},
|
|
3313
|
-
children:
|
|
3315
|
+
children: u.retryButton
|
|
3314
3316
|
}
|
|
3315
3317
|
),
|
|
3316
3318
|
/* @__PURE__ */ s(
|
|
@@ -3324,7 +3326,7 @@ function On({
|
|
|
3324
3326
|
onMouseOut: (l) => {
|
|
3325
3327
|
l.currentTarget.style.backgroundColor = "#f3f4f6";
|
|
3326
3328
|
},
|
|
3327
|
-
children:
|
|
3329
|
+
children: u.backToLoginButton
|
|
3328
3330
|
}
|
|
3329
3331
|
)
|
|
3330
3332
|
] })
|
|
@@ -3333,18 +3335,18 @@ function On({
|
|
|
3333
3335
|
return null;
|
|
3334
3336
|
}
|
|
3335
3337
|
};
|
|
3336
|
-
return /* @__PURE__ */
|
|
3338
|
+
return /* @__PURE__ */ c("div", { style: A.container, className: p, children: [
|
|
3337
3339
|
/* @__PURE__ */ s("style", { children: `
|
|
3338
3340
|
@keyframes spin {
|
|
3339
3341
|
0% { transform: rotate(0deg); }
|
|
3340
3342
|
100% { transform: rotate(360deg); }
|
|
3341
3343
|
}
|
|
3342
3344
|
` }),
|
|
3343
|
-
/* @__PURE__ */ s("h1", { style: A.title, children:
|
|
3344
|
-
|
|
3345
|
+
/* @__PURE__ */ s("h1", { style: A.title, children: u.title }),
|
|
3346
|
+
U()
|
|
3345
3347
|
] });
|
|
3346
3348
|
}
|
|
3347
|
-
const
|
|
3349
|
+
const tn = {
|
|
3348
3350
|
title: "Reset Password",
|
|
3349
3351
|
subtitle: "Enter your email address and we'll send you a link to reset your password.",
|
|
3350
3352
|
emailLabel: "Email",
|
|
@@ -3366,7 +3368,7 @@ const Xt = {
|
|
|
3366
3368
|
resetLoadingText: "Resetting...",
|
|
3367
3369
|
resetSuccessMessage: "Password reset successfully!",
|
|
3368
3370
|
passwordMismatchError: "Passwords do not match"
|
|
3369
|
-
},
|
|
3371
|
+
}, nn = {
|
|
3370
3372
|
container: {
|
|
3371
3373
|
maxWidth: "400px",
|
|
3372
3374
|
margin: "0 auto",
|
|
@@ -3458,7 +3460,7 @@ const Xt = {
|
|
|
3458
3460
|
cursor: "pointer"
|
|
3459
3461
|
}
|
|
3460
3462
|
};
|
|
3461
|
-
function
|
|
3463
|
+
function Wn({
|
|
3462
3464
|
copy: r = {},
|
|
3463
3465
|
styles: e = {},
|
|
3464
3466
|
mode: t = "request",
|
|
@@ -3469,101 +3471,101 @@ function zn({
|
|
|
3469
3471
|
onModeChange: p,
|
|
3470
3472
|
className: f
|
|
3471
3473
|
}) {
|
|
3472
|
-
const [w,
|
|
3473
|
-
const
|
|
3474
|
-
return w.trim() || (
|
|
3475
|
-
},
|
|
3476
|
-
const
|
|
3477
|
-
return
|
|
3478
|
-
},
|
|
3479
|
-
if (
|
|
3474
|
+
const [w, d] = x(""), [m, h] = x(n), [v, I] = x(""), [F, M] = x(""), [P, u] = x(!1), [A, b] = x(""), [L, E] = x(""), [N, R] = x({}), { requestPasswordReset: U, confirmPasswordReset: l } = ce(), { tenant: D } = ge(), $ = { ...tn, ...r }, g = { ...nn, ...e }, C = () => {
|
|
3475
|
+
const O = {};
|
|
3476
|
+
return w.trim() || (O.email = !0), R(O), Object.keys(O).length === 0;
|
|
3477
|
+
}, T = () => {
|
|
3478
|
+
const O = {};
|
|
3479
|
+
return m.trim() || (O.token = !0), v.trim() || (O.newPassword = !0), F.trim() || (O.confirmPassword = !0), R(O), Object.keys(O).length === 0;
|
|
3480
|
+
}, S = async (O) => {
|
|
3481
|
+
if (O.preventDefault(), !!C()) {
|
|
3480
3482
|
if (!(D != null && D.id)) {
|
|
3481
|
-
|
|
3483
|
+
b("Tenant not found");
|
|
3482
3484
|
return;
|
|
3483
3485
|
}
|
|
3484
|
-
|
|
3486
|
+
u(!0), b(""), E("");
|
|
3485
3487
|
try {
|
|
3486
|
-
await
|
|
3487
|
-
} catch (
|
|
3488
|
-
const
|
|
3489
|
-
|
|
3488
|
+
await U({ email: w, tenantId: D.id }), E($.successMessage), i == null || i();
|
|
3489
|
+
} catch (q) {
|
|
3490
|
+
const W = q.message || $.errorMessage;
|
|
3491
|
+
b(W), o == null || o(W);
|
|
3490
3492
|
} finally {
|
|
3491
|
-
|
|
3493
|
+
u(!1);
|
|
3492
3494
|
}
|
|
3493
3495
|
}
|
|
3494
|
-
},
|
|
3495
|
-
if (
|
|
3496
|
-
if (
|
|
3497
|
-
|
|
3496
|
+
}, y = async (O) => {
|
|
3497
|
+
if (O.preventDefault(), !!T()) {
|
|
3498
|
+
if (v !== F) {
|
|
3499
|
+
b($.passwordMismatchError), R({ confirmPassword: !0 });
|
|
3498
3500
|
return;
|
|
3499
3501
|
}
|
|
3500
|
-
|
|
3502
|
+
u(!0), b(""), E("");
|
|
3501
3503
|
try {
|
|
3502
|
-
await l({ token:
|
|
3503
|
-
} catch (
|
|
3504
|
-
const
|
|
3505
|
-
|
|
3504
|
+
await l({ token: m, newPassword: v }), E($.resetSuccessMessage), i == null || i();
|
|
3505
|
+
} catch (q) {
|
|
3506
|
+
const W = q.message || $.errorMessage;
|
|
3507
|
+
b(W), o == null || o(W);
|
|
3506
3508
|
} finally {
|
|
3507
|
-
|
|
3509
|
+
u(!1);
|
|
3508
3510
|
}
|
|
3509
3511
|
}
|
|
3510
|
-
},
|
|
3511
|
-
...
|
|
3512
|
-
...
|
|
3513
|
-
}),
|
|
3514
|
-
...
|
|
3515
|
-
...P ?
|
|
3512
|
+
}, k = (O) => ({
|
|
3513
|
+
...g.input,
|
|
3514
|
+
...N[O] ? g.inputError : {}
|
|
3515
|
+
}), j = () => ({
|
|
3516
|
+
...g.button,
|
|
3517
|
+
...P ? g.buttonLoading : {}
|
|
3516
3518
|
});
|
|
3517
3519
|
if (t === "reset") {
|
|
3518
|
-
const
|
|
3519
|
-
return /* @__PURE__ */
|
|
3520
|
-
/* @__PURE__ */ s("h2", { style:
|
|
3521
|
-
/* @__PURE__ */ s("p", { style:
|
|
3522
|
-
/* @__PURE__ */
|
|
3523
|
-
/* @__PURE__ */
|
|
3524
|
-
/* @__PURE__ */ s("label", { style:
|
|
3520
|
+
const O = m && v && F;
|
|
3521
|
+
return /* @__PURE__ */ c("div", { className: f, style: g.container, children: [
|
|
3522
|
+
/* @__PURE__ */ s("h2", { style: g.title, children: $.resetTitle }),
|
|
3523
|
+
/* @__PURE__ */ s("p", { style: g.subtitle, children: $.resetSubtitle }),
|
|
3524
|
+
/* @__PURE__ */ c("form", { onSubmit: y, style: g.form, children: [
|
|
3525
|
+
/* @__PURE__ */ c("div", { style: g.fieldGroup, children: [
|
|
3526
|
+
/* @__PURE__ */ s("label", { style: g.label, children: $.tokenLabel }),
|
|
3525
3527
|
/* @__PURE__ */ s(
|
|
3526
3528
|
"input",
|
|
3527
3529
|
{
|
|
3528
3530
|
type: "text",
|
|
3529
|
-
value:
|
|
3530
|
-
onChange: (
|
|
3531
|
-
|
|
3531
|
+
value: m,
|
|
3532
|
+
onChange: (q) => {
|
|
3533
|
+
h(q.target.value), N.token && R((W) => ({ ...W, token: !1 }));
|
|
3532
3534
|
},
|
|
3533
|
-
placeholder:
|
|
3534
|
-
style:
|
|
3535
|
+
placeholder: $.tokenPlaceholder,
|
|
3536
|
+
style: k("token"),
|
|
3535
3537
|
disabled: P
|
|
3536
3538
|
}
|
|
3537
3539
|
)
|
|
3538
3540
|
] }),
|
|
3539
|
-
/* @__PURE__ */
|
|
3540
|
-
/* @__PURE__ */ s("label", { style:
|
|
3541
|
+
/* @__PURE__ */ c("div", { style: g.fieldGroup, children: [
|
|
3542
|
+
/* @__PURE__ */ s("label", { style: g.label, children: $.newPasswordLabel }),
|
|
3541
3543
|
/* @__PURE__ */ s(
|
|
3542
3544
|
"input",
|
|
3543
3545
|
{
|
|
3544
3546
|
type: "password",
|
|
3545
|
-
value:
|
|
3546
|
-
onChange: (
|
|
3547
|
-
I(
|
|
3547
|
+
value: v,
|
|
3548
|
+
onChange: (q) => {
|
|
3549
|
+
I(q.target.value), N.newPassword && R((W) => ({ ...W, newPassword: !1 }));
|
|
3548
3550
|
},
|
|
3549
|
-
placeholder:
|
|
3550
|
-
style:
|
|
3551
|
+
placeholder: $.newPasswordPlaceholder,
|
|
3552
|
+
style: k("newPassword"),
|
|
3551
3553
|
disabled: P
|
|
3552
3554
|
}
|
|
3553
3555
|
)
|
|
3554
3556
|
] }),
|
|
3555
|
-
/* @__PURE__ */
|
|
3556
|
-
/* @__PURE__ */ s("label", { style:
|
|
3557
|
+
/* @__PURE__ */ c("div", { style: g.fieldGroup, children: [
|
|
3558
|
+
/* @__PURE__ */ s("label", { style: g.label, children: $.confirmPasswordLabel }),
|
|
3557
3559
|
/* @__PURE__ */ s(
|
|
3558
3560
|
"input",
|
|
3559
3561
|
{
|
|
3560
3562
|
type: "password",
|
|
3561
|
-
value:
|
|
3562
|
-
onChange: (
|
|
3563
|
-
M(
|
|
3563
|
+
value: F,
|
|
3564
|
+
onChange: (q) => {
|
|
3565
|
+
M(q.target.value), N.confirmPassword && R((W) => ({ ...W, confirmPassword: !1 })), A === $.passwordMismatchError && b("");
|
|
3564
3566
|
},
|
|
3565
|
-
placeholder:
|
|
3566
|
-
style:
|
|
3567
|
+
placeholder: $.confirmPasswordPlaceholder,
|
|
3568
|
+
style: k("confirmPassword"),
|
|
3567
3569
|
disabled: P
|
|
3568
3570
|
}
|
|
3569
3571
|
)
|
|
@@ -3572,43 +3574,43 @@ function zn({
|
|
|
3572
3574
|
"button",
|
|
3573
3575
|
{
|
|
3574
3576
|
type: "submit",
|
|
3575
|
-
disabled: !
|
|
3577
|
+
disabled: !O || P,
|
|
3576
3578
|
style: {
|
|
3577
|
-
...
|
|
3578
|
-
...!
|
|
3579
|
+
...j(),
|
|
3580
|
+
...!O || P ? g.buttonDisabled : {}
|
|
3579
3581
|
},
|
|
3580
|
-
children: P ?
|
|
3582
|
+
children: P ? $.resetLoadingText : $.resetSubmitButton
|
|
3581
3583
|
}
|
|
3582
3584
|
),
|
|
3583
|
-
A && /* @__PURE__ */ s("div", { style:
|
|
3584
|
-
L && /* @__PURE__ */ s("div", { style:
|
|
3585
|
+
A && /* @__PURE__ */ s("div", { style: g.errorText, children: A }),
|
|
3586
|
+
L && /* @__PURE__ */ s("div", { style: g.successText, children: L })
|
|
3585
3587
|
] }),
|
|
3586
|
-
/* @__PURE__ */
|
|
3587
|
-
/* @__PURE__ */ s("a", { onClick: a, style:
|
|
3588
|
-
p && /* @__PURE__ */
|
|
3588
|
+
/* @__PURE__ */ c("div", { style: g.linkContainer, children: [
|
|
3589
|
+
/* @__PURE__ */ s("a", { onClick: a, style: g.link, children: $.backToLoginLink }),
|
|
3590
|
+
p && /* @__PURE__ */ c(_, { children: [
|
|
3589
3591
|
/* @__PURE__ */ s("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3590
|
-
/* @__PURE__ */ s("a", { onClick: () => p("request"), style:
|
|
3592
|
+
/* @__PURE__ */ s("a", { onClick: () => p("request"), style: g.link, children: "Request New Link" })
|
|
3591
3593
|
] })
|
|
3592
3594
|
] })
|
|
3593
3595
|
] });
|
|
3594
3596
|
}
|
|
3595
|
-
const
|
|
3596
|
-
return /* @__PURE__ */
|
|
3597
|
-
/* @__PURE__ */ s("h2", { style:
|
|
3598
|
-
/* @__PURE__ */ s("p", { style:
|
|
3599
|
-
/* @__PURE__ */
|
|
3600
|
-
/* @__PURE__ */
|
|
3601
|
-
/* @__PURE__ */ s("label", { style:
|
|
3597
|
+
const Z = w;
|
|
3598
|
+
return /* @__PURE__ */ c("div", { className: f, style: g.container, children: [
|
|
3599
|
+
/* @__PURE__ */ s("h2", { style: g.title, children: $.title }),
|
|
3600
|
+
/* @__PURE__ */ s("p", { style: g.subtitle, children: $.subtitle }),
|
|
3601
|
+
/* @__PURE__ */ c("form", { onSubmit: S, style: g.form, children: [
|
|
3602
|
+
/* @__PURE__ */ c("div", { style: g.fieldGroup, children: [
|
|
3603
|
+
/* @__PURE__ */ s("label", { style: g.label, children: $.emailLabel }),
|
|
3602
3604
|
/* @__PURE__ */ s(
|
|
3603
3605
|
"input",
|
|
3604
3606
|
{
|
|
3605
3607
|
type: "email",
|
|
3606
3608
|
value: w,
|
|
3607
|
-
onChange: (
|
|
3608
|
-
|
|
3609
|
+
onChange: (O) => {
|
|
3610
|
+
d(O.target.value), N.email && R((q) => ({ ...q, email: !1 }));
|
|
3609
3611
|
},
|
|
3610
|
-
placeholder:
|
|
3611
|
-
style:
|
|
3612
|
+
placeholder: $.emailPlaceholder,
|
|
3613
|
+
style: k("email"),
|
|
3612
3614
|
disabled: P
|
|
3613
3615
|
}
|
|
3614
3616
|
)
|
|
@@ -3617,27 +3619,27 @@ function zn({
|
|
|
3617
3619
|
"button",
|
|
3618
3620
|
{
|
|
3619
3621
|
type: "submit",
|
|
3620
|
-
disabled: !
|
|
3622
|
+
disabled: !Z || P,
|
|
3621
3623
|
style: {
|
|
3622
|
-
...
|
|
3623
|
-
...!
|
|
3624
|
+
...j(),
|
|
3625
|
+
...!Z || P ? g.buttonDisabled : {}
|
|
3624
3626
|
},
|
|
3625
|
-
children: P ?
|
|
3627
|
+
children: P ? $.loadingText : $.submitButton
|
|
3626
3628
|
}
|
|
3627
3629
|
),
|
|
3628
|
-
A && /* @__PURE__ */ s("div", { style:
|
|
3629
|
-
L && /* @__PURE__ */ s("div", { style:
|
|
3630
|
+
A && /* @__PURE__ */ s("div", { style: g.errorText, children: A }),
|
|
3631
|
+
L && /* @__PURE__ */ s("div", { style: g.successText, children: L })
|
|
3630
3632
|
] }),
|
|
3631
|
-
/* @__PURE__ */
|
|
3632
|
-
/* @__PURE__ */ s("a", { onClick: a, style:
|
|
3633
|
-
p && /* @__PURE__ */
|
|
3633
|
+
/* @__PURE__ */ c("div", { style: g.linkContainer, children: [
|
|
3634
|
+
/* @__PURE__ */ s("a", { onClick: a, style: g.link, children: $.backToLoginLink }),
|
|
3635
|
+
p && /* @__PURE__ */ c(_, { children: [
|
|
3634
3636
|
/* @__PURE__ */ s("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3635
|
-
/* @__PURE__ */ s("a", { onClick: () => p("reset"), style:
|
|
3637
|
+
/* @__PURE__ */ s("a", { onClick: () => p("reset"), style: g.link, children: "I have a token" })
|
|
3636
3638
|
] })
|
|
3637
3639
|
] })
|
|
3638
3640
|
] });
|
|
3639
3641
|
}
|
|
3640
|
-
const
|
|
3642
|
+
const rn = () => /* @__PURE__ */ s(
|
|
3641
3643
|
"div",
|
|
3642
3644
|
{
|
|
3643
3645
|
style: {
|
|
@@ -3649,7 +3651,7 @@ const tn = () => /* @__PURE__ */ s(
|
|
|
3649
3651
|
},
|
|
3650
3652
|
children: /* @__PURE__ */ s("div", { children: "Loading..." })
|
|
3651
3653
|
}
|
|
3652
|
-
),
|
|
3654
|
+
), sn = ({ error: r, retry: e }) => /* @__PURE__ */ c(
|
|
3653
3655
|
"div",
|
|
3654
3656
|
{
|
|
3655
3657
|
style: {
|
|
@@ -3683,43 +3685,43 @@ const tn = () => /* @__PURE__ */ s(
|
|
|
3683
3685
|
]
|
|
3684
3686
|
}
|
|
3685
3687
|
);
|
|
3686
|
-
function
|
|
3688
|
+
function Vn({
|
|
3687
3689
|
children: r,
|
|
3688
3690
|
loadingFallback: e,
|
|
3689
3691
|
errorFallback: t,
|
|
3690
3692
|
requireTenant: n = !0
|
|
3691
3693
|
}) {
|
|
3692
|
-
const { isAppLoading: i, appError: o, retryApp: a } =
|
|
3693
|
-
}),
|
|
3694
|
-
o && a(),
|
|
3694
|
+
const { isAppLoading: i, appError: o, retryApp: a } = we(), p = ve(), f = Ne(), w = Ke(), d = Je(), m = (p == null ? void 0 : p.isTenantLoading) ?? !1, h = (p == null ? void 0 : p.tenantError) ?? null, v = (p == null ? void 0 : p.tenantSlug) ?? null, I = (p == null ? void 0 : p.retryTenant) ?? (() => {
|
|
3695
|
+
}), F = (f == null ? void 0 : f.isAuthReady) ?? !0, M = (w == null ? void 0 : w.isReady) ?? !0, P = (d == null ? void 0 : d.isReady) ?? !0, u = n && p && v, E = i || u && m || f && !F || w && !M || d && !P, N = o || (u ? h : null), R = () => {
|
|
3696
|
+
o && a(), h && p && I();
|
|
3695
3697
|
};
|
|
3696
3698
|
if (E)
|
|
3697
|
-
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(
|
|
3698
|
-
if (
|
|
3699
|
-
const
|
|
3700
|
-
return /* @__PURE__ */ s(_, { children:
|
|
3699
|
+
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(rn, {}) });
|
|
3700
|
+
if (N) {
|
|
3701
|
+
const U = typeof t == "function" ? t(N, R) : t || /* @__PURE__ */ s(sn, { error: N, retry: R });
|
|
3702
|
+
return /* @__PURE__ */ s(_, { children: U });
|
|
3701
3703
|
}
|
|
3702
3704
|
return /* @__PURE__ */ s(_, { children: r });
|
|
3703
3705
|
}
|
|
3704
|
-
function
|
|
3705
|
-
const { isAppLoading: e, appError: t, retryApp: n, appInfo: i } =
|
|
3706
|
-
}), I = (a == null ? void 0 : a.isAuthReady) ?? !0,
|
|
3706
|
+
function jn(r = !0) {
|
|
3707
|
+
const { isAppLoading: e, appError: t, retryApp: n, appInfo: i } = we(), o = ve(), a = Ne(), p = Ke(), f = Je(), w = (o == null ? void 0 : o.isTenantLoading) ?? !1, d = (o == null ? void 0 : o.tenantError) ?? null, m = (o == null ? void 0 : o.tenant) ?? null, h = (o == null ? void 0 : o.tenantSlug) ?? null, v = (o == null ? void 0 : o.retryTenant) ?? (() => {
|
|
3708
|
+
}), I = (a == null ? void 0 : a.isAuthReady) ?? !0, F = (p == null ? void 0 : p.isReady) ?? !0, M = (f == null ? void 0 : f.isReady) ?? !0, P = r && o && h, L = e || P && w || a && !I || p && !F || f && !M, E = t || (P ? d : null);
|
|
3707
3709
|
return {
|
|
3708
3710
|
isLoading: L,
|
|
3709
3711
|
error: E,
|
|
3710
|
-
isReady: !L && !E && i !== null && (!P ||
|
|
3712
|
+
isReady: !L && !E && i !== null && (!P || m !== null),
|
|
3711
3713
|
retry: () => {
|
|
3712
|
-
t && n(),
|
|
3714
|
+
t && n(), d && o && v();
|
|
3713
3715
|
},
|
|
3714
3716
|
// Individual states
|
|
3715
3717
|
app: { isLoading: e, error: t, data: i },
|
|
3716
|
-
tenant: o ? { isLoading: w, error:
|
|
3718
|
+
tenant: o ? { isLoading: w, error: d, data: m } : null,
|
|
3717
3719
|
auth: a ? { isReady: I } : null,
|
|
3718
|
-
featureFlags: p ? { isReady:
|
|
3720
|
+
featureFlags: p ? { isReady: F } : null,
|
|
3719
3721
|
subscription: f ? { isReady: M } : null
|
|
3720
3722
|
};
|
|
3721
3723
|
}
|
|
3722
|
-
function
|
|
3724
|
+
function Gn({
|
|
3723
3725
|
tenants: r,
|
|
3724
3726
|
currentTenantId: e,
|
|
3725
3727
|
onSelect: t,
|
|
@@ -3732,34 +3734,34 @@ function Vn({
|
|
|
3732
3734
|
showCurrentTenant: w = !0
|
|
3733
3735
|
}) {
|
|
3734
3736
|
var A;
|
|
3735
|
-
const
|
|
3736
|
-
|
|
3737
|
+
const d = Ne(), [m, h] = x(!1), v = Ge(null), I = r ?? (d == null ? void 0 : d.userTenants) ?? [], F = e ?? ((A = d == null ? void 0 : d.currentUser) == null ? void 0 : A.tenantId) ?? null, M = async (b) => {
|
|
3738
|
+
h(!1), t ? t(b) : d != null && d.switchToTenant && await d.switchToTenant(b);
|
|
3737
3739
|
};
|
|
3738
|
-
|
|
3739
|
-
const
|
|
3740
|
-
|
|
3740
|
+
ee(() => {
|
|
3741
|
+
const b = (L) => {
|
|
3742
|
+
v.current && !v.current.contains(L.target) && h(!1);
|
|
3741
3743
|
};
|
|
3742
|
-
return document.addEventListener("mousedown",
|
|
3744
|
+
return document.addEventListener("mousedown", b), () => document.removeEventListener("mousedown", b);
|
|
3743
3745
|
}, []);
|
|
3744
|
-
const P = I.find((
|
|
3746
|
+
const P = I.find((b) => b.id === F);
|
|
3745
3747
|
if (I.length === 0)
|
|
3746
3748
|
return null;
|
|
3747
3749
|
if (I.length === 1 && w)
|
|
3748
3750
|
return /* @__PURE__ */ s("div", { className: n, children: /* @__PURE__ */ s("span", { children: I[0].name }) });
|
|
3749
|
-
const
|
|
3750
|
-
|
|
3751
|
-
|
|
3751
|
+
const u = (b, L) => /* @__PURE__ */ c("span", { style: { fontWeight: L ? "bold" : "normal" }, children: [
|
|
3752
|
+
b.name,
|
|
3753
|
+
b.role && /* @__PURE__ */ c("span", { style: { opacity: 0.7, marginLeft: 8 }, children: [
|
|
3752
3754
|
"(",
|
|
3753
|
-
|
|
3755
|
+
b.role,
|
|
3754
3756
|
")"
|
|
3755
3757
|
] })
|
|
3756
3758
|
] });
|
|
3757
|
-
return /* @__PURE__ */
|
|
3758
|
-
/* @__PURE__ */
|
|
3759
|
+
return /* @__PURE__ */ c("div", { ref: v, className: n, style: { position: "relative" }, children: [
|
|
3760
|
+
/* @__PURE__ */ c(
|
|
3759
3761
|
"button",
|
|
3760
3762
|
{
|
|
3761
3763
|
type: "button",
|
|
3762
|
-
onClick: () => !f &&
|
|
3764
|
+
onClick: () => !f && h(!m),
|
|
3763
3765
|
disabled: f,
|
|
3764
3766
|
style: {
|
|
3765
3767
|
cursor: f ? "not-allowed" : "pointer",
|
|
@@ -3767,11 +3769,11 @@ function Vn({
|
|
|
3767
3769
|
},
|
|
3768
3770
|
children: [
|
|
3769
3771
|
P ? P.name : p,
|
|
3770
|
-
/* @__PURE__ */ s("span", { style: { marginLeft: 8 }, children:
|
|
3772
|
+
/* @__PURE__ */ s("span", { style: { marginLeft: 8 }, children: m ? "▲" : "▼" })
|
|
3771
3773
|
]
|
|
3772
3774
|
}
|
|
3773
3775
|
),
|
|
3774
|
-
|
|
3776
|
+
m && /* @__PURE__ */ s(
|
|
3775
3777
|
"div",
|
|
3776
3778
|
{
|
|
3777
3779
|
className: i,
|
|
@@ -3788,13 +3790,13 @@ function Vn({
|
|
|
3788
3790
|
maxHeight: 300,
|
|
3789
3791
|
overflowY: "auto"
|
|
3790
3792
|
},
|
|
3791
|
-
children: I.map((
|
|
3792
|
-
const L =
|
|
3793
|
+
children: I.map((b) => {
|
|
3794
|
+
const L = b.id === F;
|
|
3793
3795
|
return /* @__PURE__ */ s(
|
|
3794
3796
|
"div",
|
|
3795
3797
|
{
|
|
3796
3798
|
className: o,
|
|
3797
|
-
onClick: () => M(
|
|
3799
|
+
onClick: () => M(b.id),
|
|
3798
3800
|
style: {
|
|
3799
3801
|
padding: "8px 12px",
|
|
3800
3802
|
cursor: "pointer",
|
|
@@ -3806,16 +3808,16 @@ function Vn({
|
|
|
3806
3808
|
onMouseLeave: (E) => {
|
|
3807
3809
|
L || (E.target.style.backgroundColor = "transparent");
|
|
3808
3810
|
},
|
|
3809
|
-
children: a ? a(
|
|
3811
|
+
children: a ? a(b, L) : u(b, L)
|
|
3810
3812
|
},
|
|
3811
|
-
|
|
3813
|
+
b.id
|
|
3812
3814
|
);
|
|
3813
3815
|
})
|
|
3814
3816
|
}
|
|
3815
3817
|
)
|
|
3816
3818
|
] });
|
|
3817
3819
|
}
|
|
3818
|
-
class
|
|
3820
|
+
class Zn {
|
|
3819
3821
|
constructor(e, t) {
|
|
3820
3822
|
this.httpService = e, this.sessionManager = t;
|
|
3821
3823
|
}
|
|
@@ -3883,7 +3885,7 @@ class jn {
|
|
|
3883
3885
|
};
|
|
3884
3886
|
}
|
|
3885
3887
|
}
|
|
3886
|
-
class
|
|
3888
|
+
class Kn {
|
|
3887
3889
|
constructor(e, t) {
|
|
3888
3890
|
this.httpService = e, this.sessionManager = t;
|
|
3889
3891
|
}
|
|
@@ -3934,7 +3936,7 @@ class Gn {
|
|
|
3934
3936
|
});
|
|
3935
3937
|
}
|
|
3936
3938
|
}
|
|
3937
|
-
class
|
|
3939
|
+
class Jn {
|
|
3938
3940
|
constructor(e) {
|
|
3939
3941
|
this.httpService = e;
|
|
3940
3942
|
}
|
|
@@ -3943,7 +3945,7 @@ class Zn {
|
|
|
3943
3945
|
return await this.httpService.get("/health");
|
|
3944
3946
|
}
|
|
3945
3947
|
}
|
|
3946
|
-
class
|
|
3948
|
+
class Yn {
|
|
3947
3949
|
// Date string to Date object
|
|
3948
3950
|
static toDate(e) {
|
|
3949
3951
|
return new Date(e);
|
|
@@ -4065,136 +4067,136 @@ class Kn {
|
|
|
4065
4067
|
}), t;
|
|
4066
4068
|
}
|
|
4067
4069
|
}
|
|
4068
|
-
const
|
|
4069
|
-
function
|
|
4070
|
+
const Xe = "returnTo", Ie = "zone_return_to", Me = "zone_return_to";
|
|
4071
|
+
function Qn(r = {}) {
|
|
4070
4072
|
const {
|
|
4071
4073
|
zoneRoots: e = {},
|
|
4072
|
-
returnToParam: t =
|
|
4074
|
+
returnToParam: t = Xe,
|
|
4073
4075
|
returnToStorage: n = "url"
|
|
4074
|
-
} = r, i =
|
|
4076
|
+
} = r, i = gt(), [o, a] = pt(), { isAuthenticated: p, currentUser: f } = ce(), { tenant: w } = he(), d = J(() => ({ ...Ue, ...e }), [e]), m = !!w, h = f == null ? void 0 : f.userType, v = J(() => {
|
|
4075
4077
|
switch (n) {
|
|
4076
4078
|
case "url":
|
|
4077
4079
|
return o.get(t);
|
|
4078
4080
|
case "session":
|
|
4079
|
-
return sessionStorage.getItem(
|
|
4081
|
+
return sessionStorage.getItem(Ie);
|
|
4080
4082
|
case "local":
|
|
4081
|
-
return localStorage.getItem(
|
|
4083
|
+
return localStorage.getItem(Me);
|
|
4082
4084
|
default:
|
|
4083
4085
|
return null;
|
|
4084
4086
|
}
|
|
4085
|
-
}, [n, o, t]), I =
|
|
4087
|
+
}, [n, o, t]), I = se(() => {
|
|
4086
4088
|
switch (n) {
|
|
4087
4089
|
case "url": {
|
|
4088
|
-
const
|
|
4089
|
-
|
|
4090
|
+
const u = new URLSearchParams(o);
|
|
4091
|
+
u.delete(t), a(u, { replace: !0 });
|
|
4090
4092
|
break;
|
|
4091
4093
|
}
|
|
4092
4094
|
case "session":
|
|
4093
|
-
sessionStorage.removeItem(
|
|
4095
|
+
sessionStorage.removeItem(Ie);
|
|
4094
4096
|
break;
|
|
4095
4097
|
case "local":
|
|
4096
|
-
localStorage.removeItem(
|
|
4098
|
+
localStorage.removeItem(Me);
|
|
4097
4099
|
break;
|
|
4098
4100
|
}
|
|
4099
|
-
}, [n, o, t, a]),
|
|
4100
|
-
(
|
|
4101
|
+
}, [n, o, t, a]), F = se(
|
|
4102
|
+
(u) => {
|
|
4101
4103
|
switch (n) {
|
|
4102
4104
|
case "url": {
|
|
4103
4105
|
const A = new URLSearchParams(o);
|
|
4104
|
-
A.set(t,
|
|
4106
|
+
A.set(t, u), a(A, { replace: !0 });
|
|
4105
4107
|
break;
|
|
4106
4108
|
}
|
|
4107
4109
|
case "session":
|
|
4108
|
-
sessionStorage.setItem(
|
|
4110
|
+
sessionStorage.setItem(Ie, u);
|
|
4109
4111
|
break;
|
|
4110
4112
|
case "local":
|
|
4111
|
-
localStorage.setItem(
|
|
4113
|
+
localStorage.setItem(Me, u);
|
|
4112
4114
|
break;
|
|
4113
4115
|
}
|
|
4114
4116
|
},
|
|
4115
4117
|
[n, o, t, a]
|
|
4116
|
-
), M =
|
|
4117
|
-
(
|
|
4118
|
-
const A = u
|
|
4118
|
+
), M = se(
|
|
4119
|
+
(u) => {
|
|
4120
|
+
const A = d[u] || d.default;
|
|
4119
4121
|
i(A);
|
|
4120
4122
|
},
|
|
4121
|
-
[i,
|
|
4122
|
-
), P =
|
|
4123
|
+
[i, d]
|
|
4124
|
+
), P = se(() => m ? p ? h === ie.TENANT_ADMIN ? d.tenantAdmin : d.tenantUser : d.tenantGuest : p ? h === ie.TENANT_ADMIN ? d.publicAdmin : d.publicUser : d.publicGuest, [m, p, h, d]);
|
|
4123
4125
|
return {
|
|
4124
|
-
returnToUrl:
|
|
4126
|
+
returnToUrl: v,
|
|
4125
4127
|
clearReturnTo: I,
|
|
4126
|
-
setReturnTo:
|
|
4128
|
+
setReturnTo: F,
|
|
4127
4129
|
navigateToZone: M,
|
|
4128
4130
|
getSmartRedirect: P
|
|
4129
4131
|
};
|
|
4130
4132
|
}
|
|
4131
|
-
function
|
|
4133
|
+
function Xn(r, e, t = Xe, n = "url") {
|
|
4132
4134
|
if (!e || n !== "url")
|
|
4133
4135
|
return r;
|
|
4134
4136
|
const i = new URL(r, window.location.origin);
|
|
4135
4137
|
return i.searchParams.set(t, e), i.pathname + i.search;
|
|
4136
4138
|
}
|
|
4137
4139
|
export {
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4140
|
+
Fn as AdminZone,
|
|
4141
|
+
Yn as ApiMappers,
|
|
4142
|
+
qe as AppApiService,
|
|
4143
|
+
Vn as AppLoader,
|
|
4144
|
+
pn as AppProvider,
|
|
4145
|
+
ft as AuthApiService,
|
|
4146
|
+
bn as AuthProvider,
|
|
4147
|
+
Ln as AuthenticatedZone,
|
|
4148
|
+
Ye as DEFAULT_ZONE_PRESETS,
|
|
4149
|
+
Ue as DEFAULT_ZONE_ROOTS,
|
|
4150
|
+
Bn as FeatureFlag,
|
|
4151
|
+
xt as FeatureFlagApiService,
|
|
4152
|
+
Sn as FeatureFlagProvider,
|
|
4153
|
+
En as GuestZone,
|
|
4154
|
+
Jn as HealthApiService,
|
|
4155
|
+
ae as HttpService,
|
|
4156
|
+
Rn as LandingRoute,
|
|
4157
|
+
qn as LoginForm,
|
|
4158
|
+
zn as MagicLinkForm,
|
|
4159
|
+
_n as MagicLinkVerify,
|
|
4160
|
+
Dn as OpenZone,
|
|
4161
|
+
Wn as PasswordRecoveryForm,
|
|
4162
|
+
Zn as PermissionApiService,
|
|
4163
|
+
xn as Protected,
|
|
4164
|
+
An as ProtectedRoute,
|
|
4165
|
+
Mn as PublicZone,
|
|
4166
|
+
Oe as RoleApiService,
|
|
4167
|
+
Tn as RoutingProvider,
|
|
4168
|
+
Re as SessionManager,
|
|
4169
|
+
On as SignupForm,
|
|
4170
|
+
Pt as SubscriptionApiService,
|
|
4171
|
+
Hn as SubscriptionGuard,
|
|
4172
|
+
Kn as SubscriptionPlanApiService,
|
|
4173
|
+
vn as SubscriptionProvider,
|
|
4174
|
+
me as TenantApiService,
|
|
4175
|
+
Cn as TenantAuthenticatedZone,
|
|
4176
|
+
$n as TenantGuestZone,
|
|
4177
|
+
Un as TenantOpenZone,
|
|
4178
|
+
mn as TenantProvider,
|
|
4179
|
+
Pn as TenantRoute,
|
|
4180
|
+
Gn as TenantSelector,
|
|
4181
|
+
In as TenantZone,
|
|
4182
|
+
mt as UserApiService,
|
|
4183
|
+
ie as UserType,
|
|
4184
|
+
Nn as UserZone,
|
|
4185
|
+
le as ZoneRoute,
|
|
4186
|
+
Xn as buildRedirectUrl,
|
|
4187
|
+
fn as useApi,
|
|
4188
|
+
we as useApp,
|
|
4189
|
+
jn as useAppLoaderState,
|
|
4190
|
+
ce as useAuth,
|
|
4191
|
+
At as useFeatureFlags,
|
|
4192
|
+
kn as useRouting,
|
|
4193
|
+
It as useRoutingOptional,
|
|
4194
|
+
wn as useSettings,
|
|
4195
|
+
Rt as useSubscription,
|
|
4194
4196
|
he as useTenant,
|
|
4195
4197
|
ge as useTenantInfo,
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4198
|
+
ve as useTenantOptional,
|
|
4199
|
+
yn as useTenantSettings,
|
|
4200
|
+
Qn as useZoneNavigation
|
|
4199
4201
|
};
|
|
4200
4202
|
//# sourceMappingURL=index.es.js.map
|