Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Remove legacy merge (#2159)

Leendert de Borstb2f904dbe7f4
diff --git a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/MergeInput.cs b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/MergeInput.cs
deleted file mode 100644
index 6826777fe..000000000
--- a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/MergeInput.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="MergeInput.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;
-
-using System.Text.Json.Serialization;
-
-/// <summary>
-/// Input for the vault merge operation.
-/// </summary>
-public class MergeInput
-{
- /// <summary>
- /// Gets or sets tables from the local database.
- /// </summary>
- [JsonPropertyName("local_tables")]
- public List<TableData> LocalTables { get; set; } = [];
-
- /// <summary>
- /// Gets or sets tables from the server database.
- /// </summary>
- [JsonPropertyName("server_tables")]
- public List<TableData> ServerTables { get; set; } = [];
-}
diff --git a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/MergeOutput.cs b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/MergeOutput.cs
deleted file mode 100644
index af0da882a..000000000
--- a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/MergeOutput.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="MergeOutput.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;
-
-using System.Text.Json.Serialization;
-
-/// <summary>
-/// Output of the merge operation.
-/// </summary>
-public class MergeOutput
-{
- /// <summary>
- /// Gets or sets a value indicating whether the merge was successful.
- /// </summary>
- [JsonPropertyName("success")]
- public bool Success { get; set; }
-
- /// <summary>
- /// Gets or sets SQL statements to execute on the local database (in order).
- /// </summary>
- [JsonPropertyName("statements")]
- public List<SqlStatement> Statements { get; set; } = [];
-
- /// <summary>
- /// Gets or sets overall statistics.
- /// </summary>
- [JsonPropertyName("stats")]
- public MergeStats Stats { get; set; } = new();
-
- /// <summary>
- /// Gets or sets error message if success is false.
- /// </summary>
- [JsonPropertyName("error")]
- public string? Error { get; set; }
-}
diff --git a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/MergeStats.cs b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/MergeStats.cs
deleted file mode 100644
index c1245181c..000000000
--- a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/Models/MergeStats.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="MergeStats.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;
-
-using System.Text.Json.Serialization;
-
-/// <summary>
-/// Statistics about what was merged.
-/// </summary>
-public class MergeStats
-{
- /// <summary>
- /// Gets or sets the number of tables processed.
- /// </summary>
- [JsonPropertyName("tablesProcessed")]
- public int TablesProcessed { get; set; }
-
- /// <summary>
- /// Gets or sets records where local version was kept.
- /// </summary>
- [JsonPropertyName("recordsFromLocal")]
- public int RecordsFromLocal { get; set; }
-
- /// <summary>
- /// Gets or sets records where server version was used (updates).
- /// </summary>
- [JsonPropertyName("recordsFromServer")]
- public int RecordsFromServer { get; set; }
-
- /// <summary>
- /// Gets or sets records that only existed locally (created offline).
- /// </summary>
- [JsonPropertyName("recordsCreatedLocally")]
- public int RecordsCreatedLocally { get; set; }
-
- /// <summary>
- /// Gets or sets number of conflicts resolved (both had the record).
- /// </summary>
- [JsonPropertyName("conflicts")]
- public int Conflicts { get; set; }
-
- /// <summary>
- /// Gets or sets records inserted from server (server-only records).
- /// </summary>
- [JsonPropertyName("recordsInserted")]
- public int RecordsInserted { get; set; }
-}
diff --git a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/RustCoreService.cs b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/RustCoreService.cs
index b430a7b15..dcf1c63e1 100644
--- a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/RustCoreService.cs
+++ b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/RustCoreService.cs
@@ -76,42 +76,6 @@ public class RustCoreService : IAsyncDisposable
}
}
- /// <summary>
- /// Merge two vaults using Last-Write-Wins (LWW) strategy.
- /// </summary>
- /// <param name="input">The merge input containing local and server tables.</param>
- /// <returns>The merge output with SQL statements to execute.</returns>
- /// <exception cref="InvalidOperationException">Thrown if merge fails or WASM module is unavailable.</exception>
- public async Task<MergeOutput> MergeVaultsAsync(MergeInput input)
- {
- // Wait for WASM to be available with retries, as it may still be loading.
- if (!await WaitForAvailabilityAsync())
- {
- throw new InvalidOperationException("Rust WASM module is not available.");
- }
-
- var inputJson = JsonSerializer.Serialize(input, JsonOptions);
- var resultJson = await jsRuntime.InvokeAsync<string>("rustCoreMergeVaults", inputJson);
-
- if (string.IsNullOrEmpty(resultJson))
- {
- throw new InvalidOperationException("Merge operation returned empty result.");
- }
-
- var result = JsonSerializer.Deserialize<MergeOutput>(resultJson, JsonOptions);
- if (result == null)
- {
- throw new InvalidOperationException("Failed to deserialize merge result.");
- }
-
- if (!result.Success && !string.IsNullOrEmpty(result.Error))
- {
- throw new InvalidOperationException($"Merge failed: {result.Error}");
- }
-
- return result;
- }
-
/// <summary>
/// Get the list of table names that need to be synced.
/// </summary>
diff --git a/apps/server/AliasVault.Client/wwwroot/js/rustCoreInterop.js b/apps/server/AliasVault.Client/wwwroot/js/rustCoreInterop.js
index 067dad9e8..686a2c045 100644
--- a/apps/server/AliasVault.Client/wwwroot/js/rustCoreInterop.js
+++ b/apps/server/AliasVault.Client/wwwroot/js/rustCoreInterop.js
@@ -93,35 +93,6 @@ window.rustCoreIsAvailable = async function() {
return await initRustCore();
};
-/**
- * Merge two vaults using LWW strategy.
- * @param {string} inputJson - JSON string containing MergeInput.
- * @returns {Promise<string>} JSON string containing MergeOutput.
- */
-window.rustCoreMergeVaults = async function(inputJson) {
- if (!await initRustCore()) {
- return JSON.stringify({
- success: false,
- error: 'Rust WASM module not available',
- statements: [],
- stats: {}
- });
- }
-
- try {
- const result = wasmModule.mergeVaultsJson(inputJson);
- return result;
- } catch (error) {
- console.error('[RustCore] Merge failed:', error);
- return JSON.stringify({
- success: false,
- error: error.toString(),
- statements: [],
- stats: {}
- });
- }
-};
-
/**
* Filter credentials for autofill.
* @param {string} inputJson - JSON string containing CredentialMatcherInput.