steamcommunity 3.47.0 → 3.47.1
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/LICENSE +21 -21
- package/README.md +22 -22
- package/components/login.js +110 -0
- package/examples/README.md +35 -35
- package/examples/accept_all_confirmations.js +173 -173
- package/examples/disable_twofactor.js +135 -135
- package/examples/enable_twofactor.js +182 -182
- package/index.js +13 -151
- package/package.json +3 -5
- package/resources/ESharedFileType.js +13 -13
package/index.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
const
|
|
1
|
+
const {chrome} = require('@doctormckay/user-agents');
|
|
2
2
|
const Request = require('request');
|
|
3
|
-
const RSA = require('node-bignumber').Key;
|
|
4
3
|
const SteamID = require('steamid');
|
|
5
4
|
|
|
6
5
|
const Helpers = require('./components/helpers.js');
|
|
7
6
|
|
|
8
|
-
const USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36";
|
|
9
|
-
|
|
10
7
|
require('util').inherits(SteamCommunity, require('events').EventEmitter);
|
|
11
8
|
|
|
12
9
|
module.exports = SteamCommunity;
|
|
@@ -31,7 +28,7 @@ function SteamCommunity(options) {
|
|
|
31
28
|
"timeout": options.timeout || 50000,
|
|
32
29
|
"gzip": true,
|
|
33
30
|
"headers": {
|
|
34
|
-
"User-Agent": options.userAgent ||
|
|
31
|
+
"User-Agent": options.userAgent || chrome()
|
|
35
32
|
}
|
|
36
33
|
};
|
|
37
34
|
|
|
@@ -61,158 +58,22 @@ SteamCommunity.prototype.login = function(details, callback) {
|
|
|
61
58
|
throw new Error("Missing either accountName or password to login; both are needed");
|
|
62
59
|
}
|
|
63
60
|
|
|
64
|
-
if (details.steamguard) {
|
|
65
|
-
var parts = details.steamguard.split('||');
|
|
66
|
-
this._setCookie(Request.cookie('steamMachineAuth' + parts[0] + '=' + encodeURIComponent(parts[1])), true);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
var disableMobile = typeof details.disableMobile == 'undefined' ? true : details.disableMobile;
|
|
70
|
-
|
|
71
|
-
var self = this;
|
|
72
|
-
|
|
73
61
|
// Delete the cache
|
|
74
|
-
delete
|
|
75
|
-
|
|
76
|
-
// headers required to convince steam that we're logging in from a mobile device so that we can get the oAuth data
|
|
77
|
-
var mobileHeaders = {};
|
|
78
|
-
if (!disableMobile) {
|
|
79
|
-
mobileHeaders = {
|
|
80
|
-
"X-Requested-With": "com.valvesoftware.android.steam.community",
|
|
81
|
-
"Referer": "https://steamcommunity.com/mobilelogin?oauth_client_id=DE45CD61&oauth_scope=read_profile%20write_profile%20read_client%20write_client",
|
|
82
|
-
"User-Agent": this._options.mobileUserAgent || details.mobileUserAgent || "Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; Google Nexus 4 - 4.1.1 - API 16 - 768x1280 Build/JRO03S) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
|
|
83
|
-
"Accept": "text/javascript, text/html, application/xml, text/xml, */*"
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
this._setCookie(Request.cookie("mobileClientVersion=0 (2.1.3)"));
|
|
87
|
-
this._setCookie(Request.cookie("mobileClient=android"));
|
|
88
|
-
} else {
|
|
89
|
-
mobileHeaders = {"Referer": "https://steamcommunity.com/login"};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
this.httpRequestPost("https://steamcommunity.com/login/getrsakey/", {
|
|
93
|
-
"form": {"username": details.accountName},
|
|
94
|
-
"headers": mobileHeaders,
|
|
95
|
-
"json": true
|
|
96
|
-
}, function(err, response, body) {
|
|
97
|
-
// Remove the mobile cookies
|
|
98
|
-
if (err) {
|
|
99
|
-
deleteMobileCookies();
|
|
100
|
-
callback(err);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
62
|
+
delete this._profileURL;
|
|
103
63
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
64
|
+
// default disableMobile to true
|
|
65
|
+
let logOnOptions = Object.assign({}, details);
|
|
66
|
+
logOnOptions.disableMobile = details.disableMobile !== false;
|
|
109
67
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
var formObj = {
|
|
114
|
-
"captcha_text": details.captcha || "",
|
|
115
|
-
"captchagid": self._captchaGid,
|
|
116
|
-
"emailauth": details.authCode || "",
|
|
117
|
-
"emailsteamid": "",
|
|
118
|
-
"password": hex2b64(key.encrypt(details.password)),
|
|
119
|
-
"remember_login": "true",
|
|
120
|
-
"rsatimestamp": body.timestamp,
|
|
121
|
-
"twofactorcode": details.twoFactorCode || "",
|
|
122
|
-
"username": details.accountName,
|
|
123
|
-
"loginfriendlyname": "",
|
|
124
|
-
"donotcache": Date.now()
|
|
125
|
-
};
|
|
68
|
+
this._modernLogin(logOnOptions).then(({sessionID, cookies, steamguard, mobileAccessToken}) => {
|
|
69
|
+
this.setCookies(cookies);
|
|
126
70
|
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
formObj.oauth_scope = "read_profile write_profile read_client write_client";
|
|
130
|
-
formObj.loginfriendlyname = "#login_emailauth_friendlyname_mobile";
|
|
71
|
+
if (mobileAccessToken) {
|
|
72
|
+
this.setMobileAppAccessToken(mobileAccessToken);
|
|
131
73
|
}
|
|
132
74
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
"json": true,
|
|
136
|
-
"form": formObj,
|
|
137
|
-
"headers": mobileHeaders
|
|
138
|
-
}, function(err, response, body) {
|
|
139
|
-
deleteMobileCookies();
|
|
140
|
-
|
|
141
|
-
if (err) {
|
|
142
|
-
callback(err);
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
var error;
|
|
147
|
-
if (!body.success && body.emailauth_needed) {
|
|
148
|
-
// Steam Guard (email)
|
|
149
|
-
error = new Error("SteamGuard");
|
|
150
|
-
error.emaildomain = body.emaildomain;
|
|
151
|
-
|
|
152
|
-
callback(error);
|
|
153
|
-
} else if (!body.success && body.requires_twofactor) {
|
|
154
|
-
// Steam Guard (app)
|
|
155
|
-
callback(new Error("SteamGuardMobile"));
|
|
156
|
-
} else if (!body.success && body.captcha_needed && body.message.match(/Please verify your humanity/)) {
|
|
157
|
-
error = new Error("CAPTCHA");
|
|
158
|
-
error.captchaurl = "https://steamcommunity.com/login/rendercaptcha/?gid=" + body.captcha_gid;
|
|
159
|
-
|
|
160
|
-
self._captchaGid = body.captcha_gid;
|
|
161
|
-
|
|
162
|
-
callback(error);
|
|
163
|
-
} else if (!body.success) {
|
|
164
|
-
callback(new Error(body.message || "Unknown error"));
|
|
165
|
-
} else {
|
|
166
|
-
var sessionID = generateSessionID();
|
|
167
|
-
var oAuth = {};
|
|
168
|
-
self._setCookie(Request.cookie('sessionid=' + sessionID));
|
|
169
|
-
|
|
170
|
-
var cookies = self._jar.getCookieString("https://steamcommunity.com").split(';').map(function(cookie) {
|
|
171
|
-
return cookie.trim();
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
if (!disableMobile && body.oauth) {
|
|
175
|
-
oAuth = JSON.parse(body.oauth);
|
|
176
|
-
self.steamID = new SteamID(oAuth.steamid);
|
|
177
|
-
self.oAuthToken = oAuth.oauth_token;
|
|
178
|
-
} else {
|
|
179
|
-
for(var i = 0; i < cookies.length; i++) {
|
|
180
|
-
var parts = cookies[i].split('=');
|
|
181
|
-
if(parts[0] == 'steamLogin') {
|
|
182
|
-
self.steamID = new SteamID(decodeURIComponent(parts[1]).split('||')[0])
|
|
183
|
-
break;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
self.oAuthToken = null;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// Find the Steam Guard cookie
|
|
191
|
-
var steamguard = null;
|
|
192
|
-
for (var i = 0; i < cookies.length; i++) {
|
|
193
|
-
var parts = cookies[i].split('=');
|
|
194
|
-
if(parts[0] == 'steamMachineAuth' + self.steamID) {
|
|
195
|
-
steamguard = self.steamID.toString() + '||' + decodeURIComponent(parts[1]);
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
self.setCookies(cookies);
|
|
201
|
-
|
|
202
|
-
callback(null, sessionID, cookies, steamguard, disableMobile ? null : oAuth.oauth_token);
|
|
203
|
-
}
|
|
204
|
-
}, "steamcommunity");
|
|
205
|
-
}, "steamcommunity");
|
|
206
|
-
|
|
207
|
-
function deleteMobileCookies() {
|
|
208
|
-
var cookie = Request.cookie('mobileClientVersion=');
|
|
209
|
-
cookie.expires = new Date(0);
|
|
210
|
-
self._setCookie(cookie);
|
|
211
|
-
|
|
212
|
-
cookie = Request.cookie('mobileClient=');
|
|
213
|
-
cookie.expires = new Date(0);
|
|
214
|
-
self._setCookie(cookie);
|
|
215
|
-
}
|
|
75
|
+
callback(null, sessionID, cookies, steamguard, null);
|
|
76
|
+
}).catch(err => callback(err));
|
|
216
77
|
};
|
|
217
78
|
|
|
218
79
|
/**
|
|
@@ -576,6 +437,7 @@ SteamCommunity.prototype.getFriendsList = function(callback) {
|
|
|
576
437
|
});
|
|
577
438
|
};
|
|
578
439
|
|
|
440
|
+
require('./components/login.js');
|
|
579
441
|
require('./components/http.js');
|
|
580
442
|
require('./components/chat.js');
|
|
581
443
|
require('./components/profile.js');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "steamcommunity",
|
|
3
|
-
"version": "3.47.
|
|
3
|
+
"version": "3.47.1",
|
|
4
4
|
"description": "Provides an interface for logging into and interacting with the Steam Community website",
|
|
5
5
|
"files": [
|
|
6
6
|
"/classes",
|
|
@@ -28,18 +28,16 @@
|
|
|
28
28
|
"url": "https://github.com/DoctorMcKay/node-steamcommunity.git"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
+
"@doctormckay/user-agents": "^1.0.0",
|
|
31
32
|
"async": "^2.6.3",
|
|
32
33
|
"cheerio": "0.22.0",
|
|
33
34
|
"image-size": "^0.8.2",
|
|
34
|
-
"node-bignumber": "^1.2.1",
|
|
35
35
|
"request": "^2.88.0",
|
|
36
|
+
"steam-session": "^1.6.0",
|
|
36
37
|
"steam-totp": "^1.5.0",
|
|
37
38
|
"steamid": "^1.1.3",
|
|
38
39
|
"xml2js": "^0.6.2"
|
|
39
40
|
},
|
|
40
|
-
"devDependencies": {
|
|
41
|
-
"steam-session": "^1.2.3"
|
|
42
|
-
},
|
|
43
41
|
"engines": {
|
|
44
42
|
"node": ">=4.0.0"
|
|
45
43
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @enum ESharedFileType
|
|
3
|
-
*/
|
|
4
|
-
module.exports = {
|
|
5
|
-
"Screenshot": 0,
|
|
6
|
-
"Artwork": 1,
|
|
7
|
-
"Guide": 2,
|
|
8
|
-
|
|
9
|
-
// Value-to-name mapping for convenience
|
|
10
|
-
"0": "Screenshot",
|
|
11
|
-
"1": "Artwork",
|
|
12
|
-
"2": "Guide"
|
|
13
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* @enum ESharedFileType
|
|
3
|
+
*/
|
|
4
|
+
module.exports = {
|
|
5
|
+
"Screenshot": 0,
|
|
6
|
+
"Artwork": 1,
|
|
7
|
+
"Guide": 2,
|
|
8
|
+
|
|
9
|
+
// Value-to-name mapping for convenience
|
|
10
|
+
"0": "Screenshot",
|
|
11
|
+
"1": "Artwork",
|
|
12
|
+
"2": "Guide"
|
|
13
|
+
};
|