mirror of
https://github.com/achiez/NebulaAuth-Steam-Desktop-Authenticator-by-Achies.git
synced 2026-07-25 14:24:32 +00:00
8ff960189e
- Update: Added "Copy Password" to Mafile context menu (if available) - Update: "Save Password" now pre-fills the current password in the "Login Again" dialog when encryption is enabled - Fix: Prevented overlapping confirmation cycles in AutoConfirmer - Fix: Added a Snackbar notification when a confirmation cycle is skipped due to a too frequent timer interval - Fix: Fixed a rare bug where the previous proxy was used instead of the current one during session refresh - Fix: Corrected "Session Permanently Expired" message showing on unrelated errors (e.g. network issues) - UI-Fix: Fixed visual glitch where proxy input appeared non-empty when switching to a mafile-specific proxy - Cleanup: Refactored and cleaned up codebase, improved styling and formatting via ReSharper
57 lines
2.7 KiB
C#
57 lines
2.7 KiB
C#
using System.Threading.Tasks;
|
|
using AchiesUtilities.Web.Models;
|
|
using NebulaAuth.Model.Entities;
|
|
using SteamLib.Account;
|
|
using SteamLib.Api.Mobile;
|
|
using SteamLib.Authentication;
|
|
using SteamLib.Authentication.LoginV2;
|
|
using SteamLib.Exceptions;
|
|
using SteamLib.SteamMobile;
|
|
|
|
namespace NebulaAuth.Model;
|
|
|
|
public partial class SessionHandler //API
|
|
{
|
|
public static async Task RefreshMobileToken(HttpClientHandlerPair chp, Mafile mafile)
|
|
{
|
|
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 newToken = SteamTokenHelper.Parse(mobileToken);
|
|
mafile.SessionData.SetMobileToken(newToken);
|
|
|
|
//Trigger 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(mafile.SessionData);
|
|
Storage.UpdateMafile(mafile);
|
|
chp.Handler.CookieContainer.SetSteamMobileCookiesWithMobileToken(mafile.SessionData);
|
|
}
|
|
|
|
public static async Task LoginAgain(HttpClientHandlerPair chp, Mafile mafile, string password, bool savePassword)
|
|
{
|
|
var sgGenerator = new SteamGuardCodeGenerator(mafile.SharedSecret);
|
|
var options = new LoginV2ExecutorOptions(LoginV2Executor.NullConsumer, chp.Client)
|
|
{
|
|
Logger = Shell.ExtensionsLogger,
|
|
SteamGuardProvider = sgGenerator,
|
|
DeviceDetails = LoginV2ExecutorOptions.GetMobileDefaultDevice(),
|
|
WebsiteId = "Mobile"
|
|
};
|
|
chp.Handler.CookieContainer.ClearMobileSessionCookies();
|
|
var result = await LoginV2Executor.DoLogin(options, mafile.AccountName, password);
|
|
Shell.Logger.Info("Logged in again on {name} {steamid}", mafile.AccountName, result.SteamId);
|
|
AdmissionHelper.TransferCommunityCookies(chp.Handler.CookieContainer);
|
|
|
|
//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);
|
|
if (PHandler.IsPasswordSet)
|
|
mafile.Password = savePassword ? PHandler.Encrypt(password) : null;
|
|
Storage.UpdateMafile(mafile);
|
|
}
|
|
} |