From bbcfe59f0199827dfca44857b5856b0990b5ffb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=B2=D0=B8=D0=B4=20=D0=A7=D0=B5=D1=80=D0=BD?= =?UTF-8?q?=D0=BE=D0=BF=D1=8F=D1=82=D0=BE=D0=B2?= Date: Thu, 1 Feb 2024 16:36:49 +0200 Subject: [PATCH] 1.4.5 --- NebulaAuth/Model/MaClient.cs | 4 +- NebulaAuth/Model/SessionHandler.cs | 2 +- NebulaAuth/NebulaAuth.csproj | 2 +- NebulaAuth/View/ConfirmationTemplates.xaml | 17 ++++----- NebulaAuth/ViewModel/Other/LinkAccountVM.cs | 2 +- NebulaAuth/localization.loc.json | 7 ++++ NebulaAuth/update.xml | 6 +-- .../Authentication/AdmissionHelper.cs | 38 ++++++++++++++++++- SteamLibForked/Web/ClientBuilder.cs | 2 +- 9 files changed, 59 insertions(+), 21 deletions(-) diff --git a/NebulaAuth/Model/MaClient.cs b/NebulaAuth/Model/MaClient.cs index 7f80f9c..005531d 100644 --- a/NebulaAuth/Model/MaClient.cs +++ b/NebulaAuth/Model/MaClient.cs @@ -56,7 +56,7 @@ public static class MaClient { if (account.SessionData != null) { - ClientHandler.CookieContainer.SetSteamMobileCookies(account.SessionData); + ClientHandler.CookieContainer.SetSteamMobileCookiesWithMobileToken(account.SessionData); } else { @@ -116,7 +116,7 @@ public static class MaClient } Storage.UpdateMafile(mafile); - ClientHandler.CookieContainer.SetSteamMobileCookies(mafile.SessionData); + ClientHandler.CookieContainer.SetSteamMobileCookiesWithMobileToken(mafile.SessionData); } public static Task SendConfirmation(Mafile mafile, Confirmation confirmation, bool confirm) diff --git a/NebulaAuth/Model/SessionHandler.cs b/NebulaAuth/Model/SessionHandler.cs index 6aefe0e..866d3ee 100644 --- a/NebulaAuth/Model/SessionHandler.cs +++ b/NebulaAuth/Model/SessionHandler.cs @@ -82,7 +82,7 @@ public static class SessionHandler try { await MaClient.RefreshSession(mafile); - SnackbarController.SendSnackbar("Сессия была обновлена автоматически"); + SnackbarController.SendSnackbar(LocManager.GetCodeBehindOrDefault("SessionWasRefreshedAutomatically", "SessionHandler", "SessionWasRefreshedAutomatically")); return true; } catch (SessionInvalidException) diff --git a/NebulaAuth/NebulaAuth.csproj b/NebulaAuth/NebulaAuth.csproj index 71e6dfa..a0fbbec 100644 --- a/NebulaAuth/NebulaAuth.csproj +++ b/NebulaAuth/NebulaAuth.csproj @@ -10,7 +10,7 @@ en;ru;ua Theme\nebula lock.ico 7.0 - 1.4.4 + 1.4.5 diff --git a/NebulaAuth/View/ConfirmationTemplates.xaml b/NebulaAuth/View/ConfirmationTemplates.xaml index b4ec36f..213b87c 100644 --- a/NebulaAuth/View/ConfirmationTemplates.xaml +++ b/NebulaAuth/View/ConfirmationTemplates.xaml @@ -99,14 +99,12 @@ - + + + - - - - - - + + @@ -166,10 +164,9 @@ - + - - + diff --git a/NebulaAuth/ViewModel/Other/LinkAccountVM.cs b/NebulaAuth/ViewModel/Other/LinkAccountVM.cs index 9697241..c69f773 100644 --- a/NebulaAuth/ViewModel/Other/LinkAccountVM.cs +++ b/NebulaAuth/ViewModel/Other/LinkAccountVM.cs @@ -140,7 +140,7 @@ public partial class LinkAccountVM : ObservableObject, IEmailProvider, IPhoneNum IsFieldVisible = false; HintText = string.Empty; _sessionData = (MobileSessionData)await LoginV2Executor.DoLogin(_loginV2ExecutorOptions, userName, pass); - Handler.CookieContainer.SetSteamMobileCookies(_sessionData); + Handler.CookieContainer.SetSteamMobileCookiesWithMobileToken(_sessionData); IsEmailCode = true; } catch (EResultException ex) diff --git a/NebulaAuth/localization.loc.json b/NebulaAuth/localization.loc.json index 3119657..44fb823 100644 --- a/NebulaAuth/localization.loc.json +++ b/NebulaAuth/localization.loc.json @@ -861,6 +861,13 @@ } }, + "SessionHandler": { + "SessionWasRefreshedAutomatically": { + "ru": "Сессия была обновлена автоматически", + "en": "Session was refreshed automatically", + "ua": "Сесія була оновлена автоматично" + } + }, "ProxyManagerVM": { "WrongFormatSomeIdsMissing": { "ru": "Неверный формат. Некоторые прокси не имеют ID", diff --git a/NebulaAuth/update.xml b/NebulaAuth/update.xml index a8b924d..0e0f26a 100644 --- a/NebulaAuth/update.xml +++ b/NebulaAuth/update.xml @@ -1,7 +1,7 @@  - 1.4.4.0 - https://github.com/achiez/NebulaAuth-Steam-Desktop-Authenticator-by-Achies/releases/download/1.4.4/NebulaAuth.1.4.4.zip - https://achiez.github.io/NebulaAuth-Steam-Desktop-Authenticator-by-Achies/changelog/1.4.4.html + 1.4.5.0 + https://github.com/achiez/NebulaAuth-Steam-Desktop-Authenticator-by-Achies/releases/download/1.4.5/NebulaAuth.1.4.5.zip + https://achiez.github.io/NebulaAuth-Steam-Desktop-Authenticator-by-Achies/changelog/1.4.5.html false \ No newline at end of file diff --git a/SteamLibForked/Authentication/AdmissionHelper.cs b/SteamLibForked/Authentication/AdmissionHelper.cs index 0408494..70c5884 100644 --- a/SteamLibForked/Authentication/AdmissionHelper.cs +++ b/SteamLibForked/Authentication/AdmissionHelper.cs @@ -72,11 +72,45 @@ public static class AdmissionHelper foreach (var domain in SteamDomains.AllDomains) { var token = mobileSession.GetToken(domain); - if (token == null) continue; + if (token == null || token.Value.IsExpired) continue; AddTokenCookie(container, token.Value); } } + /// + /// Clear and set new session. Not recommended. Uses for domain instead of its own cookie. It's okay to use it only for confirmations. But Market, Trading and other pages won't be authenticated + /// + public static void SetSteamMobileCookiesWithMobileToken(this CookieContainer container, IMobileSessionData mobileSession, + string setLanguage = "english") + { + + container.ClearSteamCookies(setLanguage); + container.AddMinimalMobileCookies(); + + AddRefreshToken(container, mobileSession.RefreshToken); + + var community = SteamDomains.GetDomainUri(SteamDomain.Community); + container.Add(community, new Cookie("steamid", mobileSession.SteamId.Steam64.ToString())); + container.Add(community, new Cookie("sessionid", mobileSession.SessionId)); + container.Add(community, new Cookie("Steam_Language", setLanguage)); + TransferCommunityCookies(container); + + var domainCookieSet = false; + foreach (var domain in SteamDomains.AllDomains) + { + + var token = mobileSession.GetToken(domain); + if (token == null || token.Value.IsExpired) continue; + if(domain == SteamDomain.Community ) + domainCookieSet = true; + AddTokenCookie(container, token.Value); + } + + var mobileToken = mobileSession.GetMobileToken(); + if (domainCookieSet == false && mobileToken is {IsExpired: false}) + AddTokenCookie(container, SteamDomain.Community, mobileToken.Value); + } + public static void AddMinimalMobileCookies(this CookieContainer container) { @@ -146,7 +180,7 @@ public static class AdmissionHelper } private static void AddTokenCookie(CookieContainer container, SteamDomain domain, SteamAuthToken token) { - var domainUri = SteamDomains.GetDomainUri(token.Domain); + var domainUri = SteamDomains.GetDomainUri(domain); container.Add(domainUri, new Cookie(ACCESS_COOKIE_NAME, token.SignedToken) { HttpOnly = true, diff --git a/SteamLibForked/Web/ClientBuilder.cs b/SteamLibForked/Web/ClientBuilder.cs index 65505d9..3af1708 100644 --- a/SteamLibForked/Web/ClientBuilder.cs +++ b/SteamLibForked/Web/ClientBuilder.cs @@ -29,7 +29,7 @@ public static class ClientBuilder } else { - container.SetSteamMobileCookies(sessionData); + container.SetSteamMobileCookiesWithMobileToken(sessionData); } ConfigureCommon(handler, client);