steamutils 1.4.35 → 1.4.36
Sign up to get free protection for your applications and to get access to all the features.
- package/SteamClient.js +160 -169
- package/_steamproto.js +29 -0
- package/create_proto.js +47 -0
- package/helpers/protos.js +52 -54
- package/package.json +1 -1
- package/steamproto.js +6159 -0
package/SteamClient.js
CHANGED
@@ -1,28 +1,15 @@
|
|
1
1
|
import NodeSteamUser from "steam-user";
|
2
2
|
import _ from "lodash";
|
3
|
-
import fs from "fs";
|
4
|
-
import { protoDecode, protoEncode } from "./helpers/util.js";
|
5
3
|
import SteamID from "steamid";
|
6
4
|
import FriendCode from "csgo-friendcode";
|
7
5
|
import axios from "axios";
|
8
|
-
import helpers, { loadProfos } from "./helpers/protos.js";
|
9
|
-
import { fileURLToPath } from "url";
|
10
|
-
import path from "path";
|
11
6
|
import SteamUser from "./index.js";
|
12
7
|
import { v4 as uuidv4 } from "uuid";
|
13
8
|
import EFriendRelationship from "steam-user/enums/EFriendRelationship.js";
|
14
9
|
import SteamCommunity from "steamcommunity";
|
15
10
|
import moment from "moment-timezone";
|
16
11
|
import { encode, encodeUids } from "./bufferHelpers.js";
|
17
|
-
|
18
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
19
|
-
|
20
|
-
const Protos = helpers([
|
21
|
-
{
|
22
|
-
name: "csgo",
|
23
|
-
protos: loadProfos(`${__dirname}/protos/`),
|
24
|
-
},
|
25
|
-
]);
|
12
|
+
import { ESteamProto, SteamProto, SteamProtoType } from "./steamproto.js";
|
26
13
|
|
27
14
|
export const RANKS = {
|
28
15
|
0: "Unranked",
|
@@ -81,6 +68,29 @@ SteamUser.getAppVersion(AppID).then(function (ver) {
|
|
81
68
|
CSGO_VER = ver;
|
82
69
|
});
|
83
70
|
|
71
|
+
export const SteamClientEvents = {
|
72
|
+
user: "user",
|
73
|
+
loggedOn: "loggedOn",
|
74
|
+
csgoOnline: "csgoOnline",
|
75
|
+
csgoClientHello: "csgoClientHello",
|
76
|
+
webSession: "webSession",
|
77
|
+
friendMessage: "friendMessage",
|
78
|
+
friendTyping: "friendTyping",
|
79
|
+
disconnected: "disconnected",
|
80
|
+
error: "error",
|
81
|
+
playersProfile: "playersProfile",
|
82
|
+
fatalError: "fatalError",
|
83
|
+
partyInvite: "partyInvite",
|
84
|
+
friendRelationship: "friendRelationship",
|
85
|
+
tradeOffers: "tradeOffers",
|
86
|
+
offlineMessages: "offlineMessages",
|
87
|
+
friendsList: "friendsList",
|
88
|
+
gifts: "gifts",
|
89
|
+
playingState: "playingState",
|
90
|
+
emailInfo: "emailInfo",
|
91
|
+
accountLimitations: "accountLimitations",
|
92
|
+
wallet: "wallet",
|
93
|
+
};
|
84
94
|
const PersonasCache = [];
|
85
95
|
let isSendingFriendMessages = false;
|
86
96
|
|
@@ -106,29 +116,10 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
106
116
|
|
107
117
|
const onAnyCallbacks = [];
|
108
118
|
|
109
|
-
const events = {
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
csgoClientHello: [],
|
114
|
-
webSession: [],
|
115
|
-
friendMessage: [],
|
116
|
-
friendTyping: [],
|
117
|
-
disconnected: [],
|
118
|
-
error: [],
|
119
|
-
playersProfile: [],
|
120
|
-
fatalError: [],
|
121
|
-
partyInvite: [],
|
122
|
-
friendRelationship: [],
|
123
|
-
tradeOffers: [],
|
124
|
-
offlineMessages: [],
|
125
|
-
friendsList: [],
|
126
|
-
gifts: [],
|
127
|
-
playingState: [],
|
128
|
-
emailInfo: [],
|
129
|
-
accountLimitations: [],
|
130
|
-
wallet: [],
|
131
|
-
};
|
119
|
+
const events = { ...SteamClientEvents };
|
120
|
+
for (const name in SteamClientEvents) {
|
121
|
+
events[name] = [];
|
122
|
+
}
|
132
123
|
|
133
124
|
const gcCallback = {};
|
134
125
|
|
@@ -393,9 +384,9 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
393
384
|
const players = await new Promise((resolve) => {
|
394
385
|
steamClient.sendToGC(
|
395
386
|
AppID,
|
396
|
-
|
387
|
+
ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Party_Search,
|
397
388
|
{},
|
398
|
-
|
389
|
+
new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_Party_Search).protoEncode({
|
399
390
|
ver: CSGO_VER,
|
400
391
|
apr: prime ? 1 : 0,
|
401
392
|
ark: parseInt(Object.keys(RANKS).find((k) => RANKS[k] === rank)) * 10,
|
@@ -432,13 +423,13 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
432
423
|
|
433
424
|
steamClient._send(
|
434
425
|
{
|
435
|
-
msg:
|
426
|
+
msg: ESteamProto.EMsg.k_EMsgClientMMSCreateLobby,
|
436
427
|
proto: {
|
437
428
|
steamid: steamClient.steamID.getSteamID64(),
|
438
429
|
routing_appid: 730,
|
439
430
|
},
|
440
431
|
},
|
441
|
-
|
432
|
+
new SteamProto(SteamProtoType.CMsgClientMMSCreateLobby).protoEncode({
|
442
433
|
app_id: 730,
|
443
434
|
max_members: 1,
|
444
435
|
lobby_type: 1,
|
@@ -446,7 +437,7 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
446
437
|
}),
|
447
438
|
function (payload) {
|
448
439
|
clearTimeout(timeout);
|
449
|
-
const result =
|
440
|
+
const result = new SteamProto(SteamProtoType.CMsgClientMMSCreateLobbyResponse).protoEncode(payload.toBuffer());
|
450
441
|
const steam_id_lobby = result.steam_id_lobby.toString();
|
451
442
|
currentLobby.lobbyID = steam_id_lobby;
|
452
443
|
currentLobby.timestamp = Date.now();
|
@@ -455,15 +446,15 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
455
446
|
);
|
456
447
|
});
|
457
448
|
|
458
|
-
// return await getHandlerResult(
|
459
|
-
// const result = protoDecode(
|
449
|
+
// return await getHandlerResult(ESteamProto.EMsg.k_EMsgClientMMSCreateLobbyResponse, function (payload) {
|
450
|
+
// const result = protoDecode(SteamProtoType.CMsgClientMMSCreateLobbyResponse, payload.toBuffer())
|
460
451
|
// return result.steam_id_lobby.toString()
|
461
452
|
// })
|
462
453
|
|
463
|
-
// steamClient.sendToGC(730,
|
454
|
+
// steamClient.sendToGC(730, ESteamProto.EMsg.k_EMsgClientMMSCreateLobby, {
|
464
455
|
// steamid: steamClient.steamID,
|
465
456
|
// routing_appid: 730,
|
466
|
-
// }, protoEncode(
|
457
|
+
// }, protoEncode(SteamProtoType.CMsgClientMMSCreateLobby, {
|
467
458
|
// app_id: 730,
|
468
459
|
// max_members: 1,
|
469
460
|
// lobby_type: 1,
|
@@ -483,13 +474,13 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
483
474
|
|
484
475
|
steamClient._send(
|
485
476
|
{
|
486
|
-
msg:
|
477
|
+
msg: ESteamProto.EMsg.k_EMsgClientMMSSetLobbyData,
|
487
478
|
proto: {
|
488
479
|
steamid: steamClient.steamID.getSteamID64(),
|
489
480
|
routing_appid: 730,
|
490
481
|
},
|
491
482
|
},
|
492
|
-
|
483
|
+
new SteamProto(SteamProtoType.CMsgClientMMSSetLobbyData).protoEncode({
|
493
484
|
app_id: 730,
|
494
485
|
steam_id_lobby: lobbyID,
|
495
486
|
steam_id_member: "0",
|
@@ -519,7 +510,7 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
519
510
|
}),
|
520
511
|
function (payload) {
|
521
512
|
clearTimeout(timeout);
|
522
|
-
const result =
|
513
|
+
const result = new SteamProto(SteamProtoType.CMsgClientMMSSetLobbyDataResponse).protoDecode(payload.toBuffer());
|
523
514
|
const steam_id_lobby = result.steam_id_lobby.toString();
|
524
515
|
currentLobby.lobbyID = steam_id_lobby;
|
525
516
|
currentLobby.timestamp = Date.now();
|
@@ -528,8 +519,8 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
528
519
|
);
|
529
520
|
});
|
530
521
|
|
531
|
-
// return await getHandlerResult(
|
532
|
-
// const result = protoDecode(
|
522
|
+
// return await getHandlerResult(ESteamProto.EMsg.k_EMsgClientMMSSetLobbyDataResponse, function (payload) {
|
523
|
+
// const result = protoDecode(SteamProtoType.CMsgClientMMSSetLobbyDataResponse, payload.toBuffer())
|
533
524
|
// return result.steam_id_lobby.toString()
|
534
525
|
// })
|
535
526
|
}
|
@@ -541,13 +532,13 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
541
532
|
|
542
533
|
steamClient._send(
|
543
534
|
{
|
544
|
-
msg:
|
535
|
+
msg: ESteamProto.EMsg.k_EMsgClientMMSInviteToLobby,
|
545
536
|
proto: {
|
546
537
|
steamid: steamClient.steamID.getSteamID64(),
|
547
538
|
routing_appid: 730,
|
548
539
|
},
|
549
540
|
},
|
550
|
-
|
541
|
+
new SteamProto(SteamProtoType.CMsgClientMMSInviteToLobby).protoEncode({
|
551
542
|
app_id: 730,
|
552
543
|
steam_id_lobby: lobbyID,
|
553
544
|
steam_id_user_invited: steamId,
|
@@ -556,9 +547,9 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
556
547
|
|
557
548
|
// lobbyID = new SteamID(lobbyID).accountid;
|
558
549
|
|
559
|
-
//
|
560
|
-
//
|
561
|
-
// steamClient.sendToGC(730,
|
550
|
+
// ESteamProto.EMsg.k_EMsgGCHInviteUserToLobby
|
551
|
+
// ESteamProto.EMsg.k_EMsgClientMMSInviteToLobby
|
552
|
+
// steamClient.sendToGC(730, ESteamProto.EMsg.k_EMsgClientMMSInviteToLobby, {}, protoEncode(SteamProtoType.CMsgClientMMSInviteToLobby, {
|
562
553
|
// app_id: 730,
|
563
554
|
// steam_id_lobby: lobbyID,
|
564
555
|
// steam_id_user_invited: accountid,
|
@@ -605,19 +596,19 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
605
596
|
|
606
597
|
steamClient._send(
|
607
598
|
{
|
608
|
-
msg:
|
599
|
+
msg: ESteamProto.EMsg.k_EMsgClientMMSGetLobbyData,
|
609
600
|
proto: {
|
610
601
|
steamid: steamClient.steamID.getSteamID64(),
|
611
602
|
routing_appid: 730,
|
612
603
|
},
|
613
604
|
},
|
614
|
-
|
605
|
+
new SteamProto(SteamProtoType.CMsgClientMMSGetLobbyData).protoEncode({
|
615
606
|
app_id: 730,
|
616
607
|
steam_id_lobby: lobbyID.toString(),
|
617
608
|
}),
|
618
609
|
function (payload) {
|
619
610
|
clearTimeout(timeout);
|
620
|
-
const result =
|
611
|
+
const result = new SteamProto(SteamProtoType.CMsgClientMMSLobbyData).protoDecode(payload.toBuffer());
|
621
612
|
result.steam_id_lobby = result.steam_id_lobby.toString();
|
622
613
|
resolve(result);
|
623
614
|
},
|
@@ -630,19 +621,19 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
630
621
|
|
631
622
|
steamClient._send(
|
632
623
|
{
|
633
|
-
msg:
|
624
|
+
msg: ESteamProto.EMsg.k_EMsgClientMMSJoinLobby,
|
634
625
|
proto: {
|
635
626
|
steamid: steamClient.steamID.getSteamID64(),
|
636
627
|
routing_appid: 730,
|
637
628
|
},
|
638
629
|
}, //CMsgClientMMSUserJoinedLobby CMsgClientMMSJoinLobby
|
639
|
-
|
630
|
+
new SteamProto(SteamProtoType.CMsgClientMMSJoinLobby).protoEncode({
|
640
631
|
app_id: 730,
|
641
632
|
steam_id_lobby: lobbyID,
|
642
633
|
persona_name: steamClient.accountInfo.name,
|
643
634
|
}),
|
644
635
|
function (payload) {
|
645
|
-
const result =
|
636
|
+
const result = new SteamProto(SteamProtoType.CMsgClientMMSJoinLobbyResponse).protoDecode(payload.toBuffer());
|
646
637
|
result.steam_id_lobby = result.steam_id_lobby.toString();
|
647
638
|
result.steam_id_owner = result.steam_id_owner.toString();
|
648
639
|
console.log(result);
|
@@ -662,14 +653,14 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
662
653
|
}
|
663
654
|
|
664
655
|
async function sendHello() {
|
665
|
-
steamClient.sendToGC(AppID,
|
666
|
-
// steamClient.sendToGC(AppID,
|
656
|
+
steamClient.sendToGC(AppID, ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchmakingClient2GCHello, {}, Buffer.alloc(0));
|
657
|
+
// steamClient.sendToGC(AppID, ESteamProto.EGCBaseClientMsg.k_EMsgGCClientHello, {}, Buffer.alloc(0));
|
667
658
|
|
668
659
|
steamClient.sendToGC(
|
669
660
|
AppID,
|
670
|
-
|
661
|
+
ESteamProto.EGCBaseClientMsg.k_EMsgGCClientHello,
|
671
662
|
{},
|
672
|
-
|
663
|
+
new SteamProto(SteamProtoType.CMsgClientHello).protoEncode({
|
673
664
|
version: 2000258, //get from https://github.com/SteamDatabase/GameTracking-CS2/commits
|
674
665
|
client_session_need: 0,
|
675
666
|
client_launcher: 0,
|
@@ -680,7 +671,7 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
680
671
|
|
681
672
|
async function requestCoPlays() {
|
682
673
|
return new Promise((resolve) => {
|
683
|
-
steamClient.sendToGC(AppID,
|
674
|
+
steamClient.sendToGC(AppID, ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Account_RequestCoPlays, {}, Buffer.alloc(0));
|
684
675
|
pushGCCallback("RequestCoPlays", resolve, 30000);
|
685
676
|
});
|
686
677
|
}
|
@@ -705,7 +696,7 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
705
696
|
const isSuccess = await login(true);
|
706
697
|
if (isSuccess) {
|
707
698
|
const loggedOnResponse = await new Promise((resolve) => {
|
708
|
-
onEvent(
|
699
|
+
onEvent(SteamClientEvents.loggedOn, resolve, true, 180000);
|
709
700
|
});
|
710
701
|
if (loggedOnResponse) {
|
711
702
|
console.log("Relogin success");
|
@@ -787,17 +778,17 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
787
778
|
async receivedFromGC(appid, msgType, payload) {
|
788
779
|
const key = getECsgoGCMsgKey(msgType);
|
789
780
|
switch (msgType) {
|
790
|
-
case
|
781
|
+
case ESteamProto.EMsg.k_EMsgClientChatInvite: {
|
791
782
|
log(payload);
|
792
783
|
break;
|
793
784
|
}
|
794
|
-
case
|
795
|
-
const msg =
|
785
|
+
case ESteamProto.ECsgoGCMsg.k_EMsgClientMMSJoinLobbyResponse: {
|
786
|
+
const msg = new SteamProto(SteamProtoType.CMsgClientMMSJoinLobbyResponse).protoDecode(payload);
|
796
787
|
log(msg);
|
797
788
|
break;
|
798
789
|
}
|
799
|
-
case
|
800
|
-
const msg =
|
790
|
+
case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Party_Invite: {
|
791
|
+
const msg = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_Party_Invite).protoDecode(payload);
|
801
792
|
const sid64 = SteamID.fromIndividualAccountID(msg.accountid).getSteamID64();
|
802
793
|
if (events.partyInvite?.length) {
|
803
794
|
const personas = await getPersonas([sid64]);
|
@@ -811,22 +802,22 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
811
802
|
// joinLobby(msg.lobbyid, msg.accountid)
|
812
803
|
break;
|
813
804
|
}
|
814
|
-
case
|
815
|
-
const msg =
|
805
|
+
case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Account_RequestCoPlays: {
|
806
|
+
const msg = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_Account_RequestCoPlays).protoDecode(payload);
|
816
807
|
const personas = msg.players.map((p) => SteamID.fromIndividualAccountID(p.accountid));
|
817
808
|
callGCCallback("RequestCoPlays", personas);
|
818
809
|
break;
|
819
810
|
}
|
820
|
-
case
|
811
|
+
case ESteamProto.EGCBaseClientMsg.k_EMsgGCClientWelcome: {
|
821
812
|
prime = false;
|
822
|
-
const CMsgClientWelcome =
|
813
|
+
const CMsgClientWelcome = new SteamProto(SteamProtoType.CMsgClientWelcome).protoDecode(payload);
|
823
814
|
const obj = {};
|
824
815
|
for (const outofdate_cache of CMsgClientWelcome.outofdate_subscribed_caches) {
|
825
816
|
for (const cache_object of outofdate_cache.objects) {
|
826
817
|
for (const object_data of cache_object.object_data) {
|
827
818
|
switch (cache_object.type_id) {
|
828
819
|
case 1: {
|
829
|
-
const result =
|
820
|
+
const result = new SteamProto(SteamProtoType.CSOEconItem).protoDecode(object_data);
|
830
821
|
result.id = result.id.toNumber();
|
831
822
|
result.original_id = result.original_id.toNumber();
|
832
823
|
if (!obj.items) {
|
@@ -836,7 +827,7 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
836
827
|
break;
|
837
828
|
}
|
838
829
|
case 2: {
|
839
|
-
const result =
|
830
|
+
const result = new SteamProto(SteamProtoType.CSOPersonaDataPublic).protoDecode(object_data);
|
840
831
|
obj.PersonaDataPublic = result;
|
841
832
|
const example = {
|
842
833
|
player_level: 4, //CSGO_Profile_Rank
|
@@ -850,11 +841,11 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
850
841
|
break;
|
851
842
|
}
|
852
843
|
case 5: {
|
853
|
-
const result =
|
844
|
+
const result = new SteamProto(SteamProtoType.CSOItemRecipe).protoDecode(object_data);
|
854
845
|
break;
|
855
846
|
}
|
856
847
|
case 7: {
|
857
|
-
const CSOEconGameAccountClient =
|
848
|
+
const CSOEconGameAccountClient = new SteamProto(SteamProtoType.CSOEconGameAccountClient).protoDecode(object_data);
|
858
849
|
const CSOEconGameAccountClientExample = {
|
859
850
|
additional_backpack_slots: 0,
|
860
851
|
bonus_xp_timestamp_refresh: 1688518800, //Wednesday 1:00:00 AM every week
|
@@ -879,36 +870,36 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
879
870
|
}
|
880
871
|
|
881
872
|
case 35: {
|
882
|
-
// const result =protoDecode(
|
873
|
+
// const result =protoDecode(SteamProtoType.CSOSelectedItemPreset, object_data);
|
883
874
|
break;
|
884
875
|
}
|
885
876
|
|
886
877
|
case 36: {
|
887
|
-
// const result =protoDecode(
|
878
|
+
// const result =protoDecode(SteamProtoType.CSOEconItemPresetInstance, object_data);
|
888
879
|
break;
|
889
880
|
}
|
890
881
|
case 38: {
|
891
|
-
const result =
|
882
|
+
const result = new SteamProto(SteamProtoType.CSOEconItemDropRateBonus).protoDecode(object_data);
|
892
883
|
break;
|
893
884
|
}
|
894
885
|
case 39: {
|
895
|
-
const result =
|
886
|
+
const result = new SteamProto(SteamProtoType.CSOEconItemLeagueViewPass).protoDecode(object_data);
|
896
887
|
break;
|
897
888
|
}
|
898
889
|
case 40: {
|
899
|
-
const result =
|
890
|
+
const result = new SteamProto(SteamProtoType.CSOEconItemEventTicket).protoDecode(object_data);
|
900
891
|
break;
|
901
892
|
}
|
902
893
|
case 41: {
|
903
|
-
const result =
|
894
|
+
const result = new SteamProto(SteamProtoType.CSOAccountSeasonalOperation).protoDecode(object_data);
|
904
895
|
break;
|
905
896
|
}
|
906
897
|
case 42: {
|
907
|
-
// const result =protoDecode(
|
898
|
+
// const result =protoDecode(SteamProtoType.CSOEconItemTournamentPassport, object_data);
|
908
899
|
break;
|
909
900
|
}
|
910
901
|
case 43: {
|
911
|
-
const result =
|
902
|
+
const result = new SteamProto(SteamProtoType.CSOEconDefaultEquippedDefinitionInstanceClient).protoDecode(object_data);
|
912
903
|
const example = {
|
913
904
|
account_id: 1080136620,
|
914
905
|
item_definition: 61,
|
@@ -918,15 +909,15 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
918
909
|
break;
|
919
910
|
}
|
920
911
|
case 45: {
|
921
|
-
const result =
|
912
|
+
const result = new SteamProto(SteamProtoType.CSOEconCoupon).protoDecode(object_data);
|
922
913
|
break;
|
923
914
|
}
|
924
915
|
case 46: {
|
925
|
-
const result =
|
916
|
+
const result = new SteamProto(SteamProtoType.CSOQuestProgress).protoDecode(object_data);
|
926
917
|
break;
|
927
918
|
}
|
928
919
|
case 4: {
|
929
|
-
const result =
|
920
|
+
const result = new SteamProto(SteamProtoType.CSOAccountItemPersonalStore).protoDecode(object_data);
|
930
921
|
result.generation_time = result.generation_time * 1000;
|
931
922
|
if (Array.isArray(result.items)) {
|
932
923
|
result.items = result.items.map((item) => item.toNumber());
|
@@ -962,24 +953,24 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
962
953
|
}
|
963
954
|
break;
|
964
955
|
}
|
965
|
-
case
|
966
|
-
const result =
|
956
|
+
case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchmakingGC2ClientUpdate: {
|
957
|
+
const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_MatchmakingGC2ClientUpdate).protoDecode(payload);
|
967
958
|
break;
|
968
959
|
}
|
969
|
-
case
|
970
|
-
const result =
|
960
|
+
case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_GC2ClientGlobalStats: {
|
961
|
+
const result = new SteamProto(SteamProtoType.CMsgClientUGSGetGlobalStatsResponse).protoDecode(payload);
|
971
962
|
break;
|
972
963
|
}
|
973
|
-
case
|
974
|
-
const result =
|
964
|
+
case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientReportPlayer: {
|
965
|
+
const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientReportPlayer).protoDecode(payload);
|
975
966
|
break;
|
976
967
|
}
|
977
|
-
case
|
978
|
-
const result =
|
968
|
+
case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_GC2ClientTextMsg: {
|
969
|
+
const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_GC2ClientTextMsg).protoDecode(payload);
|
979
970
|
break;
|
980
971
|
}
|
981
|
-
case
|
982
|
-
const result =
|
972
|
+
case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchmakingGC2ClientHello: {
|
973
|
+
const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_MatchmakingGC2ClientHello).protoDecode(payload);
|
983
974
|
const example = {
|
984
975
|
my_current_event_teams: [],
|
985
976
|
my_current_event_stages: [],
|
@@ -1046,64 +1037,64 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
1046
1037
|
callEvent(events.csgoClientHello, result);
|
1047
1038
|
break;
|
1048
1039
|
}
|
1049
|
-
case
|
1050
|
-
const result =
|
1040
|
+
case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientReportResponse: {
|
1041
|
+
const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientReportResponse).protoDecode(payload);
|
1051
1042
|
break;
|
1052
1043
|
}
|
1053
|
-
case
|
1054
|
-
const result =
|
1044
|
+
case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientCommendPlayerQueryResponse: {
|
1045
|
+
const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientCommendPlayer).protoDecode(payload);
|
1055
1046
|
break;
|
1056
1047
|
}
|
1057
|
-
case
|
1058
|
-
const result =
|
1048
|
+
case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_PlayerOverwatchCaseAssignment: {
|
1049
|
+
const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_PlayerOverwatchCaseAssignment).protoDecode(payload);
|
1059
1050
|
break;
|
1060
1051
|
}
|
1061
|
-
case
|
1062
|
-
const result =
|
1052
|
+
case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchList: {
|
1053
|
+
const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_MatchList).protoDecode(payload);
|
1063
1054
|
break;
|
1064
1055
|
}
|
1065
|
-
case
|
1066
|
-
const result =
|
1056
|
+
case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_GetEventFavorites_Response: {
|
1057
|
+
const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_GetEventFavorites_Response).protoDecode(payload);
|
1067
1058
|
break;
|
1068
1059
|
}
|
1069
|
-
case
|
1060
|
+
case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_StartAgreementSessionInGame: {
|
1070
1061
|
break;
|
1071
1062
|
}
|
1072
|
-
case
|
1073
|
-
const result =
|
1063
|
+
case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_ClientDeepStats: {
|
1064
|
+
const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_ClientDeepStats).protoDecode(payload);
|
1074
1065
|
break;
|
1075
1066
|
}
|
1076
|
-
case
|
1077
|
-
const result =
|
1067
|
+
case ESteamProto.EGCBaseClientMsg.k_EMsgGCClientConnectionStatus: {
|
1068
|
+
const result = new SteamProto(SteamProtoType.CMsgConnectionStatus).protoDecode(payload);
|
1078
1069
|
break;
|
1079
1070
|
}
|
1080
|
-
case
|
1081
|
-
const result =
|
1071
|
+
case ESteamProto.EGCItemMsg.k_EMsgGCStoreGetUserDataResponse: {
|
1072
|
+
const result = new SteamProto(SteamProtoType.CMsgStoreGetUserDataResponse).protoDecode(payload);
|
1082
1073
|
break;
|
1083
1074
|
}
|
1084
|
-
case
|
1085
|
-
const result =
|
1075
|
+
case ESteamProto.EGCItemMsg.k_EMsgGCStorePurchaseFinalizeResponse: {
|
1076
|
+
const result = new SteamProto(SteamProtoType.CMsgGCStorePurchaseFinalizeResponse).protoDecode(payload);
|
1086
1077
|
break;
|
1087
1078
|
}
|
1088
|
-
case
|
1089
|
-
const result =
|
1079
|
+
case ESteamProto.EGCItemMsg.k_EMsgGCStorePurchaseCancelResponse: {
|
1080
|
+
const result = new SteamProto(SteamProtoType.CMsgGCStorePurchaseCancelResponse).protoDecode(payload);
|
1090
1081
|
break;
|
1091
1082
|
}
|
1092
|
-
case
|
1093
|
-
const result =
|
1083
|
+
case ESteamProto.EGCItemMsg.k_EMsgGCStorePurchaseInitResponse: {
|
1084
|
+
const result = new SteamProto(SteamProtoType.CMsgGCStorePurchaseInitResponse).protoDecode(payload);
|
1094
1085
|
break;
|
1095
1086
|
}
|
1096
|
-
case
|
1097
|
-
const result =
|
1087
|
+
case ESteamProto.EMsg.k_EMsgClientMMSCreateLobbyResponse: {
|
1088
|
+
const result = new SteamProto(SteamProtoType.CMsgClientMMSCreateLobbyResponse).protoDecode(payload);
|
1098
1089
|
console.log("k_EMsgClientMMSCreateLobbyResponse", result);
|
1099
1090
|
break;
|
1100
1091
|
}
|
1101
|
-
case
|
1102
|
-
const result =
|
1092
|
+
case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientGCRankUpdate: {
|
1093
|
+
const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientGCRankUpdate).protoDecode(payload);
|
1103
1094
|
break;
|
1104
1095
|
}
|
1105
|
-
case
|
1106
|
-
const result =
|
1096
|
+
case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Party_Search: {
|
1097
|
+
const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_Party_SearchResults).protoDecode(payload);
|
1107
1098
|
const entries = _.uniqBy(result.entries, "id");
|
1108
1099
|
//{
|
1109
1100
|
// id: 144900402,
|
@@ -1175,8 +1166,8 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
1175
1166
|
callGCCallback("partySearch", players);
|
1176
1167
|
break;
|
1177
1168
|
}
|
1178
|
-
case
|
1179
|
-
let data =
|
1169
|
+
case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_PlayersProfile: {
|
1170
|
+
let data = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_PlayersProfile).protoDecode(payload)?.account_profiles;
|
1180
1171
|
const dataExample = [
|
1181
1172
|
{
|
1182
1173
|
my_current_event_teams: [],
|
@@ -1248,8 +1239,8 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
1248
1239
|
callEvent(events.playersProfile, player);
|
1249
1240
|
break;
|
1250
1241
|
}
|
1251
|
-
case
|
1252
|
-
const data =
|
1242
|
+
case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientLogonFatalError: {
|
1243
|
+
const data = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientLogonFatalError).protoDecode(payload);
|
1253
1244
|
const dataExample = {
|
1254
1245
|
errorcode: 4,
|
1255
1246
|
message: "",
|
@@ -1258,8 +1249,8 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
1258
1249
|
callEvent(events.fatalError, data);
|
1259
1250
|
break;
|
1260
1251
|
}
|
1261
|
-
case
|
1262
|
-
const data =
|
1252
|
+
case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientRequestJoinFriendData: {
|
1253
|
+
const data = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientRequestJoinFriendData).protoDecode(payload);
|
1263
1254
|
if (!data?.account_id) {
|
1264
1255
|
return;
|
1265
1256
|
}
|
@@ -1276,10 +1267,10 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
1276
1267
|
}
|
1277
1268
|
default:
|
1278
1269
|
log(`receivedFromGC ${msgType} ${key}`);
|
1279
|
-
const results = Object.values(
|
1270
|
+
const results = Object.values(SteamProtoType)
|
1280
1271
|
.map(function (p) {
|
1281
1272
|
try {
|
1282
|
-
return protoDecode(
|
1273
|
+
return new SteamProto(p).protoDecode(payload);
|
1283
1274
|
} catch (e) {}
|
1284
1275
|
})
|
1285
1276
|
.filter(function (result) {
|
@@ -1534,23 +1525,23 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
1534
1525
|
// });
|
1535
1526
|
|
1536
1527
|
function getECsgoGCMsgKey(_key) {
|
1537
|
-
for (let key in
|
1538
|
-
if (
|
1528
|
+
for (let key in ESteamProto.ECsgoGCMsg) {
|
1529
|
+
if (ESteamProto.ECsgoGCMsg[key] == _key) {
|
1539
1530
|
return key;
|
1540
1531
|
}
|
1541
1532
|
}
|
1542
|
-
for (let key in
|
1543
|
-
if (
|
1533
|
+
for (let key in ESteamProto.EGCBaseClientMsg) {
|
1534
|
+
if (ESteamProto.EGCBaseClientMsg[key] == _key) {
|
1544
1535
|
return key;
|
1545
1536
|
}
|
1546
1537
|
}
|
1547
|
-
for (let key in
|
1548
|
-
if (
|
1538
|
+
for (let key in ESteamProto.EMsg) {
|
1539
|
+
if (ESteamProto.EMsg[key] == _key) {
|
1549
1540
|
return key;
|
1550
1541
|
}
|
1551
1542
|
}
|
1552
|
-
for (let key in
|
1553
|
-
if (
|
1543
|
+
for (let key in ESteamProto.EGCItemMsg) {
|
1544
|
+
if (ESteamProto.EGCItemMsg[key] == _key) {
|
1554
1545
|
return key;
|
1555
1546
|
}
|
1556
1547
|
}
|
@@ -1606,9 +1597,9 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
1606
1597
|
const accountid = new SteamID(steamId).accountid;
|
1607
1598
|
steamClient.sendToGC(
|
1608
1599
|
730,
|
1609
|
-
|
1600
|
+
ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientRequestPlayersProfile,
|
1610
1601
|
{},
|
1611
|
-
|
1602
|
+
new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientRequestPlayersProfile).protoEncode({
|
1612
1603
|
account_id: accountid, // account_id: new SteamID('76561199184696945').accountid,
|
1613
1604
|
request_level: 32,
|
1614
1605
|
}),
|
@@ -1794,12 +1785,12 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
1794
1785
|
async function init() {
|
1795
1786
|
bindEvent();
|
1796
1787
|
if (await login()) {
|
1797
|
-
steamClient._handlerManager.add(
|
1798
|
-
const result =
|
1788
|
+
steamClient._handlerManager.add(ESteamProto.EMsg.k_EMsgClientRequestedClientStats, function (payload) {
|
1789
|
+
const result = new SteamProto(SteamProtoType.CMsgClientRequestedClientStats).protoDecode(payload.toBuffer());
|
1799
1790
|
// console.log("CMsgClientRequestedClientStats", result);
|
1800
1791
|
});
|
1801
|
-
steamClient._handlerManager.add(
|
1802
|
-
const result =
|
1792
|
+
steamClient._handlerManager.add(ESteamProto.EMsg.k_EMsgClientMMSLobbyData, function (payload) {
|
1793
|
+
const result = new SteamProto(SteamProtoType.CMsgClientMMSLobbyData).protoDecode(payload.toBuffer());
|
1803
1794
|
// console.log("CMsgClientMMSLobbyData", result, result.metadata);
|
1804
1795
|
});
|
1805
1796
|
}
|
@@ -1819,9 +1810,9 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
1819
1810
|
lastTimePartyRegister = Date.now();
|
1820
1811
|
steamClient.sendToGC(
|
1821
1812
|
730,
|
1822
|
-
|
1813
|
+
ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Party_Register,
|
1823
1814
|
{},
|
1824
|
-
|
1815
|
+
new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_Party_Register).protoEncode({
|
1825
1816
|
// id : 0,
|
1826
1817
|
ver: CSGO_VER,
|
1827
1818
|
apr: prime ? 1 : 0, //prime
|
@@ -2185,9 +2176,9 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
2185
2176
|
pushGCCallback(`requestJoinFriendData_${accountID}`, resolve, 30000);
|
2186
2177
|
steamClient.sendToGC(
|
2187
2178
|
AppID,
|
2188
|
-
|
2179
|
+
ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientRequestJoinFriendData,
|
2189
2180
|
{},
|
2190
|
-
|
2181
|
+
new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientRequestJoinFriendData).protoEncode({
|
2191
2182
|
version: version || CSGO_VER,
|
2192
2183
|
account_id: accountID,
|
2193
2184
|
join_token: joinToken,
|
@@ -2198,21 +2189,21 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
2198
2189
|
}
|
2199
2190
|
|
2200
2191
|
function redeemFreeReward(itemIds, generation_time) {
|
2201
|
-
console.log(`Sent message to GC: AppID ${AppID}, MessageType ${
|
2192
|
+
console.log(`Sent message to GC: AppID ${AppID}, MessageType ${ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientRedeemFreeReward}`);
|
2202
2193
|
|
2203
|
-
const encodedMessages =
|
2194
|
+
const encodedMessages = new SteamProto(SteamProtoType.CMsgGCCstrike15_v2_ClientRedeemFreeReward).protoEncode({
|
2204
2195
|
items: itemIds,
|
2205
2196
|
redeemable_balance: 0,
|
2206
2197
|
generation_time: generation_time,
|
2207
2198
|
});
|
2208
|
-
steamClient.sendToGC(730,
|
2199
|
+
steamClient.sendToGC(730, ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientRedeemFreeReward, {}, encodedMessages, function (payload) {
|
2209
2200
|
console.log(payload);
|
2210
2201
|
});
|
2211
2202
|
|
2212
2203
|
setTimeout(function () {
|
2213
2204
|
steamClient._send(
|
2214
2205
|
{
|
2215
|
-
msg:
|
2206
|
+
msg: ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientRedeemFreeReward,
|
2216
2207
|
proto: {
|
2217
2208
|
steamid: steamClient.steamID.getSteamID64(),
|
2218
2209
|
routing_appid: 730,
|
@@ -2234,13 +2225,13 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
2234
2225
|
|
2235
2226
|
steamClient._send(
|
2236
2227
|
{
|
2237
|
-
msg:
|
2228
|
+
msg: ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientGCRankUpdate,
|
2238
2229
|
proto: {
|
2239
2230
|
steamid: steamClient.steamID.getSteamID64(),
|
2240
2231
|
routing_appid: 730,
|
2241
2232
|
},
|
2242
2233
|
},
|
2243
|
-
|
2234
|
+
new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientGCRankUpdate).protoEncode({
|
2244
2235
|
rankings: [
|
2245
2236
|
{
|
2246
2237
|
rank_type_id: 7, //wing man
|
@@ -2264,9 +2255,9 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
2264
2255
|
function acknowledgePenalty() {
|
2265
2256
|
steamClient.sendToGC(
|
2266
2257
|
730,
|
2267
|
-
|
2258
|
+
ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_AcknowledgePenalty,
|
2268
2259
|
{},
|
2269
|
-
|
2260
|
+
new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_AcknowledgePenalty).protoEncode({
|
2270
2261
|
acknowledged: 1,
|
2271
2262
|
}),
|
2272
2263
|
);
|
@@ -2514,19 +2505,19 @@ SteamClient.isAccountPlayable = async function isAccountPlayable({ cookie, clien
|
|
2514
2505
|
...rest,
|
2515
2506
|
});
|
2516
2507
|
|
2517
|
-
steamClient.onEvent(
|
2508
|
+
steamClient.onEvent(SteamClientEvents.error, ({ eresult, msg, error }) => {
|
2518
2509
|
doResolve({ eresult, msg, error });
|
2519
2510
|
});
|
2520
2511
|
|
2521
|
-
steamClient.onEvent(
|
2512
|
+
steamClient.onEvent(SteamClientEvents.csgoOnline, (ClientWelcome) => {
|
2522
2513
|
doResolve({ playable: true });
|
2523
2514
|
});
|
2524
2515
|
|
2525
|
-
steamClient.onEvent(
|
2516
|
+
steamClient.onEvent(SteamClientEvents.csgoClientHello, (ClientHello) => {
|
2526
2517
|
doResolve({ playable: true });
|
2527
2518
|
});
|
2528
2519
|
|
2529
|
-
steamClient.onEvent(
|
2520
|
+
steamClient.onEvent(SteamClientEvents.playingState, ({ playing_blocked, playing_app }) => {
|
2530
2521
|
if (playing_blocked) {
|
2531
2522
|
doResolve({ playable: false });
|
2532
2523
|
} else {
|