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.
Files changed (51) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +22 -22
  3. package/classes/CConfirmation.js +37 -37
  4. package/classes/CEconItem.js +120 -120
  5. package/classes/CMarketItem.js +189 -189
  6. package/classes/CMarketSearchResult.js +89 -89
  7. package/classes/CSteamGroup.js +155 -155
  8. package/classes/CSteamUser.js +225 -217
  9. package/components/chat.js +283 -283
  10. package/components/confirmations.js +428 -428
  11. package/components/groups.js +798 -732
  12. package/components/help.js +64 -64
  13. package/components/helpers.js +128 -108
  14. package/components/http.js +150 -150
  15. package/components/inventoryhistory.js +173 -173
  16. package/components/login.js +110 -0
  17. package/components/market.js +387 -387
  18. package/components/profile.js +475 -475
  19. package/components/twofactor.js +152 -152
  20. package/components/users.js +831 -767
  21. package/components/webapi.js +118 -118
  22. package/examples/README.md +35 -35
  23. package/examples/accept_all_confirmations.js +173 -173
  24. package/examples/disable_twofactor.js +135 -135
  25. package/examples/edit-group-announcement.js +118 -118
  26. package/examples/enable_twofactor.js +182 -182
  27. package/index.js +13 -151
  28. package/package.json +11 -6
  29. package/resources/EChatState.js +14 -14
  30. package/resources/EConfirmationType.js +12 -12
  31. package/resources/EFriendRelationship.js +23 -23
  32. package/resources/EPersonaState.js +23 -23
  33. package/resources/EPersonaStateFlag.js +32 -32
  34. package/resources/EResult.js +254 -254
  35. package/.editorconfig +0 -13
  36. package/.github/FUNDING.yml +0 -2
  37. package/.idea/.name +0 -1
  38. package/.idea/codeStyleSettings.xml +0 -13
  39. package/.idea/codeStyles/Project.xml +0 -15
  40. package/.idea/codeStyles/codeStyleConfig.xml +0 -6
  41. package/.idea/copyright/profiles_settings.xml +0 -3
  42. package/.idea/encodings.xml +0 -6
  43. package/.idea/inspectionProfiles/Project_Default.xml +0 -11
  44. package/.idea/jsLibraryMappings.xml +0 -6
  45. package/.idea/misc.xml +0 -6
  46. package/.idea/modules.xml +0 -9
  47. package/.idea/node-steamcommunity.iml +0 -8
  48. package/.idea/steamcommunity.iml +0 -10
  49. package/.idea/vcs.xml +0 -7
  50. package/.idea/watcherTasks.xml +0 -4
  51. package/CONTRIBUTING.md +0 -36
@@ -1,135 +1,135 @@
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
-
7
- let g_AbortPromptFunc = null;
8
-
9
- let community = new SteamCommunity();
10
-
11
- main();
12
- async function main() {
13
- let accountName = await promptAsync('Username: ');
14
- let password = await promptAsync('Password (hidden): ', true);
15
-
16
- // Create a LoginSession for us to use to attempt to log into steam
17
- let session = new SteamSession.LoginSession(SteamSession.EAuthTokenPlatformType.MobileApp);
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();
25
-
26
- community.setCookies(cookies);
27
- community.setMobileAppAccessToken(accessToken);
28
-
29
- // Enabling or disabling 2FA is presently the only action in node-steamcommunity which requires an access token.
30
- // In all other cases, using `community.setCookies(cookies)` is all you need to do in order to be logged in,
31
- // although there's never any harm in setting a mobile app access token.
32
-
33
- doRevoke();
34
- });
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
- }
80
-
81
- async function doRevoke() {
82
- let rCode = await promptAsync('Revocation Code: R');
83
- community.disableTwoFactor('R' + rCode, (err) => {
84
- if (err) {
85
- console.log(err);
86
- process.exit();
87
- return;
88
- }
89
-
90
- console.log('Two-factor authentication disabled!');
91
- process.exit();
92
- });
93
- }
94
-
95
- // Nothing interesting below here, just code for prompting for input from the console.
96
-
97
- function promptAsync(question, sensitiveInput = false) {
98
- return new Promise((resolve) => {
99
- let rl = ReadLine.createInterface({
100
- input: process.stdin,
101
- output: sensitiveInput ? null : process.stdout,
102
- terminal: true
103
- });
104
-
105
- g_AbortPromptFunc = () => {
106
- rl.close();
107
- resolve('');
108
- };
109
-
110
- if (sensitiveInput) {
111
- // We have to write the question manually if we didn't give readline an output stream
112
- process.stdout.write(question);
113
- }
114
-
115
- rl.question(question, (result) => {
116
- if (sensitiveInput) {
117
- // We have to manually print a newline
118
- process.stdout.write('\n');
119
- }
120
-
121
- g_AbortPromptFunc = null;
122
- rl.close();
123
- resolve(result);
124
- });
125
- });
126
- }
127
-
128
- function abortPrompt() {
129
- if (!g_AbortPromptFunc) {
130
- return;
131
- }
132
-
133
- g_AbortPromptFunc();
134
- process.stdout.write('\n');
135
- }
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
+
7
+ let g_AbortPromptFunc = null;
8
+
9
+ let community = new SteamCommunity();
10
+
11
+ main();
12
+ async function main() {
13
+ let accountName = await promptAsync('Username: ');
14
+ let password = await promptAsync('Password (hidden): ', true);
15
+
16
+ // Create a LoginSession for us to use to attempt to log into steam
17
+ let session = new SteamSession.LoginSession(SteamSession.EAuthTokenPlatformType.MobileApp);
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();
25
+
26
+ community.setCookies(cookies);
27
+ community.setMobileAppAccessToken(accessToken);
28
+
29
+ // Enabling or disabling 2FA is presently the only action in node-steamcommunity which requires an access token.
30
+ // In all other cases, using `community.setCookies(cookies)` is all you need to do in order to be logged in,
31
+ // although there's never any harm in setting a mobile app access token.
32
+
33
+ doRevoke();
34
+ });
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
+ }
80
+
81
+ async function doRevoke() {
82
+ let rCode = await promptAsync('Revocation Code: R');
83
+ community.disableTwoFactor('R' + rCode, (err) => {
84
+ if (err) {
85
+ console.log(err);
86
+ process.exit();
87
+ return;
88
+ }
89
+
90
+ console.log('Two-factor authentication disabled!');
91
+ process.exit();
92
+ });
93
+ }
94
+
95
+ // Nothing interesting below here, just code for prompting for input from the console.
96
+
97
+ function promptAsync(question, sensitiveInput = false) {
98
+ return new Promise((resolve) => {
99
+ let rl = ReadLine.createInterface({
100
+ input: process.stdin,
101
+ output: sensitiveInput ? null : process.stdout,
102
+ terminal: true
103
+ });
104
+
105
+ g_AbortPromptFunc = () => {
106
+ rl.close();
107
+ resolve('');
108
+ };
109
+
110
+ if (sensitiveInput) {
111
+ // We have to write the question manually if we didn't give readline an output stream
112
+ process.stdout.write(question);
113
+ }
114
+
115
+ rl.question(question, (result) => {
116
+ if (sensitiveInput) {
117
+ // We have to manually print a newline
118
+ process.stdout.write('\n');
119
+ }
120
+
121
+ g_AbortPromptFunc = null;
122
+ rl.close();
123
+ resolve(result);
124
+ });
125
+ });
126
+ }
127
+
128
+ function abortPrompt() {
129
+ if (!g_AbortPromptFunc) {
130
+ return;
131
+ }
132
+
133
+ g_AbortPromptFunc();
134
+ process.stdout.write('\n');
135
+ }
@@ -1,118 +1,118 @@
1
- var SteamCommunity = require('../index.js');
2
- var ReadLine = require('readline');
3
-
4
- var community = new SteamCommunity();
5
- var rl = ReadLine.createInterface({
6
- "input": process.stdin,
7
- "output": process.stdout
8
- });
9
-
10
- rl.question("Username: ", function(accountName) {
11
- rl.question("Password: ", function(password) {
12
- doLogin(accountName, password);
13
- });
14
- });
15
-
16
- function doLogin(accountName, password, authCode, twoFactorCode, captcha) {
17
- community.login({
18
- "accountName": accountName,
19
- "password": password,
20
- "authCode": authCode,
21
- "twoFactorCode": twoFactorCode,
22
- "captcha": captcha
23
- }, function(err, sessionID, cookies, steamguard) {
24
- if(err) {
25
- if(err.message == 'SteamGuardMobile') {
26
- rl.question("Steam Authenticator Code: ", function(code) {
27
- doLogin(accountName, password, null, code);
28
- });
29
-
30
- return;
31
- }
32
-
33
- if(err.message == 'SteamGuard') {
34
- console.log("An email has been sent to your address at " + err.emaildomain);
35
- rl.question("Steam Guard Code: ", function(code) {
36
- doLogin(accountName, password, code);
37
- });
38
-
39
- return;
40
- }
41
-
42
- if(err.message == 'CAPTCHA') {
43
- console.log(err.captchaurl);
44
- rl.question("CAPTCHA: ", function(captchaInput) {
45
- doLogin(accountName, password, authCode, twoFactorCode, captchaInput);
46
- });
47
-
48
- return;
49
- }
50
-
51
- console.log(err);
52
- process.exit();
53
- return;
54
- }
55
-
56
- console.log("Logged on!");
57
-
58
- rl.question("Group ID: ", function(gid) {
59
- community.getSteamGroup(gid, function(err, group) {
60
- if (err) {
61
- console.log(err);
62
- process.exit(1);
63
- }
64
-
65
- group.getAllAnnouncements(function(err, announcements) {
66
-
67
- if(announcements.length === 0) {
68
- return console.log("This group has no announcements");
69
- }
70
-
71
- for (var i = announcements.length - 1; i >= 0; i--) {
72
- console.log("[%s] %s %s: %s", announcements[i].date, announcements[i].aid, announcements[i].author, announcements[i].content);
73
- };
74
-
75
- rl.question("Would you like to delete delete or edit an annoucement? (Type edit/delete): ", function(choice) {
76
- rl.question("Annoucement ID: ", function(aid) {
77
- if(choice === 'edit') {
78
- rl.question("New title: ", function(header) {
79
- rl.question("New body: ", function(content) {
80
- // EW THE PYRAMID!
81
- // Try replace this with delete!
82
- editAnnouncement(group, aid, header, content);
83
- });
84
- });
85
- } else {
86
- deleteAnnouncement(group, aid);
87
- }
88
- });
89
- });
90
- });
91
- });
92
- });
93
- });
94
- }
95
-
96
- function editAnnouncement(group, aid, header, content) {
97
- // Actual community method.
98
- group.editAnnouncement(aid, header, content, function(error) {
99
- if(!error) {
100
- console.log("Annoucement edited!");
101
- } else {
102
- console.log("Unable to edit annoucement! %j", error);
103
- process.exit(1);
104
- }
105
- });
106
- }
107
-
108
- function deleteAnnouncement(group, aid) {
109
- // group.deleteAnnouncement(aid);
110
- // Or
111
- group.deleteAnnouncement(aid, function(err) {
112
- if(!err) {
113
- console.log("Deleted");
114
- } else {
115
- console.log("Error deleting announcement.");
116
- }
117
- })
118
- }
1
+ var SteamCommunity = require('../index.js');
2
+ var ReadLine = require('readline');
3
+
4
+ var community = new SteamCommunity();
5
+ var rl = ReadLine.createInterface({
6
+ "input": process.stdin,
7
+ "output": process.stdout
8
+ });
9
+
10
+ rl.question("Username: ", function(accountName) {
11
+ rl.question("Password: ", function(password) {
12
+ doLogin(accountName, password);
13
+ });
14
+ });
15
+
16
+ function doLogin(accountName, password, authCode, twoFactorCode, captcha) {
17
+ community.login({
18
+ "accountName": accountName,
19
+ "password": password,
20
+ "authCode": authCode,
21
+ "twoFactorCode": twoFactorCode,
22
+ "captcha": captcha
23
+ }, function(err, sessionID, cookies, steamguard) {
24
+ if(err) {
25
+ if(err.message == 'SteamGuardMobile') {
26
+ rl.question("Steam Authenticator Code: ", function(code) {
27
+ doLogin(accountName, password, null, code);
28
+ });
29
+
30
+ return;
31
+ }
32
+
33
+ if(err.message == 'SteamGuard') {
34
+ console.log("An email has been sent to your address at " + err.emaildomain);
35
+ rl.question("Steam Guard Code: ", function(code) {
36
+ doLogin(accountName, password, code);
37
+ });
38
+
39
+ return;
40
+ }
41
+
42
+ if(err.message == 'CAPTCHA') {
43
+ console.log(err.captchaurl);
44
+ rl.question("CAPTCHA: ", function(captchaInput) {
45
+ doLogin(accountName, password, authCode, twoFactorCode, captchaInput);
46
+ });
47
+
48
+ return;
49
+ }
50
+
51
+ console.log(err);
52
+ process.exit();
53
+ return;
54
+ }
55
+
56
+ console.log("Logged on!");
57
+
58
+ rl.question("Group ID: ", function(gid) {
59
+ community.getSteamGroup(gid, function(err, group) {
60
+ if (err) {
61
+ console.log(err);
62
+ process.exit(1);
63
+ }
64
+
65
+ group.getAllAnnouncements(function(err, announcements) {
66
+
67
+ if(announcements.length === 0) {
68
+ return console.log("This group has no announcements");
69
+ }
70
+
71
+ for (var i = announcements.length - 1; i >= 0; i--) {
72
+ console.log("[%s] %s %s: %s", announcements[i].date, announcements[i].aid, announcements[i].author, announcements[i].content);
73
+ };
74
+
75
+ rl.question("Would you like to delete delete or edit an annoucement? (Type edit/delete): ", function(choice) {
76
+ rl.question("Annoucement ID: ", function(aid) {
77
+ if(choice === 'edit') {
78
+ rl.question("New title: ", function(header) {
79
+ rl.question("New body: ", function(content) {
80
+ // EW THE PYRAMID!
81
+ // Try replace this with delete!
82
+ editAnnouncement(group, aid, header, content);
83
+ });
84
+ });
85
+ } else {
86
+ deleteAnnouncement(group, aid);
87
+ }
88
+ });
89
+ });
90
+ });
91
+ });
92
+ });
93
+ });
94
+ }
95
+
96
+ function editAnnouncement(group, aid, header, content) {
97
+ // Actual community method.
98
+ group.editAnnouncement(aid, header, content, function(error) {
99
+ if(!error) {
100
+ console.log("Annoucement edited!");
101
+ } else {
102
+ console.log("Unable to edit annoucement! %j", error);
103
+ process.exit(1);
104
+ }
105
+ });
106
+ }
107
+
108
+ function deleteAnnouncement(group, aid) {
109
+ // group.deleteAnnouncement(aid);
110
+ // Or
111
+ group.deleteAnnouncement(aid, function(err) {
112
+ if(!err) {
113
+ console.log("Deleted");
114
+ } else {
115
+ console.log("Error deleting announcement.");
116
+ }
117
+ })
118
+ }