Resolve misc TODOs

This commit is contained in:
Łukasz Domeradzki
2025-05-09 23:31:27 +02:00
parent 08c9636cd9
commit cba29bb2c5
2 changed files with 25 additions and 21 deletions

View File

@@ -52,19 +52,22 @@ internal static class MobileAuthenticatorWebHandler {
return null; return null;
} }
Dictionary<string, object?> arguments = new(5, StringComparer.Ordinal) { CTwoFactor_AddAuthenticator_Request request = new() {
{ "access_token", accessToken }, authenticator_time = Utilities.GetUnixTime(),
{ "authenticator_time", Utilities.GetUnixTime() }, authenticator_type = 1,
{ "authenticator_type", 1 }, device_identifier = deviceID,
{ "device_identifier", deviceID }, steamid = bot.SteamID
{ "steamid", bot.SteamID } };
Dictionary<string, object?> arguments = new(1, StringComparer.Ordinal) {
{ "access_token", accessToken }
}; };
using WebAPI.AsyncInterface twoFactorService = bot.SteamConfiguration.GetAsyncWebAPIInterface(TwoFactorService); using WebAPI.AsyncInterface twoFactorService = bot.SteamConfiguration.GetAsyncWebAPIInterface(TwoFactorService);
twoFactorService.Timeout = bot.ArchiWebHandler.WebBrowser.Timeout; twoFactorService.Timeout = bot.ArchiWebHandler.WebBrowser.Timeout;
CTwoFactor_AddAuthenticator_Response? response = null; WebAPI.WebAPIResponse<CTwoFactor_AddAuthenticator_Response>? response = null;
for (byte i = 0; (i < WebBrowser.MaxTries) && (response == null); i++) { for (byte i = 0; (i < WebBrowser.MaxTries) && (response == null); i++) {
if ((i > 0) && (ArchiWebHandler.WebLimiterDelay > 0)) { if ((i > 0) && (ArchiWebHandler.WebLimiterDelay > 0)) {
@@ -72,12 +75,11 @@ internal static class MobileAuthenticatorWebHandler {
} }
try { try {
// TODO: Move to CallProtobufAsync<TResponse, TRequest> when we update to SK2 3.2.0+ <https://github.com/SteamRE/SteamKit/pull/1537>
response = await ArchiWebHandler.WebLimitRequest( response = await ArchiWebHandler.WebLimitRequest(
WebAPI.DefaultBaseAddress, WebAPI.DefaultBaseAddress,
// ReSharper disable once AccessToDisposedClosure // ReSharper disable once AccessToDisposedClosure
async () => await twoFactorService.CallProtobufAsync<CTwoFactor_AddAuthenticator_Response>(HttpMethod.Post, "AddAuthenticator", args: arguments).ConfigureAwait(false) async () => await twoFactorService.CallProtobufAsync<CTwoFactor_AddAuthenticator_Response, CTwoFactor_AddAuthenticator_Request>(HttpMethod.Post, "AddAuthenticator", request, extraArgs: arguments).ConfigureAwait(false)
).ConfigureAwait(false); ).ConfigureAwait(false);
} catch (TaskCanceledException e) { } catch (TaskCanceledException e) {
bot.ArchiLogger.LogGenericDebuggingException(e); bot.ArchiLogger.LogGenericDebuggingException(e);
@@ -92,7 +94,7 @@ internal static class MobileAuthenticatorWebHandler {
return null; return null;
} }
return response; return response.Body;
} }
internal static async Task<CTwoFactor_FinalizeAddAuthenticator_Response?> FinalizeAuthenticator(Bot bot, string activationCode, string authenticatorCode, ulong authenticatorTime) { internal static async Task<CTwoFactor_FinalizeAddAuthenticator_Response?> FinalizeAuthenticator(Bot bot, string activationCode, string authenticatorCode, ulong authenticatorTime) {
@@ -111,19 +113,22 @@ internal static class MobileAuthenticatorWebHandler {
return null; return null;
} }
Dictionary<string, object?> arguments = new(5, StringComparer.Ordinal) { CTwoFactor_FinalizeAddAuthenticator_Request request = new() {
{ "access_token", accessToken }, activation_code = activationCode,
{ "activation_code", activationCode }, authenticator_code = authenticatorCode,
{ "authenticator_code", authenticatorCode }, authenticator_time = authenticatorTime,
{ "authenticator_time", authenticatorTime }, steamid = bot.SteamID
{ "steamid", bot.SteamID } };
Dictionary<string, object?> arguments = new(1, StringComparer.Ordinal) {
{ "access_token", accessToken }
}; };
using WebAPI.AsyncInterface twoFactorService = bot.SteamConfiguration.GetAsyncWebAPIInterface(TwoFactorService); using WebAPI.AsyncInterface twoFactorService = bot.SteamConfiguration.GetAsyncWebAPIInterface(TwoFactorService);
twoFactorService.Timeout = bot.ArchiWebHandler.WebBrowser.Timeout; twoFactorService.Timeout = bot.ArchiWebHandler.WebBrowser.Timeout;
CTwoFactor_FinalizeAddAuthenticator_Response? response = null; WebAPI.WebAPIResponse<CTwoFactor_FinalizeAddAuthenticator_Response>? response = null;
for (byte i = 0; (i < WebBrowser.MaxTries) && (response == null); i++) { for (byte i = 0; (i < WebBrowser.MaxTries) && (response == null); i++) {
if ((i > 0) && (ArchiWebHandler.WebLimiterDelay > 0)) { if ((i > 0) && (ArchiWebHandler.WebLimiterDelay > 0)) {
@@ -131,12 +136,11 @@ internal static class MobileAuthenticatorWebHandler {
} }
try { try {
// TODO: Move to CallProtobufAsync<TResponse, TRequest> when we update to SK2 3.2.0+ <https://github.com/SteamRE/SteamKit/pull/1537>
response = await ArchiWebHandler.WebLimitRequest( response = await ArchiWebHandler.WebLimitRequest(
WebAPI.DefaultBaseAddress, WebAPI.DefaultBaseAddress,
// ReSharper disable once AccessToDisposedClosure // ReSharper disable once AccessToDisposedClosure
async () => await twoFactorService.CallProtobufAsync<CTwoFactor_FinalizeAddAuthenticator_Response>(HttpMethod.Post, "FinalizeAddAuthenticator", args: arguments).ConfigureAwait(false) async () => await twoFactorService.CallProtobufAsync<CTwoFactor_FinalizeAddAuthenticator_Response, CTwoFactor_FinalizeAddAuthenticator_Request>(HttpMethod.Post, "FinalizeAddAuthenticator", request, extraArgs: arguments).ConfigureAwait(false)
).ConfigureAwait(false); ).ConfigureAwait(false);
} catch (TaskCanceledException e) { } catch (TaskCanceledException e) {
bot.ArchiLogger.LogGenericDebuggingException(e); bot.ArchiLogger.LogGenericDebuggingException(e);
@@ -151,6 +155,6 @@ internal static class MobileAuthenticatorWebHandler {
return null; return null;
} }
return response; return response.Body;
} }
} }

View File

@@ -17,7 +17,7 @@
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.12.0" /> <PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.12.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.12.0" /> <PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.12.0" />
<PackageVersion Include="Scalar.AspNetCore" Version="2.2.7" /> <PackageVersion Include="Scalar.AspNetCore" Version="2.2.7" />
<PackageVersion Include="SteamKit2" Version="3.1.0" /> <PackageVersion Include="SteamKit2" Version="3.2.0" />
<PackageVersion Include="System.Composition" Version="9.0.4" /> <PackageVersion Include="System.Composition" Version="9.0.4" />
<PackageVersion Include="System.Composition.AttributedModel" Version="9.0.4" /> <PackageVersion Include="System.Composition.AttributedModel" Version="9.0.4" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" /> <PackageVersion Include="System.Linq.Async" Version="6.0.1" />