steamcommunity 3.43.1 → 3.44.2
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/.idea/codeStyles/Project.xml +0 -3
- package/.idea/codeStyles/codeStyleConfig.xml +1 -0
- package/.idea/modules.xml +1 -0
- package/.idea/steamcommunity.iml +1 -0
- package/.idea/vcs.xml +1 -0
- package/classes/CSteamGroup.js +155 -155
- package/components/confirmations.js +425 -425
- package/components/help.js +64 -61
- package/components/http.js +1 -1
- package/components/market.js +118 -0
- package/components/profile.js +475 -475
- package/components/users.js +767 -767
- package/index.js +589 -589
- package/package.json +1 -1
package/components/help.js
CHANGED
|
@@ -1,61 +1,64 @@
|
|
|
1
|
-
const SteamCommunity = require('../index.js');
|
|
2
|
-
|
|
3
|
-
const Helpers = require('./helpers.js');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
@@ -124,7 +124,7 @@ SteamCommunity.prototype._checkCommunityError = function(html, callback) {
|
|
|
124
124
|
return err;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
if (typeof html === 'string' && html.
|
|
127
|
+
if (typeof html === 'string' && html.indexOf('g_steamID = false;') > -1 && html.indexOf('<title>Sign In</title>') > -1) {
|
|
128
128
|
err = new Error("Not Logged In");
|
|
129
129
|
callback(err);
|
|
130
130
|
this._notifySessionExpired(err);
|
package/components/market.js
CHANGED
|
@@ -148,6 +148,124 @@ SteamCommunity.prototype.openBoosterPack = function(appid, assetid, callback) {
|
|
|
148
148
|
})
|
|
149
149
|
};
|
|
150
150
|
|
|
151
|
+
/**
|
|
152
|
+
* Get the booster pack catalog to see what booster packs you can create
|
|
153
|
+
* @param {function} callback
|
|
154
|
+
*/
|
|
155
|
+
SteamCommunity.prototype.getBoosterPackCatalog = function(callback) {
|
|
156
|
+
this.httpRequestGet('https://steamcommunity.com/tradingcards/boostercreator/', (err, res, body) => {
|
|
157
|
+
if (err) {
|
|
158
|
+
callback(err);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
let idx = body.indexOf('CBoosterCreatorPage.Init(');
|
|
163
|
+
if (idx == -1) {
|
|
164
|
+
callback(new Error('Malformed response'));
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
let lines = body.slice(idx).split('\n').map(l => l.trim());
|
|
169
|
+
|
|
170
|
+
for (let i = 1; i <= 4; i++) {
|
|
171
|
+
if (typeof lines[i] != 'string' || !lines[i].match(/,$/)) {
|
|
172
|
+
let err = new Error('Malformed response');
|
|
173
|
+
err.line = i;
|
|
174
|
+
callback(err);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
lines[i] = lines[i].replace(/,$/, '');
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
let boosterPackCatalog, totalGems, tradableGems, untradableGems;
|
|
182
|
+
try {
|
|
183
|
+
boosterPackCatalog = JSON.parse(lines[1]);
|
|
184
|
+
totalGems = parseInt(lines[2].match(/\d+/)[0], 10);
|
|
185
|
+
tradableGems = parseInt(lines[3].match(/\d+/)[0], 10);
|
|
186
|
+
untradableGems = parseInt(lines[4].match(/\d+/)[0], 10);
|
|
187
|
+
} catch (ex) {
|
|
188
|
+
let err = new Error('Malformed response');
|
|
189
|
+
err.inner = ex;
|
|
190
|
+
callback(err);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
let keyedCatalog = {};
|
|
195
|
+
boosterPackCatalog.forEach((app) => {
|
|
196
|
+
app.price = parseInt(app.price, 10);
|
|
197
|
+
app.unavailable = app.unavailable || false;
|
|
198
|
+
app.availableAtTime = app.available_at_time || null;
|
|
199
|
+
|
|
200
|
+
if (typeof app.availableAtTime == 'string') {
|
|
201
|
+
app.availableAtTime = Helpers.decodeSteamTime(app.availableAtTime);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
delete app.available_at_time;
|
|
205
|
+
|
|
206
|
+
keyedCatalog[app.appid] = app;
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
callback(null, {
|
|
210
|
+
totalGems,
|
|
211
|
+
tradableGems,
|
|
212
|
+
untradableGems,
|
|
213
|
+
catalog: keyedCatalog
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Create a booster pack using gems.
|
|
220
|
+
* @param {int} appid
|
|
221
|
+
* @param {boolean} [useUntradableGems=false]
|
|
222
|
+
* @param callback
|
|
223
|
+
*/
|
|
224
|
+
SteamCommunity.prototype.createBoosterPack = function(appid, useUntradableGems, callback) {
|
|
225
|
+
if (typeof useUntradableGems == 'function') {
|
|
226
|
+
callback = useUntradableGems;
|
|
227
|
+
useUntradableGems = false;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
this.httpRequestPost({
|
|
231
|
+
uri: 'https://steamcommunity.com/tradingcards/ajaxcreatebooster/',
|
|
232
|
+
form: {
|
|
233
|
+
sessionid: this.getSessionID(),
|
|
234
|
+
appid,
|
|
235
|
+
series: 1,
|
|
236
|
+
// tradability_preference can be a value 1-3
|
|
237
|
+
// 1: Prefer using tradable gems, but use untradable if necessary
|
|
238
|
+
// 2: Only use tradable gems
|
|
239
|
+
// 3: Prefer using untradable gems, but use tradable if necessary
|
|
240
|
+
tradability_preference: useUntradableGems ? 3 : 2
|
|
241
|
+
},
|
|
242
|
+
json: true,
|
|
243
|
+
checkHttpError: false
|
|
244
|
+
}, (err, res, body) => {
|
|
245
|
+
if (err) {
|
|
246
|
+
callback(err);
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (body.purchase_eresult && body.purchase_eresult != 1) {
|
|
251
|
+
callback(Helpers.eresultError(body.purchase_eresult));
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// We can now check HTTP status codes
|
|
256
|
+
if (this._checkHttpError(err, res, callback, body)) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
callback(null, {
|
|
261
|
+
totalGems: parseInt(body.goo_amount, 10),
|
|
262
|
+
tradableGems: parseInt(body.tradable_goo_amount, 10),
|
|
263
|
+
untradableGems: parseInt(body.untradable_goo_amount, 10),
|
|
264
|
+
resultItem: body.purchase_result
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
};
|
|
268
|
+
|
|
151
269
|
/**
|
|
152
270
|
* Get details about a gift in your inventory.
|
|
153
271
|
* @param {string} giftID
|