Files
Nebula-Auth/SteamLibForked/Account/SteamAuthToken.cs
T
Давид Чернопятов ef8e12e20d 1.5.4 progress
- Mafile version was updated (3), new property SteamId added
- MafileSerializer was refactored to adjust compability and code readability.
- Serialization work moved from Storage to new class NebulaSerializer
2024-11-10 02:29:40 +02:00

50 lines
1.5 KiB
C#

using AchiesUtilities.Models;
using AchiesUtilities.Newtonsoft.JSON.Converters.Special;
using Newtonsoft.Json;
using SteamLib.Authentication;
using SteamLib.Core.Enums;
using SteamLib.Core.Models;
using SteamLib.Web.Converters;
namespace SteamLib.Account;
public readonly struct SteamAuthToken
{
public string Token { get; }
[JsonConverter(typeof(SteamIdToSteam64Converter))]
public SteamId SteamId { get; }
[JsonConverter(typeof(UnixTimeStampConverter))]
public UnixTimeStamp Expires { get; }
public SteamDomain Domain { get; init; }
public SteamAccessTokenType Type { get; }
[JsonIgnore]
public bool IsExpired => Expires.Time < DateTime.UtcNow;
[JsonIgnore]
public string SignedToken { get; }
public SteamAuthToken(string token, long steamId, UnixTimeStamp expires, SteamDomain domain, SteamAccessTokenType type)
{
Token = token;
Expires = expires;
Domain = domain;
Type = type;
SteamId = SteamId.FromSteam64(steamId);
SignedToken = SteamTokenHelper.CombineJwtWithSteamId(SteamId.Steam64.Id, Token);
}
[JsonConstructor]
public SteamAuthToken(string token, SteamId steamId, UnixTimeStamp expires, SteamDomain domain, SteamAccessTokenType type)
{
Token = token;
SteamId = steamId;
Expires = expires;
Domain = domain;
Type = type;
SignedToken = SteamTokenHelper.CombineJwtWithSteamId(SteamId.Steam64.Id, Token);
}
}