diff --git a/DepotDownloader/DepotDownloaderAuthenticator.cs b/DepotDownloader/DepotDownloaderAuthenticator.cs new file mode 100644 index 00000000..70184d1a --- /dev/null +++ b/DepotDownloader/DepotDownloaderAuthenticator.cs @@ -0,0 +1,60 @@ +using System; +using System.Threading.Tasks; +using SteamKit2.Authentication; + +namespace DepotDownloader; + +public class DepotDownloaderAuthenticator : IAuthenticator +{ + public Task GetDeviceCodeAsync(bool previousCodeWasIncorrect) + { + if (previousCodeWasIncorrect) + { + Console.Out.WriteLine("[2FA]|[Wrong]|The previous 2-factor auth code you have provided is incorrect."); + } + + string? code; + + do + { + Console.Out.Write("[2FA]|Please enter your 2 factor auth code from your authenticator app: "); + code = Console.ReadLine()?.Trim(); + + if (code == null) + { + break; + } + } while (string.IsNullOrEmpty(code)); + + return Task.FromResult(code!); + } + + public Task GetEmailCodeAsync(string email, bool previousCodeWasIncorrect) + { + if (previousCodeWasIncorrect) + { + Console.Out.WriteLine("[Guard]|[Wrong]|The previous 2-factor auth code you have provided is incorrect."); + } + + string? code; + + do + { + Console.Out.Write($"[Guard]|Please enter the authentication code sent to your email address: "); + code = Console.ReadLine()?.Trim(); + + if (code == null) + { + break; + } + } while (string.IsNullOrEmpty(code)); + + return Task.FromResult(code!); + } + + public Task AcceptDeviceConfirmationAsync() + { + Console.Out.WriteLine("[MobileApp]|Use the Steam Mobile App to confirm your sign in..."); + return Task.FromResult(true); + } +} diff --git a/DepotDownloader/Steam3Session.cs b/DepotDownloader/Steam3Session.cs index 51260f1e..7150a55e 100644 --- a/DepotDownloader/Steam3Session.cs +++ b/DepotDownloader/Steam3Session.cs @@ -513,7 +513,7 @@ namespace DepotDownloader Username = logonDetails.Username, Password = logonDetails.Password, IsPersistentSession = ContentDownloader.Config.RememberPassword, - Authenticator = new UserConsoleAuthenticator(), + Authenticator = new DepotDownloaderAuthenticator(), }); } catch (TaskCanceledException)