mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2026-08-19 13:13:28 +08:00
Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a12174a7c | ||
|
|
caa76ee84b | ||
|
|
bc8893fedd | ||
|
|
d3e90f6fd3 | ||
|
|
a61b50b7a2 | ||
|
|
39fe4a4106 | ||
|
|
0d991c2655 | ||
|
|
0a307de9b9 | ||
|
|
c0b8dcf3a2 | ||
|
|
dcf00b4ea1 | ||
|
|
ee0cc34512 | ||
|
|
c52533ea06 | ||
|
|
67774f86f7 | ||
|
|
2f03e09f50 | ||
|
|
2868b1f45f | ||
|
|
ac222ef8c3 | ||
|
|
4b8799ddd4 | ||
|
|
f02f85a2aa | ||
|
|
4948cbeac0 | ||
|
|
1c1ff82543 | ||
|
|
63015259af | ||
|
|
ad67805ad9 | ||
|
|
3347d87f29 | ||
|
|
c97351543a | ||
|
|
1067d4572e | ||
|
|
49a7165052 | ||
|
|
0fb2798424 | ||
|
|
e16136866c | ||
|
|
cae85433f9 |
@@ -4,9 +4,8 @@
|
||||
[](https://github.com/DoctorMcKay/node-steamcommunity/blob/master/LICENSE)
|
||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=N36YVAT42CZ4G&item_name=node%2dsteamcommunity¤cy_code=USD)
|
||||
|
||||
This module provides an easy interface for the Steam Community website. This module can be used to simply login to steamcommunity.com for use with other libraries, or to interact with steamcommunity.com.
|
||||
|
||||
It supports Steam Guard and CAPTCHAs.
|
||||
This module provides an easy interface for the Steam Community website. This module can be used to simply login to
|
||||
steamcommunity.com for use with other libraries, or to interact with steamcommunity.com.
|
||||
|
||||
**Have a question about the module or coding in general? *Do not create a GitHub issue.* GitHub issues are for feature
|
||||
requests and bug reports. Instead, post in the [dedicated forum](https://dev.doctormckay.com/forum/8-node-steamcommunity/).
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module.exports = CEconItem;
|
||||
|
||||
function CEconItem(item, description, contextID) {
|
||||
function CEconItem(item, description, contextID, assetProperties) {
|
||||
var thing;
|
||||
for (thing in item) {
|
||||
if (item.hasOwnProperty(thing)) {
|
||||
@@ -28,7 +28,7 @@ function CEconItem(item, description, contextID) {
|
||||
}
|
||||
|
||||
for (thing in description) {
|
||||
if (description.hasOwnProperty(thing)) {
|
||||
if (description.hasOwnProperty(thing) && !this.hasOwnProperty(thing)) {
|
||||
this[thing] = description[thing];
|
||||
}
|
||||
}
|
||||
@@ -68,9 +68,9 @@ function CEconItem(item, description, contextID) {
|
||||
|
||||
// Restore cache_expiration, if we can (for CS:GO items)
|
||||
if (this.appid == 730 && this.contextid == 2 && this.owner_descriptions) {
|
||||
let description = this.owner_descriptions.find(d => d.value && d.value.indexOf('Tradable After ') == 0);
|
||||
let description = this.owner_descriptions.find(d => d.value && d.value.indexOf('Tradable/Marketable After ') == 0);
|
||||
if (description) {
|
||||
let date = new Date(description.value.substring(15).replace(/[,()]/g, ''));
|
||||
let date = new Date(description.value.substring(26).replace(/[,()]/g, ''));
|
||||
if (date) {
|
||||
this.cache_expiration = date.toISOString();
|
||||
}
|
||||
@@ -86,6 +86,11 @@ function CEconItem(item, description, contextID) {
|
||||
this.actions = [];
|
||||
}
|
||||
|
||||
// Assign asset_properties if provided
|
||||
if (assetProperties) {
|
||||
this.asset_properties = assetProperties;
|
||||
}
|
||||
|
||||
// One wouldn't think that we need this if statement, but apparently v8 has a weird bug/quirk where deleting a
|
||||
// property results in greatly increased memory usage. Because that makes sense.
|
||||
if (this.currency) {
|
||||
|
||||
@@ -13,7 +13,7 @@ SteamCommunity.prototype.getSteamUser = function(id, callback) {
|
||||
}
|
||||
|
||||
var self = this;
|
||||
this.httpRequest("http://steamcommunity.com/" + (typeof id === 'string' ? "id/" + id : "profiles/" + id.toString()) + "/?xml=1", function(err, response, body) {
|
||||
this.httpRequest("https://steamcommunity.com/" + (typeof id === 'string' ? "id/" + id : "profiles/" + id.toString()) + "/?xml=1", function(err, response, body) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
|
||||
@@ -392,6 +392,22 @@ SteamCommunity.prototype.checkConfirmations = function() {
|
||||
}
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.acknowledgeTradeProtection = function(callback) {
|
||||
this.httpRequestPost({
|
||||
uri: 'https://steamcommunity.com//trade/new/acknowledge',
|
||||
form: {
|
||||
sessionid: this.getSessionID(),
|
||||
message: 1
|
||||
}
|
||||
}, (err, res, body) => {
|
||||
if (err) {
|
||||
return callback && callback(err);
|
||||
}
|
||||
|
||||
callback && callback(null);
|
||||
}, 'steamcommunity');
|
||||
}
|
||||
|
||||
SteamCommunity.prototype._confirmationCheckerGetKey = function(tag, callback) {
|
||||
if(this._identitySecret) {
|
||||
if(tag == 'details') {
|
||||
|
||||
@@ -11,17 +11,17 @@ SteamCommunity.prototype.getGroupMembers = function(gid, callback, members, link
|
||||
if (!link) {
|
||||
if (typeof gid !== 'string') {
|
||||
// It's a SteamID object
|
||||
link = "http://steamcommunity.com/gid/" + gid.toString() + "/memberslistxml/?xml=1";
|
||||
link = "https://steamcommunity.com/gid/" + gid.toString() + "/memberslistxml/?xml=1";
|
||||
} else {
|
||||
try {
|
||||
var sid = new SteamID(gid);
|
||||
if (sid.type == SteamID.Type.CLAN && sid.isValid()) {
|
||||
link = "http://steamcommunity.com/gid/" + sid.getSteamID64() + "/memberslistxml/?xml=1";
|
||||
link = "https://steamcommunity.com/gid/" + sid.getSteamID64() + "/memberslistxml/?xml=1";
|
||||
} else {
|
||||
throw new Error("Doesn't particularly matter what this message is");
|
||||
}
|
||||
} catch (e) {
|
||||
link = "http://steamcommunity.com/groups/" + gid + "/memberslistxml/?xml=1";
|
||||
link = "https://steamcommunity.com/groups/" + gid + "/memberslistxml/?xml=1";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
var URL = require('url');
|
||||
|
||||
var SteamCommunity = require('../index.js');
|
||||
|
||||
SteamCommunity.prototype.httpRequest = function(uri, options, callback, source) {
|
||||
@@ -19,6 +21,16 @@ SteamCommunity.prototype.httpRequest = function(uri, options, callback, source)
|
||||
delete this._httpRequestConvenienceMethod;
|
||||
}
|
||||
|
||||
// Add origin header if necessary
|
||||
// https://github.com/DoctorMcKay/node-steamcommunity/issues/351
|
||||
if ((options.method || 'GET').toUpperCase() != 'GET') {
|
||||
options.headers = options.headers || {};
|
||||
if (!options.headers.origin) {
|
||||
var parsedUrl = URL.parse(options.url);
|
||||
options.headers.origin = parsedUrl.protocol + '//' + parsedUrl.host;
|
||||
}
|
||||
}
|
||||
|
||||
var requestID = ++this._httpRequestID;
|
||||
source = source || "";
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ SteamCommunity.prototype._modernLogin = function(logOnDetails) {
|
||||
let webCookies = await session.getWebCookies();
|
||||
let sessionIdCookie = webCookies.find(c => c.startsWith('sessionid='));
|
||||
resolve({
|
||||
sessionID: sessionIdCookie.split('=')[1],
|
||||
sessionID: sessionIdCookie.split('=')[1].split(';')[0].trim(),
|
||||
cookies: webCookies,
|
||||
steamguard: session.steamGuardMachineToken,
|
||||
mobileAccessToken: logOnDetails.disableMobile ? null : session.accessToken
|
||||
|
||||
@@ -590,7 +590,7 @@ SteamCommunity.prototype.getUserInventoryContents = function(userID, appID, cont
|
||||
},
|
||||
"qs": {
|
||||
"l": language, // Default language
|
||||
"count": 2000, // Max items per 'page'
|
||||
"count": 1000, // Max items per 'page'
|
||||
"start_assetid": start
|
||||
},
|
||||
"json": true
|
||||
@@ -629,6 +629,13 @@ SteamCommunity.prototype.getUserInventoryContents = function(userID, appID, cont
|
||||
return;
|
||||
}
|
||||
|
||||
if (appID == 730 && body && body.success && !body.assets) {
|
||||
// CS inventory has no visible items. We need a special case for this because Valve is incapable of
|
||||
// doing anything not dumb.
|
||||
callback(null, [], [], body.total_inventory_count);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!body || !body.success || !body.assets || !body.descriptions) {
|
||||
if (body) {
|
||||
// Dunno if the error/Error property even exists on this new endpoint
|
||||
@@ -640,12 +647,21 @@ SteamCommunity.prototype.getUserInventoryContents = function(userID, appID, cont
|
||||
return;
|
||||
}
|
||||
|
||||
// Build asset_properties lookup by assetid
|
||||
var assetPropertiesLookup = {};
|
||||
if (body.asset_properties) {
|
||||
for (var j = 0; j < body.asset_properties.length; j++) {
|
||||
assetPropertiesLookup[body.asset_properties[j].assetid] = body.asset_properties[j].asset_properties;
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < body.assets.length; i++) {
|
||||
var description = getDescription(body.descriptions, body.assets[i].classid, body.assets[i].instanceid);
|
||||
|
||||
if (!tradableOnly || (description && description.tradable)) {
|
||||
body.assets[i].pos = pos++;
|
||||
(body.assets[i].currencyid ? currency : inventory).push(new CEconItem(body.assets[i], description, contextID));
|
||||
var assetProperties = assetPropertiesLookup[body.assets[i].assetid] || null;
|
||||
(body.assets[i].currencyid ? currency : inventory).push(new CEconItem(body.assets[i], description, contextID, assetProperties));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1
examples/.gitignore
vendored
Normal file
1
examples/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
twofactor_*.json
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "steamcommunity",
|
||||
"version": "3.48.2",
|
||||
"version": "3.50.0",
|
||||
"description": "Provides an interface for logging into and interacting with the Steam Community website",
|
||||
"files": [
|
||||
"/classes",
|
||||
@@ -33,7 +33,7 @@
|
||||
"cheerio": "0.22.0",
|
||||
"image-size": "^0.8.2",
|
||||
"request": "^2.88.0",
|
||||
"steam-session": "^1.7.2",
|
||||
"steam-session": "^1.9.1",
|
||||
"steam-totp": "^1.5.0",
|
||||
"steamid": "^1.1.3",
|
||||
"xml2js": "^0.6.2"
|
||||
|
||||
Reference in New Issue
Block a user