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.
- package/.github/FUNDING.yml +2 -2
- package/.idea/codeStyles/Project.xml +0 -3
- package/.idea/codeStyles/codeStyleConfig.xml +1 -0
- package/.idea/copyright/profiles_settings.xml +2 -2
- package/.idea/inspectionProfiles/Project_Default.xml +10 -10
- package/.idea/jsLibraryMappings.xml +5 -5
- package/.idea/misc.xml +5 -5
- package/.idea/modules.xml +8 -7
- package/.idea/steamcommunity.iml +9 -8
- package/.idea/vcs.xml +6 -5
- package/README.md +23 -23
- package/classes/CConfirmation.js +35 -35
- package/classes/CEconItem.js +120 -120
- package/classes/CMarketItem.js +189 -189
- package/classes/CMarketSearchResult.js +89 -89
- package/classes/CSteamGroup.js +155 -155
- package/classes/CSteamUser.js +8 -0
- package/components/chat.js +283 -283
- package/components/groups.js +732 -732
- package/components/help.js +64 -0
- package/components/http.js +150 -150
- package/components/inventoryhistory.js +188 -188
- package/components/market.js +387 -214
- package/components/twofactor.js +159 -159
- package/components/users.js +767 -667
- package/components/webapi.js +57 -73
- package/examples/disable_twofactor.js +62 -62
- package/examples/edit-group-announcement.js +118 -118
- package/examples/enable_twofactor.js +112 -112
- package/index.js +35 -2
- package/package.json +1 -1
- package/resources/EFriendRelationship.js +23 -0
- package/resources/EPersonaState.js +2 -2
- package/resources/EPersonaStateFlag.js +6 -1
- package/resources/EResult.js +14 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const SteamCommunity = require('../index.js');
|
|
2
|
+
|
|
3
|
+
const Helpers = require('./helpers.js');
|
|
4
|
+
|
|
5
|
+
const HELP_SITE_DOMAIN = 'https://help.steampowered.com';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Restore a previously removed steam package from your steam account.
|
|
9
|
+
* @param {int|string} packageID
|
|
10
|
+
* @param {function} callback
|
|
11
|
+
*/
|
|
12
|
+
SteamCommunity.prototype.restorePackage = function(packageID, callback) {
|
|
13
|
+
this.httpRequestPost({
|
|
14
|
+
uri: HELP_SITE_DOMAIN + '/wizard/AjaxDoPackageRestore',
|
|
15
|
+
form: {
|
|
16
|
+
packageid: packageID,
|
|
17
|
+
sessionid: this.getSessionID(HELP_SITE_DOMAIN),
|
|
18
|
+
wizard_ajax: 1
|
|
19
|
+
},
|
|
20
|
+
json: true
|
|
21
|
+
}, wizardAjaxHandler(callback));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Remove a steam package from your steam account.
|
|
26
|
+
* @param {int|string} packageID
|
|
27
|
+
* @param {function} callback
|
|
28
|
+
*/
|
|
29
|
+
SteamCommunity.prototype.removePackage = function(packageID, callback) {
|
|
30
|
+
this.httpRequestPost({
|
|
31
|
+
uri: HELP_SITE_DOMAIN + '/wizard/AjaxDoPackageRemove',
|
|
32
|
+
form: {
|
|
33
|
+
packageid: packageID,
|
|
34
|
+
sessionid: this.getSessionID(HELP_SITE_DOMAIN),
|
|
35
|
+
wizard_ajax: 1
|
|
36
|
+
},
|
|
37
|
+
json: true
|
|
38
|
+
}, wizardAjaxHandler(callback));
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Returns a handler for wizard ajax HTTP requests.
|
|
43
|
+
* @param {function} callback
|
|
44
|
+
* @returns {(function(*=, *, *): void)|*}
|
|
45
|
+
*/
|
|
46
|
+
function wizardAjaxHandler(callback) {
|
|
47
|
+
return (err, res, body) => {
|
|
48
|
+
if (!callback) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (err) {
|
|
53
|
+
callback(err);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!body.success) {
|
|
58
|
+
callback(body.errorMsg ? new Error(body.errorMsg) : Helpers.eresultError(body.success));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
callback(null);
|
|
63
|
+
};
|
|
64
|
+
}
|
package/components/http.js
CHANGED
|
@@ -1,150 +1,150 @@
|
|
|
1
|
-
var SteamCommunity = require('../index.js');
|
|
2
|
-
|
|
3
|
-
SteamCommunity.prototype.httpRequest = function(uri, options, callback, source) {
|
|
4
|
-
if (typeof uri === 'object') {
|
|
5
|
-
source = callback;
|
|
6
|
-
callback = options;
|
|
7
|
-
options = uri;
|
|
8
|
-
uri = options.url || options.uri;
|
|
9
|
-
} else if (typeof options === 'function') {
|
|
10
|
-
source = callback;
|
|
11
|
-
callback = options;
|
|
12
|
-
options = {};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
options.url = options.uri = uri;
|
|
16
|
-
|
|
17
|
-
if (this._httpRequestConvenienceMethod) {
|
|
18
|
-
options.method = this._httpRequestConvenienceMethod;
|
|
19
|
-
delete this._httpRequestConvenienceMethod;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
var requestID = ++this._httpRequestID;
|
|
23
|
-
source = source || "";
|
|
24
|
-
|
|
25
|
-
var self = this;
|
|
26
|
-
var continued = false;
|
|
27
|
-
|
|
28
|
-
if (!this.onPreHttpRequest || !this.onPreHttpRequest(requestID, source, options, continueRequest)) {
|
|
29
|
-
// No pre-hook, or the pre-hook doesn't want to delay the request.
|
|
30
|
-
continueRequest(null);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function continueRequest(err) {
|
|
34
|
-
if (continued) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
continued = true;
|
|
39
|
-
|
|
40
|
-
if (err) {
|
|
41
|
-
if (callback) {
|
|
42
|
-
callback(err);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
self.request(options, function (err, response, body) {
|
|
49
|
-
var hasCallback = !!callback;
|
|
50
|
-
var httpError = options.checkHttpError !== false && self._checkHttpError(err, response, callback, body);
|
|
51
|
-
var communityError = !options.json && options.checkCommunityError !== false && self._checkCommunityError(body, httpError ? function () {} : callback); // don't fire the callback if hasHttpError did it already
|
|
52
|
-
var tradeError = !options.json && options.checkTradeError !== false && self._checkTradeError(body, httpError || communityError ? function () {} : callback); // don't fire the callback if either of the previous already did
|
|
53
|
-
var jsonError = options.json && options.checkJsonError !== false && !body ? new Error("Malformed JSON response") : null;
|
|
54
|
-
|
|
55
|
-
self.emit('postHttpRequest', requestID, source, options, httpError || communityError || tradeError || jsonError || null, response, body, {
|
|
56
|
-
"hasCallback": hasCallback,
|
|
57
|
-
"httpError": httpError,
|
|
58
|
-
"communityError": communityError,
|
|
59
|
-
"tradeError": tradeError,
|
|
60
|
-
"jsonError": jsonError
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
if (hasCallback && !(httpError || communityError || tradeError)) {
|
|
64
|
-
if (jsonError) {
|
|
65
|
-
callback.call(self, jsonError, response);
|
|
66
|
-
} else {
|
|
67
|
-
callback.apply(self, arguments);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
SteamCommunity.prototype.httpRequestGet = function() {
|
|
75
|
-
this._httpRequestConvenienceMethod = "GET";
|
|
76
|
-
return this.httpRequest.apply(this, arguments);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
SteamCommunity.prototype.httpRequestPost = function() {
|
|
80
|
-
this._httpRequestConvenienceMethod = "POST";
|
|
81
|
-
return this.httpRequest.apply(this, arguments);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
SteamCommunity.prototype._notifySessionExpired = function(err) {
|
|
85
|
-
this.emit('sessionExpired', err);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
SteamCommunity.prototype._checkHttpError = function(err, response, callback, body) {
|
|
89
|
-
if (err) {
|
|
90
|
-
callback(err, response, body);
|
|
91
|
-
return err;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (response.statusCode >= 300 && response.statusCode <= 399 && response.headers.location.indexOf('/login') != -1) {
|
|
95
|
-
err = new Error("Not Logged In");
|
|
96
|
-
callback(err, response, body);
|
|
97
|
-
this._notifySessionExpired(err);
|
|
98
|
-
return err;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (response.statusCode == 403 && typeof response.body === 'string' && response.body.match(/<div id="parental_notice_instructions">Enter your PIN below to exit Family View.<\/div>/)) {
|
|
102
|
-
err = new Error("Family View Restricted");
|
|
103
|
-
callback(err, response, body);
|
|
104
|
-
return err;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (response.statusCode >= 400) {
|
|
108
|
-
err = new Error("HTTP error " + response.statusCode);
|
|
109
|
-
err.code = response.statusCode;
|
|
110
|
-
callback(err, response, body);
|
|
111
|
-
return err;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return false;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
SteamCommunity.prototype._checkCommunityError = function(html, callback) {
|
|
118
|
-
var err;
|
|
119
|
-
|
|
120
|
-
if(typeof html === 'string' && html.match(/<h1>Sorry!<\/h1>/)) {
|
|
121
|
-
var match = html.match(/<h3>(.+)<\/h3>/);
|
|
122
|
-
err = new Error(match ? match[1] : "Unknown error occurred");
|
|
123
|
-
callback(err);
|
|
124
|
-
return err;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (typeof html === 'string' && html.match(/g_steamID = false;/) && html.match(/<h1>Sign In<\/h1>/)) {
|
|
128
|
-
err = new Error("Not Logged In");
|
|
129
|
-
callback(err);
|
|
130
|
-
this._notifySessionExpired(err);
|
|
131
|
-
return err;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return false;
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
SteamCommunity.prototype._checkTradeError = function(html, callback) {
|
|
138
|
-
if (typeof html !== 'string') {
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
var match = html.match(/<div id="error_msg">\s*([^<]+)\s*<\/div>/);
|
|
143
|
-
if (match) {
|
|
144
|
-
var err = new Error(match[1].trim());
|
|
145
|
-
callback(err);
|
|
146
|
-
return err;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return false;
|
|
150
|
-
};
|
|
1
|
+
var SteamCommunity = require('../index.js');
|
|
2
|
+
|
|
3
|
+
SteamCommunity.prototype.httpRequest = function(uri, options, callback, source) {
|
|
4
|
+
if (typeof uri === 'object') {
|
|
5
|
+
source = callback;
|
|
6
|
+
callback = options;
|
|
7
|
+
options = uri;
|
|
8
|
+
uri = options.url || options.uri;
|
|
9
|
+
} else if (typeof options === 'function') {
|
|
10
|
+
source = callback;
|
|
11
|
+
callback = options;
|
|
12
|
+
options = {};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
options.url = options.uri = uri;
|
|
16
|
+
|
|
17
|
+
if (this._httpRequestConvenienceMethod) {
|
|
18
|
+
options.method = this._httpRequestConvenienceMethod;
|
|
19
|
+
delete this._httpRequestConvenienceMethod;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var requestID = ++this._httpRequestID;
|
|
23
|
+
source = source || "";
|
|
24
|
+
|
|
25
|
+
var self = this;
|
|
26
|
+
var continued = false;
|
|
27
|
+
|
|
28
|
+
if (!this.onPreHttpRequest || !this.onPreHttpRequest(requestID, source, options, continueRequest)) {
|
|
29
|
+
// No pre-hook, or the pre-hook doesn't want to delay the request.
|
|
30
|
+
continueRequest(null);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function continueRequest(err) {
|
|
34
|
+
if (continued) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
continued = true;
|
|
39
|
+
|
|
40
|
+
if (err) {
|
|
41
|
+
if (callback) {
|
|
42
|
+
callback(err);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
self.request(options, function (err, response, body) {
|
|
49
|
+
var hasCallback = !!callback;
|
|
50
|
+
var httpError = options.checkHttpError !== false && self._checkHttpError(err, response, callback, body);
|
|
51
|
+
var communityError = !options.json && options.checkCommunityError !== false && self._checkCommunityError(body, httpError ? function () {} : callback); // don't fire the callback if hasHttpError did it already
|
|
52
|
+
var tradeError = !options.json && options.checkTradeError !== false && self._checkTradeError(body, httpError || communityError ? function () {} : callback); // don't fire the callback if either of the previous already did
|
|
53
|
+
var jsonError = options.json && options.checkJsonError !== false && !body ? new Error("Malformed JSON response") : null;
|
|
54
|
+
|
|
55
|
+
self.emit('postHttpRequest', requestID, source, options, httpError || communityError || tradeError || jsonError || null, response, body, {
|
|
56
|
+
"hasCallback": hasCallback,
|
|
57
|
+
"httpError": httpError,
|
|
58
|
+
"communityError": communityError,
|
|
59
|
+
"tradeError": tradeError,
|
|
60
|
+
"jsonError": jsonError
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
if (hasCallback && !(httpError || communityError || tradeError)) {
|
|
64
|
+
if (jsonError) {
|
|
65
|
+
callback.call(self, jsonError, response);
|
|
66
|
+
} else {
|
|
67
|
+
callback.apply(self, arguments);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
SteamCommunity.prototype.httpRequestGet = function() {
|
|
75
|
+
this._httpRequestConvenienceMethod = "GET";
|
|
76
|
+
return this.httpRequest.apply(this, arguments);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
SteamCommunity.prototype.httpRequestPost = function() {
|
|
80
|
+
this._httpRequestConvenienceMethod = "POST";
|
|
81
|
+
return this.httpRequest.apply(this, arguments);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
SteamCommunity.prototype._notifySessionExpired = function(err) {
|
|
85
|
+
this.emit('sessionExpired', err);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
SteamCommunity.prototype._checkHttpError = function(err, response, callback, body) {
|
|
89
|
+
if (err) {
|
|
90
|
+
callback(err, response, body);
|
|
91
|
+
return err;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (response.statusCode >= 300 && response.statusCode <= 399 && response.headers.location.indexOf('/login') != -1) {
|
|
95
|
+
err = new Error("Not Logged In");
|
|
96
|
+
callback(err, response, body);
|
|
97
|
+
this._notifySessionExpired(err);
|
|
98
|
+
return err;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (response.statusCode == 403 && typeof response.body === 'string' && response.body.match(/<div id="parental_notice_instructions">Enter your PIN below to exit Family View.<\/div>/)) {
|
|
102
|
+
err = new Error("Family View Restricted");
|
|
103
|
+
callback(err, response, body);
|
|
104
|
+
return err;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (response.statusCode >= 400) {
|
|
108
|
+
err = new Error("HTTP error " + response.statusCode);
|
|
109
|
+
err.code = response.statusCode;
|
|
110
|
+
callback(err, response, body);
|
|
111
|
+
return err;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return false;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
SteamCommunity.prototype._checkCommunityError = function(html, callback) {
|
|
118
|
+
var err;
|
|
119
|
+
|
|
120
|
+
if(typeof html === 'string' && html.match(/<h1>Sorry!<\/h1>/)) {
|
|
121
|
+
var match = html.match(/<h3>(.+)<\/h3>/);
|
|
122
|
+
err = new Error(match ? match[1] : "Unknown error occurred");
|
|
123
|
+
callback(err);
|
|
124
|
+
return err;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (typeof html === 'string' && html.match(/g_steamID = false;/) && html.match(/<h1>Sign In<\/h1>/)) {
|
|
128
|
+
err = new Error("Not Logged In");
|
|
129
|
+
callback(err);
|
|
130
|
+
this._notifySessionExpired(err);
|
|
131
|
+
return err;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return false;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
SteamCommunity.prototype._checkTradeError = function(html, callback) {
|
|
138
|
+
if (typeof html !== 'string') {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
var match = html.match(/<div id="error_msg">\s*([^<]+)\s*<\/div>/);
|
|
143
|
+
if (match) {
|
|
144
|
+
var err = new Error(match[1].trim());
|
|
145
|
+
callback(err);
|
|
146
|
+
return err;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return false;
|
|
150
|
+
};
|