Skip to content

Commit fe29ccf

Browse files
committed
Bulk Code Cleanup (No data change)
1 parent 5330665 commit fe29ccf

File tree

98 files changed

+5641
-6564
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+5641
-6564
lines changed

.editorconfig

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ root = true
77
#### Core EditorConfig Options ####
88

99
# Indentation and spacing
10-
indent_size = 4
10+
#indent_size = 4
1111
indent_style = tab
12-
tab_width = 4
12+
#tab_width = 4
1313

1414
# New line preferences
1515
end_of_line = crlf
@@ -308,4 +308,7 @@ csharp_style_var_elsewhere = false:error
308308

309309
dotnet_diagnostic.IDE0079.severity = none
310310
dotnet_diagnostic.IDE00130.severity = none
311-
dotnet_diagnostic.SYSLIB1054.severity = none
311+
dotnet_diagnostic.SYSLIB1054.severity = none
312+
dotnet_diagnostic.IDE0010.severity = none
313+
dotnet_diagnostic.IDE0055.severity = none
314+
dotnet_diagnostic.IDE0058.severity = none

Authentication/Authentication.cs

Lines changed: 119 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using RadiantConnect.Authentication.CaptchaRiotAuth;
2-
using RadiantConnect.Authentication.DriverRiotAuth;
1+
using RadiantConnect.Authentication.DriverRiotAuth;
32
using RadiantConnect.Authentication.DriverRiotAuth.Handlers;
43
using RadiantConnect.Authentication.DriverRiotAuth.Records;
54
using RadiantConnect.Authentication.QRSignIn.Handlers;
@@ -9,152 +8,127 @@
98

109
namespace RadiantConnect.Authentication
1110
{
12-
public class Authentication
13-
{
14-
private readonly string[] _unSupportedBrowsers = ["firefox", "brave", "opera"];
15-
16-
public enum DriverStatus {
17-
CheckingExistingProcesses,
18-
CreatingDriver,
19-
DriverCreated,
20-
BeginSignIn,
21-
LoggingIntoValorant,
22-
CaptchaFound,
23-
CaptchaSolved,
24-
CheckingRSOMultiFactor,
25-
GrabbingRequiredTokens,
26-
MultiFactorRequested,
27-
MultiFactorCompleted,
28-
}
29-
30-
public enum CountryCode
31-
{
32-
Na,
33-
Kr,
34-
Jp,
35-
Cn,
36-
Tw,
37-
Euw,
38-
Ru,
39-
Tr,
40-
Th,
41-
Vn,
42-
Id,
43-
My,
44-
Eun,
45-
Br,
46-
}
47-
48-
[Flags]
49-
public enum CaptchaService
50-
{
51-
SuperMemory,
52-
CaptchaSolverNet
53-
};
54-
55-
public event Events.MultiFactorEvent? OnMultiFactorRequested;
56-
57-
public event Events.DriverEvent? OnDriverUpdate;
58-
59-
public event UrlBuilder? OnUrlBuilt;
60-
61-
public string? MultiFactorCode
62-
{
63-
get => AuthHandler.MultiFactorCode;
64-
set => AuthHandler.MultiFactorCode = value;
65-
}
66-
67-
internal AuthHandler AuthHandler = null!;
68-
69-
internal async Task<RSOAuth?> AuthenticateWithCaptcha(string username, string password, CaptchaService service, string captchaAuthorization)
70-
{
71-
#if DEBUG
72-
switch (service)
73-
{
74-
case CaptchaService.SuperMemory | CaptchaService.CaptchaSolverNet:
75-
SuperMemory superMemory = new(captchaAuthorization);
76-
RSOAuth? rsoData = await superMemory.BeginSignIn(username, password);
77-
superMemory.Dispose();
78-
return rsoData;
79-
default:
80-
throw new NotImplementedException();
81-
}
82-
#else
83-
await Task.Delay(0); // Placeholder for actual implementation, and to prevent build errors in release mode.
84-
throw new RadiantConnectAuthException("Captcha authentication is not supported in this build. Please use the driver authentication method instead.");
85-
#endif
86-
}
87-
88-
public async Task<RSOAuth?> AuthenticateWithSsid(string ssid, string? clid = "", string? csid = "", string? tdid = "", string? asid = "", WebProxy? proxy = null) => await SsidAuthManager.Authenticate(ssid, clid, csid, tdid, asid, proxy);
89-
90-
public async Task<RSOAuth?> AuthenticateWithQr(CountryCode countryCode, bool returnLoginUrl = false)
91-
{
92-
SignInManager manager = new(countryCode, returnLoginUrl);
93-
94-
if (returnLoginUrl)
95-
manager.OnUrlBuilt += OnUrlBuilt;
96-
97-
return await manager.Authenticate();
98-
}
99-
100-
public async Task<RSOAuth?> AuthenticateWithDriver(string username, string password, DriverSettings? driverSettings = null, bool acceptedTerms = false)
101-
{
102-
if (!acceptedTerms)
103-
throw new RadiantConnectAuthException("Due to recent changes in the library, you must target windows to hide the driver automatically\nOn other OS's I am unable to hide the driver.\nTo use this authentication method add the parameter `acceptedTerms: true`");
104-
105-
driverSettings ??= new DriverSettings();
106-
107-
if (_unSupportedBrowsers.Contains(driverSettings.ProcessName))
108-
throw new RadiantConnectAuthException("Unsupported browser");
109-
110-
AuthHandler = new AuthHandler(
111-
driverSettings.ProcessName,
112-
driverSettings.BrowserExecutable,
113-
driverSettings.KillBrowser,
114-
driverSettings.CacheCookies,
115-
driverSettings.UseHeadless
116-
);
117-
118-
AuthHandler.OnMultiFactorRequested += () => OnMultiFactorRequested?.Invoke();
119-
AuthHandler.OnDriverUpdate += status => OnDriverUpdate?.Invoke(status);
120-
121-
Task<(string, string, string, string)> authTask = AuthHandler.Authenticate(username, password);
11+
public class Authentication
12+
{
13+
private readonly string[] _unSupportedBrowsers = ["firefox", "brave", "opera"];
14+
15+
public enum DriverStatus {
16+
CheckingExistingProcesses,
17+
CreatingDriver,
18+
DriverCreated,
19+
BeginSignIn,
20+
LoggingIntoValorant,
21+
CaptchaFound,
22+
CaptchaSolved,
23+
CheckingRSOMultiFactor,
24+
GrabbingRequiredTokens,
25+
MultiFactorRequested,
26+
MultiFactorCompleted,
27+
}
28+
29+
public enum CountryCode
30+
{
31+
Na,
32+
Kr,
33+
Jp,
34+
Cn,
35+
Tw,
36+
Euw,
37+
Ru,
38+
Tr,
39+
Th,
40+
Vn,
41+
Id,
42+
My,
43+
Eun,
44+
Br,
45+
}
46+
47+
48+
public event Events.MultiFactorEvent? OnMultiFactorRequested;
49+
50+
public event Events.DriverEvent? OnDriverUpdate;
51+
52+
public event UrlBuilder? OnUrlBuilt;
53+
54+
public string? MultiFactorCode
55+
{
56+
get => AuthHandler.MultiFactorCode;
57+
set => AuthHandler.MultiFactorCode = value;
58+
}
59+
60+
internal AuthHandler AuthHandler = null!;
61+
62+
public async Task<RSOAuth?> AuthenticateWithSsid(string ssid, string? clid = "", string? csid = "", string? tdid = "", string? asid = "", WebProxy? proxy = null) => await SsidAuthManager.Authenticate(ssid, clid, csid, tdid, asid, proxy);
63+
64+
public async Task<RSOAuth?> AuthenticateWithQr(CountryCode countryCode, bool returnLoginUrl = false)
65+
{
66+
SignInManager manager = new(countryCode, returnLoginUrl);
67+
68+
if (returnLoginUrl)
69+
manager.OnUrlBuilt += OnUrlBuilt;
70+
71+
return await manager.Authenticate();
72+
}
73+
74+
public async Task<RSOAuth?> AuthenticateWithDriver(string username, string password, DriverSettings? driverSettings = null, bool acceptedTerms = false)
75+
{
76+
if (!acceptedTerms)
77+
throw new RadiantConnectAuthException("Due to recent changes in the library, you must target windows to hide the driver automatically\nOn other OS's I am unable to hide the driver.\nTo use this authentication method add the parameter `acceptedTerms: true`");
78+
79+
driverSettings ??= new DriverSettings();
80+
81+
if (_unSupportedBrowsers.Contains(driverSettings.ProcessName))
82+
throw new RadiantConnectAuthException("Unsupported browser");
83+
84+
AuthHandler = new AuthHandler(
85+
driverSettings.ProcessName,
86+
driverSettings.BrowserExecutable,
87+
driverSettings.KillBrowser,
88+
driverSettings.CacheCookies,
89+
driverSettings.UseHeadless
90+
);
91+
92+
AuthHandler.OnMultiFactorRequested += () => OnMultiFactorRequested?.Invoke();
93+
AuthHandler.OnDriverUpdate += status => OnDriverUpdate?.Invoke(status);
94+
95+
Task<(string, string, string, string)> authTask = AuthHandler.Authenticate(username, password);
12296
#if DEBUG
123-
Task delayTask = Task.Delay(TimeSpan.FromDays(1));
97+
Task delayTask = Task.Delay(TimeSpan.FromDays(1));
12498
#else
125-
Task delayTask = Task.Delay(TimeSpan.FromSeconds(45));
99+
Task delayTask = Task.Delay(TimeSpan.FromSeconds(45));
126100
#endif
127-
if (await Task.WhenAny(authTask, delayTask) == authTask)
128-
{
129-
// Authentication completed within timeout
130-
(string ssid, string clid, string tdid, string csid) = await authTask;
131-
Debug.WriteLine($"{DateTime.Now} LOGIN DONE");
132-
133-
AuthHandler.Dispose();
134-
135-
return await SsidAuthManager.Authenticate(ssid, clid, csid, tdid);
136-
}
137-
138-
AuthHandler.Dispose();
139-
140-
Debug.WriteLine($"{DateTime.Now} LOGIN TIMEOUT");
141-
throw new TimeoutException("Authentication timed out after 45 seconds.");
142-
}
143-
144-
public async Task<IReadOnlyList<Cookie>?> GetCachedCookies()
145-
{
146-
string cacheFile = $@"{Path.GetTempPath()}\RadiantConnect\cookies.json";
147-
return !File.Exists(cacheFile) ? null : JsonSerializer.Deserialize<CookieRoot>(await File.ReadAllTextAsync(cacheFile))?.Result.Cookies;
148-
}
149-
150-
public async Task<string?> GetSsidFromDriverCache()
151-
{
152-
IEnumerable<Cookie>? cookiesData = await GetCachedCookies();
153-
return cookiesData?.FirstOrDefault(x => x.Name == "ssid")?.Value;
154-
}
101+
if (await Task.WhenAny(authTask, delayTask) == authTask)
102+
{
103+
// Authentication completed within timeout
104+
(string ssid, string clid, string tdid, string csid) = await authTask;
105+
Debug.WriteLine($"{DateTime.Now} LOGIN DONE");
106+
107+
AuthHandler.Dispose();
108+
109+
return await SsidAuthManager.Authenticate(ssid, clid, csid, tdid);
110+
}
111+
112+
AuthHandler.Dispose();
113+
114+
Debug.WriteLine($"{DateTime.Now} LOGIN TIMEOUT");
115+
throw new TimeoutException("Authentication timed out after 45 seconds.");
116+
}
117+
118+
public async Task<IReadOnlyList<Cookie>?> GetCachedCookies()
119+
{
120+
string cacheFile = $@"{Path.GetTempPath()}\RadiantConnect\cookies.json";
121+
return !File.Exists(cacheFile) ? null : JsonSerializer.Deserialize<CookieRoot>(await File.ReadAllTextAsync(cacheFile))?.Result.Cookies;
122+
}
123+
124+
public async Task<string?> GetSsidFromDriverCache()
125+
{
126+
IEnumerable<Cookie>? cookiesData = await GetCachedCookies();
127+
return cookiesData?.FirstOrDefault(x => x.Name == "ssid")?.Value;
128+
}
155129

156-
public async Task<RSOAuth?> AuthenticateWithRiotClient(string? settingsFile = null, bool skipTdid = false, bool skipClid = false, bool skipCsid = false) => await new RtcAuth().Run(settingsFile, this, skipTdid, skipClid, skipCsid);
130+
public async Task<RSOAuth?> AuthenticateWithRiotClient(string? settingsFile = null, bool skipTdid = false, bool skipClid = false, bool skipCsid = false) => await new RtcAuth().Run(settingsFile, this, skipTdid, skipClid, skipCsid);
157131

158-
public async Task<RSOAuth?> AuthenticateWithLockFile() => await new LockFileAuth().Run();
159-
}
132+
public async Task<RSOAuth?> AuthenticateWithLockFile() => await new LockFileAuth().Run();
133+
}
160134
}

Authentication/CaptchaRiotAuth/2Captcha.cs

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)