steamutils 1.1.46 → 1.1.48

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/index.js +40 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -5425,6 +5425,46 @@ class SteamUser {
5425
5425
  const trade_offer_access_url = $('#trade_offer_access_url').attr('value')
5426
5426
  return trade_offer_access_url
5427
5427
  }
5428
+
5429
+ async sendTradeOffer({tradeURL, me, them, tradeoffermessage = ''}) {//partner: steamid not accountid
5430
+ // const meExample = {
5431
+ // "assets": [{"appid": 730, "contextid": "2", "amount": 1, "assetid": "30492209501"}],
5432
+ // "currency": [],
5433
+ // "ready": false
5434
+ // }
5435
+ // const themExample = {
5436
+ // "assets": [{"appid": 730, "contextid": "2", "amount": 1, "assetid": "30494845811"}],
5437
+ // "currency": [],
5438
+ // "ready": false
5439
+ // }
5440
+ const tradeURLParams = url.parse(tradeURL).query.split('&').reduce((accumulator, currentValue, index) => ({
5441
+ ...accumulator, [currentValue.split('=')[0]]: currentValue.split('=')[1]
5442
+ }), {})
5443
+ const result = await this._httpRequest({
5444
+ url: `tradeoffer/new/send`,
5445
+ headers: {
5446
+ Referer: tradeURL,
5447
+ accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
5448
+ 'Content-Type': 'application/x-www-form-urlencoded',
5449
+ },
5450
+ data: {
5451
+ serverid: 1,
5452
+ partner: SteamID.fromIndividualAccountID(tradeURLParams.partner).getSteamID64(),
5453
+ tradeoffermessage,
5454
+ json: JSON.stringify({
5455
+ newversion: true,
5456
+ version: 3,
5457
+ me,
5458
+ them,
5459
+ }),
5460
+ captcha: '',
5461
+ trade_offer_create_params: JSON.stringify({trade_offer_access_token: tradeURLParams.token}),
5462
+ account: this.getMiniProfileUser(),
5463
+ },
5464
+ method: 'POST',
5465
+ })
5466
+ return result.data
5467
+ }
5428
5468
  }
5429
5469
 
5430
5470
  export default SteamUser
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.1.46",
3
+ "version": "1.1.48",
4
4
  "main":"index.js",
5
5
  "dependencies": {
6
6
  "axios": "^1.3.4",