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
69 lines
2.1 KiB
C#
69 lines
2.1 KiB
C#
using System.Collections.Concurrent;
|
|
using Newtonsoft.Json;
|
|
using SteamLib.Core.Enums;
|
|
using SteamLib.Core.Interfaces;
|
|
using SteamLib.Core.Models;
|
|
using SteamLib.Web.Converters;
|
|
|
|
namespace SteamLib.Account;
|
|
|
|
public class SessionData : ISessionData
|
|
{
|
|
[JsonIgnore] public bool? IsValid { get; set; }
|
|
[JsonIgnore] public bool IsExpired => RefreshToken.IsExpired;
|
|
|
|
public string SessionId { get; }
|
|
|
|
[JsonConverter(typeof(SteamIdToSteam64Converter))]
|
|
public SteamId SteamId { get; }
|
|
|
|
public SteamAuthToken RefreshToken { get; }
|
|
public ConcurrentDictionary<SteamDomain, SteamAuthToken> Tokens { get; }
|
|
|
|
[JsonConstructor]
|
|
public SessionData(string sessionId, SteamId steamId, SteamAuthToken refreshToken,
|
|
IDictionary<SteamDomain, SteamAuthToken>? tokens)
|
|
{
|
|
SessionId = sessionId;
|
|
SteamId = steamId;
|
|
RefreshToken = refreshToken;
|
|
Tokens = new ConcurrentDictionary<SteamDomain, SteamAuthToken>(tokens ??
|
|
new Dictionary<SteamDomain, SteamAuthToken>());
|
|
}
|
|
|
|
public SessionData(string sessionId, SteamId steamId, SteamAuthToken refreshToken,
|
|
IEnumerable<SteamAuthToken>? tokensCollection)
|
|
{
|
|
SessionId = sessionId;
|
|
SteamId = steamId;
|
|
RefreshToken = refreshToken;
|
|
tokensCollection ??= Array.Empty<SteamAuthToken>();
|
|
Tokens = new ConcurrentDictionary<SteamDomain, SteamAuthToken>(
|
|
tokensCollection.ToDictionary(t => t.Domain, t => t));
|
|
}
|
|
|
|
public virtual SteamAuthToken? GetToken(SteamDomain domain)
|
|
{
|
|
if (domain == SteamDomain.Undefined)
|
|
throw new ArgumentException("SteamDomain.Undefined is not allowed");
|
|
if (Tokens.TryGetValue(domain, out var token))
|
|
return token;
|
|
return null;
|
|
}
|
|
|
|
public void SetToken(SteamDomain domain, SteamAuthToken token)
|
|
{
|
|
Tokens[domain] = token;
|
|
}
|
|
|
|
|
|
public virtual SessionData Clone()
|
|
{
|
|
return (SessionData) ((ICloneable) this).Clone();
|
|
}
|
|
|
|
object ICloneable.Clone()
|
|
{
|
|
return new SessionData(SessionId, SteamId, RefreshToken, Tokens);
|
|
}
|
|
} |