steamutils 1.1.89 → 1.1.90

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.
@@ -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$/.tmp" />
6
5
  <excludeFolder url="file://$MODULE_DIR$/temp" />
6
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
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="" vcs="Git" />
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
5
  </component>
6
6
  </project>
package/index.js CHANGED
@@ -1506,6 +1506,7 @@ class SteamUser {
1506
1506
  let response = null
1507
1507
  let retry = 10
1508
1508
  let checkTooManyRequest = false
1509
+
1509
1510
  while (--retry) {
1510
1511
  const config = {
1511
1512
  baseURL: SteamcommunityURL,
@@ -1535,50 +1536,65 @@ class SteamUser {
1535
1536
  response = await axios.request(config)
1536
1537
 
1537
1538
  this._cookies.setCookies(response.headers["set-cookie"])
1538
- if (response.status === 302) {
1539
- redirectURL = response.headers.location
1540
1539
 
1541
- if (redirectURL?.startsWith('https://steamcommunity.com/id/')) {
1542
- const customURL = redirectURL.split('/')[4];
1543
- if (customURL) {
1544
- this._myProfile = `id/${customURL}`
1540
+ switch (response.status) {
1541
+ case 302: {
1542
+ redirectURL = response.headers.location
1543
+
1544
+ if (redirectURL?.startsWith('https://steamcommunity.com/id/')) {
1545
+ const customURL = redirectURL.split('/')[4];
1546
+ if (customURL) {
1547
+ this._myProfile = `id/${customURL}`
1548
+ }
1549
+ } else if (redirectURL?.startsWith('https://steamcommunity.com/login/')) {
1550
+ console.error('Login first', this._steamid_user)
1551
+ return null
1545
1552
  }
1546
- } else if (redirectURL?.startsWith('https://steamcommunity.com/login/')) {
1547
- console.error('Login first', this._steamid_user)
1548
- return null
1549
- }
1550
1553
 
1551
- console.log(`Redirect to ${redirectURL}`)
1552
- } else if (response.status === 200) {
1553
- if (response.data && typeof response.data === 'string') {
1554
- response._$ = function () {
1555
- return cheerio.load(response.data
1556
- .replaceAll(/[\t\n\r]/gi, '')
1557
- .trim())
1554
+ console.log(`Redirect ${config.url} to ${redirectURL}`)
1555
+ break
1556
+ }
1557
+ case 200: {
1558
+ if (response.data && typeof response.data === 'string') {
1559
+ response._$ = function () {
1560
+ return cheerio.load(response.data
1561
+ .replaceAll(/[\t\n\r]/gi, '')
1562
+ .trim())
1563
+ }
1558
1564
  }
1565
+ return response
1566
+ break
1559
1567
  }
1560
- break
1561
- } else if (response.status === 429) {
1562
- console.log('Too Many Requests', config.url)
1563
- tooManyRequestTimestamp = new Date().getTime()
1564
- checkTooManyRequest = true
1565
- await sleep(30000)
1566
- } else if (response.status === 401) {
1567
- console.log('Unauthorized', config.url)
1568
- if (params.method.toUpperCase() === 'POST') {
1569
- config.headers['Content-Type'] = config.headers['content-type'] = 'multipart/form-data'
1570
- retry = 1
1568
+ case 429: {
1569
+ console.log('Too Many Requests', config.url)
1570
+ tooManyRequestTimestamp = new Date().getTime()
1571
+ checkTooManyRequest = true
1572
+ await sleep(30000)
1573
+ break
1571
1574
  }
1572
- } else if (response.status === 400) {
1573
- console.log('Error', response.status, config.url)
1574
- if (params.method.toUpperCase() === 'POST') {
1575
- config.headers['Content-Type'] = config.headers['content-type'] = 'application/x-www-form-urlencoded'
1576
- retry = 1
1575
+ case 401: {
1576
+ console.log('Unauthorized', config.url)
1577
+ if (params.method.toUpperCase() === 'POST') {
1578
+ config.headers['Content-Type'] = config.headers['content-type'] = 'multipart/form-data'
1579
+ retry = 1
1580
+ }
1581
+ break
1582
+ }
1583
+ case 400: {
1584
+ console.log('Error', response.status, config.url)
1585
+ if (params.method.toUpperCase() === 'POST') {
1586
+ config.headers['Content-Type'] = config.headers['content-type'] = 'application/x-www-form-urlencoded'
1587
+ retry = 1
1588
+ }
1589
+ break
1590
+ }
1591
+ case 500: {
1592
+ console.log(response.status, response.statusText, config.url, response.data)
1593
+ break
1594
+ }
1595
+ default: {
1596
+ console.log(response.status, config.url);
1577
1597
  }
1578
- } else if (response.status === 500) {
1579
- console.log(response.status, response.statusText, config.url, response.data)
1580
- } else {
1581
- console.log(response.status, config.url);
1582
1598
  }
1583
1599
  }
1584
1600
  return response
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.1.89",
3
+ "version": "1.1.90",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "axios": "^1.3.4",
@@ -1,5 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <state>
3
- <option name="USE_PER_PROJECT_SETTINGS" value="true" />
4
- </state>
5
- </component>