Skip to content

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

Add password protected export modal (#773)

Leendert de Borst34111eb95c3a
diff --git a/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ExportPasswordModal.razor b/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ExportPasswordModal.razor
new file mode 100644
index 000000000..8bae60105
--- /dev/null
+++ b/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ExportPasswordModal.razor
@@ -0,0 +1,142 @@
+@using Microsoft.Extensions.Localization
+@using AliasVault.RazorComponents.Services
+@using AliasVault.Client.Main.Components.Shared
+@inject IStringLocalizerFactory LocalizerFactory
+
+@if (IsOpen)
+{
+ <div class="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50">
+ <div class="bg-white dark:bg-gray-800 rounded-lg shadow-lg p-6 w-full max-w-md">
+ <h3 class="text-xl font-semibold text-gray-900 dark:text-white mb-4">@Title</h3>
+ <p class="text-sm text-gray-500 dark:text-gray-400 mb-4">@Description</p>
+
+ @if (!string.IsNullOrEmpty(ErrorMessage))
+ {
+ <div class="mb-4 p-3 bg-red-100 dark:bg-red-900 text-red-700 dark:text-red-200 rounded-lg text-sm">
+ @ErrorMessage
+ </div>
+ }
+
+ <div class="mb-4">
+ <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
+ @Localizer["ExportPasswordLabel"]
+ </label>
+ <input
+ type="password"
+ @bind="_exportPassword"
+ @bind:event="oninput"
+ @onkeydown="HandleKeyDown"
+ class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"
+ autofocus />
+
+ <PasswordStrengthIndicator Password="@_exportPassword" OnStrengthChanged="@HandleStrengthChanged" />
+ </div>
+
+ <div class="mb-4">
+ <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
+ @Localizer["ConfirmExportPasswordLabel"]
+ </label>
+ <input
+ type="password"
+ @bind="_confirmPassword"
+ @bind:event="oninput"
+ @onkeydown="HandleKeyDown"
+ class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"
+ />
+
+ @if (!string.IsNullOrEmpty(_confirmPassword) && _exportPassword != _confirmPassword)
+ {
+ <p class="mt-1 text-xs text-red-600 dark:text-red-400">@Localizer["PasswordsDoNotMatch"]</p>
+ }
+ </div>
+
+ <div class="flex justify-end space-x-3">
+ <button
+ type="button"
+ @onclick="OnClose"
+ class="px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-lg">
+ @SharedLocalizer["Cancel"]
+ </button>
+ <button
+ type="button"
+ @onclick="HandleSubmit"
+ disabled="@(!IsPasswordValid())"
+ class="px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 disabled:bg-gray-400 disabled:cursor-not-allowed rounded-lg">
+ @Localizer["CreateEncryptedExportButton"]
+ </button>
+ </div>
+ </div>
+ </div>
+}
+
+@code {
+ [Parameter]
+ public bool IsOpen { get; set; }
+
+ [Parameter]
+ public string Title { get; set; } = string.Empty;
+
+ [Parameter]
+ public string Description { get; set; } = string.Empty;
+
+ [Parameter]
+ public string ErrorMessage { get; set; } = string.Empty;
+
+ [Parameter]
+ public EventCallback<string> OnPasswordSubmitted { get; set; }
+
+ [Parameter]
+ public EventCallback OnClose { get; set; }
+
+ private string _exportPassword = string.Empty;
+ private string _confirmPassword = string.Empty;
+ private int _passwordStrength = 0;
+
+ private IStringLocalizer Localizer => LocalizerFactory.Create("Pages.Main.Settings.ImportExport.Components.ExportPasswordModal", "AliasVault.Client");
+ private IStringLocalizer SharedLocalizer => LocalizerFactory.Create("Shared", "AliasVault.Client");
+
+ protected override void OnParametersSet()
+ {
+ if (!IsOpen)
+ {
+ _exportPassword = string.Empty;
+ _confirmPassword = string.Empty;
+ _passwordStrength = 0;
+ }
+ }
+
+ private void HandleStrengthChanged(int strength)
+ {
+ _passwordStrength = strength;
+ }
+
+ private bool IsPasswordValid()
+ {
+ return !string.IsNullOrEmpty(_exportPassword) &&
+ !string.IsNullOrEmpty(_confirmPassword) &&
+ _exportPassword == _confirmPassword &&
+ _exportPassword.Length >= 8;
+ }
+
+ private async Task HandleSubmit()
+ {
+ if (IsPasswordValid())
+ {
+ await OnPasswordSubmitted.InvokeAsync(_exportPassword);
+ _exportPassword = string.Empty;
+ _confirmPassword = string.Empty;
+ }
+ }
+
+ private async Task HandleKeyDown(KeyboardEventArgs e)
+ {
+ if (e.Key == "Enter" && IsPasswordValid())
+ {
+ await HandleSubmit();
+ }
+ else if (e.Key == "Escape")
+ {
+ await OnClose.InvokeAsync();
+ }
+ }
+}
diff --git a/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceCard.razor b/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceCard.razor
index 8fd0c6b8f..b6deb003b 100644
--- a/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceCard.razor
+++ b/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceCard.razor
@@ -6,7 +6,9 @@
@inject GlobalNotificationService GlobalNotificationService
@inject HttpClient HttpClient
@inject IStringLocalizerFactory LocalizerFactory
+@inject AliasVault.Client.Services.Crypto.AvexCryptoService AvexCrypto
@using Microsoft.Extensions.Localization
+@using AliasVault.ImportExport
@using AliasVault.ImportExport.Importers
@using AliasVault.ImportExport.Models
@using AliasVault.ImportExport.Models.Exports
@@ -97,6 +99,53 @@
</div>
break;
+ case ImportStep.PasswordInput:
+ <div class="max-w-lg mx-auto">
+ @if (!string.IsNullOrEmpty(ImportError))
+ {
+ <div class="mb-4 p-4 text-red-700 bg-red-100 rounded-lg dark:bg-red-200 dark:text-red-800" role="alert">
+ @ImportError
+ </div>
+ }
+
+ @if (IsImporting)
+ {
+ <div class="text-center">
+ <LoadingIndicator />
+ <p class="mt-4 text-gray-700 dark:text-gray-300">@Localizer["DecryptingFile"]</p>
+ </div>
+ }
+ else
+ {
+ <div class="mb-4">
+ <p class="mb-4 text-gray-700 dark:text-gray-300">@Localizer["EncryptedFilePasswordPrompt"]</p>
+ <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
+ @Localizer["DecryptionPasswordLabel"]
+ </label>
+ <input
+ type="password"
+ @bind="_decryptionPassword"
+ @bind:event="oninput"
+ @onkeydown="HandlePasswordKeyDown"
+ class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"
+ placeholder="@Localizer["DecryptionPasswordPlaceholder"]"
+ autofocus />
+ </div>
+
+ <div class="mb-4 p-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg">
+ <p class="text-xs text-blue-800 dark:text-blue-200">
+ @Localizer["DecryptionPasswordHint"]
+ </p>
+ </div>
+
+ <div class="flex justify-end mt-6 space-x-2">
+ <Button OnClick="@HandlePreviousStep" Color="secondary">@Localizer["BackButton"]</Button>
+ <Button OnClick="@HandleDecryptFile" Color="primary" IsDisabled="@string.IsNullOrWhiteSpace(_decryptionPassword)">@Localizer["DecryptAndContinueButton"]</Button>
+ </div>
+ }
+ </div>
+ break;
+
case ImportStep.Preview:
<div class="mb-4">
@if (DuplicateCredentialsCount > 0)
@@ -232,6 +281,7 @@
private enum ImportStep
{
FileUpload,
+ PasswordInput,
Preview,
Confirm
}
@@ -260,6 +310,13 @@
[Parameter]
public EventCallback OnImportConfirmed { get; set; }
+ /// <summary>
+ /// The callback for processing text-based CSV files (accepts file contents as string).
+ /// Returns List of ImportedCredential.
+ /// </summary>
+ [Parameter]
+ public Func<string, Task<List<ImportedCredential>>>? ProcessFileCallback { get; set; }
+
/// <summary>
/// The callback for auto-detecting and processing files (accepts filename and bytes).
/// This callback should determine whether to process as text or binary based on the file extension.
@@ -312,11 +369,24 @@
private int TotalCredentialsToSave { get; set; }
private bool IsSyncingVault { get; set; }
private Dictionary<string, Guid> ImportSessionLogoIds { get; set; } = new();
- private Dictionary<Guid, (string Source, byte[] FileData)> AvuxLogos { get; set; } = new();
- private bool IsAvuxImport { get; set; } = false;
+ /// <summary>
+ /// Gets or sets the .avux logos for import. Public to allow external setting.
+ /// </summary>
+ public Dictionary<Guid, (string Source, byte[] FileData)> AvuxLogos { get; set; } = new();
+
+ /// <summary>
+ /// Gets or sets whether this is an .avux import. Public to allow external setting.
+ /// </summary>
+ public bool IsAvuxImport { get; set; } = false;
private int DuplicateCredentialsCount { get; set; } = 0;
+ // Fields for .avex encrypted file handling
+ private string _decryptionPassword = string.Empty;
+ private byte[]? _pendingAvexBytes;
+ private string? _pendingAvexFilename;
+ private bool _requiresPassword = false;
+
/// <summary>
/// Sets the imported credentials and continues to the preview step.
/// </summary>
@@ -329,6 +399,23 @@
await HandleNextStep();
}
+ /// <summary>
+ /// Sets pending encrypted file data and moves to password input step.
+ /// </summary>
+ /// <param name="encryptedBytes">The encrypted file bytes.</param>
+ /// <param name="filename">The filename.</param>
+ public void SetPendingEncryptedFile(byte[] encryptedBytes, string filename)
+ {
+ _pendingAvexBytes = encryptedBytes;
+ _pendingAvexFilename = filename;
+ _decryptionPassword = string.Empty;
+ _requiresPassword = true;
+ ImportError = null;
+ CurrentStep = ImportStep.PasswordInput;
+ IsImporting = false; // Stop the loading state
+ StateHasChanged();
+ }
+
/// <summary>
/// Called when a file is selected in the parent file upload step.
/// </summary>
@@ -358,6 +445,10 @@
ImportError = null;
ImportSuccessMessage = null;
ImportedCredentials.Clear();
+ _requiresPassword = false;
+ _decryptionPassword = string.Empty;
+ _pendingAvexBytes = null;
+ _pendingAvexFilename = null;
StateHasChanged();
}
@@ -381,9 +472,25 @@
/// </summary>
protected virtual void HandlePreviousStep()
{
- if (CurrentStep == ImportStep.Preview)
+ if (CurrentStep == ImportStep.PasswordInput)
{
CurrentStep = ImportStep.FileUpload;
+ _decryptionPassword = string.Empty;
+ _pendingAvexBytes = null;
+ _pendingAvexFilename = null;
+ _requiresPassword = false;
+ }
+ else if (CurrentStep == ImportStep.Preview)
+ {
+ // If we came from password input (encrypted file), go back to password
+ if (_pendingAvexBytes != null)
+ {
+ CurrentStep = ImportStep.PasswordInput;
+ }
+ else
+ {
+ CurrentStep = ImportStep.FileUpload;
+ }
}
else if (CurrentStep == ImportStep.Confirm)
{
@@ -391,6 +498,85 @@
}
}
+ /// <summary>
+ /// Handles password keyboard events (Enter to submit, Escape to cancel).
+ /// </summary>
+ private async Task HandlePasswordKeyDown(KeyboardEventArgs e)
+ {
+ if (e.Key == "Enter" && !string.IsNullOrWhiteSpace(_decryptionPassword))
+ {
+ await HandleDecryptFile();
+ }
+ else if (e.Key == "Escape")
+ {
+ HandlePreviousStep();
+ }
+ }
+
+ /// <summary>
+ /// Handles decrypting the .avex file with the provided password.
+ /// </summary>
+ private async Task HandleDecryptFile()
+ {
+ if (_pendingAvexBytes == null)
+ {
+ return;
+ }
+
+ try
+ {
+ IsImporting = true;
+ ImportError = null;
+ StateHasChanged();
+ await Task.Delay(50);
+
+ // Decrypt the file to .avux bytes using AvexCryptoService
+ var avuxBytes = await AvexCrypto.DecryptAvexAsync(_pendingAvexBytes, _decryptionPassword);
+
+ // Process via the normal file handler as if it was an .avux upload
+ // This ensures consistent handling and avoids EF tracking issues
+ var result = await ProcessFileWithAutoDetectionCallback!("decrypted.avux", avuxBytes);
+
+ if (result is AvuxImportResult avuxResult)
+ {
+ // Store logos
+ IsAvuxImport = true;
+ AvuxLogos = avuxResult.Logos;
+ ImportedCredentials = avuxResult.Credentials;
+ }
+ else
+ {
+ throw new InvalidOperationException("Unexpected result type from .avux processing");
+ }
+
+ // Clear password and encrypted data
+ _decryptionPassword = string.Empty;
+ _pendingAvexBytes = null;
+ _pendingAvexFilename = null;
+ _requiresPassword = false;
+
+ IsImporting = false;
+
+ // Move to preview step
+ await DetectAndRemoveDuplicates();
+ CurrentStep = ImportStep.Preview;
+ StateHasChanged();
+ }
+ catch (InvalidOperationException ex) when (ex.Message.Contains("password may be incorrect"))
+ {
+ IsImporting = false;
+ ImportError = Localizer["IncorrectPasswordError"];
+ StateHasChanged();
+ }
+ catch (Exception ex)
+ {
+ Logger.LogError(ex, "Error decrypting .avex file");
+ IsImporting = false;
+ ImportError = Localizer["DecryptionErrorGeneric"];
+ StateHasChanged();
+ }
+ }
+
/// <summary>
/// Handles the modal confirm.
/// </summary>
@@ -833,7 +1019,15 @@
await stream.CopyToAsync(memoryStream);
var fileBytes = memoryStream.ToArray();
- // Call auto-detection callback
+ // Check if this is an encrypted .avex file
+ if (e.File.Name.EndsWith(".avex", StringComparison.OrdinalIgnoreCase))
+ {
+ // Encrypted file - trigger password input step
+ SetPendingEncryptedFile(fileBytes, e.File.Name);
+ return; // Password step will handle the rest
+ }
+
+ // Call auto-detection callback for regular files
var processingTask = ProcessFileWithAutoDetectionCallback(e.File.Name, fileBytes);
var delayTask = Task.Delay(500);
await Task.WhenAll(processingTask, delayTask);
@@ -862,16 +1056,35 @@
return;
}
}
+ else if (ProcessFileCallback != null)
+ {
+ // Read file as text for text-based CSV processing
+ using var reader = new StreamReader(stream);
+ var fileContents = await reader.ReadToEndAsync();
+
+ // Call text-based callback
+ var processingTask = ProcessFileCallback(fileContents);
+ var delayTask = Task.Delay(500);
+ await Task.WhenAll(processingTask, delayTask);
+
+ ImportedCredentials = await processingTask;
+ IsAvuxImport = false;
+ }
else
{
ImportError = "No file processor configured";
return;
}
- // Detect and remove duplicates before showing the preview
- await DetectAndRemoveDuplicates();
-
- CurrentStep = ImportStep.Preview;
+ // If password is required, the callback will handle setting the step to PasswordInput
+ // So we only proceed to preview if no password is required
+ if (!_requiresPassword)
+ {
+ // Detect and remove duplicates before showing the preview
+ await DetectAndRemoveDuplicates();
+ CurrentStep = ImportStep.Preview;
+ }
+ // else: the step was already set to PasswordInput by SetPendingEncryptedFile()
}
catch (Exception ex)
{
@@ -880,7 +1093,11 @@
}
finally
{
- IsImporting = false;
+ // Only set IsImporting to false if we're not waiting for password
+ if (!_requiresPassword)
+ {
+ IsImporting = false;
+ }
StateHasChanged();
}
}
diff --git a/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/ImportExport.razor b/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/ImportExport.razor
index c2015800c..4e1c2878f 100644
--- a/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/ImportExport.razor
+++ b/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/ImportExport.razor
@@ -3,6 +3,7 @@
@inject ItemService ItemService
@inject ILogger<ImportExport> Logger
@inject ConfirmModalService ConfirmModalService
+@inject AliasVault.Client.Services.Crypto.AvexCryptoService AvexCrypto
@using Microsoft.Extensions.Localization
@using AliasVault.RazorComponents.Services
@using AliasVault.Client.Main.Pages.Settings.ImportExport.Components
@@ -27,6 +28,7 @@
@((MarkupString)Localizer["ImportSectionDescription"].Value)
</div>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
+ <ImportServiceAliasVault />
<ImportService1Password />
<ImportServiceBitwarden />
<ImportServiceChrome />
@@ -42,26 +44,52 @@
<ImportServiceProtonPass />
<ImportServiceRoboform />
<ImportServiceStrongbox />
- <ImportServiceAliasVault />
<ImportServiceGenericCsv />
</div>
</div>
<div class="p-4 mx-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800">
<h3 class="mb-4 text-xl font-semibold dark:text-white">@Localizer["ExportSectionTitle"]</h3>
- <div class="mb-4">
- <p class="text-sm text-gray-500 dark:text-gray-400 mb-4">
- @Localizer["ExportSectionDescription"]
- </p>
- <div>
- <Button OnClick="@(() => ShowExportConfirmation(ExportType.Csv))">@Localizer["ExportCsvButton"]</Button>
+ <p class="text-sm text-gray-500 dark:text-gray-400 mb-4">
+ @Localizer["ExportSectionDescription"]
+ </p>
+
+ <div class="space-y-3">
+ <!-- Encrypted Export (.avex) - Recommended -->
+ <div class="flex items-center justify-between p-3 border-2 border-orange-200 dark:border-orange-800 rounded-lg bg-orange-50 dark:bg-orange-900/20">
+ <div class="flex-1 min-w-0 mr-4">
+ <div class="flex items-center gap-2 mb-1">
+ <h4 class="text-sm font-semibold text-gray-900 dark:text-white">@Localizer["ExportAvexTitle"]</h4>
+ <span class="px-1.5 py-0.5 text-xs font-medium text-orange-700 dark:text-orange-300 bg-orange-100 dark:bg-orange-900 rounded">@Localizer["RecommendedLabel"]</span>
+ </div>
+ <p class="text-xs text-gray-600 dark:text-gray-300">
+ @Localizer["ExportAvexDescription"]
+ </p>
+ </div>
+ <Button OnClick="@(() => ShowExportEncryptedConfirmation())">@Localizer["ExportAvexButton"]</Button>
</div>
- <div class="mt-6">
- <Button OnClick="@(() => ShowExportConfirmation(ExportType.Sqlite))">@Localizer["ExportSqliteButton"]</Button>
- </div>
- <div class="mt-6">
+
+ <!-- Unencrypted Export (.avux) -->
+ <div class="flex items-center justify-between p-3 border border-gray-200 dark:border-gray-700 rounded-lg">
+ <div class="flex-1 min-w-0 mr-4">
+ <h4 class="text-sm font-semibold text-gray-900 dark:text-white mb-1">@Localizer["ExportAvuxTitle"]</h4>
+ <p class="text-xs text-gray-600 dark:text-gray-300">
+ @Localizer["ExportAvuxDescription"]
+ </p>
+ </div>
<Button OnClick="@(() => ShowExportConfirmation(ExportType.Avux))">@Localizer["ExportAvuxButton"]</Button>
</div>
+
+ <!-- CSV Export -->
+ <div class="flex items-center justify-between p-3 border border-gray-200 dark:border-gray-700 rounded-lg">
+ <div class="flex-1 min-w-0 mr-4">
+ <h4 class="text-sm font-semibold text-gray-900 dark:text-white mb-1">@Localizer["ExportCsvTitle"]</h4>
+ <p class="text-xs text-gray-600 dark:text-gray-300">
+ @Localizer["ExportCsvDescription"]
+ </p>
+ </div>
+ <Button OnClick="@(() => ShowExportConfirmation(ExportType.Csv))">@Localizer["ExportCsvButton"]</Button>
+ </div>
</div>
</div>
@@ -75,18 +103,28 @@
OnPasswordSubmitted="@HandlePasswordSubmitted"
OnClose="@ClosePasswordConfirmation" />
+<ExportPasswordModal
+ IsOpen="@_showExportPasswordModal"
+ Title="@Localizer["ExportEncryptedPasswordTitle"]"
+ Description="@Localizer["ExportEncryptedPasswordDescription"]"
+ ErrorMessage="@_exportPasswordError"
+ OnPasswordSubmitted="@HandleExportPasswordSubmitted"
+ OnClose="@CloseExportPasswordModal" />
+
@code {
private string _username = string.Empty;
private bool _showPasswordConfirmation;
private string _passwordError = string.Empty;
+ private bool _showExportPasswordModal;
+ private string _exportPasswordError = string.Empty;
private IStringLocalizer Localizer => LocalizerFactory.Create("Pages.Main.Settings.ImportExport.ImportExport", "AliasVault.Client");
private ExportType _currentExportType;
private enum ExportType
{
Csv,
- Sqlite,
- Avux
+ Avux,
+ Avex
}
/// <inheritdoc />
@@ -116,6 +154,23 @@
StateHasChanged();
}
+ private async Task ShowExportEncryptedConfirmation()
+ {
+ _currentExportType = ExportType.Avex;
+ var confirmMessage = Localizer["ExportEncryptedWarningMessage"];
+
+ var result = await ConfirmModalService.ShowConfirmation(Localizer["ExportConfirmTitle"], confirmMessage, SharedLocalizer["Confirm"], SharedLocalizer["Cancel"]);
+ if (!result)
+ {
+ return;
+ }
+
+ // For encrypted export, show export password modal directly (no master password verification needed)
+ _exportPasswordError = string.Empty;
+ _showExportPasswordModal = true;
+ StateHasChanged();
+ }
+
/// <summary>
/// Handles the password submission - verifies password and proceeds with export.
/// </summary>
@@ -175,6 +230,23 @@
StateHasChanged();
}
+ private async Task HandleExportPasswordSubmitted(string exportPassword)
+ {
+ // Close modal first
+ _showExportPasswordModal = false;
+ _exportPasswordError = string.Empty;
+ StateHasChanged();
+
+ await ExportVaultAvex(exportPassword);
+ }
+
+ private void CloseExportPasswordModal()
+ {
+ _showExportPasswordModal = false;
+ _exportPasswordError = string.Empty;
+ StateHasChanged();
+ }
+
private async Task HandleExportConfirmed()
{
switch (_currentExportType)
@@ -182,27 +254,27 @@
case ExportType.Csv:
await ExportVaultCsv();
break;
- case ExportType.Sqlite:
- await ExportVaultSqlite();
- break;
case ExportType.Avux:
await ExportVaultAvux();
break;
+ case ExportType.Avex:
+ break;
}
}
- private async Task ExportVaultSqlite()
+ private async Task ExportVaultCsv()
{
try
{
- // Decode the base64 string to a byte array.
- byte[] fileBytes = Convert.FromBase64String(await DbService.ExportSqliteToBase64Async());
+ var items = await ItemService.LoadAllAsync();
+
+ var csvBytes = ItemCsvService.ExportItemsToCsv(items);
// Create a memory stream from the byte array.
- using (MemoryStream memoryStream = new MemoryStream(fileBytes))
+ using (MemoryStream memoryStream = new MemoryStream(csvBytes))
{
- // Invoke JavaScript to initiate the download.
- await JsInteropService.DownloadFileFromStream($"{await GetExportFileName("sqlite")}", memoryStream.ToArray());
+ // Invoke JavaScript to initiate the download with date and username in filename
+ await JsInteropService.DownloadFileFromStream($"{await GetExportFileName("csv")}", memoryStream.ToArray());
}
}
catch (Exception ex)
@@ -211,90 +283,112 @@
}
}
- private async Task ExportVaultCsv()
+ private async Task ExportVaultAvux()
{
+ GlobalLoadingSpinner.Show(Localizer["ExportingVaultMessage"]);
try
{
- var items = await ItemService.LoadAllAsync();
-
- var csvBytes = ItemCsvService.ExportItemsToCsv(items);
+ var avuxBytes = await GenerateAvuxBytesAsync();
- // Create a memory stream from the byte array.
- using (MemoryStream memoryStream = new MemoryStream(csvBytes))
- {
- // Invoke JavaScript to initiate the download with date and username in filename
- await JsInteropService.DownloadFileFromStream($"{await GetExportFileName("csv")}", memoryStream.ToArray());
- }
+ await JsInteropService.DownloadFileFromStream(
+ $"{await GetExportFileName("avux")}",
+ avuxBytes);
}
catch (Exception ex)
{
- Logger.LogError(ex, "Error downloading file");
+ Logger.LogError(ex, "Error exporting vault to .avux format");
+ GlobalNotificationService.AddErrorMessage(
+ SharedLocalizer["ErrorGeneric"],
+ true);
+ }
+ finally
+ {
+ GlobalLoadingSpinner.Hide();
}
}
- private async Task ExportVaultAvux()
+ /// <summary>
+ /// Generates .avux bytes from the current vault data.
+ /// This is used by both .avux export (unencrypted) and .avex export (encrypted).
+ /// </summary>
+ private async Task<byte[]> GenerateAvuxBytesAsync()
+ {
+ var context = await DbService.GetDbContextAsync();
+
+ // Load all vault entities with their related data
+ var items = await context.Items
+ .Where(i => !i.IsDeleted && i.DeletedAt == null)
+ .Include(i => i.FieldValues)
+ .Include(i => i.Attachments)
+ .Include(i => i.TotpCodes)
+ .Include(i => i.Passkeys)
+ .ToListAsync();
+
+ var folders = await context.Folders
+ .Where(f => !f.IsDeleted)
+ .ToListAsync();
+
+ var tags = await context.Tags
+ .Where(t => !t.IsDeleted)
+ .ToListAsync();
+
+ var itemTags = await context.ItemTags
+ .Where(it => !it.IsDeleted)
+ .ToListAsync();
+
+ var fieldDefinitions = await context.FieldDefinitions
+ .Where(fd => !fd.IsDeleted)
+ .ToListAsync();
+
+ // Get unique logo IDs from items
+ var logoIds = items
+ .Where(i => i.LogoId.HasValue)
+ .Select(i => i.LogoId!.Value)
+ .Distinct()
+ .ToList();
+
+ // Load logos used by items
+ var logos = await context.Logos
+ .Where(l => !l.IsDeleted && logoIds.Contains(l.Id))
+ .ToListAsync();
+
+ var username = await GetUsernameAsync();
+
+ // Export to .avux format
+ return await VaultExportService.ExportToAvuxAsync(
+ items,
+ folders,
+ tags,
+ itemTags,
+ fieldDefinitions,
+ logos,
+ username);
+ }
+
+ private async Task ExportVaultAvex(string exportPassword)
{
GlobalLoadingSpinner.Show(Localizer["ExportingVaultMessage"]);
try
{
- var context = await DbService.GetDbContextAsync();
-
- // Load all vault entities with their related data
- var items = await context.Items
- .Where(i => !i.IsDeleted && i.DeletedAt == null)
- .Include(i => i.FieldValues)
- .Include(i => i.Attachments)
- .Include(i => i.TotpCodes)
- .Include(i => i.Passkeys)
- .ToListAsync();
-
- var folders = await context.Folders
- .Where(f => !f.IsDeleted)
- .ToListAsync();
-
- var tags = await context.Tags
- .Where(t => !t.IsDeleted)
- .ToListAsync();
-
- var itemTags = await context.ItemTags
- .Where(it => !it.IsDeleted)
- .ToListAsync();
-
- var fieldDefinitions = await context.FieldDefinitions
- .Where(fd => !fd.IsDeleted)
- .ToListAsync();
-
- // Get unique logo IDs from items
- var logoIds = items
- .Where(i => i.LogoId.HasValue)
- .Select(i => i.LogoId!.Value)
- .Distinct()
- .ToList();
-
- // Load logos used by items
- var logos = await context.Logos
- .Where(l => !l.IsDeleted && logoIds.Contains(l.Id))
- .ToListAsync();
+ var avuxBytes = await GenerateAvuxBytesAsync();
var username = await GetUsernameAsync();
-
- // Export to .avux format
- var zipBytes = await VaultExportService.ExportToAvuxAsync(
- items,
- folders,
- tags,
- itemTags,
- fieldDefinitions,
- logos,
+ var avexBytes = await AvexCrypto.EncryptToAvexAsync(
+ avuxBytes,
+ exportPassword,
username);
await JsInteropService.DownloadFileFromStream(
- $"{await GetExportFileName("avux")}",
- zipBytes);
+ $"{await GetExportFileName("avex")}",
+ avexBytes);
+
+ GlobalNotificationService.AddSuccessMessage(
+ Localizer["ExportEncryptedSuccessMessage"],
+ true);
}
catch (Exception ex)
{
- Logger.LogError(ex, "Error exporting vault to .avux format");
+ Logger.LogError(ex, "Error exporting vault to .avex format");
GlobalNotificationService.AddErrorMessage(
SharedLocalizer["ErrorGeneric"],
true);
diff --git a/apps/server/AliasVault.Client/Resources/Components/Main/Settings/ImportExport/ImportServiceCard.en.resx b/apps/server/AliasVault.Client/Resources/Components/Main/Settings/ImportExport/ImportServiceCard.en.resx
index 14a15ff8c..e75c6fcd6 100644
--- a/apps/server/AliasVault.Client/Resources/Components/Main/Settings/ImportExport/ImportServiceCard.en.resx
+++ b/apps/server/AliasVault.Client/Resources/Components/Main/Settings/ImportExport/ImportServiceCard.en.resx
@@ -170,4 +170,36 @@
<value>Supported formats:</value>
<comment>Label for the list of supported file formats in the import modal</comment>
</data>
+ <data name="EncryptedFilePasswordPrompt" xml:space="preserve">
+ <value>This file is encrypted. Please enter the password you used when creating the export.</value>
+ <comment>Prompt for encrypted file password</comment>
+ </data>
+ <data name="DecryptionPasswordLabel" xml:space="preserve">
+ <value>Decryption Password</value>
+ <comment>Label for decryption password input</comment>
+ </data>
+ <data name="DecryptionPasswordPlaceholder" xml:space="preserve">
+ <value>Enter the password used to encrypt this export</value>
+ <comment>Placeholder for decryption password input</comment>
+ </data>
+ <data name="DecryptionPasswordHint" xml:space="preserve">
+ <value>This is the password you set when creating the encrypted export (.avex file), not your vault master password.</value>
+ <comment>Hint explaining what password is needed</comment>
+ </data>
+ <data name="DecryptAndContinueButton" xml:space="preserve">
+ <value>Decrypt and Continue</value>
+ <comment>Button text for decryption</comment>
+ </data>
+ <data name="DecryptingFile" xml:space="preserve">
+ <value>Decrypting file...</value>
+ <comment>Progress text during decryption</comment>
+ </data>
+ <data name="IncorrectPasswordError" xml:space="preserve">
+ <value>Incorrect password. Please try again.</value>
+ <comment>Error message for incorrect decryption password</comment>
+ </data>
+ <data name="DecryptionErrorGeneric" xml:space="preserve">
+ <value>Failed to decrypt the file. Please check that the file is not corrupted and try again.</value>
+ <comment>Generic error message for decryption failure</comment>
+ </data>
</root>
\ No newline at end of file
diff --git a/apps/server/AliasVault.Client/Resources/Components/Main/Settings/ImportExport/ImportServices.en.resx b/apps/server/AliasVault.Client/Resources/Components/Main/Settings/ImportExport/ImportServices.en.resx
index ae81d1acd..c6347ea47 100644
--- a/apps/server/AliasVault.Client/Resources/Components/Main/Settings/ImportExport/ImportServices.en.resx
+++ b/apps/server/AliasVault.Client/Resources/Components/Main/Settings/ImportExport/ImportServices.en.resx
@@ -247,19 +247,43 @@
<value>Complete backup format (includes passkeys, attachments, custom fields, and all metadata)</value>
<comment>Description of what .avux format includes</comment>
</data>
- <!-- AliasVault CSV/AVUX -->
+ <!-- AliasVault CSV/AVUX/AVEX -->
<data name="AliasVaultDescription" xml:space="preserve">
- <value>Import from AliasVault backup (.csv or .avux)</value>
+ <value>Import from AliasVault backup (.csv, .avux, or .avex)</value>
<comment>Description for AliasVault import service</comment>
</data>
<data name="AliasVaultInstructionsPart1" xml:space="preserve">
- <value>Import your AliasVault backup from another server or a manual backup. Supports both CSV and .avux formats.</value>
+ <value>Import your AliasVault backup from another server or a manual backup.</value>
<comment>AliasVault import instructions</comment>
</data>
+ <data name="AliasVaultSupportedFormatsInfo" xml:space="preserve">
+ <value>Supports CSV (basic), .avux (complete unencrypted), and .avex (encrypted) formats.</value>
+ <comment>Supported formats information for AliasVault imports</comment>
+ </data>
<data name="CsvFormatDescription" xml:space="preserve">
<value>Basic backup format (passwords, usernames, notes, TOTP codes)</value>
<comment>Description of CSV format capabilities</comment>
</data>
+ <data name="AvexFormatDescription" xml:space="preserve">
+ <value>Encrypted complete backup (password-protected .avux)</value>
+ <comment>Description of .avex format capabilities</comment>
+ </data>
+ <data name="DecryptImportTitle" xml:space="preserve">
+ <value>Enter Decryption Password</value>
+ <comment>Title for import password modal</comment>
+ </data>
+ <data name="DecryptImportDescription" xml:space="preserve">
+ <value>This file is encrypted. Please enter the password you used when creating the export.</value>
+ <comment>Description for import password modal</comment>
+ </data>
+ <data name="IncorrectPasswordError" xml:space="preserve">
+ <value>Incorrect password. Please try again.</value>
+ <comment>Error message for incorrect decryption password</comment>
+ </data>
+ <data name="DecryptionErrorGeneric" xml:space="preserve">
+ <value>Failed to decrypt the file. Please check that the file is not corrupted and try again.</value>
+ <comment>Generic error message for decryption failure</comment>
+ </data>
<!-- Dropbox -->
<data name="DropboxDescription" xml:space="preserve">
<value>Import passwords from Dropbox Passwords</value>
diff --git a/apps/server/AliasVault.Client/Resources/Pages/Main/Settings/ImportExport/Components/ExportPasswordModal.en.resx b/apps/server/AliasVault.Client/Resources/Pages/Main/Settings/ImportExport/Components/ExportPasswordModal.en.resx
new file mode 100644
index 000000000..bfc4ae648
--- /dev/null
+++ b/apps/server/AliasVault.Client/Resources/Pages/Main/Settings/ImportExport/Components/ExportPasswordModal.en.resx
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <data name="ExportPasswordLabel" xml:space="preserve">
+ <value>Encryption Password</value>
+ <comment>Label for export password input field</comment>
+ </data>
+ <data name="ConfirmExportPasswordLabel" xml:space="preserve">
+ <value>Confirm Password</value>
+ <comment>Label for password confirmation field</comment>
+ </data>
+ <data name="PasswordsDoNotMatch" xml:space="preserve">
+ <value>Passwords do not match</value>
+ <comment>Error when passwords don't match</comment>
+ </data>
+ <data name="CreateEncryptedExportButton" xml:space="preserve">
+ <value>Create Encrypted Export</value>
+ <comment>Button text for creating encrypted export</comment>
+ </data>
+</root>
diff --git a/apps/server/AliasVault.Client/Resources/Pages/Main/Settings/ImportExport/ImportExport.en.resx b/apps/server/AliasVault.Client/Resources/Pages/Main/Settings/ImportExport/ImportExport.en.resx
index 697a79bf6..14d8141e8 100644
--- a/apps/server/AliasVault.Client/Resources/Pages/Main/Settings/ImportExport/ImportExport.en.resx
+++ b/apps/server/AliasVault.Client/Resources/Pages/Main/Settings/ImportExport/ImportExport.en.resx
@@ -71,7 +71,7 @@
<comment>Import section title</comment>
</data>
<data name="ImportSectionDescription" xml:space="preserve">
- <value>Select a service to import from. If you are using a service that is not listed here and would like to see it supported, please raise an issue on &lt;a href="https://github.com/aliasvault/aliasvault/issues" target="_blank" class="text-primary-500 hover:text-primary-700"&gt;GitHub&lt;/a&gt; or contact us.</value>
+ <value>Select a service to import from.</value>
<comment>Import section description with HTML link</comment>
</data>
<data name="ExportSectionTitle" xml:space="preserve">
@@ -79,19 +79,43 @@
<comment>Export section title</comment>
</data>
<data name="ExportSectionDescription" xml:space="preserve">
- <value>If you want to export your AliasVault credentials to another AliasVault server (e.g. from cloud to self-hosted or vice-versa) or to another service altogether, you can export it here. Note that all exports are unencrypted so store it in a safe place and delete it when you no longer need it.</value>
+ <value>Export your vault to move credentials between AliasVault servers or to another password manager.</value>
<comment>Export section description</comment>
</data>
+ <data name="RecommendedLabel" xml:space="preserve">
+ <value>Recommended</value>
+ <comment>Label for recommended option</comment>
+ </data>
+ <data name="ExportAvexTitle" xml:space="preserve">
+ <value>Encrypted full vault export</value>
+ <comment>Title for encrypted export option</comment>
+ </data>
+ <data name="ExportAvexDescription" xml:space="preserve">
+ <value>Password-protected backup of your entire vault. Includes all items, passkeys, and attachments. Use as manual backup and/or to restore to another AliasVault server.</value>
+ <comment>Description for encrypted export option</comment>
+ </data>
+ <data name="ExportAvuxTitle" xml:space="preserve">
+ <value>Unencrypted full vault export</value>
+ <comment>Title for unencrypted full export option</comment>
+ </data>
+ <data name="ExportAvuxDescription" xml:space="preserve">
+ <value>Complete vault export as unencrypted ZIP-compatible archive. Includes all items, passkeys and attachments.</value>
+ <comment>Description for unencrypted full export option</comment>
+ </data>
+ <data name="ExportCsvTitle" xml:space="preserve">
+ <value>CSV export</value>
+ <comment>Title for CSV export option</comment>
+ </data>
+ <data name="ExportCsvDescription" xml:space="preserve">
+ <value>Basic export for importing into other password managers. Does not include passkeys or attachments.</value>
+ <comment>Description for CSV export option</comment>
+ </data>
<data name="ExportCsvButton" xml:space="preserve">
- <value>Export vault to unencrypted CSV file</value>
+ <value>Export to CSV</value>
<comment>Button to export as CSV</comment>
</data>
- <data name="ExportSqliteButton" xml:space="preserve">
- <value>Export vault to unencrypted SQLite file</value>
- <comment>Button to export as SQLite</comment>
- </data>
<data name="ExportAvuxButton" xml:space="preserve">
- <value>Export full vault (.avux)</value>
+ <value>Export unencrypted vault (.avux)</value>
<comment>Button to export full vault as .avux archive</comment>
</data>
<data name="ExportingVaultMessage" xml:space="preserve">
@@ -140,4 +164,26 @@ Are you sure you want to continue with the export?</value>
<value>An error occurred while verifying your password. Please try again.</value>
<comment>Generic error message for password verification failure</comment>
</data>
+ <data name="ExportAvexButton" xml:space="preserve">
+ <value>Export encrypted vault (.avex)</value>
+ <comment>Button to export encrypted vault as .avex archive</comment>
+ </data>
+ <data name="ExportEncryptedWarningMessage" xml:space="preserve">
+ <value>This will create an encrypted export of your entire vault. You will need to provide a password to encrypt the export file.
+
+Are you sure you want to continue?</value>
+ <comment>Warning message for encrypted export confirmation</comment>
+ </data>
+ <data name="ExportEncryptedPasswordTitle" xml:space="preserve">
+ <value>Set Export Password</value>
+ <comment>Title for export password modal</comment>
+ </data>
+ <data name="ExportEncryptedPasswordDescription" xml:space="preserve">
+ <value>Choose a strong, unique password to encrypt this export. This password is required to decrypt the export. If you lose this password, you will not be able to recover the exported data.</value>
+ <comment>Description for export password modal with security warning</comment>
+ </data>
+ <data name="ExportEncryptedSuccessMessage" xml:space="preserve">
+ <value>Your encrypted vault has been exported successfully.</value>
+ <comment>Success message after encrypted export completes</comment>
+ </data>
</root>
\ No newline at end of file