diff --git a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs index 5351ba560..e603abc41 100644 --- a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs +++ b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs @@ -1467,7 +1467,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { pendingMobileTradeOfferIDs.UnionWith(mobileTradeOfferIDs); if (pendingMobileTradeOfferIDs.Count >= MaxTradeOffersActive) { - (bool twoFactorSuccess, IReadOnlyCollection? handledConfirmations, _) = await Bot.Actions.HandleTwoFactorAuthenticationConfirmations(true, Confirmation.EConfirmationType.Trade, pendingMobileTradeOfferIDs, true).ConfigureAwait(false); + (bool twoFactorSuccess, IReadOnlyCollection? handledConfirmations, _) = await Bot.Actions.HandleTwoFactorAuthenticationConfirmations(true, EMobileConfirmationType.Trade, pendingMobileTradeOfferIDs, true).ConfigureAwait(false); if (!twoFactorSuccess) { Bot.ArchiLogger.LogGenericWarning(Localization.Strings.FormatActivelyMatchingSomeConfirmationsFailed(handledConfirmations?.Count ?? 0, pendingMobileTradeOfferIDs.Count)); @@ -1563,7 +1563,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { } if (pendingMobileTradeOfferIDs.Count > 0) { - (bool twoFactorSuccess, IReadOnlyCollection? handledConfirmations, _) = Bot.IsConnectedAndLoggedOn ? await Bot.Actions.HandleTwoFactorAuthenticationConfirmations(true, Confirmation.EConfirmationType.Trade, pendingMobileTradeOfferIDs, true).ConfigureAwait(false) : (false, null, null); + (bool twoFactorSuccess, IReadOnlyCollection? handledConfirmations, _) = Bot.IsConnectedAndLoggedOn ? await Bot.Actions.HandleTwoFactorAuthenticationConfirmations(true, EMobileConfirmationType.Trade, pendingMobileTradeOfferIDs, true).ConfigureAwait(false) : (false, null, null); if (!twoFactorSuccess) { Bot.ArchiLogger.LogGenericWarning(Localization.Strings.FormatActivelyMatchingSomeConfirmationsFailed(handledConfirmations?.Count ?? 0, pendingMobileTradeOfferIDs.Count)); diff --git a/ArchiSteamFarm/IPC/Controllers/Api/TwoFactorAuthenticationController.cs b/ArchiSteamFarm/IPC/Controllers/Api/TwoFactorAuthenticationController.cs index 7d5f5514a..529f1e4ae 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/TwoFactorAuthenticationController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/TwoFactorAuthenticationController.cs @@ -36,6 +36,7 @@ using ArchiSteamFarm.Steam.Data; using ArchiSteamFarm.Steam.Security; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using SteamKit2; namespace ArchiSteamFarm.IPC.Controllers.Api; @@ -74,7 +75,7 @@ public sealed class TwoFactorAuthenticationController : ArchiController { ArgumentException.ThrowIfNullOrEmpty(botNames); ArgumentNullException.ThrowIfNull(request); - if (request.AcceptedType.HasValue && ((request.AcceptedType.Value == Confirmation.EConfirmationType.Unknown) || !Enum.IsDefined(request.AcceptedType.Value))) { + if (request.AcceptedType.HasValue && ((request.AcceptedType.Value == EMobileConfirmationType.Invalid) || !Enum.IsDefined(request.AcceptedType.Value))) { return BadRequest(new GenericResponse(false, Strings.FormatErrorIsInvalid(nameof(request.AcceptedType)))); } diff --git a/ArchiSteamFarm/IPC/Requests/TwoFactorAuthenticationConfirmationsRequest.cs b/ArchiSteamFarm/IPC/Requests/TwoFactorAuthenticationConfirmationsRequest.cs index dac5c480d..6f2639362 100644 --- a/ArchiSteamFarm/IPC/Requests/TwoFactorAuthenticationConfirmationsRequest.cs +++ b/ArchiSteamFarm/IPC/Requests/TwoFactorAuthenticationConfirmationsRequest.cs @@ -33,7 +33,7 @@ using System.Text.Json.Serialization; using ArchiSteamFarm.Core; using ArchiSteamFarm.Helpers.Json; using ArchiSteamFarm.Localization; -using ArchiSteamFarm.Steam.Data; +using SteamKit2; namespace ArchiSteamFarm.IPC.Requests; @@ -52,7 +52,7 @@ public sealed class TwoFactorAuthenticationConfirmationsRequest { [Description("Specifies the type of confirmations to handle. If not provided, all confirmation types are considered for an action")] [JsonInclude] - public Confirmation.EConfirmationType? AcceptedType { get; private init; } + public EMobileConfirmationType? AcceptedType { get; private init; } [Description($"A helper property which works the same as {nameof(AcceptedCreatorIDs)} but with values written as strings - for javascript compatibility purposes. Use either this one, or {nameof(AcceptedCreatorIDs)}, not both")] [JsonDisallowNull] diff --git a/ArchiSteamFarm/Steam/Data/Confirmation.cs b/ArchiSteamFarm/Steam/Data/Confirmation.cs index f67afd12e..48b02bfc5 100644 --- a/ArchiSteamFarm/Steam/Data/Confirmation.cs +++ b/ArchiSteamFarm/Steam/Data/Confirmation.cs @@ -24,6 +24,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json.Serialization; using JetBrains.Annotations; +using SteamKit2; namespace ArchiSteamFarm.Steam.Data; @@ -33,7 +34,7 @@ public sealed class Confirmation { [JsonInclude] [JsonPropertyName("type")] [JsonRequired] - public EConfirmationType ConfirmationType { get; private init; } + public EMobileConfirmationType ConfirmationType { get; private init; } [JsonInclude] [JsonPropertyName("type_name")] @@ -62,18 +63,4 @@ public sealed class Confirmation { [UsedImplicitly] public static bool ShouldSerializeNonce() => false; - - [PublicAPI] - public enum EConfirmationType : byte { - Unknown, - Generic, - Trade, - Market, - FeatureOptOut, - PhoneNumberChange, - AccountRecovery, - ApiKeyRegistration = 9, - FamilyJoin = 11, - AccountSecurity = 12 - } } diff --git a/ArchiSteamFarm/Steam/Exchange/Trading.cs b/ArchiSteamFarm/Steam/Exchange/Trading.cs index 90c8c0ebc..3415e5d62 100644 --- a/ArchiSteamFarm/Steam/Exchange/Trading.cs +++ b/ArchiSteamFarm/Steam/Exchange/Trading.cs @@ -303,7 +303,7 @@ public sealed class Trading : IDisposable { if (mobileTradeResults.Count > 0) { HashSet mobileTradeOfferIDs = mobileTradeResults.Select(static tradeOffer => tradeOffer.TradeOfferID).ToHashSet(); - (bool twoFactorSuccess, _, _) = await Bot.Actions.HandleTwoFactorAuthenticationConfirmations(true, Confirmation.EConfirmationType.Trade, mobileTradeOfferIDs, true).ConfigureAwait(false); + (bool twoFactorSuccess, _, _) = await Bot.Actions.HandleTwoFactorAuthenticationConfirmations(true, EMobileConfirmationType.Trade, mobileTradeOfferIDs, true).ConfigureAwait(false); if (twoFactorSuccess) { foreach (ParseTradeResult mobileTradeResult in mobileTradeResults) { diff --git a/ArchiSteamFarm/Steam/Interaction/Actions.cs b/ArchiSteamFarm/Steam/Interaction/Actions.cs index 7bd09d04e..e9c3951bb 100644 --- a/ArchiSteamFarm/Steam/Interaction/Actions.cs +++ b/ArchiSteamFarm/Steam/Interaction/Actions.cs @@ -217,7 +217,7 @@ public sealed class Actions : IAsyncDisposable, IDisposable { } [PublicAPI] - public async Task<(bool Success, IReadOnlyCollection? HandledConfirmations, string Message)> HandleTwoFactorAuthenticationConfirmations(bool accept, Confirmation.EConfirmationType? acceptedType = null, IReadOnlyCollection? acceptedCreatorIDs = null, bool waitIfNeeded = false) { + public async Task<(bool Success, IReadOnlyCollection? HandledConfirmations, string Message)> HandleTwoFactorAuthenticationConfirmations(bool accept, EMobileConfirmationType? acceptedType = null, IReadOnlyCollection? acceptedCreatorIDs = null, bool waitIfNeeded = false) { if (Bot.BotDatabase.MobileAuthenticator == null) { return (false, null, Strings.BotNoASFAuthenticator); } @@ -468,7 +468,7 @@ public sealed class Actions : IAsyncDisposable, IDisposable { (bool success, _, HashSet? mobileTradeOfferIDs) = await Bot.ArchiWebHandler.SendTradeOffer(targetSteamID, items, token: tradeToken, customMessage: customMessage, itemsPerTrade: itemsPerTrade).ConfigureAwait(false); if ((mobileTradeOfferIDs?.Count > 0) && Bot.HasMobileAuthenticator) { - (bool twoFactorSuccess, _, _) = await HandleTwoFactorAuthenticationConfirmations(true, Confirmation.EConfirmationType.Trade, mobileTradeOfferIDs, true).ConfigureAwait(false); + (bool twoFactorSuccess, _, _) = await HandleTwoFactorAuthenticationConfirmations(true, EMobileConfirmationType.Trade, mobileTradeOfferIDs, true).ConfigureAwait(false); if (!twoFactorSuccess) { return (false, Strings.BotLootingFailed); diff --git a/ArchiSteamFarm/Steam/Security/MobileAuthenticator.cs b/ArchiSteamFarm/Steam/Security/MobileAuthenticator.cs index ddeb66fc9..85fb067ed 100644 --- a/ArchiSteamFarm/Steam/Security/MobileAuthenticator.cs +++ b/ArchiSteamFarm/Steam/Security/MobileAuthenticator.cs @@ -38,6 +38,7 @@ using ArchiSteamFarm.Helpers; using ArchiSteamFarm.Localization; using ArchiSteamFarm.Steam.Data; using ArchiSteamFarm.Storage; +using SteamKit2; namespace ArchiSteamFarm.Steam.Security; @@ -175,7 +176,7 @@ public sealed class MobileAuthenticator : IDisposable { return null; } - foreach (Confirmation confirmation in response.Confirmations.Where(static confirmation => (confirmation.ConfirmationType == Confirmation.EConfirmationType.Unknown) || !Enum.IsDefined(confirmation.ConfirmationType))) { + foreach (Confirmation confirmation in response.Confirmations.Where(static confirmation => (confirmation.ConfirmationType == EMobileConfirmationType.Invalid) || !Enum.IsDefined(confirmation.ConfirmationType))) { Bot.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(confirmation.ConfirmationType), $"{confirmation.ConfirmationType} ({confirmation.ConfirmationTypeName ?? "null"})")); }