steamcommunity 3.41.8 → 3.44.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.
@@ -1,112 +1,112 @@
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 ReadLine = require('readline');
5
- const FS = require('fs');
6
-
7
- const EResult = SteamCommunity.EResult;
8
-
9
- let community = new SteamCommunity();
10
- let rl = ReadLine.createInterface({
11
- input: process.stdin,
12
- output: process.stdout
13
- });
14
-
15
- rl.question('Username: ', (accountName) => {
16
- rl.question('Password: ', (password) => {
17
- doLogin(accountName, password);
18
- });
19
- });
20
-
21
- function doLogin(accountName, password, authCode, captcha) {
22
- community.login({
23
- accountName: accountName,
24
- password: password,
25
- authCode: authCode,
26
- captcha: captcha
27
- }, (err, sessionID, cookies, steamguard) => {
28
- if (err) {
29
- if (err.message == 'SteamGuardMobile') {
30
- console.log('This account already has two-factor authentication enabled.');
31
- process.exit();
32
- return;
33
- }
34
-
35
- if (err.message == 'SteamGuard') {
36
- console.log(`An email has been sent to your address at ${err.emaildomain}`);
37
- rl.question('Steam Guard Code: ', (code) => {
38
- doLogin(accountName, password, code);
39
- });
40
-
41
- return;
42
- }
43
-
44
- if (err.message == 'CAPTCHA') {
45
- console.log(err.captchaurl);
46
- rl.question('CAPTCHA: ', (captchaInput) => {
47
- doLogin(accountName, password, authCode, captchaInput);
48
- });
49
-
50
- return;
51
- }
52
-
53
- console.log(err);
54
- process.exit();
55
- return;
56
- }
57
-
58
- console.log('Logged on!');
59
- community.enableTwoFactor((err, response) => {
60
- if (err) {
61
- if (err.eresult == EResult.Fail) {
62
- console.log('Error: Failed to enable two-factor authentication. Do you have a phone number attached to your account?');
63
- process.exit();
64
- return;
65
- }
66
-
67
- if (err.eresult == EResult.RateLimitExceeded) {
68
- console.log('Error: RateLimitExceeded. Try again later.');
69
- process.exit();
70
- return;
71
- }
72
-
73
- console.log(err);
74
- process.exit();
75
- return;
76
- }
77
-
78
- if (response.status != EResult.OK) {
79
- console.log(`Error: Status ${response.status}`);
80
- process.exit();
81
- return;
82
- }
83
-
84
- let filename = `twofactor_${community.steamID.getSteamID64()}.json`;
85
- console.log(`Writing secrets to ${filename}`);
86
- console.log(`Revocation code: ${response.revocation_code}`);
87
- FS.writeFileSync(filename, JSON.stringify(response, null, '\t'));
88
-
89
- promptActivationCode(response);
90
- });
91
- });
92
- }
93
-
94
- function promptActivationCode(response) {
95
- rl.question('SMS Code: ', (smsCode) => {
96
- community.finalizeTwoFactor(response.shared_secret, smsCode, (err) => {
97
- if (err) {
98
- if (err.message == 'Invalid activation code') {
99
- console.log(err);
100
- promptActivationCode(response);
101
- return;
102
- }
103
-
104
- console.log(err);
105
- } else {
106
- console.log('Two-factor authentication enabled!');
107
- }
108
-
109
- process.exit();
110
- });
111
- });
112
- }
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 ReadLine = require('readline');
5
+ const FS = require('fs');
6
+
7
+ const EResult = SteamCommunity.EResult;
8
+
9
+ let community = new SteamCommunity();
10
+ let rl = ReadLine.createInterface({
11
+ input: process.stdin,
12
+ output: process.stdout
13
+ });
14
+
15
+ rl.question('Username: ', (accountName) => {
16
+ rl.question('Password: ', (password) => {
17
+ doLogin(accountName, password);
18
+ });
19
+ });
20
+
21
+ function doLogin(accountName, password, authCode, captcha) {
22
+ community.login({
23
+ accountName: accountName,
24
+ password: password,
25
+ authCode: authCode,
26
+ captcha: captcha
27
+ }, (err, sessionID, cookies, steamguard) => {
28
+ if (err) {
29
+ if (err.message == 'SteamGuardMobile') {
30
+ console.log('This account already has two-factor authentication enabled.');
31
+ process.exit();
32
+ return;
33
+ }
34
+
35
+ if (err.message == 'SteamGuard') {
36
+ console.log(`An email has been sent to your address at ${err.emaildomain}`);
37
+ rl.question('Steam Guard Code: ', (code) => {
38
+ doLogin(accountName, password, code);
39
+ });
40
+
41
+ return;
42
+ }
43
+
44
+ if (err.message == 'CAPTCHA') {
45
+ console.log(err.captchaurl);
46
+ rl.question('CAPTCHA: ', (captchaInput) => {
47
+ doLogin(accountName, password, authCode, captchaInput);
48
+ });
49
+
50
+ return;
51
+ }
52
+
53
+ console.log(err);
54
+ process.exit();
55
+ return;
56
+ }
57
+
58
+ console.log('Logged on!');
59
+ community.enableTwoFactor((err, response) => {
60
+ if (err) {
61
+ if (err.eresult == EResult.Fail) {
62
+ console.log('Error: Failed to enable two-factor authentication. Do you have a phone number attached to your account?');
63
+ process.exit();
64
+ return;
65
+ }
66
+
67
+ if (err.eresult == EResult.RateLimitExceeded) {
68
+ console.log('Error: RateLimitExceeded. Try again later.');
69
+ process.exit();
70
+ return;
71
+ }
72
+
73
+ console.log(err);
74
+ process.exit();
75
+ return;
76
+ }
77
+
78
+ if (response.status != EResult.OK) {
79
+ console.log(`Error: Status ${response.status}`);
80
+ process.exit();
81
+ return;
82
+ }
83
+
84
+ let filename = `twofactor_${community.steamID.getSteamID64()}.json`;
85
+ console.log(`Writing secrets to ${filename}`);
86
+ console.log(`Revocation code: ${response.revocation_code}`);
87
+ FS.writeFileSync(filename, JSON.stringify(response, null, '\t'));
88
+
89
+ promptActivationCode(response);
90
+ });
91
+ });
92
+ }
93
+
94
+ function promptActivationCode(response) {
95
+ rl.question('SMS Code: ', (smsCode) => {
96
+ community.finalizeTwoFactor(response.shared_secret, smsCode, (err) => {
97
+ if (err) {
98
+ if (err.message == 'Invalid activation code') {
99
+ console.log(err);
100
+ promptActivationCode(response);
101
+ return;
102
+ }
103
+
104
+ console.log(err);
105
+ } else {
106
+ console.log('Two-factor authentication enabled!');
107
+ }
108
+
109
+ process.exit();
110
+ });
111
+ });
112
+ }
package/index.js CHANGED
@@ -14,6 +14,7 @@ module.exports = SteamCommunity;
14
14
  SteamCommunity.SteamID = SteamID;
15
15
  SteamCommunity.ConfirmationType = require('./resources/EConfirmationType.js');
16
16
  SteamCommunity.EResult = require('./resources/EResult.js');
17
+ SteamCommunity.EFriendRelationship = require('./resources/EFriendRelationship.js');
17
18
 
18
19
 
19
20
  function SteamCommunity(options) {
@@ -303,8 +304,8 @@ SteamCommunity.prototype.setCookies = function(cookies) {
303
304
  });
304
305
  };
305
306
 
306
- SteamCommunity.prototype.getSessionID = function() {
307
- var cookies = this._jar.getCookieString("http://steamcommunity.com").split(';');
307
+ SteamCommunity.prototype.getSessionID = function(host = "http://steamcommunity.com") {
308
+ var cookies = this._jar.getCookieString(host).split(';');
308
309
  for(var i = 0; i < cookies.length; i++) {
309
310
  var match = cookies[i].trim().match(/([^=]+)=(.+)/);
310
311
  if(match[1] == 'sessionid') {
@@ -535,6 +536,37 @@ SteamCommunity.prototype._myProfile = function(endpoint, form, callback) {
535
536
  }
536
537
  };
537
538
 
539
+ /**
540
+ * Returns an object whose keys are 64-bit SteamIDs, and whose values are values from the EFriendRelationship enum.
541
+ * Therefore, you can deduce your friends or blocked list from this object.
542
+ * @param {function} callback
543
+ */
544
+ SteamCommunity.prototype.getFriendsList = function(callback) {
545
+ this.httpRequestGet({
546
+ "uri": "https://steamcommunity.com/textfilter/ajaxgetfriendslist",
547
+ "json": true
548
+ }, (err, res, body) => {
549
+ if (err) {
550
+ callback(err ? err : new Error('HTTP error ' + res.statusCode));
551
+ return;
552
+ }
553
+
554
+ if (body.success != 1) {
555
+ callback(Helpers.eresultError(body.success));
556
+ return;
557
+ }
558
+
559
+ if (!body.friendslist || !body.friendslist.friends) {
560
+ callback(new Error('Malformed response'));
561
+ return;
562
+ }
563
+
564
+ const friends = {};
565
+ body.friendslist.friends.forEach(friend => (friends[friend.ulfriendid] = friend.efriendrelationship));
566
+ callback(null, friends);
567
+ });
568
+ };
569
+
538
570
  require('./components/http.js');
539
571
  require('./components/chat.js');
540
572
  require('./components/profile.js');
@@ -545,6 +577,7 @@ require('./components/inventoryhistory.js');
545
577
  require('./components/webapi.js');
546
578
  require('./components/twofactor.js');
547
579
  require('./components/confirmations.js');
580
+ require('./components/help.js');
548
581
  require('./classes/CMarketItem.js');
549
582
  require('./classes/CMarketSearchResult.js');
550
583
  require('./classes/CSteamGroup.js');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamcommunity",
3
- "version": "3.41.8",
3
+ "version": "3.44.0",
4
4
  "description": "Provides an interface for logging into and interacting with the Steam Community website",
5
5
  "keywords": [
6
6
  "steam",
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @enum EFriendRelationship
3
+ */
4
+ module.exports = {
5
+ "None": 0,
6
+ "Blocked": 1,
7
+ "RequestRecipient": 2,
8
+ "Friend": 3,
9
+ "RequestInitiator": 4,
10
+ "Ignored": 5,
11
+ "IgnoredFriend": 6,
12
+ "SuggestedFriend": 7, // removed "was used by the original implementation of the facebook linking feature; but now unused."
13
+
14
+ // Value-to-name mapping for convenience
15
+ "0": "None",
16
+ "1": "Blocked",
17
+ "2": "RequestRecipient",
18
+ "3": "Friend",
19
+ "4": "RequestInitiator",
20
+ "5": "Ignored",
21
+ "6": "IgnoredFriend",
22
+ "7": "SuggestedFriend",
23
+ };
@@ -9,7 +9,7 @@ module.exports = {
9
9
  "Snooze": 4,
10
10
  "LookingToTrade": 5,
11
11
  "LookingToPlay": 6,
12
- "Max": 7,
12
+ "Invisible": 7,
13
13
 
14
14
  // Value-to-name mapping for convenience
15
15
  "0": "Offline",
@@ -19,5 +19,5 @@ module.exports = {
19
19
  "4": "Snooze",
20
20
  "5": "LookingToTrade",
21
21
  "6": "LookingToPlay",
22
- "7": "Max",
22
+ "7": "Invisible",
23
23
  };
@@ -4,7 +4,8 @@
4
4
  module.exports = {
5
5
  "HasRichPresence": 1,
6
6
  "InJoinableGame": 2,
7
- "Golden": 4, // removed "no longer has any effect"
7
+ "Golden": 4,
8
+ "RemotePlayTogether": 8,
8
9
  "OnlineUsingWeb": 256, // removed "renamed to ClientTypeWeb"
9
10
  "ClientTypeWeb": 256,
10
11
  "OnlineUsingMobile": 512, // removed "renamed to ClientTypeMobile"
@@ -14,14 +15,18 @@ module.exports = {
14
15
  "OnlineUsingVR": 2048, // removed "renamed to ClientTypeVR"
15
16
  "ClientTypeVR": 2048,
16
17
  "LaunchTypeGamepad": 4096,
18
+ "LaunchTypeCompatTool": 8192,
17
19
 
18
20
  // Value-to-name mapping for convenience
19
21
  "1": "HasRichPresence",
20
22
  "2": "InJoinableGame",
21
23
  "4": "Golden",
24
+ "8": "RemotePlayTogether",
22
25
  "256": "ClientTypeWeb",
23
26
  "512": "ClientTypeMobile",
24
27
  "1024": "ClientTypeTenfoot",
25
28
  "2048": "ClientTypeVR",
26
29
  "4096": "LaunchTypeGamepad",
30
+ "8192": "LaunchTypeCompatTool",
27
31
  };
32
+
@@ -123,6 +123,13 @@ module.exports = {
123
123
  "WGNetworkSendExceeded": 110,
124
124
  "AccountNotFriends": 111,
125
125
  "LimitedUserAccount": 112,
126
+ "CantRemoveItem": 113,
127
+ "AccountHasBeenDeleted": 114,
128
+ "AccountHasAnExistingUserCancelledLicense": 115,
129
+ "DeniedDueToCommunityCooldown": 116,
130
+ "NoLauncherSpecified": 117,
131
+ "MustAgreeToSSA": 118,
132
+ "ClientNoLongerSupported": 119,
126
133
 
127
134
  // Value-to-name mapping for convenience
128
135
  "0": "Invalid",
@@ -237,4 +244,11 @@ module.exports = {
237
244
  "110": "WGNetworkSendExceeded",
238
245
  "111": "AccountNotFriends",
239
246
  "112": "LimitedUserAccount",
247
+ "113": "CantRemoveItem",
248
+ "114": "AccountHasBeenDeleted",
249
+ "115": "AccountHasAnExistingUserCancelledLicense",
250
+ "116": "DeniedDueToCommunityCooldown",
251
+ "117": "NoLauncherSpecified",
252
+ "118": "MustAgreeToSSA",
253
+ "119": "ClientNoLongerSupported",
240
254
  };