Files
Nebula-Auth/SteamLibForked/Account/SessionData.cs
T
achiez 8ff960189e 1.5.6 Bug fixes and code clean-ups
- 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
2025-05-02 23:29:24 +03:00

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);
}
}