diff --git a/NebulaAuth.sln b/NebulaAuth.sln index 2db9a5a..361999a 100644 --- a/NebulaAuth.sln +++ b/NebulaAuth.sln @@ -3,15 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.4.33205.214 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NebulaAuth", "NebulaAuth\NebulaAuth.csproj", "{0FD01700-6D5C-451B-93BA-0860647E8F13}" - ProjectSection(ProjectDependencies) = postProject - {09F02072-F91D-4DAA-87BC-A34D3E150570} = {09F02072-F91D-4DAA-87BC-A34D3E150570} - EndProjectSection -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NebulaAuth.LegacyConverter", "NebulaAuth.LegacyConverter\NebulaAuth.LegacyConverter.csproj", "{2D78A7D9-986A-4890-8A91-7ABD57A91830}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SteamLibForked", "SteamLibForked\SteamLibForked.csproj", "{09F02072-F91D-4DAA-87BC-A34D3E150570}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "changelog", "changelog", "{161BFADE-FCF3-45D1-82EA-8A1B187529F7}" ProjectSection(SolutionItems) = preProject changelog\1.3.4.html = changelog\1.3.4.html @@ -28,27 +19,33 @@ 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 + changelog\1.7.1.html = changelog\1.7.1.html EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SteamLibForked", "src\SteamLibForked\SteamLibForked.csproj", "{224F9DB0-3D20-A614-BA2A-12F22B13A2C6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NebulaAuth.LegacyConverter", "src\NebulaAuth.LegacyConverter\NebulaAuth.LegacyConverter.csproj", "{C8235305-E5C4-155B-C718-C0F239CA3AB7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NebulaAuth", "src\NebulaAuth\NebulaAuth.csproj", "{C42F63B6-32F7-ED08-5B86-CD51989761AD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0FD01700-6D5C-451B-93BA-0860647E8F13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0FD01700-6D5C-451B-93BA-0860647E8F13}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0FD01700-6D5C-451B-93BA-0860647E8F13}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0FD01700-6D5C-451B-93BA-0860647E8F13}.Release|Any CPU.Build.0 = Release|Any CPU - {2D78A7D9-986A-4890-8A91-7ABD57A91830}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2D78A7D9-986A-4890-8A91-7ABD57A91830}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2D78A7D9-986A-4890-8A91-7ABD57A91830}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2D78A7D9-986A-4890-8A91-7ABD57A91830}.Release|Any CPU.Build.0 = Release|Any CPU - {09F02072-F91D-4DAA-87BC-A34D3E150570}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {09F02072-F91D-4DAA-87BC-A34D3E150570}.Debug|Any CPU.Build.0 = Debug|Any CPU - {09F02072-F91D-4DAA-87BC-A34D3E150570}.Release|Any CPU.ActiveCfg = Release|Any CPU - {09F02072-F91D-4DAA-87BC-A34D3E150570}.Release|Any CPU.Build.0 = Release|Any CPU + {224F9DB0-3D20-A614-BA2A-12F22B13A2C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {224F9DB0-3D20-A614-BA2A-12F22B13A2C6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {224F9DB0-3D20-A614-BA2A-12F22B13A2C6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {224F9DB0-3D20-A614-BA2A-12F22B13A2C6}.Release|Any CPU.Build.0 = Release|Any CPU + {C8235305-E5C4-155B-C718-C0F239CA3AB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C8235305-E5C4-155B-C718-C0F239CA3AB7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C8235305-E5C4-155B-C718-C0F239CA3AB7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C8235305-E5C4-155B-C718-C0F239CA3AB7}.Release|Any CPU.Build.0 = Release|Any CPU + {C42F63B6-32F7-ED08-5B86-CD51989761AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C42F63B6-32F7-ED08-5B86-CD51989761AD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C42F63B6-32F7-ED08-5B86-CD51989761AD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C42F63B6-32F7-ED08-5B86-CD51989761AD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/NebulaAuth/App.xaml.cs b/NebulaAuth/App.xaml.cs deleted file mode 100644 index 9ae9dc1..0000000 --- a/NebulaAuth/App.xaml.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Windows; -using NebulaAuth.Core; -using NebulaAuth.Model; -using NebulaAuth.Model.Exceptions; - -namespace NebulaAuth; - -public partial class App -{ - protected override void OnStartup(StartupEventArgs e) - { - base.OnStartup(e); - - LocManager.Init(); - LocManager.SetApplicationLocalization(Settings.Instance.Language); - try - { - Shell.Initialize(); - } - catch (Exception ex) - { - var msg = ex.ToString(); - if (ex is CantAlignTimeException) - { - msg = LocManager.Get("CantAlignTimeError"); - } - - MessageBox.Show(msg, "Error", MessageBoxButton.OK, MessageBoxImage.Stop, MessageBoxResult.OK, - MessageBoxOptions.DefaultDesktopOnly); - throw; - } - } -} \ No newline at end of file diff --git a/NebulaAuth/NebulaAuth.csproj b/NebulaAuth/NebulaAuth.csproj deleted file mode 100644 index a8eff3f..0000000 --- a/NebulaAuth/NebulaAuth.csproj +++ /dev/null @@ -1,68 +0,0 @@ - - - - WinExe - net8.0-windows7.0 - enable - true - true - latest - en;ru;ua - Theme\lock.ico - 7.0 - 1.5.7 - true - - - - - - - - - - - - - - - - - - - - - - - - - Never - - - - - - - - - - - - - - - Code - - - - - - - Always - - - Always - - - - diff --git a/NebulaAuth/Theme/Brushes.xaml b/NebulaAuth/Theme/Brushes.xaml deleted file mode 100644 index d96edc1..0000000 --- a/NebulaAuth/Theme/Brushes.xaml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/NebulaAuth/Theme/SplashScreen.png b/NebulaAuth/Theme/SplashScreen.png deleted file mode 100644 index 3255bc0..0000000 Binary files a/NebulaAuth/Theme/SplashScreen.png and /dev/null differ diff --git a/NebulaAuth/Theme/lock small-detailed.png b/NebulaAuth/Theme/lock small-detailed.png deleted file mode 100644 index a88ff31..0000000 Binary files a/NebulaAuth/Theme/lock small-detailed.png and /dev/null differ diff --git a/NebulaAuth/Theme/lock.ico b/NebulaAuth/Theme/lock.ico deleted file mode 100644 index 3397e22..0000000 Binary files a/NebulaAuth/Theme/lock.ico and /dev/null differ diff --git a/NebulaAuth/View/Dialogs/LoginAgainDialog.xaml b/NebulaAuth/View/Dialogs/LoginAgainDialog.xaml deleted file mode 100644 index dfbeaf4..0000000 --- a/NebulaAuth/View/Dialogs/LoginAgainDialog.xaml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/NebulaAuth/View/SettingsView.xaml.cs b/NebulaAuth/View/SettingsView.xaml.cs deleted file mode 100644 index 183e3a7..0000000 --- a/NebulaAuth/View/SettingsView.xaml.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace NebulaAuth.View; - -/// -/// Логика взаимодействия для SettingsView.xaml -/// -public partial class SettingsView -{ - public SettingsView() - { - InitializeComponent(); - } -} \ No newline at end of file diff --git a/NebulaAuth/ViewModel/Other/LinkAccountVM.cs b/NebulaAuth/ViewModel/Other/LinkAccountVM.cs deleted file mode 100644 index 62f7ec2..0000000 --- a/NebulaAuth/ViewModel/Other/LinkAccountVM.cs +++ /dev/null @@ -1,457 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Net.Http; -using System.Threading.Tasks; -using System.Windows; -using AchiesUtilities.Collections; -using AchiesUtilities.Web.Proxy; -using CommunityToolkit.Mvvm.ComponentModel; -using CommunityToolkit.Mvvm.Input; -using MaterialDesignThemes.Wpf; -using NebulaAuth.Core; -using NebulaAuth.Model; -using NebulaAuth.Model.Entities; -using NebulaAuth.Utility; -using NLog; -using SteamLib; -using SteamLib.Account; -using SteamLib.Authentication; -using SteamLib.Authentication.LoginV2; -using SteamLib.Core.Interfaces; -using SteamLib.Exceptions; -using SteamLib.Exceptions.Mobile; -using SteamLib.ProtoCore.Exceptions; -using SteamLib.SteamMobile.AuthenticatorLinker; -using SteamLib.Web; -using ILogger = Microsoft.Extensions.Logging.ILogger; - -namespace NebulaAuth.ViewModel.Other; - -public partial class LinkAccountVM : ObservableObject, IEmailProvider, IPhoneNumberProvider, ISmsCodeProvider -{ - private const string LOCALIZATION_KEY = "LinkVM"; - private static Logger Logger => Shell.Logger; - private static ILogger Logger2 => Shell.ExtensionsLogger; - -#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. - public LinkAccountVM() -#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. - { - if (MaClient.DefaultProxy != null) - { - var def = Proxies.FirstOrDefault(p => p.Value.Equals(MaClient.DefaultProxy)); - if (def.Value != null!) - { - SelectedProxy = def; - } - } - } - - [RelayCommand(AllowConcurrentExecutions = true, CanExecute = nameof(CanProceed))] - public async Task Proceed() - { - if (IsCompleted) - DialogHost.Close(null); - - CanProceed = false; - - #region Login - - if (IsLogin == false) - { - SetProxy(); - ClearCookies(); - _loginV2ExecutorOptions = new LoginV2ExecutorOptions(LoginV2Executor.NullConsumer, Client) - { - DeviceDetails = LoginV2ExecutorOptions.GetMobileDefaultDevice(), - WebsiteId = "Mobile", - EmailAuthProvider = this, - Logger = Logger2 - }; - - try - { - IsLogin = true; - var userName = FieldText; - var pass = PassFieldText; - _password = pass; - FieldText = string.Empty; - IsFieldVisible = false; - HintText = string.Empty; - _sessionData = - (MobileSessionData) await LoginV2Executor.DoLogin(_loginV2ExecutorOptions, userName, pass); - Handler.CookieContainer.SetSteamMobileCookiesWithMobileToken(_sessionData); - IsEmailCode = true; - } - catch (EResultException ex) - { - Logger.Error(ex, "Link exception on login"); - HintText = GetLocalizationOrDefault("CantLogin") + ErrorTranslatorHelper.TranslateEResult(ex.Result); - InvokeOnDispatcher(ResetState); - return; - } - catch (LoginException ex) - { - Logger.Error(ex, "Link exception on login"); - HintText = GetLocalizationOrDefault("CantLogin") + ErrorTranslatorHelper.TranslateLoginError(ex.Error); - InvokeOnDispatcher(ResetState); - return; - } - catch (Exception ex) - { - Logger.Error(ex, "Link exception on login"); - HintText = GetLocalizationOrDefault("CantLogin") + ex.Message; - InvokeOnDispatcher(ResetState); - return; - } - } - - if (IsEmailCode == false) - { - _emailCodeTcs.SetResult(FieldText); - HintText = string.Empty; - FieldText = string.Empty; - _emailCodeTcs = new TaskCompletionSource(); - IsFieldVisible = false; - return; - } - - #endregion - - if (_isLinkStarted) - goto linkStarted; - - try - { - _isLinkStarted = true; - var linkOptions = new LinkOptions(Client, LoginV2Executor.NullConsumer, this, - null, this, this, Backup, Logger2); - _linker = new SteamAuthenticatorLinker(linkOptions); - var result = await _linker.LinkAccount(_sessionData); - IsLinkCode = true; - IsCompleted = true; - var mafile = Mafile.FromMobileDataExtended(result); - try - { - if (SelectedProxy.HasValue) - mafile.Proxy = new MaProxy(SelectedProxy.Value.Key, SelectedProxy.Value.Value); - if (Settings.Instance.IsPasswordSet) - mafile.Password = PHandler.Encrypt(_password); - } - catch (Exception ex) - { - Logger.Error(ex, "Error during saving Nebula data to mafile"); - } - - Storage.SaveMafile(mafile); - File.Delete(Path.Combine("mafiles_backup", mafile.AccountName + ".mafile")); - HintText = - string.Format(GetLocalizationOrDefault("MafileLinked"), - mafile.RevocationCode, - mafile.SessionData?.SteamId.Steam64); - - _rCode = mafile.RevocationCode ?? string.Empty; - CanProceed = true; - return; - } - catch (AuthenticatorLinkerException ex) - { - Logger.Error(ex, "Link exception"); - HintText = $"{GetLocalizationCommon("Error")}: {ErrorTranslatorHelper.TranslateLinkerError(ex.Error)}"; - InvokeOnDispatcher(ResetState); - return; - } - catch (HttpRequestException ex) - { - var msg = ex.StatusCode?.ToString() ?? ex.Message; - HintText = $"{GetLocalizationCommon("RequestError")}: {msg}"; - InvokeOnDispatcher(ResetState); - return; - } - catch (EResultException ex) - { - Logger.Error(ex, "Link exception"); - HintText = GetLocalizationOrDefault("ErrorWithCode") + ErrorTranslatorHelper.TranslateEResult(ex.Result); - InvokeOnDispatcher(ResetState); - return; - } - catch (Exception ex) - { - Logger.Error(ex, "Link exception"); - HintText = GetLocalizationOrDefault("UnknownError") + ex.Message; - InvokeOnDispatcher(ResetState); - return; - } - - - linkStarted: - if (IsPhoneNumber == false) - { - var phoneText = FieldText; - FieldText = string.Empty; - - if (string.IsNullOrWhiteSpace(phoneText)) - { - HintText = string.Empty; - IsFieldVisible = false; - _phoneNumberTcs.SetResult(null); - _phoneNumberTcs = new TaskCompletionSource(); - return; - } - - if (!string.IsNullOrWhiteSpace(phoneText) && phoneText.Length >= 4 && - long.TryParse(phoneText, out var phone)) - { - HintText = string.Empty; - IsFieldVisible = false; - _phoneNumberTcs.SetResult(phone); - _phoneNumberTcs = new TaskCompletionSource(); - return; - } - - HintText = GetLocalizationOrDefault("PleaseEnterCorrectPhone"); - CanProceed = true; - return; - } - - if (IsEmailConfirmation == false) - { - HintText = string.Empty; - _emailConfTcs.SetResult(); - _emailConfTcs = new TaskCompletionSource(); - CanProceed = false; - return; - } - - if (IsLinkCode == false) - { - var linkCode = FieldText; - FieldText = string.Empty; - if (!string.IsNullOrWhiteSpace(linkCode) && linkCode.Length >= 4) - { - HintText = string.Empty; - IsFieldVisible = false; - _linkCodeTcs.SetResult(linkCode); - _linkCodeTcs = new TaskCompletionSource(); - } - else - { - HintText = GetLocalizationOrDefault("PleaseEnterCorrectCode"); - CanProceed = true; - } - } - } - - [RelayCommand] - public void ResetProxy() - { - if (IsPasswordFieldVisible == false) return; - SelectedProxy = null; - } - - private void InvokeOnDispatcher(Action action) - { - Application.Current.Dispatcher.BeginInvoke(action, null); - } - - private void ResetState() - { - PassFieldText = string.Empty; - IsLogin = false; - IsFieldVisible = true; - IsEmailCode = false; - _isLinkStarted = false; - IsPhoneNumber = false; - IsEmailConfirmation = false; - CanProceed = true; - _emailCodeTcs = new TaskCompletionSource(); - _rCode = string.Empty; - _password = string.Empty; - } - - private void Backup(MobileDataExtended data) - { - if (Directory.Exists("mafiles_backup") == false) - { - Directory.CreateDirectory("mafiles_backup"); - } - - var json = NebulaSerializer.SerializeMafile(data, null); - File.WriteAllText(Path.Combine("mafiles_backup", data.AccountName + ".mafile"), - json); //TODO: Move logic to Storage - } - - [RelayCommand] - private void OpenTroubleshooting() - { - const string troubleshootingURI = - "https://achiez.github.io/NebulaAuth-Steam-Desktop-Authenticator-by-Achies/docs/{0}/LinkingTroubleshooting"; - - var localized = string.Format(troubleshootingURI, LocManager.GetCurrentLanguageCode()); - Process.Start(new ProcessStartInfo(new Uri(localized).ToString()) - { - UseShellExecute = true - }); - } - - [RelayCommand] - private void CopyCode() - { - try - { - Clipboard.SetText(_rCode); - } - catch (Exception ex) - { - Shell.Logger.Error(ex, "Error whily copying RCode"); - } - } - - - private static string GetLocalizationOrDefault(string key) - { - return LocManager.GetCodeBehindOrDefault(key, LOCALIZATION_KEY, key); - } - - private static string GetLocalizationCommon(string key) - { - return LocManager.GetCommonOrDefault(key, key); - } - - #region Properties - - [ObservableProperty] [NotifyPropertyChangedFor(nameof(IsPasswordFieldVisible))] - private bool _isLogin; - - - [ObservableProperty] private bool _isEmailCode; - [ObservableProperty] private bool _isPhoneNumber; - [ObservableProperty] private bool _isEmailConfirmation; - [ObservableProperty] private bool _isLinkCode; - [ObservableProperty] private bool _isCompleted; - - [ObservableProperty] private bool _isFieldVisible = true; - - - [ObservableProperty] private string _fieldText; - [ObservableProperty] private string _passFieldText; - [ObservableProperty] private string _hintText = GetLocalizationOrDefault("EnterLoginAndPassword"); - - private TaskCompletionSource _emailCodeTcs = new(); - private TaskCompletionSource _phoneNumberTcs = new(); - private TaskCompletionSource _emailConfTcs = new(); - private TaskCompletionSource _linkCodeTcs = new(); - - private bool _isLinkStarted; - private string _rCode = string.Empty; - private string _password = string.Empty; - - [ObservableProperty] [NotifyCanExecuteChangedFor(nameof(ProceedCommand))] - private bool _canProceed = true; - - public bool IsPasswordFieldVisible => !IsLogin; - - private LoginV2ExecutorOptions _loginV2ExecutorOptions; - private SteamAuthenticatorLinker _linker; - private MobileSessionData _sessionData; - - #endregion - - #region HttpClient - - private static HttpClient Client { get; } - private static HttpClientHandler Handler { get; } - private static DynamicProxy Proxy { get; } - public ObservableDictionary Proxies => ProxyStorage.Proxies; - - public KeyValuePair? SelectedProxy - { - get => _selectedProxy; - set - { - SetProperty(ref _selectedProxy, value); - SetProxy(); - } - } - - private KeyValuePair? _selectedProxy; - - #endregion - - #region Providers - - public int MaxRetryCount { get; } - - public Task GetEmailAuthCode(ILoginConsumer caller) - { - CanProceed = true; - HintText = GetLocalizationOrDefault("EnterEmailCode"); - IsFieldVisible = true; - return _emailCodeTcs.Task; - } - - public Task GetAddAuthenticatorCode(ILoginConsumer caller) - { - IsPhoneNumber = true; - IsEmailConfirmation = true; - CanProceed = true; - HintText = GetLocalizationOrDefault("EnterEmailCode"); - IsFieldVisible = true; - return _linkCodeTcs.Task; - } - - public Task ConfirmEmailLink(ILoginConsumer caller, EmailConfirmationType confirmationType) - { - IsPhoneNumber = true; - CanProceed = true; - HintText = GetLocalizationOrDefault("ClickOnEmailLink"); - return _emailConfTcs.Task; - } - - public Task GetPhoneNumber(ILoginConsumer caller) - { - CanProceed = true; - HintText = GetLocalizationOrDefault("EnterPhoneNumber"); - IsFieldVisible = true; - return _phoneNumberTcs.Task; - } - - public async Task GetSmsCode(ILoginConsumer caller, long? phoneNumber, string? hint) - { - IsPhoneNumber = true; - IsEmailConfirmation = true; - CanProceed = true; - HintText = string.Format(GetLocalizationOrDefault("PhoneHint"), hint); - IsFieldVisible = true; - var code = await _linkCodeTcs.Task; - return int.Parse(code); - } - - #endregion - - - #region Client - - static LinkAccountVM() - { - Proxy = new DynamicProxy(); - var clientPair = ClientBuilder.BuildMobileClient(Proxy, null); - Client = clientPair.Client; - Handler = clientPair.Handler; - } - - private void ClearCookies() - { - Handler.CookieContainer.ClearMobileSessionCookies(); - } - - private void SetProxy() - { - Proxy.SetData(SelectedProxy?.Value); - } - - #endregion -} \ No newline at end of file diff --git a/NebulaAuth/update.xml b/NebulaAuth/update.xml index 9c85715..8f82293 100644 --- a/NebulaAuth/update.xml +++ b/NebulaAuth/update.xml @@ -1,8 +1,8 @@  - 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 + 1.7.1.0 + https://github.com/achiez/NebulaAuth-Steam-Desktop-Authenticator-by-Achies/releases/download/1.7.1/NebulaAuth.1.7.1.zip + https://achiez.github.io/NebulaAuth-Steam-Desktop-Authenticator-by-Achies/changelog/1.7.1.html false \ No newline at end of file diff --git a/SteamLibForked/Api/Mobile/SteamMobileAuthenticatorApi.cs b/SteamLibForked/Api/Mobile/SteamMobileAuthenticatorApi.cs deleted file mode 100644 index 327846a..0000000 --- a/SteamLibForked/Api/Mobile/SteamMobileAuthenticatorApi.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System.Net; -using SteamLib.Core; -using SteamLib.Exceptions; -using SteamLib.ProtoCore; -using SteamLib.ProtoCore.Services; - -namespace SteamLib.Api.Mobile; - -public static class SteamMobileAuthenticatorApi -{ - public static async Task GetAuthSessionsForAccount(HttpClient client, - string accessToken, CancellationToken cancellationToken = default) - { - var req = SteamConstants.STEAM_API + "IAuthenticationService/GetAuthSessionsForAccount/v1?access_token=" + - accessToken; - - try - { - return await client.GetProto(req, new EmptyMessage(), - cancellationToken); - } - catch (HttpRequestException ex) - when (ex.StatusCode == HttpStatusCode.Unauthorized) - { - throw new SessionInvalidException(SessionInvalidException.GOT_401_MSG, ex); - } - } - - public static async Task GetAuthSessionInfo(HttpClient client, string accessToken, - ulong clientId, CancellationToken cancellationToken = default) - { - var req = SteamConstants.STEAM_API + "IAuthenticationService/GetAuthSessionInfo/v1?access_token=" + accessToken; - var reqData = new GetAuthSessionInfo_Request - { - ClientId = clientId - }; - try - { - return await client.PostProto(req, reqData, cancellationToken); - } - catch (HttpRequestException ex) - when (ex.StatusCode == HttpStatusCode.Unauthorized) - { - throw new SessionInvalidException(SessionInvalidException.GOT_401_MSG, ex); - } - } - - - public static async Task UpdateAuthSessionStatus(HttpClient client, string accessToken, string sharedSecret, - UpdateAuthSessionWithMobileConfirmation_Request request) - { - var req = SteamConstants.STEAM_API + - "IAuthenticationService/UpdateAuthSessionWithMobileConfirmation/v1?access_token=" + accessToken; - - request.ComputeSignature(sharedSecret); - await client.PostProtoEnsureSuccess(req, request); - return true; - } -} \ No newline at end of file diff --git a/SteamLibForked/Api/SteamGlobalApi.cs b/SteamLibForked/Api/SteamGlobalApi.cs deleted file mode 100644 index 226781c..0000000 --- a/SteamLibForked/Api/SteamGlobalApi.cs +++ /dev/null @@ -1,114 +0,0 @@ -using AchiesUtilities.Models; -using AchiesUtilities.Newtonsoft.JSON.Converters.Special; -using Newtonsoft.Json; -using SteamLib.Authentication; -using SteamLib.Core; -using SteamLib.Core.Enums; -using SteamLib.Core.StatusCodes; -using SteamLib.Exceptions; -using SteamLib.Exceptions.General; - -namespace SteamLib.Api; - -public static class SteamGlobalApi -{ - /// - /// Raw AccessToken value - /// - /// - /// - /// - /// - /// - public static async Task RefreshJwt(HttpClient client, SteamDomain domain, - CancellationToken cancellationToken = default) - { - var domainUri = SteamDomains.GetDomain(domain); - var data = new Dictionary - { - {"redir", domainUri} - }; - var cont = new FormUrlEncodedContent(data); - var resp = await client.PostAsync("https://login.steampowered.com/jwt/ajaxrefresh", cont, cancellationToken); - var respStr = await resp.EnsureSuccessStatusCode().Content.ReadAsStringAsync(cancellationToken); - - JwtRefreshJson? jwtRefresh; - try - { - jwtRefresh = JsonConvert.DeserializeObject(respStr); - } - catch (Exception ex) - { - throw new UnsupportedResponseException(respStr, ex); - } - - if (jwtRefresh?.Success != true) - { - Exception? inner = null; - if (jwtRefresh?.Error != null) - { - var errorCode = jwtRefresh.Error.Value; - var translated = SteamStatusCode.Translate(errorCode, out _); - inner = new SteamStatusCodeException(translated, respStr); - } - - throw new SessionInvalidException( - "AjaxRefresh was not successful. 'steamRefresh_steam' cookie is missing or refresh token is invalid", - inner); - } - - data = new Dictionary - { - {"steamID", jwtRefresh.SteamId.ToString()}, - {"nonce", jwtRefresh.Nonce}, - {"redir", jwtRefresh.Redir}, - {"auth", jwtRefresh.Auth} - }; - - cont = new FormUrlEncodedContent(data); - var update = await client.PostAsync(jwtRefresh.LoginUrl, cont, cancellationToken); - var updateResp = await update.Content.ReadAsStringAsync(cancellationToken); - JwtUpdateJson result; - try - { - result = JsonConvert.DeserializeObject(updateResp) ?? throw new NullReferenceException(); - } - catch (Exception ex) - { - throw new UnsupportedResponseException(updateResp, ex); - } - - var resultStatus = SteamStatusCode.Translate(result.Result, out _); - if (resultStatus.Equals(SteamStatusCode.Ok) == false) - { - throw new SessionInvalidException( - "AjaxRefresh (set-token) response was not successful. Response string stored in Exception.Data") - { - Data = {{"Response", updateResp}} - }; - } - - return SteamTokenHelper.ExtractJwtFromSetCookiesHeader(update.Headers); - } - - - private class JwtRefreshJson - { - [JsonProperty("success")] public bool Success { get; set; } - [JsonProperty("login_url")] public string LoginUrl { get; set; } = string.Empty; - [JsonProperty("steamID")] public long SteamId { get; set; } - [JsonProperty("nonce")] public string Nonce { get; set; } = string.Empty; - [JsonProperty("redir")] public string Redir { get; set; } = string.Empty; - [JsonProperty("auth")] public string Auth { get; set; } = string.Empty; - [JsonProperty("error")] public int? Error { get; set; } - } - - private class JwtUpdateJson - { - [JsonProperty("result")] public int Result { get; set; } - - [JsonProperty("rtExpiry")] - [JsonConverter(typeof(UnixTimeStampConverter))] - public UnixTimeStamp RtExpiry { get; set; } - } -} \ No newline at end of file diff --git a/SteamLibForked/Authentication/Default/LoginExecutor.cs b/SteamLibForked/Authentication/Default/LoginExecutor.cs deleted file mode 100644 index 90e7154..0000000 --- a/SteamLibForked/Authentication/Default/LoginExecutor.cs +++ /dev/null @@ -1,112 +0,0 @@ -using Microsoft.Extensions.Logging; -using SteamLib.Authentication; -using SteamLib.Core.Interfaces; -using SteamLib.Exceptions; - -namespace SteamLib.Login.Default; - -[Obsolete("Method removed from Steam")] -public class LoginExecutor -{ - public static ILoginConsumer NullConsumer { get; } = new NullLoginConsumer(); - public ILoginConsumer Caller { get; } - public HttpClient HttpClient { get; } - public ILogger? Logger { get; init; } - public IEmailProvider? EmailAuthProvider { get; init; } - public ICaptchaResolver? CaptchaResolver { get; init; } - public ISteamGuardProvider? SteamGuardProvider { get; init; } - - private LoginExecutor(LoginExecutorOptions options) - { - Caller = options.Consumer; - HttpClient = options.HttpClient; - Logger = options.Logger; - EmailAuthProvider = options.EmailAuthProvider; - SteamGuardProvider = options.SteamGuardProvider; - CaptchaResolver = options.CaptchaResolver; - } - - - public static async Task DoLogin(LoginExecutorOptions options, string username, string password, - CancellationToken cancellationToken = default) //TODO: logs - { - var executor = new LoginExecutor(options); - var client = executor.HttpClient; - - LoginStage loginStage = new GetRsaStage(username); - loginStage = await ((GetRsaStage) loginStage).Proceed(client, cancellationToken); - cancellationToken.ThrowIfCancellationRequested(); - - if (loginStage is ReadyToLoginStage rdyToLoginStage) - { - loginStage = await rdyToLoginStage.Proceed(client, password, string.Empty, cancellationToken); - } - - cancellationToken.ThrowIfCancellationRequested(); - var twoFactorTry = 0; - var emailTry = 0; - while (loginStage.GetType() != typeof(LoginErrorStage) && loginStage is not LoginSuccessStage) - { - cancellationToken.ThrowIfCancellationRequested(); - switch (loginStage) - { - case CaptchaNeededStage captchaNeededStage: - { - if (executor.CaptchaResolver == null) throw new LoginException(LoginError.CaptchaRequired); - var captchaText = await executor.CaptchaResolver.Resolve(captchaNeededStage.CaptchaImage, client); - loginStage = await captchaNeededStage.Proceed(client, captchaText, cancellationToken); - break; - } - case EmailAuthStage emailAuthStage: - { - if (executor.EmailAuthProvider == null) throw new LoginException(LoginError.EmailAuthRequired); - if (emailTry > executor.EmailAuthProvider.MaxRetryCount) - throw new LoginException(LoginError.InvalidEmailAuthCode); - var code = await executor.EmailAuthProvider.GetEmailAuthCode(executor.Caller); - loginStage = await emailAuthStage.Proceed(client, code, cancellationToken); - emailTry++; - break; - } - case TwoFactorStage twoFactorStage: - { - if (executor.SteamGuardProvider == null) throw new LoginException(LoginError.SteamGuardRequired); - if (twoFactorTry > executor.SteamGuardProvider.MaxRetryCount) - throw new LoginException(LoginError.InvalidTwoFactorCode); - var twoFactor = await executor.SteamGuardProvider.GetSteamGuardCode(executor.Caller); - loginStage = await twoFactorStage.Proceed(client, twoFactor, cancellationToken); - twoFactorTry++; - break; - } - case ReadyToLoginStage readyToLoginStage: //When captcha proceeded, stage goes there - { - loginStage = await readyToLoginStage.Proceed(client, password, string.Empty, cancellationToken); - break; - } - default: - throw new ArgumentOutOfRangeException(nameof(loginStage)); - } - } - - if (loginStage is LoginErrorStage error) - { - var content = await error.Response.Content.ReadAsStringAsync(cancellationToken); - if (content.Contains("The account name or password that you have entered is incorrect")) - { - throw new LoginException(LoginError.InvalidCredentials); - } - - throw new LoginException(content); - } - - - if (loginStage is not LoginSuccessStage successStage) - { - throw new InvalidOperationException("Unexpected login stage at this point. " + loginStage.GetType()) - { - Data = {{"stage", loginStage}} - }; - } - - return successStage.TransferParameters; - } -} \ No newline at end of file diff --git a/SteamLibForked/Authentication/Default/LoginExecutorOptions.cs b/SteamLibForked/Authentication/Default/LoginExecutorOptions.cs deleted file mode 100644 index b8f93a4..0000000 --- a/SteamLibForked/Authentication/Default/LoginExecutorOptions.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Microsoft.Extensions.Logging; -using SteamLib.Core.Interfaces; - -namespace SteamLib.Login.Default; - -public class LoginExecutorOptions -{ - public ILoginConsumer Consumer { get; } - public HttpClient HttpClient { get; } - public ILogger? Logger { get; init; } - public IEmailProvider? EmailAuthProvider { get; init; } - public ICaptchaResolver? CaptchaResolver { get; init; } - public ISteamGuardProvider? SteamGuardProvider { get; init; } - - public LoginExecutorOptions(ILoginConsumer consumer, HttpClient httpClient) - { - Consumer = consumer; - HttpClient = httpClient; - } -} \ No newline at end of file diff --git a/SteamLibForked/Authentication/Default/LoginResultJson.cs b/SteamLibForked/Authentication/Default/LoginResultJson.cs deleted file mode 100644 index 47d3a8e..0000000 --- a/SteamLibForked/Authentication/Default/LoginResultJson.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Newtonsoft.Json; - -namespace SteamLib.Login.Default; - -#pragma warning disable CS8618 -/// -/// Class to Deserialize the json response strings after the login/> -/// -internal class LoginResultJson -{ - [JsonProperty("success")] public bool Success { get; set; } - [JsonProperty("message")] public string Message { get; set; } - [JsonProperty("captcha_needed")] public bool CaptchaNeeded { get; set; } - [JsonProperty("captcha_gid")] public string CaptchaGid { get; set; } - [JsonProperty("emailauth_needed")] public bool EmailAuthNeeded { get; set; } - [JsonProperty("emailsteamid")] public string EmailSteamId { get; set; } - [JsonProperty("requires_twofactor")] public bool RequiresTwoFactor { get; set; } -} \ No newline at end of file diff --git a/SteamLibForked/Authentication/Default/LoginStage.cs b/SteamLibForked/Authentication/Default/LoginStage.cs deleted file mode 100644 index bdcb1a8..0000000 --- a/SteamLibForked/Authentication/Default/LoginStage.cs +++ /dev/null @@ -1,252 +0,0 @@ -using AchiesUtilities.Web.Extensions; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using SteamLib.Authentication; -using SteamLib.Utility; - -namespace SteamLib.Login.Default; - -internal abstract class LoginStage -{ - protected Dictionary Data { get; } - - protected LoginStage() - { - Data = new Dictionary(); - } - - protected LoginStage(Dictionary data) - { - Data = data; - } - - protected bool CheckIfLoginCompleted(LoginResultJson json) - { - return !json.CaptchaNeeded && !json.EmailAuthNeeded && !json.RequiresTwoFactor && json.Success; - } - - protected async Task ConvertJson(HttpResponseMessage response) - { - response.EnsureSuccessStatusCode(); - var webResponseString = await response.Content.ReadAsStringAsync(); - return JsonConvert.DeserializeObject(webResponseString)!; - } - - protected async Task CompleteLogin(HttpResponseMessage response) - { - var jsonStr = await response.Content.ReadAsStringAsync(); - var json = JObject.Parse(jsonStr); - var transferParameters = json["transfer_parameters"]!.ToObject()!; - return new LoginSuccessStage(transferParameters); - } - - protected async Task LoginRequest(HttpClient client, - CancellationToken cancellationToken = default) - { - return await client.PostAsync("https://steamcommunity.com/login/dologin", new FormUrlEncodedContent(Data), - cancellationToken); - } -} - -internal class LoginErrorStage : LoginStage -{ - public readonly int ErrorCode; - public readonly string ErrorString; - public readonly HttpResponseMessage Response; - public readonly LoginStage Stage; - - public LoginErrorStage(string errorString, HttpResponseMessage responseMessage, LoginStage stage) - { - ErrorString = errorString; - Stage = stage; - ErrorCode = Utilities.GetSuccessCode(responseMessage.Content.ReadAsStringSync()); - Response = responseMessage; - } -} - -internal class GetRsaStage : LoginStage -{ - public GetRsaStage(Dictionary data) : base(data) - { - } - - public GetRsaStage(string userName) - { - Data["username"] = userName; - } - - - /// - /// - /// - /// - /// if success - public async Task Proceed(HttpClient client, CancellationToken cancellationToken = default) - { - var content = new FormUrlEncodedContent(Data); - var response = await client.PostAsync("https://steamcommunity.com/login/getrsakey", content, cancellationToken); - var responseString = await response.Content.ReadAsStringAsync(cancellationToken); - var rsaJson = JsonConvert.DeserializeObject(responseString)!; - if (!rsaJson.success) - return new LoginErrorStage("Can't get RSA", response, this); - - Data["rsatimestamp"] = rsaJson.timestamp; - return new ReadyToLoginStage(Data, rsaJson.publickey_exp, rsaJson.publickey_mod); - } -} - -internal class ReadyToLoginStage : LoginStage -{ - private readonly string _publicKeyExp; - private readonly string _publicKeyMod; - - internal ReadyToLoginStage(Dictionary data, string publicKeyExp, string publicKeyMod) : base(data) - { - _publicKeyExp = publicKeyExp; - _publicKeyMod = publicKeyMod; - } - - public async Task Proceed(HttpClient client, string password, string loginFriendlyName, - CancellationToken cancellationToken = default) - { - var encryptedBase64Password = - EncryptionHelper.ToBase64EncryptedPassword(_publicKeyExp, _publicKeyMod, password); - var unixTimestamp = (int) DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; - Data["password"] = encryptedBase64Password; - Data["remember_login"] = "true"; - Data["loginfriendlyname"] = loginFriendlyName; - Data["donotcache"] = - unixTimestamp + "000"; // Added three "0"'s because Steam has a weird unix timestamp interpretation. - - _ = await client.GetAsync("https://steamcommunity.com/", cancellationToken); - var webResponse = await LoginRequest(client, cancellationToken); - var result = await ConvertJson(webResponse); - - if (CheckIfLoginCompleted(result)) - { - return await CompleteLogin(webResponse); - } - - if (result.CaptchaNeeded) - { - return new CaptchaNeededStage(Data, result.CaptchaGid); - } - - if (result.EmailAuthNeeded) - { - return new EmailAuthStage(Data); - } - - if (result.RequiresTwoFactor) - { - return new TwoFactorStage(Data); - } - - return new LoginErrorStage("Can't proceed login.", webResponse, this); - } -} - -internal class TwoFactorStage : LoginStage -{ - internal TwoFactorStage(Dictionary data) : base(data) - { - } - - public async Task Proceed(HttpClient client, string twoFactorCode, - CancellationToken cancellationToken = default) - { - Data["twofactorcode"] = twoFactorCode; - var webResponse = await LoginRequest(client, cancellationToken); - var result = await ConvertJson(webResponse); - - if (CheckIfLoginCompleted(result)) - { - return await CompleteLogin(webResponse); - } - - if (result.CaptchaNeeded) - { - return new CaptchaNeededStage(Data, result.CaptchaGid); - } - - if (result.RequiresTwoFactor) - { - return new TwoFactorStage(Data); - } - - return new LoginErrorStage("Can't proceed login. Bad TwoFactor code", webResponse, this); - } -} - -internal class EmailAuthStage : LoginStage -{ - internal EmailAuthStage(Dictionary data) : base(data) - { - } - - public async Task Proceed(HttpClient client, string emailCode, - CancellationToken cancellationToken = default) - { - Data["emailauth"] = emailCode; - var webResponse = await LoginRequest(client, cancellationToken); - var result = await ConvertJson(webResponse); - - if (CheckIfLoginCompleted(result)) - { - return await CompleteLogin(webResponse); - } - - if (result.CaptchaNeeded) - { - return new CaptchaNeededStage(Data, result.CaptchaGid); - } - - if (result.EmailAuthNeeded) - { - return new EmailAuthStage(Data); - } - - - return new LoginErrorStage("Can't proceed login. Bad Email code", webResponse, this); - } -} - -internal class CaptchaNeededStage : LoginStage -{ - internal Uri CaptchaImage { get; } - - public CaptchaNeededStage(Dictionary data, string captchaGid) : base(data) - { - captchaGid = Uri.EscapeDataString(captchaGid); - Data["captchagid"] = captchaGid; - CaptchaImage = new Uri("https://steamcommunity.com/login/rendercaptcha?gid=" + captchaGid); - } - - /// - /// - /// - /// - /// - /// or - public async Task Proceed(HttpClient client, string captchaText, - CancellationToken cancellationToken = default) - { - Data["captcha_text"] = captchaText; - //When captcha required we need to do login from start - - var rsaStage = new GetRsaStage(Data); - var res = await rsaStage.Proceed(client, cancellationToken); - - return res; - } -} - -internal class LoginSuccessStage : LoginStage -{ - public TransferParameters TransferParameters { get; } - - public LoginSuccessStage(TransferParameters transferParameters) - { - TransferParameters = transferParameters; - } -} \ No newline at end of file diff --git a/SteamLibForked/Authentication/Default/NullLoginConsumer.cs b/SteamLibForked/Authentication/Default/NullLoginConsumer.cs deleted file mode 100644 index 0d23b9f..0000000 --- a/SteamLibForked/Authentication/Default/NullLoginConsumer.cs +++ /dev/null @@ -1,8 +0,0 @@ -using SteamLib.Core.Interfaces; - -namespace SteamLib.Login.Default; - -internal class NullLoginConsumer : ILoginConsumer -{ - public string FriendlyName { get; } = "null"; -} \ No newline at end of file diff --git a/SteamLibForked/Authentication/Default/RsaKeyJson.cs b/SteamLibForked/Authentication/Default/RsaKeyJson.cs deleted file mode 100644 index aea1a0a..0000000 --- a/SteamLibForked/Authentication/Default/RsaKeyJson.cs +++ /dev/null @@ -1,17 +0,0 @@ -// ReSharper disable InconsistentNaming -// ReSharper disable IdentifierTypo - -#pragma warning disable CS8618 - -namespace SteamLib.Login.Default; - -/// -/// Class to Deserialize the json response strings of the getResKey request/> -/// -internal class RsaKeyJson -{ - public bool success { get; set; } - public string publickey_mod { get; set; } - public string publickey_exp { get; set; } - public string timestamp { get; set; } -} \ No newline at end of file diff --git a/SteamLibForked/Authentication/LoginV2/LoginV2Executor.cs b/SteamLibForked/Authentication/LoginV2/LoginV2Executor.cs deleted file mode 100644 index 1582f2e..0000000 --- a/SteamLibForked/Authentication/LoginV2/LoginV2Executor.cs +++ /dev/null @@ -1,254 +0,0 @@ -using AchiesUtilities.Web.Extensions; -using Microsoft.Extensions.Logging; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using SteamLib.Account; -using SteamLib.Core; -using SteamLib.Core.Enums; -using SteamLib.Core.Interfaces; -using SteamLib.Core.Models; -using SteamLib.Core.StatusCodes; -using SteamLib.Exceptions; -using SteamLib.Login.Default; -using SteamLib.ProtoCore; -using SteamLib.ProtoCore.Enums; -using SteamLib.ProtoCore.Exceptions; -using SteamLib.ProtoCore.Services; -using SteamLib.Utility; -using SteamLib.Web; - -namespace SteamLib.Authentication.LoginV2; - -public class LoginV2Executor -{ - public static ILoginConsumer NullConsumer { get; } = new NullLoginConsumer(); - public ILoginConsumer Caller { get; } - public HttpClient HttpClient { get; } - public ILogger? Logger { get; init; } - public IEmailProvider? EmailAuthProvider { get; init; } - public ICaptchaResolver? CaptchaResolver { get; init; } - public ISteamGuardProvider? SteamGuardProvider { get; init; } - public string WebsiteId { get; init; } - public DeviceDetails DeviceDetails { get; init; } - - private LoginV2Executor(LoginV2ExecutorOptions options) - { - Caller = options.Consumer; - HttpClient = options.HttpClient; - Logger = options.Logger; - EmailAuthProvider = options.EmailAuthProvider; - SteamGuardProvider = options.SteamGuardProvider; - WebsiteId = options.GetWebsiteIdOrDefault(); - DeviceDetails = options.DeviceDetails ?? DeviceDetails.CreateDefault(); - } - - - /// - /// Do log in on SteamCommunity.
- /// Some functions require proper SessionId. But contains only SteamCommunity related - /// SessionId and some functions on other services may not work - ///
- /// - /// - /// - /// - /// or depending on which token type is returned - /// - /// - /// - /// - public static async Task DoLogin(LoginV2ExecutorOptions options, string username, string password, - CancellationToken cancellationToken = default) //TODO: logs - { - var executor = new LoginV2Executor(options); - var client = executor.HttpClient; - - var sessionId = await SteamWebApi.GetLoginSessionId(client, cancellationToken); - var rsgMsg = new GetPasswordRSAPublicKey_Request - { - AccountName = username - }; - var rsaResp = await client.GetProto( - "https://api.steampowered.com/IAuthenticationService/GetPasswordRSAPublicKey/v1", rsgMsg, - cancellationToken); - - - var encodedPassword = - EncryptionHelper.ToBase64EncryptedPassword(rsaResp.PublickKeyExp, rsaResp.PublickKeyMod, password); - - - var beginAuthMsg = new BeginAuthSessionViaCredentials_Request - { - DeviceFriendlyName = string.Empty, - AccountName = username, - EncryptedPassword = encodedPassword, - EncryptionTimestamp = rsaResp.Timestamp, - RememberLogin = true, - PlatformType = executor.DeviceDetails.PlatformType, - Persistence = 1, - WebsiteId = executor.WebsiteId, - DeviceDetails = executor.DeviceDetails - }; - - BeginAuthSessionViaCredentials_Response beginAuthResp; - try - { - beginAuthResp = await client.PostProto( - "https://api.steampowered.com/IAuthenticationService/BeginAuthSessionViaCredentials/v1", beginAuthMsg, - cancellationToken); - } - catch (EResultException ex) - when (ex.Result == EResult.InvalidPassword) - { - throw new LoginException(LoginError.InvalidCredentials); - } - - - var clientId = beginAuthResp.ClientId; - var steamId = (long) beginAuthResp.Steamid; - - var conf = beginAuthResp.AllowedConfirmations.FirstOrDefault(c => - c.ConfirmationType is EAuthSessionGuardType.EmailCode or EAuthSessionGuardType.DeviceCode); - - conf ??= beginAuthResp.AllowedConfirmations.FirstOrDefault(); - - switch (conf?.ConfirmationType) - { - case EAuthSessionGuardType.None: - break; - case EAuthSessionGuardType.DeviceCode: - case EAuthSessionGuardType.EmailCode: - await UpdateWithCode(executor, clientId, (ulong) steamId, conf.ConfirmationType); - break; - case EAuthSessionGuardType.Unknown: - case EAuthSessionGuardType.DeviceConfirmation: - case EAuthSessionGuardType.EmailConfirmation: - case EAuthSessionGuardType.MachineToken: - case EAuthSessionGuardType.LegacyMachineAuth: - throw new NotSupportedException( - $"Auth confirmation type of {conf.ConfirmationType} is not implemented yet"); - default: - throw new ArgumentOutOfRangeException(nameof(conf.ConfirmationType), conf?.ConfirmationType, - "Unknown confirmation type or null"); - } - - var pollSessionMsg = new PollAuthSessionStatus_Request - { - ClientId = clientId, - RequestId = beginAuthResp.RequestId - }; - - var pollResp = - await client.PostProto( - "https://api.steampowered.com/IAuthenticationService/PollAuthSessionStatus/v1", pollSessionMsg, - cancellationToken); - - SteamAuthToken refreshToken; - try - { - refreshToken = SteamTokenHelper.Parse(pollResp.RefreshToken); - if (refreshToken.Type is not (SteamAccessTokenType.Refresh or SteamAccessTokenType.MobileRefresh)) - throw new ArgumentException( - "Refresh token must be of type Refresh or MobileRefresh. No 'renew' audience found in JWT.", - nameof(pollResp.RefreshToken)); //Argument exception for less code - } - catch (ArgumentException ex) - { - throw new LoginException(null, - "Steam returned invalid refresh token or it's schema was unsupported. See inner exception for more details", - LoginError.UndefinedError, ex); - } - - var data = new Dictionary - { - {"nonce", pollResp.RefreshToken}, - {"sessionid", sessionId} - }; - - var finalize = await client.PostAsync("https://login.steampowered.com/jwt/finalizelogin", - new FormUrlEncodedContent(data), cancellationToken); - var finalizeContent = await finalize.EnsureSuccessStatusCode().Content.ReadAsStringAsync(cancellationToken); - - var finalizeResp = - SteamLibErrorMonitor.HandleResponse(finalizeContent, - () => JsonConvert.DeserializeObject(finalizeContent)!); - - - List tokens = new(); - foreach (var transferInfo in finalizeResp.TransferInfo) - { - var transferData = new Dictionary - { - {"nonce", transferInfo.TransferInfoParams.Nonce}, - {"auth", transferInfo.TransferInfoParams.Auth}, - {"steamID", steamId.ToString()} - }; - - - try - { - var req = new HttpRequestMessage(HttpMethod.Post, transferInfo.Url); - req.Content = new FormUrlEncodedContent(transferData); - req.Headers.Referrer = SteamDomains.GetDomainUri(SteamDomain.Store); - var transferResp = await client.SendAsync(req, cancellationToken); - var transferContent = await transferResp.ReadAsStringEnsureSuccessAsync(cancellationToken); - var status = JObject.Parse(transferContent); - var result = status["result"]?.Value(); - if (result != null) - SteamStatusCode - .ValidateSuccessOrThrow(result - .Value); //TODO: Fix steam.tv token transfer (result always 8). But who really cares.. - - var tokenStr = SteamTokenHelper.ExtractJwtFromSetCookiesHeader(transferResp.Headers); - var token = SteamTokenHelper.Parse(tokenStr); - tokens.Add(token); - } - catch (Exception ex) - { - executor.Logger?.Log(LogLevel.Warning, ex, "Can't transfer tokens for URI: {uri}", transferInfo.Url); - } - } - - var accessToken = SteamTokenHelper.Parse(pollResp.AccessToken); - - if (accessToken.Type == SteamAccessTokenType.Mobile) - { - return new MobileSessionData(sessionId, SteamId.FromSteam64(steamId), refreshToken, accessToken, tokens); - } - - return new SessionData(sessionId, SteamId.FromSteam64(steamId), refreshToken, tokens); - } - - private static async Task UpdateWithCode(LoginV2Executor executor, ulong clientId, ulong steamId, - EAuthSessionGuardType guardType) - { - string? code; - if (guardType == EAuthSessionGuardType.DeviceCode) - { - if (executor.SteamGuardProvider != null) - code = await executor.SteamGuardProvider.GetSteamGuardCode(executor.Caller); - else - { - throw new LoginException(LoginError.SteamGuardRequired); - } - } - else - { - var t = executor.EmailAuthProvider?.GetEmailAuthCode(executor.Caller) ?? - throw new LoginException(LoginError.EmailAuthRequired); - code = await t; - } - - var updateCodeMsg = new UpdateAuthSessionWithSteamGuardCode_Request - { - ClientId = clientId, - Code = code, - CodeType = guardType, - Steamid = steamId - }; - - await executor.HttpClient.PostProtoEnsureSuccess( - new Uri("https://api.steampowered.com/IAuthenticationService/UpdateAuthSessionWithSteamGuardCode/v1"), - updateCodeMsg); - } -} \ No newline at end of file diff --git a/SteamLibForked/Core/Enums/Country.cs b/SteamLibForked/Core/Enums/Country.cs deleted file mode 100644 index 737e437..0000000 --- a/SteamLibForked/Core/Enums/Country.cs +++ /dev/null @@ -1,757 +0,0 @@ -// ReSharper disable All - -using System.Collections.Generic; -using System.Collections.ObjectModel; - -namespace SteamLib.Core.Enums; - -public enum Country -{ - Afghanistan, - Aland_Islands, - Albania, - Algeria, - American_Samoa, - Andorra, - Angola, - Anguilla, - Antigua_and_Barbuda, - Argentina, - Armenia, - Aruba, - Australia, - Austria, - Azerbaijan, - Bahamas, - Bahrain, - Bangladesh, - Barbados, - Belarus, - Belgium, - Belize, - Bhutan, - Bolivia, - Bosnia_and_Herzegovina, - Botswana, - Brazil, - Brunei_Darussalam, - Bulgaria, - Burundi, - Cambodia, - Cameroon, - Canada, - Cape_Verde, - Cayman_Islands, - Chad, - Chile, - China, - Colombia, - Congo, - Costa_Rica, - Cote_d_Ivoire, - Croatia, - Cyprus, - Czech_Republic, - Denmark, - Dominica, - Dominican_Republic, - Ecuador, - Egypt, - El_Salvador, - Estonia, - Eswatini, - Ethiopia, - Faroe_Islands, - Finland, - France, - French_Guiana, - French_Polynesia, - Gabon, - Georgia, - Germany, - Ghana, - Gibraltar, - Greece, - Greenland, - Grenada, - Guadeloupe, - Guam, - Guatemala, - Guernsey, - Guyana, - Haiti, - Honduras, - Hong_Kong, - Hungary, - Iceland, - India, - Indonesia, - Iran, - Iraq, - Ireland, - Isle_of_Man, - Israel, - Italy, - Jamaica, - Japan, - Jersey, - Jordan, - Kazakhstan, - Kenya, - Korea, - Kuwait, - Kyrgyzstan, - Laos, - Latvia, - Lebanon, - Libya, - Liechtenstein, - Lithuania, - Luxembourg, - Macau, - Macedonia, - Madagascar, - Malaysia, - Maldives, - Mali, - Malta, - Martinique, - Mauritius, - Mayotte, - Mexico, - Moldova, - Monaco, - Mongolia, - Montenegro, - Morocco, - Mozambique, - Myanmar, - Namibia, - Nepal, - Netherlands, - New_Zealand, - Nicaragua, - Nigeria, - Northern_Mariana_Islands, - Norway, - Oman, - Pakistan, - Palestinian_Territory, - Panama, - Papua_New_Guinea, - Paraguay, - Peru, - Philippines, - Poland, - Portugal, - Puerto_Rico, - Qatar, - Reunion, - Romania, - Russian_Federation, - Rwanda, - Saint_Kitts_and_Nevis, - Saint_Lucia, - Saint_Vincent_and_the_Grenadines, - Saudi_Arabia, - Senegal, - Serbia, - Seychelles, - Singapore, - Slovakia, - Slovenia, - South_Africa, - Spain, - Sri_Lanka, - Sudan, - Suriname, - Sweden, - Switzerland, - Taiwan, - Tajikistan, - Tanzania, - Thailand, - Togo, - Trinidad_and_Tobago, - Tunisia, - Turkey, - Turkmenistan, - Turks_and_Caicos_Islands, - Uganda, - Ukraine, - United_Arab_Emirates, - United_Kingdom, - United_States, - Uruguay, - Uzbekistan, - Venezuela, - Viet_Nam, - Virgin_Islands, - Yemen, - Zambia, - Zimbabwe -} - -public static class CountryResolver -{ - public static IReadOnlyDictionary ResolveByCountryCode = new ReadOnlyDictionary( - new Dictionary() - { - {"US", Country.United_States}, - {"CA", Country.Canada}, - {"AF", Country.Afghanistan}, - {"AX", Country.Aland_Islands}, - {"AL", Country.Albania}, - {"DZ", Country.Algeria}, - {"AS", Country.American_Samoa}, - {"AD", Country.Andorra}, - {"AO", Country.Angola}, - {"AI", Country.Anguilla}, - {"AG", Country.Antigua_and_Barbuda}, - {"AR", Country.Argentina}, - {"AM", Country.Armenia}, - {"AW", Country.Aruba}, - {"AU", Country.Australia}, - {"AT", Country.Austria}, - {"AZ", Country.Azerbaijan}, - {"BS", Country.Bahamas}, - {"BH", Country.Bahrain}, - {"BD", Country.Bangladesh}, - {"BB", Country.Barbados}, - {"BY", Country.Belarus}, - {"BE", Country.Belgium}, - {"BZ", Country.Belize}, - {"BT", Country.Bhutan}, - {"BO", Country.Bolivia}, - {"BA", Country.Bosnia_and_Herzegovina}, - {"BW", Country.Botswana}, - {"BR", Country.Brazil}, - {"BN", Country.Brunei_Darussalam}, - {"BG", Country.Bulgaria}, - {"BI", Country.Burundi}, - {"KH", Country.Cambodia}, - {"CM", Country.Cameroon}, - {"CV", Country.Cape_Verde}, - {"KY", Country.Cayman_Islands}, - {"TD", Country.Chad}, - {"CL", Country.Chile}, - {"CN", Country.China}, - {"CO", Country.Colombia}, - {"CD", Country.Congo}, - {"CR", Country.Costa_Rica}, - {"CI", Country.Cote_d_Ivoire}, - {"HR", Country.Croatia}, - {"CY", Country.Cyprus}, - {"CZ", Country.Czech_Republic}, - {"DK", Country.Denmark}, - {"DM", Country.Dominica}, - {"DO", Country.Dominican_Republic}, - {"EC", Country.Ecuador}, - {"EG", Country.Egypt}, - {"SV", Country.El_Salvador}, - {"EE", Country.Estonia}, - {"ET", Country.Ethiopia}, - {"FO", Country.Faroe_Islands}, - {"FI", Country.Finland}, - {"FR", Country.France}, - {"GF", Country.French_Guiana}, - {"PF", Country.French_Polynesia}, - {"GA", Country.Gabon}, - {"GE", Country.Georgia}, - {"DE", Country.Germany}, - {"GH", Country.Ghana}, - {"GI", Country.Gibraltar}, - {"GR", Country.Greece}, - {"GL", Country.Greenland}, - {"GD", Country.Grenada}, - {"GP", Country.Guadeloupe}, - {"GU", Country.Guam}, - {"GT", Country.Guatemala}, - {"GG", Country.Guernsey}, - {"GY", Country.Guyana}, - {"HT", Country.Haiti}, - {"HN", Country.Honduras}, - {"HK", Country.Hong_Kong}, - {"HU", Country.Hungary}, - {"IS", Country.Iceland}, - {"IN", Country.India}, - {"ID", Country.Indonesia}, - {"IQ", Country.Iraq}, - {"IE", Country.Ireland}, - {"IR", Country.Iran}, - {"IM", Country.Isle_of_Man}, - {"IL", Country.Israel}, - {"IT", Country.Italy}, - {"JM", Country.Jamaica}, - {"JP", Country.Japan}, - {"JE", Country.Jersey}, - {"JO", Country.Jordan}, - {"KZ", Country.Kazakhstan}, - {"KE", Country.Kenya}, - {"KR", Country.Korea}, - {"KW", Country.Kuwait}, - {"KG", Country.Kyrgyzstan}, - {"LA", Country.Laos}, - {"LV", Country.Latvia}, - {"LB", Country.Lebanon}, - {"LY", Country.Libya}, - {"LI", Country.Liechtenstein}, - {"LT", Country.Lithuania}, - {"LU", Country.Luxembourg}, - {"MO", Country.Macau}, - {"MK", Country.Macedonia}, - {"MG", Country.Madagascar}, - {"MY", Country.Malaysia}, - {"MV", Country.Maldives}, - {"ML", Country.Mali}, - {"MT", Country.Malta}, - {"MQ", Country.Martinique}, - {"MU", Country.Mauritius}, - {"YT", Country.Mayotte}, - {"MX", Country.Mexico}, - {"MD", Country.Moldova}, - {"MC", Country.Monaco}, - {"MN", Country.Mongolia}, - {"ME", Country.Montenegro}, - {"MA", Country.Morocco}, - {"MZ", Country.Mozambique}, - {"MM", Country.Myanmar}, - {"NA", Country.Namibia}, - {"NP", Country.Nepal}, - {"NL", Country.Netherlands}, - {"NZ", Country.New_Zealand}, - {"NI", Country.Nicaragua}, - {"NG", Country.Nigeria}, - {"MP", Country.Northern_Mariana_Islands}, - {"NO", Country.Norway}, - {"OM", Country.Oman}, - {"PK", Country.Pakistan}, - {"PS", Country.Palestinian_Territory}, - {"PA", Country.Panama}, - {"PG", Country.Papua_New_Guinea}, - {"PY", Country.Paraguay}, - {"PE", Country.Peru}, - {"PH", Country.Philippines}, - {"PL", Country.Poland}, - {"PT", Country.Portugal}, - {"PR", Country.Puerto_Rico}, - {"QA", Country.Qatar}, - {"RE", Country.Reunion}, - {"RO", Country.Romania}, - {"RU", Country.Russian_Federation}, - {"RW", Country.Rwanda}, - {"LC", Country.Saint_Lucia}, - {"SA", Country.Saudi_Arabia}, - {"SN", Country.Senegal}, - {"RS", Country.Serbia}, - {"SC", Country.Seychelles}, - {"SG", Country.Singapore}, - {"SK", Country.Slovakia}, - {"SI", Country.Slovenia}, - {"ZA", Country.South_Africa}, - {"ES", Country.Spain}, - {"LK", Country.Sri_Lanka}, - {"KN", Country.Saint_Kitts_and_Nevis}, - {"PM", Country.Saint_Vincent_and_the_Grenadines}, - {"SD", Country.Sudan}, - {"SR", Country.Suriname}, - {"SE", Country.Sweden}, - {"CH", Country.Switzerland}, - {"TW", Country.Taiwan}, - {"TJ", Country.Tajikistan}, - {"TZ", Country.Tanzania}, - {"TH", Country.Thailand}, - {"TG", Country.Togo}, - {"TT", Country.Trinidad_and_Tobago}, - {"TN", Country.Tunisia}, - {"TR", Country.Turkey}, - {"TM", Country.Turkmenistan}, - {"TC", Country.Turks_and_Caicos_Islands}, - {"UG", Country.Uganda}, - {"UA", Country.Ukraine}, - {"GB", Country.United_Kingdom}, - {"VI", Country.Virgin_Islands}, - {"AE", Country.United_Arab_Emirates}, - {"UY", Country.Uruguay}, - {"UZ", Country.Uzbekistan}, - {"VE", Country.Venezuela}, - {"VN", Country.Viet_Nam}, - {"YE", Country.Yemen}, - {"ZM", Country.Zambia}, - {"ZW", Country.Zimbabwe} - }); - - public static IReadOnlyDictionary ResolveString { get; } = new Dictionary - { - {Country.Afghanistan, "Afghanistan"}, - {Country.Aland_Islands, "Aland Islands"}, - {Country.Albania, "Albania"}, - {Country.Algeria, "Algeria"}, - {Country.American_Samoa, "American Samoa"}, - {Country.Andorra, "Andorra"}, - {Country.Angola, "Angola"}, - {Country.Anguilla, "Anguilla"}, - {Country.Antigua_and_Barbuda, "Antigua and Barbuda"}, - {Country.Argentina, "Argentina"}, - {Country.Armenia, "Armenia"}, - {Country.Aruba, "Aruba"}, - {Country.Australia, "Australia"}, - {Country.Austria, "Austria"}, - {Country.Azerbaijan, "Azerbaijan"}, - {Country.Bahamas, "Bahamas"}, - {Country.Bahrain, "Bahrain"}, - {Country.Bangladesh, "Bangladesh"}, - {Country.Barbados, "Barbados"}, - {Country.Belarus, "Belarus"}, - {Country.Belgium, "Belgium"}, - {Country.Belize, "Belize"}, - {Country.Bhutan, "Bhutan"}, - {Country.Bolivia, "Bolivia"}, - {Country.Bosnia_and_Herzegovina, "Bosnia and Herzegovina"}, - {Country.Botswana, "Botswana"}, - {Country.Brazil, "Brazil"}, - {Country.Brunei_Darussalam, "Brunei Darussalam"}, - {Country.Bulgaria, "Bulgaria"}, - {Country.Burundi, "Burundi"}, - {Country.Cambodia, "Cambodia"}, - {Country.Cameroon, "Cameroon"}, - {Country.Canada, "Canada"}, - {Country.Cape_Verde, "Cape Verde"}, - {Country.Cayman_Islands, "Cayman Islands"}, - {Country.Chad, "Chad"}, - {Country.Chile, "Chile"}, - {Country.China, "China"}, - {Country.Colombia, "Colombia"}, - {Country.Congo, "Congo, the Democratic Republic of the"}, - {Country.Costa_Rica, "Costa Rica"}, - {Country.Cote_d_Ivoire, "Cote d'Ivoire"}, - {Country.Croatia, "Croatia"}, - {Country.Cyprus, "Cyprus"}, - {Country.Czech_Republic, "Czech Republic"}, - {Country.Denmark, "Denmark"}, - {Country.Dominica, "Dominica"}, - {Country.Dominican_Republic, "Dominican Republic"}, - {Country.Ecuador, "Ecuador"}, - {Country.Egypt, "Egypt"}, - {Country.El_Salvador, "El Salvador"}, - {Country.Estonia, "Estonia"}, - {Country.Eswatini, "Eswatini"}, - {Country.Ethiopia, "Ethiopia"}, - {Country.Faroe_Islands, "Faroe Islands"}, - {Country.Finland, "Finland"}, - {Country.France, "France"}, - {Country.French_Guiana, "French Guiana"}, - {Country.French_Polynesia, "French Polynesia"}, - {Country.Gabon, "Gabon"}, - {Country.Georgia, "Georgia"}, - {Country.Germany, "Germany"}, - {Country.Ghana, "Ghana"}, - {Country.Gibraltar, "Gibraltar"}, - {Country.Greece, "Greece"}, - {Country.Greenland, "Greenland"}, - {Country.Grenada, "Grenada"}, - {Country.Guadeloupe, "Guadeloupe"}, - {Country.Guam, "Guam"}, - {Country.Guatemala, "Guatemala"}, - {Country.Guernsey, "Guernsey"}, - {Country.Guyana, "Guyana"}, - {Country.Haiti, "Haiti"}, - {Country.Honduras, "Honduras"}, - {Country.Hong_Kong, "Hong Kong"}, - {Country.Hungary, "Hungary"}, - {Country.Iceland, "Iceland"}, - {Country.India, "India"}, - {Country.Indonesia, "Indonesia"}, - {Country.Iran, "Iran"}, - {Country.Iraq, "Iraq"}, - {Country.Ireland, "Ireland"}, - {Country.Isle_of_Man, "Isle of Man"}, - {Country.Israel, "Israel"}, - {Country.Italy, "Italy"}, - {Country.Jamaica, "Jamaica"}, - {Country.Japan, "Japan"}, - {Country.Jersey, "Jersey"}, - {Country.Jordan, "Jordan"}, - {Country.Kazakhstan, "Kazakhstan"}, - {Country.Kenya, "Kenya"}, - {Country.Korea, "Korea, Republic of"}, - {Country.Kuwait, "Kuwait"}, - {Country.Kyrgyzstan, "Kyrgyzstan"}, - {Country.Laos, "Lao People's Democratic Republic"}, - {Country.Latvia, "Latvia"}, - {Country.Lebanon, "Lebanon"}, - {Country.Libya, "Libya"}, - {Country.Liechtenstein, "Liechtenstein"}, - {Country.Lithuania, "Lithuania"}, - {Country.Luxembourg, "Luxembourg"}, - {Country.Macau, "Macau"}, - {Country.Macedonia, "Macedonia, the former Yugoslav Republic of"}, - {Country.Madagascar, "Madagascar"}, - {Country.Malaysia, "Malaysia"}, - {Country.Maldives, "Maldives"}, - {Country.Mali, "Mali"}, - {Country.Malta, "Malta"}, - {Country.Martinique, "Martinique"}, - {Country.Mauritius, "Mauritius"}, - {Country.Mayotte, "Mayotte"}, - {Country.Mexico, "Mexico"}, - {Country.Moldova, "Moldova, Republic of"}, - {Country.Monaco, "Monaco"}, - {Country.Mongolia, "Mongolia"}, - {Country.Montenegro, "Montenegro"}, - {Country.Morocco, "Morocco"}, - {Country.Mozambique, "Mozambique"}, - {Country.Myanmar, "Myanmar"}, - {Country.Namibia, "Namibia"}, - {Country.Nepal, "Nepal"}, - {Country.Netherlands, "Netherlands"}, - {Country.New_Zealand, "New Zealand"}, - {Country.Nicaragua, "Nicaragua"}, - {Country.Nigeria, "Nigeria"}, - {Country.Northern_Mariana_Islands, "Northern Mariana Islands"}, - {Country.Norway, "Norway"}, - {Country.Oman, "Oman"}, - {Country.Pakistan, "Pakistan"}, - {Country.Palestinian_Territory, "Palestinian Territory, Occupied"}, - {Country.Panama, "Panama"}, - {Country.Papua_New_Guinea, "Papua New Guinea"}, - {Country.Paraguay, "Paraguay"}, - {Country.Peru, "Peru"}, - {Country.Philippines, "Philippines"}, - {Country.Poland, "Poland"}, - {Country.Portugal, "Portugal"}, - {Country.Puerto_Rico, "Puerto Rico"}, - {Country.Qatar, "Qatar"}, - {Country.Reunion, "Reunion"}, - {Country.Romania, "Romania"}, - {Country.Russian_Federation, "Russian Federation"}, - {Country.Rwanda, "Rwanda"}, - {Country.Saint_Kitts_and_Nevis, "Saint Kitts and Nevis"}, - {Country.Saint_Lucia, "Saint Lucia"}, - {Country.Saint_Vincent_and_the_Grenadines, "Saint Vincent and the Grenadines"}, - {Country.Saudi_Arabia, "Saudi Arabia"}, - {Country.Senegal, "Senegal"}, - {Country.Serbia, "Serbia"}, - {Country.Seychelles, "Seychelles"}, - {Country.Singapore, "Singapore"}, - {Country.Slovakia, "Slovakia"}, - {Country.Slovenia, "Slovenia"}, - {Country.South_Africa, "South Africa"}, - {Country.Spain, "Spain"}, - {Country.Sri_Lanka, "Sri Lanka"}, - {Country.Sudan, "Sudan"}, - {Country.Suriname, "Suriname"}, - {Country.Sweden, "Sweden"}, - {Country.Switzerland, "Switzerland"}, - {Country.Taiwan, "Taiwan"}, - {Country.Tajikistan, "Tajikistan"}, - {Country.Tanzania, "Tanzania, United Republic of"}, - {Country.Thailand, "Thailand"}, - {Country.Togo, "Togo"}, - {Country.Trinidad_and_Tobago, "Trinidad and Tobago"}, - {Country.Tunisia, "Tunisia"}, - {Country.Turkey, "Turkey"}, - {Country.Turkmenistan, "Turkmenistan"}, - {Country.Turks_and_Caicos_Islands, "Turks and Caicos Islands"}, - {Country.Uganda, "Uganda"}, - {Country.Ukraine, "Ukraine"}, - {Country.United_Arab_Emirates, "United Arab Emirates"}, - {Country.United_Kingdom, "United Kingdom"}, - {Country.United_States, "United States"}, - {Country.Uruguay, "Uruguay"}, - {Country.Uzbekistan, "Uzbekistan"}, - {Country.Venezuela, "Venezuela"}, - {Country.Viet_Nam, "Viet Nam"}, - {Country.Virgin_Islands, "Virgin Islands, U.S."}, - {Country.Yemen, "Yemen"}, - {Country.Zambia, "Zambia"}, - {Country.Zimbabwe, "Zimbabwe"} - }; - - public static IReadOnlyDictionary ResolveCountry { get; } = new Dictionary() - { - {"Afghanistan", Country.Afghanistan}, - {"Aland Islands", Country.Aland_Islands}, - {"Albania", Country.Albania}, - {"Algeria", Country.Algeria}, - {"American Samoa", Country.American_Samoa}, - {"Andorra", Country.Andorra}, - {"Angola", Country.Angola}, - {"Anguilla", Country.Anguilla}, - {"Antigua and Barbuda", Country.Antigua_and_Barbuda}, - {"Argentina", Country.Argentina}, - {"Armenia", Country.Armenia}, - {"Aruba", Country.Aruba}, - {"Australia", Country.Australia}, - {"Austria", Country.Austria}, - {"Azerbaijan", Country.Azerbaijan}, - {"Bahamas", Country.Bahamas}, - {"Bahrain", Country.Bahrain}, - {"Bangladesh", Country.Bangladesh}, - {"Barbados", Country.Barbados}, - {"Belarus", Country.Belarus}, - {"Belgium", Country.Belgium}, - {"Belize", Country.Belize}, - {"Bhutan", Country.Bhutan}, - {"Bolivia", Country.Bolivia}, - {"Bosnia and Herzegovina", Country.Bosnia_and_Herzegovina}, - {"Botswana", Country.Botswana}, - {"Brazil", Country.Brazil}, - {"Brunei Darussalam", Country.Brunei_Darussalam}, - {"Bulgaria", Country.Bulgaria}, - {"Burundi", Country.Burundi}, - {"Cambodia", Country.Cambodia}, - {"Cameroon", Country.Cameroon}, - {"Canada", Country.Canada}, - {"Cape Verde", Country.Cape_Verde}, - {"Cayman Islands", Country.Cayman_Islands}, - {"Chad", Country.Chad}, - {"Chile", Country.Chile}, - {"China", Country.China}, - {"Colombia", Country.Colombia}, - {"Congo, the Democratic Republic of the", Country.Congo}, - {"Costa Rica", Country.Costa_Rica}, - {"Cote d'Ivoire", Country.Cote_d_Ivoire}, - {"Croatia", Country.Croatia}, - {"Cyprus", Country.Cyprus}, - {"Czech Republic", Country.Czech_Republic}, - {"Denmark", Country.Denmark}, - {"Dominica", Country.Dominica}, - {"Dominican Republic", Country.Dominican_Republic}, - {"Ecuador", Country.Ecuador}, - {"Egypt", Country.Egypt}, - {"El Salvador", Country.El_Salvador}, - {"Estonia", Country.Estonia}, - {"Eswatini", Country.Eswatini}, - {"Ethiopia", Country.Ethiopia}, - {"Faroe Islands", Country.Faroe_Islands}, - {"Finland", Country.Finland}, - {"France", Country.France}, - {"French Guiana", Country.French_Guiana}, - {"French Polynesia", Country.French_Polynesia}, - {"Gabon", Country.Gabon}, - {"Georgia", Country.Georgia}, - {"Germany", Country.Germany}, - {"Ghana", Country.Ghana}, - {"Gibraltar", Country.Gibraltar}, - {"Greece", Country.Greece}, - {"Greenland", Country.Greenland}, - {"Grenada", Country.Grenada}, - {"Guadeloupe", Country.Guadeloupe}, - {"Guam", Country.Guam}, - {"Guatemala", Country.Guatemala}, - {"Guernsey", Country.Guernsey}, - {"Guyana", Country.Guyana}, - {"Haiti", Country.Haiti}, - {"Honduras", Country.Honduras}, - {"Hong Kong", Country.Hong_Kong}, - {"Hungary", Country.Hungary}, - {"Iceland", Country.Iceland}, - {"India", Country.India}, - {"Indonesia", Country.Indonesia}, - {"Iran", Country.Iran}, - {"Iraq", Country.Iraq}, - {"Ireland", Country.Ireland}, - {"Isle of Man", Country.Isle_of_Man}, - {"Israel", Country.Israel}, - {"Italy", Country.Italy}, - {"Jamaica", Country.Jamaica}, - {"Japan", Country.Japan}, - {"Jersey", Country.Jersey}, - {"Jordan", Country.Jordan}, - {"Kazakhstan", Country.Kazakhstan}, - {"Kenya", Country.Kenya}, - {"Korea, Republic of", Country.Korea}, - {"Kuwait", Country.Kuwait}, - {"Kyrgyzstan", Country.Kyrgyzstan}, - {"Lao People's Democratic Republic", Country.Laos}, - {"Latvia", Country.Latvia}, - {"Lebanon", Country.Lebanon}, - {"Libya", Country.Libya}, - {"Liechtenstein", Country.Liechtenstein}, - {"Lithuania", Country.Lithuania}, - {"Luxembourg", Country.Luxembourg}, - {"Macau", Country.Macau}, - {"Macedonia, the former Yugoslav Republic of", Country.Macedonia}, - {"Madagascar", Country.Madagascar}, - {"Malaysia", Country.Malaysia}, - {"Maldives", Country.Maldives}, - {"Mali", Country.Mali}, - {"Malta", Country.Malta}, - {"Martinique", Country.Martinique}, - {"Mauritius", Country.Mauritius}, - {"Mayotte", Country.Mayotte}, - {"Mexico", Country.Mexico}, - {"Moldova, Republic of", Country.Moldova}, - {"Monaco", Country.Monaco}, - {"Mongolia", Country.Mongolia}, - {"Montenegro", Country.Montenegro}, - {"Morocco", Country.Morocco}, - {"Mozambique", Country.Mozambique}, - {"Myanmar", Country.Myanmar}, - {"Namibia", Country.Namibia}, - {"Nepal", Country.Nepal}, - {"Netherlands", Country.Netherlands}, - {"New Zealand", Country.New_Zealand}, - {"Nicaragua", Country.Nicaragua}, - {"Nigeria", Country.Nigeria}, - {"Northern Mariana Islands", Country.Northern_Mariana_Islands}, - {"Norway", Country.Norway}, - {"Oman", Country.Oman}, - {"Pakistan", Country.Pakistan}, - {"Palestinian Territory, Occupied", Country.Palestinian_Territory}, - {"Panama", Country.Panama}, - {"Papua New Guinea", Country.Papua_New_Guinea}, - {"Paraguay", Country.Paraguay}, - {"Peru", Country.Peru}, - {"Philippines", Country.Philippines}, - {"Poland", Country.Poland}, - {"Portugal", Country.Portugal}, - {"Puerto Rico", Country.Puerto_Rico}, - {"Qatar", Country.Qatar}, - {"Reunion", Country.Reunion}, - {"Romania", Country.Romania}, - {"Russian Federation", Country.Russian_Federation}, - {"Rwanda", Country.Rwanda}, - {"Saint Kitts and Nevis", Country.Saint_Kitts_and_Nevis}, - {"Saint Lucia", Country.Saint_Lucia}, - {"Saint Vincent and the Grenadines", Country.Saint_Vincent_and_the_Grenadines}, - {"Saudi Arabia", Country.Saudi_Arabia}, - {"Senegal", Country.Senegal}, - {"Serbia", Country.Serbia}, - {"Seychelles", Country.Seychelles}, - {"Singapore", Country.Singapore}, - {"Slovakia", Country.Slovakia}, - {"Slovenia", Country.Slovenia}, - {"South Africa", Country.South_Africa}, - {"Spain", Country.Spain}, - {"Sri Lanka", Country.Sri_Lanka}, - {"Sudan", Country.Sudan}, - {"Suriname", Country.Suriname}, - {"Sweden", Country.Sweden}, - {"Switzerland", Country.Switzerland}, - {"Taiwan", Country.Taiwan}, - {"Tajikistan", Country.Tajikistan}, - {"Tanzania, United Republic of", Country.Tanzania}, - {"Thailand", Country.Thailand}, - {"Togo", Country.Togo}, - {"Trinidad and Tobago", Country.Trinidad_and_Tobago}, - {"Tunisia", Country.Tunisia}, - {"Turkey", Country.Turkey}, - {"Turkmenistan", Country.Turkmenistan}, - {"Turks and Caicos Islands", Country.Turks_and_Caicos_Islands}, - {"Uganda", Country.Uganda}, - {"Ukraine", Country.Ukraine}, - {"United Arab Emirates", Country.United_Arab_Emirates}, - {"United Kingdom", Country.United_Kingdom}, - {"United States", Country.United_States}, - {"Uruguay", Country.Uruguay}, - {"Uzbekistan", Country.Uzbekistan}, - {"Venezuela", Country.Venezuela}, - {"Viet Nam", Country.Viet_Nam}, - {"Virgin Islands, U.S.", Country.Virgin_Islands}, - {"Yemen", Country.Yemen}, - {"Zambia", Country.Zambia}, - {"Zimbabwe", Country.Zimbabwe} - }; -} \ No newline at end of file diff --git a/SteamLibForked/Core/Enums/Currency.cs b/SteamLibForked/Core/Enums/Currency.cs deleted file mode 100644 index ed7c6e5..0000000 --- a/SteamLibForked/Core/Enums/Currency.cs +++ /dev/null @@ -1,103 +0,0 @@ -// ReSharper disable InconsistentNaming - -namespace SteamLib.Core.Enums; - -public enum Currency -{ - None = 0, - USD = 1, - GBP = 2, - EUR = 3, - CHF = 4, - RUB = 5, - PLN = 6, - BRL = 7, - JPY = 8, - NOK = 9, - IDR = 10, - MYR = 11, - PHP = 12, - SGD = 13, - THB = 14, - VND = 15, - KRW = 16, - TRY = 17, - UAH = 18, - MXN = 19, - CAD = 20, - AUD = 21, - NZD = 22, - CNY = 23, - INR = 24, - CLP = 25, - PEN = 26, - COP = 27, - ZAR = 28, - HKD = 29, - TWD = 30, - SAR = 31, - AED = 32, - ARS = 34, - ILS = 35, - KZT = 37, - KWD = 38, - QAR = 39, - CRC = 40, - UYU = 41 -} - -public static class CurrencyInfo -{ - public static IReadOnlyDictionary CurrencySymbols { get; } = new Dictionary - { - {Currency.USD, "$"}, - {Currency.GBP, "£"}, - {Currency.EUR, "€"}, - {Currency.CHF, "CHF"}, - {Currency.RUB, "pуб."}, - {Currency.PLN, "zł"}, - {Currency.BRL, "R$"}, - {Currency.JPY, "¥"}, - {Currency.NOK, "kr"}, - {Currency.IDR, "Rp"}, - {Currency.MYR, "RM"}, - {Currency.PHP, "P"}, - {Currency.SGD, "S$"}, - {Currency.THB, "฿"}, - {Currency.VND, "₫"}, - {Currency.KRW, "₩"}, - {Currency.TRY, "TL"}, - {Currency.UAH, "₴"}, - {Currency.MXN, "Mex$"}, - {Currency.CAD, "CDN$"}, - {Currency.AUD, "A$"}, - {Currency.NZD, "NZ$"}, - {Currency.CNY, "¥"}, - {Currency.INR, "₹"}, - {Currency.CLP, "CLP$"}, - {Currency.PEN, "S/."}, - {Currency.COP, "COL$"}, - {Currency.ZAR, "R"}, - {Currency.HKD, "HK$"}, - {Currency.TWD, "NT$"}, - {Currency.SAR, "SR"}, - {Currency.AED, "AED"}, - {Currency.ARS, "ARS$"}, - {Currency.ILS, "₪"}, - {Currency.KZT, "₸"}, - {Currency.KWD, "KD"}, - {Currency.QAR, "QR"}, - {Currency.CRC, "₡"}, - {Currency.UYU, "$U"} - }; - - public static int ToInt(this Currency currency) - { - return (int) currency; - } - - public static string ToIntString(this Currency currency) - { - return currency.ToInt().ToString(); - } -} \ No newline at end of file diff --git a/SteamLibForked/Core/Enums/SteamDomain.cs b/SteamLibForked/Core/Enums/SteamDomain.cs deleted file mode 100644 index ea87a28..0000000 --- a/SteamLibForked/Core/Enums/SteamDomain.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace SteamLib.Core.Enums; - -public enum SteamDomain -{ - Undefined = 0, - Community = 1, - Store = 2, - Help = 3, - TV = 4, - Checkout = 5 -} \ No newline at end of file diff --git a/SteamLibForked/Core/Interfaces/ICaptchaResolver.cs b/SteamLibForked/Core/Interfaces/ICaptchaResolver.cs deleted file mode 100644 index a2d75d5..0000000 --- a/SteamLibForked/Core/Interfaces/ICaptchaResolver.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace SteamLib.Core.Interfaces; - -public interface ICaptchaResolver -{ - public Task Resolve(Uri imageUrl, HttpClient client); -} \ No newline at end of file diff --git a/SteamLibForked/Core/Interfaces/IEmailAuthProvider.cs b/SteamLibForked/Core/Interfaces/IEmailAuthProvider.cs deleted file mode 100644 index 6d12ef0..0000000 --- a/SteamLibForked/Core/Interfaces/IEmailAuthProvider.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace SteamLib.Core.Interfaces; - -public enum EmailConfirmationType -{ - AttachPhoneAuthenticator -} - -public interface IEmailProvider -{ - public int MaxRetryCount { get; } - public Task GetEmailAuthCode(ILoginConsumer caller); - public Task GetAddAuthenticatorCode(ILoginConsumer caller); - - public Task ConfirmEmailLink(ILoginConsumer caller, EmailConfirmationType confirmationType); -} \ No newline at end of file diff --git a/SteamLibForked/Core/Interfaces/ILoginConsumer.cs b/SteamLibForked/Core/Interfaces/ILoginConsumer.cs deleted file mode 100644 index 82dacd5..0000000 --- a/SteamLibForked/Core/Interfaces/ILoginConsumer.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace SteamLib.Core.Interfaces; - -public interface ILoginConsumer -{ - public string FriendlyName { get; } -} \ No newline at end of file diff --git a/SteamLibForked/Core/Interfaces/ISteamGuardProvider.cs b/SteamLibForked/Core/Interfaces/ISteamGuardProvider.cs deleted file mode 100644 index dacbb88..0000000 --- a/SteamLibForked/Core/Interfaces/ISteamGuardProvider.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace SteamLib.Core.Interfaces; - -public interface ISteamGuardProvider -{ - public int MaxRetryCount { get; } - public ValueTask GetSteamGuardCode(ILoginConsumer caller); -} \ No newline at end of file diff --git a/SteamLibForked/Core/StatusCodes/SteamStatusCode.cs b/SteamLibForked/Core/StatusCodes/SteamStatusCode.cs deleted file mode 100644 index 3c9cc69..0000000 --- a/SteamLibForked/Core/StatusCodes/SteamStatusCode.cs +++ /dev/null @@ -1,174 +0,0 @@ -using System.Collections.ObjectModel; -using AchiesUtilities.Models; -using SteamLib.Exceptions; -using SteamLib.Utility; - -namespace SteamLib.Core.StatusCodes; - -public partial class SteamStatusCode : Enumeration -{ - public static IReadOnlyDictionary StatusCodes { get; } - - static SteamStatusCode() - { - StatusCodes = - new ReadOnlyDictionary(GetAll() - .ToDictionary(ssc => ssc.Id, ssc => ssc)); - } - - protected SteamStatusCode(int id, string name) : base(id, name) - { - } - - /// - /// Tries to translate status code. If no status code was found with - /// will be thrown - /// - /// - /// - /// - /// - /// if value is universal. if value is - /// specific - /// - /// - public static SteamStatusCode Translate(string response, out bool isUniversal) where T : SteamStatusCode - { - int statusCode; - try - { - statusCode = Utilities.GetSuccessCode(response); - } - catch - { - throw new SteamStatusCodeException(Undefined, response); - } - - return Translate(statusCode, out isUniversal); - } - - - /// - /// Translate to specific or - /// - /// - /// - /// - /// - /// if value is universal. if value is - /// specific - /// - /// - public static SteamStatusCode Translate(int statusCode, out bool isUniversal) where T : SteamStatusCode - { - if (statusCode < 2) - { - var status = StatusCodes[statusCode]; - isUniversal = true; - return status; - } - - var allSpecific = GetAll(); - var translated = allSpecific.FirstOrDefault(s => s.Id == statusCode); - - isUniversal = translated == null; - - if (translated != null) - { - return translated; - } - - if (translated == null && StatusCodes.TryGetValue(statusCode, out var universal)) - { - return universal; - } - - return translated ?? new SteamStatusCode(statusCode, nameof(Unknown)); - } - - - public override bool Equals(object? obj) - { - if (obj is not SteamStatusCode translated) - return false; - - if (Id < 2) - { - return translated.Id == Id; - } - - return base.Equals(translated); - } - - public override int GetHashCode() - { - return base.GetHashCode(); - } - - - /// - /// - /// - /// - public static void ValidateSuccessOrThrow(string response) where T : SteamStatusCode - { - var translated = Translate(response, out _); - if (translated.Id != 1) - throw new SteamStatusCodeException(translated, response); - } - - /// - /// Same as with generic parameter - ///
- /// (Used in case when steam status code is not defined for this operation) - ///
- /// - /// - public static void ValidateSuccessOrThrow(string response) - { - ValidateSuccessOrThrow(response); - } - - /// - /// - /// - /// - public static void ValidateSuccessOrThrow(int statusCode) where T : SteamStatusCode - { - if (statusCode == 1) return; - var translated = Translate(statusCode, out _); - throw new SteamStatusCodeException(translated, statusCode.ToString()); - } - - - /// - /// Same as with generic parameter
- /// (Used in case when steam status code is not defined for this operation) - ///
- /// - /// - public static void ValidateSuccessOrThrow(int statusCode) - { - ValidateSuccessOrThrow(statusCode); - } - - /// - /// Validates that status code is or specific - /// - /// - /// - /// - /// - public static SteamStatusCode TranslateOrThrow(string response, out bool isUniversal) where T : SteamStatusCode - { - var translated = Translate(response, out isUniversal); - if (translated.Id < 1) - throw new SteamStatusCodeException(translated, response); - return translated; - } - - public override string ToString() - { - return $"{Name} ({Id})"; - } -} \ No newline at end of file diff --git a/SteamLibForked/Exceptions/LoginException.cs b/SteamLibForked/Exceptions/LoginException.cs deleted file mode 100644 index 8a39f64..0000000 --- a/SteamLibForked/Exceptions/LoginException.cs +++ /dev/null @@ -1,51 +0,0 @@ -using SteamLib.Core.Interfaces; - -namespace SteamLib.Exceptions; - -public class LoginException : Exception -{ - public LoginError Error { get; } - public string? Response { get; } - - public LoginException(LoginError error) - : base($"Login was unsuccessful. Error {error}") - { - Error = error; - } - - public LoginException(string response) - { - Error = LoginError.UndefinedError; - Response = response; - } - - public LoginException(string? response, string? message, LoginError? error, Exception? innerException) : base( - message, innerException) - { - Response = response; - Error = error ?? LoginError.UndefinedError; - } -} - -public enum LoginError -{ - CaptchaRequired, - InvalidCredentials, - InvalidEmailAuthCode, - InvalidTwoFactorCode, - - /// - /// SteamEmail authentication is required to login but no was provided - /// - EmailAuthRequired, - - /// - /// SteamGuard is required to login but no was provided - /// - SteamGuardRequired, - - /// - /// Some error occurred while trying to login. - /// - UndefinedError -} \ No newline at end of file diff --git a/SteamLibForked/Exceptions/SteamStatusCodeException.cs b/SteamLibForked/Exceptions/SteamStatusCodeException.cs deleted file mode 100644 index fc8199c..0000000 --- a/SteamLibForked/Exceptions/SteamStatusCodeException.cs +++ /dev/null @@ -1,24 +0,0 @@ -using SteamLib.Core.StatusCodes; - -namespace SteamLib.Exceptions; - -public class SteamStatusCodeException : Exception -{ - public SteamStatusCode StatusCode { get; } - public string? Response { get; } - - public SteamStatusCodeException(SteamStatusCode statusCode, string? response, Exception? innerException = null) - : base($"Steam return not successful status code {statusCode}", innerException) - { - StatusCode = statusCode; - Response = response; - } - - public SteamStatusCodeException(string message, SteamStatusCode statusCode, string? response = null, - Exception? innerException = null) - : base(message, innerException) - { - StatusCode = statusCode; - Response = response; - } -} \ No newline at end of file diff --git a/SteamLibForked/ProtoCore/Exceptions/EResutException.cs b/SteamLibForked/ProtoCore/Exceptions/EResutException.cs deleted file mode 100644 index 81dadf4..0000000 --- a/SteamLibForked/ProtoCore/Exceptions/EResutException.cs +++ /dev/null @@ -1,28 +0,0 @@ -using SteamLib.ProtoCore.Enums; - -namespace SteamLib.ProtoCore.Exceptions; - -[Serializable] -public class EResultException : Exception -{ - public EResult Result { get; } - - public EResultException() - { - } - - public EResultException(EResult result) : base("EResult error: " + result) - { - Result = result; - } - - public EResultException(string message, EResult result, Exception inner) : base(message, inner) - { - Result = result; - } - - public EResultException(EResult result, Exception inner) : base("EResult error: " + result, inner) - { - Result = result; - } -} \ No newline at end of file diff --git a/SteamLibForked/ProtoCore/Exceptions/UnknownEResultException.cs b/SteamLibForked/ProtoCore/Exceptions/UnknownEResultException.cs deleted file mode 100644 index 099c2d8..0000000 --- a/SteamLibForked/ProtoCore/Exceptions/UnknownEResultException.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace SteamLib.ProtoCore.Exceptions; - -[Serializable] -public class UnknownEResultException : Exception -{ - public int EResult { get; } - - public UnknownEResultException() - { - } - - public UnknownEResultException(int eResult) : base("Got unknown EResult: " + eResult) - { - EResult = eResult; - } -} \ No newline at end of file diff --git a/SteamLibForked/SteamLibForked.csproj b/SteamLibForked/SteamLibForked.csproj deleted file mode 100644 index 7d959fe..0000000 --- a/SteamLibForked/SteamLibForked.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - net8.0 - enable - enable - - - - - - - - - - - - - - - diff --git a/SteamLibForked/Utility/MafileSerialization/MafileSerializer_Write.cs b/SteamLibForked/Utility/MafileSerialization/MafileSerializer_Write.cs deleted file mode 100644 index 1e346d5..0000000 --- a/SteamLibForked/Utility/MafileSerialization/MafileSerializer_Write.cs +++ /dev/null @@ -1,110 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace SteamLib.Utility.MafileSerialization; - -public partial class MafileSerializer //Write -{ - private const string CREDITS_PROPERTY_NAME = "Credits"; - - public static string Serialize(MobileDataExtended mobileData, Formatting formatting = Formatting.Indented, - bool sign = true, MafileCredits? credits = null) - { - using var w = new StringWriter(); - using var write = new JsonTextWriter(w); - write.Formatting = formatting; - var j = JObject.FromObject(mobileData); - j.Add(SIGNATURE_PROPERTY_NAME, MAFILE_VERSION); - if (sign) - { - credits ??= MafileCredits.Instance; - var obj = JObject.FromObject(credits); - j.Add(CREDITS_PROPERTY_NAME, obj); - } - - j.WriteTo(write); - return w.ToString(); - } - - public static async Task SerializeAsync(MobileDataExtended mobileData, - Formatting formatting = Formatting.Indented, bool sign = true, MafileCredits? credits = null) - { - await using var w = new StringWriter(); - await using var write = new JsonTextWriter(w); - write.Formatting = formatting; - var j = JObject.FromObject(mobileData); - j.Add(SIGNATURE_PROPERTY_NAME, j); - if (sign) - { - credits ??= MafileCredits.Instance; - var obj = JObject.FromObject(credits); - j.Add(CREDITS_PROPERTY_NAME, obj); - } - - - await j.WriteToAsync(write); - return w.ToString(); - } - - public static string SerializeLegacy(MobileData mobileData, Formatting formatting, - Dictionary? additionalProperties = null, bool sign = true, MafileCredits? credits = null) - { - var result = new LegacyMafile - { - SharedSecret = mobileData.SharedSecret, - IdentitySecret = mobileData.IdentitySecret, - DeviceId = mobileData.DeviceId - }; - - if (mobileData is MobileDataExtended ext) - { - result.RevocationCode = ext.RevocationCode ?? string.Empty; - result.AccountName = ext.AccountName; - result.SessionData = ext.SessionData == null - ? null - : new - { - AccessToken = ext.SessionData?.MobileToken?.Token, - steamLoginSecure = ext.SessionData?.MobileToken?.SignedToken, - RefreshToken = ext.SessionData?.RefreshToken.Token, - SteamID = ext.SessionData?.SteamId.Steam64.Id, - SessionID = ext.SessionData?.SessionId - }; - result.ServerTime = ext.ServerTime; - result.SerialNumber = ext.SerialNumber.ToString(); - result.Uri = ext.Uri; - result.TokenGid = ext.TokenGid; - result.Secret1 = ext.Secret1; - result.SteamId = ext.SteamId.Steam64.Id; - } - - - using var w = new StringWriter(); - using var write = new JsonTextWriter(w); - write.Formatting = formatting; - var j = JObject.FromObject(result); - if (additionalProperties != null) - { - foreach (var (name, value) in additionalProperties) - { - JToken? jToken = null; - if (value != null) - { - jToken = JToken.FromObject(value); - } - - j.Add(name, jToken); - } - } - - if (sign) - { - credits ??= MafileCredits.Instance; - var obj = JObject.FromObject(credits); - j.Add(CREDITS_PROPERTY_NAME, obj); - } - - j.WriteTo(write); - return w.ToString(); - } -} \ No newline at end of file diff --git a/SteamLibForked/Web/Converters/StringToLongIfNeededConverter.cs b/SteamLibForked/Web/Converters/StringToLongIfNeededConverter.cs deleted file mode 100644 index 0f06f41..0000000 --- a/SteamLibForked/Web/Converters/StringToLongIfNeededConverter.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Newtonsoft.Json; - -namespace SteamLib.Web.Converters; - -public class StringToLongIfNeededConverter : JsonConverter -{ - public override void WriteJson(JsonWriter writer, string? value, JsonSerializer serializer) - { - writer.WriteValue(value); - } - - public override string ReadJson(JsonReader reader, Type objectType, string? existingValue, bool hasExistingValue, - JsonSerializer serializer) - { - return reader.Value?.ToString() ?? "null"; - } -} \ No newline at end of file diff --git a/SteamLibForked/Web/Models/GlobalMarketInfo/GlobalInfoModel.cs b/SteamLibForked/Web/Models/GlobalMarketInfo/GlobalInfoModel.cs deleted file mode 100644 index d0da1cf..0000000 --- a/SteamLibForked/Web/Models/GlobalMarketInfo/GlobalInfoModel.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using JetBrains.Annotations; - -#pragma warning disable CS8618 - -namespace SteamLib.Web.Models.GlobalMarketInfo; - -[PublicAPI] -public class GlobalInfoModel -{ - [MemberNotNullWhen(true, nameof(SteamId))] - public bool IsLoggedIn { get; set; } - - /// - /// if is or wallet doesn't exist - /// - public MarketWalletSchema? WalletInfo { get; set; } - - public bool RequiresBillingInfo { get; set; } - public bool HasBillingStates { get; set; } - public string CountryCode { get; set; } - public string Language { get; set; } - public long? SteamId { get; set; } - public string SessionId { get; set; } -} \ No newline at end of file diff --git a/SteamLibForked/Web/Models/GlobalMarketInfo/MarketWalletSchema.cs b/SteamLibForked/Web/Models/GlobalMarketInfo/MarketWalletSchema.cs deleted file mode 100644 index 617707c..0000000 --- a/SteamLibForked/Web/Models/GlobalMarketInfo/MarketWalletSchema.cs +++ /dev/null @@ -1,56 +0,0 @@ -using AchiesUtilities.Newtonsoft.JSON.Converters.Common; -using Newtonsoft.Json; -using SteamLib.Core.Enums; - -#pragma warning disable CS8618 - -namespace SteamLib.Web.Models.GlobalMarketInfo; - -public class MarketWalletSchema -{ - [JsonProperty("wallet_currency")] public Currency WalletCurrency { get; set; } - - [JsonProperty("wallet_country")] public string WalletCountry { get; set; } - - [JsonProperty("wallet_state")] public string WalletState { get; set; } - - [JsonProperty("wallet_fee")] - [JsonConverter(typeof(IntToStringConverter))] - public int WalletFee { get; set; } - - [JsonProperty("wallet_fee_minimum")] - [JsonConverter(typeof(IntToStringConverter))] - public int WalletFeeMinimum { get; set; } - - [JsonProperty("wallet_fee_percent")] - [JsonConverter(typeof(DecimalToStringConverter))] - public decimal WalletFeePercent { get; set; } - - [JsonProperty("wallet_publisher_fee_percent_default")] - [JsonConverter(typeof(DecimalToStringConverter))] - public decimal WalletPublisherFeePercentDefault { get; set; } - - [JsonProperty("wallet_fee_base")] - [JsonConverter(typeof(IntToStringConverter))] - public int WalletFeeBase { get; set; } - - [JsonProperty("wallet_balance")] - [JsonConverter(typeof(LongToStringConverter))] - public long WalletBalance { get; set; } - - [JsonProperty("wallet_delayed_balance")] - [JsonConverter(typeof(LongToStringConverter))] - public long WalletDelayedBalance { get; set; } - - [JsonProperty("wallet_max_balance")] - [JsonConverter(typeof(LongToStringConverter))] - public long WalletMaxBalance { get; set; } - - [JsonProperty("wallet_trade_max_balance")] - [JsonConverter(typeof(LongToStringConverter))] - public long WalletTradeMaxBalance { get; set; } - - [JsonProperty("success")] public int Success { get; set; } - - [JsonProperty("rwgrsn")] public int Rwgrsn { get; set; } -} \ No newline at end of file diff --git a/SteamLibForked/Web/Scrappers/HTML/MarketGlobalInfoScrapper.cs b/SteamLibForked/Web/Scrappers/HTML/MarketGlobalInfoScrapper.cs deleted file mode 100644 index 5634c33..0000000 --- a/SteamLibForked/Web/Scrappers/HTML/MarketGlobalInfoScrapper.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System.Text.RegularExpressions; -using HtmlAgilityPack; -using Newtonsoft.Json; -using SteamLib.Web.Models.GlobalMarketInfo; - -namespace SteamLib.Web.Scrappers.HTML; - -public static class MarketGlobalInfoScrapper -{ - private static readonly Regex LoggedInRegex = new("var g_bLoggedIn = (.+);", RegexOptions.Compiled); - - private static readonly Regex ReqBillingInfoRegex = - new("var g_bRequiresBillingInfo = (.+);", RegexOptions.Compiled); - - private static readonly Regex CountryCodeRegex = new("var g_strCountryCode = \"(.+)\";", RegexOptions.Compiled); - private static readonly Regex HasBillingStates = new("var g_bHasBillingStates = (.+);", RegexOptions.Compiled); - private static readonly Regex LanguageRegex = new("var g_strLanguage = \"(.+)\";", RegexOptions.Compiled); - private static readonly Regex WalletInfoRegex = new("var g_rgWalletInfo = (.+);", RegexOptions.Compiled); - - private static readonly Regex SessionIdRegex = new("g_sessionID = \"(.+)\";", RegexOptions.Compiled); - private static readonly Regex SteamIdRegex = new("g_steamID = \"(.+)\";", RegexOptions.Compiled); - - public static GlobalInfoModel Scrap(string html) - { - var document = new HtmlDocument(); - document.LoadHtml(html); - - var scriptNodes = document.DocumentNode.SelectNodes("//*[@id=\"responsive_page_template_content\"]/script"); - var index = scriptNodes.Count > 2 - ? 1 - : 0; //If account is limited or market unavailable elements will be displaced - - var scriptNode = scriptNodes[index]; - var script = scriptNode.InnerText!; - - var logged = GetBool(script, LoggedInRegex); - var hasBillingStates = GetBool(script, HasBillingStates); - var reqBillingInfo = GetBool(script, ReqBillingInfoRegex); - - var country = CountryCodeRegex.Match(html).Groups[1].Value; - var language = LanguageRegex.Match(html).Groups[1].Value; - - - var walletInfoStr = WalletInfoRegex.Match(html).Groups[1].Value; - MarketWalletSchema? wallet = null; - - var sessionScriptNode = - document.DocumentNode.SelectSingleNode("//div[@class='responsive_page_content']/script"); - var sessionScript = sessionScriptNode.InnerText!; - - var sessionId = SessionIdRegex.Match(sessionScript).Groups[1].Value; - long? steamId = null; - - - if (logged) - { - wallet = JsonConvert.DeserializeObject(walletInfoStr); - var steamIdStr = SteamIdRegex.Match(sessionScript).Groups[1].Value; - steamId = long.Parse(new string(steamIdStr.Where(char.IsDigit).ToArray())); - } - - - return new GlobalInfoModel - { - CountryCode = country, - HasBillingStates = hasBillingStates, - IsLoggedIn = logged, - Language = language, - RequiresBillingInfo = reqBillingInfo, - WalletInfo = wallet, - SessionId = sessionId, - SteamId = steamId - }; - } - - private static bool GetBool(string script, Regex regex) - { - var value = regex.Match(script).Groups[1].Value; - return bool.Parse(value); - } -} \ No newline at end of file diff --git a/SteamLibForked/Web/SteamWebApi[folder]/SteamApi_Market.cs b/SteamLibForked/Web/SteamWebApi[folder]/SteamApi_Market.cs deleted file mode 100644 index 66c26a0..0000000 --- a/SteamLibForked/Web/SteamWebApi[folder]/SteamApi_Market.cs +++ /dev/null @@ -1,60 +0,0 @@ -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; - -public static class SteamWebApi -{ - /// - /// Login is not required - /// - /// - /// - /// - public static async Task GetMarketGlobalInfo(HttpClient client, - CancellationToken cancellationToken = default) - { - var resp = await client.GetStringAsync(SteamConstants.STEAM_MARKET, cancellationToken); - try - { - return MarketGlobalInfoScrapper.Scrap(resp); - } - catch (Exception ex) - { - 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.7.1.html b/changelog/1.7.1.html new file mode 100644 index 0000000..9a7fab9 --- /dev/null +++ b/changelog/1.7.1.html @@ -0,0 +1,89 @@ + + + + + + Changelog + + + + +
+ +
+
Version 1.7.1
+
09.07.2025
+
+
    +
  • + NEWS: Official Telegram group now available! Join us at + + t.me/nebulaauth + +
  • +
  • UPDATE: Added support for a new confirmation type — Purchase.
  • +
  • UPDATE: Merged Global 1.7.0 updates into the release version (patch notes).
  • +
  • FIX: Fixed a crash occurring during confirmation loading.
  • +
  • ENHANCEMENT: Improved localization and system messages.
  • +
+
+
+
+ + + \ No newline at end of file diff --git a/misc/update.xml b/misc/update.xml new file mode 100644 index 0000000..0d26b50 --- /dev/null +++ b/misc/update.xml @@ -0,0 +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 + false + \ No newline at end of file diff --git a/NebulaAuth.LegacyConverter/EncryptedManifest.cs b/src/NebulaAuth.LegacyConverter/EncryptedManifest.cs similarity index 100% rename from NebulaAuth.LegacyConverter/EncryptedManifest.cs rename to src/NebulaAuth.LegacyConverter/EncryptedManifest.cs diff --git a/NebulaAuth.LegacyConverter/NebulaAuth.LegacyConverter.csproj b/src/NebulaAuth.LegacyConverter/NebulaAuth.LegacyConverter.csproj similarity index 86% rename from NebulaAuth.LegacyConverter/NebulaAuth.LegacyConverter.csproj rename to src/NebulaAuth.LegacyConverter/NebulaAuth.LegacyConverter.csproj index fa02bbb..e1632f6 100644 --- a/NebulaAuth.LegacyConverter/NebulaAuth.LegacyConverter.csproj +++ b/src/NebulaAuth.LegacyConverter/NebulaAuth.LegacyConverter.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net9.0 enable enable diff --git a/NebulaAuth.LegacyConverter/Program.cs b/src/NebulaAuth.LegacyConverter/Program.cs similarity index 100% rename from NebulaAuth.LegacyConverter/Program.cs rename to src/NebulaAuth.LegacyConverter/Program.cs diff --git a/NebulaAuth.LegacyConverter/SDADecryptor.cs b/src/NebulaAuth.LegacyConverter/SDADecryptor.cs similarity index 100% rename from NebulaAuth.LegacyConverter/SDADecryptor.cs rename to src/NebulaAuth.LegacyConverter/SDADecryptor.cs diff --git a/NebulaAuth/App.xaml b/src/NebulaAuth/App.xaml similarity index 67% rename from NebulaAuth/App.xaml rename to src/NebulaAuth/App.xaml index ef12067..1253945 100644 --- a/NebulaAuth/App.xaml +++ b/src/NebulaAuth/App.xaml @@ -4,13 +4,11 @@ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:converters="clr-namespace:NebulaAuth.Converters" xmlns:system="clr-namespace:System;assembly=System.Runtime" - xmlns:background="clr-namespace:NebulaAuth.Converters.Background" - StartupUri="MainWindow.xaml"> + xmlns:background="clr-namespace:NebulaAuth.Converters.Background"> - #1E2025 - pack://application:,,,/Fonts/Roboto/#Roboto - pack://application:,,,/Fonts/Roboto/#Roboto Symbols + + @@ -19,32 +17,50 @@ + + + + + + True False - - + + Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign3.Defaults.xaml" /> + + + - - - - - - + + + + + + + + + + + + + + diff --git a/src/NebulaAuth/App.xaml.cs b/src/NebulaAuth/App.xaml.cs new file mode 100644 index 0000000..53c3e81 --- /dev/null +++ b/src/NebulaAuth/App.xaml.cs @@ -0,0 +1,52 @@ +using System; +using System.IO; +using System.Linq; +using System.Windows; +using AchiesUtilities.Extensions; +using NebulaAuth.Core; +using NebulaAuth.Model; +using NebulaAuth.Model.Exceptions; + +namespace NebulaAuth; + +public partial class App +{ + protected override async void OnStartup(StartupEventArgs e) + { + try + { + var splashScreen = new SplashScreen("Theme\\SplashScreen.png"); + splashScreen.Show(false, true); + base.OnStartup(e); + LocManager.Init(); + LocManager.SetApplicationLocalization(Settings.Instance.Language); + Shell.Initialize(); + + var files = 0; + if (Directory.Exists(Storage.MAFILE_F)) + files = Directory.GetFiles(Storage.MafileFolder) + .Count(f => Path.GetExtension(f).EqualsIgnoreCase(".mafile")); + + var threads = files > 0 ? files / 100 + 1 : 1; + await Storage.Initialize(threads); + var mainWindow = new MainWindow(); + Current.MainWindow = mainWindow; + mainWindow.Show(); + splashScreen.Close(TimeSpan.Zero); + } + catch (Exception ex) + { + var msg = ex.ToString(); + if (ex is CantAlignTimeException) + { + msg = LocManager.Get("CantAlignTimeError"); + } + + MessageBox.Show(msg, "Error", MessageBoxButton.OK, MessageBoxImage.Stop, MessageBoxResult.OK, + MessageBoxOptions.DefaultDesktopOnly); + + Shell.Logger.Fatal(ex, "Application startup failed"); + Current.Shutdown(1); + } + } +} \ No newline at end of file diff --git a/NebulaAuth/AssemblyInfo.cs b/src/NebulaAuth/AssemblyInfo.cs similarity index 100% rename from NebulaAuth/AssemblyInfo.cs rename to src/NebulaAuth/AssemblyInfo.cs diff --git a/NebulaAuth/Converters/AnyMafilesToVisibilityConverter.cs b/src/NebulaAuth/Converters/AnyMafilesToVisibilityConverter.cs similarity index 87% rename from NebulaAuth/Converters/AnyMafilesToVisibilityConverter.cs rename to src/NebulaAuth/Converters/AnyMafilesToVisibilityConverter.cs index 0ef92fa..016bcb0 100644 --- a/NebulaAuth/Converters/AnyMafilesToVisibilityConverter.cs +++ b/src/NebulaAuth/Converters/AnyMafilesToVisibilityConverter.cs @@ -11,10 +11,10 @@ public class AnyMafilesToVisibilityConverter : IValueConverter public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { - if (_everAnyMafiles) - { - return Visibility.Collapsed; - } + //if (_everAnyMafiles) + //{ + // return Visibility.Collapsed; + //} if (value is 0) { diff --git a/NebulaAuth/Converters/Background/BackgroundImageVisibleConverter.cs b/src/NebulaAuth/Converters/Background/BackgroundImageVisibleConverter.cs similarity index 100% rename from NebulaAuth/Converters/Background/BackgroundImageVisibleConverter.cs rename to src/NebulaAuth/Converters/Background/BackgroundImageVisibleConverter.cs diff --git a/NebulaAuth/Converters/Background/BackgroundSourceConverter.cs b/src/NebulaAuth/Converters/Background/BackgroundSourceConverter.cs similarity index 97% rename from NebulaAuth/Converters/Background/BackgroundSourceConverter.cs rename to src/NebulaAuth/Converters/Background/BackgroundSourceConverter.cs index e4a5255..3dcef44 100644 --- a/NebulaAuth/Converters/Background/BackgroundSourceConverter.cs +++ b/src/NebulaAuth/Converters/Background/BackgroundSourceConverter.cs @@ -18,7 +18,7 @@ public class BackgroundSourceConverter : IValueConverter } - return new BitmapImage(new Uri("pack://application:,,,/Theme/Background.jpg")); + return new BitmapImage(new Uri("pack://application:,,,/Theme/Background.png")); } public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) diff --git a/NebulaAuth/Converters/CoefficientConverter.cs b/src/NebulaAuth/Converters/CoefficientConverter.cs similarity index 100% rename from NebulaAuth/Converters/CoefficientConverter.cs rename to src/NebulaAuth/Converters/CoefficientConverter.cs diff --git a/NebulaAuth/Converters/ColorToBrushConverter.cs b/src/NebulaAuth/Converters/ColorToBrushConverter.cs similarity index 100% rename from NebulaAuth/Converters/ColorToBrushConverter.cs rename to src/NebulaAuth/Converters/ColorToBrushConverter.cs diff --git a/src/NebulaAuth/Converters/Converters.xaml b/src/NebulaAuth/Converters/Converters.xaml new file mode 100644 index 0000000..5b35f4c --- /dev/null +++ b/src/NebulaAuth/Converters/Converters.xaml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + True + False + + \ No newline at end of file diff --git a/NebulaAuth/Converters/MultiCommandParamaterConverter.cs b/src/NebulaAuth/Converters/MultiCommandParamaterConverter.cs similarity index 100% rename from NebulaAuth/Converters/MultiCommandParamaterConverter.cs rename to src/NebulaAuth/Converters/MultiCommandParamaterConverter.cs diff --git a/src/NebulaAuth/Converters/NullableToBooleanConverter.cs b/src/NebulaAuth/Converters/NullableToBooleanConverter.cs new file mode 100644 index 0000000..06897f7 --- /dev/null +++ b/src/NebulaAuth/Converters/NullableToBooleanConverter.cs @@ -0,0 +1,18 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace NebulaAuth.Converters; + +public class NullableToBooleanConverter : IValueConverter +{ + public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + { + return value != null; + } + + public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) + { + throw new NotSupportedException(); + } +} \ No newline at end of file diff --git a/NebulaAuth/Converters/PortableMaClientStatusToColorConverter.cs b/src/NebulaAuth/Converters/PortableMaClientStatusToColorConverter.cs similarity index 99% rename from NebulaAuth/Converters/PortableMaClientStatusToColorConverter.cs rename to src/NebulaAuth/Converters/PortableMaClientStatusToColorConverter.cs index 6e84920..89acb45 100644 --- a/NebulaAuth/Converters/PortableMaClientStatusToColorConverter.cs +++ b/src/NebulaAuth/Converters/PortableMaClientStatusToColorConverter.cs @@ -14,6 +14,7 @@ public class PortableMaClientStatusToColorConverter : IValueConverter return new SolidColorBrush(Color.FromRgb(187, 224, 139)); } + return new SolidColorBrush(Color.FromRgb(224, 139, 139)); } diff --git a/NebulaAuth/Converters/ProxyTextConverter.cs b/src/NebulaAuth/Converters/ProxyTextConverter.cs similarity index 100% rename from NebulaAuth/Converters/ProxyTextConverter.cs rename to src/NebulaAuth/Converters/ProxyTextConverter.cs diff --git a/NebulaAuth/Converters/ReverseBooleanConverter.cs b/src/NebulaAuth/Converters/ReverseBooleanConverter.cs similarity index 100% rename from NebulaAuth/Converters/ReverseBooleanConverter.cs rename to src/NebulaAuth/Converters/ReverseBooleanConverter.cs diff --git a/NebulaAuth/Converters/ValueConverterGroup.cs b/src/NebulaAuth/Converters/ValueConverterGroup.cs similarity index 100% rename from NebulaAuth/Converters/ValueConverterGroup.cs rename to src/NebulaAuth/Converters/ValueConverterGroup.cs diff --git a/NebulaAuth/Core/DialogsController.cs b/src/NebulaAuth/Core/DialogsController.cs similarity index 75% rename from NebulaAuth/Core/DialogsController.cs rename to src/NebulaAuth/Core/DialogsController.cs index 6d41807..36c778e 100644 --- a/NebulaAuth/Core/DialogsController.cs +++ b/src/NebulaAuth/Core/DialogsController.cs @@ -5,6 +5,8 @@ using NebulaAuth.Model; using NebulaAuth.Model.Entities; using NebulaAuth.View; using NebulaAuth.View.Dialogs; +using NebulaAuth.ViewModel.Linker; +using NebulaAuth.ViewModel.MafileMover; using NebulaAuth.ViewModel.Other; namespace NebulaAuth.Core; @@ -86,11 +88,37 @@ public static class DialogsController public static async Task ShowLinkerDialog() { - var vm = new LinkAccountVM(); - var view = new LinkerView + LinkAccountVM? vm = null; + try { - DataContext = vm - }; - await DialogHost.Show(view); + vm = new LinkAccountVM(); + var view = new LinkerView + { + DataContext = vm + }; + await DialogHost.Show(view); + } + finally + { + vm?.Dispose(); + } + } + + public static async Task ShowMafileMoverDialog() + { + MafileMoverVM? vm = null; + try + { + vm = new MafileMoverVM(); + var view = new MafileMoverView + { + DataContext = vm + }; + await DialogHost.Show(view); + } + finally + { + vm?.Dispose(); + } } } \ No newline at end of file diff --git a/NebulaAuth/Core/LocalizationManager.cs b/src/NebulaAuth/Core/LocalizationManager.cs similarity index 98% rename from NebulaAuth/Core/LocalizationManager.cs rename to src/NebulaAuth/Core/LocalizationManager.cs index fd01f0d..d805052 100644 --- a/NebulaAuth/Core/LocalizationManager.cs +++ b/src/NebulaAuth/Core/LocalizationManager.cs @@ -38,7 +38,7 @@ public static class LocManager public static void Init() { - Loc.LogOutMissingTranslations = true; + Loc.Instance.LogOutMissingTranslations = true; LocalizationLoader.Instance.FileLanguageLoaders.Add(new JsonFileLoader()); diff --git a/NebulaAuth/Core/SnackbarController.cs b/src/NebulaAuth/Core/SnackbarController.cs similarity index 97% rename from NebulaAuth/Core/SnackbarController.cs rename to src/NebulaAuth/Core/SnackbarController.cs index 8404c7f..976822c 100644 --- a/NebulaAuth/Core/SnackbarController.cs +++ b/src/NebulaAuth/Core/SnackbarController.cs @@ -44,7 +44,7 @@ public class SnackbarController private static TimeSpan GetSnackbarTime(string str) { - var duration = str.Length / 0.03; + var duration = str.Length / 0.022; if (duration < MIN_SNACKBAR_TIME) { duration = MIN_SNACKBAR_TIME; diff --git a/NebulaAuth/Core/ThemeManager.cs b/src/NebulaAuth/Core/ThemeManager.cs similarity index 63% rename from NebulaAuth/Core/ThemeManager.cs rename to src/NebulaAuth/Core/ThemeManager.cs index 81b123f..22ab707 100644 --- a/NebulaAuth/Core/ThemeManager.cs +++ b/src/NebulaAuth/Core/ThemeManager.cs @@ -2,9 +2,9 @@ using System.ComponentModel; using System.Drawing; using System.Drawing.Drawing2D; +using System.Linq; using System.Windows; using System.Windows.Interop; -using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shell; using NebulaAuth.Model; @@ -14,7 +14,6 @@ namespace NebulaAuth.Core; public static class ThemeManager { - public static System.Windows.Media.Color DefaultBackgroundColor = System.Windows.Media.Color.FromRgb(30, 32, 37); private static readonly Window MainWindow = Application.Current.MainWindow!; static ThemeManager() @@ -24,11 +23,7 @@ public static class ThemeManager private static void SettingsOnPropertyChanged(object? sender, PropertyChangedEventArgs e) { - if (e.PropertyName == nameof(Settings.BackgroundColor)) - { - UpdateBackground(); - } - else if (e.PropertyName == nameof(Settings.IconColor)) + if (e.PropertyName == nameof(Settings.IconColor)) { UpdateIcon(); } @@ -58,15 +53,40 @@ public static class ThemeManager } } - private static void UpdateBackground() + + public static void ApplyTheme(string themeName) { - var color = Settings.Instance.BackgroundColor ?? DefaultBackgroundColor; - Application.Current.Resources["WindowBackground"] = new SolidColorBrush(color); + var colorDict = new ResourceDictionary + { + Source = new Uri($"Theme/Themes/{themeName}.xaml", UriKind.Relative) + }; + + var brushDict = new ResourceDictionary + { + Source = new Uri("Theme/Brushes.xaml", UriKind.Relative) + }; + + var mergedDictionaries = Application.Current.Resources.MergedDictionaries; + + + var toRemove = mergedDictionaries + .Where(d => d.Source?.OriginalString.Contains("Theme/Themes/") == true || + d.Source?.OriginalString.EndsWith("Brushes.xaml") == true) + .ToList(); + + foreach (var dict in toRemove) + { + mergedDictionaries.Remove(dict); + } + + mergedDictionaries.Insert(0, colorDict); + mergedDictionaries.Insert(0, brushDict); } + public static void InitializeTheme() { UpdateIcon(); - UpdateBackground(); + ApplyTheme(Settings.Instance.GetTheme()); } } \ No newline at end of file diff --git a/NebulaAuth/Core/TrayManager.cs b/src/NebulaAuth/Core/TrayManager.cs similarity index 100% rename from NebulaAuth/Core/TrayManager.cs rename to src/NebulaAuth/Core/TrayManager.cs diff --git a/NebulaAuth/Core/UpdateManager.cs b/src/NebulaAuth/Core/UpdateManager.cs similarity index 96% rename from NebulaAuth/Core/UpdateManager.cs rename to src/NebulaAuth/Core/UpdateManager.cs index 3415a49..dc8db72 100644 --- a/NebulaAuth/Core/UpdateManager.cs +++ b/src/NebulaAuth/Core/UpdateManager.cs @@ -8,7 +8,7 @@ namespace NebulaAuth.Core; public static class UpdateManager { private const string UPDATE_URL = - "https://raw.githubusercontent.com/achiez/NebulaAuth-Steam-Desktop-Authenticator-by-Achies/master/NebulaAuth/update.xml"; + "https://raw.githubusercontent.com/achiez/NebulaAuth-Steam-Desktop-Authenticator-by-Achies/master/misc/update.xml"; public static void CheckForUpdates() { diff --git a/NebulaAuth/FodyWeavers.xml b/src/NebulaAuth/FodyWeavers.xml similarity index 100% rename from NebulaAuth/FodyWeavers.xml rename to src/NebulaAuth/FodyWeavers.xml diff --git a/NebulaAuth/MainWindow.xaml b/src/NebulaAuth/MainWindow.xaml similarity index 56% rename from NebulaAuth/MainWindow.xaml rename to src/NebulaAuth/MainWindow.xaml index 41e64c2..df97241 100644 --- a/NebulaAuth/MainWindow.xaml +++ b/src/NebulaAuth/MainWindow.xaml @@ -9,12 +9,14 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:entities="clr-namespace:NebulaAuth.Model.Entities" xmlns:viewModel="clr-namespace:NebulaAuth.ViewModel" + xmlns:controls="clr-namespace:NebulaAuth.Theme.Controls" WindowStartupLocation="CenterScreen" MinHeight="500" MinWidth="500" DefaultFontSize="18" ScaleCoefficient="0.4" - Title="NebulaAuth" Height="800" Width="730" Style="{StaticResource MainWindow}" - RenderOptions.BitmapScalingMode="HighQuality" Foreground="#FFF5F5F5" + Title="NebulaAuth" Height="800" Width="730" + Style="{StaticResource MainWindow}" + RenderOptions.BitmapScalingMode="HighQuality" FontFamily="{md:MaterialDesignFont}" - TextElement.Foreground="{DynamicResource MaterialDesignBody}" + TextElement.Foreground="{DynamicResource BaseContentBrush}" mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModel:MainVM}"> @@ -28,20 +30,31 @@ - + + - - + Source="{Binding Settings.BackgroundMode, Mode=OneWay, Converter={StaticResource BackgroundSourceConverter}}"> + + + + + + - - - - - - + + + @@ -75,8 +85,11 @@ + + + SelectedValue="{Binding SelectedGroup}" + md:TextFieldAssist.HasClearButton="True"> @@ -114,6 +128,7 @@ md:HintAssist.Hint="{Tr MainWindow.AppBar.Proxy.ProxyHint}" md:ComboBoxAssist.ShowSelectedItem="False" SelectedValue="{Binding SelectedProxy}" + ItemsSource="{Binding Proxies}"> @@ -132,7 +147,8 @@ + Foreground="{DynamicResource ErrorBrush}" Margin="3" + ToolTipService.InitialShowDelay="300"> @@ -175,7 +190,6 @@ @@ -197,7 +211,7 @@ PreviewTextInput="UIElement_OnPreviewTextInput" /> @@ -214,117 +228,138 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + BorderThickness="1" + CornerRadius="12"> + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - + - + + @@ -334,47 +369,50 @@ - - - - - - - + + + Width="{Binding Path=ActualWidth, Converter={StaticResource CoefficientConverter}, ConverterParameter=0.6, RelativeSource={RelativeSource AncestorType=md:Card}}" /> - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/NebulaAuth/View/Dialogs/ConfirmCancelDialog.xaml b/src/NebulaAuth/View/Dialogs/ConfirmCancelDialog.xaml similarity index 100% rename from NebulaAuth/View/Dialogs/ConfirmCancelDialog.xaml rename to src/NebulaAuth/View/Dialogs/ConfirmCancelDialog.xaml diff --git a/NebulaAuth/View/Dialogs/ConfirmCancelDialog.xaml.cs b/src/NebulaAuth/View/Dialogs/ConfirmCancelDialog.xaml.cs similarity index 100% rename from NebulaAuth/View/Dialogs/ConfirmCancelDialog.xaml.cs rename to src/NebulaAuth/View/Dialogs/ConfirmCancelDialog.xaml.cs diff --git a/src/NebulaAuth/View/Dialogs/LoginAgainDialog.xaml b/src/NebulaAuth/View/Dialogs/LoginAgainDialog.xaml new file mode 100644 index 0000000..0a02b2a --- /dev/null +++ b/src/NebulaAuth/View/Dialogs/LoginAgainDialog.xaml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + theme:FontScaleWindow.ResizeFont="True" Margin="10" HorizontalAlignment="Left" /> - + diff --git a/NebulaAuth/View/Dialogs/SetCryptPasswordDialog.xaml.cs b/src/NebulaAuth/View/Dialogs/SetCryptPasswordDialog.xaml.cs similarity index 100% rename from NebulaAuth/View/Dialogs/SetCryptPasswordDialog.xaml.cs rename to src/NebulaAuth/View/Dialogs/SetCryptPasswordDialog.xaml.cs diff --git a/NebulaAuth/View/Dialogs/WaitLoginDialog.xaml b/src/NebulaAuth/View/Dialogs/WaitLoginDialog.xaml similarity index 100% rename from NebulaAuth/View/Dialogs/WaitLoginDialog.xaml rename to src/NebulaAuth/View/Dialogs/WaitLoginDialog.xaml diff --git a/src/NebulaAuth/View/Dialogs/WaitLoginDialog.xaml.cs b/src/NebulaAuth/View/Dialogs/WaitLoginDialog.xaml.cs new file mode 100644 index 0000000..8ed0802 --- /dev/null +++ b/src/NebulaAuth/View/Dialogs/WaitLoginDialog.xaml.cs @@ -0,0 +1,30 @@ +using System.Threading.Tasks; +using System.Windows; + +namespace NebulaAuth.View.Dialogs; + +/// +/// Логика взаимодействия для WaitLoginDialog.xaml +/// +public partial class WaitLoginDialog +{ + private TaskCompletionSource _tcs = new(); + + public WaitLoginDialog() + { + InitializeComponent(); + } + + private void CancelButton_OnClick(object sender, RoutedEventArgs e) + { + _tcs.SetCanceled(); + } + + private void SendCaptchaBtn_Click(object sender, RoutedEventArgs e) + { + if (string.IsNullOrWhiteSpace(CaptchaTB.Text)) return; + var oldTcs = _tcs; + _tcs = new TaskCompletionSource(); + oldTcs.SetResult(CaptchaTB.Text); + } +} \ No newline at end of file diff --git a/src/NebulaAuth/View/LinkerStepTemplates.xaml b/src/NebulaAuth/View/LinkerStepTemplates.xaml new file mode 100644 index 0000000..5921781 --- /dev/null +++ b/src/NebulaAuth/View/LinkerStepTemplates.xaml @@ -0,0 +1,200 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/NebulaAuth/View/LinkerView.xaml.cs b/src/NebulaAuth/View/LinkerView.xaml.cs similarity index 100% rename from NebulaAuth/View/LinkerView.xaml.cs rename to src/NebulaAuth/View/LinkerView.xaml.cs diff --git a/src/NebulaAuth/View/LinksView.xaml b/src/NebulaAuth/View/LinksView.xaml new file mode 100644 index 0000000..47bd926 --- /dev/null +++ b/src/NebulaAuth/View/LinksView.xaml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/NebulaAuth/View/MafileMoverView.xaml.cs b/src/NebulaAuth/View/MafileMoverView.xaml.cs new file mode 100644 index 0000000..275c1d7 --- /dev/null +++ b/src/NebulaAuth/View/MafileMoverView.xaml.cs @@ -0,0 +1,14 @@ +using System.Windows.Controls; + +namespace NebulaAuth.View; + +/// +/// Логика взаимодействия для MafileMoverView.xaml +/// +public partial class MafileMoverView : UserControl +{ + public MafileMoverView() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/NebulaAuth/View/ProxyManagerView.xaml b/src/NebulaAuth/View/ProxyManagerView.xaml similarity index 87% rename from NebulaAuth/View/ProxyManagerView.xaml rename to src/NebulaAuth/View/ProxyManagerView.xaml index e05fd15..5e879ca 100644 --- a/NebulaAuth/View/ProxyManagerView.xaml +++ b/src/NebulaAuth/View/ProxyManagerView.xaml @@ -7,13 +7,12 @@ xmlns:other="clr-namespace:NebulaAuth.ViewModel.Other" mc:Ignorable="d" d:DesignHeight="500" d:DesignWidth="400" - Foreground="WhiteSmoke" FontFamily="{md:MaterialDesignFont}" MinHeight="500" MinWidth="400" MaxHeight="550" d:DataContext="{d:DesignInstance other:ProxyManagerVM}" - Background="{DynamicResource WindowBackground}"> + Background="Transparent"> @@ -22,19 +21,23 @@ - + - - + + - - - diff --git a/NebulaAuth/View/ProxyManagerView.xaml.cs b/src/NebulaAuth/View/ProxyManagerView.xaml.cs similarity index 100% rename from NebulaAuth/View/ProxyManagerView.xaml.cs rename to src/NebulaAuth/View/ProxyManagerView.xaml.cs diff --git a/src/NebulaAuth/View/SettingsView.xaml b/src/NebulaAuth/View/SettingsView.xaml new file mode 100644 index 0000000..0f048fb --- /dev/null +++ b/src/NebulaAuth/View/SettingsView.xaml @@ -0,0 +1,169 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +