steamutils 1.4.76 → 1.4.78
Sign up to get free protection for your applications and to get access to all the features.
- package/SteamClient.js +3106 -3126
- package/create_remote_file.js +109 -37
- package/index.js +1 -1
- package/package.json +1 -1
- package/remote.js +1784 -7875
package/create_remote_file.js
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
import SteamUser from "./index.js";
|
2
|
-
import
|
2
|
+
import fs from "fs";
|
3
3
|
|
4
4
|
(async function () {
|
5
|
-
|
6
|
-
|
7
|
-
let json = "";
|
5
|
+
let content = "";
|
8
6
|
|
9
7
|
function doWrite(user, is_static) {
|
10
8
|
for (const methodName of Object.getOwnPropertyNames(user)) {
|
@@ -26,43 +24,15 @@ import _ from "lodash";
|
|
26
24
|
params = `${params}}`;
|
27
25
|
}
|
28
26
|
|
29
|
-
|
27
|
+
content += `${`
|
30
28
|
${is_static ? "static " : ""} ${async} ${methodName}(${params}){
|
31
|
-
const __params = [${params}];
|
32
|
-
|
33
|
-
__params.length = 0
|
34
|
-
}
|
35
|
-
let __cookies = this._cookies;
|
36
|
-
if (__cookies) {
|
37
|
-
if (!Array.isArray(__cookies)) {
|
38
|
-
__cookies = [__cookies];
|
39
|
-
}
|
40
|
-
__cookies = __cookies.map(function (cookie) {
|
41
|
-
return cookie.toString();
|
42
|
-
});
|
43
|
-
}
|
44
|
-
|
45
|
-
for (let i = 0; i < 5; i++) {
|
46
|
-
try {
|
47
|
-
const response = await axios.post(getAppURL(), {
|
29
|
+
const {__params, __cookies} = formatParams([${params}] ${is_static ? "" : ", this._cookies"} );
|
30
|
+
const config = {
|
48
31
|
method: "${methodName}",
|
49
|
-
params: __params,
|
50
|
-
cookies: __cookies,
|
32
|
+
params: __params,${is_static ? "" : "cookies: __cookies,"}
|
51
33
|
is_static: ${!!is_static}
|
52
|
-
});
|
53
|
-
|
54
|
-
if (!response || response.error) {
|
55
|
-
if (response?.message) {
|
56
|
-
console.error(response?.message);
|
57
|
-
}
|
58
|
-
continue;
|
59
34
|
}
|
60
|
-
|
61
|
-
return response.data?.result;
|
62
|
-
} catch (e) {
|
63
|
-
/* empty */
|
64
|
-
}
|
65
|
-
}
|
35
|
+
return await doRequest(config)
|
66
36
|
}`.trim()}\n`;
|
67
37
|
}
|
68
38
|
}
|
@@ -70,5 +40,107 @@ import _ from "lodash";
|
|
70
40
|
doWrite(SteamUser.prototype, false);
|
71
41
|
doWrite(SteamUser, true);
|
72
42
|
|
43
|
+
const fileContent = `
|
44
|
+
|
45
|
+
import axios from "axios";
|
46
|
+
import SteamUser, { ELanguage } from "./index.js";
|
47
|
+
import CookieManager from "./CookieManager.js";
|
48
|
+
|
49
|
+
function getAppURL() {
|
50
|
+
if (!RemoteSteamUser.__appIndex) {
|
51
|
+
RemoteSteamUser.__appIndex = 0;
|
52
|
+
}
|
53
|
+
RemoteSteamUser.__appIndex++;
|
54
|
+
if (RemoteSteamUser.__appIndex >= RemoteSteamUser.__apps.length) {
|
55
|
+
RemoteSteamUser.__appIndex = 0;
|
56
|
+
}
|
57
|
+
return RemoteSteamUser.__apps[RemoteSteamUser.__appIndex];
|
58
|
+
}
|
59
|
+
|
60
|
+
function formatParams(__params, __cookies) {
|
61
|
+
if (__params.length === 1 && __params[0] === undefined) {
|
62
|
+
__params.length = 0;
|
63
|
+
}
|
64
|
+
if (__cookies) {
|
65
|
+
if (!Array.isArray(__cookies)) {
|
66
|
+
__cookies = [__cookies];
|
67
|
+
}
|
68
|
+
__cookies = __cookies.map(function (cookie) {
|
69
|
+
return cookie.toString();
|
70
|
+
});
|
71
|
+
}
|
72
|
+
|
73
|
+
return {
|
74
|
+
__params,
|
75
|
+
__cookies,
|
76
|
+
};
|
77
|
+
}
|
78
|
+
|
79
|
+
const MAX_RETRY = 5;
|
80
|
+
|
81
|
+
async function doRequest(config){
|
82
|
+
for (let i = 0; i < MAX_RETRY; i++) {
|
83
|
+
const url = getAppURL();
|
84
|
+
|
85
|
+
try {
|
86
|
+
const response = await axios.post(url, config);
|
87
|
+
|
88
|
+
if (!response || !response.data) {
|
89
|
+
continue;
|
90
|
+
}
|
91
|
+
|
92
|
+
return response.data?.result;
|
93
|
+
} catch (e) {
|
94
|
+
/* empty */
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
export default class RemoteSteamUser {
|
100
|
+
constructor(cookies, refreshCookie, onRefreshCookie) {
|
101
|
+
if (!Array.isArray(cookies)) {
|
102
|
+
cookies = [cookies];
|
103
|
+
}
|
104
|
+
this._refreshCookie = refreshCookie;
|
105
|
+
this._onRefreshCookie = onRefreshCookie;
|
106
|
+
this._cookies = cookies.map(function (cookie) {
|
107
|
+
return new CookieManager(cookie?.cookie || cookie);
|
108
|
+
});
|
109
|
+
const timezoneOffset = new Date().getTimezoneOffset() * -1 * 60 + ",0";
|
110
|
+
for (const cookie of this._cookies) {
|
111
|
+
cookie.setCookie("timezoneOffset", timezoneOffset);
|
112
|
+
|
113
|
+
let { steamMachineAuth, steamLoginSecure, steamRememberLogin, steamId, miniprofile, sessionid } = SteamUser.parseCookie(cookie.toString());
|
114
|
+
|
115
|
+
if (!sessionid) {
|
116
|
+
sessionid = SteamUser.generateSessionID();
|
117
|
+
cookie.setCookie("sessionid", sessionid);
|
118
|
+
}
|
119
|
+
|
120
|
+
this._sessionId = sessionid;
|
121
|
+
this._customURL = null;
|
122
|
+
this._steamIdUser = steamId;
|
123
|
+
this._miniProfileUser = miniprofile;
|
124
|
+
this._steamMachineAuth = steamMachineAuth;
|
125
|
+
this._steamLoginSecure = steamLoginSecure;
|
126
|
+
this._steamRememberLogin = steamRememberLogin;
|
127
|
+
}
|
128
|
+
|
129
|
+
this.setSteamLanguage(ELanguage.english);
|
130
|
+
|
131
|
+
if (!this._steamIdUser) {
|
132
|
+
console.error("Invalid cookie. Missing steamId");
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
${content}
|
137
|
+
|
138
|
+
}
|
139
|
+
|
140
|
+
|
141
|
+
`;
|
142
|
+
|
143
|
+
fs.writeFileSync("./remote.js", fileContent.trim());
|
144
|
+
|
73
145
|
console.log("");
|
74
146
|
})();
|
package/index.js
CHANGED
@@ -36,7 +36,7 @@ export default class SteamUser {
|
|
36
36
|
this._cookies = cookies.map(function (cookie) {
|
37
37
|
return new CookieManager(cookie?.cookie || cookie);
|
38
38
|
});
|
39
|
-
const timezoneOffset =
|
39
|
+
const timezoneOffset = new Date().getTimezoneOffset() * -1 * 60 + ",0";
|
40
40
|
for (const cookie of this._cookies) {
|
41
41
|
cookie.setCookie("timezoneOffset", timezoneOffset);
|
42
42
|
|