steamutils 1.4.74 → 1.4.75

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/SteamClient.js CHANGED
@@ -923,19 +923,17 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
923
923
  steamClient.webSession = webSession;
924
924
  callEvent(events.webSession, webSession);
925
925
  },
926
- receivedFromGC: async function (appid, msgType, payload) {
926
+ receivedFromGC: async function (appId, msgType, payload) {
927
927
  const key = getECsgoGCMsgKey(msgType);
928
- switch (msgType) {
929
- case ESteamProto.EMsg.k_EMsgClientChatInvite: {
928
+ const handleGC = {
929
+ async [ESteamProto.EMsg.k_EMsgClientChatInvite]({ appId, msgType, payload }) {
930
930
  log(payload);
931
- break;
932
- }
933
- case ESteamProto.ECsgoGCMsg.k_EMsgClientMMSJoinLobbyResponse: {
931
+ },
932
+ async [ESteamProto.ECsgoGCMsg.k_EMsgClientMMSJoinLobbyResponse]({ appId, msgType, payload }) {
934
933
  const msg = new SteamProto(SteamProtoType.CMsgClientMMSJoinLobbyResponse).protoDecode(payload);
935
934
  log(msg);
936
- break;
937
- }
938
- case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Party_Invite: {
935
+ },
936
+ async [ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Party_Invite]({ appId, msgType, payload }) {
939
937
  const msg = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_Party_Invite).protoDecode(payload);
940
938
  const sid64 = SteamID.fromIndividualAccountID(msg.accountid).getSteamID64();
941
939
  if (events.partyInvite?.length) {
@@ -948,9 +946,8 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
948
946
  }
949
947
  // log(player_name, `https://steamcommunity.com/profiles/${sid64}`);
950
948
  // joinLobby(msg.lobbyid, msg.accountid)
951
- break;
952
- }
953
- case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Account_RequestCoPlays: {
949
+ },
950
+ [ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Account_RequestCoPlays]({ appId, msgType, payload }) {
954
951
  callGCCallback({
955
952
  name: gcEvents.requestCoPlays,
956
953
  data() {
@@ -958,9 +955,8 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
958
955
  return msg.players.map((p) => SteamID.fromIndividualAccountID(p.accountid));
959
956
  },
960
957
  });
961
- break;
962
- }
963
- case ESteamProto.EGCBaseClientMsg.k_EMsgGCClientWelcome: {
958
+ },
959
+ [ESteamProto.EGCBaseClientMsg.k_EMsgGCClientWelcome]({ appId, msgType, payload }) {
964
960
  prime = false;
965
961
  const CMsgClientWelcome = new SteamProto(SteamProtoType.CMsgClientWelcome).protoDecode(payload);
966
962
  const obj = {};
@@ -1019,12 +1015,12 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
1019
1015
  }
1020
1016
 
1021
1017
  case 35: {
1022
- // const result =protoDecode(SteamProtoType.CSOSelectedItemPreset, object_data);
1018
+ // const result = protoDecode(SteamProtoType.CSOSelectedItemPreset, object_data);
1023
1019
  break;
1024
1020
  }
1025
1021
 
1026
1022
  case 36: {
1027
- // const result =protoDecode(SteamProtoType.CSOEconItemPresetInstance, object_data);
1023
+ // const result = protoDecode(SteamProtoType.CSOEconItemPresetInstance, object_data);
1028
1024
  break;
1029
1025
  }
1030
1026
  case 38: {
@@ -1044,7 +1040,7 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
1044
1040
  break;
1045
1041
  }
1046
1042
  case 42: {
1047
- // const result =protoDecode(SteamProtoType.CSOEconItemTournamentPassport, object_data);
1043
+ // const result = protoDecode(SteamProtoType.CSOEconItemTournamentPassport, object_data);
1048
1044
  break;
1049
1045
  }
1050
1046
  case 43: {
@@ -1089,13 +1085,13 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
1089
1085
  }
1090
1086
  _clientWelcome = obj;
1091
1087
 
1092
- for (const itemId in items) {
1093
- try {
1094
- if (!obj.personalStore.items.includes(parseInt(itemId))) {
1095
- delete items[itemId];
1096
- }
1097
- } catch (e) {}
1098
- }
1088
+ // for (const itemId in items) {
1089
+ // try {
1090
+ // if (!obj.personalStore.items.includes(parseInt(itemId))) {
1091
+ // delete items[itemId];
1092
+ // }
1093
+ // } catch (e) {}
1094
+ // }
1099
1095
  obj.items = items;
1100
1096
  callEvent(events.csgoOnline, obj);
1101
1097
 
@@ -1109,25 +1105,20 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
1109
1105
  "autoPartyRegister",
1110
1106
  );
1111
1107
  }
1112
- break;
1113
- }
1114
- case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchmakingGC2ClientUpdate: {
1108
+ },
1109
+ [ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchmakingGC2ClientUpdate]({ appId, msgType, payload }) {
1115
1110
  const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_MatchmakingGC2ClientUpdate).protoDecode(payload);
1116
- break;
1117
- }
1118
- case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_GC2ClientGlobalStats: {
1111
+ },
1112
+ [ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_GC2ClientGlobalStats]({ appId, msgType, payload }) {
1119
1113
  const result = new SteamProto(SteamProtoType.CMsgClientUGSGetGlobalStatsResponse).protoDecode(payload);
1120
- break;
1121
- }
1122
- case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientReportPlayer: {
1114
+ },
1115
+ [ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientReportPlayer]({ appId, msgType, payload }) {
1123
1116
  const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientReportPlayer).protoDecode(payload);
1124
- break;
1125
- }
1126
- case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_GC2ClientTextMsg: {
1117
+ },
1118
+ [ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_GC2ClientTextMsg]({ appId, msgType, payload }) {
1127
1119
  const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_GC2ClientTextMsg).protoDecode(payload);
1128
- break;
1129
- }
1130
- case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchmakingGC2ClientHello: {
1120
+ },
1121
+ [ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchmakingGC2ClientHello]({ appId, msgType, payload }) {
1131
1122
  const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_MatchmakingGC2ClientHello).protoDecode(payload);
1132
1123
  const example = {
1133
1124
  my_current_event_teams: [],
@@ -1193,65 +1184,49 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
1193
1184
  }
1194
1185
  _clientHello = result;
1195
1186
  callEvent(events.csgoClientHello, result);
1196
- break;
1197
- }
1198
- case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientReportResponse: {
1187
+ },
1188
+ [ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientReportResponse]({ appId, msgType, payload }) {
1199
1189
  const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientReportResponse).protoDecode(payload);
1200
- break;
1201
- }
1202
- case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientCommendPlayerQueryResponse: {
1190
+ },
1191
+ [ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientCommendPlayerQueryResponse]({ appId, msgType, payload }) {
1203
1192
  const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientCommendPlayer).protoDecode(payload);
1204
- break;
1205
- }
1206
- case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_PlayerOverwatchCaseAssignment: {
1193
+ },
1194
+ [ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_PlayerOverwatchCaseAssignment]({ appId, msgType, payload }) {
1207
1195
  const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_PlayerOverwatchCaseAssignment).protoDecode(payload);
1208
- break;
1209
- }
1210
- case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchList: {
1196
+ },
1197
+ [ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchList]({ appId, msgType, payload }) {
1211
1198
  const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_MatchList).protoDecode(payload);
1212
- break;
1213
- }
1214
- case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_GetEventFavorites_Response: {
1199
+ },
1200
+ [ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_GetEventFavorites_Response]({ appId, msgType, payload }) {
1215
1201
  const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_GetEventFavorites_Response).protoDecode(payload);
1216
- break;
1217
- }
1218
- case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_StartAgreementSessionInGame: {
1219
- break;
1220
- }
1221
- case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_ClientDeepStats: {
1202
+ },
1203
+ [ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_StartAgreementSessionInGame]({ appId, msgType, payload }) {},
1204
+ [ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_ClientDeepStats]({ appId, msgType, payload }) {
1222
1205
  const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_ClientDeepStats).protoDecode(payload);
1223
- break;
1224
- }
1225
- case ESteamProto.EGCBaseClientMsg.k_EMsgGCClientConnectionStatus: {
1206
+ },
1207
+ [ESteamProto.EGCBaseClientMsg.k_EMsgGCClientConnectionStatus]({ appId, msgType, payload }) {
1226
1208
  const result = new SteamProto(SteamProtoType.CMsgConnectionStatus).protoDecode(payload);
1227
- break;
1228
- }
1229
- case ESteamProto.EGCItemMsg.k_EMsgGCStoreGetUserDataResponse: {
1209
+ },
1210
+ [ESteamProto.EGCItemMsg.k_EMsgGCStoreGetUserDataResponse]({ appId, msgType, payload }) {
1230
1211
  const result = new SteamProto(SteamProtoType.CMsgStoreGetUserDataResponse).protoDecode(payload);
1231
- break;
1232
- }
1233
- case ESteamProto.EGCItemMsg.k_EMsgGCStorePurchaseFinalizeResponse: {
1212
+ },
1213
+ [ESteamProto.EGCItemMsg.k_EMsgGCStorePurchaseFinalizeResponse]({ appId, msgType, payload }) {
1234
1214
  const result = new SteamProto(SteamProtoType.CMsgGCStorePurchaseFinalizeResponse).protoDecode(payload);
1235
- break;
1236
- }
1237
- case ESteamProto.EGCItemMsg.k_EMsgGCStorePurchaseCancelResponse: {
1215
+ },
1216
+ [ESteamProto.EGCItemMsg.k_EMsgGCStorePurchaseCancelResponse]({ appId, msgType, payload }) {
1238
1217
  const result = new SteamProto(SteamProtoType.CMsgGCStorePurchaseCancelResponse).protoDecode(payload);
1239
- break;
1240
- }
1241
- case ESteamProto.EGCItemMsg.k_EMsgGCStorePurchaseInitResponse: {
1218
+ },
1219
+ [ESteamProto.EGCItemMsg.k_EMsgGCStorePurchaseInitResponse]({ appId, msgType, payload }) {
1242
1220
  const result = new SteamProto(SteamProtoType.CMsgGCStorePurchaseInitResponse).protoDecode(payload);
1243
- break;
1244
- }
1245
- case ESteamProto.EMsg.k_EMsgClientMMSCreateLobbyResponse: {
1221
+ },
1222
+ [ESteamProto.EMsg.k_EMsgClientMMSCreateLobbyResponse]({ appId, msgType, payload }) {
1246
1223
  const result = new SteamProto(SteamProtoType.CMsgClientMMSCreateLobbyResponse).protoDecode(payload);
1247
- console.log("k_EMsgClientMMSCreateLobbyResponse", result);
1248
- break;
1249
- }
1250
- case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientGCRankUpdate: {
1224
+ log("k_EMsgClientMMSCreateLobbyResponse", result);
1225
+ },
1226
+ [ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientGCRankUpdate]({ appId, msgType, payload }) {
1251
1227
  const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientGCRankUpdate).protoDecode(payload);
1252
- break;
1253
- }
1254
- case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Party_Search: {
1228
+ },
1229
+ [ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Party_Search]({ appId, msgType, payload }) {
1255
1230
  callGCCallback({
1256
1231
  name: gcEvents.partySearch,
1257
1232
  async data() {
@@ -1329,10 +1304,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
1329
1304
  return players;
1330
1305
  },
1331
1306
  });
1332
- break;
1333
- }
1334
- case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_PlayersProfile: {
1335
- let data = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_PlayersProfile).protoDecode(payload)?.account_profiles;
1307
+ },
1308
+ [ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_PlayersProfile]({ appId, msgType, payload }) {
1309
+ const data = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_PlayersProfile).protoDecode(payload)?.account_profiles;
1336
1310
  const dataExample = [
1337
1311
  {
1338
1312
  my_current_event_teams: [],
@@ -1406,9 +1380,8 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
1406
1380
  });
1407
1381
  }
1408
1382
  callEvent(events.playersProfile, player);
1409
- break;
1410
- }
1411
- case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientLogonFatalError: {
1383
+ },
1384
+ [ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientLogonFatalError]({ appId, msgType, payload }) {
1412
1385
  const data = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientLogonFatalError).protoDecode(payload);
1413
1386
  const dataExample = {
1414
1387
  errorcode: 4,
@@ -1416,9 +1389,8 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
1416
1389
  country: "VN",
1417
1390
  };
1418
1391
  callEvent(events.fatalError, data);
1419
- break;
1420
- }
1421
- case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientRequestJoinFriendData: {
1392
+ },
1393
+ [ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientRequestJoinFriendData]({ appId, msgType, payload }) {
1422
1394
  const data = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientRequestJoinFriendData).protoDecode(payload);
1423
1395
  if (!data?.account_id) {
1424
1396
  return;
@@ -1436,20 +1408,75 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
1436
1408
  data,
1437
1409
  key: data.account_id,
1438
1410
  });
1439
- break;
1440
- }
1441
- default:
1442
- log(`receivedFromGC ${msgType} ${key}`);
1443
- const results = Object.values(SteamProtoType)
1444
- .map(function (p) {
1445
- try {
1446
- return new SteamProto(p).protoDecode(payload);
1447
- } catch (e) {}
1448
- })
1449
- .filter(function (result) {
1450
- return result && Object.keys(result).length;
1451
- });
1452
- log(key, results);
1411
+ },
1412
+ [ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientNetworkConfig]({ appId, msgType, payload }) {
1413
+ const data = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientNetworkConfig).protoDecode(payload);
1414
+ let json = null;
1415
+ try {
1416
+ json = JSON.parse(data.data.toString());
1417
+ } catch (e) {}
1418
+ const dataExample = {
1419
+ revision: 1728581583,
1420
+ pops: {
1421
+ ams: {
1422
+ desc: "Amsterdam (Netherlands)",
1423
+ geo: [4.9, 52.37],
1424
+ partners: 1,
1425
+ tier: 1,
1426
+ relays: [
1427
+ {
1428
+ ipv4: "155.133.248.36",
1429
+ port_range: [27015, 27060],
1430
+ },
1431
+ ],
1432
+ },
1433
+ atl: {
1434
+ desc: "Atlanta (Georgia)",
1435
+ geo: [-84.39, 33.76],
1436
+ partners: 1,
1437
+ tier: 1,
1438
+ relays: [
1439
+ {
1440
+ ipv4: "162.254.199.166",
1441
+ port_range: [27015, 27060],
1442
+ },
1443
+ ],
1444
+ },
1445
+ },
1446
+ certs: ["Ii4IARIgSJbwDpn/07/GHiGMKio0Vh18VN3D/hKzQGh6n0Yx9qpFBayqZk0F7rB4KT6tfJIvitz8MkBJbZJixvdiUoHAs+u62Gd9lyGbHPAwHXlt4Ux3OEsXKgAxRK2wTcKoPWzjcHoKWHW8jpCT2k3YEDnx1HRLb3UO"],
1447
+ p2p_share_ip: {
1448
+ cn: 20,
1449
+ default: 40,
1450
+ ru: 20,
1451
+ },
1452
+ relay_public_key: "5AC884C1045BA0FF44142AC8DCA51B8A98C8F1CB4FEE36284AFBE92FCF594932",
1453
+ revoked_keys: ["11146342570456886677"],
1454
+ typical_pings: [
1455
+ ["ams", "fra", 6],
1456
+ ["vie", "waw", 10],
1457
+ ],
1458
+ success: true,
1459
+ };
1460
+ },
1461
+ };
1462
+
1463
+ if (typeof handleGC[msgType] === "function") {
1464
+ try {
1465
+ await handleGC[msgType]({ appId, msgType, payload });
1466
+ } catch (e) {}
1467
+ } else {
1468
+ log(`receivedFromGC ${msgType} ${key}`);
1469
+ const results = Object.values(SteamProtoType)
1470
+ .map(function (p) {
1471
+ try {
1472
+ return new SteamProto(p).protoDecode(payload);
1473
+ } catch (e) {}
1474
+ })
1475
+ .filter(function (result) {
1476
+ return result && Object.keys(result).length;
1477
+ });
1478
+ log(key, results);
1479
+ results;
1453
1480
  }
1454
1481
  },
1455
1482
  async loggedOn(loggedOnResponse) {
@@ -2139,7 +2166,34 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
2139
2166
 
2140
2167
  if (steamClient) {
2141
2168
  steamClient.logOff();
2142
- await sleep(30000);
2169
+
2170
+ steamClient.limitations = null;
2171
+ steamClient.vac = null;
2172
+ steamClient.wallet = null;
2173
+ steamClient.emailInfo = null;
2174
+ steamClient.licenses = null;
2175
+ steamClient.gifts = null;
2176
+
2177
+ // Friends and users info
2178
+ steamClient.users = {};
2179
+ steamClient.groups = {};
2180
+ steamClient.chats = {};
2181
+ steamClient.myFriends = {};
2182
+ steamClient.myGroups = {};
2183
+ steamClient.myFriendGroups = {};
2184
+ steamClient.myNicknames = {};
2185
+ steamClient.steamServers = {};
2186
+ steamClient.playingState = { blocked: false, appid: 0 };
2187
+ steamClient._playingBlocked = false;
2188
+ steamClient._playingAppIds = [];
2189
+
2190
+ steamClient._gcTokens = []; // game connect tokens
2191
+ steamClient._activeAuthTickets = [];
2192
+ steamClient._contentServerCache = {};
2193
+ steamClient._contentServerTokens = {};
2194
+ steamClient._lastNotificationCounts = {};
2195
+ steamClient._richPresenceLocalization = {};
2196
+ steamClient._incomingMessageQueue = [];
2143
2197
 
2144
2198
  function cleanSteamClient(obj, key) {
2145
2199
  const value = obj[key];
@@ -2175,9 +2229,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
2175
2229
  }
2176
2230
  }
2177
2231
 
2178
- for (const key in steamClient) {
2179
- cleanSteamClient(steamClient, key);
2180
- }
2232
+ // for (const key in steamClient) {
2233
+ // cleanSteamClient(steamClient, key);
2234
+ // }
2181
2235
  steamClient = null;
2182
2236
  }
2183
2237
  }