steamcommunity 3.46.1 → 3.47.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.
Files changed (44) hide show
  1. package/classes/CConfirmation.js +37 -37
  2. package/classes/CEconItem.js +120 -120
  3. package/classes/CMarketItem.js +189 -189
  4. package/classes/CMarketSearchResult.js +89 -89
  5. package/classes/CSteamGroup.js +155 -155
  6. package/classes/CSteamUser.js +225 -217
  7. package/components/chat.js +283 -283
  8. package/components/confirmations.js +428 -428
  9. package/components/groups.js +798 -732
  10. package/components/help.js +64 -64
  11. package/components/helpers.js +128 -108
  12. package/components/http.js +150 -150
  13. package/components/inventoryhistory.js +173 -173
  14. package/components/market.js +387 -387
  15. package/components/profile.js +475 -475
  16. package/components/twofactor.js +152 -152
  17. package/components/users.js +831 -767
  18. package/components/webapi.js +118 -118
  19. package/examples/edit-group-announcement.js +118 -118
  20. package/package.json +9 -2
  21. package/resources/EChatState.js +14 -14
  22. package/resources/EConfirmationType.js +12 -12
  23. package/resources/EFriendRelationship.js +23 -23
  24. package/resources/EPersonaState.js +23 -23
  25. package/resources/EPersonaStateFlag.js +32 -32
  26. package/resources/EResult.js +254 -254
  27. package/resources/ESharedFileType.js +13 -13
  28. package/.editorconfig +0 -13
  29. package/.github/FUNDING.yml +0 -2
  30. package/.idea/.name +0 -1
  31. package/.idea/codeStyleSettings.xml +0 -13
  32. package/.idea/codeStyles/Project.xml +0 -15
  33. package/.idea/codeStyles/codeStyleConfig.xml +0 -6
  34. package/.idea/copyright/profiles_settings.xml +0 -3
  35. package/.idea/encodings.xml +0 -6
  36. package/.idea/inspectionProfiles/Project_Default.xml +0 -11
  37. package/.idea/jsLibraryMappings.xml +0 -6
  38. package/.idea/misc.xml +0 -6
  39. package/.idea/modules.xml +0 -9
  40. package/.idea/node-steamcommunity.iml +0 -8
  41. package/.idea/steamcommunity.iml +0 -10
  42. package/.idea/vcs.xml +0 -7
  43. package/.idea/watcherTasks.xml +0 -4
  44. package/CONTRIBUTING.md +0 -36
@@ -1,118 +1,118 @@
1
- var SteamCommunity = require('../index.js');
2
-
3
- const Helpers = require('./helpers.js');
4
-
5
- SteamCommunity.prototype.getWebApiKey = function(domain, callback) {
6
- var self = this;
7
- this.httpRequest({
8
- "uri": "https://steamcommunity.com/dev/apikey?l=english",
9
- "followRedirect": false
10
- }, function(err, response, body) {
11
- if (err) {
12
- callback(err);
13
- return;
14
- }
15
-
16
- if(body.match(/<h2>Access Denied<\/h2>/)) {
17
- return callback(new Error("Access Denied"));
18
- }
19
-
20
- if(body.match(/You must have a validated email address to create a Steam Web API key./)) {
21
- return callback(new Error("You must have a validated email address to create a Steam Web API key."));
22
- }
23
-
24
- var match = body.match(/<p>Key: ([0-9A-F]+)<\/p>/);
25
- if(match) {
26
- // We already have an API key registered
27
- callback(null, match[1]);
28
- } else {
29
- // We need to register a new API key
30
- self.httpRequestPost('https://steamcommunity.com/dev/registerkey?l=english', {
31
- "form": {
32
- "domain": domain,
33
- "agreeToTerms": "agreed",
34
- "sessionid": self.getSessionID(),
35
- "Submit": "Register"
36
- }
37
- }, function(err, response, body) {
38
- if (err) {
39
- callback(err);
40
- return;
41
- }
42
-
43
- self.getWebApiKey(domain, callback);
44
- }, "steamcommunity");
45
- }
46
- }, "steamcommunity");
47
- };
48
-
49
- /**
50
- * @deprecated No longer works. Will be removed in a future release.
51
- * @param {function} callback
52
- */
53
- SteamCommunity.prototype.getWebApiOauthToken = function(callback) {
54
- if (this.oAuthToken) {
55
- return callback(null, this.oAuthToken);
56
- }
57
-
58
- callback(new Error('This operation requires an OAuth token, which is no longer issued by Steam.'));
59
- };
60
-
61
- /**
62
- * Sets an access_token generated by steam-session using EAuthTokenPlatformType.MobileApp.
63
- * Required for some operations such as 2FA enabling and disabling.
64
- * This will throw an Error if the provided token is not valid, was not generated for the MobileApp platform, is expired,
65
- * or does not belong to the logged-in user account.
66
- *
67
- * @param {string} token
68
- */
69
- SteamCommunity.prototype.setMobileAppAccessToken = function(token) {
70
- if (!this.steamID) {
71
- throw new Error('Log on to steamcommunity before setting a mobile app access token');
72
- }
73
-
74
- let decodedToken = Helpers.decodeJwt(token);
75
-
76
- if (!decodedToken.iss || !decodedToken.sub || !decodedToken.aud || !decodedToken.exp) {
77
- throw new Error('Provided value is not a valid Steam access token');
78
- }
79
-
80
- if (decodedToken.iss == 'steam') {
81
- throw new Error('Provided token is a refresh token, not an access token');
82
- }
83
-
84
- if (decodedToken.sub != this.steamID.getSteamID64()) {
85
- throw new Error(`Provided token belongs to account ${decodedToken.sub}, but we are logged into ${this.steamID.getSteamID64()}`);
86
- }
87
-
88
- if (decodedToken.exp < Math.floor(Date.now() / 1000)) {
89
- throw new Error('Provided token is expired');
90
- }
91
-
92
- if ((decodedToken.aud || []).indexOf('mobile') == -1) {
93
- throw new Error('Provided token is not valid for MobileApp platform type');
94
- }
95
-
96
- this.mobileAccessToken = token;
97
- };
98
-
99
- /**
100
- * Verifies that the mobile access token we already have set is still valid for current login.
101
- *
102
- * @private
103
- */
104
- SteamCommunity.prototype._verifyMobileAccessToken = function() {
105
- if (!this.mobileAccessToken) {
106
- // No access token, so nothing to do here.
107
- return;
108
- }
109
-
110
- let decodedToken = Helpers.decodeJwt(this.mobileAccessToken);
111
-
112
- let isTokenInvalid = decodedToken.sub != this.steamID.getSteamID64() // SteamID doesn't match
113
- || decodedToken.exp < Math.floor(Date.now() / 1000); // Token is expired
114
-
115
- if (isTokenInvalid) {
116
- delete this.mobileAccessToken;
117
- }
118
- };
1
+ var SteamCommunity = require('../index.js');
2
+
3
+ const Helpers = require('./helpers.js');
4
+
5
+ SteamCommunity.prototype.getWebApiKey = function(domain, callback) {
6
+ var self = this;
7
+ this.httpRequest({
8
+ "uri": "https://steamcommunity.com/dev/apikey?l=english",
9
+ "followRedirect": false
10
+ }, function(err, response, body) {
11
+ if (err) {
12
+ callback(err);
13
+ return;
14
+ }
15
+
16
+ if(body.match(/<h2>Access Denied<\/h2>/)) {
17
+ return callback(new Error("Access Denied"));
18
+ }
19
+
20
+ if(body.match(/You must have a validated email address to create a Steam Web API key./)) {
21
+ return callback(new Error("You must have a validated email address to create a Steam Web API key."));
22
+ }
23
+
24
+ var match = body.match(/<p>Key: ([0-9A-F]+)<\/p>/);
25
+ if(match) {
26
+ // We already have an API key registered
27
+ callback(null, match[1]);
28
+ } else {
29
+ // We need to register a new API key
30
+ self.httpRequestPost('https://steamcommunity.com/dev/registerkey?l=english', {
31
+ "form": {
32
+ "domain": domain,
33
+ "agreeToTerms": "agreed",
34
+ "sessionid": self.getSessionID(),
35
+ "Submit": "Register"
36
+ }
37
+ }, function(err, response, body) {
38
+ if (err) {
39
+ callback(err);
40
+ return;
41
+ }
42
+
43
+ self.getWebApiKey(domain, callback);
44
+ }, "steamcommunity");
45
+ }
46
+ }, "steamcommunity");
47
+ };
48
+
49
+ /**
50
+ * @deprecated No longer works. Will be removed in a future release.
51
+ * @param {function} callback
52
+ */
53
+ SteamCommunity.prototype.getWebApiOauthToken = function(callback) {
54
+ if (this.oAuthToken) {
55
+ return callback(null, this.oAuthToken);
56
+ }
57
+
58
+ callback(new Error('This operation requires an OAuth token, which is no longer issued by Steam.'));
59
+ };
60
+
61
+ /**
62
+ * Sets an access_token generated by steam-session using EAuthTokenPlatformType.MobileApp.
63
+ * Required for some operations such as 2FA enabling and disabling.
64
+ * This will throw an Error if the provided token is not valid, was not generated for the MobileApp platform, is expired,
65
+ * or does not belong to the logged-in user account.
66
+ *
67
+ * @param {string} token
68
+ */
69
+ SteamCommunity.prototype.setMobileAppAccessToken = function(token) {
70
+ if (!this.steamID) {
71
+ throw new Error('Log on to steamcommunity before setting a mobile app access token');
72
+ }
73
+
74
+ let decodedToken = Helpers.decodeJwt(token);
75
+
76
+ if (!decodedToken.iss || !decodedToken.sub || !decodedToken.aud || !decodedToken.exp) {
77
+ throw new Error('Provided value is not a valid Steam access token');
78
+ }
79
+
80
+ if (decodedToken.iss == 'steam') {
81
+ throw new Error('Provided token is a refresh token, not an access token');
82
+ }
83
+
84
+ if (decodedToken.sub != this.steamID.getSteamID64()) {
85
+ throw new Error(`Provided token belongs to account ${decodedToken.sub}, but we are logged into ${this.steamID.getSteamID64()}`);
86
+ }
87
+
88
+ if (decodedToken.exp < Math.floor(Date.now() / 1000)) {
89
+ throw new Error('Provided token is expired');
90
+ }
91
+
92
+ if ((decodedToken.aud || []).indexOf('mobile') == -1) {
93
+ throw new Error('Provided token is not valid for MobileApp platform type');
94
+ }
95
+
96
+ this.mobileAccessToken = token;
97
+ };
98
+
99
+ /**
100
+ * Verifies that the mobile access token we already have set is still valid for current login.
101
+ *
102
+ * @private
103
+ */
104
+ SteamCommunity.prototype._verifyMobileAccessToken = function() {
105
+ if (!this.mobileAccessToken) {
106
+ // No access token, so nothing to do here.
107
+ return;
108
+ }
109
+
110
+ let decodedToken = Helpers.decodeJwt(this.mobileAccessToken);
111
+
112
+ let isTokenInvalid = decodedToken.sub != this.steamID.getSteamID64() // SteamID doesn't match
113
+ || decodedToken.exp < Math.floor(Date.now() / 1000); // Token is expired
114
+
115
+ if (isTokenInvalid) {
116
+ delete this.mobileAccessToken;
117
+ }
118
+ };
@@ -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
+ }
package/package.json CHANGED
@@ -1,7 +1,14 @@
1
1
  {
2
2
  "name": "steamcommunity",
3
- "version": "3.46.1",
3
+ "version": "3.47.0",
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"
@@ -28,7 +35,7 @@
28
35
  "request": "^2.88.0",
29
36
  "steam-totp": "^1.5.0",
30
37
  "steamid": "^1.1.3",
31
- "xml2js": "^0.4.22"
38
+ "xml2js": "^0.6.2"
32
39
  },
33
40
  "devDependencies": {
34
41
  "steam-session": "^1.2.3"
@@ -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
+ };
@@ -1,23 +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
- };
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
+ };
@@ -1,23 +1,23 @@
1
- /**
2
- * @enum EPersonaState
3
- */
4
- module.exports = {
5
- "Offline": 0,
6
- "Online": 1,
7
- "Busy": 2,
8
- "Away": 3,
9
- "Snooze": 4,
10
- "LookingToTrade": 5,
11
- "LookingToPlay": 6,
12
- "Invisible": 7,
13
-
14
- // Value-to-name mapping for convenience
15
- "0": "Offline",
16
- "1": "Online",
17
- "2": "Busy",
18
- "3": "Away",
19
- "4": "Snooze",
20
- "5": "LookingToTrade",
21
- "6": "LookingToPlay",
22
- "7": "Invisible",
23
- };
1
+ /**
2
+ * @enum EPersonaState
3
+ */
4
+ module.exports = {
5
+ "Offline": 0,
6
+ "Online": 1,
7
+ "Busy": 2,
8
+ "Away": 3,
9
+ "Snooze": 4,
10
+ "LookingToTrade": 5,
11
+ "LookingToPlay": 6,
12
+ "Invisible": 7,
13
+
14
+ // Value-to-name mapping for convenience
15
+ "0": "Offline",
16
+ "1": "Online",
17
+ "2": "Busy",
18
+ "3": "Away",
19
+ "4": "Snooze",
20
+ "5": "LookingToTrade",
21
+ "6": "LookingToPlay",
22
+ "7": "Invisible",
23
+ };