steamutils 1.1.74 → 1.1.76
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/codeStyleConfig.xml +5 -0
- package/.idea/steamutils.iml +1 -1
- package/.idea/vcs.xml +1 -1
- package/index.js +65 -2
- package/package.json +3 -2
package/.idea/steamutils.iml
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
<module type="WEB_MODULE" version="4">
|
3
3
|
<component name="NewModuleRootManager">
|
4
4
|
<content url="file://$MODULE_DIR$">
|
5
|
-
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
6
5
|
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
7
7
|
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
8
8
|
</content>
|
9
9
|
<orderEntry type="inheritedJdk" />
|
package/.idea/vcs.xml
CHANGED
package/index.js
CHANGED
@@ -16,6 +16,8 @@ import { getJSObjectFronXML } from './xml2json.js'
|
|
16
16
|
import axios from 'axios'
|
17
17
|
import url from 'url'
|
18
18
|
import * as cherrio from "cheerio";
|
19
|
+
import fs from "fs";
|
20
|
+
import FormData from "form-data";
|
19
21
|
|
20
22
|
const MAX_RETRY = 10
|
21
23
|
let requestTimestamp = 0
|
@@ -1474,7 +1476,7 @@ class SteamUser {
|
|
1474
1476
|
}
|
1475
1477
|
|
1476
1478
|
if (params.method.toUpperCase() === 'POST') {
|
1477
|
-
if (params.data instanceof URLSearchParams) {
|
1479
|
+
if (params.data instanceof URLSearchParams || params.data instanceof FormData) {
|
1478
1480
|
params.data.append('sessionid', this._sessionid)
|
1479
1481
|
params.data.append('sessionID', this._sessionid)
|
1480
1482
|
} else if (typeof params.data === 'string') {
|
@@ -1495,6 +1497,9 @@ class SteamUser {
|
|
1495
1497
|
if (params.data instanceof URLSearchParams) {
|
1496
1498
|
params.headers.set('content-type', 'application/x-www-form-urlencoded')
|
1497
1499
|
}
|
1500
|
+
else if (params.data instanceof FormData) {
|
1501
|
+
params.headers.set('content-type', 'multipart/form-data')
|
1502
|
+
}
|
1498
1503
|
}
|
1499
1504
|
|
1500
1505
|
let redirectURL = null
|
@@ -3211,7 +3216,7 @@ class SteamUser {
|
|
3211
3216
|
playingTime,
|
3212
3217
|
name,
|
3213
3218
|
onlineStatus,
|
3214
|
-
miniprofile,
|
3219
|
+
steamId: SteamUser.miniprofile2SteamID64(miniprofile),
|
3215
3220
|
avatar,
|
3216
3221
|
})
|
3217
3222
|
})
|
@@ -5583,6 +5588,64 @@ class SteamUser {
|
|
5583
5588
|
token: tradeURLParams.token,
|
5584
5589
|
}
|
5585
5590
|
}
|
5591
|
+
|
5592
|
+
async uploadAvatar(filePath) {
|
5593
|
+
const form = new FormData();
|
5594
|
+
form.append('avatar', fs.createReadStream(filePath));
|
5595
|
+
form.append('type', 'player_avatar_image');
|
5596
|
+
form.append('sId', this._steamid_user);
|
5597
|
+
form.append('sessionid', this._sessionid);
|
5598
|
+
form.append('doSub', '1');
|
5599
|
+
form.append('json', '1');
|
5600
|
+
|
5601
|
+
const result = await this._httpRequest({
|
5602
|
+
url: 'actions/FileUploader/',
|
5603
|
+
method: "POST",
|
5604
|
+
data: form,
|
5605
|
+
headers: {
|
5606
|
+
'Accept': 'application/json, text/plain, */*',
|
5607
|
+
}
|
5608
|
+
})
|
5609
|
+
return result?.data
|
5610
|
+
const successResponse = {
|
5611
|
+
"success": true,
|
5612
|
+
"images": {
|
5613
|
+
"0": "https:\/\/avatars.akamai.steamstatic.com\/8c150c6499937982c66e3ae27061b903a4bb168b.jpg",
|
5614
|
+
"full": "https:\/\/avatars.akamai.steamstatic.com\/8c150c6499937982c66e3ae27061b903a4bb168b_full.jpg",
|
5615
|
+
"medium": "https:\/\/avatars.akamai.steamstatic.com\/8c150c6499937982c66e3ae27061b903a4bb168b_medium.jpg"
|
5616
|
+
},
|
5617
|
+
"hash": "8c150c6499937982c66e3ae27061b903a4bb168b",
|
5618
|
+
"message": ""
|
5619
|
+
}
|
5620
|
+
|
5621
|
+
const error = `#Error_BadOrMissingSteamID`
|
5622
|
+
const error2 = {
|
5623
|
+
"success": false,
|
5624
|
+
"images": [],
|
5625
|
+
"hash": null,
|
5626
|
+
"message": "No file received."
|
5627
|
+
}
|
5628
|
+
}
|
5629
|
+
|
5630
|
+
async getMiniprofile(steamId = this._steamid_user){
|
5631
|
+
const response = await this._httpRequestAjax({
|
5632
|
+
url: `${SteamUser.steamID642Miniprofile(steamId)}/json/?origin=https://steamcommunity.com/`
|
5633
|
+
})
|
5634
|
+
return response.data
|
5635
|
+
const example = {
|
5636
|
+
"level": 0,
|
5637
|
+
"level_class": "friendPlayerLevel lvl_0",
|
5638
|
+
"avatar_url": "https:\/\/avatars.akamai.steamstatic.com\/2da65f05388ed7c857a46d82dfb9dbc19edef261_full.jpg",
|
5639
|
+
"persona_name": "Natri",
|
5640
|
+
"in_game": {
|
5641
|
+
"name": "Counter-Strike: Global Offensive",
|
5642
|
+
"is_non_steam": false,
|
5643
|
+
"logo": "https:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/730\/capsule_184x69.jpg?t=1683566799",
|
5644
|
+
"rich_presence": "",
|
5645
|
+
"os_type": -700
|
5646
|
+
}
|
5647
|
+
}
|
5648
|
+
}
|
5586
5649
|
}
|
5587
5650
|
|
5588
5651
|
export default SteamUser
|
package/package.json
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "steamutils",
|
3
|
-
"version": "1.1.
|
4
|
-
"main":"index.js",
|
3
|
+
"version": "1.1.76",
|
4
|
+
"main": "index.js",
|
5
5
|
"dependencies": {
|
6
6
|
"axios": "^1.3.4",
|
7
7
|
"cheerio": "^1.0.0-rc.12",
|
8
8
|
"crypto-js": "^4.1.1",
|
9
9
|
"csgo-friendcode": "^3.0.3",
|
10
|
+
"form-data": "^4.0.0",
|
10
11
|
"lodash": "^4.17.21",
|
11
12
|
"moment": "^2.29.4",
|
12
13
|
"node-bignumber": "^1.2.2",
|