steamutils 1.5.7 → 1.5.9

Sign up to get free protection for your applications and to get access to all the features.
package/SteamClient.js CHANGED
@@ -1465,6 +1465,10 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
1465
1465
  success: true,
1466
1466
  };
1467
1467
  },
1468
+ [ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientPollState]({ appId, msgType, payload }) {
1469
+ const data = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientPollState).protoDecode(payload);
1470
+ const dataExample = {};
1471
+ },
1468
1472
  };
1469
1473
 
1470
1474
  if (typeof handleGC[msgType] === "function") {
@@ -1,153 +1,153 @@
1
- import SteamUser from "./index.js";
2
- import fs from "fs";
3
-
4
- (async function () {
5
- let content = "";
6
- const ignoreMethods = ["constructor", "length", "name", "prototype", "RequestXML_TooManyRequests", "MAX_RETRY", "_httpRequest", "_httpMyRequest", "_httpRequestAjax", "_httpMyRequestAjax"];
7
- const dupplicateMethods = ["setSteamLanguage", "getCookies", "getSteamIdUser", "getMiniProfileUser", "getSessionid", "getSteamMachineAuth", "getSteamUserProfileURL", "getMyProfileURL"];
8
-
9
- function doWrite(user, is_static) {
10
- for (const methodName of Object.getOwnPropertyNames(user)) {
11
- if (ignoreMethods.includes(methodName)) {
12
- continue;
13
- }
14
- const fnString = user[methodName].toString().trim();
15
- if (dupplicateMethods.includes(methodName)) {
16
- content += `${fnString}\n`;
17
- continue;
18
- }
19
- const async = "async";
20
- // const async = fnString.startsWith("async") ? "async" : "";
21
- let params = fnString.split("(")[1].split(")")[0];
22
- const paramsList = params.split(",");
23
- for (let i = 0; i < paramsList.length; i++) {
24
- if (paramsList[i].includes("=")) {
25
- paramsList[i] = paramsList[i].split("=")[0].trim();
26
- }
27
- }
28
- params = paramsList.join(", ").trim();
29
- if (params.startsWith("{") && !params.endsWith("}")) {
30
- params = `${params}}`;
31
- }
32
-
33
- content += `${`
34
- ${is_static ? "static " : ""} ${async} ${methodName}(${params}){
35
- const {__params, __cookies} = formatParams([${params}] ${is_static ? "" : ", this._cookies"} );
36
- const config = {
37
- method: "${methodName}",
38
- params: __params,${is_static ? "" : "cookies: __cookies,"}
39
- is_static: ${!!is_static}
40
- }
41
- return await doRequest(config)
42
- }`.trim()}\n`;
43
- }
44
- }
45
-
46
- doWrite(SteamUser.prototype, false);
47
- doWrite(SteamUser, true);
48
-
49
- const fileContent = `
50
-
51
- import axios from "axios";
52
- import SteamUser, { ELanguage } from "./index.js";
53
- import CookieManager from "./CookieManager.js";
54
-
55
- function getAppURL() {
56
- if (!RemoteSteamUser.__appIndex) {
57
- RemoteSteamUser.__appIndex = 0;
58
- }
59
- RemoteSteamUser.__appIndex++;
60
- if (RemoteSteamUser.__appIndex >= RemoteSteamUser.__apps.length) {
61
- RemoteSteamUser.__appIndex = 0;
62
- }
63
- return RemoteSteamUser.__apps[RemoteSteamUser.__appIndex];
64
- }
65
-
66
- function formatParams(__params, __cookies) {
67
- if (__params.length === 1 && __params[0] === undefined) {
68
- __params.length = 0;
69
- }
70
- if (__cookies) {
71
- if (!Array.isArray(__cookies)) {
72
- __cookies = [__cookies];
73
- }
74
- __cookies = __cookies.map(function (cookie) {
75
- return cookie.toString();
76
- });
77
- }
78
-
79
- return {
80
- __params,
81
- __cookies,
82
- };
83
- }
84
-
85
- const MAX_RETRY = 5;
86
-
87
- async function doRequest(config){
88
- for (let i = 0; i < MAX_RETRY; i++) {
89
- let url = getAppURL();
90
- url = [url.replace(/\\/$/, ""), config.method].join("/");
91
-
92
- try {
93
- const response = await axios.post(url, config);
94
-
95
- if (!response || !response.data) {
96
- continue;
97
- }
98
-
99
- return response.data?.result;
100
- } catch (e) {
101
- /* empty */
102
- }
103
- }
104
- }
105
-
106
- export default class RemoteSteamUser {
107
- constructor(cookies, refreshCookie, onRefreshCookie) {
108
- if (!Array.isArray(cookies)) {
109
- cookies = [cookies];
110
- }
111
- this._refreshCookie = refreshCookie;
112
- this._onRefreshCookie = onRefreshCookie;
113
- this._cookies = cookies.map(function (cookie) {
114
- return new CookieManager(cookie?.cookie || cookie);
115
- });
116
- const timezoneOffset = new Date().getTimezoneOffset() * -1 * 60 + ",0";
117
- for (const cookie of this._cookies) {
118
- cookie.setCookie("timezoneOffset", timezoneOffset);
119
-
120
- let { steamMachineAuth, steamLoginSecure, steamRememberLogin, steamId, miniprofile, sessionid } = SteamUser.parseCookie(cookie.toString());
121
-
122
- if (!sessionid) {
123
- sessionid = SteamUser.generateSessionID();
124
- cookie.setCookie("sessionid", sessionid);
125
- }
126
-
127
- this._sessionId = sessionid;
128
- this._customURL = null;
129
- this._steamIdUser = steamId;
130
- this._miniProfileUser = miniprofile;
131
- this._steamMachineAuth = steamMachineAuth;
132
- this._steamLoginSecure = steamLoginSecure;
133
- this._steamRememberLogin = steamRememberLogin;
134
- }
135
-
136
- this.setSteamLanguage(ELanguage.english);
137
-
138
- if (!this._steamIdUser) {
139
- console.error("Invalid cookie. Missing steamId");
140
- }
141
- }
142
-
143
- ${content}
144
-
145
- }
146
-
147
-
148
- `;
149
-
150
- fs.writeFileSync("./remote.js", fileContent.trim());
151
-
152
- console.log("");
153
- })();
1
+ import SteamUser from "./index.js";
2
+ import fs from "fs";
3
+
4
+ (async function () {
5
+ let content = "";
6
+ const ignoreMethods = ["constructor", "length", "name", "prototype", "RequestXML_TooManyRequests", "MAX_RETRY", "_httpRequest", "_httpMyRequest", "_httpRequestAjax", "_httpMyRequestAjax"];
7
+ const dupplicateMethods = ["setSteamLanguage", "getCookies", "getSteamIdUser", "getMiniProfileUser", "getSessionid", "getSteamMachineAuth", "getSteamUserProfileURL", "getMyProfileURL"];
8
+
9
+ function doWrite(user, is_static) {
10
+ for (const methodName of Object.getOwnPropertyNames(user)) {
11
+ if (ignoreMethods.includes(methodName)) {
12
+ continue;
13
+ }
14
+ const fnString = user[methodName].toString().trim();
15
+ if (dupplicateMethods.includes(methodName)) {
16
+ content += `${fnString}\n`;
17
+ continue;
18
+ }
19
+ const async = "async";
20
+ // const async = fnString.startsWith("async") ? "async" : "";
21
+ let params = fnString.split("(")[1].split(")")[0];
22
+ const paramsList = params.split(",");
23
+ for (let i = 0; i < paramsList.length; i++) {
24
+ if (paramsList[i].includes("=")) {
25
+ paramsList[i] = paramsList[i].split("=")[0].trim();
26
+ }
27
+ }
28
+ params = paramsList.join(", ").trim();
29
+ if (params.startsWith("{") && !params.endsWith("}")) {
30
+ params = `${params}}`;
31
+ }
32
+
33
+ content += `${`
34
+ ${is_static ? "static " : ""} ${async} ${methodName}(${params}){
35
+ const {__params, __cookies} = formatParams([${params}] ${is_static ? "" : ", this._cookies"} );
36
+ const config = {
37
+ method: "${methodName}",
38
+ params: __params,${is_static ? "" : "cookies: __cookies,"}
39
+ is_static: ${!!is_static}
40
+ }
41
+ return await doRequest(config)
42
+ }`.trim()}\n`;
43
+ }
44
+ }
45
+
46
+ doWrite(SteamUser.prototype, false);
47
+ doWrite(SteamUser, true);
48
+
49
+ const fileContent = `
50
+
51
+ import axios from "axios";
52
+ import SteamUser, { ELanguage } from "./index.js";
53
+ import CookieManager from "./CookieManager.js";
54
+
55
+ function getAppURL() {
56
+ if (!RemoteSteamUser.__appIndex) {
57
+ RemoteSteamUser.__appIndex = 0;
58
+ }
59
+ RemoteSteamUser.__appIndex++;
60
+ if (RemoteSteamUser.__appIndex >= RemoteSteamUser.__apps.length) {
61
+ RemoteSteamUser.__appIndex = 0;
62
+ }
63
+ return RemoteSteamUser.__apps[RemoteSteamUser.__appIndex];
64
+ }
65
+
66
+ function formatParams(__params, __cookies) {
67
+ if (__params.length === 1 && __params[0] === undefined) {
68
+ __params.length = 0;
69
+ }
70
+ if (__cookies) {
71
+ if (!Array.isArray(__cookies)) {
72
+ __cookies = [__cookies];
73
+ }
74
+ __cookies = __cookies.map(function (cookie) {
75
+ return cookie.toString();
76
+ });
77
+ }
78
+
79
+ return {
80
+ __params,
81
+ __cookies,
82
+ };
83
+ }
84
+
85
+ const MAX_RETRY = 5;
86
+
87
+ async function doRequest(config){
88
+ for (let i = 0; i < MAX_RETRY; i++) {
89
+ let url = getAppURL();
90
+ url = [url.replace(/\\/$/, ""), config.method].join("/");
91
+
92
+ try {
93
+ const response = await axios.post(url, config);
94
+
95
+ if (!response || !response.data) {
96
+ continue;
97
+ }
98
+
99
+ return response.data?.result;
100
+ } catch (e) {
101
+ /* empty */
102
+ }
103
+ }
104
+ }
105
+
106
+ export default class RemoteSteamUser {
107
+ constructor(cookies, refreshCookie, onRefreshCookie) {
108
+ if (!Array.isArray(cookies)) {
109
+ cookies = [cookies];
110
+ }
111
+ this._refreshCookie = refreshCookie;
112
+ this._onRefreshCookie = onRefreshCookie;
113
+ this._cookies = cookies.map(function (cookie) {
114
+ return new CookieManager(cookie?.cookie || cookie);
115
+ });
116
+ const timezoneOffset = new Date().getTimezoneOffset() * -1 * 60 + ",0";
117
+ for (const cookie of this._cookies) {
118
+ cookie.setCookie("timezoneOffset", timezoneOffset);
119
+
120
+ let { steamMachineAuth, steamLoginSecure, steamRememberLogin, steamId, miniprofile, sessionid } = SteamUser.parseCookie(cookie.toString());
121
+
122
+ if (!sessionid) {
123
+ sessionid = SteamUser.generateSessionID();
124
+ cookie.setCookie("sessionid", sessionid);
125
+ }
126
+
127
+ this._sessionId = sessionid;
128
+ this._customURL = null;
129
+ this._steamIdUser = steamId;
130
+ this._miniProfileUser = miniprofile;
131
+ this._steamMachineAuth = steamMachineAuth;
132
+ this._steamLoginSecure = steamLoginSecure;
133
+ this._steamRememberLogin = steamRememberLogin;
134
+ }
135
+
136
+ this.setSteamLanguage(ELanguage.english);
137
+
138
+ if (!this._steamIdUser) {
139
+ console.error("Invalid cookie. Missing steamId");
140
+ }
141
+ }
142
+
143
+ ${content}
144
+
145
+ }
146
+
147
+
148
+ `;
149
+
150
+ fs.writeFileSync("./remote.js", fileContent.trim());
151
+
152
+ console.log("");
153
+ })();