Skip to content

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

Update import service card to support multiple formats (#773)

Leendert de Borst98886d399e1f
diff --git a/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceAliasVault.razor b/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceAliasVault.razor
index fa3b36bd9..1ae206da4 100644
--- a/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceAliasVault.razor
+++ b/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceAliasVault.razor
@@ -4,22 +4,66 @@
@inject IStringLocalizerFactory LocalizerFactory
@using AliasVault.ImportExport.Models
@using AliasVault.ImportExport.Importers
+@using AliasVault.ImportExport
@using Microsoft.Extensions.Localization
+@using System.Text
<ImportServiceCard
ServiceName="AliasVault"
Description="@Localizer["AliasVaultDescription"]"
LogoUrl="img/logo.svg"
- ProcessFileCallback="ProcessFile">
+ AcceptedFileTypes=".csv,.avux"
+ ProcessFileWithAutoDetectionCallback="ProcessFile"
+ SupportedFormats="@GetSupportedFormats()">
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["AliasVaultInstructionsPart1"]</p>
</ImportServiceCard>
@code {
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Settings.ImportExport.ImportServices", "AliasVault.Client");
- private static async Task<List<ImportedCredential>> ProcessFile(string fileContents)
+ /// <summary>
+ /// Gets the supported file formats with their descriptions.
+ /// </summary>
+ /// <returns>Dictionary of file extensions to format descriptions.</returns>
+ private Dictionary<string, string> GetSupportedFormats()
{
- var importedCredentials = await AliasVault.ImportExport.ItemCsvService.ImportItemsFromCsv(fileContents);
- return importedCredentials;
+ return new Dictionary<string, string>
+ {
+ { ".csv", Localizer["CsvFormatDescription"] },
+ { ".avux", Localizer["AvuxFormatDescription"] }
+ };
+ }
+
+ /// <summary>
+ /// Processes the file with auto-detection based on file extension.
+ /// </summary>
+ /// <param name="filename">The name of the uploaded file.</param>
+ /// <param name="fileBytes">The file content as bytes.</param>
+ /// <returns>List of imported credentials.</returns>
+ private static async Task<List<ImportedCredential>> ProcessFile(string filename, byte[] fileBytes)
+ {
+ try
+ {
+ // Detect file format based on extension
+ if (filename.EndsWith(".avux", StringComparison.OrdinalIgnoreCase))
+ {
+ // Process as binary .avux file
+ return await VaultImportService.ImportFromAvuxAsync(fileBytes);
+ }
+ else if (filename.EndsWith(".csv", StringComparison.OrdinalIgnoreCase))
+ {
+ // Process as text CSV file
+ var fileContents = Encoding.UTF8.GetString(fileBytes);
+ return await ItemCsvService.ImportItemsFromCsv(fileContents);
+ }
+ else
+ {
+ throw new InvalidOperationException($"Unsupported file format: {filename}. Expected .csv or .avux");
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new InvalidOperationException($"Failed to import file '{filename}': {ex.Message}", ex);
+ }
}
}
\ No newline at end of file
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 229e18c79..928fcb813 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
@@ -71,9 +71,23 @@
<div class="@(IsImporting ? "hidden" : "")">
@ChildContent
+ @if (SupportedFormats != null && SupportedFormats.Count > 0)
+ {
+ <div class="mb-4">
+ <p class="text-sm font-semibold text-gray-700 dark:text-gray-200 mb-2">
+ @Localizer["SupportedFormatsLabel"]
+ </p>
+ <ul class="list-disc list-inside text-sm text-gray-600 dark:text-gray-400 space-y-1">
+ @foreach (var format in SupportedFormats)
+ {
+ <li><strong class="text-gray-700 dark:text-gray-300">@format.Key</strong> - @format.Value</li>
+ }
+ </ul>
+ </div>
+ }
<div class="mb-4 bg-amber-50 border border-amber-400 dark:bg-amber-800/30 dark:border-amber-500/50 rounded-lg p-4">
<p class="mb-4 text-gray-700 dark:text-gray-200">@string.Format(Localizer["UploadExportFileText"], ServiceName)</p>
- <InputFile OnChange="HandleFileUpload" class="text-gray-700 dark:text-gray-200 file:mr-4 file:py-2 file:px-4 file:rounded-lg file:border-0 file:text-sm file:font-semibold file:bg-primary-50 file:text-primary-700 hover:file:bg-primary-100 dark:file:bg-primary-900/40 dark:file:text-primary-300 dark:hover:file:bg-primary-800/60" />
+ <InputFile OnChange="HandleFileUpload" accept="@AcceptedFileTypes" class="text-gray-700 dark:text-gray-200 file:mr-4 file:py-2 file:px-4 file:rounded-lg file:border-0 file:text-sm file:font-semibold file:bg-primary-50 file:text-primary-700 hover:file:bg-primary-100 dark:file:bg-primary-900/40 dark:file:text-primary-300 dark:hover:file:bg-primary-800/60" />
</div>
<div class="flex justify-end mt-6 space-x-2">
<Button OnClick="@CloseModal" Color="secondary">@Localizer["CancelButton"]</Button>
@@ -86,7 +100,7 @@
<div class="mb-4">
@if (DuplicateCredentialsCount > 0)
{
- <div class="p-4 mb-4 text-blue-700 bg-blue-100 rounded-lg dark:bg-blue-800/30 dark:text-blue-300" role="alert">
+ <div class="p-4 mb-4 text-gray-700 bg-gray-100 rounded-lg dark:bg-gray-700/50 dark:text-gray-300" role="alert">
<p>@string.Format(Localizer["DuplicateCredentialsWarning"], DuplicateCredentialsCount)</p>
</div>
}
@@ -243,10 +257,29 @@
public EventCallback OnImportConfirmed { get; set; }
/// <summary>
- /// The callback for processing the file.
+ /// The callback for processing the file (text-based).
+ /// </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.
/// </summary>
[Parameter]
- public Func<string, Task<List<ImportedCredential>>> ProcessFileCallback { get; set; } = null!;
+ public Func<string, byte[], Task<List<ImportedCredential>>>? ProcessFileWithAutoDetectionCallback { get; set; }
+
+ /// <summary>
+ /// Gets or sets the accepted file types (e.g., ".csv", ".avux").
+ /// </summary>
+ [Parameter]
+ public string AcceptedFileTypes { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the supported file formats with descriptions (e.g., {".csv": "CSV format", ".avux": "Complete backup"}).
+ /// </summary>
+ [Parameter]
+ public Dictionary<string, string>? SupportedFormats { get; set; }
private bool IsModalOpen { get; set; } = false;
private bool IsImporting { get; set; } = false;
@@ -688,18 +721,40 @@
IsImporting = true;
StateHasChanged();
- // Limit file size to 10MB
- if (e.File.Size > 10 * 1024 * 1024)
+ // Limit file size to 50MB (increased for binary files with attachments)
+ var maxFileSize = 50 * 1024 * 1024;
+ if (e.File.Size > maxFileSize)
{
ImportError = Localizer["ImportErrorFileTooLarge"];
return;
}
- await using var stream = e.File.OpenReadStream(maxAllowedSize: 10 * 1024 * 1024);
- using var reader = new StreamReader(stream);
- var fileContents = await reader.ReadToEndAsync();
+ await using var stream = e.File.OpenReadStream(maxAllowedSize: maxFileSize);
+
+ Task<List<ImportedCredential>> processingTask;
+
+ // Check if we have auto-detection callback first
+ if (ProcessFileWithAutoDetectionCallback != null)
+ {
+ // Read as binary and let the callback decide how to process
+ using var memoryStream = new MemoryStream();
+ await stream.CopyToAsync(memoryStream);
+ var fileBytes = memoryStream.ToArray();
+ processingTask = ProcessFileWithAutoDetectionCallback(e.File.Name, fileBytes);
+ }
+ else if (ProcessFileCallback != null)
+ {
+ // Read as text
+ using var reader = new StreamReader(stream);
+ var fileContents = await reader.ReadToEndAsync();
+ processingTask = ProcessFileCallback(fileContents);
+ }
+ else
+ {
+ ImportError = "No file processor configured";
+ return;
+ }
- var processingTask = ProcessFileCallback(fileContents);
var delayTask = Task.Delay(500);
await Task.WhenAll(processingTask, delayTask);
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 dd2337af6..ad7620d4c 100644
--- a/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/ImportExport.razor
+++ b/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/ImportExport.razor
@@ -283,7 +283,7 @@
{
Logger.LogError(ex, "Error exporting vault to .avux format");
GlobalNotificationService.AddErrorMessage(
- $"{Localizer["ExportErrorTitle"]}: {Localizer["ExportErrorMessage"]}",
+ SharedLocalizer["ErrorGeneric"],
true);
}
finally
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 c80fee9ac..14a15ff8c 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
@@ -166,4 +166,8 @@
<value>File size exceeds 10MB limit.</value>
<comment>Error message when file is too large</comment>
</data>
+ <data name="SupportedFormatsLabel" xml:space="preserve">
+ <value>Supported formats:</value>
+ <comment>Label for the list of supported file formats in the import modal</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 367812d7a..ae81d1acd 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
@@ -230,15 +230,36 @@
<value>Once you have exported the file, you can upload it below.</value>
<comment>Strongbox export instructions part 2</comment>
</data>
- <!-- AliasVault -->
+ <!-- AliasVault .avux -->
+ <data name="AvuxDescription" xml:space="preserve">
+ <value>Import complete AliasVault backup (.avux format)</value>
+ <comment>Description for AliasVault .avux import service</comment>
+ </data>
+ <data name="AvuxInstructions" xml:space="preserve">
+ <value>Use this option to restore a complete vault backup including all items, folders, tags, passkeys, TOTP codes, and attachments from an .avux export file.</value>
+ <comment>AliasVault .avux import instructions</comment>
+ </data>
+ <data name="AvuxFormatTitle" xml:space="preserve">
+ <value>Complete Vault Backup:</value>
+ <comment>Title for .avux format explanation</comment>
+ </data>
+ <data name="AvuxFormatDescription" xml:space="preserve">
+ <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 -->
<data name="AliasVaultDescription" xml:space="preserve">
- <value>Import passwords from another AliasVault server or manual back-up</value>
+ <value>Import from AliasVault backup (.csv or .avux)</value>
<comment>Description for AliasVault import service</comment>
</data>
<data name="AliasVaultInstructionsPart1" xml:space="preserve">
- <value>If you have a CSV file back-up of your AliasVault database (from a different AliasVault server), you can import it here.</value>
+ <value>Import your AliasVault backup from another server or a manual backup. Supports both CSV and .avux formats.</value>
<comment>AliasVault import instructions</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>
<!-- 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/ImportExport.en.resx b/apps/server/AliasVault.Client/Resources/Pages/Main/Settings/ImportExport/ImportExport.en.resx
index b9487202f..697a79bf6 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
@@ -90,6 +90,14 @@
<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>
+ <comment>Button to export full vault as .avux archive</comment>
+ </data>
+ <data name="ExportingVaultMessage" xml:space="preserve">
+ <value>Exporting vault...</value>
+ <comment>Message shown while exporting vault</comment>
+ </data>
<data name="ExportConfirmTitle" xml:space="preserve">
<value>Export vault</value>
<comment>Export confirmation dialog title</comment>
diff --git a/apps/server/AliasVault.Client/wwwroot/css/tailwind.css b/apps/server/AliasVault.Client/wwwroot/css/tailwind.css
index 715190a47..ed57844e3 100644
--- a/apps/server/AliasVault.Client/wwwroot/css/tailwind.css
+++ b/apps/server/AliasVault.Client/wwwroot/css/tailwind.css
@@ -3280,10 +3280,6 @@ video {
background-color: rgb(30 64 175 / var(--tw-bg-opacity));
}
-.dark\:bg-blue-800\/30:is(.dark *) {
- background-color: rgb(30 64 175 / 0.3);
-}
-
.dark\:bg-blue-900:is(.dark *) {
--tw-bg-opacity: 1;
background-color: rgb(30 58 138 / var(--tw-bg-opacity));
@@ -3460,11 +3456,6 @@ video {
color: rgb(251 191 36 / var(--tw-text-opacity));
}
-.dark\:text-blue-300:is(.dark *) {
- --tw-text-opacity: 1;
- color: rgb(147 197 253 / var(--tw-text-opacity));
-}
-
.dark\:text-blue-400:is(.dark *) {
--tw-text-opacity: 1;
color: rgb(96 165 250 / var(--tw-text-opacity));