major refactor: auth v3

This commit is contained in:
Matthew Toro 2026-04-06 02:33:39 -04:00
parent 8a8b4b2573
commit 179d21d7b6
18 changed files with 376 additions and 166 deletions

View file

@ -56,7 +56,6 @@
#include "DLCTexturePack.h"
#include "..\Minecraft.World\HandshakeManager.h"
#include "..\Minecraft.World\SessionAuthModule.h"
#include "..\Minecraft.World\OfflineAuthModule.h"
#include "AuthScreen.h"
#ifdef _WINDOWS64
@ -4141,21 +4140,33 @@ ClientConnection::DeferredEntityLinkPacket::DeferredEntityLinkPacket(shared_ptr<
void ClientConnection::beginAuth()
{
app.DebugPrintf("AUTH: beginAuth() starting\n");
handshakeManager = new HandshakeManager(false);
handshakeManager->registerModule(std::make_unique<SessionAuthModule>());
handshakeManager->registerModule(std::make_unique<KeypairOfflineAuthModule>());
handshakeManager->registerModule(std::make_unique<OfflineAuthModule>());
const auto &profiles = AuthProfileManager::getProfiles();
int idx = AuthProfileManager::getSelectedIndex();
bool isOffline = true;
if (idx >= 0 && idx < static_cast<int>(profiles.size()))
{
const auto &p = profiles[idx];
isOffline = (p.type == AuthProfile::OFFLINE);
wstring variation;
if (p.type == AuthProfile::MICROSOFT) variation = L"mojang";
else if (p.type == AuthProfile::ELYBY) variation = L"elyby";
else if (p.type == AuthProfile::YGGDRASIL) variation = p.variation;
app.DebugPrintf("AUTH: profile type=%d variation=%ls username=%ls\n",
(int)p.type, variation.c_str(), p.username.c_str());
handshakeManager->setCredentials(p.token, p.uid, p.username, variation);
}
else
{
app.DebugPrintf("AUTH: no valid profile selected (idx=%d, count=%d)\n",
idx, (int)profiles.size());
}
if (!isOffline)
handshakeManager->registerModule(std::make_unique<SessionAuthModule>());
handshakeManager->registerModule(std::make_unique<KeypairOfflineAuthModule>());
handshakeManager->registerModule(std::make_unique<OfflineAuthModule>());
auto initial = handshakeManager->createInitialPacket();
if (initial) send(initial);