jett.admin.npmpackage 2.0.30 → 2.0.31
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.js +69 -56
- package/dist/index.mjs +69 -56
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -816,6 +816,59 @@ function buildLogoUrl(CDNBasePath, logoPath) {
|
|
|
816
816
|
return `${base}/${path}`;
|
|
817
817
|
}
|
|
818
818
|
|
|
819
|
+
// src/utils/switchProfileEncryption.js
|
|
820
|
+
var import_node_forge = __toESM(require("node-forge"));
|
|
821
|
+
var RSA_MODULUS_BASE64 = "zktSGmyKa5SR8HO540HKTdgDPVmXafgGFrf4OYtRNApRssnt0hGoMU7Jitc/SVWbPstFshIi5XblbDL2NXWYhZtj4PWL4SKc1/bM02xxabPw/eFr3XAAPCF62WxAVPsJBbEoAB0AcOCeIcGHb+tzLtXQJAvOuIBsKLQiiB7/c9ltt5AVVM4si1RC3JsxpqcGTkgwnh+FMg8CFvLdHjh/oi789wj8zoGWLAdYSBBa8IoQgTuzZt1tft2LF0y4Ck3yT8F9TX5GbAiVXb0G9cM/hUmDNz/6xOvHuOfH5147tKDUNCT/sr5tEaLm5ePUmRdpoc5PZa04q1KGJ0rxf6T55E5pQ8Qh2EFr1yPyLh12wiSTRsnHwXwVsosbNNBBN3HdBOMklTQx2VJNDHpi19G+z4d1evlS8yDqNZe9QyRFKEsTd+xPg3ob3j/ObpYDOtXoMaw8fXWbvyG4MJTz7nWG5YL2s5oWSAFZ4mifgwOmM/OuTO/uholelws25k/a3+O/s5Xd/HOugBvpeb5azGLfMHrGvu6J9DSIVI28hfbaFm2+smjyLdS+5PWV2+hM9EQLgaw/euGx4Qhzo2nagLwl9+hNOZ2gjtNHJxJtbQJTNrE90d3mX2/yfxHzh8FiiAiraxiZCgdUQeEZbZNlAwQLHIYWazSqgmRhf4D1LGMMrak=";
|
|
822
|
+
var RSA_EXPONENT_BASE64 = "AQAB";
|
|
823
|
+
var convertModulusExponentToPem = (modulus, exponent) => {
|
|
824
|
+
const decodedModulus = import_node_forge.default.util.decode64(modulus);
|
|
825
|
+
const decodedExponent = import_node_forge.default.util.decode64(exponent);
|
|
826
|
+
const publicKey = import_node_forge.default.pki.setRsaPublicKey(
|
|
827
|
+
new import_node_forge.default.jsbn.BigInteger(import_node_forge.default.util.bytesToHex(decodedModulus), 16),
|
|
828
|
+
new import_node_forge.default.jsbn.BigInteger(import_node_forge.default.util.bytesToHex(decodedExponent), 16)
|
|
829
|
+
);
|
|
830
|
+
return import_node_forge.default.pki.publicKeyToPem(publicKey);
|
|
831
|
+
};
|
|
832
|
+
var cachedPemKey = null;
|
|
833
|
+
var getPemKey = () => {
|
|
834
|
+
if (!cachedPemKey) {
|
|
835
|
+
cachedPemKey = convertModulusExponentToPem(RSA_MODULUS_BASE64, RSA_EXPONENT_BASE64);
|
|
836
|
+
}
|
|
837
|
+
return cachedPemKey;
|
|
838
|
+
};
|
|
839
|
+
var encryptForSwitchProfile = (plainText) => {
|
|
840
|
+
const publicKey = import_node_forge.default.pki.publicKeyFromPem(getPemKey());
|
|
841
|
+
const encrypted = publicKey.encrypt(plainText, "RSAES-PKCS1-V1_5");
|
|
842
|
+
return import_node_forge.default.util.encode64(encrypted).replace(/\r?\n|\r/g, "");
|
|
843
|
+
};
|
|
844
|
+
|
|
845
|
+
// src/utils/switchProfileApi.js
|
|
846
|
+
var buildRequestContext = () => ({
|
|
847
|
+
UserAgent: typeof navigator !== "undefined" ? navigator.userAgent : "Mozilla/5.0",
|
|
848
|
+
TrackingId: crypto.randomUUID(),
|
|
849
|
+
TransactionId: crypto.randomUUID(),
|
|
850
|
+
CountryCode: "IN",
|
|
851
|
+
IpAddress: "127.0.0.1"
|
|
852
|
+
// Client IP cannot be retrieved from browser
|
|
853
|
+
});
|
|
854
|
+
var switchProfile = async (profile) => {
|
|
855
|
+
const encryptedRequest = encryptForSwitchProfile(
|
|
856
|
+
JSON.stringify({
|
|
857
|
+
ProfileToken: profile.ProfileToken,
|
|
858
|
+
ProfileId: profile.ProfileId
|
|
859
|
+
})
|
|
860
|
+
);
|
|
861
|
+
return fetch(`${window.location.origin}/auth/switch/profile`, {
|
|
862
|
+
method: "POST",
|
|
863
|
+
credentials: "include",
|
|
864
|
+
headers: { "Content-Type": "application/json" },
|
|
865
|
+
body: JSON.stringify({
|
|
866
|
+
Context: buildRequestContext(),
|
|
867
|
+
Request: encryptedRequest
|
|
868
|
+
})
|
|
869
|
+
}).then((res) => res.json());
|
|
870
|
+
};
|
|
871
|
+
|
|
819
872
|
// src/sideBar/SwitchProfileSection.jsx
|
|
820
873
|
var import_react13 = __toESM(require("react"));
|
|
821
874
|
var import_react_dom2 = require("react-dom");
|
|
@@ -870,32 +923,6 @@ var LogoutConfirmModal = ({
|
|
|
870
923
|
);
|
|
871
924
|
};
|
|
872
925
|
|
|
873
|
-
// src/utils/switchProfileEncryption.js
|
|
874
|
-
var import_node_forge = __toESM(require("node-forge"));
|
|
875
|
-
var RSA_MODULUS_BASE64 = "zktSGmyKa5SR8HO540HKTdgDPVmXafgGFrf4OYtRNApRssnt0hGoMU7Jitc/SVWbPstFshIi5XblbDL2NXWYhZtj4PWL4SKc1/bM02xxabPw/eFr3XAAPCF62WxAVPsJBbEoAB0AcOCeIcGHb+tzLtXQJAvOuIBsKLQiiB7/c9ltt5AVVM4si1RC3JsxpqcGTkgwnh+FMg8CFvLdHjh/oi789wj8zoGWLAdYSBBa8IoQgTuzZt1tft2LF0y4Ck3yT8F9TX5GbAiVXb0G9cM/hUmDNz/6xOvHuOfH5147tKDUNCT/sr5tEaLm5ePUmRdpoc5PZa04q1KGJ0rxf6T55E5pQ8Qh2EFr1yPyLh12wiSTRsnHwXwVsosbNNBBN3HdBOMklTQx2VJNDHpi19G+z4d1evlS8yDqNZe9QyRFKEsTd+xPg3ob3j/ObpYDOtXoMaw8fXWbvyG4MJTz7nWG5YL2s5oWSAFZ4mifgwOmM/OuTO/uholelws25k/a3+O/s5Xd/HOugBvpeb5azGLfMHrGvu6J9DSIVI28hfbaFm2+smjyLdS+5PWV2+hM9EQLgaw/euGx4Qhzo2nagLwl9+hNOZ2gjtNHJxJtbQJTNrE90d3mX2/yfxHzh8FiiAiraxiZCgdUQeEZbZNlAwQLHIYWazSqgmRhf4D1LGMMrak=";
|
|
876
|
-
var RSA_EXPONENT_BASE64 = "AQAB";
|
|
877
|
-
var convertModulusExponentToPem = (modulus, exponent) => {
|
|
878
|
-
const decodedModulus = import_node_forge.default.util.decode64(modulus);
|
|
879
|
-
const decodedExponent = import_node_forge.default.util.decode64(exponent);
|
|
880
|
-
const publicKey = import_node_forge.default.pki.setRsaPublicKey(
|
|
881
|
-
new import_node_forge.default.jsbn.BigInteger(import_node_forge.default.util.bytesToHex(decodedModulus), 16),
|
|
882
|
-
new import_node_forge.default.jsbn.BigInteger(import_node_forge.default.util.bytesToHex(decodedExponent), 16)
|
|
883
|
-
);
|
|
884
|
-
return import_node_forge.default.pki.publicKeyToPem(publicKey);
|
|
885
|
-
};
|
|
886
|
-
var cachedPemKey = null;
|
|
887
|
-
var getPemKey = () => {
|
|
888
|
-
if (!cachedPemKey) {
|
|
889
|
-
cachedPemKey = convertModulusExponentToPem(RSA_MODULUS_BASE64, RSA_EXPONENT_BASE64);
|
|
890
|
-
}
|
|
891
|
-
return cachedPemKey;
|
|
892
|
-
};
|
|
893
|
-
var encryptForSwitchProfile = (plainText) => {
|
|
894
|
-
const publicKey = import_node_forge.default.pki.publicKeyFromPem(getPemKey());
|
|
895
|
-
const encrypted = publicKey.encrypt(plainText, "RSAES-PKCS1-V1_5");
|
|
896
|
-
return import_node_forge.default.util.encode64(encrypted).replace(/\r?\n|\r/g, "");
|
|
897
|
-
};
|
|
898
|
-
|
|
899
926
|
// src/sideBar/SwitchProfileSection.jsx
|
|
900
927
|
var SwitchProfileSection = ({
|
|
901
928
|
id = "switch-profile",
|
|
@@ -919,35 +946,13 @@ var SwitchProfileSection = ({
|
|
|
919
946
|
const markets = allMarkets.length ? allMarkets : (jettIdData == null ? void 0 : jettIdData.EntityName) ? [{ ProfileId: cookieProfileId, EntityName: jettIdData.EntityName }] : [];
|
|
920
947
|
const tmcProfile = allMarkets.find((profile) => profile.Scope === "TMC");
|
|
921
948
|
const currentProfileId = tmcProfile ? tmcProfile.ProfileId : cookieProfileId;
|
|
922
|
-
const buildRequestContext = () => ({
|
|
923
|
-
UserAgent: typeof navigator !== "undefined" ? navigator.userAgent : "Mozilla/5.0",
|
|
924
|
-
TrackingId: crypto.randomUUID(),
|
|
925
|
-
TransactionId: crypto.randomUUID(),
|
|
926
|
-
CountryCode: "IN",
|
|
927
|
-
IpAddress: "127.0.0.1"
|
|
928
|
-
// Client IP cannot be retrieved from browser
|
|
929
|
-
});
|
|
930
949
|
const handleProfileSwitch = async (profile) => {
|
|
931
950
|
var _a, _b, _c;
|
|
932
951
|
if (switchingProfileId) return;
|
|
933
952
|
setSwitchingProfileId(profile.ProfileId);
|
|
934
953
|
setSwitchError(null);
|
|
935
954
|
try {
|
|
936
|
-
const
|
|
937
|
-
JSON.stringify({
|
|
938
|
-
ProfileToken: profile.ProfileToken,
|
|
939
|
-
ProfileId: profile.ProfileId
|
|
940
|
-
})
|
|
941
|
-
);
|
|
942
|
-
const response = await fetch(`${window.location.origin}/auth/switch/profile`, {
|
|
943
|
-
method: "POST",
|
|
944
|
-
credentials: "include",
|
|
945
|
-
headers: { "Content-Type": "application/json" },
|
|
946
|
-
body: JSON.stringify({
|
|
947
|
-
Context: buildRequestContext(),
|
|
948
|
-
Request: encryptedRequest
|
|
949
|
-
})
|
|
950
|
-
}).then((res) => res.json());
|
|
955
|
+
const response = await switchProfile(profile);
|
|
951
956
|
const statusCode = (_a = response == null ? void 0 : response.Context) == null ? void 0 : _a.StatusCode;
|
|
952
957
|
const isSuccess = !statusCode || statusCode === 200;
|
|
953
958
|
if (!isSuccess) {
|
|
@@ -992,13 +997,6 @@ var SwitchProfileSection = ({
|
|
|
992
997
|
const timer = setTimeout(() => setSwitchError(null), 5e3);
|
|
993
998
|
return () => clearTimeout(timer);
|
|
994
999
|
}, [switchError]);
|
|
995
|
-
(0, import_react13.useEffect)(() => {
|
|
996
|
-
if (!open || switchingProfileId) return;
|
|
997
|
-
if (allMarkets.length <= 1) return;
|
|
998
|
-
if (tmcProfile && tmcProfile.ProfileId !== cookieProfileId) {
|
|
999
|
-
handleProfileSwitch(tmcProfile);
|
|
1000
|
-
}
|
|
1001
|
-
}, [open, allMarkets, cookieProfileId, tmcProfile, switchingProfileId]);
|
|
1002
1000
|
if (!open && !showLogoutConfirm || typeof document === "undefined") return null;
|
|
1003
1001
|
const handleConfirmLogout = () => {
|
|
1004
1002
|
setShowLogoutConfirm(false);
|
|
@@ -1190,6 +1188,21 @@ var AppSideBar = ({
|
|
|
1190
1188
|
setScope(cookieScope);
|
|
1191
1189
|
}
|
|
1192
1190
|
}, []);
|
|
1191
|
+
(0, import_react14.useEffect)(() => {
|
|
1192
|
+
const jettIdData = getJettIdCookieData();
|
|
1193
|
+
const allProfiles = getProfilesFromJettIdCookie(true);
|
|
1194
|
+
if (allProfiles.length <= 1) return;
|
|
1195
|
+
const tmcProfile = allProfiles.find((profile) => profile.Scope === "TMC");
|
|
1196
|
+
if (!tmcProfile || tmcProfile.ProfileId === (jettIdData == null ? void 0 : jettIdData.ProfileId)) return;
|
|
1197
|
+
switchProfile(tmcProfile).then((response) => {
|
|
1198
|
+
var _a2;
|
|
1199
|
+
if ((_a2 = response == null ? void 0 : response.Response) == null ? void 0 : _a2.RedirectUrl) {
|
|
1200
|
+
window.location.href = response.Response.RedirectUrl;
|
|
1201
|
+
}
|
|
1202
|
+
}).catch((error) => {
|
|
1203
|
+
console.error("Auto TMC profile switch failed:", error);
|
|
1204
|
+
});
|
|
1205
|
+
}, []);
|
|
1193
1206
|
const extractUrlFromOnClick = (onClick) => {
|
|
1194
1207
|
if (!onClick || typeof onClick !== "function") return null;
|
|
1195
1208
|
const funcString = onClick.toString();
|
package/dist/index.mjs
CHANGED
|
@@ -782,6 +782,59 @@ function buildLogoUrl(CDNBasePath, logoPath) {
|
|
|
782
782
|
return `${base}/${path}`;
|
|
783
783
|
}
|
|
784
784
|
|
|
785
|
+
// src/utils/switchProfileEncryption.js
|
|
786
|
+
import forge from "node-forge";
|
|
787
|
+
var RSA_MODULUS_BASE64 = "zktSGmyKa5SR8HO540HKTdgDPVmXafgGFrf4OYtRNApRssnt0hGoMU7Jitc/SVWbPstFshIi5XblbDL2NXWYhZtj4PWL4SKc1/bM02xxabPw/eFr3XAAPCF62WxAVPsJBbEoAB0AcOCeIcGHb+tzLtXQJAvOuIBsKLQiiB7/c9ltt5AVVM4si1RC3JsxpqcGTkgwnh+FMg8CFvLdHjh/oi789wj8zoGWLAdYSBBa8IoQgTuzZt1tft2LF0y4Ck3yT8F9TX5GbAiVXb0G9cM/hUmDNz/6xOvHuOfH5147tKDUNCT/sr5tEaLm5ePUmRdpoc5PZa04q1KGJ0rxf6T55E5pQ8Qh2EFr1yPyLh12wiSTRsnHwXwVsosbNNBBN3HdBOMklTQx2VJNDHpi19G+z4d1evlS8yDqNZe9QyRFKEsTd+xPg3ob3j/ObpYDOtXoMaw8fXWbvyG4MJTz7nWG5YL2s5oWSAFZ4mifgwOmM/OuTO/uholelws25k/a3+O/s5Xd/HOugBvpeb5azGLfMHrGvu6J9DSIVI28hfbaFm2+smjyLdS+5PWV2+hM9EQLgaw/euGx4Qhzo2nagLwl9+hNOZ2gjtNHJxJtbQJTNrE90d3mX2/yfxHzh8FiiAiraxiZCgdUQeEZbZNlAwQLHIYWazSqgmRhf4D1LGMMrak=";
|
|
788
|
+
var RSA_EXPONENT_BASE64 = "AQAB";
|
|
789
|
+
var convertModulusExponentToPem = (modulus, exponent) => {
|
|
790
|
+
const decodedModulus = forge.util.decode64(modulus);
|
|
791
|
+
const decodedExponent = forge.util.decode64(exponent);
|
|
792
|
+
const publicKey = forge.pki.setRsaPublicKey(
|
|
793
|
+
new forge.jsbn.BigInteger(forge.util.bytesToHex(decodedModulus), 16),
|
|
794
|
+
new forge.jsbn.BigInteger(forge.util.bytesToHex(decodedExponent), 16)
|
|
795
|
+
);
|
|
796
|
+
return forge.pki.publicKeyToPem(publicKey);
|
|
797
|
+
};
|
|
798
|
+
var cachedPemKey = null;
|
|
799
|
+
var getPemKey = () => {
|
|
800
|
+
if (!cachedPemKey) {
|
|
801
|
+
cachedPemKey = convertModulusExponentToPem(RSA_MODULUS_BASE64, RSA_EXPONENT_BASE64);
|
|
802
|
+
}
|
|
803
|
+
return cachedPemKey;
|
|
804
|
+
};
|
|
805
|
+
var encryptForSwitchProfile = (plainText) => {
|
|
806
|
+
const publicKey = forge.pki.publicKeyFromPem(getPemKey());
|
|
807
|
+
const encrypted = publicKey.encrypt(plainText, "RSAES-PKCS1-V1_5");
|
|
808
|
+
return forge.util.encode64(encrypted).replace(/\r?\n|\r/g, "");
|
|
809
|
+
};
|
|
810
|
+
|
|
811
|
+
// src/utils/switchProfileApi.js
|
|
812
|
+
var buildRequestContext = () => ({
|
|
813
|
+
UserAgent: typeof navigator !== "undefined" ? navigator.userAgent : "Mozilla/5.0",
|
|
814
|
+
TrackingId: crypto.randomUUID(),
|
|
815
|
+
TransactionId: crypto.randomUUID(),
|
|
816
|
+
CountryCode: "IN",
|
|
817
|
+
IpAddress: "127.0.0.1"
|
|
818
|
+
// Client IP cannot be retrieved from browser
|
|
819
|
+
});
|
|
820
|
+
var switchProfile = async (profile) => {
|
|
821
|
+
const encryptedRequest = encryptForSwitchProfile(
|
|
822
|
+
JSON.stringify({
|
|
823
|
+
ProfileToken: profile.ProfileToken,
|
|
824
|
+
ProfileId: profile.ProfileId
|
|
825
|
+
})
|
|
826
|
+
);
|
|
827
|
+
return fetch(`${window.location.origin}/auth/switch/profile`, {
|
|
828
|
+
method: "POST",
|
|
829
|
+
credentials: "include",
|
|
830
|
+
headers: { "Content-Type": "application/json" },
|
|
831
|
+
body: JSON.stringify({
|
|
832
|
+
Context: buildRequestContext(),
|
|
833
|
+
Request: encryptedRequest
|
|
834
|
+
})
|
|
835
|
+
}).then((res) => res.json());
|
|
836
|
+
};
|
|
837
|
+
|
|
785
838
|
// src/sideBar/SwitchProfileSection.jsx
|
|
786
839
|
import React13, { useEffect, useLayoutEffect, useState as useState3 } from "react";
|
|
787
840
|
import { createPortal as createPortal2 } from "react-dom";
|
|
@@ -836,32 +889,6 @@ var LogoutConfirmModal = ({
|
|
|
836
889
|
);
|
|
837
890
|
};
|
|
838
891
|
|
|
839
|
-
// src/utils/switchProfileEncryption.js
|
|
840
|
-
import forge from "node-forge";
|
|
841
|
-
var RSA_MODULUS_BASE64 = "zktSGmyKa5SR8HO540HKTdgDPVmXafgGFrf4OYtRNApRssnt0hGoMU7Jitc/SVWbPstFshIi5XblbDL2NXWYhZtj4PWL4SKc1/bM02xxabPw/eFr3XAAPCF62WxAVPsJBbEoAB0AcOCeIcGHb+tzLtXQJAvOuIBsKLQiiB7/c9ltt5AVVM4si1RC3JsxpqcGTkgwnh+FMg8CFvLdHjh/oi789wj8zoGWLAdYSBBa8IoQgTuzZt1tft2LF0y4Ck3yT8F9TX5GbAiVXb0G9cM/hUmDNz/6xOvHuOfH5147tKDUNCT/sr5tEaLm5ePUmRdpoc5PZa04q1KGJ0rxf6T55E5pQ8Qh2EFr1yPyLh12wiSTRsnHwXwVsosbNNBBN3HdBOMklTQx2VJNDHpi19G+z4d1evlS8yDqNZe9QyRFKEsTd+xPg3ob3j/ObpYDOtXoMaw8fXWbvyG4MJTz7nWG5YL2s5oWSAFZ4mifgwOmM/OuTO/uholelws25k/a3+O/s5Xd/HOugBvpeb5azGLfMHrGvu6J9DSIVI28hfbaFm2+smjyLdS+5PWV2+hM9EQLgaw/euGx4Qhzo2nagLwl9+hNOZ2gjtNHJxJtbQJTNrE90d3mX2/yfxHzh8FiiAiraxiZCgdUQeEZbZNlAwQLHIYWazSqgmRhf4D1LGMMrak=";
|
|
842
|
-
var RSA_EXPONENT_BASE64 = "AQAB";
|
|
843
|
-
var convertModulusExponentToPem = (modulus, exponent) => {
|
|
844
|
-
const decodedModulus = forge.util.decode64(modulus);
|
|
845
|
-
const decodedExponent = forge.util.decode64(exponent);
|
|
846
|
-
const publicKey = forge.pki.setRsaPublicKey(
|
|
847
|
-
new forge.jsbn.BigInteger(forge.util.bytesToHex(decodedModulus), 16),
|
|
848
|
-
new forge.jsbn.BigInteger(forge.util.bytesToHex(decodedExponent), 16)
|
|
849
|
-
);
|
|
850
|
-
return forge.pki.publicKeyToPem(publicKey);
|
|
851
|
-
};
|
|
852
|
-
var cachedPemKey = null;
|
|
853
|
-
var getPemKey = () => {
|
|
854
|
-
if (!cachedPemKey) {
|
|
855
|
-
cachedPemKey = convertModulusExponentToPem(RSA_MODULUS_BASE64, RSA_EXPONENT_BASE64);
|
|
856
|
-
}
|
|
857
|
-
return cachedPemKey;
|
|
858
|
-
};
|
|
859
|
-
var encryptForSwitchProfile = (plainText) => {
|
|
860
|
-
const publicKey = forge.pki.publicKeyFromPem(getPemKey());
|
|
861
|
-
const encrypted = publicKey.encrypt(plainText, "RSAES-PKCS1-V1_5");
|
|
862
|
-
return forge.util.encode64(encrypted).replace(/\r?\n|\r/g, "");
|
|
863
|
-
};
|
|
864
|
-
|
|
865
892
|
// src/sideBar/SwitchProfileSection.jsx
|
|
866
893
|
var SwitchProfileSection = ({
|
|
867
894
|
id = "switch-profile",
|
|
@@ -885,35 +912,13 @@ var SwitchProfileSection = ({
|
|
|
885
912
|
const markets = allMarkets.length ? allMarkets : (jettIdData == null ? void 0 : jettIdData.EntityName) ? [{ ProfileId: cookieProfileId, EntityName: jettIdData.EntityName }] : [];
|
|
886
913
|
const tmcProfile = allMarkets.find((profile) => profile.Scope === "TMC");
|
|
887
914
|
const currentProfileId = tmcProfile ? tmcProfile.ProfileId : cookieProfileId;
|
|
888
|
-
const buildRequestContext = () => ({
|
|
889
|
-
UserAgent: typeof navigator !== "undefined" ? navigator.userAgent : "Mozilla/5.0",
|
|
890
|
-
TrackingId: crypto.randomUUID(),
|
|
891
|
-
TransactionId: crypto.randomUUID(),
|
|
892
|
-
CountryCode: "IN",
|
|
893
|
-
IpAddress: "127.0.0.1"
|
|
894
|
-
// Client IP cannot be retrieved from browser
|
|
895
|
-
});
|
|
896
915
|
const handleProfileSwitch = async (profile) => {
|
|
897
916
|
var _a, _b, _c;
|
|
898
917
|
if (switchingProfileId) return;
|
|
899
918
|
setSwitchingProfileId(profile.ProfileId);
|
|
900
919
|
setSwitchError(null);
|
|
901
920
|
try {
|
|
902
|
-
const
|
|
903
|
-
JSON.stringify({
|
|
904
|
-
ProfileToken: profile.ProfileToken,
|
|
905
|
-
ProfileId: profile.ProfileId
|
|
906
|
-
})
|
|
907
|
-
);
|
|
908
|
-
const response = await fetch(`${window.location.origin}/auth/switch/profile`, {
|
|
909
|
-
method: "POST",
|
|
910
|
-
credentials: "include",
|
|
911
|
-
headers: { "Content-Type": "application/json" },
|
|
912
|
-
body: JSON.stringify({
|
|
913
|
-
Context: buildRequestContext(),
|
|
914
|
-
Request: encryptedRequest
|
|
915
|
-
})
|
|
916
|
-
}).then((res) => res.json());
|
|
921
|
+
const response = await switchProfile(profile);
|
|
917
922
|
const statusCode = (_a = response == null ? void 0 : response.Context) == null ? void 0 : _a.StatusCode;
|
|
918
923
|
const isSuccess = !statusCode || statusCode === 200;
|
|
919
924
|
if (!isSuccess) {
|
|
@@ -958,13 +963,6 @@ var SwitchProfileSection = ({
|
|
|
958
963
|
const timer = setTimeout(() => setSwitchError(null), 5e3);
|
|
959
964
|
return () => clearTimeout(timer);
|
|
960
965
|
}, [switchError]);
|
|
961
|
-
useEffect(() => {
|
|
962
|
-
if (!open || switchingProfileId) return;
|
|
963
|
-
if (allMarkets.length <= 1) return;
|
|
964
|
-
if (tmcProfile && tmcProfile.ProfileId !== cookieProfileId) {
|
|
965
|
-
handleProfileSwitch(tmcProfile);
|
|
966
|
-
}
|
|
967
|
-
}, [open, allMarkets, cookieProfileId, tmcProfile, switchingProfileId]);
|
|
968
966
|
if (!open && !showLogoutConfirm || typeof document === "undefined") return null;
|
|
969
967
|
const handleConfirmLogout = () => {
|
|
970
968
|
setShowLogoutConfirm(false);
|
|
@@ -1156,6 +1154,21 @@ var AppSideBar = ({
|
|
|
1156
1154
|
setScope(cookieScope);
|
|
1157
1155
|
}
|
|
1158
1156
|
}, []);
|
|
1157
|
+
useEffect2(() => {
|
|
1158
|
+
const jettIdData = getJettIdCookieData();
|
|
1159
|
+
const allProfiles = getProfilesFromJettIdCookie(true);
|
|
1160
|
+
if (allProfiles.length <= 1) return;
|
|
1161
|
+
const tmcProfile = allProfiles.find((profile) => profile.Scope === "TMC");
|
|
1162
|
+
if (!tmcProfile || tmcProfile.ProfileId === (jettIdData == null ? void 0 : jettIdData.ProfileId)) return;
|
|
1163
|
+
switchProfile(tmcProfile).then((response) => {
|
|
1164
|
+
var _a2;
|
|
1165
|
+
if ((_a2 = response == null ? void 0 : response.Response) == null ? void 0 : _a2.RedirectUrl) {
|
|
1166
|
+
window.location.href = response.Response.RedirectUrl;
|
|
1167
|
+
}
|
|
1168
|
+
}).catch((error) => {
|
|
1169
|
+
console.error("Auto TMC profile switch failed:", error);
|
|
1170
|
+
});
|
|
1171
|
+
}, []);
|
|
1159
1172
|
const extractUrlFromOnClick = (onClick) => {
|
|
1160
1173
|
if (!onClick || typeof onClick !== "function") return null;
|
|
1161
1174
|
const funcString = onClick.toString();
|