steamutils 1.4.66 → 1.4.69

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.
Files changed (2) hide show
  1. package/SteamClient.js +49 -54
  2. package/package.json +1 -1
package/SteamClient.js CHANGED
@@ -2046,34 +2046,27 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
2046
2046
  }
2047
2047
  }
2048
2048
 
2049
- async function reLogin(retry = 50) {
2050
- if (isLogOff || retry <= 0) {
2051
- offAllEvent();
2052
- doClearIntervals();
2049
+ async function reLogin(retry = 0) {
2050
+ const MAX_RETRY = 1000;
2053
2051
 
2054
- error(`Cannot relogin (${isLogOff ? "logoff" : "retry limit reached"})`);
2055
- return false;
2056
- }
2052
+ while (++retry < MAX_RETRY) {
2053
+ if (isLogOff || retry > MAX_RETRY) {
2054
+ offAllEvent();
2055
+ doClearIntervals();
2057
2056
 
2058
- const isSuccess = await login(true);
2059
- if (isSuccess) {
2060
- log("Relogin success");
2061
- return true;
2062
- }
2057
+ error(`Cannot relogin (${isLogOff ? "logoff" : "retry limit reached"})`);
2058
+ return false;
2059
+ }
2063
2060
 
2064
- if (isLogOff) {
2065
- offAllEvent();
2066
- doClearIntervals();
2067
- error(`Cannot relogin (${isLogOff ? "logoff" : "retry limit reached"})`);
2068
- return false;
2069
- }
2061
+ const isSuccess = await login(true);
2062
+ if (isSuccess) {
2063
+ log("Relogin success");
2064
+ return true;
2065
+ }
2070
2066
 
2071
- if (retry > 1) {
2072
- await sleep(60000);
2073
- return await reLogin(retry - 1);
2074
- } else {
2075
- return false;
2067
+ await sleep(15000);
2076
2068
  }
2069
+ return false;
2077
2070
  }
2078
2071
 
2079
2072
  async function login(reconnect = false) {
@@ -2131,49 +2124,51 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
2131
2124
  clearTimeout(_cleanNodeSteamFriendTimeout);
2132
2125
  }
2133
2126
 
2134
- steamClient.logOff();
2135
- await sleep(5000);
2127
+ if (steamClient) {
2128
+ steamClient.logOff();
2129
+ await sleep(5000);
2136
2130
 
2137
- steamClient._connection?.end(true);
2131
+ steamClient._connection?.end(true);
2138
2132
 
2139
- function cleanSteamClient(obj, key) {
2140
- const value = obj[key];
2133
+ function cleanSteamClient(obj, key) {
2134
+ const value = obj[key];
2141
2135
 
2142
- try {
2143
- delete obj[key];
2144
- } catch (e) {
2145
- return;
2146
- }
2136
+ try {
2137
+ delete obj[key];
2138
+ } catch (e) {
2139
+ return;
2140
+ }
2147
2141
 
2148
- if (!value) {
2149
- return;
2150
- }
2142
+ if (!value) {
2143
+ return;
2144
+ }
2151
2145
 
2152
- if (typeof value !== "object") {
2153
- return;
2154
- }
2146
+ if (typeof value !== "object") {
2147
+ return;
2148
+ }
2155
2149
 
2156
- if (Array.isArray(value)) {
2157
- value.length = 0;
2158
- } else {
2159
- const constructorName = Object.getPrototypeOf(value)?.constructor?.name;
2160
- if (constructorName === "TLSSocket") {
2161
- value.destroy?.();
2162
- } else if (constructorName === "Timeout") {
2163
- clearTimeout(value);
2164
- } else if (constructorName === "SteamUser") {
2150
+ if (Array.isArray(value)) {
2151
+ value.length = 0;
2165
2152
  } else {
2166
- for (const valuekey in value) {
2167
- cleanSteamClient(value, valuekey);
2153
+ const constructorName = Object.getPrototypeOf(value)?.constructor?.name;
2154
+ if (constructorName === "TLSSocket") {
2155
+ value.destroy?.();
2156
+ } else if (constructorName === "Timeout") {
2157
+ clearTimeout(value);
2158
+ } else if (constructorName === "SteamUser") {
2159
+ } else {
2160
+ for (const valuekey in value) {
2161
+ cleanSteamClient(value, valuekey);
2162
+ }
2168
2163
  }
2169
2164
  }
2170
2165
  }
2171
- }
2172
2166
 
2173
- for (const key in steamClient) {
2174
- cleanSteamClient(steamClient, key);
2167
+ for (const key in steamClient) {
2168
+ cleanSteamClient(steamClient, key);
2169
+ }
2170
+ steamClient = null;
2175
2171
  }
2176
- steamClient = null;
2177
2172
  }
2178
2173
 
2179
2174
  async function init() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.4.66",
3
+ "version": "1.4.69",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "alpha-common-utils": "^1.0.6",