steamutils 1.0.65 → 1.0.67

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 (3) hide show
  1. package/SteamClient.js +17 -6
  2. package/index.js +10 -10
  3. package/package.json +1 -1
package/SteamClient.js CHANGED
@@ -837,12 +837,22 @@ function SteamClient({
837
837
  }
838
838
 
839
839
  async function getNewCookie(cookie) {
840
- let response = (await axios.request({
841
- url: 'https://store.steampowered.com/', headers: {
842
- cookie,
843
- accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
840
+ let response = null
841
+ for (let i = 0; i < 10; i++) {
842
+ if(!response){
843
+ try {
844
+ response = (await axios.request({
845
+ url: 'https://store.steampowered.com/', headers: {
846
+ cookie,
847
+ accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
848
+ },
849
+ }))
850
+ } catch (e) { }
844
851
  }
845
- }))
852
+ }
853
+ if(!response){
854
+ return
855
+ }
846
856
  while (Array.isArray(response.headers?.["set-cookie"])) {
847
857
  const cookieObj = cookie.split(';').reduce(function (accumulator, currentValue) {
848
858
  accumulator[currentValue.trim().split('=')[0].trim()] = currentValue.trim().split('=')[1].trim()
@@ -894,7 +904,8 @@ function SteamClient({
894
904
  log('You are not logged in', cookie)
895
905
  return null
896
906
  } else {
897
- return await loginWithCookie(await getNewCookie(cookie), true)
907
+ const newCookie = await getNewCookie(cookie)
908
+ return newCookie && await loginWithCookie(newCookie, true)
898
909
  }
899
910
  }
900
911
  }
package/index.js CHANGED
@@ -1808,17 +1808,17 @@ class SteamUser {
1808
1808
  return await this.getFriendsList()
1809
1809
  }
1810
1810
 
1811
- async getMyFriendsIDList() {
1812
- const { data } = await this._httpRequestAjax(`textfilter/ajaxgetfriendslist`)
1813
- if(!data) {
1814
- return []
1811
+ async getMyFriendsIDList () {
1812
+ for (let i = 0; i < 5; i++) {
1813
+ const { data } = await this._httpRequestAjax(`textfilter/ajaxgetfriendslist`) //{ success: 21 }
1814
+ if (data?.success === 1) {
1815
+ return data.friendslist.friends.filter(function (friend) {
1816
+ return EFriendRelationship.Friend === friend.efriendrelationship
1817
+ }).map(function (friend) {
1818
+ return friend.ulfriendid
1819
+ })
1820
+ }
1815
1821
  }
1816
- console.log(`data`, data)
1817
- return data.friendslist.friends.filter(function (friend) {
1818
- return EFriendRelationship.Friend === friend.efriendrelationship
1819
- }).map(function (friend) {
1820
- return friend.ulfriendid
1821
- })
1822
1822
  }
1823
1823
 
1824
1824
  async getMyFollowingPlayersList() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.0.65",
3
+ "version": "1.0.67",
4
4
  "dependencies": {
5
5
  "axios": "^1.3.4",
6
6
  "cheerio": "^1.0.0-rc.12",