steamutils 1.2.7 → 1.2.9

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.
@@ -0,0 +1,5 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <state>
3
+ <option name="USE_PER_PROJECT_SETTINGS" value="true" />
4
+ </state>
5
+ </component>
@@ -2,8 +2,8 @@
2
2
  <module type="WEB_MODULE" version="4">
3
3
  <component name="NewModuleRootManager">
4
4
  <content url="file://$MODULE_DIR$">
5
- <excludeFolder url="file://$MODULE_DIR$/temp" />
6
5
  <excludeFolder url="file://$MODULE_DIR$/.tmp" />
6
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
7
7
  <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
8
  </content>
9
9
  <orderEntry type="inheritedJdk" />
package/.idea/vcs.xml CHANGED
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <project version="4">
3
3
  <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
4
+ <mapping directory="" vcs="Git" />
5
5
  </component>
6
6
  </project>
package/SteamClient.js CHANGED
@@ -377,9 +377,30 @@ function SteamClient({
377
377
  callEvent(events.disconnected, {eresult, msg})
378
378
 
379
379
  if (eresult === 3 && autoReconnect && !isLogOff) {
380
- setTimeout(function () {
381
- login(true)
382
- }, 30000)
380
+
381
+ async function relogin(retry) {
382
+ if (retry <= 0) {
383
+ console.error("Cannot relogin")
384
+ return
385
+ }
386
+ const isSuccess = await login(true)
387
+ if (isSuccess) {
388
+ onEvent('loggedOn', function (loggedOnResponse) {
389
+ if (loggedOnResponse) {
390
+ console.log("Relogin success")
391
+ } else {
392
+ relogin(retry - 1)
393
+ }
394
+ }, true, 120000)
395
+ } else {
396
+ setTimeout(function () {
397
+ relogin(retry - 1)
398
+ }, 60000)
399
+ }
400
+ }
401
+
402
+ await sleep(60000)
403
+ await relogin(10)
383
404
  }
384
405
  })
385
406
  steamClient.on('error', async (e) => {
@@ -720,7 +741,7 @@ function SteamClient({
720
741
  steamClient.setPersona(SteamUser.EPersonaState.Online)
721
742
  state = 'Online'
722
743
  await sendHello()
723
- callEvent(events.loggedOn)
744
+ callEvent(events.loggedOn, loggedOnResponse)
724
745
  if (isAutoRequestFreeLicense) {
725
746
  doSetInterval(function () {
726
747
  autoRequestFreeLicense(false, 50)
@@ -995,7 +1016,7 @@ function SteamClient({
995
1016
  if(!response){
996
1017
  return
997
1018
  }
998
- while (Array.isArray(response.headers?.["set-cookie"])) {
1019
+ while (Array.isArray(response?.headers?.["set-cookie"])) {
999
1020
  const cookieObj = cookie.split(';').reduce(function (accumulator, currentValue) {
1000
1021
  accumulator[currentValue.trim().split('=')[0].trim()] = currentValue.trim().split('=')[1].trim()
1001
1022
  return accumulator
@@ -1031,20 +1052,23 @@ function SteamClient({
1031
1052
 
1032
1053
  const result = response?.data
1033
1054
  if (result?.logged_in) {
1034
- console.log(`clientjstoken success`)
1035
1055
  Object.assign(result, {
1036
1056
  steamID: new SteamID(result.steamid), accountName: result.account_name, webLogonToken: result.token
1037
1057
  })
1038
1058
  steamClient.logOn(result)
1039
1059
  return cookie
1040
1060
  } else {
1041
- console.log(`clientjstoken fail`)
1042
1061
  if (tryNewCookie) {
1043
1062
  log('You are not logged in', cookie)
1044
1063
  return null
1045
1064
  } else {
1046
1065
  const newCookie = await getNewCookie(cookie)
1047
- return newCookie && await loginWithCookie(newCookie, true)
1066
+ if(!newCookie){
1067
+ console.error("Cannot get new cookie")
1068
+ return null
1069
+ } else {
1070
+ return await loginWithCookie(newCookie, true)
1071
+ }
1048
1072
  }
1049
1073
  }
1050
1074
  }
@@ -1055,12 +1079,16 @@ function SteamClient({
1055
1079
  const newCookie = await loginWithCookie(cookie)
1056
1080
  if (newCookie) {
1057
1081
  cookie = newCookie
1082
+ return true
1083
+ } else {
1084
+ return false
1058
1085
  }
1059
1086
  } else if (username && password) {
1060
1087
  log(reconnect ? `reconnect with username ${username}` : `login with username ${username}`)
1061
1088
  steamClient.logOn({
1062
1089
  accountName: username, password: password, rememberPassword: true, machineName: 'Natri',
1063
1090
  })
1091
+ return true
1064
1092
  }
1065
1093
  }
1066
1094
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.2.07",
3
+ "version": "1.2.09",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "axios": "^1.3.4",