@skylabs-digital/react-identity-access 3.1.0 → 3.2.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 +150 -141
- 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 +8 -2
- package/dist/providers/AppProvider.d.ts.map +1 -1
- package/dist/services/AuthApiService.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -21,7 +21,7 @@ class he {
|
|
|
21
21
|
const c = await this.sessionManager.getValidAccessToken();
|
|
22
22
|
d = { ...d, Authorization: `Bearer ${c}` };
|
|
23
23
|
}
|
|
24
|
-
const T = new AbortController(),
|
|
24
|
+
const T = new AbortController(), A = setTimeout(() => T.abort(), l);
|
|
25
25
|
try {
|
|
26
26
|
const c = await fetch(a, {
|
|
27
27
|
method: e,
|
|
@@ -29,12 +29,12 @@ class he {
|
|
|
29
29
|
body: n ? JSON.stringify(n) : void 0,
|
|
30
30
|
signal: T.signal
|
|
31
31
|
});
|
|
32
|
-
if (clearTimeout(
|
|
32
|
+
if (clearTimeout(A), !c.ok)
|
|
33
33
|
throw new Error(`HTTP ${c.status}: ${c.statusText}`);
|
|
34
34
|
const S = c.headers.get("content-type");
|
|
35
35
|
return !S || !S.includes("application/json") ? {} : await c.json();
|
|
36
36
|
} catch (c) {
|
|
37
|
-
throw clearTimeout(
|
|
37
|
+
throw clearTimeout(A), c instanceof Error && c.name === "AbortError" ? new Error(`Request timeout after ${l}ms`) : c;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
async get(e, t) {
|
|
@@ -101,7 +101,7 @@ class Je {
|
|
|
101
101
|
const $e = fe(null), Tt = 5 * 60 * 1e3;
|
|
102
102
|
function Sr({ config: r, children: e }) {
|
|
103
103
|
var k, m, g;
|
|
104
|
-
const { appId: t, baseUrl: n } = r, i = ((k = r.cache) == null ? void 0 : k.enabled) ?? !0, a = ((m = r.cache) == null ? void 0 : m.ttl) ?? Tt, l = ((g = r.cache) == null ? void 0 : g.storageKey) ?? `app_cache_${t}`, [d, T] = N(() => {
|
|
104
|
+
const { appId: t, baseUrl: n } = r, i = (((k = r.cache) == null ? void 0 : k.enabled) ?? !0) && !!t, a = ((m = r.cache) == null ? void 0 : m.ttl) ?? Tt, l = ((g = r.cache) == null ? void 0 : g.storageKey) ?? `app_cache_${t}`, [d, T] = N(() => {
|
|
105
105
|
if (!i) return null;
|
|
106
106
|
try {
|
|
107
107
|
const b = localStorage.getItem(l);
|
|
@@ -111,10 +111,14 @@ function Sr({ config: r, children: e }) {
|
|
|
111
111
|
} catch {
|
|
112
112
|
return null;
|
|
113
113
|
}
|
|
114
|
-
}), [
|
|
114
|
+
}), [A, c] = N(!!t && !d), [S, h] = N(null), x = Ee(d);
|
|
115
115
|
x.current = d;
|
|
116
116
|
const P = te(
|
|
117
117
|
async (b = !1) => {
|
|
118
|
+
if (!t) {
|
|
119
|
+
c(!1), h(null);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
118
122
|
if (!(!b && i && x.current))
|
|
119
123
|
try {
|
|
120
124
|
c(!0), h(null);
|
|
@@ -139,7 +143,7 @@ function Sr({ config: r, children: e }) {
|
|
|
139
143
|
},
|
|
140
144
|
[n, t, i, l]
|
|
141
145
|
), I = te(async () => {
|
|
142
|
-
if (!(!i || !x.current))
|
|
146
|
+
if (!(!t || !i || !x.current))
|
|
143
147
|
try {
|
|
144
148
|
const b = localStorage.getItem(l);
|
|
145
149
|
if (!b) return;
|
|
@@ -156,24 +160,24 @@ function Sr({ config: r, children: e }) {
|
|
|
156
160
|
} catch (b) {
|
|
157
161
|
process.env.NODE_ENV === "development" && console.warn("[AppProvider] Background app refresh failed:", b);
|
|
158
162
|
}
|
|
159
|
-
}, [n, t, i, a, l]),
|
|
163
|
+
}, [n, t, i, a, l]), R = V(
|
|
160
164
|
() => ({
|
|
161
165
|
appId: t,
|
|
162
166
|
baseUrl: n,
|
|
163
167
|
appInfo: d,
|
|
164
|
-
isAppLoading:
|
|
168
|
+
isAppLoading: A,
|
|
165
169
|
appError: S,
|
|
166
170
|
retryApp: () => {
|
|
167
171
|
P(!0);
|
|
168
172
|
}
|
|
169
173
|
}),
|
|
170
|
-
[t, n, d,
|
|
174
|
+
[t, n, d, A, S, P]
|
|
171
175
|
);
|
|
172
176
|
return re(() => {
|
|
173
|
-
x.current ? I() : P();
|
|
174
|
-
}, []), /* @__PURE__ */ s($e.Provider, { value:
|
|
177
|
+
t && (x.current ? I() : P());
|
|
178
|
+
}, []), /* @__PURE__ */ s($e.Provider, { value: R, children: e });
|
|
175
179
|
}
|
|
176
|
-
function
|
|
180
|
+
function Ae() {
|
|
177
181
|
const r = ne($e);
|
|
178
182
|
if (!r)
|
|
179
183
|
throw new Error("useApp must be used within an AppProvider");
|
|
@@ -182,7 +186,7 @@ function Re() {
|
|
|
182
186
|
function Ue() {
|
|
183
187
|
return ne($e);
|
|
184
188
|
}
|
|
185
|
-
const kr =
|
|
189
|
+
const kr = Ae;
|
|
186
190
|
class ee extends Error {
|
|
187
191
|
constructor(e, t) {
|
|
188
192
|
const n = {
|
|
@@ -222,7 +226,7 @@ function Et(r) {
|
|
|
222
226
|
function Ze(r) {
|
|
223
227
|
return JSON.parse(atob(r.replace(/-/g, "+").replace(/_/g, "/")));
|
|
224
228
|
}
|
|
225
|
-
function
|
|
229
|
+
function Re(r) {
|
|
226
230
|
const e = r.split(".");
|
|
227
231
|
if (e.length !== 3) return null;
|
|
228
232
|
try {
|
|
@@ -232,22 +236,22 @@ function Ae(r) {
|
|
|
232
236
|
}
|
|
233
237
|
}
|
|
234
238
|
function Ke(r) {
|
|
235
|
-
const e =
|
|
239
|
+
const e = Re(r), t = e == null ? void 0 : e.payload.exp;
|
|
236
240
|
return typeof t == "number" ? t * 1e3 : void 0;
|
|
237
241
|
}
|
|
238
242
|
function xt(r, e) {
|
|
239
243
|
var n;
|
|
240
|
-
const t = (n =
|
|
244
|
+
const t = (n = Re(r)) == null ? void 0 : n.payload[e];
|
|
241
245
|
return typeof t == "string" ? t : void 0;
|
|
242
246
|
}
|
|
243
|
-
const
|
|
247
|
+
const At = /^(javascript|data|vbscript|file):/i, Rt = /^https?:\/\//i;
|
|
244
248
|
function Pt(r, e = "baseUrl") {
|
|
245
249
|
if (!(r == null || r === "")) {
|
|
246
250
|
if (typeof r != "string")
|
|
247
251
|
throw new oe(e, r, "must be a string");
|
|
248
|
-
if (
|
|
252
|
+
if (At.test(r))
|
|
249
253
|
throw new oe(e, r, "dangerous URL scheme is not allowed");
|
|
250
|
-
if (!
|
|
254
|
+
if (!Rt.test(r))
|
|
251
255
|
throw new oe(e, r, "must start with http:// or https://");
|
|
252
256
|
}
|
|
253
257
|
}
|
|
@@ -276,7 +280,7 @@ function It(r, e = "accessToken") {
|
|
|
276
280
|
`<${t.length}-segment token>`,
|
|
277
281
|
"JWT must have exactly 3 segments (header.payload.signature)"
|
|
278
282
|
);
|
|
279
|
-
if (
|
|
283
|
+
if (Re(r) === null)
|
|
280
284
|
throw new oe(
|
|
281
285
|
e,
|
|
282
286
|
"<malformed JWT>",
|
|
@@ -664,11 +668,11 @@ const ie = class ie {
|
|
|
664
668
|
}
|
|
665
669
|
if (this.sessionGeneration !== t)
|
|
666
670
|
throw new ee("token_invalid", "Session cleared during refresh");
|
|
667
|
-
const
|
|
671
|
+
const A = await T.json();
|
|
668
672
|
this.setTokens({
|
|
669
|
-
accessToken:
|
|
670
|
-
refreshToken:
|
|
671
|
-
expiresIn:
|
|
673
|
+
accessToken: A.accessToken,
|
|
674
|
+
refreshToken: A.refreshToken || i,
|
|
675
|
+
expiresIn: A.expiresIn
|
|
672
676
|
});
|
|
673
677
|
}
|
|
674
678
|
// --- Session expiry handler ---
|
|
@@ -707,7 +711,7 @@ const ie = class ie {
|
|
|
707
711
|
getTokenPayload() {
|
|
708
712
|
var t, n;
|
|
709
713
|
const e = (t = this.getTokens()) == null ? void 0 : t.accessToken;
|
|
710
|
-
return e ? ((n =
|
|
714
|
+
return e ? ((n = Re(e)) == null ? void 0 : n.payload) ?? null : null;
|
|
711
715
|
}
|
|
712
716
|
/**
|
|
713
717
|
* Get userId from token (source of truth) or fallback to stored user
|
|
@@ -733,21 +737,26 @@ class Nt {
|
|
|
733
737
|
constructor(e) {
|
|
734
738
|
this.httpService = e, this.pendingVerifications = /* @__PURE__ */ new Map(), this.pendingMagicLinks = /* @__PURE__ */ new Map();
|
|
735
739
|
}
|
|
736
|
-
// Public endpoints - no auth required
|
|
740
|
+
// Public endpoints - no auth required.
|
|
741
|
+
// Must pass `{ skipAuth: true }` so HttpService does NOT call
|
|
742
|
+
// SessionManager.getValidAccessToken (which throws when no tokens exist).
|
|
737
743
|
async login(e) {
|
|
738
|
-
return
|
|
744
|
+
return this.httpService.post("/auth/login", e, { skipAuth: !0 });
|
|
739
745
|
}
|
|
740
746
|
async signup(e) {
|
|
741
|
-
return
|
|
747
|
+
return this.httpService.post("/auth/signup", e, { skipAuth: !0 });
|
|
742
748
|
}
|
|
743
749
|
async signupTenantAdmin(e) {
|
|
744
|
-
return
|
|
750
|
+
return this.httpService.post(
|
|
745
751
|
"/auth/signup/tenant-admin",
|
|
746
|
-
e
|
|
752
|
+
e,
|
|
753
|
+
{ skipAuth: !0 }
|
|
747
754
|
);
|
|
748
755
|
}
|
|
749
756
|
async refreshToken(e) {
|
|
750
|
-
return
|
|
757
|
+
return this.httpService.post("/auth/refresh", e, {
|
|
758
|
+
skipAuth: !0
|
|
759
|
+
});
|
|
751
760
|
}
|
|
752
761
|
async switchTenant(e) {
|
|
753
762
|
return await this.httpService.post(
|
|
@@ -759,7 +768,7 @@ class Nt {
|
|
|
759
768
|
return this.httpService.get("/auth/tenants");
|
|
760
769
|
}
|
|
761
770
|
async requestPasswordReset(e) {
|
|
762
|
-
await this.httpService.post("/auth/password-reset/request", e);
|
|
771
|
+
await this.httpService.post("/auth/password-reset/request", e, { skipAuth: !0 });
|
|
763
772
|
}
|
|
764
773
|
async sendMagicLink(e) {
|
|
765
774
|
const t = JSON.stringify([
|
|
@@ -769,7 +778,7 @@ class Nt {
|
|
|
769
778
|
e.frontendUrl ?? ""
|
|
770
779
|
]), n = this.pendingMagicLinks.get(t);
|
|
771
780
|
if (n) return n;
|
|
772
|
-
const i = this.httpService.post("/auth/magic-link/send", e).finally(() => {
|
|
781
|
+
const i = this.httpService.post("/auth/magic-link/send", e, { skipAuth: !0 }).finally(() => {
|
|
773
782
|
this.pendingMagicLinks.delete(t);
|
|
774
783
|
});
|
|
775
784
|
return this.pendingMagicLinks.set(t, i), i;
|
|
@@ -777,13 +786,13 @@ class Nt {
|
|
|
777
786
|
async verifyMagicLink(e) {
|
|
778
787
|
const t = e.token, n = this.pendingVerifications.get(t);
|
|
779
788
|
if (n) return n;
|
|
780
|
-
const i = this.httpService.post("/auth/magic-link/verify", e).finally(() => {
|
|
789
|
+
const i = this.httpService.post("/auth/magic-link/verify", e, { skipAuth: !0 }).finally(() => {
|
|
781
790
|
this.pendingVerifications.delete(t);
|
|
782
791
|
});
|
|
783
792
|
return this.pendingVerifications.set(t, i), i;
|
|
784
793
|
}
|
|
785
794
|
async confirmPasswordReset(e) {
|
|
786
|
-
await this.httpService.post("/auth/password-reset/confirm", e);
|
|
795
|
+
await this.httpService.post("/auth/password-reset/confirm", e, { skipAuth: !0 });
|
|
787
796
|
}
|
|
788
797
|
async changePassword(e) {
|
|
789
798
|
await this.httpService.post("/auth/change-password", e);
|
|
@@ -925,7 +934,7 @@ function Bt(r, e, t) {
|
|
|
925
934
|
const Be = fe(null);
|
|
926
935
|
function Er({ config: r, children: e }) {
|
|
927
936
|
var j, Z, $;
|
|
928
|
-
const { baseUrl: t, appInfo: n, appId: i } =
|
|
937
|
+
const { baseUrl: t, appInfo: n, appId: i } = Ae(), a = te(() => typeof window > "u" ? null : Ut(
|
|
929
938
|
{
|
|
930
939
|
tenantMode: r.tenantMode || "selector",
|
|
931
940
|
baseDomain: r.baseDomain,
|
|
@@ -937,9 +946,9 @@ function Er({ config: r, children: e }) {
|
|
|
937
946
|
search: window.location.search
|
|
938
947
|
},
|
|
939
948
|
window.localStorage
|
|
940
|
-
), [r.tenantMode, r.baseDomain, r.selectorParam, r.fixedTenantSlug]), [l, d] = N(() => a()), T = ((j = r.cache) == null ? void 0 : j.enabled) ?? !0,
|
|
941
|
-
() => ({ enabled: T, ttl:
|
|
942
|
-
[T,
|
|
949
|
+
), [r.tenantMode, r.baseDomain, r.selectorParam, r.fixedTenantSlug]), [l, d] = N(() => a()), T = ((j = r.cache) == null ? void 0 : j.enabled) ?? !0, A = ((Z = r.cache) == null ? void 0 : Z.ttl) ?? 5 * 60 * 1e3, c = (($ = r.cache) == null ? void 0 : $.storageKey) ?? `tenant_cache_${l || "default"}`, S = V(
|
|
950
|
+
() => ({ enabled: T, ttl: A, storageKey: c }),
|
|
951
|
+
[T, A, c]
|
|
943
952
|
), [h, x] = N(() => {
|
|
944
953
|
if (r.initialTenant) return r.initialTenant;
|
|
945
954
|
if (!S.enabled || !l) return null;
|
|
@@ -951,7 +960,7 @@ function Er({ config: r, children: e }) {
|
|
|
951
960
|
} catch {
|
|
952
961
|
return null;
|
|
953
962
|
}
|
|
954
|
-
}), [P, I] = N(!h && !r.initialTenant), [
|
|
963
|
+
}), [P, I] = N(!h && !r.initialTenant), [R, k] = N(null), [m, g] = N(null), [b, C] = N(!1), [o, p] = N(null);
|
|
955
964
|
re(() => {
|
|
956
965
|
if (r.tenantMode === "fixed") return;
|
|
957
966
|
const U = a();
|
|
@@ -1101,7 +1110,7 @@ function Er({ config: r, children: e }) {
|
|
|
1101
1110
|
tenant: h,
|
|
1102
1111
|
tenantSlug: l,
|
|
1103
1112
|
isTenantLoading: P,
|
|
1104
|
-
tenantError:
|
|
1113
|
+
tenantError: R,
|
|
1105
1114
|
retryTenant: () => {
|
|
1106
1115
|
l && y(l);
|
|
1107
1116
|
},
|
|
@@ -1119,7 +1128,7 @@ function Er({ config: r, children: e }) {
|
|
|
1119
1128
|
h,
|
|
1120
1129
|
l,
|
|
1121
1130
|
P,
|
|
1122
|
-
|
|
1131
|
+
R,
|
|
1123
1132
|
m,
|
|
1124
1133
|
E,
|
|
1125
1134
|
b,
|
|
@@ -1140,7 +1149,7 @@ function pe() {
|
|
|
1140
1149
|
return ne(Be);
|
|
1141
1150
|
}
|
|
1142
1151
|
const xr = ve;
|
|
1143
|
-
function
|
|
1152
|
+
function Ar() {
|
|
1144
1153
|
const { settings: r, settingsSchema: e, isSettingsLoading: t, settingsError: n, validateSettings: i } = ve();
|
|
1145
1154
|
return {
|
|
1146
1155
|
settings: r,
|
|
@@ -1182,14 +1191,14 @@ function et() {
|
|
|
1182
1191
|
}
|
|
1183
1192
|
}
|
|
1184
1193
|
const Pe = fe(null), Ie = fe(null);
|
|
1185
|
-
function
|
|
1194
|
+
function Rr({ config: r = {}, children: e }) {
|
|
1186
1195
|
const t = Ue(), n = pe(), i = (t == null ? void 0 : t.baseUrl) ?? r.baseUrl ?? "", a = (t == null ? void 0 : t.appId) ?? r.appId, l = (n == null ? void 0 : n.tenant) ?? null, d = (n == null ? void 0 : n.tenantSlug) ?? null, T = (n == null ? void 0 : n.switchTenant) ?? (() => {
|
|
1187
1196
|
});
|
|
1188
1197
|
if (!i)
|
|
1189
1198
|
throw new Error(
|
|
1190
1199
|
"[AuthProvider] baseUrl is required. Provide it via AppProvider or AuthConfig.baseUrl."
|
|
1191
1200
|
);
|
|
1192
|
-
const [
|
|
1201
|
+
const [A, c] = N(r.initialRoles || []), [S, h] = N(!r.initialRoles), [x, P] = N(null), [I, R] = N(!1), [k, m] = N(null), [g, b] = N(() => _t()), C = Ee({ done: !1 });
|
|
1193
1202
|
C.current.done || (C.current.done = !0);
|
|
1194
1203
|
const o = V(() => Me.getInstance({
|
|
1195
1204
|
baseUrl: i,
|
|
@@ -1219,7 +1228,7 @@ function Ar({ config: r = {}, children: e }) {
|
|
|
1219
1228
|
), se = V(
|
|
1220
1229
|
() => new Ct(u),
|
|
1221
1230
|
[u]
|
|
1222
|
-
), F = V(() => x != null && x.roleId &&
|
|
1231
|
+
), F = V(() => x != null && x.roleId && A.find((w) => w.id === x.roleId) || null, [x, A]), H = V(() => (F == null ? void 0 : F.permissions) || [], [F]), j = V(
|
|
1223
1232
|
() => o.hasValidSession() && x !== null,
|
|
1224
1233
|
[o, x]
|
|
1225
1234
|
), Z = V(() => (x == null ? void 0 : x.tenantId) != null, [x]), $ = Ee(null), U = async (w = !1) => {
|
|
@@ -1230,14 +1239,14 @@ function Ar({ config: r = {}, children: e }) {
|
|
|
1230
1239
|
process.env.NODE_ENV === "development" && console.warn("[AuthProvider] No userId available in token or storage");
|
|
1231
1240
|
return;
|
|
1232
1241
|
}
|
|
1233
|
-
|
|
1242
|
+
R(!0), m(null);
|
|
1234
1243
|
const z = await D.getUserById(M);
|
|
1235
1244
|
P(z), o.setUser(z);
|
|
1236
1245
|
} catch (M) {
|
|
1237
1246
|
const z = M instanceof Error ? M : new Error("Failed to load user data");
|
|
1238
1247
|
m(z), process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to load user data:", z);
|
|
1239
1248
|
} finally {
|
|
1240
|
-
|
|
1249
|
+
R(!1);
|
|
1241
1250
|
}
|
|
1242
1251
|
}, L = async (w) => {
|
|
1243
1252
|
var He;
|
|
@@ -1451,7 +1460,7 @@ function Ar({ config: r = {}, children: e }) {
|
|
|
1451
1460
|
userError: k,
|
|
1452
1461
|
userRole: F,
|
|
1453
1462
|
userPermissions: H,
|
|
1454
|
-
availableRoles:
|
|
1463
|
+
availableRoles: A,
|
|
1455
1464
|
rolesLoading: S,
|
|
1456
1465
|
userTenants: g,
|
|
1457
1466
|
hasTenantContext: Z,
|
|
@@ -1470,7 +1479,7 @@ function Ar({ config: r = {}, children: e }) {
|
|
|
1470
1479
|
k,
|
|
1471
1480
|
F,
|
|
1472
1481
|
H,
|
|
1473
|
-
|
|
1482
|
+
A,
|
|
1474
1483
|
S,
|
|
1475
1484
|
g,
|
|
1476
1485
|
Z,
|
|
@@ -1578,10 +1587,10 @@ class Ot {
|
|
|
1578
1587
|
}
|
|
1579
1588
|
const Ve = fe(null);
|
|
1580
1589
|
function Lr({ config: r = {}, children: e }) {
|
|
1581
|
-
const t = Ue(), n = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", a = (t == null ? void 0 : t.appId) ?? "", l = (n == null ? void 0 : n.tenant) ?? null, [d, T] = N([]), [
|
|
1590
|
+
const t = Ue(), n = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", a = (t == null ? void 0 : t.appId) ?? "", l = (n == null ? void 0 : n.tenant) ?? null, [d, T] = N([]), [A, c] = N(!1), [S, h] = N(null), [x, P] = N(!1), I = V(() => {
|
|
1582
1591
|
const m = new he(i);
|
|
1583
1592
|
return new Ot(m);
|
|
1584
|
-
}, [i]),
|
|
1593
|
+
}, [i]), R = async () => {
|
|
1585
1594
|
if (!(l != null && l.id)) {
|
|
1586
1595
|
T([]);
|
|
1587
1596
|
return;
|
|
@@ -1599,8 +1608,8 @@ function Lr({ config: r = {}, children: e }) {
|
|
|
1599
1608
|
};
|
|
1600
1609
|
re(() => {
|
|
1601
1610
|
if (!i || !a) return;
|
|
1602
|
-
|
|
1603
|
-
const m = r.refreshInterval || 5 * 60 * 1e3, g = setInterval(
|
|
1611
|
+
R().finally(() => P(!0));
|
|
1612
|
+
const m = r.refreshInterval || 5 * 60 * 1e3, g = setInterval(R, m);
|
|
1604
1613
|
return () => clearInterval(g);
|
|
1605
1614
|
}, [l == null ? void 0 : l.id, i, a, r.refreshInterval]);
|
|
1606
1615
|
const k = V(() => {
|
|
@@ -1611,11 +1620,11 @@ function Lr({ config: r = {}, children: e }) {
|
|
|
1611
1620
|
const E = d.find((y) => y.key === p);
|
|
1612
1621
|
return E ? E.value ? "enabled" : "disabled" : "not_found";
|
|
1613
1622
|
}, C = async () => {
|
|
1614
|
-
await
|
|
1623
|
+
await R();
|
|
1615
1624
|
}, o = !!(i && a) && (x || !(l != null && l.id));
|
|
1616
1625
|
return {
|
|
1617
1626
|
featureFlags: d,
|
|
1618
|
-
loading:
|
|
1627
|
+
loading: A,
|
|
1619
1628
|
error: S,
|
|
1620
1629
|
isReady: o,
|
|
1621
1630
|
isEnabled: m,
|
|
@@ -1623,7 +1632,7 @@ function Lr({ config: r = {}, children: e }) {
|
|
|
1623
1632
|
getFlagState: b,
|
|
1624
1633
|
refresh: C
|
|
1625
1634
|
};
|
|
1626
|
-
}, [d,
|
|
1635
|
+
}, [d, A, S, i, a, l == null ? void 0 : l.id, x]);
|
|
1627
1636
|
return /* @__PURE__ */ s(Ve.Provider, { value: k, children: e });
|
|
1628
1637
|
}
|
|
1629
1638
|
function Vt() {
|
|
@@ -1677,7 +1686,7 @@ class qt {
|
|
|
1677
1686
|
}
|
|
1678
1687
|
const qe = fe(void 0);
|
|
1679
1688
|
function Fr({ config: r = {}, children: e }) {
|
|
1680
|
-
const t = Ue(), n = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", a = (n == null ? void 0 : n.tenant) ?? null, [l, d] = N(null), [T,
|
|
1689
|
+
const t = Ue(), n = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", a = (n == null ? void 0 : n.tenant) ?? null, [l, d] = N(null), [T, A] = N(!1), [c, S] = N(null), [h, x] = N(!1), P = V(() => {
|
|
1681
1690
|
const k = new he(i);
|
|
1682
1691
|
return new qt(k);
|
|
1683
1692
|
}, [i]), I = async () => {
|
|
@@ -1685,7 +1694,7 @@ function Fr({ config: r = {}, children: e }) {
|
|
|
1685
1694
|
d(null);
|
|
1686
1695
|
return;
|
|
1687
1696
|
}
|
|
1688
|
-
|
|
1697
|
+
A(!0), S(null);
|
|
1689
1698
|
try {
|
|
1690
1699
|
const k = await P.getTenantSubscriptionFeatures(a.id);
|
|
1691
1700
|
d(k);
|
|
@@ -1693,7 +1702,7 @@ function Fr({ config: r = {}, children: e }) {
|
|
|
1693
1702
|
const m = k instanceof Error ? k.message : "Failed to fetch subscription";
|
|
1694
1703
|
S(m), r.onError && r.onError(k instanceof Error ? k : new Error(m));
|
|
1695
1704
|
} finally {
|
|
1696
|
-
|
|
1705
|
+
A(!1);
|
|
1697
1706
|
}
|
|
1698
1707
|
};
|
|
1699
1708
|
re(() => {
|
|
@@ -1701,7 +1710,7 @@ function Fr({ config: r = {}, children: e }) {
|
|
|
1701
1710
|
const k = r.refreshInterval || 10 * 60 * 1e3, m = setInterval(I, k);
|
|
1702
1711
|
return () => clearInterval(m);
|
|
1703
1712
|
}, [a == null ? void 0 : a.id, i, r.refreshInterval]);
|
|
1704
|
-
const
|
|
1713
|
+
const R = V(() => {
|
|
1705
1714
|
const k = (l == null ? void 0 : l.features) || [], m = (E) => {
|
|
1706
1715
|
const y = k.find((u) => u.key === E);
|
|
1707
1716
|
return y ? y.type === "BOOLEAN" || y.type === "boolean" ? y.value === !0 : !!y.value : !1;
|
|
@@ -1724,7 +1733,7 @@ function Fr({ config: r = {}, children: e }) {
|
|
|
1724
1733
|
refresh: o
|
|
1725
1734
|
};
|
|
1726
1735
|
}, [l, T, c, i, a == null ? void 0 : a.id, h]);
|
|
1727
|
-
return /* @__PURE__ */ s(qe.Provider, { value:
|
|
1736
|
+
return /* @__PURE__ */ s(qe.Provider, { value: R, children: e });
|
|
1728
1737
|
}
|
|
1729
1738
|
function zt() {
|
|
1730
1739
|
const r = ne(qe);
|
|
@@ -1893,7 +1902,7 @@ function Dr({
|
|
|
1893
1902
|
requiredPermissions: n,
|
|
1894
1903
|
requireAllPermissions: i = !1
|
|
1895
1904
|
}) {
|
|
1896
|
-
const { hasValidSession: a, sessionManager: l, hasPermission: d, hasAnyPermission: T, hasAllPermissions:
|
|
1905
|
+
const { hasValidSession: a, sessionManager: l, hasPermission: d, hasAnyPermission: T, hasAllPermissions: A } = de();
|
|
1897
1906
|
if (!a())
|
|
1898
1907
|
return /* @__PURE__ */ s(B, { children: e || /* @__PURE__ */ s(tt, {}) });
|
|
1899
1908
|
const c = l.getUser();
|
|
@@ -1901,7 +1910,7 @@ function Dr({
|
|
|
1901
1910
|
return /* @__PURE__ */ s(B, { children: e || /* @__PURE__ */ s(tt, {}) });
|
|
1902
1911
|
if (t && !Gt(c.userType, t))
|
|
1903
1912
|
return /* @__PURE__ */ s(rt, { userType: c.userType, minUserType: t });
|
|
1904
|
-
if (n && n.length > 0 && !(i ?
|
|
1913
|
+
if (n && n.length > 0 && !(i ? A(n) : T(n))) {
|
|
1905
1914
|
const h = n.filter((x) => !d(x)).map((x) => typeof x == "string" ? x : x.name);
|
|
1906
1915
|
return /* @__PURE__ */ s(rt, { missingPermissions: h });
|
|
1907
1916
|
}
|
|
@@ -2003,7 +2012,7 @@ function Mr({
|
|
|
2003
2012
|
requireAllPermissions: i = !1,
|
|
2004
2013
|
fallback: a
|
|
2005
2014
|
}) {
|
|
2006
|
-
const { hasValidSession: l, sessionManager: d, hasPermission: T, hasAnyPermission:
|
|
2015
|
+
const { hasValidSession: l, sessionManager: d, hasPermission: T, hasAnyPermission: A, hasAllPermissions: c } = de(), S = xe();
|
|
2007
2016
|
if (re(() => {
|
|
2008
2017
|
process.env.NODE_ENV === "development" && console.warn(
|
|
2009
2018
|
"[react-identity-access] ProtectedRoute is deprecated. Use AuthenticatedZone or AdminZone from ZoneRoute instead."
|
|
@@ -2024,7 +2033,7 @@ function Mr({
|
|
|
2024
2033
|
requiredUserType: t
|
|
2025
2034
|
}
|
|
2026
2035
|
);
|
|
2027
|
-
if (n && n.length > 0 && !(i ? c(n) :
|
|
2036
|
+
if (n && n.length > 0 && !(i ? c(n) : A(n))) {
|
|
2028
2037
|
const P = n.filter((I) => !T(I)).map((I) => typeof I == "string" ? I : I.name);
|
|
2029
2038
|
return /* @__PURE__ */ s(nt, { missingPermissions: P });
|
|
2030
2039
|
}
|
|
@@ -2159,11 +2168,11 @@ const ue = ({
|
|
|
2159
2168
|
requireAllPermissions: l = !0,
|
|
2160
2169
|
returnTo: d,
|
|
2161
2170
|
onAccessDenied: T,
|
|
2162
|
-
redirectTo:
|
|
2171
|
+
redirectTo: A,
|
|
2163
2172
|
loadingFallback: c,
|
|
2164
2173
|
accessDeniedFallback: S
|
|
2165
2174
|
}) => {
|
|
2166
|
-
const h = xe(), { isAuthenticated: x, isAuthInitializing: P, currentUser: I, userPermissions:
|
|
2175
|
+
const h = xe(), { isAuthenticated: x, isAuthInitializing: P, currentUser: I, userPermissions: R } = de(), { tenant: k, isTenantLoading: m } = ve(), g = Wt(), b = V(() => {
|
|
2167
2176
|
if (e)
|
|
2168
2177
|
return g.presets[e];
|
|
2169
2178
|
}, [e, g.presets]), C = V(
|
|
@@ -2180,18 +2189,18 @@ const ue = ({
|
|
|
2180
2189
|
hasTenant: !!k,
|
|
2181
2190
|
isAuthenticated: x,
|
|
2182
2191
|
userType: I == null ? void 0 : I.userType,
|
|
2183
|
-
permissions:
|
|
2192
|
+
permissions: R,
|
|
2184
2193
|
isLoading: P || m
|
|
2185
2194
|
}),
|
|
2186
2195
|
[
|
|
2187
2196
|
k,
|
|
2188
2197
|
x,
|
|
2189
2198
|
I == null ? void 0 : I.userType,
|
|
2190
|
-
|
|
2199
|
+
R,
|
|
2191
2200
|
P,
|
|
2192
2201
|
m
|
|
2193
2202
|
]
|
|
2194
|
-
), p = V(() => o.isLoading ? null : Yt(C, o), [C, o]), E = V(() => p ?
|
|
2203
|
+
), p = V(() => o.isLoading ? null : Yt(C, o), [C, o]), E = V(() => p ? A || Xt(o, g.zoneRoots) : null, [p, A, o, g.zoneRoots]), y = V(() => !p || !E ? null : {
|
|
2195
2204
|
type: p,
|
|
2196
2205
|
required: {
|
|
2197
2206
|
tenant: C.tenant,
|
|
@@ -2314,26 +2323,26 @@ function Jr({ name: r, children: e, fallback: t }) {
|
|
|
2314
2323
|
) : n(r) ? /* @__PURE__ */ s(B, { children: e }) : /* @__PURE__ */ s(B, { children: t || /* @__PURE__ */ s(nr, { flagName: r }) });
|
|
2315
2324
|
}
|
|
2316
2325
|
function we(r) {
|
|
2317
|
-
const { submit: e, defaultErrorMessage: t, validate: n, onSuccess: i, onError: a } = r, [l, d] = N(!1), [T,
|
|
2318
|
-
S((m) => ({ ...m, [
|
|
2319
|
-
}, []), x = te((
|
|
2326
|
+
const { submit: e, defaultErrorMessage: t, validate: n, onSuccess: i, onError: a } = r, [l, d] = N(!1), [T, A] = N(""), [c, S] = N({}), h = te((R, k) => {
|
|
2327
|
+
S((m) => ({ ...m, [R]: k }));
|
|
2328
|
+
}, []), x = te((R) => {
|
|
2320
2329
|
S((k) => {
|
|
2321
|
-
if (!k[
|
|
2330
|
+
if (!k[R]) return k;
|
|
2322
2331
|
const m = { ...k };
|
|
2323
|
-
return delete m[
|
|
2332
|
+
return delete m[R], m;
|
|
2324
2333
|
});
|
|
2325
2334
|
}, []), P = te(() => {
|
|
2326
|
-
|
|
2335
|
+
A(""), S({});
|
|
2327
2336
|
}, []), I = te(
|
|
2328
|
-
async (
|
|
2329
|
-
if (
|
|
2330
|
-
d(!0),
|
|
2337
|
+
async (R) => {
|
|
2338
|
+
if (R && R.preventDefault(), !(n && !n())) {
|
|
2339
|
+
d(!0), A("");
|
|
2331
2340
|
try {
|
|
2332
2341
|
const k = await e();
|
|
2333
2342
|
return i == null || i(k), k;
|
|
2334
2343
|
} catch (k) {
|
|
2335
2344
|
const m = k instanceof Error ? k.message : t;
|
|
2336
|
-
|
|
2345
|
+
A(m), a == null || a(m);
|
|
2337
2346
|
return;
|
|
2338
2347
|
} finally {
|
|
2339
2348
|
d(!1);
|
|
@@ -2345,7 +2354,7 @@ function we(r) {
|
|
|
2345
2354
|
return {
|
|
2346
2355
|
loading: l,
|
|
2347
2356
|
error: T,
|
|
2348
|
-
setError:
|
|
2357
|
+
setError: A,
|
|
2349
2358
|
fieldErrors: c,
|
|
2350
2359
|
setFieldError: h,
|
|
2351
2360
|
clearFieldError: x,
|
|
@@ -2592,11 +2601,11 @@ function Zr({
|
|
|
2592
2601
|
onSignupClick: l,
|
|
2593
2602
|
onMagicLinkClick: d,
|
|
2594
2603
|
showForgotPassword: T = !0,
|
|
2595
|
-
showSignupLink:
|
|
2604
|
+
showSignupLink: A = !0,
|
|
2596
2605
|
showMagicLinkOption: c = !0,
|
|
2597
2606
|
className: S
|
|
2598
2607
|
}) {
|
|
2599
|
-
const [h, x] = N(""), [P, I] = N(""), [
|
|
2608
|
+
const [h, x] = N(""), [P, I] = N(""), [R, k] = N(!1), { login: m } = de(), g = { ...ar, ...r }, b = Le("#3b82f6", e), C = { ...or, ...t }, o = we({
|
|
2600
2609
|
defaultErrorMessage: g.errorMessage,
|
|
2601
2610
|
validate: () => {
|
|
2602
2611
|
const u = [];
|
|
@@ -2642,7 +2651,7 @@ function Zr({
|
|
|
2642
2651
|
{
|
|
2643
2652
|
id: "password",
|
|
2644
2653
|
name: "password",
|
|
2645
|
-
type:
|
|
2654
|
+
type: R ? "text" : "password",
|
|
2646
2655
|
value: P,
|
|
2647
2656
|
onChange: (u) => {
|
|
2648
2657
|
I(u.target.value), o.clearFieldError("password");
|
|
@@ -2656,11 +2665,11 @@ function Zr({
|
|
|
2656
2665
|
"button",
|
|
2657
2666
|
{
|
|
2658
2667
|
type: "button",
|
|
2659
|
-
onClick: () => k(!
|
|
2668
|
+
onClick: () => k(!R),
|
|
2660
2669
|
style: b.passwordToggle,
|
|
2661
2670
|
disabled: o.loading,
|
|
2662
|
-
"aria-label":
|
|
2663
|
-
children:
|
|
2671
|
+
"aria-label": R ? g.hidePasswordAriaLabel : g.showPasswordAriaLabel,
|
|
2672
|
+
children: R ? C.hidePassword : C.showPassword
|
|
2664
2673
|
}
|
|
2665
2674
|
)
|
|
2666
2675
|
] })
|
|
@@ -2668,7 +2677,7 @@ function Zr({
|
|
|
2668
2677
|
/* @__PURE__ */ s("button", { type: "submit", disabled: E, style: y, children: o.loading ? g.loadingText : g.submitButton }),
|
|
2669
2678
|
o.error && /* @__PURE__ */ s("div", { style: b.errorText, children: o.error })
|
|
2670
2679
|
] }),
|
|
2671
|
-
(T ||
|
|
2680
|
+
(T || A || c) && /* @__PURE__ */ f("div", { style: b.linkContainer, children: [
|
|
2672
2681
|
c && /* @__PURE__ */ f("div", { children: [
|
|
2673
2682
|
/* @__PURE__ */ f("span", { style: b.divider, children: [
|
|
2674
2683
|
g.magicLinkText,
|
|
@@ -2676,10 +2685,10 @@ function Zr({
|
|
|
2676
2685
|
] }),
|
|
2677
2686
|
/* @__PURE__ */ s("a", { onClick: d, style: b.link, children: g.magicLinkLink })
|
|
2678
2687
|
] }),
|
|
2679
|
-
c && (T ||
|
|
2688
|
+
c && (T || A) && /* @__PURE__ */ s("div", { style: b.divider, children: g.dividerBullet }),
|
|
2680
2689
|
T && /* @__PURE__ */ s("a", { onClick: a, style: b.link, children: g.forgotPasswordLink }),
|
|
2681
|
-
T &&
|
|
2682
|
-
|
|
2690
|
+
T && A && /* @__PURE__ */ s("div", { style: b.divider, children: g.dividerBullet }),
|
|
2691
|
+
A && /* @__PURE__ */ f("div", { children: [
|
|
2683
2692
|
/* @__PURE__ */ f("span", { style: b.divider, children: [
|
|
2684
2693
|
g.signupText,
|
|
2685
2694
|
" "
|
|
@@ -2729,25 +2738,25 @@ function Kr({
|
|
|
2729
2738
|
onMagicLinkClick: l,
|
|
2730
2739
|
showLoginLink: d = !0,
|
|
2731
2740
|
showMagicLinkOption: T = !0,
|
|
2732
|
-
className:
|
|
2741
|
+
className: A
|
|
2733
2742
|
}) {
|
|
2734
2743
|
var U;
|
|
2735
|
-
const [c, S] = N(""), [h, x] = N(""), [P, I] = N(""), [
|
|
2744
|
+
const [c, S] = N(""), [h, x] = N(""), [P, I] = N(""), [R, k] = N(""), [m, g] = N(""), [b, C] = N(""), [o, p] = N(""), { signup: E, signupTenantAdmin: y } = de(), u = ((U = pe()) == null ? void 0 : U.tenant) ?? null, v = { ...lr, ...r }, D = Le("#10b981", e), se = !!c && (!!P || !!R) && !!m && !!b && (t === "user" || !!o), F = we({
|
|
2736
2745
|
defaultErrorMessage: v.errorMessage,
|
|
2737
2746
|
validate: () => {
|
|
2738
2747
|
const L = [];
|
|
2739
|
-
return c.trim() || L.push("name"), !P.trim() && !
|
|
2748
|
+
return c.trim() || L.push("name"), !P.trim() && !R.trim() && (L.push("email"), L.push("phoneNumber")), m.trim() || L.push("password"), b.trim() || L.push("confirmPassword"), t === "tenant" && !o.trim() && L.push("tenantName"), L.forEach((q) => F.setFieldError(q, !0)), L.length > 0 ? !1 : m !== b ? (F.setError(v.passwordMismatchError), F.setFieldError("confirmPassword", !0), !1) : t === "user" && !(u != null && u.id) ? (F.setError(v.tenantNotFoundError), !1) : !0;
|
|
2740
2749
|
},
|
|
2741
2750
|
submit: async () => t === "tenant" ? y({
|
|
2742
2751
|
email: P || void 0,
|
|
2743
|
-
phoneNumber:
|
|
2752
|
+
phoneNumber: R || void 0,
|
|
2744
2753
|
name: c,
|
|
2745
2754
|
password: m,
|
|
2746
2755
|
tenantName: o,
|
|
2747
2756
|
lastName: h || void 0
|
|
2748
2757
|
}) : E({
|
|
2749
2758
|
email: P || void 0,
|
|
2750
|
-
phoneNumber:
|
|
2759
|
+
phoneNumber: R || void 0,
|
|
2751
2760
|
name: c,
|
|
2752
2761
|
password: m,
|
|
2753
2762
|
tenantId: u.id,
|
|
@@ -2765,7 +2774,7 @@ function Kr({
|
|
|
2765
2774
|
}, $ = () => {
|
|
2766
2775
|
F.clearFieldError("email"), F.clearFieldError("phoneNumber");
|
|
2767
2776
|
};
|
|
2768
|
-
return /* @__PURE__ */ f("div", { className:
|
|
2777
|
+
return /* @__PURE__ */ f("div", { className: A, style: D.container, children: [
|
|
2769
2778
|
/* @__PURE__ */ s("h2", { style: D.title, children: v.title }),
|
|
2770
2779
|
/* @__PURE__ */ f("form", { onSubmit: F.handleSubmit, style: D.form, children: [
|
|
2771
2780
|
/* @__PURE__ */ f("div", { style: D.fieldGroup, children: [
|
|
@@ -2828,7 +2837,7 @@ function Kr({
|
|
|
2828
2837
|
id: "phoneNumber",
|
|
2829
2838
|
name: "phoneNumber",
|
|
2830
2839
|
type: "tel",
|
|
2831
|
-
value:
|
|
2840
|
+
value: R,
|
|
2832
2841
|
onChange: (L) => {
|
|
2833
2842
|
k(L.target.value), $();
|
|
2834
2843
|
},
|
|
@@ -2950,10 +2959,10 @@ function Yr({
|
|
|
2950
2959
|
showTraditionalLinks: l = !0,
|
|
2951
2960
|
className: d,
|
|
2952
2961
|
verifyToken: T,
|
|
2953
|
-
frontendUrl:
|
|
2962
|
+
frontendUrl: A
|
|
2954
2963
|
}) {
|
|
2955
2964
|
var H;
|
|
2956
|
-
const [c, S] = N(""), [h, x] = N(""), [P, I] = N(""), [
|
|
2965
|
+
const [c, S] = N(""), [h, x] = N(""), [P, I] = N(""), [R, k] = N(!1), [m, g] = N(""), [b, C] = N(!1), { sendMagicLink: o, verifyMagicLink: p } = de(), E = ((H = pe()) == null ? void 0 : H.tenant) ?? null, y = { ...cr, ...r }, u = Le("#3b82f6", e), v = we({
|
|
2957
2966
|
defaultErrorMessage: y.errorMessage,
|
|
2958
2967
|
validate: () => {
|
|
2959
2968
|
const j = [];
|
|
@@ -2961,7 +2970,7 @@ function Yr({
|
|
|
2961
2970
|
},
|
|
2962
2971
|
submit: async () => {
|
|
2963
2972
|
g("");
|
|
2964
|
-
const j =
|
|
2973
|
+
const j = A || (typeof window < "u" ? window.location.origin : ""), Z = await o({
|
|
2965
2974
|
email: c,
|
|
2966
2975
|
tenantId: E.id,
|
|
2967
2976
|
frontendUrl: j,
|
|
@@ -2995,12 +3004,12 @@ function Yr({
|
|
|
2995
3004
|
const D = (j) => ({
|
|
2996
3005
|
...u.input,
|
|
2997
3006
|
...v.fieldErrors[j] ? u.inputError : {}
|
|
2998
|
-
}), se = !c || v.loading ||
|
|
3007
|
+
}), se = !c || v.loading || R, F = {
|
|
2999
3008
|
...u.button,
|
|
3000
|
-
...v.loading ||
|
|
3009
|
+
...v.loading || R ? u.buttonLoading : {},
|
|
3001
3010
|
...se ? u.buttonDisabled : {}
|
|
3002
3011
|
};
|
|
3003
|
-
return
|
|
3012
|
+
return R ? /* @__PURE__ */ f("div", { className: d, style: u.container, children: [
|
|
3004
3013
|
/* @__PURE__ */ s("h2", { style: u.title, children: y.verifyingText }),
|
|
3005
3014
|
/* @__PURE__ */ s("div", { style: u.verifyingContainer, children: /* @__PURE__ */ s("div", { style: u.verifyingText, children: y.verifyingDescription }) })
|
|
3006
3015
|
] }) : /* @__PURE__ */ f("div", { className: d, style: u.container, children: [
|
|
@@ -3021,7 +3030,7 @@ function Yr({
|
|
|
3021
3030
|
},
|
|
3022
3031
|
placeholder: y.emailPlaceholder,
|
|
3023
3032
|
style: D("email"),
|
|
3024
|
-
disabled: v.loading ||
|
|
3033
|
+
disabled: v.loading || R
|
|
3025
3034
|
}
|
|
3026
3035
|
)
|
|
3027
3036
|
] }),
|
|
@@ -3049,7 +3058,7 @@ function Yr({
|
|
|
3049
3058
|
},
|
|
3050
3059
|
placeholder: y.namePlaceholder,
|
|
3051
3060
|
style: D("name"),
|
|
3052
|
-
disabled: v.loading ||
|
|
3061
|
+
disabled: v.loading || R
|
|
3053
3062
|
}
|
|
3054
3063
|
)
|
|
3055
3064
|
] }),
|
|
@@ -3065,7 +3074,7 @@ function Yr({
|
|
|
3065
3074
|
onChange: (j) => I(j.target.value),
|
|
3066
3075
|
placeholder: y.lastNamePlaceholder,
|
|
3067
3076
|
style: u.input,
|
|
3068
|
-
disabled: v.loading ||
|
|
3077
|
+
disabled: v.loading || R
|
|
3069
3078
|
}
|
|
3070
3079
|
)
|
|
3071
3080
|
] }),
|
|
@@ -3256,22 +3265,22 @@ function Xr({
|
|
|
3256
3265
|
onBackToLogin: l,
|
|
3257
3266
|
className: d,
|
|
3258
3267
|
token: T,
|
|
3259
|
-
email:
|
|
3268
|
+
email: A,
|
|
3260
3269
|
appId: c,
|
|
3261
3270
|
tenantSlug: S,
|
|
3262
3271
|
autoRedirectDelay: h = 3e3
|
|
3263
3272
|
}) {
|
|
3264
|
-
const [x, P] = N("verifying"), [I,
|
|
3273
|
+
const [x, P] = N("verifying"), [I, R] = N(""), { verifyMagicLink: k } = de(), m = { ...ur, ...r }, g = { ...ut, ...e }, b = { ...fr, ...t }, C = () => {
|
|
3265
3274
|
if (typeof window > "u") return {};
|
|
3266
3275
|
const u = new URLSearchParams(window.location.search);
|
|
3267
3276
|
return {
|
|
3268
3277
|
token: T || u.get("token") || "",
|
|
3269
|
-
email:
|
|
3278
|
+
email: A || u.get("email") || "",
|
|
3270
3279
|
appId: c || u.get("appId") || "",
|
|
3271
3280
|
tenantSlug: S || u.get("tenantSlug") || void 0
|
|
3272
3281
|
};
|
|
3273
3282
|
}, o = async () => {
|
|
3274
|
-
P("verifying"),
|
|
3283
|
+
P("verifying"), R("");
|
|
3275
3284
|
try {
|
|
3276
3285
|
const u = C();
|
|
3277
3286
|
if (!u.token || !u.email)
|
|
@@ -3286,7 +3295,7 @@ function Xr({
|
|
|
3286
3295
|
}, h);
|
|
3287
3296
|
} catch (u) {
|
|
3288
3297
|
const v = u.message || m.errorMessage;
|
|
3289
|
-
|
|
3298
|
+
R(v), P("error"), i == null || i(v);
|
|
3290
3299
|
}
|
|
3291
3300
|
}, p = () => {
|
|
3292
3301
|
a == null || a(), o();
|
|
@@ -3408,11 +3417,11 @@ function en({
|
|
|
3408
3417
|
className: T
|
|
3409
3418
|
}) {
|
|
3410
3419
|
var se;
|
|
3411
|
-
const [
|
|
3420
|
+
const [A, c] = N(""), [S, h] = N(n), [x, P] = N(""), [I, R] = N(""), [k, m] = N(""), { requestPasswordReset: g, confirmPasswordReset: b } = de(), C = ((se = pe()) == null ? void 0 : se.tenant) ?? null, o = { ...mr, ...r }, p = Le("#f59e0b", e), E = we({
|
|
3412
3421
|
defaultErrorMessage: o.errorMessage,
|
|
3413
|
-
validate: () =>
|
|
3422
|
+
validate: () => A.trim() ? C != null && C.id ? !0 : (E.setError(o.tenantNotFoundError), !1) : (E.setFieldError("email", !0), !1),
|
|
3414
3423
|
submit: async () => {
|
|
3415
|
-
m(""), await g({ email:
|
|
3424
|
+
m(""), await g({ email: A, tenantId: C.id }), m(o.successMessage);
|
|
3416
3425
|
},
|
|
3417
3426
|
onSuccess: () => i == null ? void 0 : i(),
|
|
3418
3427
|
onError: a
|
|
@@ -3481,7 +3490,7 @@ function en({
|
|
|
3481
3490
|
type: "password",
|
|
3482
3491
|
value: I,
|
|
3483
3492
|
onChange: ($) => {
|
|
3484
|
-
|
|
3493
|
+
R($.target.value), y.clearFieldError("confirmPassword"), y.error === o.passwordMismatchError && y.setError("");
|
|
3485
3494
|
},
|
|
3486
3495
|
placeholder: o.confirmPasswordPlaceholder,
|
|
3487
3496
|
style: F("confirmPassword"),
|
|
@@ -3505,7 +3514,7 @@ function en({
|
|
|
3505
3514
|
const u = (F) => ({
|
|
3506
3515
|
...p.input,
|
|
3507
3516
|
...E.fieldErrors[F] ? p.inputError : {}
|
|
3508
|
-
}), v = !
|
|
3517
|
+
}), v = !A || E.loading, D = {
|
|
3509
3518
|
...p.button,
|
|
3510
3519
|
...E.loading ? p.buttonLoading : {},
|
|
3511
3520
|
...v ? p.buttonDisabled : {}
|
|
@@ -3520,7 +3529,7 @@ function en({
|
|
|
3520
3529
|
"input",
|
|
3521
3530
|
{
|
|
3522
3531
|
type: "email",
|
|
3523
|
-
value:
|
|
3532
|
+
value: A,
|
|
3524
3533
|
onChange: (F) => {
|
|
3525
3534
|
c(F.target.value), E.clearFieldError("email");
|
|
3526
3535
|
},
|
|
@@ -3595,8 +3604,8 @@ function tn({
|
|
|
3595
3604
|
errorFallback: t,
|
|
3596
3605
|
requireTenant: n = !0
|
|
3597
3606
|
}) {
|
|
3598
|
-
const { isAppLoading: i, appError: a, retryApp: l } =
|
|
3599
|
-
}), I = (T == null ? void 0 : T.isAuthReady) ?? !0,
|
|
3607
|
+
const { isAppLoading: i, appError: a, retryApp: l } = Ae(), d = pe(), T = Oe(), A = at(), c = lt(), S = (d == null ? void 0 : d.isTenantLoading) ?? !1, h = (d == null ? void 0 : d.tenantError) ?? null, x = (d == null ? void 0 : d.tenantSlug) ?? null, P = (d == null ? void 0 : d.retryTenant) ?? (() => {
|
|
3608
|
+
}), I = (T == null ? void 0 : T.isAuthReady) ?? !0, R = (A == null ? void 0 : A.isReady) ?? !0, k = (c == null ? void 0 : c.isReady) ?? !0, m = n && d && x, o = i || m && S || T && !I || A && !R || c && !k, p = a || (m ? h : null), E = () => {
|
|
3600
3609
|
a && l(), h && d && P();
|
|
3601
3610
|
};
|
|
3602
3611
|
if (o)
|
|
@@ -3608,8 +3617,8 @@ function tn({
|
|
|
3608
3617
|
return /* @__PURE__ */ s(B, { children: r });
|
|
3609
3618
|
}
|
|
3610
3619
|
function rn(r = !0) {
|
|
3611
|
-
const { isAppLoading: e, appError: t, retryApp: n, appInfo: i } =
|
|
3612
|
-
}), P = (l == null ? void 0 : l.isAuthReady) ?? !0, I = (d == null ? void 0 : d.isReady) ?? !0,
|
|
3620
|
+
const { isAppLoading: e, appError: t, retryApp: n, appInfo: i } = Ae(), a = pe(), l = Oe(), d = at(), T = lt(), A = (a == null ? void 0 : a.isTenantLoading) ?? !1, c = (a == null ? void 0 : a.tenantError) ?? null, S = (a == null ? void 0 : a.tenant) ?? null, h = (a == null ? void 0 : a.tenantSlug) ?? null, x = (a == null ? void 0 : a.retryTenant) ?? (() => {
|
|
3621
|
+
}), P = (l == null ? void 0 : l.isAuthReady) ?? !0, I = (d == null ? void 0 : d.isReady) ?? !0, R = (T == null ? void 0 : T.isReady) ?? !0, k = r && a && h, C = e || k && A || l && !P || d && !I || T && !R, o = t || (k ? c : null);
|
|
3613
3622
|
return {
|
|
3614
3623
|
isLoading: C,
|
|
3615
3624
|
error: o,
|
|
@@ -3619,10 +3628,10 @@ function rn(r = !0) {
|
|
|
3619
3628
|
},
|
|
3620
3629
|
// Individual states
|
|
3621
3630
|
app: { isLoading: e, error: t, data: i },
|
|
3622
|
-
tenant: a ? { isLoading:
|
|
3631
|
+
tenant: a ? { isLoading: A, error: c, data: S } : null,
|
|
3623
3632
|
auth: l ? { isReady: P } : null,
|
|
3624
3633
|
featureFlags: d ? { isReady: I } : null,
|
|
3625
|
-
subscription: T ? { isReady:
|
|
3634
|
+
subscription: T ? { isReady: R } : null
|
|
3626
3635
|
};
|
|
3627
3636
|
}
|
|
3628
3637
|
const br = {
|
|
@@ -3679,11 +3688,11 @@ function nn({
|
|
|
3679
3688
|
itemClassName: l = "",
|
|
3680
3689
|
renderItem: d,
|
|
3681
3690
|
placeholder: T = "Select tenant",
|
|
3682
|
-
disabled:
|
|
3691
|
+
disabled: A = !1,
|
|
3683
3692
|
showCurrentTenant: c = !0
|
|
3684
3693
|
}) {
|
|
3685
3694
|
var C;
|
|
3686
|
-
const S = { ...br, ...n }, h = Oe(), [x, P] = N(!1), I = Ee(null),
|
|
3695
|
+
const S = { ...br, ...n }, h = Oe(), [x, P] = N(!1), I = Ee(null), R = r ?? (h == null ? void 0 : h.userTenants) ?? [], k = e ?? ((C = h == null ? void 0 : h.currentUser) == null ? void 0 : C.tenantId) ?? null, m = async (o) => {
|
|
3687
3696
|
P(!1), t ? t(o) : h != null && h.switchToTenant && await h.switchToTenant(o);
|
|
3688
3697
|
};
|
|
3689
3698
|
re(() => {
|
|
@@ -3692,11 +3701,11 @@ function nn({
|
|
|
3692
3701
|
};
|
|
3693
3702
|
return document.addEventListener("mousedown", o), () => document.removeEventListener("mousedown", o);
|
|
3694
3703
|
}, []);
|
|
3695
|
-
const g =
|
|
3696
|
-
if (
|
|
3704
|
+
const g = R.find((o) => o.id === k);
|
|
3705
|
+
if (R.length === 0)
|
|
3697
3706
|
return null;
|
|
3698
|
-
if (
|
|
3699
|
-
return /* @__PURE__ */ s("div", { className: i, children: /* @__PURE__ */ s("span", { children:
|
|
3707
|
+
if (R.length === 1 && c)
|
|
3708
|
+
return /* @__PURE__ */ s("div", { className: i, children: /* @__PURE__ */ s("span", { children: R[0].name }) });
|
|
3700
3709
|
const b = (o, p) => /* @__PURE__ */ f("span", { style: { fontWeight: p ? "bold" : "normal" }, children: [
|
|
3701
3710
|
o.name,
|
|
3702
3711
|
o.role && /* @__PURE__ */ f("span", { style: S.itemRole, children: [
|
|
@@ -3710,11 +3719,11 @@ function nn({
|
|
|
3710
3719
|
"button",
|
|
3711
3720
|
{
|
|
3712
3721
|
type: "button",
|
|
3713
|
-
onClick: () => !
|
|
3714
|
-
disabled:
|
|
3722
|
+
onClick: () => !A && P(!x),
|
|
3723
|
+
disabled: A,
|
|
3715
3724
|
style: {
|
|
3716
3725
|
...S.button,
|
|
3717
|
-
...
|
|
3726
|
+
...A ? S.buttonDisabled : {}
|
|
3718
3727
|
},
|
|
3719
3728
|
children: [
|
|
3720
3729
|
g ? g.name : T,
|
|
@@ -3722,7 +3731,7 @@ function nn({
|
|
|
3722
3731
|
]
|
|
3723
3732
|
}
|
|
3724
3733
|
),
|
|
3725
|
-
x && /* @__PURE__ */ s("div", { className: a, style: S.dropdown, children:
|
|
3734
|
+
x && /* @__PURE__ */ s("div", { className: a, style: S.dropdown, children: R.map((o) => {
|
|
3726
3735
|
const p = o.id === k;
|
|
3727
3736
|
return /* @__PURE__ */ s(
|
|
3728
3737
|
"div",
|
|
@@ -3830,7 +3839,7 @@ function ln(r = {}) {
|
|
|
3830
3839
|
zoneRoots: e = {},
|
|
3831
3840
|
returnToParam: t = dt,
|
|
3832
3841
|
returnToStorage: n = "url"
|
|
3833
|
-
} = r, i = wt(), [a, l] = vt(), { isAuthenticated: d, currentUser: T } = de(), { tenant:
|
|
3842
|
+
} = r, i = wt(), [a, l] = vt(), { isAuthenticated: d, currentUser: T } = de(), { tenant: A } = ve(), c = V(() => ({ ...ze, ...e }), [e]), S = !!A, h = T == null ? void 0 : T.userType, x = V(() => {
|
|
3834
3843
|
switch (n) {
|
|
3835
3844
|
case "url":
|
|
3836
3845
|
return a.get(t);
|
|
@@ -3872,7 +3881,7 @@ function ln(r = {}) {
|
|
|
3872
3881
|
}
|
|
3873
3882
|
},
|
|
3874
3883
|
[n, a, t, l]
|
|
3875
|
-
),
|
|
3884
|
+
), R = te(
|
|
3876
3885
|
(m) => {
|
|
3877
3886
|
const g = c[m] || c.default;
|
|
3878
3887
|
i(g);
|
|
@@ -3883,7 +3892,7 @@ function ln(r = {}) {
|
|
|
3883
3892
|
returnToUrl: x,
|
|
3884
3893
|
clearReturnTo: P,
|
|
3885
3894
|
setReturnTo: I,
|
|
3886
|
-
navigateToZone:
|
|
3895
|
+
navigateToZone: R,
|
|
3887
3896
|
getSmartRedirect: k
|
|
3888
3897
|
};
|
|
3889
3898
|
}
|
|
@@ -3899,7 +3908,7 @@ export {
|
|
|
3899
3908
|
tn as AppLoader,
|
|
3900
3909
|
Sr as AppProvider,
|
|
3901
3910
|
Nt as AuthApiService,
|
|
3902
|
-
|
|
3911
|
+
Rr as AuthProvider,
|
|
3903
3912
|
Or as AuthenticatedZone,
|
|
3904
3913
|
oe as ConfigurationError,
|
|
3905
3914
|
ct as DEFAULT_ZONE_PRESETS,
|
|
@@ -3945,7 +3954,7 @@ export {
|
|
|
3945
3954
|
ue as ZoneRoute,
|
|
3946
3955
|
cn as buildRedirectUrl,
|
|
3947
3956
|
kr as useApi,
|
|
3948
|
-
|
|
3957
|
+
Ae as useApp,
|
|
3949
3958
|
rn as useAppLoaderState,
|
|
3950
3959
|
de as useAuth,
|
|
3951
3960
|
Ir as useAuthActions,
|
|
@@ -3954,7 +3963,7 @@ export {
|
|
|
3954
3963
|
Vt as useFeatureFlags,
|
|
3955
3964
|
Cr as useRouting,
|
|
3956
3965
|
Wt as useRoutingOptional,
|
|
3957
|
-
|
|
3966
|
+
Ar as useSettings,
|
|
3958
3967
|
zt as useSubscription,
|
|
3959
3968
|
ve as useTenant,
|
|
3960
3969
|
ot as useTenantInfo,
|