CVR Manager 1.0.0

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Exterrata
2026-10-25 02:46:35 -04:00
commit 9bb4f85802
59 changed files with 7913 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
using SteamKit2;
namespace CVRManager.Services;
public static class BranchCodeService
{
public static async Task<Dictionary<string, byte[]>> ResolveAsync(string code, string account, string refreshToken, CancellationToken ct)
{
await using var link = await SteamLink.OpenAsync(account, refreshToken, ct);
return await ResolveAsync(link, code);
}
public static async Task<Dictionary<string, byte[]>> ResolveAsync(SteamLink link, string code)
{
var call = link.Apps.CheckAppBetaPassword((uint)Paths.AppId, code).ToTask();
if (await Task.WhenAny(call, Task.Delay(TimeSpan.FromSeconds(25))) != call)
throw new TimeoutException("Steam did not answer the code check. It limits how often codes can be checked; try again in a few minutes.");
var reply = await call;
if (reply.Result == EResult.OK) return new Dictionary<string, byte[]>(reply.BetaPasswords);
throw new InvalidOperationException(reply.Result switch
{
EResult.InvalidPassword => "Steam did not accept that access code.",
EResult.RateLimitExceeded => "Steam is rate limiting code checks. Wait a few minutes and try again.",
_ => $"Steam could not check the code ({reply.Result}){(link.IsAnonymous ? "; sign in to Steam in Settings and try again" : "")}.",
});
}
public static string ProtectKey(byte[] key) => TokenVault.Protect(Convert.ToBase64String(key));
public static byte[]? UnprotectKey(string stored)
{
var text = TokenVault.Unprotect(stored);
try { return text.Length == 0 ? null : Convert.FromBase64String(text); }
catch (FormatException) { return null; }
}
}