steamutils 1.4.30 → 1.4.32
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/SteamClient.js +7 -0
- package/axios.js +59 -66
- package/index.js +7785 -7791
- package/package.json +8 -8
- package/utils.js +12 -1
package/SteamClient.js
CHANGED
|
@@ -1238,6 +1238,13 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
|
1238
1238
|
if (player) {
|
|
1239
1239
|
player.prime = !!(player.ranking?.account_id || player.player_level || player.player_cur_xp);
|
|
1240
1240
|
player.steamId = SteamID.fromIndividualAccountID(player.account_id).getSteamID64();
|
|
1241
|
+
player.current_xp = player.player_cur_xp ? player.player_cur_xp - 327680000 : 0;
|
|
1242
|
+
if (Array.isArray(player.rankings)) {
|
|
1243
|
+
const ranking = player.rankings.find((r) => r.rank_type_id === 11);
|
|
1244
|
+
if (ranking) {
|
|
1245
|
+
player.elo = ranking.rank_id;
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1241
1248
|
callGCCallback(`PlayersProfile_${player.account_id}`, player);
|
|
1242
1249
|
}
|
|
1243
1250
|
callEvent(events.playersProfile, player);
|
package/axios.js
CHANGED
|
@@ -1,62 +1,58 @@
|
|
|
1
|
-
import * as _axios from
|
|
2
|
-
import cheerio from
|
|
3
|
-
import {console_log} from './utils.js'
|
|
1
|
+
import * as _axios from "axios";
|
|
2
|
+
import * as cheerio from "cheerio";
|
|
4
3
|
|
|
5
4
|
export class Header {
|
|
6
|
-
|
|
5
|
+
headers = {};
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
7
|
+
constructor(headers) {
|
|
8
|
+
if (typeof headers === "object" && Object.keys(headers).length) {
|
|
9
|
+
this.headers = this.validate(headers);
|
|
12
10
|
}
|
|
11
|
+
}
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
return headers
|
|
13
|
+
validate(headers) {
|
|
14
|
+
headers = Object.keys(headers).reduce(function (previousValue, currentValue, currentIndex, array) {
|
|
15
|
+
previousValue[currentValue.toLowerCase()] = headers[currentValue]?.trim();
|
|
16
|
+
return previousValue;
|
|
17
|
+
}, {});
|
|
18
|
+
if (headers.cookie === undefined || headers.cookie === null) {
|
|
19
|
+
headers.cookie = "";
|
|
23
20
|
}
|
|
21
|
+
return headers;
|
|
22
|
+
}
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return this.headers[key.toLowerCase()]
|
|
31
|
-
}
|
|
24
|
+
get(key) {
|
|
25
|
+
if (key === undefined) {
|
|
26
|
+
return { ...this.headers };
|
|
27
|
+
} else {
|
|
28
|
+
return this.headers[key.toLowerCase()];
|
|
32
29
|
}
|
|
30
|
+
}
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
this.headers = this.validate(this.headers)
|
|
44
|
-
return this
|
|
32
|
+
set(key, value) {
|
|
33
|
+
if (typeof key === "string") {
|
|
34
|
+
this.headers[key.toLowerCase()] = value;
|
|
35
|
+
} else {
|
|
36
|
+
for (let _key in key) {
|
|
37
|
+
this.headers[_key.toLowerCase()] = key[_key];
|
|
38
|
+
}
|
|
45
39
|
}
|
|
40
|
+
this.headers = this.validate(this.headers);
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
46
43
|
}
|
|
47
44
|
|
|
48
45
|
const axios = _axios.default.create({
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
})
|
|
46
|
+
baseURL: "/",
|
|
47
|
+
timeout: 60000,
|
|
48
|
+
headers: {
|
|
49
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36",
|
|
50
|
+
},
|
|
51
|
+
validateStatus: () => true,
|
|
52
|
+
withCredentials: true,
|
|
53
|
+
maxContentLength: Infinity,
|
|
54
|
+
maxBodyLength: Infinity,
|
|
55
|
+
});
|
|
60
56
|
|
|
61
57
|
//debug
|
|
62
58
|
// axios.interceptors.request.use(function (config) {
|
|
@@ -67,25 +63,22 @@ const axios = _axios.default.create({
|
|
|
67
63
|
// })
|
|
68
64
|
|
|
69
65
|
export async function request(config) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
.replaceAll(/[\t\n\r]/gi, '')
|
|
82
|
-
.trim())
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return result
|
|
86
|
-
} catch (e) {
|
|
87
|
-
return {
|
|
88
|
-
error: e
|
|
89
|
-
}
|
|
66
|
+
try {
|
|
67
|
+
if (!config?.headers?.cookie) {
|
|
68
|
+
try {
|
|
69
|
+
delete config.headers.cookie;
|
|
70
|
+
} catch (e) {}
|
|
71
|
+
}
|
|
72
|
+
const result = await axios.request(config);
|
|
73
|
+
if (result.data && typeof result.data === "string") {
|
|
74
|
+
result._$ = function () {
|
|
75
|
+
return cheerio.load(result.data.replaceAll(/[\t\n\r]/gi, "").trim());
|
|
76
|
+
};
|
|
90
77
|
}
|
|
78
|
+
return result;
|
|
79
|
+
} catch (e) {
|
|
80
|
+
return {
|
|
81
|
+
error: e,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
91
84
|
}
|