Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: DoctorMcKay/node-steam-tradeoffer-manager
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.11.0
Choose a base ref
...
head repository: DoctorMcKay/node-steam-tradeoffer-manager
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 17 commits
  • 8 files changed
  • 5 contributors

Commits on Apr 4, 2024

  1. Copy the full SHA
    107d8cc View commit details
  2. Updated IDE configs

    DoctorMcKay committed Apr 4, 2024
    Copy the full SHA
    3dbd871 View commit details
  3. 2.11.1

    DoctorMcKay committed Apr 4, 2024
    Copy the full SHA
    d04af9d View commit details

Commits on Apr 6, 2024

  1. Copy the full SHA
    7e0808e View commit details

Commits on Apr 11, 2024

  1. Merge pull request #352 from Noobgam/noobgam/notify-session-expired-403

    fix: notify session expired on 403
    DoctorMcKay authored Apr 11, 2024
    Copy the full SHA
    84867a9 View commit details
  2. 2.11.2

    DoctorMcKay committed Apr 11, 2024
    Copy the full SHA
    04f6058 View commit details
  3. Copy the full SHA
    ab18134 View commit details
  4. 2.11.3

    DoctorMcKay committed Apr 11, 2024
    Copy the full SHA
    9d5509c View commit details

Commits on Apr 17, 2024

  1. Copy the full SHA
    71c9151 View commit details

Commits on Apr 18, 2024

  1. 2.11.4

    DoctorMcKay committed Apr 18, 2024
    Copy the full SHA
    5405fbe View commit details

Commits on Jul 27, 2024

  1. Copy the full SHA
    290b43f View commit details
  2. 2.11.5

    DoctorMcKay committed Jul 27, 2024
    Copy the full SHA
    7d27ae1 View commit details

Commits on Oct 4, 2024

  1. Copy the full SHA
    d9134fb View commit details

Commits on Oct 5, 2024

  1. Merge pull request #357 from tavindev/master

    fix(#356): doPoll after setCookies only if polling is enabled
    DoctorMcKay authored Oct 5, 2024
    Copy the full SHA
    c080cd4 View commit details
  2. 2.11.6

    DoctorMcKay committed Oct 5, 2024
    Copy the full SHA
    906cf8d View commit details

Commits on Nov 2, 2024

  1. Copy the full SHA
    1db1747 View commit details
  2. 2.11.7

    DoctorMcKay committed Nov 2, 2024
    Copy the full SHA
    e8c8b25 View commit details
Showing with 92 additions and 22 deletions.
  1. +1 −0 .idea/modules.xml
  2. +1 −0 .idea/steam-tradeoffer-manager.iml
  3. +2 −1 .idea/vcs.xml
  4. +7 −3 lib/classes/EconItem.js
  5. +67 −6 lib/classes/TradeOffer.js
  6. +4 −1 lib/index.js
  7. +9 −10 lib/webapi.js
  8. +1 −1 package.json
1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/steam-tradeoffer-manager.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions lib/classes/EconItem.js
Original file line number Diff line number Diff line change
@@ -29,9 +29,9 @@ function EconItem(item) {
this.market_actions = fixArray(this.market_actions);
this.tags = fixTags(this.tags);

this.tradable = !!parseInt(this.tradable, 10);
this.marketable = !!parseInt(this.marketable, 10);
this.commodity = !!parseInt(this.commodity, 10);
this.tradable = fixBool(this.tradable);
this.marketable = fixBool(this.marketable);
this.commodity = fixBool(this.commodity);
this.market_tradable_restriction = (this.market_tradable_restriction ? parseInt(this.market_tradable_restriction, 10) : 0);
this.market_marketable_restriction = (this.market_marketable_restriction ? parseInt(this.market_marketable_restriction, 10) : 0);

@@ -43,6 +43,10 @@ function EconItem(item) {
}
}

function fixBool(val) {
return typeof val == 'boolean' ? val : !!parseInt(val, 10);
}

function fixArray(obj) {
if (typeof obj === 'undefined' || obj == '') {
return [];
73 changes: 67 additions & 6 deletions lib/classes/TradeOffer.js
Original file line number Diff line number Diff line change
@@ -127,11 +127,6 @@ TradeOffer.prototype.data = function(key, value) {
return;
}

// We're setting the value. Check if the value already exists and is set to this value.
if (this.data(key) === value) {
return; // Already set, nothing to do
}

// Make sure pollData has offerData set.
pollData.offerData = pollData.offerData || {};
pollData.offerData[this.id] = pollData.offerData[this.id] || {};
@@ -150,7 +145,73 @@ TradeOffer.prototype.data = function(key, value) {
* @param {function} callback
*/
TradeOffer.prototype.loadPartnerInventory = function(appid, contextid, callback) {
this.manager.loadUserInventory(this.partner, appid, contextid, true, callback);
let items = [];

let req = (start) => {
let qs = {
sessionid: this.manager._community.getSessionID(),
partner: this.partner.toString(),
appid,
contextid
};

if (start) {
qs.start = start;
}

let refererUrl = 'https://steamcommunity.com/tradeoffer/new/?partner=' + this.partner.accountid;
if (this._token) {
refererUrl += '&token=' + this._token;
}

this.manager._community.httpRequest({
method: 'GET',
uri: 'https://steamcommunity.com/tradeoffer/new/partnerinventory/',
qs,
headers: {
Referer: refererUrl
},
json: true
}, (err, response, body) => {
if (err) {
callback(err);
return;
}

if (response.statusCode != 200) {
callback(new Error('HTTP error ' + response.statusCode));
return;
}

if (!body || !body.success) {
callback(new Error('Malformed response'));
return;
}

for (let i in (body.rgInventory || {})) {
let item = body.rgInventory[i];
let descKey = [item.classid, item.instanceid || 0].join('_');
let description = (body.rgDescriptions || {})[descKey];

for (let j in description) {
item[j] = description[j];
}

item.appid = appid;
item.contextid = contextid;

items.push(new EconItem(item));
}

if (body.more) {
req(body.more_start);
} else {
callback(null, items);
}
});
};

req();
};

/**
5 changes: 4 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
@@ -249,7 +249,10 @@ TradeOfferManager.prototype.setCookies = function(cookies, familyViewPin, callba
}

clearTimeout(this._pollTimer);
this.doPoll();

if (this.pollInterval >= 0) {
this.doPoll();
}

callback && callback();
};
19 changes: 9 additions & 10 deletions lib/webapi.js
Original file line number Diff line number Diff line change
@@ -25,7 +25,9 @@ TradeOfferManager.prototype._apiCall = function(httpMethod, method, version, inp

input = input || {};

if (this.apiKey) {
// We shouldn't strictly need to check useAccessToken here because we wouldn't have an API key anyway, but some
// people insist on manually assigning their API key despite the docs telling you not to do that.
if (this.apiKey && !this.useAccessToken) {
input.key = this.apiKey;
} else {
input.access_token = this.accessToken;
@@ -34,19 +36,16 @@ TradeOfferManager.prototype._apiCall = function(httpMethod, method, version, inp
options[httpMethod == 'GET' ? 'qs' : 'form'] = input;

this._community.httpRequest(options, (err, response, body) => {
if (err) {
err.body = body;
callback(err);
return;
}

var error;
var error = err;

if (response.statusCode != 200) {
if (response && response.statusCode != 200 && !error) {
error = new Error('HTTP error ' + response.statusCode);
}

if (error) {
error.body = body;

if (typeof response.body === 'string' && response.body.indexOf('Access is denied') >= 0) {
if (response && typeof response.body === 'string' && response.body.indexOf('Access is denied') >= 0) {
this._notifySessionExpired(error);
}

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "steam-tradeoffer-manager",
"version": "2.11.0",
"version": "2.11.7",
"description": "A simple trade offers API for Steam",
"main": "./lib/index.js",
"repository": {