@skylabs-digital/react-identity-access 2.24.0 → 2.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +560 -150
- package/dist/components/LoginForm.d.ts +5 -0
- package/dist/components/LoginForm.d.ts.map +1 -1
- package/dist/components/MagicLinkForm.d.ts +10 -0
- package/dist/components/MagicLinkForm.d.ts.map +1 -1
- package/dist/components/MagicLinkVerify.d.ts +3 -0
- package/dist/components/MagicLinkVerify.d.ts.map +1 -1
- package/dist/components/PasswordRecoveryForm.d.ts +5 -0
- package/dist/components/PasswordRecoveryForm.d.ts.map +1 -1
- package/dist/components/SignupForm.d.ts +4 -0
- package/dist/components/SignupForm.d.ts.map +1 -1
- package/dist/components/TenantSelector.d.ts +13 -1
- package/dist/components/TenantSelector.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +1212 -1161
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/providers/AppProvider.d.ts.map +1 -1
- package/dist/providers/AuthProvider.d.ts.map +1 -1
- package/dist/providers/TenantProvider.d.ts.map +1 -1
- package/dist/services/SessionManager.d.ts.map +1 -1
- package/dist/utils/crossDomainAuth.d.ts.map +1 -1
- package/package.json +9 -9
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as s, Fragment as _, jsxs as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { useLocation as ke, Navigate as
|
|
1
|
+
import { jsx as s, Fragment as _, jsxs as d } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as fe, useMemo as K, useState as k, useCallback as se, useEffect as re, useContext as ae, useRef as Me } from "react";
|
|
3
|
+
import { useLocation as ke, Navigate as ve, useNavigate as pt, useSearchParams as ft } from "react-router-dom";
|
|
4
4
|
class le {
|
|
5
5
|
constructor(e, t = 1e4) {
|
|
6
6
|
this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
|
|
@@ -13,28 +13,28 @@ class le {
|
|
|
13
13
|
}
|
|
14
14
|
async executeRequest(e, t, r, i) {
|
|
15
15
|
const o = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, a = (i == null ? void 0 : i.timeout) || this.timeout;
|
|
16
|
-
let
|
|
16
|
+
let p = {
|
|
17
17
|
"Content-Type": "application/json",
|
|
18
18
|
...i == null ? void 0 : i.headers
|
|
19
19
|
};
|
|
20
20
|
if (!(i != null && i.skipAuth) && this.sessionManager) {
|
|
21
|
-
const
|
|
22
|
-
|
|
21
|
+
const f = await this.sessionManager.getValidAccessToken();
|
|
22
|
+
p = { ...p, Authorization: `Bearer ${f}` };
|
|
23
23
|
}
|
|
24
|
-
const
|
|
24
|
+
const w = new AbortController(), y = setTimeout(() => w.abort(), a);
|
|
25
25
|
try {
|
|
26
|
-
const
|
|
26
|
+
const f = await fetch(o, {
|
|
27
27
|
method: e,
|
|
28
|
-
headers:
|
|
28
|
+
headers: p,
|
|
29
29
|
body: r ? JSON.stringify(r) : void 0,
|
|
30
|
-
signal:
|
|
30
|
+
signal: w.signal
|
|
31
31
|
});
|
|
32
|
-
if (clearTimeout(
|
|
33
|
-
throw new Error(`HTTP ${
|
|
34
|
-
const
|
|
35
|
-
return !
|
|
36
|
-
} catch (
|
|
37
|
-
throw clearTimeout(
|
|
32
|
+
if (clearTimeout(y), !f.ok)
|
|
33
|
+
throw new Error(`HTTP ${f.status}: ${f.statusText}`);
|
|
34
|
+
const x = f.headers.get("content-type");
|
|
35
|
+
return !x || !x.includes("application/json") ? {} : await f.json();
|
|
36
|
+
} catch (f) {
|
|
37
|
+
throw clearTimeout(y), f instanceof Error && f.name === "AbortError" ? new Error(`Request timeout after ${a}ms`) : f;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
async get(e, t) {
|
|
@@ -50,7 +50,7 @@ class le {
|
|
|
50
50
|
return this.executeRequest("DELETE", e, void 0, t);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
class
|
|
53
|
+
class qe {
|
|
54
54
|
constructor(e, t) {
|
|
55
55
|
this.httpService = e, this.sessionManager = t;
|
|
56
56
|
}
|
|
@@ -109,32 +109,32 @@ class Oe {
|
|
|
109
109
|
})).data;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
const Le =
|
|
113
|
-
function
|
|
112
|
+
const Le = fe(null);
|
|
113
|
+
function mr({ config: n, children: e }) {
|
|
114
114
|
const t = K(
|
|
115
115
|
() => {
|
|
116
|
-
var
|
|
116
|
+
var h, R, N;
|
|
117
117
|
return {
|
|
118
|
-
enabled: ((
|
|
118
|
+
enabled: ((h = n.cache) == null ? void 0 : h.enabled) ?? !0,
|
|
119
119
|
ttl: ((R = n.cache) == null ? void 0 : R.ttl) ?? 3e5,
|
|
120
120
|
// 5 minutes default
|
|
121
|
-
storageKey: ((
|
|
121
|
+
storageKey: ((N = n.cache) == null ? void 0 : N.storageKey) ?? `app_cache_${n.appId}`
|
|
122
122
|
};
|
|
123
123
|
},
|
|
124
124
|
[n.cache, n.appId]
|
|
125
125
|
), [r, i] = k(() => {
|
|
126
126
|
if (!t.enabled) return null;
|
|
127
127
|
try {
|
|
128
|
-
const
|
|
129
|
-
if (!
|
|
130
|
-
const R = JSON.parse(
|
|
128
|
+
const h = localStorage.getItem(t.storageKey);
|
|
129
|
+
if (!h) return null;
|
|
130
|
+
const R = JSON.parse(h);
|
|
131
131
|
return Date.now() - R.timestamp < t.ttl && R.appId === n.appId ? R.data : (localStorage.removeItem(t.storageKey), null);
|
|
132
132
|
} catch {
|
|
133
133
|
return null;
|
|
134
134
|
}
|
|
135
|
-
}), [o, a] = k(!r), [
|
|
136
|
-
const
|
|
137
|
-
|
|
135
|
+
}), [o, a] = k(!r), [p, w] = k(null), y = K(() => {
|
|
136
|
+
const h = () => {
|
|
137
|
+
f();
|
|
138
138
|
};
|
|
139
139
|
return {
|
|
140
140
|
appId: n.appId,
|
|
@@ -142,59 +142,59 @@ function gr({ config: n, children: e }) {
|
|
|
142
142
|
// App info
|
|
143
143
|
appInfo: r,
|
|
144
144
|
isAppLoading: o,
|
|
145
|
-
appError:
|
|
146
|
-
retryApp:
|
|
145
|
+
appError: p,
|
|
146
|
+
retryApp: h
|
|
147
147
|
};
|
|
148
|
-
}, [n, r, o,
|
|
149
|
-
async (
|
|
150
|
-
if (!(!
|
|
148
|
+
}, [n, r, o, p]), f = se(
|
|
149
|
+
async (h = !1) => {
|
|
150
|
+
if (!(!h && t.enabled && r))
|
|
151
151
|
try {
|
|
152
|
-
a(!0),
|
|
153
|
-
const R = new le(n.baseUrl),
|
|
154
|
-
if (i(
|
|
152
|
+
a(!0), w(null);
|
|
153
|
+
const R = new le(n.baseUrl), D = await new qe(R, {}).getPublicAppInfo(n.appId);
|
|
154
|
+
if (i(D), t.enabled)
|
|
155
155
|
try {
|
|
156
156
|
const E = {
|
|
157
|
-
data:
|
|
157
|
+
data: D,
|
|
158
158
|
timestamp: Date.now(),
|
|
159
159
|
appId: n.appId
|
|
160
160
|
};
|
|
161
161
|
localStorage.setItem(t.storageKey, JSON.stringify(E));
|
|
162
162
|
} catch (E) {
|
|
163
|
-
console.warn("Failed to cache app info:", E);
|
|
163
|
+
process.env.NODE_ENV === "development" && console.warn("[AppProvider] Failed to cache app info:", E);
|
|
164
164
|
}
|
|
165
165
|
} catch (R) {
|
|
166
|
-
const
|
|
167
|
-
|
|
166
|
+
const N = R instanceof Error ? R : new Error("Failed to load app information");
|
|
167
|
+
w(N), i(null);
|
|
168
168
|
} finally {
|
|
169
169
|
a(!1);
|
|
170
170
|
}
|
|
171
171
|
},
|
|
172
172
|
[n.baseUrl, n.appId, t, r]
|
|
173
|
-
),
|
|
173
|
+
), x = se(async () => {
|
|
174
174
|
if (!(!t.enabled || !r))
|
|
175
175
|
try {
|
|
176
|
-
const
|
|
177
|
-
if (!
|
|
178
|
-
const R = JSON.parse(
|
|
176
|
+
const h = localStorage.getItem(t.storageKey);
|
|
177
|
+
if (!h) return;
|
|
178
|
+
const R = JSON.parse(h);
|
|
179
179
|
if (Date.now() - R.timestamp > t.ttl * 0.5) {
|
|
180
|
-
const
|
|
181
|
-
i(
|
|
182
|
-
const
|
|
183
|
-
data:
|
|
180
|
+
const D = new le(n.baseUrl), P = await new qe(D, {}).getPublicAppInfo(n.appId);
|
|
181
|
+
i(P);
|
|
182
|
+
const u = {
|
|
183
|
+
data: P,
|
|
184
184
|
timestamp: Date.now(),
|
|
185
185
|
appId: n.appId
|
|
186
186
|
};
|
|
187
|
-
localStorage.setItem(t.storageKey, JSON.stringify(
|
|
187
|
+
localStorage.setItem(t.storageKey, JSON.stringify(u));
|
|
188
188
|
}
|
|
189
|
-
} catch (
|
|
190
|
-
console.warn("Background app refresh failed:",
|
|
189
|
+
} catch (h) {
|
|
190
|
+
process.env.NODE_ENV === "development" && console.warn("[AppProvider] Background app refresh failed:", h);
|
|
191
191
|
}
|
|
192
192
|
}, [n, t, r]);
|
|
193
193
|
return re(() => {
|
|
194
|
-
r ?
|
|
195
|
-
}, []), /* @__PURE__ */ s(Le.Provider, { value:
|
|
194
|
+
r ? x() : f();
|
|
195
|
+
}, []), /* @__PURE__ */ s(Le.Provider, { value: y, children: e });
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function Se() {
|
|
198
198
|
const n = ae(Le);
|
|
199
199
|
if (!n)
|
|
200
200
|
throw new Error("useApp must be used within an AppProvider");
|
|
@@ -203,7 +203,7 @@ function ve() {
|
|
|
203
203
|
function Qe() {
|
|
204
204
|
return ae(Le);
|
|
205
205
|
}
|
|
206
|
-
const
|
|
206
|
+
const yr = Se;
|
|
207
207
|
class ne extends Error {
|
|
208
208
|
constructor(e, t) {
|
|
209
209
|
const r = {
|
|
@@ -354,7 +354,7 @@ const ie = class ie {
|
|
|
354
354
|
const t = this.sessionGeneration;
|
|
355
355
|
this.startRefreshAndResolveQueue(e.refreshToken).then(() => {
|
|
356
356
|
}).catch((r) => {
|
|
357
|
-
r instanceof ne || this.sessionGeneration === t && (console.warn(
|
|
357
|
+
r instanceof ne || this.sessionGeneration === t && (process.env.NODE_ENV === "development" && console.warn(
|
|
358
358
|
"[SessionManager] Background refresh failed, retrying in 30s:",
|
|
359
359
|
r.message
|
|
360
360
|
), this.backgroundRetryTimerId = setTimeout(() => {
|
|
@@ -456,8 +456,8 @@ const ie = class ie {
|
|
|
456
456
|
if (a instanceof ne)
|
|
457
457
|
throw a;
|
|
458
458
|
if (t = a, i < this.maxRefreshRetries) {
|
|
459
|
-
const
|
|
460
|
-
await this.sleep(
|
|
459
|
+
const p = this.retryBackoffBase * Math.pow(2, i);
|
|
460
|
+
await this.sleep(p);
|
|
461
461
|
}
|
|
462
462
|
}
|
|
463
463
|
}
|
|
@@ -485,8 +485,8 @@ const ie = class ie {
|
|
|
485
485
|
if (!i.ok) {
|
|
486
486
|
let a = "";
|
|
487
487
|
try {
|
|
488
|
-
const
|
|
489
|
-
a = (
|
|
488
|
+
const p = await i.json();
|
|
489
|
+
a = (p.message || p.error || "").toLowerCase();
|
|
490
490
|
} catch {
|
|
491
491
|
a = i.statusText.toLowerCase();
|
|
492
492
|
}
|
|
@@ -836,13 +836,13 @@ function bt(n, e) {
|
|
|
836
836
|
const r = n.split(".");
|
|
837
837
|
return r.length >= 3 && r[0] !== "www" ? r[0] : null;
|
|
838
838
|
}
|
|
839
|
-
function
|
|
839
|
+
function vt(n, e = "tenant", t) {
|
|
840
840
|
const i = new URLSearchParams(n).get(e);
|
|
841
841
|
return i ? (t && t.setItem("tenant", i), i) : t ? t.getItem("tenant") : null;
|
|
842
842
|
}
|
|
843
|
-
function
|
|
843
|
+
function St(n, e, t) {
|
|
844
844
|
const { tenantMode: r, baseDomain: i, selectorParam: o, fixedTenantSlug: a } = n;
|
|
845
|
-
return r === "fixed" ? a || null : r === "subdomain" ? bt(e.hostname, i) : r === "selector" ?
|
|
845
|
+
return r === "fixed" ? a || null : r === "subdomain" ? bt(e.hostname, i) : r === "selector" ? vt(e.search, o, t) : null;
|
|
846
846
|
}
|
|
847
847
|
function Tt(n, e, t) {
|
|
848
848
|
if (t)
|
|
@@ -850,7 +850,7 @@ function Tt(n, e, t) {
|
|
|
850
850
|
const r = e.split(".");
|
|
851
851
|
return r.length === 2 ? `${n}.${e}` : r.length >= 3 ? (r[0] = n, r.join(".")) : null;
|
|
852
852
|
}
|
|
853
|
-
const
|
|
853
|
+
const pe = "_auth";
|
|
854
854
|
function _e(n) {
|
|
855
855
|
const e = JSON.stringify(n);
|
|
856
856
|
return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
@@ -868,32 +868,18 @@ function kt(n) {
|
|
|
868
868
|
}
|
|
869
869
|
function xt() {
|
|
870
870
|
if (typeof window > "u")
|
|
871
|
-
return
|
|
872
|
-
const e = new URLSearchParams(window.location.search).get(
|
|
873
|
-
|
|
874
|
-
hasAuthParam: !!e,
|
|
875
|
-
searchParams: window.location.search,
|
|
876
|
-
encodedLength: e == null ? void 0 : e.length
|
|
877
|
-
}), !e) return null;
|
|
878
|
-
const t = kt(e);
|
|
879
|
-
return console.log("[CrossDomainAuth] Token decode result:", {
|
|
880
|
-
success: !!t,
|
|
881
|
-
hasAccessToken: !!(t != null && t.accessToken),
|
|
882
|
-
hasRefreshToken: !!(t != null && t.refreshToken),
|
|
883
|
-
expiresIn: t == null ? void 0 : t.expiresIn
|
|
884
|
-
}), t;
|
|
871
|
+
return null;
|
|
872
|
+
const e = new URLSearchParams(window.location.search).get(pe);
|
|
873
|
+
return e ? kt(e) : null;
|
|
885
874
|
}
|
|
886
875
|
function At() {
|
|
887
876
|
if (typeof window > "u") return;
|
|
888
877
|
const n = new URL(window.location.href);
|
|
889
|
-
n.searchParams.delete(
|
|
890
|
-
oldUrl: window.location.href,
|
|
891
|
-
newUrl: n.toString()
|
|
892
|
-
}), window.history.replaceState({}, "", n.toString());
|
|
878
|
+
n.searchParams.delete(pe), window.history.replaceState({}, "", n.toString());
|
|
893
879
|
}
|
|
894
|
-
const
|
|
895
|
-
function
|
|
896
|
-
const { baseUrl: t, appInfo: r, appId: i } =
|
|
880
|
+
const Ne = fe(null);
|
|
881
|
+
function wr({ config: n, children: e }) {
|
|
882
|
+
const { baseUrl: t, appInfo: r, appId: i } = Se(), o = se(() => typeof window > "u" ? null : St(
|
|
897
883
|
{
|
|
898
884
|
tenantMode: n.tenantMode || "selector",
|
|
899
885
|
baseDomain: n.baseDomain,
|
|
@@ -905,119 +891,119 @@ function yr({ config: n, children: e }) {
|
|
|
905
891
|
search: window.location.search
|
|
906
892
|
},
|
|
907
893
|
window.localStorage
|
|
908
|
-
), [n.tenantMode, n.baseDomain, n.selectorParam, n.fixedTenantSlug]), [a,
|
|
894
|
+
), [n.tenantMode, n.baseDomain, n.selectorParam, n.fixedTenantSlug]), [a, p] = k(() => o()), w = K(
|
|
909
895
|
() => {
|
|
910
|
-
var
|
|
896
|
+
var c, H, I;
|
|
911
897
|
return {
|
|
912
|
-
enabled: ((
|
|
913
|
-
ttl: ((
|
|
898
|
+
enabled: ((c = n.cache) == null ? void 0 : c.enabled) ?? !0,
|
|
899
|
+
ttl: ((H = n.cache) == null ? void 0 : H.ttl) ?? 5 * 60 * 1e3,
|
|
914
900
|
// 5 minutes default
|
|
915
|
-
storageKey: ((
|
|
901
|
+
storageKey: ((I = n.cache) == null ? void 0 : I.storageKey) ?? `tenant_cache_${a || "default"}`
|
|
916
902
|
};
|
|
917
903
|
},
|
|
918
904
|
[n.cache, a]
|
|
919
|
-
), [
|
|
905
|
+
), [y, f] = k(() => {
|
|
920
906
|
if (n.initialTenant) return n.initialTenant;
|
|
921
|
-
if (!
|
|
907
|
+
if (!w.enabled || !a) return null;
|
|
922
908
|
try {
|
|
923
|
-
const
|
|
924
|
-
if (!
|
|
925
|
-
const
|
|
926
|
-
return Date.now() -
|
|
909
|
+
const c = localStorage.getItem(w.storageKey);
|
|
910
|
+
if (!c) return null;
|
|
911
|
+
const H = JSON.parse(c);
|
|
912
|
+
return Date.now() - H.timestamp < w.ttl && H.tenantSlug === a ? H.data : (localStorage.removeItem(w.storageKey), null);
|
|
927
913
|
} catch {
|
|
928
914
|
return null;
|
|
929
915
|
}
|
|
930
|
-
}), [
|
|
916
|
+
}), [x, h] = k(!y && !n.initialTenant), [R, N] = k(null), [D, E] = k(null), [P, u] = k(!1), [S, C] = k(null);
|
|
931
917
|
re(() => {
|
|
932
918
|
if (n.tenantMode === "fixed") return;
|
|
933
|
-
const
|
|
934
|
-
|
|
919
|
+
const c = o();
|
|
920
|
+
p(c);
|
|
935
921
|
}, [o, n.tenantMode]);
|
|
936
|
-
const
|
|
937
|
-
async (
|
|
938
|
-
if (!(!
|
|
922
|
+
const M = (r == null ? void 0 : r.settingsSchema) || null, T = se(
|
|
923
|
+
async (c, H = !1) => {
|
|
924
|
+
if (!(!H && w.enabled && y && y.domain === c))
|
|
939
925
|
try {
|
|
940
|
-
|
|
941
|
-
const
|
|
942
|
-
if (
|
|
926
|
+
h(!0), N(null);
|
|
927
|
+
const I = new le(t), m = await new be(I, i).getPublicTenantInfo(c);
|
|
928
|
+
if (f(m), w.enabled)
|
|
943
929
|
try {
|
|
944
|
-
const
|
|
945
|
-
data:
|
|
930
|
+
const v = {
|
|
931
|
+
data: m,
|
|
946
932
|
timestamp: Date.now(),
|
|
947
|
-
tenantSlug:
|
|
933
|
+
tenantSlug: c
|
|
948
934
|
};
|
|
949
|
-
localStorage.setItem(
|
|
950
|
-
} catch (
|
|
951
|
-
console.warn("Failed to cache tenant info:",
|
|
935
|
+
localStorage.setItem(w.storageKey, JSON.stringify(v));
|
|
936
|
+
} catch (v) {
|
|
937
|
+
process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Failed to cache tenant info:", v);
|
|
952
938
|
}
|
|
953
|
-
} catch (
|
|
954
|
-
const
|
|
955
|
-
|
|
939
|
+
} catch (I) {
|
|
940
|
+
const g = I instanceof Error ? I : new Error("Failed to load tenant information");
|
|
941
|
+
N(g), f(null);
|
|
956
942
|
} finally {
|
|
957
|
-
|
|
943
|
+
h(!1);
|
|
958
944
|
}
|
|
959
945
|
},
|
|
960
|
-
[t, i,
|
|
961
|
-
),
|
|
962
|
-
if (!(!
|
|
946
|
+
[t, i, w, y]
|
|
947
|
+
), $ = se(async () => {
|
|
948
|
+
if (!(!w.enabled || !y || !a))
|
|
963
949
|
try {
|
|
964
|
-
const
|
|
965
|
-
if (!
|
|
966
|
-
const
|
|
967
|
-
if (Date.now() -
|
|
968
|
-
const
|
|
969
|
-
|
|
950
|
+
const c = localStorage.getItem(w.storageKey);
|
|
951
|
+
if (!c) return;
|
|
952
|
+
const H = JSON.parse(c);
|
|
953
|
+
if (Date.now() - H.timestamp > w.ttl * 0.5) {
|
|
954
|
+
const g = new le(t), v = await new be(g, i).getPublicTenantInfo(a);
|
|
955
|
+
f(v);
|
|
970
956
|
const Q = {
|
|
971
|
-
data:
|
|
957
|
+
data: v,
|
|
972
958
|
timestamp: Date.now(),
|
|
973
959
|
tenantSlug: a
|
|
974
960
|
};
|
|
975
|
-
localStorage.setItem(
|
|
961
|
+
localStorage.setItem(w.storageKey, JSON.stringify(Q));
|
|
976
962
|
}
|
|
977
|
-
} catch (
|
|
978
|
-
console.warn("Background tenant refresh failed:",
|
|
963
|
+
} catch (c) {
|
|
964
|
+
process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Background tenant refresh failed:", c);
|
|
979
965
|
}
|
|
980
|
-
}, [t, i,
|
|
981
|
-
if (
|
|
966
|
+
}, [t, i, w, y, a]), l = se(async () => {
|
|
967
|
+
if (y != null && y.id)
|
|
982
968
|
try {
|
|
983
|
-
|
|
984
|
-
const
|
|
985
|
-
E(
|
|
986
|
-
} catch (
|
|
987
|
-
const
|
|
988
|
-
|
|
969
|
+
u(!0), C(null);
|
|
970
|
+
const c = new le(t), I = await new be(c, y.appId).getTenantSettings(y.id);
|
|
971
|
+
E(I);
|
|
972
|
+
} catch (c) {
|
|
973
|
+
const H = c instanceof Error ? c : new Error("Failed to load tenant settings");
|
|
974
|
+
C(H), E(null);
|
|
989
975
|
} finally {
|
|
990
|
-
|
|
976
|
+
u(!1);
|
|
991
977
|
}
|
|
992
|
-
}, [t,
|
|
978
|
+
}, [t, y]), U = se(() => {
|
|
993
979
|
l();
|
|
994
|
-
}, [l]),
|
|
995
|
-
(
|
|
996
|
-
if (!
|
|
980
|
+
}, [l]), b = se(
|
|
981
|
+
(c) => {
|
|
982
|
+
if (!M)
|
|
997
983
|
return { isValid: !0, errors: [] };
|
|
998
|
-
const
|
|
984
|
+
const H = [];
|
|
999
985
|
try {
|
|
1000
|
-
return
|
|
1001
|
-
var
|
|
1002
|
-
const
|
|
1003
|
-
if ((
|
|
1004
|
-
|
|
986
|
+
return M.properties && Object.entries(M.properties).forEach(([I, g]) => {
|
|
987
|
+
var v;
|
|
988
|
+
const m = c[I];
|
|
989
|
+
if ((v = M.required) != null && v.includes(I) && m == null) {
|
|
990
|
+
H.push(`Field '${I}' is required`);
|
|
1005
991
|
return;
|
|
1006
992
|
}
|
|
1007
|
-
if (
|
|
1008
|
-
if (
|
|
1009
|
-
const Q =
|
|
1010
|
-
Q === "string" && J !== "string" ?
|
|
993
|
+
if (m != null) {
|
|
994
|
+
if (g.type) {
|
|
995
|
+
const Q = g.type, J = typeof m;
|
|
996
|
+
Q === "string" && J !== "string" ? H.push(`Field '${I}' must be a string`) : (Q === "number" || Q === "integer") && J !== "number" ? H.push(`Field '${I}' must be a number`) : Q === "boolean" && J !== "boolean" ? H.push(`Field '${I}' must be a boolean`) : Q === "array" && !Array.isArray(m) && H.push(`Field '${I}' must be an array`);
|
|
1011
997
|
}
|
|
1012
|
-
|
|
1013
|
-
`Field '${
|
|
1014
|
-
),
|
|
1015
|
-
`Field '${
|
|
1016
|
-
),
|
|
998
|
+
g.minLength !== void 0 && typeof m == "string" && m.length < g.minLength && H.push(
|
|
999
|
+
`Field '${I}' must be at least ${g.minLength} characters long`
|
|
1000
|
+
), g.maxLength !== void 0 && typeof m == "string" && m.length > g.maxLength && H.push(
|
|
1001
|
+
`Field '${I}' must be no more than ${g.maxLength} characters long`
|
|
1002
|
+
), g.minimum !== void 0 && typeof m == "number" && m < g.minimum && H.push(`Field '${I}' must be at least ${g.minimum}`), g.maximum !== void 0 && typeof m == "number" && m > g.maximum && H.push(`Field '${I}' must be no more than ${g.maximum}`), g.pattern && typeof m == "string" && (new RegExp(g.pattern).test(m) || H.push(`Field '${I}' does not match the required pattern`)), g.enum && !g.enum.includes(m) && H.push(`Field '${I}' must be one of: ${g.enum.join(", ")}`);
|
|
1017
1003
|
}
|
|
1018
1004
|
}), {
|
|
1019
|
-
isValid:
|
|
1020
|
-
errors:
|
|
1005
|
+
isValid: H.length === 0,
|
|
1006
|
+
errors: H
|
|
1021
1007
|
};
|
|
1022
1008
|
} catch {
|
|
1023
1009
|
return {
|
|
@@ -1026,97 +1012,97 @@ function yr({ config: n, children: e }) {
|
|
|
1026
1012
|
};
|
|
1027
1013
|
}
|
|
1028
1014
|
},
|
|
1029
|
-
[
|
|
1015
|
+
[M]
|
|
1030
1016
|
);
|
|
1031
1017
|
re(() => {
|
|
1032
|
-
!n.initialTenant && a ?
|
|
1033
|
-
}, [n.initialTenant, a,
|
|
1034
|
-
|
|
1035
|
-
}, [
|
|
1036
|
-
const
|
|
1037
|
-
(
|
|
1038
|
-
const { mode:
|
|
1039
|
-
if (
|
|
1040
|
-
console.warn(
|
|
1018
|
+
!n.initialTenant && a ? y ? $() : T(a) : !n.initialTenant && !a && (f(null), N(null), h(!1));
|
|
1019
|
+
}, [n.initialTenant, a, y, T, $]), re(() => {
|
|
1020
|
+
y != null && y.id ? l() : (E(null), C(null), u(!1));
|
|
1021
|
+
}, [y == null ? void 0 : y.id, l]);
|
|
1022
|
+
const L = se(
|
|
1023
|
+
(c, H) => {
|
|
1024
|
+
const { mode: I = "reload", tokens: g, redirectPath: m } = H || {}, v = n.tenantMode || "selector";
|
|
1025
|
+
if (v === "fixed") {
|
|
1026
|
+
process.env.NODE_ENV === "development" && console.warn(
|
|
1041
1027
|
"[TenantProvider] switchTenant is a no-op in fixed mode. Tenant is always:",
|
|
1042
1028
|
n.fixedTenantSlug
|
|
1043
|
-
),
|
|
1029
|
+
), m && (window.location.href = m);
|
|
1044
1030
|
return;
|
|
1045
1031
|
}
|
|
1046
|
-
if (localStorage.setItem("tenant",
|
|
1032
|
+
if (localStorage.setItem("tenant", c), v === "subdomain") {
|
|
1047
1033
|
const Q = window.location.hostname, J = Tt(
|
|
1048
|
-
|
|
1034
|
+
c,
|
|
1049
1035
|
Q,
|
|
1050
1036
|
n.baseDomain
|
|
1051
1037
|
);
|
|
1052
1038
|
if (!J) {
|
|
1053
|
-
console.warn(
|
|
1039
|
+
process.env.NODE_ENV === "development" && console.warn(
|
|
1054
1040
|
"[TenantProvider] Cannot switch subdomain, invalid hostname:",
|
|
1055
1041
|
Q
|
|
1056
1042
|
);
|
|
1057
1043
|
return;
|
|
1058
1044
|
}
|
|
1059
|
-
const
|
|
1060
|
-
new URLSearchParams(window.location.search).forEach((
|
|
1061
|
-
V !==
|
|
1062
|
-
}),
|
|
1063
|
-
} else if (
|
|
1064
|
-
const Q =
|
|
1065
|
-
if (J.set(n.selectorParam || "tenant",
|
|
1066
|
-
const
|
|
1067
|
-
window.location.href =
|
|
1045
|
+
const O = m || window.location.pathname, q = new URL(`${window.location.protocol}//${J}${O}`);
|
|
1046
|
+
new URLSearchParams(window.location.search).forEach((A, V) => {
|
|
1047
|
+
V !== pe && q.searchParams.set(V, A);
|
|
1048
|
+
}), g && q.searchParams.set(pe, _e(g)), window.location.href = q.toString();
|
|
1049
|
+
} else if (v === "selector") {
|
|
1050
|
+
const Q = m || window.location.pathname, J = new URLSearchParams(window.location.search);
|
|
1051
|
+
if (J.set(n.selectorParam || "tenant", c), J.delete(pe), g && J.set(pe, _e(g)), I === "reload") {
|
|
1052
|
+
const O = `${Q}?${J.toString()}${window.location.hash}`;
|
|
1053
|
+
window.location.href = O;
|
|
1068
1054
|
} else {
|
|
1069
|
-
const
|
|
1070
|
-
window.history.pushState({}, "",
|
|
1055
|
+
const O = `${Q}?${J.toString()}${window.location.hash}`;
|
|
1056
|
+
window.history.pushState({}, "", O), p(c), T(c);
|
|
1071
1057
|
}
|
|
1072
1058
|
}
|
|
1073
1059
|
},
|
|
1074
|
-
[n.tenantMode, n.selectorParam, n.baseDomain,
|
|
1075
|
-
),
|
|
1060
|
+
[n.tenantMode, n.selectorParam, n.baseDomain, T]
|
|
1061
|
+
), F = K(() => ({
|
|
1076
1062
|
// Tenant info
|
|
1077
|
-
tenant:
|
|
1063
|
+
tenant: y,
|
|
1078
1064
|
tenantSlug: a,
|
|
1079
|
-
isTenantLoading:
|
|
1065
|
+
isTenantLoading: x,
|
|
1080
1066
|
tenantError: R,
|
|
1081
1067
|
retryTenant: () => {
|
|
1082
|
-
a &&
|
|
1068
|
+
a && T(a);
|
|
1083
1069
|
},
|
|
1084
1070
|
// Settings
|
|
1085
|
-
settings:
|
|
1086
|
-
settingsSchema:
|
|
1087
|
-
isSettingsLoading:
|
|
1088
|
-
settingsError:
|
|
1071
|
+
settings: D,
|
|
1072
|
+
settingsSchema: M,
|
|
1073
|
+
isSettingsLoading: P,
|
|
1074
|
+
settingsError: S,
|
|
1089
1075
|
// Actions
|
|
1090
|
-
refreshSettings:
|
|
1091
|
-
switchTenant:
|
|
1076
|
+
refreshSettings: U,
|
|
1077
|
+
switchTenant: L,
|
|
1092
1078
|
// Validation
|
|
1093
|
-
validateSettings:
|
|
1079
|
+
validateSettings: b
|
|
1094
1080
|
}), [
|
|
1095
|
-
|
|
1081
|
+
y,
|
|
1096
1082
|
a,
|
|
1097
|
-
L,
|
|
1098
|
-
R,
|
|
1099
|
-
M,
|
|
1100
|
-
v,
|
|
1101
1083
|
x,
|
|
1102
|
-
|
|
1103
|
-
H,
|
|
1084
|
+
R,
|
|
1104
1085
|
D,
|
|
1105
|
-
|
|
1086
|
+
M,
|
|
1087
|
+
P,
|
|
1088
|
+
S,
|
|
1089
|
+
U,
|
|
1090
|
+
L,
|
|
1091
|
+
b
|
|
1106
1092
|
]);
|
|
1107
|
-
return /* @__PURE__ */ s(
|
|
1093
|
+
return /* @__PURE__ */ s(Ne.Provider, { value: F, children: e });
|
|
1108
1094
|
}
|
|
1109
1095
|
function ge() {
|
|
1110
|
-
const n = ae(
|
|
1096
|
+
const n = ae(Ne);
|
|
1111
1097
|
if (!n)
|
|
1112
1098
|
throw new Error("useTenant must be used within a TenantProvider");
|
|
1113
1099
|
return n;
|
|
1114
1100
|
}
|
|
1115
1101
|
function xe() {
|
|
1116
|
-
return ae(
|
|
1102
|
+
return ae(Ne);
|
|
1117
1103
|
}
|
|
1118
|
-
const
|
|
1119
|
-
function
|
|
1104
|
+
const br = ge;
|
|
1105
|
+
function vr() {
|
|
1120
1106
|
const { settings: n, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: i } = ge();
|
|
1121
1107
|
return {
|
|
1122
1108
|
settings: n,
|
|
@@ -1136,30 +1122,25 @@ function me() {
|
|
|
1136
1122
|
retry: i
|
|
1137
1123
|
};
|
|
1138
1124
|
}
|
|
1139
|
-
const
|
|
1125
|
+
const De = fe(null);
|
|
1140
1126
|
function Sr({ config: n = {}, children: e }) {
|
|
1141
|
-
const { appId: t, baseUrl: r } =
|
|
1127
|
+
const { appId: t, baseUrl: r } = Se(), { tenant: i, tenantSlug: o, switchTenant: a } = ge(), [p, w] = k(n.initialRoles || []), [y, f] = k(!n.initialRoles), [x, h] = k(null), [R, N] = k(!1), [D, E] = k(null), [P, u] = k(() => {
|
|
1142
1128
|
try {
|
|
1143
|
-
const
|
|
1144
|
-
return
|
|
1129
|
+
const A = localStorage.getItem("userTenants");
|
|
1130
|
+
return A ? JSON.parse(A) : [];
|
|
1145
1131
|
} catch {
|
|
1146
1132
|
return [];
|
|
1147
1133
|
}
|
|
1148
|
-
}), [
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
const [N, B] = k(() => {
|
|
1153
|
-
const T = v.current.urlTokens !== null;
|
|
1154
|
-
return console.log("[AuthProvider] SYNC: isLoadingAfterUrlTokens initial:", T), T;
|
|
1155
|
-
}), l = K(() => {
|
|
1156
|
-
const T = we.getInstance({
|
|
1134
|
+
}), [S, C] = k(!1), M = Me({ done: !1, urlTokens: null });
|
|
1135
|
+
M.current.done || (M.current.done = !0, M.current.urlTokens = xt());
|
|
1136
|
+
const [T, $] = k(() => M.current.urlTokens !== null), l = K(() => {
|
|
1137
|
+
const A = we.getInstance({
|
|
1157
1138
|
tenantSlug: o,
|
|
1158
1139
|
baseUrl: r,
|
|
1159
1140
|
refreshQueueTimeout: n.refreshQueueTimeout,
|
|
1160
1141
|
proactiveRefreshMargin: n.proactiveRefreshMargin,
|
|
1161
1142
|
onSessionExpired: (V) => {
|
|
1162
|
-
|
|
1143
|
+
h(null), E(null), u([]), C(!1);
|
|
1163
1144
|
try {
|
|
1164
1145
|
localStorage.removeItem("userTenants");
|
|
1165
1146
|
} catch {
|
|
@@ -1167,46 +1148,46 @@ function Sr({ config: n = {}, children: e }) {
|
|
|
1167
1148
|
n.onSessionExpired ? n.onSessionExpired(V) : n.onRefreshFailed && n.onRefreshFailed();
|
|
1168
1149
|
}
|
|
1169
1150
|
});
|
|
1170
|
-
return
|
|
1171
|
-
accessToken:
|
|
1172
|
-
refreshToken:
|
|
1173
|
-
expiresIn:
|
|
1174
|
-
}),
|
|
1175
|
-
}, [o, r, n.refreshQueueTimeout, n.proactiveRefreshMargin]), [
|
|
1176
|
-
if (
|
|
1177
|
-
const
|
|
1178
|
-
return
|
|
1179
|
-
}),
|
|
1180
|
-
const
|
|
1181
|
-
return
|
|
1182
|
-
}, [r, l]),
|
|
1183
|
-
}),
|
|
1184
|
-
const
|
|
1151
|
+
return M.current.urlTokens && A.setTokens({
|
|
1152
|
+
accessToken: M.current.urlTokens.accessToken,
|
|
1153
|
+
refreshToken: M.current.urlTokens.refreshToken,
|
|
1154
|
+
expiresIn: M.current.urlTokens.expiresIn
|
|
1155
|
+
}), A;
|
|
1156
|
+
}, [o, r, n.refreshQueueTimeout, n.proactiveRefreshMargin]), [U, b] = k(() => {
|
|
1157
|
+
if (M.current.urlTokens) return !1;
|
|
1158
|
+
const A = l.getTokens();
|
|
1159
|
+
return A ? l.hasValidSession() || !!A.refreshToken : !1;
|
|
1160
|
+
}), L = M.current.done && !T && !U, F = K(() => {
|
|
1161
|
+
const A = new le(r);
|
|
1162
|
+
return A.setSessionManager(l), A;
|
|
1163
|
+
}, [r, l]), c = K(() => new yt(new le(r)), [r]), H = K(() => new wt(F, l), [F, l]), I = K(() => new ze(new le(r)), [r]), g = K(() => x || l.getUser(), [x, l]), m = K(() => g != null && g.roleId && p.find((A) => A.id === g.roleId) || null, [g, p]), v = K(() => (m == null ? void 0 : m.permissions) || [], [m]), Q = K(() => l.hasValidSession() && x !== null, [l, x]), J = Me(async () => {
|
|
1164
|
+
}), O = K(() => {
|
|
1165
|
+
const A = async (B = !1) => {
|
|
1185
1166
|
try {
|
|
1186
|
-
if (!l.hasValidSession() ||
|
|
1167
|
+
if (!l.hasValidSession() || !B && x)
|
|
1187
1168
|
return;
|
|
1188
1169
|
const z = l.getUserId();
|
|
1189
1170
|
if (!z) {
|
|
1190
|
-
console.warn("[AuthProvider] No userId available in token or storage");
|
|
1171
|
+
process.env.NODE_ENV === "development" && console.warn("[AuthProvider] No userId available in token or storage");
|
|
1191
1172
|
return;
|
|
1192
1173
|
}
|
|
1193
|
-
|
|
1194
|
-
const Z = await
|
|
1195
|
-
|
|
1174
|
+
N(!0), E(null);
|
|
1175
|
+
const Z = await H.getUserById(z);
|
|
1176
|
+
h(Z), l.setUser(Z);
|
|
1196
1177
|
} catch (z) {
|
|
1197
1178
|
const Z = z instanceof Error ? z : new Error("Failed to load user data");
|
|
1198
|
-
E(Z), console.error("[AuthProvider] Failed to load user data:", Z);
|
|
1179
|
+
E(Z), process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to load user data:", Z);
|
|
1199
1180
|
} finally {
|
|
1200
|
-
|
|
1181
|
+
N(!1);
|
|
1201
1182
|
}
|
|
1202
1183
|
}, V = async () => {
|
|
1203
|
-
await
|
|
1204
|
-
}, de = async (
|
|
1184
|
+
await A();
|
|
1185
|
+
}, de = async (B) => {
|
|
1205
1186
|
var Be;
|
|
1206
|
-
const { username: z, password: Z, tenantSlug: W, redirectPath: Y } =
|
|
1187
|
+
const { username: z, password: Z, tenantSlug: W, redirectPath: Y } = B;
|
|
1207
1188
|
let X = i == null ? void 0 : i.id, ee = o, te = l;
|
|
1208
|
-
W && (X = (await new be(
|
|
1209
|
-
const G = await
|
|
1189
|
+
W && (X = (await new be(F, t).getPublicTenantInfo(W)).id, ee = W);
|
|
1190
|
+
const G = await c.login({
|
|
1210
1191
|
username: z,
|
|
1211
1192
|
password: Z,
|
|
1212
1193
|
appId: t,
|
|
@@ -1220,22 +1201,22 @@ function Sr({ config: n = {}, children: e }) {
|
|
|
1220
1201
|
refreshToken: G.refreshToken,
|
|
1221
1202
|
expiresIn: G.expiresIn
|
|
1222
1203
|
}), G.user) {
|
|
1223
|
-
te.setUser(G.user),
|
|
1204
|
+
te.setUser(G.user), h(G.user);
|
|
1224
1205
|
try {
|
|
1225
|
-
await
|
|
1206
|
+
await A();
|
|
1226
1207
|
} catch (Te) {
|
|
1227
|
-
console.warn("Failed to load complete user data after login:", Te);
|
|
1208
|
+
process.env.NODE_ENV === "development" && console.warn("[AuthProvider] Failed to load complete user data after login:", Te);
|
|
1228
1209
|
}
|
|
1229
1210
|
}
|
|
1230
1211
|
if (G.tenants && G.tenants.length > 0) {
|
|
1231
|
-
|
|
1212
|
+
u(G.tenants);
|
|
1232
1213
|
try {
|
|
1233
1214
|
localStorage.setItem("userTenants", JSON.stringify(G.tenants));
|
|
1234
1215
|
} catch {
|
|
1235
1216
|
}
|
|
1236
1217
|
}
|
|
1237
1218
|
const Pe = ((Be = G.user) == null ? void 0 : Be.tenantId) !== null;
|
|
1238
|
-
|
|
1219
|
+
C(Pe);
|
|
1239
1220
|
const Re = {
|
|
1240
1221
|
accessToken: G.accessToken,
|
|
1241
1222
|
refreshToken: G.refreshToken,
|
|
@@ -1246,21 +1227,21 @@ function Sr({ config: n = {}, children: e }) {
|
|
|
1246
1227
|
if (Y && Y !== window.location.pathname)
|
|
1247
1228
|
return a(ee || o || "", { tokens: Re, redirectPath: Y }), G;
|
|
1248
1229
|
if (!Pe && G.tenants && G.tenants.length > 0) {
|
|
1249
|
-
const Te =
|
|
1230
|
+
const Te = B.autoSwitch !== !1 && n.autoSwitchSingleTenant !== !1;
|
|
1250
1231
|
if (G.tenants.length === 1 && Te) {
|
|
1251
|
-
const
|
|
1252
|
-
return a(
|
|
1232
|
+
const Oe = G.tenants[0];
|
|
1233
|
+
return a(Oe.subdomain, { tokens: Re, redirectPath: Y }), G;
|
|
1253
1234
|
} else G.tenants.length > 1 && n.onTenantSelectionRequired && n.onTenantSelectionRequired(G.tenants);
|
|
1254
1235
|
}
|
|
1255
1236
|
return G;
|
|
1256
|
-
}, he = async (
|
|
1257
|
-
const { email: z, phoneNumber: Z, name: W, password: Y, lastName: X, tenantId: ee } =
|
|
1237
|
+
}, he = async (B) => {
|
|
1238
|
+
const { email: z, phoneNumber: Z, name: W, password: Y, lastName: X, tenantId: ee } = B;
|
|
1258
1239
|
if (!z && !Z)
|
|
1259
1240
|
throw new Error("Either email or phoneNumber is required");
|
|
1260
1241
|
if (!W || !Y)
|
|
1261
1242
|
throw new Error("Name and password are required");
|
|
1262
1243
|
const te = ee ?? (i == null ? void 0 : i.id);
|
|
1263
|
-
return await
|
|
1244
|
+
return await c.signup({
|
|
1264
1245
|
email: z,
|
|
1265
1246
|
phoneNumber: Z,
|
|
1266
1247
|
name: W,
|
|
@@ -1269,13 +1250,13 @@ function Sr({ config: n = {}, children: e }) {
|
|
|
1269
1250
|
lastName: X,
|
|
1270
1251
|
appId: t
|
|
1271
1252
|
});
|
|
1272
|
-
}, et = async (
|
|
1273
|
-
const { email: z, phoneNumber: Z, name: W, password: Y, tenantName: X, lastName: ee } =
|
|
1253
|
+
}, et = async (B) => {
|
|
1254
|
+
const { email: z, phoneNumber: Z, name: W, password: Y, tenantName: X, lastName: ee } = B;
|
|
1274
1255
|
if (!z && !Z)
|
|
1275
1256
|
throw new Error("Either email or phoneNumber is required");
|
|
1276
1257
|
if (!W || !Y || !X)
|
|
1277
1258
|
throw new Error("Name, password, and tenantName are required");
|
|
1278
|
-
return await
|
|
1259
|
+
return await c.signupTenantAdmin({
|
|
1279
1260
|
email: z,
|
|
1280
1261
|
phoneNumber: Z,
|
|
1281
1262
|
name: W,
|
|
@@ -1284,22 +1265,22 @@ function Sr({ config: n = {}, children: e }) {
|
|
|
1284
1265
|
appId: t,
|
|
1285
1266
|
lastName: ee
|
|
1286
1267
|
});
|
|
1287
|
-
}, tt = async (
|
|
1288
|
-
const { currentPassword: z, newPassword: Z } =
|
|
1289
|
-
await
|
|
1290
|
-
}, rt = async (
|
|
1291
|
-
const { email: z, tenantId: Z } =
|
|
1268
|
+
}, tt = async (B) => {
|
|
1269
|
+
const { currentPassword: z, newPassword: Z } = B, W = await l.getAuthHeaders();
|
|
1270
|
+
await c.changePassword({ currentPassword: z, newPassword: Z }, W);
|
|
1271
|
+
}, rt = async (B) => {
|
|
1272
|
+
const { email: z, tenantId: Z } = B, W = Z ?? (i == null ? void 0 : i.id);
|
|
1292
1273
|
if (!W)
|
|
1293
1274
|
throw new Error("tenantId is required for password reset");
|
|
1294
|
-
await
|
|
1295
|
-
}, nt = async (
|
|
1296
|
-
const { token: z, newPassword: Z } =
|
|
1297
|
-
await
|
|
1298
|
-
}, st = async (
|
|
1299
|
-
const { email: z, frontendUrl: Z, name: W, lastName: Y, tenantId: X } =
|
|
1275
|
+
await c.requestPasswordReset({ email: z, tenantId: W });
|
|
1276
|
+
}, nt = async (B) => {
|
|
1277
|
+
const { token: z, newPassword: Z } = B;
|
|
1278
|
+
await c.confirmPasswordReset({ token: z, newPassword: Z });
|
|
1279
|
+
}, st = async (B) => {
|
|
1280
|
+
const { email: z, frontendUrl: Z, name: W, lastName: Y, tenantId: X } = B, ee = X ?? (i == null ? void 0 : i.id);
|
|
1300
1281
|
if (!ee)
|
|
1301
1282
|
throw new Error("tenantId is required for magic link authentication");
|
|
1302
|
-
return await
|
|
1283
|
+
return await c.sendMagicLink({
|
|
1303
1284
|
email: z,
|
|
1304
1285
|
tenantId: ee,
|
|
1305
1286
|
frontendUrl: Z,
|
|
@@ -1307,11 +1288,11 @@ function Sr({ config: n = {}, children: e }) {
|
|
|
1307
1288
|
lastName: Y,
|
|
1308
1289
|
appId: t
|
|
1309
1290
|
});
|
|
1310
|
-
}, it = async (
|
|
1311
|
-
const { token: z, email: Z, tenantSlug: W } =
|
|
1291
|
+
}, it = async (B) => {
|
|
1292
|
+
const { token: z, email: Z, tenantSlug: W } = B;
|
|
1312
1293
|
let Y = i == null ? void 0 : i.id, X = o, ee = l;
|
|
1313
|
-
W && (Y = (await new be(
|
|
1314
|
-
const te = await
|
|
1294
|
+
W && (Y = (await new be(F, t).getPublicTenantInfo(W)).id, X = W);
|
|
1295
|
+
const te = await c.verifyMagicLink({
|
|
1315
1296
|
token: z,
|
|
1316
1297
|
email: Z,
|
|
1317
1298
|
appId: t,
|
|
@@ -1325,11 +1306,14 @@ function Sr({ config: n = {}, children: e }) {
|
|
|
1325
1306
|
refreshToken: te.refreshToken,
|
|
1326
1307
|
expiresIn: te.expiresIn
|
|
1327
1308
|
}), te.user) {
|
|
1328
|
-
ee.setUser(te.user),
|
|
1309
|
+
ee.setUser(te.user), h(te.user);
|
|
1329
1310
|
try {
|
|
1330
|
-
await
|
|
1311
|
+
await A();
|
|
1331
1312
|
} catch (ye) {
|
|
1332
|
-
|
|
1313
|
+
process.env.NODE_ENV === "development" && console.warn(
|
|
1314
|
+
"[AuthProvider] Failed to load complete user data after magic link:",
|
|
1315
|
+
ye
|
|
1316
|
+
);
|
|
1333
1317
|
}
|
|
1334
1318
|
}
|
|
1335
1319
|
return G && X && X !== o && a(X, {
|
|
@@ -1340,53 +1324,53 @@ function Sr({ config: n = {}, children: e }) {
|
|
|
1340
1324
|
}
|
|
1341
1325
|
}), te;
|
|
1342
1326
|
}, ot = async () => {
|
|
1343
|
-
const
|
|
1344
|
-
if (!(
|
|
1327
|
+
const B = l.getTokens();
|
|
1328
|
+
if (!(B != null && B.refreshToken))
|
|
1345
1329
|
throw new Error("No refresh token available");
|
|
1346
|
-
const z = await
|
|
1347
|
-
refreshToken:
|
|
1330
|
+
const z = await c.refreshToken({
|
|
1331
|
+
refreshToken: B.refreshToken
|
|
1348
1332
|
});
|
|
1349
1333
|
l.setTokens({
|
|
1350
1334
|
accessToken: z.accessToken,
|
|
1351
|
-
refreshToken: z.refreshToken ||
|
|
1335
|
+
refreshToken: z.refreshToken || B.refreshToken,
|
|
1352
1336
|
expiresIn: z.expiresIn
|
|
1353
1337
|
});
|
|
1354
1338
|
}, at = () => {
|
|
1355
|
-
l.clearSession(),
|
|
1339
|
+
l.clearSession(), h(null), E(null), u([]), C(!1);
|
|
1356
1340
|
try {
|
|
1357
1341
|
localStorage.removeItem("userTenants");
|
|
1358
1342
|
} catch {
|
|
1359
1343
|
}
|
|
1360
|
-
}, lt = (
|
|
1361
|
-
l.setTokens(
|
|
1344
|
+
}, lt = (B) => {
|
|
1345
|
+
l.setTokens(B);
|
|
1362
1346
|
}, ct = () => l.hasValidSession(), dt = () => {
|
|
1363
|
-
l.clearSession(),
|
|
1347
|
+
l.clearSession(), h(null), E(null);
|
|
1364
1348
|
}, ut = async () => {
|
|
1365
1349
|
if (t)
|
|
1366
1350
|
try {
|
|
1367
|
-
|
|
1368
|
-
const { roles:
|
|
1369
|
-
|
|
1370
|
-
} catch (
|
|
1371
|
-
console.error("Failed to fetch roles:",
|
|
1351
|
+
f(!0);
|
|
1352
|
+
const { roles: B } = await I.getRolesByApp(t);
|
|
1353
|
+
w(B);
|
|
1354
|
+
} catch (B) {
|
|
1355
|
+
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:", B);
|
|
1372
1356
|
} finally {
|
|
1373
|
-
|
|
1357
|
+
f(!1);
|
|
1374
1358
|
}
|
|
1375
1359
|
}, ht = async () => {
|
|
1376
1360
|
await ut();
|
|
1377
|
-
}, Ae = (
|
|
1378
|
-
if (!
|
|
1361
|
+
}, Ae = (B) => {
|
|
1362
|
+
if (!v || v.length === 0)
|
|
1379
1363
|
return !1;
|
|
1380
|
-
if (typeof
|
|
1381
|
-
return
|
|
1382
|
-
const z = `${
|
|
1383
|
-
return
|
|
1364
|
+
if (typeof B == "string")
|
|
1365
|
+
return v.includes(B);
|
|
1366
|
+
const z = `${B.resource}.${B.action}`;
|
|
1367
|
+
return v.includes(z);
|
|
1384
1368
|
};
|
|
1385
1369
|
return {
|
|
1386
1370
|
// RFC-003: Authentication state
|
|
1387
1371
|
isAuthenticated: Q,
|
|
1388
1372
|
sessionManager: l,
|
|
1389
|
-
authenticatedHttpService:
|
|
1373
|
+
authenticatedHttpService: F,
|
|
1390
1374
|
login: de,
|
|
1391
1375
|
signup: he,
|
|
1392
1376
|
signupTenantAdmin: et,
|
|
@@ -1400,40 +1384,40 @@ function Sr({ config: n = {}, children: e }) {
|
|
|
1400
1384
|
setTokens: lt,
|
|
1401
1385
|
hasValidSession: ct,
|
|
1402
1386
|
clearSession: dt,
|
|
1403
|
-
currentUser:
|
|
1387
|
+
currentUser: x,
|
|
1404
1388
|
isUserLoading: R,
|
|
1405
|
-
userError:
|
|
1406
|
-
loadUserData:
|
|
1389
|
+
userError: D,
|
|
1390
|
+
loadUserData: A,
|
|
1407
1391
|
refreshUser: V,
|
|
1408
|
-
isAuthInitializing: !
|
|
1409
|
-
isAuthReady:
|
|
1410
|
-
userRole:
|
|
1411
|
-
userPermissions:
|
|
1412
|
-
availableRoles:
|
|
1413
|
-
rolesLoading:
|
|
1392
|
+
isAuthInitializing: !L,
|
|
1393
|
+
isAuthReady: L,
|
|
1394
|
+
userRole: m,
|
|
1395
|
+
userPermissions: v,
|
|
1396
|
+
availableRoles: p,
|
|
1397
|
+
rolesLoading: y,
|
|
1414
1398
|
hasPermission: Ae,
|
|
1415
|
-
hasAnyPermission: (
|
|
1416
|
-
hasAllPermissions: (
|
|
1417
|
-
getUserPermissionStrings: () =>
|
|
1399
|
+
hasAnyPermission: (B) => B.some((z) => Ae(z)),
|
|
1400
|
+
hasAllPermissions: (B) => B.every((z) => Ae(z)),
|
|
1401
|
+
getUserPermissionStrings: () => v || [],
|
|
1418
1402
|
refreshRoles: ht,
|
|
1419
1403
|
// RFC-004: Multi-tenant user membership
|
|
1420
|
-
userTenants:
|
|
1421
|
-
hasTenantContext:
|
|
1422
|
-
switchToTenant: async (
|
|
1404
|
+
userTenants: P,
|
|
1405
|
+
hasTenantContext: S,
|
|
1406
|
+
switchToTenant: async (B, z) => {
|
|
1423
1407
|
const { redirectPath: Z } = z || {}, W = l.getTokens();
|
|
1424
1408
|
if (!(W != null && W.refreshToken))
|
|
1425
1409
|
throw new Error("No refresh token available for tenant switch");
|
|
1426
|
-
const Y = await
|
|
1410
|
+
const Y = await c.switchTenant({
|
|
1427
1411
|
refreshToken: W.refreshToken,
|
|
1428
|
-
tenantId:
|
|
1412
|
+
tenantId: B
|
|
1429
1413
|
});
|
|
1430
1414
|
l.setTokens({
|
|
1431
1415
|
accessToken: Y.accessToken,
|
|
1432
1416
|
refreshToken: W.refreshToken,
|
|
1433
1417
|
// Keep the same refresh token
|
|
1434
1418
|
expiresIn: Y.expiresIn
|
|
1435
|
-
}),
|
|
1436
|
-
const X =
|
|
1419
|
+
}), h(Y.user), l.setUser(Y.user), C(!0);
|
|
1420
|
+
const X = P.find((ee) => ee.id === B);
|
|
1437
1421
|
X && a(X.subdomain, {
|
|
1438
1422
|
tokens: {
|
|
1439
1423
|
accessToken: Y.accessToken,
|
|
@@ -1444,8 +1428,8 @@ function Sr({ config: n = {}, children: e }) {
|
|
|
1444
1428
|
});
|
|
1445
1429
|
},
|
|
1446
1430
|
refreshUserTenants: async () => {
|
|
1447
|
-
const
|
|
1448
|
-
|
|
1431
|
+
const B = await l.getAuthHeaders(), z = await c.getUserTenants(B);
|
|
1432
|
+
u(z);
|
|
1449
1433
|
try {
|
|
1450
1434
|
localStorage.setItem("userTenants", JSON.stringify(z));
|
|
1451
1435
|
} catch {
|
|
@@ -1456,69 +1440,69 @@ function Sr({ config: n = {}, children: e }) {
|
|
|
1456
1440
|
}, [
|
|
1457
1441
|
Q,
|
|
1458
1442
|
l,
|
|
1459
|
-
C,
|
|
1460
|
-
d,
|
|
1461
|
-
U,
|
|
1462
1443
|
F,
|
|
1444
|
+
c,
|
|
1445
|
+
H,
|
|
1446
|
+
I,
|
|
1463
1447
|
t,
|
|
1464
1448
|
i,
|
|
1465
1449
|
o,
|
|
1466
1450
|
a,
|
|
1467
|
-
|
|
1468
|
-
L,
|
|
1469
|
-
R,
|
|
1470
|
-
M,
|
|
1451
|
+
p,
|
|
1471
1452
|
x,
|
|
1472
|
-
|
|
1453
|
+
R,
|
|
1473
1454
|
D,
|
|
1474
|
-
|
|
1475
|
-
S
|
|
1455
|
+
P,
|
|
1456
|
+
S,
|
|
1457
|
+
L,
|
|
1458
|
+
m,
|
|
1459
|
+
v
|
|
1476
1460
|
]);
|
|
1477
|
-
J.current =
|
|
1461
|
+
J.current = O.loadUserData, re(() => {
|
|
1478
1462
|
!n.initialRoles && t && (async () => {
|
|
1479
1463
|
try {
|
|
1480
|
-
|
|
1464
|
+
f(!0);
|
|
1481
1465
|
const V = new le(r), de = new ze(V), { roles: he } = await de.getRolesByApp(t);
|
|
1482
|
-
|
|
1466
|
+
w(he);
|
|
1483
1467
|
} catch (V) {
|
|
1484
|
-
console.error("Failed to fetch roles:", V);
|
|
1468
|
+
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:", V);
|
|
1485
1469
|
} finally {
|
|
1486
|
-
|
|
1470
|
+
f(!1);
|
|
1487
1471
|
}
|
|
1488
1472
|
})();
|
|
1489
1473
|
}, [t, r, n.initialRoles]);
|
|
1490
|
-
const [
|
|
1474
|
+
const [q, j] = k(!1);
|
|
1491
1475
|
return re(() => {
|
|
1492
|
-
|
|
1493
|
-
console.error("[AuthProvider] Failed to load user data:",
|
|
1476
|
+
q || (j(!0), M.current.urlTokens && (At(), $(!0), O.loadUserData().catch((A) => {
|
|
1477
|
+
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to load user data after URL tokens:", A);
|
|
1494
1478
|
}).finally(() => {
|
|
1495
|
-
|
|
1479
|
+
$(!1);
|
|
1496
1480
|
})));
|
|
1497
|
-
}, [
|
|
1498
|
-
let
|
|
1481
|
+
}, [O, q]), re(() => {
|
|
1482
|
+
let A = !1;
|
|
1499
1483
|
return (async () => {
|
|
1500
1484
|
var he;
|
|
1501
|
-
if (!l.hasValidSession() && ((he = l.getTokens()) != null && he.refreshToken) && await l.waitForPendingRefresh(),
|
|
1485
|
+
if (!l.hasValidSession() && ((he = l.getTokens()) != null && he.refreshToken) && await l.waitForPendingRefresh(), A) return;
|
|
1502
1486
|
const de = l.getUser();
|
|
1503
|
-
de && l.hasValidSession() &&
|
|
1487
|
+
de && l.hasValidSession() && h(de), b(!1);
|
|
1504
1488
|
})(), () => {
|
|
1505
|
-
|
|
1489
|
+
A = !0;
|
|
1506
1490
|
};
|
|
1507
1491
|
}, [l]), re(() => {
|
|
1508
|
-
|
|
1492
|
+
q && (M.current.urlTokens || (!x && !R && !D && l.hasValidSession() ? J.current().catch(() => {
|
|
1509
1493
|
}).finally(() => {
|
|
1510
|
-
|
|
1511
|
-
})
|
|
1512
|
-
}, [
|
|
1494
|
+
b(!1);
|
|
1495
|
+
}) : b(!1)));
|
|
1496
|
+
}, [x, R, D, l, q]), /* @__PURE__ */ s(De.Provider, { value: O, children: e });
|
|
1513
1497
|
}
|
|
1514
1498
|
function ue() {
|
|
1515
|
-
const n = ae(
|
|
1499
|
+
const n = ae(De);
|
|
1516
1500
|
if (!n)
|
|
1517
1501
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
1518
1502
|
return n;
|
|
1519
1503
|
}
|
|
1520
|
-
function
|
|
1521
|
-
return ae(
|
|
1504
|
+
function Fe() {
|
|
1505
|
+
return ae(De);
|
|
1522
1506
|
}
|
|
1523
1507
|
class Pt {
|
|
1524
1508
|
constructor(e, t) {
|
|
@@ -1600,55 +1584,55 @@ class Pt {
|
|
|
1600
1584
|
})).data;
|
|
1601
1585
|
}
|
|
1602
1586
|
}
|
|
1603
|
-
const Ce =
|
|
1604
|
-
function
|
|
1605
|
-
const t = Qe(), r = xe(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (r == null ? void 0 : r.tenant) ?? null, [
|
|
1606
|
-
const
|
|
1607
|
-
return new Pt(
|
|
1587
|
+
const Ce = fe(null);
|
|
1588
|
+
function Tr({ config: n = {}, children: e }) {
|
|
1589
|
+
const t = Qe(), r = xe(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (r == null ? void 0 : r.tenant) ?? null, [p, w] = k([]), [y, f] = k(!1), [x, h] = k(null), [R, N] = k(!1), D = K(() => {
|
|
1590
|
+
const u = new le(i);
|
|
1591
|
+
return new Pt(u);
|
|
1608
1592
|
}, [i]), E = async () => {
|
|
1609
1593
|
if (!(a != null && a.id)) {
|
|
1610
|
-
|
|
1594
|
+
w([]);
|
|
1611
1595
|
return;
|
|
1612
1596
|
}
|
|
1613
|
-
|
|
1597
|
+
f(!0), h(null);
|
|
1614
1598
|
try {
|
|
1615
|
-
const
|
|
1616
|
-
|
|
1617
|
-
} catch (
|
|
1618
|
-
const
|
|
1619
|
-
|
|
1599
|
+
const u = await D.getTenantFeatureFlags(a.id, o);
|
|
1600
|
+
w(u);
|
|
1601
|
+
} catch (u) {
|
|
1602
|
+
const S = u instanceof Error ? u.message : "Failed to fetch feature flags";
|
|
1603
|
+
h(S), n.onError && n.onError(u instanceof Error ? u : new Error(S));
|
|
1620
1604
|
} finally {
|
|
1621
|
-
|
|
1605
|
+
f(!1);
|
|
1622
1606
|
}
|
|
1623
1607
|
};
|
|
1624
1608
|
re(() => {
|
|
1625
1609
|
if (!i || !o) return;
|
|
1626
|
-
E().finally(() =>
|
|
1627
|
-
const
|
|
1628
|
-
return () => clearInterval(
|
|
1610
|
+
E().finally(() => N(!0));
|
|
1611
|
+
const u = n.refreshInterval || 5 * 60 * 1e3, S = setInterval(E, u);
|
|
1612
|
+
return () => clearInterval(S);
|
|
1629
1613
|
}, [a == null ? void 0 : a.id, i, o, n.refreshInterval]);
|
|
1630
|
-
const
|
|
1631
|
-
const
|
|
1632
|
-
const l =
|
|
1614
|
+
const P = K(() => {
|
|
1615
|
+
const u = ($) => {
|
|
1616
|
+
const l = p.find((U) => U.key === $);
|
|
1633
1617
|
return (l == null ? void 0 : l.value) === !0;
|
|
1634
|
-
},
|
|
1635
|
-
const l =
|
|
1618
|
+
}, S = ($) => p.find((l) => l.key === $), C = ($) => {
|
|
1619
|
+
const l = p.find((U) => U.key === $);
|
|
1636
1620
|
return l ? l.value ? "enabled" : "disabled" : "not_found";
|
|
1637
|
-
},
|
|
1621
|
+
}, M = async () => {
|
|
1638
1622
|
await E();
|
|
1639
|
-
},
|
|
1623
|
+
}, T = !!(i && o) && (R || !(a != null && a.id));
|
|
1640
1624
|
return {
|
|
1641
|
-
featureFlags:
|
|
1642
|
-
loading:
|
|
1643
|
-
error:
|
|
1644
|
-
isReady:
|
|
1645
|
-
isEnabled:
|
|
1646
|
-
getFlag:
|
|
1647
|
-
getFlagState:
|
|
1648
|
-
refresh:
|
|
1625
|
+
featureFlags: p,
|
|
1626
|
+
loading: y,
|
|
1627
|
+
error: x,
|
|
1628
|
+
isReady: T,
|
|
1629
|
+
isEnabled: u,
|
|
1630
|
+
getFlag: S,
|
|
1631
|
+
getFlagState: C,
|
|
1632
|
+
refresh: M
|
|
1649
1633
|
};
|
|
1650
|
-
}, [
|
|
1651
|
-
return /* @__PURE__ */ s(Ce.Provider, { value:
|
|
1634
|
+
}, [p, y, x, i, o, a == null ? void 0 : a.id, R]);
|
|
1635
|
+
return /* @__PURE__ */ s(Ce.Provider, { value: P, children: e });
|
|
1652
1636
|
}
|
|
1653
1637
|
function Rt() {
|
|
1654
1638
|
const n = ae(Ce);
|
|
@@ -1659,7 +1643,7 @@ function Rt() {
|
|
|
1659
1643
|
function Ke() {
|
|
1660
1644
|
return ae(Ce);
|
|
1661
1645
|
}
|
|
1662
|
-
class
|
|
1646
|
+
class Et {
|
|
1663
1647
|
constructor(e, t) {
|
|
1664
1648
|
this.httpService = e, this.sessionManager = t;
|
|
1665
1649
|
}
|
|
@@ -1725,68 +1709,68 @@ class It {
|
|
|
1725
1709
|
)).data;
|
|
1726
1710
|
}
|
|
1727
1711
|
}
|
|
1728
|
-
const
|
|
1729
|
-
function
|
|
1730
|
-
const t = Qe(), r = xe(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a,
|
|
1731
|
-
const
|
|
1732
|
-
return new
|
|
1733
|
-
}, [i]),
|
|
1712
|
+
const $e = fe(void 0);
|
|
1713
|
+
function kr({ config: n = {}, children: e }) {
|
|
1714
|
+
const t = Qe(), r = xe(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a, p] = k(null), [w, y] = k(!1), [f, x] = k(null), [h, R] = k(!1), N = K(() => {
|
|
1715
|
+
const P = new le(i);
|
|
1716
|
+
return new Et(P);
|
|
1717
|
+
}, [i]), D = async () => {
|
|
1734
1718
|
if (!(o != null && o.id)) {
|
|
1735
|
-
|
|
1719
|
+
p(null);
|
|
1736
1720
|
return;
|
|
1737
1721
|
}
|
|
1738
|
-
|
|
1722
|
+
y(!0), x(null);
|
|
1739
1723
|
try {
|
|
1740
|
-
const
|
|
1741
|
-
|
|
1742
|
-
} catch (
|
|
1743
|
-
const
|
|
1744
|
-
|
|
1724
|
+
const P = await N.getTenantSubscriptionFeatures(o.id);
|
|
1725
|
+
p(P);
|
|
1726
|
+
} catch (P) {
|
|
1727
|
+
const u = P instanceof Error ? P.message : "Failed to fetch subscription";
|
|
1728
|
+
x(u), n.onError && n.onError(P instanceof Error ? P : new Error(u));
|
|
1745
1729
|
} finally {
|
|
1746
|
-
|
|
1730
|
+
y(!1);
|
|
1747
1731
|
}
|
|
1748
1732
|
};
|
|
1749
1733
|
re(() => {
|
|
1750
|
-
if (!i || (
|
|
1751
|
-
const
|
|
1752
|
-
return () => clearInterval(
|
|
1734
|
+
if (!i || (D().finally(() => R(!0)), !n.refreshInterval)) return;
|
|
1735
|
+
const P = n.refreshInterval || 10 * 60 * 1e3, u = setInterval(D, P);
|
|
1736
|
+
return () => clearInterval(u);
|
|
1753
1737
|
}, [o == null ? void 0 : o.id, i, n.refreshInterval]);
|
|
1754
1738
|
const E = K(() => {
|
|
1755
|
-
const
|
|
1756
|
-
const
|
|
1757
|
-
return
|
|
1758
|
-
},
|
|
1759
|
-
const
|
|
1760
|
-
return
|
|
1761
|
-
},
|
|
1762
|
-
await
|
|
1763
|
-
},
|
|
1739
|
+
const P = (a == null ? void 0 : a.features) || [], u = (l) => {
|
|
1740
|
+
const U = P.find((b) => b.key === l);
|
|
1741
|
+
return U ? U.type === "BOOLEAN" || U.type === "boolean" ? U.value === !0 : !!U.value : !1;
|
|
1742
|
+
}, S = (l) => P.find((U) => U.key === l), C = (l, U) => {
|
|
1743
|
+
const b = P.find((L) => L.key === l);
|
|
1744
|
+
return b ? b.value : U;
|
|
1745
|
+
}, M = (l) => !a || !a.isActive ? !1 : l.includes(a.planId), T = async () => {
|
|
1746
|
+
await D();
|
|
1747
|
+
}, $ = !!i && (h || !(o != null && o.id));
|
|
1764
1748
|
return {
|
|
1765
1749
|
subscription: a,
|
|
1766
|
-
features:
|
|
1767
|
-
loading:
|
|
1768
|
-
error:
|
|
1769
|
-
isReady:
|
|
1770
|
-
isFeatureEnabled:
|
|
1771
|
-
getFeature:
|
|
1772
|
-
getFeatureValue:
|
|
1773
|
-
hasAllowedPlan:
|
|
1774
|
-
refresh:
|
|
1750
|
+
features: P,
|
|
1751
|
+
loading: w,
|
|
1752
|
+
error: f,
|
|
1753
|
+
isReady: $,
|
|
1754
|
+
isFeatureEnabled: u,
|
|
1755
|
+
getFeature: S,
|
|
1756
|
+
getFeatureValue: C,
|
|
1757
|
+
hasAllowedPlan: M,
|
|
1758
|
+
refresh: T
|
|
1775
1759
|
};
|
|
1776
|
-
}, [a,
|
|
1777
|
-
return /* @__PURE__ */ s(
|
|
1760
|
+
}, [a, w, f, i, o == null ? void 0 : o.id, h]);
|
|
1761
|
+
return /* @__PURE__ */ s($e.Provider, { value: E, children: e });
|
|
1778
1762
|
}
|
|
1779
|
-
function
|
|
1780
|
-
const n = ae(
|
|
1763
|
+
function It() {
|
|
1764
|
+
const n = ae($e);
|
|
1781
1765
|
if (n === void 0)
|
|
1782
1766
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1783
1767
|
return n;
|
|
1784
1768
|
}
|
|
1785
1769
|
function Ze() {
|
|
1786
|
-
return ae(
|
|
1770
|
+
return ae($e) ?? null;
|
|
1787
1771
|
}
|
|
1788
1772
|
var oe = /* @__PURE__ */ ((n) => (n.SUPERUSER = "SUPERUSER", n.TENANT_ADMIN = "TENANT_ADMIN", n.USER = "USER", n))(oe || {});
|
|
1789
|
-
const
|
|
1773
|
+
const Ue = {
|
|
1790
1774
|
publicGuest: "/",
|
|
1791
1775
|
publicUser: "/account",
|
|
1792
1776
|
publicAdmin: "/admin",
|
|
@@ -1811,11 +1795,11 @@ const $e = {
|
|
|
1811
1795
|
admin: { tenant: "required", auth: "required", userType: oe.TENANT_ADMIN },
|
|
1812
1796
|
// Fully open
|
|
1813
1797
|
open: { tenant: "optional", auth: "optional" }
|
|
1814
|
-
}, He =
|
|
1815
|
-
function
|
|
1798
|
+
}, He = fe(null);
|
|
1799
|
+
function xr({ config: n = {}, children: e }) {
|
|
1816
1800
|
const t = K(() => {
|
|
1817
1801
|
const r = {
|
|
1818
|
-
|
|
1802
|
+
...Ue,
|
|
1819
1803
|
...n.zoneRoots
|
|
1820
1804
|
}, i = {
|
|
1821
1805
|
...Je,
|
|
@@ -1833,7 +1817,7 @@ function kr({ config: n = {}, children: e }) {
|
|
|
1833
1817
|
}, [n]);
|
|
1834
1818
|
return /* @__PURE__ */ s(He.Provider, { value: t, children: e });
|
|
1835
1819
|
}
|
|
1836
|
-
function
|
|
1820
|
+
function Ar() {
|
|
1837
1821
|
const n = ae(He);
|
|
1838
1822
|
if (!n)
|
|
1839
1823
|
throw new Error("useRouting must be used within a RoutingProvider");
|
|
@@ -1842,7 +1826,7 @@ function xr() {
|
|
|
1842
1826
|
function Mt() {
|
|
1843
1827
|
const n = ae(He);
|
|
1844
1828
|
return n || {
|
|
1845
|
-
zoneRoots:
|
|
1829
|
+
zoneRoots: Ue,
|
|
1846
1830
|
presets: Je,
|
|
1847
1831
|
loadingFallback: null,
|
|
1848
1832
|
accessDeniedFallback: null,
|
|
@@ -1851,7 +1835,7 @@ function Mt() {
|
|
|
1851
1835
|
returnToStorage: "url"
|
|
1852
1836
|
};
|
|
1853
1837
|
}
|
|
1854
|
-
const We = () => /* @__PURE__ */
|
|
1838
|
+
const We = () => /* @__PURE__ */ d(
|
|
1855
1839
|
"div",
|
|
1856
1840
|
{
|
|
1857
1841
|
style: {
|
|
@@ -1892,7 +1876,7 @@ const We = () => /* @__PURE__ */ u(
|
|
|
1892
1876
|
userType: n,
|
|
1893
1877
|
minUserType: e,
|
|
1894
1878
|
missingPermissions: t
|
|
1895
|
-
}) => /* @__PURE__ */
|
|
1879
|
+
}) => /* @__PURE__ */ d(
|
|
1896
1880
|
"div",
|
|
1897
1881
|
{
|
|
1898
1882
|
style: {
|
|
@@ -1910,19 +1894,19 @@ const We = () => /* @__PURE__ */ u(
|
|
|
1910
1894
|
children: [
|
|
1911
1895
|
/* @__PURE__ */ s("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
|
|
1912
1896
|
/* @__PURE__ */ s("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
|
|
1913
|
-
e && n ? /* @__PURE__ */
|
|
1914
|
-
/* @__PURE__ */
|
|
1897
|
+
e && n ? /* @__PURE__ */ d(_, { children: [
|
|
1898
|
+
/* @__PURE__ */ d("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
|
|
1915
1899
|
"This content requires ",
|
|
1916
1900
|
/* @__PURE__ */ s("strong", { children: e }),
|
|
1917
1901
|
" access level or higher."
|
|
1918
1902
|
] }),
|
|
1919
|
-
/* @__PURE__ */
|
|
1903
|
+
/* @__PURE__ */ d("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1920
1904
|
"Your current access level: ",
|
|
1921
1905
|
/* @__PURE__ */ s("strong", { children: n })
|
|
1922
1906
|
] })
|
|
1923
|
-
] }) : /* @__PURE__ */
|
|
1907
|
+
] }) : /* @__PURE__ */ d(_, { children: [
|
|
1924
1908
|
/* @__PURE__ */ s("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
|
|
1925
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1909
|
+
t && t.length > 0 && /* @__PURE__ */ d("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1926
1910
|
"Required permissions: ",
|
|
1927
1911
|
/* @__PURE__ */ s("strong", { children: t.join(", ") })
|
|
1928
1912
|
] })
|
|
@@ -1937,28 +1921,28 @@ const We = () => /* @__PURE__ */ u(
|
|
|
1937
1921
|
};
|
|
1938
1922
|
return t[n] >= t[e];
|
|
1939
1923
|
};
|
|
1940
|
-
function
|
|
1924
|
+
function Pr({
|
|
1941
1925
|
children: n,
|
|
1942
1926
|
fallback: e,
|
|
1943
1927
|
minUserType: t,
|
|
1944
1928
|
requiredPermissions: r,
|
|
1945
1929
|
requireAllPermissions: i = !1
|
|
1946
1930
|
}) {
|
|
1947
|
-
const { hasValidSession: o, sessionManager: a, hasPermission:
|
|
1931
|
+
const { hasValidSession: o, sessionManager: a, hasPermission: p, hasAnyPermission: w, hasAllPermissions: y } = ue();
|
|
1948
1932
|
if (!o())
|
|
1949
1933
|
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(We, {}) });
|
|
1950
|
-
const
|
|
1951
|
-
if (!
|
|
1934
|
+
const f = a.getUser();
|
|
1935
|
+
if (!f)
|
|
1952
1936
|
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(We, {}) });
|
|
1953
|
-
if (t && !Lt(
|
|
1954
|
-
return /* @__PURE__ */ s(Ve, { userType:
|
|
1955
|
-
if (r && r.length > 0 && !(i ?
|
|
1956
|
-
const
|
|
1957
|
-
return /* @__PURE__ */ s(Ve, { missingPermissions:
|
|
1937
|
+
if (t && !Lt(f.userType, t))
|
|
1938
|
+
return /* @__PURE__ */ s(Ve, { userType: f.userType, minUserType: t });
|
|
1939
|
+
if (r && r.length > 0 && !(i ? y(r) : w(r))) {
|
|
1940
|
+
const h = r.filter((R) => !p(R)).map((R) => typeof R == "string" ? R : R.name);
|
|
1941
|
+
return /* @__PURE__ */ s(Ve, { missingPermissions: h });
|
|
1958
1942
|
}
|
|
1959
1943
|
return /* @__PURE__ */ s(_, { children: n });
|
|
1960
1944
|
}
|
|
1961
|
-
const
|
|
1945
|
+
const Nt = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
1962
1946
|
"div",
|
|
1963
1947
|
{
|
|
1964
1948
|
style: {
|
|
@@ -1971,7 +1955,7 @@ const Ft = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
1971
1955
|
backgroundColor: "#f9fafb",
|
|
1972
1956
|
textAlign: "center"
|
|
1973
1957
|
},
|
|
1974
|
-
children: /* @__PURE__ */
|
|
1958
|
+
children: /* @__PURE__ */ d(
|
|
1975
1959
|
"div",
|
|
1976
1960
|
{
|
|
1977
1961
|
style: {
|
|
@@ -1985,7 +1969,7 @@ const Ft = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
1985
1969
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
|
|
1986
1970
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
|
|
1987
1971
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
|
|
1988
|
-
/* @__PURE__ */
|
|
1972
|
+
/* @__PURE__ */ d("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1989
1973
|
"Redirecting to ",
|
|
1990
1974
|
n,
|
|
1991
1975
|
"..."
|
|
@@ -2011,7 +1995,7 @@ const Ft = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2011
1995
|
backgroundColor: "#f9fafb",
|
|
2012
1996
|
textAlign: "center"
|
|
2013
1997
|
},
|
|
2014
|
-
children: /* @__PURE__ */
|
|
1998
|
+
children: /* @__PURE__ */ d(
|
|
2015
1999
|
"div",
|
|
2016
2000
|
{
|
|
2017
2001
|
style: {
|
|
@@ -2024,19 +2008,19 @@ const Ft = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2024
2008
|
children: [
|
|
2025
2009
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
|
|
2026
2010
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
|
|
2027
|
-
e && n ? /* @__PURE__ */
|
|
2028
|
-
/* @__PURE__ */
|
|
2011
|
+
e && n ? /* @__PURE__ */ d(_, { children: [
|
|
2012
|
+
/* @__PURE__ */ d("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
|
|
2029
2013
|
"This page requires ",
|
|
2030
2014
|
/* @__PURE__ */ s("strong", { children: e }),
|
|
2031
2015
|
" access."
|
|
2032
2016
|
] }),
|
|
2033
|
-
/* @__PURE__ */
|
|
2017
|
+
/* @__PURE__ */ d("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
2034
2018
|
"Your current user type: ",
|
|
2035
2019
|
/* @__PURE__ */ s("strong", { children: n })
|
|
2036
2020
|
] })
|
|
2037
|
-
] }) : /* @__PURE__ */
|
|
2021
|
+
] }) : /* @__PURE__ */ d(_, { children: [
|
|
2038
2022
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
|
|
2039
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
2023
|
+
t && t.length > 0 && /* @__PURE__ */ d("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
2040
2024
|
"Required permissions: ",
|
|
2041
2025
|
/* @__PURE__ */ s("strong", { children: t.join(", ") })
|
|
2042
2026
|
] })
|
|
@@ -2045,8 +2029,8 @@ const Ft = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2045
2029
|
}
|
|
2046
2030
|
)
|
|
2047
2031
|
}
|
|
2048
|
-
),
|
|
2049
|
-
function
|
|
2032
|
+
), Dt = (n, e) => n === e;
|
|
2033
|
+
function Rr({
|
|
2050
2034
|
children: n,
|
|
2051
2035
|
redirectTo: e = "/login",
|
|
2052
2036
|
requiredUserType: t,
|
|
@@ -2054,34 +2038,34 @@ function Pr({
|
|
|
2054
2038
|
requireAllPermissions: i = !1,
|
|
2055
2039
|
fallback: o
|
|
2056
2040
|
}) {
|
|
2057
|
-
const { hasValidSession: a, sessionManager:
|
|
2041
|
+
const { hasValidSession: a, sessionManager: p, hasPermission: w, hasAnyPermission: y, hasAllPermissions: f } = ue(), x = ke();
|
|
2058
2042
|
if (re(() => {
|
|
2059
2043
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2060
2044
|
"[react-identity-access] ProtectedRoute is deprecated. Use AuthenticatedZone or AdminZone from ZoneRoute instead."
|
|
2061
2045
|
);
|
|
2062
2046
|
}, []), !a())
|
|
2063
|
-
return o ? /* @__PURE__ */ s(_, { children: o }) : /* @__PURE__ */
|
|
2064
|
-
/* @__PURE__ */ s(
|
|
2065
|
-
/* @__PURE__ */ s(
|
|
2047
|
+
return o ? /* @__PURE__ */ s(_, { children: o }) : /* @__PURE__ */ d(_, { children: [
|
|
2048
|
+
/* @__PURE__ */ s(Nt, { redirectPath: e }),
|
|
2049
|
+
/* @__PURE__ */ s(ve, { to: e, state: { from: x.pathname }, replace: !0 })
|
|
2066
2050
|
] });
|
|
2067
|
-
const
|
|
2068
|
-
if (!
|
|
2069
|
-
return /* @__PURE__ */ s(
|
|
2070
|
-
if (t && !
|
|
2051
|
+
const h = p.getUser();
|
|
2052
|
+
if (!h)
|
|
2053
|
+
return /* @__PURE__ */ s(ve, { to: e, state: { from: x.pathname }, replace: !0 });
|
|
2054
|
+
if (t && !Dt(h.userType, t))
|
|
2071
2055
|
return /* @__PURE__ */ s(
|
|
2072
2056
|
je,
|
|
2073
2057
|
{
|
|
2074
|
-
userType:
|
|
2058
|
+
userType: h.userType,
|
|
2075
2059
|
requiredUserType: t
|
|
2076
2060
|
}
|
|
2077
2061
|
);
|
|
2078
|
-
if (r && r.length > 0 && !(i ?
|
|
2079
|
-
const
|
|
2080
|
-
return /* @__PURE__ */ s(je, { missingPermissions:
|
|
2062
|
+
if (r && r.length > 0 && !(i ? f(r) : y(r))) {
|
|
2063
|
+
const N = r.filter((D) => !w(D)).map((D) => typeof D == "string" ? D : D.name);
|
|
2064
|
+
return /* @__PURE__ */ s(je, { missingPermissions: N });
|
|
2081
2065
|
}
|
|
2082
2066
|
return /* @__PURE__ */ s(_, { children: n });
|
|
2083
2067
|
}
|
|
2084
|
-
const
|
|
2068
|
+
const Ft = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
2085
2069
|
"div",
|
|
2086
2070
|
{
|
|
2087
2071
|
style: {
|
|
@@ -2094,7 +2078,7 @@ const Dt = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2094
2078
|
backgroundColor: "#f9fafb",
|
|
2095
2079
|
textAlign: "center"
|
|
2096
2080
|
},
|
|
2097
|
-
children: /* @__PURE__ */
|
|
2081
|
+
children: /* @__PURE__ */ d(
|
|
2098
2082
|
"div",
|
|
2099
2083
|
{
|
|
2100
2084
|
style: {
|
|
@@ -2108,7 +2092,7 @@ const Dt = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2108
2092
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
|
|
2109
2093
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
|
|
2110
2094
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
|
|
2111
|
-
/* @__PURE__ */
|
|
2095
|
+
/* @__PURE__ */ d("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
2112
2096
|
"Redirecting to ",
|
|
2113
2097
|
n,
|
|
2114
2098
|
"..."
|
|
@@ -2118,15 +2102,15 @@ const Dt = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2118
2102
|
)
|
|
2119
2103
|
}
|
|
2120
2104
|
);
|
|
2121
|
-
function
|
|
2105
|
+
function Er({ children: n, redirectTo: e = "/", fallback: t }) {
|
|
2122
2106
|
const { tenant: r, isLoading: i, error: o } = me(), a = ke();
|
|
2123
2107
|
return re(() => {
|
|
2124
2108
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2125
2109
|
"[react-identity-access] TenantRoute is deprecated. Use TenantZone from ZoneRoute instead."
|
|
2126
2110
|
);
|
|
2127
|
-
}, []), i || o ? null : r ? /* @__PURE__ */ s(_, { children: n }) : t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */
|
|
2128
|
-
/* @__PURE__ */ s(
|
|
2129
|
-
/* @__PURE__ */ s(
|
|
2111
|
+
}, []), i || o ? null : r ? /* @__PURE__ */ s(_, { children: n }) : t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ d(_, { children: [
|
|
2112
|
+
/* @__PURE__ */ s(Ft, { redirectPath: e }),
|
|
2113
|
+
/* @__PURE__ */ s(ve, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
2130
2114
|
] });
|
|
2131
2115
|
}
|
|
2132
2116
|
const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
@@ -2142,7 +2126,7 @@ const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2142
2126
|
backgroundColor: "#f9fafb",
|
|
2143
2127
|
textAlign: "center"
|
|
2144
2128
|
},
|
|
2145
|
-
children: /* @__PURE__ */
|
|
2129
|
+
children: /* @__PURE__ */ d(
|
|
2146
2130
|
"div",
|
|
2147
2131
|
{
|
|
2148
2132
|
style: {
|
|
@@ -2156,7 +2140,7 @@ const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2156
2140
|
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
|
|
2157
2141
|
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
|
|
2158
2142
|
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
|
|
2159
|
-
/* @__PURE__ */
|
|
2143
|
+
/* @__PURE__ */ d("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
2160
2144
|
"Redirecting to ",
|
|
2161
2145
|
n,
|
|
2162
2146
|
"..."
|
|
@@ -2172,19 +2156,19 @@ function Ir({ children: n, redirectTo: e = "/dashboard", fallback: t }) {
|
|
|
2172
2156
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2173
2157
|
"[react-identity-access] LandingRoute is deprecated. Use PublicZone from ZoneRoute instead."
|
|
2174
2158
|
);
|
|
2175
|
-
}, []), i || o ? null : r ? t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */
|
|
2159
|
+
}, []), i || o ? null : r ? t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ d(_, { children: [
|
|
2176
2160
|
/* @__PURE__ */ s(Ct, { redirectPath: e }),
|
|
2177
|
-
/* @__PURE__ */ s(
|
|
2161
|
+
/* @__PURE__ */ s(ve, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
2178
2162
|
] }) : /* @__PURE__ */ s(_, { children: n });
|
|
2179
2163
|
}
|
|
2180
|
-
function
|
|
2164
|
+
function $t(n, e) {
|
|
2181
2165
|
return e ? n ? Array.isArray(e) ? e.includes(n) : n === e : !1 : !0;
|
|
2182
2166
|
}
|
|
2183
2167
|
function Ge(n, e) {
|
|
2184
2168
|
return !n || n === "optional" ? "skip" : n === "required" ? e ? "pass" : "fail" : n === "forbidden" ? e ? "fail" : "pass" : "skip";
|
|
2185
2169
|
}
|
|
2186
|
-
function
|
|
2187
|
-
return Ge(n.tenant, e.hasTenant) === "fail" ? e.hasTenant ? "has_tenant" : "no_tenant" : Ge(n.auth, e.isAuthenticated) === "fail" ? e.isAuthenticated ? "already_authenticated" : "not_authenticated" : n.userType && e.isAuthenticated &&
|
|
2170
|
+
function Ut(n, e) {
|
|
2171
|
+
return Ge(n.tenant, e.hasTenant) === "fail" ? e.hasTenant ? "has_tenant" : "no_tenant" : Ge(n.auth, e.isAuthenticated) === "fail" ? e.isAuthenticated ? "already_authenticated" : "not_authenticated" : n.userType && e.isAuthenticated && !$t(e.userType, n.userType) ? "wrong_user_type" : n.permissions && n.permissions.length > 0 && !(n.requireAllPermissions !== !1 ? (o) => o.every((a) => e.permissions.includes(a)) : (o) => o.some((a) => e.permissions.includes(a)))(n.permissions) ? "missing_permissions" : null;
|
|
2188
2172
|
}
|
|
2189
2173
|
function Ht(n, e) {
|
|
2190
2174
|
return n.hasTenant ? n.isAuthenticated ? n.userType === oe.TENANT_ADMIN ? e.tenantAdmin : e.tenantUser : e.tenantGuest : n.isAuthenticated ? n.userType === oe.TENANT_ADMIN ? e.publicAdmin : e.publicUser : e.publicGuest;
|
|
@@ -2195,7 +2179,7 @@ function Bt(n, e, t, r, i) {
|
|
|
2195
2179
|
const o = typeof e == "string" ? e : t, a = n.includes("?") ? "&" : "?";
|
|
2196
2180
|
return `${n}${a}${r}=${encodeURIComponent(o)}`;
|
|
2197
2181
|
}
|
|
2198
|
-
function
|
|
2182
|
+
function Ot(n, e, t) {
|
|
2199
2183
|
if (!n || t === "url") return;
|
|
2200
2184
|
const r = typeof n == "string" ? n : e, i = "zone_return_to";
|
|
2201
2185
|
t === "session" ? sessionStorage.setItem(i, r) : t === "local" && localStorage.setItem(i, r);
|
|
@@ -2208,83 +2192,83 @@ const ce = ({
|
|
|
2208
2192
|
userType: i,
|
|
2209
2193
|
requiredPermissions: o,
|
|
2210
2194
|
requireAllPermissions: a = !0,
|
|
2211
|
-
returnTo:
|
|
2212
|
-
onAccessDenied:
|
|
2213
|
-
redirectTo:
|
|
2214
|
-
loadingFallback:
|
|
2215
|
-
accessDeniedFallback:
|
|
2195
|
+
returnTo: p,
|
|
2196
|
+
onAccessDenied: w,
|
|
2197
|
+
redirectTo: y,
|
|
2198
|
+
loadingFallback: f,
|
|
2199
|
+
accessDeniedFallback: x
|
|
2216
2200
|
}) => {
|
|
2217
|
-
const
|
|
2201
|
+
const h = ke(), { isAuthenticated: R, isAuthInitializing: N, currentUser: D, userPermissions: E } = ue(), { tenant: P, isTenantLoading: u } = ge(), S = Mt(), C = K(() => {
|
|
2218
2202
|
if (e)
|
|
2219
|
-
return
|
|
2220
|
-
}, [e,
|
|
2203
|
+
return S.presets[e];
|
|
2204
|
+
}, [e, S.presets]), M = K(
|
|
2221
2205
|
() => ({
|
|
2222
|
-
tenant: t ?? (
|
|
2223
|
-
auth: r ?? (
|
|
2224
|
-
userType: i ?? (
|
|
2225
|
-
permissions: o ?? (
|
|
2206
|
+
tenant: t ?? (C == null ? void 0 : C.tenant),
|
|
2207
|
+
auth: r ?? (C == null ? void 0 : C.auth),
|
|
2208
|
+
userType: i ?? (C == null ? void 0 : C.userType),
|
|
2209
|
+
permissions: o ?? (C == null ? void 0 : C.requiredPermissions),
|
|
2226
2210
|
requireAllPermissions: a
|
|
2227
2211
|
}),
|
|
2228
|
-
[t, r, i, o,
|
|
2229
|
-
),
|
|
2212
|
+
[t, r, i, o, C, a]
|
|
2213
|
+
), T = K(
|
|
2230
2214
|
() => ({
|
|
2231
|
-
hasTenant: !!
|
|
2215
|
+
hasTenant: !!P,
|
|
2232
2216
|
isAuthenticated: R,
|
|
2233
|
-
userType:
|
|
2217
|
+
userType: D == null ? void 0 : D.userType,
|
|
2234
2218
|
permissions: E,
|
|
2235
|
-
isLoading:
|
|
2219
|
+
isLoading: N || u
|
|
2236
2220
|
}),
|
|
2237
2221
|
[
|
|
2238
|
-
|
|
2222
|
+
P,
|
|
2239
2223
|
R,
|
|
2240
|
-
|
|
2224
|
+
D == null ? void 0 : D.userType,
|
|
2241
2225
|
E,
|
|
2242
|
-
|
|
2243
|
-
|
|
2226
|
+
N,
|
|
2227
|
+
u
|
|
2244
2228
|
]
|
|
2245
|
-
),
|
|
2246
|
-
type:
|
|
2229
|
+
), $ = K(() => T.isLoading ? null : Ut(M, T), [M, T]), l = K(() => $ ? y || Ht(T, S.zoneRoots) : null, [$, y, T, S.zoneRoots]), U = K(() => !$ || !l ? null : {
|
|
2230
|
+
type: $,
|
|
2247
2231
|
required: {
|
|
2248
|
-
tenant:
|
|
2249
|
-
auth:
|
|
2250
|
-
userType:
|
|
2251
|
-
permissions:
|
|
2232
|
+
tenant: M.tenant,
|
|
2233
|
+
auth: M.auth,
|
|
2234
|
+
userType: M.userType,
|
|
2235
|
+
permissions: M.permissions
|
|
2252
2236
|
},
|
|
2253
2237
|
current: {
|
|
2254
|
-
hasTenant:
|
|
2255
|
-
isAuthenticated:
|
|
2256
|
-
userType:
|
|
2257
|
-
permissions:
|
|
2238
|
+
hasTenant: T.hasTenant,
|
|
2239
|
+
isAuthenticated: T.isAuthenticated,
|
|
2240
|
+
userType: T.userType,
|
|
2241
|
+
permissions: T.permissions
|
|
2258
2242
|
},
|
|
2259
2243
|
redirectTo: l
|
|
2260
|
-
}, [
|
|
2244
|
+
}, [$, l, M, T]);
|
|
2261
2245
|
if (re(() => {
|
|
2262
|
-
|
|
2263
|
-
}, [
|
|
2264
|
-
|
|
2246
|
+
U && (w ? w(U) : S.onAccessDenied && S.onAccessDenied(U));
|
|
2247
|
+
}, [U, w, S]), re(() => {
|
|
2248
|
+
U && p && Ot(p, h.pathname + h.search, S.returnToStorage);
|
|
2265
2249
|
}, [
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
]),
|
|
2272
|
-
return /* @__PURE__ */ s(_, { children:
|
|
2273
|
-
if (
|
|
2274
|
-
const
|
|
2275
|
-
if (
|
|
2276
|
-
return /* @__PURE__ */ s(_, { children:
|
|
2277
|
-
const
|
|
2250
|
+
U,
|
|
2251
|
+
p,
|
|
2252
|
+
h.pathname,
|
|
2253
|
+
h.search,
|
|
2254
|
+
S.returnToStorage
|
|
2255
|
+
]), T.isLoading)
|
|
2256
|
+
return /* @__PURE__ */ s(_, { children: f ?? S.loadingFallback ?? null });
|
|
2257
|
+
if (U && l) {
|
|
2258
|
+
const b = x ?? S.accessDeniedFallback;
|
|
2259
|
+
if (b)
|
|
2260
|
+
return /* @__PURE__ */ s(_, { children: b });
|
|
2261
|
+
const L = Bt(
|
|
2278
2262
|
l,
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2263
|
+
p,
|
|
2264
|
+
h.pathname + h.search,
|
|
2265
|
+
S.returnToParam,
|
|
2266
|
+
S.returnToStorage
|
|
2283
2267
|
);
|
|
2284
|
-
return /* @__PURE__ */ s(
|
|
2268
|
+
return /* @__PURE__ */ s(ve, { to: L, replace: !0 });
|
|
2285
2269
|
}
|
|
2286
2270
|
return /* @__PURE__ */ s(_, { children: n });
|
|
2287
|
-
},
|
|
2271
|
+
}, Mr = (n) => /* @__PURE__ */ s(ce, { tenant: "required", ...n }), Lr = (n) => /* @__PURE__ */ s(ce, { tenant: "forbidden", ...n }), Nr = (n) => /* @__PURE__ */ s(ce, { auth: "required", ...n }), Dr = (n) => /* @__PURE__ */ s(ce, { auth: "forbidden", ...n }), Fr = (n) => /* @__PURE__ */ s(ce, { auth: "required", userType: oe.TENANT_ADMIN, ...n }), Cr = (n) => /* @__PURE__ */ s(ce, { auth: "required", userType: oe.USER, ...n }), $r = (n) => /* @__PURE__ */ s(ce, { tenant: "optional", auth: "optional", ...n }), Ur = (n) => /* @__PURE__ */ s(ce, { tenant: "required", auth: "required", ...n }), Hr = (n) => /* @__PURE__ */ s(ce, { tenant: "required", auth: "optional", ...n }), Br = (n) => /* @__PURE__ */ s(ce, { tenant: "required", auth: "forbidden", ...n }), qt = () => /* @__PURE__ */ d(
|
|
2288
2272
|
"div",
|
|
2289
2273
|
{
|
|
2290
2274
|
style: {
|
|
@@ -2301,14 +2285,14 @@ const ce = ({
|
|
|
2301
2285
|
]
|
|
2302
2286
|
}
|
|
2303
2287
|
);
|
|
2304
|
-
function
|
|
2288
|
+
function Or({
|
|
2305
2289
|
children: n,
|
|
2306
|
-
fallback: e = /* @__PURE__ */ s(
|
|
2290
|
+
fallback: e = /* @__PURE__ */ s(qt, {}),
|
|
2307
2291
|
allowedPlans: t,
|
|
2308
2292
|
requiredFeature: r
|
|
2309
2293
|
}) {
|
|
2310
|
-
const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading:
|
|
2311
|
-
return
|
|
2294
|
+
const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: p } = It();
|
|
2295
|
+
return p ? /* @__PURE__ */ s(
|
|
2312
2296
|
"div",
|
|
2313
2297
|
{
|
|
2314
2298
|
style: {
|
|
@@ -2320,7 +2304,7 @@ function Br({
|
|
|
2320
2304
|
}
|
|
2321
2305
|
) : i ? i.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ s(_, { children: e }) : r && !a(r) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: n }) : /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: e });
|
|
2322
2306
|
}
|
|
2323
|
-
const zt = ({ flagName: n }) => /* @__PURE__ */
|
|
2307
|
+
const zt = ({ flagName: n }) => /* @__PURE__ */ d(
|
|
2324
2308
|
"div",
|
|
2325
2309
|
{
|
|
2326
2310
|
style: {
|
|
@@ -2339,7 +2323,7 @@ const zt = ({ flagName: n }) => /* @__PURE__ */ u(
|
|
|
2339
2323
|
children: [
|
|
2340
2324
|
/* @__PURE__ */ s("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
|
|
2341
2325
|
/* @__PURE__ */ s("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
|
|
2342
|
-
/* @__PURE__ */
|
|
2326
|
+
/* @__PURE__ */ d("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
|
|
2343
2327
|
'Feature flag "',
|
|
2344
2328
|
n,
|
|
2345
2329
|
'" is disabled'
|
|
@@ -2364,7 +2348,7 @@ function qr({ name: n, children: e, fallback: t }) {
|
|
|
2364
2348
|
}
|
|
2365
2349
|
) : r(n) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: t || /* @__PURE__ */ s(zt, { flagName: n }) });
|
|
2366
2350
|
}
|
|
2367
|
-
const _t = () => /* @__PURE__ */
|
|
2351
|
+
const _t = () => /* @__PURE__ */ d(
|
|
2368
2352
|
"svg",
|
|
2369
2353
|
{
|
|
2370
2354
|
width: "16",
|
|
@@ -2381,7 +2365,7 @@ const _t = () => /* @__PURE__ */ u(
|
|
|
2381
2365
|
/* @__PURE__ */ s("circle", { cx: "12", cy: "12", r: "3" })
|
|
2382
2366
|
]
|
|
2383
2367
|
}
|
|
2384
|
-
), Wt = () => /* @__PURE__ */
|
|
2368
|
+
), Wt = () => /* @__PURE__ */ d(
|
|
2385
2369
|
"svg",
|
|
2386
2370
|
{
|
|
2387
2371
|
width: "16",
|
|
@@ -2414,7 +2398,11 @@ const _t = () => /* @__PURE__ */ u(
|
|
|
2414
2398
|
magicLinkText: "Prefer passwordless?",
|
|
2415
2399
|
magicLinkLink: "Use Magic Link",
|
|
2416
2400
|
errorMessage: "Invalid credentials",
|
|
2417
|
-
loadingText: "Signing in..."
|
|
2401
|
+
loadingText: "Signing in...",
|
|
2402
|
+
tenantNotFoundError: "Tenant not found",
|
|
2403
|
+
dividerBullet: "•",
|
|
2404
|
+
showPasswordAriaLabel: "Show password",
|
|
2405
|
+
hidePasswordAriaLabel: "Hide password"
|
|
2418
2406
|
}, Gt = {
|
|
2419
2407
|
container: {
|
|
2420
2408
|
maxWidth: "400px",
|
|
@@ -2520,9 +2508,12 @@ const _t = () => /* @__PURE__ */ u(
|
|
|
2520
2508
|
margin: "0.5rem 0",
|
|
2521
2509
|
color: "#6b7280",
|
|
2522
2510
|
fontSize: "0.875rem"
|
|
2511
|
+
},
|
|
2512
|
+
inputWithIcon: {
|
|
2513
|
+
paddingRight: "2.5rem"
|
|
2523
2514
|
}
|
|
2524
2515
|
};
|
|
2525
|
-
function
|
|
2516
|
+
function zr({
|
|
2526
2517
|
copy: n = {},
|
|
2527
2518
|
styles: e = {},
|
|
2528
2519
|
icons: t = {},
|
|
@@ -2530,120 +2521,119 @@ function Or({
|
|
|
2530
2521
|
onError: i,
|
|
2531
2522
|
onForgotPassword: o,
|
|
2532
2523
|
onSignupClick: a,
|
|
2533
|
-
onMagicLinkClick:
|
|
2534
|
-
showForgotPassword:
|
|
2535
|
-
showSignupLink:
|
|
2536
|
-
showMagicLinkOption:
|
|
2537
|
-
className:
|
|
2524
|
+
onMagicLinkClick: p,
|
|
2525
|
+
showForgotPassword: w = !0,
|
|
2526
|
+
showSignupLink: y = !0,
|
|
2527
|
+
showMagicLinkOption: f = !0,
|
|
2528
|
+
className: x
|
|
2538
2529
|
}) {
|
|
2539
|
-
const [
|
|
2540
|
-
const
|
|
2541
|
-
return
|
|
2542
|
-
},
|
|
2543
|
-
if (
|
|
2544
|
-
if (!(
|
|
2545
|
-
|
|
2530
|
+
const [h, R] = k(""), [N, D] = k(""), [E, P] = k(!1), [u, S] = k(!1), [C, M] = k(""), [T, $] = k({}), { login: l } = ue(), { tenant: U } = me(), b = { ...jt, ...n }, L = { ...Gt, ...e }, F = { ...Vt, ...t }, c = () => {
|
|
2531
|
+
const m = {};
|
|
2532
|
+
return h.trim() || (m.username = !0), N.trim() || (m.password = !0), $(m), Object.keys(m).length === 0;
|
|
2533
|
+
}, H = async (m) => {
|
|
2534
|
+
if (m.preventDefault(), !!c()) {
|
|
2535
|
+
if (!(U != null && U.id)) {
|
|
2536
|
+
M(b.tenantNotFoundError);
|
|
2546
2537
|
return;
|
|
2547
2538
|
}
|
|
2548
|
-
|
|
2539
|
+
S(!0), M("");
|
|
2549
2540
|
try {
|
|
2550
|
-
const
|
|
2551
|
-
username:
|
|
2552
|
-
password:
|
|
2541
|
+
const v = await l({
|
|
2542
|
+
username: h,
|
|
2543
|
+
password: N
|
|
2553
2544
|
// tenantId inferred from context automatically
|
|
2554
2545
|
});
|
|
2555
|
-
r == null || r(
|
|
2556
|
-
} catch (
|
|
2557
|
-
const Q =
|
|
2558
|
-
|
|
2546
|
+
r == null || r(v);
|
|
2547
|
+
} catch (v) {
|
|
2548
|
+
const Q = v.message || b.errorMessage;
|
|
2549
|
+
M(Q), i == null || i(Q);
|
|
2559
2550
|
} finally {
|
|
2560
|
-
|
|
2551
|
+
S(!1);
|
|
2561
2552
|
}
|
|
2562
2553
|
}
|
|
2563
|
-
},
|
|
2564
|
-
...
|
|
2565
|
-
...
|
|
2566
|
-
}),
|
|
2567
|
-
...
|
|
2568
|
-
...
|
|
2569
|
-
...!
|
|
2554
|
+
}, I = (m) => ({
|
|
2555
|
+
...L.input,
|
|
2556
|
+
...T[m] ? L.inputError : {}
|
|
2557
|
+
}), g = () => ({
|
|
2558
|
+
...L.button,
|
|
2559
|
+
...u ? L.buttonLoading : {},
|
|
2560
|
+
...!h || !N || u ? L.buttonDisabled : {}
|
|
2570
2561
|
});
|
|
2571
|
-
return /* @__PURE__ */
|
|
2572
|
-
/* @__PURE__ */ s("h2", { style:
|
|
2573
|
-
/* @__PURE__ */
|
|
2574
|
-
/* @__PURE__ */
|
|
2575
|
-
/* @__PURE__ */ s("label", { style:
|
|
2562
|
+
return /* @__PURE__ */ d("div", { className: x, style: L.container, children: [
|
|
2563
|
+
/* @__PURE__ */ s("h2", { style: L.title, children: b.title }),
|
|
2564
|
+
/* @__PURE__ */ d("form", { onSubmit: H, style: L.form, children: [
|
|
2565
|
+
/* @__PURE__ */ d("div", { style: L.fieldGroup, children: [
|
|
2566
|
+
/* @__PURE__ */ s("label", { style: L.label, children: b.usernameLabel }),
|
|
2576
2567
|
/* @__PURE__ */ s(
|
|
2577
2568
|
"input",
|
|
2578
2569
|
{
|
|
2579
2570
|
id: "username",
|
|
2580
2571
|
name: "username",
|
|
2581
2572
|
type: "text",
|
|
2582
|
-
value:
|
|
2583
|
-
onChange: (
|
|
2584
|
-
R(
|
|
2573
|
+
value: h,
|
|
2574
|
+
onChange: (m) => {
|
|
2575
|
+
R(m.target.value), T.username && $((v) => ({ ...v, username: !1 }));
|
|
2585
2576
|
},
|
|
2586
|
-
placeholder:
|
|
2587
|
-
style:
|
|
2588
|
-
disabled:
|
|
2577
|
+
placeholder: b.usernamePlaceholder,
|
|
2578
|
+
style: I("username"),
|
|
2579
|
+
disabled: u
|
|
2589
2580
|
}
|
|
2590
2581
|
)
|
|
2591
2582
|
] }),
|
|
2592
|
-
/* @__PURE__ */
|
|
2593
|
-
/* @__PURE__ */ s("label", { style:
|
|
2594
|
-
/* @__PURE__ */
|
|
2583
|
+
/* @__PURE__ */ d("div", { style: L.fieldGroup, children: [
|
|
2584
|
+
/* @__PURE__ */ s("label", { style: L.label, children: b.passwordLabel }),
|
|
2585
|
+
/* @__PURE__ */ d("div", { style: L.inputContainer, children: [
|
|
2595
2586
|
/* @__PURE__ */ s(
|
|
2596
2587
|
"input",
|
|
2597
2588
|
{
|
|
2598
2589
|
id: "password",
|
|
2599
2590
|
name: "password",
|
|
2600
2591
|
type: E ? "text" : "password",
|
|
2601
|
-
value:
|
|
2602
|
-
onChange: (
|
|
2603
|
-
|
|
2592
|
+
value: N,
|
|
2593
|
+
onChange: (m) => {
|
|
2594
|
+
D(m.target.value), T.password && $((v) => ({ ...v, password: !1 }));
|
|
2604
2595
|
},
|
|
2605
|
-
placeholder:
|
|
2596
|
+
placeholder: b.passwordPlaceholder,
|
|
2606
2597
|
style: {
|
|
2607
|
-
...
|
|
2608
|
-
|
|
2609
|
-
// Make room for the icon
|
|
2598
|
+
...I("password"),
|
|
2599
|
+
...L.inputWithIcon
|
|
2610
2600
|
},
|
|
2611
|
-
disabled:
|
|
2601
|
+
disabled: u
|
|
2612
2602
|
}
|
|
2613
2603
|
),
|
|
2614
2604
|
/* @__PURE__ */ s(
|
|
2615
2605
|
"button",
|
|
2616
2606
|
{
|
|
2617
2607
|
type: "button",
|
|
2618
|
-
onClick: () =>
|
|
2619
|
-
style:
|
|
2620
|
-
disabled:
|
|
2621
|
-
"aria-label": E ?
|
|
2622
|
-
children: E ?
|
|
2608
|
+
onClick: () => P(!E),
|
|
2609
|
+
style: L.passwordToggle,
|
|
2610
|
+
disabled: u,
|
|
2611
|
+
"aria-label": E ? b.hidePasswordAriaLabel : b.showPasswordAriaLabel,
|
|
2612
|
+
children: E ? F.hidePassword : F.showPassword
|
|
2623
2613
|
}
|
|
2624
2614
|
)
|
|
2625
2615
|
] })
|
|
2626
2616
|
] }),
|
|
2627
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: !
|
|
2628
|
-
|
|
2617
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !h || !N || u, style: g(), children: u ? b.loadingText : b.submitButton }),
|
|
2618
|
+
C && /* @__PURE__ */ s("div", { style: L.errorText, children: C })
|
|
2629
2619
|
] }),
|
|
2630
|
-
(
|
|
2631
|
-
|
|
2632
|
-
/* @__PURE__ */
|
|
2633
|
-
|
|
2620
|
+
(w || y || f) && /* @__PURE__ */ d("div", { style: L.linkContainer, children: [
|
|
2621
|
+
f && /* @__PURE__ */ d("div", { children: [
|
|
2622
|
+
/* @__PURE__ */ d("span", { style: L.divider, children: [
|
|
2623
|
+
b.magicLinkText,
|
|
2634
2624
|
" "
|
|
2635
2625
|
] }),
|
|
2636
|
-
/* @__PURE__ */ s("a", { onClick:
|
|
2626
|
+
/* @__PURE__ */ s("a", { onClick: p, style: L.link, children: b.magicLinkLink })
|
|
2637
2627
|
] }),
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
/* @__PURE__ */
|
|
2643
|
-
|
|
2628
|
+
f && (w || y) && /* @__PURE__ */ s("div", { style: L.divider, children: b.dividerBullet }),
|
|
2629
|
+
w && /* @__PURE__ */ s("a", { onClick: o, style: L.link, children: b.forgotPasswordLink }),
|
|
2630
|
+
w && y && /* @__PURE__ */ s("div", { style: L.divider, children: b.dividerBullet }),
|
|
2631
|
+
y && /* @__PURE__ */ d("div", { children: [
|
|
2632
|
+
/* @__PURE__ */ d("span", { style: L.divider, children: [
|
|
2633
|
+
b.signupText,
|
|
2644
2634
|
" "
|
|
2645
2635
|
] }),
|
|
2646
|
-
/* @__PURE__ */ s("a", { onClick: a, style:
|
|
2636
|
+
/* @__PURE__ */ s("a", { onClick: a, style: L.link, children: b.signupLink })
|
|
2647
2637
|
] })
|
|
2648
2638
|
] })
|
|
2649
2639
|
] });
|
|
@@ -2673,7 +2663,10 @@ const Qt = {
|
|
|
2673
2663
|
loadingText: "Creating account...",
|
|
2674
2664
|
passwordMismatchError: "Passwords do not match",
|
|
2675
2665
|
isAdminLabel: "Create new organization",
|
|
2676
|
-
isAdminDescription: "Check this if you want to create a new organization"
|
|
2666
|
+
isAdminDescription: "Check this if you want to create a new organization",
|
|
2667
|
+
contactMethodHint: "At least one contact method (email or phone) is required",
|
|
2668
|
+
tenantNotFoundError: "Tenant not found",
|
|
2669
|
+
dividerBullet: "•"
|
|
2677
2670
|
}, Kt = {
|
|
2678
2671
|
container: {
|
|
2679
2672
|
maxWidth: "400px",
|
|
@@ -2771,9 +2764,15 @@ const Qt = {
|
|
|
2771
2764
|
margin: "0.5rem 0",
|
|
2772
2765
|
color: "#6b7280",
|
|
2773
2766
|
fontSize: "0.875rem"
|
|
2767
|
+
},
|
|
2768
|
+
hintText: {
|
|
2769
|
+
fontSize: "0.875rem",
|
|
2770
|
+
color: "#6b7280",
|
|
2771
|
+
textAlign: "center",
|
|
2772
|
+
margin: "0.5rem 0"
|
|
2774
2773
|
}
|
|
2775
2774
|
};
|
|
2776
|
-
function
|
|
2775
|
+
function _r({
|
|
2777
2776
|
copy: n = {},
|
|
2778
2777
|
styles: e = {},
|
|
2779
2778
|
signupType: t = "user",
|
|
@@ -2781,113 +2780,113 @@ function zr({
|
|
|
2781
2780
|
onError: i,
|
|
2782
2781
|
onLoginClick: o,
|
|
2783
2782
|
onMagicLinkClick: a,
|
|
2784
|
-
showLoginLink:
|
|
2785
|
-
showMagicLinkOption:
|
|
2786
|
-
className:
|
|
2783
|
+
showLoginLink: p = !0,
|
|
2784
|
+
showMagicLinkOption: w = !0,
|
|
2785
|
+
className: y
|
|
2787
2786
|
}) {
|
|
2788
|
-
const [
|
|
2789
|
-
const
|
|
2790
|
-
return
|
|
2791
|
-
}, J = async (
|
|
2792
|
-
if (
|
|
2793
|
-
if (
|
|
2794
|
-
|
|
2787
|
+
const [f, x] = k(""), [h, R] = k(""), [N, D] = k(""), [E, P] = k(""), [u, S] = k(""), [C, M] = k(""), [T, $] = k(""), [l, U] = k(!1), [b, L] = k(""), [F, c] = k({}), { signup: H, signupTenantAdmin: I } = ue(), { tenant: g } = me(), m = { ...Qt, ...n }, v = { ...Kt, ...e }, Q = () => {
|
|
2788
|
+
const A = {};
|
|
2789
|
+
return f.trim() || (A.name = !0), !N.trim() && !E.trim() && (A.email = !0, A.phoneNumber = !0), u.trim() || (A.password = !0), C.trim() || (A.confirmPassword = !0), t === "tenant" && !T.trim() && (A.tenantName = !0), c(A), Object.keys(A).length === 0;
|
|
2790
|
+
}, J = async (A) => {
|
|
2791
|
+
if (A.preventDefault(), !!Q()) {
|
|
2792
|
+
if (u !== C) {
|
|
2793
|
+
L(m.passwordMismatchError), c({ confirmPassword: !0 });
|
|
2795
2794
|
return;
|
|
2796
2795
|
}
|
|
2797
|
-
if (t === "user" && !(
|
|
2798
|
-
|
|
2796
|
+
if (t === "user" && !(g != null && g.id)) {
|
|
2797
|
+
L(m.tenantNotFoundError);
|
|
2799
2798
|
return;
|
|
2800
2799
|
}
|
|
2801
|
-
|
|
2800
|
+
U(!0), L("");
|
|
2802
2801
|
try {
|
|
2803
2802
|
let V;
|
|
2804
|
-
t === "tenant" ? V = await
|
|
2805
|
-
email:
|
|
2803
|
+
t === "tenant" ? V = await I({
|
|
2804
|
+
email: N || void 0,
|
|
2806
2805
|
phoneNumber: E || void 0,
|
|
2807
|
-
name:
|
|
2808
|
-
password:
|
|
2809
|
-
tenantName:
|
|
2810
|
-
lastName:
|
|
2811
|
-
}) : V = await
|
|
2812
|
-
email:
|
|
2806
|
+
name: f,
|
|
2807
|
+
password: u,
|
|
2808
|
+
tenantName: T,
|
|
2809
|
+
lastName: h || void 0
|
|
2810
|
+
}) : V = await H({
|
|
2811
|
+
email: N || void 0,
|
|
2813
2812
|
phoneNumber: E || void 0,
|
|
2814
|
-
name:
|
|
2815
|
-
password:
|
|
2816
|
-
tenantId:
|
|
2817
|
-
lastName:
|
|
2813
|
+
name: f,
|
|
2814
|
+
password: u,
|
|
2815
|
+
tenantId: g.id,
|
|
2816
|
+
lastName: h || void 0
|
|
2818
2817
|
}), r == null || r(V);
|
|
2819
2818
|
} catch (V) {
|
|
2820
|
-
const de = V.message ||
|
|
2821
|
-
|
|
2819
|
+
const de = V.message || m.errorMessage;
|
|
2820
|
+
L(de), i == null || i(de);
|
|
2822
2821
|
} finally {
|
|
2823
|
-
|
|
2822
|
+
U(!1);
|
|
2824
2823
|
}
|
|
2825
2824
|
}
|
|
2826
|
-
},
|
|
2827
|
-
...
|
|
2828
|
-
...
|
|
2829
|
-
}),
|
|
2830
|
-
...
|
|
2831
|
-
...l ?
|
|
2832
|
-
...!
|
|
2833
|
-
}), j =
|
|
2834
|
-
return /* @__PURE__ */
|
|
2835
|
-
/* @__PURE__ */ s("h2", { style:
|
|
2836
|
-
/* @__PURE__ */
|
|
2837
|
-
/* @__PURE__ */
|
|
2838
|
-
/* @__PURE__ */ s("label", { style:
|
|
2825
|
+
}, O = (A) => ({
|
|
2826
|
+
...v.input,
|
|
2827
|
+
...F[A] ? v.inputError : {}
|
|
2828
|
+
}), q = () => ({
|
|
2829
|
+
...v.button,
|
|
2830
|
+
...l ? v.buttonLoading : {},
|
|
2831
|
+
...!f || !N && !E || !u || !C || l || t === "tenant" && !T ? v.buttonDisabled : {}
|
|
2832
|
+
}), j = f && (N || E) && u && C && (t === "user" || T);
|
|
2833
|
+
return /* @__PURE__ */ d("div", { className: y, style: v.container, children: [
|
|
2834
|
+
/* @__PURE__ */ s("h2", { style: v.title, children: m.title }),
|
|
2835
|
+
/* @__PURE__ */ d("form", { onSubmit: J, style: v.form, children: [
|
|
2836
|
+
/* @__PURE__ */ d("div", { style: v.fieldGroup, children: [
|
|
2837
|
+
/* @__PURE__ */ s("label", { style: v.label, children: m.nameLabel }),
|
|
2839
2838
|
/* @__PURE__ */ s(
|
|
2840
2839
|
"input",
|
|
2841
2840
|
{
|
|
2842
2841
|
id: "name",
|
|
2843
2842
|
name: "name",
|
|
2844
2843
|
type: "text",
|
|
2845
|
-
value:
|
|
2846
|
-
onChange: (
|
|
2847
|
-
|
|
2844
|
+
value: f,
|
|
2845
|
+
onChange: (A) => {
|
|
2846
|
+
x(A.target.value), F.name && c((V) => ({ ...V, name: !1 }));
|
|
2848
2847
|
},
|
|
2849
|
-
placeholder:
|
|
2850
|
-
style:
|
|
2848
|
+
placeholder: m.namePlaceholder,
|
|
2849
|
+
style: O("name"),
|
|
2851
2850
|
disabled: l
|
|
2852
2851
|
}
|
|
2853
2852
|
)
|
|
2854
2853
|
] }),
|
|
2855
|
-
/* @__PURE__ */
|
|
2856
|
-
/* @__PURE__ */ s("label", { style:
|
|
2854
|
+
/* @__PURE__ */ d("div", { style: v.fieldGroup, children: [
|
|
2855
|
+
/* @__PURE__ */ s("label", { style: v.label, children: m.lastNameLabel }),
|
|
2857
2856
|
/* @__PURE__ */ s(
|
|
2858
2857
|
"input",
|
|
2859
2858
|
{
|
|
2860
2859
|
id: "lastName",
|
|
2861
2860
|
name: "lastName",
|
|
2862
2861
|
type: "text",
|
|
2863
|
-
value:
|
|
2864
|
-
onChange: (
|
|
2865
|
-
placeholder:
|
|
2866
|
-
style:
|
|
2862
|
+
value: h,
|
|
2863
|
+
onChange: (A) => R(A.target.value),
|
|
2864
|
+
placeholder: m.lastNamePlaceholder,
|
|
2865
|
+
style: v.input,
|
|
2867
2866
|
disabled: l
|
|
2868
2867
|
}
|
|
2869
2868
|
)
|
|
2870
2869
|
] }),
|
|
2871
|
-
/* @__PURE__ */
|
|
2872
|
-
/* @__PURE__ */ s("label", { style:
|
|
2870
|
+
/* @__PURE__ */ d("div", { style: v.fieldGroup, children: [
|
|
2871
|
+
/* @__PURE__ */ s("label", { style: v.label, children: m.emailLabel }),
|
|
2873
2872
|
/* @__PURE__ */ s(
|
|
2874
2873
|
"input",
|
|
2875
2874
|
{
|
|
2876
2875
|
id: "email",
|
|
2877
2876
|
name: "email",
|
|
2878
2877
|
type: "email",
|
|
2879
|
-
value:
|
|
2880
|
-
onChange: (
|
|
2881
|
-
|
|
2878
|
+
value: N,
|
|
2879
|
+
onChange: (A) => {
|
|
2880
|
+
D(A.target.value), F.email && c((V) => ({ ...V, email: !1, phoneNumber: !1 }));
|
|
2882
2881
|
},
|
|
2883
|
-
placeholder:
|
|
2884
|
-
style:
|
|
2882
|
+
placeholder: m.emailPlaceholder,
|
|
2883
|
+
style: O("email"),
|
|
2885
2884
|
disabled: l
|
|
2886
2885
|
}
|
|
2887
2886
|
)
|
|
2888
2887
|
] }),
|
|
2889
|
-
/* @__PURE__ */
|
|
2890
|
-
/* @__PURE__ */ s("label", { style:
|
|
2888
|
+
/* @__PURE__ */ d("div", { style: v.fieldGroup, children: [
|
|
2889
|
+
/* @__PURE__ */ s("label", { style: v.label, children: m.phoneNumberLabel }),
|
|
2891
2890
|
/* @__PURE__ */ s(
|
|
2892
2891
|
"input",
|
|
2893
2892
|
{
|
|
@@ -2895,99 +2894,88 @@ function zr({
|
|
|
2895
2894
|
name: "phoneNumber",
|
|
2896
2895
|
type: "tel",
|
|
2897
2896
|
value: E,
|
|
2898
|
-
onChange: (
|
|
2899
|
-
|
|
2897
|
+
onChange: (A) => {
|
|
2898
|
+
P(A.target.value), F.phoneNumber && c((V) => ({ ...V, email: !1, phoneNumber: !1 }));
|
|
2900
2899
|
},
|
|
2901
|
-
placeholder:
|
|
2902
|
-
style:
|
|
2900
|
+
placeholder: m.phoneNumberPlaceholder,
|
|
2901
|
+
style: O("phoneNumber"),
|
|
2903
2902
|
disabled: l
|
|
2904
2903
|
}
|
|
2905
2904
|
)
|
|
2906
2905
|
] }),
|
|
2907
|
-
/* @__PURE__ */ s(
|
|
2908
|
-
|
|
2909
|
-
{
|
|
2910
|
-
style: {
|
|
2911
|
-
fontSize: "0.875rem",
|
|
2912
|
-
color: "#6b7280",
|
|
2913
|
-
textAlign: "center",
|
|
2914
|
-
margin: "0.5rem 0"
|
|
2915
|
-
},
|
|
2916
|
-
children: "At least one contact method (email or phone) is required"
|
|
2917
|
-
}
|
|
2918
|
-
),
|
|
2919
|
-
/* @__PURE__ */ u("div", { style: S.fieldGroup, children: [
|
|
2920
|
-
/* @__PURE__ */ s("label", { style: S.label, children: g.passwordLabel }),
|
|
2906
|
+
/* @__PURE__ */ s("div", { style: v.hintText, children: m.contactMethodHint }),
|
|
2907
|
+
/* @__PURE__ */ d("div", { style: v.fieldGroup, children: [
|
|
2908
|
+
/* @__PURE__ */ s("label", { style: v.label, children: m.passwordLabel }),
|
|
2921
2909
|
/* @__PURE__ */ s(
|
|
2922
2910
|
"input",
|
|
2923
2911
|
{
|
|
2924
2912
|
id: "password",
|
|
2925
2913
|
name: "password",
|
|
2926
2914
|
type: "password",
|
|
2927
|
-
value:
|
|
2928
|
-
onChange: (
|
|
2929
|
-
A
|
|
2915
|
+
value: u,
|
|
2916
|
+
onChange: (A) => {
|
|
2917
|
+
S(A.target.value), F.password && c((V) => ({ ...V, password: !1 }));
|
|
2930
2918
|
},
|
|
2931
|
-
placeholder:
|
|
2932
|
-
style:
|
|
2919
|
+
placeholder: m.passwordPlaceholder,
|
|
2920
|
+
style: O("password"),
|
|
2933
2921
|
disabled: l
|
|
2934
2922
|
}
|
|
2935
2923
|
)
|
|
2936
2924
|
] }),
|
|
2937
|
-
/* @__PURE__ */
|
|
2938
|
-
/* @__PURE__ */ s("label", { style:
|
|
2925
|
+
/* @__PURE__ */ d("div", { style: v.fieldGroup, children: [
|
|
2926
|
+
/* @__PURE__ */ s("label", { style: v.label, children: m.confirmPasswordLabel }),
|
|
2939
2927
|
/* @__PURE__ */ s(
|
|
2940
2928
|
"input",
|
|
2941
2929
|
{
|
|
2942
2930
|
id: "confirmPassword",
|
|
2943
2931
|
name: "confirmPassword",
|
|
2944
2932
|
type: "password",
|
|
2945
|
-
value:
|
|
2946
|
-
onChange: (
|
|
2947
|
-
|
|
2933
|
+
value: C,
|
|
2934
|
+
onChange: (A) => {
|
|
2935
|
+
M(A.target.value), F.confirmPassword && c((V) => ({ ...V, confirmPassword: !1 })), b === m.passwordMismatchError && L("");
|
|
2948
2936
|
},
|
|
2949
|
-
placeholder:
|
|
2950
|
-
style:
|
|
2937
|
+
placeholder: m.confirmPasswordPlaceholder,
|
|
2938
|
+
style: O("confirmPassword"),
|
|
2951
2939
|
disabled: l
|
|
2952
2940
|
}
|
|
2953
2941
|
)
|
|
2954
2942
|
] }),
|
|
2955
|
-
t === "tenant" && /* @__PURE__ */
|
|
2956
|
-
/* @__PURE__ */ s("label", { style:
|
|
2943
|
+
t === "tenant" && /* @__PURE__ */ d("div", { style: v.fieldGroup, children: [
|
|
2944
|
+
/* @__PURE__ */ s("label", { style: v.label, children: m.tenantNameLabel }),
|
|
2957
2945
|
/* @__PURE__ */ s(
|
|
2958
2946
|
"input",
|
|
2959
2947
|
{
|
|
2960
2948
|
id: "tenantName",
|
|
2961
2949
|
name: "tenantName",
|
|
2962
2950
|
type: "text",
|
|
2963
|
-
value:
|
|
2964
|
-
onChange: (
|
|
2965
|
-
|
|
2951
|
+
value: T,
|
|
2952
|
+
onChange: (A) => {
|
|
2953
|
+
$(A.target.value), F.tenantName && c((V) => ({ ...V, tenantName: !1 }));
|
|
2966
2954
|
},
|
|
2967
|
-
placeholder:
|
|
2968
|
-
style:
|
|
2955
|
+
placeholder: m.tenantNamePlaceholder,
|
|
2956
|
+
style: O("tenantName"),
|
|
2969
2957
|
disabled: l
|
|
2970
2958
|
}
|
|
2971
2959
|
)
|
|
2972
2960
|
] }),
|
|
2973
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: !j || l, style:
|
|
2974
|
-
|
|
2961
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !j || l, style: q(), children: l ? m.loadingText : m.submitButton }),
|
|
2962
|
+
b && /* @__PURE__ */ s("div", { style: v.errorText, children: b })
|
|
2975
2963
|
] }),
|
|
2976
|
-
(
|
|
2977
|
-
|
|
2978
|
-
/* @__PURE__ */
|
|
2979
|
-
|
|
2964
|
+
(p || w) && /* @__PURE__ */ d("div", { style: v.linkContainer, children: [
|
|
2965
|
+
w && /* @__PURE__ */ d("div", { children: [
|
|
2966
|
+
/* @__PURE__ */ d("span", { style: v.divider, children: [
|
|
2967
|
+
m.magicLinkText,
|
|
2980
2968
|
" "
|
|
2981
2969
|
] }),
|
|
2982
|
-
/* @__PURE__ */ s("a", { onClick: a, style:
|
|
2970
|
+
/* @__PURE__ */ s("a", { onClick: a, style: v.link, children: m.magicLinkLink })
|
|
2983
2971
|
] }),
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
/* @__PURE__ */
|
|
2987
|
-
|
|
2972
|
+
w && p && /* @__PURE__ */ s("div", { style: v.divider, children: m.dividerBullet }),
|
|
2973
|
+
p && /* @__PURE__ */ d("div", { children: [
|
|
2974
|
+
/* @__PURE__ */ d("span", { style: v.divider, children: [
|
|
2975
|
+
m.loginText,
|
|
2988
2976
|
" "
|
|
2989
2977
|
] }),
|
|
2990
|
-
/* @__PURE__ */ s("a", { onClick: o, style:
|
|
2978
|
+
/* @__PURE__ */ s("a", { onClick: o, style: v.link, children: m.loginLink })
|
|
2991
2979
|
] })
|
|
2992
2980
|
] })
|
|
2993
2981
|
] });
|
|
@@ -3009,7 +2997,13 @@ const Zt = {
|
|
|
3009
2997
|
errorMessage: "Failed to send magic link. Please try again.",
|
|
3010
2998
|
loadingText: "Sending magic link...",
|
|
3011
2999
|
verifyingText: "Verifying magic link...",
|
|
3012
|
-
|
|
3000
|
+
verifyingDescription: "Please wait while we verify your magic link...",
|
|
3001
|
+
description: "Enter your email to receive a magic link. If you don't have an account, we'll create one for you.",
|
|
3002
|
+
showNameToggle: "New user? Add your name",
|
|
3003
|
+
hideNameToggle: "Existing user? Hide name fields",
|
|
3004
|
+
tenantNotFoundError: "Tenant not found",
|
|
3005
|
+
missingTenantOrEmailError: "Missing tenant or email",
|
|
3006
|
+
dividerBullet: "•"
|
|
3013
3007
|
}, Jt = {
|
|
3014
3008
|
container: {
|
|
3015
3009
|
maxWidth: "400px",
|
|
@@ -3111,9 +3105,29 @@ const Zt = {
|
|
|
3111
3105
|
margin: "0.5rem 0",
|
|
3112
3106
|
color: "#6b7280",
|
|
3113
3107
|
fontSize: "0.875rem"
|
|
3108
|
+
},
|
|
3109
|
+
verifyingContainer: {
|
|
3110
|
+
textAlign: "center",
|
|
3111
|
+
padding: "2rem"
|
|
3112
|
+
},
|
|
3113
|
+
verifyingText: {
|
|
3114
|
+
fontSize: "1rem",
|
|
3115
|
+
color: "#6b7280"
|
|
3116
|
+
},
|
|
3117
|
+
toggleContainer: {
|
|
3118
|
+
textAlign: "center",
|
|
3119
|
+
marginTop: "0.5rem"
|
|
3120
|
+
},
|
|
3121
|
+
toggleLink: {
|
|
3122
|
+
background: "none",
|
|
3123
|
+
border: "none",
|
|
3124
|
+
color: "#3b82f6",
|
|
3125
|
+
fontSize: "0.875rem",
|
|
3126
|
+
cursor: "pointer",
|
|
3127
|
+
textDecoration: "underline"
|
|
3114
3128
|
}
|
|
3115
3129
|
};
|
|
3116
|
-
function
|
|
3130
|
+
function Wr({
|
|
3117
3131
|
copy: n = {},
|
|
3118
3132
|
styles: e = {},
|
|
3119
3133
|
onSuccess: t,
|
|
@@ -3121,181 +3135,167 @@ function _r({
|
|
|
3121
3135
|
onLoginClick: i,
|
|
3122
3136
|
onSignupClick: o,
|
|
3123
3137
|
showTraditionalLinks: a = !0,
|
|
3124
|
-
className:
|
|
3125
|
-
verifyToken:
|
|
3126
|
-
frontendUrl:
|
|
3138
|
+
className: p,
|
|
3139
|
+
verifyToken: w,
|
|
3140
|
+
frontendUrl: y
|
|
3127
3141
|
}) {
|
|
3128
|
-
const [
|
|
3142
|
+
const [f, x] = k(""), [h, R] = k(""), [N, D] = k(""), [E, P] = k(!1), [u, S] = k(!1), [C, M] = k(""), [T, $] = k(""), [l, U] = k({}), [b, L] = k(!1), { sendMagicLink: F, verifyMagicLink: c } = ue(), { tenant: H } = me(), I = { ...Zt, ...n }, g = { ...Jt, ...e };
|
|
3129
3143
|
re(() => {
|
|
3130
|
-
|
|
3131
|
-
}, [
|
|
3132
|
-
const
|
|
3133
|
-
if (!
|
|
3134
|
-
|
|
3144
|
+
w && m(w);
|
|
3145
|
+
}, [w]);
|
|
3146
|
+
const m = async (q) => {
|
|
3147
|
+
if (!H || !f) {
|
|
3148
|
+
M(I.missingTenantOrEmailError);
|
|
3135
3149
|
return;
|
|
3136
3150
|
}
|
|
3137
|
-
|
|
3151
|
+
S(!0), M("");
|
|
3138
3152
|
try {
|
|
3139
|
-
const j = await
|
|
3140
|
-
token:
|
|
3141
|
-
email:
|
|
3153
|
+
const j = await c({
|
|
3154
|
+
token: q,
|
|
3155
|
+
email: f
|
|
3142
3156
|
// tenantId inferred from context automatically
|
|
3143
3157
|
});
|
|
3144
3158
|
t == null || t(j);
|
|
3145
3159
|
} catch (j) {
|
|
3146
|
-
const
|
|
3147
|
-
|
|
3160
|
+
const A = j.message || "Failed to verify magic link";
|
|
3161
|
+
M(A), r == null || r(A);
|
|
3148
3162
|
} finally {
|
|
3149
|
-
|
|
3163
|
+
S(!1);
|
|
3150
3164
|
}
|
|
3151
|
-
},
|
|
3152
|
-
const
|
|
3153
|
-
return
|
|
3154
|
-
}, Q = async (
|
|
3155
|
-
if (
|
|
3156
|
-
if (!(
|
|
3157
|
-
|
|
3165
|
+
}, v = () => {
|
|
3166
|
+
const q = {};
|
|
3167
|
+
return f.trim() || (q.email = !0), b && !h.trim() && (q.name = !0), U(q), Object.keys(q).length === 0;
|
|
3168
|
+
}, Q = async (q) => {
|
|
3169
|
+
if (q.preventDefault(), !!v()) {
|
|
3170
|
+
if (!(H != null && H.id)) {
|
|
3171
|
+
M(I.tenantNotFoundError);
|
|
3158
3172
|
return;
|
|
3159
3173
|
}
|
|
3160
|
-
|
|
3174
|
+
P(!0), M(""), $("");
|
|
3161
3175
|
try {
|
|
3162
|
-
const j =
|
|
3163
|
-
email:
|
|
3164
|
-
tenantId:
|
|
3176
|
+
const j = y || (typeof window < "u" ? window.location.origin : ""), A = await F({
|
|
3177
|
+
email: f,
|
|
3178
|
+
tenantId: H.id,
|
|
3165
3179
|
frontendUrl: j,
|
|
3166
|
-
name:
|
|
3167
|
-
lastName:
|
|
3180
|
+
name: b ? h : void 0,
|
|
3181
|
+
lastName: b ? N : void 0
|
|
3168
3182
|
});
|
|
3169
|
-
|
|
3183
|
+
$(I.successMessage), t == null || t(A);
|
|
3170
3184
|
} catch (j) {
|
|
3171
|
-
const
|
|
3172
|
-
|
|
3185
|
+
const A = j.message || I.errorMessage;
|
|
3186
|
+
M(A), r == null || r(A);
|
|
3173
3187
|
} finally {
|
|
3174
|
-
|
|
3188
|
+
P(!1);
|
|
3175
3189
|
}
|
|
3176
3190
|
}
|
|
3177
|
-
}, J = (
|
|
3178
|
-
...
|
|
3179
|
-
...l[
|
|
3180
|
-
}),
|
|
3181
|
-
...
|
|
3182
|
-
...E ||
|
|
3183
|
-
...!
|
|
3191
|
+
}, J = (q) => ({
|
|
3192
|
+
...g.input,
|
|
3193
|
+
...l[q] ? g.inputError : {}
|
|
3194
|
+
}), O = () => ({
|
|
3195
|
+
...g.button,
|
|
3196
|
+
...E || u ? g.buttonLoading : {},
|
|
3197
|
+
...!f || E || u ? g.buttonDisabled : {}
|
|
3184
3198
|
});
|
|
3185
|
-
return
|
|
3186
|
-
/* @__PURE__ */ s("h2", { style:
|
|
3187
|
-
/* @__PURE__ */ s("div", { style:
|
|
3188
|
-
] }) : /* @__PURE__ */
|
|
3189
|
-
/* @__PURE__ */ s("h2", { style:
|
|
3190
|
-
/* @__PURE__ */ s("p", { style:
|
|
3191
|
-
/* @__PURE__ */
|
|
3192
|
-
/* @__PURE__ */
|
|
3193
|
-
/* @__PURE__ */ s("label", { style:
|
|
3199
|
+
return u ? /* @__PURE__ */ d("div", { className: p, style: g.container, children: [
|
|
3200
|
+
/* @__PURE__ */ s("h2", { style: g.title, children: I.verifyingText }),
|
|
3201
|
+
/* @__PURE__ */ s("div", { style: g.verifyingContainer, children: /* @__PURE__ */ s("div", { style: g.verifyingText, children: I.verifyingDescription }) })
|
|
3202
|
+
] }) : /* @__PURE__ */ d("div", { className: p, style: g.container, children: [
|
|
3203
|
+
/* @__PURE__ */ s("h2", { style: g.title, children: I.title }),
|
|
3204
|
+
/* @__PURE__ */ s("p", { style: g.description, children: I.description }),
|
|
3205
|
+
/* @__PURE__ */ d("form", { onSubmit: Q, style: g.form, children: [
|
|
3206
|
+
/* @__PURE__ */ d("div", { style: g.fieldGroup, children: [
|
|
3207
|
+
/* @__PURE__ */ s("label", { style: g.label, children: I.emailLabel }),
|
|
3194
3208
|
/* @__PURE__ */ s(
|
|
3195
3209
|
"input",
|
|
3196
3210
|
{
|
|
3197
3211
|
id: "email",
|
|
3198
3212
|
name: "email",
|
|
3199
3213
|
type: "email",
|
|
3200
|
-
value:
|
|
3201
|
-
onChange: (
|
|
3202
|
-
|
|
3214
|
+
value: f,
|
|
3215
|
+
onChange: (q) => {
|
|
3216
|
+
x(q.target.value), l.email && U((j) => ({ ...j, email: !1 }));
|
|
3203
3217
|
},
|
|
3204
|
-
placeholder:
|
|
3218
|
+
placeholder: I.emailPlaceholder,
|
|
3205
3219
|
style: J("email"),
|
|
3206
|
-
disabled: E ||
|
|
3220
|
+
disabled: E || u
|
|
3207
3221
|
}
|
|
3208
3222
|
)
|
|
3209
3223
|
] }),
|
|
3210
|
-
!
|
|
3224
|
+
!b && /* @__PURE__ */ s("div", { style: g.toggleContainer, children: /* @__PURE__ */ s(
|
|
3211
3225
|
"button",
|
|
3212
3226
|
{
|
|
3213
3227
|
type: "button",
|
|
3214
|
-
onClick: () =>
|
|
3215
|
-
style:
|
|
3216
|
-
|
|
3217
|
-
border: "none",
|
|
3218
|
-
color: "#3b82f6",
|
|
3219
|
-
fontSize: "0.875rem",
|
|
3220
|
-
cursor: "pointer",
|
|
3221
|
-
textDecoration: "underline"
|
|
3222
|
-
},
|
|
3223
|
-
children: "New user? Add your name"
|
|
3228
|
+
onClick: () => L(!0),
|
|
3229
|
+
style: g.toggleLink,
|
|
3230
|
+
children: I.showNameToggle
|
|
3224
3231
|
}
|
|
3225
3232
|
) }),
|
|
3226
|
-
|
|
3227
|
-
/* @__PURE__ */
|
|
3228
|
-
/* @__PURE__ */ s("label", { style:
|
|
3233
|
+
b && /* @__PURE__ */ d(_, { children: [
|
|
3234
|
+
/* @__PURE__ */ d("div", { style: g.fieldGroup, children: [
|
|
3235
|
+
/* @__PURE__ */ s("label", { style: g.label, children: I.nameLabel }),
|
|
3229
3236
|
/* @__PURE__ */ s(
|
|
3230
3237
|
"input",
|
|
3231
3238
|
{
|
|
3232
3239
|
id: "name",
|
|
3233
3240
|
name: "name",
|
|
3234
3241
|
type: "text",
|
|
3235
|
-
value:
|
|
3236
|
-
onChange: (
|
|
3237
|
-
R(
|
|
3242
|
+
value: h,
|
|
3243
|
+
onChange: (q) => {
|
|
3244
|
+
R(q.target.value), l.name && U((j) => ({ ...j, name: !1 }));
|
|
3238
3245
|
},
|
|
3239
|
-
placeholder:
|
|
3246
|
+
placeholder: I.namePlaceholder,
|
|
3240
3247
|
style: J("name"),
|
|
3241
|
-
disabled: E ||
|
|
3248
|
+
disabled: E || u
|
|
3242
3249
|
}
|
|
3243
3250
|
)
|
|
3244
3251
|
] }),
|
|
3245
|
-
/* @__PURE__ */
|
|
3246
|
-
/* @__PURE__ */ s("label", { style:
|
|
3252
|
+
/* @__PURE__ */ d("div", { style: g.fieldGroup, children: [
|
|
3253
|
+
/* @__PURE__ */ s("label", { style: g.label, children: I.lastNameLabel }),
|
|
3247
3254
|
/* @__PURE__ */ s(
|
|
3248
3255
|
"input",
|
|
3249
3256
|
{
|
|
3250
3257
|
id: "lastName",
|
|
3251
3258
|
name: "lastName",
|
|
3252
3259
|
type: "text",
|
|
3253
|
-
value:
|
|
3254
|
-
onChange: (
|
|
3255
|
-
placeholder:
|
|
3256
|
-
style:
|
|
3257
|
-
disabled: E ||
|
|
3260
|
+
value: N,
|
|
3261
|
+
onChange: (q) => D(q.target.value),
|
|
3262
|
+
placeholder: I.lastNamePlaceholder,
|
|
3263
|
+
style: g.input,
|
|
3264
|
+
disabled: E || u
|
|
3258
3265
|
}
|
|
3259
3266
|
)
|
|
3260
3267
|
] }),
|
|
3261
|
-
/* @__PURE__ */ s("div", { style:
|
|
3268
|
+
/* @__PURE__ */ s("div", { style: g.toggleContainer, children: /* @__PURE__ */ s(
|
|
3262
3269
|
"button",
|
|
3263
3270
|
{
|
|
3264
3271
|
type: "button",
|
|
3265
3272
|
onClick: () => {
|
|
3266
|
-
|
|
3267
|
-
},
|
|
3268
|
-
style: {
|
|
3269
|
-
background: "none",
|
|
3270
|
-
border: "none",
|
|
3271
|
-
color: "#6b7280",
|
|
3272
|
-
fontSize: "0.875rem",
|
|
3273
|
-
cursor: "pointer",
|
|
3274
|
-
textDecoration: "underline"
|
|
3273
|
+
L(!1), R(""), D("");
|
|
3275
3274
|
},
|
|
3276
|
-
|
|
3275
|
+
style: g.toggleLink,
|
|
3276
|
+
children: I.hideNameToggle
|
|
3277
3277
|
}
|
|
3278
3278
|
) })
|
|
3279
3279
|
] }),
|
|
3280
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: !
|
|
3281
|
-
|
|
3282
|
-
|
|
3280
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !f || E || u, style: O(), children: E ? I.loadingText : I.submitButton }),
|
|
3281
|
+
C && /* @__PURE__ */ s("div", { style: g.errorText, children: C }),
|
|
3282
|
+
T && /* @__PURE__ */ s("div", { style: g.successText, children: T })
|
|
3283
3283
|
] }),
|
|
3284
|
-
a && /* @__PURE__ */
|
|
3285
|
-
/* @__PURE__ */
|
|
3286
|
-
/* @__PURE__ */
|
|
3287
|
-
|
|
3284
|
+
a && /* @__PURE__ */ d("div", { style: g.linkContainer, children: [
|
|
3285
|
+
/* @__PURE__ */ d("div", { children: [
|
|
3286
|
+
/* @__PURE__ */ d("span", { style: g.divider, children: [
|
|
3287
|
+
I.loginText,
|
|
3288
3288
|
" "
|
|
3289
3289
|
] }),
|
|
3290
|
-
/* @__PURE__ */ s("a", { onClick: i, style:
|
|
3290
|
+
/* @__PURE__ */ s("a", { onClick: i, style: g.link, children: I.loginLink })
|
|
3291
3291
|
] }),
|
|
3292
|
-
/* @__PURE__ */ s("div", { style:
|
|
3293
|
-
/* @__PURE__ */
|
|
3294
|
-
/* @__PURE__ */
|
|
3295
|
-
|
|
3292
|
+
/* @__PURE__ */ s("div", { style: g.divider, children: I.dividerBullet }),
|
|
3293
|
+
/* @__PURE__ */ d("div", { children: [
|
|
3294
|
+
/* @__PURE__ */ d("span", { style: g.divider, children: [
|
|
3295
|
+
I.signupText,
|
|
3296
3296
|
" "
|
|
3297
3297
|
] }),
|
|
3298
|
-
/* @__PURE__ */ s("a", { onClick: o, style:
|
|
3298
|
+
/* @__PURE__ */ s("a", { onClick: o, style: g.link, children: I.signupLink })
|
|
3299
3299
|
] })
|
|
3300
3300
|
] })
|
|
3301
3301
|
] });
|
|
@@ -3307,7 +3307,8 @@ const Yt = {
|
|
|
3307
3307
|
errorMessage: "Failed to verify magic link. The link may be expired or invalid.",
|
|
3308
3308
|
redirectingMessage: "Redirecting you to the dashboard...",
|
|
3309
3309
|
retryButton: "Try Again",
|
|
3310
|
-
backToLoginButton: "Back to Login"
|
|
3310
|
+
backToLoginButton: "Back to Login",
|
|
3311
|
+
missingParamsError: "Missing required parameters: token or email"
|
|
3311
3312
|
}, Ye = {
|
|
3312
3313
|
container: {
|
|
3313
3314
|
maxWidth: "400px",
|
|
@@ -3394,8 +3395,14 @@ const Yt = {
|
|
|
3394
3395
|
fontWeight: "500",
|
|
3395
3396
|
cursor: "pointer",
|
|
3396
3397
|
transition: "all 0.15s ease-in-out"
|
|
3398
|
+
},
|
|
3399
|
+
retryButtonHover: {
|
|
3400
|
+
backgroundColor: "#2563eb"
|
|
3401
|
+
},
|
|
3402
|
+
backButtonHover: {
|
|
3403
|
+
backgroundColor: "#e5e7eb"
|
|
3397
3404
|
}
|
|
3398
|
-
}, Xt = () => /* @__PURE__ */ s("div", { style: Ye.spinner }), er = () => /* @__PURE__ */
|
|
3405
|
+
}, Xt = () => /* @__PURE__ */ s("div", { style: Ye.spinner }), er = () => /* @__PURE__ */ d(
|
|
3399
3406
|
"svg",
|
|
3400
3407
|
{
|
|
3401
3408
|
width: "48",
|
|
@@ -3412,7 +3419,7 @@ const Yt = {
|
|
|
3412
3419
|
/* @__PURE__ */ s("polyline", { points: "22,4 12,14.01 9,11.01" })
|
|
3413
3420
|
]
|
|
3414
3421
|
}
|
|
3415
|
-
), tr = () => /* @__PURE__ */
|
|
3422
|
+
), tr = () => /* @__PURE__ */ d(
|
|
3416
3423
|
"svg",
|
|
3417
3424
|
{
|
|
3418
3425
|
width: "48",
|
|
@@ -3435,7 +3442,7 @@ const Yt = {
|
|
|
3435
3442
|
success: /* @__PURE__ */ s(er, {}),
|
|
3436
3443
|
error: /* @__PURE__ */ s(tr, {})
|
|
3437
3444
|
};
|
|
3438
|
-
function
|
|
3445
|
+
function Vr({
|
|
3439
3446
|
copy: n = {},
|
|
3440
3447
|
styles: e = {},
|
|
3441
3448
|
icons: t = {},
|
|
@@ -3443,96 +3450,102 @@ function Wr({
|
|
|
3443
3450
|
onError: i,
|
|
3444
3451
|
onRetry: o,
|
|
3445
3452
|
onBackToLogin: a,
|
|
3446
|
-
className:
|
|
3447
|
-
token:
|
|
3448
|
-
email:
|
|
3449
|
-
appId:
|
|
3450
|
-
tenantSlug:
|
|
3451
|
-
autoRedirectDelay:
|
|
3453
|
+
className: p,
|
|
3454
|
+
token: w,
|
|
3455
|
+
email: y,
|
|
3456
|
+
appId: f,
|
|
3457
|
+
tenantSlug: x,
|
|
3458
|
+
autoRedirectDelay: h = 3e3
|
|
3452
3459
|
}) {
|
|
3453
|
-
const [R,
|
|
3460
|
+
const [R, N] = k("verifying"), [D, E] = k(""), { verifyMagicLink: P } = ue(), u = { ...Yt, ...n }, S = { ...Ye, ...e }, C = { ...rr, ...t }, M = () => {
|
|
3454
3461
|
if (typeof window > "u") return {};
|
|
3455
|
-
const
|
|
3462
|
+
const b = new URLSearchParams(window.location.search);
|
|
3456
3463
|
return {
|
|
3457
|
-
token:
|
|
3458
|
-
email:
|
|
3459
|
-
appId:
|
|
3460
|
-
tenantSlug:
|
|
3464
|
+
token: w || b.get("token") || "",
|
|
3465
|
+
email: y || b.get("email") || "",
|
|
3466
|
+
appId: f || b.get("appId") || "",
|
|
3467
|
+
tenantSlug: x || b.get("tenantSlug") || void 0
|
|
3461
3468
|
};
|
|
3462
|
-
},
|
|
3463
|
-
|
|
3469
|
+
}, T = async () => {
|
|
3470
|
+
N("verifying"), E("");
|
|
3464
3471
|
try {
|
|
3465
|
-
const
|
|
3466
|
-
if (!
|
|
3467
|
-
throw new Error(
|
|
3468
|
-
const
|
|
3469
|
-
token:
|
|
3470
|
-
email:
|
|
3471
|
-
tenantSlug:
|
|
3472
|
+
const b = M();
|
|
3473
|
+
if (!b.token || !b.email)
|
|
3474
|
+
throw new Error(u.missingParamsError);
|
|
3475
|
+
const L = await P({
|
|
3476
|
+
token: b.token,
|
|
3477
|
+
email: b.email,
|
|
3478
|
+
tenantSlug: b.tenantSlug
|
|
3472
3479
|
});
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
},
|
|
3476
|
-
} catch (
|
|
3477
|
-
const
|
|
3478
|
-
E(
|
|
3480
|
+
N("success"), r == null || r(L), h > 0 && setTimeout(() => {
|
|
3481
|
+
N("redirecting");
|
|
3482
|
+
}, h);
|
|
3483
|
+
} catch (b) {
|
|
3484
|
+
const L = b.message || u.errorMessage;
|
|
3485
|
+
E(L), N("error"), i == null || i(L);
|
|
3479
3486
|
}
|
|
3480
|
-
},
|
|
3481
|
-
o == null || o(),
|
|
3487
|
+
}, $ = () => {
|
|
3488
|
+
o == null || o(), T();
|
|
3482
3489
|
}, l = () => {
|
|
3483
3490
|
a == null || a();
|
|
3484
3491
|
};
|
|
3485
3492
|
re(() => {
|
|
3486
|
-
|
|
3493
|
+
T();
|
|
3487
3494
|
}, []);
|
|
3488
|
-
const
|
|
3495
|
+
const U = () => {
|
|
3489
3496
|
switch (R) {
|
|
3490
3497
|
case "verifying":
|
|
3491
|
-
return /* @__PURE__ */
|
|
3492
|
-
|
|
3493
|
-
|
|
3498
|
+
return /* @__PURE__ */ d("div", { style: S.message, children: [
|
|
3499
|
+
C.loading,
|
|
3500
|
+
u.verifyingMessage
|
|
3494
3501
|
] });
|
|
3495
3502
|
case "success":
|
|
3496
|
-
return /* @__PURE__ */
|
|
3497
|
-
|
|
3498
|
-
/* @__PURE__ */ s("div", { style:
|
|
3503
|
+
return /* @__PURE__ */ d(_, { children: [
|
|
3504
|
+
C.success,
|
|
3505
|
+
/* @__PURE__ */ s("div", { style: S.successMessage, children: u.successMessage })
|
|
3499
3506
|
] });
|
|
3500
3507
|
case "redirecting":
|
|
3501
|
-
return /* @__PURE__ */
|
|
3502
|
-
|
|
3503
|
-
/* @__PURE__ */ s("div", { style:
|
|
3508
|
+
return /* @__PURE__ */ d(_, { children: [
|
|
3509
|
+
C.loading,
|
|
3510
|
+
/* @__PURE__ */ s("div", { style: S.message, children: u.redirectingMessage })
|
|
3504
3511
|
] });
|
|
3505
3512
|
case "error":
|
|
3506
|
-
return /* @__PURE__ */
|
|
3507
|
-
|
|
3508
|
-
/* @__PURE__ */ s("div", { style:
|
|
3509
|
-
/* @__PURE__ */
|
|
3513
|
+
return /* @__PURE__ */ d(_, { children: [
|
|
3514
|
+
C.error,
|
|
3515
|
+
/* @__PURE__ */ s("div", { style: S.errorMessage, children: D || u.errorMessage }),
|
|
3516
|
+
/* @__PURE__ */ d("div", { style: S.buttonContainer, children: [
|
|
3510
3517
|
/* @__PURE__ */ s(
|
|
3511
3518
|
"button",
|
|
3512
3519
|
{
|
|
3513
|
-
onClick:
|
|
3514
|
-
style:
|
|
3515
|
-
onMouseOver: (
|
|
3516
|
-
|
|
3520
|
+
onClick: $,
|
|
3521
|
+
style: S.retryButton,
|
|
3522
|
+
onMouseOver: (b) => {
|
|
3523
|
+
Object.assign(b.currentTarget.style, S.retryButtonHover);
|
|
3517
3524
|
},
|
|
3518
|
-
onMouseOut: (
|
|
3519
|
-
|
|
3525
|
+
onMouseOut: (b) => {
|
|
3526
|
+
const L = S.retryButton || {};
|
|
3527
|
+
Object.keys(S.retryButtonHover || {}).forEach((F) => {
|
|
3528
|
+
b.currentTarget.style[F] = L[F] ?? "";
|
|
3529
|
+
});
|
|
3520
3530
|
},
|
|
3521
|
-
children:
|
|
3531
|
+
children: u.retryButton
|
|
3522
3532
|
}
|
|
3523
3533
|
),
|
|
3524
3534
|
/* @__PURE__ */ s(
|
|
3525
3535
|
"button",
|
|
3526
3536
|
{
|
|
3527
3537
|
onClick: l,
|
|
3528
|
-
style:
|
|
3529
|
-
onMouseOver: (
|
|
3530
|
-
|
|
3538
|
+
style: S.backButton,
|
|
3539
|
+
onMouseOver: (b) => {
|
|
3540
|
+
Object.assign(b.currentTarget.style, S.backButtonHover);
|
|
3531
3541
|
},
|
|
3532
|
-
onMouseOut: (
|
|
3533
|
-
|
|
3542
|
+
onMouseOut: (b) => {
|
|
3543
|
+
const L = S.backButton || {};
|
|
3544
|
+
Object.keys(S.backButtonHover || {}).forEach((F) => {
|
|
3545
|
+
b.currentTarget.style[F] = L[F] ?? "";
|
|
3546
|
+
});
|
|
3534
3547
|
},
|
|
3535
|
-
children:
|
|
3548
|
+
children: u.backToLoginButton
|
|
3536
3549
|
}
|
|
3537
3550
|
)
|
|
3538
3551
|
] })
|
|
@@ -3541,15 +3554,15 @@ function Wr({
|
|
|
3541
3554
|
return null;
|
|
3542
3555
|
}
|
|
3543
3556
|
};
|
|
3544
|
-
return /* @__PURE__ */
|
|
3557
|
+
return /* @__PURE__ */ d("div", { style: S.container, className: p, children: [
|
|
3545
3558
|
/* @__PURE__ */ s("style", { children: `
|
|
3546
3559
|
@keyframes spin {
|
|
3547
3560
|
0% { transform: rotate(0deg); }
|
|
3548
3561
|
100% { transform: rotate(360deg); }
|
|
3549
3562
|
}
|
|
3550
3563
|
` }),
|
|
3551
|
-
/* @__PURE__ */ s("h1", { style:
|
|
3552
|
-
|
|
3564
|
+
/* @__PURE__ */ s("h1", { style: S.title, children: u.title }),
|
|
3565
|
+
U()
|
|
3553
3566
|
] });
|
|
3554
3567
|
}
|
|
3555
3568
|
const nr = {
|
|
@@ -3573,7 +3586,11 @@ const nr = {
|
|
|
3573
3586
|
resetSubmitButton: "Reset Password",
|
|
3574
3587
|
resetLoadingText: "Resetting...",
|
|
3575
3588
|
resetSuccessMessage: "Password reset successfully!",
|
|
3576
|
-
passwordMismatchError: "Passwords do not match"
|
|
3589
|
+
passwordMismatchError: "Passwords do not match",
|
|
3590
|
+
requestNewLinkLink: "Request New Link",
|
|
3591
|
+
haveTokenLink: "I have a token",
|
|
3592
|
+
tenantNotFoundError: "Tenant not found",
|
|
3593
|
+
dividerBullet: "•"
|
|
3577
3594
|
}, sr = {
|
|
3578
3595
|
container: {
|
|
3579
3596
|
maxWidth: "400px",
|
|
@@ -3664,9 +3681,13 @@ const nr = {
|
|
|
3664
3681
|
textDecoration: "none",
|
|
3665
3682
|
fontSize: "0.875rem",
|
|
3666
3683
|
cursor: "pointer"
|
|
3684
|
+
},
|
|
3685
|
+
modeSwitchDivider: {
|
|
3686
|
+
margin: "0 0.5rem",
|
|
3687
|
+
color: "#6b7280"
|
|
3667
3688
|
}
|
|
3668
3689
|
};
|
|
3669
|
-
function
|
|
3690
|
+
function jr({
|
|
3670
3691
|
copy: n = {},
|
|
3671
3692
|
styles: e = {},
|
|
3672
3693
|
mode: t = "request",
|
|
@@ -3674,105 +3695,105 @@ function Vr({
|
|
|
3674
3695
|
onSuccess: i,
|
|
3675
3696
|
onError: o,
|
|
3676
3697
|
onBackToLogin: a,
|
|
3677
|
-
onModeChange:
|
|
3678
|
-
className:
|
|
3698
|
+
onModeChange: p,
|
|
3699
|
+
className: w
|
|
3679
3700
|
}) {
|
|
3680
|
-
const [
|
|
3681
|
-
const
|
|
3682
|
-
return
|
|
3683
|
-
},
|
|
3684
|
-
const
|
|
3685
|
-
return
|
|
3686
|
-
},
|
|
3687
|
-
if (
|
|
3688
|
-
if (!(
|
|
3689
|
-
|
|
3701
|
+
const [y, f] = k(""), [x, h] = k(r), [R, N] = k(""), [D, E] = k(""), [P, u] = k(!1), [S, C] = k(""), [M, T] = k(""), [$, l] = k({}), { requestPasswordReset: U, confirmPasswordReset: b } = ue(), { tenant: L } = me(), F = { ...nr, ...n }, c = { ...sr, ...e }, H = () => {
|
|
3702
|
+
const O = {};
|
|
3703
|
+
return y.trim() || (O.email = !0), l(O), Object.keys(O).length === 0;
|
|
3704
|
+
}, I = () => {
|
|
3705
|
+
const O = {};
|
|
3706
|
+
return x.trim() || (O.token = !0), R.trim() || (O.newPassword = !0), D.trim() || (O.confirmPassword = !0), l(O), Object.keys(O).length === 0;
|
|
3707
|
+
}, g = async (O) => {
|
|
3708
|
+
if (O.preventDefault(), !!H()) {
|
|
3709
|
+
if (!(L != null && L.id)) {
|
|
3710
|
+
C(F.tenantNotFoundError);
|
|
3690
3711
|
return;
|
|
3691
3712
|
}
|
|
3692
|
-
|
|
3713
|
+
u(!0), C(""), T("");
|
|
3693
3714
|
try {
|
|
3694
|
-
await
|
|
3695
|
-
} catch (
|
|
3696
|
-
const j =
|
|
3697
|
-
|
|
3715
|
+
await U({ email: y, tenantId: L.id }), T(F.successMessage), i == null || i();
|
|
3716
|
+
} catch (q) {
|
|
3717
|
+
const j = q.message || F.errorMessage;
|
|
3718
|
+
C(j), o == null || o(j);
|
|
3698
3719
|
} finally {
|
|
3699
|
-
|
|
3720
|
+
u(!1);
|
|
3700
3721
|
}
|
|
3701
3722
|
}
|
|
3702
|
-
},
|
|
3703
|
-
if (
|
|
3704
|
-
if (R !==
|
|
3705
|
-
|
|
3723
|
+
}, m = async (O) => {
|
|
3724
|
+
if (O.preventDefault(), !!I()) {
|
|
3725
|
+
if (R !== D) {
|
|
3726
|
+
C(F.passwordMismatchError), l({ confirmPassword: !0 });
|
|
3706
3727
|
return;
|
|
3707
3728
|
}
|
|
3708
|
-
|
|
3729
|
+
u(!0), C(""), T("");
|
|
3709
3730
|
try {
|
|
3710
|
-
await
|
|
3711
|
-
} catch (
|
|
3712
|
-
const j =
|
|
3713
|
-
|
|
3731
|
+
await b({ token: x, newPassword: R }), T(F.resetSuccessMessage), i == null || i();
|
|
3732
|
+
} catch (q) {
|
|
3733
|
+
const j = q.message || F.errorMessage;
|
|
3734
|
+
C(j), o == null || o(j);
|
|
3714
3735
|
} finally {
|
|
3715
|
-
|
|
3736
|
+
u(!1);
|
|
3716
3737
|
}
|
|
3717
3738
|
}
|
|
3718
|
-
},
|
|
3719
|
-
...
|
|
3720
|
-
|
|
3739
|
+
}, v = (O) => ({
|
|
3740
|
+
...c.input,
|
|
3741
|
+
...$[O] ? c.inputError : {}
|
|
3721
3742
|
}), Q = () => ({
|
|
3722
|
-
...
|
|
3723
|
-
...
|
|
3743
|
+
...c.button,
|
|
3744
|
+
...P ? c.buttonLoading : {}
|
|
3724
3745
|
});
|
|
3725
3746
|
if (t === "reset") {
|
|
3726
|
-
const
|
|
3727
|
-
return /* @__PURE__ */
|
|
3728
|
-
/* @__PURE__ */ s("h2", { style:
|
|
3729
|
-
/* @__PURE__ */ s("p", { style:
|
|
3730
|
-
/* @__PURE__ */
|
|
3731
|
-
/* @__PURE__ */
|
|
3732
|
-
/* @__PURE__ */ s("label", { style:
|
|
3747
|
+
const O = x && R && D;
|
|
3748
|
+
return /* @__PURE__ */ d("div", { className: w, style: c.container, children: [
|
|
3749
|
+
/* @__PURE__ */ s("h2", { style: c.title, children: F.resetTitle }),
|
|
3750
|
+
/* @__PURE__ */ s("p", { style: c.subtitle, children: F.resetSubtitle }),
|
|
3751
|
+
/* @__PURE__ */ d("form", { onSubmit: m, style: c.form, children: [
|
|
3752
|
+
/* @__PURE__ */ d("div", { style: c.fieldGroup, children: [
|
|
3753
|
+
/* @__PURE__ */ s("label", { style: c.label, children: F.tokenLabel }),
|
|
3733
3754
|
/* @__PURE__ */ s(
|
|
3734
3755
|
"input",
|
|
3735
3756
|
{
|
|
3736
3757
|
type: "text",
|
|
3737
|
-
value:
|
|
3738
|
-
onChange: (
|
|
3739
|
-
|
|
3758
|
+
value: x,
|
|
3759
|
+
onChange: (q) => {
|
|
3760
|
+
h(q.target.value), $.token && l((j) => ({ ...j, token: !1 }));
|
|
3740
3761
|
},
|
|
3741
|
-
placeholder:
|
|
3742
|
-
style:
|
|
3743
|
-
disabled:
|
|
3762
|
+
placeholder: F.tokenPlaceholder,
|
|
3763
|
+
style: v("token"),
|
|
3764
|
+
disabled: P
|
|
3744
3765
|
}
|
|
3745
3766
|
)
|
|
3746
3767
|
] }),
|
|
3747
|
-
/* @__PURE__ */
|
|
3748
|
-
/* @__PURE__ */ s("label", { style:
|
|
3768
|
+
/* @__PURE__ */ d("div", { style: c.fieldGroup, children: [
|
|
3769
|
+
/* @__PURE__ */ s("label", { style: c.label, children: F.newPasswordLabel }),
|
|
3749
3770
|
/* @__PURE__ */ s(
|
|
3750
3771
|
"input",
|
|
3751
3772
|
{
|
|
3752
3773
|
type: "password",
|
|
3753
3774
|
value: R,
|
|
3754
|
-
onChange: (
|
|
3755
|
-
|
|
3775
|
+
onChange: (q) => {
|
|
3776
|
+
N(q.target.value), $.newPassword && l((j) => ({ ...j, newPassword: !1 }));
|
|
3756
3777
|
},
|
|
3757
|
-
placeholder:
|
|
3758
|
-
style:
|
|
3759
|
-
disabled:
|
|
3778
|
+
placeholder: F.newPasswordPlaceholder,
|
|
3779
|
+
style: v("newPassword"),
|
|
3780
|
+
disabled: P
|
|
3760
3781
|
}
|
|
3761
3782
|
)
|
|
3762
3783
|
] }),
|
|
3763
|
-
/* @__PURE__ */
|
|
3764
|
-
/* @__PURE__ */ s("label", { style:
|
|
3784
|
+
/* @__PURE__ */ d("div", { style: c.fieldGroup, children: [
|
|
3785
|
+
/* @__PURE__ */ s("label", { style: c.label, children: F.confirmPasswordLabel }),
|
|
3765
3786
|
/* @__PURE__ */ s(
|
|
3766
3787
|
"input",
|
|
3767
3788
|
{
|
|
3768
3789
|
type: "password",
|
|
3769
|
-
value:
|
|
3770
|
-
onChange: (
|
|
3771
|
-
E(
|
|
3790
|
+
value: D,
|
|
3791
|
+
onChange: (q) => {
|
|
3792
|
+
E(q.target.value), $.confirmPassword && l((j) => ({ ...j, confirmPassword: !1 })), S === F.passwordMismatchError && C("");
|
|
3772
3793
|
},
|
|
3773
|
-
placeholder:
|
|
3774
|
-
style:
|
|
3775
|
-
disabled:
|
|
3794
|
+
placeholder: F.confirmPasswordPlaceholder,
|
|
3795
|
+
style: v("confirmPassword"),
|
|
3796
|
+
disabled: P
|
|
3776
3797
|
}
|
|
3777
3798
|
)
|
|
3778
3799
|
] }),
|
|
@@ -3780,44 +3801,44 @@ function Vr({
|
|
|
3780
3801
|
"button",
|
|
3781
3802
|
{
|
|
3782
3803
|
type: "submit",
|
|
3783
|
-
disabled: !
|
|
3804
|
+
disabled: !O || P,
|
|
3784
3805
|
style: {
|
|
3785
3806
|
...Q(),
|
|
3786
|
-
...!
|
|
3807
|
+
...!O || P ? c.buttonDisabled : {}
|
|
3787
3808
|
},
|
|
3788
|
-
children:
|
|
3809
|
+
children: P ? F.resetLoadingText : F.resetSubmitButton
|
|
3789
3810
|
}
|
|
3790
3811
|
),
|
|
3791
|
-
|
|
3792
|
-
|
|
3812
|
+
S && /* @__PURE__ */ s("div", { style: c.errorText, children: S }),
|
|
3813
|
+
M && /* @__PURE__ */ s("div", { style: c.successText, children: M })
|
|
3793
3814
|
] }),
|
|
3794
|
-
/* @__PURE__ */
|
|
3795
|
-
/* @__PURE__ */ s("a", { onClick: a, style:
|
|
3796
|
-
|
|
3797
|
-
/* @__PURE__ */ s("span", { style:
|
|
3798
|
-
/* @__PURE__ */ s("a", { onClick: () =>
|
|
3815
|
+
/* @__PURE__ */ d("div", { style: c.linkContainer, children: [
|
|
3816
|
+
/* @__PURE__ */ s("a", { onClick: a, style: c.link, children: F.backToLoginLink }),
|
|
3817
|
+
p && /* @__PURE__ */ d(_, { children: [
|
|
3818
|
+
/* @__PURE__ */ s("span", { style: c.modeSwitchDivider, children: F.dividerBullet }),
|
|
3819
|
+
/* @__PURE__ */ s("a", { onClick: () => p("request"), style: c.link, children: F.requestNewLinkLink })
|
|
3799
3820
|
] })
|
|
3800
3821
|
] })
|
|
3801
3822
|
] });
|
|
3802
3823
|
}
|
|
3803
|
-
const J =
|
|
3804
|
-
return /* @__PURE__ */
|
|
3805
|
-
/* @__PURE__ */ s("h2", { style:
|
|
3806
|
-
/* @__PURE__ */ s("p", { style:
|
|
3807
|
-
/* @__PURE__ */
|
|
3808
|
-
/* @__PURE__ */
|
|
3809
|
-
/* @__PURE__ */ s("label", { style:
|
|
3824
|
+
const J = y;
|
|
3825
|
+
return /* @__PURE__ */ d("div", { className: w, style: c.container, children: [
|
|
3826
|
+
/* @__PURE__ */ s("h2", { style: c.title, children: F.title }),
|
|
3827
|
+
/* @__PURE__ */ s("p", { style: c.subtitle, children: F.subtitle }),
|
|
3828
|
+
/* @__PURE__ */ d("form", { onSubmit: g, style: c.form, children: [
|
|
3829
|
+
/* @__PURE__ */ d("div", { style: c.fieldGroup, children: [
|
|
3830
|
+
/* @__PURE__ */ s("label", { style: c.label, children: F.emailLabel }),
|
|
3810
3831
|
/* @__PURE__ */ s(
|
|
3811
3832
|
"input",
|
|
3812
3833
|
{
|
|
3813
3834
|
type: "email",
|
|
3814
|
-
value:
|
|
3815
|
-
onChange: (
|
|
3816
|
-
|
|
3835
|
+
value: y,
|
|
3836
|
+
onChange: (O) => {
|
|
3837
|
+
f(O.target.value), $.email && l((q) => ({ ...q, email: !1 }));
|
|
3817
3838
|
},
|
|
3818
|
-
placeholder:
|
|
3819
|
-
style:
|
|
3820
|
-
disabled:
|
|
3839
|
+
placeholder: F.emailPlaceholder,
|
|
3840
|
+
style: v("email"),
|
|
3841
|
+
disabled: P
|
|
3821
3842
|
}
|
|
3822
3843
|
)
|
|
3823
3844
|
] }),
|
|
@@ -3825,22 +3846,22 @@ function Vr({
|
|
|
3825
3846
|
"button",
|
|
3826
3847
|
{
|
|
3827
3848
|
type: "submit",
|
|
3828
|
-
disabled: !J ||
|
|
3849
|
+
disabled: !J || P,
|
|
3829
3850
|
style: {
|
|
3830
3851
|
...Q(),
|
|
3831
|
-
...!J ||
|
|
3852
|
+
...!J || P ? c.buttonDisabled : {}
|
|
3832
3853
|
},
|
|
3833
|
-
children:
|
|
3854
|
+
children: P ? F.loadingText : F.submitButton
|
|
3834
3855
|
}
|
|
3835
3856
|
),
|
|
3836
|
-
|
|
3837
|
-
|
|
3857
|
+
S && /* @__PURE__ */ s("div", { style: c.errorText, children: S }),
|
|
3858
|
+
M && /* @__PURE__ */ s("div", { style: c.successText, children: M })
|
|
3838
3859
|
] }),
|
|
3839
|
-
/* @__PURE__ */
|
|
3840
|
-
/* @__PURE__ */ s("a", { onClick: a, style:
|
|
3841
|
-
|
|
3842
|
-
/* @__PURE__ */ s("span", { style:
|
|
3843
|
-
/* @__PURE__ */ s("a", { onClick: () =>
|
|
3860
|
+
/* @__PURE__ */ d("div", { style: c.linkContainer, children: [
|
|
3861
|
+
/* @__PURE__ */ s("a", { onClick: a, style: c.link, children: F.backToLoginLink }),
|
|
3862
|
+
p && /* @__PURE__ */ d(_, { children: [
|
|
3863
|
+
/* @__PURE__ */ s("span", { style: c.modeSwitchDivider, children: F.dividerBullet }),
|
|
3864
|
+
/* @__PURE__ */ s("a", { onClick: () => p("reset"), style: c.link, children: F.haveTokenLink })
|
|
3844
3865
|
] })
|
|
3845
3866
|
] })
|
|
3846
3867
|
] });
|
|
@@ -3857,7 +3878,7 @@ const ir = () => /* @__PURE__ */ s(
|
|
|
3857
3878
|
},
|
|
3858
3879
|
children: /* @__PURE__ */ s("div", { children: "Loading..." })
|
|
3859
3880
|
}
|
|
3860
|
-
), or = ({ error: n, retry: e }) => /* @__PURE__ */
|
|
3881
|
+
), or = ({ error: n, retry: e }) => /* @__PURE__ */ d(
|
|
3861
3882
|
"div",
|
|
3862
3883
|
{
|
|
3863
3884
|
style: {
|
|
@@ -3891,139 +3912,169 @@ const ir = () => /* @__PURE__ */ s(
|
|
|
3891
3912
|
]
|
|
3892
3913
|
}
|
|
3893
3914
|
);
|
|
3894
|
-
function
|
|
3915
|
+
function Gr({
|
|
3895
3916
|
children: n,
|
|
3896
3917
|
loadingFallback: e,
|
|
3897
3918
|
errorFallback: t,
|
|
3898
3919
|
requireTenant: r = !0
|
|
3899
3920
|
}) {
|
|
3900
|
-
const { isAppLoading: i, appError: o, retryApp: a } =
|
|
3901
|
-
}),
|
|
3902
|
-
o && a(),
|
|
3921
|
+
const { isAppLoading: i, appError: o, retryApp: a } = Se(), p = xe(), w = Fe(), y = Ke(), f = Ze(), x = (p == null ? void 0 : p.isTenantLoading) ?? !1, h = (p == null ? void 0 : p.tenantError) ?? null, R = (p == null ? void 0 : p.tenantSlug) ?? null, N = (p == null ? void 0 : p.retryTenant) ?? (() => {
|
|
3922
|
+
}), D = (w == null ? void 0 : w.isAuthReady) ?? !0, E = (y == null ? void 0 : y.isReady) ?? !0, P = (f == null ? void 0 : f.isReady) ?? !0, u = r && p && R, T = i || u && x || w && !D || y && !E || f && !P, $ = o || (u ? h : null), l = () => {
|
|
3923
|
+
o && a(), h && p && N();
|
|
3903
3924
|
};
|
|
3904
|
-
if (
|
|
3925
|
+
if (T)
|
|
3905
3926
|
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(ir, {}) });
|
|
3906
|
-
if (
|
|
3907
|
-
const
|
|
3908
|
-
return /* @__PURE__ */ s(_, { children:
|
|
3927
|
+
if ($) {
|
|
3928
|
+
const U = typeof t == "function" ? t($, l) : t || /* @__PURE__ */ s(or, { error: $, retry: l });
|
|
3929
|
+
return /* @__PURE__ */ s(_, { children: U });
|
|
3909
3930
|
}
|
|
3910
3931
|
return /* @__PURE__ */ s(_, { children: n });
|
|
3911
3932
|
}
|
|
3912
|
-
function
|
|
3913
|
-
const { isAppLoading: e, appError: t, retryApp: r, appInfo: i } =
|
|
3914
|
-
}),
|
|
3933
|
+
function Qr(n = !0) {
|
|
3934
|
+
const { isAppLoading: e, appError: t, retryApp: r, appInfo: i } = Se(), o = xe(), a = Fe(), p = Ke(), w = Ze(), y = (o == null ? void 0 : o.isTenantLoading) ?? !1, f = (o == null ? void 0 : o.tenantError) ?? null, x = (o == null ? void 0 : o.tenant) ?? null, h = (o == null ? void 0 : o.tenantSlug) ?? null, R = (o == null ? void 0 : o.retryTenant) ?? (() => {
|
|
3935
|
+
}), N = (a == null ? void 0 : a.isAuthReady) ?? !0, D = (p == null ? void 0 : p.isReady) ?? !0, E = (w == null ? void 0 : w.isReady) ?? !0, P = n && o && h, M = e || P && y || a && !N || p && !D || w && !E, T = t || (P ? f : null);
|
|
3915
3936
|
return {
|
|
3916
|
-
isLoading:
|
|
3917
|
-
error:
|
|
3918
|
-
isReady: !
|
|
3937
|
+
isLoading: M,
|
|
3938
|
+
error: T,
|
|
3939
|
+
isReady: !M && !T && i !== null && (!P || x !== null),
|
|
3919
3940
|
retry: () => {
|
|
3920
|
-
t && r(),
|
|
3941
|
+
t && r(), f && o && R();
|
|
3921
3942
|
},
|
|
3922
3943
|
// Individual states
|
|
3923
3944
|
app: { isLoading: e, error: t, data: i },
|
|
3924
|
-
tenant: o ? { isLoading:
|
|
3925
|
-
auth: a ? { isReady:
|
|
3926
|
-
featureFlags:
|
|
3927
|
-
subscription:
|
|
3945
|
+
tenant: o ? { isLoading: y, error: f, data: x } : null,
|
|
3946
|
+
auth: a ? { isReady: N } : null,
|
|
3947
|
+
featureFlags: p ? { isReady: D } : null,
|
|
3948
|
+
subscription: w ? { isReady: E } : null
|
|
3928
3949
|
};
|
|
3929
3950
|
}
|
|
3930
|
-
|
|
3951
|
+
const ar = {
|
|
3952
|
+
wrapper: {
|
|
3953
|
+
position: "relative"
|
|
3954
|
+
},
|
|
3955
|
+
button: {
|
|
3956
|
+
cursor: "pointer",
|
|
3957
|
+
opacity: 1
|
|
3958
|
+
},
|
|
3959
|
+
buttonDisabled: {
|
|
3960
|
+
cursor: "not-allowed",
|
|
3961
|
+
opacity: 0.6
|
|
3962
|
+
},
|
|
3963
|
+
dropdown: {
|
|
3964
|
+
position: "absolute",
|
|
3965
|
+
top: "100%",
|
|
3966
|
+
left: 0,
|
|
3967
|
+
right: 0,
|
|
3968
|
+
zIndex: 1e3,
|
|
3969
|
+
backgroundColor: "white",
|
|
3970
|
+
border: "1px solid #ccc",
|
|
3971
|
+
borderRadius: 4,
|
|
3972
|
+
boxShadow: "0 2px 8px rgba(0,0,0,0.15)",
|
|
3973
|
+
maxHeight: 300,
|
|
3974
|
+
overflowY: "auto"
|
|
3975
|
+
},
|
|
3976
|
+
item: {
|
|
3977
|
+
padding: "8px 12px",
|
|
3978
|
+
cursor: "pointer",
|
|
3979
|
+
backgroundColor: "transparent"
|
|
3980
|
+
},
|
|
3981
|
+
itemSelected: {
|
|
3982
|
+
backgroundColor: "#f0f0f0"
|
|
3983
|
+
},
|
|
3984
|
+
itemHover: {
|
|
3985
|
+
backgroundColor: "#f5f5f5"
|
|
3986
|
+
},
|
|
3987
|
+
itemRole: {
|
|
3988
|
+
opacity: 0.7,
|
|
3989
|
+
marginLeft: 8
|
|
3990
|
+
},
|
|
3991
|
+
arrow: {
|
|
3992
|
+
marginLeft: 8
|
|
3993
|
+
}
|
|
3994
|
+
};
|
|
3995
|
+
function Kr({
|
|
3931
3996
|
tenants: n,
|
|
3932
3997
|
currentTenantId: e,
|
|
3933
3998
|
onSelect: t,
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3999
|
+
styles: r = {},
|
|
4000
|
+
className: i = "",
|
|
4001
|
+
dropdownClassName: o = "",
|
|
4002
|
+
itemClassName: a = "",
|
|
4003
|
+
renderItem: p,
|
|
4004
|
+
placeholder: w = "Select tenant",
|
|
4005
|
+
disabled: y = !1,
|
|
4006
|
+
showCurrentTenant: f = !0
|
|
3941
4007
|
}) {
|
|
3942
|
-
var
|
|
3943
|
-
const
|
|
3944
|
-
|
|
4008
|
+
var M;
|
|
4009
|
+
const x = { ...ar, ...r }, h = Fe(), [R, N] = k(!1), D = Me(null), E = n ?? (h == null ? void 0 : h.userTenants) ?? [], P = e ?? ((M = h == null ? void 0 : h.currentUser) == null ? void 0 : M.tenantId) ?? null, u = async (T) => {
|
|
4010
|
+
N(!1), t ? t(T) : h != null && h.switchToTenant && await h.switchToTenant(T);
|
|
3945
4011
|
};
|
|
3946
4012
|
re(() => {
|
|
3947
|
-
const
|
|
3948
|
-
|
|
4013
|
+
const T = ($) => {
|
|
4014
|
+
D.current && !D.current.contains($.target) && N(!1);
|
|
3949
4015
|
};
|
|
3950
|
-
return document.addEventListener("mousedown",
|
|
4016
|
+
return document.addEventListener("mousedown", T), () => document.removeEventListener("mousedown", T);
|
|
3951
4017
|
}, []);
|
|
3952
|
-
const
|
|
3953
|
-
if (
|
|
4018
|
+
const S = E.find((T) => T.id === P);
|
|
4019
|
+
if (E.length === 0)
|
|
3954
4020
|
return null;
|
|
3955
|
-
if (
|
|
3956
|
-
return /* @__PURE__ */ s("div", { className:
|
|
3957
|
-
const
|
|
3958
|
-
|
|
3959
|
-
|
|
4021
|
+
if (E.length === 1 && f)
|
|
4022
|
+
return /* @__PURE__ */ s("div", { className: i, children: /* @__PURE__ */ s("span", { children: E[0].name }) });
|
|
4023
|
+
const C = (T, $) => /* @__PURE__ */ d("span", { style: { fontWeight: $ ? "bold" : "normal" }, children: [
|
|
4024
|
+
T.name,
|
|
4025
|
+
T.role && /* @__PURE__ */ d("span", { style: x.itemRole, children: [
|
|
3960
4026
|
"(",
|
|
3961
|
-
|
|
4027
|
+
T.role,
|
|
3962
4028
|
")"
|
|
3963
4029
|
] })
|
|
3964
4030
|
] });
|
|
3965
|
-
return /* @__PURE__ */
|
|
3966
|
-
/* @__PURE__ */
|
|
4031
|
+
return /* @__PURE__ */ d("div", { ref: D, className: i, style: x.wrapper, children: [
|
|
4032
|
+
/* @__PURE__ */ d(
|
|
3967
4033
|
"button",
|
|
3968
4034
|
{
|
|
3969
4035
|
type: "button",
|
|
3970
|
-
onClick: () => !
|
|
3971
|
-
disabled:
|
|
4036
|
+
onClick: () => !y && N(!R),
|
|
4037
|
+
disabled: y,
|
|
3972
4038
|
style: {
|
|
3973
|
-
|
|
3974
|
-
|
|
4039
|
+
...x.button,
|
|
4040
|
+
...y ? x.buttonDisabled : {}
|
|
3975
4041
|
},
|
|
3976
4042
|
children: [
|
|
3977
|
-
|
|
3978
|
-
/* @__PURE__ */ s("span", { style:
|
|
4043
|
+
S ? S.name : w,
|
|
4044
|
+
/* @__PURE__ */ s("span", { style: x.arrow, children: R ? "▲" : "▼" })
|
|
3979
4045
|
]
|
|
3980
4046
|
}
|
|
3981
4047
|
),
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
4048
|
+
R && /* @__PURE__ */ s("div", { className: o, style: x.dropdown, children: E.map((T) => {
|
|
4049
|
+
const $ = T.id === P;
|
|
4050
|
+
return /* @__PURE__ */ s(
|
|
4051
|
+
"div",
|
|
4052
|
+
{
|
|
4053
|
+
className: a,
|
|
4054
|
+
onClick: () => u(T.id),
|
|
4055
|
+
style: {
|
|
4056
|
+
...x.item,
|
|
4057
|
+
...$ ? x.itemSelected : {}
|
|
4058
|
+
},
|
|
4059
|
+
onMouseEnter: (l) => {
|
|
4060
|
+
$ || Object.assign(l.currentTarget.style, x.itemHover);
|
|
4061
|
+
},
|
|
4062
|
+
onMouseLeave: (l) => {
|
|
4063
|
+
if (!$) {
|
|
4064
|
+
const U = x.item || {};
|
|
4065
|
+
Object.keys(x.itemHover || {}).forEach((b) => {
|
|
4066
|
+
l.currentTarget.style[b] = U[b] ?? "";
|
|
4067
|
+
});
|
|
4068
|
+
}
|
|
4069
|
+
},
|
|
4070
|
+
children: p ? p(T, $) : C(T, $)
|
|
3998
4071
|
},
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
"div",
|
|
4003
|
-
{
|
|
4004
|
-
className: o,
|
|
4005
|
-
onClick: () => E(w.id),
|
|
4006
|
-
style: {
|
|
4007
|
-
padding: "8px 12px",
|
|
4008
|
-
cursor: "pointer",
|
|
4009
|
-
backgroundColor: v ? "#f0f0f0" : "transparent"
|
|
4010
|
-
},
|
|
4011
|
-
onMouseEnter: (N) => {
|
|
4012
|
-
v || (N.target.style.backgroundColor = "#f5f5f5");
|
|
4013
|
-
},
|
|
4014
|
-
onMouseLeave: (N) => {
|
|
4015
|
-
v || (N.target.style.backgroundColor = "transparent");
|
|
4016
|
-
},
|
|
4017
|
-
children: a ? a(w, v) : h(w, v)
|
|
4018
|
-
},
|
|
4019
|
-
w.id
|
|
4020
|
-
);
|
|
4021
|
-
})
|
|
4022
|
-
}
|
|
4023
|
-
)
|
|
4072
|
+
T.id
|
|
4073
|
+
);
|
|
4074
|
+
}) })
|
|
4024
4075
|
] });
|
|
4025
4076
|
}
|
|
4026
|
-
class
|
|
4077
|
+
class Zr {
|
|
4027
4078
|
constructor(e, t) {
|
|
4028
4079
|
this.httpService = e, this.sessionManager = t;
|
|
4029
4080
|
}
|
|
@@ -4091,7 +4142,7 @@ class Kr {
|
|
|
4091
4142
|
};
|
|
4092
4143
|
}
|
|
4093
4144
|
}
|
|
4094
|
-
class
|
|
4145
|
+
class Jr {
|
|
4095
4146
|
constructor(e, t) {
|
|
4096
4147
|
this.httpService = e, this.sessionManager = t;
|
|
4097
4148
|
}
|
|
@@ -4142,7 +4193,7 @@ class Zr {
|
|
|
4142
4193
|
});
|
|
4143
4194
|
}
|
|
4144
4195
|
}
|
|
4145
|
-
class
|
|
4196
|
+
class Yr {
|
|
4146
4197
|
constructor(e) {
|
|
4147
4198
|
this.httpService = e;
|
|
4148
4199
|
}
|
|
@@ -4151,7 +4202,7 @@ class Jr {
|
|
|
4151
4202
|
return await this.httpService.get("/health");
|
|
4152
4203
|
}
|
|
4153
4204
|
}
|
|
4154
|
-
class
|
|
4205
|
+
class Xr {
|
|
4155
4206
|
// Date string to Date object
|
|
4156
4207
|
static toDate(e) {
|
|
4157
4208
|
return new Date(e);
|
|
@@ -4273,139 +4324,139 @@ class Yr {
|
|
|
4273
4324
|
}), t;
|
|
4274
4325
|
}
|
|
4275
4326
|
}
|
|
4276
|
-
const Xe = "returnTo",
|
|
4277
|
-
function
|
|
4327
|
+
const Xe = "returnTo", Ee = "zone_return_to", Ie = "zone_return_to";
|
|
4328
|
+
function en(n = {}) {
|
|
4278
4329
|
const {
|
|
4279
4330
|
zoneRoots: e = {},
|
|
4280
4331
|
returnToParam: t = Xe,
|
|
4281
4332
|
returnToStorage: r = "url"
|
|
4282
|
-
} = n, i =
|
|
4333
|
+
} = n, i = pt(), [o, a] = ft(), { isAuthenticated: p, currentUser: w } = ue(), { tenant: y } = ge(), f = K(() => ({ ...Ue, ...e }), [e]), x = !!y, h = w == null ? void 0 : w.userType, R = K(() => {
|
|
4283
4334
|
switch (r) {
|
|
4284
4335
|
case "url":
|
|
4285
4336
|
return o.get(t);
|
|
4286
4337
|
case "session":
|
|
4287
|
-
return sessionStorage.getItem(
|
|
4338
|
+
return sessionStorage.getItem(Ee);
|
|
4288
4339
|
case "local":
|
|
4289
|
-
return localStorage.getItem(
|
|
4340
|
+
return localStorage.getItem(Ie);
|
|
4290
4341
|
default:
|
|
4291
4342
|
return null;
|
|
4292
4343
|
}
|
|
4293
|
-
}, [r, o, t]),
|
|
4344
|
+
}, [r, o, t]), N = se(() => {
|
|
4294
4345
|
switch (r) {
|
|
4295
4346
|
case "url": {
|
|
4296
|
-
const
|
|
4297
|
-
|
|
4347
|
+
const u = new URLSearchParams(o);
|
|
4348
|
+
u.delete(t), a(u, { replace: !0 });
|
|
4298
4349
|
break;
|
|
4299
4350
|
}
|
|
4300
4351
|
case "session":
|
|
4301
|
-
sessionStorage.removeItem(
|
|
4352
|
+
sessionStorage.removeItem(Ee);
|
|
4302
4353
|
break;
|
|
4303
4354
|
case "local":
|
|
4304
|
-
localStorage.removeItem(
|
|
4355
|
+
localStorage.removeItem(Ie);
|
|
4305
4356
|
break;
|
|
4306
4357
|
}
|
|
4307
|
-
}, [r, o, t, a]),
|
|
4308
|
-
(
|
|
4358
|
+
}, [r, o, t, a]), D = se(
|
|
4359
|
+
(u) => {
|
|
4309
4360
|
switch (r) {
|
|
4310
4361
|
case "url": {
|
|
4311
|
-
const
|
|
4312
|
-
|
|
4362
|
+
const S = new URLSearchParams(o);
|
|
4363
|
+
S.set(t, u), a(S, { replace: !0 });
|
|
4313
4364
|
break;
|
|
4314
4365
|
}
|
|
4315
4366
|
case "session":
|
|
4316
|
-
sessionStorage.setItem(
|
|
4367
|
+
sessionStorage.setItem(Ee, u);
|
|
4317
4368
|
break;
|
|
4318
4369
|
case "local":
|
|
4319
|
-
localStorage.setItem(
|
|
4370
|
+
localStorage.setItem(Ie, u);
|
|
4320
4371
|
break;
|
|
4321
4372
|
}
|
|
4322
4373
|
},
|
|
4323
4374
|
[r, o, t, a]
|
|
4324
4375
|
), E = se(
|
|
4325
|
-
(
|
|
4326
|
-
const
|
|
4327
|
-
i(
|
|
4376
|
+
(u) => {
|
|
4377
|
+
const S = f[u] || f.default;
|
|
4378
|
+
i(S);
|
|
4328
4379
|
},
|
|
4329
|
-
[i,
|
|
4330
|
-
),
|
|
4380
|
+
[i, f]
|
|
4381
|
+
), P = se(() => x ? p ? h === oe.TENANT_ADMIN ? f.tenantAdmin : f.tenantUser : f.tenantGuest : p ? h === oe.TENANT_ADMIN ? f.publicAdmin : f.publicUser : f.publicGuest, [x, p, h, f]);
|
|
4331
4382
|
return {
|
|
4332
4383
|
returnToUrl: R,
|
|
4333
|
-
clearReturnTo:
|
|
4334
|
-
setReturnTo:
|
|
4384
|
+
clearReturnTo: N,
|
|
4385
|
+
setReturnTo: D,
|
|
4335
4386
|
navigateToZone: E,
|
|
4336
|
-
getSmartRedirect:
|
|
4387
|
+
getSmartRedirect: P
|
|
4337
4388
|
};
|
|
4338
4389
|
}
|
|
4339
|
-
function
|
|
4390
|
+
function tn(n, e, t = Xe, r = "url") {
|
|
4340
4391
|
if (!e || r !== "url")
|
|
4341
4392
|
return n;
|
|
4342
4393
|
const i = new URL(n, window.location.origin);
|
|
4343
4394
|
return i.searchParams.set(t, e), i.pathname + i.search;
|
|
4344
4395
|
}
|
|
4345
4396
|
export {
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4397
|
+
Fr as AdminZone,
|
|
4398
|
+
Xr as ApiMappers,
|
|
4399
|
+
qe as AppApiService,
|
|
4400
|
+
Gr as AppLoader,
|
|
4401
|
+
mr as AppProvider,
|
|
4351
4402
|
yt as AuthApiService,
|
|
4352
4403
|
Sr as AuthProvider,
|
|
4353
|
-
|
|
4404
|
+
Nr as AuthenticatedZone,
|
|
4354
4405
|
Je as DEFAULT_ZONE_PRESETS,
|
|
4355
|
-
|
|
4406
|
+
Ue as DEFAULT_ZONE_ROOTS,
|
|
4356
4407
|
qr as FeatureFlag,
|
|
4357
4408
|
Pt as FeatureFlagApiService,
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4409
|
+
Tr as FeatureFlagProvider,
|
|
4410
|
+
Dr as GuestZone,
|
|
4411
|
+
Yr as HealthApiService,
|
|
4361
4412
|
le as HttpService,
|
|
4362
4413
|
Ir as LandingRoute,
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4414
|
+
zr as LoginForm,
|
|
4415
|
+
Wr as MagicLinkForm,
|
|
4416
|
+
Vr as MagicLinkVerify,
|
|
4417
|
+
$r as OpenZone,
|
|
4418
|
+
jr as PasswordRecoveryForm,
|
|
4419
|
+
Zr as PermissionApiService,
|
|
4420
|
+
Pr as Protected,
|
|
4421
|
+
Rr as ProtectedRoute,
|
|
4422
|
+
Lr as PublicZone,
|
|
4372
4423
|
ze as RoleApiService,
|
|
4373
|
-
|
|
4424
|
+
xr as RoutingProvider,
|
|
4374
4425
|
ne as SessionExpiredError,
|
|
4375
4426
|
we as SessionManager,
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4427
|
+
_r as SignupForm,
|
|
4428
|
+
Et as SubscriptionApiService,
|
|
4429
|
+
Or as SubscriptionGuard,
|
|
4430
|
+
Jr as SubscriptionPlanApiService,
|
|
4431
|
+
kr as SubscriptionProvider,
|
|
4381
4432
|
be as TenantApiService,
|
|
4382
4433
|
Ur as TenantAuthenticatedZone,
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4434
|
+
Br as TenantGuestZone,
|
|
4435
|
+
Hr as TenantOpenZone,
|
|
4436
|
+
wr as TenantProvider,
|
|
4437
|
+
Er as TenantRoute,
|
|
4438
|
+
Kr as TenantSelector,
|
|
4439
|
+
Mr as TenantZone,
|
|
4389
4440
|
mt as TokenRefreshError,
|
|
4390
4441
|
gt as TokenRefreshTimeoutError,
|
|
4391
4442
|
wt as UserApiService,
|
|
4392
4443
|
oe as UserType,
|
|
4393
|
-
|
|
4444
|
+
Cr as UserZone,
|
|
4394
4445
|
ce as ZoneRoute,
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4446
|
+
tn as buildRedirectUrl,
|
|
4447
|
+
yr as useApi,
|
|
4448
|
+
Se as useApp,
|
|
4449
|
+
Qr as useAppLoaderState,
|
|
4399
4450
|
ue as useAuth,
|
|
4400
4451
|
Rt as useFeatureFlags,
|
|
4401
|
-
|
|
4452
|
+
Ar as useRouting,
|
|
4402
4453
|
Mt as useRoutingOptional,
|
|
4403
|
-
|
|
4404
|
-
|
|
4454
|
+
vr as useSettings,
|
|
4455
|
+
It as useSubscription,
|
|
4405
4456
|
ge as useTenant,
|
|
4406
4457
|
me as useTenantInfo,
|
|
4407
4458
|
xe as useTenantOptional,
|
|
4408
|
-
|
|
4409
|
-
|
|
4459
|
+
br as useTenantSettings,
|
|
4460
|
+
en as useZoneNavigation
|
|
4410
4461
|
};
|
|
4411
4462
|
//# sourceMappingURL=index.es.js.map
|