steamcommunity 3.46.1 → 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/classes/CConfirmation.js +37 -37
- package/classes/CEconItem.js +120 -120
- package/classes/CMarketItem.js +189 -189
- package/classes/CMarketSearchResult.js +89 -89
- package/classes/CSteamGroup.js +155 -155
- package/classes/CSteamUser.js +225 -217
- package/components/chat.js +283 -283
- package/components/confirmations.js +428 -428
- package/components/groups.js +798 -732
- package/components/help.js +64 -64
- package/components/helpers.js +128 -108
- package/components/http.js +150 -150
- package/components/inventoryhistory.js +173 -173
- package/components/login.js +110 -0
- package/components/market.js +387 -387
- package/components/profile.js +475 -475
- package/components/twofactor.js +152 -152
- package/components/users.js +831 -767
- package/components/webapi.js +118 -118
- package/examples/README.md +35 -35
- package/examples/accept_all_confirmations.js +173 -173
- package/examples/disable_twofactor.js +135 -135
- package/examples/edit-group-announcement.js +118 -118
- package/examples/enable_twofactor.js +182 -182
- package/index.js +13 -151
- package/package.json +11 -6
- package/resources/EChatState.js +14 -14
- package/resources/EConfirmationType.js +12 -12
- package/resources/EFriendRelationship.js +23 -23
- package/resources/EPersonaState.js +23 -23
- package/resources/EPersonaStateFlag.js +32 -32
- package/resources/EResult.js +254 -254
- package/.editorconfig +0 -13
- package/.github/FUNDING.yml +0 -2
- package/.idea/.name +0 -1
- package/.idea/codeStyleSettings.xml +0 -13
- package/.idea/codeStyles/Project.xml +0 -15
- package/.idea/codeStyles/codeStyleConfig.xml +0 -6
- package/.idea/copyright/profiles_settings.xml +0 -3
- package/.idea/encodings.xml +0 -6
- package/.idea/inspectionProfiles/Project_Default.xml +0 -11
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -9
- package/.idea/node-steamcommunity.iml +0 -8
- package/.idea/steamcommunity.iml +0 -10
- package/.idea/vcs.xml +0 -7
- package/.idea/watcherTasks.xml +0 -4
- package/CONTRIBUTING.md +0 -36
|
@@ -1,182 +1,182 @@
|
|
|
1
|
-
// If you aren't running this script inside of the repository, replace the following line with:
|
|
2
|
-
// const SteamCommunity = require('steamcommunity');
|
|
3
|
-
const SteamCommunity = require('../index.js');
|
|
4
|
-
const SteamSession = require('steam-session');
|
|
5
|
-
const ReadLine = require('readline');
|
|
6
|
-
const FS = require('fs');
|
|
7
|
-
|
|
8
|
-
const EResult = SteamCommunity.EResult;
|
|
9
|
-
|
|
10
|
-
let g_AbortPromptFunc = null;
|
|
11
|
-
|
|
12
|
-
let community = new SteamCommunity();
|
|
13
|
-
|
|
14
|
-
main();
|
|
15
|
-
async function main() {
|
|
16
|
-
let accountName = await promptAsync('Username: ');
|
|
17
|
-
let password = await promptAsync('Password (hidden): ', true);
|
|
18
|
-
|
|
19
|
-
// Create a LoginSession for us to use to attempt to log into steam
|
|
20
|
-
let session = new SteamSession.LoginSession(SteamSession.EAuthTokenPlatformType.MobileApp);
|
|
21
|
-
|
|
22
|
-
// Go ahead and attach our event handlers before we do anything else.
|
|
23
|
-
session.on('authenticated', async () => {
|
|
24
|
-
abortPrompt();
|
|
25
|
-
|
|
26
|
-
let accessToken = session.accessToken;
|
|
27
|
-
let cookies = await session.getWebCookies();
|
|
28
|
-
|
|
29
|
-
community.setCookies(cookies);
|
|
30
|
-
community.setMobileAppAccessToken(accessToken);
|
|
31
|
-
|
|
32
|
-
// Enabling or disabling 2FA is presently the only action in node-steamcommunity which requires an access token.
|
|
33
|
-
// In all other cases, using `community.setCookies(cookies)` is all you need to do in order to be logged in,
|
|
34
|
-
// although there's never any harm in setting a mobile app access token.
|
|
35
|
-
|
|
36
|
-
doSetup();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
session.on('timeout', () => {
|
|
40
|
-
abortPrompt();
|
|
41
|
-
console.log('This login attempt has timed out.');
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
session.on('error', (err) => {
|
|
45
|
-
abortPrompt();
|
|
46
|
-
|
|
47
|
-
// This should ordinarily not happen. This only happens in case there's some kind of unexpected error while
|
|
48
|
-
// polling, e.g. the network connection goes down or Steam chokes on something.
|
|
49
|
-
|
|
50
|
-
console.log(`ERROR: This login attempt has failed! ${err.message}`);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// Start our login attempt
|
|
54
|
-
let startResult = await session.startWithCredentials({accountName, password});
|
|
55
|
-
if (startResult.actionRequired) {
|
|
56
|
-
// Some Steam Guard action is required. We only care about email and device codes; in theory an
|
|
57
|
-
// EmailConfirmation and/or DeviceConfirmation action could be possible, but we're just going to ignore those.
|
|
58
|
-
// If the user does receive a confirmation and accepts it, LoginSession will detect and handle that automatically.
|
|
59
|
-
// The only consequence of ignoring it here is that we don't print a message to the user indicating that they
|
|
60
|
-
// could accept an email or device confirmation.
|
|
61
|
-
|
|
62
|
-
let codeActionTypes = [SteamSession.EAuthSessionGuardType.EmailCode, SteamSession.EAuthSessionGuardType.DeviceCode];
|
|
63
|
-
let codeAction = startResult.validActions.find(action => codeActionTypes.includes(action.type));
|
|
64
|
-
if (codeAction) {
|
|
65
|
-
if (codeAction.type == SteamSession.EAuthSessionGuardType.EmailCode) {
|
|
66
|
-
console.log(`A code has been sent to your email address at ${codeAction.detail}.`);
|
|
67
|
-
} else {
|
|
68
|
-
// We wouldn't expect this to happen since we're trying to enable 2FA, but just in case...
|
|
69
|
-
console.log('You need to provide a Steam Guard Mobile Authenticator code.');
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
let code = await promptAsync('Code: ');
|
|
73
|
-
if (code) {
|
|
74
|
-
await session.submitSteamGuardCode(code);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// If we fall through here without submitting a Steam Guard code, that means one of two things:
|
|
78
|
-
// 1. The user pressed enter without providing a code, in which case the script will simply exit
|
|
79
|
-
// 2. The user approved a device/email confirmation, in which case 'authenticated' was emitted and the prompt was canceled
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function doSetup() {
|
|
85
|
-
community.enableTwoFactor((err, response) => {
|
|
86
|
-
if (err) {
|
|
87
|
-
if (err.eresult == EResult.Fail) {
|
|
88
|
-
console.log('Error: Failed to enable two-factor authentication. Do you have a phone number attached to your account?');
|
|
89
|
-
process.exit();
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (err.eresult == EResult.RateLimitExceeded) {
|
|
94
|
-
console.log('Error: RateLimitExceeded. Try again later.');
|
|
95
|
-
process.exit();
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
console.log(err);
|
|
100
|
-
process.exit();
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (response.status != EResult.OK) {
|
|
105
|
-
console.log(`Error: Status ${response.status}`);
|
|
106
|
-
process.exit();
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
let filename = `twofactor_${community.steamID.getSteamID64()}.json`;
|
|
111
|
-
console.log(`Writing secrets to ${filename}`);
|
|
112
|
-
console.log(`Revocation code: ${response.revocation_code}`);
|
|
113
|
-
FS.writeFileSync(filename, JSON.stringify(response, null, '\t'));
|
|
114
|
-
|
|
115
|
-
promptActivationCode(response);
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
async function promptActivationCode(response) {
|
|
120
|
-
if (response.phone_number_hint) {
|
|
121
|
-
console.log(`A code has been sent to your phone ending in ${response.phone_number_hint}.`);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
let smsCode = await promptAsync('SMS Code: ');
|
|
125
|
-
community.finalizeTwoFactor(response.shared_secret, smsCode, (err) => {
|
|
126
|
-
if (err) {
|
|
127
|
-
if (err.message == 'Invalid activation code') {
|
|
128
|
-
console.log(err);
|
|
129
|
-
promptActivationCode(response);
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
console.log(err);
|
|
134
|
-
} else {
|
|
135
|
-
console.log('Two-factor authentication enabled!');
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
process.exit();
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Nothing interesting below here, just code for prompting for input from the console.
|
|
143
|
-
|
|
144
|
-
function promptAsync(question, sensitiveInput = false) {
|
|
145
|
-
return new Promise((resolve) => {
|
|
146
|
-
let rl = ReadLine.createInterface({
|
|
147
|
-
input: process.stdin,
|
|
148
|
-
output: sensitiveInput ? null : process.stdout,
|
|
149
|
-
terminal: true
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
g_AbortPromptFunc = () => {
|
|
153
|
-
rl.close();
|
|
154
|
-
resolve('');
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
if (sensitiveInput) {
|
|
158
|
-
// We have to write the question manually if we didn't give readline an output stream
|
|
159
|
-
process.stdout.write(question);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
rl.question(question, (result) => {
|
|
163
|
-
if (sensitiveInput) {
|
|
164
|
-
// We have to manually print a newline
|
|
165
|
-
process.stdout.write('\n');
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
g_AbortPromptFunc = null;
|
|
169
|
-
rl.close();
|
|
170
|
-
resolve(result);
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function abortPrompt() {
|
|
176
|
-
if (!g_AbortPromptFunc) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
g_AbortPromptFunc();
|
|
181
|
-
process.stdout.write('\n');
|
|
182
|
-
}
|
|
1
|
+
// If you aren't running this script inside of the repository, replace the following line with:
|
|
2
|
+
// const SteamCommunity = require('steamcommunity');
|
|
3
|
+
const SteamCommunity = require('../index.js');
|
|
4
|
+
const SteamSession = require('steam-session');
|
|
5
|
+
const ReadLine = require('readline');
|
|
6
|
+
const FS = require('fs');
|
|
7
|
+
|
|
8
|
+
const EResult = SteamCommunity.EResult;
|
|
9
|
+
|
|
10
|
+
let g_AbortPromptFunc = null;
|
|
11
|
+
|
|
12
|
+
let community = new SteamCommunity();
|
|
13
|
+
|
|
14
|
+
main();
|
|
15
|
+
async function main() {
|
|
16
|
+
let accountName = await promptAsync('Username: ');
|
|
17
|
+
let password = await promptAsync('Password (hidden): ', true);
|
|
18
|
+
|
|
19
|
+
// Create a LoginSession for us to use to attempt to log into steam
|
|
20
|
+
let session = new SteamSession.LoginSession(SteamSession.EAuthTokenPlatformType.MobileApp);
|
|
21
|
+
|
|
22
|
+
// Go ahead and attach our event handlers before we do anything else.
|
|
23
|
+
session.on('authenticated', async () => {
|
|
24
|
+
abortPrompt();
|
|
25
|
+
|
|
26
|
+
let accessToken = session.accessToken;
|
|
27
|
+
let cookies = await session.getWebCookies();
|
|
28
|
+
|
|
29
|
+
community.setCookies(cookies);
|
|
30
|
+
community.setMobileAppAccessToken(accessToken);
|
|
31
|
+
|
|
32
|
+
// Enabling or disabling 2FA is presently the only action in node-steamcommunity which requires an access token.
|
|
33
|
+
// In all other cases, using `community.setCookies(cookies)` is all you need to do in order to be logged in,
|
|
34
|
+
// although there's never any harm in setting a mobile app access token.
|
|
35
|
+
|
|
36
|
+
doSetup();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
session.on('timeout', () => {
|
|
40
|
+
abortPrompt();
|
|
41
|
+
console.log('This login attempt has timed out.');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
session.on('error', (err) => {
|
|
45
|
+
abortPrompt();
|
|
46
|
+
|
|
47
|
+
// This should ordinarily not happen. This only happens in case there's some kind of unexpected error while
|
|
48
|
+
// polling, e.g. the network connection goes down or Steam chokes on something.
|
|
49
|
+
|
|
50
|
+
console.log(`ERROR: This login attempt has failed! ${err.message}`);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Start our login attempt
|
|
54
|
+
let startResult = await session.startWithCredentials({accountName, password});
|
|
55
|
+
if (startResult.actionRequired) {
|
|
56
|
+
// Some Steam Guard action is required. We only care about email and device codes; in theory an
|
|
57
|
+
// EmailConfirmation and/or DeviceConfirmation action could be possible, but we're just going to ignore those.
|
|
58
|
+
// If the user does receive a confirmation and accepts it, LoginSession will detect and handle that automatically.
|
|
59
|
+
// The only consequence of ignoring it here is that we don't print a message to the user indicating that they
|
|
60
|
+
// could accept an email or device confirmation.
|
|
61
|
+
|
|
62
|
+
let codeActionTypes = [SteamSession.EAuthSessionGuardType.EmailCode, SteamSession.EAuthSessionGuardType.DeviceCode];
|
|
63
|
+
let codeAction = startResult.validActions.find(action => codeActionTypes.includes(action.type));
|
|
64
|
+
if (codeAction) {
|
|
65
|
+
if (codeAction.type == SteamSession.EAuthSessionGuardType.EmailCode) {
|
|
66
|
+
console.log(`A code has been sent to your email address at ${codeAction.detail}.`);
|
|
67
|
+
} else {
|
|
68
|
+
// We wouldn't expect this to happen since we're trying to enable 2FA, but just in case...
|
|
69
|
+
console.log('You need to provide a Steam Guard Mobile Authenticator code.');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
let code = await promptAsync('Code: ');
|
|
73
|
+
if (code) {
|
|
74
|
+
await session.submitSteamGuardCode(code);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// If we fall through here without submitting a Steam Guard code, that means one of two things:
|
|
78
|
+
// 1. The user pressed enter without providing a code, in which case the script will simply exit
|
|
79
|
+
// 2. The user approved a device/email confirmation, in which case 'authenticated' was emitted and the prompt was canceled
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function doSetup() {
|
|
85
|
+
community.enableTwoFactor((err, response) => {
|
|
86
|
+
if (err) {
|
|
87
|
+
if (err.eresult == EResult.Fail) {
|
|
88
|
+
console.log('Error: Failed to enable two-factor authentication. Do you have a phone number attached to your account?');
|
|
89
|
+
process.exit();
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (err.eresult == EResult.RateLimitExceeded) {
|
|
94
|
+
console.log('Error: RateLimitExceeded. Try again later.');
|
|
95
|
+
process.exit();
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
console.log(err);
|
|
100
|
+
process.exit();
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (response.status != EResult.OK) {
|
|
105
|
+
console.log(`Error: Status ${response.status}`);
|
|
106
|
+
process.exit();
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
let filename = `twofactor_${community.steamID.getSteamID64()}.json`;
|
|
111
|
+
console.log(`Writing secrets to ${filename}`);
|
|
112
|
+
console.log(`Revocation code: ${response.revocation_code}`);
|
|
113
|
+
FS.writeFileSync(filename, JSON.stringify(response, null, '\t'));
|
|
114
|
+
|
|
115
|
+
promptActivationCode(response);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async function promptActivationCode(response) {
|
|
120
|
+
if (response.phone_number_hint) {
|
|
121
|
+
console.log(`A code has been sent to your phone ending in ${response.phone_number_hint}.`);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
let smsCode = await promptAsync('SMS Code: ');
|
|
125
|
+
community.finalizeTwoFactor(response.shared_secret, smsCode, (err) => {
|
|
126
|
+
if (err) {
|
|
127
|
+
if (err.message == 'Invalid activation code') {
|
|
128
|
+
console.log(err);
|
|
129
|
+
promptActivationCode(response);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
console.log(err);
|
|
134
|
+
} else {
|
|
135
|
+
console.log('Two-factor authentication enabled!');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
process.exit();
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Nothing interesting below here, just code for prompting for input from the console.
|
|
143
|
+
|
|
144
|
+
function promptAsync(question, sensitiveInput = false) {
|
|
145
|
+
return new Promise((resolve) => {
|
|
146
|
+
let rl = ReadLine.createInterface({
|
|
147
|
+
input: process.stdin,
|
|
148
|
+
output: sensitiveInput ? null : process.stdout,
|
|
149
|
+
terminal: true
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
g_AbortPromptFunc = () => {
|
|
153
|
+
rl.close();
|
|
154
|
+
resolve('');
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
if (sensitiveInput) {
|
|
158
|
+
// We have to write the question manually if we didn't give readline an output stream
|
|
159
|
+
process.stdout.write(question);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
rl.question(question, (result) => {
|
|
163
|
+
if (sensitiveInput) {
|
|
164
|
+
// We have to manually print a newline
|
|
165
|
+
process.stdout.write('\n');
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
g_AbortPromptFunc = null;
|
|
169
|
+
rl.close();
|
|
170
|
+
resolve(result);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function abortPrompt() {
|
|
176
|
+
if (!g_AbortPromptFunc) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
g_AbortPromptFunc();
|
|
181
|
+
process.stdout.write('\n');
|
|
182
|
+
}
|
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,7 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "steamcommunity",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.47.1",
|
|
4
4
|
"description": "Provides an interface for logging into and interacting with the Steam Community website",
|
|
5
|
+
"files": [
|
|
6
|
+
"/classes",
|
|
7
|
+
"/components",
|
|
8
|
+
"/examples",
|
|
9
|
+
"/resources",
|
|
10
|
+
"/index.js"
|
|
11
|
+
],
|
|
5
12
|
"keywords": [
|
|
6
13
|
"steam",
|
|
7
14
|
"steam community"
|
|
@@ -21,17 +28,15 @@
|
|
|
21
28
|
"url": "https://github.com/DoctorMcKay/node-steamcommunity.git"
|
|
22
29
|
},
|
|
23
30
|
"dependencies": {
|
|
31
|
+
"@doctormckay/user-agents": "^1.0.0",
|
|
24
32
|
"async": "^2.6.3",
|
|
25
33
|
"cheerio": "0.22.0",
|
|
26
34
|
"image-size": "^0.8.2",
|
|
27
|
-
"node-bignumber": "^1.2.1",
|
|
28
35
|
"request": "^2.88.0",
|
|
36
|
+
"steam-session": "^1.6.0",
|
|
29
37
|
"steam-totp": "^1.5.0",
|
|
30
38
|
"steamid": "^1.1.3",
|
|
31
|
-
"xml2js": "^0.
|
|
32
|
-
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"steam-session": "^1.2.3"
|
|
39
|
+
"xml2js": "^0.6.2"
|
|
35
40
|
},
|
|
36
41
|
"engines": {
|
|
37
42
|
"node": ">=4.0.0"
|
package/resources/EChatState.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @enum EChatState
|
|
3
|
-
*/
|
|
4
|
-
module.exports = {
|
|
5
|
-
"Offline": 0,
|
|
6
|
-
"LoggingOn": 1,
|
|
7
|
-
"LogOnFailed": 2,
|
|
8
|
-
"LoggedOn": 3,
|
|
9
|
-
|
|
10
|
-
"0": "Offline",
|
|
11
|
-
"1": "LoggingOn",
|
|
12
|
-
"2": "LogOnFailed",
|
|
13
|
-
"3": "LoggedOn"
|
|
14
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* @enum EChatState
|
|
3
|
+
*/
|
|
4
|
+
module.exports = {
|
|
5
|
+
"Offline": 0,
|
|
6
|
+
"LoggingOn": 1,
|
|
7
|
+
"LogOnFailed": 2,
|
|
8
|
+
"LoggedOn": 3,
|
|
9
|
+
|
|
10
|
+
"0": "Offline",
|
|
11
|
+
"1": "LoggingOn",
|
|
12
|
+
"2": "LogOnFailed",
|
|
13
|
+
"3": "LoggedOn"
|
|
14
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @enum EConfirmationType
|
|
3
|
-
*/
|
|
4
|
-
module.exports = {
|
|
5
|
-
// 1 is unknown, possibly "Invalid"
|
|
6
|
-
"Trade": 2,
|
|
7
|
-
"MarketListing": 3,
|
|
8
|
-
// 4 is opt-out or other like account confirmation?
|
|
9
|
-
|
|
10
|
-
"2": "Trade",
|
|
11
|
-
"3": "MarketListing"
|
|
12
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* @enum EConfirmationType
|
|
3
|
+
*/
|
|
4
|
+
module.exports = {
|
|
5
|
+
// 1 is unknown, possibly "Invalid"
|
|
6
|
+
"Trade": 2,
|
|
7
|
+
"MarketListing": 3,
|
|
8
|
+
// 4 is opt-out or other like account confirmation?
|
|
9
|
+
|
|
10
|
+
"2": "Trade",
|
|
11
|
+
"3": "MarketListing"
|
|
12
|
+
};
|