From cba29bb2c56082ceefb5fd901eeca8c94b23a03d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Domeradzki?= Date: Fri, 9 May 2025 23:31:27 +0200 Subject: [PATCH] Resolve misc TODOs --- .../MobileAuthenticatorWebHandler.cs | 44 ++++++++++--------- Directory.Packages.props | 2 +- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/ArchiSteamFarm.OfficialPlugins.MobileAuthenticator/MobileAuthenticatorWebHandler.cs b/ArchiSteamFarm.OfficialPlugins.MobileAuthenticator/MobileAuthenticatorWebHandler.cs index ab6ce592e..75d88fe30 100644 --- a/ArchiSteamFarm.OfficialPlugins.MobileAuthenticator/MobileAuthenticatorWebHandler.cs +++ b/ArchiSteamFarm.OfficialPlugins.MobileAuthenticator/MobileAuthenticatorWebHandler.cs @@ -52,19 +52,22 @@ internal static class MobileAuthenticatorWebHandler { return null; } - Dictionary arguments = new(5, StringComparer.Ordinal) { - { "access_token", accessToken }, - { "authenticator_time", Utilities.GetUnixTime() }, - { "authenticator_type", 1 }, - { "device_identifier", deviceID }, - { "steamid", bot.SteamID } + CTwoFactor_AddAuthenticator_Request request = new() { + authenticator_time = Utilities.GetUnixTime(), + authenticator_type = 1, + device_identifier = deviceID, + steamid = bot.SteamID + }; + + Dictionary arguments = new(1, StringComparer.Ordinal) { + { "access_token", accessToken } }; using WebAPI.AsyncInterface twoFactorService = bot.SteamConfiguration.GetAsyncWebAPIInterface(TwoFactorService); twoFactorService.Timeout = bot.ArchiWebHandler.WebBrowser.Timeout; - CTwoFactor_AddAuthenticator_Response? response = null; + WebAPI.WebAPIResponse? response = null; for (byte i = 0; (i < WebBrowser.MaxTries) && (response == null); i++) { if ((i > 0) && (ArchiWebHandler.WebLimiterDelay > 0)) { @@ -72,12 +75,11 @@ internal static class MobileAuthenticatorWebHandler { } try { - // TODO: Move to CallProtobufAsync when we update to SK2 3.2.0+ response = await ArchiWebHandler.WebLimitRequest( WebAPI.DefaultBaseAddress, // ReSharper disable once AccessToDisposedClosure - async () => await twoFactorService.CallProtobufAsync(HttpMethod.Post, "AddAuthenticator", args: arguments).ConfigureAwait(false) + async () => await twoFactorService.CallProtobufAsync(HttpMethod.Post, "AddAuthenticator", request, extraArgs: arguments).ConfigureAwait(false) ).ConfigureAwait(false); } catch (TaskCanceledException e) { bot.ArchiLogger.LogGenericDebuggingException(e); @@ -92,7 +94,7 @@ internal static class MobileAuthenticatorWebHandler { return null; } - return response; + return response.Body; } internal static async Task FinalizeAuthenticator(Bot bot, string activationCode, string authenticatorCode, ulong authenticatorTime) { @@ -111,19 +113,22 @@ internal static class MobileAuthenticatorWebHandler { return null; } - Dictionary arguments = new(5, StringComparer.Ordinal) { - { "access_token", accessToken }, - { "activation_code", activationCode }, - { "authenticator_code", authenticatorCode }, - { "authenticator_time", authenticatorTime }, - { "steamid", bot.SteamID } + CTwoFactor_FinalizeAddAuthenticator_Request request = new() { + activation_code = activationCode, + authenticator_code = authenticatorCode, + authenticator_time = authenticatorTime, + steamid = bot.SteamID + }; + + Dictionary arguments = new(1, StringComparer.Ordinal) { + { "access_token", accessToken } }; using WebAPI.AsyncInterface twoFactorService = bot.SteamConfiguration.GetAsyncWebAPIInterface(TwoFactorService); twoFactorService.Timeout = bot.ArchiWebHandler.WebBrowser.Timeout; - CTwoFactor_FinalizeAddAuthenticator_Response? response = null; + WebAPI.WebAPIResponse? response = null; for (byte i = 0; (i < WebBrowser.MaxTries) && (response == null); i++) { if ((i > 0) && (ArchiWebHandler.WebLimiterDelay > 0)) { @@ -131,12 +136,11 @@ internal static class MobileAuthenticatorWebHandler { } try { - // TODO: Move to CallProtobufAsync when we update to SK2 3.2.0+ response = await ArchiWebHandler.WebLimitRequest( WebAPI.DefaultBaseAddress, // ReSharper disable once AccessToDisposedClosure - async () => await twoFactorService.CallProtobufAsync(HttpMethod.Post, "FinalizeAddAuthenticator", args: arguments).ConfigureAwait(false) + async () => await twoFactorService.CallProtobufAsync(HttpMethod.Post, "FinalizeAddAuthenticator", request, extraArgs: arguments).ConfigureAwait(false) ).ConfigureAwait(false); } catch (TaskCanceledException e) { bot.ArchiLogger.LogGenericDebuggingException(e); @@ -151,6 +155,6 @@ internal static class MobileAuthenticatorWebHandler { return null; } - return response; + return response.Body; } } diff --git a/Directory.Packages.props b/Directory.Packages.props index 9f3b4040e..615a3d3ee 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -17,7 +17,7 @@ - +