Skip to content

Commit

Permalink
4.0.0 Final Build
Browse files Browse the repository at this point in the history
See Nuget Patch Notes
  • Loading branch information
RiisDev committed Jan 10, 2024
1 parent ccf5848 commit 173da40
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 98 deletions.
4 changes: 2 additions & 2 deletions EventHandler/Events/PreGameEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public void HandlePreGameEvents(string invoker, string logData)
break;
case "Pregame_LockCharacter":
agentId = logData.ExtractValue(@"lock/([a-fA-F\d-]+)", 1);
OnAgentLockedIn?.Invoke(InternalValorantMethods.AgentIdToAgent[agentId]);
OnAgentLockedIn?.Invoke(ValorantTables.AgentIdToAgent[agentId]);
break;
case "Pregame_SelectCharacter":
agentId = logData.ExtractValue(@"select/([a-fA-F\d-]+)", 1);
OnAgentSelected?.Invoke(InternalValorantMethods.AgentIdToAgent[agentId]);
OnAgentSelected?.Invoke(ValorantTables.AgentIdToAgent[agentId]);
break;
}
}
Expand Down
11 changes: 6 additions & 5 deletions Initiator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using RadiantConnect.Methods;
using RadiantConnect.Services;
using RadiantConnect.Network;
using RadiantConnect.Network.Authorization.DataTypes;
using RadiantConnect.Network.ChatEndpoints;
using RadiantConnect.Network.ContractEndpoints;
using RadiantConnect.Network.CurrentGameEndpoints;
Expand All @@ -21,7 +20,6 @@ public record InternalSystem(
LogService.ClientData ClientData
);


public record Endpoints(
ChatEndpoints ChatEndpoints,
ContractEndpoints ContractEndpoints,
Expand All @@ -48,14 +46,15 @@ internal static bool ClientIsReady()
public InternalSystem ExternalSystem { get; }
public Endpoints Endpoints { get; }
public GameEvents GameEvents { get; set; } = null!;
public LogService.ClientData Client { get; }

public Initiator(InternalAuth? internalAuth = null)
public Initiator()
{
while (!ClientIsReady() && internalAuth is null) Task.Delay(500);
while (!ClientIsReady()) Task.Delay(500);
ValorantService client = new();
LogService logService = new();
LogService.ClientData cData = LogService.GetClientData();
ValorantNet net = internalAuth is null ? new ValorantNet(client) : new ValorantNet(null, internalAuth);
ValorantNet net = new(client);

ExternalSystem = new InternalSystem(
client,
Expand All @@ -64,6 +63,8 @@ public Initiator(InternalAuth? internalAuth = null)
cData
);

Client = cData;

Endpoints = new Endpoints(
new ChatEndpoints(this),
new ContractEndpoints(this),
Expand Down
18 changes: 0 additions & 18 deletions Network/Authorization/Authorization.cs

This file was deleted.

18 changes: 0 additions & 18 deletions Network/Authorization/DataTypes/ClientVersion.cs

This file was deleted.

15 changes: 0 additions & 15 deletions Network/Authorization/DataTypes/InternalAuth.cs

This file was deleted.

4 changes: 2 additions & 2 deletions Network/PartyEndpoints/PartyEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public enum PartyState
public async Task<Party?> ChangeQueueAsync(string partyId, QueueId queueId)
{
JsonContent jsonContent = JsonContent.Create(new NameValueCollection() { { "queueId", queueId.ToString() } });
return await initiator.ExternalSystem.Net.PostAsync<Party>(Url, $"parties/v1/parties/{partyId}/queue", jsonContent);
return await initiator.ExternalSystem.Net.PostAsync<Party>(Url, $"parties/v1/parties/{partyId}/queue", jsonContent);
}

public async Task<Party?> StartCustomGameeAsync(string partyId)
Expand All @@ -96,7 +96,7 @@ public enum PartyState
public async Task<Party?> SetPartyOpenStatusAsync(string partyId, PartyState state)
{
JsonContent jsonContent = JsonContent.Create(new NameValueCollection() { { "accessibility", state.ToString() } });
return await initiator.ExternalSystem.Net.PostAsync<Party>(Url, $"parties/v1/parties/{partyId}/accessibility", jsonContent);
return await initiator.ExternalSystem.Net.PostAsync<Party>(Url, $"parties/v1/parties/{partyId}/accessibility", jsonContent);
}

public async Task<Party?> SetCustomGameSettingsAsync(string partyId, CustomGameSettings gameSettings)
Expand Down
39 changes: 8 additions & 31 deletions Network/ValorantNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using RadiantConnect.Methods;
using RadiantConnect.Network.Authorization.DataTypes;
using RadiantConnect.Services;

namespace RadiantConnect.Network
{
public class ValorantNet
{
internal InternalAuth? InternalAuth;
internal HttpClient Client = new(new HttpClientHandler { ServerCertificateCustomValidationCallback = (_, _, _, _) => true });

public static int? GetAuthPort(){return GetAuth()?.AuthorizationPort;}
Expand All @@ -39,15 +37,11 @@ internal enum HttpMethod
Head
}

public ValorantNet(ValorantService? valorantClient = null, InternalAuth? internalAuth = null)
public ValorantNet(ValorantService? valorantClient = null)
{
Client.DefaultRequestHeaders.TryAddWithoutValidation("X-Riot-ClientPlatform", "ew0KCSJwbGF0Zm9ybVR5cGUiOiAiUEMiLA0KCSJwbGF0Zm9ybU9TIjogIldpbmRvd3MiLA0KCSJwbGF0Zm9ybU9TVmVyc2lvbiI6ICIxMC4wLjE5MDQyLjEuMjU2LjY0Yml0IiwNCgkicGxhdGZvcm1DaGlwc2V0IjogIlVua25vd24iDQp9");
Client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "ShooterGame/13 Windows/10.0.19043.1.256.64bit");
Client.DefaultRequestHeaders.TryAddWithoutValidation("X-Riot-ClientVersion",
internalAuth is not null
? internalAuth.ClientVersion.Data.RiotClientVersion
: valorantClient?.ValorantClientVersion.RiotClientVersion);
InternalAuth = internalAuth;
Client.DefaultRequestHeaders.TryAddWithoutValidation("X-Riot-ClientVersion",valorantClient?.ValorantClientVersion.RiotClientVersion);
}

internal static InternalRecords.UserAuth? GetAuth()
Expand Down Expand Up @@ -90,7 +84,7 @@ internalAuth is not null
return (entitlement?.AccessToken ?? "", entitlement?.Token ?? "");
}

internal async Task LocalAuthReset()
internal async Task ResetAuth()
{
Client.DefaultRequestHeaders.Remove("X-Riot-Entitlements-JWT");
Client.DefaultRequestHeaders.Remove("Authorization");
Expand All @@ -103,32 +97,13 @@ internal async Task LocalAuthReset()
Client.DefaultRequestHeaders.TryAddWithoutValidation("X-Riot-Entitlements-JWT", authTokens.Item2);
}

internal async Task DoExternalAuthReset()
{
if (InternalAuth is null) return;
Client.DefaultRequestHeaders.Remove("X-Riot-Entitlements-JWT");
Client.DefaultRequestHeaders.Remove("Authorization");

InternalAuth = await Authorization.Authorization.PerformSignIn(InternalAuth);

Client.DefaultRequestHeaders.Authorization = AuthenticationHeaderValue.Parse($"Bearer {InternalAuth?.AuthorizationHeaders?.Bearer}");
Client.DefaultRequestHeaders.TryAddWithoutValidation("X-Riot-Entitlements-JWT", InternalAuth?.AuthorizationHeaders?.XRiotEntitlementsJWT);
}

internal async Task ResetAuth()
{
if (InternalAuth is null) await LocalAuthReset().ConfigureAwait(false);
else await DoExternalAuthReset().ConfigureAwait(false);
}

internal async Task<string?> CreateRequest(HttpMethod httpMethod, string baseUrl, string endPoint, HttpContent? content = null)
{
if (baseUrl.Contains("127.0.0") && InternalAuth is not null) return "INVALID_REQUEST";
while (InternalValorantMethods.IsValorantProcessRunning() || InternalAuth is not null)
while (InternalValorantMethods.IsValorantProcessRunning())
{
if (!Client.DefaultRequestHeaders.Contains("X-Riot-Entitlements-JWT")) { await ResetAuth(); continue; }

using HttpRequestMessage httpRequest = new();
HttpRequestMessage httpRequest = new();
httpRequest.Method = InternalToHttpMethod[httpMethod];
httpRequest.RequestUri = new Uri($"{baseUrl}{endPoint}");
httpRequest.Content = content;
Expand All @@ -147,6 +122,8 @@ internal async Task ResetAuth()

string responseContent = await responseMessage.Content.ReadAsStringAsync();
Debug.WriteLine($"{baseUrl}{endPoint}\n{JsonSerializer.Serialize(content)}");
httpRequest.Dispose();
responseMessage.Dispose();
return (responseContent.Contains("<html>") || responseContent.Contains("errorCode")) ? null : responseContent;
}
return string.Empty;
Expand All @@ -166,7 +143,7 @@ internal async Task ResetAuth()
return string.IsNullOrEmpty(jsonData) ? default : JsonSerializer.Deserialize<T>(jsonData);
}

internal async Task<T?> PutAsync<T>(string baseUrl, string endPoint, HttpContent httpContent)
internal async Task<T?> PutAsync<T>(string baseUrl, string endPoint,HttpContent httpContent)
{
string? jsonData = await CreateRequest(HttpMethod.Put, baseUrl, endPoint, httpContent);
if (endPoint == "name-service/v2/players")
Expand Down
9 changes: 5 additions & 4 deletions RadiantConnect.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
<GenerateDocumentationFile>False</GenerateDocumentationFile>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Title>Radiant Connect Valorant API (UnOfficialt)</Title>
<Version>3.0.0</Version>
<Version>4.0.0</Version>
<Authors>IrisDev</Authors>
<PackageProjectUrl>https://irisapp.ca/RadiantConnect</PackageProjectUrl>
<RepositoryUrl>https://github.com/IrisV3rm/RadiantConnect</RepositoryUrl>
<RepositoryUrl>https://github.com/RiisDev/RadiantConnect</RepositoryUrl>
<Copyright>https://github.com/RiisDev</Copyright>
<Description>Unoffical Valorant Local API, Offers game events.</Description>
<Description>Valorant .Net API, Internal Riot API Usage, With automatic game event handlers</Description>
<PackageIcon>icon.png</PackageIcon>
<PackageTags>valorant;.net;api;valorant api; open source</PackageTags>
<PackageReleaseNotes>More bug fixees + updates.</PackageReleaseNotes>
<PackageReleaseNotes>+Built into dictionaries for known PUUIDs (Will be added to docs later)
+End point changes (Bugs always)</PackageReleaseNotes>
<NeutralLanguage>en</NeutralLanguage>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down
2 changes: 1 addition & 1 deletion obj/RadiantConnect.csproj.nuget.dgspec.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"projects": {
"G:\\Sources\\C#\\Public Source Releases\\RadiantConnect\\RadiantConnect.csproj": {
"version": "3.0.0",
"version": "4.0.0",
"restore": {
"projectUniqueName": "G:\\Sources\\C#\\Public Source Releases\\RadiantConnect\\RadiantConnect.csproj",
"projectName": "RadiantConnect",
Expand Down
2 changes: 1 addition & 1 deletion obj/project.assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {}
},
"project": {
"version": "3.0.0",
"version": "4.0.0",
"restore": {
"projectUniqueName": "G:\\Sources\\C#\\Public Source Releases\\RadiantConnect\\RadiantConnect.csproj",
"projectName": "RadiantConnect",
Expand Down
2 changes: 1 addition & 1 deletion obj/project.nuget.cache
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 2,
"dgSpecHash": "4tY0Y0Nq8NyWs093XlKo6Rfhxr1znDVQUIg7ys4jdGkc5gk5PTyUYik3o9rXLCzwN5XXk20eNHV7AWWEAn0Lyw==",
"dgSpecHash": "9raa73aI+2SYKIjiXTYm5WhaVElm3Q5C28KCrRST+YvMPXydDWjv3rlVF5PGmo7FoxyDpwPkQWIyZuuC/4xd3g==",
"success": true,
"projectFilePath": "G:\\Sources\\C#\\Public Source Releases\\RadiantConnect\\RadiantConnect.csproj",
"expectedPackageFiles": [],
Expand Down

0 comments on commit 173da40

Please sign in to comment.