steamutils 1.2.89 → 1.2.91

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 +20 -6
  2. package/package.json +1 -1
package/SteamClient.js CHANGED
@@ -340,9 +340,16 @@ function SteamClient({
340
340
 
341
341
  async function gamePlay() {
342
342
  let ownedApps = null
343
- while (!Array.isArray(ownedApps)) {
344
- ownedApps = (await (new SteamUtils(await getCookiesWait())).getDynamicStoreUserData())?.rgOwnedApps
343
+ for (let i = 0; i < 10; i++) {
344
+ if (!Array.isArray(ownedApps)) {
345
+ ownedApps = Array.isArray(steamClient.licenses) ? steamClient.licenses.map(({package_id}) => package_id) : (await (new SteamUtils(await getCookiesWait())).getDynamicStoreUserData())?.rgOwnedApps
346
+ await sleep(1000)
347
+ } else {
348
+ break
349
+ }
345
350
  }
351
+
352
+ ownedApps = _.shuffle(ownedApps || [])
346
353
  ownedApps.length = Math.min(ownedApps.length, 10)
347
354
  _.remove(ownedApps, 730)
348
355
  gamesPlayed([...ownedApps, 730])
@@ -1303,11 +1310,15 @@ function SteamClient({
1303
1310
  }
1304
1311
 
1305
1312
  async function getNewCookie(cookie) {
1313
+ if (!cookie) {
1314
+ return
1315
+ }
1306
1316
  let response = await _getStoreSteamPoweredResponse(cookie)
1307
1317
  if (!response) {
1308
1318
  return
1309
1319
  }
1310
1320
  while (Array.isArray(response?.headers?.["set-cookie"])) {
1321
+ console.log(cookie);
1311
1322
  const cookieObj = cookie.split(';').reduce(function (accumulator, currentValue) {
1312
1323
  accumulator[currentValue.trim().split('=')[0].trim()] = currentValue.trim().split('=')[1].trim()
1313
1324
  return accumulator
@@ -1365,15 +1376,18 @@ function SteamClient({
1365
1376
  }
1366
1377
 
1367
1378
  async function login(reconnect = false) {
1368
- if (clientJsToken?.logged_in) {
1379
+ if (clientJsToken?.logged_in === true) {
1369
1380
  log(reconnect ? 'reconnect with clientJsToken' : 'login with clientJsToken')
1370
1381
  steamClient.logOn(clientJsToken)
1382
+ setTimeout(function () {
1383
+ clientJsToken = null
1384
+ }, 1000)
1371
1385
  return true
1372
1386
  } else if (cookie) {
1373
1387
  log(reconnect ? 'reconnect with cookie' : 'login with cookie')
1374
- const newCookie = await loginWithCookie(cookie)
1375
- if (newCookie) {
1376
- cookie = newCookie
1388
+ const _clientJsToken = await new SteamUtils(typeof cookie === "function" ? await cookie() : cookie).getClientJsToken()
1389
+ if (_clientJsToken?.logged_in === true) {
1390
+ steamClient.logOn(_clientJsToken)
1377
1391
  return true
1378
1392
  } else {
1379
1393
  return false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.2.89",
3
+ "version": "1.2.91",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "axios": "^1.5.1",