Initial version

This commit is contained in:
Sithis 2026-10-15 05:46:35 +02:00
commit e5b6226a85
68 changed files with 7338 additions and 0 deletions

View file

@ -0,0 +1,21 @@
using DataTransfer.Client.Shared;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
namespace DataTransfer.Client.Services;
/// <summary>Solves the server's proof-of-work bot check in web workers (<c>wwwroot/js/bot-check.js</c> of the server).</summary>
public sealed class BotCheckSolver(IJSRuntime js, NavigationManager navigation)
{
/// <returns>The solution, or <c>-1</c> if none was found.</returns>
public async Task<int> SolveAsync(BotCheckChallenge challenge)
{
ArgumentNullException.ThrowIfNull(challenge);
// An absolute URL, so the module resolves relative to the app's base URI under any path base.
await using var module = await js.InvokeAsync<IJSObjectReference>(
"import",
navigation.ToAbsoluteUri("js/bot-check.js").ToString());
return await module.InvokeAsync<int>("solve", challenge.Salt, challenge.Hash, challenge.MaxNumber);
}
}