Skip to content

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

Add ProtonPass importer (#772)

Leendert de Borst9d2a39731785
diff --git a/src/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceProtonPass.razor b/src/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceProtonPass.razor
new file mode 100644
index 000000000..40e650b76
--- /dev/null
+++ b/src/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceProtonPass.razor
@@ -0,0 +1,21 @@
+@using AliasVault.ImportExport.Models
+@using AliasVault.ImportExport.Importers
+@inject NavigationManager NavigationManager
+@inject GlobalNotificationService GlobalNotificationService
+@inject ILogger<ImportServiceProtonPass> Logger
+
+<ImportServiceCard
+ ServiceName="Proton Pass"
+ Description="Import passwords from Proton Pass"
+ LogoUrl="img/importers/protonpass.svg"
+ ProcessFileCallback="ProcessFile">
+ <p class="text-gray-700 dark:text-gray-300 mb-4">In order to import your Proton Pass passwords, you need to export it as a CSV file. You can do this by logging into Proton Pass (web), clicking on the 'Settings' menu > 'Export' > 'File format: CSV'. Then click on 'Export'.</p>
+ <p class="text-gray-700 dark:text-gray-300 mb-4">Once you have exported the file, you can upload it below.</p>
+</ImportServiceCard>
+
+@code {
+ private static async Task<List<ImportedCredential>> ProcessFile(string fileContents)
+ {
+ return await ProtonPassImporter.ImportFromCsvAsync(fileContents);
+ }
+}
diff --git a/src/AliasVault.Client/Main/Pages/Settings/ImportExport/ImportExport.razor b/src/AliasVault.Client/Main/Pages/Settings/ImportExport/ImportExport.razor
index 166e8ace8..d81bf2ef1 100644
--- a/src/AliasVault.Client/Main/Pages/Settings/ImportExport/ImportExport.razor
+++ b/src/AliasVault.Client/Main/Pages/Settings/ImportExport/ImportExport.razor
@@ -27,6 +27,7 @@
<ImportServiceFirefox />
<ImportServiceKeePass />
<ImportServiceKeePassXC />
+ <ImportServiceProtonPass />
<ImportServiceStrongbox />
<ImportServiceAliasVault />
</div>
diff --git a/src/AliasVault.Client/wwwroot/img/importers/protonpass.svg b/src/AliasVault.Client/wwwroot/img/importers/protonpass.svg
new file mode 100644
index 000000000..214cb3869
--- /dev/null
+++ b/src/AliasVault.Client/wwwroot/img/importers/protonpass.svg
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 27.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<svg version="1.1" id="Слой_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ width="500px" height="500px" viewBox="0 0 500 500" style="enable-background:new 0 0 500 500;" xml:space="preserve">
+<style type="text/css">
+ .st0{clip-path:url(#SVGID_00000160880367675937928300000013114190071515040655_);}
+ .st1{fill:url(#SVGID_00000158020781677298841590000014386279406831169436_);}
+ .st2{fill:url(#SVGID_00000038389245457700614160000015930090567954731184_);}
+ .st3{fill:url(#SVGID_00000074402669088272121800000007567021010918974869_);}
+</style>
+<g>
+ <defs>
+ <rect id="SVGID_1_" width="500" height="500"/>
+ </defs>
+ <clipPath id="SVGID_00000097476224578929584770000017210037084984045718_">
+ <use xlink:href="#SVGID_1_" style="overflow:visible;"/>
+ </clipPath>
+ <g style="clip-path:url(#SVGID_00000097476224578929584770000017210037084984045718_);">
+
+ <radialGradient id="SVGID_00000047755579261974386440000006872451468367864226_" cx="148.4036" cy="350.2411" r="4.717" gradientTransform="matrix(46.7033 -75.1155 -117.4926 -73.0513 34370.6797 37242.4727)" gradientUnits="userSpaceOnUse">
+ <stop offset="0" style="stop-color:#FFD580"/>
+ <stop offset="9.375000e-02" style="stop-color:#F6C592"/>
+ <stop offset="0.205" style="stop-color:#EBB6A2"/>
+ <stop offset="0.3245" style="stop-color:#DFA5AF"/>
+ <stop offset="0.4288" style="stop-color:#D397BE"/>
+ <stop offset="0.5337" style="stop-color:#C486CB"/>
+ <stop offset="0.6488" style="stop-color:#B578D9"/>
+ <stop offset="0.7713" style="stop-color:#A166E5"/>
+ <stop offset="0.8913" style="stop-color:#8B57F2"/>
+ <stop offset="1" style="stop-color:#704CFF"/>
+ </radialGradient>
+ <path style="fill:url(#SVGID_00000047755579261974386440000006872451468367864226_);" d="M150.4,63.1
+ c34.9-34.9,52.3-52.3,72.4-58.8c17.7-5.7,36.7-5.7,54.4,0c20.1,6.5,37.5,24,72.4,58.8l87.2,87.1c34.9,34.9,52.3,52.3,58.9,72.4
+ c5.8,17.7,5.8,36.7,0,54.4c-6.5,20.1-24,37.5-58.9,72.4l-87.2,87.1c-34.9,34.9-52.3,52.3-72.4,58.8c-17.7,5.7-36.7,5.7-54.4,0
+ c-20.1-6.5-37.5-24-72.4-58.8L134,418.2c-9.9-11.1-14.9-16.7-18.4-23c-3.1-5.6-5.4-11.6-6.8-17.9c-1.6-7.1-1.6-14.5-1.6-29.4
+ V151.8c0-14.9,0-22.3,1.6-29.4c1.4-6.3,3.7-12.3,6.8-17.9c3.5-6.3,8.5-11.9,18.4-23L150.4,63.1z"/>
+
+ <linearGradient id="SVGID_00000017511077749203986220000003166735930388103090_" gradientUnits="userSpaceOnUse" x1="234.6024" y1="617.7536" x2="331.7387" y2="24.506" gradientTransform="matrix(1 0 0 -1 0 502)">
+ <stop offset="0" style="stop-color:#6D4AFF"/>
+ <stop offset="0.392" style="stop-color:#B39FFB;stop-opacity:0.978"/>
+ <stop offset="1" style="stop-color:#FFE8DB;stop-opacity:0.8"/>
+ </linearGradient>
+ <path style="fill:url(#SVGID_00000017511077749203986220000003166735930388103090_);" d="M150.4,63.1
+ c34.9-34.9,52.3-52.3,72.4-58.8c17.7-5.7,36.7-5.7,54.4,0c20.1,6.5,37.5,24,72.4,58.8l87.2,87.1c34.9,34.9,52.3,52.3,58.9,72.4
+ c5.8,17.7,5.8,36.7,0,54.4c-6.5,20.1-24,37.5-58.9,72.4l-87.2,87.1c-34.9,34.9-52.3,52.3-72.4,58.8c-17.7,5.7-36.7,5.7-54.4,0
+ c-20.1-6.5-37.5-24-72.4-58.8L134,418.2c-9.9-11.1-14.9-16.7-18.4-23c-3.1-5.6-5.4-11.6-6.8-17.9c-1.6-7.1-1.6-14.5-1.6-29.4
+ V151.8c0-14.9,0-22.3,1.6-29.4c1.4-6.3,3.7-12.3,6.8-17.9c3.5-6.3,8.5-11.9,18.4-23L150.4,63.1z"/>
+
+ <radialGradient id="SVGID_00000089555210451034675070000005649055941905357209_" cx="148.0355" cy="350.4669" r="4.717" gradientTransform="matrix(37.5657 -60.419 -94.5046 -58.7585 27673.916 29995.748)" gradientUnits="userSpaceOnUse">
+ <stop offset="0" style="stop-color:#FFD580"/>
+ <stop offset="9.375000e-02" style="stop-color:#F6C592"/>
+ <stop offset="0.205" style="stop-color:#EBB6A2"/>
+ <stop offset="0.3245" style="stop-color:#DFA5AF"/>
+ <stop offset="0.4288" style="stop-color:#D397BE"/>
+ <stop offset="0.5337" style="stop-color:#C486CB"/>
+ <stop offset="0.6488" style="stop-color:#B578D9"/>
+ <stop offset="0.7713" style="stop-color:#A166E5"/>
+ <stop offset="0.8913" style="stop-color:#8B57F2"/>
+ <stop offset="1" style="stop-color:#704CFF"/>
+ </radialGradient>
+ <path style="fill:url(#SVGID_00000089555210451034675070000005649055941905357209_);" d="M144.1,69.4
+ c17.4-17.4,26.2-26.1,36.2-29.4c8.8-2.9,18.4-2.9,27.2,0c10.1,3.3,18.8,12,36.2,29.4l130.8,130.7c17.4,17.4,26.2,26.1,29.4,36.2
+ c2.9,8.8,2.9,18.4,0,27.2c-3.3,10.1-12,18.8-29.4,36.2L243.8,430.4c-17.4,17.4-26.2,26.1-36.2,29.4c-8.8,2.9-18.4,2.9-27.2,0
+ c-10.1-3.3-18.8-12-36.2-29.4l-81-80.9c-34.9-34.9-52.3-52.3-58.9-72.4c-5.7-17.7-5.7-36.7,0-54.4c6.5-20.1,24-37.5,58.9-72.4
+ L144.1,69.4z"/>
+ </g>
+</g>
+</svg>
diff --git a/src/Tests/AliasVault.UnitTests/AliasVault.UnitTests.csproj b/src/Tests/AliasVault.UnitTests/AliasVault.UnitTests.csproj
index be668c41b..efd702f83 100644
--- a/src/Tests/AliasVault.UnitTests/AliasVault.UnitTests.csproj
+++ b/src/Tests/AliasVault.UnitTests/AliasVault.UnitTests.csproj
@@ -68,6 +68,7 @@
<EmbeddedResource Include="TestData\Exports\keepass.csv" />
<EmbeddedResource Include="TestData\Exports\keepassxc.csv" />
<EmbeddedResource Include="TestData\Exports\1password_8.csv" />
+ <EmbeddedResource Include="TestData\Exports\protonpass.csv" />
</ItemGroup>
</Project>
diff --git a/src/Tests/AliasVault.UnitTests/TestData/Exports/protonpass.csv b/src/Tests/AliasVault.UnitTests/TestData/Exports/protonpass.csv
new file mode 100644
index 000000000..acc632dfd
--- /dev/null
+++ b/src/Tests/AliasVault.UnitTests/TestData/Exports/protonpass.csv
@@ -0,0 +1,5 @@
+type,name,url,email,username,password,note,totp,createTime,modifyTime,vault
+login,Test proton 1,https://www.website.com/,,user1,pass1,,otpauth://totp/Strongbox?secret=PLW4SB3PQ7MKVXY2MXF4NEXS6Y&algorithm=SHA1&digits=6&period=30,1744362003,1744362003,Personal
+alias,Test alias,,[email protected],,,,,1744362031,1744362052,Personal
+login,Test proton2,,,testuser2,testpassword2,,,1744362088,1744362088,Personal
+login,testwithoutpass,,,testuser,,,,1744362100,1744362110,Personal
\ No newline at end of file
diff --git a/src/Tests/AliasVault.UnitTests/Utilities/ImportExportTests.cs b/src/Tests/AliasVault.UnitTests/Utilities/ImportExportTests.cs
index 412dbc760..59c72c9fc 100644
--- a/src/Tests/AliasVault.UnitTests/Utilities/ImportExportTests.cs
+++ b/src/Tests/AliasVault.UnitTests/Utilities/ImportExportTests.cs
@@ -355,4 +355,55 @@ public class ImportExportTests
Assert.That(sampleEntry2.TwoFactorSecret, Is.Empty);
});
}
+
+ /// <summary>
+ /// Test case for importing credentials from ProtonPass CSV and ensuring all values are present.
+ /// </summary>
+ /// <returns>Async task.</returns>
+ [Test]
+ public async Task ImportCredentialsFromProtonPassCsv()
+ {
+ // Arrange
+ var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.protonpass.csv");
+
+ // Act
+ var importedCredentials = await ProtonPassImporter.ImportFromCsvAsync(fileContent);
+
+ // Assert
+ Assert.That(importedCredentials, Has.Count.EqualTo(4));
+
+ // Test specific entries
+ var testProton1Credential = importedCredentials.First(c => c.ServiceName == "Test proton 1");
+ Assert.Multiple(() =>
+ {
+ Assert.That(testProton1Credential.ServiceName, Is.EqualTo("Test proton 1"));
+ Assert.That(testProton1Credential.ServiceUrl, Is.EqualTo("https://www.website.com/"));
+ Assert.That(testProton1Credential.Username, Is.EqualTo("user1"));
+ Assert.That(testProton1Credential.Password, Is.EqualTo("pass1"));
+ Assert.That(testProton1Credential.TwoFactorSecret, Is.EqualTo("otpauth://totp/Strongbox?secret=PLW4SB3PQ7MKVXY2MXF4NEXS6Y&algorithm=SHA1&digits=6&period=30"));
+ });
+
+ var testProton2Credential = importedCredentials.First(c => c.ServiceName == "Test proton2");
+ Assert.Multiple(() =>
+ {
+ Assert.That(testProton2Credential.ServiceName, Is.EqualTo("Test proton2"));
+ Assert.That(testProton2Credential.Username, Is.EqualTo("testuser2"));
+ Assert.That(testProton2Credential.Password, Is.EqualTo("testpassword2"));
+ });
+
+ var testWithoutPassCredential = importedCredentials.First(c => c.ServiceName == "testwithoutpass");
+ Assert.Multiple(() =>
+ {
+ Assert.That(testWithoutPassCredential.ServiceName, Is.EqualTo("testwithoutpass"));
+ Assert.That(testWithoutPassCredential.Username, Is.EqualTo("testuser"));
+ Assert.That(testWithoutPassCredential.Password, Is.Empty);
+ });
+
+ var testWithEmailCredential = importedCredentials.First(c => c.ServiceName == "Test alias");
+ Assert.Multiple(() =>
+ {
+ Assert.That(testWithEmailCredential.ServiceName, Is.EqualTo("Test alias"));
+ Assert.That(testWithEmailCredential.Email, Is.EqualTo("[email protected]"));
+ });
+ }
}
diff --git a/src/Utilities/AliasVault.ImportExport/Importers/ProtonPassImporter.cs b/src/Utilities/AliasVault.ImportExport/Importers/ProtonPassImporter.cs
new file mode 100644
index 000000000..b831e36d4
--- /dev/null
+++ b/src/Utilities/AliasVault.ImportExport/Importers/ProtonPassImporter.cs
@@ -0,0 +1,55 @@
+//-----------------------------------------------------------------------
+// <copyright file="ProtonPassImporter.cs" company="lanedirt">
+// Copyright (c) lanedirt. All rights reserved.
+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasVault.ImportExport.Importers;
+
+using AliasVault.ImportExport.Models;
+using AliasVault.ImportExport.Models.Imports;
+using CsvHelper;
+using CsvHelper.Configuration;
+using System.Globalization;
+
+/// <summary>
+/// Imports credentials from ProtonPass.
+/// </summary>
+public static class ProtonPassImporter
+{
+ /// <summary>
+ /// Imports ProtonPass CSV file and converts contents to list of ImportedCredential model objects.
+ /// </summary>
+ /// <param name="fileContent">The content of the CSV file.</param>
+ /// <returns>The imported list of ImportedCredential objects.</returns>
+ public static async Task<List<ImportedCredential>> ImportFromCsvAsync(string fileContent)
+ {
+ using var reader = new StringReader(fileContent);
+ using var csv = new CsvReader(reader, new CsvConfiguration(CultureInfo.InvariantCulture));
+
+ var credentials = new List<ImportedCredential>();
+ await foreach (var record in csv.GetRecordsAsync<ProtonPassCsvRecord>())
+ {
+ var credential = new ImportedCredential
+ {
+ ServiceName = record.Name,
+ ServiceUrl = record.Url,
+ Email = record.Email,
+ Username = record.Username,
+ Password = record.Password,
+ Notes = record.Note,
+ TwoFactorSecret = record.Totp,
+ };
+
+ credentials.Add(credential);
+ }
+
+ if (credentials.Count == 0)
+ {
+ throw new InvalidOperationException("No records found in the CSV file.");
+ }
+
+ return credentials;
+ }
+}
diff --git a/src/Utilities/AliasVault.ImportExport/Models/Imports/ProtonPassCsvRecord.cs b/src/Utilities/AliasVault.ImportExport/Models/Imports/ProtonPassCsvRecord.cs
new file mode 100644
index 000000000..961a683af
--- /dev/null
+++ b/src/Utilities/AliasVault.ImportExport/Models/Imports/ProtonPassCsvRecord.cs
@@ -0,0 +1,82 @@
+//-----------------------------------------------------------------------
+// <copyright file="ProtonPassCsvRecord.cs" company="lanedirt">
+// Copyright (c) lanedirt. All rights reserved.
+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasVault.ImportExport.Models.Imports;
+
+using CsvHelper.Configuration.Attributes;
+
+/// <summary>
+/// Represents a ProtonPass CSV record that is being imported from a ProtonPass CSV export file.
+/// </summary>
+public class ProtonPassCsvRecord
+{
+ /// <summary>
+ /// Gets or sets the type of the item (e.g., login, alias).
+ /// </summary>
+ [Name("type")]
+ public string Type { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the name of the item.
+ /// </summary>
+ [Name("name")]
+ public string Name { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the URL of the item.
+ /// </summary>
+ [Name("url")]
+ public string Url { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the email of the item.
+ /// </summary>
+ [Name("email")]
+ public string Email { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the username of the item.
+ /// </summary>
+ [Name("username")]
+ public string Username { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the password of the item.
+ /// </summary>
+ [Name("password")]
+ public string Password { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets any additional notes.
+ /// </summary>
+ [Name("note")]
+ public string? Note { get; set; }
+
+ /// <summary>
+ /// Gets or sets the TOTP (Time-based One-Time Password) URI.
+ /// </summary>
+ [Name("totp")]
+ public string? Totp { get; set; }
+
+ /// <summary>
+ /// Gets or sets the creation time of the item.
+ /// </summary>
+ [Name("createTime")]
+ public string CreateTime { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the modification time of the item.
+ /// </summary>
+ [Name("modifyTime")]
+ public string ModifyTime { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the vault name where the item is stored.
+ /// </summary>
+ [Name("vault")]
+ public string Vault { get; set; } = string.Empty;
+}