steamutils 1.3.54 → 1.3.56
Sign up to get free protection for your applications and to get access to all the features.
- package/SteamClient.js +16 -18
- package/index.js +60 -16
- package/package.json +2 -2
- package/test_steamclient.js +1 -1
package/SteamClient.js
CHANGED
@@ -1696,15 +1696,14 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
1696
1696
|
|
1697
1697
|
async function login(reconnect = false) {
|
1698
1698
|
function logOn(clientJsToken) {
|
1699
|
-
|
1700
|
-
|
1699
|
+
try {
|
1700
|
+
steamClient.logOn({
|
1701
|
+
...clientJsToken,
|
1701
1702
|
steamId: new SteamID(clientJsToken.steamid),
|
1703
|
+
steamID: new SteamID(clientJsToken.steamid),
|
1702
1704
|
accountName: clientJsToken.account_name,
|
1703
1705
|
webLogonToken: clientJsToken.token,
|
1704
1706
|
});
|
1705
|
-
}
|
1706
|
-
try {
|
1707
|
-
steamClient.logOn(clientJsToken);
|
1708
1707
|
return true;
|
1709
1708
|
} catch (e) {
|
1710
1709
|
console.error(e);
|
@@ -1714,11 +1713,10 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
1714
1713
|
|
1715
1714
|
if (clientJsToken?.logged_in === true) {
|
1716
1715
|
log(reconnect ? "reconnect with clientJsToken" : "login with clientJsToken");
|
1717
|
-
return logOn(clientJsToken);
|
1718
1716
|
setTimeout(function () {
|
1719
1717
|
clientJsToken = null;
|
1720
1718
|
}, 1000);
|
1721
|
-
return
|
1719
|
+
return logOn(clientJsToken);
|
1722
1720
|
} else if (cookie) {
|
1723
1721
|
log(reconnect ? "reconnect with cookie" : "login with cookie");
|
1724
1722
|
const _clientJsToken = await new SteamUser(typeof cookie === "function" ? await cookie() : cookie).getClientJsToken();
|
@@ -1763,18 +1761,18 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
1763
1761
|
}
|
1764
1762
|
}
|
1765
1763
|
|
1766
|
-
function init() {
|
1764
|
+
async function init() {
|
1767
1765
|
bindEvent();
|
1768
|
-
login()
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
}
|
1766
|
+
if (await login()) {
|
1767
|
+
steamClient._handlerManager.add(Protos.csgo.EMsg.k_EMsgClientRequestedClientStats, function (payload) {
|
1768
|
+
const result = protoDecode(Protos.csgo.CMsgClientRequestedClientStats, payload.toBuffer());
|
1769
|
+
// console.log("CMsgClientRequestedClientStats", result);
|
1770
|
+
});
|
1771
|
+
steamClient._handlerManager.add(Protos.csgo.EMsg.k_EMsgClientMMSLobbyData, function (payload) {
|
1772
|
+
const result = protoDecode(Protos.csgo.CMsgClientMMSLobbyData, payload.toBuffer());
|
1773
|
+
// console.log("CMsgClientMMSLobbyData", result, result.metadata);
|
1774
|
+
});
|
1775
|
+
}
|
1778
1776
|
}
|
1779
1777
|
|
1780
1778
|
function partyRegister() {
|
package/index.js
CHANGED
@@ -2093,19 +2093,45 @@ export default class SteamUser {
|
|
2093
2093
|
}
|
2094
2094
|
|
2095
2095
|
async getClientJsToken(retry = null) {
|
2096
|
+
function returnAlter(userinfo) {
|
2097
|
+
return userinfo
|
2098
|
+
? {
|
2099
|
+
...userinfo,
|
2100
|
+
steamId: new SteamID(userinfo.steamid),
|
2101
|
+
steamID: new SteamID(userinfo.steamid),
|
2102
|
+
accountName: userinfo.account_name,
|
2103
|
+
webLogonToken: userinfo.token,
|
2104
|
+
}
|
2105
|
+
: null;
|
2106
|
+
}
|
2107
|
+
|
2108
|
+
const html = (await this._httpRequest("chat"))?.data;
|
2109
|
+
const userinfo = cheerio
|
2110
|
+
.load(html || "")("#webui_config")
|
2111
|
+
.data("userinfo");
|
2112
|
+
if (userinfo?.logged_in === true) {
|
2113
|
+
return returnAlter(userinfo);
|
2114
|
+
}
|
2115
|
+
|
2116
|
+
const exampleUserinfo = {
|
2117
|
+
logged_in: true,
|
2118
|
+
steamid: "76561199040402348",
|
2119
|
+
accountid: 1080136620,
|
2120
|
+
account_name: "henry22230",
|
2121
|
+
is_support: false,
|
2122
|
+
is_limited: false,
|
2123
|
+
is_partner_member: false,
|
2124
|
+
country_code: "VN",
|
2125
|
+
token: "tpXZZcmhvw4AAAAAAAAAAAAAAAAAAAAAAwCNGElboy44N8CqQzVFAkX4",
|
2126
|
+
token_use_id: "432e9779bcc4c2bf39022031",
|
2127
|
+
};
|
2128
|
+
|
2096
2129
|
const result = (await this._httpRequest("chat/clientjstoken"))?.data;
|
2097
2130
|
if (result instanceof ResponseError) {
|
2098
2131
|
return result;
|
2099
2132
|
}
|
2100
|
-
if (!result?.steamid) {
|
2101
|
-
if (retry !== null && retry !== undefined && retry >= 0) {
|
2102
|
-
await sleep(2000);
|
2103
|
-
return await this.getClientJsToken(retry - 1);
|
2104
|
-
} else {
|
2105
|
-
return null;
|
2106
|
-
}
|
2107
|
-
}
|
2108
2133
|
|
2134
|
+
return returnAlter(result);
|
2109
2135
|
const dataExample = {
|
2110
2136
|
logged_in: true,
|
2111
2137
|
steamid: "76561199040402348",
|
@@ -2113,12 +2139,6 @@ export default class SteamUser {
|
|
2113
2139
|
account_name: "henry22230",
|
2114
2140
|
token: "1o7xYpbcmTsAAAAAAAAAAAAAAAAAAAAAAwCf6fVEGxM9H7Tnk5oW5QPI",
|
2115
2141
|
};
|
2116
|
-
|
2117
|
-
return Object.assign(result, {
|
2118
|
-
steamId: new SteamID(result.steamid),
|
2119
|
-
accountName: result.account_name,
|
2120
|
-
webLogonToken: result.token,
|
2121
|
-
});
|
2122
2142
|
}
|
2123
2143
|
|
2124
2144
|
getClientLogonToken = this.getClientJsToken;
|
@@ -4918,10 +4938,10 @@ export default class SteamUser {
|
|
4918
4938
|
if (result instanceof ResponseError) {
|
4919
4939
|
return result;
|
4920
4940
|
}
|
4921
|
-
if (!result.data) {
|
4941
|
+
if (!result.data || typeof result.data !== "string") {
|
4922
4942
|
return;
|
4923
4943
|
}
|
4924
|
-
const $ = result.
|
4944
|
+
const $ = cheerio.load(result.data);
|
4925
4945
|
let email = "";
|
4926
4946
|
$(".account_setting_block").each(function () {
|
4927
4947
|
if (email) return;
|
@@ -6307,6 +6327,30 @@ export default class SteamUser {
|
|
6307
6327
|
|
6308
6328
|
return { steamId, wallet, country, email, accountSecurity, accountName };
|
6309
6329
|
}
|
6330
|
+
|
6331
|
+
async getFriendSince(steamId) {
|
6332
|
+
const accountId = SteamUser.steamID642Miniprofile(steamId);
|
6333
|
+
const result = await this._httpRequest("tradeoffer/new/?partner=" + accountId);
|
6334
|
+
if (result instanceof ResponseError) {
|
6335
|
+
return result;
|
6336
|
+
}
|
6337
|
+
const html = result?.data;
|
6338
|
+
if (!html || typeof html !== "string") {
|
6339
|
+
return;
|
6340
|
+
}
|
6341
|
+
const $ = cheerio.load(html);
|
6342
|
+
const container = $(".trade_partner_header.responsive_trade_offersection");
|
6343
|
+
const friendSince = [...container.find(".trade_partner_info_block")]
|
6344
|
+
.map(function (el) {
|
6345
|
+
el = $(el);
|
6346
|
+
if (el.text().includes("You've been friends since")) {
|
6347
|
+
return StringUtils.cleanSpace(el.find(".trade_partner_info_text").text());
|
6348
|
+
}
|
6349
|
+
})
|
6350
|
+
.filter(Boolean);
|
6351
|
+
//example 13 June, 2023
|
6352
|
+
return friendSince[0];
|
6353
|
+
}
|
6310
6354
|
}
|
6311
6355
|
|
6312
6356
|
SteamUser.MAX_RETRY = 10;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "steamutils",
|
3
|
-
"version": "1.3.
|
3
|
+
"version": "1.3.56",
|
4
4
|
"main": "index.js",
|
5
5
|
"dependencies": {
|
6
6
|
"alpha-common-utils": "^1.0.6",
|
@@ -10,7 +10,7 @@
|
|
10
10
|
"crypto-js": "^4.2.0",
|
11
11
|
"csgo-friendcode": "^3.0.3",
|
12
12
|
"form-data": "^4.0.0",
|
13
|
-
"jimp": "^0.22.
|
13
|
+
"jimp": "^0.22.12",
|
14
14
|
"lodash": "^4.17.21",
|
15
15
|
"moment": "^2.30.1",
|
16
16
|
"moment-timezone": "^0.5.45",
|
package/test_steamclient.js
CHANGED
@@ -2,7 +2,7 @@ import SteamClient from "./SteamClient.js";
|
|
2
2
|
|
3
3
|
(async function () {
|
4
4
|
const steamClient = new SteamClient({
|
5
|
-
cookie: "steamLoginSecure=
|
5
|
+
cookie: "timezoneOffset=25200,0; _ga=GA1.2.51100933.1683654836; browserid=2699389310852036147; rgDiscussionPrefs=%7B%22cTopicRepliesPerPage%22%3A50%7D; wants_mature_content_apps=218640|1599340; strInventoryLastContext=730_2; steamLoginSecure=76561199040402348%7C%7CeyAidHlwIjogIkpXVCIsICJhbGciOiAiRWREU0EiIH0.eyAiaXNzIjogInI6MUI0Ql8yM0Y3MUE1MV8wNjRDMSIsICJzdWIiOiAiNzY1NjExOTkwNDA0MDIzNDgiLCAiYXVkIjogWyAid2ViOmNvbW11bml0eSIgXSwgImV4cCI6IDE3MDg3NzcyNTgsICJuYmYiOiAxNzAwMDUwMzkxLCAiaWF0IjogMTcwODY5MDM5MSwgImp0aSI6ICIwRUUxXzIzRkVEN0YxXzczNjVEIiwgIm9hdCI6IDE3MDgyNDUxNjAsICJydF9leHAiOiAxNzI2MTg5NzEyLCAicGVyIjogMCwgImlwX3N1YmplY3QiOiAiMTQuMTkxLjE2Ny4yMDEiLCAiaXBfY29uZmlybWVyIjogIjE0LjE5MS4xNjcuMjAxIiB9.dkeAiPn2YX3S60olBHLL7cbQVAbDvqjgAmKpnLaKiiQIglks6z590YW-4wLPLCKl-uExgf_gtd_JrKk3qZkWAQ; recentlyVisitedAppHubs=218640%2C1568590%2C413850%2C1580960%2C221410%2C346110%2C2529120%2C552540%2C1203220%2C264710%2C1599340%2C439700%2C1085660%2C730%2C440; sessionid=e5fbb58bfa8c18fd51891d24",
|
6
6
|
isAutoPlay: true,
|
7
7
|
// password: "VitGa_23",
|
8
8
|
// twoFactorCode: "99B9G",
|