diff --git a/ArchiSteamFarm/ArchiSteamFarm.csproj b/ArchiSteamFarm/ArchiSteamFarm.csproj
index 4057cf61c..9a1202ff2 100644
--- a/ArchiSteamFarm/ArchiSteamFarm.csproj
+++ b/ArchiSteamFarm/ArchiSteamFarm.csproj
@@ -16,6 +16,7 @@
+
@@ -24,7 +25,6 @@
-
diff --git a/ArchiSteamFarm/Core/Utilities.cs b/ArchiSteamFarm/Core/Utilities.cs
index 89aa79d8c..acecc4056 100644
--- a/ArchiSteamFarm/Core/Utilities.cs
+++ b/ArchiSteamFarm/Core/Utilities.cs
@@ -25,7 +25,6 @@ using System.Collections.Frozen;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
-using System.IdentityModel.Tokens.Jwt;
using System.IO;
using System.Linq;
using System.Net;
@@ -40,6 +39,7 @@ using ArchiSteamFarm.Storage;
using Humanizer;
using Humanizer.Localisation;
using JetBrains.Annotations;
+using Microsoft.IdentityModel.JsonWebTokens;
using SteamKit2;
using Zxcvbn;
@@ -178,41 +178,6 @@ public static class Utilities {
return (text.Length % 2 == 0) && text.All(Uri.IsHexDigit);
}
- [Obsolete($"Use {nameof(TryReadJwtToken)} instead, this function will be removed in the next version.")]
- [PublicAPI]
- public static JwtSecurityToken? ReadJwtToken(string token) {
- ArgumentException.ThrowIfNullOrEmpty(token);
-
- JwtSecurityTokenHandler jwtSecurityTokenHandler = new();
-
- try {
- return jwtSecurityTokenHandler.ReadJwtToken(token);
- } catch (Exception e) {
- ASF.ArchiLogger.LogGenericDebuggingException(e);
-
- return null;
- }
- }
-
- [PublicAPI]
- public static bool TryReadJwtToken(string token, [NotNullWhen(true)] out JwtSecurityToken? result) {
- ArgumentException.ThrowIfNullOrEmpty(token);
-
- JwtSecurityTokenHandler jwtSecurityTokenHandler = new();
-
- try {
- result = jwtSecurityTokenHandler.ReadJwtToken(token);
-
- return true;
- } catch (Exception e) {
- ASF.ArchiLogger.LogGenericDebuggingException(e);
-
- result = null;
-
- return false;
- }
- }
-
[PublicAPI]
public static IList SelectNodes(this IDocument document, string xpath) {
ArgumentNullException.ThrowIfNull(document);
@@ -281,6 +246,23 @@ public static class Utilities {
return job.ToTask();
}
+ [PublicAPI]
+ public static bool TryReadJsonWebToken(string token, [NotNullWhen(true)] out JsonWebToken? result) {
+ ArgumentException.ThrowIfNullOrEmpty(token);
+
+ try {
+ result = new JsonWebToken(token);
+ } catch (Exception e) {
+ ASF.ArchiLogger.LogGenericDebuggingException(e);
+
+ result = null;
+
+ return false;
+ }
+
+ return true;
+ }
+
internal static void DeleteEmptyDirectoriesRecursively(string directory) {
ArgumentException.ThrowIfNullOrEmpty(directory);
diff --git a/ArchiSteamFarm/Steam/Bot.cs b/ArchiSteamFarm/Steam/Bot.cs
index e71181d1b..175f9a4e3 100644
--- a/ArchiSteamFarm/Steam/Bot.cs
+++ b/ArchiSteamFarm/Steam/Bot.cs
@@ -28,7 +28,6 @@ using System.Collections.Immutable;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
-using System.IdentityModel.Tokens.Jwt;
using System.IO;
using System.Linq;
using System.Net.Http;
@@ -53,6 +52,7 @@ using ArchiSteamFarm.Steam.Storage;
using ArchiSteamFarm.Storage;
using ArchiSteamFarm.Web;
using JetBrains.Annotations;
+using Microsoft.IdentityModel.JsonWebTokens;
using Newtonsoft.Json;
using SteamKit2;
using SteamKit2.Authentication;
@@ -203,7 +203,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable {
return;
}
- if (!Utilities.TryReadJwtToken(value, out JwtSecurityToken? accessToken)) {
+ if (!Utilities.TryReadJsonWebToken(value, out JsonWebToken? accessToken)) {
ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(accessToken)));
return;
@@ -2380,13 +2380,13 @@ public sealed class Bot : IAsyncDisposable, IDisposable {
}
}
- if (!string.IsNullOrEmpty(accessTokenText) && Utilities.TryReadJwtToken(accessTokenText, out JwtSecurityToken? accessToken) && ((accessToken.ValidTo == DateTime.MinValue) || (accessToken.ValidTo >= DateTime.UtcNow))) {
+ if (!string.IsNullOrEmpty(accessTokenText) && Utilities.TryReadJsonWebToken(accessTokenText, out JsonWebToken? accessToken) && ((accessToken.ValidTo == DateTime.MinValue) || (accessToken.ValidTo >= DateTime.UtcNow))) {
AccessToken = accessTokenText;
} else {
AccessToken = null;
}
- if (!string.IsNullOrEmpty(refreshTokenText) && Utilities.TryReadJwtToken(refreshTokenText, out JwtSecurityToken? refreshToken) && ((refreshToken.ValidTo == DateTime.MinValue) || (refreshToken.ValidTo >= DateTime.UtcNow))) {
+ if (!string.IsNullOrEmpty(refreshTokenText) && Utilities.TryReadJsonWebToken(refreshTokenText, out JsonWebToken? refreshToken) && ((refreshToken.ValidTo == DateTime.MinValue) || (refreshToken.ValidTo >= DateTime.UtcNow))) {
RefreshToken = refreshTokenText;
} else {
RefreshToken = null;
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 4dad2b863..ffed38ca6 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -6,6 +6,7 @@
+
@@ -18,7 +19,6 @@
-