OnLogout, Steam platform auth in account creation. Not configurable to ensure server uses ticket to validate.
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using BestHTTP;
|
||||
using BestHTTP.Forms;
|
||||
using HarmonyLib;
|
||||
using undead_universal_patch_il2cpp.Core;
|
||||
using undead_universal_patch_il2cpp.Core.Config;
|
||||
using UnityEngine;
|
||||
|
||||
namespace undead_universal_patch_il2cpp.Patches
|
||||
{
|
||||
@@ -22,6 +25,8 @@ namespace undead_universal_patch_il2cpp.Patches
|
||||
|
||||
static readonly MethodInfo getHeaderMethod = requestType?.GetMethod("GetFirstHeaderValue");
|
||||
static readonly MethodInfo addHeaderMethod = requestType?.GetMethod("AddHeader");
|
||||
static readonly MethodInfo getFormFields = requestType?.GetMethod("GetFormFields");
|
||||
static readonly PropertyInfo formImplProp = requestType?.GetProperty("FormImpl");
|
||||
static readonly PropertyInfo methodTypeProp = requestType?.GetProperty("MethodType");
|
||||
static readonly PropertyInfo uriProp = requestType?.GetProperty("Uri");
|
||||
static readonly PropertyInfo customCertProp = requestType?.GetProperty("CustomCertificateVerifyer");
|
||||
@@ -30,13 +35,13 @@ namespace undead_universal_patch_il2cpp.Patches
|
||||
getHeaderMethod,
|
||||
addHeaderMethod,
|
||||
methodTypeProp,
|
||||
getFormFields,
|
||||
formImplProp,
|
||||
uriProp,
|
||||
customCertProp
|
||||
]).Success;
|
||||
|
||||
static MethodBase TargetMethod() => patchResult.Method;
|
||||
|
||||
[HarmonyPrefix]
|
||||
static void Prefix(ref object request)
|
||||
{
|
||||
if (PatchConfig.CertificatePatch.Value) customCertProp.GetSetMethod().Invoke(request, [null]);
|
||||
@@ -59,6 +64,16 @@ namespace undead_universal_patch_il2cpp.Patches
|
||||
|
||||
if (newUri.Host.Contains("ns.rec.net")) newUri = new Il2CppSystem.Uri(NameserverConfig.NewUrl.Value);
|
||||
|
||||
bool isAccCreate = newUri.PathAndQuery.Contains("account/create");
|
||||
if (isAccCreate && SteamPlatform.AuthTicket != null)
|
||||
{
|
||||
HTTPFormBase form = (HTTPFormBase)formImplProp.GetValue(request, null);
|
||||
|
||||
form.AddField("x-steam-ticket", SteamPlatform.AuthTicket);
|
||||
Util.ConditionalDebug("Added Steam ticket to create request");
|
||||
}
|
||||
else if (isAccCreate) UniversalPatchPlugin.Log.LogError("The Steam auth ticket has not yet been fetched, account creation might fail!");
|
||||
|
||||
// Finish request changes
|
||||
|
||||
string afterUrl = newUri.ToString();
|
||||
@@ -71,9 +86,8 @@ namespace undead_universal_patch_il2cpp.Patches
|
||||
$" URL After : {(beforeUrl == afterUrl ? "(unmodified)" : afterUrl)}\n" +
|
||||
$" Method : {method}\n" +
|
||||
$" Content-Type : {contentType ?? "(not set)"}");
|
||||
else UniversalPatchPlugin.Log.LogInfo("BestHTTPProxy Request Log\n" +
|
||||
$" Before : {beforeUrl}\n" +
|
||||
$" After : {afterUrl}");
|
||||
else UniversalPatchPlugin.Log.LogInfo("BestHTTPProxy Request\n" +
|
||||
$" {method} {afterUrl}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
30
Patches/Internals/OnLogout.cs
Normal file
30
Patches/Internals/OnLogout.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using HarmonyLib;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using undead_universal_patch_il2cpp.Core;
|
||||
using undead_universal_patch_il2cpp.Core.Content.CustomRecNet;
|
||||
|
||||
namespace undead_universal_patch_il2cpp.Patches.Internals;
|
||||
|
||||
[HarmonyPatch]
|
||||
public static class LogoutEvent
|
||||
{
|
||||
static PatchTypesResult typesResult = Util.PreparePatchTypes(
|
||||
"RecNet logout event patch",
|
||||
"RecNet.Login",
|
||||
"OnLogout"
|
||||
);
|
||||
|
||||
static MethodBase TargetMethod() => typesResult.Method;
|
||||
static bool Prepare() => typesResult.Success;
|
||||
|
||||
static void Postfix()
|
||||
{
|
||||
Util.ConditionalDebug("Running onLogout actions");
|
||||
foreach (var action in RecNetInteractions.onLogout) action();
|
||||
}
|
||||
}
|
||||
29
Patches/Internals/PlatformManager.cs
Normal file
29
Patches/Internals/PlatformManager.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using HarmonyLib;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using undead_universal_patch_il2cpp.Core;
|
||||
using undead_universal_patch_il2cpp.Core.Content.CustomRecNet;
|
||||
|
||||
namespace undead_universal_patch_il2cpp.Patches.Internals;
|
||||
|
||||
[HarmonyPatch]
|
||||
public class SteamPlatformManagerEvent
|
||||
{
|
||||
static PatchTypesResult typesResult = Util.PreparePatchTypes(
|
||||
"On SteamPlatformManager.Initialize",
|
||||
"SteamPlatformManager",
|
||||
"Initialize"
|
||||
);
|
||||
|
||||
static MethodBase TargetMethod() => typesResult.Method;
|
||||
static bool Prepare() => typesResult.Success;
|
||||
|
||||
static void Postfix()
|
||||
{
|
||||
UniversalPatchPlugin.Log.LogInfo("Running post-steam platform initialize actions");
|
||||
foreach (var action in RecNetInteractions.onPlatformInitialize) action();
|
||||
}
|
||||
}
|
||||
@@ -22,19 +22,13 @@ public class AuthenticationEventPatch
|
||||
|
||||
static MethodBase TargetMethod() => patchResult.Method;
|
||||
|
||||
private static bool RanPostActions { get; set; } = false;
|
||||
static void Postfix(ref string accessToken)
|
||||
{
|
||||
UniversalPatchPlugin.Log.LogInfo("Intercepted AccessToken");
|
||||
RecNetInteractions.AccessToken = accessToken;
|
||||
|
||||
if (!RanPostActions)
|
||||
{
|
||||
bool value = (bool)hasAccessTokenProperty.GetValue(patchResult.Type);
|
||||
if (value) UniversalPatchPlugin.Log.LogInfo("Running post-authentication actions");
|
||||
foreach (var action in RecNetInteractions.postAuthenticationActions)
|
||||
action();
|
||||
}
|
||||
else RanPostActions = true;
|
||||
UniversalPatchPlugin.Log.LogInfo("Running post-authentication actions");
|
||||
foreach (var action in RecNetInteractions.postAuthenticationActions)
|
||||
action();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user