Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update JsInteropService and refactor model namespace (#2159)
Leendert de Borst2376e41046ca
diff --git a/apps/server/AliasVault.Client/Services/JsInterop/JsInteropService.cs b/apps/server/AliasVault.Client/Services/JsInterop/JsInteropService.csindex ebcfa31dd..5c0c4f2ba 100644--- a/apps/server/AliasVault.Client/Services/JsInterop/JsInteropService.cs+++ b/apps/server/AliasVault.Client/Services/JsInterop/JsInteropService.cs@@ -371,7 +371,17 @@ public sealed class JsInteropService(IJSRuntime jsRuntime)return [];}- var base64Ciphertext = Convert.ToBase64String(cipherBytes);+ return await SymmetricDecryptBase64ToBytes(Convert.ToBase64String(cipherBytes), encryptionKey);+ }++ /// <summary>+ /// Symmetrically decrypts a base64 ciphertext (IV | ciphertext | tag) into raw bytes using the provided encryption key.+ /// </summary>+ /// <param name="base64Ciphertext">Cipher text to decrypt.</param>+ /// <param name="encryptionKey">Encryption key to use as base64.</param>+ /// <returns>Decrypted bytes.</returns>+ public async Task<byte[]> SymmetricDecryptBase64ToBytes(string base64Ciphertext, string encryptionKey)+ {return await jsRuntime.InvokeAsync<byte[]>("cryptoInterop.decryptBytes", base64Ciphertext, encryptionKey);}@@ -629,6 +639,21 @@ public sealed class JsInteropService(IJSRuntime jsRuntime)}}+ /// <summary>+ /// Gets the complete SQL schema of the current client data model, which a materialized vault is created from.+ /// </summary>+ /// <returns>The COMPLETE_SCHEMA_SQL script.</returns>+ public async Task<string> GetCompleteSchemaSqlAsync()+ {+ if (_vaultSqlInteropModule == null)+ {+ await InitializeAsync();+ }++ var vaultGenerator = await _vaultSqlInteropModule!.InvokeAsync<IJSObjectReference>(_VAULT_SQL_GENERATOR_FACTORY_FUNCTION);+ return await vaultGenerator.InvokeAsync<string>("getCompleteSchemaSql");+ }+/// <summary>/// Gets all available vault versions./// </summary>diff --git a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/CodecBucketLayoutEntry.cs b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/CodecBucketLayoutEntry.csnew file mode 100644index 000000000..b4ad56fa9--- /dev/null+++ b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/CodecBucketLayoutEntry.cs@@ -0,0 +1,24 @@+//-----------------------------------------------------------------------+// <copyright file="CodecBucketLayoutEntry.cs" company="aliasvault">+// Copyright (c) aliasvault. All rights reserved.+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------++namespace AliasVault.Client.Services.JsInterop.RustCore.Models;++/// <summary>+/// One entry in the bucket layout: a category and the tables it owns.+/// </summary>+public class CodecBucketLayoutEntry+{+ /// <summary>+ /// Gets or sets the bucket category (matches the server enum name, e.g. "Settings").+ /// </summary>+ public string Category { get; set; } = string.Empty;++ /// <summary>+ /// Gets or sets the tables the category owns.+ /// </summary>+ public List<string> Tables { get; set; } = [];+}diff --git a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/CodecValidation.cs b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/CodecValidation.csnew file mode 100644index 000000000..04c8368b8--- /dev/null+++ b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/CodecValidation.cs@@ -0,0 +1,29 @@+//-----------------------------------------------------------------------+// <copyright file="CodecValidation.cs" company="aliasvault">+// Copyright (c) aliasvault. All rights reserved.+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------++namespace AliasVault.Client.Services.JsInterop.RustCore.Models;++/// <summary>+/// Structural validation outcome of a manifest or data bucket.+/// </summary>+public class CodecValidation+{+ /// <summary>+ /// Gets or sets a value indicating whether the payload is valid.+ /// </summary>+ public bool Ok { get; set; }++ /// <summary>+ /// Gets or sets the stable ids of the rules that failed.+ /// </summary>+ public List<string> FailedRules { get; set; } = [];++ /// <summary>+ /// Gets or sets the human-readable failure description.+ /// </summary>+ public string Message { get; set; } = string.Empty;+}diff --git a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/MergeInput.cs b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/MergeInput.cssimilarity index 93%rename from apps/server/AliasVault.Client/Services/JsInterop/RustCore/MergeInput.csrename to apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/MergeInput.csindex 55c869b9e..6826777fe 100644--- a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/MergeInput.cs+++ b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/MergeInput.cs@@ -5,7 +5,7 @@// </copyright>//------------------------------------------------------------------------namespace AliasVault.Client.Services.JsInterop.RustCore;+namespace AliasVault.Client.Services.JsInterop.RustCore.Models;using System.Text.Json.Serialization;diff --git a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/MergeOutput.cs b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/MergeOutput.cssimilarity index 95%rename from apps/server/AliasVault.Client/Services/JsInterop/RustCore/MergeOutput.csrename to apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/MergeOutput.csindex cbdbf211d..af0da882a 100644--- a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/MergeOutput.cs+++ b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/MergeOutput.cs@@ -5,7 +5,7 @@// </copyright>//------------------------------------------------------------------------namespace AliasVault.Client.Services.JsInterop.RustCore;+namespace AliasVault.Client.Services.JsInterop.RustCore.Models;using System.Text.Json.Serialization;diff --git a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/MergeStats.cs b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/MergeStats.cssimilarity index 96%rename from apps/server/AliasVault.Client/Services/JsInterop/RustCore/MergeStats.csrename to apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/MergeStats.csindex 36cece9ea..c1245181c 100644--- a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/MergeStats.cs+++ b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/MergeStats.cs@@ -5,7 +5,7 @@// </copyright>//------------------------------------------------------------------------namespace AliasVault.Client.Services.JsInterop.RustCore;+namespace AliasVault.Client.Services.JsInterop.RustCore.Models;using System.Text.Json.Serialization;diff --git a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/PruneInput.cs b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/PruneInput.cssimilarity index 94%rename from apps/server/AliasVault.Client/Services/JsInterop/RustCore/PruneInput.csrename to apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/PruneInput.csindex a9ab66c97..57d6df7ad 100644--- a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/PruneInput.cs+++ b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/PruneInput.cs@@ -5,7 +5,7 @@// </copyright>//------------------------------------------------------------------------namespace AliasVault.Client.Services.JsInterop.RustCore;+namespace AliasVault.Client.Services.JsInterop.RustCore.Models;/// <summary>/// Input structure for vault prune operation.diff --git a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/PruneOutput.cs b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/PruneOutput.cssimilarity index 93%rename from apps/server/AliasVault.Client/Services/JsInterop/RustCore/PruneOutput.csrename to apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/PruneOutput.csindex e0f72ec11..da3417404 100644--- a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/PruneOutput.cs+++ b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/PruneOutput.cs@@ -5,7 +5,7 @@// </copyright>//------------------------------------------------------------------------namespace AliasVault.Client.Services.JsInterop.RustCore;+namespace AliasVault.Client.Services.JsInterop.RustCore.Models;/// <summary>/// Output structure from vault prune operation.diff --git a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/PruneTableQuery.cs b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/PruneTableQuery.cssimilarity index 93%rename from apps/server/AliasVault.Client/Services/JsInterop/RustCore/PruneTableQuery.csrename to apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/PruneTableQuery.csindex b22186c09..808c28e9b 100644--- a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/PruneTableQuery.cs+++ b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/PruneTableQuery.cs@@ -5,7 +5,7 @@// </copyright>//------------------------------------------------------------------------namespace AliasVault.Client.Services.JsInterop.RustCore;+namespace AliasVault.Client.Services.JsInterop.RustCore.Models;using System.Text.Json.Serialization;diff --git a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/SqlStatement.cs b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/SqlStatement.cssimilarity index 93%rename from apps/server/AliasVault.Client/Services/JsInterop/RustCore/SqlStatement.csrename to apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/SqlStatement.csindex bf21390a8..fe278f79e 100644--- a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/SqlStatement.cs+++ b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/SqlStatement.cs@@ -5,7 +5,7 @@// </copyright>//------------------------------------------------------------------------namespace AliasVault.Client.Services.JsInterop.RustCore;+namespace AliasVault.Client.Services.JsInterop.RustCore.Models;using System.Text.Json.Serialization;diff --git a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/SrpEphemeral.cs b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/SrpEphemeral.cssimilarity index 92%rename from apps/server/AliasVault.Client/Services/JsInterop/RustCore/SrpEphemeral.csrename to apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/SrpEphemeral.csindex 99e801e80..1424c3b29 100644--- a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/SrpEphemeral.cs+++ b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/SrpEphemeral.cs@@ -5,7 +5,7 @@// </copyright>//------------------------------------------------------------------------namespace AliasVault.Client.Services.JsInterop.RustCore;+namespace AliasVault.Client.Services.JsInterop.RustCore.Models;/// <summary>/// SRP Ephemeral keypair with public and secret components.diff --git a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/SrpSession.cs b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/SrpSession.cssimilarity index 92%rename from apps/server/AliasVault.Client/Services/JsInterop/RustCore/SrpSession.csrename to apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/SrpSession.csindex 63db99e9a..b46feebd3 100644--- a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/SrpSession.cs+++ b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/SrpSession.cs@@ -5,7 +5,7 @@// </copyright>//------------------------------------------------------------------------namespace AliasVault.Client.Services.JsInterop.RustCore;+namespace AliasVault.Client.Services.JsInterop.RustCore.Models;/// <summary>/// SRP Session with key and proof.diff --git a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/TableData.cs b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/TableData.cssimilarity index 93%rename from apps/server/AliasVault.Client/Services/JsInterop/RustCore/TableData.csrename to apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/TableData.csindex a2916d556..613fa0219 100644--- a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/TableData.cs+++ b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/TableData.cs@@ -5,7 +5,7 @@// </copyright>//------------------------------------------------------------------------namespace AliasVault.Client.Services.JsInterop.RustCore;+namespace AliasVault.Client.Services.JsInterop.RustCore.Models;using System.Text.Json.Serialization;diff --git a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/RustCoreService.cs b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/RustCoreService.csindex d096da897..11cc111f6 100644--- a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/RustCoreService.cs+++ b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/RustCoreService.cs@@ -11,6 +11,7 @@ using System.Security.Cryptography;using System.Text.Json;using System.Text.Json.Nodes;using AliasVault.Client.Main.Models;+using AliasVault.Client.Services.JsInterop.RustCore.Models;using Microsoft.JSInterop;/// <summary>@@ -25,6 +26,15 @@ public class RustCoreService : IAsyncDisposableWriteIndented = false,};+ /// <summary>+ /// The vault codec and sharing DTOs are camelCase, unlike the older merge/prune DTOs. TODO: make all calls use consistent casing in future refactor.+ /// </summary>+ private static readonly JsonSerializerOptions CodecJsonOptions = new()+ {+ PropertyNamingPolicy = JsonNamingPolicy.CamelCase,+ PropertyNameCaseInsensitive = true,+ };+private readonly IJSRuntime jsRuntime;private bool? isAvailable;@@ -448,12 +458,184 @@ public class RustCoreService : IAsyncDisposable}}+ /// <summary>+ /// Canonicalize normalized vault tables into manifests, data buckets and blob maps.+ /// </summary>+ /// <param name="inputJson">The CanonicalizeInput JSON.</param>+ /// <returns>The CanonicalizedVault JSON.</returns>+ public Task<string> VaultCodecCanonicalizeFromSqliteAsync(string inputJson) => InvokeCoreAsync<string>("rustCoreVaultCodecCanonicalizeFromSqlite", inputJson);++ /// <summary>+ /// Materialize manifests and data buckets into the table set to insert into a fresh SQLite database.+ /// </summary>+ /// <param name="inputJson">The MaterializeInput JSON (manifests, dataBuckets, schemaColumns).</param>+ /// <returns>The MaterializedTables JSON (tables, overflow).</returns>+ public Task<string> VaultCodecMaterializeAsSqliteAsync(string inputJson) => InvokeCoreAsync<string>("rustCoreVaultCodecMaterializeAsSqlite", inputJson);++ /// <summary>+ /// Merge the local canonical vault onto the server canonical vault (the base), one manifest at a time.+ /// </summary>+ /// <param name="inputJson">The canonical merge input JSON.</param>+ /// <returns>The canonical merge output JSON.</returns>+ public Task<string> MergeCanonicalAsync(string inputJson) => InvokeCoreAsync<string>("rustCoreMergeCanonical", inputJson);++ /// <summary>+ /// Extract the encryption-key row whose PublicKey matches from a decrypted manifest.+ /// </summary>+ /// <param name="manifestJson">The decrypted manifest JSON.</param>+ /// <param name="publicKey">The public key to look up.</param>+ /// <returns>The key row JSON, or null when the manifest holds no such key.</returns>+ public Task<string?> VaultCodecExtractEncryptionKeyForPublicKeyAsync(string manifestJson, string publicKey) => InvokeCoreAsync<string?>("rustCoreVaultCodecExtractEncryptionKeyForPublicKey", manifestJson, publicKey);++ /// <summary>+ /// Build a bucket category's data buckets from its tables, one per manifest.+ /// </summary>+ /// <param name="inputJson">JSON with category, manifestIds and tables.</param>+ /// <returns>The data bucket list JSON.</returns>+ public Task<string> VaultCodecExtractBucketsAsync(string inputJson) => InvokeCoreAsync<string>("rustCoreVaultCodecExtractBuckets", inputJson);++ /// <summary>+ /// The name of the client-local table that carries the codec overflow inside the vault database.+ /// </summary>+ /// <returns>The table name.</returns>+ public Task<string> VaultCodecOverflowTableAsync() => InvokeCoreAsync<string>("rustCoreVaultCodecOverflowTable");++ /// <summary>+ /// The bucket layout: every category and the tables it owns.+ /// </summary>+ /// <returns>The layout entries.</returns>+ public async Task<List<CodecBucketLayoutEntry>> VaultCodecBucketLayoutAsync()+ {+ var json = await InvokeCoreAsync<string>("rustCoreVaultCodecBucketLayout");+ return JsonSerializer.Deserialize<List<CodecBucketLayoutEntry>>(json, CodecJsonOptions) ?? [];+ }++ /// <summary>+ /// The Logos.Id to use for the logo (kind, source) inside the given manifest.+ /// </summary>+ /// <param name="manifestId">Owning manifest id.</param>+ /// <param name="kind">Logo kind (favicon, builtin, custom).</param>+ /// <param name="source">Logo source (domain, icon key or content hash).</param>+ /// <returns>The logo id.</returns>+ public Task<string> VaultCodecLogoIdForAsync(string manifestId, string kind, string source) => InvokeCoreAsync<string>("rustCoreVaultCodecLogoIdFor", manifestId, kind, source);++ /// <summary>+ /// The SHA-256 (lowercase hex) of an uploaded logo's bytes, the Source a custom logo row is stored under.+ /// </summary>+ /// <param name="bytes">The image bytes.</param>+ /// <returns>The content hash.</returns>+ public Task<string> VaultCodecLogoContentHashAsync(byte[] bytes) => InvokeCoreAsync<string>("rustCoreVaultCodecLogoContentHash", bytes);++ /// <summary>+ /// Generate a fresh 32-byte per-manifest blob-hashing salt (lowercase hex).+ /// </summary>+ /// <returns>The salt.</returns>+ public Task<string> VaultCodecGenerateManifestSaltAsync() => InvokeCoreAsync<string>("rustCoreVaultCodecGenerateManifestSalt");++ /// <summary>+ /// Pack a payload JSON string into gzip(envelope{contentHash, payload}). The caller encrypts the result.+ /// </summary>+ /// <param name="payloadJson">The manifest or data bucket JSON.</param>+ /// <returns>The packed bytes.</returns>+ public Task<byte[]> VaultCodecPackPayloadAsync(string payloadJson) => InvokeCoreAsync<byte[]>("rustCoreVaultCodecPackPayload", payloadJson);++ /// <summary>+ /// Unpack a decrypted payload: gunzip, verify the embedded content hash, return the payload JSON.+ /// </summary>+ /// <param name="plainBytes">The decrypted packed bytes.</param>+ /// <returns>The payload JSON.</returns>+ public Task<string> VaultCodecUnpackPayloadAsync(byte[] plainBytes) => InvokeCoreAsync<string>("rustCoreVaultCodecUnpackPayload", plainBytes);++ /// <summary>+ /// Decrypt a manifest or data bucket ciphertext and unpack it via the codec in one interop call.+ /// </summary>+ /// <param name="base64Ciphertext">The ciphertext as served by the server.</param>+ /// <param name="base64Key">The symmetric key.</param>+ /// <returns>The payload JSON.</returns>+ public Task<string> VaultCodecDecryptAndUnpackPayloadAsync(string base64Ciphertext, string base64Key) => InvokeCoreAsync<string>("rustCoreVaultCodecDecryptAndUnpackPayload", base64Ciphertext, base64Key);++ /// <summary>+ /// Pack a manifest or data bucket payload via the codec and encrypt it in one interop call.+ /// </summary>+ /// <param name="payloadJson">The payload JSON.</param>+ /// <param name="base64Key">The symmetric key.</param>+ /// <returns>The base64 ciphertext.</returns>+ public Task<string> VaultCodecPackAndEncryptPayloadAsync(string payloadJson, string base64Key) => InvokeCoreAsync<string>("rustCoreVaultCodecPackAndEncryptPayload", payloadJson, base64Key);++ /// <summary>+ /// Structurally validate a manifest before upload.+ /// </summary>+ /// <param name="manifestJson">The manifest JSON.</param>+ /// <returns>The validation outcome.</returns>+ public async Task<CodecValidation> VaultCodecValidateManifestAsync(string manifestJson)+ {+ var json = await InvokeCoreAsync<string>("rustCoreVaultCodecValidateManifest", manifestJson);+ return JsonSerializer.Deserialize<CodecValidation>(json, CodecJsonOptions) ?? throw new InvalidOperationException("Failed to deserialize manifest validation result.");+ }++ /// <summary>+ /// Validate a data bucket before upload.+ /// </summary>+ /// <param name="bucketJson">The data bucket JSON.</param>+ /// <returns>The validation outcome.</returns>+ public async Task<CodecValidation> VaultCodecValidateDataBucketAsync(string bucketJson)+ {+ var json = await InvokeCoreAsync<string>("rustCoreVaultCodecValidateDataBucket", bucketJson);+ return JsonSerializer.Deserialize<CodecValidation>(json, CodecJsonOptions) ?? throw new InvalidOperationException("Failed to deserialize data bucket validation result.");+ }++ /// <summary>+ /// SHA-256 (lowercase hex) of a base64 ciphertext string.+ /// </summary>+ /// <param name="base64Ciphertext">The ciphertext.</param>+ /// <returns>The hash.</returns>+ public Task<string> VaultCodecComputeCiphertextHashAsync(string base64Ciphertext) => InvokeCoreAsync<string>("rustCoreVaultCodecComputeCiphertextHash", base64Ciphertext);++ /// <summary>+ /// Content fingerprint of a manifest or data bucket payload for change detection (canonical JSON minus canonicalizedAt).+ /// </summary>+ /// <param name="payloadJson">The payload JSON.</param>+ /// <returns>The fingerprint.</returns>+ public Task<string> VaultCodecComputeContentFingerprintAsync(string payloadJson) => InvokeCoreAsync<string>("rustCoreVaultCodecComputeContentFingerprint", payloadJson);++ /// <summary>+ /// Determine which manifests the next push writes, personal manifest first.+ /// </summary>+ /// <param name="inputJson">The write-set request JSON.</param>+ /// <returns>The write set JSON (records, skipped).</returns>+ public Task<string> VaultSharingResolveManifestWriteSetAsync(string inputJson) => InvokeCoreAsync<string>("rustCoreVaultSharingResolveManifestWriteSet", inputJson);++ /// <summary>+ /// Split what the local vault holds by what this account can still open.+ /// </summary>+ /// <param name="inputJson">The access partition request JSON.</param>+ /// <returns>The partition JSON (unwritable, lost).</returns>+ public Task<string> VaultSharingPartitionManifestAccessAsync(string inputJson) => InvokeCoreAsync<string>("rustCoreVaultSharingPartitionManifestAccess", inputJson);+/// <inheritdoc/>public ValueTask DisposeAsync(){return ValueTask.CompletedTask;}+ /// <summary>+ /// Invoke a Rust core interop function once the WASM module is available. Errors propagate as JS exceptions.+ /// </summary>+ /// <typeparam name="T">The return type.</typeparam>+ /// <param name="function">The window-level interop function name.</param>+ /// <param name="args">The arguments.</param>+ /// <returns>The function result.</returns>+ /// <exception cref="InvalidOperationException">Thrown if the WASM module is unavailable.</exception>+ private async Task<T> InvokeCoreAsync<T>(string function, params object?[] args)+ {+ if (!await WaitForAvailabilityAsync())+ {+ throw new InvalidOperationException("Rust WASM module is not available.");+ }++ return await jsRuntime.InvokeAsync<T>(function, args);+ }+/// <summary>/// Wait for the Rust WASM module to become available with retries./// Uses exponential backoff for more robust loading in slow environments (e.g., E2E tests, mobile devices).