jett.admin.npmpackage 2.0.30 → 2.0.32

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 CHANGED
@@ -816,6 +816,84 @@ 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 PROFILE_SWITCH_FLAG_KEY = "jett_profile_switch_done";
847
+ var hasSwitchedProfileThisSession = () => {
848
+ try {
849
+ return typeof localStorage !== "undefined" && localStorage.getItem(PROFILE_SWITCH_FLAG_KEY) === "true";
850
+ } catch {
851
+ return false;
852
+ }
853
+ };
854
+ var markProfileSwitched = () => {
855
+ try {
856
+ if (typeof localStorage !== "undefined") {
857
+ localStorage.setItem(PROFILE_SWITCH_FLAG_KEY, "true");
858
+ }
859
+ } catch {
860
+ }
861
+ };
862
+ var clearProfileSwitchFlag = () => {
863
+ try {
864
+ if (typeof localStorage !== "undefined") {
865
+ localStorage.removeItem(PROFILE_SWITCH_FLAG_KEY);
866
+ }
867
+ } catch {
868
+ }
869
+ };
870
+ var buildRequestContext = () => ({
871
+ UserAgent: typeof navigator !== "undefined" ? navigator.userAgent : "Mozilla/5.0",
872
+ TrackingId: crypto.randomUUID(),
873
+ TransactionId: crypto.randomUUID(),
874
+ CountryCode: "IN",
875
+ IpAddress: "127.0.0.1"
876
+ // Client IP cannot be retrieved from browser
877
+ });
878
+ var switchProfile = async (profile) => {
879
+ markProfileSwitched();
880
+ const encryptedRequest = encryptForSwitchProfile(
881
+ JSON.stringify({
882
+ ProfileToken: profile.ProfileToken,
883
+ ProfileId: profile.ProfileId
884
+ })
885
+ );
886
+ return fetch(`${window.location.origin}/auth/switch/profile`, {
887
+ method: "POST",
888
+ credentials: "include",
889
+ headers: { "Content-Type": "application/json" },
890
+ body: JSON.stringify({
891
+ Context: buildRequestContext(),
892
+ Request: encryptedRequest
893
+ })
894
+ }).then((res) => res.json());
895
+ };
896
+
819
897
  // src/sideBar/SwitchProfileSection.jsx
820
898
  var import_react13 = __toESM(require("react"));
821
899
  var import_react_dom2 = require("react-dom");
@@ -870,32 +948,6 @@ var LogoutConfirmModal = ({
870
948
  );
871
949
  };
872
950
 
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
951
  // src/sideBar/SwitchProfileSection.jsx
900
952
  var SwitchProfileSection = ({
901
953
  id = "switch-profile",
@@ -919,35 +971,13 @@ var SwitchProfileSection = ({
919
971
  const markets = allMarkets.length ? allMarkets : (jettIdData == null ? void 0 : jettIdData.EntityName) ? [{ ProfileId: cookieProfileId, EntityName: jettIdData.EntityName }] : [];
920
972
  const tmcProfile = allMarkets.find((profile) => profile.Scope === "TMC");
921
973
  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
974
  const handleProfileSwitch = async (profile) => {
931
975
  var _a, _b, _c;
932
976
  if (switchingProfileId) return;
933
977
  setSwitchingProfileId(profile.ProfileId);
934
978
  setSwitchError(null);
935
979
  try {
936
- const encryptedRequest = encryptForSwitchProfile(
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());
980
+ const response = await switchProfile(profile);
951
981
  const statusCode = (_a = response == null ? void 0 : response.Context) == null ? void 0 : _a.StatusCode;
952
982
  const isSuccess = !statusCode || statusCode === 200;
953
983
  if (!isSuccess) {
@@ -992,13 +1022,6 @@ var SwitchProfileSection = ({
992
1022
  const timer = setTimeout(() => setSwitchError(null), 5e3);
993
1023
  return () => clearTimeout(timer);
994
1024
  }, [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
1025
  if (!open && !showLogoutConfirm || typeof document === "undefined") return null;
1003
1026
  const handleConfirmLogout = () => {
1004
1027
  setShowLogoutConfirm(false);
@@ -1190,6 +1213,22 @@ var AppSideBar = ({
1190
1213
  setScope(cookieScope);
1191
1214
  }
1192
1215
  }, []);
1216
+ (0, import_react14.useEffect)(() => {
1217
+ if (hasSwitchedProfileThisSession()) return;
1218
+ const jettIdData = getJettIdCookieData();
1219
+ const allProfiles = getProfilesFromJettIdCookie(true);
1220
+ if (allProfiles.length <= 1) return;
1221
+ const tmcProfile = allProfiles.find((profile) => profile.Scope === "TMC");
1222
+ if (!tmcProfile || tmcProfile.ProfileId === (jettIdData == null ? void 0 : jettIdData.ProfileId)) return;
1223
+ switchProfile(tmcProfile).then((response) => {
1224
+ var _a2;
1225
+ if ((_a2 = response == null ? void 0 : response.Response) == null ? void 0 : _a2.RedirectUrl) {
1226
+ window.location.href = response.Response.RedirectUrl;
1227
+ }
1228
+ }).catch((error) => {
1229
+ console.error("Auto TMC profile switch failed:", error);
1230
+ });
1231
+ }, []);
1193
1232
  const extractUrlFromOnClick = (onClick) => {
1194
1233
  if (!onClick || typeof onClick !== "function") return null;
1195
1234
  const funcString = onClick.toString();
@@ -1560,6 +1599,7 @@ var AppSideBar = ({
1560
1599
  },
1561
1600
  onLogout: () => {
1562
1601
  setIsSwitchProfileOpen(false);
1602
+ clearProfileSwitchFlag();
1563
1603
  if (onLogout) {
1564
1604
  onLogout();
1565
1605
  } else {
package/dist/index.mjs CHANGED
@@ -782,6 +782,84 @@ 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 PROFILE_SWITCH_FLAG_KEY = "jett_profile_switch_done";
813
+ var hasSwitchedProfileThisSession = () => {
814
+ try {
815
+ return typeof localStorage !== "undefined" && localStorage.getItem(PROFILE_SWITCH_FLAG_KEY) === "true";
816
+ } catch {
817
+ return false;
818
+ }
819
+ };
820
+ var markProfileSwitched = () => {
821
+ try {
822
+ if (typeof localStorage !== "undefined") {
823
+ localStorage.setItem(PROFILE_SWITCH_FLAG_KEY, "true");
824
+ }
825
+ } catch {
826
+ }
827
+ };
828
+ var clearProfileSwitchFlag = () => {
829
+ try {
830
+ if (typeof localStorage !== "undefined") {
831
+ localStorage.removeItem(PROFILE_SWITCH_FLAG_KEY);
832
+ }
833
+ } catch {
834
+ }
835
+ };
836
+ var buildRequestContext = () => ({
837
+ UserAgent: typeof navigator !== "undefined" ? navigator.userAgent : "Mozilla/5.0",
838
+ TrackingId: crypto.randomUUID(),
839
+ TransactionId: crypto.randomUUID(),
840
+ CountryCode: "IN",
841
+ IpAddress: "127.0.0.1"
842
+ // Client IP cannot be retrieved from browser
843
+ });
844
+ var switchProfile = async (profile) => {
845
+ markProfileSwitched();
846
+ const encryptedRequest = encryptForSwitchProfile(
847
+ JSON.stringify({
848
+ ProfileToken: profile.ProfileToken,
849
+ ProfileId: profile.ProfileId
850
+ })
851
+ );
852
+ return fetch(`${window.location.origin}/auth/switch/profile`, {
853
+ method: "POST",
854
+ credentials: "include",
855
+ headers: { "Content-Type": "application/json" },
856
+ body: JSON.stringify({
857
+ Context: buildRequestContext(),
858
+ Request: encryptedRequest
859
+ })
860
+ }).then((res) => res.json());
861
+ };
862
+
785
863
  // src/sideBar/SwitchProfileSection.jsx
786
864
  import React13, { useEffect, useLayoutEffect, useState as useState3 } from "react";
787
865
  import { createPortal as createPortal2 } from "react-dom";
@@ -836,32 +914,6 @@ var LogoutConfirmModal = ({
836
914
  );
837
915
  };
838
916
 
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
917
  // src/sideBar/SwitchProfileSection.jsx
866
918
  var SwitchProfileSection = ({
867
919
  id = "switch-profile",
@@ -885,35 +937,13 @@ var SwitchProfileSection = ({
885
937
  const markets = allMarkets.length ? allMarkets : (jettIdData == null ? void 0 : jettIdData.EntityName) ? [{ ProfileId: cookieProfileId, EntityName: jettIdData.EntityName }] : [];
886
938
  const tmcProfile = allMarkets.find((profile) => profile.Scope === "TMC");
887
939
  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
940
  const handleProfileSwitch = async (profile) => {
897
941
  var _a, _b, _c;
898
942
  if (switchingProfileId) return;
899
943
  setSwitchingProfileId(profile.ProfileId);
900
944
  setSwitchError(null);
901
945
  try {
902
- const encryptedRequest = encryptForSwitchProfile(
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());
946
+ const response = await switchProfile(profile);
917
947
  const statusCode = (_a = response == null ? void 0 : response.Context) == null ? void 0 : _a.StatusCode;
918
948
  const isSuccess = !statusCode || statusCode === 200;
919
949
  if (!isSuccess) {
@@ -958,13 +988,6 @@ var SwitchProfileSection = ({
958
988
  const timer = setTimeout(() => setSwitchError(null), 5e3);
959
989
  return () => clearTimeout(timer);
960
990
  }, [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
991
  if (!open && !showLogoutConfirm || typeof document === "undefined") return null;
969
992
  const handleConfirmLogout = () => {
970
993
  setShowLogoutConfirm(false);
@@ -1156,6 +1179,22 @@ var AppSideBar = ({
1156
1179
  setScope(cookieScope);
1157
1180
  }
1158
1181
  }, []);
1182
+ useEffect2(() => {
1183
+ if (hasSwitchedProfileThisSession()) return;
1184
+ const jettIdData = getJettIdCookieData();
1185
+ const allProfiles = getProfilesFromJettIdCookie(true);
1186
+ if (allProfiles.length <= 1) return;
1187
+ const tmcProfile = allProfiles.find((profile) => profile.Scope === "TMC");
1188
+ if (!tmcProfile || tmcProfile.ProfileId === (jettIdData == null ? void 0 : jettIdData.ProfileId)) return;
1189
+ switchProfile(tmcProfile).then((response) => {
1190
+ var _a2;
1191
+ if ((_a2 = response == null ? void 0 : response.Response) == null ? void 0 : _a2.RedirectUrl) {
1192
+ window.location.href = response.Response.RedirectUrl;
1193
+ }
1194
+ }).catch((error) => {
1195
+ console.error("Auto TMC profile switch failed:", error);
1196
+ });
1197
+ }, []);
1159
1198
  const extractUrlFromOnClick = (onClick) => {
1160
1199
  if (!onClick || typeof onClick !== "function") return null;
1161
1200
  const funcString = onClick.toString();
@@ -1526,6 +1565,7 @@ var AppSideBar = ({
1526
1565
  },
1527
1566
  onLogout: () => {
1528
1567
  setIsSwitchProfileOpen(false);
1568
+ clearProfileSwitchFlag();
1529
1569
  if (onLogout) {
1530
1570
  onLogout();
1531
1571
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jett.admin.npmpackage",
3
- "version": "2.0.30",
3
+ "version": "2.0.32",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "exports": {