From 2a641e99aea281b41296d77bb85004a613e893ee Mon Sep 17 00:00:00 2001 From: achiez Date: Fri, 23 May 2025 16:32:50 +0300 Subject: [PATCH] Update version to 1.5.7 - Changed session ID retrieval method in `LoginV2Executor` for avoiding 429 errors --- NebulaAuth.sln | 1 + NebulaAuth/NebulaAuth.csproj | 2 +- NebulaAuth/update.xml | 6 +- SteamLibForked/Account/SessionData.cs | 2 +- .../Authentication/LoginV2/LoginV2Executor.cs | 4 +- .../SteamWebApi[folder]/SteamApi_Market.cs | 33 ++++++- changelog/1.5.7.html | 85 +++++++++++++++++++ 7 files changed, 124 insertions(+), 9 deletions(-) create mode 100644 changelog/1.5.7.html diff --git a/NebulaAuth.sln b/NebulaAuth.sln index b2d6f6d..2db9a5a 100644 --- a/NebulaAuth.sln +++ b/NebulaAuth.sln @@ -28,6 +28,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "changelog", "changelog", "{ changelog\1.5.4.html = changelog\1.5.4.html changelog\1.5.5.html = changelog\1.5.5.html changelog\1.5.6.html = changelog\1.5.6.html + changelog\1.5.7.html = changelog\1.5.7.html EndProjectSection EndProject Global diff --git a/NebulaAuth/NebulaAuth.csproj b/NebulaAuth/NebulaAuth.csproj index 440bd73..a8eff3f 100644 --- a/NebulaAuth/NebulaAuth.csproj +++ b/NebulaAuth/NebulaAuth.csproj @@ -10,7 +10,7 @@ en;ru;ua Theme\lock.ico 7.0 - 1.5.6 + 1.5.7 true diff --git a/NebulaAuth/update.xml b/NebulaAuth/update.xml index b7683e1..9c85715 100644 --- a/NebulaAuth/update.xml +++ b/NebulaAuth/update.xml @@ -1,8 +1,8 @@  - 1.5.6.0 - https://github.com/achiez/NebulaAuth-Steam-Desktop-Authenticator-by-Achies/releases/download/1.5.6/NebulaAuth.1.5.6.zip - https://achiez.github.io/NebulaAuth-Steam-Desktop-Authenticator-by-Achies/changelog/1.5.6.html + 1.5.7.0 + https://github.com/achiez/NebulaAuth-Steam-Desktop-Authenticator-by-Achies/releases/download/1.5.7/NebulaAuth.1.5.7.zip + https://achiez.github.io/NebulaAuth-Steam-Desktop-Authenticator-by-Achies/changelog/1.5.7.html false \ No newline at end of file diff --git a/SteamLibForked/Account/SessionData.cs b/SteamLibForked/Account/SessionData.cs index 2030771..9446365 100644 --- a/SteamLibForked/Account/SessionData.cs +++ b/SteamLibForked/Account/SessionData.cs @@ -19,7 +19,7 @@ public class SessionData : ISessionData public SteamAuthToken RefreshToken { get; } public ConcurrentDictionary Tokens { get; } - + [JsonConstructor] public SessionData(string sessionId, SteamId steamId, SteamAuthToken refreshToken, IDictionary? tokens) diff --git a/SteamLibForked/Authentication/LoginV2/LoginV2Executor.cs b/SteamLibForked/Authentication/LoginV2/LoginV2Executor.cs index e60ee51..1582f2e 100644 --- a/SteamLibForked/Authentication/LoginV2/LoginV2Executor.cs +++ b/SteamLibForked/Authentication/LoginV2/LoginV2Executor.cs @@ -63,9 +63,7 @@ public class LoginV2Executor var executor = new LoginV2Executor(options); var client = executor.HttpClient; - var globalData = await SteamWebApi.GetMarketGlobalInfo(client, cancellationToken); - var sessionId = globalData.SessionId; - + var sessionId = await SteamWebApi.GetLoginSessionId(client, cancellationToken); var rsgMsg = new GetPasswordRSAPublicKey_Request { AccountName = username diff --git a/SteamLibForked/Web/SteamWebApi[folder]/SteamApi_Market.cs b/SteamLibForked/Web/SteamWebApi[folder]/SteamApi_Market.cs index f4593c5..66c26a0 100644 --- a/SteamLibForked/Web/SteamWebApi[folder]/SteamApi_Market.cs +++ b/SteamLibForked/Web/SteamWebApi[folder]/SteamApi_Market.cs @@ -1,7 +1,13 @@ -using SteamLib.Core; +using System.Diagnostics.CodeAnalysis; +using System.Text.RegularExpressions; +using SteamLib.Core; using SteamLib.Exceptions.General; using SteamLib.Web.Models.GlobalMarketInfo; using SteamLib.Web.Scrappers.HTML; +using System.Threading; +using JetBrains.Annotations; +using HtmlAgilityPack; +using SteamLib.Core.Models; namespace SteamLib.Web; @@ -26,4 +32,29 @@ public static class SteamWebApi throw new UnsupportedResponseException(resp, ex); } } + + + [RegexPattern] + [SuppressMessage("ReSharper", "UseRawString")] + [SuppressMessage("ReSharper", "StringLiteralTypo")] + private static readonly string _regexTip = + @"g_sessionID = ""(?.*)"";" + + @"\s*g_steamID = (?.*);"; + + private static readonly Regex Regex = new(_regexTip, RegexOptions.Compiled); + private const string XPATH = "//div[@class='responsive_page_content']/script"; + + public static async Task GetLoginSessionId(HttpClient client, CancellationToken cancellationToken = default) + { + var resp = await client.GetStringAsync("https://steamcommunity.com/login/home", cancellationToken); + + var document = new HtmlDocument(); + document.LoadHtml(resp); + var scriptNode = document.DocumentNode.SelectSingleNode(XPATH) ?? throw new NullReferenceException("Script Node was null"); + var script = scriptNode.InnerText; + var match = Regex.Match(script); + if (!match.Success) + throw new UnsupportedResponseException(script, "Page contains script but regex was unsuccessful"); + return match.Groups["g_sessionID"].Value; + } } \ No newline at end of file diff --git a/changelog/1.5.7.html b/changelog/1.5.7.html new file mode 100644 index 0000000..ffb00ff --- /dev/null +++ b/changelog/1.5.7.html @@ -0,0 +1,85 @@ + + + + + + Changelog + + + + +
+ +
+
Version 1.5.7
+
23.05.2025
+
+
    +
  • + NEWS: Official Telegram group now available! Join us at + + t.me/nebulaauth + +
  • +
  • FIX:Removed request to /market/ upon login to prevent 429 error on banned IP
  • +
+
+
+
+ + \ No newline at end of file