steamutils 1.3.57 → 1.3.58

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/SteamClient.js +21 -7
  2. package/package.json +1 -1
package/SteamClient.js CHANGED
@@ -1741,7 +1741,7 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
1741
1741
  }
1742
1742
  }
1743
1743
 
1744
- async function logOff() {
1744
+ function logOff() {
1745
1745
  isLogOff = true;
1746
1746
  logOffEvent?.(true);
1747
1747
  steamClient.logOff();
@@ -2327,11 +2327,14 @@ export function increaseCSGO_VER() {
2327
2327
  return ++CSGO_VER;
2328
2328
  }
2329
2329
 
2330
- SteamClient.isAccountPlayable = async function isAccountPlayable(params, timeoutMs) {
2331
- if (!params.clientJsToken && params.cookie) {
2332
- params.clientJsToken = await new SteamUser(typeof params.cookie === "function" ? await params.cookie() : params.cookie).getClientJsToken();
2330
+ SteamClient.isAccountPlayable = async function isAccountPlayable({ cookie, clientJsToken, timeoutMs, onPlayable, onNotPlayable }) {
2331
+ if (!clientJsToken && cookie) {
2332
+ clientJsToken = await new SteamUser(typeof cookie === "function" ? await cookie() : cookie).getClientJsToken();
2333
2333
  }
2334
- if (params.clientJsToken?.logged_in !== true) {
2334
+ if (clientJsToken?.logged_in !== true) {
2335
+ if (typeof onNotPlayable === "function") {
2336
+ await onNotPlayable(null);
2337
+ }
2335
2338
  return { invalidClientJsToken: true };
2336
2339
  }
2337
2340
  return await new Promise((resolve) => {
@@ -2348,7 +2351,7 @@ SteamClient.isAccountPlayable = async function isAccountPlayable(params, timeout
2348
2351
  isInvisible: false,
2349
2352
  MAX_GAME_PLAY: 10,
2350
2353
  games: 730,
2351
- ...params,
2354
+ clientJsToken,
2352
2355
  });
2353
2356
 
2354
2357
  steamClient.onEvent("error", ({ eresult, msg, error }) => {
@@ -2382,10 +2385,21 @@ SteamClient.isAccountPlayable = async function isAccountPlayable(params, timeout
2382
2385
 
2383
2386
  steamClient.init();
2384
2387
 
2385
- function doResolve(data) {
2388
+ async function doResolve(data) {
2386
2389
  timeouts.forEach((timeout) => clearTimeout(timeout));
2387
2390
  steamClient.doClearIntervals();
2388
2391
  steamClient.offAllEvent();
2392
+
2393
+ if (data?.playable === true) {
2394
+ if (typeof onPlayable === "function") {
2395
+ await onPlayable(steamClient);
2396
+ }
2397
+ } else {
2398
+ if (typeof onNotPlayable === "function") {
2399
+ await onNotPlayable(steamClient);
2400
+ }
2401
+ }
2402
+
2389
2403
  steamClient.logOff();
2390
2404
  return resolve(data);
2391
2405
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.3.57",
3
+ "version": "1.3.58",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "alpha-common-utils": "^1.0.6",