steamutils 1.3.53 → 1.3.55

Sign up to get free protection for your applications and to get access to all the features.
package/SteamClient.js CHANGED
@@ -1696,17 +1696,14 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
1696
1696
 
1697
1697
  async function login(reconnect = false) {
1698
1698
  function logOn(clientJsToken) {
1699
- if (clientJsToken.steamid) {
1700
- Object.assign(clientJsToken, {
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
- password,
1705
- twoFactorCode,
1706
1706
  });
1707
- }
1708
- try {
1709
- steamClient.logOn(clientJsToken);
1710
1707
  return true;
1711
1708
  } catch (e) {
1712
1709
  console.error(e);
@@ -1716,18 +1713,17 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
1716
1713
 
1717
1714
  if (clientJsToken?.logged_in === true) {
1718
1715
  log(reconnect ? "reconnect with clientJsToken" : "login with clientJsToken");
1719
- return logOn(clientJsToken);
1720
1716
  setTimeout(function () {
1721
1717
  clientJsToken = null;
1722
1718
  }, 1000);
1723
- return true;
1719
+ return logOn(clientJsToken);
1724
1720
  } else if (cookie) {
1725
1721
  log(reconnect ? "reconnect with cookie" : "login with cookie");
1726
1722
  const _clientJsToken = await new SteamUser(typeof cookie === "function" ? await cookie() : cookie).getClientJsToken();
1727
1723
  if (_clientJsToken?.logged_in === true) {
1728
1724
  return logOn(_clientJsToken);
1729
1725
  } else {
1730
- log("Account not logged in");
1726
+ log(`Account not logged in ${clientJsToken?.account_name || ""}`);
1731
1727
  return false;
1732
1728
  }
1733
1729
  } else if (username && password) {
@@ -1739,6 +1735,9 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
1739
1735
  machineName: "Natri",
1740
1736
  });
1741
1737
  return true;
1738
+ } else {
1739
+ log(`Account not logged in ${clientJsToken?.account_name || ""}`);
1740
+ return false;
1742
1741
  }
1743
1742
  }
1744
1743
 
@@ -1762,18 +1761,18 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
1762
1761
  }
1763
1762
  }
1764
1763
 
1765
- function init() {
1764
+ async function init() {
1766
1765
  bindEvent();
1767
- login();
1768
-
1769
- steamClient._handlerManager.add(Protos.csgo.EMsg.k_EMsgClientRequestedClientStats, function (payload) {
1770
- const result = protoDecode(Protos.csgo.CMsgClientRequestedClientStats, payload.toBuffer());
1771
- // console.log("CMsgClientRequestedClientStats", result);
1772
- });
1773
- steamClient._handlerManager.add(Protos.csgo.EMsg.k_EMsgClientMMSLobbyData, function (payload) {
1774
- const result = protoDecode(Protos.csgo.CMsgClientMMSLobbyData, payload.toBuffer());
1775
- // console.log("CMsgClientMMSLobbyData", result, result.metadata);
1776
- });
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
+ }
1777
1776
  }
1778
1777
 
1779
1778
  function partyRegister() {
package/index.js CHANGED
@@ -20,7 +20,7 @@ import * as https from "https";
20
20
  import Jimp from "jimp";
21
21
  import path from "path";
22
22
  import CookieManager from "./CookieManager.js";
23
- import { AppID_CSGO, E1GameBanOnRecord, E1VACBanOnRecord, EActivityType, ECommentPrivacyState, ECurrentlyTradeBanned, EdaySinceLastBanRegExp, EFriendRelationship, ELanguage, EmptyProfileSummary, EMultipleGameBansOnRecord, EMultipleVACBansOnRecord, EPrivacyState, ErrorProcessingRequest, FRIEND_CODE_REPLACEMENTS, NotYetSetupProfileTextList, PrivateProfileTextList, SteamcommunityURL, SteamErrorTitle, SteamImageCDN } from "./const.js";
23
+ import { AppID_CSGO, E1GameBanOnRecord, E1VACBanOnRecord, EActivityType, ECommentPrivacyState, ECurrentlyTradeBanned, EdaySinceLastBanRegExp, EFriendRelationship, ELanguage, EmptyProfileSummary, EMultipleGameBansOnRecord, EMultipleVACBansOnRecord, EPrivacyState, ErrorProcessingRequest, FRIEND_CODE_REPLACEMENTS, NotYetSetupProfileTextList, PrivacySettings, PrivateProfileTextList, SteamcommunityURL, SteamErrorTitle, SteamImageCDN } from "./const.js";
24
24
 
25
25
  let requestTimestamp = 0;
26
26
  let tooManyRequestTimestamp = 0;
@@ -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;
@@ -6311,7 +6331,7 @@ export default class SteamUser {
6311
6331
 
6312
6332
  SteamUser.MAX_RETRY = 10;
6313
6333
 
6314
- class ResponseError {
6334
+ export class ResponseError {
6315
6335
  constructor({ loginFirst, message, steamId, originalURL }) {
6316
6336
  this.loginFirst = loginFirst;
6317
6337
  this.message = message;
@@ -6327,7 +6347,7 @@ class ResponseError {
6327
6347
  return false;
6328
6348
  }
6329
6349
  }
6330
- class ResponseSuccess {
6350
+ export class ResponseSuccess {
6331
6351
  constructor(response) {
6332
6352
  this.response = response;
6333
6353
  }
@@ -6345,3 +6365,5 @@ class ResponseSuccess {
6345
6365
  return cheerio.load(this.response.data.replaceAll(/[\t\n\r]/gi, "").trim());
6346
6366
  }
6347
6367
  }
6368
+
6369
+ export * from "./const.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.3.53",
3
+ "version": "1.3.55",
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.10",
13
+ "jimp": "^0.22.12",
14
14
  "lodash": "^4.17.21",
15
15
  "moment": "^2.30.1",
16
16
  "moment-timezone": "^0.5.45",