steamutils 1.3.34 → 1.3.36

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 (2) hide show
  1. package/index.js +353 -126
  2. package/package.json +8 -7
package/index.js CHANGED
@@ -18,6 +18,8 @@ import fs from "fs";
18
18
  import FormData from "form-data";
19
19
  import {StringUtils} from "alpha-common-utils/index.js";
20
20
  import * as https from "https";
21
+ import sharp from "sharp";
22
+ import path from "path";
21
23
 
22
24
  const MAX_RETRY = 10
23
25
  let requestTimestamp = 0
@@ -1072,21 +1074,21 @@ class SteamUser {
1072
1074
  let response = await request(`https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=${webApiKey}&steamids=${steamIds.join(',')}`)
1073
1075
  return response?.data?.response?.players || []
1074
1076
  const resultExample = [{
1075
- "steamid": "76561199040402348",
1076
- "communityvisibilitystate": 3,
1077
- "profilestate": 1,
1078
- "personaname": "Na",
1079
- "commentpermission": 1,
1080
- "profileurl": "https://steamcommunity.com/id/natri99/",
1081
- "avatar": "https://avatars.steamstatic.com/834966fea6a0a8a3b7011db7f96d38b61ee0ba64.jpg",
1082
- "avatarmedium": "https://avatars.steamstatic.com/834966fea6a0a8a3b7011db7f66d38b51ee0ba64_medium.jpg",
1083
- "avatarfull": "https://avatars.steamstatic.com/834966fea6a0a8a3b7011db7f96e38b51ee0ba64_full.jpg",
1084
- "avatarhash": "834966fea6a0a8a3b7011db7f96d38b51ee0ba64",
1085
- "lastlogoff": 1685298425,
1086
- "personastate": 0,
1087
- "primaryclanid": "103582791470373577",
1088
- "timecreated": 1585473529,
1089
- "personastateflags": 0
1077
+ steamid: "76561199040402348",
1078
+ communityvisibilitystate: 3,
1079
+ profilestate: 1,
1080
+ personaname: "Na",
1081
+ commentpermission: 1,
1082
+ profileurl: "https://steamcommunity.com/id/natri99/",
1083
+ avatar: "https://avatars.steamstatic.com/834966fea6a0a8a3b7011db7f96d38b61ee0ba64.jpg",
1084
+ avatarmedium: "https://avatars.steamstatic.com/834966fea6a0a8a3b7011db7f66d38b51ee0ba64_medium.jpg",
1085
+ avatarfull: "https://avatars.steamstatic.com/834966fea6a0a8a3b7011db7f96e38b51ee0ba64_full.jpg",
1086
+ avatarhash: "834966fea6a0a8a3b7011db7f96d38b51ee0ba64",
1087
+ lastlogoff: 1685298425,
1088
+ personastate: 0,
1089
+ primaryclanid: "103582791470373577",
1090
+ timecreated: 1585473529,
1091
+ personastateflags: 0
1090
1092
  }]
1091
1093
  }
1092
1094
 
@@ -1228,96 +1230,96 @@ class SteamUser {
1228
1230
  let result = await request(`https://store.steampowered.com/api/appdetails?appids=${appIds}&hl=en`)
1229
1231
  return result?.data
1230
1232
  const resultExample = {
1231
- "730": {
1232
- "success": true,
1233
- "data": {
1234
- "type": "game",
1235
- "name": "Counter-Strike: Global Offensive",
1236
- "steam_appid": 730,
1237
- "required_age": 0,
1238
- "is_free": true,
1239
- "controller_support": "full",
1240
- "detailed_description": "Counter-Strike: Global Offensive (CS: GO) expands upon the team-based action gameplay that it pioneered when it was launched 19 years ago.<br \/>\r\n<br \/>\r\nCS: GO features new maps, characters, weapons, and game modes, and delivers updated versions of the classic CS content (de_dust2, etc.).<br \/>\r\n<br \/>\r\n&quot;Counter-Strike took the gaming industry by surprise when the unlikely MOD became the most played online PC action game in the world almost immediately after its release in August 1999,&quot; said Doug Lombardi at Valve. &quot;For the past 12 years, it has continued to be one of the most-played games in the world, headline competitive gaming tournaments and selling over 25 million units worldwide across the franchise. CS: GO promises to expand on CS' award-winning gameplay and deliver it to gamers on the PC as well as the next gen consoles and the Mac.&quot;",
1241
- "about_the_game": "Counter-Strike: Global Offensive (CS: GO) expands upon the team-based action gameplay that it pioneered when it was launched 19 years ago.<br \/>\r\n<br \/>\r\nCS: GO features new maps, characters, weapons, and game modes, and delivers updated versions of the classic CS content (de_dust2, etc.).<br \/>\r\n<br \/>\r\n&quot;Counter-Strike took the gaming industry by surprise when the unlikely MOD became the most played online PC action game in the world almost immediately after its release in August 1999,&quot; said Doug Lombardi at Valve. &quot;For the past 12 years, it has continued to be one of the most-played games in the world, headline competitive gaming tournaments and selling over 25 million units worldwide across the franchise. CS: GO promises to expand on CS' award-winning gameplay and deliver it to gamers on the PC as well as the next gen consoles and the Mac.&quot;",
1242
- "short_description": "Counter-Strike: Global Offensive (CS: GO) expands upon the team-based action gameplay that it pioneered when it was launched 19 years ago. CS: GO features new maps, characters, weapons, and game modes, and delivers updated versions of the classic CS content (de_dust2, etc.).",
1243
- "supported_languages": "Czech, Danish, Dutch, English<strong>*<\/strong>, Finnish, French, German, Hungarian, Italian, Japanese, Korean, Norwegian, Polish, Portuguese - Portugal, Portuguese - Brazil, Romanian, Russian, Simplified Chinese, Spanish - Spain, Swedish, Thai, Traditional Chinese, Turkish, Bulgarian, Ukrainian, Greek, Spanish - Latin America, Vietnamese<br><strong>*<\/strong>languages with full audio support",
1244
- "header_image": "https:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/730\/header.jpg?t=1683566799",
1245
- "capsule_image": "https:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/730\/capsule_231x87.jpg?t=1683566799",
1246
- "capsule_imagev5": "https:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/730\/capsule_184x69.jpg?t=1683566799",
1247
- "website": "http:\/\/blog.counter-strike.net\/",
1248
- "pc_requirements": {"minimum": "<strong>Minimum:<\/strong><br><ul class=\"bb_ul\"><li><strong>OS:<\/strong> Windows® 7\/Vista\/XP<br><\/li><li><strong>Processor:<\/strong> Intel® Core™ 2 Duo E6600 or AMD Phenom™ X3 8750 processor or better<br><\/li><li><strong>Memory:<\/strong> 2 GB RAM<br><\/li><li><strong>Graphics:<\/strong> Video card must be 256 MB or more and should be a DirectX 9-compatible with support for Pixel Shader 3.0<br><\/li><li><strong>DirectX:<\/strong> Version 9.0c<br><\/li><li><strong>Storage:<\/strong> 15 GB available space<\/li><\/ul>"},
1249
- "mac_requirements": {"minimum": "<strong>Minimum:<\/strong><br><ul class=\"bb_ul\"><li><strong>OS:<\/strong> MacOS X 10.11 (El Capitan) or later<br><\/li><li><strong>Processor:<\/strong> Intel Core Duo Processor (2GHz or better)<br><\/li><li><strong>Memory:<\/strong> 2 GB RAM<br><\/li><li><strong>Graphics:<\/strong> ATI Radeon HD 2400 or better \/ NVIDIA 8600M or better<br><\/li><li><strong>Storage:<\/strong> 15 GB available space<\/li><\/ul>"},
1250
- "linux_requirements": {"minimum": "<strong>Minimum:<\/strong><br><ul class=\"bb_ul\"><li><strong>OS:<\/strong> Ubuntu 12.04<br><\/li><li><strong>Processor:<\/strong> 64-bit Dual core from Intel or AMD at 2.8 GHz<br><\/li><li><strong>Memory:<\/strong> 4 GB RAM<br><\/li><li><strong>Graphics:<\/strong> NVIDIA GeForce 8600\/9600GT, ATI\/AMD Radeon HD2600\/3600 (Graphic Drivers: NVIDIA 310, AMD 12.11), OpenGL 2.1<br><\/li><li><strong>Storage:<\/strong> 15 GB available space<br><\/li><li><strong>Sound Card:<\/strong> OpenAL Compatible Sound Card<\/li><\/ul>"},
1251
- "developers": ["Valve", "Hidden Path Entertainment"],
1252
- "publishers": ["Valve"],
1253
- "packages": [329385, 298963, 54029],
1254
- "package_groups": [{
1255
- "name": "default",
1256
- "title": "Buy Counter-Strike: Global Offensive",
1257
- "description": "",
1258
- "selection_text": "Select a purchase option",
1259
- "save_text": "",
1260
- "display_type": 0,
1261
- "is_recurring_subscription": "false",
1262
- "subs": [{
1263
- "packageid": 298963,
1264
- "percent_savings_text": " ",
1265
- "percent_savings": 0,
1266
- "option_text": "Counter-Strike: Global Offensive - Free",
1267
- "option_description": "",
1268
- "can_get_free_license": "0",
1269
- "is_free_license": true,
1270
- "price_in_cents_with_discount": 0
1233
+ 730: {
1234
+ success: true,
1235
+ data: {
1236
+ type: "game",
1237
+ name: "Counter-Strike: Global Offensive",
1238
+ steam_appid: 730,
1239
+ required_age: 0,
1240
+ is_free: true,
1241
+ controller_support: "full",
1242
+ detailed_description: "Counter-Strike: Global Offensive (CS: GO) expands upon the team-based action gameplay that it pioneered when it was launched 19 years ago.<br \/>\r\n<br \/>\r\nCS: GO features new maps, characters, weapons, and game modes, and delivers updated versions of the classic CS content (de_dust2, etc.).<br \/>\r\n<br \/>\r\n&quot;Counter-Strike took the gaming industry by surprise when the unlikely MOD became the most played online PC action game in the world almost immediately after its release in August 1999,&quot; said Doug Lombardi at Valve. &quot;For the past 12 years, it has continued to be one of the most-played games in the world, headline competitive gaming tournaments and selling over 25 million units worldwide across the franchise. CS: GO promises to expand on CS' award-winning gameplay and deliver it to gamers on the PC as well as the next gen consoles and the Mac.&quot;",
1243
+ about_the_game: "Counter-Strike: Global Offensive (CS: GO) expands upon the team-based action gameplay that it pioneered when it was launched 19 years ago.<br \/>\r\n<br \/>\r\nCS: GO features new maps, characters, weapons, and game modes, and delivers updated versions of the classic CS content (de_dust2, etc.).<br \/>\r\n<br \/>\r\n&quot;Counter-Strike took the gaming industry by surprise when the unlikely MOD became the most played online PC action game in the world almost immediately after its release in August 1999,&quot; said Doug Lombardi at Valve. &quot;For the past 12 years, it has continued to be one of the most-played games in the world, headline competitive gaming tournaments and selling over 25 million units worldwide across the franchise. CS: GO promises to expand on CS' award-winning gameplay and deliver it to gamers on the PC as well as the next gen consoles and the Mac.&quot;",
1244
+ short_description: "Counter-Strike: Global Offensive (CS: GO) expands upon the team-based action gameplay that it pioneered when it was launched 19 years ago. CS: GO features new maps, characters, weapons, and game modes, and delivers updated versions of the classic CS content (de_dust2, etc.).",
1245
+ supported_languages: "Czech, Danish, Dutch, English<strong>*<\/strong>, Finnish, French, German, Hungarian, Italian, Japanese, Korean, Norwegian, Polish, Portuguese - Portugal, Portuguese - Brazil, Romanian, Russian, Simplified Chinese, Spanish - Spain, Swedish, Thai, Traditional Chinese, Turkish, Bulgarian, Ukrainian, Greek, Spanish - Latin America, Vietnamese<br><strong>*<\/strong>languages with full audio support",
1246
+ header_image: "https:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/730\/header.jpg?t=1683566799",
1247
+ capsule_image: "https:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/730\/capsule_231x87.jpg?t=1683566799",
1248
+ capsule_imagev5: "https:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/730\/capsule_184x69.jpg?t=1683566799",
1249
+ website: "http:\/\/blog.counter-strike.net\/",
1250
+ pc_requirements: {minimum: "<strong>Minimum:<\/strong><br><ul class=\"bb_ul\"><li><strong>OS:<\/strong> Windows® 7\/Vista\/XP<br><\/li><li><strong>Processor:<\/strong> Intel® Core™ 2 Duo E6600 or AMD Phenom™ X3 8750 processor or better<br><\/li><li><strong>Memory:<\/strong> 2 GB RAM<br><\/li><li><strong>Graphics:<\/strong> Video card must be 256 MB or more and should be a DirectX 9-compatible with support for Pixel Shader 3.0<br><\/li><li><strong>DirectX:<\/strong> Version 9.0c<br><\/li><li><strong>Storage:<\/strong> 15 GB available space<\/li><\/ul>"},
1251
+ mac_requirements: {minimum: "<strong>Minimum:<\/strong><br><ul class=\"bb_ul\"><li><strong>OS:<\/strong> MacOS X 10.11 (El Capitan) or later<br><\/li><li><strong>Processor:<\/strong> Intel Core Duo Processor (2GHz or better)<br><\/li><li><strong>Memory:<\/strong> 2 GB RAM<br><\/li><li><strong>Graphics:<\/strong> ATI Radeon HD 2400 or better \/ NVIDIA 8600M or better<br><\/li><li><strong>Storage:<\/strong> 15 GB available space<\/li><\/ul>"},
1252
+ linux_requirements: {minimum: "<strong>Minimum:<\/strong><br><ul class=\"bb_ul\"><li><strong>OS:<\/strong> Ubuntu 12.04<br><\/li><li><strong>Processor:<\/strong> 64-bit Dual core from Intel or AMD at 2.8 GHz<br><\/li><li><strong>Memory:<\/strong> 4 GB RAM<br><\/li><li><strong>Graphics:<\/strong> NVIDIA GeForce 8600\/9600GT, ATI\/AMD Radeon HD2600\/3600 (Graphic Drivers: NVIDIA 310, AMD 12.11), OpenGL 2.1<br><\/li><li><strong>Storage:<\/strong> 15 GB available space<br><\/li><li><strong>Sound Card:<\/strong> OpenAL Compatible Sound Card<\/li><\/ul>"},
1253
+ developers: ["Valve", "Hidden Path Entertainment"],
1254
+ publishers: ["Valve"],
1255
+ packages: [329385, 298963, 54029],
1256
+ package_groups: [{
1257
+ name: "default",
1258
+ title: "Buy Counter-Strike: Global Offensive",
1259
+ description: "",
1260
+ selection_text: "Select a purchase option",
1261
+ save_text: "",
1262
+ display_type: 0,
1263
+ is_recurring_subscription: "false",
1264
+ subs: [{
1265
+ packageid: 298963,
1266
+ percent_savings_text: " ",
1267
+ percent_savings: 0,
1268
+ option_text: "Counter-Strike: Global Offensive - Free",
1269
+ option_description: "",
1270
+ can_get_free_license: "0",
1271
+ is_free_license: true,
1272
+ price_in_cents_with_discount: 0
1271
1273
  }, {
1272
- "packageid": 54029,
1273
- "percent_savings_text": " ",
1274
- "percent_savings": 0,
1275
- "option_text": "Prime Status Upgrade - 375.000₫",
1276
- "option_description": "",
1277
- "can_get_free_license": "0",
1278
- "is_free_license": false,
1279
- "price_in_cents_with_discount": 37500000
1274
+ packageid: 54029,
1275
+ percent_savings_text: " ",
1276
+ percent_savings: 0,
1277
+ option_text: "Prime Status Upgrade - 375.000₫",
1278
+ option_description: "",
1279
+ can_get_free_license: "0",
1280
+ is_free_license: false,
1281
+ price_in_cents_with_discount: 37500000
1280
1282
  }]
1281
1283
  }],
1282
- "platforms": {"windows": true, "mac": true, "linux": true},
1283
- "metacritic": {
1284
- "score": 83,
1285
- "url": "https:\/\/www.metacritic.com\/game\/pc\/counter-strike-global-offensive?ftag=MCD-06-10aaa1f"
1284
+ platforms: {windows: true, mac: true, linux: true},
1285
+ metacritic: {
1286
+ score: 83,
1287
+ url: "https:\/\/www.metacritic.com\/game\/pc\/counter-strike-global-offensive?ftag=MCD-06-10aaa1f"
1286
1288
  },
1287
- "categories": [{"id": 1, "description": "Multi-player"}],
1288
- "genres": [{"id": "1", "description": "Action"}],
1289
- "screenshots": [{
1290
- "id": 0,
1291
- "path_thumbnail": "https:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/730\/ss_118cb022b9a43f70d2e5a2df7427f29088b6b191.600x338.jpg?t=1683566799",
1292
- "path_full": "https:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/730\/ss_118cb022b9a43f70d2e5a2df7427f29088b6b191.1920x1080.jpg?t=1683566799"
1289
+ categories: [{id: 1, description: "Multi-player"}],
1290
+ genres: [{id: "1", description: "Action"}],
1291
+ screenshots: [{
1292
+ id: 0,
1293
+ path_thumbnail: "https:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/730\/ss_118cb022b9a43f70d2e5a2df7427f29088b6b191.600x338.jpg?t=1683566799",
1294
+ path_full: "https:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/730\/ss_118cb022b9a43f70d2e5a2df7427f29088b6b191.1920x1080.jpg?t=1683566799"
1293
1295
  }],
1294
- "movies": [{
1295
- "id": 81958,
1296
- "name": "CS:GO Trailer Long",
1297
- "thumbnail": "https:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/81958\/movie.293x165.jpg?t=1554409259",
1298
- "webm": {
1299
- "480": "http:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/81958\/movie480.webm?t=1554409259",
1300
- "max": "http:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/81958\/movie_max.webm?t=1554409259"
1296
+ movies: [{
1297
+ id: 81958,
1298
+ name: "CS:GO Trailer Long",
1299
+ thumbnail: "https:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/81958\/movie.293x165.jpg?t=1554409259",
1300
+ webm: {
1301
+ 480: "http:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/81958\/movie480.webm?t=1554409259",
1302
+ max: "http:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/81958\/movie_max.webm?t=1554409259"
1301
1303
  },
1302
- "mp4": {
1303
- "480": "http:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/81958\/movie480.mp4?t=1554409259",
1304
- "max": "http:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/81958\/movie_max.mp4?t=1554409259"
1304
+ mp4: {
1305
+ 480: "http:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/81958\/movie480.mp4?t=1554409259",
1306
+ max: "http:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/81958\/movie_max.mp4?t=1554409259"
1305
1307
  },
1306
- "highlight": true
1308
+ highlight: true
1307
1309
  }],
1308
- "recommendations": {"total": 3833937},
1309
- "achievements": {
1310
- "total": 167,
1311
- "highlighted": [{
1312
- "name": "Someone Set Up Us The Bomb",
1313
- "path": "https:\/\/cdn.akamai.steamstatic.com\/steamcommunity\/public\/images\/apps\/730\/9f60ea3c56b4ab248ab598bbd62568b953116301.jpg"
1310
+ recommendations: {total: 3833937},
1311
+ achievements: {
1312
+ total: 167,
1313
+ highlighted: [{
1314
+ name: "Someone Set Up Us The Bomb",
1315
+ path: "https:\/\/cdn.akamai.steamstatic.com\/steamcommunity\/public\/images\/apps\/730\/9f60ea3c56b4ab248ab598bbd62568b953116301.jpg"
1314
1316
  }]
1315
1317
  },
1316
- "release_date": {"coming_soon": false, "date": "22 Aug, 2012"},
1317
- "support_info": {"url": "", "email": ""},
1318
- "background": "https:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/730\/page_bg_generated_v6b.jpg?t=1683566799",
1319
- "background_raw": "https:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/730\/page_bg_generated.jpg?t=1683566799",
1320
- "content_descriptors": {"ids": [2, 5], "notes": "Includes intense violence and blood."}
1318
+ release_date: {coming_soon: false, date: "22 Aug, 2012"},
1319
+ support_info: {url: "", email: ""},
1320
+ background: "https:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/730\/page_bg_generated_v6b.jpg?t=1683566799",
1321
+ background_raw: "https:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/730\/page_bg_generated.jpg?t=1683566799",
1322
+ content_descriptors: {ids: [2, 5], notes: "Includes intense violence and blood."}
1321
1323
  }
1322
1324
  }
1323
1325
  }
@@ -5806,13 +5808,28 @@ class SteamUser {
5806
5808
 
5807
5809
  return result?.data
5808
5810
  const successExample = {
5809
- "tradeid": "4726012948246770347"
5811
+ tradeid: "4726012948246770347"
5810
5812
  }
5811
5813
  }
5812
5814
 
5815
+ async declineTradeOffer(tradeOfferID, partnerSteamId) {
5816
+ const result = await this._httpRequest({
5817
+ url: `tradeoffer/${tradeOfferID}/decline`,
5818
+ method: 'POST',
5819
+ data: `sessionid=${this._sessionid}`,
5820
+ headers: {
5821
+ "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
5822
+ Referer: `https://steamcommunity.com/tradeoffer/${tradeOfferID}/`
5823
+ }
5824
+ })
5825
+
5826
+ return result?.data
5827
+ const successExample = {"tradeofferid": "6690438715"}
5828
+ }
5829
+
5813
5830
  async getTradeOffer() {
5814
5831
  const result = await this._httpMyRequest(`tradeoffers/`)
5815
- if (!result?.data) {
5832
+ if (!result?.data || typeof result._$ !== "function") {
5816
5833
  return
5817
5834
  }
5818
5835
  const $ = result._$()
@@ -5855,7 +5872,7 @@ class SteamUser {
5855
5872
  return;
5856
5873
  }
5857
5874
  const tradeofferid = parseInt(id.split('tradeofferid_')[1])
5858
- if(!tradeofferid){
5875
+ if (!tradeofferid) {
5859
5876
  return
5860
5877
  }
5861
5878
  let partner = $1.html().split('ReportTradeScam(')[1].split(');')[0].trim()
@@ -5954,22 +5971,22 @@ class SteamUser {
5954
5971
  })
5955
5972
  return result?.data
5956
5973
  const successResponse = {
5957
- "success": true,
5958
- "images": {
5959
- "0": "https:\/\/avatars.akamai.steamstatic.com\/8c150c6499937982c66e3ae27061b903a4bb168b.jpg",
5960
- "full": "https:\/\/avatars.akamai.steamstatic.com\/8c150c6499937982c66e3ae27061b903a4bb168b_full.jpg",
5961
- "medium": "https:\/\/avatars.akamai.steamstatic.com\/8c150c6499937982c66e3ae27061b903a4bb168b_medium.jpg"
5974
+ success: true,
5975
+ images: {
5976
+ 0: "https:\/\/avatars.akamai.steamstatic.com\/8c150c6499937982c66e3ae27061b903a4bb168b.jpg",
5977
+ full: "https:\/\/avatars.akamai.steamstatic.com\/8c150c6499937982c66e3ae27061b903a4bb168b_full.jpg",
5978
+ medium: "https:\/\/avatars.akamai.steamstatic.com\/8c150c6499937982c66e3ae27061b903a4bb168b_medium.jpg"
5962
5979
  },
5963
- "hash": "8c150c6499937982c66e3ae27061b903a4bb168b",
5964
- "message": ""
5980
+ hash: "8c150c6499937982c66e3ae27061b903a4bb168b",
5981
+ message: ""
5965
5982
  }
5966
5983
 
5967
5984
  const error = `#Error_BadOrMissingSteamID`
5968
5985
  const error2 = {
5969
- "success": false,
5970
- "images": [],
5971
- "hash": null,
5972
- "message": "No file received."
5986
+ success: false,
5987
+ images: [],
5988
+ hash: null,
5989
+ message: "No file received."
5973
5990
  }
5974
5991
  }
5975
5992
 
@@ -5996,7 +6013,7 @@ class SteamUser {
5996
6013
  },
5997
6014
  })
5998
6015
  return result?.data
5999
- const successResponse = {"success": 1}
6016
+ const successResponse = {success: 1}
6000
6017
  }
6001
6018
 
6002
6019
  async getMiniprofile(steamId = this._steamid_user) {
@@ -6008,16 +6025,16 @@ class SteamUser {
6008
6025
  avatar_hash,
6009
6026
  }
6010
6027
  const example = {
6011
- "level": 0,
6012
- "level_class": "friendPlayerLevel lvl_0",
6013
- "avatar_url": "https:\/\/avatars.akamai.steamstatic.com\/2da65f05388ed7c857a46d82dfb9dbc19edef261_full.jpg",
6014
- "persona_name": "Natri",
6015
- "in_game": {
6016
- "name": "Counter-Strike: Global Offensive",
6017
- "is_non_steam": false,
6018
- "logo": "https:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/730\/capsule_184x69.jpg?t=1683566799",
6019
- "rich_presence": "",
6020
- "os_type": -700
6028
+ level: 0,
6029
+ level_class: "friendPlayerLevel lvl_0",
6030
+ avatar_url: "https:\/\/avatars.akamai.steamstatic.com\/2da65f05388ed7c857a46d82dfb9dbc19edef261_full.jpg",
6031
+ persona_name: "Natri",
6032
+ in_game: {
6033
+ name: "Counter-Strike: Global Offensive",
6034
+ is_non_steam: false,
6035
+ logo: "https:\/\/cdn.akamai.steamstatic.com\/steam\/apps\/730\/capsule_184x69.jpg?t=1683566799",
6036
+ rich_presence: "",
6037
+ os_type: -700
6021
6038
  }
6022
6039
  }
6023
6040
  }
@@ -6029,7 +6046,7 @@ class SteamUser {
6029
6046
  data: "action=deauthorize&sessionid=" + this._sessionid,
6030
6047
  headers: {
6031
6048
  "content-type": "application/x-www-form-urlencoded",
6032
- "Referer": "https://store.steampowered.com/twofactor/manage",
6049
+ Referer: "https://store.steampowered.com/twofactor/manage",
6033
6050
  }
6034
6051
  })
6035
6052
  console.log(response.data);
@@ -6106,11 +6123,11 @@ class SteamUser {
6106
6123
  return response
6107
6124
 
6108
6125
  const resultExample = {
6109
- "success": true,
6110
- "requires_confirmation": 1,
6111
- "needs_mobile_confirmation": true,
6112
- "needs_email_confirmation": false,
6113
- "email_domain": "gmail.com"
6126
+ success: true,
6127
+ requires_confirmation: 1,
6128
+ needs_mobile_confirmation: true,
6129
+ needs_email_confirmation: false,
6130
+ email_domain: "gmail.com"
6114
6131
  }
6115
6132
  }
6116
6133
 
@@ -6226,6 +6243,216 @@ class SteamUser {
6226
6243
  result && onPageCb?.(result)
6227
6244
  } while (token)
6228
6245
  }
6246
+
6247
+ async beginFileUpload(filePath) {
6248
+ const metadata = await new sharp(filePath).metadata()
6249
+ const stats = fs.statSync(filePath)
6250
+
6251
+ let sha1 = "";
6252
+ for (; sha1.length < 40;) {
6253
+ sha1 += Math.floor(16 * Math.random()).toString(16);
6254
+ }
6255
+
6256
+ const input = {
6257
+ l: 'english',
6258
+ file_size: stats.size,
6259
+ file_name: path.basename(filePath),
6260
+ file_sha: sha1,
6261
+ file_image_width: metadata.width,
6262
+ file_image_height: metadata.height,
6263
+ file_type: "image/" + metadata.format,
6264
+ sessionid: this.getSessionid()
6265
+ }
6266
+
6267
+ const form = new FormData();
6268
+ for (const key in input) {
6269
+ form.append(key, input[key].toString());
6270
+ }
6271
+
6272
+ const result = (await this._httpRequestAjax({
6273
+ url: "chat/beginfileupload/?l=english",
6274
+ data: form,
6275
+ method: 'POST',
6276
+ headers: {
6277
+ 'Content-Type': 'multipart/form-data',
6278
+ },
6279
+ }))?.data
6280
+
6281
+ return result?.success === 1 ? {
6282
+ ...result,
6283
+ result: {
6284
+ ...result.result,
6285
+ ...input
6286
+ }
6287
+ } : result
6288
+ const successExample = {
6289
+ success: 1,
6290
+ result: {
6291
+ ugcid: "2277199680653980183",
6292
+ timestamp: 1705578275,
6293
+ url_host: "steamcloud-ugc.storage.googleapis.com",
6294
+ url_path: "\/AC\/93\/61\/40\/744350\/07E_6_23D0B600_37217_1.dat?GoogleAccessId=1034790105812-5bdngop952i7sjvk3q8dm3nur4tlg4vb@developer.gserviceaccount.com&Expires=1705581875&Signature=qjLnq%2Bf4j86fxug7jO9rL0mBRZHEyKgM9U%2BeFShapk9J%2FvPXPLxpLxMHLFvy5yfl6qGbl7Tv%2FsMesXlqNRZLpCHnELmYuD3t6Dfi4IIRT32vlZGuNFC92vooXYM%2FRVmPzx1mGHkxz26p4huEqJj7%2B7qT%2FJT3%2F%2BTqNQYYFvGIwR4%3D",
6295
+ use_https: 1,
6296
+ request_headers: [
6297
+ {
6298
+ name: "Content-Type",
6299
+ value: "image\/png"
6300
+ },
6301
+ {
6302
+ name: "Content-Length",
6303
+ value: "48620"
6304
+ },
6305
+ {
6306
+ name: "Content-Disposition",
6307
+ value: "inline; filename*=UTF-8''26252_image.png;"
6308
+ }
6309
+ ],
6310
+ success: 1,
6311
+ rwgrsn: -2
6312
+ },
6313
+ hmac: "0cbb56d9e8217943095b66f87997878a",
6314
+ timestamp: 1705578275
6315
+ }
6316
+ }
6317
+
6318
+ async doFileUpload({
6319
+ filePath,
6320
+ beginFileUploadResult,
6321
+ }) {
6322
+ const headers = beginFileUploadResult.request_headers.reduce(function (prev, currentValue) {
6323
+ const existedName = Object.keys(prev).find(k => k.toLowerCase() === currentValue.name.toLowerCase())
6324
+ if (existedName) {
6325
+ delete prev[existedName]
6326
+ }
6327
+
6328
+ if (["Content-Length", "Host"].some(k => k.toLowerCase() === currentValue.name.toLowerCase())) {
6329
+ return prev
6330
+ }
6331
+
6332
+ return {
6333
+ ...prev,
6334
+ [currentValue.name]: currentValue.value
6335
+ }
6336
+ }, {});
6337
+
6338
+ const result = await axios.request({
6339
+ url: `${beginFileUploadResult.use_https === 1 ? "https" : "http"}://${beginFileUploadResult.url_host}${beginFileUploadResult.url_path}`,
6340
+ method: 'PUT',
6341
+ headers: headers,
6342
+ data: fs.createReadStream(filePath)
6343
+ })
6344
+
6345
+ return result
6346
+ }
6347
+
6348
+ async commitFileUpload({
6349
+ file_name,
6350
+ file_sha,
6351
+ file_image_width,
6352
+ file_image_height,
6353
+ file_type,
6354
+ hmac,
6355
+ timestamp,
6356
+ ugcid,
6357
+ friend_steamid,
6358
+ }) {
6359
+
6360
+ const input = {
6361
+ sessionid: this.getSessionid(),
6362
+ l: "english",
6363
+ file_name: file_name,
6364
+ success: 1,
6365
+ file_sha: file_sha,
6366
+ file_image_width: file_image_width,
6367
+ file_image_height: file_image_height,
6368
+ file_type: file_type,
6369
+ ugcid: ugcid,
6370
+ timestamp: timestamp,
6371
+ hmac: hmac,
6372
+ friend_steamid: friend_steamid,
6373
+ spoiler: 0,
6374
+ }
6375
+
6376
+ const form = new FormData();
6377
+ for (const key in input) {
6378
+ form.append(key, input[key].toString());
6379
+ }
6380
+
6381
+ const result = (await this._httpRequestAjax({
6382
+ url: "chat/commitfileupload/?l=english",
6383
+ data: form,
6384
+ method: 'POST',
6385
+ headers: {
6386
+ 'Content-Type': 'multipart/form-data',
6387
+ },
6388
+ }))?.data
6389
+
6390
+ return result
6391
+ const successExample = {
6392
+ success: 1,
6393
+ result: {
6394
+ details: {
6395
+ appid: 744350,
6396
+ ugcid: null,
6397
+ filename: "26252_image.png",
6398
+ timestamp: "1705578275",
6399
+ file_size: 48620,
6400
+ url: "https:\/\/steamuserimages-a.akamaihd.net\/ugc\/2277199680653980183\/71FCD5C7180C630833FEE30B24B687B9D3E0B08A\/",
6401
+ steamid_creator: "76561199040402348",
6402
+ flags: 16,
6403
+ platforms_to_sync: [],
6404
+ file_sha: "71fcd5c7180c630833fee30b24b687b9d3e0b08a"
6405
+ },
6406
+ success: 1,
6407
+ rwgrsn: -2
6408
+ }
6409
+ }
6410
+ }
6411
+
6412
+ async sendImageMessage({
6413
+ imagePath,
6414
+ friend_steamid,
6415
+ }) {
6416
+ const beginFileUploadResult = await this.beginFileUpload(imagePath)
6417
+ if (beginFileUploadResult?.success !== 1) {
6418
+ return beginFileUploadResult
6419
+ }
6420
+ const uploadingResult = await this.doFileUpload({
6421
+ filePath: imagePath,
6422
+ beginFileUploadResult: beginFileUploadResult.result,
6423
+ })
6424
+
6425
+ const result = await this.commitFileUpload({
6426
+ ...beginFileUploadResult.result,
6427
+ hmac: beginFileUploadResult.hmac,
6428
+ timestamp: beginFileUploadResult.timestamp,
6429
+ friend_steamid: friend_steamid
6430
+ })
6431
+ return result
6432
+ const successExample = {
6433
+ success: 1,
6434
+ result: {
6435
+ details: {
6436
+ appid: 744350,
6437
+ ugcid: null,
6438
+ filename: "26252_image.png",
6439
+ timestamp: "1705578275",
6440
+ file_size: 48620,
6441
+ url: "https:\/\/steamuserimages-a.akamaihd.net\/ugc\/2277199680653980183\/71FCD5C7180C630833FEE30B24B687B9D3E0B08A\/",
6442
+ steamid_creator: "76561199040402348",
6443
+ flags: 16,
6444
+ platforms_to_sync: [],
6445
+ file_sha: "71fcd5c7180c630833fee30b24b687b9d3e0b08a"
6446
+ },
6447
+ success: 1,
6448
+ rwgrsn: -2
6449
+ }
6450
+ }
6451
+ const errorExample = {
6452
+ success: 112,
6453
+ message: "Limited users cannot upload images."
6454
+ }
6455
+ }
6229
6456
  }
6230
6457
 
6231
6458
  function querySelectorAll($, selector, root) {
package/package.json CHANGED
@@ -1,22 +1,23 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.3.34",
3
+ "version": "1.3.36",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "alpha-common-utils": "^1.0.5",
7
- "axios": "^1.6.1",
7
+ "axios": "^1.6.5",
8
8
  "bytebuffer": "^5.0.1",
9
9
  "cheerio": "^1.0.0-rc.12",
10
10
  "crypto-js": "^4.2.0",
11
11
  "csgo-friendcode": "^3.0.3",
12
12
  "form-data": "^4.0.0",
13
13
  "lodash": "^4.17.21",
14
- "moment": "^2.29.4",
15
- "moment-timezone": "^0.5.43",
14
+ "moment": "^2.30.1",
15
+ "moment-timezone": "^0.5.44",
16
16
  "node-bignumber": "^1.2.2",
17
- "steam-session": "^1.7.1",
18
- "steam-user": "^5.0.4",
19
- "steamcommunity": "^3.47.1",
17
+ "sharp": "^0.33.2",
18
+ "steam-session": "^1.7.2",
19
+ "steam-user": "^5.0.7",
20
+ "steamcommunity": "^3.48.2",
20
21
  "steamid": "^2.0.0",
21
22
  "url-parse": "^1.5.10",
22
23
  "uuid": "^9.0.1",