steamutils 1.2.95 → 1.2.98
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.
- package/SteamClient.js +11 -2
- package/index.js +31 -17
- package/package.json +1 -1
package/SteamClient.js
CHANGED
@@ -76,7 +76,7 @@ export const LOCS = {
|
|
76
76
|
|
77
77
|
const AppID = 730
|
78
78
|
export let CSGO_VER = 13960
|
79
|
-
const FreeAppList = JSON.parse(fs.readFileSync(path.join(__dirname, 'free_packages.json'))).packages
|
79
|
+
export const FreeAppList = JSON.parse(fs.readFileSync(path.join(__dirname, 'free_packages.json'))).packages
|
80
80
|
|
81
81
|
SteamUtils.getAppVersion(AppID).then(function (ver) {
|
82
82
|
CSGO_VER = ver
|
@@ -1674,7 +1674,16 @@ function SteamClient({
|
|
1674
1674
|
if (isMe && ownedApps.length) {
|
1675
1675
|
return ownedApps
|
1676
1676
|
}
|
1677
|
-
|
1677
|
+
let result = {}
|
1678
|
+
try {
|
1679
|
+
result = await steamClient.getUserOwnedApps(steamId)
|
1680
|
+
} catch (e) {
|
1681
|
+
try {
|
1682
|
+
result = await steamClient.getUserOwnedApps(steamId)
|
1683
|
+
} catch (e) {
|
1684
|
+
result = {}
|
1685
|
+
}
|
1686
|
+
}
|
1678
1687
|
if (isMe && Array.isArray(result.apps)) {
|
1679
1688
|
ownedApps.length = 0
|
1680
1689
|
ownedApps.push(...result.apps)
|
package/index.js
CHANGED
@@ -1614,6 +1614,7 @@ class SteamUser {
|
|
1614
1614
|
}
|
1615
1615
|
|
1616
1616
|
async _httpRequest(params) {
|
1617
|
+
const isRedirect = typeof params.isRedirect === "boolean" ? params.isRedirect : true
|
1617
1618
|
params = this._formatHttpRequest(params)
|
1618
1619
|
|
1619
1620
|
if (!this._cookies) {
|
@@ -1675,19 +1676,23 @@ class SteamUser {
|
|
1675
1676
|
|
1676
1677
|
switch (response.status) {
|
1677
1678
|
case 302: {
|
1678
|
-
|
1679
|
+
if(isRedirect){
|
1680
|
+
redirectURL = response.headers.location
|
1679
1681
|
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1682
|
+
if (redirectURL?.startsWith('https://steamcommunity.com/id/')) {
|
1683
|
+
const customURL = redirectURL.split('/')[4];
|
1684
|
+
if (customURL) {
|
1685
|
+
this._myProfile = `id/${customURL}`
|
1686
|
+
}
|
1687
|
+
} else if (redirectURL?.startsWith('https://steamcommunity.com/login/')) {
|
1688
|
+
console.error('Login first', this._steamid_user)
|
1689
|
+
return null
|
1684
1690
|
}
|
1685
|
-
} else if (redirectURL?.startsWith('https://steamcommunity.com/login/')) {
|
1686
|
-
console.error('Login first', this._steamid_user)
|
1687
|
-
return null
|
1688
|
-
}
|
1689
1691
|
|
1690
|
-
|
1692
|
+
console.log(`Redirect ${config.url} to ${redirectURL}`)
|
1693
|
+
} else {
|
1694
|
+
return response
|
1695
|
+
}
|
1691
1696
|
break
|
1692
1697
|
}
|
1693
1698
|
case 200: {
|
@@ -4355,15 +4360,24 @@ class SteamUser {
|
|
4355
4360
|
}
|
4356
4361
|
}
|
4357
4362
|
|
4358
|
-
async addFreeLicense(
|
4359
|
-
const
|
4360
|
-
|
4361
|
-
|
4362
|
-
|
4363
|
-
|
4363
|
+
async addFreeLicense(packageID) {//packageID not appID
|
4364
|
+
const form = new FormData();
|
4365
|
+
form.append('ajax', "true");
|
4366
|
+
form.append('sessionid', this.getSessionid());
|
4367
|
+
|
4368
|
+
const result = await this._httpRequestAjax({
|
4369
|
+
// url: `https://checkout.steampowered.com/checkout/addfreelicense/${appID}`,
|
4370
|
+
// url: `https://store.steampowered.com/checkout/addfreelicense/${appID}`,
|
4371
|
+
url: `https://store.steampowered.com/freelicense/addfreelicense/${packageID}`,
|
4372
|
+
data: form,
|
4364
4373
|
method: 'POST',
|
4374
|
+
headers: {
|
4375
|
+
'Content-Type': 'multipart/form-data',
|
4376
|
+
},
|
4365
4377
|
})
|
4366
|
-
|
4378
|
+
|
4379
|
+
const data = result.data
|
4380
|
+
return result.status === 200 && Array.isArray(data) && !data.length//empty array
|
4367
4381
|
}
|
4368
4382
|
|
4369
4383
|
async addSubFreeLicense(subid) {
|