diff --git a/NebulaAuth.LegacyConverter/EncryptedManifest.cs b/NebulaAuth.LegacyConverter/EncryptedManifest.cs
index 49591b1..8a8f0c4 100644
--- a/NebulaAuth.LegacyConverter/EncryptedManifest.cs
+++ b/NebulaAuth.LegacyConverter/EncryptedManifest.cs
@@ -5,19 +5,16 @@
namespace NebulaAuth.LegacyConverter;
+
public class Manifest
{
- [JsonProperty("encrypted")]
- public bool Encrypted { get; set; }
+ [JsonProperty("encrypted")] public bool Encrypted { get; set; }
- [JsonProperty("first_run")]
- public bool FirstRun { get; set; }
+ [JsonProperty("first_run")] public bool FirstRun { get; set; }
- [JsonProperty("entries")]
- public Entry[] Entries { get; set; }
+ [JsonProperty("entries")] public Entry[] Entries { get; set; }
- [JsonProperty("periodic_checking")]
- public bool PeriodicChecking { get; set; }
+ [JsonProperty("periodic_checking")] public bool PeriodicChecking { get; set; }
[JsonProperty("periodic_checking_interval")]
public long PeriodicCheckingInterval { get; set; }
@@ -28,21 +25,16 @@ public class Manifest
[JsonProperty("auto_confirm_market_transactions")]
public bool AutoConfirmMarketTransactions { get; set; }
- [JsonProperty("auto_confirm_trades")]
- public bool AutoConfirmTrades { get; set; }
+ [JsonProperty("auto_confirm_trades")] public bool AutoConfirmTrades { get; set; }
}
public class Entry
{
- [JsonProperty("encryption_iv")]
- public string EncryptionIv { get; set; }
+ [JsonProperty("encryption_iv")] public string EncryptionIv { get; set; }
- [JsonProperty("encryption_salt")]
- public string EncryptionSalt { get; set; }
+ [JsonProperty("encryption_salt")] public string EncryptionSalt { get; set; }
- [JsonProperty("filename")]
- public string Filename { get; set; }
+ [JsonProperty("filename")] public string Filename { get; set; }
- [JsonProperty("steamid")]
- public ulong SteamId { get; set; }
+ [JsonProperty("steamid")] public ulong SteamId { get; set; }
}
\ No newline at end of file
diff --git a/NebulaAuth.LegacyConverter/Program.cs b/NebulaAuth.LegacyConverter/Program.cs
index 5e72683..64f48a5 100644
--- a/NebulaAuth.LegacyConverter/Program.cs
+++ b/NebulaAuth.LegacyConverter/Program.cs
@@ -1,10 +1,9 @@
-using AchiesUtilities.Extensions;
+using System.Reflection;
+using AchiesUtilities.Extensions;
using NebulaAuth.LegacyConverter;
using Newtonsoft.Json;
using SteamLib.Utility.MafileSerialization;
-
-
try
{
var mafileSerializer = new MafileSerializer(new MafileSerializerSettings
@@ -12,10 +11,10 @@ try
DeserializationOptions =
{
AllowDeviceIdGeneration = true,
- AllowSessionIdGeneration = true,
+ AllowSessionIdGeneration = true
}
});
- var currentPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
+ var currentPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if (currentPath != null)
Environment.CurrentDirectory = currentPath;
const string toStoreFolder = "ConvertedMafiles";
@@ -108,7 +107,6 @@ try
foreach (var path in args)
{
-
if (Path.Exists(path) == false)
{
Console.WriteLine($"NOT VALID PATH: '{path}'");
@@ -147,15 +145,12 @@ try
{
Console.WriteLine("-----------------------------------------");
}
-
-
}
//Local Functions
void Write(string maf, string name)
{
-
var path = Path.Combine(toStoreFolder, name + "_legacy.mafile");
File.WriteAllText(path, maf);
}
@@ -172,8 +167,6 @@ try
var iv = entry.EncryptionIv;
var salt = entry.EncryptionSalt;
return SDAEncryptor.DecryptData(password, salt, iv, cipherText);
-
-
}
}
finally
diff --git a/NebulaAuth.LegacyConverter/SDADecryptor.cs b/NebulaAuth.LegacyConverter/SDADecryptor.cs
index fd2f402..a1989b5 100644
--- a/NebulaAuth.LegacyConverter/SDADecryptor.cs
+++ b/NebulaAuth.LegacyConverter/SDADecryptor.cs
@@ -1,9 +1,7 @@
-#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
-namespace NebulaAuth.LegacyConverter;
+using System.Security.Cryptography;
-using System;
-using System.IO;
-using System.Security.Cryptography;
+#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
+namespace NebulaAuth.LegacyConverter;
#pragma warning disable all
#pragma warning disable SYSLIB0023
@@ -13,24 +11,23 @@ using System.Security.Cryptography;
//Resharper disable all
//Pragma is disabled because it's legacy code from SDA
-
-
///
-/// This class provides the controls that will encrypt and decrypt the *.maFile files
-///
-/// Passwords entered will be passed into 100k rounds of PBKDF2 (RFC2898) with a cryptographically random salt.
-/// The generated key will then be passed into AES-256 (RijndalManaged) which will encrypt the data
-/// in cypher block chaining (CBC) mode, and then write both the PBKDF2 salt and encrypted data onto the disk.
+/// This class provides the controls that will encrypt and decrypt the *.maFile files
+/// Passwords entered will be passed into 100k rounds of PBKDF2 (RFC2898) with a cryptographically random salt.
+/// The generated key will then be passed into AES-256 (RijndalManaged) which will encrypt the data
+/// in cypher block chaining (CBC) mode, and then write both the PBKDF2 salt and encrypted data onto the disk.
///
public static class SDAEncryptor
{
- private const int PBKDF2_ITERATIONS = 50000; //Set to 50k to make program not unbearably slow. May increase in future.
+ private const int
+ PBKDF2_ITERATIONS = 50000; //Set to 50k to make program not unbearably slow. May increase in future.
+
private const int SALT_LENGTH = 8;
private const int KEY_SIZE_BYTES = 32;
private const int IV_LENGTH = 16;
///
- /// Returns an 8-byte cryptographically random salt in base64 encoding
+ /// Returns an 8-byte cryptographically random salt in base64 encoding
///
///
public static string GetRandomSalt()
@@ -40,11 +37,12 @@ public static class SDAEncryptor
{
rng.GetBytes(salt);
}
+
return Convert.ToBase64String(salt);
}
///
- /// Returns a 16-byte cryptographically random initialization vector (IV) in base64 encoding
+ /// Returns a 16-byte cryptographically random initialization vector (IV) in base64 encoding
///
///
public static string GetInitializationVector()
@@ -54,14 +52,14 @@ public static class SDAEncryptor
{
rng.GetBytes(IV);
}
+
return Convert.ToBase64String(IV);
}
///
- /// Generates an encryption key derived using a password, a random salt, and specified number of rounds of PBKDF2
- ///
- /// TODO: pass in password via SecureString?
+ /// Generates an encryption key derived using a password, a random salt, and specified number of rounds of PBKDF2
+ /// TODO: pass in password via SecureString?
///
///
///
@@ -72,19 +70,22 @@ public static class SDAEncryptor
{
throw new ArgumentException("Password is empty");
}
+
if (string.IsNullOrEmpty(salt))
{
throw new ArgumentException("Salt is empty");
}
- using (Rfc2898DeriveBytes pbkdf2 = new Rfc2898DeriveBytes(password, Convert.FromBase64String(salt), PBKDF2_ITERATIONS))
+
+ using (Rfc2898DeriveBytes pbkdf2 =
+ new Rfc2898DeriveBytes(password, Convert.FromBase64String(salt), PBKDF2_ITERATIONS))
{
return pbkdf2.GetBytes(KEY_SIZE_BYTES);
}
}
///
- /// Tries to decrypt and return data given an encrypted base64 encoded string. Must use the same
- /// password, salt, IV, and ciphertext that was used during the original encryption of the data.
+ /// Tries to decrypt and return data given an encrypted base64 encoded string. Must use the same
+ /// password, salt, IV, and ciphertext that was used during the original encryption of the data.
///
///
///
@@ -97,14 +98,17 @@ public static class SDAEncryptor
{
throw new ArgumentException("Password is empty");
}
+
if (string.IsNullOrEmpty(passwordSalt))
{
throw new ArgumentException("Salt is empty");
}
+
if (string.IsNullOrEmpty(IV))
{
throw new ArgumentException("Initialization Vector is empty");
}
+
if (string.IsNullOrEmpty(encryptedData))
{
throw new ArgumentException("Encrypted data is empty");
@@ -143,13 +147,14 @@ public static class SDAEncryptor
plaintext = null;
}
}
+
return plaintext;
}
///
- /// Encrypts a string given a password, salt, and initialization vector, then returns result in base64 encoded string.
- ///
- /// To retrieve this data, you must decrypt with the same password, salt, IV, and cyphertext that was used during encryption
+ /// Encrypts a string given a password, salt, and initialization vector, then returns result in base64 encoded string.
+ /// To retrieve this data, you must decrypt with the same password, salt, IV, and cyphertext that was used during
+ /// encryption
///
///
///
@@ -162,18 +167,22 @@ public static class SDAEncryptor
{
throw new ArgumentException("Password is empty");
}
+
if (string.IsNullOrEmpty(passwordSalt))
{
throw new ArgumentException("Salt is empty");
}
+
if (string.IsNullOrEmpty(IV))
{
throw new ArgumentException("Initialization Vector is empty");
}
+
if (string.IsNullOrEmpty(plaintext))
{
throw new ArgumentException("Plaintext data is empty");
}
+
byte[] key = GetEncryptionKey(password, passwordSalt);
byte[] ciphertext;
@@ -194,10 +203,12 @@ public static class SDAEncryptor
{
swEncypt.Write(plaintext);
}
+
ciphertext = msEncrypt.ToArray();
}
}
}
+
return Convert.ToBase64String(ciphertext);
}
-}
+}
\ No newline at end of file
diff --git a/NebulaAuth.sln b/NebulaAuth.sln
index d4d148d..b2d6f6d 100644
--- a/NebulaAuth.sln
+++ b/NebulaAuth.sln
@@ -27,6 +27,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "changelog", "changelog", "{
changelog\1.5.3.html = changelog\1.5.3.html
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
EndProjectSection
EndProject
Global
diff --git a/NebulaAuth/App.xaml b/NebulaAuth/App.xaml
index cd88f9d..ef12067 100644
--- a/NebulaAuth/App.xaml
+++ b/NebulaAuth/App.xaml
@@ -11,38 +11,41 @@
#1E2025
pack://application:,,,/Fonts/Roboto/#Roboto
pack://application:,,,/Fonts/Roboto/#Roboto Symbols
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
+
+
True
False
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
+
+
-
+
-
+
\ No newline at end of file
diff --git a/NebulaAuth/App.xaml.cs b/NebulaAuth/App.xaml.cs
index f80f81e..9ae9dc1 100644
--- a/NebulaAuth/App.xaml.cs
+++ b/NebulaAuth/App.xaml.cs
@@ -1,12 +1,11 @@
-using NebulaAuth.Core;
+using System;
+using System.Windows;
+using NebulaAuth.Core;
using NebulaAuth.Model;
using NebulaAuth.Model.Exceptions;
-using System;
-using System.Windows;
namespace NebulaAuth;
-
public partial class App
{
protected override void OnStartup(StartupEventArgs e)
@@ -27,9 +26,9 @@ public partial class App
msg = LocManager.Get("CantAlignTimeError");
}
- MessageBox.Show(msg, "Error", MessageBoxButton.OK, MessageBoxImage.Stop, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
+ MessageBox.Show(msg, "Error", MessageBoxButton.OK, MessageBoxImage.Stop, MessageBoxResult.OK,
+ MessageBoxOptions.DefaultDesktopOnly);
throw;
-
}
}
-}
+}
\ No newline at end of file
diff --git a/NebulaAuth/AssemblyInfo.cs b/NebulaAuth/AssemblyInfo.cs
index 8b5504e..4a05c7d 100644
--- a/NebulaAuth/AssemblyInfo.cs
+++ b/NebulaAuth/AssemblyInfo.cs
@@ -2,9 +2,9 @@ using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
- //(used if a resource is not found in the page,
- // or application resource dictionaries)
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
- //(used if a resource is not found in the page,
- // app, or any theme specific resource dictionaries)
-)]
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
\ No newline at end of file
diff --git a/NebulaAuth/Converters/AnyMafilesToVisibilityConverter.cs b/NebulaAuth/Converters/AnyMafilesToVisibilityConverter.cs
index 04dcf5c..0ef92fa 100644
--- a/NebulaAuth/Converters/AnyMafilesToVisibilityConverter.cs
+++ b/NebulaAuth/Converters/AnyMafilesToVisibilityConverter.cs
@@ -8,12 +8,14 @@ namespace NebulaAuth.Converters;
public class AnyMafilesToVisibilityConverter : IValueConverter
{
private static bool _everAnyMafiles;
+
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (_everAnyMafiles)
{
return Visibility.Collapsed;
}
+
if (value is 0)
{
return Visibility.Visible;
diff --git a/NebulaAuth/Converters/Background/BackgroundImageVisibleConverter.cs b/NebulaAuth/Converters/Background/BackgroundImageVisibleConverter.cs
index 3a92e03..5383db1 100644
--- a/NebulaAuth/Converters/Background/BackgroundImageVisibleConverter.cs
+++ b/NebulaAuth/Converters/Background/BackgroundImageVisibleConverter.cs
@@ -1,8 +1,8 @@
-using NebulaAuth.Model;
-using System;
+using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
+using NebulaAuth.Model;
namespace NebulaAuth.Converters.Background;
diff --git a/NebulaAuth/Converters/Background/BackgroundSourceConverter.cs b/NebulaAuth/Converters/Background/BackgroundSourceConverter.cs
index d4399a2..e4a5255 100644
--- a/NebulaAuth/Converters/Background/BackgroundSourceConverter.cs
+++ b/NebulaAuth/Converters/Background/BackgroundSourceConverter.cs
@@ -13,10 +13,10 @@ public class BackgroundSourceConverter : IValueConverter
{
if (value is BackgroundMode.Custom)
{
- if(File.Exists("Background.png"))
+ if (File.Exists("Background.png"))
return new BitmapImage(new Uri(Path.GetFullPath("Background.png")));
}
-
+
return new BitmapImage(new Uri("pack://application:,,,/Theme/Background.jpg"));
}
diff --git a/NebulaAuth/Converters/ColorToBrushConverter.cs b/NebulaAuth/Converters/ColorToBrushConverter.cs
index c84794b..878ed51 100644
--- a/NebulaAuth/Converters/ColorToBrushConverter.cs
+++ b/NebulaAuth/Converters/ColorToBrushConverter.cs
@@ -1,7 +1,7 @@
-using System.Globalization;
+using System;
+using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
-using System;
namespace NebulaAuth.Converters;
@@ -16,6 +16,7 @@ public class ColorToBrushConverter : IValueConverter
rv.Freeze();
return rv;
}
+
return Binding.DoNothing;
}
@@ -25,6 +26,7 @@ public class ColorToBrushConverter : IValueConverter
{
return brush.Color;
}
+
return default(Color);
}
}
\ No newline at end of file
diff --git a/NebulaAuth/Converters/PortableMaClientStatusToColorConverter.cs b/NebulaAuth/Converters/PortableMaClientStatusToColorConverter.cs
index fdd0516..6e84920 100644
--- a/NebulaAuth/Converters/PortableMaClientStatusToColorConverter.cs
+++ b/NebulaAuth/Converters/PortableMaClientStatusToColorConverter.cs
@@ -1,7 +1,7 @@
-using System.Globalization;
+using System;
+using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
-using System;
namespace NebulaAuth.Converters;
@@ -13,8 +13,8 @@ public class PortableMaClientStatusToColorConverter : IValueConverter
{
return new SolidColorBrush(Color.FromRgb(187, 224, 139));
}
- return new SolidColorBrush(Color.FromRgb(224, 139, 139));
+ return new SolidColorBrush(Color.FromRgb(224, 139, 139));
}
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
diff --git a/NebulaAuth/Converters/ReverseBooleanConverter.cs b/NebulaAuth/Converters/ReverseBooleanConverter.cs
index 0f40c2c..01d1c29 100644
--- a/NebulaAuth/Converters/ReverseBooleanConverter.cs
+++ b/NebulaAuth/Converters/ReverseBooleanConverter.cs
@@ -25,4 +25,4 @@ public class ReverseBooleanConverter : IValueConverter
throw new ArgumentException("Value must be of type bool", nameof(value));
}
-}
+}
\ No newline at end of file
diff --git a/NebulaAuth/Converters/ValueConverterGroup.cs b/NebulaAuth/Converters/ValueConverterGroup.cs
index ebd749f..d015ebb 100644
--- a/NebulaAuth/Converters/ValueConverterGroup.cs
+++ b/NebulaAuth/Converters/ValueConverterGroup.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
using System.Windows.Data;
@@ -9,12 +10,13 @@ public class ValueConverterGroup : List, IValueConverter
{
#region IValueConverter Members
- public object? Convert(object? value, Type targetType, object? parameter, System.Globalization.CultureInfo culture)
+ public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
- return this.Aggregate(value, (current, converter) => converter.Convert(current, targetType, parameter, culture));
+ return this.Aggregate(value,
+ (current, converter) => converter.Convert(current, targetType, parameter, culture));
}
- public object ConvertBack(object? value, Type targetType, object? parameter, System.Globalization.CultureInfo culture)
+ public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
diff --git a/NebulaAuth/Core/DialogsController.cs b/NebulaAuth/Core/DialogsController.cs
index f7047a7..6d41807 100644
--- a/NebulaAuth/Core/DialogsController.cs
+++ b/NebulaAuth/Core/DialogsController.cs
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using MaterialDesignThemes.Wpf;
+using NebulaAuth.Model;
using NebulaAuth.Model.Entities;
using NebulaAuth.View;
using NebulaAuth.View.Dialogs;
@@ -10,12 +11,10 @@ namespace NebulaAuth.Core;
public static class DialogsController
{
-
#region CommonDialogs
public static async Task ShowConfirmCancelDialog(string? msg = null)
{
-
var content = msg == null ? new ConfirmCancelDialog() : new ConfirmCancelDialog(msg);
var result = await DialogHost.Show(content);
@@ -31,11 +30,13 @@ public static class DialogsController
#endregion
- public static async Task ShowLoginAgainDialog(string username)
+ public static async Task ShowLoginAgainDialog(string username, string? currentPassword = null)
{
var vm = new LoginAgainVM
{
- UserName = username
+ UserName = username,
+ Password = currentPassword ?? string.Empty,
+ SavePassword = PHandler.IsPasswordSet
};
var content = new LoginAgainDialog
{
@@ -50,10 +51,11 @@ public static class DialogsController
return null;
}
- public static async Task ShowLoginAgainOnImportDialog(Mafile mafile, IEnumerable proxies)
+ public static async Task ShowLoginAgainOnImportDialog(Mafile mafile,
+ IEnumerable proxies)
{
var vm = new LoginAgainOnImportVM(mafile, proxies);
- var content = new LoginAgainOnImportDialog()
+ var content = new LoginAgainOnImportDialog
{
DataContext = vm
};
@@ -66,7 +68,7 @@ public static class DialogsController
return null;
}
- public static async Task ShowProxyManager(MaProxy? currentProxy)
+ public static async Task ShowProxyManager()
{
var vm = new ProxyManagerVM();
var view = new ProxyManagerView
@@ -74,20 +76,21 @@ public static class DialogsController
DataContext = vm
};
await DialogHost.Show(view);
+ return vm.AnyChanges;
}
+
public static void CloseDialog()
{
DialogHost.Close(null);
}
+
public static async Task ShowLinkerDialog()
{
var vm = new LinkAccountVM();
- var view = new LinkerView()
+ var view = new LinkerView
{
DataContext = vm
};
await DialogHost.Show(view);
}
-
-
}
\ No newline at end of file
diff --git a/NebulaAuth/Core/LocalizationManager.cs b/NebulaAuth/Core/LocalizationManager.cs
index a111a09..fd01f0d 100644
--- a/NebulaAuth/Core/LocalizationManager.cs
+++ b/NebulaAuth/Core/LocalizationManager.cs
@@ -1,9 +1,9 @@
-using CodingSeb.Localization;
-using CodingSeb.Localization.Loaders;
-using System;
+using System;
using System.IO;
using System.Reflection;
using System.Text;
+using CodingSeb.Localization;
+using CodingSeb.Localization.Loaders;
namespace NebulaAuth.Core;
@@ -11,6 +11,7 @@ public static class LocManager
{
public const string CODE_BEHIND_PATH_PART = "CodeBehind";
public const string COMMON_PATH_PART = "Common";
+
public static void SetApplicationLocalization(LocalizationLanguage language)
{
Loc.Instance.CurrentLanguage = GetLanguageCode(language);
@@ -35,7 +36,6 @@ public static class LocManager
}
-
public static void Init()
{
Loc.LogOutMissingTranslations = true;
@@ -47,7 +47,8 @@ public static class LocManager
public static void ReloadFiles()
{
- string exampleFileFileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "localization.loc.json");
+ var exampleFileFileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!,
+ "localization.loc.json");
LocalizationLoader.Instance.ClearAllTranslations();
LocalizationLoader.Instance.AddFile(exampleFileFileName);
}
@@ -64,14 +65,14 @@ public static class LocManager
public static string? GetCommon(params string[] path)
{
- return GetConcat(COMMON_PATH_PART, path);
+ return GetConcat(COMMON_PATH_PART, path);
}
public static string GetCommonOrDefault(string def, params string[] path)
{
- return GetCommon(path) ?? def;
+ return GetCommon(path) ?? def;
}
-
+
public static string? Get(params string[] path)
{
@@ -92,9 +93,10 @@ public static class LocManager
{
return Get(path) ?? def;
}
+
private static string? GetConcat(string first, string[] path)
{
- string[] newArray = new string[path.Length + 1];
+ var newArray = new string[path.Length + 1];
newArray[0] = first;
Array.Copy(path, 0, newArray, 1, path.Length);
return Get(newArray);
diff --git a/NebulaAuth/Core/SnackbarController.cs b/NebulaAuth/Core/SnackbarController.cs
index 2d6b142..8404c7f 100644
--- a/NebulaAuth/Core/SnackbarController.cs
+++ b/NebulaAuth/Core/SnackbarController.cs
@@ -5,12 +5,11 @@ namespace NebulaAuth.Core;
public class SnackbarController
{
-
- public static SnackbarMessageQueue MessageQueue { get; } = new() { DiscardDuplicates = true};
private const int MIN_SNACKBAR_TIME = 1200;
+ public static SnackbarMessageQueue MessageQueue { get; } = new() {DiscardDuplicates = true};
+
///
- ///
///
///
/// Default duration is 1 second
@@ -21,13 +20,13 @@ public class SnackbarController
}
///
- ///
///
///
///
/// Default duration is 1 second
/// Default: 'OK'
- public static void SendSnackbarWithButton(string text, string actionText = "OK", Action? action = null, TimeSpan? duration = null)
+ public static void SendSnackbarWithButton(string text, string actionText = "OK", Action? action = null,
+ TimeSpan? duration = null)
{
duration ??= GetSnackbarTime(text);
Action argAction;
@@ -48,10 +47,9 @@ public class SnackbarController
var duration = str.Length / 0.03;
if (duration < MIN_SNACKBAR_TIME)
{
- duration = MIN_SNACKBAR_TIME;
+ duration = MIN_SNACKBAR_TIME;
}
+
return TimeSpan.FromMilliseconds(duration);
-
}
-
}
\ No newline at end of file
diff --git a/NebulaAuth/Core/ThemeManager.cs b/NebulaAuth/Core/ThemeManager.cs
index ffbe285..81b123f 100644
--- a/NebulaAuth/Core/ThemeManager.cs
+++ b/NebulaAuth/Core/ThemeManager.cs
@@ -1,11 +1,13 @@
-using NebulaAuth.Model;
-using System;
+using System;
using System.ComponentModel;
using System.Drawing;
+using System.Drawing.Drawing2D;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
+using System.Windows.Shell;
+using NebulaAuth.Model;
using Color = System.Drawing.Color;
namespace NebulaAuth.Core;
@@ -14,6 +16,7 @@ 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()
{
Settings.Instance.PropertyChanged += SettingsOnPropertyChanged;
@@ -44,13 +47,13 @@ public static class ThemeManager
var diameter = 14;
var bitmap = new Bitmap(diameter, diameter);
var graphics = Graphics.FromImage(bitmap);
- graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+ graphics.SmoothingMode = SmoothingMode.AntiAlias;
var brush = new SolidBrush(Color.FromArgb(c.A, c.R, c.G, c.B));
graphics.FillEllipse(brush, 0, 0, diameter, diameter);
var bitmapSource = Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
- MainWindow.TaskbarItemInfo = new();
+ MainWindow.TaskbarItemInfo = new TaskbarItemInfo();
MainWindow.TaskbarItemInfo.Overlay = bitmapSource;
}
}
@@ -59,7 +62,6 @@ public static class ThemeManager
{
var color = Settings.Instance.BackgroundColor ?? DefaultBackgroundColor;
Application.Current.Resources["WindowBackground"] = new SolidColorBrush(color);
-
}
public static void InitializeTheme()
diff --git a/NebulaAuth/Core/TrayManager.cs b/NebulaAuth/Core/TrayManager.cs
index aa57e35..91724c1 100644
--- a/NebulaAuth/Core/TrayManager.cs
+++ b/NebulaAuth/Core/TrayManager.cs
@@ -1,9 +1,9 @@
-using NebulaAuth.Model;
-using System;
+using System;
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.Windows;
using System.Windows.Forms;
+using NebulaAuth.Model;
using Application = System.Windows.Application;
namespace NebulaAuth.Core;
@@ -29,7 +29,7 @@ public static class TrayManager
var contextMenu = new ContextMenuStrip();
- contextMenu.Items.Add("Выйти", null!, onClick: OnExitClick);
+ contextMenu.Items.Add("Выйти", null!, OnExitClick);
_notifyIcon.ContextMenuStrip = contextMenu;
diff --git a/NebulaAuth/Core/UpdateManager.cs b/NebulaAuth/Core/UpdateManager.cs
index d93e794..3415a49 100644
--- a/NebulaAuth/Core/UpdateManager.cs
+++ b/NebulaAuth/Core/UpdateManager.cs
@@ -1,24 +1,23 @@
-using AutoUpdaterDotNET;
-using NebulaAuth.Model;
-using System;
+using System;
using System.IO;
-
+using AutoUpdaterDotNET;
+using NebulaAuth.Model;
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";
+ private const string UPDATE_URL =
+ "https://raw.githubusercontent.com/achiez/NebulaAuth-Steam-Desktop-Authenticator-by-Achies/master/NebulaAuth/update.xml";
+
public static void CheckForUpdates()
{
- string jsonPath = Path.Combine(Environment.CurrentDirectory, "update-settings.json");
+ var jsonPath = Path.Combine(Environment.CurrentDirectory, "update-settings.json");
AutoUpdater.PersistenceProvider = new JsonFilePersistenceProvider(jsonPath);
AutoUpdater.ShowSkipButton = false;
if (Settings.Instance.AllowAutoUpdate)
AutoUpdater.UpdateMode = Mode.ForcedDownload;
AutoUpdater.Start(UPDATE_URL);
-
-
}
diff --git a/NebulaAuth/FodyWeavers.xml b/NebulaAuth/FodyWeavers.xml
index 4025f81..c97e85c 100644
--- a/NebulaAuth/FodyWeavers.xml
+++ b/NebulaAuth/FodyWeavers.xml
@@ -1,3 +1,3 @@
-
+
\ No newline at end of file
diff --git a/NebulaAuth/MainWindow.xaml b/NebulaAuth/MainWindow.xaml
index fbe2140..41e64c2 100644
--- a/NebulaAuth/MainWindow.xaml
+++ b/NebulaAuth/MainWindow.xaml
@@ -15,21 +15,19 @@
RenderOptions.BitmapScalingMode="HighQuality" Foreground="#FFF5F5F5"
FontFamily="{md:MaterialDesignFont}"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
- mc:Ignorable="d"
- d:DataContext="{d:DesignInstance viewModel:MainVM}"
-
-
- >
+ mc:Ignorable="d"
+ d:DataContext="{d:DesignInstance viewModel:MainVM}">
-
+
-
+
@@ -37,39 +35,61 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
+
-
-
-
+
+
+
-
+
-
-
+
+
-
-
+
+
-
@@ -82,37 +102,43 @@
-
+
-
+
-
+
-
+
-
-
+
+
+
@@ -126,27 +152,53 @@
-
-
-
+
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
@@ -162,74 +214,107 @@
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
-
+
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
@@ -247,7 +332,10 @@
-
+
@@ -257,14 +345,27 @@
-
+
-
-
+
+
-
-
+
+
@@ -273,15 +374,23 @@
-
+
-
+
-
- by achies
+
+
+ by achies
+
diff --git a/NebulaAuth/MainWindow.xaml.cs b/NebulaAuth/MainWindow.xaml.cs
index 114df1a..036123e 100644
--- a/NebulaAuth/MainWindow.xaml.cs
+++ b/NebulaAuth/MainWindow.xaml.cs
@@ -1,10 +1,4 @@
-using MaterialDesignThemes.Wpf;
-using NebulaAuth.Core;
-using NebulaAuth.Model;
-using NebulaAuth.View.Dialogs;
-using NebulaAuth.ViewModel;
-using NebulaAuth.ViewModel.Other;
-using System;
+using System;
using System.Diagnostics;
using System.Reflection;
using System.Threading.Tasks;
@@ -12,6 +6,12 @@ using System.Windows;
using System.Windows.Input;
using System.Windows.Navigation;
using System.Windows.Threading;
+using MaterialDesignThemes.Wpf;
+using NebulaAuth.Core;
+using NebulaAuth.Model;
+using NebulaAuth.View.Dialogs;
+using NebulaAuth.ViewModel;
+using NebulaAuth.ViewModel.Other;
namespace NebulaAuth;
@@ -37,7 +37,7 @@ public partial class MainWindow
private async Task ShowSetPasswordDialog()
{
var vm = new SetEncryptPasswordVM();
- var dialog = new SetCryptPasswordDialog()
+ var dialog = new SetCryptPasswordDialog
{
DataContext = vm
};
@@ -49,12 +49,20 @@ public partial class MainWindow
}
}
+ private void Hyperlink_OnRequestNavigate(object sender, RequestNavigateEventArgs e)
+ {
+ Process.Start(new ProcessStartInfo(e.Uri.ToString())
+ {
+ UseShellExecute = true
+ });
+ }
+
#region Dran'n'Drop
+
private void UIElement_OnPreviewTextInput(object sender, TextCompositionEventArgs e)
{
if (int.TryParse(e.Text, out _) == false) e.Handled = true;
-
}
private void Rectangle_DragEnter(object sender, DragEventArgs e)
@@ -72,12 +80,13 @@ public partial class MainWindow
private async void Rectangle_Drop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop) == false) return;
- string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop)!;
+ var filePaths = (string[]) e.Data.GetData(DataFormats.FileDrop)!;
if (filePaths.Length == 0) return;
if (DataContext is MainVM mainVm)
{
await mainVm.AddMafile(filePaths);
}
+
DragNDropPanel.Visibility = Visibility.Hidden;
DragNDropOverlay.Visibility = Visibility.Hidden;
}
@@ -98,15 +107,6 @@ public partial class MainWindow
{
DragNDropBorder.AllowDrop = true;
}
+
#endregion
-
- private void Hyperlink_OnRequestNavigate(object sender, RequestNavigateEventArgs e)
- {
- Process.Start(new ProcessStartInfo(e.Uri.ToString())
- {
- UseShellExecute = true
- });
- }
-
-
}
\ No newline at end of file
diff --git a/NebulaAuth/Model/Entities/LoginConfirmationResult.cs b/NebulaAuth/Model/Entities/LoginConfirmationResult.cs
index bb9b043..457aeec 100644
--- a/NebulaAuth/Model/Entities/LoginConfirmationResult.cs
+++ b/NebulaAuth/Model/Entities/LoginConfirmationResult.cs
@@ -6,14 +6,12 @@ public class LoginConfirmationResult
{
[MemberNotNullWhen(false, nameof(Error))]
public bool Success { get; set; }
+
public string IP { get; set; } = null!;
public string Country { get; set; } = null!;
public LoginConfirmationError? Error { get; set; }
-
-
}
-
public enum LoginConfirmationError
{
NoRequests,
diff --git a/NebulaAuth/Model/Entities/MaProxy.cs b/NebulaAuth/Model/Entities/MaProxy.cs
index 81e79bf..83af30b 100644
--- a/NebulaAuth/Model/Entities/MaProxy.cs
+++ b/NebulaAuth/Model/Entities/MaProxy.cs
@@ -5,7 +5,7 @@ using NebulaAuth.Model.Comparers;
namespace NebulaAuth.Model.Entities;
public class MaProxy
-{
+{
public int Id { get; }
public ProxyData Data { get; }
diff --git a/NebulaAuth/Model/Entities/Mafile.cs b/NebulaAuth/Model/Entities/Mafile.cs
index f869ca9..8773f08 100644
--- a/NebulaAuth/Model/Entities/Mafile.cs
+++ b/NebulaAuth/Model/Entities/Mafile.cs
@@ -20,8 +20,7 @@ public partial class Mafile : MobileDataExtended
set => SetProperty(ref _linkedClient, value);
}
- [JsonIgnore]
- private PortableMaClient? _linkedClient;
+ [JsonIgnore] private PortableMaClient? _linkedClient;
public void SetSessionData(MobileSessionData? sessionData)
@@ -48,7 +47,9 @@ public partial class Mafile : MobileDataExtended
SteamId = data.SteamId
};
}
- public static Mafile FromMobileDataExtended(MobileDataExtended data, MaProxy? proxy, string? group, string? password)
+
+ public static Mafile FromMobileDataExtended(MobileDataExtended data, MaProxy? proxy, string? group,
+ string? password)
{
var result = FromMobileDataExtended(data);
result.Proxy = proxy;
diff --git a/NebulaAuth/Model/Entities/MarketMultiConfirmation.cs b/NebulaAuth/Model/Entities/MarketMultiConfirmation.cs
index 7eda406..4b00ec2 100644
--- a/NebulaAuth/Model/Entities/MarketMultiConfirmation.cs
+++ b/NebulaAuth/Model/Entities/MarketMultiConfirmation.cs
@@ -8,9 +8,11 @@ namespace NebulaAuth.Model.Entities;
public class MarketMultiConfirmation : Confirmation
{
public ObservableCollection Confirmations { get; }
- public MarketMultiConfirmation(IEnumerable confirmations) : base(0, 0, 0, 0, ConfirmationType.Unknown, "")
+
+ public MarketMultiConfirmation(IEnumerable confirmations) : base(0, 0, 0, 0,
+ ConfirmationType.Unknown, "")
{
- Confirmations = new(confirmations);
+ Confirmations = new ObservableCollection(confirmations);
Time = Confirmations.FirstOrDefault()?.Time ?? default;
}
}
\ No newline at end of file
diff --git a/NebulaAuth/Model/Exceptions/MafileNeedReloginException.cs b/NebulaAuth/Model/Exceptions/MafileNeedReloginException.cs
index dbc7004..548008f 100644
--- a/NebulaAuth/Model/Exceptions/MafileNeedReloginException.cs
+++ b/NebulaAuth/Model/Exceptions/MafileNeedReloginException.cs
@@ -1,6 +1,5 @@
using System;
using NebulaAuth.Model.Entities;
-using SteamLib;
namespace NebulaAuth.Model.Exceptions;
diff --git a/NebulaAuth/Model/MAAC/MultiAccountAutoConfirmer.cs b/NebulaAuth/Model/MAAC/MultiAccountAutoConfirmer.cs
index 70b7224..63894c3 100644
--- a/NebulaAuth/Model/MAAC/MultiAccountAutoConfirmer.cs
+++ b/NebulaAuth/Model/MAAC/MultiAccountAutoConfirmer.cs
@@ -1,22 +1,23 @@
-using AchiesUtilities.Extensions;
-using NebulaAuth.Core;
-using NebulaAuth.Model.Entities;
-using System;
+using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using AchiesUtilities.Extensions;
+using NebulaAuth.Core;
+using NebulaAuth.Model.Entities;
+using NLog;
namespace NebulaAuth.Model.MAAC;
public static class MultiAccountAutoConfirmer
{
+ private const string LOC_PATH = "MAAC";
+ private static readonly ReaderWriterLockSlim Lock = new();
public static ObservableCollection Clients { get; }
private static Timer Timer { get; }
- private static readonly ReaderWriterLockSlim Lock = new();
- private const string LOC_PATH = "MAAC";
static MultiAccountAutoConfirmer()
{
@@ -26,7 +27,37 @@ public static class MultiAccountAutoConfirmer
UpdateTimer();
}
+ private static readonly SemaphoreSlim ExecutionLock = new(1, 1);
+
+ // ReSharper disable once AsyncVoidMethod //Already safe
private static async void TimerConfirm(object? state)
+ {
+ bool isHeld = false;
+ try
+ {
+ isHeld = await ExecutionLock.WaitAsync(0);
+ if (!isHeld)
+ {
+ SnackbarController.SendSnackbar(GetLocalization("TimerPreventedOverlap"));
+ return;
+ }
+ await TimerConfirmInternal();
+
+ }
+ catch (Exception e)
+ {
+ Shell.Logger.Error(e, "Error in MAAC timer");
+ }
+ finally
+ {
+ if (isHeld)
+ {
+ ExecutionLock.Release();
+ }
+ }
+ }
+
+ private static async Task TimerConfirmInternal()
{
var clients = Lock.ReadLock(() => Clients.ToArray());
var enabledClients = clients.Where(x => x.LinkedClient is { IsError: false }).ToArray();
@@ -78,23 +109,22 @@ public static class MultiAccountAutoConfirmer
added = true;
}
}
- }
- while (added);
+ } while (added);
return result;
}
}
-
+
public static bool TryAddToConfirm(Mafile mafile)
{
return Lock.WriteLock(() =>
- {
- if (Clients.Contains(mafile)) return false;
- Clients.Add(mafile);
- mafile.LinkedClient = new PortableMaClient(mafile);
- return true;
- });
+ {
+ if (Clients.Contains(mafile)) return false;
+ Clients.Add(mafile);
+ mafile.LinkedClient = new PortableMaClient(mafile);
+ return true;
+ });
}
diff --git a/NebulaAuth/Model/MAAC/PortableMaClient.cs b/NebulaAuth/Model/MAAC/PortableMaClient.cs
index 8376151..c73161e 100644
--- a/NebulaAuth/Model/MAAC/PortableMaClient.cs
+++ b/NebulaAuth/Model/MAAC/PortableMaClient.cs
@@ -1,4 +1,13 @@
-using AchiesUtilities.Web.Proxy;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Net.Http;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows;
+using AchiesUtilities.Web.Models;
+using AchiesUtilities.Web.Proxy;
using CommunityToolkit.Mvvm.ComponentModel;
using NebulaAuth.Core;
using NebulaAuth.Model.Entities;
@@ -9,30 +18,23 @@ using SteamLib.Core.Interfaces;
using SteamLib.Exceptions;
using SteamLib.SteamMobile.Confirmations;
using SteamLib.Web;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net.Http;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Windows;
-using AchiesUtilities.Web.Models;
namespace NebulaAuth.Model.MAAC;
public partial class PortableMaClient : ObservableObject, IDisposable
{
+ private const string LOC_PATH = "MAAC";
public Mafile Mafile { get; }
private HttpClient Client { get; }
private HttpClientHandler ClientHandler { get; }
private DynamicProxy Proxy { get; }
- [ObservableProperty] private bool _autoConfirmTrades;
- [ObservableProperty] private bool _autoConfirmMarket;
- [ObservableProperty] private bool _isError;
- private const string LOC_PATH = "MAAC";
-
private readonly CancellationTokenSource _cts = new();
+ [ObservableProperty] private bool _autoConfirmMarket;
+
+ [ObservableProperty] private bool _autoConfirmTrades;
+ [ObservableProperty] private bool _isError;
+
public PortableMaClient(Mafile mafile)
{
Mafile = mafile;
@@ -45,7 +47,7 @@ public partial class PortableMaClient : ObservableObject, IDisposable
Mafile.PropertyChanged += Mafile_PropertyChanged;
}
- private void Mafile_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
+ private void Mafile_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(Mafile.SessionData))
{
@@ -84,12 +86,14 @@ public partial class PortableMaClient : ObservableObject, IDisposable
Shell.Logger.Warn(ex, "Timer {accountName}: Error GetConf in timer.", Mafile.AccountName);
return 0;
}
+
var toConfirm = new List();
if (AutoConfirmMarket)
{
var market = conf.Where(c => c.ConfType == ConfirmationType.MarketSellTransaction);
toConfirm.AddRange(market);
}
+
if (AutoConfirmTrades)
{
var trade = conf.Where(c => c.ConfType == ConfirmationType.Trade);
@@ -99,7 +103,8 @@ public partial class PortableMaClient : ObservableObject, IDisposable
if (toConfirm.Count == 0) return 0;
try
{
- Shell.Logger.Debug("Timer {accountName}: Sending confirmations. Count: {count}", Mafile.AccountName, toConfirm.Count);
+ Shell.Logger.Debug("Timer {accountName}: Sending confirmations. Count: {count}", Mafile.AccountName,
+ toConfirm.Count);
var success = await HandleTimerRequest(() => SendConfirmations(toConfirm));
Shell.Logger.Debug("Timer {accountName}: Confirmation sent: {confirmResult}", Mafile.AccountName, success);
return toConfirm.Count;
@@ -114,12 +119,14 @@ public partial class PortableMaClient : ObservableObject, IDisposable
private async Task> GetConfirmations()
{
- return await SteamMobileConfirmationsApi.GetConfirmations(Client, Mafile, Mafile.SessionData!.SteamId, _cts.Token);
+ return await SteamMobileConfirmationsApi.GetConfirmations(Client, Mafile, Mafile.SessionData!.SteamId,
+ _cts.Token);
}
private async Task SendConfirmations(IEnumerable confirmations)
{
- return await SteamMobileConfirmationsApi.SendMultipleConfirmations(Client, confirmations, Mafile.SessionData!.SteamId, Mafile, true, _cts.Token);
+ return await SteamMobileConfirmationsApi.SendMultipleConfirmations(Client, confirmations,
+ Mafile.SessionData!.SteamId, Mafile, true, _cts.Token);
}
private async Task HandleTimerRequest(Func> func)
@@ -131,26 +138,30 @@ public partial class PortableMaClient : ObservableObject, IDisposable
}
catch (OperationCanceledException ex)
{
- innerException = ex; //Ignored
+ innerException = ex; //Ignored
}
catch (SessionInvalidException ex)
{
if (IgnoreTimerErrors())
{
- Shell.Logger.Warn("Timer {accountName}: Session error while requesting in timer. Ignored due to IgnorePatchTuesdayErrors setting", Mafile.AccountName);
+ Shell.Logger.Warn(
+ "Timer {accountName}: Session error while requesting in timer. Ignored due to IgnorePatchTuesdayErrors setting",
+ Mafile.AccountName);
}
else
{
- Shell.Logger.Warn("Timer {accountName}: Session error while requesting in timer. Timer disabled", Mafile.AccountName);
+ Shell.Logger.Warn("Timer {accountName}: Session error while requesting in timer. Timer disabled",
+ Mafile.AccountName);
SetError();
}
innerException = ex;
}
- catch (Exception ex) when (ExceptionHandler.Handle(ex, prefix: GetTimerPrefix()))
+ catch (Exception ex) when (ExceptionHandler.Handle(ex, GetTimerPrefix()))
{
innerException = ex;
}
+
throw new ApplicationException("Swallowed", innerException);
}
@@ -163,13 +174,16 @@ public partial class PortableMaClient : ObservableObject, IDisposable
var pstNow = TimeZoneInfo.ConvertTime(DateTime.UtcNow, pstZone);
var startTime = pstNow.Date.AddHours(15).AddMinutes(55); // 15:55 PST //22:55 GMT //00:55 GMT+2
- var endTime = pstNow.Date.AddHours(17).AddMinutes(15); // 17:15 PST //00:15 GMT //02:15 GMT+2
+ var endTime = pstNow.Date.AddHours(17).AddMinutes(15); // 17:15 PST //00:15 GMT //02:15 GMT+2
return pstNow.DayOfWeek == DayOfWeek.Tuesday && pstNow >= startTime && pstNow <= endTime;
}
- private HttpClientHandlerPair Chp() => new(Client, ClientHandler);
+ private HttpClientHandlerPair Chp()
+ {
+ return new HttpClientHandlerPair(Client, ClientHandler);
+ }
private static string GetLocalization(string key)
{
diff --git a/NebulaAuth/Model/MaClient.cs b/NebulaAuth/Model/MaClient.cs
index 344eb43..2ad2a31 100644
--- a/NebulaAuth/Model/MaClient.cs
+++ b/NebulaAuth/Model/MaClient.cs
@@ -1,4 +1,9 @@
-using AchiesUtilities.Web.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Http;
+using System.Threading.Tasks;
+using AchiesUtilities.Web.Models;
using AchiesUtilities.Web.Proxy;
using NebulaAuth.Model.Entities;
using SteamLib.Api.Mobile;
@@ -8,15 +13,9 @@ using SteamLib.Exceptions;
using SteamLib.ProtoCore.Services;
using SteamLib.SteamMobile.Confirmations;
using SteamLib.Web;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net.Http;
-using System.Threading.Tasks;
namespace NebulaAuth.Model;
-
public static class MaClient
{
private static HttpClientHandler ClientHandler { get; }
@@ -26,7 +25,6 @@ public static class MaClient
private static DynamicProxy Proxy { get; }
public static ProxyData? DefaultProxy { get; set; }
- public static HttpClientHandlerPair Chp => new(Client, ClientHandler);
static MaClient()
{
@@ -52,6 +50,7 @@ public static class MaClient
ClientHandler.CookieContainer.AddMinimalMobileCookies();
AdmissionHelper.TransferCommunityCookies(ClientHandler.CookieContainer);
}
+
Proxy.SetData(account.Proxy?.Data);
}
}
@@ -66,7 +65,8 @@ public static class MaClient
public static Task LoginAgain(Mafile mafile, string password, bool savePassword, ICaptchaResolver? resolver)
{
SetProxy(mafile);
- return SessionHandler.LoginAgain(Chp, mafile, password, savePassword);
+ return SessionHandler.LoginAgain(new HttpClientHandlerPair(Client, ClientHandler), mafile, password,
+ savePassword);
}
@@ -74,27 +74,30 @@ public static class MaClient
{
ValidateMafile(mafile, true);
SetProxy(mafile);
- return SessionHandler.RefreshMobileToken(Chp, mafile);
+ return SessionHandler.RefreshMobileToken(new HttpClientHandlerPair(Client, ClientHandler), mafile);
}
public static Task SendConfirmation(Mafile mafile, Confirmation confirmation, bool confirm)
{
ValidateMafile(mafile);
SetProxy(mafile);
- return SteamMobileConfirmationsApi.SendConfirmation(Client, confirmation, mafile.SessionData!.SteamId, mafile, confirm);
+ return SteamMobileConfirmationsApi.SendConfirmation(Client, confirmation, mafile.SessionData!.SteamId, mafile,
+ confirm);
}
- public static Task SendMultipleConfirmation(Mafile mafile, IEnumerable confirmations, bool confirm)
+ public static Task SendMultipleConfirmation(Mafile mafile, IEnumerable confirmations,
+ bool confirm)
{
var enumerable = confirmations.ToList();
if (enumerable.Count == 0)
{
- return Task.FromResult(result: false);
+ return Task.FromResult(false);
}
ValidateMafile(mafile);
SetProxy(mafile);
- return SteamMobileConfirmationsApi.SendMultipleConfirmations(Client, enumerable, mafile.SessionData!.SteamId, mafile, confirm);
+ return SteamMobileConfirmationsApi.SendMultipleConfirmations(Client, enumerable, mafile.SessionData!.SteamId,
+ mafile, confirm);
}
public static Task RemoveAuthenticator(Mafile mafile)
@@ -105,6 +108,7 @@ public static class MaClient
{
throw new InvalidOperationException("This mafile does not have R-Code");
}
+
var token = mafile.SessionData!.GetMobileToken()!;
return SteamMobileApi.RemoveAuthenticator(Client, token.Value.Token, mafile.RevocationCode);
}
@@ -126,7 +130,6 @@ public static class MaClient
if (access == null || access.Value.IsExpired)
throw new SessionPermanentlyExpiredException();
}
-
}
public static async Task ConfirmLoginRequest(Mafile mafile)
@@ -143,6 +146,7 @@ public static class MaClient
Error = LoginConfirmationError.NoRequests
};
}
+
if (sessions.ClientIds.Count > 1)
{
return new LoginConfirmationResult
@@ -169,4 +173,10 @@ public static class MaClient
Success = true
};
}
+
+ public static HttpClientHandlerPair GetHttpClientHandlerPair(Mafile mafile)
+ {
+ SetProxy(mafile);
+ return new HttpClientHandlerPair(Client, ClientHandler);
+ }
}
\ No newline at end of file
diff --git a/NebulaAuth/Model/NebulaSerializer.cs b/NebulaAuth/Model/NebulaSerializer.cs
index 8a28f23..6ab8654 100644
--- a/NebulaAuth/Model/NebulaSerializer.cs
+++ b/NebulaAuth/Model/NebulaSerializer.cs
@@ -1,11 +1,11 @@
-using NebulaAuth.Model.Entities;
+using System;
+using System.Collections.Generic;
+using NebulaAuth.Model.Entities;
+using NebulaAuth.Model.Exceptions;
+using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SteamLib;
using SteamLib.Utility.MafileSerialization;
-using System.Collections.Generic;
-using System;
-using NebulaAuth.Model.Exceptions;
-using Newtonsoft.Json;
namespace NebulaAuth.Model;
@@ -34,13 +34,13 @@ public static class NebulaSerializer
var info = data.Info;
if (info.IsExtended == false)
throw new FormatException("Mafile is not extended data");
-
+
var props = info.UnusedProperties ?? new Dictionary();
var proxy = GetPropertyValue("Proxy", props);
var group = GetPropertyValue("Group", props);
var password = GetPropertyValue("Password", props);
- var mafile = Mafile.FromMobileDataExtended((MobileDataExtended)mobileData, proxy, group, password);
+ var mafile = Mafile.FromMobileDataExtended((MobileDataExtended) mobileData, proxy, group, password);
if (!info.SteamIdValid)
@@ -82,9 +82,7 @@ public static class NebulaSerializer
{
return MafileSerializer.SerializeLegacy(data, Formatting.Indented, properties);
}
- else
- {
- return MafileSerializer.Serialize(data);
- }
+
+ return MafileSerializer.Serialize(data);
}
}
\ No newline at end of file
diff --git a/NebulaAuth/Model/PHandler.cs b/NebulaAuth/Model/PHandler.cs
index b5d8687..4b9c664 100644
--- a/NebulaAuth/Model/PHandler.cs
+++ b/NebulaAuth/Model/PHandler.cs
@@ -7,15 +7,14 @@ namespace NebulaAuth.Model;
public static class PHandler
{
- public static bool IsPasswordSet => _k.Length > 0;
private static byte[] _k = [];
+ public static bool IsPasswordSet => _k.Length > 0;
///
- ///
///
///
- /// if password was set and not empty. Otherwise -
+ /// if password was set and not empty. Otherwise -
public static bool SetPassword(string? password)
{
if (string.IsNullOrWhiteSpace(password))
@@ -80,5 +79,16 @@ public static class PHandler
return decryptedText;
}
-
+ public static string? DecryptPassword(string? encryptedPassword)
+ {
+ if (string.IsNullOrWhiteSpace(encryptedPassword)) return null;
+ try
+ {
+ return Decrypt(encryptedPassword);
+ }
+ catch (Exception)
+ {
+ return null;
+ }
+ }
}
\ No newline at end of file
diff --git a/NebulaAuth/Model/ProxyStorage.cs b/NebulaAuth/Model/ProxyStorage.cs
index 3e542d0..49b4ccb 100644
--- a/NebulaAuth/Model/ProxyStorage.cs
+++ b/NebulaAuth/Model/ProxyStorage.cs
@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Linq;
using AchiesUtilities.Collections;
using AchiesUtilities.Web.Proxy;
-using System.Linq;
using AchiesUtilities.Web.Proxy.Parsing;
using NebulaAuth.Core;
using Newtonsoft.Json;
@@ -12,14 +12,13 @@ namespace NebulaAuth.Model;
public static class ProxyStorage
{
-
public const string FORMAT = ADDRESS_FORMAT + ":{USER}:{PASS}";
public const string ADDRESS_FORMAT = "{IP}:{PORT}";
public static readonly ProxyParser DefaultScheme = new(
ProxyDefaultFormats.UniversalColon, false, ProxyProtocol.HTTP,
ProxyPatternProtocol.All,
- ProxyPatternHostFormat.Domain | ProxyPatternHostFormat.IPv4,
+ ProxyPatternHostFormat.Domain | ProxyPatternHostFormat.IPv4,
PatternRequirement.Optional,
PatternRequirement.Optional);
@@ -29,7 +28,6 @@ public static class ProxyStorage
static ProxyStorage()
{
-
if (File.Exists("proxies.json") == false)
return;
try
@@ -145,7 +143,7 @@ public static class ProxyStorage
private class ProxiesSchema
{
- public ObservableDictionary ProxiesData = [];
public int? DefaultProxy;
+ public ObservableDictionary ProxiesData = [];
}
}
\ No newline at end of file
diff --git a/NebulaAuth/Model/SessionHandler.cs b/NebulaAuth/Model/SessionHandler.cs
index 8c0e267..d042159 100644
--- a/NebulaAuth/Model/SessionHandler.cs
+++ b/NebulaAuth/Model/SessionHandler.cs
@@ -1,25 +1,24 @@
-using AchiesUtilities.Web.Models;
-using MaterialDesignThemes.Wpf;
-using NebulaAuth.Core;
-using NebulaAuth.Model.Entities;
-using SteamLib.Exceptions;
-using System;
+using System;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
+using AchiesUtilities.Web.Models;
+using MaterialDesignThemes.Wpf;
+using NebulaAuth.Core;
+using NebulaAuth.Model.Entities;
using NebulaAuth.View.Dialogs;
+using SteamLib.Exceptions;
namespace NebulaAuth.Model;
public static partial class SessionHandler
{
-
private static readonly SemaphoreSlim Semaphore = new(1, 1);
public static async Task Handle(Func> func, Mafile mafile,
HttpClientHandlerPair? chp = null, string? snackbarPrefix = null)
{
- chp ??= MaClient.Chp;
+ chp ??= MaClient.GetHttpClientHandlerPair(mafile);
await Semaphore.WaitAsync();
try
{
@@ -50,12 +49,14 @@ public static partial class SessionHandler
{
if (ex is SessionPermanentlyExpiredException)
{
- Shell.Logger.Debug(ex, "RefreshToken on mafile {name} {steamid} is expired", mafile.AccountName, mafile.SessionData?.SteamId);
+ Shell.Logger.Debug(ex, "RefreshToken on mafile {name} {steamid} is expired", mafile.AccountName,
+ mafile.SessionData?.SteamId);
refreshTokenExpired = true;
}
else
{
- Shell.Logger.Debug(ex, "MobileToken on mafile {name} {steamid} is expired", mafile.AccountName, mafile.SessionData?.SteamId);
+ Shell.Logger.Debug(ex, "MobileToken on mafile {name} {steamid} is expired", mafile.AccountName,
+ mafile.SessionData?.SteamId);
}
}
}
@@ -67,21 +68,25 @@ public static partial class SessionHandler
var refreshed = await RefreshInternal(chp, mafile);
if (refreshed)
{
- SnackbarController.SendSnackbar(snackbarPrefix + LocManager.GetCodeBehindOrDefault("SessionWasRefreshedAutomatically", "SessionHandler", "SessionWasRefreshedAutomatically"));
+ SnackbarController.SendSnackbar(snackbarPrefix +
+ LocManager.GetCodeBehindOrDefault("SessionWasRefreshedAutomatically",
+ "SessionHandler", "SessionWasRefreshedAutomatically"));
try
{
return await func();
}
catch (SessionInvalidException ex)
{
- Shell.Logger.Info(ex, "MobileToken on {name} {steamid} was refreshed but after it, error occured", mafile.AccountName, mafile.SessionData?.SteamId);
+ Shell.Logger.Info(ex, "MobileToken on {name} {steamid} was refreshed but after it, error occured",
+ mafile.AccountName, mafile.SessionData?.SteamId);
if (password == null)
throw;
}
}
}
- Shell.Logger.Debug("Session on mafile {name} {steamid} is invalid/expired", mafile.AccountName, mafile.SessionData?.SteamId);
+ Shell.Logger.Debug("Session on mafile {name} {steamid} is invalid/expired", mafile.AccountName,
+ mafile.SessionData?.SteamId);
//State: mobileToken invalid/expired, refreshToken invalid/expired
if (password != null)
@@ -89,7 +94,8 @@ public static partial class SessionHandler
var logged = await LoginAgainInternal(chp, mafile, password, true);
if (logged)
{
- Shell.Logger.Debug("Mafile {name} {steamid} was succesfully auto-relogined", mafile.AccountName, mafile.SessionData?.SteamId);
+ Shell.Logger.Debug("Mafile {name} {steamid} was succesfully auto-relogined", mafile.AccountName,
+ mafile.SessionData?.SteamId);
return await func();
}
}
@@ -99,7 +105,6 @@ public static partial class SessionHandler
}
-
private static bool MobileTokenExpired(Mafile mafile)
{
var mobileToken = mafile.SessionData?.GetMobileToken();
@@ -108,7 +113,8 @@ public static partial class SessionHandler
private static bool RefreshTokenExpired(Mafile mafile)
{
- return mafile.SessionData?.RefreshToken.IsExpired != false;
+ var refreshToken = mafile.SessionData?.RefreshToken;
+ return refreshToken == null || refreshToken.Value.IsExpired;
}
private static string? GetPassword(Mafile mafile)
@@ -136,9 +142,10 @@ public static partial class SessionHandler
await RefreshMobileToken(chp, mafile);
return true;
}
- catch(Exception ex)
+ catch (SessionInvalidException ex)
{
- Shell.Logger.Debug(ex, "Failed to refresh session on mafile {name} {steamid}", mafile.AccountName, mafile.SessionData?.SteamId);
+ Shell.Logger.Debug(ex, "Failed to refresh session on mafile {name} {steamid}", mafile.AccountName,
+ mafile.SessionData?.SteamId);
return false;
}
}
@@ -149,11 +156,10 @@ public static partial class SessionHandler
var t = Task.Run(OnLoginStarted);
try
{
-
await LoginAgain(chp, mafile, password, savePassword);
return true;
}
- catch (Exception ex)
+ catch (Exception ex) //TODO: this will catch any error, even Proxy/Http/Socket errors.
{
Shell.Logger.Debug(ex, "Failed to relogin mafile {name} {steamid}", mafile.AccountName,
mafile.SessionData?.SteamId);
@@ -169,10 +175,7 @@ public static partial class SessionHandler
private static async Task OnLoginStarted()
{
if (DialogHost.IsDialogOpen(null)) return;
- await Application.Current.Dispatcher.BeginInvoke(async () =>
- {
- await DialogHost.Show(new WaitLoginDialog());
- });
+ await Application.Current.Dispatcher.BeginInvoke(async () => { await DialogHost.Show(new WaitLoginDialog()); });
}
private static void OnLoginCompleted()
@@ -180,7 +183,7 @@ public static partial class SessionHandler
var currentSession = DialogHost.GetDialogSession(null);
Application.Current.Dispatcher.BeginInvoke(() =>
{
- if (currentSession is { Content: WaitLoginDialog, IsEnded: false })
+ if (currentSession is {Content: WaitLoginDialog, IsEnded: false})
{
try
{
@@ -193,6 +196,4 @@ public static partial class SessionHandler
}
});
}
-
-
}
\ No newline at end of file
diff --git a/NebulaAuth/Model/SessionHandler_API.cs b/NebulaAuth/Model/SessionHandler_API.cs
index 9c9e7c0..c6ebd25 100644
--- a/NebulaAuth/Model/SessionHandler_API.cs
+++ b/NebulaAuth/Model/SessionHandler_API.cs
@@ -1,4 +1,5 @@
-using AchiesUtilities.Web.Models;
+using System.Threading.Tasks;
+using AchiesUtilities.Web.Models;
using NebulaAuth.Model.Entities;
using SteamLib.Account;
using SteamLib.Api.Mobile;
@@ -6,7 +7,6 @@ using SteamLib.Authentication;
using SteamLib.Authentication.LoginV2;
using SteamLib.Exceptions;
using SteamLib.SteamMobile;
-using System.Threading.Tasks;
namespace NebulaAuth.Model;
@@ -14,11 +14,13 @@ public partial class SessionHandler //API
{
public static async Task RefreshMobileToken(HttpClientHandlerPair chp, Mafile mafile)
{
- if (mafile.SessionData is not { RefreshToken.IsExpired: false })
+ if (mafile.SessionData is not {RefreshToken.IsExpired: false})
throw new SessionPermanentlyExpiredException(SessionInvalidException.SESSION_NULL_MSG);
- var mobileToken = await SteamMobileApi.RefreshJwt(chp.Client, mafile.SessionData.RefreshToken.Token, mafile.SessionData.SteamId);
- Shell.Logger.Info("MobileToken on {name} {steamid} successfully refreshed", mafile.AccountName, mafile.SessionData.SteamId);
+ var mobileToken = await SteamMobileApi.RefreshJwt(chp.Client, mafile.SessionData.RefreshToken.Token,
+ mafile.SessionData.SteamId);
+ Shell.Logger.Info("MobileToken on {name} {steamid} successfully refreshed", mafile.AccountName,
+ mafile.SessionData.SteamId);
var newToken = SteamTokenHelper.Parse(mobileToken);
mafile.SessionData.SetMobileToken(newToken);
@@ -38,7 +40,7 @@ public partial class SessionHandler //API
Logger = Shell.ExtensionsLogger,
SteamGuardProvider = sgGenerator,
DeviceDetails = LoginV2ExecutorOptions.GetMobileDefaultDevice(),
- WebsiteId = "Mobile",
+ WebsiteId = "Mobile"
};
chp.Handler.CookieContainer.ClearMobileSessionCookies();
var result = await LoginV2Executor.DoLogin(options, mafile.AccountName, password);
@@ -47,7 +49,7 @@ public partial class SessionHandler //API
//Triggers PropertyChanged event for PortableMaClient handling session updated from MaClient
//RETHINK: it makes double operation when session handled from PortableMaClient (more often scenario) which is unwanted behaviour
- mafile.SetSessionData((MobileSessionData)result);
+ mafile.SetSessionData((MobileSessionData) result);
if (PHandler.IsPasswordSet)
mafile.Password = savePassword ? PHandler.Encrypt(password) : null;
Storage.UpdateMafile(mafile);
diff --git a/NebulaAuth/Model/Settings.cs b/NebulaAuth/Model/Settings.cs
index 31a4438..12fc064 100644
--- a/NebulaAuth/Model/Settings.cs
+++ b/NebulaAuth/Model/Settings.cs
@@ -1,36 +1,22 @@
-using NebulaAuth.Core;
-using Newtonsoft.Json;
-using System;
+using System;
using System.ComponentModel;
using System.IO;
using System.Windows.Media;
using CommunityToolkit.Mvvm.ComponentModel;
+using NebulaAuth.Core;
+using Newtonsoft.Json;
namespace NebulaAuth.Model;
public partial class Settings : ObservableObject
{
- #region Properties
-
- [ObservableProperty] private BackgroundMode _backgroundMode = BackgroundMode.Default;
- [ObservableProperty] private bool _hideToTray;
- [ObservableProperty] private int _timerSeconds = 60;
- [ObservableProperty] private Color? _backgroundColor;
- [ObservableProperty] private Color? _iconColor;
- [ObservableProperty] private bool _isPasswordSet;
- [ObservableProperty] private LocalizationLanguage _language = LocalizationLanguage.English;
- [ObservableProperty] private bool _legacyMode = true;
- [ObservableProperty] private bool _allowAutoUpdate;
- [ObservableProperty] private bool _useAccountNameAsMafileName;
- [ObservableProperty] private bool _ignorePatchTuesdayErrors;
- #endregion
-
public static Settings Instance { get; }
+
static Settings()
{
if (File.Exists("settings.json") == false)
{
- Instance = new();
+ Instance = new Settings();
Instance.PropertyChanged += SettingsOnPropertyChanged;
return;
}
@@ -45,8 +31,9 @@ public partial class Settings : ObservableObject
{
SnackbarController.SendSnackbar("Ошибка при загрузке настроек. Настройки были сброшены");
SnackbarController.SendSnackbar(ex.Message);
- Instance = new();
+ Instance = new Settings();
}
+
Instance.PropertyChanged += SettingsOnPropertyChanged;
}
@@ -61,10 +48,26 @@ public partial class Settings : ObservableObject
File.WriteAllText("settings.json", json);
}
-}
+ #region Properties
+ [ObservableProperty] private BackgroundMode _backgroundMode = BackgroundMode.Default;
+ [ObservableProperty] private bool _hideToTray;
+ [ObservableProperty] private int _timerSeconds = 60;
+ [ObservableProperty] private Color? _backgroundColor;
+ [ObservableProperty] private Color? _iconColor;
+ [ObservableProperty] private bool _isPasswordSet;
+ [ObservableProperty] private LocalizationLanguage _language = LocalizationLanguage.English;
+ [ObservableProperty] private bool _legacyMode = true;
+ [ObservableProperty] private bool _allowAutoUpdate;
+ [ObservableProperty] private bool _useAccountNameAsMafileName;
+ [ObservableProperty] private bool _ignorePatchTuesdayErrors;
+
+ #endregion
+}
public enum BackgroundMode
{
- Default, Custom, Color
+ Default,
+ Custom,
+ Color
}
\ No newline at end of file
diff --git a/NebulaAuth/Model/Shell.cs b/NebulaAuth/Model/Shell.cs
index 581702d..6464c68 100644
--- a/NebulaAuth/Model/Shell.cs
+++ b/NebulaAuth/Model/Shell.cs
@@ -1,9 +1,10 @@
-using NebulaAuth.Model.Exceptions;
+using System;
+using Microsoft.Extensions.Logging;
+using NebulaAuth.Model.Exceptions;
using NLog;
+using NLog.Extensions.Logging;
using SteamLib.Core;
using SteamLib.SteamMobile;
-using System;
-using Microsoft.Extensions.Logging;
using ILogger = Microsoft.Extensions.Logging.ILogger;
namespace NebulaAuth.Model;
@@ -12,15 +13,15 @@ public static class Shell
{
public static Logger Logger { get; } = LogManager.GetLogger("Logger");
public static ILogger ExtensionsLogger { get; private set; } = null!;
+
public static void Initialize()
{
-
- var lp = new NLog.Extensions.Logging.NLogLoggerProvider();
+ var lp = new NLogLoggerProvider();
var logger = lp.CreateLogger("SteamLib");
SteamLibErrorMonitor.MonitorLogger = logger;
AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
- var loggerFactory = new NLog.Extensions.Logging.NLogLoggerFactory();
+ var loggerFactory = new NLogLoggerFactory();
ExtensionsLogger = loggerFactory.CreateLogger("Logger");
try
@@ -31,11 +32,12 @@ public static class Shell
{
throw new CantAlignTimeException("", ex);
}
+
ExtensionsLogger.LogDebug("Application started");
}
private static void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
- Logger.Fatal((Exception)e.ExceptionObject);
+ Logger.Fatal((Exception) e.ExceptionObject);
}
}
\ No newline at end of file
diff --git a/NebulaAuth/Model/Storage.cs b/NebulaAuth/Model/Storage.cs
index 45e935a..49f42ad 100644
--- a/NebulaAuth/Model/Storage.cs
+++ b/NebulaAuth/Model/Storage.cs
@@ -1,16 +1,14 @@
-using NebulaAuth.Model.Entities;
-using SteamLib.Core.Models;
-using SteamLib.Exceptions;
-using SteamLib.SteamMobile;
-using System;
+using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using AchiesUtilities.Extensions;
+using NebulaAuth.Model.Entities;
using NebulaAuth.Model.Exceptions;
-using NLog.Targets;
-using SteamLib;
+using SteamLib.Core.Models;
+using SteamLib.Exceptions;
+using SteamLib.SteamMobile;
namespace NebulaAuth.Model;
@@ -20,12 +18,13 @@ public static class Storage
public const string MAFILE_F = "maFiles";
public const string REMOVED_F = "maFiles_removed";
+ public static readonly int DuplicateFound;
+
public static string MafileFolder { get; } = Path.GetFullPath(MAFILE_F);
public static string RemovedMafileFolder { get; } = Path.GetFullPath(REMOVED_F);
public static ObservableCollection MaFiles { get; } = new();
- public static readonly int DuplicateFound;
static Storage()
{
if (Directory.Exists(MafileFolder) == false)
@@ -55,6 +54,7 @@ public static class Storage
Shell.Logger.Error("Duplicate mafile {file}", Path.GetFileName(file));
continue;
}
+
hashNames.Add(data.AccountName);
if (data.SessionData != null) hashIds.Add(data.SteamId);
MaFiles.Add(data);
@@ -69,7 +69,6 @@ public static class Storage
}
///
- ///
///
///
///
@@ -84,11 +83,12 @@ public static class Storage
data = ReadMafile(path);
}
catch (Exception ex)
- when(ex is not MafileNeedReloginException)
+ when (ex is not MafileNeedReloginException)
{
Shell.Logger.Warn(ex, "Can't load mafile");
throw new FormatException("File data is not valid", ex);
}
+
if (string.IsNullOrWhiteSpace(data.AccountName))
throw new FormatException("File data is not valid. Missing AccountName");
@@ -153,6 +153,7 @@ public static class Storage
i++;
copyPathCompleted = copyPath + $" ({i})";
}
+
File.Copy(path, copyPathCompleted, false);
File.Delete(path);
MaFiles.Remove(data);
@@ -167,8 +168,15 @@ public static class Storage
return Path.Combine(MafileFolder, fileName);
}
- private static string CreateFileNameWithAccountName(string accountName) => accountName + ".mafile";
- private static string CreateFileNameWithSteamId(SteamId steamId) => steamId.Steam64.Id + ".mafile";
+ private static string CreateFileNameWithAccountName(string accountName)
+ {
+ return accountName + ".mafile";
+ }
+
+ private static string CreateFileNameWithSteamId(SteamId steamId)
+ {
+ return steamId.Steam64.Id + ".mafile";
+ }
public static string? TryFindMafilePath(Mafile data)
{
@@ -186,10 +194,12 @@ public static class Storage
{
return Settings.Instance.UseAccountNameAsMafileName ? pathFileName : pathSteamId;
}
+
if (steamIdExist ^ accountNameExist)
{
return steamIdExist ? pathSteamId : pathFileName;
}
+
return null;
}
}
@@ -197,9 +207,10 @@ public static class Storage
//TODO: Refactor
internal class MafileNameComparer : IComparer
{
- public bool MafileNameMode { get; }
private const string MAF_64_START = "765";
private static readonly IComparer DefaultComparer = Comparer.Default;
+ public bool MafileNameMode { get; }
+
public MafileNameComparer(bool mafileNameMode)
{
MafileNameMode = mafileNameMode;
@@ -213,8 +224,8 @@ internal class MafileNameComparer : IComparer
if (y == null) return 1;
- bool xisSteamId = Path.GetFileName(x).StartsWith(MAF_64_START);
- bool yisSteamId = Path.GetFileName(y).StartsWith(MAF_64_START);
+ var xisSteamId = Path.GetFileName(x).StartsWith(MAF_64_START);
+ var yisSteamId = Path.GetFileName(y).StartsWith(MAF_64_START);
if (xisSteamId ^ yisSteamId)
{
@@ -222,13 +233,10 @@ internal class MafileNameComparer : IComparer
{
return xisSteamId ? 1 : -1;
}
- else
- {
- return yisSteamId ? 1 : -1;
- }
+
+ return yisSteamId ? 1 : -1;
}
return DefaultComparer.Compare(x, y);
}
-
}
\ No newline at end of file
diff --git a/NebulaAuth/NLog.config b/NebulaAuth/NLog.config
index 8e85183..dd93a45 100644
--- a/NebulaAuth/NLog.config
+++ b/NebulaAuth/NLog.config
@@ -1,22 +1,22 @@
-
+
+
+ deleteOldFileOnStartup="true">
-
+
-
+
-
+
diff --git a/NebulaAuth/NebulaAuth.csproj b/NebulaAuth/NebulaAuth.csproj
index 3660279..440bd73 100644
--- a/NebulaAuth/NebulaAuth.csproj
+++ b/NebulaAuth/NebulaAuth.csproj
@@ -10,7 +10,7 @@
en;ru;ua
Theme\lock.ico
7.0
- 1.5.5
+ 1.5.6
true
diff --git a/NebulaAuth/Theme/FontScaleWindow.cs b/NebulaAuth/Theme/FontScaleWindow.cs
index b5836d4..b82515b 100644
--- a/NebulaAuth/Theme/FontScaleWindow.cs
+++ b/NebulaAuth/Theme/FontScaleWindow.cs
@@ -6,51 +6,15 @@ namespace NebulaAuth.Theme;
public class FontScaleWindow : Window
{
-
- private readonly Func _diagonal = (h, w) => Math.Sqrt(h * h + w * w);
- private double _currentDiagonal;
- private double _defaultDiagonal = 1;
- private readonly HashSet _cachedObjects = new();
- private bool _loaded;
-
- public FontScaleWindow()
- {
- Loaded += OnLoaded;
-
- }
-
- private void OnLoaded(object sender, RoutedEventArgs e)
- {
- var w = (FontScaleWindow)sender;
- w._defaultDiagonal = _diagonal(MinHeight, MinWidth);
- w.SizeChanged += OnSizeChanged;
- w.Loaded -= OnLoaded;
- _loaded = true;
- w.Width += 1;
- w.Width -= 1;
- }
-
-
- //<-------------------Window-------------------->
- public double DefaultFontSize
- {
- get => (double)GetValue(DefaultFontSizeProperty);
- set => SetValue(DefaultFontSizeProperty, value);
- }
-
- public double ScaleCoefficient
- {
- get => (double)GetValue(ScaleCoefficientProperty);
- set => SetValue(ScaleCoefficientProperty, value);
- }
-
// Using a DependencyProperty as the backing store for ScaleCoefficient. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ScaleCoefficientProperty =
- DependencyProperty.Register("ScaleCoefficient", typeof(double), typeof(FontScaleWindow), new PropertyMetadata(1d));
+ DependencyProperty.Register("ScaleCoefficient", typeof(double), typeof(FontScaleWindow),
+ new PropertyMetadata(1d));
public static readonly DependencyProperty DefaultFontSizeProperty =
- DependencyProperty.Register("DefaultFontSize", typeof(double), typeof(FontScaleWindow), new PropertyMetadata(20d));
+ DependencyProperty.Register("DefaultFontSize", typeof(double), typeof(FontScaleWindow),
+ new PropertyMetadata(20d));
private static readonly DependencyPropertyKey ParentScaleWindowKey
@@ -63,19 +27,74 @@ public class FontScaleWindow : Window
public static readonly DependencyProperty ParentScaleWindowProperty
= ParentScaleWindowKey.DependencyProperty;
- private static FontScaleWindow? GetParentScaleWindow(DependencyObject element) =>
- (FontScaleWindow)element.GetValue(ParentScaleWindowProperty);
- private static void SetParentScaleWindow(DependencyObject element, FontScaleWindow value) =>
- element.SetValue(ParentScaleWindowKey, value);
-
public static readonly DependencyProperty ResizeFontProperty = DependencyProperty.RegisterAttached(
"ResizeFont", typeof(bool), typeof(FontScaleWindow), new FrameworkPropertyMetadata(false, ResizeCallBack));
+ //<-------------------Window-------------------->
+
+
+ //<-------------------Scaling-------------------->
+
+ public static readonly DependencyProperty ScaleProperty = DependencyProperty.RegisterAttached(
+ "Scale", typeof(double), typeof(FontScaleWindow),
+ new FrameworkPropertyMetadata(0.9999d, FrameworkPropertyMetadataOptions.Inherits, ScalePropertyCallback));
+
+
+ //<-------------------Window-------------------->
+ public double DefaultFontSize
+ {
+ get => (double) GetValue(DefaultFontSizeProperty);
+ set => SetValue(DefaultFontSizeProperty, value);
+ }
+
+ public double ScaleCoefficient
+ {
+ get => (double) GetValue(ScaleCoefficientProperty);
+ set => SetValue(ScaleCoefficientProperty, value);
+ }
+
+ private readonly HashSet _cachedObjects = new();
+
+ private readonly Func _diagonal = (h, w) => Math.Sqrt(h * h + w * w);
+ private double _currentDiagonal;
+ private double _defaultDiagonal = 1;
+ private bool _loaded;
+
+ public FontScaleWindow()
+ {
+ Loaded += OnLoaded;
+ }
+
+ private void OnLoaded(object sender, RoutedEventArgs e)
+ {
+ var w = (FontScaleWindow) sender;
+ w._defaultDiagonal = _diagonal(MinHeight, MinWidth);
+ w.SizeChanged += OnSizeChanged;
+ w.Loaded -= OnLoaded;
+ _loaded = true;
+ w.Width += 1;
+ w.Width -= 1;
+ }
+
+ private static FontScaleWindow? GetParentScaleWindow(DependencyObject element)
+ {
+ return (FontScaleWindow) element.GetValue(ParentScaleWindowProperty);
+ }
+
+ private static void SetParentScaleWindow(DependencyObject element, FontScaleWindow value)
+ {
+ element.SetValue(ParentScaleWindowKey, value);
+ }
public static void SetResizeFont(DependencyObject element, bool value)
- => element.SetValue(ResizeFontProperty, value);
+ {
+ element.SetValue(ResizeFontProperty, value);
+ }
+
public static bool GetResizeFont(DependencyObject element)
- => (bool)element.GetValue(ResizeFontProperty);
+ {
+ return (bool) element.GetValue(ResizeFontProperty);
+ }
private static bool SetWindow(FrameworkElement el)
{
@@ -91,7 +110,7 @@ public class FontScaleWindow : Window
private static void ObjOnLoaded(object sender, RoutedEventArgs e)
{
- var el = (FrameworkElement)sender;
+ var el = (FrameworkElement) sender;
if (GetParentScaleWindow(el) == null)
{
if (!SetWindow(el))
@@ -100,6 +119,7 @@ public class FontScaleWindow : Window
return;
}
}
+
ResizeCallBack(sender, new DependencyPropertyChangedEventArgs());
}
@@ -116,17 +136,19 @@ public class FontScaleWindow : Window
obj.Loaded += ObjOnLoaded;
}
- if (window is not { _loaded: true }) return;
+ if (window is not {_loaded: true}) return;
CalculateFontSizeResized(obj);
}
+
private static void ObjOnUnloaded(object sender, RoutedEventArgs e)
{
- var obj = (FrameworkElement)sender;
+ var obj = (FrameworkElement) sender;
var w = GetParentScaleWindow(obj)!;
w._cachedObjects.Remove(obj);
obj.Unloaded -= ObjOnUnloaded;
obj.Loaded -= ObjOnLoaded;
}
+
private void OnSizeChanged(object sender, SizeChangedEventArgs e)
{
_currentDiagonal = _diagonal(e.NewSize.Width, e.NewSize.Height);
@@ -135,18 +157,16 @@ public class FontScaleWindow : Window
CalculateFontSizeResized(cached);
}
}
- //<-------------------Window-------------------->
-
-
- //<-------------------Scaling-------------------->
-
- public static readonly DependencyProperty ScaleProperty = DependencyProperty.RegisterAttached(
- "Scale", typeof(double), typeof(FontScaleWindow), new FrameworkPropertyMetadata(0.9999d ,FrameworkPropertyMetadataOptions.Inherits, ScalePropertyCallback));
public static void SetScale(DependencyObject element, double value)
- => element.SetValue(ScaleProperty, value);
+ {
+ element.SetValue(ScaleProperty, value);
+ }
+
public static double GetScale(DependencyObject element)
- => (double)element.GetValue(ScaleProperty);
+ {
+ return (double) element.GetValue(ScaleProperty);
+ }
private static void ScalePropertyCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
@@ -160,6 +180,7 @@ public class FontScaleWindow : Window
SetParentScaleWindow(d, fsWindow);
}
}
+
ResizeElement(d);
}
@@ -176,9 +197,9 @@ public class FontScaleWindow : Window
{
CalculateFontSize(d);
}
-
}
}
+
public static void CalculateFontSize(DependencyObject d)
{
var window = GetParentScaleWindow(d);
@@ -196,5 +217,4 @@ public class FontScaleWindow : Window
var fontSize = window.DefaultFontSize * elScale * windowsScale;
d.SetValue(FontSizeProperty, fontSize);
}
-}
-
+}
\ No newline at end of file
diff --git a/NebulaAuth/Theme/Palette.xaml b/NebulaAuth/Theme/Palette.xaml
index c1b6973..5a16c24 100644
--- a/NebulaAuth/Theme/Palette.xaml
+++ b/NebulaAuth/Theme/Palette.xaml
@@ -2,33 +2,33 @@
x:Class="LolzFucker.Theme.Palette"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- mc:Ignorable="d"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="300">
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
+ Text="Primary - Mid" />
+ Text="Light" />
+ Text="Mid" />
+ Text="Dark" />
+ Text="Light" />
+ Text="Mid" />
+ Text="Dark" />
+ Text="Background" />
-
+ Grid.Row="3"
+ Grid.Column="1">
+
+ Text="Paper" />
+
+ Text="Body" />
+ Text="BodyLight" />
+ Text="ToolTipBack" />
-
+
\ No newline at end of file
diff --git a/NebulaAuth/Theme/WindowStyle/NativeMethods.cs b/NebulaAuth/Theme/WindowStyle/NativeMethods.cs
index 2170b34..22e7612 100644
--- a/NebulaAuth/Theme/WindowStyle/NativeMethods.cs
+++ b/NebulaAuth/Theme/WindowStyle/NativeMethods.cs
@@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
+
// ReSharper disable InconsistentNaming
// ReSharper disable IdentifierTypo
@@ -8,18 +9,6 @@ namespace NebulaAuth.Theme.WindowStyle;
// ReSharper disable once PartialTypeWithSinglePart //Required
public static partial class NativeMethods
{
- public const int WM_NCCALCSIZE = 0x83;
- public const int WM_NCPAINT = 0x85;
-
- [DllImport("kernel32", SetLastError = true)]
- private static extern IntPtr LoadLibrary(string lpFileName);
-
- [DllImport("dwmapi.dll", PreserveSig = false)]
- public static extern bool DwmIsCompositionEnabled();
-
- [DllImport("kernel32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
- private static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
-
public enum DWMWINDOWATTRIBUTE : uint
{
NCRenderingEnabled = 1,
@@ -39,16 +28,17 @@ public static partial class NativeMethods
FreezeRepresentation
}
- [StructLayout(LayoutKind.Sequential)]
- public struct MARGINS
- {
- public int leftWidth;
- public int rightWidth;
- public int topHeight;
- public int bottomHeight;
- }
+ public const int WM_NCCALCSIZE = 0x83;
+ public const int WM_NCPAINT = 0x85;
- private delegate int DwmExtendFrameIntoClientAreaDelegate(IntPtr hwnd, ref MARGINS margins);
+ [DllImport("kernel32", SetLastError = true)]
+ private static extern IntPtr LoadLibrary(string lpFileName);
+
+ [DllImport("dwmapi.dll", PreserveSig = false)]
+ public static extern bool DwmIsCompositionEnabled();
+
+ [DllImport("kernel32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
+ private static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
public static int DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS margins)
{
@@ -66,7 +56,9 @@ public static partial class NativeMethods
return 0;
}
- var delegateForFunctionPointer = (DwmExtendFrameIntoClientAreaDelegate)Marshal.GetDelegateForFunctionPointer(procAddress, typeof(DwmExtendFrameIntoClientAreaDelegate));
+ var delegateForFunctionPointer =
+ (DwmExtendFrameIntoClientAreaDelegate) Marshal.GetDelegateForFunctionPointer(procAddress,
+ typeof(DwmExtendFrameIntoClientAreaDelegate));
return delegateForFunctionPointer(hwnd, ref margins);
}
@@ -77,9 +69,25 @@ public static partial class NativeMethods
{
return false;
}
+
return true;
}
+ [DllImport("user32.dll", SetLastError = true)]
+ public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy,
+ int uFlags);
+
+ [StructLayout(LayoutKind.Sequential)]
+ public struct MARGINS
+ {
+ public int leftWidth;
+ public int rightWidth;
+ public int topHeight;
+ public int bottomHeight;
+ }
+
+ private delegate int DwmExtendFrameIntoClientAreaDelegate(IntPtr hwnd, ref MARGINS margins);
+
internal enum WVR
{
ALIGNTOP = 0x0010,
@@ -91,7 +99,4 @@ public static partial class NativeMethods
VALIDRECTS = 0x0400,
REDRAW = HREDRAW | VREDRAW
}
-
- [DllImport("user32.dll", SetLastError = true)]
- public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);
}
\ No newline at end of file
diff --git a/NebulaAuth/Theme/WindowStyle/WindowChromeHelper.cs b/NebulaAuth/Theme/WindowStyle/WindowChromeHelper.cs
index 70a471c..5fdb4ea 100644
--- a/NebulaAuth/Theme/WindowStyle/WindowChromeHelper.cs
+++ b/NebulaAuth/Theme/WindowStyle/WindowChromeHelper.cs
@@ -9,10 +9,11 @@ namespace NebulaAuth.Theme.WindowStyle;
public static class WindowChromeHelper
{
- public static Thickness LayoutOffsetThickness => new(0d, 0d, 0d, SystemParameters.WindowResizeBorderThickness.Bottom);
+ public static Thickness LayoutOffsetThickness =>
+ new(0d, 0d, 0d, SystemParameters.WindowResizeBorderThickness.Bottom);
///
- /// Gets the properly adjusted window resize border thickness from system parameters.
+ /// Gets the properly adjusted window resize border thickness from system parameters.
///
public static Thickness WindowResizeBorderThickness
{
@@ -52,24 +53,25 @@ public static class WindowChromeHelper
float dpi;
try
{
- dpi = GetDeviceCaps(dc, (int)index);
+ dpi = GetDeviceCaps(dc, (int) index);
}
finally
{
ReleaseDC(desktopWnd, dc);
}
+
return dpi / 96f;
}
+ [DllImport("user32.dll")]
+ private static extern int GetSystemMetrics(GetSystemMetricsIndex nIndex);
+
private enum GetDeviceCapsIndex
{
LOGPIXELSX = 88,
LOGPIXELSY = 90
}
- [DllImport("user32.dll")]
- private static extern int GetSystemMetrics(GetSystemMetricsIndex nIndex);
-
private enum GetSystemMetricsIndex
{
CXFRAME = 32,
diff --git a/NebulaAuth/Theme/WindowStyle/WindowChromeRenderedBehavior.cs b/NebulaAuth/Theme/WindowStyle/WindowChromeRenderedBehavior.cs
index b4b1b25..1d9b92e 100644
--- a/NebulaAuth/Theme/WindowStyle/WindowChromeRenderedBehavior.cs
+++ b/NebulaAuth/Theme/WindowStyle/WindowChromeRenderedBehavior.cs
@@ -60,11 +60,11 @@ public class WindowChromeRenderedBehavior : Behavior
break;
case NativeMethods.WM_NCCALCSIZE:
handled = true;
- var rcClientArea = (RECT)Marshal.PtrToStructure(lParam, typeof(RECT));
- rcClientArea.Bottom += (int)(WindowChromeHelper.WindowResizeBorderThickness.Bottom / 2);
+ var rcClientArea = (RECT) Marshal.PtrToStructure(lParam, typeof(RECT));
+ rcClientArea.Bottom += (int) (WindowChromeHelper.WindowResizeBorderThickness.Bottom / 2);
Marshal.StructureToPtr(rcClientArea, lParam, false);
- return wParam == new IntPtr(1) ? new IntPtr((int)NativeMethods.WVR.REDRAW) : IntPtr.Zero;
+ return wParam == new IntPtr(1) ? new IntPtr((int) NativeMethods.WVR.REDRAW) : IntPtr.Zero;
}
return IntPtr.Zero;
diff --git a/NebulaAuth/Theme/WindowStyle/WindowStyle.xaml b/NebulaAuth/Theme/WindowStyle/WindowStyle.xaml
index 69b3133..4e8e25c 100644
--- a/NebulaAuth/Theme/WindowStyle/WindowStyle.xaml
+++ b/NebulaAuth/Theme/WindowStyle/WindowStyle.xaml
@@ -8,7 +8,7 @@
-
+
@@ -24,43 +24,42 @@
+ Grid.Row="0"
+ Height="28"
+ Background="{DynamicResource WindowBackground}">
+ Foreground="{DynamicResource PrimaryHueMidBrush}"
+ Text="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=Title}"
+ FontSize="17" />
-
+ Click="OnMinimizeClick">
+
-
+ Click="OnMaximizeRestoreClick">
+
-
+
+ Grid.Row="1"
+ Background="{DynamicResource MainBackgroundBrush}">
@@ -74,11 +73,12 @@
-
+
-
+
-
+
diff --git a/NebulaAuth/Theme/WindowStyle/WindowStyle.xaml.cs b/NebulaAuth/Theme/WindowStyle/WindowStyle.xaml.cs
index c46e2ab..3005904 100644
--- a/NebulaAuth/Theme/WindowStyle/WindowStyle.xaml.cs
+++ b/NebulaAuth/Theme/WindowStyle/WindowStyle.xaml.cs
@@ -3,7 +3,7 @@
namespace NebulaAuth.Theme.WindowStyle;
///
-/// Логика взаимодействия для WindowStyle.xaml
+/// Логика взаимодействия для WindowStyle.xaml
///
partial class WindowStyle
{
@@ -14,21 +14,21 @@ partial class WindowStyle
private void OnCloseClick(object sender, RoutedEventArgs e)
{
- var window = (Window)((FrameworkElement)sender).TemplatedParent;
+ var window = (Window) ((FrameworkElement) sender).TemplatedParent;
window.Close();
}
private void OnMaximizeRestoreClick(object sender, RoutedEventArgs e)
{
- var window = (Window)((FrameworkElement)sender).TemplatedParent;
+ var window = (Window) ((FrameworkElement) sender).TemplatedParent;
window.WindowState = window.WindowState == WindowState.Normal ? WindowState.Maximized : WindowState.Normal;
}
private void OnMinimizeClick(object sender, RoutedEventArgs e)
{
- var window = (Window)((FrameworkElement)sender).TemplatedParent;
+ var window = (Window) ((FrameworkElement) sender).TemplatedParent;
window.WindowState = WindowState.Minimized;
}
diff --git a/NebulaAuth/Utility/ClipboardHelper.cs b/NebulaAuth/Utility/ClipboardHelper.cs
index 084fead..6235546 100644
--- a/NebulaAuth/Utility/ClipboardHelper.cs
+++ b/NebulaAuth/Utility/ClipboardHelper.cs
@@ -1,8 +1,8 @@
-using NebulaAuth.Core;
-using NebulaAuth.Model;
-using System;
+using System;
using System.Collections.Specialized;
using System.Windows;
+using NebulaAuth.Core;
+using NebulaAuth.Model;
namespace NebulaAuth.Utility;
@@ -25,8 +25,8 @@ public class ClipboardHelper
Shell.Logger.Error(ex);
SnackbarController.SendSnackbar(LocManager.GetCommonOrDefault("Error", "Error"));
}
-
}
+
i++;
}
@@ -50,8 +50,8 @@ public class ClipboardHelper
Shell.Logger.Error(ex);
SnackbarController.SendSnackbar(LocManager.GetCommonOrDefault("Error", "Error"));
}
-
}
+
i++;
}
diff --git a/NebulaAuth/Utility/ErrorTranslatorHelper.cs b/NebulaAuth/Utility/ErrorTranslatorHelper.cs
index b024bc6..9f39d81 100644
--- a/NebulaAuth/Utility/ErrorTranslatorHelper.cs
+++ b/NebulaAuth/Utility/ErrorTranslatorHelper.cs
@@ -8,7 +8,6 @@ namespace NebulaAuth.Utility;
public static class ErrorTranslatorHelper
{
-
public static string TranslateLoginError(LoginError error)
{
var result = GetMessage("Login", error.ToString());
@@ -20,7 +19,6 @@ public static class ErrorTranslatorHelper
{
var result = GetMessage("EResult", eResult.ToString());
return result ?? eResult.ToString();
-
}
public static string TranslateLinkerError(AuthenticatorLinkerError error)
@@ -34,6 +32,5 @@ public static class ErrorTranslatorHelper
var message = Loc.Tr(fullPath, "|ABSENT|");
if (message == "|ABSENT|") return null;
return message;
-
}
}
\ No newline at end of file
diff --git a/NebulaAuth/Utility/ExceptionHandler.cs b/NebulaAuth/Utility/ExceptionHandler.cs
index e9b034f..395c462 100644
--- a/NebulaAuth/Utility/ExceptionHandler.cs
+++ b/NebulaAuth/Utility/ExceptionHandler.cs
@@ -1,93 +1,99 @@
-using NebulaAuth.Core;
+using System;
+using System.Net.Http;
+using System.Threading.Tasks;
+using NebulaAuth.Core;
using NebulaAuth.Model;
using SteamLib.Exceptions;
using SteamLib.Exceptions.General;
using SteamLib.ProtoCore.Exceptions;
-using System;
-using System.Net.Http;
-using System.Threading.Tasks;
namespace NebulaAuth.Utility;
public static class ExceptionHandler
{
private const string EXCEPTION_HANDLER_LOC_PATH = "ExceptionHandler";
- public static bool Handle(Exception ex, string? prefix = null, string? postfix = null, bool handleAllExceptions = false)
+
+ public static bool Handle(Exception ex, string? prefix = null, string? postfix = null,
+ bool handleAllExceptions = false)
{
string msg;
Shell.Logger.Error(ex);
switch (ex)
{
case SessionPermanentlyExpiredException:
- {
- msg = "SessionExpiredException".GetCodeBehindLocalization();
- break;
- }
+ {
+ msg = "SessionExpiredException".GetCodeBehindLocalization();
+ break;
+ }
case SessionInvalidException:
- {
- msg = "SessionExpiredException".GetCodeBehindLocalization();
- break;
- }
+ {
+ msg = "SessionExpiredException".GetCodeBehindLocalization();
+ break;
+ }
case TaskCanceledException e:
- {
- msg = e.InnerException is TimeoutException
- ? "TimeoutException".GetCodeBehindLocalization()
- : "TaskCanceledException".GetCodeBehindLocalization();
- break;
- }
+ {
+ msg = e.InnerException is TimeoutException
+ ? "TimeoutException".GetCodeBehindLocalization()
+ : "TaskCanceledException".GetCodeBehindLocalization();
+ break;
+ }
case HttpRequestException e:
+ {
+ var str = "RequestError".GetCommonLocalization() + ": ";
+ if (e.StatusCode != null)
{
- var str = "RequestError".GetCommonLocalization() + ": ";
- if (e.StatusCode != null)
- {
- msg = str + e.StatusCode;
- }
- else if (e.InnerException != null)
- {
- msg = (str + e.InnerException.Message);
- }
- else
- {
- msg = (str + e.Message);
- }
+ msg = str + e.StatusCode;
+ }
+ else if (e.InnerException != null)
+ {
+ msg = str + e.InnerException.Message;
+ }
+ else
+ {
+ msg = str + e.Message;
+ }
- break;
- }
+ break;
+ }
case UnsupportedResponseException:
- {
- msg = "UnsupportedResponseException".GetCodeBehindLocalization();
- break;
- }
+ {
+ msg = "UnsupportedResponseException".GetCodeBehindLocalization();
+ break;
+ }
case CantLoadConfirmationsException e:
+ {
+ msg = LocManager.GetCodeBehindOrDefault(nameof(CantLoadConfirmationsException),
+ EXCEPTION_HANDLER_LOC_PATH, nameof(CantLoadConfirmationsException), "Common");
+ if (e.Error == LoadConfirmationsError.Unknown)
{
- msg = LocManager.GetCodeBehindOrDefault(nameof(CantLoadConfirmationsException), EXCEPTION_HANDLER_LOC_PATH, nameof(CantLoadConfirmationsException), "Common");
- if (e.Error == LoadConfirmationsError.Unknown)
- {
- msg += e.ErrorMessage;
- msg += ' ';
- msg += e.ErrorDetails;
- }
- else
- {
- msg += LocManager.GetCodeBehindOrDefault(e.Error.ToString(), EXCEPTION_HANDLER_LOC_PATH, nameof(CantLoadConfirmationsException), e.Error.ToString());
- }
- break;
+ msg += e.ErrorMessage;
+ msg += ' ';
+ msg += e.ErrorDetails;
}
+ else
+ {
+ msg += LocManager.GetCodeBehindOrDefault(e.Error.ToString(), EXCEPTION_HANDLER_LOC_PATH,
+ nameof(CantLoadConfirmationsException), e.Error.ToString());
+ }
+
+ break;
+ }
case EResultException e:
- {
- msg = "Error".GetCommonLocalization() + ": " + ErrorTranslatorHelper.TranslateEResult(e.Result);
- break;
- }
+ {
+ msg = "Error".GetCommonLocalization() + ": " + ErrorTranslatorHelper.TranslateEResult(e.Result);
+ break;
+ }
case LoginException e:
- {
- msg = "LoginException".GetCodeBehindLocalization() + ": " + ErrorTranslatorHelper.TranslateLoginError(e.Error);
- break;
- }
+ {
+ msg = "LoginException".GetCodeBehindLocalization() + ": " +
+ ErrorTranslatorHelper.TranslateLoginError(e.Error);
+ break;
+ }
case not null when handleAllExceptions:
- {
- msg = "UnknownException".GetCodeBehindLocalization() + ex.Message;
- break;
- }
+ {
+ msg = "UnknownException".GetCodeBehindLocalization() + ex.Message;
+ break;
+ }
default:
return false;
}
@@ -95,6 +101,7 @@ public static class ExceptionHandler
SnackbarController.SendSnackbar(prefix + msg + postfix);
return true;
}
+
private static string GetCommonLocalization(this string key)
{
return LocManager.GetCommonOrDefault(key, key);
diff --git a/NebulaAuth/View/ConfirmationTemplates.xaml b/NebulaAuth/View/ConfirmationTemplates.xaml
index 60ded1c..56b2f01 100644
--- a/NebulaAuth/View/ConfirmationTemplates.xaml
+++ b/NebulaAuth/View/ConfirmationTemplates.xaml
@@ -9,18 +9,21 @@
-
+
-
-
-
-
-
+
+
+
+
+
-
+
-
-
+
@@ -33,25 +36,31 @@
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
+
+
@@ -64,18 +73,21 @@
-
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
@@ -88,36 +100,43 @@
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
+
+
+
-
-
+
+
-
+
-
-
+
@@ -130,18 +149,21 @@
-
+
-
-
-
-
-
+
+
+
+
+
-
+
-
-
+
@@ -154,23 +176,26 @@
-
+
-
-
-
-
-
+
+
+
+
+
-
+
-
-
-
+
+
+
-
-
+
diff --git a/NebulaAuth/View/Dialogs/ConfirmCancelDialog.xaml b/NebulaAuth/View/Dialogs/ConfirmCancelDialog.xaml
index 560da51..19b0a8a 100644
--- a/NebulaAuth/View/Dialogs/ConfirmCancelDialog.xaml
+++ b/NebulaAuth/View/Dialogs/ConfirmCancelDialog.xaml
@@ -1,31 +1,31 @@
-
-
+
+
+ TextWrapping="WrapWithOverflow" />
-
-
+
+
-
-
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
\ No newline at end of file
diff --git a/NebulaAuth/View/Dialogs/LoginAgainDialog.xaml.cs b/NebulaAuth/View/Dialogs/LoginAgainDialog.xaml.cs
index 2c8cb00..294f5b6 100644
--- a/NebulaAuth/View/Dialogs/LoginAgainDialog.xaml.cs
+++ b/NebulaAuth/View/Dialogs/LoginAgainDialog.xaml.cs
@@ -1,7 +1,7 @@
namespace NebulaAuth.View.Dialogs;
///
-/// Логика взаимодействия для LoginAgainDialog.xaml
+/// Логика взаимодействия для LoginAgainDialog.xaml
///
public partial class LoginAgainDialog
{
diff --git a/NebulaAuth/View/Dialogs/LoginAgainOnImportDialog.xaml b/NebulaAuth/View/Dialogs/LoginAgainOnImportDialog.xaml
index 670ae8d..379dfab 100644
--- a/NebulaAuth/View/Dialogs/LoginAgainOnImportDialog.xaml
+++ b/NebulaAuth/View/Dialogs/LoginAgainOnImportDialog.xaml
@@ -1,34 +1,39 @@
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+
+
+
-
-
+
+
@@ -38,15 +43,23 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
+
\ No newline at end of file
diff --git a/NebulaAuth/View/Dialogs/LoginAgainOnImportDialog.xaml.cs b/NebulaAuth/View/Dialogs/LoginAgainOnImportDialog.xaml.cs
index 4e189d4..8d936f9 100644
--- a/NebulaAuth/View/Dialogs/LoginAgainOnImportDialog.xaml.cs
+++ b/NebulaAuth/View/Dialogs/LoginAgainOnImportDialog.xaml.cs
@@ -1,7 +1,7 @@
namespace NebulaAuth.View.Dialogs;
///
-/// Логика взаимодействия для LoginAgainDialog.xaml
+/// Логика взаимодействия для LoginAgainDialog.xaml
///
public partial class LoginAgainOnImportDialog
{
diff --git a/NebulaAuth/View/Dialogs/SetCryptPasswordDialog.xaml b/NebulaAuth/View/Dialogs/SetCryptPasswordDialog.xaml
index 051a197..785b2b5 100644
--- a/NebulaAuth/View/Dialogs/SetCryptPasswordDialog.xaml
+++ b/NebulaAuth/View/Dialogs/SetCryptPasswordDialog.xaml
@@ -1,32 +1,42 @@
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
\ No newline at end of file
diff --git a/NebulaAuth/View/Dialogs/SetCryptPasswordDialog.xaml.cs b/NebulaAuth/View/Dialogs/SetCryptPasswordDialog.xaml.cs
index 02dd5aa..a9a5b1e 100644
--- a/NebulaAuth/View/Dialogs/SetCryptPasswordDialog.xaml.cs
+++ b/NebulaAuth/View/Dialogs/SetCryptPasswordDialog.xaml.cs
@@ -1,7 +1,7 @@
namespace NebulaAuth.View.Dialogs;
///
-/// Логика взаимодействия для SetCryptPasswordDialog.xaml
+/// Логика взаимодействия для SetCryptPasswordDialog.xaml
///
public partial class SetCryptPasswordDialog
{
diff --git a/NebulaAuth/View/Dialogs/WaitLoginDialog.xaml b/NebulaAuth/View/Dialogs/WaitLoginDialog.xaml
index 864df13..eb8c40d 100644
--- a/NebulaAuth/View/Dialogs/WaitLoginDialog.xaml
+++ b/NebulaAuth/View/Dialogs/WaitLoginDialog.xaml
@@ -1,42 +1,42 @@
-
-
+
+
-
-
+
+
-
+
-
-
-
+
+
+
-
+
-
-
+
+
Отправить
Отмена
-
+
\ No newline at end of file
diff --git a/NebulaAuth/View/Dialogs/WaitLoginDialog.xaml.cs b/NebulaAuth/View/Dialogs/WaitLoginDialog.xaml.cs
index 156f5f7..bc1268f 100644
--- a/NebulaAuth/View/Dialogs/WaitLoginDialog.xaml.cs
+++ b/NebulaAuth/View/Dialogs/WaitLoginDialog.xaml.cs
@@ -10,11 +10,12 @@ using SteamLib.Exceptions;
namespace NebulaAuth.View.Dialogs;
///
-/// Логика взаимодействия для WaitLoginDialog.xaml
+/// Логика взаимодействия для WaitLoginDialog.xaml
///
public partial class WaitLoginDialog : ICaptchaResolver
{
private TaskCompletionSource _tcs = new();
+
public WaitLoginDialog()
{
InitializeComponent();
@@ -22,7 +23,6 @@ public partial class WaitLoginDialog : ICaptchaResolver
public async Task Resolve(Uri imageUrl, HttpClient client)
{
-
CaptchaGrid.Visibility = Visibility.Visible;
var stream = await client.GetStreamAsync(imageUrl);
return await Application.Current.Dispatcher.Invoke(async () =>
diff --git a/NebulaAuth/View/LinkerView.xaml b/NebulaAuth/View/LinkerView.xaml
index 736df5a..970d539 100644
--- a/NebulaAuth/View/LinkerView.xaml
+++ b/NebulaAuth/View/LinkerView.xaml
@@ -1,11 +1,11 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
-
-
-
+
+
+
-
+
-
+
@@ -77,72 +82,85 @@
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/NebulaAuth/View/LinkerView.xaml.cs b/NebulaAuth/View/LinkerView.xaml.cs
index d958b17..7068f07 100644
--- a/NebulaAuth/View/LinkerView.xaml.cs
+++ b/NebulaAuth/View/LinkerView.xaml.cs
@@ -1,7 +1,7 @@
namespace NebulaAuth.View;
///
-/// Логика взаимодействия для LinkerView.xaml
+/// Логика взаимодействия для LinkerView.xaml
///
public partial class LinkerView
{
diff --git a/NebulaAuth/View/ProxyManagerView.xaml b/NebulaAuth/View/ProxyManagerView.xaml
index 469611a..e05fd15 100644
--- a/NebulaAuth/View/ProxyManagerView.xaml
+++ b/NebulaAuth/View/ProxyManagerView.xaml
@@ -1,11 +1,11 @@
-
-
-
-
-
+
+
+
+
+
-
-
+
+
-
-
+
+
@@ -36,14 +39,15 @@
-
-
+
+
-
-
-
-
+
+
+
@@ -51,26 +55,29 @@
-
+
-
+
@@ -78,36 +85,41 @@
-
+
-
-
+
+
-
-
-
+
+
+
-
-
+
-
+
-
-
-
+
+
+
-
-
+
+
@@ -117,4 +129,4 @@
-
+
\ No newline at end of file
diff --git a/NebulaAuth/View/ProxyManagerView.xaml.cs b/NebulaAuth/View/ProxyManagerView.xaml.cs
index 955fda2..068ddf1 100644
--- a/NebulaAuth/View/ProxyManagerView.xaml.cs
+++ b/NebulaAuth/View/ProxyManagerView.xaml.cs
@@ -1,7 +1,7 @@
namespace NebulaAuth.View;
///
-/// Логика взаимодействия для ProxyManagerView.xaml
+/// Логика взаимодействия для ProxyManagerView.xaml
///
public partial class ProxyManagerView
{
diff --git a/NebulaAuth/View/SettingsView.xaml b/NebulaAuth/View/SettingsView.xaml
index 327144b..0e98086 100644
--- a/NebulaAuth/View/SettingsView.xaml
+++ b/NebulaAuth/View/SettingsView.xaml
@@ -1,71 +1,90 @@
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
+
+
-
+
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/NebulaAuth/View/SettingsView.xaml.cs b/NebulaAuth/View/SettingsView.xaml.cs
index baa65f3..183e3a7 100644
--- a/NebulaAuth/View/SettingsView.xaml.cs
+++ b/NebulaAuth/View/SettingsView.xaml.cs
@@ -1,7 +1,7 @@
namespace NebulaAuth.View;
///
-/// Логика взаимодействия для SettingsView.xaml
+/// Логика взаимодействия для SettingsView.xaml
///
public partial class SettingsView
{
diff --git a/NebulaAuth/View/UpdaterView.xaml b/NebulaAuth/View/UpdaterView.xaml
index 07b33c0..7340a81 100644
--- a/NebulaAuth/View/UpdaterView.xaml
+++ b/NebulaAuth/View/UpdaterView.xaml
@@ -1,11 +1,11 @@
-
-
-
-
-
+
+
+
+
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
Version 1.3.4
-
2024-02-01
-
- - First release
+
+
+
Version 1.3.4
+
2024-02-01
+
+ - First release
+
-