steamcommunity 3.44.4 → 3.45.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.
- package/.github/FUNDING.yml +2 -2
- 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/README.md +23 -23
- package/classes/CConfirmation.js +4 -2
- package/classes/CMarketItem.js +189 -189
- package/classes/CMarketSearchResult.js +89 -89
- package/classes/CSteamGroup.js +155 -155
- package/components/chat.js +283 -283
- package/components/confirmations.js +412 -425
- package/components/groups.js +732 -732
- package/components/helpers.js +12 -0
- package/components/inventoryhistory.js +188 -188
- package/components/twofactor.js +152 -159
- package/components/webapi.js +63 -2
- package/examples/disable_twofactor.js +81 -62
- package/examples/edit-group-announcement.js +118 -118
- package/examples/enable_twofactor.js +131 -112
- package/index.js +597 -587
- package/package.json +1 -1
package/components/helpers.js
CHANGED
|
@@ -54,3 +54,15 @@ exports.eresultError = function(eresult) {
|
|
|
54
54
|
err.eresult = eresult;
|
|
55
55
|
return err;
|
|
56
56
|
};
|
|
57
|
+
|
|
58
|
+
exports.decodeJwt = function(jwt) {
|
|
59
|
+
let parts = jwt.split('.');
|
|
60
|
+
if (parts.length != 3) {
|
|
61
|
+
throw new Error('Invalid JWT');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let standardBase64 = parts[1].replace(/-/g, '+')
|
|
65
|
+
.replace(/_/g, '/');
|
|
66
|
+
|
|
67
|
+
return JSON.parse(Buffer.from(standardBase64, 'base64').toString('utf8'));
|
|
68
|
+
}
|
|
@@ -1,188 +1,188 @@
|
|
|
1
|
-
var SteamCommunity = require('../index.js');
|
|
2
|
-
var CEconItem = require('../classes/CEconItem.js');
|
|
3
|
-
var SteamID = require('steamid');
|
|
4
|
-
var request = require('request');
|
|
5
|
-
var Cheerio = require('cheerio');
|
|
6
|
-
var Async = require('async');
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
* Inventory history in a nutshell.
|
|
10
|
-
*
|
|
11
|
-
* There are no more page numbers. Now you have to request after_time and optionally after_trade.
|
|
12
|
-
* Without "prev" set, you will request 30 trades that were completed FURTHER IN THE PAST than after_time (and optionally after_trade)
|
|
13
|
-
* With "prev" set, you will request 30 trades that were completed MORE RECENTLY than after_time (and optionally after_trade)
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated Use GetTradeHistory instead: https://lab.xpaw.me/steam_api_documentation.html#IEconService_GetTradeHistory_v1
|
|
18
|
-
* @param {object} options
|
|
19
|
-
* @param {function} callback
|
|
20
|
-
*/
|
|
21
|
-
SteamCommunity.prototype.getInventoryHistory = function(options, callback) {
|
|
22
|
-
if (typeof options === 'function') {
|
|
23
|
-
callback = options;
|
|
24
|
-
options = {};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
options.direction = options.direction || "past";
|
|
28
|
-
|
|
29
|
-
var qs = "?l=english";
|
|
30
|
-
if (options.startTime) {
|
|
31
|
-
if (options.startTime instanceof Date) {
|
|
32
|
-
options.startTime = Math.floor(options.startTime.getTime() / 1000);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
qs += "&after_time=" + options.startTime;
|
|
36
|
-
|
|
37
|
-
if (options.startTrade) {
|
|
38
|
-
qs += "&after_trade=" + options.startTrade;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (options.direction == "future") {
|
|
43
|
-
qs += "&prev=1";
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
this._myProfile("inventoryhistory" + qs, null, function(err, response, body) {
|
|
47
|
-
if (err) {
|
|
48
|
-
callback(err);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
var output = {};
|
|
53
|
-
var vanityURLs = [];
|
|
54
|
-
|
|
55
|
-
var $ = Cheerio.load(body);
|
|
56
|
-
if (!$('.inventory_history_pagingrow').html()) {
|
|
57
|
-
callback(new Error("Malformed page: no paging row found"));
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Load the inventory item data
|
|
62
|
-
var match2 = body.match(/var g_rgHistoryInventory = (.*);/);
|
|
63
|
-
if (!match2) {
|
|
64
|
-
callback(new Error("Malformed page: no trade found"));
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
var historyInventory = JSON.parse(match2[1]);
|
|
70
|
-
} catch (ex) {
|
|
71
|
-
callback(new Error("Malformed page: no well-formed trade data found"));
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
var i;
|
|
76
|
-
|
|
77
|
-
// See if we've got paging buttons
|
|
78
|
-
var $paging = $('.inventory_history_nextbtn .pagebtn:not(.disabled)');
|
|
79
|
-
var href;
|
|
80
|
-
for (i = 0; i < $paging.length; i++) {
|
|
81
|
-
href = $paging[i].attribs.href;
|
|
82
|
-
if (href.match(/prev=1/)) {
|
|
83
|
-
output.firstTradeTime = new Date(href.match(/after_time=(\d+)/)[1] * 1000);
|
|
84
|
-
output.firstTradeID = href.match(/after_trade=(\d+)/)[1];
|
|
85
|
-
} else {
|
|
86
|
-
output.lastTradeTime = new Date(href.match(/after_time=(\d+)/)[1] * 1000);
|
|
87
|
-
output.lastTradeID = href.match(/after_trade=(\d+)/)[1];
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
output.trades = [];
|
|
92
|
-
var trades = $('.tradehistoryrow');
|
|
93
|
-
|
|
94
|
-
var item, trade, profileLink, items, j, econItem, timeMatch, time;
|
|
95
|
-
for (i = 0; i < trades.length; i++) {
|
|
96
|
-
item = $(trades[i]);
|
|
97
|
-
trade = {};
|
|
98
|
-
|
|
99
|
-
trade.onHold = !!item.find('span:nth-of-type(2)').text().match(/Trade on Hold/i);
|
|
100
|
-
|
|
101
|
-
timeMatch = item.find('.tradehistory_timestamp').html().match(/(\d+):(\d+)(am|pm)/);
|
|
102
|
-
if (timeMatch[1] == 12 && timeMatch[3] == 'am') {
|
|
103
|
-
timeMatch[1] = 0;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (timeMatch[1] < 12 && timeMatch[3] == 'pm') {
|
|
107
|
-
timeMatch[1] = parseInt(timeMatch[1], 10) + 12;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
time = (timeMatch[1] < 10 ? '0' : '') + timeMatch[1] + ':' + timeMatch[2] + ':00';
|
|
111
|
-
|
|
112
|
-
trade.date = new Date(item.find('.tradehistory_date').html() + ' ' + time + ' UTC');
|
|
113
|
-
trade.partnerName = item.find('.tradehistory_event_description a').html();
|
|
114
|
-
trade.partnerSteamID = null;
|
|
115
|
-
trade.partnerVanityURL = null;
|
|
116
|
-
trade.itemsReceived = [];
|
|
117
|
-
trade.itemsGiven = [];
|
|
118
|
-
|
|
119
|
-
profileLink = item.find('.tradehistory_event_description a').attr('href');
|
|
120
|
-
if (profileLink.indexOf('/profiles/') != -1) {
|
|
121
|
-
trade.partnerSteamID = new SteamID(profileLink.match(/(\d+)$/)[1]);
|
|
122
|
-
} else {
|
|
123
|
-
trade.partnerVanityURL = profileLink.match(/\/([^\/]+)$/)[1];
|
|
124
|
-
if (options.resolveVanityURLs && vanityURLs.indexOf(trade.partnerVanityURL) == -1) {
|
|
125
|
-
vanityURLs.push(trade.partnerVanityURL);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
items = item.find('.history_item');
|
|
130
|
-
for (j = 0; j < items.length; j++) {
|
|
131
|
-
match = body.match(new RegExp("HistoryPageCreateItemHover\\( '" + $(items[j]).attr('id') + "', (\\d+), '(\\d+)', '(\\d+|class_\\d+_instance_\\d+|class_\\d+)', '(\\d+)' \\);"));
|
|
132
|
-
econItem = historyInventory[match[1]][match[2]][match[3]];
|
|
133
|
-
|
|
134
|
-
if ($(items[j]).attr('id').indexOf('received') != -1) {
|
|
135
|
-
trade.itemsReceived.push(new CEconItem(econItem));
|
|
136
|
-
} else {
|
|
137
|
-
trade.itemsGiven.push(new CEconItem(econItem));
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
output.trades.push(trade);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (options.resolveVanityURLs) {
|
|
145
|
-
Async.map(vanityURLs, resolveVanityURL, function(err, results) {
|
|
146
|
-
if (err) {
|
|
147
|
-
callback(err);
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
for (i = 0; i < output.trades.length; i++) {
|
|
152
|
-
if (output.trades[i].partnerSteamID || !output.trades[i].partnerVanityURL) {
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// Find the vanity URL
|
|
157
|
-
for (j = 0; j < results.length; j++) {
|
|
158
|
-
if (results[j].vanityURL == output.trades[i].partnerVanityURL) {
|
|
159
|
-
output.trades[i].partnerSteamID = new SteamID(results[j].steamID);
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
callback(null, output);
|
|
166
|
-
});
|
|
167
|
-
} else {
|
|
168
|
-
callback(null, output);
|
|
169
|
-
}
|
|
170
|
-
}, "steamcommunity");
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
function resolveVanityURL(vanityURL, callback) {
|
|
174
|
-
request("https://steamcommunity.com/id/" + vanityURL + "/?xml=1", function(err, response, body) {
|
|
175
|
-
if (err) {
|
|
176
|
-
callback(err);
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
var match = body.match(/<steamID64>(\d+)<\/steamID64>/);
|
|
181
|
-
if (!match || !match[1]) {
|
|
182
|
-
callback(new Error("Couldn't find Steam ID"));
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
callback(null, {"vanityURL": vanityURL, "steamID": match[1]});
|
|
187
|
-
});
|
|
188
|
-
}
|
|
1
|
+
var SteamCommunity = require('../index.js');
|
|
2
|
+
var CEconItem = require('../classes/CEconItem.js');
|
|
3
|
+
var SteamID = require('steamid');
|
|
4
|
+
var request = require('request');
|
|
5
|
+
var Cheerio = require('cheerio');
|
|
6
|
+
var Async = require('async');
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* Inventory history in a nutshell.
|
|
10
|
+
*
|
|
11
|
+
* There are no more page numbers. Now you have to request after_time and optionally after_trade.
|
|
12
|
+
* Without "prev" set, you will request 30 trades that were completed FURTHER IN THE PAST than after_time (and optionally after_trade)
|
|
13
|
+
* With "prev" set, you will request 30 trades that were completed MORE RECENTLY than after_time (and optionally after_trade)
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use GetTradeHistory instead: https://lab.xpaw.me/steam_api_documentation.html#IEconService_GetTradeHistory_v1
|
|
18
|
+
* @param {object} options
|
|
19
|
+
* @param {function} callback
|
|
20
|
+
*/
|
|
21
|
+
SteamCommunity.prototype.getInventoryHistory = function(options, callback) {
|
|
22
|
+
if (typeof options === 'function') {
|
|
23
|
+
callback = options;
|
|
24
|
+
options = {};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
options.direction = options.direction || "past";
|
|
28
|
+
|
|
29
|
+
var qs = "?l=english";
|
|
30
|
+
if (options.startTime) {
|
|
31
|
+
if (options.startTime instanceof Date) {
|
|
32
|
+
options.startTime = Math.floor(options.startTime.getTime() / 1000);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
qs += "&after_time=" + options.startTime;
|
|
36
|
+
|
|
37
|
+
if (options.startTrade) {
|
|
38
|
+
qs += "&after_trade=" + options.startTrade;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (options.direction == "future") {
|
|
43
|
+
qs += "&prev=1";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
this._myProfile("inventoryhistory" + qs, null, function(err, response, body) {
|
|
47
|
+
if (err) {
|
|
48
|
+
callback(err);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
var output = {};
|
|
53
|
+
var vanityURLs = [];
|
|
54
|
+
|
|
55
|
+
var $ = Cheerio.load(body);
|
|
56
|
+
if (!$('.inventory_history_pagingrow').html()) {
|
|
57
|
+
callback(new Error("Malformed page: no paging row found"));
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Load the inventory item data
|
|
62
|
+
var match2 = body.match(/var g_rgHistoryInventory = (.*);/);
|
|
63
|
+
if (!match2) {
|
|
64
|
+
callback(new Error("Malformed page: no trade found"));
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
var historyInventory = JSON.parse(match2[1]);
|
|
70
|
+
} catch (ex) {
|
|
71
|
+
callback(new Error("Malformed page: no well-formed trade data found"));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
var i;
|
|
76
|
+
|
|
77
|
+
// See if we've got paging buttons
|
|
78
|
+
var $paging = $('.inventory_history_nextbtn .pagebtn:not(.disabled)');
|
|
79
|
+
var href;
|
|
80
|
+
for (i = 0; i < $paging.length; i++) {
|
|
81
|
+
href = $paging[i].attribs.href;
|
|
82
|
+
if (href.match(/prev=1/)) {
|
|
83
|
+
output.firstTradeTime = new Date(href.match(/after_time=(\d+)/)[1] * 1000);
|
|
84
|
+
output.firstTradeID = href.match(/after_trade=(\d+)/)[1];
|
|
85
|
+
} else {
|
|
86
|
+
output.lastTradeTime = new Date(href.match(/after_time=(\d+)/)[1] * 1000);
|
|
87
|
+
output.lastTradeID = href.match(/after_trade=(\d+)/)[1];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
output.trades = [];
|
|
92
|
+
var trades = $('.tradehistoryrow');
|
|
93
|
+
|
|
94
|
+
var item, trade, profileLink, items, j, econItem, timeMatch, time;
|
|
95
|
+
for (i = 0; i < trades.length; i++) {
|
|
96
|
+
item = $(trades[i]);
|
|
97
|
+
trade = {};
|
|
98
|
+
|
|
99
|
+
trade.onHold = !!item.find('span:nth-of-type(2)').text().match(/Trade on Hold/i);
|
|
100
|
+
|
|
101
|
+
timeMatch = item.find('.tradehistory_timestamp').html().match(/(\d+):(\d+)(am|pm)/);
|
|
102
|
+
if (timeMatch[1] == 12 && timeMatch[3] == 'am') {
|
|
103
|
+
timeMatch[1] = 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (timeMatch[1] < 12 && timeMatch[3] == 'pm') {
|
|
107
|
+
timeMatch[1] = parseInt(timeMatch[1], 10) + 12;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
time = (timeMatch[1] < 10 ? '0' : '') + timeMatch[1] + ':' + timeMatch[2] + ':00';
|
|
111
|
+
|
|
112
|
+
trade.date = new Date(item.find('.tradehistory_date').html() + ' ' + time + ' UTC');
|
|
113
|
+
trade.partnerName = item.find('.tradehistory_event_description a').html();
|
|
114
|
+
trade.partnerSteamID = null;
|
|
115
|
+
trade.partnerVanityURL = null;
|
|
116
|
+
trade.itemsReceived = [];
|
|
117
|
+
trade.itemsGiven = [];
|
|
118
|
+
|
|
119
|
+
profileLink = item.find('.tradehistory_event_description a').attr('href');
|
|
120
|
+
if (profileLink.indexOf('/profiles/') != -1) {
|
|
121
|
+
trade.partnerSteamID = new SteamID(profileLink.match(/(\d+)$/)[1]);
|
|
122
|
+
} else {
|
|
123
|
+
trade.partnerVanityURL = profileLink.match(/\/([^\/]+)$/)[1];
|
|
124
|
+
if (options.resolveVanityURLs && vanityURLs.indexOf(trade.partnerVanityURL) == -1) {
|
|
125
|
+
vanityURLs.push(trade.partnerVanityURL);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
items = item.find('.history_item');
|
|
130
|
+
for (j = 0; j < items.length; j++) {
|
|
131
|
+
match = body.match(new RegExp("HistoryPageCreateItemHover\\( '" + $(items[j]).attr('id') + "', (\\d+), '(\\d+)', '(\\d+|class_\\d+_instance_\\d+|class_\\d+)', '(\\d+)' \\);"));
|
|
132
|
+
econItem = historyInventory[match[1]][match[2]][match[3]];
|
|
133
|
+
|
|
134
|
+
if ($(items[j]).attr('id').indexOf('received') != -1) {
|
|
135
|
+
trade.itemsReceived.push(new CEconItem(econItem));
|
|
136
|
+
} else {
|
|
137
|
+
trade.itemsGiven.push(new CEconItem(econItem));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
output.trades.push(trade);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (options.resolveVanityURLs) {
|
|
145
|
+
Async.map(vanityURLs, resolveVanityURL, function(err, results) {
|
|
146
|
+
if (err) {
|
|
147
|
+
callback(err);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
for (i = 0; i < output.trades.length; i++) {
|
|
152
|
+
if (output.trades[i].partnerSteamID || !output.trades[i].partnerVanityURL) {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Find the vanity URL
|
|
157
|
+
for (j = 0; j < results.length; j++) {
|
|
158
|
+
if (results[j].vanityURL == output.trades[i].partnerVanityURL) {
|
|
159
|
+
output.trades[i].partnerSteamID = new SteamID(results[j].steamID);
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
callback(null, output);
|
|
166
|
+
});
|
|
167
|
+
} else {
|
|
168
|
+
callback(null, output);
|
|
169
|
+
}
|
|
170
|
+
}, "steamcommunity");
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
function resolveVanityURL(vanityURL, callback) {
|
|
174
|
+
request("https://steamcommunity.com/id/" + vanityURL + "/?xml=1", function(err, response, body) {
|
|
175
|
+
if (err) {
|
|
176
|
+
callback(err);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
var match = body.match(/<steamID64>(\d+)<\/steamID64>/);
|
|
181
|
+
if (!match || !match[1]) {
|
|
182
|
+
callback(new Error("Couldn't find Steam ID"));
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
callback(null, {"vanityURL": vanityURL, "steamID": match[1]});
|
|
187
|
+
});
|
|
188
|
+
}
|