Integrate AzuresPackager for renderer asset packaging

Added AzuresPackager as a dependency and MSBuild target to package wwwroot assets into root.dat with XOR encryption before build/run. Updated Program.cs to load UI assets from the packed root.dat using a custom scheme handler, replacing direct file access. This improves asset protection and streamlines deployment.
This commit is contained in:
Gilles Lazures 2026-01-27 03:22:04 +01:00
parent a5a53803bf
commit 79987fda6d
2 changed files with 38 additions and 7 deletions

View File

@ -8,6 +8,16 @@
<AssemblyName>LentiaLauncher</AssemblyName>
<ApplicationIcon>./src/resources/icon.ico</ApplicationIcon>
</PropertyGroup>
<Target Name="PackRenderer" BeforeTargets="BeforeBuild;BeforeRun">
<PropertyGroup>
<RendererSrc>$(ProjectDir)wwwroot</RendererSrc>
<RendererOut>$(OutputPath)root.dat</RendererOut>
<XorKey>66</XorKey>
</PropertyGroup>
<Message Importance="high" Text="[Lentia] Packaging renderer..." />
<Exec Command="dotnet run --project ../AzuresPackager/AzuresPackager.csproj --action pack --input &quot;$(RendererSrc)&quot; --output &quot;$(RendererOut)&quot; --key $(XorKey)" />
<Message Importance="high" Text="[Lentia] Renderer packed in : $(RendererOut)" />
</Target>
<ItemGroup>
<Compile Remove="wwwroot\**" />
<None Update="wwwroot\**">
@ -15,6 +25,7 @@
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="AzuresPackager" Version="0.0.2" />
<PackageReference Include="Photino.NET" Version="4.0.16" />
<PackageReference Include="System.Management" Version="10.0.2" />
</ItemGroup>

View File

@ -1,14 +1,19 @@
using Lentia.Core.Auth.OAuth2;
using AzuresPackager;
using Lentia.Core.Auth.OAuth2;
using Lentia.Core.Constants;
using Lentia.Core.Game;
using Lentia.Utils;
using Photino.NET;
using System.Reflection;
using System.Text;
using System.Text.Json;
using LentRules = Lentia.Core.Auth.Yggdrasil;
namespace Lentia;
class Program {
private static readonly string __dirname = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!;
private static LentRules.AuthenticateResponse? _authenticatedPlayer;
private static readonly string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
private static readonly string gameRoot = Path.Combine(appData, ".lentia2");
@ -21,18 +26,33 @@ class Program {
}
public static PhotinoWindow CreateLoginWindow() {
AzuresPackage azp = new AzuresPackage(Path.Combine(__dirname, "root.dat"), 66);
List<string> entries = azp.ListEntries();
var window = new PhotinoWindow()
.SetUseOsDefaultLocation(false)
.SetUseOsDefaultSize(false)
.SetContextMenuEnabled(false)
.SetChromeless(true);
.SetChromeless(true)
.RegisterCustomSchemeHandler("http", (object sender, string scheme, string url, out string contentType) =>{
Uri uri = new Uri(url);
if (uri.Host == "internal") {
string internalPath = uri.AbsolutePath;
contentType = MimeHelper.GetMimeType(uri.AbsolutePath);
byte[] fileData = azp.GetFileBytes(internalPath.TrimStart('/'));
return fileData != null ? new MemoryStream(fileData) : null;
}
contentType = null;
return null;
});
window.WindowCreated += (sender, e) => {
SetupBridge(window);
WindowHelper.MakeLoginWindow(window);
};
SetupBridge(window);
window.Load("wwwroot/login.html");
window.Load("http://internal/login.html");
return window;
}
@ -71,7 +91,7 @@ class Program {
if (lentiaAuthResult.Success) {
_authenticatedPlayer = lentiaAuthResult.Player;
WindowHelper.MakeStandardWindow(pw, 1356, 720, "wwwroot/logged.html");
WindowHelper.MakeStandardWindow(pw, 1356, 720, "http://internal/logged.html");
payload = new { success = true };
} else {
payload = new { success = false, error = lentiaAuthResult.Error };
@ -80,7 +100,7 @@ class Program {
case "auth::logout":
_authenticatedPlayer = null;
pw.Load("wwwroot/login.html");
pw.Load("http://internal/login.html");
WindowHelper.MakeLoginWindow(pw);
payload = true;
break;
@ -201,7 +221,7 @@ class Program {
if (discordLoginResult.Success) {
_authenticatedPlayer = discordLoginResult.Player;
WindowHelper.MakeStandardWindow(pw, 1356, 720, "wwwroot/logged.html");
WindowHelper.MakeStandardWindow(pw, 1356, 720, "http://internal/logged.html");
payload = new { success = true };
} else {
Console.WriteLine(discordLoginResult);