steamutils 1.4.86 → 1.4.88

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,13 +3,19 @@ import fs from "fs";
3
3
 
4
4
  (async function () {
5
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"];
6
8
 
7
9
  function doWrite(user, is_static) {
8
10
  for (const methodName of Object.getOwnPropertyNames(user)) {
9
- if (methodName === "constructor" || methodName === "length" || methodName === "name" || methodName === "prototype" || methodName === "RequestXML_TooManyRequests" || methodName === "MAX_RETRY") {
11
+ if (ignoreMethods.includes(methodName)) {
10
12
  continue;
11
13
  }
12
14
  const fnString = user[methodName].toString().trim();
15
+ if (dupplicateMethods.includes(methodName)) {
16
+ content += `${fnString}\n`;
17
+ continue;
18
+ }
13
19
  const async = "async";
14
20
  // const async = fnString.startsWith("async") ? "async" : "";
15
21
  let params = fnString.split("(")[1].split(")")[0];
@@ -80,7 +86,8 @@ const MAX_RETRY = 5;
80
86
 
81
87
  async function doRequest(config){
82
88
  for (let i = 0; i < MAX_RETRY; i++) {
83
- const url = getAppURL();
89
+ let url = getAppURL();
90
+ url = [url.replace(/\\/$/, ""), config.method].join("/");
84
91
 
85
92
  try {
86
93
  const response = await axios.post(url, config);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.4.86",
3
+ "version": "1.4.88",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "alpha-common-utils": "^1.0.6",
package/remote.js CHANGED
@@ -36,7 +36,8 @@ const MAX_RETRY = 5;
36
36
 
37
37
  async function doRequest(config) {
38
38
  for (let i = 0; i < MAX_RETRY; i++) {
39
- const url = getAppURL();
39
+ let url = getAppURL();
40
+ url = [url.replace(/\/$/, ""), config.method].join("/");
40
41
 
41
42
  try {
42
43
  const response = await axios.post(url, config);
@@ -89,85 +90,40 @@ export default class RemoteSteamUser {
89
90
  }
90
91
  }
91
92
 
92
- async setSteamLanguage(language) {
93
- const { __params, __cookies } = formatParams([language], this._cookies);
94
- const config = {
95
- method: "setSteamLanguage",
96
- params: __params,
97
- cookies: __cookies,
98
- is_static: false,
99
- };
100
- return await doRequest(config);
93
+ setSteamLanguage(language) {
94
+ language = language?.toLowerCase();
95
+ if (!Object.hasOwn(ELanguage, language)) {
96
+ return;
97
+ }
98
+ this.Steam_Language = language;
99
+ this._cookies.forEach(function (cookie) {
100
+ cookie.setCookie("Steam_Language", language);
101
+ cookie.setCookie("strInventoryLastContext", "730_2");
102
+ });
101
103
  }
102
- async getCookies(index) {
103
- const { __params, __cookies } = formatParams([index], this._cookies);
104
- const config = {
105
- method: "getCookies",
106
- params: __params,
107
- cookies: __cookies,
108
- is_static: false,
109
- };
110
- return await doRequest(config);
104
+ getCookies(index = 0) {
105
+ return this._cookies[index].toString();
111
106
  }
112
- async getSteamIdUser() {
113
- const { __params, __cookies } = formatParams([], this._cookies);
114
- const config = {
115
- method: "getSteamIdUser",
116
- params: __params,
117
- cookies: __cookies,
118
- is_static: false,
119
- };
120
- return await doRequest(config);
107
+ getSteamIdUser() {
108
+ return this._steamIdUser;
121
109
  }
122
- async getMiniProfileUser() {
123
- const { __params, __cookies } = formatParams([], this._cookies);
124
- const config = {
125
- method: "getMiniProfileUser",
126
- params: __params,
127
- cookies: __cookies,
128
- is_static: false,
129
- };
130
- return await doRequest(config);
110
+ getMiniProfileUser() {
111
+ return this._miniProfileUser;
131
112
  }
132
- async getSessionid() {
133
- const { __params, __cookies } = formatParams([], this._cookies);
134
- const config = {
135
- method: "getSessionid",
136
- params: __params,
137
- cookies: __cookies,
138
- is_static: false,
139
- };
140
- return await doRequest(config);
113
+ getSessionid() {
114
+ return this._sessionId;
141
115
  }
142
- async getSteamMachineAuth() {
143
- const { __params, __cookies } = formatParams([], this._cookies);
144
- const config = {
145
- method: "getSteamMachineAuth",
146
- params: __params,
147
- cookies: __cookies,
148
- is_static: false,
149
- };
150
- return await doRequest(config);
116
+ getSteamMachineAuth() {
117
+ return this._steamMachineAuth;
151
118
  }
152
- async getSteamUserProfileURL(steamId) {
153
- const { __params, __cookies } = formatParams([steamId], this._cookies);
154
- const config = {
155
- method: "getSteamUserProfileURL",
156
- params: __params,
157
- cookies: __cookies,
158
- is_static: false,
159
- };
160
- return await doRequest(config);
119
+ getSteamUserProfileURL(steamId) {
120
+ return `profiles/${steamId}`;
161
121
  }
162
- async getMyProfileURL() {
163
- const { __params, __cookies } = formatParams([], this._cookies);
164
- const config = {
165
- method: "getMyProfileURL",
166
- params: __params,
167
- cookies: __cookies,
168
- is_static: false,
169
- };
170
- return await doRequest(config);
122
+ getMyProfileURL() {
123
+ if (this._customURL) {
124
+ return `id/${this._customURL}`;
125
+ }
126
+ return "my";
171
127
  }
172
128
  async getUserSummary(steamId) {
173
129
  const { __params, __cookies } = formatParams([steamId], this._cookies);
@@ -189,46 +145,6 @@ export default class RemoteSteamUser {
189
145
  };
190
146
  return await doRequest(config);
191
147
  }
192
- async _httpRequest(params) {
193
- const { __params, __cookies } = formatParams([params], this._cookies);
194
- const config = {
195
- method: "_httpRequest",
196
- params: __params,
197
- cookies: __cookies,
198
- is_static: false,
199
- };
200
- return await doRequest(config);
201
- }
202
- async _httpMyRequest(params) {
203
- const { __params, __cookies } = formatParams([params], this._cookies);
204
- const config = {
205
- method: "_httpMyRequest",
206
- params: __params,
207
- cookies: __cookies,
208
- is_static: false,
209
- };
210
- return await doRequest(config);
211
- }
212
- async _httpRequestAjax(params) {
213
- const { __params, __cookies } = formatParams([params], this._cookies);
214
- const config = {
215
- method: "_httpRequestAjax",
216
- params: __params,
217
- cookies: __cookies,
218
- is_static: false,
219
- };
220
- return await doRequest(config);
221
- }
222
- async _httpMyRequestAjax(params) {
223
- const { __params, __cookies } = formatParams([params], this._cookies);
224
- const config = {
225
- method: "_httpMyRequestAjax",
226
- params: __params,
227
- cookies: __cookies,
228
- is_static: false,
229
- };
230
- return await doRequest(config);
231
- }
232
148
  async getQuickInviteData() {
233
149
  const { __params, __cookies } = formatParams([], this._cookies);
234
150
  const config = {