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,283 +1,283 @@
1
- var SteamCommunity = require('../index.js');
2
- var SteamID = require('steamid');
3
-
4
- SteamCommunity.ChatState = require('../resources/EChatState.js');
5
- SteamCommunity.PersonaState = require('../resources/EPersonaState.js');
6
- SteamCommunity.PersonaStateFlag = require('../resources/EPersonaStateFlag.js');
7
-
8
- /**
9
- * @deprecated No support for new Steam chat. Use steam-user instead.
10
- * @param {int} interval
11
- * @param {string} uiMode
12
- */
13
- SteamCommunity.prototype.chatLogon = function(interval, uiMode) {
14
- if(this.chatState == SteamCommunity.ChatState.LoggingOn || this.chatState == SteamCommunity.ChatState.LoggedOn) {
15
- return;
16
- }
17
-
18
- interval = interval || 500;
19
- uiMode = uiMode || "web";
20
-
21
- this.emit('debug', 'Requesting chat WebAPI token');
22
- this.chatState = SteamCommunity.ChatState.LoggingOn;
23
-
24
- var self = this;
25
- this.getWebApiOauthToken(function(err, token) {
26
- if(err) {
27
- var fatal = err.message.indexOf('not authorized') != -1;
28
-
29
- if (!fatal) {
30
- self.chatState = SteamCommunity.ChatState.LogOnFailed;
31
- setTimeout(self.chatLogon.bind(self), 5000);
32
- } else {
33
- self.chatState = SteamCommunity.ChatState.Offline;
34
- }
35
-
36
- self.emit('chatLogOnFailed', err, fatal);
37
- self.emit('debug', "Cannot get oauth token: " + err.message);
38
- return;
39
- }
40
-
41
- self.httpRequestPost({
42
- "uri": "https://api.steampowered.com/ISteamWebUserPresenceOAuth/Logon/v1",
43
- "form": {
44
- "ui_mode": uiMode,
45
- "access_token": token
46
- },
47
- "json": true
48
- }, function(err, response, body) {
49
- if(err || response.statusCode != 200) {
50
- self.chatState = SteamCommunity.ChatState.LogOnFailed;
51
- self.emit('chatLogOnFailed', err ? err : new Error("HTTP error " + response.statusCode), false);
52
- self.emit('debug', 'Error logging into webchat: ' + (err ? err.message : "HTTP error " + response.statusCode));
53
- setTimeout(self.chatLogon.bind(self), 5000);
54
- return;
55
- }
56
-
57
- if(body.error != 'OK') {
58
- self.chatState = SteamCommunity.ChatState.LogOnFailed;
59
- self.emit('chatLogOnFailed', new Error(body.error), false);
60
- self.emit('debug', 'Error logging into webchat: ' + body.error);
61
- setTimeout(self.chatLogon.bind(self), 5000);
62
- return;
63
- }
64
-
65
- self._chat = {
66
- "umqid": body.umqid,
67
- "message": body.message,
68
- "accessToken": token,
69
- "interval": interval,
70
- "uiMode": uiMode
71
- };
72
-
73
- self.chatFriends = {};
74
-
75
- self.chatState = SteamCommunity.ChatState.LoggedOn;
76
- self.emit('chatLoggedOn');
77
- self._chatPoll();
78
- }, "steamcommunity");
79
- });
80
- };
81
-
82
- /**
83
- * @deprecated No support for new Steam chat. Use steam-user instead.
84
- * @param {string|SteamID} recipient
85
- * @param {string} text
86
- * @param {string} [type]
87
- * @param {function} [callback]
88
- */
89
- SteamCommunity.prototype.chatMessage = function(recipient, text, type, callback) {
90
- if(this.chatState != SteamCommunity.ChatState.LoggedOn) {
91
- throw new Error("Chat must be logged on before messages can be sent");
92
- }
93
-
94
- if(typeof recipient === 'string') {
95
- recipient = new SteamID(recipient);
96
- }
97
-
98
- if(typeof type === 'function') {
99
- callback = type;
100
- type = 'saytext';
101
- }
102
-
103
- type = type || 'saytext';
104
-
105
- var self = this;
106
- this.httpRequestPost({
107
- "uri": "https://api.steampowered.com/ISteamWebUserPresenceOAuth/Message/v1",
108
- "form": {
109
- "access_token": this._chat.accessToken,
110
- "steamid_dst": recipient.toString(),
111
- "text": text,
112
- "type": type,
113
- "umqid": this._chat.umqid
114
- },
115
- "json": true
116
- }, function(err, response, body) {
117
- if(!callback) {
118
- return;
119
- }
120
-
121
- if (err) {
122
- callback(err);
123
- return;
124
- }
125
-
126
- if(body.error != 'OK') {
127
- callback(new Error(body.error));
128
- } else {
129
- callback(null);
130
- }
131
- }, "steamcommunity");
132
- };
133
-
134
- /**
135
- * @deprecated No support for new Steam chat. Use steam-user instead.
136
- */
137
- SteamCommunity.prototype.chatLogoff = function() {
138
- var self = this;
139
- this.httpRequestPost({
140
- "uri": "https://api.steampowered.com/ISteamWebUserPresenceOAuth/Logoff/v1",
141
- "form": {
142
- "access_token": this._chat.accessToken,
143
- "umqid": this._chat.umqid
144
- }
145
- }, function(err, response, body) {
146
- if(err || response.statusCode != 200) {
147
- self.emit('debug', 'Error logging off of chat: ' + (err ? err.message : "HTTP error " + response.statusCode));
148
- setTimeout(self.chatLogoff.bind(self), 1000);
149
- } else {
150
- self.emit('chatLoggedOff');
151
- clearTimeout(self._chat.timer);
152
- delete self._chat;
153
- delete self.chatFriends;
154
- self.chatState = SteamCommunity.ChatState.Offline;
155
- }
156
- }, "steamcommunity");
157
- };
158
-
159
- /**
160
- * @private
161
- */
162
- SteamCommunity.prototype._chatPoll = function() {
163
- this.emit('debug', 'Doing chat poll');
164
-
165
- var self = this;
166
- this.httpRequestPost({
167
- "uri": "https://api.steampowered.com/ISteamWebUserPresenceOAuth/Poll/v1",
168
- "form": {
169
- "umqid": self._chat.umqid,
170
- "message": self._chat.message,
171
- "pollid": 1,
172
- "sectimeout": 20,
173
- "secidletime": 0,
174
- "use_accountids": 1,
175
- "access_token": self._chat.accessToken
176
- },
177
- "json": true
178
- }, function(err, response, body) {
179
- if (self.chatState == SteamCommunity.ChatState.Offline) {
180
- return;
181
- }
182
-
183
- self._chat.timer = setTimeout(self._chatPoll.bind(self), self._chat.interval);
184
-
185
- if(err || response.statusCode != 200) {
186
- self.emit('debug', 'Error in chat poll: ' + (err ? err.message : "HTTP error " + response.statusCode));
187
- if (err.message == "Not Logged On") {
188
- self._relogWebChat();
189
- }
190
-
191
- return;
192
- }
193
-
194
- if(!body || body.error != 'OK') {
195
- self.emit('debug', 'Error in chat poll: ' + (body && body.error ? body.error : "Malformed response"));
196
- if (body && body.error && body.error == "Not Logged On") {
197
- self._relogWebChat();
198
- }
199
-
200
- return;
201
- }
202
-
203
- self._chat.message = body.messagelast;
204
-
205
- (body.messages || []).forEach(function(message) {
206
- var sender = new SteamID();
207
- sender.universe = SteamID.Universe.PUBLIC;
208
- sender.type = SteamID.Type.INDIVIDUAL;
209
- sender.instance = SteamID.Instance.DESKTOP;
210
- sender.accountid = message.accountid_from;
211
-
212
- switch(message.type) {
213
- case 'personastate':
214
- self._chatUpdatePersona(sender);
215
- break;
216
-
217
- case 'saytext':
218
- self.emit('chatMessage', sender, message.text);
219
- break;
220
-
221
- case 'typing':
222
- self.emit('chatTyping', sender);
223
- break;
224
-
225
- default:
226
- self.emit('debug', 'Unhandled chat message type: ' + message.type);
227
- }
228
- });
229
- }, "steamcommunity");
230
- };
231
-
232
- /**
233
- * @private
234
- */
235
- SteamCommunity.prototype._relogWebChat = function() {
236
- this.emit('debug', "Relogging web chat");
237
- clearTimeout(this._chat.timer);
238
- this.chatState = SteamCommunity.ChatState.Offline;
239
- this.chatLogon(this._chat.interval, this._chat.uiMode);
240
- };
241
-
242
- /**
243
- * @param {SteamID} steamID
244
- * @private
245
- */
246
- SteamCommunity.prototype._chatUpdatePersona = function(steamID) {
247
- if (!this.chatFriends || this.chatState == SteamCommunity.ChatState.Offline) {
248
- return; // we no longer care
249
- }
250
-
251
- this.emit('debug', 'Updating persona data for ' + steamID);
252
- var self = this;
253
- this.httpRequest({
254
- "uri": "https://steamcommunity.com/chat/friendstate/" + steamID.accountid,
255
- "json": true
256
- }, function(err, response, body) {
257
- if (!self.chatFriends || self.chatState == SteamCommunity.ChatState.Offline) {
258
- return; // welp
259
- }
260
-
261
- if(err || response.statusCode != 200) {
262
- self.emit('debug', 'Chat update persona error: ' + (err ? err.message : "HTTP error " + response.statusCode));
263
- setTimeout(function() {
264
- self._chatUpdatePersona(steamID);
265
- }, 2000);
266
- return;
267
- }
268
-
269
- var persona = {
270
- "steamID": steamID,
271
- "personaName": body.m_strName,
272
- "personaState": body.m_ePersonaState,
273
- "personaStateFlags": body.m_nPersonaStateFlags || 0,
274
- "avatarHash": body.m_strAvatarHash,
275
- "inGame": !!body.m_bInGame,
276
- "inGameAppID": body.m_nInGameAppID ? parseInt(body.m_nInGameAppID, 10) : null,
277
- "inGameName": body.m_strInGameName || null
278
- };
279
-
280
- self.emit('chatPersonaState', steamID, persona);
281
- self.chatFriends[steamID.getSteamID64()] = persona;
282
- }, "steamcommunity");
283
- };
1
+ var SteamCommunity = require('../index.js');
2
+ var SteamID = require('steamid');
3
+
4
+ SteamCommunity.ChatState = require('../resources/EChatState.js');
5
+ SteamCommunity.PersonaState = require('../resources/EPersonaState.js');
6
+ SteamCommunity.PersonaStateFlag = require('../resources/EPersonaStateFlag.js');
7
+
8
+ /**
9
+ * @deprecated No support for new Steam chat. Use steam-user instead.
10
+ * @param {int} interval
11
+ * @param {string} uiMode
12
+ */
13
+ SteamCommunity.prototype.chatLogon = function(interval, uiMode) {
14
+ if(this.chatState == SteamCommunity.ChatState.LoggingOn || this.chatState == SteamCommunity.ChatState.LoggedOn) {
15
+ return;
16
+ }
17
+
18
+ interval = interval || 500;
19
+ uiMode = uiMode || "web";
20
+
21
+ this.emit('debug', 'Requesting chat WebAPI token');
22
+ this.chatState = SteamCommunity.ChatState.LoggingOn;
23
+
24
+ var self = this;
25
+ this.getWebApiOauthToken(function(err, token) {
26
+ if(err) {
27
+ var fatal = err.message.indexOf('not authorized') != -1;
28
+
29
+ if (!fatal) {
30
+ self.chatState = SteamCommunity.ChatState.LogOnFailed;
31
+ setTimeout(self.chatLogon.bind(self), 5000);
32
+ } else {
33
+ self.chatState = SteamCommunity.ChatState.Offline;
34
+ }
35
+
36
+ self.emit('chatLogOnFailed', err, fatal);
37
+ self.emit('debug', "Cannot get oauth token: " + err.message);
38
+ return;
39
+ }
40
+
41
+ self.httpRequestPost({
42
+ "uri": "https://api.steampowered.com/ISteamWebUserPresenceOAuth/Logon/v1",
43
+ "form": {
44
+ "ui_mode": uiMode,
45
+ "access_token": token
46
+ },
47
+ "json": true
48
+ }, function(err, response, body) {
49
+ if(err || response.statusCode != 200) {
50
+ self.chatState = SteamCommunity.ChatState.LogOnFailed;
51
+ self.emit('chatLogOnFailed', err ? err : new Error("HTTP error " + response.statusCode), false);
52
+ self.emit('debug', 'Error logging into webchat: ' + (err ? err.message : "HTTP error " + response.statusCode));
53
+ setTimeout(self.chatLogon.bind(self), 5000);
54
+ return;
55
+ }
56
+
57
+ if(body.error != 'OK') {
58
+ self.chatState = SteamCommunity.ChatState.LogOnFailed;
59
+ self.emit('chatLogOnFailed', new Error(body.error), false);
60
+ self.emit('debug', 'Error logging into webchat: ' + body.error);
61
+ setTimeout(self.chatLogon.bind(self), 5000);
62
+ return;
63
+ }
64
+
65
+ self._chat = {
66
+ "umqid": body.umqid,
67
+ "message": body.message,
68
+ "accessToken": token,
69
+ "interval": interval,
70
+ "uiMode": uiMode
71
+ };
72
+
73
+ self.chatFriends = {};
74
+
75
+ self.chatState = SteamCommunity.ChatState.LoggedOn;
76
+ self.emit('chatLoggedOn');
77
+ self._chatPoll();
78
+ }, "steamcommunity");
79
+ });
80
+ };
81
+
82
+ /**
83
+ * @deprecated No support for new Steam chat. Use steam-user instead.
84
+ * @param {string|SteamID} recipient
85
+ * @param {string} text
86
+ * @param {string} [type]
87
+ * @param {function} [callback]
88
+ */
89
+ SteamCommunity.prototype.chatMessage = function(recipient, text, type, callback) {
90
+ if(this.chatState != SteamCommunity.ChatState.LoggedOn) {
91
+ throw new Error("Chat must be logged on before messages can be sent");
92
+ }
93
+
94
+ if(typeof recipient === 'string') {
95
+ recipient = new SteamID(recipient);
96
+ }
97
+
98
+ if(typeof type === 'function') {
99
+ callback = type;
100
+ type = 'saytext';
101
+ }
102
+
103
+ type = type || 'saytext';
104
+
105
+ var self = this;
106
+ this.httpRequestPost({
107
+ "uri": "https://api.steampowered.com/ISteamWebUserPresenceOAuth/Message/v1",
108
+ "form": {
109
+ "access_token": this._chat.accessToken,
110
+ "steamid_dst": recipient.toString(),
111
+ "text": text,
112
+ "type": type,
113
+ "umqid": this._chat.umqid
114
+ },
115
+ "json": true
116
+ }, function(err, response, body) {
117
+ if(!callback) {
118
+ return;
119
+ }
120
+
121
+ if (err) {
122
+ callback(err);
123
+ return;
124
+ }
125
+
126
+ if(body.error != 'OK') {
127
+ callback(new Error(body.error));
128
+ } else {
129
+ callback(null);
130
+ }
131
+ }, "steamcommunity");
132
+ };
133
+
134
+ /**
135
+ * @deprecated No support for new Steam chat. Use steam-user instead.
136
+ */
137
+ SteamCommunity.prototype.chatLogoff = function() {
138
+ var self = this;
139
+ this.httpRequestPost({
140
+ "uri": "https://api.steampowered.com/ISteamWebUserPresenceOAuth/Logoff/v1",
141
+ "form": {
142
+ "access_token": this._chat.accessToken,
143
+ "umqid": this._chat.umqid
144
+ }
145
+ }, function(err, response, body) {
146
+ if(err || response.statusCode != 200) {
147
+ self.emit('debug', 'Error logging off of chat: ' + (err ? err.message : "HTTP error " + response.statusCode));
148
+ setTimeout(self.chatLogoff.bind(self), 1000);
149
+ } else {
150
+ self.emit('chatLoggedOff');
151
+ clearTimeout(self._chat.timer);
152
+ delete self._chat;
153
+ delete self.chatFriends;
154
+ self.chatState = SteamCommunity.ChatState.Offline;
155
+ }
156
+ }, "steamcommunity");
157
+ };
158
+
159
+ /**
160
+ * @private
161
+ */
162
+ SteamCommunity.prototype._chatPoll = function() {
163
+ this.emit('debug', 'Doing chat poll');
164
+
165
+ var self = this;
166
+ this.httpRequestPost({
167
+ "uri": "https://api.steampowered.com/ISteamWebUserPresenceOAuth/Poll/v1",
168
+ "form": {
169
+ "umqid": self._chat.umqid,
170
+ "message": self._chat.message,
171
+ "pollid": 1,
172
+ "sectimeout": 20,
173
+ "secidletime": 0,
174
+ "use_accountids": 1,
175
+ "access_token": self._chat.accessToken
176
+ },
177
+ "json": true
178
+ }, function(err, response, body) {
179
+ if (self.chatState == SteamCommunity.ChatState.Offline) {
180
+ return;
181
+ }
182
+
183
+ self._chat.timer = setTimeout(self._chatPoll.bind(self), self._chat.interval);
184
+
185
+ if(err || response.statusCode != 200) {
186
+ self.emit('debug', 'Error in chat poll: ' + (err ? err.message : "HTTP error " + response.statusCode));
187
+ if (err.message == "Not Logged On") {
188
+ self._relogWebChat();
189
+ }
190
+
191
+ return;
192
+ }
193
+
194
+ if(!body || body.error != 'OK') {
195
+ self.emit('debug', 'Error in chat poll: ' + (body && body.error ? body.error : "Malformed response"));
196
+ if (body && body.error && body.error == "Not Logged On") {
197
+ self._relogWebChat();
198
+ }
199
+
200
+ return;
201
+ }
202
+
203
+ self._chat.message = body.messagelast;
204
+
205
+ (body.messages || []).forEach(function(message) {
206
+ var sender = new SteamID();
207
+ sender.universe = SteamID.Universe.PUBLIC;
208
+ sender.type = SteamID.Type.INDIVIDUAL;
209
+ sender.instance = SteamID.Instance.DESKTOP;
210
+ sender.accountid = message.accountid_from;
211
+
212
+ switch(message.type) {
213
+ case 'personastate':
214
+ self._chatUpdatePersona(sender);
215
+ break;
216
+
217
+ case 'saytext':
218
+ self.emit('chatMessage', sender, message.text);
219
+ break;
220
+
221
+ case 'typing':
222
+ self.emit('chatTyping', sender);
223
+ break;
224
+
225
+ default:
226
+ self.emit('debug', 'Unhandled chat message type: ' + message.type);
227
+ }
228
+ });
229
+ }, "steamcommunity");
230
+ };
231
+
232
+ /**
233
+ * @private
234
+ */
235
+ SteamCommunity.prototype._relogWebChat = function() {
236
+ this.emit('debug', "Relogging web chat");
237
+ clearTimeout(this._chat.timer);
238
+ this.chatState = SteamCommunity.ChatState.Offline;
239
+ this.chatLogon(this._chat.interval, this._chat.uiMode);
240
+ };
241
+
242
+ /**
243
+ * @param {SteamID} steamID
244
+ * @private
245
+ */
246
+ SteamCommunity.prototype._chatUpdatePersona = function(steamID) {
247
+ if (!this.chatFriends || this.chatState == SteamCommunity.ChatState.Offline) {
248
+ return; // we no longer care
249
+ }
250
+
251
+ this.emit('debug', 'Updating persona data for ' + steamID);
252
+ var self = this;
253
+ this.httpRequest({
254
+ "uri": "https://steamcommunity.com/chat/friendstate/" + steamID.accountid,
255
+ "json": true
256
+ }, function(err, response, body) {
257
+ if (!self.chatFriends || self.chatState == SteamCommunity.ChatState.Offline) {
258
+ return; // welp
259
+ }
260
+
261
+ if(err || response.statusCode != 200) {
262
+ self.emit('debug', 'Chat update persona error: ' + (err ? err.message : "HTTP error " + response.statusCode));
263
+ setTimeout(function() {
264
+ self._chatUpdatePersona(steamID);
265
+ }, 2000);
266
+ return;
267
+ }
268
+
269
+ var persona = {
270
+ "steamID": steamID,
271
+ "personaName": body.m_strName,
272
+ "personaState": body.m_ePersonaState,
273
+ "personaStateFlags": body.m_nPersonaStateFlags || 0,
274
+ "avatarHash": body.m_strAvatarHash,
275
+ "inGame": !!body.m_bInGame,
276
+ "inGameAppID": body.m_nInGameAppID ? parseInt(body.m_nInGameAppID, 10) : null,
277
+ "inGameName": body.m_strInGameName || null
278
+ };
279
+
280
+ self.emit('chatPersonaState', steamID, persona);
281
+ self.chatFriends[steamID.getSteamID64()] = persona;
282
+ }, "steamcommunity");
283
+ };