@skylabs-digital/react-identity-access 2.15.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 +1141 -1130
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/providers/AuthProvider.d.ts.map +1 -1
- package/dist/providers/TenantProvider.d.ts +2 -1
- package/dist/providers/TenantProvider.d.ts.map +1 -1
- package/dist/utils/tenantDetection.d.ts +2 -1
- package/dist/utils/tenantDetection.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,32 +124,32 @@ 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
|
};
|
|
138
138
|
},
|
|
139
139
|
[r.cache, r.appId]
|
|
140
|
-
), [n, i] =
|
|
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] =
|
|
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 xe {
|
|
|
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
|
|
646
|
-
const { tenantMode: n, baseDomain: i, selectorParam: o } = r;
|
|
647
|
-
return n === "subdomain" ?
|
|
645
|
+
function bt(r, e, t) {
|
|
646
|
+
const { tenantMode: n, baseDomain: i, selectorParam: o, fixedTenantSlug: a } = r;
|
|
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,131 +693,133 @@ 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,
|
|
702
|
-
selectorParam: r.selectorParam
|
|
702
|
+
selectorParam: r.selectorParam,
|
|
703
|
+
fixedTenantSlug: r.fixedTenantSlug
|
|
703
704
|
},
|
|
704
705
|
{
|
|
705
706
|
hostname: window.location.hostname,
|
|
706
707
|
search: window.location.search
|
|
707
708
|
},
|
|
708
709
|
window.localStorage
|
|
709
|
-
), [r.tenantMode, r.baseDomain, r.selectorParam]), [a, p] =
|
|
710
|
+
), [r.tenantMode, r.baseDomain, r.selectorParam, r.fixedTenantSlug]), [a, p] = x(() => o()), f = J(
|
|
710
711
|
() => {
|
|
711
|
-
var
|
|
712
|
+
var g, C, T;
|
|
712
713
|
return {
|
|
713
|
-
enabled: ((
|
|
714
|
-
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,
|
|
715
716
|
// 5 minutes default
|
|
716
|
-
storageKey: ((
|
|
717
|
+
storageKey: ((T = r.cache) == null ? void 0 : T.storageKey) ?? `tenant_cache_${a || "default"}`
|
|
717
718
|
};
|
|
718
719
|
},
|
|
719
720
|
[r.cache, a]
|
|
720
|
-
), [w,
|
|
721
|
+
), [w, d] = x(() => {
|
|
721
722
|
if (r.initialTenant) return r.initialTenant;
|
|
722
723
|
if (!f.enabled || !a) return null;
|
|
723
724
|
try {
|
|
724
|
-
const
|
|
725
|
-
if (!
|
|
726
|
-
const
|
|
727
|
-
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);
|
|
728
729
|
} catch {
|
|
729
730
|
return null;
|
|
730
731
|
}
|
|
731
|
-
}), [
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
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
|
+
if (r.tenantMode === "fixed") return;
|
|
735
|
+
const g = o();
|
|
736
|
+
p(g);
|
|
737
|
+
}, [o, r.tenantMode]);
|
|
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))
|
|
739
741
|
try {
|
|
740
|
-
|
|
741
|
-
const
|
|
742
|
-
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)
|
|
743
745
|
try {
|
|
744
|
-
const
|
|
745
|
-
data:
|
|
746
|
+
const k = {
|
|
747
|
+
data: y,
|
|
746
748
|
timestamp: Date.now(),
|
|
747
|
-
tenantSlug:
|
|
749
|
+
tenantSlug: g
|
|
748
750
|
};
|
|
749
|
-
localStorage.setItem(f.storageKey, JSON.stringify(
|
|
750
|
-
} catch (
|
|
751
|
-
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);
|
|
752
754
|
}
|
|
753
|
-
} catch (
|
|
754
|
-
const
|
|
755
|
-
I(
|
|
755
|
+
} catch (T) {
|
|
756
|
+
const S = T instanceof Error ? T : new Error("Failed to load tenant information");
|
|
757
|
+
I(S), d(null);
|
|
756
758
|
} finally {
|
|
757
|
-
|
|
759
|
+
h(!1);
|
|
758
760
|
}
|
|
759
761
|
},
|
|
760
762
|
[t, i, f, w]
|
|
761
|
-
),
|
|
763
|
+
), N = se(async () => {
|
|
762
764
|
if (!(!f.enabled || !w || !a))
|
|
763
765
|
try {
|
|
764
|
-
const
|
|
765
|
-
if (!
|
|
766
|
-
const
|
|
767
|
-
if (Date.now() -
|
|
768
|
-
const
|
|
769
|
-
|
|
770
|
-
const
|
|
771
|
-
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,
|
|
772
774
|
timestamp: Date.now(),
|
|
773
775
|
tenantSlug: a
|
|
774
776
|
};
|
|
775
|
-
localStorage.setItem(f.storageKey, JSON.stringify(
|
|
777
|
+
localStorage.setItem(f.storageKey, JSON.stringify(j));
|
|
776
778
|
}
|
|
777
|
-
} catch (
|
|
778
|
-
console.warn("Background tenant refresh failed:",
|
|
779
|
+
} catch (g) {
|
|
780
|
+
console.warn("Background tenant refresh failed:", g);
|
|
779
781
|
}
|
|
780
|
-
}, [t, i, f, w, a]), R =
|
|
782
|
+
}, [t, i, f, w, a]), R = se(async () => {
|
|
781
783
|
if (w != null && w.id)
|
|
782
784
|
try {
|
|
783
|
-
|
|
784
|
-
const
|
|
785
|
-
M(
|
|
786
|
-
} catch (
|
|
787
|
-
const
|
|
788
|
-
|
|
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);
|
|
789
791
|
} finally {
|
|
790
|
-
|
|
792
|
+
u(!1);
|
|
791
793
|
}
|
|
792
|
-
}, [t, w]),
|
|
794
|
+
}, [t, w]), U = se(() => {
|
|
793
795
|
R();
|
|
794
|
-
}, [R]), l =
|
|
795
|
-
(
|
|
796
|
+
}, [R]), l = se(
|
|
797
|
+
(g) => {
|
|
796
798
|
if (!L)
|
|
797
799
|
return { isValid: !0, errors: [] };
|
|
798
|
-
const
|
|
800
|
+
const C = [];
|
|
799
801
|
try {
|
|
800
|
-
return L.properties && Object.entries(L.properties).forEach(([
|
|
801
|
-
var
|
|
802
|
-
const
|
|
803
|
-
if ((
|
|
804
|
-
|
|
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`);
|
|
805
807
|
return;
|
|
806
808
|
}
|
|
807
|
-
if (
|
|
808
|
-
if (
|
|
809
|
-
const
|
|
810
|
-
|
|
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`);
|
|
811
813
|
}
|
|
812
|
-
|
|
813
|
-
`Field '${
|
|
814
|
-
),
|
|
815
|
-
`Field '${
|
|
816
|
-
),
|
|
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(", ")}`);
|
|
817
819
|
}
|
|
818
820
|
}), {
|
|
819
|
-
isValid:
|
|
820
|
-
errors:
|
|
821
|
+
isValid: C.length === 0,
|
|
822
|
+
errors: C
|
|
821
823
|
};
|
|
822
824
|
} catch {
|
|
823
825
|
return {
|
|
@@ -828,88 +830,95 @@ function pn({ config: r, children: e }) {
|
|
|
828
830
|
},
|
|
829
831
|
[L]
|
|
830
832
|
);
|
|
831
|
-
|
|
832
|
-
!r.initialTenant && a ? w ?
|
|
833
|
-
}, [r.initialTenant, a, w, E,
|
|
834
|
-
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));
|
|
835
837
|
}, [w == null ? void 0 : w.id, R]);
|
|
836
|
-
const D =
|
|
837
|
-
(
|
|
838
|
-
const { mode:
|
|
839
|
-
if (
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
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
|
+
console.warn(
|
|
843
|
+
"[TenantProvider] switchTenant is a no-op in fixed mode. Tenant is always:",
|
|
844
|
+
r.fixedTenantSlug
|
|
845
|
+
), y && (window.location.href = y);
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
if (localStorage.setItem("tenant", g), k === "subdomain") {
|
|
849
|
+
const j = window.location.hostname, Z = St(
|
|
850
|
+
g,
|
|
851
|
+
j,
|
|
843
852
|
r.baseDomain
|
|
844
853
|
);
|
|
845
|
-
if (!
|
|
854
|
+
if (!Z) {
|
|
846
855
|
console.warn(
|
|
847
856
|
"[TenantProvider] Cannot switch subdomain, invalid hostname:",
|
|
848
|
-
|
|
857
|
+
j
|
|
849
858
|
);
|
|
850
859
|
return;
|
|
851
860
|
}
|
|
852
|
-
const
|
|
853
|
-
new URLSearchParams(window.location.search).forEach((
|
|
854
|
-
|
|
855
|
-
}),
|
|
856
|
-
} else if (
|
|
857
|
-
const
|
|
858
|
-
if (
|
|
859
|
-
const
|
|
860
|
-
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;
|
|
861
870
|
} else {
|
|
862
|
-
const
|
|
863
|
-
window.history.pushState({}, "",
|
|
871
|
+
const O = `${j}?${Z.toString()}${window.location.hash}`;
|
|
872
|
+
window.history.pushState({}, "", O), p(g), E(g);
|
|
864
873
|
}
|
|
865
874
|
}
|
|
866
875
|
},
|
|
867
876
|
[r.tenantMode, r.selectorParam, r.baseDomain, E]
|
|
868
|
-
),
|
|
877
|
+
), $ = J(() => ({
|
|
869
878
|
// Tenant info
|
|
870
879
|
tenant: w,
|
|
871
880
|
tenantSlug: a,
|
|
872
|
-
isTenantLoading:
|
|
873
|
-
tenantError:
|
|
881
|
+
isTenantLoading: m,
|
|
882
|
+
tenantError: v,
|
|
874
883
|
retryTenant: () => {
|
|
875
884
|
a && E(a);
|
|
876
885
|
},
|
|
877
886
|
// Settings
|
|
878
|
-
settings:
|
|
887
|
+
settings: F,
|
|
879
888
|
settingsSchema: L,
|
|
880
889
|
isSettingsLoading: P,
|
|
881
|
-
settingsError:
|
|
890
|
+
settingsError: A,
|
|
882
891
|
// Actions
|
|
883
|
-
refreshSettings:
|
|
892
|
+
refreshSettings: U,
|
|
884
893
|
switchTenant: D,
|
|
885
894
|
// Validation
|
|
886
895
|
validateSettings: l
|
|
887
896
|
}), [
|
|
888
897
|
w,
|
|
889
898
|
a,
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
899
|
+
m,
|
|
900
|
+
v,
|
|
901
|
+
F,
|
|
893
902
|
L,
|
|
894
903
|
P,
|
|
895
|
-
|
|
896
|
-
|
|
904
|
+
A,
|
|
905
|
+
U,
|
|
897
906
|
D,
|
|
898
907
|
l
|
|
899
908
|
]);
|
|
900
|
-
return /* @__PURE__ */ s(
|
|
909
|
+
return /* @__PURE__ */ s(Ee.Provider, { value: $, children: e });
|
|
901
910
|
}
|
|
902
911
|
function he() {
|
|
903
|
-
const r =
|
|
912
|
+
const r = oe(Ee);
|
|
904
913
|
if (!r)
|
|
905
914
|
throw new Error("useTenant must be used within a TenantProvider");
|
|
906
915
|
return r;
|
|
907
916
|
}
|
|
908
|
-
function
|
|
909
|
-
return
|
|
917
|
+
function ve() {
|
|
918
|
+
return oe(Ee);
|
|
910
919
|
}
|
|
911
|
-
const
|
|
912
|
-
function
|
|
920
|
+
const yn = he;
|
|
921
|
+
function wn() {
|
|
913
922
|
const { settings: r, settingsSchema: e, isSettingsLoading: t, settingsError: n, validateSettings: i } = he();
|
|
914
923
|
return {
|
|
915
924
|
settings: r,
|
|
@@ -929,305 +938,305 @@ function ge() {
|
|
|
929
938
|
retry: i
|
|
930
939
|
};
|
|
931
940
|
}
|
|
932
|
-
const
|
|
933
|
-
function
|
|
934
|
-
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(() => {
|
|
935
944
|
try {
|
|
936
|
-
const
|
|
937
|
-
return
|
|
945
|
+
const G = localStorage.getItem("userTenants");
|
|
946
|
+
return G ? JSON.parse(G) : [];
|
|
938
947
|
} catch {
|
|
939
948
|
return [];
|
|
940
949
|
}
|
|
941
|
-
}), [L, E] =
|
|
942
|
-
|
|
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(
|
|
943
952
|
"[AuthProvider] SYNC: URL tokens found, will block isAuthReady until user loaded"
|
|
944
953
|
));
|
|
945
|
-
const [R,
|
|
946
|
-
const
|
|
947
|
-
return console.log("[AuthProvider] SYNC: isLoadingAfterUrlTokens initial:",
|
|
948
|
-
}), l =
|
|
949
|
-
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({
|
|
950
959
|
tenantSlug: o,
|
|
951
960
|
onRefreshFailed: r.onRefreshFailed,
|
|
952
961
|
baseUrl: n
|
|
953
962
|
});
|
|
954
|
-
return
|
|
955
|
-
accessToken:
|
|
956
|
-
refreshToken:
|
|
957
|
-
expiresIn:
|
|
958
|
-
}), console.log("[AuthProvider] SYNC: Session valid:",
|
|
959
|
-
}, [o, n, r.onRefreshFailed]), D =
|
|
960
|
-
const
|
|
961
|
-
return
|
|
962
|
-
}, [n, l]),
|
|
963
|
-
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) => {
|
|
964
973
|
try {
|
|
965
974
|
if (!l.hasValidSession())
|
|
966
975
|
return;
|
|
967
976
|
const z = Date.now();
|
|
968
|
-
if (!
|
|
977
|
+
if (!H && z - P < q && m)
|
|
969
978
|
return;
|
|
970
|
-
const
|
|
971
|
-
if (!
|
|
979
|
+
const V = l.getUserId();
|
|
980
|
+
if (!V) {
|
|
972
981
|
console.warn("[AuthProvider] No userId available in token or storage");
|
|
973
982
|
return;
|
|
974
983
|
}
|
|
975
984
|
I(!0), M(null);
|
|
976
|
-
const
|
|
977
|
-
|
|
985
|
+
const Y = await S.getUserById(V);
|
|
986
|
+
h(Y), l.setUser(Y), u(Date.now());
|
|
978
987
|
} catch (z) {
|
|
979
988
|
const Q = z instanceof Error ? z : new Error("Failed to load user data");
|
|
980
989
|
M(Q), console.error("[AuthProvider] Failed to load user data:", Q);
|
|
981
990
|
} finally {
|
|
982
991
|
I(!1);
|
|
983
992
|
}
|
|
984
|
-
},
|
|
985
|
-
await
|
|
986
|
-
},
|
|
987
|
-
var
|
|
988
|
-
const { username: z, password: Q, tenantSlug:
|
|
989
|
-
let
|
|
990
|
-
|
|
991
|
-
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({
|
|
992
1001
|
username: z,
|
|
993
1002
|
password: Q,
|
|
994
1003
|
appId: t,
|
|
995
|
-
tenantId:
|
|
996
|
-
}),
|
|
997
|
-
if (
|
|
998
|
-
tenantSlug:
|
|
1004
|
+
tenantId: te
|
|
1005
|
+
}), fe = V && V !== o;
|
|
1006
|
+
if (fe && (re = new Re({
|
|
1007
|
+
tenantSlug: ne,
|
|
999
1008
|
baseUrl: n
|
|
1000
|
-
})),
|
|
1001
|
-
accessToken:
|
|
1002
|
-
refreshToken:
|
|
1003
|
-
expiresIn:
|
|
1004
|
-
}),
|
|
1005
|
-
|
|
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);
|
|
1006
1015
|
try {
|
|
1007
|
-
await
|
|
1008
|
-
} catch (
|
|
1009
|
-
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);
|
|
1010
1019
|
}
|
|
1011
1020
|
}
|
|
1012
|
-
if (
|
|
1013
|
-
|
|
1021
|
+
if (K.tenants && K.tenants.length > 0) {
|
|
1022
|
+
b(K.tenants);
|
|
1014
1023
|
try {
|
|
1015
|
-
localStorage.setItem("userTenants", JSON.stringify(
|
|
1024
|
+
localStorage.setItem("userTenants", JSON.stringify(K.tenants));
|
|
1016
1025
|
} catch {
|
|
1017
1026
|
}
|
|
1018
1027
|
}
|
|
1019
|
-
const
|
|
1020
|
-
E(
|
|
1021
|
-
const
|
|
1022
|
-
accessToken:
|
|
1023
|
-
refreshToken:
|
|
1024
|
-
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
|
|
1025
1034
|
};
|
|
1026
|
-
if (
|
|
1027
|
-
return a(
|
|
1028
|
-
if (
|
|
1029
|
-
return a(
|
|
1030
|
-
if (!
|
|
1031
|
-
const
|
|
1032
|
-
if (
|
|
1033
|
-
const
|
|
1034
|
-
return a(
|
|
1035
|
-
} 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);
|
|
1036
1045
|
}
|
|
1037
|
-
return
|
|
1038
|
-
},
|
|
1039
|
-
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;
|
|
1040
1049
|
if (!z && !Q)
|
|
1041
1050
|
throw new Error("Either email or phoneNumber is required");
|
|
1042
|
-
if (!
|
|
1051
|
+
if (!V || !Y)
|
|
1043
1052
|
throw new Error("Name and password are required");
|
|
1044
|
-
const
|
|
1045
|
-
return await
|
|
1053
|
+
const re = ne ?? (i == null ? void 0 : i.id);
|
|
1054
|
+
return await T.signup({
|
|
1046
1055
|
email: z,
|
|
1047
1056
|
phoneNumber: Q,
|
|
1048
|
-
name:
|
|
1049
|
-
password:
|
|
1050
|
-
tenantId:
|
|
1051
|
-
lastName:
|
|
1057
|
+
name: V,
|
|
1058
|
+
password: Y,
|
|
1059
|
+
tenantId: re,
|
|
1060
|
+
lastName: te,
|
|
1052
1061
|
appId: t
|
|
1053
1062
|
});
|
|
1054
|
-
},
|
|
1055
|
-
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;
|
|
1056
1065
|
if (!z && !Q)
|
|
1057
1066
|
throw new Error("Either email or phoneNumber is required");
|
|
1058
|
-
if (!
|
|
1067
|
+
if (!V || !Y || !te)
|
|
1059
1068
|
throw new Error("Name, password, and tenantName are required");
|
|
1060
|
-
return await
|
|
1069
|
+
return await T.signupTenantAdmin({
|
|
1061
1070
|
email: z,
|
|
1062
1071
|
phoneNumber: Q,
|
|
1063
|
-
name:
|
|
1064
|
-
password:
|
|
1065
|
-
tenantName:
|
|
1072
|
+
name: V,
|
|
1073
|
+
password: Y,
|
|
1074
|
+
tenantName: te,
|
|
1066
1075
|
appId: t,
|
|
1067
|
-
lastName:
|
|
1076
|
+
lastName: ne
|
|
1068
1077
|
});
|
|
1069
|
-
},
|
|
1070
|
-
const { currentPassword: z, newPassword: Q } =
|
|
1071
|
-
await
|
|
1072
|
-
},
|
|
1073
|
-
const { email: z, tenantId: Q } =
|
|
1074
|
-
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)
|
|
1075
1084
|
throw new Error("tenantId is required for password reset");
|
|
1076
|
-
await
|
|
1077
|
-
},
|
|
1078
|
-
const { token: z, newPassword: Q } =
|
|
1079
|
-
await
|
|
1080
|
-
},
|
|
1081
|
-
const { email: z, frontendUrl: Q, name:
|
|
1082
|
-
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)
|
|
1083
1092
|
throw new Error("tenantId is required for magic link authentication");
|
|
1084
|
-
return await
|
|
1093
|
+
return await T.sendMagicLink({
|
|
1085
1094
|
email: z,
|
|
1086
|
-
tenantId:
|
|
1095
|
+
tenantId: ne,
|
|
1087
1096
|
frontendUrl: Q,
|
|
1088
|
-
name:
|
|
1089
|
-
lastName:
|
|
1097
|
+
name: V,
|
|
1098
|
+
lastName: Y,
|
|
1090
1099
|
appId: t
|
|
1091
1100
|
});
|
|
1092
|
-
},
|
|
1093
|
-
const { token: z, email: Q, tenantSlug:
|
|
1094
|
-
let
|
|
1095
|
-
|
|
1096
|
-
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({
|
|
1097
1106
|
token: z,
|
|
1098
1107
|
email: Q,
|
|
1099
1108
|
appId: t,
|
|
1100
|
-
tenantId:
|
|
1101
|
-
}),
|
|
1102
|
-
if (
|
|
1103
|
-
tenantSlug:
|
|
1109
|
+
tenantId: Y
|
|
1110
|
+
}), K = V && V !== o;
|
|
1111
|
+
if (K && (ne = new Re({
|
|
1112
|
+
tenantSlug: te,
|
|
1104
1113
|
baseUrl: n
|
|
1105
|
-
})),
|
|
1106
|
-
accessToken:
|
|
1107
|
-
refreshToken:
|
|
1108
|
-
expiresIn:
|
|
1109
|
-
}),
|
|
1110
|
-
|
|
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);
|
|
1111
1120
|
try {
|
|
1112
|
-
await
|
|
1113
|
-
} catch (
|
|
1114
|
-
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);
|
|
1115
1124
|
}
|
|
1116
1125
|
}
|
|
1117
|
-
return
|
|
1126
|
+
return K && te && te !== o && a(te, {
|
|
1118
1127
|
tokens: {
|
|
1119
|
-
accessToken:
|
|
1120
|
-
refreshToken:
|
|
1121
|
-
expiresIn:
|
|
1128
|
+
accessToken: re.accessToken,
|
|
1129
|
+
refreshToken: re.refreshToken,
|
|
1130
|
+
expiresIn: re.expiresIn
|
|
1122
1131
|
}
|
|
1123
|
-
}),
|
|
1124
|
-
},
|
|
1125
|
-
const
|
|
1126
|
-
if (!(
|
|
1132
|
+
}), re;
|
|
1133
|
+
}, ot = async () => {
|
|
1134
|
+
const H = l.getTokens();
|
|
1135
|
+
if (!(H != null && H.refreshToken))
|
|
1127
1136
|
throw new Error("No refresh token available");
|
|
1128
|
-
const z = await
|
|
1129
|
-
refreshToken:
|
|
1137
|
+
const z = await T.refreshToken({
|
|
1138
|
+
refreshToken: H.refreshToken
|
|
1130
1139
|
});
|
|
1131
1140
|
l.setTokens({
|
|
1132
1141
|
accessToken: z.accessToken,
|
|
1133
|
-
refreshToken: z.refreshToken ||
|
|
1142
|
+
refreshToken: z.refreshToken || H.refreshToken,
|
|
1134
1143
|
expiresIn: z.expiresIn
|
|
1135
1144
|
});
|
|
1136
|
-
},
|
|
1137
|
-
l.clearSession(),
|
|
1145
|
+
}, at = () => {
|
|
1146
|
+
l.clearSession(), h(null), M(null), b([]), E(!1);
|
|
1138
1147
|
try {
|
|
1139
1148
|
localStorage.removeItem("userTenants");
|
|
1140
1149
|
} catch {
|
|
1141
1150
|
}
|
|
1142
|
-
},
|
|
1143
|
-
l.setTokens(
|
|
1144
|
-
},
|
|
1145
|
-
l.clearSession(),
|
|
1146
|
-
},
|
|
1151
|
+
}, lt = (H) => {
|
|
1152
|
+
l.setTokens(H);
|
|
1153
|
+
}, ct = () => l.hasValidSession(), dt = () => {
|
|
1154
|
+
l.clearSession(), h(null), M(null);
|
|
1155
|
+
}, ut = async () => {
|
|
1147
1156
|
if (t)
|
|
1148
1157
|
try {
|
|
1149
|
-
|
|
1150
|
-
const { roles:
|
|
1151
|
-
f(
|
|
1152
|
-
} catch (
|
|
1153
|
-
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);
|
|
1154
1163
|
} finally {
|
|
1155
|
-
|
|
1164
|
+
d(!1);
|
|
1156
1165
|
}
|
|
1157
|
-
},
|
|
1158
|
-
await
|
|
1159
|
-
},
|
|
1160
|
-
if (!
|
|
1166
|
+
}, ht = async () => {
|
|
1167
|
+
await ut();
|
|
1168
|
+
}, xe = (H) => {
|
|
1169
|
+
if (!Z || Z.length === 0)
|
|
1161
1170
|
return !1;
|
|
1162
|
-
if (typeof
|
|
1163
|
-
return
|
|
1164
|
-
const z = `${
|
|
1165
|
-
return
|
|
1171
|
+
if (typeof H == "string")
|
|
1172
|
+
return Z.includes(H);
|
|
1173
|
+
const z = `${H.resource}.${H.action}`;
|
|
1174
|
+
return Z.includes(z);
|
|
1166
1175
|
};
|
|
1167
1176
|
return {
|
|
1168
1177
|
// RFC-003: Authentication state
|
|
1169
|
-
isAuthenticated:
|
|
1178
|
+
isAuthenticated: O,
|
|
1170
1179
|
sessionManager: l,
|
|
1171
|
-
authenticatedHttpService:
|
|
1172
|
-
login:
|
|
1173
|
-
signup:
|
|
1174
|
-
signupTenantAdmin:
|
|
1175
|
-
sendMagicLink:
|
|
1176
|
-
verifyMagicLink:
|
|
1177
|
-
changePassword:
|
|
1178
|
-
requestPasswordReset:
|
|
1179
|
-
confirmPasswordReset:
|
|
1180
|
-
refreshToken:
|
|
1181
|
-
logout:
|
|
1182
|
-
setTokens:
|
|
1183
|
-
hasValidSession:
|
|
1184
|
-
clearSession:
|
|
1185
|
-
currentUser:
|
|
1186
|
-
isUserLoading:
|
|
1187
|
-
userError:
|
|
1188
|
-
loadUserData:
|
|
1189
|
-
refreshUser:
|
|
1190
|
-
isAuthInitializing: !
|
|
1191
|
-
isAuthReady:
|
|
1192
|
-
userRole:
|
|
1193
|
-
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,
|
|
1194
1203
|
availableRoles: p,
|
|
1195
1204
|
rolesLoading: w,
|
|
1196
|
-
hasPermission:
|
|
1197
|
-
hasAnyPermission: (
|
|
1198
|
-
hasAllPermissions: (
|
|
1199
|
-
getUserPermissionStrings: () =>
|
|
1200
|
-
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,
|
|
1201
1210
|
// RFC-004: Multi-tenant user membership
|
|
1202
|
-
userTenants:
|
|
1211
|
+
userTenants: A,
|
|
1203
1212
|
hasTenantContext: L,
|
|
1204
|
-
switchToTenant: async (
|
|
1205
|
-
const { redirectPath: Q } = z || {},
|
|
1206
|
-
if (!(
|
|
1213
|
+
switchToTenant: async (H, z) => {
|
|
1214
|
+
const { redirectPath: Q } = z || {}, V = l.getTokens();
|
|
1215
|
+
if (!(V != null && V.refreshToken))
|
|
1207
1216
|
throw new Error("No refresh token available for tenant switch");
|
|
1208
|
-
const
|
|
1209
|
-
refreshToken:
|
|
1210
|
-
tenantId:
|
|
1217
|
+
const Y = await T.switchTenant({
|
|
1218
|
+
refreshToken: V.refreshToken,
|
|
1219
|
+
tenantId: H
|
|
1211
1220
|
});
|
|
1212
1221
|
l.setTokens({
|
|
1213
|
-
accessToken:
|
|
1214
|
-
refreshToken:
|
|
1222
|
+
accessToken: Y.accessToken,
|
|
1223
|
+
refreshToken: V.refreshToken,
|
|
1215
1224
|
// Keep the same refresh token
|
|
1216
|
-
expiresIn:
|
|
1217
|
-
}),
|
|
1218
|
-
const
|
|
1219
|
-
|
|
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, {
|
|
1220
1229
|
tokens: {
|
|
1221
|
-
accessToken:
|
|
1222
|
-
refreshToken:
|
|
1223
|
-
expiresIn:
|
|
1230
|
+
accessToken: Y.accessToken,
|
|
1231
|
+
refreshToken: V.refreshToken,
|
|
1232
|
+
expiresIn: Y.expiresIn
|
|
1224
1233
|
},
|
|
1225
1234
|
redirectPath: Q
|
|
1226
1235
|
});
|
|
1227
1236
|
},
|
|
1228
1237
|
refreshUserTenants: async () => {
|
|
1229
|
-
const
|
|
1230
|
-
|
|
1238
|
+
const H = await l.getAuthHeaders(), z = await T.getUserTenants(H);
|
|
1239
|
+
b(z);
|
|
1231
1240
|
try {
|
|
1232
1241
|
localStorage.setItem("userTenants", JSON.stringify(z));
|
|
1233
1242
|
} catch {
|
|
@@ -1236,74 +1245,76 @@ function yn({ config: r = {}, children: e }) {
|
|
|
1236
1245
|
}
|
|
1237
1246
|
};
|
|
1238
1247
|
}, [
|
|
1239
|
-
|
|
1248
|
+
O,
|
|
1240
1249
|
l,
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1250
|
+
C,
|
|
1251
|
+
T,
|
|
1252
|
+
S,
|
|
1253
|
+
y,
|
|
1245
1254
|
t,
|
|
1246
1255
|
i,
|
|
1247
1256
|
o,
|
|
1248
1257
|
a,
|
|
1249
1258
|
p,
|
|
1250
|
-
b,
|
|
1251
|
-
T,
|
|
1252
|
-
N,
|
|
1253
|
-
x,
|
|
1254
|
-
L,
|
|
1255
|
-
D,
|
|
1256
1259
|
m,
|
|
1257
1260
|
v,
|
|
1261
|
+
F,
|
|
1262
|
+
A,
|
|
1263
|
+
L,
|
|
1264
|
+
g,
|
|
1265
|
+
j,
|
|
1266
|
+
Z,
|
|
1258
1267
|
P,
|
|
1259
|
-
|
|
1268
|
+
q
|
|
1260
1269
|
]);
|
|
1261
|
-
|
|
1270
|
+
ee(() => {
|
|
1262
1271
|
!r.initialRoles && t && (async () => {
|
|
1263
1272
|
try {
|
|
1264
|
-
|
|
1265
|
-
const
|
|
1266
|
-
f(
|
|
1267
|
-
} catch (
|
|
1268
|
-
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);
|
|
1269
1278
|
} finally {
|
|
1270
|
-
|
|
1279
|
+
d(!1);
|
|
1271
1280
|
}
|
|
1272
1281
|
})();
|
|
1273
1282
|
}, [t, n, r.initialRoles]);
|
|
1274
|
-
const [
|
|
1275
|
-
return
|
|
1276
|
-
|
|
1277
|
-
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);
|
|
1278
1287
|
}).finally(() => {
|
|
1279
|
-
console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"),
|
|
1288
|
+
console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"), U(!1);
|
|
1280
1289
|
})));
|
|
1281
|
-
}, [
|
|
1282
|
-
const
|
|
1283
|
-
|
|
1284
|
-
}, [l]),
|
|
1285
|
-
|
|
1286
|
-
}))
|
|
1287
|
-
|
|
1288
|
-
|
|
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)
|
|
1289
1300
|
return;
|
|
1290
|
-
const
|
|
1291
|
-
|
|
1301
|
+
const G = setInterval(() => {
|
|
1302
|
+
W.loadUserData().catch(() => {
|
|
1292
1303
|
});
|
|
1293
|
-
},
|
|
1294
|
-
return () => clearInterval(
|
|
1295
|
-
}, [l,
|
|
1304
|
+
}, q);
|
|
1305
|
+
return () => clearInterval(G);
|
|
1306
|
+
}, [l, m, W, q]), /* @__PURE__ */ s(Fe.Provider, { value: W, children: e });
|
|
1296
1307
|
}
|
|
1297
|
-
function
|
|
1298
|
-
const r =
|
|
1308
|
+
function ce() {
|
|
1309
|
+
const r = oe(Fe);
|
|
1299
1310
|
if (!r)
|
|
1300
1311
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
1301
1312
|
return r;
|
|
1302
1313
|
}
|
|
1303
|
-
function
|
|
1304
|
-
return
|
|
1314
|
+
function Ne() {
|
|
1315
|
+
return oe(Fe);
|
|
1305
1316
|
}
|
|
1306
|
-
class
|
|
1317
|
+
class xt {
|
|
1307
1318
|
constructor(e, t) {
|
|
1308
1319
|
this.httpService = e, this.sessionManager = t;
|
|
1309
1320
|
}
|
|
@@ -1383,66 +1394,66 @@ class Tt {
|
|
|
1383
1394
|
})).data;
|
|
1384
1395
|
}
|
|
1385
1396
|
}
|
|
1386
|
-
const
|
|
1387
|
-
function
|
|
1388
|
-
const t =
|
|
1389
|
-
const
|
|
1390
|
-
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);
|
|
1391
1402
|
}, [i]), M = async () => {
|
|
1392
1403
|
if (!(a != null && a.id)) {
|
|
1393
1404
|
f([]);
|
|
1394
1405
|
return;
|
|
1395
1406
|
}
|
|
1396
|
-
|
|
1407
|
+
d(!0), h(null);
|
|
1397
1408
|
try {
|
|
1398
|
-
const
|
|
1399
|
-
f(
|
|
1400
|
-
} catch (
|
|
1401
|
-
const
|
|
1402
|
-
|
|
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));
|
|
1403
1414
|
} finally {
|
|
1404
|
-
|
|
1415
|
+
d(!1);
|
|
1405
1416
|
}
|
|
1406
1417
|
};
|
|
1407
|
-
|
|
1418
|
+
ee(() => {
|
|
1408
1419
|
if (!i || !o) return;
|
|
1409
1420
|
M().finally(() => I(!0));
|
|
1410
|
-
const
|
|
1411
|
-
return () => clearInterval(
|
|
1421
|
+
const u = r.refreshInterval || 5 * 60 * 1e3, A = setInterval(M, u);
|
|
1422
|
+
return () => clearInterval(A);
|
|
1412
1423
|
}, [a == null ? void 0 : a.id, i, o, r.refreshInterval]);
|
|
1413
|
-
const P =
|
|
1414
|
-
const
|
|
1415
|
-
const R = p.find((
|
|
1424
|
+
const P = J(() => {
|
|
1425
|
+
const u = (N) => {
|
|
1426
|
+
const R = p.find((U) => U.key === N);
|
|
1416
1427
|
return (R == null ? void 0 : R.value) === !0;
|
|
1417
|
-
},
|
|
1418
|
-
const R = p.find((
|
|
1428
|
+
}, A = (N) => p.find((R) => R.key === N), b = (N) => {
|
|
1429
|
+
const R = p.find((U) => U.key === N);
|
|
1419
1430
|
return R ? R.value ? "enabled" : "disabled" : "not_found";
|
|
1420
1431
|
}, L = async () => {
|
|
1421
1432
|
await M();
|
|
1422
|
-
}, E = !!(i && o) && (
|
|
1433
|
+
}, E = !!(i && o) && (v || !(a != null && a.id));
|
|
1423
1434
|
return {
|
|
1424
1435
|
featureFlags: p,
|
|
1425
1436
|
loading: w,
|
|
1426
|
-
error:
|
|
1437
|
+
error: m,
|
|
1427
1438
|
isReady: E,
|
|
1428
|
-
isEnabled:
|
|
1429
|
-
getFlag:
|
|
1430
|
-
getFlagState:
|
|
1439
|
+
isEnabled: u,
|
|
1440
|
+
getFlag: A,
|
|
1441
|
+
getFlagState: b,
|
|
1431
1442
|
refresh: L
|
|
1432
1443
|
};
|
|
1433
|
-
}, [p, w,
|
|
1434
|
-
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 });
|
|
1435
1446
|
}
|
|
1436
|
-
function
|
|
1437
|
-
const r =
|
|
1447
|
+
function At() {
|
|
1448
|
+
const r = oe(De);
|
|
1438
1449
|
if (!r)
|
|
1439
1450
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1440
1451
|
return r;
|
|
1441
1452
|
}
|
|
1442
|
-
function
|
|
1443
|
-
return
|
|
1453
|
+
function Ke() {
|
|
1454
|
+
return oe(De);
|
|
1444
1455
|
}
|
|
1445
|
-
class
|
|
1456
|
+
class Pt {
|
|
1446
1457
|
constructor(e, t) {
|
|
1447
1458
|
this.httpService = e, this.sessionManager = t;
|
|
1448
1459
|
}
|
|
@@ -1508,68 +1519,68 @@ class At {
|
|
|
1508
1519
|
)).data;
|
|
1509
1520
|
}
|
|
1510
1521
|
}
|
|
1511
|
-
const
|
|
1512
|
-
function
|
|
1513
|
-
const t =
|
|
1514
|
-
const P = new
|
|
1515
|
-
return new
|
|
1516
|
-
}, [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 () => {
|
|
1517
1528
|
if (!(o != null && o.id)) {
|
|
1518
1529
|
p(null);
|
|
1519
1530
|
return;
|
|
1520
1531
|
}
|
|
1521
|
-
w(!0),
|
|
1532
|
+
w(!0), m(null);
|
|
1522
1533
|
try {
|
|
1523
1534
|
const P = await I.getTenantSubscriptionFeatures(o.id);
|
|
1524
1535
|
p(P);
|
|
1525
1536
|
} catch (P) {
|
|
1526
|
-
const
|
|
1527
|
-
|
|
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));
|
|
1528
1539
|
} finally {
|
|
1529
1540
|
w(!1);
|
|
1530
1541
|
}
|
|
1531
1542
|
};
|
|
1532
|
-
|
|
1533
|
-
if (!i || (
|
|
1534
|
-
const P = r.refreshInterval || 10 * 60 * 1e3,
|
|
1535
|
-
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);
|
|
1536
1547
|
}, [o == null ? void 0 : o.id, i, r.refreshInterval]);
|
|
1537
|
-
const M =
|
|
1538
|
-
const P = (a == null ? void 0 : a.features) || [],
|
|
1539
|
-
const
|
|
1540
|
-
return
|
|
1541
|
-
},
|
|
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) => {
|
|
1542
1553
|
const l = P.find((D) => D.key === R);
|
|
1543
|
-
return l ? l.value :
|
|
1554
|
+
return l ? l.value : U;
|
|
1544
1555
|
}, L = (R) => !a || !a.isActive ? !1 : R.includes(a.planId), E = async () => {
|
|
1545
|
-
await
|
|
1546
|
-
},
|
|
1556
|
+
await F();
|
|
1557
|
+
}, N = !!i && (h || !(o != null && o.id));
|
|
1547
1558
|
return {
|
|
1548
1559
|
subscription: a,
|
|
1549
1560
|
features: P,
|
|
1550
1561
|
loading: f,
|
|
1551
|
-
error:
|
|
1552
|
-
isReady:
|
|
1553
|
-
isFeatureEnabled:
|
|
1554
|
-
getFeature:
|
|
1555
|
-
getFeatureValue:
|
|
1562
|
+
error: d,
|
|
1563
|
+
isReady: N,
|
|
1564
|
+
isFeatureEnabled: u,
|
|
1565
|
+
getFeature: A,
|
|
1566
|
+
getFeatureValue: b,
|
|
1556
1567
|
hasAllowedPlan: L,
|
|
1557
1568
|
refresh: E
|
|
1558
1569
|
};
|
|
1559
|
-
}, [a, f,
|
|
1560
|
-
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 });
|
|
1561
1572
|
}
|
|
1562
|
-
function
|
|
1563
|
-
const r =
|
|
1573
|
+
function Rt() {
|
|
1574
|
+
const r = oe(Ce);
|
|
1564
1575
|
if (r === void 0)
|
|
1565
1576
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1566
1577
|
return r;
|
|
1567
1578
|
}
|
|
1568
|
-
function
|
|
1569
|
-
return
|
|
1579
|
+
function Je() {
|
|
1580
|
+
return oe(Ce) ?? null;
|
|
1570
1581
|
}
|
|
1571
|
-
var
|
|
1572
|
-
const
|
|
1582
|
+
var ie = /* @__PURE__ */ ((r) => (r.SUPERUSER = "SUPERUSER", r.TENANT_ADMIN = "TENANT_ADMIN", r.USER = "USER", r))(ie || {});
|
|
1583
|
+
const Ue = {
|
|
1573
1584
|
publicGuest: "/",
|
|
1574
1585
|
publicUser: "/account",
|
|
1575
1586
|
publicAdmin: "/admin",
|
|
@@ -1577,7 +1588,7 @@ const De = {
|
|
|
1577
1588
|
tenantUser: "/dashboard",
|
|
1578
1589
|
tenantAdmin: "/admin/dashboard",
|
|
1579
1590
|
default: "/"
|
|
1580
|
-
},
|
|
1591
|
+
}, Ye = {
|
|
1581
1592
|
// Public/Landing zones
|
|
1582
1593
|
landing: { tenant: "forbidden", auth: "optional" },
|
|
1583
1594
|
publicOnly: { tenant: "forbidden", auth: "forbidden" },
|
|
@@ -1590,18 +1601,18 @@ const De = {
|
|
|
1590
1601
|
tenantOpen: { tenant: "required", auth: "optional" },
|
|
1591
1602
|
tenantAuth: { tenant: "required", auth: "required" },
|
|
1592
1603
|
// User type zones
|
|
1593
|
-
user: { tenant: "required", auth: "required", userType:
|
|
1594
|
-
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 },
|
|
1595
1606
|
// Fully open
|
|
1596
1607
|
open: { tenant: "optional", auth: "optional" }
|
|
1597
|
-
},
|
|
1598
|
-
function
|
|
1599
|
-
const t =
|
|
1608
|
+
}, $e = ue(null);
|
|
1609
|
+
function Tn({ config: r = {}, children: e }) {
|
|
1610
|
+
const t = J(() => {
|
|
1600
1611
|
const n = {
|
|
1601
|
-
...
|
|
1612
|
+
...Ue,
|
|
1602
1613
|
...r.zoneRoots
|
|
1603
1614
|
}, i = {
|
|
1604
|
-
...
|
|
1615
|
+
...Ye,
|
|
1605
1616
|
...r.presets
|
|
1606
1617
|
};
|
|
1607
1618
|
return {
|
|
@@ -1614,19 +1625,19 @@ function Sn({ config: r = {}, children: e }) {
|
|
|
1614
1625
|
returnToStorage: r.returnToStorage ?? "url"
|
|
1615
1626
|
};
|
|
1616
1627
|
}, [r]);
|
|
1617
|
-
return /* @__PURE__ */ s(
|
|
1628
|
+
return /* @__PURE__ */ s($e.Provider, { value: t, children: e });
|
|
1618
1629
|
}
|
|
1619
|
-
function
|
|
1620
|
-
const r =
|
|
1630
|
+
function kn() {
|
|
1631
|
+
const r = oe($e);
|
|
1621
1632
|
if (!r)
|
|
1622
1633
|
throw new Error("useRouting must be used within a RoutingProvider");
|
|
1623
1634
|
return r;
|
|
1624
1635
|
}
|
|
1625
|
-
function
|
|
1626
|
-
const r =
|
|
1636
|
+
function It() {
|
|
1637
|
+
const r = oe($e);
|
|
1627
1638
|
return r || {
|
|
1628
|
-
zoneRoots:
|
|
1629
|
-
presets:
|
|
1639
|
+
zoneRoots: Ue,
|
|
1640
|
+
presets: Ye,
|
|
1630
1641
|
loadingFallback: null,
|
|
1631
1642
|
accessDeniedFallback: null,
|
|
1632
1643
|
onAccessDenied: void 0,
|
|
@@ -1634,7 +1645,7 @@ function Pt() {
|
|
|
1634
1645
|
returnToStorage: "url"
|
|
1635
1646
|
};
|
|
1636
1647
|
}
|
|
1637
|
-
const
|
|
1648
|
+
const _e = () => /* @__PURE__ */ c(
|
|
1638
1649
|
"div",
|
|
1639
1650
|
{
|
|
1640
1651
|
style: {
|
|
@@ -1671,11 +1682,11 @@ const Oe = () => /* @__PURE__ */ d(
|
|
|
1671
1682
|
)
|
|
1672
1683
|
]
|
|
1673
1684
|
}
|
|
1674
|
-
),
|
|
1685
|
+
), We = ({
|
|
1675
1686
|
userType: r,
|
|
1676
1687
|
minUserType: e,
|
|
1677
1688
|
missingPermissions: t
|
|
1678
|
-
}) => /* @__PURE__ */
|
|
1689
|
+
}) => /* @__PURE__ */ c(
|
|
1679
1690
|
"div",
|
|
1680
1691
|
{
|
|
1681
1692
|
style: {
|
|
@@ -1693,55 +1704,55 @@ const Oe = () => /* @__PURE__ */ d(
|
|
|
1693
1704
|
children: [
|
|
1694
1705
|
/* @__PURE__ */ s("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
|
|
1695
1706
|
/* @__PURE__ */ s("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
|
|
1696
|
-
e && r ? /* @__PURE__ */
|
|
1697
|
-
/* @__PURE__ */
|
|
1707
|
+
e && r ? /* @__PURE__ */ c(_, { children: [
|
|
1708
|
+
/* @__PURE__ */ c("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
|
|
1698
1709
|
"This content requires ",
|
|
1699
1710
|
/* @__PURE__ */ s("strong", { children: e }),
|
|
1700
1711
|
" access level or higher."
|
|
1701
1712
|
] }),
|
|
1702
|
-
/* @__PURE__ */
|
|
1713
|
+
/* @__PURE__ */ c("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1703
1714
|
"Your current access level: ",
|
|
1704
1715
|
/* @__PURE__ */ s("strong", { children: r })
|
|
1705
1716
|
] })
|
|
1706
|
-
] }) : /* @__PURE__ */
|
|
1717
|
+
] }) : /* @__PURE__ */ c(_, { children: [
|
|
1707
1718
|
/* @__PURE__ */ s("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
|
|
1708
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1719
|
+
t && t.length > 0 && /* @__PURE__ */ c("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1709
1720
|
"Required permissions: ",
|
|
1710
1721
|
/* @__PURE__ */ s("strong", { children: t.join(", ") })
|
|
1711
1722
|
] })
|
|
1712
1723
|
] })
|
|
1713
1724
|
]
|
|
1714
1725
|
}
|
|
1715
|
-
),
|
|
1726
|
+
), Mt = (r, e) => {
|
|
1716
1727
|
const t = {
|
|
1717
|
-
[
|
|
1718
|
-
[
|
|
1719
|
-
[
|
|
1728
|
+
[ie.USER]: 1,
|
|
1729
|
+
[ie.TENANT_ADMIN]: 2,
|
|
1730
|
+
[ie.SUPERUSER]: 3
|
|
1720
1731
|
};
|
|
1721
1732
|
return t[r] >= t[e];
|
|
1722
1733
|
};
|
|
1723
|
-
function
|
|
1734
|
+
function xn({
|
|
1724
1735
|
children: r,
|
|
1725
1736
|
fallback: e,
|
|
1726
1737
|
minUserType: t,
|
|
1727
1738
|
requiredPermissions: n,
|
|
1728
1739
|
requireAllPermissions: i = !1
|
|
1729
1740
|
}) {
|
|
1730
|
-
const { hasValidSession: o, sessionManager: a, hasPermission: p, hasAnyPermission: f, hasAllPermissions: w } =
|
|
1741
|
+
const { hasValidSession: o, sessionManager: a, hasPermission: p, hasAnyPermission: f, hasAllPermissions: w } = ce();
|
|
1731
1742
|
if (!o())
|
|
1732
|
-
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(
|
|
1733
|
-
const
|
|
1734
|
-
if (!
|
|
1735
|
-
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(
|
|
1736
|
-
if (t && !
|
|
1737
|
-
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 });
|
|
1738
1749
|
if (n && n.length > 0 && !(i ? w(n) : f(n))) {
|
|
1739
|
-
const
|
|
1740
|
-
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 });
|
|
1741
1752
|
}
|
|
1742
1753
|
return /* @__PURE__ */ s(_, { children: r });
|
|
1743
1754
|
}
|
|
1744
|
-
const
|
|
1755
|
+
const Lt = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
1745
1756
|
"div",
|
|
1746
1757
|
{
|
|
1747
1758
|
style: {
|
|
@@ -1754,7 +1765,7 @@ const It = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1754
1765
|
backgroundColor: "#f9fafb",
|
|
1755
1766
|
textAlign: "center"
|
|
1756
1767
|
},
|
|
1757
|
-
children: /* @__PURE__ */
|
|
1768
|
+
children: /* @__PURE__ */ c(
|
|
1758
1769
|
"div",
|
|
1759
1770
|
{
|
|
1760
1771
|
style: {
|
|
@@ -1768,7 +1779,7 @@ const It = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1768
1779
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
|
|
1769
1780
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
|
|
1770
1781
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
|
|
1771
|
-
/* @__PURE__ */
|
|
1782
|
+
/* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1772
1783
|
"Redirecting to ",
|
|
1773
1784
|
r,
|
|
1774
1785
|
"..."
|
|
@@ -1777,7 +1788,7 @@ const It = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1777
1788
|
}
|
|
1778
1789
|
)
|
|
1779
1790
|
}
|
|
1780
|
-
),
|
|
1791
|
+
), Ve = ({
|
|
1781
1792
|
userType: r,
|
|
1782
1793
|
requiredUserType: e,
|
|
1783
1794
|
missingPermissions: t
|
|
@@ -1794,7 +1805,7 @@ const It = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1794
1805
|
backgroundColor: "#f9fafb",
|
|
1795
1806
|
textAlign: "center"
|
|
1796
1807
|
},
|
|
1797
|
-
children: /* @__PURE__ */
|
|
1808
|
+
children: /* @__PURE__ */ c(
|
|
1798
1809
|
"div",
|
|
1799
1810
|
{
|
|
1800
1811
|
style: {
|
|
@@ -1807,19 +1818,19 @@ const It = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1807
1818
|
children: [
|
|
1808
1819
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
|
|
1809
1820
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
|
|
1810
|
-
e && r ? /* @__PURE__ */
|
|
1811
|
-
/* @__PURE__ */
|
|
1821
|
+
e && r ? /* @__PURE__ */ c(_, { children: [
|
|
1822
|
+
/* @__PURE__ */ c("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
|
|
1812
1823
|
"This page requires ",
|
|
1813
1824
|
/* @__PURE__ */ s("strong", { children: e }),
|
|
1814
1825
|
" access."
|
|
1815
1826
|
] }),
|
|
1816
|
-
/* @__PURE__ */
|
|
1827
|
+
/* @__PURE__ */ c("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1817
1828
|
"Your current user type: ",
|
|
1818
1829
|
/* @__PURE__ */ s("strong", { children: r })
|
|
1819
1830
|
] })
|
|
1820
|
-
] }) : /* @__PURE__ */
|
|
1831
|
+
] }) : /* @__PURE__ */ c(_, { children: [
|
|
1821
1832
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
|
|
1822
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1833
|
+
t && t.length > 0 && /* @__PURE__ */ c("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1823
1834
|
"Required permissions: ",
|
|
1824
1835
|
/* @__PURE__ */ s("strong", { children: t.join(", ") })
|
|
1825
1836
|
] })
|
|
@@ -1828,8 +1839,8 @@ const It = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1828
1839
|
}
|
|
1829
1840
|
)
|
|
1830
1841
|
}
|
|
1831
|
-
),
|
|
1832
|
-
function
|
|
1842
|
+
), Et = (r, e) => r === e;
|
|
1843
|
+
function An({
|
|
1833
1844
|
children: r,
|
|
1834
1845
|
redirectTo: e = "/login",
|
|
1835
1846
|
requiredUserType: t,
|
|
@@ -1837,34 +1848,34 @@ function kn({
|
|
|
1837
1848
|
requireAllPermissions: i = !1,
|
|
1838
1849
|
fallback: o
|
|
1839
1850
|
}) {
|
|
1840
|
-
const { hasValidSession: a, sessionManager: p, hasPermission: f, hasAnyPermission: w, hasAllPermissions:
|
|
1841
|
-
if (
|
|
1851
|
+
const { hasValidSession: a, sessionManager: p, hasPermission: f, hasAnyPermission: w, hasAllPermissions: d } = ce(), m = Se();
|
|
1852
|
+
if (ee(() => {
|
|
1842
1853
|
process.env.NODE_ENV === "development" && console.warn(
|
|
1843
1854
|
"[react-identity-access] ProtectedRoute is deprecated. Use AuthenticatedZone or AdminZone from ZoneRoute instead."
|
|
1844
1855
|
);
|
|
1845
1856
|
}, []), !a())
|
|
1846
|
-
return o ? /* @__PURE__ */ s(_, { children: o }) : /* @__PURE__ */
|
|
1847
|
-
/* @__PURE__ */ s(
|
|
1848
|
-
/* @__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 })
|
|
1849
1860
|
] });
|
|
1850
|
-
const
|
|
1851
|
-
if (!
|
|
1852
|
-
return /* @__PURE__ */ s(
|
|
1853
|
-
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))
|
|
1854
1865
|
return /* @__PURE__ */ s(
|
|
1855
|
-
|
|
1866
|
+
Ve,
|
|
1856
1867
|
{
|
|
1857
|
-
userType:
|
|
1868
|
+
userType: h.userType,
|
|
1858
1869
|
requiredUserType: t
|
|
1859
1870
|
}
|
|
1860
1871
|
);
|
|
1861
|
-
if (n && n.length > 0 && !(i ?
|
|
1862
|
-
const I = n.filter((
|
|
1863
|
-
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 });
|
|
1864
1875
|
}
|
|
1865
1876
|
return /* @__PURE__ */ s(_, { children: r });
|
|
1866
1877
|
}
|
|
1867
|
-
const
|
|
1878
|
+
const Ft = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
1868
1879
|
"div",
|
|
1869
1880
|
{
|
|
1870
1881
|
style: {
|
|
@@ -1877,7 +1888,7 @@ const Lt = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1877
1888
|
backgroundColor: "#f9fafb",
|
|
1878
1889
|
textAlign: "center"
|
|
1879
1890
|
},
|
|
1880
|
-
children: /* @__PURE__ */
|
|
1891
|
+
children: /* @__PURE__ */ c(
|
|
1881
1892
|
"div",
|
|
1882
1893
|
{
|
|
1883
1894
|
style: {
|
|
@@ -1891,7 +1902,7 @@ const Lt = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1891
1902
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
|
|
1892
1903
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
|
|
1893
1904
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
|
|
1894
|
-
/* @__PURE__ */
|
|
1905
|
+
/* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1895
1906
|
"Redirecting to ",
|
|
1896
1907
|
r,
|
|
1897
1908
|
"..."
|
|
@@ -1901,18 +1912,18 @@ const Lt = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1901
1912
|
)
|
|
1902
1913
|
}
|
|
1903
1914
|
);
|
|
1904
|
-
function
|
|
1905
|
-
const { tenant: n, isLoading: i, error: o } = ge(), a =
|
|
1906
|
-
return
|
|
1915
|
+
function Pn({ children: r, redirectTo: e = "/", fallback: t }) {
|
|
1916
|
+
const { tenant: n, isLoading: i, error: o } = ge(), a = Se();
|
|
1917
|
+
return ee(() => {
|
|
1907
1918
|
process.env.NODE_ENV === "development" && console.warn(
|
|
1908
1919
|
"[react-identity-access] TenantRoute is deprecated. Use TenantZone from ZoneRoute instead."
|
|
1909
1920
|
);
|
|
1910
|
-
}, []), i || o ? null : n ? /* @__PURE__ */ s(_, { children: r }) : t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */
|
|
1911
|
-
/* @__PURE__ */ s(
|
|
1912
|
-
/* @__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 })
|
|
1913
1924
|
] });
|
|
1914
1925
|
}
|
|
1915
|
-
const
|
|
1926
|
+
const Nt = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
1916
1927
|
"div",
|
|
1917
1928
|
{
|
|
1918
1929
|
style: {
|
|
@@ -1925,7 +1936,7 @@ const Et = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1925
1936
|
backgroundColor: "#f9fafb",
|
|
1926
1937
|
textAlign: "center"
|
|
1927
1938
|
},
|
|
1928
|
-
children: /* @__PURE__ */
|
|
1939
|
+
children: /* @__PURE__ */ c(
|
|
1929
1940
|
"div",
|
|
1930
1941
|
{
|
|
1931
1942
|
style: {
|
|
@@ -1939,7 +1950,7 @@ const Et = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1939
1950
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
|
|
1940
1951
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
|
|
1941
1952
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
|
|
1942
|
-
/* @__PURE__ */
|
|
1953
|
+
/* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1943
1954
|
"Redirecting to ",
|
|
1944
1955
|
r,
|
|
1945
1956
|
"..."
|
|
@@ -1949,41 +1960,41 @@ const Et = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1949
1960
|
)
|
|
1950
1961
|
}
|
|
1951
1962
|
);
|
|
1952
|
-
function
|
|
1953
|
-
const { tenant: n, isLoading: i, error: o } = ge(), a =
|
|
1954
|
-
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(() => {
|
|
1955
1966
|
process.env.NODE_ENV === "development" && console.warn(
|
|
1956
1967
|
"[react-identity-access] LandingRoute is deprecated. Use PublicZone from ZoneRoute instead."
|
|
1957
1968
|
);
|
|
1958
|
-
}, []), i || o ? null : n ? t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */
|
|
1959
|
-
/* @__PURE__ */ s(
|
|
1960
|
-
/* @__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 })
|
|
1961
1972
|
] }) : /* @__PURE__ */ s(_, { children: r });
|
|
1962
1973
|
}
|
|
1963
|
-
function
|
|
1974
|
+
function Dt(r, e) {
|
|
1964
1975
|
return e ? r ? Array.isArray(e) ? e.includes(r) : r === e : !1 : !0;
|
|
1965
1976
|
}
|
|
1966
|
-
function
|
|
1977
|
+
function je(r, e) {
|
|
1967
1978
|
return !r || r === "optional" ? "skip" : r === "required" ? e ? "pass" : "fail" : r === "forbidden" ? e ? "fail" : "pass" : "skip";
|
|
1968
1979
|
}
|
|
1969
|
-
function
|
|
1970
|
-
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;
|
|
1971
1982
|
}
|
|
1972
|
-
function
|
|
1973
|
-
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;
|
|
1974
1985
|
}
|
|
1975
|
-
function
|
|
1986
|
+
function $t(r, e, t, n, i) {
|
|
1976
1987
|
if (!e || i !== "url")
|
|
1977
1988
|
return r;
|
|
1978
1989
|
const o = typeof e == "string" ? e : t, a = r.includes("?") ? "&" : "?";
|
|
1979
1990
|
return `${r}${a}${n}=${encodeURIComponent(o)}`;
|
|
1980
1991
|
}
|
|
1981
|
-
function
|
|
1992
|
+
function Ht(r, e, t) {
|
|
1982
1993
|
if (!r || t === "url") return;
|
|
1983
1994
|
const n = typeof r == "string" ? r : e, i = "zone_return_to";
|
|
1984
1995
|
t === "session" ? sessionStorage.setItem(i, n) : t === "local" && localStorage.setItem(i, n);
|
|
1985
1996
|
}
|
|
1986
|
-
const
|
|
1997
|
+
const le = ({
|
|
1987
1998
|
children: r,
|
|
1988
1999
|
preset: e,
|
|
1989
2000
|
tenant: t,
|
|
@@ -1994,39 +2005,39 @@ const ae = ({
|
|
|
1994
2005
|
returnTo: p,
|
|
1995
2006
|
onAccessDenied: f,
|
|
1996
2007
|
redirectTo: w,
|
|
1997
|
-
loadingFallback:
|
|
1998
|
-
accessDeniedFallback:
|
|
2008
|
+
loadingFallback: d,
|
|
2009
|
+
accessDeniedFallback: m
|
|
1999
2010
|
}) => {
|
|
2000
|
-
const
|
|
2011
|
+
const h = Se(), { isAuthenticated: v, isAuthInitializing: I, currentUser: F, userPermissions: M } = ce(), { tenant: P, isTenantLoading: u } = he(), A = It(), b = J(() => {
|
|
2001
2012
|
if (e)
|
|
2002
|
-
return
|
|
2003
|
-
}, [e,
|
|
2013
|
+
return A.presets[e];
|
|
2014
|
+
}, [e, A.presets]), L = J(
|
|
2004
2015
|
() => ({
|
|
2005
|
-
tenant: t ?? (
|
|
2006
|
-
auth: n ?? (
|
|
2007
|
-
userType: i ?? (
|
|
2008
|
-
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),
|
|
2009
2020
|
requireAllPermissions: a
|
|
2010
2021
|
}),
|
|
2011
|
-
[t, n, i, o,
|
|
2012
|
-
), E =
|
|
2022
|
+
[t, n, i, o, b, a]
|
|
2023
|
+
), E = J(
|
|
2013
2024
|
() => ({
|
|
2014
2025
|
hasTenant: !!P,
|
|
2015
|
-
isAuthenticated:
|
|
2016
|
-
userType:
|
|
2026
|
+
isAuthenticated: v,
|
|
2027
|
+
userType: F == null ? void 0 : F.userType,
|
|
2017
2028
|
permissions: M,
|
|
2018
|
-
isLoading: I ||
|
|
2029
|
+
isLoading: I || u
|
|
2019
2030
|
}),
|
|
2020
2031
|
[
|
|
2021
2032
|
P,
|
|
2022
|
-
|
|
2023
|
-
|
|
2033
|
+
v,
|
|
2034
|
+
F == null ? void 0 : F.userType,
|
|
2024
2035
|
M,
|
|
2025
2036
|
I,
|
|
2026
|
-
|
|
2037
|
+
u
|
|
2027
2038
|
]
|
|
2028
|
-
),
|
|
2029
|
-
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,
|
|
2030
2041
|
required: {
|
|
2031
2042
|
tenant: L.tenant,
|
|
2032
2043
|
auth: L.auth,
|
|
@@ -2040,34 +2051,34 @@ const ae = ({
|
|
|
2040
2051
|
permissions: E.permissions
|
|
2041
2052
|
},
|
|
2042
2053
|
redirectTo: R
|
|
2043
|
-
}, [
|
|
2044
|
-
if (
|
|
2045
|
-
|
|
2046
|
-
}, [
|
|
2047
|
-
|
|
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);
|
|
2048
2059
|
}, [
|
|
2049
|
-
|
|
2060
|
+
U,
|
|
2050
2061
|
p,
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2062
|
+
h.pathname,
|
|
2063
|
+
h.search,
|
|
2064
|
+
A.returnToStorage
|
|
2054
2065
|
]), E.isLoading)
|
|
2055
|
-
return /* @__PURE__ */ s(_, { children:
|
|
2056
|
-
if (
|
|
2057
|
-
const l =
|
|
2066
|
+
return /* @__PURE__ */ s(_, { children: d ?? A.loadingFallback ?? null });
|
|
2067
|
+
if (U && R) {
|
|
2068
|
+
const l = m ?? A.accessDeniedFallback;
|
|
2058
2069
|
if (l)
|
|
2059
2070
|
return /* @__PURE__ */ s(_, { children: l });
|
|
2060
|
-
const D =
|
|
2071
|
+
const D = $t(
|
|
2061
2072
|
R,
|
|
2062
2073
|
p,
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2074
|
+
h.pathname + h.search,
|
|
2075
|
+
A.returnToParam,
|
|
2076
|
+
A.returnToStorage
|
|
2066
2077
|
);
|
|
2067
|
-
return /* @__PURE__ */ s(
|
|
2078
|
+
return /* @__PURE__ */ s(ye, { to: D, replace: !0 });
|
|
2068
2079
|
}
|
|
2069
2080
|
return /* @__PURE__ */ s(_, { children: r });
|
|
2070
|
-
},
|
|
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(
|
|
2071
2082
|
"div",
|
|
2072
2083
|
{
|
|
2073
2084
|
style: {
|
|
@@ -2084,13 +2095,13 @@ const ae = ({
|
|
|
2084
2095
|
]
|
|
2085
2096
|
}
|
|
2086
2097
|
);
|
|
2087
|
-
function
|
|
2098
|
+
function Hn({
|
|
2088
2099
|
children: r,
|
|
2089
|
-
fallback: e = /* @__PURE__ */ s(
|
|
2100
|
+
fallback: e = /* @__PURE__ */ s(Bt, {}),
|
|
2090
2101
|
allowedPlans: t,
|
|
2091
2102
|
requiredFeature: n
|
|
2092
2103
|
}) {
|
|
2093
|
-
const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: p } =
|
|
2104
|
+
const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: p } = Rt();
|
|
2094
2105
|
return p ? /* @__PURE__ */ s(
|
|
2095
2106
|
"div",
|
|
2096
2107
|
{
|
|
@@ -2103,7 +2114,7 @@ function Un({
|
|
|
2103
2114
|
}
|
|
2104
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 });
|
|
2105
2116
|
}
|
|
2106
|
-
const
|
|
2117
|
+
const qt = ({ flagName: r }) => /* @__PURE__ */ c(
|
|
2107
2118
|
"div",
|
|
2108
2119
|
{
|
|
2109
2120
|
style: {
|
|
@@ -2122,7 +2133,7 @@ const Ht = ({ flagName: r }) => /* @__PURE__ */ d(
|
|
|
2122
2133
|
children: [
|
|
2123
2134
|
/* @__PURE__ */ s("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
|
|
2124
2135
|
/* @__PURE__ */ s("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
|
|
2125
|
-
/* @__PURE__ */
|
|
2136
|
+
/* @__PURE__ */ c("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
|
|
2126
2137
|
'Feature flag "',
|
|
2127
2138
|
r,
|
|
2128
2139
|
'" is disabled'
|
|
@@ -2130,8 +2141,8 @@ const Ht = ({ flagName: r }) => /* @__PURE__ */ d(
|
|
|
2130
2141
|
]
|
|
2131
2142
|
}
|
|
2132
2143
|
);
|
|
2133
|
-
function
|
|
2134
|
-
const { isEnabled: n, loading: i } =
|
|
2144
|
+
function Bn({ name: r, children: e, fallback: t }) {
|
|
2145
|
+
const { isEnabled: n, loading: i } = At();
|
|
2135
2146
|
return i ? /* @__PURE__ */ s(
|
|
2136
2147
|
"div",
|
|
2137
2148
|
{
|
|
@@ -2145,9 +2156,9 @@ function $n({ name: r, children: e, fallback: t }) {
|
|
|
2145
2156
|
},
|
|
2146
2157
|
children: "Loading feature flags..."
|
|
2147
2158
|
}
|
|
2148
|
-
) : 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 }) });
|
|
2149
2160
|
}
|
|
2150
|
-
const
|
|
2161
|
+
const Ot = () => /* @__PURE__ */ c(
|
|
2151
2162
|
"svg",
|
|
2152
2163
|
{
|
|
2153
2164
|
width: "16",
|
|
@@ -2164,7 +2175,7 @@ const Bt = () => /* @__PURE__ */ d(
|
|
|
2164
2175
|
/* @__PURE__ */ s("circle", { cx: "12", cy: "12", r: "3" })
|
|
2165
2176
|
]
|
|
2166
2177
|
}
|
|
2167
|
-
),
|
|
2178
|
+
), zt = () => /* @__PURE__ */ c(
|
|
2168
2179
|
"svg",
|
|
2169
2180
|
{
|
|
2170
2181
|
width: "16",
|
|
@@ -2181,10 +2192,10 @@ const Bt = () => /* @__PURE__ */ d(
|
|
|
2181
2192
|
/* @__PURE__ */ s("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
2182
2193
|
]
|
|
2183
2194
|
}
|
|
2184
|
-
),
|
|
2185
|
-
showPassword: /* @__PURE__ */ s(
|
|
2186
|
-
hidePassword: /* @__PURE__ */ s(
|
|
2187
|
-
},
|
|
2195
|
+
), _t = {
|
|
2196
|
+
showPassword: /* @__PURE__ */ s(Ot, {}),
|
|
2197
|
+
hidePassword: /* @__PURE__ */ s(zt, {})
|
|
2198
|
+
}, Wt = {
|
|
2188
2199
|
title: "Sign In",
|
|
2189
2200
|
usernameLabel: "Email or Phone",
|
|
2190
2201
|
usernamePlaceholder: "Enter your email or phone number",
|
|
@@ -2198,7 +2209,7 @@ const Bt = () => /* @__PURE__ */ d(
|
|
|
2198
2209
|
magicLinkLink: "Use Magic Link",
|
|
2199
2210
|
errorMessage: "Invalid credentials",
|
|
2200
2211
|
loadingText: "Signing in..."
|
|
2201
|
-
},
|
|
2212
|
+
}, Vt = {
|
|
2202
2213
|
container: {
|
|
2203
2214
|
maxWidth: "400px",
|
|
2204
2215
|
width: "100%",
|
|
@@ -2305,7 +2316,7 @@ const Bt = () => /* @__PURE__ */ d(
|
|
|
2305
2316
|
fontSize: "0.875rem"
|
|
2306
2317
|
}
|
|
2307
2318
|
};
|
|
2308
|
-
function
|
|
2319
|
+
function qn({
|
|
2309
2320
|
copy: r = {},
|
|
2310
2321
|
styles: e = {},
|
|
2311
2322
|
icons: t = {},
|
|
@@ -2316,45 +2327,45 @@ function Hn({
|
|
|
2316
2327
|
onMagicLinkClick: p,
|
|
2317
2328
|
showForgotPassword: f = !0,
|
|
2318
2329
|
showSignupLink: w = !0,
|
|
2319
|
-
showMagicLinkOption:
|
|
2320
|
-
className:
|
|
2330
|
+
showMagicLinkOption: d = !0,
|
|
2331
|
+
className: m
|
|
2321
2332
|
}) {
|
|
2322
|
-
const [
|
|
2323
|
-
const
|
|
2324
|
-
return
|
|
2325
|
-
},
|
|
2326
|
-
if (
|
|
2327
|
-
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)) {
|
|
2328
2339
|
L("Tenant not found");
|
|
2329
2340
|
return;
|
|
2330
2341
|
}
|
|
2331
|
-
|
|
2342
|
+
A(!0), L("");
|
|
2332
2343
|
try {
|
|
2333
|
-
const
|
|
2334
|
-
username:
|
|
2344
|
+
const k = await R({
|
|
2345
|
+
username: h,
|
|
2335
2346
|
password: I
|
|
2336
2347
|
// tenantId inferred from context automatically
|
|
2337
2348
|
});
|
|
2338
|
-
n == null || n(
|
|
2339
|
-
} catch (
|
|
2340
|
-
const
|
|
2341
|
-
L(
|
|
2349
|
+
n == null || n(k);
|
|
2350
|
+
} catch (k) {
|
|
2351
|
+
const j = k.message || l.errorMessage;
|
|
2352
|
+
L(j), i == null || i(j);
|
|
2342
2353
|
} finally {
|
|
2343
|
-
|
|
2354
|
+
A(!1);
|
|
2344
2355
|
}
|
|
2345
2356
|
}
|
|
2346
|
-
},
|
|
2357
|
+
}, T = (y) => ({
|
|
2347
2358
|
...D.input,
|
|
2348
|
-
...E[
|
|
2349
|
-
}),
|
|
2359
|
+
...E[y] ? D.inputError : {}
|
|
2360
|
+
}), S = () => ({
|
|
2350
2361
|
...D.button,
|
|
2351
|
-
...
|
|
2352
|
-
...!
|
|
2362
|
+
...u ? D.buttonLoading : {},
|
|
2363
|
+
...!h || !I || u ? D.buttonDisabled : {}
|
|
2353
2364
|
});
|
|
2354
|
-
return /* @__PURE__ */
|
|
2365
|
+
return /* @__PURE__ */ c("div", { className: m, style: D.container, children: [
|
|
2355
2366
|
/* @__PURE__ */ s("h2", { style: D.title, children: l.title }),
|
|
2356
|
-
/* @__PURE__ */
|
|
2357
|
-
/* @__PURE__ */
|
|
2367
|
+
/* @__PURE__ */ c("form", { onSubmit: C, style: D.form, children: [
|
|
2368
|
+
/* @__PURE__ */ c("div", { style: D.fieldGroup, children: [
|
|
2358
2369
|
/* @__PURE__ */ s("label", { style: D.label, children: l.usernameLabel }),
|
|
2359
2370
|
/* @__PURE__ */ s(
|
|
2360
2371
|
"input",
|
|
@@ -2362,19 +2373,19 @@ function Hn({
|
|
|
2362
2373
|
id: "username",
|
|
2363
2374
|
name: "username",
|
|
2364
2375
|
type: "text",
|
|
2365
|
-
value:
|
|
2366
|
-
onChange: (
|
|
2367
|
-
|
|
2376
|
+
value: h,
|
|
2377
|
+
onChange: (y) => {
|
|
2378
|
+
v(y.target.value), E.username && N((k) => ({ ...k, username: !1 }));
|
|
2368
2379
|
},
|
|
2369
2380
|
placeholder: l.usernamePlaceholder,
|
|
2370
|
-
style:
|
|
2371
|
-
disabled:
|
|
2381
|
+
style: T("username"),
|
|
2382
|
+
disabled: u
|
|
2372
2383
|
}
|
|
2373
2384
|
)
|
|
2374
2385
|
] }),
|
|
2375
|
-
/* @__PURE__ */
|
|
2386
|
+
/* @__PURE__ */ c("div", { style: D.fieldGroup, children: [
|
|
2376
2387
|
/* @__PURE__ */ s("label", { style: D.label, children: l.passwordLabel }),
|
|
2377
|
-
/* @__PURE__ */
|
|
2388
|
+
/* @__PURE__ */ c("div", { style: D.inputContainer, children: [
|
|
2378
2389
|
/* @__PURE__ */ s(
|
|
2379
2390
|
"input",
|
|
2380
2391
|
{
|
|
@@ -2382,16 +2393,16 @@ function Hn({
|
|
|
2382
2393
|
name: "password",
|
|
2383
2394
|
type: M ? "text" : "password",
|
|
2384
2395
|
value: I,
|
|
2385
|
-
onChange: (
|
|
2386
|
-
|
|
2396
|
+
onChange: (y) => {
|
|
2397
|
+
F(y.target.value), E.password && N((k) => ({ ...k, password: !1 }));
|
|
2387
2398
|
},
|
|
2388
2399
|
placeholder: l.passwordPlaceholder,
|
|
2389
2400
|
style: {
|
|
2390
|
-
...
|
|
2401
|
+
...T("password"),
|
|
2391
2402
|
paddingRight: "2.5rem"
|
|
2392
2403
|
// Make room for the icon
|
|
2393
2404
|
},
|
|
2394
|
-
disabled:
|
|
2405
|
+
disabled: u
|
|
2395
2406
|
}
|
|
2396
2407
|
),
|
|
2397
2408
|
/* @__PURE__ */ s(
|
|
@@ -2400,29 +2411,29 @@ function Hn({
|
|
|
2400
2411
|
type: "button",
|
|
2401
2412
|
onClick: () => P(!M),
|
|
2402
2413
|
style: D.passwordToggle,
|
|
2403
|
-
disabled:
|
|
2414
|
+
disabled: u,
|
|
2404
2415
|
"aria-label": M ? "Hide password" : "Show password",
|
|
2405
|
-
children: M ?
|
|
2416
|
+
children: M ? $.hidePassword : $.showPassword
|
|
2406
2417
|
}
|
|
2407
2418
|
)
|
|
2408
2419
|
] })
|
|
2409
2420
|
] }),
|
|
2410
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: !
|
|
2411
|
-
|
|
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 })
|
|
2412
2423
|
] }),
|
|
2413
|
-
(f || w ||
|
|
2414
|
-
|
|
2415
|
-
/* @__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: [
|
|
2416
2427
|
l.magicLinkText,
|
|
2417
2428
|
" "
|
|
2418
2429
|
] }),
|
|
2419
2430
|
/* @__PURE__ */ s("a", { onClick: p, style: D.link, children: l.magicLinkLink })
|
|
2420
2431
|
] }),
|
|
2421
|
-
|
|
2432
|
+
d && (f || w) && /* @__PURE__ */ s("div", { style: D.divider, children: "•" }),
|
|
2422
2433
|
f && /* @__PURE__ */ s("a", { onClick: o, style: D.link, children: l.forgotPasswordLink }),
|
|
2423
2434
|
f && w && /* @__PURE__ */ s("div", { style: D.divider, children: "•" }),
|
|
2424
|
-
w && /* @__PURE__ */
|
|
2425
|
-
/* @__PURE__ */
|
|
2435
|
+
w && /* @__PURE__ */ c("div", { children: [
|
|
2436
|
+
/* @__PURE__ */ c("span", { style: D.divider, children: [
|
|
2426
2437
|
l.signupText,
|
|
2427
2438
|
" "
|
|
2428
2439
|
] }),
|
|
@@ -2431,7 +2442,7 @@ function Hn({
|
|
|
2431
2442
|
] })
|
|
2432
2443
|
] });
|
|
2433
2444
|
}
|
|
2434
|
-
const
|
|
2445
|
+
const jt = {
|
|
2435
2446
|
title: "Create Account",
|
|
2436
2447
|
nameLabel: "First Name",
|
|
2437
2448
|
namePlaceholder: "Enter your first name",
|
|
@@ -2457,7 +2468,7 @@ const Wt = {
|
|
|
2457
2468
|
passwordMismatchError: "Passwords do not match",
|
|
2458
2469
|
isAdminLabel: "Create new organization",
|
|
2459
2470
|
isAdminDescription: "Check this if you want to create a new organization"
|
|
2460
|
-
},
|
|
2471
|
+
}, Gt = {
|
|
2461
2472
|
container: {
|
|
2462
2473
|
maxWidth: "400px",
|
|
2463
2474
|
width: "100%",
|
|
@@ -2556,7 +2567,7 @@ const Wt = {
|
|
|
2556
2567
|
fontSize: "0.875rem"
|
|
2557
2568
|
}
|
|
2558
2569
|
};
|
|
2559
|
-
function
|
|
2570
|
+
function On({
|
|
2560
2571
|
copy: r = {},
|
|
2561
2572
|
styles: e = {},
|
|
2562
2573
|
signupType: t = "user",
|
|
@@ -2568,91 +2579,91 @@ function Bn({
|
|
|
2568
2579
|
showMagicLinkOption: f = !0,
|
|
2569
2580
|
className: w
|
|
2570
2581
|
}) {
|
|
2571
|
-
const [
|
|
2572
|
-
const
|
|
2573
|
-
return
|
|
2574
|
-
},
|
|
2575
|
-
if (
|
|
2576
|
-
if (
|
|
2577
|
-
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 });
|
|
2578
2589
|
return;
|
|
2579
2590
|
}
|
|
2580
|
-
if (t === "user" && !(
|
|
2591
|
+
if (t === "user" && !(S != null && S.id)) {
|
|
2581
2592
|
D("Tenant not found");
|
|
2582
2593
|
return;
|
|
2583
2594
|
}
|
|
2584
|
-
|
|
2595
|
+
U(!0), D("");
|
|
2585
2596
|
try {
|
|
2586
|
-
let
|
|
2587
|
-
t === "tenant" ?
|
|
2597
|
+
let X;
|
|
2598
|
+
t === "tenant" ? X = await T({
|
|
2588
2599
|
email: I || void 0,
|
|
2589
2600
|
phoneNumber: M || void 0,
|
|
2590
|
-
name:
|
|
2591
|
-
password:
|
|
2601
|
+
name: d,
|
|
2602
|
+
password: u,
|
|
2592
2603
|
tenantName: E,
|
|
2593
|
-
lastName:
|
|
2594
|
-
}) :
|
|
2604
|
+
lastName: h || void 0
|
|
2605
|
+
}) : X = await C({
|
|
2595
2606
|
email: I || void 0,
|
|
2596
2607
|
phoneNumber: M || void 0,
|
|
2597
|
-
name:
|
|
2598
|
-
password:
|
|
2599
|
-
tenantId:
|
|
2600
|
-
lastName:
|
|
2601
|
-
}), n == null || n(
|
|
2602
|
-
} catch (
|
|
2603
|
-
const
|
|
2604
|
-
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);
|
|
2605
2616
|
} finally {
|
|
2606
|
-
|
|
2617
|
+
U(!1);
|
|
2607
2618
|
}
|
|
2608
2619
|
}
|
|
2609
|
-
},
|
|
2610
|
-
...
|
|
2611
|
-
|
|
2612
|
-
}),
|
|
2613
|
-
...
|
|
2614
|
-
...R ?
|
|
2615
|
-
...!
|
|
2616
|
-
}),
|
|
2617
|
-
return /* @__PURE__ */
|
|
2618
|
-
/* @__PURE__ */ s("h2", { style:
|
|
2619
|
-
/* @__PURE__ */
|
|
2620
|
-
/* @__PURE__ */
|
|
2621
|
-
/* @__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 }),
|
|
2622
2633
|
/* @__PURE__ */ s(
|
|
2623
2634
|
"input",
|
|
2624
2635
|
{
|
|
2625
2636
|
id: "name",
|
|
2626
2637
|
name: "name",
|
|
2627
2638
|
type: "text",
|
|
2628
|
-
value:
|
|
2629
|
-
onChange: (
|
|
2630
|
-
|
|
2639
|
+
value: d,
|
|
2640
|
+
onChange: (B) => {
|
|
2641
|
+
m(B.target.value), $.name && g((X) => ({ ...X, name: !1 }));
|
|
2631
2642
|
},
|
|
2632
|
-
placeholder:
|
|
2633
|
-
style:
|
|
2643
|
+
placeholder: y.namePlaceholder,
|
|
2644
|
+
style: O("name"),
|
|
2634
2645
|
disabled: R
|
|
2635
2646
|
}
|
|
2636
2647
|
)
|
|
2637
2648
|
] }),
|
|
2638
|
-
/* @__PURE__ */
|
|
2639
|
-
/* @__PURE__ */ s("label", { style:
|
|
2649
|
+
/* @__PURE__ */ c("div", { style: k.fieldGroup, children: [
|
|
2650
|
+
/* @__PURE__ */ s("label", { style: k.label, children: y.lastNameLabel }),
|
|
2640
2651
|
/* @__PURE__ */ s(
|
|
2641
2652
|
"input",
|
|
2642
2653
|
{
|
|
2643
2654
|
id: "lastName",
|
|
2644
2655
|
name: "lastName",
|
|
2645
2656
|
type: "text",
|
|
2646
|
-
value:
|
|
2647
|
-
onChange: (
|
|
2648
|
-
placeholder:
|
|
2649
|
-
style:
|
|
2657
|
+
value: h,
|
|
2658
|
+
onChange: (B) => v(B.target.value),
|
|
2659
|
+
placeholder: y.lastNamePlaceholder,
|
|
2660
|
+
style: k.input,
|
|
2650
2661
|
disabled: R
|
|
2651
2662
|
}
|
|
2652
2663
|
)
|
|
2653
2664
|
] }),
|
|
2654
|
-
/* @__PURE__ */
|
|
2655
|
-
/* @__PURE__ */ s("label", { style:
|
|
2665
|
+
/* @__PURE__ */ c("div", { style: k.fieldGroup, children: [
|
|
2666
|
+
/* @__PURE__ */ s("label", { style: k.label, children: y.emailLabel }),
|
|
2656
2667
|
/* @__PURE__ */ s(
|
|
2657
2668
|
"input",
|
|
2658
2669
|
{
|
|
@@ -2660,17 +2671,17 @@ function Bn({
|
|
|
2660
2671
|
name: "email",
|
|
2661
2672
|
type: "email",
|
|
2662
2673
|
value: I,
|
|
2663
|
-
onChange: (
|
|
2664
|
-
|
|
2674
|
+
onChange: (B) => {
|
|
2675
|
+
F(B.target.value), $.email && g((X) => ({ ...X, email: !1, phoneNumber: !1 }));
|
|
2665
2676
|
},
|
|
2666
|
-
placeholder:
|
|
2667
|
-
style:
|
|
2677
|
+
placeholder: y.emailPlaceholder,
|
|
2678
|
+
style: O("email"),
|
|
2668
2679
|
disabled: R
|
|
2669
2680
|
}
|
|
2670
2681
|
)
|
|
2671
2682
|
] }),
|
|
2672
|
-
/* @__PURE__ */
|
|
2673
|
-
/* @__PURE__ */ s("label", { style:
|
|
2683
|
+
/* @__PURE__ */ c("div", { style: k.fieldGroup, children: [
|
|
2684
|
+
/* @__PURE__ */ s("label", { style: k.label, children: y.phoneNumberLabel }),
|
|
2674
2685
|
/* @__PURE__ */ s(
|
|
2675
2686
|
"input",
|
|
2676
2687
|
{
|
|
@@ -2678,11 +2689,11 @@ function Bn({
|
|
|
2678
2689
|
name: "phoneNumber",
|
|
2679
2690
|
type: "tel",
|
|
2680
2691
|
value: M,
|
|
2681
|
-
onChange: (
|
|
2682
|
-
P(
|
|
2692
|
+
onChange: (B) => {
|
|
2693
|
+
P(B.target.value), $.phoneNumber && g((X) => ({ ...X, email: !1, phoneNumber: !1 }));
|
|
2683
2694
|
},
|
|
2684
|
-
placeholder:
|
|
2685
|
-
style:
|
|
2695
|
+
placeholder: y.phoneNumberPlaceholder,
|
|
2696
|
+
style: O("phoneNumber"),
|
|
2686
2697
|
disabled: R
|
|
2687
2698
|
}
|
|
2688
2699
|
)
|
|
@@ -2699,44 +2710,44 @@ function Bn({
|
|
|
2699
2710
|
children: "At least one contact method (email or phone) is required"
|
|
2700
2711
|
}
|
|
2701
2712
|
),
|
|
2702
|
-
/* @__PURE__ */
|
|
2703
|
-
/* @__PURE__ */ s("label", { style:
|
|
2713
|
+
/* @__PURE__ */ c("div", { style: k.fieldGroup, children: [
|
|
2714
|
+
/* @__PURE__ */ s("label", { style: k.label, children: y.passwordLabel }),
|
|
2704
2715
|
/* @__PURE__ */ s(
|
|
2705
2716
|
"input",
|
|
2706
2717
|
{
|
|
2707
2718
|
id: "password",
|
|
2708
2719
|
name: "password",
|
|
2709
2720
|
type: "password",
|
|
2710
|
-
value:
|
|
2711
|
-
onChange: (
|
|
2712
|
-
|
|
2721
|
+
value: u,
|
|
2722
|
+
onChange: (B) => {
|
|
2723
|
+
A(B.target.value), $.password && g((X) => ({ ...X, password: !1 }));
|
|
2713
2724
|
},
|
|
2714
|
-
placeholder:
|
|
2715
|
-
style:
|
|
2725
|
+
placeholder: y.passwordPlaceholder,
|
|
2726
|
+
style: O("password"),
|
|
2716
2727
|
disabled: R
|
|
2717
2728
|
}
|
|
2718
2729
|
)
|
|
2719
2730
|
] }),
|
|
2720
|
-
/* @__PURE__ */
|
|
2721
|
-
/* @__PURE__ */ s("label", { style:
|
|
2731
|
+
/* @__PURE__ */ c("div", { style: k.fieldGroup, children: [
|
|
2732
|
+
/* @__PURE__ */ s("label", { style: k.label, children: y.confirmPasswordLabel }),
|
|
2722
2733
|
/* @__PURE__ */ s(
|
|
2723
2734
|
"input",
|
|
2724
2735
|
{
|
|
2725
2736
|
id: "confirmPassword",
|
|
2726
2737
|
name: "confirmPassword",
|
|
2727
2738
|
type: "password",
|
|
2728
|
-
value:
|
|
2729
|
-
onChange: (
|
|
2730
|
-
L(
|
|
2739
|
+
value: b,
|
|
2740
|
+
onChange: (B) => {
|
|
2741
|
+
L(B.target.value), $.confirmPassword && g((X) => ({ ...X, confirmPassword: !1 })), l === y.passwordMismatchError && D("");
|
|
2731
2742
|
},
|
|
2732
|
-
placeholder:
|
|
2733
|
-
style:
|
|
2743
|
+
placeholder: y.confirmPasswordPlaceholder,
|
|
2744
|
+
style: O("confirmPassword"),
|
|
2734
2745
|
disabled: R
|
|
2735
2746
|
}
|
|
2736
2747
|
)
|
|
2737
2748
|
] }),
|
|
2738
|
-
t === "tenant" && /* @__PURE__ */
|
|
2739
|
-
/* @__PURE__ */ s("label", { style:
|
|
2749
|
+
t === "tenant" && /* @__PURE__ */ c("div", { style: k.fieldGroup, children: [
|
|
2750
|
+
/* @__PURE__ */ s("label", { style: k.label, children: y.tenantNameLabel }),
|
|
2740
2751
|
/* @__PURE__ */ s(
|
|
2741
2752
|
"input",
|
|
2742
2753
|
{
|
|
@@ -2744,38 +2755,38 @@ function Bn({
|
|
|
2744
2755
|
name: "tenantName",
|
|
2745
2756
|
type: "text",
|
|
2746
2757
|
value: E,
|
|
2747
|
-
onChange: (
|
|
2748
|
-
|
|
2758
|
+
onChange: (B) => {
|
|
2759
|
+
N(B.target.value), $.tenantName && g((X) => ({ ...X, tenantName: !1 }));
|
|
2749
2760
|
},
|
|
2750
|
-
placeholder:
|
|
2751
|
-
style:
|
|
2761
|
+
placeholder: y.tenantNamePlaceholder,
|
|
2762
|
+
style: O("tenantName"),
|
|
2752
2763
|
disabled: R
|
|
2753
2764
|
}
|
|
2754
2765
|
)
|
|
2755
2766
|
] }),
|
|
2756
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: !
|
|
2757
|
-
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 })
|
|
2758
2769
|
] }),
|
|
2759
|
-
(p || f) && /* @__PURE__ */
|
|
2760
|
-
f && /* @__PURE__ */
|
|
2761
|
-
/* @__PURE__ */
|
|
2762
|
-
|
|
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,
|
|
2763
2774
|
" "
|
|
2764
2775
|
] }),
|
|
2765
|
-
/* @__PURE__ */ s("a", { onClick: a, style:
|
|
2776
|
+
/* @__PURE__ */ s("a", { onClick: a, style: k.link, children: y.magicLinkLink })
|
|
2766
2777
|
] }),
|
|
2767
|
-
f && p && /* @__PURE__ */ s("div", { style:
|
|
2768
|
-
p && /* @__PURE__ */
|
|
2769
|
-
/* @__PURE__ */
|
|
2770
|
-
|
|
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,
|
|
2771
2782
|
" "
|
|
2772
2783
|
] }),
|
|
2773
|
-
/* @__PURE__ */ s("a", { onClick: o, style:
|
|
2784
|
+
/* @__PURE__ */ s("a", { onClick: o, style: k.link, children: y.loginLink })
|
|
2774
2785
|
] })
|
|
2775
2786
|
] })
|
|
2776
2787
|
] });
|
|
2777
2788
|
}
|
|
2778
|
-
const
|
|
2789
|
+
const Zt = {
|
|
2779
2790
|
title: "Sign In with Magic Link",
|
|
2780
2791
|
emailLabel: "Email",
|
|
2781
2792
|
emailPlaceholder: "Enter your email",
|
|
@@ -2793,7 +2804,7 @@ const jt = {
|
|
|
2793
2804
|
loadingText: "Sending magic link...",
|
|
2794
2805
|
verifyingText: "Verifying magic link...",
|
|
2795
2806
|
description: "Enter your email to receive a magic link. If you don't have an account, we'll create one for you."
|
|
2796
|
-
},
|
|
2807
|
+
}, Kt = {
|
|
2797
2808
|
container: {
|
|
2798
2809
|
maxWidth: "400px",
|
|
2799
2810
|
width: "100%",
|
|
@@ -2896,7 +2907,7 @@ const jt = {
|
|
|
2896
2907
|
fontSize: "0.875rem"
|
|
2897
2908
|
}
|
|
2898
2909
|
};
|
|
2899
|
-
function
|
|
2910
|
+
function zn({
|
|
2900
2911
|
copy: r = {},
|
|
2901
2912
|
styles: e = {},
|
|
2902
2913
|
onSuccess: t,
|
|
@@ -2908,85 +2919,85 @@ function qn({
|
|
|
2908
2919
|
verifyToken: f,
|
|
2909
2920
|
frontendUrl: w
|
|
2910
2921
|
}) {
|
|
2911
|
-
const [
|
|
2912
|
-
|
|
2913
|
-
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);
|
|
2914
2925
|
}, [f]);
|
|
2915
|
-
const
|
|
2916
|
-
if (!
|
|
2926
|
+
const y = async (q) => {
|
|
2927
|
+
if (!C || !d) {
|
|
2917
2928
|
L("Missing tenant or email");
|
|
2918
2929
|
return;
|
|
2919
2930
|
}
|
|
2920
|
-
|
|
2931
|
+
A(!0), L("");
|
|
2921
2932
|
try {
|
|
2922
|
-
const
|
|
2923
|
-
token:
|
|
2924
|
-
email:
|
|
2933
|
+
const W = await g({
|
|
2934
|
+
token: q,
|
|
2935
|
+
email: d
|
|
2925
2936
|
// tenantId inferred from context automatically
|
|
2926
2937
|
});
|
|
2927
|
-
t == null || t(
|
|
2928
|
-
} catch (
|
|
2929
|
-
const
|
|
2930
|
-
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);
|
|
2931
2942
|
} finally {
|
|
2932
|
-
|
|
2943
|
+
A(!1);
|
|
2933
2944
|
}
|
|
2934
|
-
},
|
|
2935
|
-
const
|
|
2936
|
-
return
|
|
2937
|
-
},
|
|
2938
|
-
if (
|
|
2939
|
-
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)) {
|
|
2940
2951
|
L("Tenant not found");
|
|
2941
2952
|
return;
|
|
2942
2953
|
}
|
|
2943
|
-
P(!0), L(""),
|
|
2954
|
+
P(!0), L(""), N("");
|
|
2944
2955
|
try {
|
|
2945
|
-
const
|
|
2946
|
-
email:
|
|
2947
|
-
tenantId:
|
|
2948
|
-
frontendUrl:
|
|
2949
|
-
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,
|
|
2950
2961
|
lastName: l ? I : void 0
|
|
2951
2962
|
});
|
|
2952
|
-
|
|
2953
|
-
} catch (
|
|
2954
|
-
const
|
|
2955
|
-
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);
|
|
2956
2967
|
} finally {
|
|
2957
2968
|
P(!1);
|
|
2958
2969
|
}
|
|
2959
2970
|
}
|
|
2960
|
-
},
|
|
2961
|
-
...
|
|
2962
|
-
...R[
|
|
2963
|
-
}),
|
|
2964
|
-
...
|
|
2965
|
-
...M ||
|
|
2966
|
-
...!
|
|
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 : {}
|
|
2967
2978
|
});
|
|
2968
|
-
return
|
|
2969
|
-
/* @__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 }),
|
|
2970
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..." }) })
|
|
2971
|
-
] }) : /* @__PURE__ */
|
|
2972
|
-
/* @__PURE__ */ s("h2", { style:
|
|
2973
|
-
/* @__PURE__ */ s("p", { style:
|
|
2974
|
-
/* @__PURE__ */
|
|
2975
|
-
/* @__PURE__ */
|
|
2976
|
-
/* @__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 }),
|
|
2977
2988
|
/* @__PURE__ */ s(
|
|
2978
2989
|
"input",
|
|
2979
2990
|
{
|
|
2980
2991
|
id: "email",
|
|
2981
2992
|
name: "email",
|
|
2982
2993
|
type: "email",
|
|
2983
|
-
value:
|
|
2984
|
-
onChange: (
|
|
2985
|
-
|
|
2994
|
+
value: d,
|
|
2995
|
+
onChange: (q) => {
|
|
2996
|
+
m(q.target.value), R.email && U((W) => ({ ...W, email: !1 }));
|
|
2986
2997
|
},
|
|
2987
|
-
placeholder:
|
|
2988
|
-
style:
|
|
2989
|
-
disabled: M ||
|
|
2998
|
+
placeholder: T.emailPlaceholder,
|
|
2999
|
+
style: Z("email"),
|
|
3000
|
+
disabled: M || u
|
|
2990
3001
|
}
|
|
2991
3002
|
)
|
|
2992
3003
|
] }),
|
|
@@ -3006,27 +3017,27 @@ function qn({
|
|
|
3006
3017
|
children: "New user? Add your name"
|
|
3007
3018
|
}
|
|
3008
3019
|
) }),
|
|
3009
|
-
l && /* @__PURE__ */
|
|
3010
|
-
/* @__PURE__ */
|
|
3011
|
-
/* @__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 }),
|
|
3012
3023
|
/* @__PURE__ */ s(
|
|
3013
3024
|
"input",
|
|
3014
3025
|
{
|
|
3015
3026
|
id: "name",
|
|
3016
3027
|
name: "name",
|
|
3017
3028
|
type: "text",
|
|
3018
|
-
value:
|
|
3019
|
-
onChange: (
|
|
3020
|
-
|
|
3029
|
+
value: h,
|
|
3030
|
+
onChange: (q) => {
|
|
3031
|
+
v(q.target.value), R.name && U((W) => ({ ...W, name: !1 }));
|
|
3021
3032
|
},
|
|
3022
|
-
placeholder:
|
|
3023
|
-
style:
|
|
3024
|
-
disabled: M ||
|
|
3033
|
+
placeholder: T.namePlaceholder,
|
|
3034
|
+
style: Z("name"),
|
|
3035
|
+
disabled: M || u
|
|
3025
3036
|
}
|
|
3026
3037
|
)
|
|
3027
3038
|
] }),
|
|
3028
|
-
/* @__PURE__ */
|
|
3029
|
-
/* @__PURE__ */ s("label", { style:
|
|
3039
|
+
/* @__PURE__ */ c("div", { style: S.fieldGroup, children: [
|
|
3040
|
+
/* @__PURE__ */ s("label", { style: S.label, children: T.lastNameLabel }),
|
|
3030
3041
|
/* @__PURE__ */ s(
|
|
3031
3042
|
"input",
|
|
3032
3043
|
{
|
|
@@ -3034,10 +3045,10 @@ function qn({
|
|
|
3034
3045
|
name: "lastName",
|
|
3035
3046
|
type: "text",
|
|
3036
3047
|
value: I,
|
|
3037
|
-
onChange: (
|
|
3038
|
-
placeholder:
|
|
3039
|
-
style:
|
|
3040
|
-
disabled: M ||
|
|
3048
|
+
onChange: (q) => F(q.target.value),
|
|
3049
|
+
placeholder: T.lastNamePlaceholder,
|
|
3050
|
+
style: S.input,
|
|
3051
|
+
disabled: M || u
|
|
3041
3052
|
}
|
|
3042
3053
|
)
|
|
3043
3054
|
] }),
|
|
@@ -3046,7 +3057,7 @@ function qn({
|
|
|
3046
3057
|
{
|
|
3047
3058
|
type: "button",
|
|
3048
3059
|
onClick: () => {
|
|
3049
|
-
D(!1),
|
|
3060
|
+
D(!1), v(""), F("");
|
|
3050
3061
|
},
|
|
3051
3062
|
style: {
|
|
3052
3063
|
background: "none",
|
|
@@ -3060,30 +3071,30 @@ function qn({
|
|
|
3060
3071
|
}
|
|
3061
3072
|
) })
|
|
3062
3073
|
] }),
|
|
3063
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: !
|
|
3064
|
-
|
|
3065
|
-
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 })
|
|
3066
3077
|
] }),
|
|
3067
|
-
a && /* @__PURE__ */
|
|
3068
|
-
/* @__PURE__ */
|
|
3069
|
-
/* @__PURE__ */
|
|
3070
|
-
|
|
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,
|
|
3071
3082
|
" "
|
|
3072
3083
|
] }),
|
|
3073
|
-
/* @__PURE__ */ s("a", { onClick: i, style:
|
|
3084
|
+
/* @__PURE__ */ s("a", { onClick: i, style: S.link, children: T.loginLink })
|
|
3074
3085
|
] }),
|
|
3075
|
-
/* @__PURE__ */ s("div", { style:
|
|
3076
|
-
/* @__PURE__ */
|
|
3077
|
-
/* @__PURE__ */
|
|
3078
|
-
|
|
3086
|
+
/* @__PURE__ */ s("div", { style: S.divider, children: "•" }),
|
|
3087
|
+
/* @__PURE__ */ c("div", { children: [
|
|
3088
|
+
/* @__PURE__ */ c("span", { style: S.divider, children: [
|
|
3089
|
+
T.signupText,
|
|
3079
3090
|
" "
|
|
3080
3091
|
] }),
|
|
3081
|
-
/* @__PURE__ */ s("a", { onClick: o, style:
|
|
3092
|
+
/* @__PURE__ */ s("a", { onClick: o, style: S.link, children: T.signupLink })
|
|
3082
3093
|
] })
|
|
3083
3094
|
] })
|
|
3084
3095
|
] });
|
|
3085
3096
|
}
|
|
3086
|
-
const
|
|
3097
|
+
const Jt = {
|
|
3087
3098
|
title: "Verifying Magic Link",
|
|
3088
3099
|
verifyingMessage: "Please wait while we verify your magic link...",
|
|
3089
3100
|
successMessage: "Magic link verified successfully! You are now logged in.",
|
|
@@ -3091,7 +3102,7 @@ const Zt = {
|
|
|
3091
3102
|
redirectingMessage: "Redirecting you to the dashboard...",
|
|
3092
3103
|
retryButton: "Try Again",
|
|
3093
3104
|
backToLoginButton: "Back to Login"
|
|
3094
|
-
},
|
|
3105
|
+
}, Qe = {
|
|
3095
3106
|
container: {
|
|
3096
3107
|
maxWidth: "400px",
|
|
3097
3108
|
width: "100%",
|
|
@@ -3178,7 +3189,7 @@ const Zt = {
|
|
|
3178
3189
|
cursor: "pointer",
|
|
3179
3190
|
transition: "all 0.15s ease-in-out"
|
|
3180
3191
|
}
|
|
3181
|
-
},
|
|
3192
|
+
}, Yt = () => /* @__PURE__ */ s("div", { style: Qe.spinner }), Qt = () => /* @__PURE__ */ c(
|
|
3182
3193
|
"svg",
|
|
3183
3194
|
{
|
|
3184
3195
|
width: "48",
|
|
@@ -3195,7 +3206,7 @@ const Zt = {
|
|
|
3195
3206
|
/* @__PURE__ */ s("polyline", { points: "22,4 12,14.01 9,11.01" })
|
|
3196
3207
|
]
|
|
3197
3208
|
}
|
|
3198
|
-
),
|
|
3209
|
+
), Xt = () => /* @__PURE__ */ c(
|
|
3199
3210
|
"svg",
|
|
3200
3211
|
{
|
|
3201
3212
|
width: "48",
|
|
@@ -3213,12 +3224,12 @@ const Zt = {
|
|
|
3213
3224
|
/* @__PURE__ */ s("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
|
|
3214
3225
|
]
|
|
3215
3226
|
}
|
|
3216
|
-
),
|
|
3217
|
-
loading: /* @__PURE__ */ s(
|
|
3218
|
-
success: /* @__PURE__ */ s(
|
|
3219
|
-
error: /* @__PURE__ */ s(
|
|
3227
|
+
), en = {
|
|
3228
|
+
loading: /* @__PURE__ */ s(Yt, {}),
|
|
3229
|
+
success: /* @__PURE__ */ s(Qt, {}),
|
|
3230
|
+
error: /* @__PURE__ */ s(Xt, {})
|
|
3220
3231
|
};
|
|
3221
|
-
function
|
|
3232
|
+
function _n({
|
|
3222
3233
|
copy: r = {},
|
|
3223
3234
|
styles: e = {},
|
|
3224
3235
|
icons: t = {},
|
|
@@ -3229,18 +3240,18 @@ function On({
|
|
|
3229
3240
|
className: p,
|
|
3230
3241
|
token: f,
|
|
3231
3242
|
email: w,
|
|
3232
|
-
appId:
|
|
3233
|
-
tenantSlug:
|
|
3234
|
-
autoRedirectDelay:
|
|
3243
|
+
appId: d,
|
|
3244
|
+
tenantSlug: m,
|
|
3245
|
+
autoRedirectDelay: h = 3e3
|
|
3235
3246
|
}) {
|
|
3236
|
-
const [
|
|
3247
|
+
const [v, I] = x("verifying"), [F, M] = x(""), { verifyMagicLink: P } = ce(), u = { ...Jt, ...r }, A = { ...Qe, ...e }, b = { ...en, ...t }, L = () => {
|
|
3237
3248
|
if (typeof window > "u") return {};
|
|
3238
3249
|
const l = new URLSearchParams(window.location.search);
|
|
3239
3250
|
return {
|
|
3240
3251
|
token: f || l.get("token") || "",
|
|
3241
3252
|
email: w || l.get("email") || "",
|
|
3242
|
-
appId:
|
|
3243
|
-
tenantSlug:
|
|
3253
|
+
appId: d || l.get("appId") || "",
|
|
3254
|
+
tenantSlug: m || l.get("tenantSlug") || void 0
|
|
3244
3255
|
};
|
|
3245
3256
|
}, E = async () => {
|
|
3246
3257
|
I("verifying"), M("");
|
|
@@ -3253,69 +3264,69 @@ function On({
|
|
|
3253
3264
|
email: l.email,
|
|
3254
3265
|
tenantSlug: l.tenantSlug
|
|
3255
3266
|
});
|
|
3256
|
-
I("success"), n == null || n(D),
|
|
3267
|
+
I("success"), n == null || n(D), h > 0 && setTimeout(() => {
|
|
3257
3268
|
I("redirecting");
|
|
3258
|
-
},
|
|
3269
|
+
}, h);
|
|
3259
3270
|
} catch (l) {
|
|
3260
|
-
const D = l.message ||
|
|
3271
|
+
const D = l.message || u.errorMessage;
|
|
3261
3272
|
M(D), I("error"), i == null || i(D);
|
|
3262
3273
|
}
|
|
3263
|
-
},
|
|
3274
|
+
}, N = () => {
|
|
3264
3275
|
o == null || o(), E();
|
|
3265
3276
|
}, R = () => {
|
|
3266
3277
|
a == null || a();
|
|
3267
3278
|
};
|
|
3268
|
-
|
|
3279
|
+
ee(() => {
|
|
3269
3280
|
E();
|
|
3270
3281
|
}, []);
|
|
3271
|
-
const
|
|
3272
|
-
switch (
|
|
3282
|
+
const U = () => {
|
|
3283
|
+
switch (v) {
|
|
3273
3284
|
case "verifying":
|
|
3274
|
-
return /* @__PURE__ */
|
|
3275
|
-
|
|
3276
|
-
|
|
3285
|
+
return /* @__PURE__ */ c("div", { style: A.message, children: [
|
|
3286
|
+
b.loading,
|
|
3287
|
+
u.verifyingMessage
|
|
3277
3288
|
] });
|
|
3278
3289
|
case "success":
|
|
3279
|
-
return /* @__PURE__ */
|
|
3280
|
-
|
|
3281
|
-
/* @__PURE__ */ s("div", { style:
|
|
3290
|
+
return /* @__PURE__ */ c(_, { children: [
|
|
3291
|
+
b.success,
|
|
3292
|
+
/* @__PURE__ */ s("div", { style: A.successMessage, children: u.successMessage })
|
|
3282
3293
|
] });
|
|
3283
3294
|
case "redirecting":
|
|
3284
|
-
return /* @__PURE__ */
|
|
3285
|
-
|
|
3286
|
-
/* @__PURE__ */ s("div", { style:
|
|
3295
|
+
return /* @__PURE__ */ c(_, { children: [
|
|
3296
|
+
b.loading,
|
|
3297
|
+
/* @__PURE__ */ s("div", { style: A.message, children: u.redirectingMessage })
|
|
3287
3298
|
] });
|
|
3288
3299
|
case "error":
|
|
3289
|
-
return /* @__PURE__ */
|
|
3290
|
-
|
|
3291
|
-
/* @__PURE__ */ s("div", { style:
|
|
3292
|
-
/* @__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: [
|
|
3293
3304
|
/* @__PURE__ */ s(
|
|
3294
3305
|
"button",
|
|
3295
3306
|
{
|
|
3296
|
-
onClick:
|
|
3297
|
-
style:
|
|
3307
|
+
onClick: N,
|
|
3308
|
+
style: A.retryButton,
|
|
3298
3309
|
onMouseOver: (l) => {
|
|
3299
3310
|
l.currentTarget.style.backgroundColor = "#2563eb";
|
|
3300
3311
|
},
|
|
3301
3312
|
onMouseOut: (l) => {
|
|
3302
3313
|
l.currentTarget.style.backgroundColor = "#3b82f6";
|
|
3303
3314
|
},
|
|
3304
|
-
children:
|
|
3315
|
+
children: u.retryButton
|
|
3305
3316
|
}
|
|
3306
3317
|
),
|
|
3307
3318
|
/* @__PURE__ */ s(
|
|
3308
3319
|
"button",
|
|
3309
3320
|
{
|
|
3310
3321
|
onClick: R,
|
|
3311
|
-
style:
|
|
3322
|
+
style: A.backButton,
|
|
3312
3323
|
onMouseOver: (l) => {
|
|
3313
3324
|
l.currentTarget.style.backgroundColor = "#e5e7eb";
|
|
3314
3325
|
},
|
|
3315
3326
|
onMouseOut: (l) => {
|
|
3316
3327
|
l.currentTarget.style.backgroundColor = "#f3f4f6";
|
|
3317
3328
|
},
|
|
3318
|
-
children:
|
|
3329
|
+
children: u.backToLoginButton
|
|
3319
3330
|
}
|
|
3320
3331
|
)
|
|
3321
3332
|
] })
|
|
@@ -3324,18 +3335,18 @@ function On({
|
|
|
3324
3335
|
return null;
|
|
3325
3336
|
}
|
|
3326
3337
|
};
|
|
3327
|
-
return /* @__PURE__ */
|
|
3338
|
+
return /* @__PURE__ */ c("div", { style: A.container, className: p, children: [
|
|
3328
3339
|
/* @__PURE__ */ s("style", { children: `
|
|
3329
3340
|
@keyframes spin {
|
|
3330
3341
|
0% { transform: rotate(0deg); }
|
|
3331
3342
|
100% { transform: rotate(360deg); }
|
|
3332
3343
|
}
|
|
3333
3344
|
` }),
|
|
3334
|
-
/* @__PURE__ */ s("h1", { style:
|
|
3335
|
-
|
|
3345
|
+
/* @__PURE__ */ s("h1", { style: A.title, children: u.title }),
|
|
3346
|
+
U()
|
|
3336
3347
|
] });
|
|
3337
3348
|
}
|
|
3338
|
-
const
|
|
3349
|
+
const tn = {
|
|
3339
3350
|
title: "Reset Password",
|
|
3340
3351
|
subtitle: "Enter your email address and we'll send you a link to reset your password.",
|
|
3341
3352
|
emailLabel: "Email",
|
|
@@ -3357,7 +3368,7 @@ const Xt = {
|
|
|
3357
3368
|
resetLoadingText: "Resetting...",
|
|
3358
3369
|
resetSuccessMessage: "Password reset successfully!",
|
|
3359
3370
|
passwordMismatchError: "Passwords do not match"
|
|
3360
|
-
},
|
|
3371
|
+
}, nn = {
|
|
3361
3372
|
container: {
|
|
3362
3373
|
maxWidth: "400px",
|
|
3363
3374
|
margin: "0 auto",
|
|
@@ -3449,7 +3460,7 @@ const Xt = {
|
|
|
3449
3460
|
cursor: "pointer"
|
|
3450
3461
|
}
|
|
3451
3462
|
};
|
|
3452
|
-
function
|
|
3463
|
+
function Wn({
|
|
3453
3464
|
copy: r = {},
|
|
3454
3465
|
styles: e = {},
|
|
3455
3466
|
mode: t = "request",
|
|
@@ -3460,101 +3471,101 @@ function zn({
|
|
|
3460
3471
|
onModeChange: p,
|
|
3461
3472
|
className: f
|
|
3462
3473
|
}) {
|
|
3463
|
-
const [w,
|
|
3464
|
-
const
|
|
3465
|
-
return w.trim() || (
|
|
3466
|
-
},
|
|
3467
|
-
const
|
|
3468
|
-
return
|
|
3469
|
-
},
|
|
3470
|
-
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()) {
|
|
3471
3482
|
if (!(D != null && D.id)) {
|
|
3472
|
-
|
|
3483
|
+
b("Tenant not found");
|
|
3473
3484
|
return;
|
|
3474
3485
|
}
|
|
3475
|
-
|
|
3486
|
+
u(!0), b(""), E("");
|
|
3476
3487
|
try {
|
|
3477
|
-
await
|
|
3478
|
-
} catch (
|
|
3479
|
-
const
|
|
3480
|
-
|
|
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);
|
|
3481
3492
|
} finally {
|
|
3482
|
-
|
|
3493
|
+
u(!1);
|
|
3483
3494
|
}
|
|
3484
3495
|
}
|
|
3485
|
-
},
|
|
3486
|
-
if (
|
|
3487
|
-
if (
|
|
3488
|
-
|
|
3496
|
+
}, y = async (O) => {
|
|
3497
|
+
if (O.preventDefault(), !!T()) {
|
|
3498
|
+
if (v !== F) {
|
|
3499
|
+
b($.passwordMismatchError), R({ confirmPassword: !0 });
|
|
3489
3500
|
return;
|
|
3490
3501
|
}
|
|
3491
|
-
|
|
3502
|
+
u(!0), b(""), E("");
|
|
3492
3503
|
try {
|
|
3493
|
-
await l({ token:
|
|
3494
|
-
} catch (
|
|
3495
|
-
const
|
|
3496
|
-
|
|
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);
|
|
3497
3508
|
} finally {
|
|
3498
|
-
|
|
3509
|
+
u(!1);
|
|
3499
3510
|
}
|
|
3500
3511
|
}
|
|
3501
|
-
},
|
|
3502
|
-
...
|
|
3503
|
-
...
|
|
3504
|
-
}),
|
|
3505
|
-
...
|
|
3506
|
-
...P ?
|
|
3512
|
+
}, k = (O) => ({
|
|
3513
|
+
...g.input,
|
|
3514
|
+
...N[O] ? g.inputError : {}
|
|
3515
|
+
}), j = () => ({
|
|
3516
|
+
...g.button,
|
|
3517
|
+
...P ? g.buttonLoading : {}
|
|
3507
3518
|
});
|
|
3508
3519
|
if (t === "reset") {
|
|
3509
|
-
const
|
|
3510
|
-
return /* @__PURE__ */
|
|
3511
|
-
/* @__PURE__ */ s("h2", { style:
|
|
3512
|
-
/* @__PURE__ */ s("p", { style:
|
|
3513
|
-
/* @__PURE__ */
|
|
3514
|
-
/* @__PURE__ */
|
|
3515
|
-
/* @__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 }),
|
|
3516
3527
|
/* @__PURE__ */ s(
|
|
3517
3528
|
"input",
|
|
3518
3529
|
{
|
|
3519
3530
|
type: "text",
|
|
3520
|
-
value:
|
|
3521
|
-
onChange: (
|
|
3522
|
-
|
|
3531
|
+
value: m,
|
|
3532
|
+
onChange: (q) => {
|
|
3533
|
+
h(q.target.value), N.token && R((W) => ({ ...W, token: !1 }));
|
|
3523
3534
|
},
|
|
3524
|
-
placeholder:
|
|
3525
|
-
style:
|
|
3535
|
+
placeholder: $.tokenPlaceholder,
|
|
3536
|
+
style: k("token"),
|
|
3526
3537
|
disabled: P
|
|
3527
3538
|
}
|
|
3528
3539
|
)
|
|
3529
3540
|
] }),
|
|
3530
|
-
/* @__PURE__ */
|
|
3531
|
-
/* @__PURE__ */ s("label", { style:
|
|
3541
|
+
/* @__PURE__ */ c("div", { style: g.fieldGroup, children: [
|
|
3542
|
+
/* @__PURE__ */ s("label", { style: g.label, children: $.newPasswordLabel }),
|
|
3532
3543
|
/* @__PURE__ */ s(
|
|
3533
3544
|
"input",
|
|
3534
3545
|
{
|
|
3535
3546
|
type: "password",
|
|
3536
|
-
value:
|
|
3537
|
-
onChange: (
|
|
3538
|
-
I(
|
|
3547
|
+
value: v,
|
|
3548
|
+
onChange: (q) => {
|
|
3549
|
+
I(q.target.value), N.newPassword && R((W) => ({ ...W, newPassword: !1 }));
|
|
3539
3550
|
},
|
|
3540
|
-
placeholder:
|
|
3541
|
-
style:
|
|
3551
|
+
placeholder: $.newPasswordPlaceholder,
|
|
3552
|
+
style: k("newPassword"),
|
|
3542
3553
|
disabled: P
|
|
3543
3554
|
}
|
|
3544
3555
|
)
|
|
3545
3556
|
] }),
|
|
3546
|
-
/* @__PURE__ */
|
|
3547
|
-
/* @__PURE__ */ s("label", { style:
|
|
3557
|
+
/* @__PURE__ */ c("div", { style: g.fieldGroup, children: [
|
|
3558
|
+
/* @__PURE__ */ s("label", { style: g.label, children: $.confirmPasswordLabel }),
|
|
3548
3559
|
/* @__PURE__ */ s(
|
|
3549
3560
|
"input",
|
|
3550
3561
|
{
|
|
3551
3562
|
type: "password",
|
|
3552
|
-
value:
|
|
3553
|
-
onChange: (
|
|
3554
|
-
M(
|
|
3563
|
+
value: F,
|
|
3564
|
+
onChange: (q) => {
|
|
3565
|
+
M(q.target.value), N.confirmPassword && R((W) => ({ ...W, confirmPassword: !1 })), A === $.passwordMismatchError && b("");
|
|
3555
3566
|
},
|
|
3556
|
-
placeholder:
|
|
3557
|
-
style:
|
|
3567
|
+
placeholder: $.confirmPasswordPlaceholder,
|
|
3568
|
+
style: k("confirmPassword"),
|
|
3558
3569
|
disabled: P
|
|
3559
3570
|
}
|
|
3560
3571
|
)
|
|
@@ -3563,43 +3574,43 @@ function zn({
|
|
|
3563
3574
|
"button",
|
|
3564
3575
|
{
|
|
3565
3576
|
type: "submit",
|
|
3566
|
-
disabled: !
|
|
3577
|
+
disabled: !O || P,
|
|
3567
3578
|
style: {
|
|
3568
|
-
...
|
|
3569
|
-
...!
|
|
3579
|
+
...j(),
|
|
3580
|
+
...!O || P ? g.buttonDisabled : {}
|
|
3570
3581
|
},
|
|
3571
|
-
children: P ?
|
|
3582
|
+
children: P ? $.resetLoadingText : $.resetSubmitButton
|
|
3572
3583
|
}
|
|
3573
3584
|
),
|
|
3574
|
-
|
|
3575
|
-
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 })
|
|
3576
3587
|
] }),
|
|
3577
|
-
/* @__PURE__ */
|
|
3578
|
-
/* @__PURE__ */ s("a", { onClick: a, style:
|
|
3579
|
-
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: [
|
|
3580
3591
|
/* @__PURE__ */ s("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3581
|
-
/* @__PURE__ */ s("a", { onClick: () => p("request"), style:
|
|
3592
|
+
/* @__PURE__ */ s("a", { onClick: () => p("request"), style: g.link, children: "Request New Link" })
|
|
3582
3593
|
] })
|
|
3583
3594
|
] })
|
|
3584
3595
|
] });
|
|
3585
3596
|
}
|
|
3586
|
-
const
|
|
3587
|
-
return /* @__PURE__ */
|
|
3588
|
-
/* @__PURE__ */ s("h2", { style:
|
|
3589
|
-
/* @__PURE__ */ s("p", { style:
|
|
3590
|
-
/* @__PURE__ */
|
|
3591
|
-
/* @__PURE__ */
|
|
3592
|
-
/* @__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 }),
|
|
3593
3604
|
/* @__PURE__ */ s(
|
|
3594
3605
|
"input",
|
|
3595
3606
|
{
|
|
3596
3607
|
type: "email",
|
|
3597
3608
|
value: w,
|
|
3598
|
-
onChange: (
|
|
3599
|
-
|
|
3609
|
+
onChange: (O) => {
|
|
3610
|
+
d(O.target.value), N.email && R((q) => ({ ...q, email: !1 }));
|
|
3600
3611
|
},
|
|
3601
|
-
placeholder:
|
|
3602
|
-
style:
|
|
3612
|
+
placeholder: $.emailPlaceholder,
|
|
3613
|
+
style: k("email"),
|
|
3603
3614
|
disabled: P
|
|
3604
3615
|
}
|
|
3605
3616
|
)
|
|
@@ -3608,27 +3619,27 @@ function zn({
|
|
|
3608
3619
|
"button",
|
|
3609
3620
|
{
|
|
3610
3621
|
type: "submit",
|
|
3611
|
-
disabled: !
|
|
3622
|
+
disabled: !Z || P,
|
|
3612
3623
|
style: {
|
|
3613
|
-
...
|
|
3614
|
-
...!
|
|
3624
|
+
...j(),
|
|
3625
|
+
...!Z || P ? g.buttonDisabled : {}
|
|
3615
3626
|
},
|
|
3616
|
-
children: P ?
|
|
3627
|
+
children: P ? $.loadingText : $.submitButton
|
|
3617
3628
|
}
|
|
3618
3629
|
),
|
|
3619
|
-
|
|
3620
|
-
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 })
|
|
3621
3632
|
] }),
|
|
3622
|
-
/* @__PURE__ */
|
|
3623
|
-
/* @__PURE__ */ s("a", { onClick: a, style:
|
|
3624
|
-
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: [
|
|
3625
3636
|
/* @__PURE__ */ s("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3626
|
-
/* @__PURE__ */ s("a", { onClick: () => p("reset"), style:
|
|
3637
|
+
/* @__PURE__ */ s("a", { onClick: () => p("reset"), style: g.link, children: "I have a token" })
|
|
3627
3638
|
] })
|
|
3628
3639
|
] })
|
|
3629
3640
|
] });
|
|
3630
3641
|
}
|
|
3631
|
-
const
|
|
3642
|
+
const rn = () => /* @__PURE__ */ s(
|
|
3632
3643
|
"div",
|
|
3633
3644
|
{
|
|
3634
3645
|
style: {
|
|
@@ -3640,7 +3651,7 @@ const tn = () => /* @__PURE__ */ s(
|
|
|
3640
3651
|
},
|
|
3641
3652
|
children: /* @__PURE__ */ s("div", { children: "Loading..." })
|
|
3642
3653
|
}
|
|
3643
|
-
),
|
|
3654
|
+
), sn = ({ error: r, retry: e }) => /* @__PURE__ */ c(
|
|
3644
3655
|
"div",
|
|
3645
3656
|
{
|
|
3646
3657
|
style: {
|
|
@@ -3674,43 +3685,43 @@ const tn = () => /* @__PURE__ */ s(
|
|
|
3674
3685
|
]
|
|
3675
3686
|
}
|
|
3676
3687
|
);
|
|
3677
|
-
function
|
|
3688
|
+
function Vn({
|
|
3678
3689
|
children: r,
|
|
3679
3690
|
loadingFallback: e,
|
|
3680
3691
|
errorFallback: t,
|
|
3681
3692
|
requireTenant: n = !0
|
|
3682
3693
|
}) {
|
|
3683
|
-
const { isAppLoading: i, appError: o, retryApp: a } =
|
|
3684
|
-
}),
|
|
3685
|
-
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();
|
|
3686
3697
|
};
|
|
3687
3698
|
if (E)
|
|
3688
|
-
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(
|
|
3689
|
-
if (
|
|
3690
|
-
const
|
|
3691
|
-
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 });
|
|
3692
3703
|
}
|
|
3693
3704
|
return /* @__PURE__ */ s(_, { children: r });
|
|
3694
3705
|
}
|
|
3695
|
-
function
|
|
3696
|
-
const { isAppLoading: e, appError: t, retryApp: n, appInfo: i } =
|
|
3697
|
-
}), 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);
|
|
3698
3709
|
return {
|
|
3699
3710
|
isLoading: L,
|
|
3700
3711
|
error: E,
|
|
3701
|
-
isReady: !L && !E && i !== null && (!P ||
|
|
3712
|
+
isReady: !L && !E && i !== null && (!P || m !== null),
|
|
3702
3713
|
retry: () => {
|
|
3703
|
-
t && n(),
|
|
3714
|
+
t && n(), d && o && v();
|
|
3704
3715
|
},
|
|
3705
3716
|
// Individual states
|
|
3706
3717
|
app: { isLoading: e, error: t, data: i },
|
|
3707
|
-
tenant: o ? { isLoading: w, error:
|
|
3718
|
+
tenant: o ? { isLoading: w, error: d, data: m } : null,
|
|
3708
3719
|
auth: a ? { isReady: I } : null,
|
|
3709
|
-
featureFlags: p ? { isReady:
|
|
3720
|
+
featureFlags: p ? { isReady: F } : null,
|
|
3710
3721
|
subscription: f ? { isReady: M } : null
|
|
3711
3722
|
};
|
|
3712
3723
|
}
|
|
3713
|
-
function
|
|
3724
|
+
function Gn({
|
|
3714
3725
|
tenants: r,
|
|
3715
3726
|
currentTenantId: e,
|
|
3716
3727
|
onSelect: t,
|
|
@@ -3722,35 +3733,35 @@ function Vn({
|
|
|
3722
3733
|
disabled: f = !1,
|
|
3723
3734
|
showCurrentTenant: w = !0
|
|
3724
3735
|
}) {
|
|
3725
|
-
var
|
|
3726
|
-
const
|
|
3727
|
-
|
|
3736
|
+
var A;
|
|
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);
|
|
3728
3739
|
};
|
|
3729
|
-
|
|
3730
|
-
const
|
|
3731
|
-
|
|
3740
|
+
ee(() => {
|
|
3741
|
+
const b = (L) => {
|
|
3742
|
+
v.current && !v.current.contains(L.target) && h(!1);
|
|
3732
3743
|
};
|
|
3733
|
-
return document.addEventListener("mousedown",
|
|
3744
|
+
return document.addEventListener("mousedown", b), () => document.removeEventListener("mousedown", b);
|
|
3734
3745
|
}, []);
|
|
3735
|
-
const P = I.find((
|
|
3746
|
+
const P = I.find((b) => b.id === F);
|
|
3736
3747
|
if (I.length === 0)
|
|
3737
3748
|
return null;
|
|
3738
3749
|
if (I.length === 1 && w)
|
|
3739
3750
|
return /* @__PURE__ */ s("div", { className: n, children: /* @__PURE__ */ s("span", { children: I[0].name }) });
|
|
3740
|
-
const
|
|
3741
|
-
|
|
3742
|
-
|
|
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: [
|
|
3743
3754
|
"(",
|
|
3744
|
-
|
|
3755
|
+
b.role,
|
|
3745
3756
|
")"
|
|
3746
3757
|
] })
|
|
3747
3758
|
] });
|
|
3748
|
-
return /* @__PURE__ */
|
|
3749
|
-
/* @__PURE__ */
|
|
3759
|
+
return /* @__PURE__ */ c("div", { ref: v, className: n, style: { position: "relative" }, children: [
|
|
3760
|
+
/* @__PURE__ */ c(
|
|
3750
3761
|
"button",
|
|
3751
3762
|
{
|
|
3752
3763
|
type: "button",
|
|
3753
|
-
onClick: () => !f &&
|
|
3764
|
+
onClick: () => !f && h(!m),
|
|
3754
3765
|
disabled: f,
|
|
3755
3766
|
style: {
|
|
3756
3767
|
cursor: f ? "not-allowed" : "pointer",
|
|
@@ -3758,11 +3769,11 @@ function Vn({
|
|
|
3758
3769
|
},
|
|
3759
3770
|
children: [
|
|
3760
3771
|
P ? P.name : p,
|
|
3761
|
-
/* @__PURE__ */ s("span", { style: { marginLeft: 8 }, children:
|
|
3772
|
+
/* @__PURE__ */ s("span", { style: { marginLeft: 8 }, children: m ? "▲" : "▼" })
|
|
3762
3773
|
]
|
|
3763
3774
|
}
|
|
3764
3775
|
),
|
|
3765
|
-
|
|
3776
|
+
m && /* @__PURE__ */ s(
|
|
3766
3777
|
"div",
|
|
3767
3778
|
{
|
|
3768
3779
|
className: i,
|
|
@@ -3779,13 +3790,13 @@ function Vn({
|
|
|
3779
3790
|
maxHeight: 300,
|
|
3780
3791
|
overflowY: "auto"
|
|
3781
3792
|
},
|
|
3782
|
-
children: I.map((
|
|
3783
|
-
const L =
|
|
3793
|
+
children: I.map((b) => {
|
|
3794
|
+
const L = b.id === F;
|
|
3784
3795
|
return /* @__PURE__ */ s(
|
|
3785
3796
|
"div",
|
|
3786
3797
|
{
|
|
3787
3798
|
className: o,
|
|
3788
|
-
onClick: () => M(
|
|
3799
|
+
onClick: () => M(b.id),
|
|
3789
3800
|
style: {
|
|
3790
3801
|
padding: "8px 12px",
|
|
3791
3802
|
cursor: "pointer",
|
|
@@ -3797,16 +3808,16 @@ function Vn({
|
|
|
3797
3808
|
onMouseLeave: (E) => {
|
|
3798
3809
|
L || (E.target.style.backgroundColor = "transparent");
|
|
3799
3810
|
},
|
|
3800
|
-
children: a ? a(
|
|
3811
|
+
children: a ? a(b, L) : u(b, L)
|
|
3801
3812
|
},
|
|
3802
|
-
|
|
3813
|
+
b.id
|
|
3803
3814
|
);
|
|
3804
3815
|
})
|
|
3805
3816
|
}
|
|
3806
3817
|
)
|
|
3807
3818
|
] });
|
|
3808
3819
|
}
|
|
3809
|
-
class
|
|
3820
|
+
class Zn {
|
|
3810
3821
|
constructor(e, t) {
|
|
3811
3822
|
this.httpService = e, this.sessionManager = t;
|
|
3812
3823
|
}
|
|
@@ -3874,7 +3885,7 @@ class jn {
|
|
|
3874
3885
|
};
|
|
3875
3886
|
}
|
|
3876
3887
|
}
|
|
3877
|
-
class
|
|
3888
|
+
class Kn {
|
|
3878
3889
|
constructor(e, t) {
|
|
3879
3890
|
this.httpService = e, this.sessionManager = t;
|
|
3880
3891
|
}
|
|
@@ -3925,7 +3936,7 @@ class Gn {
|
|
|
3925
3936
|
});
|
|
3926
3937
|
}
|
|
3927
3938
|
}
|
|
3928
|
-
class
|
|
3939
|
+
class Jn {
|
|
3929
3940
|
constructor(e) {
|
|
3930
3941
|
this.httpService = e;
|
|
3931
3942
|
}
|
|
@@ -3934,7 +3945,7 @@ class Zn {
|
|
|
3934
3945
|
return await this.httpService.get("/health");
|
|
3935
3946
|
}
|
|
3936
3947
|
}
|
|
3937
|
-
class
|
|
3948
|
+
class Yn {
|
|
3938
3949
|
// Date string to Date object
|
|
3939
3950
|
static toDate(e) {
|
|
3940
3951
|
return new Date(e);
|
|
@@ -4056,136 +4067,136 @@ class Kn {
|
|
|
4056
4067
|
}), t;
|
|
4057
4068
|
}
|
|
4058
4069
|
}
|
|
4059
|
-
const
|
|
4060
|
-
function
|
|
4070
|
+
const Xe = "returnTo", Ie = "zone_return_to", Me = "zone_return_to";
|
|
4071
|
+
function Qn(r = {}) {
|
|
4061
4072
|
const {
|
|
4062
4073
|
zoneRoots: e = {},
|
|
4063
|
-
returnToParam: t =
|
|
4074
|
+
returnToParam: t = Xe,
|
|
4064
4075
|
returnToStorage: n = "url"
|
|
4065
|
-
} = 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(() => {
|
|
4066
4077
|
switch (n) {
|
|
4067
4078
|
case "url":
|
|
4068
4079
|
return o.get(t);
|
|
4069
4080
|
case "session":
|
|
4070
|
-
return sessionStorage.getItem(
|
|
4081
|
+
return sessionStorage.getItem(Ie);
|
|
4071
4082
|
case "local":
|
|
4072
|
-
return localStorage.getItem(
|
|
4083
|
+
return localStorage.getItem(Me);
|
|
4073
4084
|
default:
|
|
4074
4085
|
return null;
|
|
4075
4086
|
}
|
|
4076
|
-
}, [n, o, t]), I =
|
|
4087
|
+
}, [n, o, t]), I = se(() => {
|
|
4077
4088
|
switch (n) {
|
|
4078
4089
|
case "url": {
|
|
4079
|
-
const
|
|
4080
|
-
|
|
4090
|
+
const u = new URLSearchParams(o);
|
|
4091
|
+
u.delete(t), a(u, { replace: !0 });
|
|
4081
4092
|
break;
|
|
4082
4093
|
}
|
|
4083
4094
|
case "session":
|
|
4084
|
-
sessionStorage.removeItem(
|
|
4095
|
+
sessionStorage.removeItem(Ie);
|
|
4085
4096
|
break;
|
|
4086
4097
|
case "local":
|
|
4087
|
-
localStorage.removeItem(
|
|
4098
|
+
localStorage.removeItem(Me);
|
|
4088
4099
|
break;
|
|
4089
4100
|
}
|
|
4090
|
-
}, [n, o, t, a]),
|
|
4091
|
-
(
|
|
4101
|
+
}, [n, o, t, a]), F = se(
|
|
4102
|
+
(u) => {
|
|
4092
4103
|
switch (n) {
|
|
4093
4104
|
case "url": {
|
|
4094
|
-
const
|
|
4095
|
-
|
|
4105
|
+
const A = new URLSearchParams(o);
|
|
4106
|
+
A.set(t, u), a(A, { replace: !0 });
|
|
4096
4107
|
break;
|
|
4097
4108
|
}
|
|
4098
4109
|
case "session":
|
|
4099
|
-
sessionStorage.setItem(
|
|
4110
|
+
sessionStorage.setItem(Ie, u);
|
|
4100
4111
|
break;
|
|
4101
4112
|
case "local":
|
|
4102
|
-
localStorage.setItem(
|
|
4113
|
+
localStorage.setItem(Me, u);
|
|
4103
4114
|
break;
|
|
4104
4115
|
}
|
|
4105
4116
|
},
|
|
4106
4117
|
[n, o, t, a]
|
|
4107
|
-
), M =
|
|
4108
|
-
(
|
|
4109
|
-
const
|
|
4110
|
-
i(
|
|
4118
|
+
), M = se(
|
|
4119
|
+
(u) => {
|
|
4120
|
+
const A = d[u] || d.default;
|
|
4121
|
+
i(A);
|
|
4111
4122
|
},
|
|
4112
|
-
[i,
|
|
4113
|
-
), 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]);
|
|
4114
4125
|
return {
|
|
4115
|
-
returnToUrl:
|
|
4126
|
+
returnToUrl: v,
|
|
4116
4127
|
clearReturnTo: I,
|
|
4117
|
-
setReturnTo:
|
|
4128
|
+
setReturnTo: F,
|
|
4118
4129
|
navigateToZone: M,
|
|
4119
4130
|
getSmartRedirect: P
|
|
4120
4131
|
};
|
|
4121
4132
|
}
|
|
4122
|
-
function
|
|
4133
|
+
function Xn(r, e, t = Xe, n = "url") {
|
|
4123
4134
|
if (!e || n !== "url")
|
|
4124
4135
|
return r;
|
|
4125
4136
|
const i = new URL(r, window.location.origin);
|
|
4126
4137
|
return i.searchParams.set(t, e), i.pathname + i.search;
|
|
4127
4138
|
}
|
|
4128
4139
|
export {
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
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
|
-
|
|
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,
|
|
4185
4196
|
he as useTenant,
|
|
4186
4197
|
ge as useTenantInfo,
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4198
|
+
ve as useTenantOptional,
|
|
4199
|
+
yn as useTenantSettings,
|
|
4200
|
+
Qn as useZoneNavigation
|
|
4190
4201
|
};
|
|
4191
4202
|
//# sourceMappingURL=index.es.js.map
|