@skylabs-digital/react-identity-access 2.19.0 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +406 -379
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/services/SessionManager.d.ts +12 -0
- package/dist/services/SessionManager.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as s, Fragment as _, jsxs as d } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as fe, useMemo as
|
|
3
|
-
import { useLocation as
|
|
4
|
-
class
|
|
2
|
+
import { createContext as fe, useMemo as Z, useState as T, useCallback as se, useEffect as ee, useContext as le, useRef as Ke } from "react";
|
|
3
|
+
import { useLocation as ke, Navigate as Se, useNavigate as gt, useSearchParams as mt } from "react-router-dom";
|
|
4
|
+
class ce {
|
|
5
5
|
constructor(e, t = 1e4) {
|
|
6
6
|
this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
|
|
7
7
|
}
|
|
@@ -50,7 +50,7 @@ class le {
|
|
|
50
50
|
return this.executeRequest("DELETE", e, void 0, t);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
class
|
|
53
|
+
class ze {
|
|
54
54
|
constructor(e, t) {
|
|
55
55
|
this.httpService = e, this.sessionManager = t;
|
|
56
56
|
}
|
|
@@ -109,9 +109,9 @@ class Oe {
|
|
|
109
109
|
})).data;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
const
|
|
113
|
-
function
|
|
114
|
-
const t =
|
|
112
|
+
const Fe = fe(null);
|
|
113
|
+
function yr({ config: n, children: e }) {
|
|
114
|
+
const t = Z(
|
|
115
115
|
() => {
|
|
116
116
|
var p, x, R;
|
|
117
117
|
return {
|
|
@@ -132,7 +132,7 @@ function mr({ config: n, children: e }) {
|
|
|
132
132
|
} catch {
|
|
133
133
|
return null;
|
|
134
134
|
}
|
|
135
|
-
}), [o, a] = T(!r), [f, g] = T(null), w =
|
|
135
|
+
}), [o, a] = T(!r), [f, g] = T(null), w = Z(() => {
|
|
136
136
|
const p = () => {
|
|
137
137
|
c();
|
|
138
138
|
};
|
|
@@ -150,7 +150,7 @@ function mr({ config: n, children: e }) {
|
|
|
150
150
|
if (!(!p && t.enabled && r))
|
|
151
151
|
try {
|
|
152
152
|
a(!0), g(null);
|
|
153
|
-
const x = new
|
|
153
|
+
const x = new ce(n.baseUrl), F = await new ze(x, {}).getPublicAppInfo(n.appId);
|
|
154
154
|
if (i(F), t.enabled)
|
|
155
155
|
try {
|
|
156
156
|
const E = {
|
|
@@ -177,7 +177,7 @@ function mr({ config: n, children: e }) {
|
|
|
177
177
|
if (!p) return;
|
|
178
178
|
const x = JSON.parse(p);
|
|
179
179
|
if (Date.now() - x.timestamp > t.ttl * 0.5) {
|
|
180
|
-
const F = new
|
|
180
|
+
const F = new ce(n.baseUrl), A = await new ze(F, {}).getPublicAppInfo(n.appId);
|
|
181
181
|
i(A);
|
|
182
182
|
const u = {
|
|
183
183
|
data: A,
|
|
@@ -192,18 +192,18 @@ function mr({ config: n, children: e }) {
|
|
|
192
192
|
}, [n, t, r]);
|
|
193
193
|
return ee(() => {
|
|
194
194
|
r ? I() : c();
|
|
195
|
-
}, []), /* @__PURE__ */ s(
|
|
195
|
+
}, []), /* @__PURE__ */ s(Fe.Provider, { value: w, children: e });
|
|
196
196
|
}
|
|
197
|
-
function
|
|
198
|
-
const n =
|
|
197
|
+
function ve() {
|
|
198
|
+
const n = le(Fe);
|
|
199
199
|
if (!n)
|
|
200
200
|
throw new Error("useApp must be used within an AppProvider");
|
|
201
201
|
return n;
|
|
202
202
|
}
|
|
203
203
|
function Ze() {
|
|
204
|
-
return
|
|
204
|
+
return le(Fe);
|
|
205
205
|
}
|
|
206
|
-
const
|
|
206
|
+
const wr = ve;
|
|
207
207
|
class ie extends Error {
|
|
208
208
|
constructor(e, t) {
|
|
209
209
|
const r = {
|
|
@@ -214,22 +214,47 @@ class ie extends Error {
|
|
|
214
214
|
super(t || r[e]), this.name = "SessionExpiredError", this.reason = e;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
class
|
|
217
|
+
class yt extends Error {
|
|
218
218
|
constructor(e) {
|
|
219
219
|
super(`Token refresh timed out after ${e}ms`), this.name = "TokenRefreshTimeoutError", this.timeoutMs = e;
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
|
-
class
|
|
222
|
+
class wt extends Error {
|
|
223
223
|
constructor(e, t) {
|
|
224
224
|
super(
|
|
225
225
|
`Token refresh failed after ${e} attempts: ${(t == null ? void 0 : t.message) || "Unknown error"}`
|
|
226
226
|
), this.name = "TokenRefreshError", this.attempts = e, this.lastError = t;
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
|
-
class
|
|
229
|
+
const oe = class oe {
|
|
230
230
|
constructor(e = {}) {
|
|
231
231
|
this.refreshPromise = null, this.refreshQueue = [], this.proactiveTimerId = null, this.backgroundRetryTimerId = null, this.isDestroyed = !1, e.tenantSlug !== void 0 ? this.storageKey = e.tenantSlug ? `auth_tokens_${e.tenantSlug}` : "auth_tokens" : this.storageKey = e.storageKey || "auth_tokens", this.autoRefresh = e.autoRefresh ?? !0, this.refreshThreshold = e.refreshThreshold || 3e5, this.onRefreshFailed = e.onRefreshFailed, this.onSessionExpired = e.onSessionExpired, this.baseUrl = e.baseUrl || "", this.proactiveRefreshMargin = e.proactiveRefreshMargin ?? 6e4, this.refreshQueueTimeout = e.refreshQueueTimeout ?? 1e4, this.maxRefreshRetries = e.maxRefreshRetries ?? 3, this.retryBackoffBase = e.retryBackoffBase ?? 1e3, this.tokenStorage = e.tokenStorage || this.createTokenStorage(this.storageKey), this.scheduleProactiveRefresh();
|
|
232
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Get or create a SessionManager instance for the given config.
|
|
235
|
+
* Returns the same instance when called with the same storageKey/tenantSlug.
|
|
236
|
+
* Mutable config (callbacks, baseUrl) is updated on the existing instance.
|
|
237
|
+
*/
|
|
238
|
+
static getInstance(e = {}) {
|
|
239
|
+
const t = oe.resolveStorageKey(e), r = oe.instances.get(t);
|
|
240
|
+
if (r)
|
|
241
|
+
return r.updateConfig(e), r;
|
|
242
|
+
const i = new oe(e);
|
|
243
|
+
return oe.instances.set(t, i), i;
|
|
244
|
+
}
|
|
245
|
+
/** Reset all singleton instances. For testing only. */
|
|
246
|
+
static resetAllInstances() {
|
|
247
|
+
for (const e of oe.instances.values())
|
|
248
|
+
e.destroy();
|
|
249
|
+
oe.instances.clear();
|
|
250
|
+
}
|
|
251
|
+
static resolveStorageKey(e) {
|
|
252
|
+
return e.storageKey ? e.storageKey : e.tenantSlug !== void 0 && e.tenantSlug ? `auth_tokens_${e.tenantSlug}` : "auth_tokens";
|
|
253
|
+
}
|
|
254
|
+
/** Update mutable config (callbacks, baseUrl) on an existing instance. */
|
|
255
|
+
updateConfig(e) {
|
|
256
|
+
e.onSessionExpired !== void 0 && (this.onSessionExpired = e.onSessionExpired), e.onRefreshFailed !== void 0 && (this.onRefreshFailed = e.onRefreshFailed), e.baseUrl && (this.baseUrl = e.baseUrl);
|
|
257
|
+
}
|
|
233
258
|
// --- Storage helpers ---
|
|
234
259
|
createTokenStorage(e) {
|
|
235
260
|
return {
|
|
@@ -271,7 +296,7 @@ class pe {
|
|
|
271
296
|
}
|
|
272
297
|
}
|
|
273
298
|
setTokens(e) {
|
|
274
|
-
const t = e.expiresAt || (e.expiresIn ? Date.now() + e.expiresIn * 1e3 : void 0) ||
|
|
299
|
+
const t = e.expiresAt || (e.expiresIn ? Date.now() + e.expiresIn * 1e3 : void 0) || oe.extractJwtExpiry(e.accessToken), r = {
|
|
275
300
|
...e,
|
|
276
301
|
expiresAt: t
|
|
277
302
|
};
|
|
@@ -281,7 +306,7 @@ class pe {
|
|
|
281
306
|
const { accessToken: e, refreshToken: t, expiresAt: r, expiresIn: i, tokenType: o } = this.tokenStorage.get() || {};
|
|
282
307
|
if (!e)
|
|
283
308
|
return null;
|
|
284
|
-
const a = r ||
|
|
309
|
+
const a = r || oe.extractJwtExpiry(e);
|
|
285
310
|
return {
|
|
286
311
|
accessToken: e,
|
|
287
312
|
refreshToken: t,
|
|
@@ -372,7 +397,7 @@ class pe {
|
|
|
372
397
|
return new Promise((e, t) => {
|
|
373
398
|
const r = setTimeout(() => {
|
|
374
399
|
const i = this.refreshQueue.findIndex((o) => o.timeoutId === r);
|
|
375
|
-
i !== -1 && this.refreshQueue.splice(i, 1), t(new
|
|
400
|
+
i !== -1 && this.refreshQueue.splice(i, 1), t(new yt(this.refreshQueueTimeout));
|
|
376
401
|
}, this.refreshQueueTimeout);
|
|
377
402
|
this.refreshQueue.push({ resolve: e, reject: t, timeoutId: r });
|
|
378
403
|
});
|
|
@@ -418,7 +443,7 @@ class pe {
|
|
|
418
443
|
await this.sleep(a);
|
|
419
444
|
}
|
|
420
445
|
}
|
|
421
|
-
throw new
|
|
446
|
+
throw new wt(this.maxRefreshRetries + 1, t);
|
|
422
447
|
}
|
|
423
448
|
/**
|
|
424
449
|
* Single refresh attempt with error classification.
|
|
@@ -484,7 +509,7 @@ class pe {
|
|
|
484
509
|
* Cancels all timers and rejects pending queue entries.
|
|
485
510
|
*/
|
|
486
511
|
destroy() {
|
|
487
|
-
this.isDestroyed = !0, this.cancelProactiveTimer();
|
|
512
|
+
this.isDestroyed = !0, oe.instances.delete(this.storageKey), this.cancelProactiveTimer();
|
|
488
513
|
const e = new ie("token_invalid", "SessionManager destroyed");
|
|
489
514
|
this.rejectQueue(e);
|
|
490
515
|
}
|
|
@@ -522,8 +547,10 @@ class pe {
|
|
|
522
547
|
sleep(e) {
|
|
523
548
|
return new Promise((t) => setTimeout(t, e));
|
|
524
549
|
}
|
|
525
|
-
}
|
|
526
|
-
|
|
550
|
+
};
|
|
551
|
+
oe.instances = /* @__PURE__ */ new Map();
|
|
552
|
+
let we = oe;
|
|
553
|
+
class bt {
|
|
527
554
|
constructor(e) {
|
|
528
555
|
this.httpService = e;
|
|
529
556
|
}
|
|
@@ -579,7 +606,7 @@ class wt {
|
|
|
579
606
|
});
|
|
580
607
|
}
|
|
581
608
|
}
|
|
582
|
-
class
|
|
609
|
+
class _e {
|
|
583
610
|
constructor(e, t) {
|
|
584
611
|
this.httpService = e, this.sessionManager = t;
|
|
585
612
|
}
|
|
@@ -655,7 +682,7 @@ class ze {
|
|
|
655
682
|
};
|
|
656
683
|
}
|
|
657
684
|
}
|
|
658
|
-
class
|
|
685
|
+
class St {
|
|
659
686
|
constructor(e, t) {
|
|
660
687
|
this.httpService = e, this.sessionManager = t;
|
|
661
688
|
}
|
|
@@ -695,7 +722,7 @@ class bt {
|
|
|
695
722
|
});
|
|
696
723
|
}
|
|
697
724
|
}
|
|
698
|
-
class
|
|
725
|
+
class be {
|
|
699
726
|
constructor(e, t, r) {
|
|
700
727
|
this.httpService = e, this.appId = t, this.sessionManager = r;
|
|
701
728
|
}
|
|
@@ -773,7 +800,7 @@ class we {
|
|
|
773
800
|
)).data;
|
|
774
801
|
}
|
|
775
802
|
}
|
|
776
|
-
function
|
|
803
|
+
function vt(n, e) {
|
|
777
804
|
if (n === "localhost" || n.startsWith("127.") || n.startsWith("192.168."))
|
|
778
805
|
return null;
|
|
779
806
|
if (e) {
|
|
@@ -789,26 +816,26 @@ function St(n, e) {
|
|
|
789
816
|
const r = n.split(".");
|
|
790
817
|
return r.length >= 3 && r[0] !== "www" ? r[0] : null;
|
|
791
818
|
}
|
|
792
|
-
function
|
|
819
|
+
function Tt(n, e = "tenant", t) {
|
|
793
820
|
const i = new URLSearchParams(n).get(e);
|
|
794
821
|
return i ? (t && t.setItem("tenant", i), i) : t ? t.getItem("tenant") : null;
|
|
795
822
|
}
|
|
796
|
-
function
|
|
823
|
+
function kt(n, e, t) {
|
|
797
824
|
const { tenantMode: r, baseDomain: i, selectorParam: o, fixedTenantSlug: a } = n;
|
|
798
|
-
return r === "fixed" ? a || null : r === "subdomain" ?
|
|
825
|
+
return r === "fixed" ? a || null : r === "subdomain" ? vt(e.hostname, i) : r === "selector" ? Tt(e.search, o, t) : null;
|
|
799
826
|
}
|
|
800
|
-
function
|
|
827
|
+
function xt(n, e, t) {
|
|
801
828
|
if (t)
|
|
802
829
|
return `${n}.${t}`;
|
|
803
830
|
const r = e.split(".");
|
|
804
831
|
return r.length === 2 ? `${n}.${e}` : r.length >= 3 ? (r[0] = n, r.join(".")) : null;
|
|
805
832
|
}
|
|
806
|
-
const
|
|
807
|
-
function
|
|
833
|
+
const pe = "_auth";
|
|
834
|
+
function We(n) {
|
|
808
835
|
const e = JSON.stringify(n);
|
|
809
836
|
return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
810
837
|
}
|
|
811
|
-
function
|
|
838
|
+
function At(n) {
|
|
812
839
|
try {
|
|
813
840
|
let e = n.replace(/-/g, "+").replace(/_/g, "/");
|
|
814
841
|
for (; e.length % 4; )
|
|
@@ -819,16 +846,16 @@ function xt(n) {
|
|
|
819
846
|
return null;
|
|
820
847
|
}
|
|
821
848
|
}
|
|
822
|
-
function
|
|
849
|
+
function Pt() {
|
|
823
850
|
if (typeof window > "u")
|
|
824
851
|
return console.log("[CrossDomainAuth] SSR environment, skipping URL token extraction"), null;
|
|
825
|
-
const e = new URLSearchParams(window.location.search).get(
|
|
852
|
+
const e = new URLSearchParams(window.location.search).get(pe);
|
|
826
853
|
if (console.log("[CrossDomainAuth] extractAuthTokensFromUrl called", {
|
|
827
854
|
hasAuthParam: !!e,
|
|
828
855
|
searchParams: window.location.search,
|
|
829
856
|
encodedLength: e == null ? void 0 : e.length
|
|
830
857
|
}), !e) return null;
|
|
831
|
-
const t =
|
|
858
|
+
const t = At(e);
|
|
832
859
|
return console.log("[CrossDomainAuth] Token decode result:", {
|
|
833
860
|
success: !!t,
|
|
834
861
|
hasAccessToken: !!(t != null && t.accessToken),
|
|
@@ -836,17 +863,17 @@ function At() {
|
|
|
836
863
|
expiresIn: t == null ? void 0 : t.expiresIn
|
|
837
864
|
}), t;
|
|
838
865
|
}
|
|
839
|
-
function
|
|
866
|
+
function Rt() {
|
|
840
867
|
if (typeof window > "u") return;
|
|
841
868
|
const n = new URL(window.location.href);
|
|
842
|
-
n.searchParams.delete(
|
|
869
|
+
n.searchParams.delete(pe), console.log("[CrossDomainAuth] Clearing auth tokens from URL", {
|
|
843
870
|
oldUrl: window.location.href,
|
|
844
871
|
newUrl: n.toString()
|
|
845
872
|
}), window.history.replaceState({}, "", n.toString());
|
|
846
873
|
}
|
|
847
|
-
const
|
|
848
|
-
function
|
|
849
|
-
const { baseUrl: t, appInfo: r, appId: i } =
|
|
874
|
+
const De = fe(null);
|
|
875
|
+
function br({ config: n, children: e }) {
|
|
876
|
+
const { baseUrl: t, appInfo: r, appId: i } = ve(), o = se(() => typeof window > "u" ? null : kt(
|
|
850
877
|
{
|
|
851
878
|
tenantMode: n.tenantMode || "selector",
|
|
852
879
|
baseDomain: n.baseDomain,
|
|
@@ -858,7 +885,7 @@ function wr({ config: n, children: e }) {
|
|
|
858
885
|
search: window.location.search
|
|
859
886
|
},
|
|
860
887
|
window.localStorage
|
|
861
|
-
), [n.tenantMode, n.baseDomain, n.selectorParam, n.fixedTenantSlug]), [a, f] = T(() => o()), g =
|
|
888
|
+
), [n.tenantMode, n.baseDomain, n.selectorParam, n.fixedTenantSlug]), [a, f] = T(() => o()), g = Z(
|
|
862
889
|
() => {
|
|
863
890
|
var h, C, S;
|
|
864
891
|
return {
|
|
@@ -891,7 +918,7 @@ function wr({ config: n, children: e }) {
|
|
|
891
918
|
if (!(!C && g.enabled && w && w.domain === h))
|
|
892
919
|
try {
|
|
893
920
|
p(!0), R(null);
|
|
894
|
-
const S = new
|
|
921
|
+
const S = new ce(t), y = await new be(S, i).getPublicTenantInfo(h);
|
|
895
922
|
if (c(y), g.enabled)
|
|
896
923
|
try {
|
|
897
924
|
const v = {
|
|
@@ -918,7 +945,7 @@ function wr({ config: n, children: e }) {
|
|
|
918
945
|
if (!h) return;
|
|
919
946
|
const C = JSON.parse(h);
|
|
920
947
|
if (Date.now() - C.timestamp > g.ttl * 0.5) {
|
|
921
|
-
const b = new
|
|
948
|
+
const b = new ce(t), v = await new be(b, i).getPublicTenantInfo(a);
|
|
922
949
|
c(v);
|
|
923
950
|
const j = {
|
|
924
951
|
data: v,
|
|
@@ -934,7 +961,7 @@ function wr({ config: n, children: e }) {
|
|
|
934
961
|
if (w != null && w.id)
|
|
935
962
|
try {
|
|
936
963
|
u(!0), m(null);
|
|
937
|
-
const h = new
|
|
964
|
+
const h = new ce(t), S = await new be(h, w.appId).getTenantSettings(w.id);
|
|
938
965
|
E(S);
|
|
939
966
|
} catch (h) {
|
|
940
967
|
const C = h instanceof Error ? h : new Error("Failed to load tenant settings");
|
|
@@ -997,7 +1024,7 @@ function wr({ config: n, children: e }) {
|
|
|
997
1024
|
return;
|
|
998
1025
|
}
|
|
999
1026
|
if (localStorage.setItem("tenant", h), v === "subdomain") {
|
|
1000
|
-
const j = window.location.hostname, Q =
|
|
1027
|
+
const j = window.location.hostname, Q = xt(
|
|
1001
1028
|
h,
|
|
1002
1029
|
j,
|
|
1003
1030
|
n.baseDomain
|
|
@@ -1011,11 +1038,11 @@ function wr({ config: n, children: e }) {
|
|
|
1011
1038
|
}
|
|
1012
1039
|
const O = y || window.location.pathname, q = new URL(`${window.location.protocol}//${Q}${O}`);
|
|
1013
1040
|
new URLSearchParams(window.location.search).forEach((B, X) => {
|
|
1014
|
-
X !==
|
|
1015
|
-
}), b && q.searchParams.set(
|
|
1041
|
+
X !== pe && q.searchParams.set(X, B);
|
|
1042
|
+
}), b && q.searchParams.set(pe, We(b)), window.location.href = q.toString();
|
|
1016
1043
|
} else if (v === "selector") {
|
|
1017
1044
|
const j = y || window.location.pathname, Q = new URLSearchParams(window.location.search);
|
|
1018
|
-
if (Q.set(n.selectorParam || "tenant", h), Q.delete(
|
|
1045
|
+
if (Q.set(n.selectorParam || "tenant", h), Q.delete(pe), b && Q.set(pe, We(b)), S === "reload") {
|
|
1019
1046
|
const O = `${j}?${Q.toString()}${window.location.hash}`;
|
|
1020
1047
|
window.location.href = O;
|
|
1021
1048
|
} else {
|
|
@@ -1025,7 +1052,7 @@ function wr({ config: n, children: e }) {
|
|
|
1025
1052
|
}
|
|
1026
1053
|
},
|
|
1027
1054
|
[n.tenantMode, n.selectorParam, n.baseDomain, L]
|
|
1028
|
-
), $ =
|
|
1055
|
+
), $ = Z(() => ({
|
|
1029
1056
|
// Tenant info
|
|
1030
1057
|
tenant: w,
|
|
1031
1058
|
tenantSlug: a,
|
|
@@ -1057,19 +1084,19 @@ function wr({ config: n, children: e }) {
|
|
|
1057
1084
|
N,
|
|
1058
1085
|
l
|
|
1059
1086
|
]);
|
|
1060
|
-
return /* @__PURE__ */ s(
|
|
1087
|
+
return /* @__PURE__ */ s(De.Provider, { value: $, children: e });
|
|
1061
1088
|
}
|
|
1062
1089
|
function ge() {
|
|
1063
|
-
const n =
|
|
1090
|
+
const n = le(De);
|
|
1064
1091
|
if (!n)
|
|
1065
1092
|
throw new Error("useTenant must be used within a TenantProvider");
|
|
1066
1093
|
return n;
|
|
1067
1094
|
}
|
|
1068
|
-
function
|
|
1069
|
-
return
|
|
1095
|
+
function xe() {
|
|
1096
|
+
return le(De);
|
|
1070
1097
|
}
|
|
1071
|
-
const
|
|
1072
|
-
function
|
|
1098
|
+
const Sr = ge;
|
|
1099
|
+
function vr() {
|
|
1073
1100
|
const { settings: n, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: i } = ge();
|
|
1074
1101
|
return {
|
|
1075
1102
|
settings: n,
|
|
@@ -1089,35 +1116,35 @@ function me() {
|
|
|
1089
1116
|
retry: i
|
|
1090
1117
|
};
|
|
1091
1118
|
}
|
|
1092
|
-
const
|
|
1093
|
-
function
|
|
1094
|
-
const { appId: t, baseUrl: r } =
|
|
1119
|
+
const Ne = fe(null);
|
|
1120
|
+
function Tr({ config: n = {}, children: e }) {
|
|
1121
|
+
const { appId: t, baseUrl: r } = ve(), { tenant: i, tenantSlug: o, switchTenant: a } = ge(), [f, g] = T(n.initialRoles || []), [w, c] = T(!n.initialRoles), [I, p] = T(null), [x, R] = T(!1), [F, E] = T(null), [A, u] = T(0), [k, m] = T(() => {
|
|
1095
1122
|
try {
|
|
1096
1123
|
const G = localStorage.getItem("userTenants");
|
|
1097
1124
|
return G ? JSON.parse(G) : [];
|
|
1098
1125
|
} catch {
|
|
1099
1126
|
return [];
|
|
1100
1127
|
}
|
|
1101
|
-
}), [M, L] = T(!1), D =
|
|
1102
|
-
D.current.done || (D.current.done = !0, D.current.urlTokens =
|
|
1128
|
+
}), [M, L] = T(!1), D = Ke({ done: !1, urlTokens: null });
|
|
1129
|
+
D.current.done || (D.current.done = !0, D.current.urlTokens = Pt(), D.current.urlTokens && console.log(
|
|
1103
1130
|
"[AuthProvider] SYNC: URL tokens found, will block isAuthReady until user loaded"
|
|
1104
1131
|
));
|
|
1105
1132
|
const [P, U] = T(() => {
|
|
1106
1133
|
const G = D.current.urlTokens !== null;
|
|
1107
1134
|
return console.log("[AuthProvider] SYNC: isLoadingAfterUrlTokens initial:", G), G;
|
|
1108
|
-
}), l =
|
|
1109
|
-
const G =
|
|
1135
|
+
}), l = Z(() => {
|
|
1136
|
+
const G = we.getInstance({
|
|
1110
1137
|
tenantSlug: o,
|
|
1111
1138
|
baseUrl: r,
|
|
1112
1139
|
refreshQueueTimeout: n.refreshQueueTimeout,
|
|
1113
1140
|
proactiveRefreshMargin: n.proactiveRefreshMargin,
|
|
1114
|
-
onSessionExpired: (
|
|
1141
|
+
onSessionExpired: (he) => {
|
|
1115
1142
|
p(null), E(null), m([]), L(!1);
|
|
1116
1143
|
try {
|
|
1117
1144
|
localStorage.removeItem("userTenants");
|
|
1118
1145
|
} catch {
|
|
1119
1146
|
}
|
|
1120
|
-
n.onSessionExpired ? n.onSessionExpired(
|
|
1147
|
+
n.onSessionExpired ? n.onSessionExpired(he) : n.onRefreshFailed && n.onRefreshFailed();
|
|
1121
1148
|
}
|
|
1122
1149
|
});
|
|
1123
1150
|
return D.current.urlTokens && (console.log("[AuthProvider] SYNC: Saving URL tokens to session manager"), G.setTokens({
|
|
@@ -1125,10 +1152,10 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1125
1152
|
refreshToken: D.current.urlTokens.refreshToken,
|
|
1126
1153
|
expiresIn: D.current.urlTokens.expiresIn
|
|
1127
1154
|
}), console.log("[AuthProvider] SYNC: Session valid:", G.hasValidSession())), G;
|
|
1128
|
-
}, [o, r, n.refreshQueueTimeout, n.proactiveRefreshMargin]), [N, $] = T(() => D.current.urlTokens ? !1 : l.hasValidSession()), h = D.current.done && !P && !N, C =
|
|
1129
|
-
const G = new
|
|
1155
|
+
}, [o, r, n.refreshQueueTimeout, n.proactiveRefreshMargin]), [N, $] = T(() => D.current.urlTokens ? !1 : l.hasValidSession()), h = D.current.done && !P && !N, C = Z(() => {
|
|
1156
|
+
const G = new ce(r);
|
|
1130
1157
|
return G.setSessionManager(l), G;
|
|
1131
|
-
}, [r, l]), S =
|
|
1158
|
+
}, [r, l]), S = Z(() => new bt(new ce(r)), [r]), b = Z(() => new St(C, l), [C, l]), y = Z(() => new _e(new ce(r)), [r]), v = Z(() => I || l.getUser(), [I, l]), j = Z(() => v != null && v.roleId && f.find((G) => G.id === v.roleId) || null, [v, f]), Q = Z(() => (j == null ? void 0 : j.permissions) || [], [j]), O = Z(() => l.hasValidSession() && I !== null, [l, I]), q = 5 * 60 * 1e3, W = Z(() => {
|
|
1132
1159
|
const G = async (H = !1) => {
|
|
1133
1160
|
try {
|
|
1134
1161
|
if (!l.hasValidSession())
|
|
@@ -1142,112 +1169,112 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1142
1169
|
return;
|
|
1143
1170
|
}
|
|
1144
1171
|
R(!0), E(null);
|
|
1145
|
-
const
|
|
1146
|
-
p(
|
|
1172
|
+
const J = await b.getUserById(V);
|
|
1173
|
+
p(J), l.setUser(J), u(Date.now());
|
|
1147
1174
|
} catch (z) {
|
|
1148
1175
|
const Y = z instanceof Error ? z : new Error("Failed to load user data");
|
|
1149
1176
|
E(Y), console.error("[AuthProvider] Failed to load user data:", Y);
|
|
1150
1177
|
} finally {
|
|
1151
1178
|
R(!1);
|
|
1152
1179
|
}
|
|
1153
|
-
},
|
|
1180
|
+
}, he = async () => {
|
|
1154
1181
|
await G();
|
|
1155
|
-
},
|
|
1156
|
-
var
|
|
1157
|
-
const { username: z, password: Y, tenantSlug: V, redirectPath:
|
|
1182
|
+
}, Ae = async (H) => {
|
|
1183
|
+
var qe;
|
|
1184
|
+
const { username: z, password: Y, tenantSlug: V, redirectPath: J } = H;
|
|
1158
1185
|
let te = i == null ? void 0 : i.id, re = o, ne = l;
|
|
1159
|
-
V && (te = (await new
|
|
1160
|
-
const
|
|
1186
|
+
V && (te = (await new be(C, t).getPublicTenantInfo(V)).id, re = V);
|
|
1187
|
+
const K = await S.login({
|
|
1161
1188
|
username: z,
|
|
1162
1189
|
password: Y,
|
|
1163
1190
|
appId: t,
|
|
1164
1191
|
tenantId: te
|
|
1165
1192
|
}), ye = V && V !== o;
|
|
1166
|
-
if (ye && (ne = new
|
|
1193
|
+
if (ye && (ne = new we({
|
|
1167
1194
|
tenantSlug: re,
|
|
1168
1195
|
baseUrl: r
|
|
1169
1196
|
})), ne.setTokens({
|
|
1170
|
-
accessToken:
|
|
1171
|
-
refreshToken:
|
|
1172
|
-
expiresIn:
|
|
1173
|
-
}),
|
|
1174
|
-
ne.setUser(
|
|
1197
|
+
accessToken: K.accessToken,
|
|
1198
|
+
refreshToken: K.refreshToken,
|
|
1199
|
+
expiresIn: K.expiresIn
|
|
1200
|
+
}), K.user) {
|
|
1201
|
+
ne.setUser(K.user), p(K.user);
|
|
1175
1202
|
try {
|
|
1176
1203
|
await G();
|
|
1177
|
-
} catch (
|
|
1178
|
-
console.warn("Failed to load complete user data after login:",
|
|
1204
|
+
} catch (Te) {
|
|
1205
|
+
console.warn("Failed to load complete user data after login:", Te);
|
|
1179
1206
|
}
|
|
1180
1207
|
}
|
|
1181
|
-
if (
|
|
1182
|
-
m(
|
|
1208
|
+
if (K.tenants && K.tenants.length > 0) {
|
|
1209
|
+
m(K.tenants);
|
|
1183
1210
|
try {
|
|
1184
|
-
localStorage.setItem("userTenants", JSON.stringify(
|
|
1211
|
+
localStorage.setItem("userTenants", JSON.stringify(K.tenants));
|
|
1185
1212
|
} catch {
|
|
1186
1213
|
}
|
|
1187
1214
|
}
|
|
1188
|
-
const
|
|
1189
|
-
L(
|
|
1190
|
-
const
|
|
1191
|
-
accessToken:
|
|
1192
|
-
refreshToken:
|
|
1193
|
-
expiresIn:
|
|
1215
|
+
const Ie = ((qe = K.user) == null ? void 0 : qe.tenantId) !== null;
|
|
1216
|
+
L(Ie);
|
|
1217
|
+
const Ee = {
|
|
1218
|
+
accessToken: K.accessToken,
|
|
1219
|
+
refreshToken: K.refreshToken,
|
|
1220
|
+
expiresIn: K.expiresIn
|
|
1194
1221
|
};
|
|
1195
1222
|
if (ye && re)
|
|
1196
|
-
return a(re, { tokens:
|
|
1197
|
-
if (
|
|
1198
|
-
return a(re || o || "", { tokens:
|
|
1199
|
-
if (!
|
|
1200
|
-
const
|
|
1201
|
-
if (
|
|
1202
|
-
const
|
|
1203
|
-
return a(
|
|
1204
|
-
} else
|
|
1223
|
+
return a(re, { tokens: Ee, redirectPath: J }), K;
|
|
1224
|
+
if (J && J !== window.location.pathname)
|
|
1225
|
+
return a(re || o || "", { tokens: Ee, redirectPath: J }), K;
|
|
1226
|
+
if (!Ie && K.tenants && K.tenants.length > 0) {
|
|
1227
|
+
const Te = H.autoSwitch !== !1 && n.autoSwitchSingleTenant !== !1;
|
|
1228
|
+
if (K.tenants.length === 1 && Te) {
|
|
1229
|
+
const Oe = K.tenants[0];
|
|
1230
|
+
return a(Oe.subdomain, { tokens: Ee, redirectPath: J }), K;
|
|
1231
|
+
} else K.tenants.length > 1 && n.onTenantSelectionRequired && n.onTenantSelectionRequired(K.tenants);
|
|
1205
1232
|
}
|
|
1206
|
-
return
|
|
1207
|
-
},
|
|
1208
|
-
const { email: z, phoneNumber: Y, name: V, password:
|
|
1233
|
+
return K;
|
|
1234
|
+
}, Pe = async (H) => {
|
|
1235
|
+
const { email: z, phoneNumber: Y, name: V, password: J, lastName: te, tenantId: re } = H;
|
|
1209
1236
|
if (!z && !Y)
|
|
1210
1237
|
throw new Error("Either email or phoneNumber is required");
|
|
1211
|
-
if (!V || !
|
|
1238
|
+
if (!V || !J)
|
|
1212
1239
|
throw new Error("Name and password are required");
|
|
1213
1240
|
const ne = re ?? (i == null ? void 0 : i.id);
|
|
1214
1241
|
return await S.signup({
|
|
1215
1242
|
email: z,
|
|
1216
1243
|
phoneNumber: Y,
|
|
1217
1244
|
name: V,
|
|
1218
|
-
password:
|
|
1245
|
+
password: J,
|
|
1219
1246
|
tenantId: ne,
|
|
1220
1247
|
lastName: te,
|
|
1221
1248
|
appId: t
|
|
1222
1249
|
});
|
|
1223
|
-
},
|
|
1224
|
-
const { email: z, phoneNumber: Y, name: V, password:
|
|
1250
|
+
}, rt = async (H) => {
|
|
1251
|
+
const { email: z, phoneNumber: Y, name: V, password: J, tenantName: te, lastName: re } = H;
|
|
1225
1252
|
if (!z && !Y)
|
|
1226
1253
|
throw new Error("Either email or phoneNumber is required");
|
|
1227
|
-
if (!V || !
|
|
1254
|
+
if (!V || !J || !te)
|
|
1228
1255
|
throw new Error("Name, password, and tenantName are required");
|
|
1229
1256
|
return await S.signupTenantAdmin({
|
|
1230
1257
|
email: z,
|
|
1231
1258
|
phoneNumber: Y,
|
|
1232
1259
|
name: V,
|
|
1233
|
-
password:
|
|
1260
|
+
password: J,
|
|
1234
1261
|
tenantName: te,
|
|
1235
1262
|
appId: t,
|
|
1236
1263
|
lastName: re
|
|
1237
1264
|
});
|
|
1238
|
-
},
|
|
1265
|
+
}, nt = async (H) => {
|
|
1239
1266
|
const { currentPassword: z, newPassword: Y } = H, V = await l.getAuthHeaders();
|
|
1240
1267
|
await S.changePassword({ currentPassword: z, newPassword: Y }, V);
|
|
1241
|
-
},
|
|
1268
|
+
}, st = async (H) => {
|
|
1242
1269
|
const { email: z, tenantId: Y } = H, V = Y ?? (i == null ? void 0 : i.id);
|
|
1243
1270
|
if (!V)
|
|
1244
1271
|
throw new Error("tenantId is required for password reset");
|
|
1245
1272
|
await S.requestPasswordReset({ email: z, tenantId: V });
|
|
1246
|
-
},
|
|
1273
|
+
}, it = async (H) => {
|
|
1247
1274
|
const { token: z, newPassword: Y } = H;
|
|
1248
1275
|
await S.confirmPasswordReset({ token: z, newPassword: Y });
|
|
1249
|
-
},
|
|
1250
|
-
const { email: z, frontendUrl: Y, name: V, lastName:
|
|
1276
|
+
}, ot = async (H) => {
|
|
1277
|
+
const { email: z, frontendUrl: Y, name: V, lastName: J, tenantId: te } = H, re = te ?? (i == null ? void 0 : i.id);
|
|
1251
1278
|
if (!re)
|
|
1252
1279
|
throw new Error("tenantId is required for magic link authentication");
|
|
1253
1280
|
return await S.sendMagicLink({
|
|
@@ -1255,20 +1282,20 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1255
1282
|
tenantId: re,
|
|
1256
1283
|
frontendUrl: Y,
|
|
1257
1284
|
name: V,
|
|
1258
|
-
lastName:
|
|
1285
|
+
lastName: J,
|
|
1259
1286
|
appId: t
|
|
1260
1287
|
});
|
|
1261
|
-
},
|
|
1288
|
+
}, at = async (H) => {
|
|
1262
1289
|
const { token: z, email: Y, tenantSlug: V } = H;
|
|
1263
|
-
let
|
|
1264
|
-
V && (
|
|
1290
|
+
let J = i == null ? void 0 : i.id, te = o, re = l;
|
|
1291
|
+
V && (J = (await new be(C, t).getPublicTenantInfo(V)).id, te = V);
|
|
1265
1292
|
const ne = await S.verifyMagicLink({
|
|
1266
1293
|
token: z,
|
|
1267
1294
|
email: Y,
|
|
1268
1295
|
appId: t,
|
|
1269
|
-
tenantId:
|
|
1270
|
-
}),
|
|
1271
|
-
if (
|
|
1296
|
+
tenantId: J
|
|
1297
|
+
}), K = V && V !== o;
|
|
1298
|
+
if (K && (re = new we({
|
|
1272
1299
|
tenantSlug: te,
|
|
1273
1300
|
baseUrl: r
|
|
1274
1301
|
})), re.setTokens({
|
|
@@ -1283,14 +1310,14 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1283
1310
|
console.warn("Failed to load complete user data after magic link login:", ye);
|
|
1284
1311
|
}
|
|
1285
1312
|
}
|
|
1286
|
-
return
|
|
1313
|
+
return K && te && te !== o && a(te, {
|
|
1287
1314
|
tokens: {
|
|
1288
1315
|
accessToken: ne.accessToken,
|
|
1289
1316
|
refreshToken: ne.refreshToken,
|
|
1290
1317
|
expiresIn: ne.expiresIn
|
|
1291
1318
|
}
|
|
1292
1319
|
}), ne;
|
|
1293
|
-
},
|
|
1320
|
+
}, lt = async () => {
|
|
1294
1321
|
const H = l.getTokens();
|
|
1295
1322
|
if (!(H != null && H.refreshToken))
|
|
1296
1323
|
throw new Error("No refresh token available");
|
|
@@ -1302,17 +1329,17 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1302
1329
|
refreshToken: z.refreshToken || H.refreshToken,
|
|
1303
1330
|
expiresIn: z.expiresIn
|
|
1304
1331
|
});
|
|
1305
|
-
},
|
|
1332
|
+
}, ct = () => {
|
|
1306
1333
|
l.clearSession(), p(null), E(null), m([]), L(!1);
|
|
1307
1334
|
try {
|
|
1308
1335
|
localStorage.removeItem("userTenants");
|
|
1309
1336
|
} catch {
|
|
1310
1337
|
}
|
|
1311
|
-
},
|
|
1338
|
+
}, dt = (H) => {
|
|
1312
1339
|
l.setTokens(H);
|
|
1313
|
-
},
|
|
1340
|
+
}, ut = () => l.hasValidSession(), ht = () => {
|
|
1314
1341
|
l.clearSession(), p(null), E(null);
|
|
1315
|
-
},
|
|
1342
|
+
}, pt = async () => {
|
|
1316
1343
|
if (t)
|
|
1317
1344
|
try {
|
|
1318
1345
|
c(!0);
|
|
@@ -1323,9 +1350,9 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1323
1350
|
} finally {
|
|
1324
1351
|
c(!1);
|
|
1325
1352
|
}
|
|
1326
|
-
},
|
|
1327
|
-
await
|
|
1328
|
-
},
|
|
1353
|
+
}, ft = async () => {
|
|
1354
|
+
await pt();
|
|
1355
|
+
}, Re = (H) => {
|
|
1329
1356
|
if (!Q || Q.length === 0)
|
|
1330
1357
|
return !1;
|
|
1331
1358
|
if (typeof H == "string")
|
|
@@ -1338,35 +1365,35 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1338
1365
|
isAuthenticated: O,
|
|
1339
1366
|
sessionManager: l,
|
|
1340
1367
|
authenticatedHttpService: C,
|
|
1341
|
-
login:
|
|
1342
|
-
signup:
|
|
1343
|
-
signupTenantAdmin:
|
|
1344
|
-
sendMagicLink:
|
|
1345
|
-
verifyMagicLink:
|
|
1346
|
-
changePassword:
|
|
1347
|
-
requestPasswordReset:
|
|
1348
|
-
confirmPasswordReset:
|
|
1349
|
-
refreshToken:
|
|
1350
|
-
logout:
|
|
1351
|
-
setTokens:
|
|
1352
|
-
hasValidSession:
|
|
1353
|
-
clearSession:
|
|
1368
|
+
login: Ae,
|
|
1369
|
+
signup: Pe,
|
|
1370
|
+
signupTenantAdmin: rt,
|
|
1371
|
+
sendMagicLink: ot,
|
|
1372
|
+
verifyMagicLink: at,
|
|
1373
|
+
changePassword: nt,
|
|
1374
|
+
requestPasswordReset: st,
|
|
1375
|
+
confirmPasswordReset: it,
|
|
1376
|
+
refreshToken: lt,
|
|
1377
|
+
logout: ct,
|
|
1378
|
+
setTokens: dt,
|
|
1379
|
+
hasValidSession: ut,
|
|
1380
|
+
clearSession: ht,
|
|
1354
1381
|
currentUser: I,
|
|
1355
1382
|
isUserLoading: x,
|
|
1356
1383
|
userError: F,
|
|
1357
1384
|
loadUserData: G,
|
|
1358
|
-
refreshUser:
|
|
1385
|
+
refreshUser: he,
|
|
1359
1386
|
isAuthInitializing: !h,
|
|
1360
1387
|
isAuthReady: h,
|
|
1361
1388
|
userRole: j,
|
|
1362
1389
|
userPermissions: Q,
|
|
1363
1390
|
availableRoles: f,
|
|
1364
1391
|
rolesLoading: w,
|
|
1365
|
-
hasPermission:
|
|
1366
|
-
hasAnyPermission: (H) => H.some((z) =>
|
|
1367
|
-
hasAllPermissions: (H) => H.every((z) =>
|
|
1392
|
+
hasPermission: Re,
|
|
1393
|
+
hasAnyPermission: (H) => H.some((z) => Re(z)),
|
|
1394
|
+
hasAllPermissions: (H) => H.every((z) => Re(z)),
|
|
1368
1395
|
getUserPermissionStrings: () => Q || [],
|
|
1369
|
-
refreshRoles:
|
|
1396
|
+
refreshRoles: ft,
|
|
1370
1397
|
// RFC-004: Multi-tenant user membership
|
|
1371
1398
|
userTenants: k,
|
|
1372
1399
|
hasTenantContext: M,
|
|
@@ -1374,22 +1401,22 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1374
1401
|
const { redirectPath: Y } = z || {}, V = l.getTokens();
|
|
1375
1402
|
if (!(V != null && V.refreshToken))
|
|
1376
1403
|
throw new Error("No refresh token available for tenant switch");
|
|
1377
|
-
const
|
|
1404
|
+
const J = await S.switchTenant({
|
|
1378
1405
|
refreshToken: V.refreshToken,
|
|
1379
1406
|
tenantId: H
|
|
1380
1407
|
});
|
|
1381
1408
|
l.setTokens({
|
|
1382
|
-
accessToken:
|
|
1409
|
+
accessToken: J.accessToken,
|
|
1383
1410
|
refreshToken: V.refreshToken,
|
|
1384
1411
|
// Keep the same refresh token
|
|
1385
|
-
expiresIn:
|
|
1386
|
-
}), p(
|
|
1412
|
+
expiresIn: J.expiresIn
|
|
1413
|
+
}), p(J.user), l.setUser(J.user), L(!0);
|
|
1387
1414
|
const te = k.find((re) => re.id === H);
|
|
1388
1415
|
te && a(te.subdomain, {
|
|
1389
1416
|
tokens: {
|
|
1390
|
-
accessToken:
|
|
1417
|
+
accessToken: J.accessToken,
|
|
1391
1418
|
refreshToken: V.refreshToken,
|
|
1392
|
-
expiresIn:
|
|
1419
|
+
expiresIn: J.expiresIn
|
|
1393
1420
|
},
|
|
1394
1421
|
redirectPath: Y
|
|
1395
1422
|
});
|
|
@@ -1431,10 +1458,10 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1431
1458
|
!n.initialRoles && t && (async () => {
|
|
1432
1459
|
try {
|
|
1433
1460
|
c(!0);
|
|
1434
|
-
const
|
|
1435
|
-
g(
|
|
1436
|
-
} catch (
|
|
1437
|
-
console.error("Failed to fetch roles:",
|
|
1461
|
+
const he = new ce(r), Ae = new _e(he), { roles: Pe } = await Ae.getRolesByApp(t);
|
|
1462
|
+
g(Pe);
|
|
1463
|
+
} catch (he) {
|
|
1464
|
+
console.error("Failed to fetch roles:", he);
|
|
1438
1465
|
} finally {
|
|
1439
1466
|
c(!1);
|
|
1440
1467
|
}
|
|
@@ -1442,7 +1469,7 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1442
1469
|
}, [t, r, n.initialRoles]);
|
|
1443
1470
|
const [B, X] = T(!1);
|
|
1444
1471
|
return ee(() => {
|
|
1445
|
-
B || (X(!0), D.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"),
|
|
1472
|
+
B || (X(!0), D.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), Rt(), U(!0), console.log("[AuthProvider] EFFECT: Loading user data (blocking isAuthReady)..."), W.loadUserData().catch((G) => {
|
|
1446
1473
|
console.error("[AuthProvider] Failed to load user data:", G);
|
|
1447
1474
|
}).finally(() => {
|
|
1448
1475
|
console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"), U(!1);
|
|
@@ -1463,18 +1490,18 @@ function vr({ config: n = {}, children: e }) {
|
|
|
1463
1490
|
});
|
|
1464
1491
|
}, q);
|
|
1465
1492
|
return () => clearInterval(G);
|
|
1466
|
-
}, [l, I, W, q]), /* @__PURE__ */ s(
|
|
1493
|
+
}, [l, I, W, q]), /* @__PURE__ */ s(Ne.Provider, { value: W, children: e });
|
|
1467
1494
|
}
|
|
1468
|
-
function
|
|
1469
|
-
const n =
|
|
1495
|
+
function ue() {
|
|
1496
|
+
const n = le(Ne);
|
|
1470
1497
|
if (!n)
|
|
1471
1498
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
1472
1499
|
return n;
|
|
1473
1500
|
}
|
|
1474
|
-
function
|
|
1475
|
-
return
|
|
1501
|
+
function Ce() {
|
|
1502
|
+
return le(Ne);
|
|
1476
1503
|
}
|
|
1477
|
-
class
|
|
1504
|
+
class It {
|
|
1478
1505
|
constructor(e, t) {
|
|
1479
1506
|
this.httpService = e, this.sessionManager = t;
|
|
1480
1507
|
}
|
|
@@ -1554,11 +1581,11 @@ class Rt {
|
|
|
1554
1581
|
})).data;
|
|
1555
1582
|
}
|
|
1556
1583
|
}
|
|
1557
|
-
const
|
|
1558
|
-
function
|
|
1559
|
-
const t = Ze(), r =
|
|
1560
|
-
const u = new
|
|
1561
|
-
return new
|
|
1584
|
+
const Ue = fe(null);
|
|
1585
|
+
function kr({ config: n = {}, children: e }) {
|
|
1586
|
+
const t = Ze(), r = xe(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (r == null ? void 0 : r.tenant) ?? null, [f, g] = T([]), [w, c] = T(!1), [I, p] = T(null), [x, R] = T(!1), F = Z(() => {
|
|
1587
|
+
const u = new ce(i);
|
|
1588
|
+
return new It(u);
|
|
1562
1589
|
}, [i]), E = async () => {
|
|
1563
1590
|
if (!(a != null && a.id)) {
|
|
1564
1591
|
g([]);
|
|
@@ -1581,7 +1608,7 @@ function Tr({ config: n = {}, children: e }) {
|
|
|
1581
1608
|
const u = n.refreshInterval || 5 * 60 * 1e3, k = setInterval(E, u);
|
|
1582
1609
|
return () => clearInterval(k);
|
|
1583
1610
|
}, [a == null ? void 0 : a.id, i, o, n.refreshInterval]);
|
|
1584
|
-
const A =
|
|
1611
|
+
const A = Z(() => {
|
|
1585
1612
|
const u = (D) => {
|
|
1586
1613
|
const P = f.find((U) => U.key === D);
|
|
1587
1614
|
return (P == null ? void 0 : P.value) === !0;
|
|
@@ -1602,18 +1629,18 @@ function Tr({ config: n = {}, children: e }) {
|
|
|
1602
1629
|
refresh: M
|
|
1603
1630
|
};
|
|
1604
1631
|
}, [f, w, I, i, o, a == null ? void 0 : a.id, x]);
|
|
1605
|
-
return /* @__PURE__ */ s(
|
|
1632
|
+
return /* @__PURE__ */ s(Ue.Provider, { value: A, children: e });
|
|
1606
1633
|
}
|
|
1607
|
-
function
|
|
1608
|
-
const n =
|
|
1634
|
+
function Et() {
|
|
1635
|
+
const n = le(Ue);
|
|
1609
1636
|
if (!n)
|
|
1610
1637
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1611
1638
|
return n;
|
|
1612
1639
|
}
|
|
1613
1640
|
function Je() {
|
|
1614
|
-
return
|
|
1641
|
+
return le(Ue);
|
|
1615
1642
|
}
|
|
1616
|
-
class
|
|
1643
|
+
class Mt {
|
|
1617
1644
|
constructor(e, t) {
|
|
1618
1645
|
this.httpService = e, this.sessionManager = t;
|
|
1619
1646
|
}
|
|
@@ -1679,11 +1706,11 @@ class Et {
|
|
|
1679
1706
|
)).data;
|
|
1680
1707
|
}
|
|
1681
1708
|
}
|
|
1682
|
-
const
|
|
1683
|
-
function
|
|
1684
|
-
const t = Ze(), r =
|
|
1685
|
-
const A = new
|
|
1686
|
-
return new
|
|
1709
|
+
const $e = fe(void 0);
|
|
1710
|
+
function xr({ config: n = {}, children: e }) {
|
|
1711
|
+
const t = Ze(), r = xe(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a, f] = T(null), [g, w] = T(!1), [c, I] = T(null), [p, x] = T(!1), R = Z(() => {
|
|
1712
|
+
const A = new ce(i);
|
|
1713
|
+
return new Mt(A);
|
|
1687
1714
|
}, [i]), F = async () => {
|
|
1688
1715
|
if (!(o != null && o.id)) {
|
|
1689
1716
|
f(null);
|
|
@@ -1705,7 +1732,7 @@ function kr({ config: n = {}, children: e }) {
|
|
|
1705
1732
|
const A = n.refreshInterval || 10 * 60 * 1e3, u = setInterval(F, A);
|
|
1706
1733
|
return () => clearInterval(u);
|
|
1707
1734
|
}, [o == null ? void 0 : o.id, i, n.refreshInterval]);
|
|
1708
|
-
const E =
|
|
1735
|
+
const E = Z(() => {
|
|
1709
1736
|
const A = (a == null ? void 0 : a.features) || [], u = (P) => {
|
|
1710
1737
|
const U = A.find((l) => l.key === P);
|
|
1711
1738
|
return U ? U.type === "BOOLEAN" || U.type === "boolean" ? U.value === !0 : !!U.value : !1;
|
|
@@ -1728,19 +1755,19 @@ function kr({ config: n = {}, children: e }) {
|
|
|
1728
1755
|
refresh: L
|
|
1729
1756
|
};
|
|
1730
1757
|
}, [a, g, c, i, o == null ? void 0 : o.id, p]);
|
|
1731
|
-
return /* @__PURE__ */ s(
|
|
1758
|
+
return /* @__PURE__ */ s($e.Provider, { value: E, children: e });
|
|
1732
1759
|
}
|
|
1733
|
-
function
|
|
1734
|
-
const n =
|
|
1760
|
+
function Lt() {
|
|
1761
|
+
const n = le($e);
|
|
1735
1762
|
if (n === void 0)
|
|
1736
1763
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1737
1764
|
return n;
|
|
1738
1765
|
}
|
|
1739
|
-
function
|
|
1740
|
-
return
|
|
1766
|
+
function Ye() {
|
|
1767
|
+
return le($e) ?? null;
|
|
1741
1768
|
}
|
|
1742
|
-
var
|
|
1743
|
-
const
|
|
1769
|
+
var ae = /* @__PURE__ */ ((n) => (n.SUPERUSER = "SUPERUSER", n.TENANT_ADMIN = "TENANT_ADMIN", n.USER = "USER", n))(ae || {});
|
|
1770
|
+
const He = {
|
|
1744
1771
|
publicGuest: "/",
|
|
1745
1772
|
publicUser: "/account",
|
|
1746
1773
|
publicAdmin: "/admin",
|
|
@@ -1748,7 +1775,7 @@ const $e = {
|
|
|
1748
1775
|
tenantUser: "/dashboard",
|
|
1749
1776
|
tenantAdmin: "/admin/dashboard",
|
|
1750
1777
|
default: "/"
|
|
1751
|
-
},
|
|
1778
|
+
}, Xe = {
|
|
1752
1779
|
// Public/Landing zones
|
|
1753
1780
|
landing: { tenant: "forbidden", auth: "optional" },
|
|
1754
1781
|
publicOnly: { tenant: "forbidden", auth: "forbidden" },
|
|
@@ -1761,18 +1788,18 @@ const $e = {
|
|
|
1761
1788
|
tenantOpen: { tenant: "required", auth: "optional" },
|
|
1762
1789
|
tenantAuth: { tenant: "required", auth: "required" },
|
|
1763
1790
|
// User type zones
|
|
1764
|
-
user: { tenant: "required", auth: "required", userType:
|
|
1765
|
-
admin: { tenant: "required", auth: "required", userType:
|
|
1791
|
+
user: { tenant: "required", auth: "required", userType: ae.USER },
|
|
1792
|
+
admin: { tenant: "required", auth: "required", userType: ae.TENANT_ADMIN },
|
|
1766
1793
|
// Fully open
|
|
1767
1794
|
open: { tenant: "optional", auth: "optional" }
|
|
1768
|
-
},
|
|
1769
|
-
function
|
|
1770
|
-
const t =
|
|
1795
|
+
}, Be = fe(null);
|
|
1796
|
+
function Ar({ config: n = {}, children: e }) {
|
|
1797
|
+
const t = Z(() => {
|
|
1771
1798
|
const r = {
|
|
1772
|
-
|
|
1799
|
+
...He,
|
|
1773
1800
|
...n.zoneRoots
|
|
1774
1801
|
}, i = {
|
|
1775
|
-
...
|
|
1802
|
+
...Xe,
|
|
1776
1803
|
...n.presets
|
|
1777
1804
|
};
|
|
1778
1805
|
return {
|
|
@@ -1785,19 +1812,19 @@ function xr({ config: n = {}, children: e }) {
|
|
|
1785
1812
|
returnToStorage: n.returnToStorage ?? "url"
|
|
1786
1813
|
};
|
|
1787
1814
|
}, [n]);
|
|
1788
|
-
return /* @__PURE__ */ s(
|
|
1815
|
+
return /* @__PURE__ */ s(Be.Provider, { value: t, children: e });
|
|
1789
1816
|
}
|
|
1790
|
-
function
|
|
1791
|
-
const n =
|
|
1817
|
+
function Pr() {
|
|
1818
|
+
const n = le(Be);
|
|
1792
1819
|
if (!n)
|
|
1793
1820
|
throw new Error("useRouting must be used within a RoutingProvider");
|
|
1794
1821
|
return n;
|
|
1795
1822
|
}
|
|
1796
|
-
function
|
|
1797
|
-
const n =
|
|
1823
|
+
function Ft() {
|
|
1824
|
+
const n = le(Be);
|
|
1798
1825
|
return n || {
|
|
1799
|
-
zoneRoots:
|
|
1800
|
-
presets:
|
|
1826
|
+
zoneRoots: He,
|
|
1827
|
+
presets: Xe,
|
|
1801
1828
|
loadingFallback: null,
|
|
1802
1829
|
accessDeniedFallback: null,
|
|
1803
1830
|
onAccessDenied: void 0,
|
|
@@ -1805,7 +1832,7 @@ function Lt() {
|
|
|
1805
1832
|
returnToStorage: "url"
|
|
1806
1833
|
};
|
|
1807
1834
|
}
|
|
1808
|
-
const
|
|
1835
|
+
const Ve = () => /* @__PURE__ */ d(
|
|
1809
1836
|
"div",
|
|
1810
1837
|
{
|
|
1811
1838
|
style: {
|
|
@@ -1842,7 +1869,7 @@ const We = () => /* @__PURE__ */ d(
|
|
|
1842
1869
|
)
|
|
1843
1870
|
]
|
|
1844
1871
|
}
|
|
1845
|
-
),
|
|
1872
|
+
), je = ({
|
|
1846
1873
|
userType: n,
|
|
1847
1874
|
minUserType: e,
|
|
1848
1875
|
missingPermissions: t
|
|
@@ -1883,36 +1910,36 @@ const We = () => /* @__PURE__ */ d(
|
|
|
1883
1910
|
] })
|
|
1884
1911
|
]
|
|
1885
1912
|
}
|
|
1886
|
-
),
|
|
1913
|
+
), Dt = (n, e) => {
|
|
1887
1914
|
const t = {
|
|
1888
|
-
[
|
|
1889
|
-
[
|
|
1890
|
-
[
|
|
1915
|
+
[ae.USER]: 1,
|
|
1916
|
+
[ae.TENANT_ADMIN]: 2,
|
|
1917
|
+
[ae.SUPERUSER]: 3
|
|
1891
1918
|
};
|
|
1892
1919
|
return t[n] >= t[e];
|
|
1893
1920
|
};
|
|
1894
|
-
function
|
|
1921
|
+
function Rr({
|
|
1895
1922
|
children: n,
|
|
1896
1923
|
fallback: e,
|
|
1897
1924
|
minUserType: t,
|
|
1898
1925
|
requiredPermissions: r,
|
|
1899
1926
|
requireAllPermissions: i = !1
|
|
1900
1927
|
}) {
|
|
1901
|
-
const { hasValidSession: o, sessionManager: a, hasPermission: f, hasAnyPermission: g, hasAllPermissions: w } =
|
|
1928
|
+
const { hasValidSession: o, sessionManager: a, hasPermission: f, hasAnyPermission: g, hasAllPermissions: w } = ue();
|
|
1902
1929
|
if (!o())
|
|
1903
|
-
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(
|
|
1930
|
+
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(Ve, {}) });
|
|
1904
1931
|
const c = a.getUser();
|
|
1905
1932
|
if (!c)
|
|
1906
|
-
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(
|
|
1907
|
-
if (t && !
|
|
1908
|
-
return /* @__PURE__ */ s(
|
|
1933
|
+
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(Ve, {}) });
|
|
1934
|
+
if (t && !Dt(c.userType, t))
|
|
1935
|
+
return /* @__PURE__ */ s(je, { userType: c.userType, minUserType: t });
|
|
1909
1936
|
if (r && r.length > 0 && !(i ? w(r) : g(r))) {
|
|
1910
1937
|
const p = r.filter((x) => !f(x)).map((x) => typeof x == "string" ? x : x.name);
|
|
1911
|
-
return /* @__PURE__ */ s(
|
|
1938
|
+
return /* @__PURE__ */ s(je, { missingPermissions: p });
|
|
1912
1939
|
}
|
|
1913
1940
|
return /* @__PURE__ */ s(_, { children: n });
|
|
1914
1941
|
}
|
|
1915
|
-
const
|
|
1942
|
+
const Nt = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
1916
1943
|
"div",
|
|
1917
1944
|
{
|
|
1918
1945
|
style: {
|
|
@@ -1948,7 +1975,7 @@ const Dt = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
1948
1975
|
}
|
|
1949
1976
|
)
|
|
1950
1977
|
}
|
|
1951
|
-
),
|
|
1978
|
+
), Ge = ({
|
|
1952
1979
|
userType: n,
|
|
1953
1980
|
requiredUserType: e,
|
|
1954
1981
|
missingPermissions: t
|
|
@@ -1999,8 +2026,8 @@ const Dt = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
1999
2026
|
}
|
|
2000
2027
|
)
|
|
2001
2028
|
}
|
|
2002
|
-
),
|
|
2003
|
-
function
|
|
2029
|
+
), Ct = (n, e) => n === e;
|
|
2030
|
+
function Ir({
|
|
2004
2031
|
children: n,
|
|
2005
2032
|
redirectTo: e = "/login",
|
|
2006
2033
|
requiredUserType: t,
|
|
@@ -2008,22 +2035,22 @@ function Rr({
|
|
|
2008
2035
|
requireAllPermissions: i = !1,
|
|
2009
2036
|
fallback: o
|
|
2010
2037
|
}) {
|
|
2011
|
-
const { hasValidSession: a, sessionManager: f, hasPermission: g, hasAnyPermission: w, hasAllPermissions: c } =
|
|
2038
|
+
const { hasValidSession: a, sessionManager: f, hasPermission: g, hasAnyPermission: w, hasAllPermissions: c } = ue(), I = ke();
|
|
2012
2039
|
if (ee(() => {
|
|
2013
2040
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2014
2041
|
"[react-identity-access] ProtectedRoute is deprecated. Use AuthenticatedZone or AdminZone from ZoneRoute instead."
|
|
2015
2042
|
);
|
|
2016
2043
|
}, []), !a())
|
|
2017
2044
|
return o ? /* @__PURE__ */ s(_, { children: o }) : /* @__PURE__ */ d(_, { children: [
|
|
2018
|
-
/* @__PURE__ */ s(
|
|
2019
|
-
/* @__PURE__ */ s(
|
|
2045
|
+
/* @__PURE__ */ s(Nt, { redirectPath: e }),
|
|
2046
|
+
/* @__PURE__ */ s(Se, { to: e, state: { from: I.pathname }, replace: !0 })
|
|
2020
2047
|
] });
|
|
2021
2048
|
const p = f.getUser();
|
|
2022
2049
|
if (!p)
|
|
2023
|
-
return /* @__PURE__ */ s(
|
|
2024
|
-
if (t && !
|
|
2050
|
+
return /* @__PURE__ */ s(Se, { to: e, state: { from: I.pathname }, replace: !0 });
|
|
2051
|
+
if (t && !Ct(p.userType, t))
|
|
2025
2052
|
return /* @__PURE__ */ s(
|
|
2026
|
-
|
|
2053
|
+
Ge,
|
|
2027
2054
|
{
|
|
2028
2055
|
userType: p.userType,
|
|
2029
2056
|
requiredUserType: t
|
|
@@ -2031,11 +2058,11 @@ function Rr({
|
|
|
2031
2058
|
);
|
|
2032
2059
|
if (r && r.length > 0 && !(i ? c(r) : w(r))) {
|
|
2033
2060
|
const R = r.filter((F) => !g(F)).map((F) => typeof F == "string" ? F : F.name);
|
|
2034
|
-
return /* @__PURE__ */ s(
|
|
2061
|
+
return /* @__PURE__ */ s(Ge, { missingPermissions: R });
|
|
2035
2062
|
}
|
|
2036
2063
|
return /* @__PURE__ */ s(_, { children: n });
|
|
2037
2064
|
}
|
|
2038
|
-
const
|
|
2065
|
+
const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
2039
2066
|
"div",
|
|
2040
2067
|
{
|
|
2041
2068
|
style: {
|
|
@@ -2072,18 +2099,18 @@ const Ct = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2072
2099
|
)
|
|
2073
2100
|
}
|
|
2074
2101
|
);
|
|
2075
|
-
function
|
|
2076
|
-
const { tenant: r, isLoading: i, error: o } = me(), a =
|
|
2102
|
+
function Er({ children: n, redirectTo: e = "/", fallback: t }) {
|
|
2103
|
+
const { tenant: r, isLoading: i, error: o } = me(), a = ke();
|
|
2077
2104
|
return ee(() => {
|
|
2078
2105
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2079
2106
|
"[react-identity-access] TenantRoute is deprecated. Use TenantZone from ZoneRoute instead."
|
|
2080
2107
|
);
|
|
2081
2108
|
}, []), i || o ? null : r ? /* @__PURE__ */ s(_, { children: n }) : t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ d(_, { children: [
|
|
2082
|
-
/* @__PURE__ */ s(
|
|
2083
|
-
/* @__PURE__ */ s(
|
|
2109
|
+
/* @__PURE__ */ s(Ut, { redirectPath: e }),
|
|
2110
|
+
/* @__PURE__ */ s(Se, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
2084
2111
|
] });
|
|
2085
2112
|
}
|
|
2086
|
-
const
|
|
2113
|
+
const $t = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
2087
2114
|
"div",
|
|
2088
2115
|
{
|
|
2089
2116
|
style: {
|
|
@@ -2120,41 +2147,41 @@ const Ut = ({ redirectPath: n }) => /* @__PURE__ */ s(
|
|
|
2120
2147
|
)
|
|
2121
2148
|
}
|
|
2122
2149
|
);
|
|
2123
|
-
function
|
|
2124
|
-
const { tenant: r, isLoading: i, error: o } = me(), a =
|
|
2150
|
+
function Mr({ children: n, redirectTo: e = "/dashboard", fallback: t }) {
|
|
2151
|
+
const { tenant: r, isLoading: i, error: o } = me(), a = ke();
|
|
2125
2152
|
return ee(() => {
|
|
2126
2153
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2127
2154
|
"[react-identity-access] LandingRoute is deprecated. Use PublicZone from ZoneRoute instead."
|
|
2128
2155
|
);
|
|
2129
2156
|
}, []), i || o ? null : r ? t ? /* @__PURE__ */ s(_, { children: t }) : /* @__PURE__ */ d(_, { children: [
|
|
2130
|
-
/* @__PURE__ */ s(
|
|
2131
|
-
/* @__PURE__ */ s(
|
|
2157
|
+
/* @__PURE__ */ s($t, { redirectPath: e }),
|
|
2158
|
+
/* @__PURE__ */ s(Se, { to: e, state: { from: a.pathname }, replace: !0 })
|
|
2132
2159
|
] }) : /* @__PURE__ */ s(_, { children: n });
|
|
2133
2160
|
}
|
|
2134
|
-
function
|
|
2161
|
+
function Ht(n, e) {
|
|
2135
2162
|
return e ? n ? Array.isArray(e) ? e.includes(n) : n === e : !1 : !0;
|
|
2136
2163
|
}
|
|
2137
|
-
function
|
|
2164
|
+
function Qe(n, e) {
|
|
2138
2165
|
return !n || n === "optional" ? "skip" : n === "required" ? e ? "pass" : "fail" : n === "forbidden" ? e ? "fail" : "pass" : "skip";
|
|
2139
2166
|
}
|
|
2140
|
-
function Ht(n, e) {
|
|
2141
|
-
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;
|
|
2142
|
-
}
|
|
2143
2167
|
function Bt(n, e) {
|
|
2144
|
-
return n.hasTenant ?
|
|
2168
|
+
return Qe(n.tenant, e.hasTenant) === "fail" ? e.hasTenant ? "has_tenant" : "no_tenant" : Qe(n.auth, e.isAuthenticated) === "fail" ? e.isAuthenticated ? "already_authenticated" : "not_authenticated" : n.userType && e.isAuthenticated && !Ht(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;
|
|
2169
|
+
}
|
|
2170
|
+
function qt(n, e) {
|
|
2171
|
+
return n.hasTenant ? n.isAuthenticated ? n.userType === ae.TENANT_ADMIN ? e.tenantAdmin : e.tenantUser : e.tenantGuest : n.isAuthenticated ? n.userType === ae.TENANT_ADMIN ? e.publicAdmin : e.publicUser : e.publicGuest;
|
|
2145
2172
|
}
|
|
2146
|
-
function
|
|
2173
|
+
function Ot(n, e, t, r, i) {
|
|
2147
2174
|
if (!e || i !== "url")
|
|
2148
2175
|
return n;
|
|
2149
2176
|
const o = typeof e == "string" ? e : t, a = n.includes("?") ? "&" : "?";
|
|
2150
2177
|
return `${n}${a}${r}=${encodeURIComponent(o)}`;
|
|
2151
2178
|
}
|
|
2152
|
-
function
|
|
2179
|
+
function zt(n, e, t) {
|
|
2153
2180
|
if (!n || t === "url") return;
|
|
2154
2181
|
const r = typeof n == "string" ? n : e, i = "zone_return_to";
|
|
2155
2182
|
t === "session" ? sessionStorage.setItem(i, r) : t === "local" && localStorage.setItem(i, r);
|
|
2156
2183
|
}
|
|
2157
|
-
const
|
|
2184
|
+
const de = ({
|
|
2158
2185
|
children: n,
|
|
2159
2186
|
preset: e,
|
|
2160
2187
|
tenant: t,
|
|
@@ -2168,10 +2195,10 @@ const ce = ({
|
|
|
2168
2195
|
loadingFallback: c,
|
|
2169
2196
|
accessDeniedFallback: I
|
|
2170
2197
|
}) => {
|
|
2171
|
-
const p =
|
|
2198
|
+
const p = ke(), { isAuthenticated: x, isAuthInitializing: R, currentUser: F, userPermissions: E } = ue(), { tenant: A, isTenantLoading: u } = ge(), k = Ft(), m = Z(() => {
|
|
2172
2199
|
if (e)
|
|
2173
2200
|
return k.presets[e];
|
|
2174
|
-
}, [e, k.presets]), M =
|
|
2201
|
+
}, [e, k.presets]), M = Z(
|
|
2175
2202
|
() => ({
|
|
2176
2203
|
tenant: t ?? (m == null ? void 0 : m.tenant),
|
|
2177
2204
|
auth: r ?? (m == null ? void 0 : m.auth),
|
|
@@ -2180,7 +2207,7 @@ const ce = ({
|
|
|
2180
2207
|
requireAllPermissions: a
|
|
2181
2208
|
}),
|
|
2182
2209
|
[t, r, i, o, m, a]
|
|
2183
|
-
), L =
|
|
2210
|
+
), L = Z(
|
|
2184
2211
|
() => ({
|
|
2185
2212
|
hasTenant: !!A,
|
|
2186
2213
|
isAuthenticated: x,
|
|
@@ -2196,7 +2223,7 @@ const ce = ({
|
|
|
2196
2223
|
R,
|
|
2197
2224
|
u
|
|
2198
2225
|
]
|
|
2199
|
-
), D =
|
|
2226
|
+
), D = Z(() => L.isLoading ? null : Bt(M, L), [M, L]), P = Z(() => D ? w || qt(L, k.zoneRoots) : null, [D, w, L, k.zoneRoots]), U = Z(() => !D || !P ? null : {
|
|
2200
2227
|
type: D,
|
|
2201
2228
|
required: {
|
|
2202
2229
|
tenant: M.tenant,
|
|
@@ -2215,7 +2242,7 @@ const ce = ({
|
|
|
2215
2242
|
if (ee(() => {
|
|
2216
2243
|
U && (g ? g(U) : k.onAccessDenied && k.onAccessDenied(U));
|
|
2217
2244
|
}, [U, g, k]), ee(() => {
|
|
2218
|
-
U && f &&
|
|
2245
|
+
U && f && zt(f, p.pathname + p.search, k.returnToStorage);
|
|
2219
2246
|
}, [
|
|
2220
2247
|
U,
|
|
2221
2248
|
f,
|
|
@@ -2228,17 +2255,17 @@ const ce = ({
|
|
|
2228
2255
|
const l = I ?? k.accessDeniedFallback;
|
|
2229
2256
|
if (l)
|
|
2230
2257
|
return /* @__PURE__ */ s(_, { children: l });
|
|
2231
|
-
const N =
|
|
2258
|
+
const N = Ot(
|
|
2232
2259
|
P,
|
|
2233
2260
|
f,
|
|
2234
2261
|
p.pathname + p.search,
|
|
2235
2262
|
k.returnToParam,
|
|
2236
2263
|
k.returnToStorage
|
|
2237
2264
|
);
|
|
2238
|
-
return /* @__PURE__ */ s(
|
|
2265
|
+
return /* @__PURE__ */ s(Se, { to: N, replace: !0 });
|
|
2239
2266
|
}
|
|
2240
2267
|
return /* @__PURE__ */ s(_, { children: n });
|
|
2241
|
-
},
|
|
2268
|
+
}, Lr = (n) => /* @__PURE__ */ s(de, { tenant: "required", ...n }), Fr = (n) => /* @__PURE__ */ s(de, { tenant: "forbidden", ...n }), Dr = (n) => /* @__PURE__ */ s(de, { auth: "required", ...n }), Nr = (n) => /* @__PURE__ */ s(de, { auth: "forbidden", ...n }), Cr = (n) => /* @__PURE__ */ s(de, { auth: "required", userType: ae.TENANT_ADMIN, ...n }), Ur = (n) => /* @__PURE__ */ s(de, { auth: "required", userType: ae.USER, ...n }), $r = (n) => /* @__PURE__ */ s(de, { tenant: "optional", auth: "optional", ...n }), Hr = (n) => /* @__PURE__ */ s(de, { tenant: "required", auth: "required", ...n }), Br = (n) => /* @__PURE__ */ s(de, { tenant: "required", auth: "optional", ...n }), qr = (n) => /* @__PURE__ */ s(de, { tenant: "required", auth: "forbidden", ...n }), _t = () => /* @__PURE__ */ d(
|
|
2242
2269
|
"div",
|
|
2243
2270
|
{
|
|
2244
2271
|
style: {
|
|
@@ -2255,13 +2282,13 @@ const ce = ({
|
|
|
2255
2282
|
]
|
|
2256
2283
|
}
|
|
2257
2284
|
);
|
|
2258
|
-
function
|
|
2285
|
+
function Or({
|
|
2259
2286
|
children: n,
|
|
2260
|
-
fallback: e = /* @__PURE__ */ s(
|
|
2287
|
+
fallback: e = /* @__PURE__ */ s(_t, {}),
|
|
2261
2288
|
allowedPlans: t,
|
|
2262
2289
|
requiredFeature: r
|
|
2263
2290
|
}) {
|
|
2264
|
-
const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: f } =
|
|
2291
|
+
const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: f } = Lt();
|
|
2265
2292
|
return f ? /* @__PURE__ */ s(
|
|
2266
2293
|
"div",
|
|
2267
2294
|
{
|
|
@@ -2274,7 +2301,7 @@ function qr({
|
|
|
2274
2301
|
}
|
|
2275
2302
|
) : 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 });
|
|
2276
2303
|
}
|
|
2277
|
-
const
|
|
2304
|
+
const Wt = ({ flagName: n }) => /* @__PURE__ */ d(
|
|
2278
2305
|
"div",
|
|
2279
2306
|
{
|
|
2280
2307
|
style: {
|
|
@@ -2301,8 +2328,8 @@ const _t = ({ flagName: n }) => /* @__PURE__ */ d(
|
|
|
2301
2328
|
]
|
|
2302
2329
|
}
|
|
2303
2330
|
);
|
|
2304
|
-
function
|
|
2305
|
-
const { isEnabled: r, loading: i } =
|
|
2331
|
+
function zr({ name: n, children: e, fallback: t }) {
|
|
2332
|
+
const { isEnabled: r, loading: i } = Et();
|
|
2306
2333
|
return i ? /* @__PURE__ */ s(
|
|
2307
2334
|
"div",
|
|
2308
2335
|
{
|
|
@@ -2316,9 +2343,9 @@ function Or({ name: n, children: e, fallback: t }) {
|
|
|
2316
2343
|
},
|
|
2317
2344
|
children: "Loading feature flags..."
|
|
2318
2345
|
}
|
|
2319
|
-
) : r(n) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: t || /* @__PURE__ */ s(
|
|
2346
|
+
) : r(n) ? /* @__PURE__ */ s(_, { children: e }) : /* @__PURE__ */ s(_, { children: t || /* @__PURE__ */ s(Wt, { flagName: n }) });
|
|
2320
2347
|
}
|
|
2321
|
-
const
|
|
2348
|
+
const Vt = () => /* @__PURE__ */ d(
|
|
2322
2349
|
"svg",
|
|
2323
2350
|
{
|
|
2324
2351
|
width: "16",
|
|
@@ -2335,7 +2362,7 @@ const Wt = () => /* @__PURE__ */ d(
|
|
|
2335
2362
|
/* @__PURE__ */ s("circle", { cx: "12", cy: "12", r: "3" })
|
|
2336
2363
|
]
|
|
2337
2364
|
}
|
|
2338
|
-
),
|
|
2365
|
+
), jt = () => /* @__PURE__ */ d(
|
|
2339
2366
|
"svg",
|
|
2340
2367
|
{
|
|
2341
2368
|
width: "16",
|
|
@@ -2352,10 +2379,10 @@ const Wt = () => /* @__PURE__ */ d(
|
|
|
2352
2379
|
/* @__PURE__ */ s("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
2353
2380
|
]
|
|
2354
2381
|
}
|
|
2355
|
-
),
|
|
2356
|
-
showPassword: /* @__PURE__ */ s(
|
|
2357
|
-
hidePassword: /* @__PURE__ */ s(
|
|
2358
|
-
},
|
|
2382
|
+
), Gt = {
|
|
2383
|
+
showPassword: /* @__PURE__ */ s(Vt, {}),
|
|
2384
|
+
hidePassword: /* @__PURE__ */ s(jt, {})
|
|
2385
|
+
}, Qt = {
|
|
2359
2386
|
title: "Sign In",
|
|
2360
2387
|
usernameLabel: "Email or Phone",
|
|
2361
2388
|
usernamePlaceholder: "Enter your email or phone number",
|
|
@@ -2369,7 +2396,7 @@ const Wt = () => /* @__PURE__ */ d(
|
|
|
2369
2396
|
magicLinkLink: "Use Magic Link",
|
|
2370
2397
|
errorMessage: "Invalid credentials",
|
|
2371
2398
|
loadingText: "Signing in..."
|
|
2372
|
-
},
|
|
2399
|
+
}, Kt = {
|
|
2373
2400
|
container: {
|
|
2374
2401
|
maxWidth: "400px",
|
|
2375
2402
|
width: "100%",
|
|
@@ -2476,7 +2503,7 @@ const Wt = () => /* @__PURE__ */ d(
|
|
|
2476
2503
|
fontSize: "0.875rem"
|
|
2477
2504
|
}
|
|
2478
2505
|
};
|
|
2479
|
-
function
|
|
2506
|
+
function _r({
|
|
2480
2507
|
copy: n = {},
|
|
2481
2508
|
styles: e = {},
|
|
2482
2509
|
icons: t = {},
|
|
@@ -2490,7 +2517,7 @@ function zr({
|
|
|
2490
2517
|
showMagicLinkOption: c = !0,
|
|
2491
2518
|
className: I
|
|
2492
2519
|
}) {
|
|
2493
|
-
const [p, x] = T(""), [R, F] = T(""), [E, A] = T(!1), [u, k] = T(!1), [m, M] = T(""), [L, D] = T({}), { login: P } =
|
|
2520
|
+
const [p, x] = T(""), [R, F] = T(""), [E, A] = T(!1), [u, k] = T(!1), [m, M] = T(""), [L, D] = T({}), { login: P } = ue(), { tenant: U } = me(), l = { ...Qt, ...n }, N = { ...Kt, ...e }, $ = { ...Gt, ...t }, h = () => {
|
|
2494
2521
|
const y = {};
|
|
2495
2522
|
return p.trim() || (y.username = !0), R.trim() || (y.password = !0), D(y), Object.keys(y).length === 0;
|
|
2496
2523
|
}, C = async (y) => {
|
|
@@ -2727,7 +2754,7 @@ const Zt = {
|
|
|
2727
2754
|
fontSize: "0.875rem"
|
|
2728
2755
|
}
|
|
2729
2756
|
};
|
|
2730
|
-
function
|
|
2757
|
+
function Wr({
|
|
2731
2758
|
copy: n = {},
|
|
2732
2759
|
styles: e = {},
|
|
2733
2760
|
signupType: t = "user",
|
|
@@ -2739,7 +2766,7 @@ function _r({
|
|
|
2739
2766
|
showMagicLinkOption: g = !0,
|
|
2740
2767
|
className: w
|
|
2741
2768
|
}) {
|
|
2742
|
-
const [c, I] = T(""), [p, x] = T(""), [R, F] = T(""), [E, A] = T(""), [u, k] = T(""), [m, M] = T(""), [L, D] = T(""), [P, U] = T(!1), [l, N] = T(""), [$, h] = T({}), { signup: C, signupTenantAdmin: S } =
|
|
2769
|
+
const [c, I] = T(""), [p, x] = T(""), [R, F] = T(""), [E, A] = T(""), [u, k] = T(""), [m, M] = T(""), [L, D] = T(""), [P, U] = T(!1), [l, N] = T(""), [$, h] = T({}), { signup: C, signupTenantAdmin: S } = ue(), { tenant: b } = me(), y = { ...Zt, ...n }, v = { ...Jt, ...e }, j = () => {
|
|
2743
2770
|
const B = {};
|
|
2744
2771
|
return c.trim() || (B.name = !0), !R.trim() && !E.trim() && (B.email = !0, B.phoneNumber = !0), u.trim() || (B.password = !0), m.trim() || (B.confirmPassword = !0), t === "tenant" && !L.trim() && (B.tenantName = !0), h(B), Object.keys(B).length === 0;
|
|
2745
2772
|
}, Q = async (B) => {
|
|
@@ -2946,7 +2973,7 @@ function _r({
|
|
|
2946
2973
|
] })
|
|
2947
2974
|
] });
|
|
2948
2975
|
}
|
|
2949
|
-
const
|
|
2976
|
+
const Yt = {
|
|
2950
2977
|
title: "Sign In with Magic Link",
|
|
2951
2978
|
emailLabel: "Email",
|
|
2952
2979
|
emailPlaceholder: "Enter your email",
|
|
@@ -2964,7 +2991,7 @@ const Kt = {
|
|
|
2964
2991
|
loadingText: "Sending magic link...",
|
|
2965
2992
|
verifyingText: "Verifying magic link...",
|
|
2966
2993
|
description: "Enter your email to receive a magic link. If you don't have an account, we'll create one for you."
|
|
2967
|
-
},
|
|
2994
|
+
}, Xt = {
|
|
2968
2995
|
container: {
|
|
2969
2996
|
maxWidth: "400px",
|
|
2970
2997
|
width: "100%",
|
|
@@ -3067,7 +3094,7 @@ const Kt = {
|
|
|
3067
3094
|
fontSize: "0.875rem"
|
|
3068
3095
|
}
|
|
3069
3096
|
};
|
|
3070
|
-
function
|
|
3097
|
+
function Vr({
|
|
3071
3098
|
copy: n = {},
|
|
3072
3099
|
styles: e = {},
|
|
3073
3100
|
onSuccess: t,
|
|
@@ -3079,7 +3106,7 @@ function Wr({
|
|
|
3079
3106
|
verifyToken: g,
|
|
3080
3107
|
frontendUrl: w
|
|
3081
3108
|
}) {
|
|
3082
|
-
const [c, I] = T(""), [p, x] = T(""), [R, F] = T(""), [E, A] = T(!1), [u, k] = T(!1), [m, M] = T(""), [L, D] = T(""), [P, U] = T({}), [l, N] = T(!1), { sendMagicLink: $, verifyMagicLink: h } =
|
|
3109
|
+
const [c, I] = T(""), [p, x] = T(""), [R, F] = T(""), [E, A] = T(!1), [u, k] = T(!1), [m, M] = T(""), [L, D] = T(""), [P, U] = T({}), [l, N] = T(!1), { sendMagicLink: $, verifyMagicLink: h } = ue(), { tenant: C } = me(), S = { ...Yt, ...n }, b = { ...Xt, ...e };
|
|
3083
3110
|
ee(() => {
|
|
3084
3111
|
g && y(g);
|
|
3085
3112
|
}, [g]);
|
|
@@ -3254,7 +3281,7 @@ function Wr({
|
|
|
3254
3281
|
] })
|
|
3255
3282
|
] });
|
|
3256
3283
|
}
|
|
3257
|
-
const
|
|
3284
|
+
const er = {
|
|
3258
3285
|
title: "Verifying Magic Link",
|
|
3259
3286
|
verifyingMessage: "Please wait while we verify your magic link...",
|
|
3260
3287
|
successMessage: "Magic link verified successfully! You are now logged in.",
|
|
@@ -3262,7 +3289,7 @@ const Xt = {
|
|
|
3262
3289
|
redirectingMessage: "Redirecting you to the dashboard...",
|
|
3263
3290
|
retryButton: "Try Again",
|
|
3264
3291
|
backToLoginButton: "Back to Login"
|
|
3265
|
-
},
|
|
3292
|
+
}, et = {
|
|
3266
3293
|
container: {
|
|
3267
3294
|
maxWidth: "400px",
|
|
3268
3295
|
width: "100%",
|
|
@@ -3349,7 +3376,7 @@ const Xt = {
|
|
|
3349
3376
|
cursor: "pointer",
|
|
3350
3377
|
transition: "all 0.15s ease-in-out"
|
|
3351
3378
|
}
|
|
3352
|
-
},
|
|
3379
|
+
}, tr = () => /* @__PURE__ */ s("div", { style: et.spinner }), rr = () => /* @__PURE__ */ d(
|
|
3353
3380
|
"svg",
|
|
3354
3381
|
{
|
|
3355
3382
|
width: "48",
|
|
@@ -3366,7 +3393,7 @@ const Xt = {
|
|
|
3366
3393
|
/* @__PURE__ */ s("polyline", { points: "22,4 12,14.01 9,11.01" })
|
|
3367
3394
|
]
|
|
3368
3395
|
}
|
|
3369
|
-
),
|
|
3396
|
+
), nr = () => /* @__PURE__ */ d(
|
|
3370
3397
|
"svg",
|
|
3371
3398
|
{
|
|
3372
3399
|
width: "48",
|
|
@@ -3384,12 +3411,12 @@ const Xt = {
|
|
|
3384
3411
|
/* @__PURE__ */ s("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
|
|
3385
3412
|
]
|
|
3386
3413
|
}
|
|
3387
|
-
),
|
|
3388
|
-
loading: /* @__PURE__ */ s(
|
|
3389
|
-
success: /* @__PURE__ */ s(
|
|
3390
|
-
error: /* @__PURE__ */ s(
|
|
3414
|
+
), sr = {
|
|
3415
|
+
loading: /* @__PURE__ */ s(tr, {}),
|
|
3416
|
+
success: /* @__PURE__ */ s(rr, {}),
|
|
3417
|
+
error: /* @__PURE__ */ s(nr, {})
|
|
3391
3418
|
};
|
|
3392
|
-
function
|
|
3419
|
+
function jr({
|
|
3393
3420
|
copy: n = {},
|
|
3394
3421
|
styles: e = {},
|
|
3395
3422
|
icons: t = {},
|
|
@@ -3404,7 +3431,7 @@ function Vr({
|
|
|
3404
3431
|
tenantSlug: I,
|
|
3405
3432
|
autoRedirectDelay: p = 3e3
|
|
3406
3433
|
}) {
|
|
3407
|
-
const [x, R] = T("verifying"), [F, E] = T(""), { verifyMagicLink: A } =
|
|
3434
|
+
const [x, R] = T("verifying"), [F, E] = T(""), { verifyMagicLink: A } = ue(), u = { ...er, ...n }, k = { ...et, ...e }, m = { ...sr, ...t }, M = () => {
|
|
3408
3435
|
if (typeof window > "u") return {};
|
|
3409
3436
|
const l = new URLSearchParams(window.location.search);
|
|
3410
3437
|
return {
|
|
@@ -3506,7 +3533,7 @@ function Vr({
|
|
|
3506
3533
|
U()
|
|
3507
3534
|
] });
|
|
3508
3535
|
}
|
|
3509
|
-
const
|
|
3536
|
+
const ir = {
|
|
3510
3537
|
title: "Reset Password",
|
|
3511
3538
|
subtitle: "Enter your email address and we'll send you a link to reset your password.",
|
|
3512
3539
|
emailLabel: "Email",
|
|
@@ -3528,7 +3555,7 @@ const sr = {
|
|
|
3528
3555
|
resetLoadingText: "Resetting...",
|
|
3529
3556
|
resetSuccessMessage: "Password reset successfully!",
|
|
3530
3557
|
passwordMismatchError: "Passwords do not match"
|
|
3531
|
-
},
|
|
3558
|
+
}, or = {
|
|
3532
3559
|
container: {
|
|
3533
3560
|
maxWidth: "400px",
|
|
3534
3561
|
margin: "0 auto",
|
|
@@ -3620,7 +3647,7 @@ const sr = {
|
|
|
3620
3647
|
cursor: "pointer"
|
|
3621
3648
|
}
|
|
3622
3649
|
};
|
|
3623
|
-
function
|
|
3650
|
+
function Gr({
|
|
3624
3651
|
copy: n = {},
|
|
3625
3652
|
styles: e = {},
|
|
3626
3653
|
mode: t = "request",
|
|
@@ -3631,7 +3658,7 @@ function jr({
|
|
|
3631
3658
|
onModeChange: f,
|
|
3632
3659
|
className: g
|
|
3633
3660
|
}) {
|
|
3634
|
-
const [w, c] = T(""), [I, p] = T(r), [x, R] = T(""), [F, E] = T(""), [A, u] = T(!1), [k, m] = T(""), [M, L] = T(""), [D, P] = T({}), { requestPasswordReset: U, confirmPasswordReset: l } =
|
|
3661
|
+
const [w, c] = T(""), [I, p] = T(r), [x, R] = T(""), [F, E] = T(""), [A, u] = T(!1), [k, m] = T(""), [M, L] = T(""), [D, P] = T({}), { requestPasswordReset: U, confirmPasswordReset: l } = ue(), { tenant: N } = me(), $ = { ...ir, ...n }, h = { ...or, ...e }, C = () => {
|
|
3635
3662
|
const O = {};
|
|
3636
3663
|
return w.trim() || (O.email = !0), P(O), Object.keys(O).length === 0;
|
|
3637
3664
|
}, S = () => {
|
|
@@ -3799,7 +3826,7 @@ function jr({
|
|
|
3799
3826
|
] })
|
|
3800
3827
|
] });
|
|
3801
3828
|
}
|
|
3802
|
-
const
|
|
3829
|
+
const ar = () => /* @__PURE__ */ s(
|
|
3803
3830
|
"div",
|
|
3804
3831
|
{
|
|
3805
3832
|
style: {
|
|
@@ -3811,7 +3838,7 @@ const or = () => /* @__PURE__ */ s(
|
|
|
3811
3838
|
},
|
|
3812
3839
|
children: /* @__PURE__ */ s("div", { children: "Loading..." })
|
|
3813
3840
|
}
|
|
3814
|
-
),
|
|
3841
|
+
), lr = ({ error: n, retry: e }) => /* @__PURE__ */ d(
|
|
3815
3842
|
"div",
|
|
3816
3843
|
{
|
|
3817
3844
|
style: {
|
|
@@ -3845,26 +3872,26 @@ const or = () => /* @__PURE__ */ s(
|
|
|
3845
3872
|
]
|
|
3846
3873
|
}
|
|
3847
3874
|
);
|
|
3848
|
-
function
|
|
3875
|
+
function Qr({
|
|
3849
3876
|
children: n,
|
|
3850
3877
|
loadingFallback: e,
|
|
3851
3878
|
errorFallback: t,
|
|
3852
3879
|
requireTenant: r = !0
|
|
3853
3880
|
}) {
|
|
3854
|
-
const { isAppLoading: i, appError: o, retryApp: a } =
|
|
3881
|
+
const { isAppLoading: i, appError: o, retryApp: a } = ve(), f = xe(), g = Ce(), w = Je(), c = Ye(), I = (f == null ? void 0 : f.isTenantLoading) ?? !1, p = (f == null ? void 0 : f.tenantError) ?? null, x = (f == null ? void 0 : f.tenantSlug) ?? null, R = (f == null ? void 0 : f.retryTenant) ?? (() => {
|
|
3855
3882
|
}), F = (g == null ? void 0 : g.isAuthReady) ?? !0, E = (w == null ? void 0 : w.isReady) ?? !0, A = (c == null ? void 0 : c.isReady) ?? !0, u = r && f && x, L = i || u && I || g && !F || w && !E || c && !A, D = o || (u ? p : null), P = () => {
|
|
3856
3883
|
o && a(), p && f && R();
|
|
3857
3884
|
};
|
|
3858
3885
|
if (L)
|
|
3859
|
-
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(
|
|
3886
|
+
return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(ar, {}) });
|
|
3860
3887
|
if (D) {
|
|
3861
|
-
const U = typeof t == "function" ? t(D, P) : t || /* @__PURE__ */ s(
|
|
3888
|
+
const U = typeof t == "function" ? t(D, P) : t || /* @__PURE__ */ s(lr, { error: D, retry: P });
|
|
3862
3889
|
return /* @__PURE__ */ s(_, { children: U });
|
|
3863
3890
|
}
|
|
3864
3891
|
return /* @__PURE__ */ s(_, { children: n });
|
|
3865
3892
|
}
|
|
3866
|
-
function
|
|
3867
|
-
const { isAppLoading: e, appError: t, retryApp: r, appInfo: i } =
|
|
3893
|
+
function Kr(n = !0) {
|
|
3894
|
+
const { isAppLoading: e, appError: t, retryApp: r, appInfo: i } = ve(), o = xe(), a = Ce(), f = Je(), g = Ye(), w = (o == null ? void 0 : o.isTenantLoading) ?? !1, c = (o == null ? void 0 : o.tenantError) ?? null, I = (o == null ? void 0 : o.tenant) ?? null, p = (o == null ? void 0 : o.tenantSlug) ?? null, x = (o == null ? void 0 : o.retryTenant) ?? (() => {
|
|
3868
3895
|
}), R = (a == null ? void 0 : a.isAuthReady) ?? !0, F = (f == null ? void 0 : f.isReady) ?? !0, E = (g == null ? void 0 : g.isReady) ?? !0, A = n && o && p, M = e || A && w || a && !R || f && !F || g && !E, L = t || (A ? c : null);
|
|
3869
3896
|
return {
|
|
3870
3897
|
isLoading: M,
|
|
@@ -3894,7 +3921,7 @@ function Zr({
|
|
|
3894
3921
|
showCurrentTenant: w = !0
|
|
3895
3922
|
}) {
|
|
3896
3923
|
var k;
|
|
3897
|
-
const c =
|
|
3924
|
+
const c = Ce(), [I, p] = T(!1), x = Ke(null), R = n ?? (c == null ? void 0 : c.userTenants) ?? [], F = e ?? ((k = c == null ? void 0 : c.currentUser) == null ? void 0 : k.tenantId) ?? null, E = async (m) => {
|
|
3898
3925
|
p(!1), t ? t(m) : c != null && c.switchToTenant && await c.switchToTenant(m);
|
|
3899
3926
|
};
|
|
3900
3927
|
ee(() => {
|
|
@@ -4045,7 +4072,7 @@ class Jr {
|
|
|
4045
4072
|
};
|
|
4046
4073
|
}
|
|
4047
4074
|
}
|
|
4048
|
-
class
|
|
4075
|
+
class Yr {
|
|
4049
4076
|
constructor(e, t) {
|
|
4050
4077
|
this.httpService = e, this.sessionManager = t;
|
|
4051
4078
|
}
|
|
@@ -4096,7 +4123,7 @@ class Kr {
|
|
|
4096
4123
|
});
|
|
4097
4124
|
}
|
|
4098
4125
|
}
|
|
4099
|
-
class
|
|
4126
|
+
class Xr {
|
|
4100
4127
|
constructor(e) {
|
|
4101
4128
|
this.httpService = e;
|
|
4102
4129
|
}
|
|
@@ -4105,7 +4132,7 @@ class Yr {
|
|
|
4105
4132
|
return await this.httpService.get("/health");
|
|
4106
4133
|
}
|
|
4107
4134
|
}
|
|
4108
|
-
class
|
|
4135
|
+
class en {
|
|
4109
4136
|
// Date string to Date object
|
|
4110
4137
|
static toDate(e) {
|
|
4111
4138
|
return new Date(e);
|
|
@@ -4227,20 +4254,20 @@ class Xr {
|
|
|
4227
4254
|
}), t;
|
|
4228
4255
|
}
|
|
4229
4256
|
}
|
|
4230
|
-
const
|
|
4231
|
-
function
|
|
4257
|
+
const tt = "returnTo", Me = "zone_return_to", Le = "zone_return_to";
|
|
4258
|
+
function tn(n = {}) {
|
|
4232
4259
|
const {
|
|
4233
4260
|
zoneRoots: e = {},
|
|
4234
|
-
returnToParam: t =
|
|
4261
|
+
returnToParam: t = tt,
|
|
4235
4262
|
returnToStorage: r = "url"
|
|
4236
|
-
} = n, i =
|
|
4263
|
+
} = n, i = gt(), [o, a] = mt(), { isAuthenticated: f, currentUser: g } = ue(), { tenant: w } = ge(), c = Z(() => ({ ...He, ...e }), [e]), I = !!w, p = g == null ? void 0 : g.userType, x = Z(() => {
|
|
4237
4264
|
switch (r) {
|
|
4238
4265
|
case "url":
|
|
4239
4266
|
return o.get(t);
|
|
4240
4267
|
case "session":
|
|
4241
|
-
return sessionStorage.getItem(
|
|
4268
|
+
return sessionStorage.getItem(Me);
|
|
4242
4269
|
case "local":
|
|
4243
|
-
return localStorage.getItem(
|
|
4270
|
+
return localStorage.getItem(Le);
|
|
4244
4271
|
default:
|
|
4245
4272
|
return null;
|
|
4246
4273
|
}
|
|
@@ -4252,10 +4279,10 @@ function en(n = {}) {
|
|
|
4252
4279
|
break;
|
|
4253
4280
|
}
|
|
4254
4281
|
case "session":
|
|
4255
|
-
sessionStorage.removeItem(
|
|
4282
|
+
sessionStorage.removeItem(Me);
|
|
4256
4283
|
break;
|
|
4257
4284
|
case "local":
|
|
4258
|
-
localStorage.removeItem(
|
|
4285
|
+
localStorage.removeItem(Le);
|
|
4259
4286
|
break;
|
|
4260
4287
|
}
|
|
4261
4288
|
}, [r, o, t, a]), F = se(
|
|
@@ -4267,10 +4294,10 @@ function en(n = {}) {
|
|
|
4267
4294
|
break;
|
|
4268
4295
|
}
|
|
4269
4296
|
case "session":
|
|
4270
|
-
sessionStorage.setItem(
|
|
4297
|
+
sessionStorage.setItem(Me, u);
|
|
4271
4298
|
break;
|
|
4272
4299
|
case "local":
|
|
4273
|
-
localStorage.setItem(
|
|
4300
|
+
localStorage.setItem(Le, u);
|
|
4274
4301
|
break;
|
|
4275
4302
|
}
|
|
4276
4303
|
},
|
|
@@ -4281,7 +4308,7 @@ function en(n = {}) {
|
|
|
4281
4308
|
i(k);
|
|
4282
4309
|
},
|
|
4283
4310
|
[i, c]
|
|
4284
|
-
), A = se(() => I ? f ? p ===
|
|
4311
|
+
), A = se(() => I ? f ? p === ae.TENANT_ADMIN ? c.tenantAdmin : c.tenantUser : c.tenantGuest : f ? p === ae.TENANT_ADMIN ? c.publicAdmin : c.publicUser : c.publicGuest, [I, f, p, c]);
|
|
4285
4312
|
return {
|
|
4286
4313
|
returnToUrl: x,
|
|
4287
4314
|
clearReturnTo: R,
|
|
@@ -4290,76 +4317,76 @@ function en(n = {}) {
|
|
|
4290
4317
|
getSmartRedirect: A
|
|
4291
4318
|
};
|
|
4292
4319
|
}
|
|
4293
|
-
function
|
|
4320
|
+
function rn(n, e, t = tt, r = "url") {
|
|
4294
4321
|
if (!e || r !== "url")
|
|
4295
4322
|
return n;
|
|
4296
4323
|
const i = new URL(n, window.location.origin);
|
|
4297
4324
|
return i.searchParams.set(t, e), i.pathname + i.search;
|
|
4298
4325
|
}
|
|
4299
4326
|
export {
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4327
|
+
Cr as AdminZone,
|
|
4328
|
+
en as ApiMappers,
|
|
4329
|
+
ze as AppApiService,
|
|
4330
|
+
Qr as AppLoader,
|
|
4331
|
+
yr as AppProvider,
|
|
4332
|
+
bt as AuthApiService,
|
|
4333
|
+
Tr as AuthProvider,
|
|
4334
|
+
Dr as AuthenticatedZone,
|
|
4335
|
+
Xe as DEFAULT_ZONE_PRESETS,
|
|
4336
|
+
He as DEFAULT_ZONE_ROOTS,
|
|
4337
|
+
zr as FeatureFlag,
|
|
4338
|
+
It as FeatureFlagApiService,
|
|
4339
|
+
kr as FeatureFlagProvider,
|
|
4340
|
+
Nr as GuestZone,
|
|
4341
|
+
Xr as HealthApiService,
|
|
4342
|
+
ce as HttpService,
|
|
4343
|
+
Mr as LandingRoute,
|
|
4344
|
+
_r as LoginForm,
|
|
4345
|
+
Vr as MagicLinkForm,
|
|
4346
|
+
jr as MagicLinkVerify,
|
|
4347
|
+
$r as OpenZone,
|
|
4348
|
+
Gr as PasswordRecoveryForm,
|
|
4322
4349
|
Jr as PermissionApiService,
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4350
|
+
Rr as Protected,
|
|
4351
|
+
Ir as ProtectedRoute,
|
|
4352
|
+
Fr as PublicZone,
|
|
4353
|
+
_e as RoleApiService,
|
|
4354
|
+
Ar as RoutingProvider,
|
|
4328
4355
|
ie as SessionExpiredError,
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4356
|
+
we as SessionManager,
|
|
4357
|
+
Wr as SignupForm,
|
|
4358
|
+
Mt as SubscriptionApiService,
|
|
4359
|
+
Or as SubscriptionGuard,
|
|
4360
|
+
Yr as SubscriptionPlanApiService,
|
|
4361
|
+
xr as SubscriptionProvider,
|
|
4362
|
+
be as TenantApiService,
|
|
4363
|
+
Hr as TenantAuthenticatedZone,
|
|
4364
|
+
qr as TenantGuestZone,
|
|
4365
|
+
Br as TenantOpenZone,
|
|
4366
|
+
br as TenantProvider,
|
|
4367
|
+
Er as TenantRoute,
|
|
4341
4368
|
Zr as TenantSelector,
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4369
|
+
Lr as TenantZone,
|
|
4370
|
+
wt as TokenRefreshError,
|
|
4371
|
+
yt as TokenRefreshTimeoutError,
|
|
4372
|
+
St as UserApiService,
|
|
4373
|
+
ae as UserType,
|
|
4374
|
+
Ur as UserZone,
|
|
4375
|
+
de as ZoneRoute,
|
|
4376
|
+
rn as buildRedirectUrl,
|
|
4377
|
+
wr as useApi,
|
|
4378
|
+
ve as useApp,
|
|
4379
|
+
Kr as useAppLoaderState,
|
|
4380
|
+
ue as useAuth,
|
|
4381
|
+
Et as useFeatureFlags,
|
|
4382
|
+
Pr as useRouting,
|
|
4383
|
+
Ft as useRoutingOptional,
|
|
4384
|
+
vr as useSettings,
|
|
4385
|
+
Lt as useSubscription,
|
|
4359
4386
|
ge as useTenant,
|
|
4360
4387
|
me as useTenantInfo,
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4388
|
+
xe as useTenantOptional,
|
|
4389
|
+
Sr as useTenantSettings,
|
|
4390
|
+
tn as useZoneNavigation
|
|
4364
4391
|
};
|
|
4365
4392
|
//# sourceMappingURL=index.es.js.map
|