Skip to content

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

Add Bitwarden .zip import scaffolding (#1947)

Leendert de Borstc3e0f8410aa6
diff --git a/apps/server/Tests/AliasVault.UnitTests/AliasVault.UnitTests.csproj b/apps/server/Tests/AliasVault.UnitTests/AliasVault.UnitTests.csproj
index 6b718133e..df9d56a53 100644
--- a/apps/server/Tests/AliasVault.UnitTests/AliasVault.UnitTests.csproj
+++ b/apps/server/Tests/AliasVault.UnitTests/AliasVault.UnitTests.csproj
@@ -46,6 +46,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
+ <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="10.0.6" />
</ItemGroup>
<ItemGroup>
@@ -61,6 +62,7 @@
<ItemGroup>
<EmbeddedResource Include="TestData\Exports\bitwarden.csv" />
+ <EmbeddedResource Include="TestData\Exports\bitwarden.zip" />
<EmbeddedResource Include="TestData\Exports\chrome.csv" />
<EmbeddedResource Include="TestData\Exports\dashlane.csv" />
<EmbeddedResource Include="TestData\Exports\dropbox.csv" />
diff --git a/apps/server/Tests/AliasVault.UnitTests/Utilities/ImportExportTests.cs b/apps/server/Tests/AliasVault.UnitTests/Utilities/ImportExportTests.cs
index 09acc36e2..d4c49ab76 100644
--- a/apps/server/Tests/AliasVault.UnitTests/Utilities/ImportExportTests.cs
+++ b/apps/server/Tests/AliasVault.UnitTests/Utilities/ImportExportTests.cs
@@ -1959,6 +1959,114 @@ public class ImportExportTests
return item;
}
+ /// <summary>
+ /// Test case for importing credentials from Bitwarden ZIP export with attachments.
+ /// </summary>
+ /// <returns>Async task.</returns>
+ [Test]
+ public async Task ImportCredentialsFromBitwardenZip()
+ {
+ // Arrange
+ var zipBytes = await ResourceReaderUtility.ReadEmbeddedResourceBytesAsync("AliasVault.UnitTests.TestData.Exports.bitwarden.zip");
+
+ // Act
+ var importer = new BitwardenZipImporter();
+ var importedCredentials = await importer.ImportFromArchiveAsync(zipBytes);
+
+ // Assert
+ Assert.That(importedCredentials, Has.Count.EqualTo(5));
+
+ // Test Login item with TOTP and custom fields
+ var loginItem = importedCredentials.First(c => c.ServiceName == "Example Login");
+ Assert.Multiple(() =>
+ {
+ Assert.That(loginItem.ServiceName, Is.EqualTo("Example Login"));
+ Assert.That(loginItem.Username, Is.EqualTo("[email protected]"));
+ Assert.That(loginItem.Password, Is.EqualTo("SecurePassword123!"));
+ Assert.That(loginItem.ServiceUrls, Has.Count.EqualTo(1));
+ Assert.That(loginItem.ServiceUrls![0], Is.EqualTo("https://example.com"));
+ Assert.That(loginItem.TwoFactorSecret, Is.EqualTo("otpauth://totp/Example:[email protected]?secret=JBSWY3DPEHPK3PXP&issuer=Example"));
+ Assert.That(loginItem.FolderPath, Is.EqualTo("Personal"));
+ Assert.That(loginItem.ItemType, Is.EqualTo(ImportedItemType.Login));
+
+ // Verify custom fields (all types: Text=0, Hidden=1, Boolean=2)
+ // Linked fields (type 3) are skipped during import
+ Assert.That(loginItem.CustomFields, Is.Not.Null);
+ Assert.That(loginItem.CustomFields, Has.Count.EqualTo(3));
+ Assert.That(loginItem.CustomFields!["Security Question"], Is.EqualTo("My first pet")); // Type 0: Text
+ Assert.That(loginItem.CustomFields["API Key"], Is.EqualTo("sk_test_123456789")); // Type 1: Hidden
+ Assert.That(loginItem.CustomFields["Two Factor Enabled"], Is.EqualTo("true")); // Type 2: Boolean
+
+ // Notes should remain unchanged (linked fields are skipped, not added to notes)
+ Assert.That(loginItem.Notes, Is.EqualTo("This is a test login item"));
+ });
+
+ // Test Secure Note item
+ var noteItem = importedCredentials.First(c => c.ServiceName == "Secure Note");
+ Assert.Multiple(() =>
+ {
+ Assert.That(noteItem.ServiceName, Is.EqualTo("Secure Note"));
+ Assert.That(noteItem.Notes, Is.EqualTo("This is a secure note with sensitive information"));
+ Assert.That(noteItem.ItemType, Is.EqualTo(ImportedItemType.Note));
+ Assert.That(noteItem.FolderPath, Is.Null);
+ });
+
+ // Test Credit Card item
+ var cardItem = importedCredentials.First(c => c.ServiceName == "My Credit Card");
+ Assert.Multiple(() =>
+ {
+ Assert.That(cardItem.ServiceName, Is.EqualTo("My Credit Card"));
+ Assert.That(cardItem.Notes, Is.EqualTo("Primary card"));
+ Assert.That(cardItem.FolderPath, Is.EqualTo("Work"));
+ Assert.That(cardItem.ItemType, Is.EqualTo(ImportedItemType.Creditcard));
+ Assert.That(cardItem.Creditcard, Is.Not.Null);
+ Assert.That(cardItem.Creditcard!.CardholderName, Is.EqualTo("John Doe"));
+ Assert.That(cardItem.Creditcard.Number, Is.EqualTo("4111111111111111"));
+ Assert.That(cardItem.Creditcard.ExpiryMonth, Is.EqualTo("12"));
+ Assert.That(cardItem.Creditcard.ExpiryYear, Is.EqualTo("2025"));
+ Assert.That(cardItem.Creditcard.Cvv, Is.EqualTo("123"));
+ });
+
+ // Test Identity item
+ var identityItem = importedCredentials.First(c => c.ServiceName == "Personal Identity");
+ Assert.Multiple(() =>
+ {
+ Assert.That(identityItem.ServiceName, Is.EqualTo("Personal Identity"));
+ Assert.That(identityItem.ItemType, Is.EqualTo(ImportedItemType.Alias));
+ Assert.That(identityItem.Alias, Is.Not.Null);
+ Assert.That(identityItem.Alias!.FirstName, Is.EqualTo("John"));
+ Assert.That(identityItem.Alias.LastName, Is.EqualTo("Doe"));
+ Assert.That(identityItem.Email, Is.EqualTo("[email protected]"));
+ Assert.That(identityItem.Notes, Does.Contain("Company: Example Corp"));
+ Assert.That(identityItem.Notes, Does.Contain("Phone: +1234567890"));
+ Assert.That(identityItem.Notes, Does.Contain("Address: 123 Main St, Apt 4B, New York, NY, 10001, US"));
+ });
+
+ // Test Login with Attachment
+ var attachmentItem = importedCredentials.First(c => c.ServiceName == "Login with Attachment");
+ Assert.Multiple(() =>
+ {
+ Assert.That(attachmentItem.ServiceName, Is.EqualTo("Login with Attachment"));
+ Assert.That(attachmentItem.Username, Is.EqualTo("admin"));
+ Assert.That(attachmentItem.Password, Is.EqualTo("AdminPass456!"));
+ });
+
+ // Note: Attachment extraction is supported but skipped in unit tests
+ // as it requires specific ZIP structure that may vary by Bitwarden export version
+
+ // Verify conversion to Item works correctly
+ var convertedItems = BaseImporter.ConvertToItem(importedCredentials);
+ Assert.That(convertedItems, Has.Count.EqualTo(5));
+
+ var convertedLogin = convertedItems.First(i => i.Name == "Example Login");
+ Assert.Multiple(() =>
+ {
+ Assert.That(convertedLogin.ItemType, Is.EqualTo(ItemType.Login));
+ Assert.That(convertedLogin.TotpCodes, Has.Count.EqualTo(1));
+ Assert.That(convertedLogin.TotpCodes.First().SecretKey, Is.EqualTo("JBSWY3DPEHPK3PXP"));
+ });
+ }
+
/// <summary>
/// Test case for importing credentials from 1Password .1pux export format.
/// </summary>
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Importers/BaseImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/BaseImporter.cs
index fdffa4308..9c9eb7b0a 100644
--- a/apps/server/Utilities/AliasVault.ImportExport/Importers/BaseImporter.cs
+++ b/apps/server/Utilities/AliasVault.ImportExport/Importers/BaseImporter.cs
@@ -293,6 +293,47 @@ public static class BaseImporter
}
}
+ // Add custom fields if present
+ if (importedCredential.CustomFields != null)
+ {
+ foreach (var customField in importedCredential.CustomFields)
+ {
+ if (string.IsNullOrWhiteSpace(customField.Value))
+ {
+ continue;
+ }
+
+ // Create a FieldDefinition for this custom field
+ var fieldDefinition = new FieldDefinition
+ {
+ Id = Guid.NewGuid(),
+ Label = customField.Key,
+ FieldType = "Text", // Default to Text type for all custom fields
+ IsMultiValue = false,
+ IsHidden = false,
+ EnableHistory = false,
+ Weight = 0,
+ ApplicableToTypes = null, // Applicable to all types
+ CreatedAt = createdAt,
+ UpdatedAt = updatedAt,
+ };
+
+ // Create a FieldValue that references this definition
+ item.FieldValues.Add(new FieldValue
+ {
+ Id = Guid.NewGuid(),
+ ItemId = item.Id,
+ FieldDefinition = fieldDefinition,
+ FieldDefinitionId = fieldDefinition.Id,
+ FieldKey = null, // Custom fields don't use FieldKey
+ Value = customField.Value,
+ Weight = 0,
+ CreatedAt = createdAt,
+ UpdatedAt = updatedAt,
+ });
+ }
+ }
+
items.Add(item);
}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Importers/BitwardenZipImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/BitwardenZipImporter.cs
new file mode 100644
index 000000000..798f1c50e
--- /dev/null
+++ b/apps/server/Utilities/AliasVault.ImportExport/Importers/BitwardenZipImporter.cs
@@ -0,0 +1,401 @@
+//-----------------------------------------------------------------------
+// <copyright file="BitwardenZipImporter.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.ImportExport.Importers;
+
+using System.IO.Compression;
+using AliasVault.ImportExport.Models;
+using AliasVault.ImportExport.Models.Imports;
+
+/// <summary>
+/// Imports credentials from Bitwarden .zip export format (with attachments).
+/// </summary>
+public class BitwardenZipImporter : BaseArchiveImporter
+{
+ /// <inheritdoc/>
+ protected override string? GetAttachmentPathPattern() => "attachments/";
+
+ /// <inheritdoc/>
+ protected override async Task<List<ImportedCredential>> ProcessArchiveAsync(
+ ZipArchive archive,
+ Dictionary<string, byte[]> attachmentMap,
+ Dictionary<string, byte[]> logoMap)
+ {
+ // Extract the main JSON manifest
+ var exportData = await ReadJsonFromArchiveAsync<BitwardenJsonExport>(archive, "data.json");
+ if (exportData == null)
+ {
+ throw new InvalidOperationException("Invalid Bitwarden ZIP file: data.json not found or could not be parsed");
+ }
+
+ // Validate the export
+ ValidateExport(exportData);
+
+ // Build folder lookup
+ var folderLookup = BuildFolderLookup(exportData.Folders);
+
+ var credentials = new List<ImportedCredential>();
+
+ foreach (var item in exportData.Items)
+ {
+ var credential = ConvertBitwardenItemToCredential(item, folderLookup, attachmentMap);
+ credentials.Add(credential);
+ }
+
+ return credentials;
+ }
+
+ /// <summary>
+ /// Validates the Bitwarden export data.
+ /// </summary>
+ /// <param name="exportData">The export data to validate.</param>
+ /// <exception cref="InvalidOperationException">Thrown when the export is encrypted or invalid.</exception>
+ private static void ValidateExport(BitwardenJsonExport exportData)
+ {
+ if (exportData.Encrypted)
+ {
+ throw new InvalidOperationException("Encrypted Bitwarden exports are not supported. Please export as unencrypted.");
+ }
+ }
+
+ /// <summary>
+ /// Builds a dictionary mapping folder IDs to folder names.
+ /// </summary>
+ /// <param name="folders">The list of folders from the export.</param>
+ /// <returns>A dictionary mapping folder IDs to folder names.</returns>
+ private static Dictionary<string, string> BuildFolderLookup(List<BitwardenFolder> folders)
+ {
+ return folders
+ .Where(f => !string.IsNullOrWhiteSpace(f.Id) && !string.IsNullOrWhiteSpace(f.Name))
+ .ToDictionary(f => f.Id!, f => f.Name!);
+ }
+
+ /// <summary>
+ /// Maps a Bitwarden item type to an ImportedItemType.
+ /// </summary>
+ /// <param name="type">The Bitwarden item type.</param>
+ /// <returns>The corresponding ImportedItemType.</returns>
+ private static ImportedItemType MapBitwardenTypeToItemType(int type)
+ {
+ return type switch
+ {
+ 1 => ImportedItemType.Login, // Login
+ 2 => ImportedItemType.Note, // Secure Note
+ 3 => ImportedItemType.Creditcard, // Card
+ 4 => ImportedItemType.Alias, // Identity
+ _ => ImportedItemType.Login, // Default to Login for unknown types
+ };
+ }
+
+ /// <summary>
+ /// Gets the folder path for an item from the folder lookup.
+ /// </summary>
+ /// <param name="folderId">The folder ID.</param>
+ /// <param name="folderLookup">Dictionary mapping folder IDs to names.</param>
+ /// <returns>The folder path, or null if not found.</returns>
+ private static string? GetFolderPath(string? folderId, Dictionary<string, string> folderLookup)
+ {
+ if (string.IsNullOrWhiteSpace(folderId))
+ {
+ return null;
+ }
+
+ return folderLookup.TryGetValue(folderId, out var folderName) ? folderName : null;
+ }
+
+ /// <summary>
+ /// Converts a Bitwarden item to an ImportedCredential.
+ /// </summary>
+ /// <param name="item">The Bitwarden item.</param>
+ /// <param name="folderLookup">Dictionary mapping folder IDs to names.</param>
+ /// <param name="attachmentMap">Dictionary mapping attachment paths to file data.</param>
+ /// <returns>The imported credential.</returns>
+ private static ImportedCredential ConvertBitwardenItemToCredential(
+ BitwardenItem item,
+ Dictionary<string, string> folderLookup,
+ Dictionary<string, byte[]> attachmentMap)
+ {
+ var credential = new ImportedCredential
+ {
+ ServiceName = item.Name,
+ Notes = item.Notes,
+ UpdatedAt = item.RevisionDate,
+ FolderPath = GetFolderPath(item.FolderId, folderLookup),
+ };
+
+ // Map item type
+ credential.ItemType = MapBitwardenTypeToItemType(item.Type);
+
+ // Extract type-specific data
+ ExtractItemData(credential, item);
+
+ // Extract custom fields
+ ExtractCustomFields(credential, item.Fields);
+
+ // Extract attachments
+ if (!string.IsNullOrWhiteSpace(item.Id))
+ {
+ ExtractAttachments(credential, item.Id, attachmentMap);
+ }
+
+ return credential;
+ }
+
+ /// <summary>
+ /// Extracts data from a Bitwarden item based on its type.
+ /// </summary>
+ /// <param name="credential">The credential to populate.</param>
+ /// <param name="item">The Bitwarden item.</param>
+ private static void ExtractItemData(ImportedCredential credential, BitwardenItem item)
+ {
+ switch (credential.ItemType)
+ {
+ case ImportedItemType.Login:
+ ExtractLoginData(credential, item.Login);
+ break;
+
+ case ImportedItemType.Creditcard:
+ ExtractCardData(credential, item.Card);
+ break;
+
+ case ImportedItemType.Alias:
+ ExtractIdentityData(credential, item.Identity);
+ break;
+
+ case ImportedItemType.Note:
+ // Secure notes only use base fields (name, notes)
+ break;
+ }
+ }
+
+ /// <summary>
+ /// Extracts custom fields from a Bitwarden item.
+ /// Bitwarden field types:
+ /// 0 = Text (plaintext)
+ /// 1 = Hidden (password/sensitive)
+ /// 2 = Boolean (true/false)
+ /// 3 = Linked (reference to another field - not supported, skipped)
+ /// </summary>
+ /// <param name="credential">The credential to populate.</param>
+ /// <param name="fields">The list of custom fields.</param>
+ private static void ExtractCustomFields(ImportedCredential credential, List<BitwardenField>? fields)
+ {
+ if (fields == null || fields.Count == 0)
+ {
+ return;
+ }
+
+ foreach (var field in fields)
+ {
+ // Skip fields without a name
+ if (string.IsNullOrWhiteSpace(field.Name))
+ {
+ continue;
+ }
+
+ // Skip linked fields (type 3) - we don't support them
+ if (field.Type == 3)
+ {
+ continue;
+ }
+
+ // For all other types (Text, Hidden, Boolean), add to custom fields if value exists
+ if (!string.IsNullOrWhiteSpace(field.Value))
+ {
+ credential.CustomFields ??= new Dictionary<string, string>();
+ credential.CustomFields[field.Name] = field.Value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Extracts login data from a Bitwarden login object.
+ /// </summary>
+ /// <param name="credential">The credential to populate.</param>
+ /// <param name="login">The Bitwarden login object.</param>
+ private static void ExtractLoginData(ImportedCredential credential, BitwardenLogin? login)
+ {
+ if (login == null)
+ {
+ return;
+ }
+
+ credential.Username = login.Username;
+ credential.Password = login.Password;
+ credential.TwoFactorSecret = login.Totp;
+
+ // Extract URLs
+ if (login.Uris != null && login.Uris.Count > 0)
+ {
+ credential.ServiceUrls = login.Uris
+ .Where(u => !string.IsNullOrWhiteSpace(u.Uri))
+ .Select(u => u.Uri!)
+ .ToList();
+ }
+ }
+
+ /// <summary>
+ /// Extracts card data from a Bitwarden card object.
+ /// </summary>
+ /// <param name="credential">The credential to populate.</param>
+ /// <param name="card">The Bitwarden card object.</param>
+ private static void ExtractCardData(ImportedCredential credential, BitwardenCard? card)
+ {
+ if (card == null)
+ {
+ return;
+ }
+
+ credential.Creditcard = new ImportedCreditcard
+ {
+ CardholderName = card.CardholderName,
+ Number = card.Number,
+ ExpiryMonth = card.ExpMonth,
+ ExpiryYear = card.ExpYear,
+ Cvv = card.Code,
+ };
+ }
+
+ /// <summary>
+ /// Extracts identity data from a Bitwarden identity object.
+ /// </summary>
+ /// <param name="credential">The credential to populate.</param>
+ /// <param name="identity">The Bitwarden identity object.</param>
+ private static void ExtractIdentityData(ImportedCredential credential, BitwardenIdentity? identity)
+ {
+ if (identity == null)
+ {
+ return;
+ }
+
+ credential.Alias = new ImportedAlias
+ {
+ FirstName = identity.FirstName,
+ LastName = identity.LastName,
+ };
+
+ credential.Email = identity.Email;
+
+ // Add identity details to notes if they exist
+ var identityNotes = new List<string>();
+
+ if (!string.IsNullOrWhiteSpace(identity.Title))
+ {
+ identityNotes.Add($"Title: {identity.Title}");
+ }
+
+ if (!string.IsNullOrWhiteSpace(identity.Company))
+ {
+ identityNotes.Add($"Company: {identity.Company}");
+ }
+
+ if (!string.IsNullOrWhiteSpace(identity.Phone))
+ {
+ identityNotes.Add($"Phone: {identity.Phone}");
+ }
+
+ var address = BuildAddress(identity);
+ if (!string.IsNullOrWhiteSpace(address))
+ {
+ identityNotes.Add($"Address: {address}");
+ }
+
+ if (identityNotes.Count > 0)
+ {
+ var existingNotes = credential.Notes ?? string.Empty;
+ var combinedNotes = string.IsNullOrWhiteSpace(existingNotes)
+ ? string.Join("\n", identityNotes)
+ : $"{existingNotes}\n\n{string.Join("\n", identityNotes)}";
+ credential.Notes = combinedNotes;
+ }
+ }
+
+ /// <summary>
+ /// Builds an address string from identity data.
+ /// </summary>
+ /// <param name="identity">The Bitwarden identity object.</param>
+ /// <returns>A formatted address string, or null if no address data exists.</returns>
+ private static string? BuildAddress(BitwardenIdentity identity)
+ {
+ var parts = new List<string>();
+
+ if (!string.IsNullOrWhiteSpace(identity.Address1))
+ {
+ parts.Add(identity.Address1);
+ }
+
+ if (!string.IsNullOrWhiteSpace(identity.Address2))
+ {
+ parts.Add(identity.Address2);
+ }
+
+ if (!string.IsNullOrWhiteSpace(identity.Address3))
+ {
+ parts.Add(identity.Address3);
+ }
+
+ if (!string.IsNullOrWhiteSpace(identity.City))
+ {
+ parts.Add(identity.City);
+ }
+
+ if (!string.IsNullOrWhiteSpace(identity.State))
+ {
+ parts.Add(identity.State);
+ }
+
+ if (!string.IsNullOrWhiteSpace(identity.PostalCode))
+ {
+ parts.Add(identity.PostalCode);
+ }
+
+ if (!string.IsNullOrWhiteSpace(identity.Country))
+ {
+ parts.Add(identity.Country);
+ }
+
+ return parts.Count > 0 ? string.Join(", ", parts) : null;
+ }
+
+ /// <summary>
+ /// Extracts attachments for a specific item from the attachment map.
+ /// </summary>
+ /// <param name="credential">The credential to add attachments to.</param>
+ /// <param name="itemId">The Bitwarden item ID.</param>
+ /// <param name="attachmentMap">Dictionary mapping attachment paths to file data.</param>
+ private static void ExtractAttachments(
+ ImportedCredential credential,
+ string itemId,
+ Dictionary<string, byte[]> attachmentMap)
+ {
+ // Bitwarden stores attachments in: attachments/<item-uuid>/<filename>
+ var attachmentPrefix = $"attachments/{itemId}/";
+
+ var itemAttachments = attachmentMap
+ .Where(kvp => kvp.Key.StartsWith(attachmentPrefix, StringComparison.OrdinalIgnoreCase))
+ .ToList();
+
+ if (itemAttachments.Count == 0)
+ {
+ return;
+ }
+
+ credential.Attachments = new List<ImportedAttachment>();
+
+ foreach (var attachmentEntry in itemAttachments)
+ {
+ // Extract filename from path (everything after the item ID directory)
+ var filename = attachmentEntry.Key.Substring(attachmentPrefix.Length);
+
+ credential.Attachments.Add(new ImportedAttachment
+ {
+ Filename = filename,
+ Blob = attachmentEntry.Value,
+ });
+ }
+ }
+}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/BitwardenJson.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/BitwardenJson.cs
new file mode 100644
index 000000000..2a878395c
--- /dev/null
+++ b/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/BitwardenJson.cs
@@ -0,0 +1,450 @@
+//-----------------------------------------------------------------------
+// <copyright file="BitwardenJson.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.ImportExport.Models.Imports;
+
+using System.Text.Json.Serialization;
+
+/// <summary>
+/// Root structure of a Bitwarden JSON export file.
+/// </summary>
+public class BitwardenJsonExport
+{
+ /// <summary>
+ /// Gets or sets a value indicating whether the export is encrypted.
+ /// </summary>
+ [JsonPropertyName("encrypted")]
+ public bool Encrypted { get; set; }
+
+ /// <summary>
+ /// Gets or sets the list of folders.
+ /// </summary>
+ [JsonPropertyName("folders")]
+ public List<BitwardenFolder> Folders { get; set; } = new();
+
+ /// <summary>
+ /// Gets or sets the list of items.
+ /// </summary>
+ [JsonPropertyName("items")]
+ public List<BitwardenItem> Items { get; set; } = new();
+
+ /// <summary>
+ /// Gets or sets the list of collections (organization exports).
+ /// </summary>
+ [JsonPropertyName("collections")]
+ public List<BitwardenCollection>? Collections { get; set; }
+}
+
+/// <summary>
+/// Represents a folder in Bitwarden.
+/// </summary>
+public class BitwardenFolder
+{
+ /// <summary>
+ /// Gets or sets the folder ID.
+ /// </summary>
+ [JsonPropertyName("id")]
+ public string? Id { get; set; }
+
+ /// <summary>
+ /// Gets or sets the folder name.
+ /// </summary>
+ [JsonPropertyName("name")]
+ public string? Name { get; set; }
+}
+
+/// <summary>
+/// Represents a collection in Bitwarden (organization exports).
+/// </summary>
+public class BitwardenCollection
+{
+ /// <summary>
+ /// Gets or sets the collection ID.
+ /// </summary>
+ [JsonPropertyName("id")]
+ public string? Id { get; set; }
+
+ /// <summary>
+ /// Gets or sets the collection name.
+ /// </summary>
+ [JsonPropertyName("name")]
+ public string? Name { get; set; }
+}
+
+/// <summary>
+/// Represents an item in Bitwarden.
+/// </summary>
+public class BitwardenItem
+{
+ /// <summary>
+ /// Gets or sets the item ID.
+ /// </summary>
+ [JsonPropertyName("id")]
+ public string? Id { get; set; }
+
+ /// <summary>
+ /// Gets or sets the organization ID.
+ /// </summary>
+ [JsonPropertyName("organizationId")]
+ public string? OrganizationId { get; set; }
+
+ /// <summary>
+ /// Gets or sets the folder ID.
+ /// </summary>
+ [JsonPropertyName("folderId")]
+ public string? FolderId { get; set; }
+
+ /// <summary>
+ /// Gets or sets the item type.
+ /// 1 = Login
+ /// 2 = Secure Note
+ /// 3 = Card
+ /// 4 = Identity
+ /// </summary>
+ [JsonPropertyName("type")]
+ public int Type { get; set; }
+
+ /// <summary>
+ /// Gets or sets the reprompt setting.
+ /// </summary>
+ [JsonPropertyName("reprompt")]
+ public int Reprompt { get; set; }
+
+ /// <summary>
+ /// Gets or sets the item name.
+ /// </summary>
+ [JsonPropertyName("name")]
+ public string? Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the notes.
+ /// </summary>
+ [JsonPropertyName("notes")]
+ public string? Notes { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether this item is a favorite.
+ /// </summary>
+ [JsonPropertyName("favorite")]
+ public bool Favorite { get; set; }
+
+ /// <summary>
+ /// Gets or sets the revision date.
+ /// </summary>
+ [JsonPropertyName("revisionDate")]
+ public DateTime? RevisionDate { get; set; }
+
+ /// <summary>
+ /// Gets or sets the password history.
+ /// </summary>
+ [JsonPropertyName("passwordHistory")]
+ public List<BitwardenPasswordHistory>? PasswordHistory { get; set; }
+
+ /// <summary>
+ /// Gets or sets the custom fields.
+ /// </summary>
+ [JsonPropertyName("fields")]
+ public List<BitwardenField>? Fields { get; set; }
+
+ /// <summary>
+ /// Gets or sets the login object (for type 1 items).
+ /// </summary>
+ [JsonPropertyName("login")]
+ public BitwardenLogin? Login { get; set; }
+
+ /// <summary>
+ /// Gets or sets the secure note object (for type 2 items).
+ /// </summary>
+ [JsonPropertyName("secureNote")]
+ public BitwardenSecureNote? SecureNote { get; set; }
+
+ /// <summary>
+ /// Gets or sets the card object (for type 3 items).
+ /// </summary>
+ [JsonPropertyName("card")]
+ public BitwardenCard? Card { get; set; }
+
+ /// <summary>
+ /// Gets or sets the identity object (for type 4 items).
+ /// </summary>
+ [JsonPropertyName("identity")]
+ public BitwardenIdentity? Identity { get; set; }
+
+ /// <summary>
+ /// Gets or sets the collection IDs.
+ /// </summary>
+ [JsonPropertyName("collectionIds")]
+ public List<string>? CollectionIds { get; set; }
+}
+
+/// <summary>
+/// Represents password history in Bitwarden.
+/// </summary>
+public class BitwardenPasswordHistory
+{
+ /// <summary>
+ /// Gets or sets the date the password was last used.
+ /// </summary>
+ [JsonPropertyName("lastUsedDate")]
+ public DateTime? LastUsedDate { get; set; }
+
+ /// <summary>
+ /// Gets or sets the password.
+ /// </summary>
+ [JsonPropertyName("password")]
+ public string? Password { get; set; }
+}
+
+/// <summary>
+/// Represents a custom field in Bitwarden.
+/// </summary>
+public class BitwardenField
+{
+ /// <summary>
+ /// Gets or sets the field name.
+ /// </summary>
+ [JsonPropertyName("name")]
+ public string? Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the field value.
+ /// </summary>
+ [JsonPropertyName("value")]
+ public string? Value { get; set; }
+
+ /// <summary>
+ /// Gets or sets the linked field ID (only for type 3 - Linked fields).
+ /// </summary>
+ [JsonPropertyName("linkedId")]
+ public int? LinkedId { get; set; }
+
+ /// <summary>
+ /// Gets or sets the field type.
+ /// 0 = Text
+ /// 1 = Hidden
+ /// 2 = Boolean
+ /// 3 = Linked
+ /// </summary>
+ [JsonPropertyName("type")]
+ public int Type { get; set; }
+}
+
+/// <summary>
+/// Represents login details in Bitwarden.
+/// </summary>
+public class BitwardenLogin
+{
+ /// <summary>
+ /// Gets or sets the URIs.
+ /// </summary>
+ [JsonPropertyName("uris")]
+ public List<BitwardenUri>? Uris { get; set; }
+
+ /// <summary>
+ /// Gets or sets the username.
+ /// </summary>
+ [JsonPropertyName("username")]
+ public string? Username { get; set; }
+
+ /// <summary>
+ /// Gets or sets the password.
+ /// </summary>
+ [JsonPropertyName("password")]
+ public string? Password { get; set; }
+
+ /// <summary>
+ /// Gets or sets the TOTP secret.
+ /// </summary>
+ [JsonPropertyName("totp")]
+ public string? Totp { get; set; }
+}
+
+/// <summary>
+/// Represents a URI in Bitwarden.
+/// </summary>
+public class BitwardenUri
+{
+ /// <summary>
+ /// Gets or sets the URI match type.
+ /// </summary>
+ [JsonPropertyName("match")]
+ public int? Match { get; set; }
+
+ /// <summary>
+ /// Gets or sets the URI.
+ /// </summary>
+ [JsonPropertyName("uri")]
+ public string? Uri { get; set; }
+}
+
+/// <summary>
+/// Represents a secure note in Bitwarden.
+/// </summary>
+public class BitwardenSecureNote
+{
+ /// <summary>
+ /// Gets or sets the note type.
+ /// </summary>
+ [JsonPropertyName("type")]
+ public int Type { get; set; }
+}
+
+/// <summary>
+/// Represents a card in Bitwarden.
+/// </summary>
+public class BitwardenCard
+{
+ /// <summary>
+ /// Gets or sets the cardholder name.
+ /// </summary>
+ [JsonPropertyName("cardholderName")]
+ public string? CardholderName { get; set; }
+
+ /// <summary>
+ /// Gets or sets the brand (Visa, Mastercard, etc.).
+ /// </summary>
+ [JsonPropertyName("brand")]
+ public string? Brand { get; set; }
+
+ /// <summary>
+ /// Gets or sets the card number.
+ /// </summary>
+ [JsonPropertyName("number")]
+ public string? Number { get; set; }
+
+ /// <summary>
+ /// Gets or sets the expiry month.
+ /// </summary>
+ [JsonPropertyName("expMonth")]
+ public string? ExpMonth { get; set; }
+
+ /// <summary>
+ /// Gets or sets the expiry year.
+ /// </summary>
+ [JsonPropertyName("expYear")]
+ public string? ExpYear { get; set; }
+
+ /// <summary>
+ /// Gets or sets the CVV/CVC code.
+ /// </summary>
+ [JsonPropertyName("code")]
+ public string? Code { get; set; }
+}
+
+/// <summary>
+/// Represents an identity in Bitwarden.
+/// </summary>
+public class BitwardenIdentity
+{
+ /// <summary>
+ /// Gets or sets the title (Mr, Mrs, etc.).
+ /// </summary>
+ [JsonPropertyName("title")]
+ public string? Title { get; set; }
+
+ /// <summary>
+ /// Gets or sets the first name.
+ /// </summary>
+ [JsonPropertyName("firstName")]
+ public string? FirstName { get; set; }
+
+ /// <summary>
+ /// Gets or sets the middle name.
+ /// </summary>
+ [JsonPropertyName("middleName")]
+ public string? MiddleName { get; set; }
+
+ /// <summary>
+ /// Gets or sets the last name.
+ /// </summary>
+ [JsonPropertyName("lastName")]
+ public string? LastName { get; set; }
+
+ /// <summary>
+ /// Gets or sets the address line 1.
+ /// </summary>
+ [JsonPropertyName("address1")]
+ public string? Address1 { get; set; }
+
+ /// <summary>
+ /// Gets or sets the address line 2.
+ /// </summary>
+ [JsonPropertyName("address2")]
+ public string? Address2 { get; set; }
+
+ /// <summary>
+ /// Gets or sets the address line 3.
+ /// </summary>
+ [JsonPropertyName("address3")]
+ public string? Address3 { get; set; }
+
+ /// <summary>
+ /// Gets or sets the city.
+ /// </summary>
+ [JsonPropertyName("city")]
+ public string? City { get; set; }
+
+ /// <summary>
+ /// Gets or sets the state.
+ /// </summary>
+ [JsonPropertyName("state")]
+ public string? State { get; set; }
+
+ /// <summary>
+ /// Gets or sets the postal code.
+ /// </summary>
+ [JsonPropertyName("postalCode")]
+ public string? PostalCode { get; set; }
+
+ /// <summary>
+ /// Gets or sets the country.
+ /// </summary>
+ [JsonPropertyName("country")]
+ public string? Country { get; set; }
+
+ /// <summary>
+ /// Gets or sets the company.
+ /// </summary>
+ [JsonPropertyName("company")]
+ public string? Company { get; set; }
+
+ /// <summary>
+ /// Gets or sets the email.
+ /// </summary>
+ [JsonPropertyName("email")]
+ public string? Email { get; set; }
+
+ /// <summary>
+ /// Gets or sets the phone number.
+ /// </summary>
+ [JsonPropertyName("phone")]
+ public string? Phone { get; set; }
+
+ /// <summary>
+ /// Gets or sets the SSN.
+ /// </summary>
+ [JsonPropertyName("ssn")]
+ public string? Ssn { get; set; }
+
+ /// <summary>
+ /// Gets or sets the username.
+ /// </summary>
+ [JsonPropertyName("username")]
+ public string? Username { get; set; }
+
+ /// <summary>
+ /// Gets or sets the passport number.
+ /// </summary>
+ [JsonPropertyName("passportNumber")]
+ public string? PassportNumber { get; set; }
+
+ /// <summary>
+ /// Gets or sets the license number.
+ /// </summary>
+ [JsonPropertyName("licenseNumber")]
+ public string? LicenseNumber { get; set; }
+}