@skylabs-digital/react-identity-access 2.10.1 → 2.11.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 +117 -117
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/types/authParams.d.ts +1 -0
- package/dist/types/authParams.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -733,7 +733,7 @@ function Yt({ config: i, children: e }) {
|
|
|
733
733
|
const l = o();
|
|
734
734
|
m(l);
|
|
735
735
|
}, [o]);
|
|
736
|
-
const E = (r == null ? void 0 : r.settingsSchema) || null,
|
|
736
|
+
const E = (r == null ? void 0 : r.settingsSchema) || null, U = ie(
|
|
737
737
|
async (l, H = !1) => {
|
|
738
738
|
if (!(!H && y.enabled && b && b.domain === l))
|
|
739
739
|
try {
|
|
@@ -829,8 +829,8 @@ function Yt({ config: i, children: e }) {
|
|
|
829
829
|
[E]
|
|
830
830
|
);
|
|
831
831
|
re(() => {
|
|
832
|
-
!i.initialTenant && a ? b ? D() :
|
|
833
|
-
}, [i.initialTenant, a, b,
|
|
832
|
+
!i.initialTenant && a ? b ? D() : U(a) : !i.initialTenant && !a && (g(null), I(null), f(!1));
|
|
833
|
+
}, [i.initialTenant, a, b, U, D]), re(() => {
|
|
834
834
|
b != null && b.id ? P() : (R(null), A(null), h(!1));
|
|
835
835
|
}, [b == null ? void 0 : b.id, P]);
|
|
836
836
|
const L = ie(
|
|
@@ -849,22 +849,22 @@ function Yt({ config: i, children: e }) {
|
|
|
849
849
|
);
|
|
850
850
|
return;
|
|
851
851
|
}
|
|
852
|
-
const
|
|
852
|
+
const B = u || window.location.pathname, q = new URL(`${window.location.protocol}//${K}${B}`);
|
|
853
853
|
new URLSearchParams(window.location.search).forEach((v, J) => {
|
|
854
854
|
J !== me && q.searchParams.set(J, v);
|
|
855
855
|
}), p && q.searchParams.set(me, at(p)), window.location.href = q.toString();
|
|
856
856
|
} else if (w === "selector") {
|
|
857
857
|
const _ = u || window.location.pathname, K = new URLSearchParams(window.location.search);
|
|
858
858
|
if (K.set(i.selectorParam || "tenant", l), M === "reload") {
|
|
859
|
-
const
|
|
860
|
-
window.location.href =
|
|
859
|
+
const B = `${_}?${K.toString()}${window.location.hash}`;
|
|
860
|
+
window.location.href = B;
|
|
861
861
|
} else {
|
|
862
|
-
const
|
|
863
|
-
window.history.pushState({}, "",
|
|
862
|
+
const B = `${_}?${K.toString()}${window.location.hash}`;
|
|
863
|
+
window.history.pushState({}, "", B), m(l), U(l);
|
|
864
864
|
}
|
|
865
865
|
}
|
|
866
866
|
},
|
|
867
|
-
[i.tenantMode, i.selectorParam, i.baseDomain,
|
|
867
|
+
[i.tenantMode, i.selectorParam, i.baseDomain, U]
|
|
868
868
|
), F = te(() => ({
|
|
869
869
|
// Tenant info
|
|
870
870
|
tenant: b,
|
|
@@ -872,7 +872,7 @@ function Yt({ config: i, children: e }) {
|
|
|
872
872
|
isTenantLoading: S,
|
|
873
873
|
tenantError: T,
|
|
874
874
|
retryTenant: () => {
|
|
875
|
-
a &&
|
|
875
|
+
a && U(a);
|
|
876
876
|
},
|
|
877
877
|
// Settings
|
|
878
878
|
settings: C,
|
|
@@ -938,7 +938,7 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
938
938
|
} catch {
|
|
939
939
|
return [];
|
|
940
940
|
}
|
|
941
|
-
}), [E,
|
|
941
|
+
}), [E, U] = k(!1), D = Ne({ done: !1, urlTokens: null });
|
|
942
942
|
D.current.done || (D.current.done = !0, D.current.urlTokens = ct(), D.current.urlTokens && console.log(
|
|
943
943
|
"[AuthProvider] SYNC: URL tokens found, will block isAuthReady until user loaded"
|
|
944
944
|
));
|
|
@@ -959,13 +959,13 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
959
959
|
}, [o, r, i.onRefreshFailed]), L = D.current.done && !P, F = te(() => {
|
|
960
960
|
const v = new ne(r);
|
|
961
961
|
return v.setSessionManager(c), v;
|
|
962
|
-
}, [r, c]), l = te(() => new tt(new ne(r)), [r]), H = te(() => new rt(F, c), [F, c]), M = te(() => new Ce(new ne(r)), [r]), p = te(() => S || c.getUser(), [S, c]), u = te(() => p != null && p.roleId && m.find((v) => v.id === p.roleId) || null, [p, m]), w = te(() => (u == null ? void 0 : u.permissions) || [], [u]), _ = te(() => c.hasValidSession() && S !== null, [c, S]), K = 5 * 60 * 1e3,
|
|
963
|
-
const v = async (
|
|
962
|
+
}, [r, c]), l = te(() => new tt(new ne(r)), [r]), H = te(() => new rt(F, c), [F, c]), M = te(() => new Ce(new ne(r)), [r]), p = te(() => S || c.getUser(), [S, c]), u = te(() => p != null && p.roleId && m.find((v) => v.id === p.roleId) || null, [p, m]), w = te(() => (u == null ? void 0 : u.permissions) || [], [u]), _ = te(() => c.hasValidSession() && S !== null, [c, S]), K = 5 * 60 * 1e3, B = te(() => {
|
|
963
|
+
const v = async (N = !1) => {
|
|
964
964
|
try {
|
|
965
965
|
if (!c.hasValidSession())
|
|
966
966
|
return;
|
|
967
967
|
const z = Date.now();
|
|
968
|
-
if (!
|
|
968
|
+
if (!N && z - x < K && S)
|
|
969
969
|
return;
|
|
970
970
|
const W = c.getUserId();
|
|
971
971
|
if (!W) {
|
|
@@ -983,9 +983,9 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
983
983
|
}
|
|
984
984
|
}, J = async () => {
|
|
985
985
|
await v();
|
|
986
|
-
}, ae = async (
|
|
986
|
+
}, ae = async (N) => {
|
|
987
987
|
var Le;
|
|
988
|
-
const { username: z, password: Y, tenantSlug: W, redirectPath: Q } =
|
|
988
|
+
const { username: z, password: Y, tenantSlug: W, redirectPath: Q } = N;
|
|
989
989
|
let X = s == null ? void 0 : s.id, Z = o, ee = c;
|
|
990
990
|
W && (X = (await new de(F, t).getPublicTenantInfo(W)).id, Z = W);
|
|
991
991
|
const G = await l.login({
|
|
@@ -1017,7 +1017,7 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1017
1017
|
}
|
|
1018
1018
|
}
|
|
1019
1019
|
const ve = ((Le = G.user) == null ? void 0 : Le.tenantId) !== null;
|
|
1020
|
-
if (
|
|
1020
|
+
if (U(ve), ce && Z && Z !== o && a(Z, {
|
|
1021
1021
|
tokens: {
|
|
1022
1022
|
accessToken: G.accessToken,
|
|
1023
1023
|
refreshToken: G.refreshToken,
|
|
@@ -1025,7 +1025,7 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1025
1025
|
},
|
|
1026
1026
|
redirectPath: Q
|
|
1027
1027
|
}), !ve && G.tenants && G.tenants.length > 0) {
|
|
1028
|
-
const ge = i.autoSwitchSingleTenant !== !1;
|
|
1028
|
+
const ge = N.autoSwitch !== !1 && i.autoSwitchSingleTenant !== !1;
|
|
1029
1029
|
if (G.tenants.length === 1 && ge) {
|
|
1030
1030
|
const Ee = G.tenants[0];
|
|
1031
1031
|
a(Ee.subdomain, {
|
|
@@ -1039,8 +1039,8 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1039
1039
|
} else G.tenants.length > 1 && i.onTenantSelectionRequired && i.onTenantSelectionRequired(G.tenants);
|
|
1040
1040
|
}
|
|
1041
1041
|
return G;
|
|
1042
|
-
}, be = async (
|
|
1043
|
-
const { email: z, phoneNumber: Y, name: W, password: Q, lastName: X, tenantId: Z } =
|
|
1042
|
+
}, be = async (N) => {
|
|
1043
|
+
const { email: z, phoneNumber: Y, name: W, password: Q, lastName: X, tenantId: Z } = N;
|
|
1044
1044
|
if (!z && !Y)
|
|
1045
1045
|
throw new Error("Either email or phoneNumber is required");
|
|
1046
1046
|
if (!W || !Q)
|
|
@@ -1055,8 +1055,8 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1055
1055
|
lastName: X,
|
|
1056
1056
|
appId: t
|
|
1057
1057
|
});
|
|
1058
|
-
}, Oe = async (
|
|
1059
|
-
const { email: z, phoneNumber: Y, name: W, password: Q, tenantName: X, lastName: Z } =
|
|
1058
|
+
}, Oe = async (N) => {
|
|
1059
|
+
const { email: z, phoneNumber: Y, name: W, password: Q, tenantName: X, lastName: Z } = N;
|
|
1060
1060
|
if (!z && !Y)
|
|
1061
1061
|
throw new Error("Either email or phoneNumber is required");
|
|
1062
1062
|
if (!W || !Q || !X)
|
|
@@ -1070,19 +1070,19 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1070
1070
|
appId: t,
|
|
1071
1071
|
lastName: Z
|
|
1072
1072
|
});
|
|
1073
|
-
}, We = async (
|
|
1074
|
-
const { currentPassword: z, newPassword: Y } =
|
|
1073
|
+
}, We = async (N) => {
|
|
1074
|
+
const { currentPassword: z, newPassword: Y } = N, W = await c.getAuthHeaders();
|
|
1075
1075
|
await l.changePassword({ currentPassword: z, newPassword: Y }, W);
|
|
1076
|
-
}, je = async (
|
|
1077
|
-
const { email: z, tenantId: Y } =
|
|
1076
|
+
}, je = async (N) => {
|
|
1077
|
+
const { email: z, tenantId: Y } = N, W = Y ?? (s == null ? void 0 : s.id);
|
|
1078
1078
|
if (!W)
|
|
1079
1079
|
throw new Error("tenantId is required for password reset");
|
|
1080
1080
|
await l.requestPasswordReset({ email: z, tenantId: W });
|
|
1081
|
-
}, Ve = async (
|
|
1082
|
-
const { token: z, newPassword: Y } =
|
|
1081
|
+
}, Ve = async (N) => {
|
|
1082
|
+
const { token: z, newPassword: Y } = N;
|
|
1083
1083
|
await l.confirmPasswordReset({ token: z, newPassword: Y });
|
|
1084
|
-
}, Ge = async (
|
|
1085
|
-
const { email: z, frontendUrl: Y, name: W, lastName: Q, tenantId: X } =
|
|
1084
|
+
}, Ge = async (N) => {
|
|
1085
|
+
const { email: z, frontendUrl: Y, name: W, lastName: Q, tenantId: X } = N, Z = X ?? (s == null ? void 0 : s.id);
|
|
1086
1086
|
if (!Z)
|
|
1087
1087
|
throw new Error("tenantId is required for magic link authentication");
|
|
1088
1088
|
return await l.sendMagicLink({
|
|
@@ -1093,8 +1093,8 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1093
1093
|
lastName: Q,
|
|
1094
1094
|
appId: t
|
|
1095
1095
|
});
|
|
1096
|
-
}, _e = async (
|
|
1097
|
-
const { token: z, email: Y, tenantSlug: W } =
|
|
1096
|
+
}, _e = async (N) => {
|
|
1097
|
+
const { token: z, email: Y, tenantSlug: W } = N;
|
|
1098
1098
|
let Q = s == null ? void 0 : s.id, X = o, Z = c;
|
|
1099
1099
|
W && (Q = (await new de(F, t).getPublicTenantInfo(W)).id, X = W);
|
|
1100
1100
|
const ee = await l.verifyMagicLink({
|
|
@@ -1126,46 +1126,46 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1126
1126
|
}
|
|
1127
1127
|
}), ee;
|
|
1128
1128
|
}, Je = async () => {
|
|
1129
|
-
const
|
|
1130
|
-
if (!(
|
|
1129
|
+
const N = c.getTokens();
|
|
1130
|
+
if (!(N != null && N.refreshToken))
|
|
1131
1131
|
throw new Error("No refresh token available");
|
|
1132
1132
|
const z = await l.refreshToken({
|
|
1133
|
-
refreshToken:
|
|
1133
|
+
refreshToken: N.refreshToken
|
|
1134
1134
|
});
|
|
1135
1135
|
c.setTokens({
|
|
1136
1136
|
accessToken: z.accessToken,
|
|
1137
|
-
refreshToken: z.refreshToken ||
|
|
1137
|
+
refreshToken: z.refreshToken || N.refreshToken,
|
|
1138
1138
|
expiresIn: z.expiresIn
|
|
1139
1139
|
});
|
|
1140
1140
|
}, Ke = () => {
|
|
1141
|
-
c.clearSession(), f(null), R(null), A([]),
|
|
1141
|
+
c.clearSession(), f(null), R(null), A([]), U(!1);
|
|
1142
1142
|
try {
|
|
1143
1143
|
localStorage.removeItem("userTenants");
|
|
1144
1144
|
} catch {
|
|
1145
1145
|
}
|
|
1146
|
-
}, Ye = (
|
|
1147
|
-
c.setTokens(
|
|
1146
|
+
}, Ye = (N) => {
|
|
1147
|
+
c.setTokens(N);
|
|
1148
1148
|
}, Qe = () => c.hasValidSession(), Xe = () => {
|
|
1149
1149
|
c.clearSession(), f(null), R(null);
|
|
1150
1150
|
}, Ze = async () => {
|
|
1151
1151
|
if (t)
|
|
1152
1152
|
try {
|
|
1153
1153
|
g(!0);
|
|
1154
|
-
const { roles:
|
|
1155
|
-
y(
|
|
1156
|
-
} catch (
|
|
1157
|
-
console.error("Failed to fetch roles:",
|
|
1154
|
+
const { roles: N } = await M.getRolesByApp(t);
|
|
1155
|
+
y(N);
|
|
1156
|
+
} catch (N) {
|
|
1157
|
+
console.error("Failed to fetch roles:", N);
|
|
1158
1158
|
} finally {
|
|
1159
1159
|
g(!1);
|
|
1160
1160
|
}
|
|
1161
1161
|
}, et = async () => {
|
|
1162
1162
|
await Ze();
|
|
1163
|
-
}, Se = (
|
|
1163
|
+
}, Se = (N) => {
|
|
1164
1164
|
if (!w || w.length === 0)
|
|
1165
1165
|
return !1;
|
|
1166
|
-
if (typeof
|
|
1167
|
-
return w.includes(
|
|
1168
|
-
const z = `${
|
|
1166
|
+
if (typeof N == "string")
|
|
1167
|
+
return w.includes(N);
|
|
1168
|
+
const z = `${N.resource}.${N.action}`;
|
|
1169
1169
|
return w.includes(z);
|
|
1170
1170
|
};
|
|
1171
1171
|
return {
|
|
@@ -1198,28 +1198,28 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1198
1198
|
availableRoles: m,
|
|
1199
1199
|
rolesLoading: b,
|
|
1200
1200
|
hasPermission: Se,
|
|
1201
|
-
hasAnyPermission: (
|
|
1202
|
-
hasAllPermissions: (
|
|
1201
|
+
hasAnyPermission: (N) => N.some((z) => Se(z)),
|
|
1202
|
+
hasAllPermissions: (N) => N.every((z) => Se(z)),
|
|
1203
1203
|
getUserPermissionStrings: () => w || [],
|
|
1204
1204
|
refreshRoles: et,
|
|
1205
1205
|
// RFC-004: Multi-tenant user membership
|
|
1206
1206
|
userTenants: $,
|
|
1207
1207
|
hasTenantContext: E,
|
|
1208
|
-
switchToTenant: async (
|
|
1208
|
+
switchToTenant: async (N, z) => {
|
|
1209
1209
|
const { redirectPath: Y } = z || {}, W = c.getTokens();
|
|
1210
1210
|
if (!(W != null && W.refreshToken))
|
|
1211
1211
|
throw new Error("No refresh token available for tenant switch");
|
|
1212
1212
|
const Q = await l.switchTenant({
|
|
1213
1213
|
refreshToken: W.refreshToken,
|
|
1214
|
-
tenantId:
|
|
1214
|
+
tenantId: N
|
|
1215
1215
|
});
|
|
1216
1216
|
c.setTokens({
|
|
1217
1217
|
accessToken: Q.accessToken,
|
|
1218
1218
|
refreshToken: W.refreshToken,
|
|
1219
1219
|
// Keep the same refresh token
|
|
1220
1220
|
expiresIn: Q.expiresIn
|
|
1221
|
-
}), f(Q.user), c.setUser(Q.user),
|
|
1222
|
-
const X = $.find((Z) => Z.id ===
|
|
1221
|
+
}), f(Q.user), c.setUser(Q.user), U(!0);
|
|
1222
|
+
const X = $.find((Z) => Z.id === N);
|
|
1223
1223
|
X && a(X.subdomain, {
|
|
1224
1224
|
tokens: {
|
|
1225
1225
|
accessToken: Q.accessToken,
|
|
@@ -1230,7 +1230,7 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1230
1230
|
});
|
|
1231
1231
|
},
|
|
1232
1232
|
refreshUserTenants: async () => {
|
|
1233
|
-
const
|
|
1233
|
+
const N = await c.getAuthHeaders(), z = await l.getUserTenants(N);
|
|
1234
1234
|
A(z);
|
|
1235
1235
|
try {
|
|
1236
1236
|
localStorage.setItem("userTenants", JSON.stringify(z));
|
|
@@ -1277,26 +1277,26 @@ function Zt({ config: i = {}, children: e }) {
|
|
|
1277
1277
|
}, [t, r, i.initialRoles]);
|
|
1278
1278
|
const [q, V] = k(!1);
|
|
1279
1279
|
return re(() => {
|
|
1280
|
-
q || (V(!0), D.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), dt(), O(!0), console.log("[AuthProvider] EFFECT: Loading user data (blocking isAuthReady)..."),
|
|
1280
|
+
q || (V(!0), D.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), dt(), O(!0), console.log("[AuthProvider] EFFECT: Loading user data (blocking isAuthReady)..."), B.loadUserData().catch((v) => {
|
|
1281
1281
|
console.error("[AuthProvider] Failed to load user data:", v);
|
|
1282
1282
|
}).finally(() => {
|
|
1283
1283
|
console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"), O(!1);
|
|
1284
1284
|
})));
|
|
1285
|
-
}, [
|
|
1285
|
+
}, [B, q]), re(() => {
|
|
1286
1286
|
const v = c.getUser();
|
|
1287
1287
|
v && c.hasValidSession() && f(v);
|
|
1288
1288
|
}, [c]), re(() => {
|
|
1289
|
-
q && (D.current.urlTokens || !S && !T && c.hasValidSession() && (console.log("[AuthProvider] Auto-loading user data..."),
|
|
1289
|
+
q && (D.current.urlTokens || !S && !T && c.hasValidSession() && (console.log("[AuthProvider] Auto-loading user data..."), B.loadUserData().catch(() => {
|
|
1290
1290
|
})));
|
|
1291
|
-
}, [S, T,
|
|
1291
|
+
}, [S, T, B, c, q]), re(() => {
|
|
1292
1292
|
if (!c.hasValidSession() || !S)
|
|
1293
1293
|
return;
|
|
1294
1294
|
const v = setInterval(() => {
|
|
1295
|
-
|
|
1295
|
+
B.loadUserData().catch(() => {
|
|
1296
1296
|
});
|
|
1297
1297
|
}, K);
|
|
1298
1298
|
return () => clearInterval(v);
|
|
1299
|
-
}, [c, S,
|
|
1299
|
+
}, [c, S, B, K]), /* @__PURE__ */ n(Pe.Provider, { value: B, children: e });
|
|
1300
1300
|
}
|
|
1301
1301
|
function oe() {
|
|
1302
1302
|
const i = se(Pe);
|
|
@@ -1423,12 +1423,12 @@ function er({ config: i = {}, children: e }) {
|
|
|
1423
1423
|
return P ? P.value ? "enabled" : "disabled" : "not_found";
|
|
1424
1424
|
}, E = async () => {
|
|
1425
1425
|
await R();
|
|
1426
|
-
},
|
|
1426
|
+
}, U = !!(s && o) && (T || !(a != null && a.id));
|
|
1427
1427
|
return {
|
|
1428
1428
|
featureFlags: m,
|
|
1429
1429
|
loading: b,
|
|
1430
1430
|
error: S,
|
|
1431
|
-
isReady:
|
|
1431
|
+
isReady: U,
|
|
1432
1432
|
isEnabled: h,
|
|
1433
1433
|
getFlag: $,
|
|
1434
1434
|
getFlagState: A,
|
|
@@ -1545,7 +1545,7 @@ function tr({ config: i = {}, children: e }) {
|
|
|
1545
1545
|
}, $ = (P) => x.find((O) => O.key === P), A = (P, O) => {
|
|
1546
1546
|
const c = x.find((L) => L.key === P);
|
|
1547
1547
|
return c ? c.value : O;
|
|
1548
|
-
}, E = (P) => !a || !a.isActive ? !1 : P.includes(a.planId),
|
|
1548
|
+
}, E = (P) => !a || !a.isActive ? !1 : P.includes(a.planId), U = async () => {
|
|
1549
1549
|
await C();
|
|
1550
1550
|
}, D = !!s && (f || !(o != null && o.id));
|
|
1551
1551
|
return {
|
|
@@ -1558,7 +1558,7 @@ function tr({ config: i = {}, children: e }) {
|
|
|
1558
1558
|
getFeature: $,
|
|
1559
1559
|
getFeatureValue: A,
|
|
1560
1560
|
hasAllowedPlan: E,
|
|
1561
|
-
refresh:
|
|
1561
|
+
refresh: U
|
|
1562
1562
|
};
|
|
1563
1563
|
}, [a, y, g, s, o == null ? void 0 : o.id, f]);
|
|
1564
1564
|
return /* @__PURE__ */ n(Re.Provider, { value: R, children: e });
|
|
@@ -2139,7 +2139,7 @@ function lr({
|
|
|
2139
2139
|
showMagicLinkOption: g = !0,
|
|
2140
2140
|
className: S
|
|
2141
2141
|
}) {
|
|
2142
|
-
const [f, T] = k(""), [I, C] = k(""), [R, x] = k(!1), [h, $] = k(!1), [A, E] = k(""), [
|
|
2142
|
+
const [f, T] = k(""), [I, C] = k(""), [R, x] = k(!1), [h, $] = k(!1), [A, E] = k(""), [U, D] = k({}), { login: P } = oe(), { tenant: O } = le(), c = { ...At, ...i }, L = { ...Pt, ...e }, F = { ...xt, ...t }, l = () => {
|
|
2143
2143
|
const u = {};
|
|
2144
2144
|
return f.trim() || (u.username = !0), I.trim() || (u.password = !0), D(u), Object.keys(u).length === 0;
|
|
2145
2145
|
}, H = async (u) => {
|
|
@@ -2165,7 +2165,7 @@ function lr({
|
|
|
2165
2165
|
}
|
|
2166
2166
|
}, M = (u) => ({
|
|
2167
2167
|
...L.input,
|
|
2168
|
-
...
|
|
2168
|
+
...U[u] ? L.inputError : {}
|
|
2169
2169
|
}), p = () => ({
|
|
2170
2170
|
...L.button,
|
|
2171
2171
|
...h ? L.buttonLoading : {},
|
|
@@ -2184,7 +2184,7 @@ function lr({
|
|
|
2184
2184
|
type: "text",
|
|
2185
2185
|
value: f,
|
|
2186
2186
|
onChange: (u) => {
|
|
2187
|
-
T(u.target.value),
|
|
2187
|
+
T(u.target.value), U.username && D((w) => ({ ...w, username: !1 }));
|
|
2188
2188
|
},
|
|
2189
2189
|
placeholder: c.usernamePlaceholder,
|
|
2190
2190
|
style: M("username"),
|
|
@@ -2203,7 +2203,7 @@ function lr({
|
|
|
2203
2203
|
type: R ? "text" : "password",
|
|
2204
2204
|
value: I,
|
|
2205
2205
|
onChange: (u) => {
|
|
2206
|
-
C(u.target.value),
|
|
2206
|
+
C(u.target.value), U.password && D((w) => ({ ...w, password: !1 }));
|
|
2207
2207
|
},
|
|
2208
2208
|
placeholder: c.passwordPlaceholder,
|
|
2209
2209
|
style: {
|
|
@@ -2388,9 +2388,9 @@ function cr({
|
|
|
2388
2388
|
showMagicLinkOption: y = !0,
|
|
2389
2389
|
className: b
|
|
2390
2390
|
}) {
|
|
2391
|
-
const [g, S] = k(""), [f, T] = k(""), [I, C] = k(""), [R, x] = k(""), [h, $] = k(""), [A, E] = k(""), [
|
|
2391
|
+
const [g, S] = k(""), [f, T] = k(""), [I, C] = k(""), [R, x] = k(""), [h, $] = k(""), [A, E] = k(""), [U, D] = k(""), [P, O] = k(!1), [c, L] = k(""), [F, l] = k({}), { signup: H, signupTenantAdmin: M } = oe(), { tenant: p } = le(), u = { ...Mt, ...i }, w = { ...It, ...e }, _ = () => {
|
|
2392
2392
|
const v = {};
|
|
2393
|
-
return g.trim() || (v.name = !0), !I.trim() && !R.trim() && (v.email = !0, v.phoneNumber = !0), h.trim() || (v.password = !0), A.trim() || (v.confirmPassword = !0), t === "tenant" && !
|
|
2393
|
+
return g.trim() || (v.name = !0), !I.trim() && !R.trim() && (v.email = !0, v.phoneNumber = !0), h.trim() || (v.password = !0), A.trim() || (v.confirmPassword = !0), t === "tenant" && !U.trim() && (v.tenantName = !0), l(v), Object.keys(v).length === 0;
|
|
2394
2394
|
}, K = async (v) => {
|
|
2395
2395
|
if (v.preventDefault(), !!_()) {
|
|
2396
2396
|
if (h !== A) {
|
|
@@ -2409,7 +2409,7 @@ function cr({
|
|
|
2409
2409
|
phoneNumber: R || void 0,
|
|
2410
2410
|
name: g,
|
|
2411
2411
|
password: h,
|
|
2412
|
-
tenantName:
|
|
2412
|
+
tenantName: U,
|
|
2413
2413
|
lastName: f || void 0
|
|
2414
2414
|
}) : J = await H({
|
|
2415
2415
|
email: I || void 0,
|
|
@@ -2426,14 +2426,14 @@ function cr({
|
|
|
2426
2426
|
O(!1);
|
|
2427
2427
|
}
|
|
2428
2428
|
}
|
|
2429
|
-
},
|
|
2429
|
+
}, B = (v) => ({
|
|
2430
2430
|
...w.input,
|
|
2431
2431
|
...F[v] ? w.inputError : {}
|
|
2432
2432
|
}), q = () => ({
|
|
2433
2433
|
...w.button,
|
|
2434
2434
|
...P ? w.buttonLoading : {},
|
|
2435
|
-
...!g || !I && !R || !h || !A || P || t === "tenant" && !
|
|
2436
|
-
}), V = g && (I || R) && h && A && (t === "user" ||
|
|
2435
|
+
...!g || !I && !R || !h || !A || P || t === "tenant" && !U ? w.buttonDisabled : {}
|
|
2436
|
+
}), V = g && (I || R) && h && A && (t === "user" || U);
|
|
2437
2437
|
return /* @__PURE__ */ d("div", { className: b, style: w.container, children: [
|
|
2438
2438
|
/* @__PURE__ */ n("h2", { style: w.title, children: u.title }),
|
|
2439
2439
|
/* @__PURE__ */ d("form", { onSubmit: K, style: w.form, children: [
|
|
@@ -2450,7 +2450,7 @@ function cr({
|
|
|
2450
2450
|
S(v.target.value), F.name && l((J) => ({ ...J, name: !1 }));
|
|
2451
2451
|
},
|
|
2452
2452
|
placeholder: u.namePlaceholder,
|
|
2453
|
-
style:
|
|
2453
|
+
style: B("name"),
|
|
2454
2454
|
disabled: P
|
|
2455
2455
|
}
|
|
2456
2456
|
)
|
|
@@ -2484,7 +2484,7 @@ function cr({
|
|
|
2484
2484
|
C(v.target.value), F.email && l((J) => ({ ...J, email: !1, phoneNumber: !1 }));
|
|
2485
2485
|
},
|
|
2486
2486
|
placeholder: u.emailPlaceholder,
|
|
2487
|
-
style:
|
|
2487
|
+
style: B("email"),
|
|
2488
2488
|
disabled: P
|
|
2489
2489
|
}
|
|
2490
2490
|
)
|
|
@@ -2502,7 +2502,7 @@ function cr({
|
|
|
2502
2502
|
x(v.target.value), F.phoneNumber && l((J) => ({ ...J, email: !1, phoneNumber: !1 }));
|
|
2503
2503
|
},
|
|
2504
2504
|
placeholder: u.phoneNumberPlaceholder,
|
|
2505
|
-
style:
|
|
2505
|
+
style: B("phoneNumber"),
|
|
2506
2506
|
disabled: P
|
|
2507
2507
|
}
|
|
2508
2508
|
)
|
|
@@ -2532,7 +2532,7 @@ function cr({
|
|
|
2532
2532
|
$(v.target.value), F.password && l((J) => ({ ...J, password: !1 }));
|
|
2533
2533
|
},
|
|
2534
2534
|
placeholder: u.passwordPlaceholder,
|
|
2535
|
-
style:
|
|
2535
|
+
style: B("password"),
|
|
2536
2536
|
disabled: P
|
|
2537
2537
|
}
|
|
2538
2538
|
)
|
|
@@ -2550,7 +2550,7 @@ function cr({
|
|
|
2550
2550
|
E(v.target.value), F.confirmPassword && l((J) => ({ ...J, confirmPassword: !1 })), c === u.passwordMismatchError && L("");
|
|
2551
2551
|
},
|
|
2552
2552
|
placeholder: u.confirmPasswordPlaceholder,
|
|
2553
|
-
style:
|
|
2553
|
+
style: B("confirmPassword"),
|
|
2554
2554
|
disabled: P
|
|
2555
2555
|
}
|
|
2556
2556
|
)
|
|
@@ -2563,12 +2563,12 @@ function cr({
|
|
|
2563
2563
|
id: "tenantName",
|
|
2564
2564
|
name: "tenantName",
|
|
2565
2565
|
type: "text",
|
|
2566
|
-
value:
|
|
2566
|
+
value: U,
|
|
2567
2567
|
onChange: (v) => {
|
|
2568
2568
|
D(v.target.value), F.tenantName && l((J) => ({ ...J, tenantName: !1 }));
|
|
2569
2569
|
},
|
|
2570
2570
|
placeholder: u.tenantNamePlaceholder,
|
|
2571
|
-
style:
|
|
2571
|
+
style: B("tenantName"),
|
|
2572
2572
|
disabled: P
|
|
2573
2573
|
}
|
|
2574
2574
|
)
|
|
@@ -2728,7 +2728,7 @@ function dr({
|
|
|
2728
2728
|
verifyToken: y,
|
|
2729
2729
|
frontendUrl: b
|
|
2730
2730
|
}) {
|
|
2731
|
-
const [g, S] = k(""), [f, T] = k(""), [I, C] = k(""), [R, x] = k(!1), [h, $] = k(!1), [A, E] = k(""), [
|
|
2731
|
+
const [g, S] = k(""), [f, T] = k(""), [I, C] = k(""), [R, x] = k(!1), [h, $] = k(!1), [A, E] = k(""), [U, D] = k(""), [P, O] = k({}), [c, L] = k(!1), { sendMagicLink: F, verifyMagicLink: l } = oe(), { tenant: H } = le(), M = { ...Rt, ...i }, p = { ...Lt, ...e };
|
|
2732
2732
|
re(() => {
|
|
2733
2733
|
y && u(y);
|
|
2734
2734
|
}, [y]);
|
|
@@ -2780,7 +2780,7 @@ function dr({
|
|
|
2780
2780
|
}, K = (q) => ({
|
|
2781
2781
|
...p.input,
|
|
2782
2782
|
...P[q] ? p.inputError : {}
|
|
2783
|
-
}),
|
|
2783
|
+
}), B = () => ({
|
|
2784
2784
|
...p.button,
|
|
2785
2785
|
...R || h ? p.buttonLoading : {},
|
|
2786
2786
|
...!g || R || h ? p.buttonDisabled : {}
|
|
@@ -2880,9 +2880,9 @@ function dr({
|
|
|
2880
2880
|
}
|
|
2881
2881
|
) })
|
|
2882
2882
|
] }),
|
|
2883
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !g || R || h, style:
|
|
2883
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !g || R || h, style: B(), children: R ? M.loadingText : M.submitButton }),
|
|
2884
2884
|
A && /* @__PURE__ */ n("div", { style: p.errorText, children: A }),
|
|
2885
|
-
|
|
2885
|
+
U && /* @__PURE__ */ n("div", { style: p.successText, children: U })
|
|
2886
2886
|
] }),
|
|
2887
2887
|
a && /* @__PURE__ */ d("div", { style: p.linkContainer, children: [
|
|
2888
2888
|
/* @__PURE__ */ d("div", { children: [
|
|
@@ -3062,7 +3062,7 @@ function ur({
|
|
|
3062
3062
|
appId: g || c.get("appId") || "",
|
|
3063
3063
|
tenantSlug: S || c.get("tenantSlug") || void 0
|
|
3064
3064
|
};
|
|
3065
|
-
},
|
|
3065
|
+
}, U = async () => {
|
|
3066
3066
|
I("verifying"), R("");
|
|
3067
3067
|
try {
|
|
3068
3068
|
const c = E();
|
|
@@ -3081,12 +3081,12 @@ function ur({
|
|
|
3081
3081
|
R(L), I("error"), s == null || s(L);
|
|
3082
3082
|
}
|
|
3083
3083
|
}, D = () => {
|
|
3084
|
-
o == null || o(),
|
|
3084
|
+
o == null || o(), U();
|
|
3085
3085
|
}, P = () => {
|
|
3086
3086
|
a == null || a();
|
|
3087
3087
|
};
|
|
3088
3088
|
re(() => {
|
|
3089
|
-
|
|
3089
|
+
U();
|
|
3090
3090
|
}, []);
|
|
3091
3091
|
const O = () => {
|
|
3092
3092
|
switch (T) {
|
|
@@ -3280,21 +3280,21 @@ function hr({
|
|
|
3280
3280
|
onModeChange: m,
|
|
3281
3281
|
className: y
|
|
3282
3282
|
}) {
|
|
3283
|
-
const [b, g] = k(""), [S, f] = k(r), [T, I] = k(""), [C, R] = k(""), [x, h] = k(!1), [$, A] = k(""), [E,
|
|
3284
|
-
const
|
|
3285
|
-
return b.trim() || (
|
|
3283
|
+
const [b, g] = k(""), [S, f] = k(r), [T, I] = k(""), [C, R] = k(""), [x, h] = k(!1), [$, A] = k(""), [E, U] = k(""), [D, P] = k({}), { requestPasswordReset: O, confirmPasswordReset: c } = oe(), { tenant: L } = le(), F = { ...Ht, ...i }, l = { ...Nt, ...e }, H = () => {
|
|
3284
|
+
const B = {};
|
|
3285
|
+
return b.trim() || (B.email = !0), P(B), Object.keys(B).length === 0;
|
|
3286
3286
|
}, M = () => {
|
|
3287
|
-
const
|
|
3288
|
-
return S.trim() || (
|
|
3289
|
-
}, p = async (
|
|
3290
|
-
if (
|
|
3287
|
+
const B = {};
|
|
3288
|
+
return S.trim() || (B.token = !0), T.trim() || (B.newPassword = !0), C.trim() || (B.confirmPassword = !0), P(B), Object.keys(B).length === 0;
|
|
3289
|
+
}, p = async (B) => {
|
|
3290
|
+
if (B.preventDefault(), !!H()) {
|
|
3291
3291
|
if (!(L != null && L.id)) {
|
|
3292
3292
|
A("Tenant not found");
|
|
3293
3293
|
return;
|
|
3294
3294
|
}
|
|
3295
|
-
h(!0), A(""),
|
|
3295
|
+
h(!0), A(""), U("");
|
|
3296
3296
|
try {
|
|
3297
|
-
await O({ email: b, tenantId: L.id }),
|
|
3297
|
+
await O({ email: b, tenantId: L.id }), U(F.successMessage), s == null || s();
|
|
3298
3298
|
} catch (q) {
|
|
3299
3299
|
const V = q.message || F.errorMessage;
|
|
3300
3300
|
A(V), o == null || o(V);
|
|
@@ -3302,15 +3302,15 @@ function hr({
|
|
|
3302
3302
|
h(!1);
|
|
3303
3303
|
}
|
|
3304
3304
|
}
|
|
3305
|
-
}, u = async (
|
|
3306
|
-
if (
|
|
3305
|
+
}, u = async (B) => {
|
|
3306
|
+
if (B.preventDefault(), !!M()) {
|
|
3307
3307
|
if (T !== C) {
|
|
3308
3308
|
A(F.passwordMismatchError), P({ confirmPassword: !0 });
|
|
3309
3309
|
return;
|
|
3310
3310
|
}
|
|
3311
|
-
h(!0), A(""),
|
|
3311
|
+
h(!0), A(""), U("");
|
|
3312
3312
|
try {
|
|
3313
|
-
await c({ token: S, newPassword: T }),
|
|
3313
|
+
await c({ token: S, newPassword: T }), U(F.resetSuccessMessage), s == null || s();
|
|
3314
3314
|
} catch (q) {
|
|
3315
3315
|
const V = q.message || F.errorMessage;
|
|
3316
3316
|
A(V), o == null || o(V);
|
|
@@ -3318,15 +3318,15 @@ function hr({
|
|
|
3318
3318
|
h(!1);
|
|
3319
3319
|
}
|
|
3320
3320
|
}
|
|
3321
|
-
}, w = (
|
|
3321
|
+
}, w = (B) => ({
|
|
3322
3322
|
...l.input,
|
|
3323
|
-
...D[
|
|
3323
|
+
...D[B] ? l.inputError : {}
|
|
3324
3324
|
}), _ = () => ({
|
|
3325
3325
|
...l.button,
|
|
3326
3326
|
...x ? l.buttonLoading : {}
|
|
3327
3327
|
});
|
|
3328
3328
|
if (t === "reset") {
|
|
3329
|
-
const
|
|
3329
|
+
const B = S && T && C;
|
|
3330
3330
|
return /* @__PURE__ */ d("div", { className: y, style: l.container, children: [
|
|
3331
3331
|
/* @__PURE__ */ n("h2", { style: l.title, children: F.resetTitle }),
|
|
3332
3332
|
/* @__PURE__ */ n("p", { style: l.subtitle, children: F.resetSubtitle }),
|
|
@@ -3383,10 +3383,10 @@ function hr({
|
|
|
3383
3383
|
"button",
|
|
3384
3384
|
{
|
|
3385
3385
|
type: "submit",
|
|
3386
|
-
disabled: !
|
|
3386
|
+
disabled: !B || x,
|
|
3387
3387
|
style: {
|
|
3388
3388
|
..._(),
|
|
3389
|
-
...!
|
|
3389
|
+
...!B || x ? l.buttonDisabled : {}
|
|
3390
3390
|
},
|
|
3391
3391
|
children: x ? F.resetLoadingText : F.resetSubmitButton
|
|
3392
3392
|
}
|
|
@@ -3415,8 +3415,8 @@ function hr({
|
|
|
3415
3415
|
{
|
|
3416
3416
|
type: "email",
|
|
3417
3417
|
value: b,
|
|
3418
|
-
onChange: (
|
|
3419
|
-
g(
|
|
3418
|
+
onChange: (B) => {
|
|
3419
|
+
g(B.target.value), D.email && P((q) => ({ ...q, email: !1 }));
|
|
3420
3420
|
},
|
|
3421
3421
|
placeholder: F.emailPlaceholder,
|
|
3422
3422
|
style: w("email"),
|
|
@@ -3501,10 +3501,10 @@ function gr({
|
|
|
3501
3501
|
requireTenant: r = !0
|
|
3502
3502
|
}) {
|
|
3503
3503
|
const { isAppLoading: s, appError: o, retryApp: a } = he(), m = we(), y = Me(), b = Be(), g = qe(), S = (m == null ? void 0 : m.isTenantLoading) ?? !1, f = (m == null ? void 0 : m.tenantError) ?? null, T = (m == null ? void 0 : m.tenantSlug) ?? null, I = (m == null ? void 0 : m.retryTenant) ?? (() => {
|
|
3504
|
-
}), C = (y == null ? void 0 : y.isAuthReady) ?? !0, R = (b == null ? void 0 : b.isReady) ?? !0, x = (g == null ? void 0 : g.isReady) ?? !0, h = r && m && T,
|
|
3504
|
+
}), C = (y == null ? void 0 : y.isAuthReady) ?? !0, R = (b == null ? void 0 : b.isReady) ?? !0, x = (g == null ? void 0 : g.isReady) ?? !0, h = r && m && T, U = s || h && S || y && !C || b && !R || g && !x, D = o || (h ? f : null), P = () => {
|
|
3505
3505
|
o && a(), f && m && I();
|
|
3506
3506
|
};
|
|
3507
|
-
if (
|
|
3507
|
+
if (U)
|
|
3508
3508
|
return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(Ut, {}) });
|
|
3509
3509
|
if (D) {
|
|
3510
3510
|
const O = typeof t == "function" ? t(D, P) : t || /* @__PURE__ */ n(Bt, { error: D, retry: P });
|
|
@@ -3514,11 +3514,11 @@ function gr({
|
|
|
3514
3514
|
}
|
|
3515
3515
|
function pr(i = !0) {
|
|
3516
3516
|
const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = he(), o = we(), a = Me(), m = Be(), y = qe(), b = (o == null ? void 0 : o.isTenantLoading) ?? !1, g = (o == null ? void 0 : o.tenantError) ?? null, S = (o == null ? void 0 : o.tenant) ?? null, f = (o == null ? void 0 : o.tenantSlug) ?? null, T = (o == null ? void 0 : o.retryTenant) ?? (() => {
|
|
3517
|
-
}), I = (a == null ? void 0 : a.isAuthReady) ?? !0, C = (m == null ? void 0 : m.isReady) ?? !0, R = (y == null ? void 0 : y.isReady) ?? !0, x = i && o && f, E = e || x && b || a && !I || m && !C || y && !R,
|
|
3517
|
+
}), I = (a == null ? void 0 : a.isAuthReady) ?? !0, C = (m == null ? void 0 : m.isReady) ?? !0, R = (y == null ? void 0 : y.isReady) ?? !0, x = i && o && f, E = e || x && b || a && !I || m && !C || y && !R, U = t || (x ? g : null);
|
|
3518
3518
|
return {
|
|
3519
3519
|
isLoading: E,
|
|
3520
|
-
error:
|
|
3521
|
-
isReady: !E && !
|
|
3520
|
+
error: U,
|
|
3521
|
+
isReady: !E && !U && s !== null && (!x || S !== null),
|
|
3522
3522
|
retry: () => {
|
|
3523
3523
|
t && r(), g && o && T();
|
|
3524
3524
|
},
|
|
@@ -3611,11 +3611,11 @@ function fr({
|
|
|
3611
3611
|
cursor: "pointer",
|
|
3612
3612
|
backgroundColor: E ? "#f0f0f0" : "transparent"
|
|
3613
3613
|
},
|
|
3614
|
-
onMouseEnter: (
|
|
3615
|
-
E || (
|
|
3614
|
+
onMouseEnter: (U) => {
|
|
3615
|
+
E || (U.target.style.backgroundColor = "#f5f5f5");
|
|
3616
3616
|
},
|
|
3617
|
-
onMouseLeave: (
|
|
3618
|
-
E || (
|
|
3617
|
+
onMouseLeave: (U) => {
|
|
3618
|
+
E || (U.target.style.backgroundColor = "transparent");
|
|
3619
3619
|
},
|
|
3620
3620
|
children: a ? a(A, E) : h(A, E)
|
|
3621
3621
|
},
|