mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-16 08:25:28 +00:00
* Implement support for access tokens A bit more work and testing is needed * Make ValidUntil computed, fix netf, among others * netf fixes as always * Allow AWH to forcefully refresh session * Unify access token lifetime
This commit is contained in:
committed by
GitHub
parent
4106c5f41a
commit
d571cd9580
@@ -24,6 +24,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Globalization;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
@@ -48,6 +49,8 @@ public static class Utilities {
|
||||
// normally we'd just use words like "steam" and "farm", but the library we're currently using is a bit iffy about banned words, so we need to also add combinations such as "steamfarm"
|
||||
private static readonly ImmutableHashSet<string> ForbiddenPasswordPhrases = ImmutableHashSet.Create(StringComparer.InvariantCultureIgnoreCase, "archisteamfarm", "archi", "steam", "farm", "archisteam", "archifarm", "steamfarm", "asf", "asffarm", "password");
|
||||
|
||||
private static readonly JwtSecurityTokenHandler JwtSecurityTokenHandler = new();
|
||||
|
||||
[PublicAPI]
|
||||
public static string GetArgsAsText(string[] args, byte argsToSkip, string delimiter) {
|
||||
ArgumentNullException.ThrowIfNull(args);
|
||||
@@ -187,6 +190,21 @@ public static class Utilities {
|
||||
return (text.Length % 2 == 0) && text.All(Uri.IsHexDigit);
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public static JwtSecurityToken? ReadJwtToken(string token) {
|
||||
if (string.IsNullOrEmpty(token)) {
|
||||
throw new ArgumentNullException(nameof(token));
|
||||
}
|
||||
|
||||
try {
|
||||
return JwtSecurityTokenHandler.ReadJwtToken(token);
|
||||
} catch (Exception e) {
|
||||
ASF.ArchiLogger.LogGenericException(e);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public static IList<INode> SelectNodes(this IDocument document, string xpath) {
|
||||
ArgumentNullException.ThrowIfNull(document);
|
||||
|
||||
Reference in New Issue
Block a user