wip auth for license minecraft support and removing unnecesary nugets

This commit is contained in:
Max Chaev 2025-02-23 18:58:27 +03:00
parent e4145eefe8
commit b781806fab
4 changed files with 40 additions and 10 deletions

View File

@ -8,16 +8,17 @@
<PublishSingleFile>true</PublishSingleFile> <PublishSingleFile>true</PublishSingleFile>
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile> <EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
<IsAotCompatible>false</IsAotCompatible> <PublishTrimmed>false</PublishTrimmed>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="CmlLib.Core" Version="4.0.4" /> <PackageReference Include="CmlLib.Core" Version="4.0.4" />
<PackageReference Include="SharpCompress" Version="0.39.0" /> <PackageReference Include="CmlLib.Core.Auth.Microsoft" Version="3.2.2" />
<PackageReference Include="XboxAuthNet.Game.Msal" Version="0.1.2" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -4,7 +4,9 @@ using System.Runtime.InteropServices;
using System.Security.AccessControl; using System.Security.AccessControl;
using CmlLib.Core; using CmlLib.Core;
using CmlLib.Core.Auth; using CmlLib.Core.Auth;
using CmlLib.Core.Auth.Microsoft;
using CmlLib.Core.ProcessBuilder; using CmlLib.Core.ProcessBuilder;
using XboxAuthNet.Game.Msal;
namespace Plombir; namespace Plombir;

View File

@ -2,8 +2,12 @@ namespace Plombir;
sealed class Program sealed class Program
{ {
public static void Main() public static async Task Main()
{ {
Console.WriteLine("init: launcher"); Console.WriteLine("init: launcher");
// var ln = new Launcher("test", "1.20.1");
// var s = await Utils.GetLicensedSession();
// Console.WriteLine(s.CheckIsValid());
} }
} }

View File

@ -1,11 +1,9 @@
using System.IO.Compression;
using System; using System;
using System.IO; using System.IO;
using SharpCompress.Archives;
using SharpCompress.Common;
using SharpCompress.Readers;
using System.Diagnostics;
using CmlLib.Core; using CmlLib.Core;
using CmlLib.Core.Auth;
using XboxAuthNet.Game.Msal;
using CmlLib.Core.Auth.Microsoft;
namespace Plombir; namespace Plombir;
@ -27,6 +25,31 @@ static public class Utils
} }
/*
Method is working, but we need to wait for client-id approval.
*/
public static async Task<MSession>? GetLicensedSession()
{
try
{
var app = await MsalClientHelper.BuildApplicationWithCache(
"d87c436c-aad0-46ea-b392-b53b3ed787b1"
);
var loginHandler = JELoginHandlerBuilder.BuildDefault();
var authenticator = loginHandler.CreateAuthenticatorWithNewAccount(default);
authenticator.AddMsalOAuth(app, msal => msal.DeviceCode(deviceCode =>
{
Console.WriteLine(deviceCode.Message);
return Task.CompletedTask;
}));
authenticator.AddXboxAuthForJE(xbox => xbox.Basic());
authenticator.AddJEAuthenticator();
return await authenticator.ExecuteForLauncherAsync();
}
catch (Exception e)
{
throw new Exception($"Failed to authentificate! {e}");
}
}
} }