steamcommunity 3.47.0 → 3.48.0
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/classes/CConfirmation.js +37 -37
- package/classes/CEconItem.js +120 -120
- package/classes/CSteamSharedFile.js +221 -221
- package/classes/CSteamUser.js +225 -225
- package/components/confirmations.js +428 -428
- package/components/groups.js +798 -798
- package/components/help.js +64 -64
- package/components/helpers.js +128 -128
- 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/sharedfiles.js +158 -158
- package/components/twofactor.js +152 -152
- package/components/users.js +831 -831
- package/components/webapi.js +128 -25
- package/examples/disable_twofactor.js +22 -59
- package/examples/enable_twofactor.js +22 -61
- package/index.js +462 -600
- package/package.json +44 -46
- 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/components/webapi.js
CHANGED
|
@@ -1,49 +1,152 @@
|
|
|
1
|
-
|
|
1
|
+
const SteamCommunity = require('../index.js');
|
|
2
2
|
|
|
3
3
|
const Helpers = require('./helpers.js');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves your account's Steam Web API key, if you already have one. If you don't yet have one, this will fail.
|
|
7
|
+
* To create a Web API key, use `createWebApiKey()`.
|
|
8
|
+
*
|
|
9
|
+
* @param {null|function} unused - No longer used, kept for backward compatibility. You can omit this parameter and pass
|
|
10
|
+
* your callback directly as the first parameter if you want.
|
|
11
|
+
* @param {function} callback
|
|
12
|
+
*/
|
|
13
|
+
SteamCommunity.prototype.getWebApiKey = function(unused, callback) {
|
|
14
|
+
if (typeof unused == 'function') {
|
|
15
|
+
callback = unused;
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
this.httpRequest({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
19
|
+
uri: 'https://steamcommunity.com/dev/apikey?l=english',
|
|
20
|
+
followRedirect: false
|
|
21
|
+
}, (err, response, body) => {
|
|
11
22
|
if (err) {
|
|
12
23
|
callback(err);
|
|
13
24
|
return;
|
|
14
25
|
}
|
|
15
26
|
|
|
16
|
-
if(body.match(
|
|
17
|
-
return callback(new Error(
|
|
27
|
+
if (body.match(/You must have a validated email address to create a Steam Web API key./)) {
|
|
28
|
+
return callback(new Error('You must have a validated email address to create a Steam Web API key.'));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (body.match(/Your account requires (<a [^>]+>)?Steam Guard Mobile Authenticator/)) {
|
|
32
|
+
return callback(new Error('Steam Guard Mobile Authenticator required to create a Steam Web API key'));
|
|
18
33
|
}
|
|
19
34
|
|
|
20
|
-
if(body.match(
|
|
21
|
-
return callback(new Error(
|
|
35
|
+
if (body.match(/<h2>Access Denied<\/h2>/)) {
|
|
36
|
+
return callback(new Error('Access Denied'));
|
|
22
37
|
}
|
|
23
38
|
|
|
24
|
-
|
|
25
|
-
if(match) {
|
|
39
|
+
let match = body.match(/<p>Key: ([0-9A-F]+)<\/p>/);
|
|
40
|
+
if (match) {
|
|
26
41
|
// We already have an API key registered
|
|
27
42
|
callback(null, match[1]);
|
|
28
43
|
} else {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
44
|
+
callback(new Error('No API key created for this account'));
|
|
45
|
+
}
|
|
46
|
+
}, "steamcommunity");
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @typedef CreateApiKeyOptions
|
|
51
|
+
* @property {string} domain - The domain to associate with your API key
|
|
52
|
+
* @property {string} [requestID] - If finalizing an existing create request, include the request ID
|
|
53
|
+
* @property {string|Buffer} [identitySecret] - If you pass your identity_secret here, then steamcommunity will
|
|
54
|
+
* internally handle accepting any confirmations.
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @typedef CreateApiKeyResponse
|
|
59
|
+
* @property {boolean} confirmationRequired
|
|
60
|
+
* @property {string} [apiKey] - If creating your API key succeeded, this is the new key
|
|
61
|
+
* @property {CreateApiKeyOptions} [finalizeOptions] - If confirmation is required to create a key, then accept the
|
|
62
|
+
* confirmation, then call createWebApiKey again and pass this whole object for the `options` parameter.
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @callback createWebApiKeyCallback
|
|
67
|
+
* @param {Error|null} err
|
|
68
|
+
* @param {CreateApiKeyResponse} [result]
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Starts the process to create a Steam Web API key. When the callback is fired, you will need to approve a mobile
|
|
73
|
+
* confirmation in your app or using getConfirmations().
|
|
74
|
+
*
|
|
75
|
+
* @param {CreateApiKeyOptions} options
|
|
76
|
+
* @param {createWebApiKeyCallback} callback
|
|
77
|
+
*/
|
|
78
|
+
SteamCommunity.prototype.createWebApiKey = function(options, callback) {
|
|
79
|
+
if (!options.domain) {
|
|
80
|
+
callback(new Error('Passing a domain is required to register an API key'));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
this.httpRequestPost({
|
|
85
|
+
uri: 'https://steamcommunity.com/dev/requestkey',
|
|
86
|
+
form: {
|
|
87
|
+
domain: options.domain,
|
|
88
|
+
request_id: options.requestID || '0',
|
|
89
|
+
sessionid: this.getSessionID(),
|
|
90
|
+
agreeToTerms: 'true'
|
|
91
|
+
},
|
|
92
|
+
json: true
|
|
93
|
+
}, (err, res, body) => {
|
|
94
|
+
if (err) {
|
|
95
|
+
callback(err);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// body.requires_confirmation is 1/0, but the Steam website doesn't check this value and instead only checks the
|
|
100
|
+
// value of `success`. So let's just do that.
|
|
101
|
+
|
|
102
|
+
// This is a mess. I'm glad we have promises and await now.
|
|
103
|
+
|
|
104
|
+
switch (body.success) {
|
|
105
|
+
case SteamCommunity.EResult.OK:
|
|
106
|
+
if (body.api_key) {
|
|
107
|
+
callback(null, {confirmationRequired: false, apiKey: body.api_key});
|
|
108
|
+
return;
|
|
36
109
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
110
|
+
|
|
111
|
+
// It's not been observed that we get result OK without api_key included, but the Steam website doesn't
|
|
112
|
+
// use this value so let's be safe just in case it disappears in the future.
|
|
113
|
+
this.getWebApiKey((err, key) => {
|
|
114
|
+
if (err) {
|
|
115
|
+
callback(err);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
callback(null, {confirmationRequired: false, apiKey: key});
|
|
120
|
+
});
|
|
121
|
+
return;
|
|
122
|
+
|
|
123
|
+
case SteamCommunity.EResult.Pending:
|
|
124
|
+
let finalizeOptions = {
|
|
125
|
+
domain: options.domain,
|
|
126
|
+
requestID: body.request_id || options.requestID
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (options.identitySecret) {
|
|
130
|
+
this.acceptConfirmationForObject(options.identitySecret, finalizeOptions.requestID, (err) => {
|
|
131
|
+
if (err) {
|
|
132
|
+
callback(err);
|
|
133
|
+
} else {
|
|
134
|
+
this.createWebApiKey(finalizeOptions, callback);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
40
137
|
return;
|
|
41
138
|
}
|
|
42
139
|
|
|
43
|
-
|
|
44
|
-
|
|
140
|
+
callback(null, {
|
|
141
|
+
confirmationRequired: true,
|
|
142
|
+
finalizeOptions: finalizeOptions
|
|
143
|
+
});
|
|
144
|
+
return;
|
|
145
|
+
|
|
146
|
+
default:
|
|
147
|
+
callback(Helpers.eresultError(body.success));
|
|
45
148
|
}
|
|
46
|
-
}
|
|
149
|
+
});
|
|
47
150
|
};
|
|
48
151
|
|
|
49
152
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// If you aren't running this script inside of the repository, replace the following line with:
|
|
2
2
|
// const SteamCommunity = require('steamcommunity');
|
|
3
3
|
const SteamCommunity = require('../index.js');
|
|
4
|
-
const
|
|
4
|
+
const SteamTotp = require('steam-totp');
|
|
5
5
|
const ReadLine = require('readline');
|
|
6
6
|
|
|
7
7
|
let g_AbortPromptFunc = null;
|
|
@@ -13,69 +13,32 @@ async function main() {
|
|
|
13
13
|
let accountName = await promptAsync('Username: ');
|
|
14
14
|
let password = await promptAsync('Password (hidden): ', true);
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// Go ahead and attach our event handlers before we do anything else.
|
|
20
|
-
session.on('authenticated', async () => {
|
|
21
|
-
abortPrompt();
|
|
22
|
-
|
|
23
|
-
let accessToken = session.accessToken;
|
|
24
|
-
let cookies = await session.getWebCookies();
|
|
16
|
+
attemptLogin(accountName, password);
|
|
17
|
+
}
|
|
25
18
|
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
function attemptLogin(accountName, password, twoFactorCode) {
|
|
20
|
+
community.login({
|
|
21
|
+
accountName,
|
|
22
|
+
password,
|
|
23
|
+
twoFactorCode,
|
|
24
|
+
disableMobile: false
|
|
25
|
+
}, async (err) => {
|
|
26
|
+
if (err && err.message == 'SteamGuardMobile') {
|
|
27
|
+
let code = await promptAsync('Steam Guard App Code OR Shared Secret: ');
|
|
28
|
+
if (code.length > 5) {
|
|
29
|
+
// If we were provided a shared secret, turn it into a code.
|
|
30
|
+
code = SteamTotp.getAuthCode(code);
|
|
31
|
+
}
|
|
32
|
+
attemptLogin(accountName, password, code);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
28
35
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
if (err) {
|
|
37
|
+
throw err;
|
|
38
|
+
}
|
|
32
39
|
|
|
33
40
|
doRevoke();
|
|
34
41
|
});
|
|
35
|
-
|
|
36
|
-
session.on('timeout', () => {
|
|
37
|
-
abortPrompt();
|
|
38
|
-
console.log('This login attempt has timed out.');
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
session.on('error', (err) => {
|
|
42
|
-
abortPrompt();
|
|
43
|
-
|
|
44
|
-
// This should ordinarily not happen. This only happens in case there's some kind of unexpected error while
|
|
45
|
-
// polling, e.g. the network connection goes down or Steam chokes on something.
|
|
46
|
-
|
|
47
|
-
console.log(`ERROR: This login attempt has failed! ${err.message}`);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
// Start our login attempt
|
|
51
|
-
let startResult = await session.startWithCredentials({accountName, password});
|
|
52
|
-
if (startResult.actionRequired) {
|
|
53
|
-
// Some Steam Guard action is required. We only care about email and device codes; in theory an
|
|
54
|
-
// EmailConfirmation and/or DeviceConfirmation action could be possible, but we're just going to ignore those.
|
|
55
|
-
// If the user does receive a confirmation and accepts it, LoginSession will detect and handle that automatically.
|
|
56
|
-
// The only consequence of ignoring it here is that we don't print a message to the user indicating that they
|
|
57
|
-
// could accept an email or device confirmation.
|
|
58
|
-
|
|
59
|
-
let codeActionTypes = [SteamSession.EAuthSessionGuardType.EmailCode, SteamSession.EAuthSessionGuardType.DeviceCode];
|
|
60
|
-
let codeAction = startResult.validActions.find(action => codeActionTypes.includes(action.type));
|
|
61
|
-
if (codeAction) {
|
|
62
|
-
if (codeAction.type == SteamSession.EAuthSessionGuardType.EmailCode) {
|
|
63
|
-
// We wouldn't expect this to happen since we're trying to disable 2FA, but just in case...
|
|
64
|
-
console.log(`A code has been sent to your email address at ${codeAction.detail}.`);
|
|
65
|
-
} else {
|
|
66
|
-
console.log('You need to provide a Steam Guard Mobile Authenticator code.');
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
let code = await promptAsync('Code: ');
|
|
70
|
-
if (code) {
|
|
71
|
-
await session.submitSteamGuardCode(code);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// If we fall through here without submitting a Steam Guard code, that means one of two things:
|
|
75
|
-
// 1. The user pressed enter without providing a code, in which case the script will simply exit
|
|
76
|
-
// 2. The user approved a device/email confirmation, in which case 'authenticated' was emitted and the prompt was canceled
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
42
|
}
|
|
80
43
|
|
|
81
44
|
async function doRevoke() {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// If you aren't running this script inside of the repository, replace the following line with:
|
|
2
2
|
// const SteamCommunity = require('steamcommunity');
|
|
3
3
|
const SteamCommunity = require('../index.js');
|
|
4
|
-
const SteamSession = require('steam-session');
|
|
5
4
|
const ReadLine = require('readline');
|
|
6
5
|
const FS = require('fs');
|
|
7
6
|
|
|
@@ -16,69 +15,28 @@ async function main() {
|
|
|
16
15
|
let accountName = await promptAsync('Username: ');
|
|
17
16
|
let password = await promptAsync('Password (hidden): ', true);
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
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();
|
|
18
|
+
attemptLogin(accountName, password);
|
|
19
|
+
}
|
|
28
20
|
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
function attemptLogin(accountName, password, authCode) {
|
|
22
|
+
community.login({
|
|
23
|
+
accountName,
|
|
24
|
+
password,
|
|
25
|
+
authCode,
|
|
26
|
+
disableMobile: false
|
|
27
|
+
}, async (err) => {
|
|
28
|
+
if (err && err.message == 'SteamGuard') {
|
|
29
|
+
let code = await promptAsync('Steam Guard Email Code: ');
|
|
30
|
+
attemptLogin(accountName, password, code);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
if (err) {
|
|
35
|
+
throw err;
|
|
36
|
+
}
|
|
35
37
|
|
|
36
38
|
doSetup();
|
|
37
39
|
});
|
|
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
40
|
}
|
|
83
41
|
|
|
84
42
|
function doSetup() {
|
|
@@ -118,10 +76,13 @@ function doSetup() {
|
|
|
118
76
|
|
|
119
77
|
async function promptActivationCode(response) {
|
|
120
78
|
if (response.phone_number_hint) {
|
|
121
|
-
console.log(`
|
|
79
|
+
console.log(`An activation code has been sent to your phone ending in ${response.phone_number_hint}.`);
|
|
80
|
+
} else if (response.confirm_type == 3) {
|
|
81
|
+
// Exact meaning of confirm_type is unknown, but 3 appears to be email code
|
|
82
|
+
console.log('An activation code has been sent to your email.');
|
|
122
83
|
}
|
|
123
84
|
|
|
124
|
-
let smsCode = await promptAsync('
|
|
85
|
+
let smsCode = await promptAsync('Activation Code: ');
|
|
125
86
|
community.finalizeTwoFactor(response.shared_secret, smsCode, (err) => {
|
|
126
87
|
if (err) {
|
|
127
88
|
if (err.message == 'Invalid activation code') {
|