Merge branch 'dyc3-trade-confirmations'
This commit is contained in:
commit
bf593af8c0
2 changed files with 15 additions and 123 deletions
133
Program.cs
133
Program.cs
|
@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
@ -60,6 +61,10 @@ public static class Program
|
||||||
{
|
{
|
||||||
action = "setup";
|
action = "setup";
|
||||||
}
|
}
|
||||||
|
else if (args[i] == "trade")
|
||||||
|
{
|
||||||
|
action = "trade";
|
||||||
|
}
|
||||||
else if (args[i] == "encrypt")
|
else if (args[i] == "encrypt")
|
||||||
{
|
{
|
||||||
action = "encrypt";
|
action = "encrypt";
|
||||||
|
@ -102,7 +107,6 @@ public static class Program
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Verbose) Console.WriteLine("maFiles path: {0}", SteamGuardPath);
|
|
||||||
|
|
||||||
if (Verbose) Console.WriteLine($"Action: {action}");
|
if (Verbose) Console.WriteLine($"Action: {action}");
|
||||||
if (Verbose) Console.WriteLine($"User: {user}");
|
if (Verbose) Console.WriteLine($"User: {user}");
|
||||||
|
@ -123,6 +127,12 @@ public static class Program
|
||||||
case "setup":
|
case "setup":
|
||||||
Setup(user);
|
Setup(user);
|
||||||
break;
|
break;
|
||||||
|
case "trade":
|
||||||
|
Trade(user);
|
||||||
|
break;
|
||||||
|
case "accept-all":
|
||||||
|
AcceptAllTrades(user);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Console.WriteLine("error: Unknown action: {0}", action);
|
Console.WriteLine("error: Unknown action: {0}", action);
|
||||||
return;
|
return;
|
||||||
|
@ -298,125 +308,4 @@ public static class Program
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Setup(string username = "")
|
|
||||||
{
|
|
||||||
if (Verbose) Console.WriteLine("Opening manifest...");
|
|
||||||
Manifest = Manifest.GetManifest(true);
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(username))
|
|
||||||
{
|
|
||||||
Console.Write("Username: ");
|
|
||||||
username = Console.ReadLine();
|
|
||||||
}
|
|
||||||
Console.Write("Password: ");
|
|
||||||
var password = Console.ReadLine();
|
|
||||||
|
|
||||||
UserLogin login = new UserLogin(username, password);
|
|
||||||
Console.Write($"Logging in {username}... ");
|
|
||||||
LoginResult loginResult = login.DoLogin();
|
|
||||||
Console.WriteLine(loginResult);
|
|
||||||
if (!login.LoggedIn) return;
|
|
||||||
|
|
||||||
AuthenticatorLinker linker = new AuthenticatorLinker(login.Session);
|
|
||||||
AuthenticatorLinker.LinkResult linkResult = AuthenticatorLinker.LinkResult.GeneralFailure;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
linkResult = linker.AddAuthenticator();
|
|
||||||
Console.WriteLine($"Link result: {linkResult}");
|
|
||||||
switch (linkResult)
|
|
||||||
{
|
|
||||||
case AuthenticatorLinker.LinkResult.MustProvidePhoneNumber:
|
|
||||||
var phonenumber = "";
|
|
||||||
do
|
|
||||||
{
|
|
||||||
Console.WriteLine("Enter your mobile phone number in the following format: +{cC} phoneNumber. EG, +1 123-456-7890");
|
|
||||||
phonenumber = Console.ReadLine();
|
|
||||||
phonenumber = FilterPhoneNumber(phonenumber);
|
|
||||||
linker.PhoneNumber = phonenumber;
|
|
||||||
} while (!PhoneNumberOkay(phonenumber));
|
|
||||||
break;
|
|
||||||
case AuthenticatorLinker.LinkResult.MustRemovePhoneNumber:
|
|
||||||
linker.PhoneNumber = null;
|
|
||||||
break;
|
|
||||||
case AuthenticatorLinker.LinkResult.AwaitingFinalization:
|
|
||||||
break;
|
|
||||||
case AuthenticatorLinker.LinkResult.GeneralFailure:
|
|
||||||
Console.WriteLine("error: Unable to add your phone number. Steam returned GeneralFailure");
|
|
||||||
return;
|
|
||||||
case AuthenticatorLinker.LinkResult.AuthenticatorPresent:
|
|
||||||
Console.WriteLine("error: Can't link authenticator, remove the previous authenticator.");
|
|
||||||
return;
|
|
||||||
default:
|
|
||||||
Console.WriteLine($"error: Unexpected linker result: {linkResult}");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} while (linkResult != AuthenticatorLinker.LinkResult.AwaitingFinalization);
|
|
||||||
|
|
||||||
string passKey = null;
|
|
||||||
if (Manifest.Entries.Count == 0)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Looks like we are setting up your first account.");
|
|
||||||
passKey = Manifest.PromptSetupPassKey();
|
|
||||||
}
|
|
||||||
else if (Manifest.Entries.Count > 0 && Manifest.Encrypted)
|
|
||||||
{
|
|
||||||
passKey = Manifest.PromptForPassKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Save the file immediately; losing this would be bad.
|
|
||||||
if (!Manifest.SaveAccount(linker.LinkedAccount, passKey != null, passKey))
|
|
||||||
{
|
|
||||||
Manifest.RemoveAccount(linker.LinkedAccount);
|
|
||||||
Console.WriteLine("Unable to save mobile authenticator file. The mobile authenticator has not been linked.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.WriteLine($"The Mobile Authenticator has not yet been linked. Before finalizing the authenticator, please write down your revocation code: {linker.LinkedAccount.RevocationCode}");
|
|
||||||
|
|
||||||
AuthenticatorLinker.FinalizeResult finalizeResponse = AuthenticatorLinker.FinalizeResult.GeneralFailure;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
Console.Write("Please input the SMS message sent to your phone number: ");
|
|
||||||
string smsCode = Console.ReadLine();
|
|
||||||
|
|
||||||
finalizeResponse = linker.FinalizeAddAuthenticator(smsCode);
|
|
||||||
if (Verbose) Console.WriteLine(finalizeResponse);
|
|
||||||
|
|
||||||
switch (finalizeResponse)
|
|
||||||
{
|
|
||||||
case AuthenticatorLinker.FinalizeResult.BadSMSCode:
|
|
||||||
continue;
|
|
||||||
|
|
||||||
case AuthenticatorLinker.FinalizeResult.UnableToGenerateCorrectCodes:
|
|
||||||
Console.WriteLine(
|
|
||||||
"Unable to generate the proper codes to finalize this authenticator. The authenticator should not have been linked.");
|
|
||||||
Console.WriteLine(
|
|
||||||
$"In the off-chance it was, please write down your revocation code, as this is the last chance to see it: {linker.LinkedAccount.RevocationCode}");
|
|
||||||
Manifest.RemoveAccount(linker.LinkedAccount);
|
|
||||||
return;
|
|
||||||
|
|
||||||
case AuthenticatorLinker.FinalizeResult.GeneralFailure:
|
|
||||||
Console.WriteLine("Unable to finalize this authenticator. The authenticator should not have been linked.");
|
|
||||||
Console.WriteLine(
|
|
||||||
$"In the off-chance it was, please write down your revocation code, as this is the last chance to see it: {linker.LinkedAccount.RevocationCode}");
|
|
||||||
Manifest.RemoveAccount(linker.LinkedAccount);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} while (finalizeResponse != AuthenticatorLinker.FinalizeResult.Success);
|
|
||||||
|
|
||||||
//Linked, finally. Re-save with FullyEnrolled property.
|
|
||||||
Manifest.SaveAccount(linker.LinkedAccount, passKey != null, passKey);
|
|
||||||
Console.WriteLine($"Mobile authenticator successfully linked. Please actually write down your revocation code: {linker.LinkedAccount.RevocationCode}");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string FilterPhoneNumber(string phoneNumber) => phoneNumber.Replace("-", "").Replace("(", "").Replace(")", "");
|
|
||||||
|
|
||||||
public static bool PhoneNumberOkay(string phoneNumber)
|
|
||||||
{
|
|
||||||
if (phoneNumber == null || phoneNumber.Length == 0) return false;
|
|
||||||
if (phoneNumber[0] != '+') return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,9 @@
|
||||||
<Reference Include="SteamAuth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
|
<Reference Include="SteamAuth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||||
<HintPath>.\build\SteamAuth.dll</HintPath>
|
<HintPath>.\build\SteamAuth.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<HintPath>..\..\..\..\..\usr\lib\mono\4.5\System.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
@ -61,4 +64,4 @@
|
||||||
<Target Name="AfterBuild">
|
<Target Name="AfterBuild">
|
||||||
</Target>
|
</Target>
|
||||||
-->
|
-->
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in a new issue