Skip to content

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

Remove .NET ImportExport project and related unittests (#2439)

Leendert de Borstcf8bc39d8924
diff --git a/apps/mobile-app/android/fdroid/net.aliasvault.app.yml.template b/apps/mobile-app/android/fdroid/net.aliasvault.app.yml.template
index 29dc10e49..774a2eff9 100644
--- a/apps/mobile-app/android/fdroid/net.aliasvault.app.yml.template
+++ b/apps/mobile-app/android/fdroid/net.aliasvault.app.yml.template
@@ -48,7 +48,6 @@ Builds:
- apps/mobile-app/node_modules/react-native-svg/android/build.gradle
scandelete:
- apps/mobile-app/node_modules/
- - apps/server/Tests/AliasVault.UnitTests/TestData/Exports/
build:
- cd ../..
- $$rustup$$/rustup-init.sh -y --default-toolchain stable -t aarch64-linux-android
diff --git a/apps/server/Tests/AliasVault.UnitTests/AliasVault.UnitTests.csproj b/apps/server/Tests/AliasVault.UnitTests/AliasVault.UnitTests.csproj
index 7e0818db0..07f814ab5 100644
--- a/apps/server/Tests/AliasVault.UnitTests/AliasVault.UnitTests.csproj
+++ b/apps/server/Tests/AliasVault.UnitTests/AliasVault.UnitTests.csproj
@@ -55,32 +55,8 @@
<ProjectReference Include="..\..\Databases\AliasServerDb\AliasServerDb.csproj" />
<ProjectReference Include="..\..\Utilities\Cryptography\AliasVault.Cryptography.Client\AliasVault.Cryptography.Client.csproj" />
<ProjectReference Include="..\..\Utilities\Cryptography\AliasVault.Cryptography.Server\AliasVault.Cryptography.Server.csproj" />
- <ProjectReference Include="..\..\Utilities\AliasVault.ImportExport\AliasVault.ImportExport.csproj" />
<ProjectReference Include="..\..\Utilities\AliasVault.FaviconExtractor\AliasVault.FaviconExtractor.csproj" />
<ProjectReference Include="..\..\Utilities\AliasVault.TotpGenerator\AliasVault.TotpGenerator.csproj" />
</ItemGroup>
- <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" />
- <EmbeddedResource Include="TestData\Exports\firefox.csv" />
- <EmbeddedResource Include="TestData\Exports\strongbox.csv" />
- <EmbeddedResource Include="TestData\Exports\keepass.csv" />
- <EmbeddedResource Include="TestData\Exports\keepass_special_chars.csv" />
- <EmbeddedResource Include="TestData\Exports\keepassxc.csv" />
- <EmbeddedResource Include="TestData\Exports\1password_8.csv" />
- <EmbeddedResource Include="TestData\Exports\1password_8.1pux" />
- <EmbeddedResource Include="TestData\Exports\protonpass.csv" />
- <EmbeddedResource Include="TestData\Exports\protonpass.zip" />
- <EmbeddedResource Include="TestData\Exports\lastpass.csv" />
- <EmbeddedResource Include="TestData\Exports\nordpass.csv" />
- <EmbeddedResource Include="TestData\Exports\aliasvault_mobile_app_export.csv" />
- <EmbeddedResource Include="TestData\Exports\roboform.csv" />
- <EmbeddedResource Include="TestData\Exports\edge.csv" />
- <EmbeddedResource Include="TestData\Exports\enpass.csv" />
- </ItemGroup>
-
</Project>
diff --git a/apps/server/Tests/AliasVault.UnitTests/Common/ResourceReaderUtility.cs b/apps/server/Tests/AliasVault.UnitTests/Common/ResourceReaderUtility.cs
deleted file mode 100644
index 34d79c2e2..000000000
--- a/apps/server/Tests/AliasVault.UnitTests/Common/ResourceReaderUtility.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="ResourceReaderUtility.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.UnitTests.Common;
-
-using System.IO;
-using System.Reflection;
-using System.Threading.Tasks;
-
-/// <summary>
-/// Utility for reading strings from project embedded resources used in tests.
-/// </summary>
-public static class ResourceReaderUtility
-{
- /// <summary>
- /// Reads string from embedded resource.
- /// </summary>
- /// <param name="resourceName">Name of the embedded resource.</param>
- /// <returns>Contents of embedded resource as string.</returns>
- /// <exception cref="InvalidOperationException">Thrown when resource is not found with that name.</exception>
- public static async Task<string> ReadEmbeddedResourceStringAsync(string resourceName)
- {
- var assembly = Assembly.GetExecutingAssembly();
-
- using var stream = assembly.GetManifestResourceStream(resourceName);
- if (stream == null)
- {
- throw new InvalidOperationException($"Resource {resourceName} not found in {assembly.FullName}");
- }
-
- using var reader = new StreamReader(stream);
- return await reader.ReadToEndAsync();
- }
-
- /// <summary>
- /// Reads byte array from embedded resource.
- /// </summary>
- /// <param name="resourceName">Name of the embedded resource.</param>
- /// <returns>Contents of embedded resource as byte array.</returns>
- /// <exception cref="InvalidOperationException">Thrown when resource is not found with that name.</exception>
- public static async Task<byte[]> ReadEmbeddedResourceBytesAsync(string resourceName)
- {
- var assembly = Assembly.GetExecutingAssembly();
-
- using var stream = assembly.GetManifestResourceStream(resourceName);
- if (stream == null)
- {
- throw new InvalidOperationException($"Resource {resourceName} not found in {assembly.FullName}");
- }
-
- using var memoryStream = new MemoryStream();
- await stream.CopyToAsync(memoryStream);
- return memoryStream.ToArray();
- }
-
- /// <summary>
- /// Get all embedded resource names in current assembly.
- /// </summary>
- /// <returns>Array of resource names.</returns>
- public static string[] GetEmbeddedResourceNames()
- {
- return Assembly.GetExecutingAssembly().GetManifestResourceNames();
- }
-}
diff --git a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/1password_8.1pux b/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/1password_8.1pux
deleted file mode 100644
index fd4cf485e..000000000
Binary files a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/1password_8.1pux and /dev/null differ
diff --git a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/1password_8.csv b/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/1password_8.csv
deleted file mode 100644
index 4fc7a3979..000000000
--- a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/1password_8.csv
+++ /dev/null
@@ -1,5 +0,0 @@
-Title,Url,Username,Password,OTPAuth,Favorite,Archived,Tags,Notes
-Test record 2 with 2FA,,username2fa,password2fa,otpauth://totp/Strongbox?secret=PLW4SB3PQ7MKVXY2MXF4NEXS6Y&period=30&algorithm=SHA1&digits=6,false,false,,Notes about 2FA record
-1Password Account (dpatel),https://my.1password.com,[email protected],passwordexample,,false,false,Starter Kit,You can use this login to sign in to your account on 1password.com.
-Test record 1,https://nu.nl,username1,password1,,false,false,,
-Password entry,,passwordusername,passwordpassword,,false,false,,
diff --git a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/aliasvault_mobile_app_export.csv b/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/aliasvault_mobile_app_export.csv
deleted file mode 100644
index 11d8e8c4c..000000000
--- a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/aliasvault_mobile_app_export.csv
+++ /dev/null
@@ -1,4 +0,0 @@
-ServiceName,FolderPath,ServiceUrl,Username,CurrentPassword,AliasEmail,TwoFactorSecret,AliasGender,AliasFirstName,AliasLastName,AliasNickName,AliasBirthDate,Notes,CreatedAt,UpdatedAt
-credential3,,,username3,,,test,,,,,,without password,09/12/2025 17:28:39,09/12/2025 17:28:39
-service2,,https://service2.com,username2,password2,[email protected],,gender2,firstname2,lastname2,nickname2,,,09/12/2025 17:28:39,09/12/2025 17:28:39
-service1,,,username1,password1,[email protected],,gender1,firstname1,lastname1,nickname1,01/01/1970 00:00:00,notes1,09/12/2025 17:28:39,09/12/2025 17:28:39
diff --git a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/bitwarden.csv b/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/bitwarden.csv
deleted file mode 100644
index 516d81254..000000000
--- a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/bitwarden.csv
+++ /dev/null
@@ -1,13 +0,0 @@
-folder,favorite,type,name,notes,fields,reprompt,login_uri,login_username,login_password,login_totp
-Business,,login,Item for business folder,,,0,,crisply,4CSp43uhSZri8A,
-,,login,Test,,,0,,,,
-,,login,Test,,,0,,test2,asdasd,
-Business,,login,TutaNota,,,0,,[email protected],blabla,otpauth://totp/Strongbox?secret=PLW4SB3PQ7MKVXY2MXF4NEXS6Y&algorithm=SHA1&digits=6&period=30
-Business,,login,Aliasvault.com,,,0,https://www.aliasvault.com,root,toor,
-Business,,login,TutaNota3,,,0,"https://www.aliasvault.com,https://app.aliasvault.com,https://downloads.aliasvault.com",[email protected],blabla,otpauth://totp/Test%20name%3Atest%40test.org?secret=PLW4SB3PQ7MKVXY2MXF4NEXS6Y&issuer=Alias%20Vault
-Business,,login,TutaNota4,,,0,,[email protected],blabla,otpauth://totp/[email protected]?secret=TEST!INVALID&issuer=Alias%20Vault&algorithm=SHA1&digits=6&period=30
-Business,,login,TutaNota5,,,0,,[email protected],blabla,incorrectstring
-Work/Projects,,login,ProjectItem,,,0,https://project.example.com,projectuser,projectpass,
-Work/Projects/Active,,login,ActiveProjectItem,,,0,https://active.example.com,activeuser,activepass,
-Personal/Finance/Banking,,login,BankAccount,,,0,https://bank.example.com,bankuser,bankpass,
-Personal/Finance/Banking/Savings,,login,SavingsAccount,,,0,https://savings.example.com,savingsuser,savingspass,
diff --git a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/bitwarden.zip b/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/bitwarden.zip
deleted file mode 100644
index 780b140b0..000000000
Binary files a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/bitwarden.zip and /dev/null differ
diff --git a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/chrome.csv b/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/chrome.csv
deleted file mode 100644
index 8f9c4672e..000000000
--- a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/chrome.csv
+++ /dev/null
@@ -1,4 +0,0 @@
-name,url,username,password,note
-example.com,https://example.com/,usernamegoogle,passwordgoogle,Note for example password from Google
-facebook.com,https://facebook.com/,facebookuser,facebookpass,Facebook comment
-youtube.com,https://youtube.com/,youtubeusername,youtubepassword,
diff --git a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/dashlane.csv b/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/dashlane.csv
deleted file mode 100644
index 157518a15..000000000
--- a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/dashlane.csv
+++ /dev/null
@@ -1,4 +0,0 @@
-username,username2,username3,title,password,note,url,category,otpUrl
-Test username,,,Test,password123,,https://Test,,
-googleuser,,,Google,googlepassword,,https://www.google.com,,
-testusername,testusernamealternative,,Local,testpassword,testnote,https://www.testwebsite.local,,
\ No newline at end of file
diff --git a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/dropbox.csv b/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/dropbox.csv
deleted file mode 100644
index 867310ae5..000000000
--- a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/dropbox.csv
+++ /dev/null
@@ -1,6 +0,0 @@
-Name,URL,Username,Password,Notes
-Gmail,https://gmail.com,[email protected],gmailpass123,Important email account
-Facebook,https://facebook.com,fbuser,fbpass456,Social media account
-GitHub,https://github.com,devuser,devpass789,Development platform
-Secure Note,,,,Important information stored securely
-Test Site,https://test.example.com,testlogin,testpassword,Test notes for example site
diff --git a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/edge.csv b/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/edge.csv
deleted file mode 100644
index 03512a534..000000000
--- a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/edge.csv
+++ /dev/null
@@ -1,5 +0,0 @@
-name,url,username,password,note
-example.app.tld,https://example.app.tld/,exampleu,examplep,
-example.com,https://example.com/,Username,password,
-google.nl,https://google.nl/,myuser,mypass,Google note here microsoft edge
-youtube.com,https://youtube.com/,youtubeuser,ytpassword,Youtubenotes
diff --git a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/enpass.csv b/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/enpass.csv
deleted file mode 100644
index 2c5a1b14c..000000000
--- a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/enpass.csv
+++ /dev/null
@@ -1,5 +0,0 @@
-"Credit Card","Cardholder","ccholder","Type","cctype","Number","1234123412341234","*CVC","1234","*PIN","1234","Expiry date","12/28","INTERNET BANKING","","Username","","*Login password","","*Transaction password","","Website","","ADDITIONAL DETAILS","","Issuing bank","Issuingbank","Issued on","01/20","Valid from","01/20","Credit limit","5000","Withdrawal limit","5000","Interest rate","10","If lost, call",""
-"Google","Username","usergoogle","E-mail","[email protected]","*Password","password","Website","https://accounts.google.com/","ADDITIONAL DETAILS","","Phone number","003112345678","One-time code","PLW4SB3PQ7MKVXY2MXF4NEXS6Y","Security question","secquestion","*Security answer","secanswer","Secnotes here"
-"Identity","Initial","J","First name","John","Middle name","middle","Last name","Johnson","Gender","Male","Birth date","01-01-1970","Social Security Number","123123123","HOME ADDRESS","","Street","Street","City","City","State","State","Country","Country","ZIP","ZIP","CONTACT DETAILS","","Phone number","003112345678","Phone home","","Phone work","","WORK DETAILS","","Occupation","Occupation","Company","Company","Department","Department","Job title","Job title","Organization","Organization","WORK ADDRESS","","Street","","City","","State","","Country","","ZIP","","SOCIAL","","Twitter","","Facebook","","LinkedIn","","Skype","","Instagram","","Yahoo","","MSN","","ICQ","","AIM","","ADDITIONAL DETAILS","","Website","","Username","","E-mail","","*Password","","Secret question","","*Secret answer","","Signature",""
-"Password","Login","loginpw1","*Password","password","Access","AccessField","CustomField1","Customfield"
-"Securenote","Note only content here"
diff --git a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/firefox.csv b/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/firefox.csv
deleted file mode 100644
index a14add6d7..000000000
--- a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/firefox.csv
+++ /dev/null
@@ -1,4 +0,0 @@
-"url","username","password","httpRealm","formActionOrigin","guid","timeCreated","timeLastUsed","timePasswordChanged"
-"https://example.com","username-example","examplepassword",,"","{2a5df2a4-c75b-4b32-bf7e-8cca012cf82c}","1743265493999","1743265493999","1743265493999"
-"https://youtube.com","youtubeusername","youtubepassword",,"","{40d0b777-551c-4875-98a2-20e486fc4289}","1743265510074","1743265510074","1743265510074"
-"https://www.aliasvault.com","username","password",,"","{73bed185-dd2a-44e1-b0f6-d397cb880300}","1743265527711","1743265527711","1743265527711"
\ No newline at end of file
diff --git a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/keepass.csv b/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/keepass.csv
deleted file mode 100644
index 2038de379..000000000
--- a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/keepass.csv
+++ /dev/null
@@ -1,3 +0,0 @@
-"Account","Login Name","Password","Web Site","Comments"
-"Sample Entry","User Name","Password","https://keepass.info/","Notes"
-"Sample Entry #2","Michael321","12345","https://keepass.info/help/kb/testform.html",""
diff --git a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/keepass_special_chars.csv b/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/keepass_special_chars.csv
deleted file mode 100644
index f4accfea7..000000000
--- a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/keepass_special_chars.csv
+++ /dev/null
@@ -1,4 +0,0 @@
-"Account","Login Name","Password","Web Site","Comments"
-"Sample Entry","User Name","Password","https://keepass.info/","Notes"
-"Sample Entry #2","Michael321","12345","https://keepass.info/help/kb/testform.html",""
-"Entry with \"notes\" special chars","","DVfIsb4TGkL7oKCwyiet","","Note \"with quotes\"'as'd as/d/asd/ z's'sd a8e89A)_@()@'"":ÄS""d';asd;á'sd"
\ No newline at end of file
diff --git a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/keepassxc.csv b/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/keepassxc.csv
deleted file mode 100644
index 84e5a0677..000000000
--- a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/keepassxc.csv
+++ /dev/null
@@ -1,4 +0,0 @@
-"Group","Title","Username","Password","URL","Notes","TOTP","Icon","Last Modified","Created"
-"Test1","Sample Entry","User Name","Password","https://keepass.info/","Notes","","0","2025-03-29T18:29:16Z","2025-03-29T18:29:16Z"
-"Test1","Sample Entry #2","Michael321","12345","https://keepass.info/help/kb/testform.html","","","0","2025-03-29T18:29:16Z","2025-03-29T18:29:16Z"
-"Database/Windows/Windowssub1","Nested Entry","testuser","testpass123","https://example.com/","Nested folder test","","0","2025-03-29T18:29:16Z","2025-03-29T18:29:16Z"
diff --git a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/lastpass.csv b/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/lastpass.csv
deleted file mode 100644
index dcb085f23..000000000
--- a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/lastpass.csv
+++ /dev/null
@@ -1,14 +0,0 @@
-url,username,password,totp,extra,name,grouping,fav
-https://example.com,Exampleusername,examplepassword,,Examplenotes,Examplename,examplefolder,0
-http://,userwithouturlornotes,userpass,,,Userwithouturlornotes,,0
-http://sn,,,,Securenotecontent here,securenote1,,0
-http://,,,,,Emptytitleonly,,0
-http://sn,,,,"NoteType:Credit Card
-Language:en-US
-Name on Card:Cardname
-Type:Creditcard
-Number:123456781234
-Security Code:1234
-Start Date:February,2001
-Expiration Date:May,2008
-Notes:Creditcardnotes here",Paymentcard1,,0
diff --git a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/nordpass.csv b/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/nordpass.csv
deleted file mode 100644
index 621eb04cb..000000000
--- a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/nordpass.csv
+++ /dev/null
@@ -1,8 +0,0 @@
-name,url,additional_urls,username,password,note,cardholdername,cardnumber,cvc,pin,expirydate,zipcode,folder,full_name,phone_number,email,address1,address2,city,country,state,type,custom_fields
-Password title,http://google.nl,,[email protected],password,,,,,,,,Business,,,,,,,,,password,"[{""type"":""text"",""label"":""CustomFieldName1"",""value"":""Test""}]"
-SecureNote1,,,,,"This is my secure note content
-
-Test test",,,,,,,,,,,,,,,,note,
-Creditcard Visa,,,,,,Holdername,1234123412341234123,1231,1231,12/28,1231AB,,,,,,,,,,credit_card,
-Business,,,,,,,,,,,,,,,,,,,,,folder,
-Root item,,,rootuser,rootpass,,,,,,,,,,,,,,,,,password,
diff --git a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/protonpass.csv b/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/protonpass.csv
deleted file mode 100644
index acc632dfd..000000000
--- a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/protonpass.csv
+++ /dev/null
@@ -1,5 +0,0 @@
-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/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/protonpass.zip b/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/protonpass.zip
deleted file mode 100644
index e7f27ffb9..000000000
Binary files a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/protonpass.zip and /dev/null differ
diff --git a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/roboform.csv b/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/roboform.csv
deleted file mode 100644
index 31917bf57..000000000
--- a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/roboform.csv
+++ /dev/null
@@ -1,9 +0,0 @@
-Name,Url,MatchUrl,Login,Pwd,Note,Folder,RfFieldsV2
-Com,https://www.example.com.com,https://www.example.com,username1,password1,,,"User ID$,,,txt,username1","Password$,,,pwd,password1","Test,,,txt,Test"
-Example,https://www.example.com,https://www.example.com,exampleusername,examplepassword,Examplenote,,"User ID$,,,txt,exampleusername","Password$,,,pwd,examplepassword"
-Safenotename,,,,,Safenote content example here,
-Business,https://www.business.com,https://www.business.com,businessusername,businesspassword,,/Business,"User ID$,,,txt,businessusername","Password$,,,pwd,businesspassword"
-Multiline safenote,,,,,"First note line
-Second note line
-
-Fourth note line after a blank one",
diff --git a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/strongbox.csv b/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/strongbox.csv
deleted file mode 100644
index ee327230c..000000000
--- a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/strongbox.csv
+++ /dev/null
@@ -1,10 +0,0 @@
-Title,Username,Email,Password,URL,OTPAuth,Notes
-Sample,username,,&3V_$z?Aiw-_x+nbYj,https://strongboxsafe.com,,
-Business1,username,,NYVqE8MpfnX#r+ukpE,,,
-Business 2,username,,+jeN9dTLy4Ahh-C3fB,,,
-Prive 1,username,,4c*Ksh??7Q_K#xKMLh,,,
-Prive 2,username,,Ld6JsF^JXR7^8_F#Ad,,,
-TutaNota,[email protected],,blabla,,otpauth://totp/Strongbox?secret=PLW4SB3PQ7MKVXY2MXF4NEXS6Y&algorithm=SHA1&digits=6&period=30,"Recovery code for main account: e45f a053 8b7e 127c 302b a816 abc2 739a 9b0c 7393 6adc 123a ff4e 084d 7798 ef26
-
-Recovery code for 2FA:
-e45f a053 8b7e 127c 302b a816 abc2 739a 9b0c 7393 6adc 123a ff4e 084d 7798 ef26"
diff --git a/apps/server/Tests/AliasVault.UnitTests/TestData/README.md b/apps/server/Tests/AliasVault.UnitTests/TestData/README.md
deleted file mode 100644
index 955e78cb9..000000000
--- a/apps/server/Tests/AliasVault.UnitTests/TestData/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
-This folder contains test data for the AliasVault.UnitTests project.
-The build action of these is set to "Embedded resource" so that they can be accessed by the tests
-using the `ResourceReaderUtility` class.
-
-Index:
-- `Exports` Folder that contains export samples from other password managers to be used in import tests.
diff --git a/apps/server/Tests/AliasVault.UnitTests/Utilities/ImportExportTests.cs b/apps/server/Tests/AliasVault.UnitTests/Utilities/ImportExportTests.cs
deleted file mode 100644
index 2e7592881..000000000
--- a/apps/server/Tests/AliasVault.UnitTests/Utilities/ImportExportTests.cs
+++ /dev/null
@@ -1,2905 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="ImportExportTests.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>
-//-----------------------------------------------------------------------
-
-#pragma warning disable SA1202 // Elements should be ordered by access
-
-namespace AliasVault.UnitTests.Utilities;
-
-using System.IO.Compression;
-using System.Text;
-using AliasClientDb;
-using AliasClientDb.Models;
-using AliasVault.ImportExport;
-using AliasVault.ImportExport.Exceptions;
-using AliasVault.ImportExport.Importers;
-using AliasVault.ImportExport.Models;
-using AliasVault.UnitTests.Common;
-
-/// <summary>
-/// Tests for the AliasVault.ImportExport class.
-/// </summary>
-public class ImportExportTests
-{
- /// <summary>
- /// Test case for importing items from CSV and ensuring all values are present.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportItemsFromCsv()
- {
- // Arrange
- var item = new Item
- {
- Id = new Guid("00000000-0000-0000-0000-000000000001"),
- Name = "Test Service",
- ItemType = ItemType.Login,
- CreatedAt = DateTime.Now,
- UpdatedAt = DateTime.Now,
- };
-
- // Add field values
- AddFieldValue(item, FieldKey.LoginUsername, "testuser");
- AddFieldValue(item, FieldKey.NotesContent, "Test notes");
- AddFieldValue(item, FieldKey.LoginUrl, "https://testservice.com");
- AddFieldValue(item, FieldKey.LoginPassword, "password123");
- AddFieldValue(item, FieldKey.LoginEmail, "johndoe");
- AddFieldValue(item, FieldKey.AliasGender, "Male");
- AddFieldValue(item, FieldKey.AliasFirstName, "John");
- AddFieldValue(item, FieldKey.AliasLastName, "Doe");
- AddFieldValue(item, FieldKey.AliasBirthdate, "1990-01-01");
-
- var csvContent = ItemCsvService.ExportItemsToCsv([item]);
- var csvString = System.Text.Encoding.Default.GetString(csvContent);
-
- // Act
- var importedCredentials = await ItemCsvService.ImportItemsFromCsv(csvString);
-
- // Assert
- Assert.That(importedCredentials, Has.Count.EqualTo(1));
-
- var importedCredential = importedCredentials[0];
-
- Assert.Multiple(() =>
- {
- Assert.That(importedCredential.ServiceName, Is.EqualTo(item.Name));
- Assert.That(importedCredential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://testservice.com"));
- Assert.That(importedCredential.Username, Is.EqualTo("testuser"));
- Assert.That(importedCredential.Notes, Is.EqualTo("Test notes"));
- Assert.That(importedCredential.CreatedAt?.Date, Is.EqualTo(item.CreatedAt.Date));
- Assert.That(importedCredential.UpdatedAt?.Date, Is.EqualTo(item.UpdatedAt.Date));
- Assert.That(importedCredential.Alias!.Gender, Is.EqualTo("Male"));
- Assert.That(importedCredential.Alias!.FirstName, Is.EqualTo("John"));
- Assert.That(importedCredential.Alias!.LastName, Is.EqualTo("Doe"));
- Assert.That(importedCredential.Alias!.BirthDate, Is.EqualTo(new DateTime(1990, 1, 1, 0, 0, 0, DateTimeKind.Utc)));
- Assert.That(importedCredential.Alias!.CreatedAt?.Date, Is.EqualTo(item.CreatedAt.Date));
- Assert.That(importedCredential.Alias!.UpdatedAt?.Date, Is.EqualTo(item.UpdatedAt.Date));
- Assert.That(importedCredential.Password, Is.EqualTo("password123"));
- });
- }
-
- /// <summary>
- /// Test case for round-tripping a credit card item through CSV export and import.
- /// Verifies that card-specific columns are populated on export and that the
- /// importer recognizes the item as a credit card.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportCreditCardItemFromCsv()
- {
- // Arrange
- var loginItem = new Item
- {
- Id = new Guid("00000000-0000-0000-0000-000000000001"),
- Name = "Login service",
- ItemType = ItemType.Login,
- CreatedAt = DateTime.Now,
- UpdatedAt = DateTime.Now,
- };
- AddFieldValue(loginItem, FieldKey.LoginUsername, "loginuser");
- AddFieldValue(loginItem, FieldKey.LoginPassword, "loginpass");
-
- var cardItem = new Item
- {
- Id = new Guid("00000000-0000-0000-0000-000000000002"),
- Name = "My Visa",
- ItemType = ItemType.CreditCard,
- CreatedAt = DateTime.Now,
- UpdatedAt = DateTime.Now,
- };
- AddFieldValue(cardItem, FieldKey.CardCardholderName, "John Doe");
- AddFieldValue(cardItem, FieldKey.CardNumber, "4111111111111111");
- AddFieldValue(cardItem, FieldKey.CardExpiryMonth, "12");
- AddFieldValue(cardItem, FieldKey.CardExpiryYear, "2030");
- AddFieldValue(cardItem, FieldKey.CardCvv, "123");
- AddFieldValue(cardItem, FieldKey.CardPin, "9876");
- AddFieldValue(cardItem, FieldKey.NotesContent, "Card notes");
-
- var csvContent = ItemCsvService.ExportItemsToCsv([loginItem, cardItem]);
- var csvString = System.Text.Encoding.Default.GetString(csvContent);
-
- // Assert: header includes the new card columns
- var headerLine = csvString.Split('\n')[0];
- Assert.Multiple(() =>
- {
- Assert.That(headerLine, Does.Contain("CardholderName"));
- Assert.That(headerLine, Does.Contain("CardNumber"));
- Assert.That(headerLine, Does.Contain("CardExpiryMonth"));
- Assert.That(headerLine, Does.Contain("CardExpiryYear"));
- Assert.That(headerLine, Does.Contain("CardCvv"));
- Assert.That(headerLine, Does.Contain("CardPin"));
- });
-
- // Act
- var importedCredentials = await ItemCsvService.ImportItemsFromCsv(csvString);
-
- // Assert
- Assert.That(importedCredentials, Has.Count.EqualTo(2));
-
- var importedLogin = importedCredentials.First(c => c.ServiceName == "Login service");
- Assert.Multiple(() =>
- {
- Assert.That(importedLogin.ItemType, Is.Null, "Login items should not have ItemType set by CSV importer.");
- Assert.That(importedLogin.Creditcard, Is.Null);
- Assert.That(importedLogin.Username, Is.EqualTo("loginuser"));
- });
-
- var importedCard = importedCredentials.First(c => c.ServiceName == "My Visa");
- Assert.Multiple(() =>
- {
- Assert.That(importedCard.ItemType, Is.EqualTo(ImportedItemType.Creditcard));
- Assert.That(importedCard.Creditcard, Is.Not.Null);
- Assert.That(importedCard.Creditcard!.CardholderName, Is.EqualTo("John Doe"));
- Assert.That(importedCard.Creditcard.Number, Is.EqualTo("4111111111111111"));
- Assert.That(importedCard.Creditcard.ExpiryMonth, Is.EqualTo("12"));
- Assert.That(importedCard.Creditcard.ExpiryYear, Is.EqualTo("2030"));
- Assert.That(importedCard.Creditcard.Cvv, Is.EqualTo("123"));
- Assert.That(importedCard.Creditcard.Pin, Is.EqualTo("9876"));
- Assert.That(importedCard.Notes, Is.EqualTo("Card notes"));
- });
- }
-
- /// <summary>
- /// Verifies that CSV files exported by older versions (without credit card columns)
- /// can still be imported successfully.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportLegacyCsvWithoutCreditCardColumns()
- {
- // Arrange: a CSV with the pre-card column set only.
- var legacyCsv =
- "ServiceName,FolderPath,ServiceUrl,Username,CurrentPassword,AliasEmail,TwoFactorSecret,AliasGender,AliasFirstName,AliasLastName,AliasNickName,AliasBirthDate,Notes,CreatedAt,UpdatedAt\n"
- + "Old Service,,https://old.example,olduser,oldpass,,,,,,,,,2024-01-01 00:00:00,2024-01-01 00:00:00\n";
-
- // Act
- var importedCredentials = await ItemCsvService.ImportItemsFromCsv(legacyCsv);
-
- // Assert
- Assert.That(importedCredentials, Has.Count.EqualTo(1));
- var credential = importedCredentials[0];
- Assert.Multiple(() =>
- {
- Assert.That(credential.ServiceName, Is.EqualTo("Old Service"));
- Assert.That(credential.Username, Is.EqualTo("olduser"));
- Assert.That(credential.ItemType, Is.Null);
- Assert.That(credential.Creditcard, Is.Null);
- });
- }
-
- /// <summary>
- /// Test case for importing credentials from Bitwarden CSV and ensuring all values are present.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportCredentialsFromBitwardenCsv()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.bitwarden.csv");
-
- // Act
- var importedCredentials = await BitwardenImporter.ImportFromCsvAsync(fileContent);
-
- // Assert
- Assert.That(importedCredentials, Has.Count.EqualTo(12));
-
- // There is one entry which has an invalid TOTP code ("! in the secret), we ensure this logic does not throw a fatal error.
- var convertedItems = BaseImporter.ConvertToItem(importedCredentials);
-
- // Test specific entries
- var tutaNotaCredential = importedCredentials.First(c => c.ServiceName == "TutaNota");
- Assert.Multiple(() =>
- {
- Assert.That(tutaNotaCredential.ServiceName, Is.EqualTo("TutaNota"));
- Assert.That(tutaNotaCredential.Username, Is.EqualTo("[email protected]"));
- Assert.That(tutaNotaCredential.Password, Is.EqualTo("blabla"));
- Assert.That(tutaNotaCredential.TwoFactorSecret, Is.EqualTo("otpauth://totp/Strongbox?secret=PLW4SB3PQ7MKVXY2MXF4NEXS6Y&algorithm=SHA1&digits=6&period=30"));
- });
-
- var aliasVaultCredential = importedCredentials.First(c => c.ServiceName == "Aliasvault.com");
- Assert.Multiple(() =>
- {
- Assert.That(aliasVaultCredential.ServiceName, Is.EqualTo("Aliasvault.com"));
- Assert.That(aliasVaultCredential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://www.aliasvault.com"));
- Assert.That(aliasVaultCredential.Username, Is.EqualTo("root"));
- Assert.That(aliasVaultCredential.Password, Is.EqualTo("toor"));
- });
-
- // Test entry with multiple URLs (TutaNota3) and URL-encoded TOTP URI
- var multiUrlCredential = importedCredentials.First(c => c.ServiceName == "TutaNota3");
- Assert.Multiple(() =>
- {
- Assert.That(multiUrlCredential.ServiceName, Is.EqualTo("TutaNota3"));
- Assert.That(multiUrlCredential.ServiceUrls, Has.Count.EqualTo(3));
- Assert.That(multiUrlCredential.ServiceUrls![0], Is.EqualTo("https://www.aliasvault.com"));
- Assert.That(multiUrlCredential.ServiceUrls[1], Is.EqualTo("https://app.aliasvault.com"));
- Assert.That(multiUrlCredential.ServiceUrls[2], Is.EqualTo("https://downloads.aliasvault.com"));
- Assert.That(multiUrlCredential.Username, Is.EqualTo("[email protected]"));
- Assert.That(multiUrlCredential.TwoFactorSecret, Is.EqualTo("otpauth://totp/Test%20name%3Atest%40test.org?secret=PLW4SB3PQ7MKVXY2MXF4NEXS6Y&issuer=Alias%20Vault"));
- });
-
- // Verify multiple URLs get converted to multiple FieldValues
- var multiUrlItem = convertedItems.First(i => i.Name == "TutaNota3");
- var urlFieldValues = multiUrlItem.FieldValues.Where(fv => fv.FieldKey == FieldKey.LoginUrl).OrderBy(fv => fv.Weight).ToList();
- Assert.Multiple(() =>
- {
- Assert.That(urlFieldValues, Has.Count.EqualTo(3));
- Assert.That(urlFieldValues[0].Value, Is.EqualTo("https://www.aliasvault.com"));
- Assert.That(urlFieldValues[1].Value, Is.EqualTo("https://app.aliasvault.com"));
- Assert.That(urlFieldValues[2].Value, Is.EqualTo("https://downloads.aliasvault.com"));
- Assert.That(urlFieldValues[0].Weight, Is.EqualTo(0));
- Assert.That(urlFieldValues[1].Weight, Is.EqualTo(1));
- Assert.That(urlFieldValues[2].Weight, Is.EqualTo(2));
- });
-
- // Verify TOTP code name is properly URL-decoded when converting from otpauth URI
- var multiUrlItemTotpCode = multiUrlItem.TotpCodes.FirstOrDefault();
- Assert.That(multiUrlItemTotpCode, Is.Not.Null);
- Assert.Multiple(() =>
- {
- Assert.That(multiUrlItemTotpCode!.SecretKey, Is.EqualTo("PLW4SB3PQ7MKVXY2MXF4NEXS6Y"));
- Assert.That(multiUrlItemTotpCode.Name, Is.EqualTo("Alias Vault: Test name:[email protected]"), "TOTP name should be URL-decoded from the otpauth URI");
- });
-
- // Test multi-depth folder paths
- var workProjectItem = importedCredentials.First(c => c.ServiceName == "ProjectItem");
- Assert.That(workProjectItem.FolderPath, Is.EqualTo("Work/Projects"));
-
- var activeProjectItem = importedCredentials.First(c => c.ServiceName == "ActiveProjectItem");
- Assert.That(activeProjectItem.FolderPath, Is.EqualTo("Work/Projects/Active"));
-
- var bankAccountItem = importedCredentials.First(c => c.ServiceName == "BankAccount");
- Assert.That(bankAccountItem.FolderPath, Is.EqualTo("Personal/Finance/Banking"));
-
- var savingsAccountItem = importedCredentials.First(c => c.ServiceName == "SavingsAccount");
- Assert.That(savingsAccountItem.FolderPath, Is.EqualTo("Personal/Finance/Banking/Savings"));
-
- // Test hierarchical folder path parsing with ParseFolderPath
- var workProjectsActiveParts = BaseImporter.ParseFolderPath("Work/Projects/Active");
- Assert.That(workProjectsActiveParts, Has.Count.EqualTo(3));
- Assert.That(workProjectsActiveParts[0], Is.EqualTo("Work"));
- Assert.That(workProjectsActiveParts[1], Is.EqualTo("Projects"));
- Assert.That(workProjectsActiveParts[2], Is.EqualTo("Active"));
-
- var savingsParts = BaseImporter.ParseFolderPath("Personal/Finance/Banking/Savings");
- Assert.That(savingsParts, Has.Count.EqualTo(4));
- Assert.That(savingsParts[0], Is.EqualTo("Personal"));
- Assert.That(savingsParts[1], Is.EqualTo("Finance"));
- Assert.That(savingsParts[2], Is.EqualTo("Banking"));
- Assert.That(savingsParts[3], Is.EqualTo("Savings"));
- }
-
- /// <summary>
- /// Test case for importing credentials from Strongbox CSV and ensuring all values are present.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportCredentialsFromStrongboxCsv()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.strongbox.csv");
-
- // Act
- var importedCredentials = await StrongboxImporter.ImportFromCsvAsync(fileContent);
-
- // Assert
- Assert.That(importedCredentials, Has.Count.EqualTo(6));
-
- // Test specific entries
- var tutaNotaCredential = importedCredentials.First(c => c.ServiceName == "TutaNota");
- Assert.Multiple(() =>
- {
- Assert.That(tutaNotaCredential.ServiceName, Is.EqualTo("TutaNota"));
- Assert.That(tutaNotaCredential.Username, Is.EqualTo("[email protected]"));
- Assert.That(tutaNotaCredential.Password, Is.EqualTo("blabla"));
- Assert.That(tutaNotaCredential.TwoFactorSecret, Is.EqualTo("otpauth://totp/Strongbox?secret=PLW4SB3PQ7MKVXY2MXF4NEXS6Y&algorithm=SHA1&digits=6&period=30"));
- Assert.That(tutaNotaCredential.Notes, Does.Contain("Recovery code for main account"));
- });
-
- var sampleCredential = importedCredentials.First(c => c.ServiceName == "Sample");
- Assert.Multiple(() =>
- {
- Assert.That(sampleCredential.ServiceName, Is.EqualTo("Sample"));
- Assert.That(sampleCredential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://strongboxsafe.com"));
- Assert.That(sampleCredential.Username, Is.EqualTo("username"));
- Assert.That(sampleCredential.Password, Is.EqualTo("&3V_$z?Aiw-_x+nbYj"));
- });
- }
-
- /// <summary>
- /// Test case for importing credentials from 1Password CSV and ensuring all values are present.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportCredentialsFrom1PasswordCsv()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.1password_8.csv");
-
- // Act
- var importedCredentials = await OnePasswordImporter.ImportFromCsvAsync(fileContent);
-
- // Assert
- Assert.That(importedCredentials, Has.Count.EqualTo(4));
-
- // Test specific entries
- var twoFactorCredential = importedCredentials.First(c => c.Username == "username2fa");
- Assert.Multiple(() =>
- {
- Assert.That(twoFactorCredential.ServiceName, Is.EqualTo("Test record 2 with 2FA"));
- Assert.That(twoFactorCredential.Username, Is.EqualTo("username2fa"));
- Assert.That(twoFactorCredential.Password, Is.EqualTo("password2fa"));
- Assert.That(twoFactorCredential.TwoFactorSecret, Is.EqualTo("otpauth://totp/Strongbox?secret=PLW4SB3PQ7MKVXY2MXF4NEXS6Y&period=30&algorithm=SHA1&digits=6"));
- Assert.That(twoFactorCredential.Notes, Is.EqualTo("Notes about 2FA record"));
- });
-
- var onePasswordAccount = importedCredentials.First(c => c.ServiceName == "1Password Account (dpatel)");
- Assert.Multiple(() =>
- {
- Assert.That(onePasswordAccount.ServiceName, Is.EqualTo("1Password Account (dpatel)"));
- Assert.That(onePasswordAccount.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://my.1password.com"));
- Assert.That(onePasswordAccount.Username, Is.EqualTo("[email protected]"));
- Assert.That(onePasswordAccount.Password, Is.EqualTo("passwordexample"));
- Assert.That(onePasswordAccount.Notes, Is.EqualTo("You can use this login to sign in to your account on 1password.com."));
- });
- }
-
- /// <summary>
- /// Test case for importing credentials from Chrome CSV and ensuring all values are present.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportCredentialsFromChromeCsv()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.chrome.csv");
-
- // Act
- var importedCredentials = await ChromeImporter.ImportFromCsvAsync(fileContent);
-
- // Assert
- Assert.That(importedCredentials, Has.Count.EqualTo(3));
-
- // Test specific entries
- var exampleCredential = importedCredentials.First(c => c.ServiceName == "example.com");
- Assert.Multiple(() =>
- {
- Assert.That(exampleCredential.ServiceName, Is.EqualTo("example.com"));
- Assert.That(exampleCredential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://example.com/"));
- Assert.That(exampleCredential.Username, Is.EqualTo("usernamegoogle"));
- Assert.That(exampleCredential.Password, Is.EqualTo("passwordgoogle"));
- Assert.That(exampleCredential.Notes, Is.EqualTo("Note for example password from Google"));
- });
-
- var facebookCredential = importedCredentials.First(c => c.ServiceName == "facebook.com");
- Assert.Multiple(() =>
- {
- Assert.That(facebookCredential.ServiceName, Is.EqualTo("facebook.com"));
- Assert.That(facebookCredential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://facebook.com/"));
- Assert.That(facebookCredential.Username, Is.EqualTo("facebookuser"));
- Assert.That(facebookCredential.Password, Is.EqualTo("facebookpass"));
- Assert.That(facebookCredential.Notes, Is.EqualTo("Facebook comment"));
- });
- }
-
- /// <summary>
- /// Test case for importing credentials from Firefox CSV and ensuring all values are present.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportCredentialsFromFirefoxCsv()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.firefox.csv");
-
- // Act
- var importedCredentials = await FirefoxImporter.ImportFromCsvAsync(fileContent);
-
- // Assert
- Assert.That(importedCredentials, Has.Count.EqualTo(3));
-
- // Test specific entries
- var exampleCredential = importedCredentials.First(c => c.ServiceName == "example.com");
- Assert.Multiple(() =>
- {
- Assert.That(exampleCredential.ServiceName, Is.EqualTo("example.com"));
- Assert.That(exampleCredential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://example.com"));
- Assert.That(exampleCredential.Username, Is.EqualTo("username-example"));
- Assert.That(exampleCredential.Password, Is.EqualTo("examplepassword"));
- });
-
- var youtubeCredential = importedCredentials.First(c => c.ServiceName == "youtube.com");
- Assert.Multiple(() =>
- {
- Assert.That(youtubeCredential.ServiceName, Is.EqualTo("youtube.com"));
- Assert.That(youtubeCredential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://youtube.com"));
- Assert.That(youtubeCredential.Username, Is.EqualTo("youtubeusername"));
- Assert.That(youtubeCredential.Password, Is.EqualTo("youtubepassword"));
- });
- }
-
- /// <summary>
- /// Test case for importing credentials from KeePass CSV and ensuring all values are present.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportCredentialsFromKeePassCsv()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.keepass.csv");
-
- // Act
- var importedCredentials = await KeePassImporter.ImportFromCsvAsync(fileContent);
-
- // Assert
- Assert.That(importedCredentials, Has.Count.EqualTo(2));
-
- // Test specific entries
- var sampleEntry = importedCredentials.First(c => c.ServiceName == "Sample Entry");
- Assert.Multiple(() =>
- {
- Assert.That(sampleEntry.ServiceName, Is.EqualTo("Sample Entry"));
- Assert.That(sampleEntry.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://keepass.info/"));
- Assert.That(sampleEntry.Username, Is.EqualTo("User Name"));
- Assert.That(sampleEntry.Password, Is.EqualTo("Password"));
- Assert.That(sampleEntry.Notes, Is.EqualTo("Notes"));
- });
-
- var sampleEntry2 = importedCredentials.First(c => c.ServiceName == "Sample Entry #2");
- Assert.Multiple(() =>
- {
- Assert.That(sampleEntry2.ServiceName, Is.EqualTo("Sample Entry #2"));
- Assert.That(sampleEntry2.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://keepass.info/help/kb/testform.html"));
- Assert.That(sampleEntry2.Username, Is.EqualTo("Michael321"));
- Assert.That(sampleEntry2.Password, Is.EqualTo("12345"));
- Assert.That(sampleEntry2.Notes, Is.Empty);
- });
- }
-
- /// <summary>
- /// Test case for importing credentials from KeePass CSV with special characters and double quotes.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportCredentialsFromKeePassCsvWithSpecialChars()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.keepass_special_chars.csv");
-
- // Act
- var importedCredentials = await KeePassImporter.ImportFromCsvAsync(fileContent);
-
- // Assert
- Assert.That(importedCredentials, Has.Count.EqualTo(3));
-
- // Test the entry with special characters and double quotes
- var specialEntry = importedCredentials.First(c => c.ServiceName?.StartsWith("Entry with") ?? false);
- Assert.Multiple(() =>
- {
- Assert.That(specialEntry.ServiceName, Is.EqualTo("Entry with \"notes\" special chars"));
- Assert.That(specialEntry.ServiceUrls?.FirstOrDefault(), Is.Null);
- Assert.That(specialEntry.Username, Is.Empty);
- Assert.That(specialEntry.Password, Is.EqualTo("DVfIsb4TGkL7oKCwyiet"));
- Assert.That(specialEntry.Notes, Does.Contain("\"with quotes\""));
- Assert.That(specialEntry.Notes, Does.Contain("as'd as/d/asd/ z"));
- Assert.That(specialEntry.Notes, Does.Contain("asd;á'sd"));
- });
-
- // Test other entries still work correctly
- var sampleEntry = importedCredentials.First(c => c.ServiceName == "Sample Entry");
- Assert.Multiple(() =>
- {
- Assert.That(sampleEntry.ServiceName, Is.EqualTo("Sample Entry"));
- Assert.That(sampleEntry.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://keepass.info/"));
- Assert.That(sampleEntry.Username, Is.EqualTo("User Name"));
- Assert.That(sampleEntry.Password, Is.EqualTo("Password"));
- Assert.That(sampleEntry.Notes, Is.EqualTo("Notes"));
- });
- }
-
- /// <summary>
- /// Test case for importing credentials from KeePassXC CSV and ensuring all values are present.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportCredentialsFromKeePassXcCsv()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.keepassxc.csv");
-
- // Act
- var importedCredentials = await KeePassXcImporter.ImportFromCsvAsync(fileContent);
-
- // Assert
- Assert.That(importedCredentials, Has.Count.EqualTo(3));
-
- // Test specific entries
- var sampleEntry = importedCredentials.First(c => c.ServiceName == "Sample Entry");
- Assert.Multiple(() =>
- {
- Assert.That(sampleEntry.ServiceName, Is.EqualTo("Sample Entry"));
- Assert.That(sampleEntry.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://keepass.info/"));
- Assert.That(sampleEntry.Username, Is.EqualTo("User Name"));
- Assert.That(sampleEntry.Password, Is.EqualTo("Password"));
- Assert.That(sampleEntry.Notes, Is.EqualTo("Notes"));
- Assert.That(sampleEntry.TwoFactorSecret, Is.Empty);
- });
-
- var sampleEntry2 = importedCredentials.First(c => c.ServiceName == "Sample Entry #2");
- Assert.Multiple(() =>
- {
- Assert.That(sampleEntry2.ServiceName, Is.EqualTo("Sample Entry #2"));
- Assert.That(sampleEntry2.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://keepass.info/help/kb/testform.html"));
- Assert.That(sampleEntry2.Username, Is.EqualTo("Michael321"));
- Assert.That(sampleEntry2.Password, Is.EqualTo("12345"));
- Assert.That(sampleEntry2.Notes, Is.Empty);
- Assert.That(sampleEntry2.TwoFactorSecret, Is.Empty);
- });
-
- var nestedEntry = importedCredentials.First(c => c.ServiceName == "Nested Entry");
- Assert.Multiple(() =>
- {
- Assert.That(nestedEntry.ServiceName, Is.EqualTo("Nested Entry"));
- Assert.That(nestedEntry.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://example.com/"));
- Assert.That(nestedEntry.Username, Is.EqualTo("testuser"));
- Assert.That(nestedEntry.Password, Is.EqualTo("testpass123"));
- Assert.That(nestedEntry.Notes, Is.EqualTo("Nested folder test"));
- Assert.That(nestedEntry.FolderPath, Is.EqualTo("Database/Windows/Windowssub1"));
- });
- }
-
- /// <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.ServiceUrls?.FirstOrDefault(), 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]"));
- });
- }
-
- /// <summary>
- /// Test case for importing credentials from Dashlane CSV and ensuring all values are present.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportCredentialsFromDashlaneCsv()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.dashlane.csv");
-
- // Act
- var importedCredentials = await DashlaneImporter.ImportFromCsvAsync(fileContent);
-
- // Assert
- Assert.That(importedCredentials, Has.Count.EqualTo(3));
-
- // Test specific entries
- var testCredential = importedCredentials.First(c => c.ServiceName == "Test");
- Assert.Multiple(() =>
- {
- Assert.That(testCredential.ServiceName, Is.EqualTo("Test"));
- Assert.That(testCredential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://Test"));
- Assert.That(testCredential.Username, Is.EqualTo("Test username"));
- Assert.That(testCredential.Password, Is.EqualTo("password123"));
- Assert.That(testCredential.Notes, Is.Null);
- });
-
- var googleCredential = importedCredentials.First(c => c.ServiceName == "Google");
- Assert.Multiple(() =>
- {
- Assert.That(googleCredential.ServiceName, Is.EqualTo("Google"));
- Assert.That(googleCredential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://www.google.com"));
- Assert.That(googleCredential.Username, Is.EqualTo("googleuser"));
- Assert.That(googleCredential.Password, Is.EqualTo("googlepassword"));
- Assert.That(googleCredential.Notes, Is.Null);
- });
-
- var localCredential = importedCredentials.First(c => c.ServiceName == "Local");
- Assert.Multiple(() =>
- {
- Assert.That(localCredential.ServiceName, Is.EqualTo("Local"));
- Assert.That(localCredential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://www.testwebsite.local"));
- Assert.That(localCredential.Username, Is.EqualTo("testusername"));
- Assert.That(localCredential.Password, Is.EqualTo("testpassword"));
- Assert.That(localCredential.Notes, Is.EqualTo("testnote\nAlternative username 1: testusernamealternative"));
- });
- }
-
- /// <summary>
- /// Test case for importing credentials from LastPass CSV and ensuring all values are present.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportCredentialsFromLastPassCsv()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.lastpass.csv");
-
- // Act
- var importedCredentials = await LastPassImporter.ImportFromCsvAsync(fileContent);
-
- // Assert - Should import 5 records
- Assert.That(importedCredentials, Has.Count.EqualTo(5));
-
- // Test regular login credential
- var exampleCredential = importedCredentials.First(c => c.ServiceName == "Examplename");
- Assert.Multiple(() =>
- {
- Assert.That(exampleCredential.ServiceName, Is.EqualTo("Examplename"));
- Assert.That(exampleCredential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://example.com"));
- Assert.That(exampleCredential.Username, Is.EqualTo("Exampleusername"));
- Assert.That(exampleCredential.Password, Is.EqualTo("examplepassword"));
- Assert.That(exampleCredential.Notes, Is.EqualTo("Examplenotes"));
- Assert.That(exampleCredential.TwoFactorSecret, Is.Empty);
- });
-
- // Test credential without URL (LastPass uses "http://" for these)
- var userWithoutUrlCredential = importedCredentials.First(c => c.ServiceName == "Userwithouturlornotes");
- Assert.Multiple(() =>
- {
- Assert.That(userWithoutUrlCredential.ServiceName, Is.EqualTo("Userwithouturlornotes"));
- Assert.That(userWithoutUrlCredential.ServiceUrls?.FirstOrDefault(), Is.Null);
- Assert.That(userWithoutUrlCredential.Username, Is.EqualTo("userwithouturlornotes"));
- Assert.That(userWithoutUrlCredential.Password, Is.EqualTo("userpass"));
- Assert.That(userWithoutUrlCredential.Notes, Is.Empty);
- Assert.That(userWithoutUrlCredential.TwoFactorSecret, Is.Empty);
- });
-
- // Test secure note (LastPass uses "http://sn" for these)
- var secureNoteCredential = importedCredentials.First(c => c.ServiceName == "securenote1");
- Assert.Multiple(() =>
- {
- Assert.That(secureNoteCredential.ServiceName, Is.EqualTo("securenote1"));
- Assert.That(secureNoteCredential.ServiceUrls?.FirstOrDefault(), Is.Null);
- Assert.That(secureNoteCredential.Username, Is.Empty);
- Assert.That(secureNoteCredential.Password, Is.Empty);
- Assert.That(secureNoteCredential.Notes, Is.EqualTo("Securenotecontent here"));
- Assert.That(secureNoteCredential.TwoFactorSecret, Is.Empty);
- });
-
- // Test credit card entry
- var creditCardCredential = importedCredentials.First(c => c.ServiceName == "Paymentcard1");
- Assert.Multiple(() =>
- {
- Assert.That(creditCardCredential.ServiceName, Is.EqualTo("Paymentcard1"));
- Assert.That(creditCardCredential.ServiceUrls?.FirstOrDefault(), Is.Null); // Should be normalized to null
- Assert.That(creditCardCredential.Username, Is.Empty);
- Assert.That(creditCardCredential.Password, Is.Empty);
- Assert.That(creditCardCredential.ItemType, Is.EqualTo(ImportedItemType.Creditcard));
- Assert.That(creditCardCredential.Creditcard, Is.Not.Null);
- Assert.That(creditCardCredential.Creditcard!.CardholderName, Is.EqualTo("Cardname"));
- Assert.That(creditCardCredential.Creditcard.Number, Is.EqualTo("123456781234"));
- Assert.That(creditCardCredential.Creditcard.Cvv, Is.EqualTo("1234"));
- Assert.That(creditCardCredential.Notes, Is.EqualTo("Creditcardnotes here")); // Extracted notes
- Assert.That(creditCardCredential.TwoFactorSecret, Is.Empty);
- });
- }
-
- /// <summary>
- /// Test case for importing credentials from Generic CSV and ensuring all values are present.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportCredentialsFromGenericCsv()
- {
- // Arrange - Use the template that users actually download
- var fileContent = GenericCsvImporter.GetCsvTemplate();
-
- // Act
- var importedCredentials = await GenericCsvImporter.ImportFromCsvAsync(fileContent);
-
- // Assert - Should import 4 records from the template
- Assert.That(importedCredentials, Has.Count.EqualTo(4));
-
- // Test Gmail credential from template
- var gmailCredential = importedCredentials.First(c => c.ServiceName == "Gmail");
- Assert.Multiple(() =>
- {
- Assert.That(gmailCredential.ServiceName, Is.EqualTo("Gmail"));
- Assert.That(gmailCredential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://gmail.com"));
- Assert.That(gmailCredential.Username, Is.EqualTo("[email protected]"));
- Assert.That(gmailCredential.Password, Is.EqualTo("your_password"));
- Assert.That(gmailCredential.Notes, Is.EqualTo("Important email account"));
- Assert.That(gmailCredential.TwoFactorSecret, Is.Empty);
- Assert.That(gmailCredential.FolderPath, Is.EqualTo("Personal"));
- });
-
- // Test Facebook credential from template
- var facebookCredential = importedCredentials.First(c => c.ServiceName == "Facebook");
- Assert.Multiple(() =>
- {
- Assert.That(facebookCredential.ServiceName, Is.EqualTo("Facebook"));
- Assert.That(facebookCredential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://facebook.com"));
- Assert.That(facebookCredential.Username, Is.EqualTo("your.username"));
- Assert.That(facebookCredential.Password, Is.EqualTo("your_password"));
- Assert.That(facebookCredential.Notes, Is.EqualTo("Social media account"));
- Assert.That(facebookCredential.TwoFactorSecret, Is.Empty);
- Assert.That(facebookCredential.FolderPath, Is.EqualTo("Personal/Social"));
- });
-
- // Test GitHub credential with TOTP from template
- var githubCredential = importedCredentials.First(c => c.ServiceName == "GitHub");
- Assert.Multiple(() =>
- {
- Assert.That(githubCredential.ServiceName, Is.EqualTo("GitHub"));
- Assert.That(githubCredential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://github.com"));
- Assert.That(githubCredential.Username, Is.EqualTo("developer_username"));
- Assert.That(githubCredential.Password, Is.EqualTo("your_password"));
- Assert.That(githubCredential.Notes, Is.EqualTo("Development platform"));
- Assert.That(githubCredential.TwoFactorSecret, Is.EqualTo("your_totp_secret_here"));
- Assert.That(githubCredential.FolderPath, Is.EqualTo("Work"));
- });
-
- // Test Secure Note (no username/password) from template
- var secureNoteCredential = importedCredentials.First(c => c.ServiceName == "Secure Note");
- Assert.Multiple(() =>
- {
- Assert.That(secureNoteCredential.ServiceName, Is.EqualTo("Secure Note"));
- Assert.That(secureNoteCredential.ServiceUrls?.FirstOrDefault(), Is.Null);
- Assert.That(secureNoteCredential.Username, Is.Empty);
- Assert.That(secureNoteCredential.Password, Is.Empty);
- Assert.That(secureNoteCredential.Notes, Is.EqualTo("Important information or notes without login credentials"));
- Assert.That(secureNoteCredential.TwoFactorSecret, Is.Empty);
- Assert.That(secureNoteCredential.FolderPath, Is.Null);
- });
- }
-
- /// <summary>
- /// Test case for importing credentials from Dropbox CSV and ensuring all values are present.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportCredentialsFromDropboxCsv()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.dropbox.csv");
-
- // Act
- var importedCredentials = await DropboxImporter.ImportFromCsvAsync(fileContent);
-
- // Assert
- Assert.That(importedCredentials, Has.Count.EqualTo(5));
-
- // Test Gmail credential
- var gmailCredential = importedCredentials.First(c => c.ServiceName == "Gmail");
- Assert.Multiple(() =>
- {
- Assert.That(gmailCredential.ServiceName, Is.EqualTo("Gmail"));
- Assert.That(gmailCredential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://gmail.com"));
- Assert.That(gmailCredential.Username, Is.EqualTo("[email protected]"));
- Assert.That(gmailCredential.Password, Is.EqualTo("gmailpass123"));
- Assert.That(gmailCredential.Notes, Is.EqualTo("Important email account"));
- });
-
- // Test GitHub credential
- var githubCredential = importedCredentials.First(c => c.ServiceName == "GitHub");
- Assert.Multiple(() =>
- {
- Assert.That(githubCredential.ServiceName, Is.EqualTo("GitHub"));
- Assert.That(githubCredential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://github.com"));
- Assert.That(githubCredential.Username, Is.EqualTo("devuser"));
- Assert.That(githubCredential.Password, Is.EqualTo("devpass789"));
- Assert.That(githubCredential.Notes, Is.EqualTo("Development platform"));
- });
-
- // Test Secure Note (no login credentials)
- var secureNoteCredential = importedCredentials.First(c => c.ServiceName == "Secure Note");
- Assert.Multiple(() =>
- {
- Assert.That(secureNoteCredential.ServiceName, Is.EqualTo("Secure Note"));
- Assert.That(secureNoteCredential.ServiceUrls?.FirstOrDefault(), Is.Null);
- Assert.That(secureNoteCredential.Username, Is.Empty);
- Assert.That(secureNoteCredential.Password, Is.Empty);
- Assert.That(secureNoteCredential.Notes, Is.EqualTo("Important information stored securely"));
- });
- }
-
- /// <summary>
- /// Test case for importing credentials from NordPass CSV and ensuring all values are present.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportCredentialsFromNordPassCsv()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.nordpass.csv");
-
- // Act
- var importedCredentials = await NordPassImporter.ImportFromCsvAsync(fileContent);
-
- // Assert - Should import 4 records (folder entry is skipped)
- Assert.That(importedCredentials, Has.Count.EqualTo(4));
-
- // Test regular password credential
- var passwordCredential = importedCredentials.First(c => c.ServiceName == "Password title");
- Assert.Multiple(() =>
- {
- Assert.That(passwordCredential.ServiceName, Is.EqualTo("Password title"));
- Assert.That(passwordCredential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("http://google.nl"));
- Assert.That(passwordCredential.Username, Is.EqualTo("[email protected]"));
- Assert.That(passwordCredential.Password, Is.EqualTo("password"));
- Assert.That(passwordCredential.FolderPath, Is.EqualTo("Business"));
- Assert.That(passwordCredential.ItemType, Is.EqualTo(ImportedItemType.Login));
- Assert.That(passwordCredential.Notes, Does.Contain("[{\"type\":\"text\",\"label\":\"CustomFieldName1\",\"value\":\"Test\"}]"));
- });
-
- // Test secure note
- var secureNote = importedCredentials.First(c => c.ServiceName == "SecureNote1");
- Assert.Multiple(() =>
- {
- Assert.That(secureNote.ServiceName, Is.EqualTo("SecureNote1"));
- Assert.That(secureNote.ServiceUrls?.FirstOrDefault(), Is.Null);
- Assert.That(secureNote.Username, Is.Empty);
- Assert.That(secureNote.Password, Is.Empty);
- Assert.That(secureNote.ItemType, Is.EqualTo(ImportedItemType.Note));
- Assert.That(secureNote.Notes, Does.Contain("This is my secure note content"));
- Assert.That(secureNote.Notes, Does.Contain("Test test"));
- });
-
- // Test credit card
- var creditCard = importedCredentials.First(c => c.ServiceName == "Creditcard Visa");
- Assert.Multiple(() =>
- {
- Assert.That(creditCard.ServiceName, Is.EqualTo("Creditcard Visa"));
- Assert.That(creditCard.ItemType, Is.EqualTo(ImportedItemType.Creditcard));
- Assert.That(creditCard.Creditcard, Is.Not.Null);
- Assert.That(creditCard.Creditcard!.CardholderName, Is.EqualTo("Holdername"));
- Assert.That(creditCard.Creditcard.Number, Is.EqualTo("1234123412341234123"));
- Assert.That(creditCard.Creditcard.Cvv, Is.EqualTo("1231"));
- Assert.That(creditCard.Creditcard.Pin, Is.EqualTo("1231"));
- Assert.That(creditCard.Creditcard.ExpiryMonth, Is.EqualTo("12"));
- Assert.That(creditCard.Creditcard.ExpiryYear, Is.EqualTo("28"));
- });
-
- // Test root item (no folder)
- var rootItem = importedCredentials.First(c => c.ServiceName == "Root item");
- Assert.Multiple(() =>
- {
- Assert.That(rootItem.ServiceName, Is.EqualTo("Root item"));
- Assert.That(rootItem.Username, Is.EqualTo("rootuser"));
- Assert.That(rootItem.Password, Is.EqualTo("rootpass"));
- Assert.That(rootItem.FolderPath, Is.Null);
- Assert.That(rootItem.ItemType, Is.EqualTo(ImportedItemType.Login));
- });
- }
-
- /// <summary>
- /// Test case for NordPass folder import.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task NordPassFolderImport()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.nordpass.csv");
-
- // Act
- var importedCredentials = await NordPassImporter.ImportFromCsvAsync(fileContent);
-
- // Assert - verify folder path is extracted
- var folderNames = BaseImporter.CollectUniqueFolderNames(importedCredentials);
- Assert.That(folderNames, Does.Contain("Business"));
-
- var credentialWithFolder = importedCredentials.First(c => c.FolderPath == "Business");
- Assert.That(credentialWithFolder.ServiceName, Is.EqualTo("Password title"));
- }
-
- /// <summary>
- /// Test case for NordPass credit card detection and parsing.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task NordPassCreditCardDetectionAndParsing()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.nordpass.csv");
-
- // Act
- var importedCredentials = await NordPassImporter.ImportFromCsvAsync(fileContent);
-
- // Assert - verify credit card is detected and parsed
- var creditCardCredential = importedCredentials.First(c => c.ServiceName == "Creditcard Visa");
- Assert.That(creditCardCredential.ItemType, Is.EqualTo(ImportedItemType.Creditcard));
- Assert.That(creditCardCredential.Creditcard, Is.Not.Null);
- Assert.That(creditCardCredential.Creditcard!.CardholderName, Is.EqualTo("Holdername"));
- Assert.That(creditCardCredential.Creditcard.Number, Is.EqualTo("1234123412341234123"));
- Assert.That(creditCardCredential.Creditcard.Cvv, Is.EqualTo("1231"));
- Assert.That(creditCardCredential.Creditcard.Pin, Is.EqualTo("1231"));
- Assert.That(creditCardCredential.Creditcard.ExpiryMonth, Is.EqualTo("12"));
- Assert.That(creditCardCredential.Creditcard.ExpiryYear, Is.EqualTo("28"));
-
- // Convert to item and verify fields
- var items = BaseImporter.ConvertToItem([creditCardCredential]);
- var creditCardItem = items[0];
- Assert.That(creditCardItem.ItemType, Is.EqualTo(ItemType.CreditCard));
-
- var cardNumber = creditCardItem.FieldValues.FirstOrDefault(fv => fv.FieldKey == FieldKey.CardNumber);
- Assert.That(cardNumber?.Value, Is.EqualTo("1234123412341234123"));
-
- var cardholderName = creditCardItem.FieldValues.FirstOrDefault(fv => fv.FieldKey == FieldKey.CardCardholderName);
- Assert.That(cardholderName?.Value, Is.EqualTo("Holdername"));
-
- var cardPin = creditCardItem.FieldValues.FirstOrDefault(fv => fv.FieldKey == FieldKey.CardPin);
- Assert.That(cardPin?.Value, Is.EqualTo("1231"));
- }
-
- /// <summary>
- /// Test case for importing credentials from AliasVault Mobile App CSV export and ensuring all values are present.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportCredentialsFromAliasVaultMobileAppCsv()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.aliasvault_mobile_app_export.csv");
-
- // Act
- var importedCredentials = await ItemCsvService.ImportItemsFromCsv(fileContent);
-
- // Assert
- Assert.That(importedCredentials, Has.Count.EqualTo(3));
-
- // Test credential3 (without password)
- var credential3 = importedCredentials.First(c => c.ServiceName == "credential3");
- Assert.Multiple(() =>
- {
- Assert.That(credential3.ServiceName, Is.EqualTo("credential3"));
- Assert.That(credential3.ServiceUrls?.FirstOrDefault(), Is.Null);
- Assert.That(credential3.Username, Is.EqualTo("username3"));
- Assert.That(credential3.Password, Is.Empty);
- Assert.That(credential3.Notes, Is.EqualTo("without password"));
- Assert.That(credential3.TwoFactorSecret, Is.EqualTo("test"));
- Assert.That(credential3.CreatedAt?.Date, Is.EqualTo(new DateTime(2025, 9, 12)));
- Assert.That(credential3.UpdatedAt?.Date, Is.EqualTo(new DateTime(2025, 9, 12)));
- Assert.That(credential3.Alias?.Gender, Is.Empty);
- Assert.That(credential3.Alias?.FirstName, Is.Empty);
- Assert.That(credential3.Alias?.LastName, Is.Empty);
- Assert.That(credential3.Alias?.NickName, Is.Empty);
- Assert.That(credential3.Email, Is.Empty);
- });
-
- // Test service2 (full credential with alias)
- var service2Credential = importedCredentials.First(c => c.ServiceName == "service2");
- Assert.Multiple(() =>
- {
- Assert.That(service2Credential.ServiceName, Is.EqualTo("service2"));
- Assert.That(service2Credential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://service2.com"));
- Assert.That(service2Credential.Username, Is.EqualTo("username2"));
- Assert.That(service2Credential.Password, Is.EqualTo("password2"));
- Assert.That(service2Credential.Notes, Is.Empty);
- Assert.That(service2Credential.TwoFactorSecret, Is.Empty);
- Assert.That(service2Credential.Email, Is.EqualTo("[email protected]"));
- Assert.That(service2Credential.Alias?.Gender, Is.EqualTo("gender2"));
- Assert.That(service2Credential.Alias?.FirstName, Is.EqualTo("firstname2"));
- Assert.That(service2Credential.Alias?.LastName, Is.EqualTo("lastname2"));
- Assert.That(service2Credential.Alias?.NickName, Is.EqualTo("nickname2"));
- });
-
- // Test service1 (with notes and birthdate)
- var service1Credential = importedCredentials.First(c => c.ServiceName == "service1");
- Assert.Multiple(() =>
- {
- Assert.That(service1Credential.ServiceName, Is.EqualTo("service1"));
- Assert.That(service1Credential.ServiceUrls?.FirstOrDefault(), Is.Null);
- Assert.That(service1Credential.Username, Is.EqualTo("username1"));
- Assert.That(service1Credential.Password, Is.EqualTo("password1"));
- Assert.That(service1Credential.Notes, Is.EqualTo("notes1"));
- Assert.That(service1Credential.TwoFactorSecret, Is.Empty);
- Assert.That(service1Credential.Email, Is.EqualTo("[email protected]"));
- Assert.That(service1Credential.Alias?.Gender, Is.EqualTo("gender1"));
- Assert.That(service1Credential.Alias?.FirstName, Is.EqualTo("firstname1"));
- Assert.That(service1Credential.Alias?.LastName, Is.EqualTo("lastname1"));
- Assert.That(service1Credential.Alias?.NickName, Is.EqualTo("nickname1"));
- Assert.That(service1Credential.Alias?.BirthDate, Is.EqualTo(new DateTime(1970, 1, 1)));
- });
- }
-
- /// <summary>
- /// Test case for getting the CSV template structure.
- /// </summary>
- [Test]
- public void GetGenericCsvTemplate()
- {
- // Act
- var template = GenericCsvImporter.GetCsvTemplate();
-
- // Assert
- Assert.That(template, Is.Not.Null);
- Assert.That(template, Does.Contain("service_name,url,username,password,totp_secret,notes,folder"));
- Assert.That(template, Does.Contain("Gmail"));
- Assert.That(template, Does.Contain("Facebook"));
- Assert.That(template, Does.Contain("GitHub"));
- Assert.That(template, Does.Contain("Secure Note"));
-
- // Verify it has example data
- Assert.That(template, Does.Contain("[email protected]"));
- Assert.That(template, Does.Contain("your_totp_secret_here"));
- }
-
- /// <summary>
- /// Test case for Bitwarden import with folder path extraction.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportBitwardenWithFolders()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.bitwarden.csv");
-
- // Act
- var importedCredentials = await BitwardenImporter.ImportFromCsvAsync(fileContent);
-
- // Assert - check folder path is extracted (6 items in Business folder in test data)
- var businessFolderItems = importedCredentials.Where(c => c.FolderPath == "Business").ToList();
- Assert.That(businessFolderItems, Has.Count.EqualTo(6), "Should have 6 items in Business folder");
-
- // Verify folder names are collected correctly
- var folderNames = BaseImporter.CollectUniqueFolderNames(importedCredentials);
- Assert.That(folderNames, Does.Contain("Business"));
- }
-
- /// <summary>
- /// Test case for multi-level folder path extraction (takes deepest folder).
- /// </summary>
- [Test]
- public void ExtractDeepestFolderName()
- {
- Assert.Multiple(() =>
- {
- Assert.That(BaseImporter.ExtractDeepestFolderName("Root/Business/Banking"), Is.EqualTo("Banking"));
- Assert.That(BaseImporter.ExtractDeepestFolderName("Business"), Is.EqualTo("Business"));
- Assert.That(BaseImporter.ExtractDeepestFolderName("Root\\Work\\Finance"), Is.EqualTo("Finance"));
- Assert.That(BaseImporter.ExtractDeepestFolderName(string.Empty), Is.Null);
- Assert.That(BaseImporter.ExtractDeepestFolderName(null), Is.Null);
- Assert.That(BaseImporter.ExtractDeepestFolderName(" / "), Is.Null);
- Assert.That(BaseImporter.ExtractDeepestFolderName("Single"), Is.EqualTo("Single"));
- });
- }
-
- /// <summary>
- /// Test case for Bitwarden type detection (login, note, card).
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task BitwardenTypeDetection()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.bitwarden.csv");
-
- // Act
- var importedCredentials = await BitwardenImporter.ImportFromCsvAsync(fileContent);
- var items = BaseImporter.ConvertToItem(importedCredentials);
-
- // Assert - verify login type items have Login item type
- var loginItems = items.Where(i => i.ItemType == ItemType.Login).ToList();
- Assert.That(loginItems, Has.Count.GreaterThan(0), "Should have at least one Login item");
- }
-
- /// <summary>
- /// Test case ensuring an imported otpauth:// URI keeps its algorithm, digits and period instead of
- /// being reduced to the RFC 6238 defaults, which would make the generated codes wrong.
- /// </summary>
- [Test]
- public void ImportPreservesTotpParameters()
- {
- // Arrange
- var credentials = new List<ImportedCredential>
- {
- new()
- {
- ServiceName = "Sha512Service",
- TwoFactorSecret = "otpauth://totp/Sha512Service:[email protected]?secret=JBSWY3DPEHPK3PXP&issuer=Sha512Service&algorithm=SHA512&digits=8&period=60",
- },
- new()
- {
- ServiceName = "PlainService",
- TwoFactorSecret = "JBSWY3DPEHPK3PXP",
- },
- };
-
- // Act
- var items = BaseImporter.ConvertToItem(credentials);
-
- // Assert
- var withParameters = items.First(i => i.Name == "Sha512Service").TotpCodes.Single();
- var withDefaults = items.First(i => i.Name == "PlainService").TotpCodes.Single();
-
- Assert.Multiple(() =>
- {
- Assert.That(withParameters.Algorithm, Is.EqualTo("SHA512"));
- Assert.That(withParameters.Digits, Is.EqualTo(8));
- Assert.That(withParameters.Period, Is.EqualTo(60));
- Assert.That(withDefaults.Algorithm, Is.EqualTo(TotpCode.AlgorithmSha1));
- Assert.That(withDefaults.Digits, Is.EqualTo(TotpCode.DefaultDigits));
- Assert.That(withDefaults.Period, Is.EqualTo(TotpCode.DefaultPeriod));
- });
- }
-
- /// <summary>
- /// Test case for LastPass secure note detection.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task LastPassSecureNoteDetection()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.lastpass.csv");
-
- // Act
- var importedCredentials = await LastPassImporter.ImportFromCsvAsync(fileContent);
- var items = BaseImporter.ConvertToItem(importedCredentials);
-
- // Assert - verify secure note is detected
- var secureNoteItem = items.FirstOrDefault(i => i.Name == "securenote1");
- Assert.That(secureNoteItem, Is.Not.Null, "Should find securenote1");
- Assert.That(secureNoteItem!.ItemType, Is.EqualTo(ItemType.Note), "Secure note should have Note item type");
- }
-
- /// <summary>
- /// Test case for LastPass credit card detection and parsing.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task LastPassCreditCardDetectionAndParsing()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.lastpass.csv");
-
- // Act
- var importedCredentials = await LastPassImporter.ImportFromCsvAsync(fileContent);
-
- // Assert - verify credit card is detected
- var creditCardCredential = importedCredentials.FirstOrDefault(c => c.ServiceName == "Paymentcard1");
- Assert.That(creditCardCredential, Is.Not.Null, "Should find Paymentcard1");
- Assert.That(creditCardCredential!.ItemType, Is.EqualTo(ImportedItemType.Creditcard), "Should be Creditcard type");
- Assert.That(creditCardCredential.Creditcard, Is.Not.Null, "Should have Creditcard data");
- Assert.That(creditCardCredential.Creditcard!.CardholderName, Is.EqualTo("Cardname"));
- Assert.That(creditCardCredential.Creditcard.Number, Is.EqualTo("123456781234"));
- Assert.That(creditCardCredential.Creditcard.Cvv, Is.EqualTo("1234"));
-
- // Convert to item and verify fields
- var items = BaseImporter.ConvertToItem([creditCardCredential]);
- var creditCardItem = items[0];
- Assert.That(creditCardItem.ItemType, Is.EqualTo(ItemType.CreditCard));
-
- var cardNumber = creditCardItem.FieldValues.FirstOrDefault(fv => fv.FieldKey == FieldKey.CardNumber);
- Assert.That(cardNumber?.Value, Is.EqualTo("123456781234"));
-
- var cardholderName = creditCardItem.FieldValues.FirstOrDefault(fv => fv.FieldKey == FieldKey.CardCardholderName);
- Assert.That(cardholderName?.Value, Is.EqualTo("Cardname"));
- }
-
- /// <summary>
- /// Test case for LastPass folder (grouping) import.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task LastPassFolderImport()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.lastpass.csv");
-
- // Act
- var importedCredentials = await LastPassImporter.ImportFromCsvAsync(fileContent);
-
- // Assert - verify folder path is extracted
- var credentialWithFolder = importedCredentials.FirstOrDefault(c => !string.IsNullOrEmpty(c.FolderPath));
- Assert.That(credentialWithFolder, Is.Not.Null, "Should have at least one credential with folder");
- Assert.That(credentialWithFolder!.FolderPath, Is.EqualTo("examplefolder"));
- }
-
- /// <summary>
- /// Test case for KeePassXC group (folder) import with nested folder support.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task KeePassXcGroupImport()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.keepassxc.csv");
-
- // Act
- var importedCredentials = await KeePassXcImporter.ImportFromCsvAsync(fileContent);
-
- // Assert - verify folder path is extracted (KeePassXC uses Group column which contains folder hierarchy)
- var folderNames = BaseImporter.CollectUniqueFolderNames(importedCredentials);
- Assert.That(folderNames, Has.Count.EqualTo(2), "Should collect leaf folder names");
- Assert.That(folderNames, Does.Contain("Test1"), "Should contain Test1 folder");
- Assert.That(folderNames, Does.Contain("Windowssub1"), "Should contain Windowssub1 folder");
-
- // Verify the nested folder structure is properly extracted on the credential
- var nestedCredential = importedCredentials.First(c => c.ServiceName == "Nested Entry");
- Assert.That(nestedCredential.FolderPath, Is.EqualTo("Database/Windows/Windowssub1"), "Should preserve full nested folder path");
-
- // Verify ParseFolderPath correctly splits the nested path into individual folder components
- var folderParts = BaseImporter.ParseFolderPath(nestedCredential.FolderPath);
- Assert.Multiple(() =>
- {
- Assert.That(folderParts, Has.Count.EqualTo(3), "Should parse three folder levels");
- Assert.That(folderParts[0], Is.EqualTo("Database"), "First level should be Database");
- Assert.That(folderParts[1], Is.EqualTo("Windows"), "Second level should be Windows");
- Assert.That(folderParts[2], Is.EqualTo("Windowssub1"), "Third level should be Windowssub1");
- });
-
- // Verify that all folder levels would be created during import
- // The folder system creates: "Database", "Database/Windows", and "Database/Windows/Windowssub1"
- var allFolderPaths = new List<string>();
- for (int i = 1; i <= folderParts.Count; i++)
- {
- allFolderPaths.Add(string.Join("/", folderParts.Take(i)));
- }
-
- Assert.Multiple(() =>
- {
- Assert.That(allFolderPaths, Has.Count.EqualTo(3), "Should have three folder paths to create");
- Assert.That(allFolderPaths[0], Is.EqualTo("Database"), "Should create Database folder");
- Assert.That(allFolderPaths[1], Is.EqualTo("Database/Windows"), "Should create Database/Windows folder");
- Assert.That(allFolderPaths[2], Is.EqualTo("Database/Windows/Windowssub1"), "Should create Database/Windows/Windowssub1 folder");
- });
- }
-
- /// <summary>
- /// Test case for folder assignment during ConvertToItem.
- /// </summary>
- [Test]
- public void ConvertToItemWithFolderMapping()
- {
- // Arrange
- var credentials = new List<AliasVault.ImportExport.Models.ImportedCredential>
- {
- new()
- {
- ServiceName = "Test Service",
- FolderPath = "Work/Projects",
- Username = "user1",
- Password = "pass1",
- },
- new()
- {
- ServiceName = "Test Service 2",
- FolderPath = "Personal",
- Username = "user2",
- Password = "pass2",
- },
- new()
- {
- ServiceName = "No Folder",
- Username = "user3",
- Password = "pass3",
- },
- };
-
- var folderMapping = new Dictionary<string, Guid>
- {
- { "Work/Projects", Guid.NewGuid() },
- { "Personal", Guid.NewGuid() },
- };
-
- // Act
- var items = BaseImporter.ConvertToItem(credentials, folderMapping);
-
- // Assert
- Assert.That(items[0].FolderId, Is.EqualTo(folderMapping["Work/Projects"]), "Should assign Work/Projects folder using full path");
- Assert.That(items[1].FolderId, Is.EqualTo(folderMapping["Personal"]), "Should assign Personal folder");
- Assert.That(items[2].FolderId, Is.Null, "Should have no folder");
- }
-
- /// <summary>
- /// Test case for ProtonPass type and vault (folder) import.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ProtonPassTypeAndVaultImport()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.protonpass.csv");
-
- // Act
- var importedCredentials = await ProtonPassImporter.ImportFromCsvAsync(fileContent);
-
- // Assert - verify vault (folder) is extracted
- var credentialsWithVault = importedCredentials.Where(c => !string.IsNullOrEmpty(c.FolderPath)).ToList();
- Assert.That(credentialsWithVault.Count, Is.GreaterThan(0), "Should have credentials with vault/folder");
-
- // Verify type detection
- var loginCredential = importedCredentials.FirstOrDefault(c => c.ItemType == ImportedItemType.Login);
- Assert.That(loginCredential, Is.Not.Null, "Should have at least one Login type");
- }
-
- /// <summary>
- /// Test case for Dashlane category (folder) import.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task DashlaneCategoryImport()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.dashlane.csv");
-
- // Act
- var importedCredentials = await DashlaneImporter.ImportFromCsvAsync(fileContent);
-
- // Assert - check if any credentials have folder path from category
- // Note: Dashlane test data may or may not have categories
- var folderNames = BaseImporter.CollectUniqueFolderNames(importedCredentials);
- Assert.That(folderNames, Is.Not.Null, "Should return a set (even if empty)");
- }
-
- /// <summary>
- /// Test case for importing credentials from RoboForm CSV and ensuring all values are present.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportCredentialsFromRoboformCsv()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.roboform.csv");
-
- // Act
- var importedCredentials = await RoboformImporter.ImportFromCsvAsync(fileContent);
-
- // Assert - Should import 5 records
- Assert.That(importedCredentials, Has.Count.EqualTo(5));
-
- // Test regular login credential
- var comCredential = importedCredentials.First(c => c.ServiceName == "Com");
- Assert.Multiple(() =>
- {
- Assert.That(comCredential.ServiceName, Is.EqualTo("Com"));
- Assert.That(comCredential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://www.example.com.com"));
- Assert.That(comCredential.Username, Is.EqualTo("username1"));
- Assert.That(comCredential.Password, Is.EqualTo("password1"));
- Assert.That(comCredential.Notes, Is.Null.Or.Empty);
- Assert.That(comCredential.FolderPath, Is.Null);
- Assert.That(comCredential.ItemType, Is.EqualTo(ImportedItemType.Login));
- });
-
- // Test credential with note
- var exampleCredential = importedCredentials.First(c => c.ServiceName == "Example");
- Assert.Multiple(() =>
- {
- Assert.That(exampleCredential.ServiceName, Is.EqualTo("Example"));
- Assert.That(exampleCredential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://www.example.com"));
- Assert.That(exampleCredential.Username, Is.EqualTo("exampleusername"));
- Assert.That(exampleCredential.Password, Is.EqualTo("examplepassword"));
- Assert.That(exampleCredential.Notes, Is.EqualTo("Examplenote"));
- Assert.That(exampleCredential.FolderPath, Is.Null);
- Assert.That(exampleCredential.ItemType, Is.EqualTo(ImportedItemType.Login));
- });
-
- // Test secure note (no URL, login, or password)
- var safeNoteCredential = importedCredentials.First(c => c.ServiceName == "Safenotename");
- Assert.Multiple(() =>
- {
- Assert.That(safeNoteCredential.ServiceName, Is.EqualTo("Safenotename"));
- Assert.That(safeNoteCredential.ServiceUrls?.FirstOrDefault(), Is.Null);
- Assert.That(safeNoteCredential.Username, Is.Null.Or.Empty);
- Assert.That(safeNoteCredential.Password, Is.Null.Or.Empty);
- Assert.That(safeNoteCredential.Notes, Is.EqualTo("Safenote content example here"));
- Assert.That(safeNoteCredential.ItemType, Is.EqualTo(ImportedItemType.Note));
- });
-
- // Test credential in folder
- var businessCredential = importedCredentials.First(c => c.ServiceName == "Business");
- Assert.Multiple(() =>
- {
- Assert.That(businessCredential.ServiceName, Is.EqualTo("Business"));
- Assert.That(businessCredential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://www.business.com"));
- Assert.That(businessCredential.Username, Is.EqualTo("businessusername"));
- Assert.That(businessCredential.Password, Is.EqualTo("businesspassword"));
- Assert.That(businessCredential.FolderPath, Is.EqualTo("Business"));
- Assert.That(businessCredential.ItemType, Is.EqualTo(ImportedItemType.Login));
- });
-
- // Test secure note with a multi-line note body
- var multilineNote = importedCredentials.First(c => c.ServiceName == "Multiline safenote");
- Assert.Multiple(() =>
- {
- Assert.That(multilineNote.Notes, Does.StartWith("First note line"));
- Assert.That(multilineNote.Notes, Does.Contain("Fourth note line after a blank one"));
- Assert.That(multilineNote.ItemType, Is.EqualTo(ImportedItemType.Note));
- });
- }
-
- /// <summary>
- /// Test case for RoboForm folder import.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task RoboformFolderImport()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.roboform.csv");
-
- // Act
- var importedCredentials = await RoboformImporter.ImportFromCsvAsync(fileContent);
-
- // Assert - verify folder path is extracted (leading slash removed)
- var folderNames = BaseImporter.CollectUniqueFolderNames(importedCredentials);
- Assert.That(folderNames, Does.Contain("Business"));
-
- var credentialWithFolder = importedCredentials.First(c => c.FolderPath == "Business");
- Assert.That(credentialWithFolder.ServiceName, Is.EqualTo("Business"));
- }
-
- /// <summary>
- /// Test case for RoboForm secure note detection.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task RoboformSecureNoteDetection()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.roboform.csv");
-
- // Act
- var importedCredentials = await RoboformImporter.ImportFromCsvAsync(fileContent);
- var items = BaseImporter.ConvertToItem(importedCredentials);
-
- // Assert - verify secure note is detected
- var secureNoteItem = items.FirstOrDefault(i => i.Name == "Safenotename");
- Assert.That(secureNoteItem, Is.Not.Null, "Should find Safenotename");
- Assert.That(secureNoteItem!.ItemType, Is.EqualTo(ItemType.Note), "Secure note should have Note item type");
-
- // Verify the note content is preserved
- var notesFieldValue = secureNoteItem.FieldValues.FirstOrDefault(fv => fv.FieldKey == FieldKey.NotesContent);
- Assert.That(notesFieldValue?.Value, Is.EqualTo("Safenote content example here"));
- }
-
- /// <summary>
- /// Test case for importing credentials from Edge CSV and ensuring all values are present.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportCredentialsFromEdgeCsv()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.edge.csv");
-
- // Act
- var importedCredentials = await EdgeImporter.ImportFromCsvAsync(fileContent);
-
- // Assert
- Assert.That(importedCredentials, Has.Count.EqualTo(4));
-
- // Test first entry (no notes)
- var exampleAppCredential = importedCredentials.First(c => c.ServiceName == "example.app.tld");
- Assert.Multiple(() =>
- {
- Assert.That(exampleAppCredential.ServiceName, Is.EqualTo("example.app.tld"));
- Assert.That(exampleAppCredential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://example.app.tld/"));
- Assert.That(exampleAppCredential.Username, Is.EqualTo("exampleu"));
- Assert.That(exampleAppCredential.Password, Is.EqualTo("examplep"));
- Assert.That(exampleAppCredential.Notes, Is.Empty);
- });
-
- // Test entry with notes
- var googleCredential = importedCredentials.First(c => c.ServiceName == "google.nl");
- Assert.Multiple(() =>
- {
- Assert.That(googleCredential.ServiceName, Is.EqualTo("google.nl"));
- Assert.That(googleCredential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://google.nl/"));
- Assert.That(googleCredential.Username, Is.EqualTo("myuser"));
- Assert.That(googleCredential.Password, Is.EqualTo("mypass"));
- Assert.That(googleCredential.Notes, Is.EqualTo("Google note here microsoft edge"));
- });
-
- // Test youtube entry
- var youtubeCredential = importedCredentials.First(c => c.ServiceName == "youtube.com");
- Assert.Multiple(() =>
- {
- Assert.That(youtubeCredential.ServiceName, Is.EqualTo("youtube.com"));
- Assert.That(youtubeCredential.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://youtube.com/"));
- Assert.That(youtubeCredential.Username, Is.EqualTo("youtubeuser"));
- Assert.That(youtubeCredential.Password, Is.EqualTo("ytpassword"));
- Assert.That(youtubeCredential.Notes, Is.EqualTo("Youtubenotes"));
- });
- }
-
- /// <summary>
- /// Test case for importing credentials from Enpass CSV and ensuring all values are present.
- /// Enpass uses a unique format with alternating key-value pairs instead of headers.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportCredentialsFromEnpassCsv()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.enpass.csv");
-
- // Act
- var importedCredentials = await EnpassImporter.ImportFromCsvAsync(fileContent);
-
- // Assert - Should import 5 records
- Assert.That(importedCredentials, Has.Count.EqualTo(5));
-
- // Test credit card
- var creditCard = importedCredentials.First(c => c.ServiceName == "Credit Card");
- Assert.Multiple(() =>
- {
- Assert.That(creditCard.ItemType, Is.EqualTo(ImportedItemType.Creditcard));
- Assert.That(creditCard.Creditcard, Is.Not.Null);
- Assert.That(creditCard.Creditcard!.CardholderName, Is.EqualTo("ccholder"));
- Assert.That(creditCard.Creditcard.Number, Is.EqualTo("1234123412341234"));
- Assert.That(creditCard.Creditcard.Cvv, Is.EqualTo("1234"));
- Assert.That(creditCard.Creditcard.Pin, Is.EqualTo("1234"));
- Assert.That(creditCard.Creditcard.ExpiryMonth, Is.EqualTo("12"));
- Assert.That(creditCard.Creditcard.ExpiryYear, Is.EqualTo("28"));
- });
-
- // Test Google login with TOTP
- var googleLogin = importedCredentials.First(c => c.ServiceName == "Google");
- Assert.Multiple(() =>
- {
- Assert.That(googleLogin.ItemType, Is.EqualTo(ImportedItemType.Login));
- Assert.That(googleLogin.Username, Is.EqualTo("usergoogle"));
- Assert.That(googleLogin.Email, Is.EqualTo("[email protected]"));
- Assert.That(googleLogin.Password, Is.EqualTo("password"));
- Assert.That(googleLogin.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://accounts.google.com/"));
- Assert.That(googleLogin.TwoFactorSecret, Is.EqualTo("PLW4SB3PQ7MKVXY2MXF4NEXS6Y"));
- Assert.That(googleLogin.Notes, Does.Contain("Security question: secquestion"));
- Assert.That(googleLogin.Notes, Does.Contain("Security answer: secanswer"));
- });
-
- // Test identity
- var identity = importedCredentials.First(c => c.ServiceName == "Identity");
- Assert.Multiple(() =>
- {
- Assert.That(identity.ItemType, Is.EqualTo(ImportedItemType.Alias));
- Assert.That(identity.Alias, Is.Not.Null);
- Assert.That(identity.Alias!.FirstName, Is.EqualTo("John"));
- Assert.That(identity.Alias.LastName, Is.EqualTo("Johnson"));
- Assert.That(identity.Alias.Gender, Is.EqualTo("Male"));
- Assert.That(identity.Alias.BirthDate, Is.EqualTo(new DateTime(1970, 1, 1)));
- });
-
- // Test password entry
- var passwordEntry = importedCredentials.First(c => c.ServiceName == "Password");
- Assert.Multiple(() =>
- {
- Assert.That(passwordEntry.ItemType, Is.EqualTo(ImportedItemType.Login));
- Assert.That(passwordEntry.Username, Is.EqualTo("loginpw1"));
- Assert.That(passwordEntry.Password, Is.EqualTo("password"));
- });
-
- // Test secure note
- var secureNote = importedCredentials.First(c => c.ServiceName == "Securenote");
- Assert.Multiple(() =>
- {
- Assert.That(secureNote.ItemType, Is.EqualTo(ImportedItemType.Note));
- Assert.That(secureNote.Notes, Is.EqualTo("Note only content here"));
- });
- }
-
- /// <summary>
- /// Test case for Enpass credit card conversion to Item.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task EnpassCreditCardConversion()
- {
- // Arrange
- var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceStringAsync("AliasVault.UnitTests.TestData.Exports.enpass.csv");
-
- // Act
- var importedCredentials = await EnpassImporter.ImportFromCsvAsync(fileContent);
- var creditCardCredential = importedCredentials.First(c => c.ServiceName == "Credit Card");
- var items = BaseImporter.ConvertToItem([creditCardCredential]);
-
- // Assert
- var creditCardItem = items[0];
- Assert.That(creditCardItem.ItemType, Is.EqualTo(ItemType.CreditCard));
-
- var cardNumber = creditCardItem.FieldValues.FirstOrDefault(fv => fv.FieldKey == FieldKey.CardNumber);
- Assert.That(cardNumber?.Value, Is.EqualTo("1234123412341234"));
-
- var cardholderName = creditCardItem.FieldValues.FirstOrDefault(fv => fv.FieldKey == FieldKey.CardCardholderName);
- Assert.That(cardholderName?.Value, Is.EqualTo("ccholder"));
-
- var cardCvv = creditCardItem.FieldValues.FirstOrDefault(fv => fv.FieldKey == FieldKey.CardCvv);
- Assert.That(cardCvv?.Value, Is.EqualTo("1234"));
-
- var cardPin = creditCardItem.FieldValues.FirstOrDefault(fv => fv.FieldKey == FieldKey.CardPin);
- Assert.That(cardPin?.Value, Is.EqualTo("1234"));
- }
-
- /// <summary>
- /// Test case for round-tripping an item with multiple service URLs through CSV export and import.
- /// Multiple URLs are exported as a single comma separated value and split again on import.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ExportAndImportMultipleServiceUrlsFromCsv()
- {
- // Arrange: add the URLs out of order to verify they are exported ordered by weight.
- var item = new Item
- {
- Id = new Guid("00000000-0000-0000-0000-000000000001"),
- Name = "Multi url service",
- ItemType = ItemType.Login,
- CreatedAt = DateTime.Now,
- UpdatedAt = DateTime.Now,
- };
-
- AddFieldValue(item, FieldKey.LoginUsername, "testuser");
- AddFieldValue(item, FieldKey.LoginUrl, "https://downloads.aliasvault.com", 2);
- AddFieldValue(item, FieldKey.LoginUrl, "https://www.aliasvault.com", 0);
- AddFieldValue(item, FieldKey.LoginUrl, "https://app.aliasvault.com", 1);
-
- // Act
- var csvString = System.Text.Encoding.Default.GetString(ItemCsvService.ExportItemsToCsv([item]));
- var importedCredentials = await ItemCsvService.ImportItemsFromCsv(csvString);
-
- // Assert: the CSV holds all URLs in a single quoted comma separated column.
- Assert.That(csvString, Does.Contain("\"https://www.aliasvault.com,https://app.aliasvault.com,https://downloads.aliasvault.com\""));
-
- Assert.That(importedCredentials, Has.Count.EqualTo(1));
- var importedCredential = importedCredentials[0];
- Assert.Multiple(() =>
- {
- Assert.That(importedCredential.ServiceUrls, Has.Count.EqualTo(3));
- Assert.That(importedCredential.ServiceUrls![0], Is.EqualTo("https://www.aliasvault.com"));
- Assert.That(importedCredential.ServiceUrls[1], Is.EqualTo("https://app.aliasvault.com"));
- Assert.That(importedCredential.ServiceUrls[2], Is.EqualTo("https://downloads.aliasvault.com"));
- });
-
- // Assert: converting back to an item results in one field value per URL with ascending weights.
- var convertedItem = BaseImporter.ConvertToItem(importedCredentials)[0];
- var urlFieldValues = convertedItem.FieldValues.Where(fv => fv.FieldKey == FieldKey.LoginUrl).OrderBy(fv => fv.Weight).ToList();
- Assert.Multiple(() =>
- {
- Assert.That(urlFieldValues, Has.Count.EqualTo(3));
- Assert.That(urlFieldValues[0].Value, Is.EqualTo("https://www.aliasvault.com"));
- Assert.That(urlFieldValues[1].Value, Is.EqualTo("https://app.aliasvault.com"));
- Assert.That(urlFieldValues[2].Value, Is.EqualTo("https://downloads.aliasvault.com"));
- });
- }
-
- /// <summary>
- /// Test case for importing a CSV where the ServiceUrl column contains multiple URLs separated by
- /// a comma with optional whitespace, as can happen when the file is edited by hand or by a spreadsheet.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportCsvWithMultipleServiceUrls()
- {
- // Arrange
- var csv =
- "ServiceName,FolderPath,ServiceUrl,Username,CurrentPassword,AliasEmail,TwoFactorSecret,AliasGender,AliasFirstName,AliasLastName,AliasNickName,AliasBirthDate,Notes,CreatedAt,UpdatedAt\n"
- + "Multi url service,,\"https://example.com, https://www.example.com\",user,pass,,,,,,,,,2024-01-01 00:00:00,2024-01-01 00:00:00\n"
- + "Single url service,,https://single.example,user,pass,,,,,,,,,2024-01-01 00:00:00,2024-01-01 00:00:00\n";
-
- // Act
- var importedCredentials = await ItemCsvService.ImportItemsFromCsv(csv);
-
- // Assert
- Assert.That(importedCredentials, Has.Count.EqualTo(2));
-
- var multiUrlCredential = importedCredentials.First(c => c.ServiceName == "Multi url service");
- var singleUrlCredential = importedCredentials.First(c => c.ServiceName == "Single url service");
- Assert.Multiple(() =>
- {
- Assert.That(multiUrlCredential.ServiceUrls, Has.Count.EqualTo(2));
- Assert.That(multiUrlCredential.ServiceUrls![0], Is.EqualTo("https://example.com"));
- Assert.That(multiUrlCredential.ServiceUrls[1], Is.EqualTo("https://www.example.com"));
- Assert.That(singleUrlCredential.ServiceUrls, Has.Count.EqualTo(1));
- Assert.That(singleUrlCredential.ServiceUrls![0], Is.EqualTo("https://single.example"));
- });
- }
-
- /// <summary>
- /// Helper method to add a field value to an item.
- /// </summary>
- /// <param name="item">The item to add the field value to.</param>
- /// <param name="fieldKey">The field key.</param>
- /// <param name="value">The field value.</param>
- /// <param name="weight">The weight used to order multiple values of the same field key.</param>
- private static void AddFieldValue(Item item, string fieldKey, string value, int weight = 0)
- {
- item.FieldValues.Add(new FieldValue
- {
- Id = Guid.NewGuid(),
- ItemId = item.Id,
- FieldKey = fieldKey,
- Value = value,
- Weight = weight,
- CreatedAt = item.CreatedAt,
- UpdatedAt = item.UpdatedAt,
- });
- }
-
- /// <summary>
- /// Helper method to add a custom (user-defined) field value to an item, referencing a field definition.
- /// </summary>
- /// <param name="item">The item to add the field value to.</param>
- /// <param name="definition">The custom field definition the value belongs to.</param>
- /// <param name="value">The field value.</param>
- private static void AddCustomFieldValue(Item item, FieldDefinition definition, string value)
- {
- item.FieldValues.Add(new FieldValue
- {
- Id = Guid.NewGuid(),
- ItemId = item.Id,
- FieldDefinition = definition,
- FieldDefinitionId = definition.Id,
- FieldKey = null,
- Value = value,
- Weight = 0,
- CreatedAt = item.CreatedAt,
- UpdatedAt = item.UpdatedAt,
- });
- }
-
- /// <summary>
- /// Test case for exporting vault data to .avux format and verifying structure.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ExportVaultToAvuxFormat()
- {
- // Arrange - Create comprehensive vault data
- var items = new List<Item>
- {
- // Login with basic fields
- CreateTestItem("Basic Login", ItemType.Login, new Dictionary<string, string>
- {
- { FieldKey.LoginUsername, "testuser" },
- { FieldKey.LoginPassword, "testpass" },
- { FieldKey.LoginUrl, "https://example.com" },
- { FieldKey.NotesContent, "Test notes" },
- }),
-
- // Login with 2FA
- CreateTestItemWithTotp("Login with 2FA", "user2fa", "pass2fa"),
-
- // Credit card
- CreateTestCreditCard(),
-
- // Note
- CreateTestNote(),
-
- // Item with attachment
- CreateTestItemWithAttachment(),
- };
-
- var folders = new List<Folder>
- {
- new()
- {
- Id = Guid.NewGuid(),
- Name = "Test Folder",
- Weight = 0,
- CreatedAt = DateTime.UtcNow,
- UpdatedAt = DateTime.UtcNow,
- },
- };
-
- var tags = new List<Tag>
- {
- new()
- {
- Id = Guid.NewGuid(),
- Name = "Test Tag",
- Color = "#FF0000",
- DisplayOrder = 0,
- CreatedAt = DateTime.UtcNow,
- UpdatedAt = DateTime.UtcNow,
- },
- };
-
- var itemTags = new List<ItemTag>
- {
- new()
- {
- ItemId = items[0].Id,
- TagId = tags[0].Id,
- },
- };
-
- var fieldDefinitions = new List<FieldDefinition>();
-
- // Act
- var avuxBytes = await VaultExportService.ExportToAvuxAsync(
- items,
- folders,
- tags,
- itemTags,
- fieldDefinitions,
- new List<Logo>(),
-
- // Assert
- Assert.That(avuxBytes, Is.Not.Null);
- Assert.That(avuxBytes.Length, Is.GreaterThan(0));
-
- // Verify it's a valid ZIP file
- using var zipStream = new MemoryStream(avuxBytes);
- using var archive = new ZipArchive(zipStream, ZipArchiveMode.Read);
-
- var manifestEntry = archive.GetEntry("manifest.json");
- Assert.That(manifestEntry, Is.Not.Null, "manifest.json should exist");
-
- // Verify manifest content
- using var reader = new StreamReader(manifestEntry.Open());
- var manifestJson = await reader.ReadToEndAsync();
- Assert.That(manifestJson, Does.Contain("\"version\""));
- Assert.That(manifestJson, Does.Contain("\"items\""));
- Assert.That(manifestJson, Does.Contain("\"folders\""));
- Assert.That(manifestJson, Does.Contain("Basic Login"));
- Assert.That(manifestJson, Does.Contain("Test Folder"));
- }
-
- /// <summary>
- /// Test case for importing vault data from .avux format.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportVaultFromAvuxFormat()
- {
- // Arrange - Create test data and export it
- var items = new List<Item>
- {
- CreateTestItem("Import Test Item", ItemType.Login, new Dictionary<string, string>
- {
- { FieldKey.LoginUsername, "importuser" },
- { FieldKey.LoginPassword, "importpass" },
- { FieldKey.LoginUrl, "https://import.example.com" },
- }),
- CreateTestItemWithTotp("Import 2FA", "user2fa", "pass2fa"),
- CreateTestCreditCard(),
- };
-
- var avuxBytes = await VaultExportService.ExportToAvuxAsync(
- items,
- new List<Folder>(),
- new List<Tag>(),
- new List<ItemTag>(),
- new List<FieldDefinition>(),
- new List<Logo>(),
-
- // Act - Import the .avux file
- var importedCredentials = await VaultImportService.ImportFromAvuxAsync(avuxBytes);
-
- // Assert
- Assert.That(importedCredentials, Has.Count.EqualTo(3));
-
- var basicLogin = importedCredentials.First(c => c.ServiceName == "Import Test Item");
- Assert.Multiple(() =>
- {
- Assert.That(basicLogin.Username, Is.EqualTo("importuser"));
- Assert.That(basicLogin.Password, Is.EqualTo("importpass"));
- Assert.That(basicLogin.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://import.example.com"));
- });
-
- var twoFaLogin = importedCredentials.First(c => c.ServiceName == "Import 2FA");
- Assert.Multiple(() =>
- {
- Assert.That(twoFaLogin.Username, Is.EqualTo("user2fa"));
- Assert.That(twoFaLogin.Password, Is.EqualTo("pass2fa"));
- Assert.That(twoFaLogin.TwoFactorSecret, Is.Not.Empty);
- });
-
- var creditCard = importedCredentials.First(c => c.ItemType == ImportedItemType.Creditcard);
- Assert.Multiple(() =>
- {
- Assert.That(creditCard.Creditcard, Is.Not.Null);
- Assert.That(creditCard.Creditcard!.Number, Is.EqualTo("4111111111111111"));
- Assert.That(creditCard.Creditcard.CardholderName, Is.EqualTo("Test Holder"));
- });
- }
-
- /// <summary>
- /// Test case for round-trip export and import preserving all data.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task AvuxRoundTripPreservesAllData()
- {
- // Arrange
- var originalItem = CreateTestItem("Round Trip Test", ItemType.Login, new Dictionary<string, string>
- {
- { FieldKey.LoginUsername, "roundtripuser" },
- { FieldKey.LoginPassword, "roundtrippass" },
- { FieldKey.LoginUrl, "https://roundtrip.example.com" },
- { FieldKey.NotesContent, "Round trip notes" },
- { FieldKey.AliasFirstName, "John" },
- { FieldKey.AliasLastName, "Doe" },
- });
-
- // Add TOTP
- originalItem.TotpCodes.Add(new TotpCode
- {
- Id = Guid.NewGuid(),
- ItemId = originalItem.Id,
- Name = "Round Trip TOTP",
- SecretKey = "JBSWY3DPEHPK3PXP",
- CreatedAt = DateTime.UtcNow,
- UpdatedAt = DateTime.UtcNow,
- });
-
- // Export
- var avuxBytes = await VaultExportService.ExportToAvuxAsync(
- new List<Item> { originalItem },
- new List<Folder>(),
- new List<Tag>(),
- new List<ItemTag>(),
- new List<FieldDefinition>(),
- new List<Logo>(),
-
- // Import
- var importedCredentials = await VaultImportService.ImportFromAvuxAsync(avuxBytes);
-
- // Assert
- Assert.That(importedCredentials, Has.Count.EqualTo(1));
-
- var imported = importedCredentials[0];
- Assert.Multiple(() =>
- {
- Assert.That(imported.ServiceName, Is.EqualTo("Round Trip Test"));
- Assert.That(imported.Username, Is.EqualTo("roundtripuser"));
- Assert.That(imported.Password, Is.EqualTo("roundtrippass"));
- Assert.That(imported.ServiceUrls?.FirstOrDefault(), Is.EqualTo("https://roundtrip.example.com"));
- Assert.That(imported.Notes, Is.EqualTo("Round trip notes"));
- Assert.That(imported.Alias?.FirstName, Is.EqualTo("John"));
- Assert.That(imported.Alias?.LastName, Is.EqualTo("Doe"));
- Assert.That(imported.TwoFactorSecret, Is.EqualTo("JBSWY3DPEHPK3PXP"));
- });
- }
-
- /// <summary>
- /// Test case verifying that custom (user-defined) fields are exported and imported correctly
- /// during a .avux export and import.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task AvuxRoundTripPreservesCustomFields()
- {
- // Arrange - an item with two custom fields: a plain text one and a hidden secret one.
- var item = CreateTestItem("Custom Field Item", ItemType.Login, new Dictionary<string, string>
- {
- { FieldKey.LoginUsername, "customuser" },
- });
-
- var textFieldDef = new FieldDefinition
- {
- Id = Guid.NewGuid(),
- Label = "Security Question",
- FieldType = "Text",
- IsHidden = false,
- Weight = 3,
- CreatedAt = DateTime.UtcNow,
- UpdatedAt = DateTime.UtcNow,
- };
- var hiddenFieldDef = new FieldDefinition
- {
- Id = Guid.NewGuid(),
- Label = "Recovery Code",
- FieldType = "Password",
- IsHidden = true,
- Weight = 5,
- CreatedAt = DateTime.UtcNow,
- UpdatedAt = DateTime.UtcNow,
- };
-
- AddCustomFieldValue(item, textFieldDef, "My first pet");
- AddCustomFieldValue(item, hiddenFieldDef, "super-secret-recovery");
-
- var fieldDefinitions = new List<FieldDefinition> { textFieldDef, hiddenFieldDef };
-
- // Export
- var avuxBytes = await VaultExportService.ExportToAvuxAsync(
- new List<Item> { item },
- new List<Folder>(),
- new List<Tag>(),
- new List<ItemTag>(),
- fieldDefinitions,
- new List<Logo>(),
-
- // Import
- var importedCredentials = await VaultImportService.ImportFromAvuxAsync(avuxBytes);
-
- // Assert - custom field values survive the import with their full metadata.
- Assert.That(importedCredentials, Has.Count.EqualTo(1));
- var imported = importedCredentials[0];
- Assert.That(imported.CustomFieldValues, Is.Not.Null);
- Assert.That(imported.CustomFieldValues, Has.Count.EqualTo(2));
-
- var textField = imported.CustomFieldValues!.First(f => f.Label == "Security Question");
- Assert.Multiple(() =>
- {
- Assert.That(textField.Value, Is.EqualTo("My first pet"));
- Assert.That(textField.FieldType, Is.EqualTo(FieldTypeKind.Text));
- Assert.That(textField.IsHidden, Is.False);
- Assert.That(textField.Weight, Is.EqualTo(3));
- });
-
- var hiddenField = imported.CustomFieldValues!.First(f => f.Label == "Recovery Code");
- Assert.Multiple(() =>
- {
- Assert.That(hiddenField.Value, Is.EqualTo("super-secret-recovery"));
- Assert.That(hiddenField.FieldType, Is.EqualTo(FieldTypeKind.Password));
- Assert.That(hiddenField.IsHidden, Is.True);
- Assert.That(hiddenField.Weight, Is.EqualTo(5));
- });
-
- // Assert - converting the imported credentials to vault items recreates the custom
- // FieldDefinitions and their FieldValues (this is the path that previously dropped them).
- var convertedItems = BaseImporter.ConvertToItem(importedCredentials);
- var convertedItem = convertedItems.Single();
-
- var customFieldValues = convertedItem.FieldValues
- .Where(fv => fv.FieldKey == null && fv.FieldDefinition != null)
- .ToList();
- Assert.That(customFieldValues, Has.Count.EqualTo(2));
-
- var recoveryValue = customFieldValues.First(fv => fv.FieldDefinition!.Label == "Recovery Code");
- Assert.Multiple(() =>
- {
- Assert.That(recoveryValue.Value, Is.EqualTo("super-secret-recovery"));
- Assert.That(recoveryValue.FieldDefinition!.FieldType, Is.EqualTo("Password"));
- Assert.That(recoveryValue.FieldDefinition.IsHidden, Is.True);
- Assert.That(recoveryValue.FieldDefinition.Weight, Is.EqualTo(5));
- });
- }
-
- /// <summary>
- /// Test case for exporting and importing vault with logos in .avux format.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ExportAndImportAvuxWithLogos()
- {
- // Arrange
- var items = new List<Item>();
- var logoId1 = Guid.NewGuid();
- var logoId2 = Guid.NewGuid();
-
- var item1 = new Item
- {
- Id = Guid.NewGuid(),
- Name = "GitHub",
- ItemType = "Login",
- LogoId = logoId1,
- CreatedAt = DateTime.UtcNow,
- UpdatedAt = DateTime.UtcNow,
- };
- AddFieldValue(item1, FieldKey.LoginUsername, "testuser");
- AddFieldValue(item1, FieldKey.LoginPassword, "password123");
- AddFieldValue(item1, FieldKey.LoginUrl, "https://github.com");
- items.Add(item1);
-
- var item2 = new Item
- {
- Id = Guid.NewGuid(),
- Name = "Google",
- ItemType = "Login",
- LogoId = logoId2,
- CreatedAt = DateTime.UtcNow,
- UpdatedAt = DateTime.UtcNow,
- };
- AddFieldValue(item2, FieldKey.LoginUsername, "[email protected]");
- AddFieldValue(item2, FieldKey.LoginPassword, "pass456");
- AddFieldValue(item2, FieldKey.LoginUrl, "https://google.com");
- items.Add(item2);
-
- // Third item uses same logo as item1 (deduplication test)
- var item3 = new Item
- {
- Id = Guid.NewGuid(),
- Name = "GitHub Issue Tracker",
- ItemType = "Login",
- LogoId = logoId1,
- CreatedAt = DateTime.UtcNow,
- UpdatedAt = DateTime.UtcNow,
- };
- AddFieldValue(item3, FieldKey.LoginUsername, "issueuser");
- AddFieldValue(item3, FieldKey.LoginPassword, "issuepass");
- items.Add(item3);
-
- var logos = new List<Logo>
- {
- new Logo
- {
- Id = logoId1,
- Source = "github.com",
- FileData = new byte[] { 1, 2, 3, 4, 5 },
- MimeType = "image/png",
- FetchedAt = DateTime.UtcNow,
- CreatedAt = DateTime.UtcNow,
- UpdatedAt = DateTime.UtcNow,
- },
- new Logo
- {
- Id = logoId2,
- Source = "google.com",
- FileData = new byte[] { 6, 7, 8, 9, 10 },
- MimeType = "image/png",
- FetchedAt = DateTime.UtcNow,
- CreatedAt = DateTime.UtcNow,
- UpdatedAt = DateTime.UtcNow,
- },
- };
-
- // Act - Export
- var zipBytes = await VaultExportService.ExportToAvuxAsync(
- items,
- new List<Folder>(),
- new List<Tag>(),
- new List<ItemTag>(),
- new List<FieldDefinition>(),
- logos,
- "testuser");
-
- // Act - Import
- var credentials = await VaultImportService.ImportFromAvuxAsync(zipBytes);
-
- // Assert - After refactor, logos are embedded in FaviconBytes property
- Assert.That(credentials, Has.Count.EqualTo(3));
-
- // Verify first credential
- var githubCred = credentials.First(c => c.ServiceName == "GitHub");
- Assert.Multiple(() =>
- {
- Assert.That(githubCred.ServiceName, Is.EqualTo("GitHub"));
- Assert.That(githubCred.Username, Is.EqualTo("testuser"));
- Assert.That(githubCred.Password, Is.EqualTo("password123"));
- Assert.That(githubCred.FaviconBytes, Is.EqualTo(new byte[] { 1, 2, 3, 4, 5 }), "Logo should be embedded in FaviconBytes");
- });
-
- // Verify second credential
- var googleCred = credentials.First(c => c.ServiceName == "Google");
- Assert.Multiple(() =>
- {
- Assert.That(googleCred.ServiceName, Is.EqualTo("Google"));
- Assert.That(googleCred.Username, Is.EqualTo("[email protected]"));
- Assert.That(googleCred.Password, Is.EqualTo("pass456"));
- Assert.That(googleCred.FaviconBytes, Is.EqualTo(new byte[] { 6, 7, 8, 9, 10 }), "Logo should be embedded in FaviconBytes");
- });
-
- // Verify third credential uses same logo as first
- var githubIssueCred = credentials.First(c => c.ServiceName == "GitHub Issue Tracker");
- Assert.That(githubIssueCred.FaviconBytes, Is.EqualTo(new byte[] { 1, 2, 3, 4, 5 }), "Should have same logo data as GitHub");
- }
-
- /// <summary>
- /// Helper method to create a test item with specific fields.
- /// </summary>
- private static Item CreateTestItem(string name, string itemType, Dictionary<string, string> fields)
- {
- var item = new Item
- {
- Id = Guid.NewGuid(),
- Name = name,
- ItemType = itemType,
- CreatedAt = DateTime.UtcNow,
- UpdatedAt = DateTime.UtcNow,
- };
-
- foreach (var field in fields)
- {
- AddFieldValue(item, field.Key, field.Value);
- }
-
- return item;
- }
-
- /// <summary>
- /// Helper method to create a test item with TOTP.
- /// </summary>
- private static Item CreateTestItemWithTotp(string name, string username, string password)
- {
- var item = CreateTestItem(name, ItemType.Login, new Dictionary<string, string>
- {
- { FieldKey.LoginUsername, username },
- { FieldKey.LoginPassword, password },
- });
-
- item.TotpCodes.Add(new TotpCode
- {
- Id = Guid.NewGuid(),
- ItemId = item.Id,
- Name = "Test TOTP",
- SecretKey = "JBSWY3DPEHPK3PXP",
- CreatedAt = DateTime.UtcNow,
- UpdatedAt = DateTime.UtcNow,
- });
-
- return item;
- }
-
- /// <summary>
- /// Helper method to create a test credit card.
- /// </summary>
- private static Item CreateTestCreditCard()
- {
- return CreateTestItem("Test Card", ItemType.CreditCard, new Dictionary<string, string>
- {
- { FieldKey.CardNumber, "4111111111111111" },
- { FieldKey.CardCardholderName, "Test Holder" },
- { FieldKey.CardExpiryMonth, "12" },
- { FieldKey.CardExpiryYear, "2025" },
- { FieldKey.CardCvv, "123" },
- { FieldKey.CardPin, "1234" },
- });
- }
-
- /// <summary>
- /// Helper method to create a test note.
- /// </summary>
- private static Item CreateTestNote()
- {
- return CreateTestItem("Test Note", ItemType.Note, new Dictionary<string, string>
- {
- { FieldKey.NotesContent, "This is a test secure note with important information." },
- });
- }
-
- /// <summary>
- /// Helper method to create a test item with attachment.
- /// </summary>
- private static Item CreateTestItemWithAttachment()
- {
- var item = CreateTestItem("Item with Attachment", ItemType.Login, new Dictionary<string, string>
- {
- { FieldKey.LoginUsername, "attachuser" },
- { FieldKey.LoginPassword, "attachpass" },
- });
-
- item.Attachments.Add(new Attachment
- {
- Id = Guid.NewGuid(),
- ItemId = item.Id,
- Filename = "test-file.txt",
- Blob = System.Text.Encoding.UTF8.GetBytes("Test attachment content"),
- CreatedAt = DateTime.UtcNow,
- UpdatedAt = DateTime.UtcNow,
- });
-
- 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)).Credentials;
-
- // 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.CustomFieldValues, Is.Not.Null);
- Assert.That(loginItem.CustomFieldValues, Has.Count.EqualTo(3));
-
- var securityQuestion = loginItem.CustomFieldValues!.First(f => f.Label == "Security Question");
- Assert.That(securityQuestion.Value, Is.EqualTo("My first pet")); // Type 0: Text
- Assert.That(securityQuestion.FieldType, Is.EqualTo(FieldTypeKind.Text));
-
- var apiKey = loginItem.CustomFieldValues!.First(f => f.Label == "API Key");
- Assert.That(apiKey.Value, Is.EqualTo("sk_test_123456789")); // Type 1: Hidden
- Assert.That(apiKey.FieldType, Is.EqualTo(FieldTypeKind.Hidden));
-
- var twoFactorEnabled = loginItem.CustomFieldValues!.First(f => f.Label == "Two Factor Enabled");
- Assert.That(twoFactorEnabled.Value, Is.EqualTo("true")); // Type 2: Boolean
- Assert.That(twoFactorEnabled.FieldType, Is.EqualTo(FieldTypeKind.Text));
-
- // 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>
- /// Regression test: a Bitwarden ZIP that includes a directory entry for the
- /// item's attachment folder (e.g. "attachments/&lt;id&gt;/") must not produce a
- /// phantom attachment with an empty filename. Many ZIP creators emit such
- /// directory entries by default, and they previously matched the StartsWith
- /// filter and ended up as empty-blob attachments rendered as "(unavailable)".
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportBitwardenZipWithDirectoryEntriesIgnoresPhantomAttachments()
- {
- // Arrange - build a Bitwarden-style ZIP in memory containing both a
- // directory entry and a single file entry under the item's attachment folder.
- const string ItemId = "item-with-attachment-uuid";
- const string FileName = "dataset_Backup_keys.json";
- var fileBytes = System.Text.Encoding.UTF8.GetBytes("{\"keys\":\"value\"}");
-
- const string DataJson = """
- {
- "encrypted": false,
- "folders": [],
- "items": [
- {
- "id": "item-with-attachment-uuid",
- "organizationId": null,
- "folderId": null,
- "type": 1,
- "reprompt": 0,
- "name": "Login with Attachment",
- "notes": "This item has an attachment",
- "favorite": false,
- "revisionDate": "2023-08-15T16:30:00.000Z",
- "fields": [],
- "login": {
- "uris": [{"match": null, "uri": "https://secure.example.com"}],
- "username": "admin",
- "password": "AdminPass456!",
- "totp": null
- },
- "collectionIds": null
- }
- ]
- }
- """;
-
- byte[] zipBytes;
- using (var ms = new MemoryStream())
- {
- using (var archive = new ZipArchive(ms, ZipArchiveMode.Create, leaveOpen: true))
- {
- var dataEntry = archive.CreateEntry("data.json");
- using (var writer = new StreamWriter(dataEntry.Open()))
- {
- await writer.WriteAsync(DataJson);
- }
-
- // Directory entries (zero-byte, trailing slash) — emitted by many ZIP tools
- // and the source of the original "(unavailable)" duplicate.
- archive.CreateEntry("attachments/");
- archive.CreateEntry($"attachments/{ItemId}/");
-
- var fileEntry = archive.CreateEntry($"attachments/{ItemId}/{FileName}");
- using (var fileStream = fileEntry.Open())
- {
- await fileStream.WriteAsync(fileBytes);
- }
- }
-
- zipBytes = ms.ToArray();
- }
-
- // Act
- var importer = new BitwardenZipImporter();
- var importedCredentials = (await importer.ImportFromArchiveAsync(zipBytes)).Credentials;
-
- // Assert - exactly one attachment with the real filename and content,
- // and no phantom empty-filename entry from the directory entries.
- Assert.That(importedCredentials, Has.Count.EqualTo(1));
- var credential = importedCredentials[0];
- Assert.That(credential.Attachments, Is.Not.Null);
- Assert.That(credential.Attachments, Has.Count.EqualTo(1));
- Assert.Multiple(() =>
- {
- Assert.That(credential.Attachments![0].Filename, Is.EqualTo(FileName));
- Assert.That(credential.Attachments[0].Blob, Is.EqualTo(fileBytes));
- Assert.That(credential.Attachments.Any(a => string.IsNullOrEmpty(a.Filename)), Is.False);
- Assert.That(credential.Attachments.Any(a => a.Blob == null || a.Blob.Length == 0), Is.False);
- });
- }
-
- /// <summary>
- /// A non-ZIP byte stream surfaces a stage=Archive ImportException so the UI can show
- /// the user "this isn't a valid archive" instead of a generic message.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public Task BitwardenZipImporterCorruptArchiveThrowsArchiveStageException()
- {
- // "Not a zip file at all" — opening this as a ZipArchive should throw InvalidDataException,
- // which BaseArchiveImporter must catch and re-wrap as ImportException(Archive).
- var corruptBytes = System.Text.Encoding.UTF8.GetBytes("definitely not a zip");
-
- var importer = new BitwardenZipImporter();
- var ex = Assert.ThrowsAsync<ImportException>(async () =>
- await importer.ImportFromArchiveAsync(corruptBytes));
-
- Assert.Multiple(() =>
- {
- Assert.That(ex!.Stage, Is.EqualTo(ImportStage.Archive));
- Assert.That(ex.Message, Does.Contain("not a valid ZIP archive"));
- });
-
- return Task.CompletedTask;
- }
-
- /// <summary>
- /// A ZIP that opens but doesn't contain data.json surfaces a stage=Parse ImportException
- /// naming the missing entry. Gives the user a concrete diagnostic instead of "an error occurred".
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task BitwardenZipImporterMissingManifestThrowsParseStageException()
- {
- byte[] zipBytes;
- using (var ms = new MemoryStream())
- {
- using (new ZipArchive(ms, ZipArchiveMode.Create, leaveOpen: true))
- {
- // Empty archive — no data.json
- }
-
- zipBytes = ms.ToArray();
- }
-
- var importer = new BitwardenZipImporter();
- var ex = Assert.ThrowsAsync<ImportException>(async () =>
- await importer.ImportFromArchiveAsync(zipBytes));
-
- Assert.Multiple(() =>
- {
- Assert.That(ex!.Stage, Is.EqualTo(ImportStage.Parse));
- Assert.That(ex.Message, Does.Contain("data.json"));
- Assert.That(ex.Message, Does.Contain("not found"));
- });
-
- await Task.CompletedTask;
- }
-
- /// <summary>
- /// A ZIP whose data.json is malformed surfaces a stage=Parse ImportException carrying the JSONPath,
- /// line, and byte position from the underlying JsonException. The precise diagnostic users need to
- /// share when reporting an import failure.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task BitwardenZipImporterMalformedJsonReportsPathAndPosition()
- {
- byte[] zipBytes;
- using (var ms = new MemoryStream())
- {
- using (var archive = new ZipArchive(ms, ZipArchiveMode.Create, leaveOpen: true))
- {
- var dataEntry = archive.CreateEntry("data.json");
- using var writer = new StreamWriter(dataEntry.Open());
-
- // Valid up to "items": then truncated mid-object — JsonSerializer will throw with a
- // populated Path / LineNumber / BytePositionInLine.
- await writer.WriteAsync("{\"encrypted\":false,\"folders\":[],\"items\":[{");
- }
-
- zipBytes = ms.ToArray();
- }
-
- var importer = new BitwardenZipImporter();
- var ex = Assert.ThrowsAsync<ImportException>(async () =>
- await importer.ImportFromArchiveAsync(zipBytes));
-
- Assert.Multiple(() =>
- {
- Assert.That(ex!.Stage, Is.EqualTo(ImportStage.Parse));
- Assert.That(ex.Message, Does.Contain("data.json"));
- Assert.That(ex.Message, Does.Contain("Failed to parse"));
- Assert.That(ex.InnerException, Is.TypeOf<System.Text.Json.JsonException>());
- });
- }
-
- /// <summary>
- /// Encrypted Bitwarden exports raise a stage=Parse ImportException with the actionable message
- /// "export as unencrypted" so the user knows how to fix their export.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task BitwardenZipImporterEncryptedExportReportsClearError()
- {
- byte[] zipBytes;
- using (var ms = new MemoryStream())
- {
- using (var archive = new ZipArchive(ms, ZipArchiveMode.Create, leaveOpen: true))
- {
- var dataEntry = archive.CreateEntry("data.json");
- using var writer = new StreamWriter(dataEntry.Open());
- await writer.WriteAsync("{\"encrypted\":true,\"folders\":[],\"items\":[]}");
- }
-
- zipBytes = ms.ToArray();
- }
-
- var importer = new BitwardenZipImporter();
- var ex = Assert.ThrowsAsync<ImportException>(async () =>
- await importer.ImportFromArchiveAsync(zipBytes));
-
- Assert.Multiple(() =>
- {
- Assert.That(ex!.Stage, Is.EqualTo(ImportStage.Parse));
- Assert.That(ex.Message, Does.Contain("Encrypted Bitwarden"));
- Assert.That(ex.Message, Does.Contain("unencrypted"));
- });
-
- await Task.CompletedTask;
- }
-
- /// <summary>
- /// Test case for importing credentials from 1Password .1pux export format.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportCredentialsFromOnePassword1pux()
- {
- // Arrange
- var zipBytes = await ResourceReaderUtility.ReadEmbeddedResourceBytesAsync("AliasVault.UnitTests.TestData.Exports.1password_8.1pux");
-
- // Act
- var importer = new OnePassword1puxImporter();
- var importedCredentials = (await importer.ImportFromArchiveAsync(zipBytes)).Credentials;
-
- // Assert
- Assert.That(importedCredentials, Has.Count.EqualTo(6));
-
- // 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("jdoe"));
- Assert.That(loginItem.Password, Is.EqualTo("mySecurePassword123"));
- 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:jdoe?secret=JBSWY3DPEHPK3PXP&issuer=Example"));
- Assert.That(loginItem.Notes, Is.EqualTo("My login notes here"));
- Assert.That(loginItem.FolderPath, Is.Null); // Single vault "Personal" promoted to root
- Assert.That(loginItem.ItemType, Is.EqualTo(ImportedItemType.Login));
- Assert.That(loginItem.Tags, Has.Count.EqualTo(2));
- Assert.That(loginItem.Tags, Does.Contain("work"));
- Assert.That(loginItem.Tags, Does.Contain("important"));
- Assert.That(loginItem.CustomFieldValues, Is.Not.Null);
- var recoveryEmail = loginItem.CustomFieldValues!.First(f => f.Label == "Recovery Email");
- Assert.That(recoveryEmail.Value, Is.EqualTo("[email protected]"));
- });
-
- // Verify created/updated timestamps are converted from Unix time
- var expectedCreatedDate = DateTimeOffset.FromUnixTimeSeconds(1614298956).UtcDateTime;
- var expectedUpdatedDate = DateTimeOffset.FromUnixTimeSeconds(1635346445).UtcDateTime;
- Assert.Multiple(() =>
- {
- Assert.That(loginItem.CreatedAt, Is.EqualTo(expectedCreatedDate));
- Assert.That(loginItem.UpdatedAt, Is.EqualTo(expectedUpdatedDate));
- });
-
- // Test Credit Card item
- var cardItem = importedCredentials.First(c => c.ServiceName == "My Visa Card");
- Assert.Multiple(() =>
- {
- Assert.That(cardItem.ServiceName, Is.EqualTo("My Visa Card"));
- Assert.That(cardItem.Notes, Is.EqualTo("Primary credit card"));
- Assert.That(cardItem.FolderPath, Is.Null); // Single vault "Personal" promoted to root
- 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.Cvv, Is.EqualTo("123"));
- Assert.That(cardItem.Creditcard.Pin, Is.EqualTo("1234"));
- Assert.That(cardItem.Creditcard.ExpiryYear, Is.EqualTo("2025"));
- Assert.That(cardItem.Creditcard.ExpiryMonth, Is.EqualTo("12"));
- });
-
- // Test Identity item
- var identityItem = importedCredentials.First(c => c.ServiceName == "My Identity");
- Assert.Multiple(() =>
- {
- Assert.That(identityItem.ServiceName, Is.EqualTo("My Identity"));
- Assert.That(identityItem.ItemType, Is.EqualTo(ImportedItemType.Alias));
- Assert.That(identityItem.Alias, Is.Not.Null);
- Assert.That(identityItem.Alias!.FirstName, Is.EqualTo("Jane"));
- Assert.That(identityItem.Alias.LastName, Is.EqualTo("Smith"));
- Assert.That(identityItem.Alias.Gender, Is.EqualTo("Female"));
- Assert.That(identityItem.Alias.BirthDate, Is.Not.Null);
- var expectedBirthDate = DateTimeOffset.FromUnixTimeSeconds(631152000).UtcDateTime;
- Assert.That(identityItem.Alias.BirthDate, Is.EqualTo(expectedBirthDate));
- });
-
- // 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 important information."));
- Assert.That(noteItem.ItemType, Is.EqualTo(ImportedItemType.Note));
- });
-
- // Test Login from Work vault
- var workLoginItem = importedCredentials.First(c => c.ServiceName == "Work Portal");
- Assert.Multiple(() =>
- {
- Assert.That(workLoginItem.ServiceName, Is.EqualTo("Work Portal"));
- Assert.That(workLoginItem.Username, Is.EqualTo("admin"));
- Assert.That(workLoginItem.Password, Is.EqualTo("WorkPassword789!"));
- Assert.That(workLoginItem.FolderPath, Is.EqualTo("Work"));
- Assert.That(workLoginItem.ItemType, Is.EqualTo(ImportedItemType.Login));
- });
-
- // Test Document item with attachment
- var docItem = importedCredentials.First(c => c.ServiceName == "Sample Document");
- Assert.Multiple(() =>
- {
- Assert.That(docItem.ServiceName, Is.EqualTo("Sample Document"));
- Assert.That(docItem.Notes, Is.EqualTo("Test document with attachment"));
- Assert.That(docItem.FolderPath, Is.Null); // Single vault "Personal" promoted to root
- Assert.That(docItem.ItemType, Is.EqualTo(ImportedItemType.Note));
- Assert.That(docItem.Attachments, Is.Not.Null);
- Assert.That(docItem.Attachments, Has.Count.EqualTo(1));
- Assert.That(docItem.Attachments![0].Filename, Is.EqualTo("sample-document.pdf"));
- Assert.That(docItem.Attachments[0].Blob, Is.Not.Empty);
- var attachmentContent = System.Text.Encoding.UTF8.GetString(docItem.Attachments[0].Blob!);
- Assert.That(attachmentContent, Does.Contain("Sample document content"));
- });
-
- // Verify conversion to Item works correctly
- var convertedItems = BaseImporter.ConvertToItem(importedCredentials);
- Assert.That(convertedItems, Has.Count.EqualTo(6));
-
- 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 a Proton Pass .zip export.
- /// </summary>
- /// <returns>Async task.</returns>
- [Test]
- public async Task ImportCredentialsFromProtonPassZip()
- {
- // Arrange
- var zipBytes = await ResourceReaderUtility.ReadEmbeddedResourceBytesAsync("AliasVault.UnitTests.TestData.Exports.protonpass.zip");
-
- // Act
- var importer = new ProtonPassZipImporter();
- var importedCredentials = (await importer.ImportFromArchiveAsync(zipBytes)).Credentials;
-
- // Assert
- Assert.That(importedCredentials, Has.Count.EqualTo(7));
-
- // Login with TOTP URI.
- var loginWithTotp = importedCredentials.First(c => c.ServiceName == "Test proton 1");
- Assert.Multiple(() =>
- {
- Assert.That(loginWithTotp.ItemType, Is.EqualTo(ImportedItemType.Login));
- Assert.That(loginWithTotp.Username, Is.EqualTo("user1"));
- Assert.That(loginWithTotp.Password, Is.EqualTo("pass1"));
- Assert.That(loginWithTotp.ServiceUrls, Has.Count.EqualTo(1));
- Assert.That(loginWithTotp.ServiceUrls![0], Is.EqualTo("https://www.website.com/"));
- Assert.That(loginWithTotp.TwoFactorSecret, Does.StartWith("otpauth://totp/"));
- Assert.That(loginWithTotp.FolderPath, Is.Null); // "Personal" vault promoted to root
- Assert.That(loginWithTotp.Email, Is.Null);
- });
-
- var expectedCreatedAt = DateTimeOffset.FromUnixTimeSeconds(1744362003).UtcDateTime;
- Assert.That(loginWithTotp.CreatedAt, Is.EqualTo(expectedCreatedAt));
-
- // Alias item
- var aliasItem = importedCredentials.First(c => c.ServiceName == "Test alias");
- Assert.Multiple(() =>
- {
- Assert.That(aliasItem.ItemType, Is.EqualTo(ImportedItemType.Login));
- Assert.That(aliasItem.Email, Is.EqualTo("[email protected]"));
- Assert.That(aliasItem.Username, Is.EqualTo("[email protected]"));
- Assert.That(aliasItem.Password, Is.Null);
- Assert.That(aliasItem.FolderPath, Is.Null);
- });
-
- // Login without URLs.
- var loginNoUrls = importedCredentials.First(c => c.ServiceName == "Test proton2");
- Assert.Multiple(() =>
- {
- Assert.That(loginNoUrls.Username, Is.EqualTo("testuser2"));
- Assert.That(loginNoUrls.Password, Is.EqualTo("testpassword2"));
- Assert.That(loginNoUrls.ServiceUrls, Is.Null);
- Assert.That(loginNoUrls.TwoFactorSecret, Is.Null);
- });
-
- // Login without a password.
- var loginNoPass = importedCredentials.First(c => c.ServiceName == "testwithoutpass");
- Assert.Multiple(() =>
- {
- Assert.That(loginNoPass.Username, Is.EqualTo("testuser"));
- Assert.That(loginNoPass.Password, Is.Null);
- });
-
- // Login with URLs and a note.
- var loginWithNote = importedCredentials.First(c => c.ServiceName == "Customfields");
- Assert.Multiple(() =>
- {
- Assert.That(loginWithNote.Username, Is.EqualTo("usernamecustom"));
- Assert.That(loginWithNote.Password, Is.EqualTo("passwordecustom"));
- Assert.That(loginWithNote.Notes, Is.EqualTo("Notecustom"));
- Assert.That(loginWithNote.ServiceUrls, Has.Count.EqualTo(1));
- Assert.That(loginWithNote.ServiceUrls![0], Is.EqualTo("http://example.com/"));
- });
-
- // Secure note
- var noteItem = importedCredentials.First(c => c.ServiceName == "Customnote");
- Assert.Multiple(() =>
- {
- Assert.That(noteItem.ItemType, Is.EqualTo(ImportedItemType.Note));
- Assert.That(noteItem.Notes, Is.EqualTo("Customnotecontent"));
- });
-
- // Credit card
- var cardItem = importedCredentials.First(c => c.ServiceName == "Testcreditcard");
- Assert.Multiple(() =>
- {
- Assert.That(cardItem.ItemType, Is.EqualTo(ImportedItemType.Creditcard));
- Assert.That(cardItem.Notes, Is.EqualTo("Custom note for creditcard"));
- Assert.That(cardItem.FolderPath, Is.Null);
- Assert.That(cardItem.Creditcard, Is.Not.Null);
- Assert.That(cardItem.Creditcard!.CardholderName, Is.EqualTo("J Johnson"));
- Assert.That(cardItem.Creditcard.Number, Is.EqualTo("1234123412341234123"));
- Assert.That(cardItem.Creditcard.Cvv, Is.EqualTo("123"));
- Assert.That(cardItem.Creditcard.Pin, Is.EqualTo("1234"));
- Assert.That(cardItem.Creditcard.ExpiryYear, Is.EqualTo("2029"));
- Assert.That(cardItem.Creditcard.ExpiryMonth, Is.EqualTo("06"));
- });
-
- // Conversion to Item extracts the TOTP secret from the URI.
- var convertedItems = BaseImporter.ConvertToItem(importedCredentials);
- Assert.That(convertedItems, Has.Count.EqualTo(7));
-
- var convertedLogin = convertedItems.First(i => i.Name == "Test proton 1");
- 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("PLW4SB3PQ7MKVXY2MXF4NEXS6Y"));
- });
- }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/AliasVault.ImportExport.csproj b/apps/server/Utilities/AliasVault.ImportExport/AliasVault.ImportExport.csproj
deleted file mode 100644
index 0297138c7..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/AliasVault.ImportExport.csproj
+++ /dev/null
@@ -1,25 +0,0 @@
-<Project Sdk="Microsoft.NET.Sdk">
-
- <PropertyGroup>
- <TargetFramework>net10.0</TargetFramework>
- <ImplicitUsings>enable</ImplicitUsings>
- <Nullable>enable</Nullable>
- <LangVersion>14</LangVersion>
- </PropertyGroup>
-
- <ItemGroup>
- <AdditionalFiles Include="..\..\stylecop.json" Link="stylecop.json" />
- </ItemGroup>
-
- <ItemGroup>
- <PackageReference Include="CsvHelper" Version="33.1.0" />
- </ItemGroup>
-
- <ItemGroup>
- <ProjectReference Include="..\..\Databases\AliasClientDb\AliasClientDb.csproj" />
- <ProjectReference Include="..\..\Shared\AliasVault.Shared.Core\AliasVault.Shared.Core.csproj" />
- <ProjectReference Include="..\..\Utilities\AliasVault.TotpGenerator\AliasVault.TotpGenerator.csproj" />
- <ProjectReference Include="..\..\Utilities\Cryptography\AliasVault.Cryptography.Client\AliasVault.Cryptography.Client.csproj" />
- </ItemGroup>
-
-</Project>
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Constants/AvexConstants.cs b/apps/server/Utilities/AliasVault.ImportExport/Constants/AvexConstants.cs
deleted file mode 100644
index 61c742267..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Constants/AvexConstants.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="AvexConstants.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.Constants;
-
-/// <summary>
-/// Constants for the .avex (AliasVault Encrypted eXport) file format.
-/// </summary>
-public static class AvexConstants
-{
- /// <summary>
- /// The delimiter that separates the JSON header from the encrypted payload in .avex files.
- /// Follows a similar pattern to PEM-encoded certificates for industry familiarity.
- /// </summary>
- public const string HeaderDelimiter = "\n-----BEGIN ENCRYPTED DATA-----\n";
-
- /// <summary>
- /// The .avex file format identifier.
- /// </summary>
- public const string FormatIdentifier = "avex";
-
- /// <summary>
- /// The .avex format version.
- /// This represents the structure version of the .avex container format itself,
- /// independent of the AliasVault application version that created the export.
- /// Note: when changing the format version, also update the import logic to support
- /// both the old and new format versions, as all current logic checks for format version 1.0.0 explicitly.
- /// Version history:
- /// - 1.0.0: Initial .avex format with Argon2id KDF + AES-256-GCM encryption.
- /// </summary>
- public const string FormatVersion = "1.0.0";
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Converters/BooleanConverter.cs b/apps/server/Utilities/AliasVault.ImportExport/Converters/BooleanConverter.cs
deleted file mode 100644
index 4db43c3d5..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Converters/BooleanConverter.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="BooleanConverter.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.Converters;
-
-using CsvHelper;
-using CsvHelper.Configuration;
-using CsvHelper.TypeConversion;
-
-/// <summary>
-/// Boolean converter for CSV import.
-/// </summary>
-public class BooleanConverter : DefaultTypeConverter
-{
- /// <summary>
- /// Converts a string to a boolean.
- /// </summary>
- /// <param name="text">The string to convert.</param>
- /// <param name="row">The current row.</param>
- /// <param name="memberMapData">The member map data.</param>
- /// <returns>The converted boolean.</returns>
- public override object ConvertFromString(string? text, IReaderRow row, MemberMapData memberMapData)
- {
- if (string.IsNullOrEmpty(text)) {
- return false;
- }
-
- var trimmedText = text.ToLowerInvariant().Trim();
-
- switch (trimmedText) {
- case "1":
- case "true":
- case "yes":
- case "on":
- return true;
- default:
- return false;
- }
- }
-}
\ No newline at end of file
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Exceptions/ImportException.cs b/apps/server/Utilities/AliasVault.ImportExport/Exceptions/ImportException.cs
deleted file mode 100644
index dfa717c45..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Exceptions/ImportException.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="ImportException.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.Exceptions;
-
-/// <summary>
-/// Identifies which stage of the import pipeline produced an error.
-/// </summary>
-public enum ImportStage
-{
- /// <summary>The file could not be opened or read as an archive (corrupt zip, truncated download, etc.).</summary>
- Archive,
-
- /// <summary>The archive could be opened but its contents could not be parsed (missing manifest, malformed JSON, unexpected schema).</summary>
- Parse,
-
- /// <summary>The parsed credentials could not be saved into the local vault database.</summary>
- Save,
-}
-
-/// <summary>
-/// Exception raised by importers when a catastrophic (non-per-item) failure occurs.
-/// Carries the stage so the UI can present an actionable, copyable error payload.
-/// </summary>
-public class ImportException : Exception
-{
- /// <summary>
- /// Initializes a new instance of the <see cref="ImportException"/> class.
- /// </summary>
- /// <param name="stage">The pipeline stage where the failure happened.</param>
- /// <param name="message">A human-readable description of what went wrong.</param>
- public ImportException(ImportStage stage, string message)
- : base(message)
- {
- Stage = stage;
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ImportException"/> class.
- /// </summary>
- /// <param name="stage">The pipeline stage where the failure happened.</param>
- /// <param name="message">A human-readable description of what went wrong.</param>
- /// <param name="innerException">The exception that triggered this failure.</param>
- public ImportException(ImportStage stage, string message, Exception innerException)
- : base(message, innerException)
- {
- Stage = stage;
- }
-
- /// <summary>
- /// Gets the pipeline stage where the failure happened.
- /// </summary>
- public ImportStage Stage { get; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Exceptions/UnsupportedFileFormatException.cs b/apps/server/Utilities/AliasVault.ImportExport/Exceptions/UnsupportedFileFormatException.cs
deleted file mode 100644
index 44c715c21..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Exceptions/UnsupportedFileFormatException.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="UnsupportedFileFormatException.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.Exceptions;
-
-/// <summary>
-/// Exception thrown when an unsupported file format is provided for import.
-/// </summary>
-public class UnsupportedFileFormatException : Exception
-{
- /// <summary>
- /// Initializes a new instance of the <see cref="UnsupportedFileFormatException"/> class.
- /// </summary>
- public UnsupportedFileFormatException()
- : base("Unsupported file format")
- {
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="UnsupportedFileFormatException"/> class.
- /// </summary>
- /// <param name="message">The error message.</param>
- public UnsupportedFileFormatException(string message)
- : base(message)
- {
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="UnsupportedFileFormatException"/> class.
- /// </summary>
- /// <param name="message">The error message.</param>
- /// <param name="innerException">The inner exception.</param>
- public UnsupportedFileFormatException(string message, Exception innerException)
- : base(message, innerException)
- {
- }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Importers/BaseArchiveImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/BaseArchiveImporter.cs
deleted file mode 100644
index bc7c8e511..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Importers/BaseArchiveImporter.cs
+++ /dev/null
@@ -1,266 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="BaseArchiveImporter.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 System.Text.Json;
-using AliasVault.ImportExport.Exceptions;
-using AliasVault.ImportExport.Models;
-
-/// <summary>
-/// Base class for importers that process archive files (ZIP-based formats).
-/// Provides common functionality for extracting JSON manifests, attachments, and logos from archives.
-/// </summary>
-public abstract class BaseArchiveImporter
-{
- /// <summary>
- /// Imports credentials from an archive file (ZIP-based format).
- /// </summary>
- /// <param name="archiveBytes">The archive file as a byte array.</param>
- /// <returns>An <see cref="ImportFileResult"/> containing the parsed credentials and any per-item failures.</returns>
- public async Task<ImportFileResult> ImportFromArchiveAsync(byte[] archiveBytes)
- {
- ZipArchive archive;
- MemoryStream archiveStream;
-
- try
- {
- archiveStream = new MemoryStream(archiveBytes);
- archive = new ZipArchive(archiveStream, ZipArchiveMode.Read);
- }
- catch (Exception ex) when (ex is InvalidDataException or EndOfStreamException or IOException)
- {
- throw new ImportException(ImportStage.Archive, $"File is not a valid ZIP archive or is corrupted: {ex.Message}", ex);
- }
-
- try
- {
- // Extract attachments and logos into dictionaries
- var attachmentMap = ExtractAttachments(archive);
- var logoMap = ExtractLogos(archive);
-
- var failures = new List<ImportFailure>();
- var credentials = await ProcessArchiveAsync(archive, attachmentMap, logoMap, failures);
-
- return new ImportFileResult
- {
- Credentials = credentials,
- FailedItems = failures,
- };
- }
- finally
- {
- archive.Dispose();
- await archiveStream.DisposeAsync();
- }
- }
-
- /// <summary>
- /// Processes the archive and extracts credentials.
- /// Must be implemented by derived classes to handle specific archive formats.
- /// </summary>
- /// <param name="archive">The ZIP archive to process.</param>
- /// <param name="attachmentMap">Dictionary mapping attachment paths to file data.</param>
- /// <param name="logoMap">Dictionary mapping logo paths to file data.</param>
- /// <param name="failures">A list that should be populated with per-item parsing failures.</param>
- /// <returns>A list of ImportedCredential objects.</returns>
- protected abstract Task<List<ImportedCredential>> ProcessArchiveAsync(
- ZipArchive archive,
- Dictionary<string, byte[]> attachmentMap,
- Dictionary<string, byte[]> logoMap,
- List<ImportFailure> failures);
-
- /// <summary>
- /// Extracts all attachments from the archive based on the attachment path pattern.
- /// </summary>
- /// <param name="archive">The ZIP archive.</param>
- /// <returns>Dictionary mapping attachment paths to file data.</returns>
- protected virtual Dictionary<string, byte[]> ExtractAttachments(ZipArchive archive)
- {
- return ExtractFilesByPrefix(archive, GetAttachmentPathPattern());
- }
-
- /// <summary>
- /// Extracts all logos from the archive based on the logo path pattern.
- /// </summary>
- /// <param name="archive">The ZIP archive.</param>
- /// <returns>Dictionary mapping logo paths to file data.</returns>
- protected virtual Dictionary<string, byte[]> ExtractLogos(ZipArchive archive)
- {
- return ExtractFilesByPrefix(archive, GetLogoPathPattern());
- }
-
- /// <summary>
- /// Extracts all file entries (skipping directory entries) from the archive whose
- /// path starts with the given prefix.
- /// </summary>
- /// <param name="archive">The ZIP archive.</param>
- /// <param name="pathPrefix">The path prefix to match (e.g. "attachments/"). When null or empty, an empty map is returned.</param>
- /// <returns>Dictionary mapping entry paths to file data.</returns>
- private static Dictionary<string, byte[]> ExtractFilesByPrefix(ZipArchive archive, string? pathPrefix)
- {
- var map = new Dictionary<string, byte[]>();
-
- if (string.IsNullOrEmpty(pathPrefix))
- {
- return map;
- }
-
- foreach (var entry in archive.Entries)
- {
- if (!entry.FullName.StartsWith(pathPrefix, StringComparison.OrdinalIgnoreCase))
- {
- continue;
- }
-
- // Skip directory entries: ZIP archives commonly include zero-byte entries
- // for directories (paths ending in '/'). For those, ZipArchiveEntry.Name is empty.
- // Including them here produced phantom attachments with empty filenames.
- if (string.IsNullOrEmpty(entry.Name))
- {
- continue;
- }
-
- using var stream = entry.Open();
- using var ms = new MemoryStream();
- stream.CopyTo(ms);
- map[entry.FullName] = ms.ToArray();
- }
-
- return map;
- }
-
- /// <summary>
- /// Gets the path pattern for attachments in the archive.
- /// Override this in derived classes to specify the attachment directory.
- /// </summary>
- /// <returns>The attachment path pattern (e.g., "attachments/"), or null if not applicable.</returns>
- protected virtual string? GetAttachmentPathPattern() => null;
-
- /// <summary>
- /// Gets the path pattern for logos in the archive.
- /// Override this in derived classes to specify the logo directory.
- /// </summary>
- /// <returns>The logo path pattern (e.g., "logos/"), or null if not applicable.</returns>
- protected virtual string? GetLogoPathPattern() => null;
-
- /// <summary>
- /// Reads a JSON file from the archive.
- /// </summary>
- /// <typeparam name="T">The type to deserialize the JSON into.</typeparam>
- /// <param name="archive">The ZIP archive.</param>
- /// <param name="entryName">The name of the JSON file in the archive.</param>
- /// <returns>The deserialized object.</returns>
- /// <exception cref="ImportException">Thrown when the entry is missing or the JSON cannot be parsed.</exception>
- protected async Task<T> ReadJsonFromArchiveAsync<T>(ZipArchive archive, string entryName)
- where T : class
- {
- var entry = archive.GetEntry(entryName) ?? throw new ImportException(ImportStage.Parse, $"'{entryName}' was not found in the archive");
-
- string jsonContent;
- try
- {
- using var stream = entry.Open();
- using var reader = new StreamReader(stream);
- jsonContent = await reader.ReadToEndAsync();
- }
- catch (Exception ex)
- {
- throw new ImportException(ImportStage.Parse, $"Failed to read '{entryName}' from archive: {ex.Message}", ex);
- }
-
- var options = new JsonSerializerOptions
- {
- PropertyNameCaseInsensitive = true,
- };
-
- try
- {
- var result = JsonSerializer.Deserialize<T>(jsonContent, options);
- if (result == null)
- {
- throw new ImportException(ImportStage.Parse, $"'{entryName}' is empty or deserialized to null");
- }
-
- return result;
- }
- catch (JsonException ex)
- {
- var path = string.IsNullOrEmpty(ex.Path) ? "(unknown)" : ex.Path;
- throw new ImportException(ImportStage.Parse, $"Failed to parse '{entryName}' at {path} (line {ex.LineNumber}, byte {ex.BytePositionInLine}): {ex.Message}", ex);
- }
- }
-
- /// <summary>
- /// Reads a JSON file from the archive if it exists.
- /// </summary>
- /// <typeparam name="T">The type to deserialize the JSON into.</typeparam>
- /// <param name="archive">The ZIP archive.</param>
- /// <param name="entryName">The name of the JSON file in the archive.</param>
- /// <returns>The deserialized object, or null if the entry is not present.</returns>
- protected async Task<T?> TryReadJsonFromArchiveAsync<T>(ZipArchive archive, string entryName)
- where T : class
- {
- if (archive.GetEntry(entryName) == null)
- {
- return null;
- }
-
- return await ReadJsonFromArchiveAsync<T>(archive, entryName);
- }
-
- /// <summary>
- /// Extracts a single file from the archive as a string.
- /// </summary>
- /// <param name="archive">The ZIP archive.</param>
- /// <param name="entryName">The name of the file in the archive.</param>
- /// <returns>The file contents as a string, or null if not found.</returns>
- protected async Task<string?> ReadTextFromArchiveAsync(ZipArchive archive, string entryName)
- {
- var entry = archive.GetEntry(entryName);
- if (entry == null)
- {
- return null;
- }
-
- using var stream = entry.Open();
- using var reader = new StreamReader(stream);
- return await reader.ReadToEndAsync();
- }
-
- /// <summary>
- /// Builds an <see cref="ImportFailure"/> for a per-item exception.
- /// </summary>
- /// <param name="index">Zero-based position of the item within the source export.</param>
- /// <param name="title">Best-effort title of the item.</param>
- /// <param name="ex">The exception that was thrown while processing the item.</param>
- /// <returns>A failure entry safe to surface in logs and the UI.</returns>
- protected static ImportFailure BuildItemFailure(int index, string? title, Exception ex)
- {
- if (ex is JsonException jsonEx)
- {
- var path = string.IsNullOrEmpty(jsonEx.Path) ? "(unknown)" : jsonEx.Path;
- return new ImportFailure
- {
- Index = index,
- ItemTitle = title,
- ExceptionType = nameof(JsonException),
- Message = $"Failed to parse item at {path} (line {jsonEx.LineNumber}, byte {jsonEx.BytePositionInLine}): {jsonEx.Message}",
- };
- }
-
- var exceptionType = ex.GetType().Name;
- return new ImportFailure
- {
- Index = index,
- ItemTitle = title,
- ExceptionType = exceptionType,
- Message = $"Item could not be processed ({exceptionType}) — see item #{index} in the export.",
- };
- }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Importers/BaseImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/BaseImporter.cs
deleted file mode 100644
index 2df5ca931..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Importers/BaseImporter.cs
+++ /dev/null
@@ -1,646 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="BaseImporter.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.Globalization;
-using System.Text;
-using System.Text.RegularExpressions;
-using AliasClientDb;
-using AliasClientDb.Models;
-using AliasVault.ImportExport.Models;
-using AliasVault.TotpGenerator;
-using CsvHelper;
-using CsvHelper.Configuration;
-
-/// <summary>
-/// Generic import logic.
-/// </summary>
-public static class BaseImporter
-{
- /// <summary>
- /// Creates a CSV configuration that handles bad data and quote escaping.
- /// </summary>
- /// <returns>A CsvConfiguration with improved error handling.</returns>
- public static CsvConfiguration CreateCsvConfiguration()
- {
- return new CsvConfiguration(CultureInfo.InvariantCulture)
- {
- BadDataFound = context =>
- {
- // Log bad data but don't throw, allowing the parser to continue
- // This helps with malformed CSV entries
- },
- MissingFieldFound = null, // Ignore missing fields
- HeaderValidated = null, // Don't validate header names
- PrepareHeaderForMatch = args => args.Header?.ToLower().Trim().Replace(" ", string.Empty) ?? string.Empty,
- };
- }
-
- /// <summary>
- /// Decodes uploaded file bytes into text.
- /// </summary>
- /// <param name="fileBytes">The raw bytes of the uploaded file.</param>
- /// <returns>The decoded file content.</returns>
- public static async Task<string> DecodeFileContentAsync(byte[] fileBytes)
- {
- using var stream = new MemoryStream(fileBytes);
- using var reader = new StreamReader(stream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true);
- return await reader.ReadToEndAsync();
- }
-
- /// <summary>
- /// Creates a CsvReader with configuration and improved error handling.
- /// </summary>
- /// <param name="fileContent">The CSV file content.</param>
- /// <returns>A configured CsvReader.</returns>
- public static CsvReader CreateCsvReader(string fileContent)
- {
- var reader = new StringReader(fileContent);
- return new CsvReader(reader, CreateCsvConfiguration());
- }
-
- /// <summary>
- /// Imports CSV data with error handling and line number reporting.
- /// </summary>
- /// <typeparam name="T">The CSV record type.</typeparam>
- /// <param name="fileContent">The CSV file content.</param>
- /// <param name="customDecoder">Optional custom field decoder function.</param>
- /// <returns>A list of parsed CSV records.</returns>
- public static async Task<List<T>> ImportCsvDataAsync<T>(string fileContent, Func<string, string>? customDecoder = null)
- {
- using var reader = new StringReader(fileContent);
- using var csv = new CsvReader(reader, CreateCsvConfiguration());
-
- var records = new List<T>();
- var lineNumber = 1; // Start at 1 for header
-
- try
- {
- await foreach (var record in csv.GetRecordsAsync<T>())
- {
- lineNumber++;
-
- // Process CSV field decoding for escaped quotes and other special characters
- DecodeFields(record, customDecoder);
-
- records.Add(record);
- }
- }
- catch (Exception ex) when (!(ex is InvalidOperationException && ex.Message.Contains("line")))
- {
- // If we get any other CSV parsing error, wrap it with line information
- throw new InvalidOperationException($"Error parsing CSV data on line {lineNumber}. {ex.Message}", ex);
- }
-
- if (records.Count == 0)
- {
- throw new InvalidOperationException("No records found in the CSV file.");
- }
-
- return records;
- }
-
- /// <summary>
- /// Decodes CSV escaped characters in string fields of the record.
- /// Specifically handles CSV-encoded double quotes and other escape sequences.
- /// </summary>
- /// <param name="record">The CSV record to process.</param>
- /// <param name="customDecoder">Optional custom decoder function for importer-specific decoding.</param>
- private static void DecodeFields<T>(T record, Func<string, string>? customDecoder = null)
- {
- if (record?.Equals(default(T)) ?? true) {
- return;
- }
-
- var type = typeof(T);
- var properties = type.GetProperties();
-
- foreach (var property in properties)
- {
- if (property.PropertyType == typeof(string))
- {
- var value = property.GetValue(record) as string;
- if (!string.IsNullOrEmpty(value))
- {
- var decodedValue = customDecoder?.Invoke(value) ?? DecodeCsvField(value);
- property.SetValue(record, decodedValue);
- }
- }
- }
- }
-
- /// <summary>
- /// Decodes a CSV field value by handling standard CSV escaped quotes.
- /// </summary>
- /// <param name="value">The CSV field value.</param>
- /// <returns>The decoded value.</returns>
- public static string DecodeCsvField(string value)
- {
- if (string.IsNullOrEmpty(value))
- return value;
-
- var decoded = value;
-
- // Handle standard CSV-style escaped quotes (two consecutive quotes) -> single quote
- decoded = decoded.Replace("\"\"", "\"");
-
- return decoded;
- }
-
- /// <summary>
- /// Parses a URL string that may contain multiple comma-separated URLs.
- /// Many password managers export multiple URIs as comma-separated values within quotes.
- /// </summary>
- /// <param name="url">The URL string to parse.</param>
- /// <returns>A list of URLs, or null if the input is empty.</returns>
- public static List<string>? ParseUrls(string? url)
- {
- if (string.IsNullOrWhiteSpace(url))
- {
- return null;
- }
-
- // Split by comma and filter out empty entries
- var urls = url.Split(',', StringSplitOptions.RemoveEmptyEntries)
- .Select(u => u.Trim())
- .Where(u => !string.IsNullOrWhiteSpace(u))
- .ToList();
-
- return urls.Count > 0 ? urls : null;
- }
-
- /// <summary>
- /// Adds a custom (user-defined) field value to the credential.
- /// </summary>
- /// <param name="credential">The credential to add the custom field to.</param>
- /// <param name="label">The field label (display name).</param>
- /// <param name="value">The field value.</param>
- /// <param name="fieldType">The field type. Defaults to <see cref="FieldTypeKind.Text"/>.</param>
- public static void AddCustomField(ImportedCredential credential, string? label, string? value, FieldTypeKind fieldType = FieldTypeKind.Text)
- {
- if (string.IsNullOrWhiteSpace(label) || string.IsNullOrWhiteSpace(value))
- {
- return;
- }
-
- credential.CustomFieldValues ??= new List<ImportedCustomField>();
- credential.CustomFieldValues.Add(new ImportedCustomField
- {
- DefinitionId = Guid.NewGuid(),
- Label = label,
- Value = value,
- FieldType = fieldType,
- IsHidden = fieldType is FieldTypeKind.Hidden or FieldTypeKind.Password,
- });
- }
-
- /// <summary>
- /// Converts a list of imported credentials to a list of AliasVault Items.
- /// </summary>
- /// <param name="importedCredentials">The list of imported credentials.</param>
- /// <param name="folderNameToId">Optional dictionary mapping folder names to folder IDs for folder import.</param>
- /// <returns>The list of AliasVault Items.</returns>
- public static List<Item> ConvertToItem(List<ImportedCredential> importedCredentials, Dictionary<string, Guid>? folderNameToId = null)
- {
- var items = new List<Item>();
-
- // Convert imported credentials to AliasVault field-based Item format.
- foreach (var importedCredential in importedCredentials)
- {
- var currentDateTime = DateTime.UtcNow;
- var createdAt = importedCredential.CreatedAt ?? currentDateTime;
- var updatedAt = importedCredential.UpdatedAt ?? currentDateTime;
-
- // Determine the item type (uses ItemType from importer if set)
- var itemType = DetermineItemType(importedCredential);
-
- var item = new Item
- {
- Id = Guid.NewGuid(),
- Name = importedCredential.ServiceName ?? string.Empty,
- ItemType = itemType,
- CreatedAt = createdAt,
- UpdatedAt = updatedAt,
- };
-
- // Handle folder assignment if folder mapping is provided
- if (folderNameToId != null && !string.IsNullOrWhiteSpace(importedCredential.FolderPath))
- {
- // Use the full folder path for lookup (handles multi-level folders)
- if (folderNameToId.TryGetValue(importedCredential.FolderPath, out var folderId))
- {
- item.FolderId = folderId;
- }
- }
-
- // Handle credit card type - parse structured notes and add card fields
- if (itemType == ItemType.CreditCard)
- {
- AddCreditCardFields(item, importedCredential, createdAt, updatedAt);
- }
- else
- {
- // Add standard field values for non-empty fields (Login, Alias, Note types)
- AddUrlFieldValues(item, importedCredential.ServiceUrls, createdAt, updatedAt);
- AddFieldValueIfNotEmpty(item, FieldKey.LoginUsername, importedCredential.Username, createdAt, updatedAt);
- AddFieldValueIfNotEmpty(item, FieldKey.LoginPassword, importedCredential.Password, createdAt, updatedAt);
- AddFieldValueIfNotEmpty(item, FieldKey.LoginEmail, importedCredential.Email, createdAt, updatedAt);
- }
-
- // Add notes for all item types
- AddFieldValueIfNotEmpty(item, FieldKey.NotesContent, importedCredential.Notes, createdAt, updatedAt);
-
- // Add alias fields if present
- if (importedCredential.Alias != null)
- {
- AddFieldValueIfNotEmpty(item, FieldKey.AliasFirstName, importedCredential.Alias.FirstName, createdAt, updatedAt);
- AddFieldValueIfNotEmpty(item, FieldKey.AliasLastName, importedCredential.Alias.LastName, createdAt, updatedAt);
- AddFieldValueIfNotEmpty(item, FieldKey.AliasGender, importedCredential.Alias.Gender, createdAt, updatedAt);
-
- if (importedCredential.Alias.BirthDate.HasValue && importedCredential.Alias.BirthDate.Value != DateTime.MinValue)
- {
- AddFieldValueIfNotEmpty(item, FieldKey.AliasBirthdate, importedCredential.Alias.BirthDate.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), createdAt, updatedAt);
- }
- }
-
- // Add TOTP codes if present
- if (!string.IsNullOrEmpty(importedCredential.TwoFactorSecret))
- {
- try
- {
- var (secretKey, name, parameters) = TotpHelper.SanitizeSecretKey(importedCredential.TwoFactorSecret);
-
- item.TotpCodes.Add(new TotpCode
- {
- Id = Guid.NewGuid(),
- Name = name ?? string.Empty,
- SecretKey = secretKey,
- Algorithm = parameters.Algorithm,
- Digits = parameters.Digits,
- Period = parameters.Period,
- CreatedAt = createdAt,
- UpdatedAt = updatedAt,
- });
- }
- catch (Exception ex)
- {
- // 2FA extraction failed, log the error and continue with the next item
- // so the import doesn't fail due to failed 2FA extraction.
- Console.WriteLine($"Error importing TOTP code: {ex.Message}");
- }
- }
-
- // Add passkeys if present
- if (importedCredential.Passkeys != null)
- {
- foreach (var passkey in importedCredential.Passkeys)
- {
- // Use the GUID from the import if available, otherwise generate a new one
- var passkeyId = passkey.Id ?? Guid.NewGuid();
-
- item.Passkeys.Add(new Passkey
- {
- Id = passkeyId,
- RpId = passkey.RpId,
- UserHandle = passkey.UserHandle ?? Array.Empty<byte>(),
- PublicKey = passkey.PublicKey,
- PrivateKey = passkey.PrivateKey,
- PrfKey = passkey.PrfKey,
- DisplayName = passkey.DisplayName,
- CreatedAt = createdAt,
- UpdatedAt = updatedAt,
- });
- }
- }
-
- // Add attachments if present
- if (importedCredential.Attachments != null)
- {
- foreach (var attachment in importedCredential.Attachments)
- {
- item.Attachments.Add(new Attachment
- {
- Id = Guid.NewGuid(),
- Filename = attachment.Filename,
- Blob = attachment.Blob,
- CreatedAt = createdAt,
- UpdatedAt = updatedAt,
- });
- }
- }
-
- // Add custom (user-defined) field values if present.
- if (importedCredential.CustomFieldValues != null)
- {
- var definitionsBySourceId = new Dictionary<Guid, FieldDefinition>();
- foreach (var customField in importedCredential.CustomFieldValues)
- {
- if (string.IsNullOrWhiteSpace(customField.Value))
- {
- continue;
- }
-
- if (!definitionsBySourceId.TryGetValue(customField.DefinitionId, out var fieldDefinition))
- {
- fieldDefinition = new FieldDefinition
- {
- Id = Guid.NewGuid(),
- Label = customField.Label,
- FieldType = customField.FieldType.ToFieldTypeString(),
- IsMultiValue = customField.IsMultiValue,
- IsHidden = customField.IsHidden,
- EnableHistory = customField.EnableHistory,
- Weight = customField.Weight,
- ApplicableToTypes = customField.ApplicableToTypes,
- CreatedAt = createdAt,
- UpdatedAt = updatedAt,
- };
- definitionsBySourceId[customField.DefinitionId] = fieldDefinition;
- }
-
- 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 = customField.ValueWeight,
- CreatedAt = createdAt,
- UpdatedAt = updatedAt,
- });
- }
- }
-
- items.Add(item);
- }
-
- return items;
- }
-
- /// <summary>
- /// Determines the item type based on the imported credential.
- /// Uses ItemType if set by the importer, otherwise checks for alias data.
- /// </summary>
- /// <param name="credential">The imported credential to analyze.</param>
- /// <returns>The item type constant from <see cref="ItemType"/>.</returns>
- private static string DetermineItemType(ImportedCredential credential)
- {
- // If the importer explicitly set a type, use it
- if (credential.ItemType.HasValue)
- {
- // If Login type was set but has alias data, upgrade to Alias
- if (credential.ItemType == ImportedItemType.Login && HasAliasData(credential))
- {
- return ItemType.Alias;
- }
-
- return credential.ItemType.Value switch
- {
- ImportedItemType.Login => ItemType.Login,
- ImportedItemType.Note => ItemType.Note,
- ImportedItemType.Creditcard => ItemType.CreditCard,
- ImportedItemType.Alias => ItemType.Alias,
- _ => ItemType.Login,
- };
- }
-
- // Fallback: check for alias data
- if (HasAliasData(credential))
- {
- return ItemType.Alias;
- }
-
- // Default to Login
- return ItemType.Login;
- }
-
- /// <summary>
- /// Checks if the credential has alias identity data.
- /// </summary>
- private static bool HasAliasData(ImportedCredential credential)
- {
- return credential.Alias != null &&
- (!string.IsNullOrEmpty(credential.Alias.FirstName) ||
- !string.IsNullOrEmpty(credential.Alias.LastName) ||
- !string.IsNullOrEmpty(credential.Alias.Gender) ||
- credential.Alias.BirthDate.HasValue);
- }
-
- /// <summary>
- /// Extracts the deepest (most specific) folder name from a potentially hierarchical path.
- /// For example: "Root/Business/Banking" returns "Banking".
- /// </summary>
- /// <param name="folderPath">The folder path, potentially with hierarchy separators.</param>
- /// <returns>The deepest folder name.</returns>
- public static string? ExtractDeepestFolderName(string? folderPath)
- {
- if (string.IsNullOrWhiteSpace(folderPath))
- {
- return null;
- }
-
- // Handle common hierarchy separators: / and \
- var separators = new[] { '/', '\\' };
- var parts = folderPath.Split(separators, StringSplitOptions.RemoveEmptyEntries);
-
- // Return the last (deepest) part, or null if no valid folder name
- if (parts.Length == 0)
- {
- return null;
- }
-
- var result = parts[^1].Trim();
- return string.IsNullOrEmpty(result) ? null : result;
- }
-
- /// <summary>
- /// Collects unique folder names from imported credentials for folder creation.
- /// </summary>
- /// <param name="credentials">The list of imported credentials.</param>
- /// <returns>A set of unique folder names (deepest level only).</returns>
- public static HashSet<string> CollectUniqueFolderNames(List<ImportedCredential> credentials)
- {
- var folderNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
-
- foreach (var credential in credentials)
- {
- var folderName = ExtractDeepestFolderName(credential.FolderPath);
- if (!string.IsNullOrWhiteSpace(folderName))
- {
- folderNames.Add(folderName);
- }
- }
-
- return folderNames;
- }
-
- /// <summary>
- /// Parses a folder path into individual folder names.
- /// For example: "Root/Business/Banking" returns ["Root", "Business", "Banking"].
- /// Supports depth up to 5 levels (0-4, where 0 is root level).
- /// </summary>
- /// <param name="folderPath">The folder path, potentially with hierarchy separators.</param>
- /// <returns>A list of folder names in order, or empty list if invalid.</returns>
- public static List<string> ParseFolderPath(string? folderPath)
- {
- if (string.IsNullOrWhiteSpace(folderPath))
- {
- return new List<string>();
- }
-
- // Handle common hierarchy separators: / and \
- var separators = new[] { '/', '\\' };
- var parts = folderPath.Split(separators, StringSplitOptions.RemoveEmptyEntries)
- .Select(p => p.Trim())
- .Where(p => !string.IsNullOrEmpty(p))
- .ToList();
-
- // Enforce maximum depth of 5 levels (depth 0-4)
- const int maxDepth = 5;
- if (parts.Count > maxDepth)
- {
- parts = parts.Take(maxDepth).ToList();
- }
-
- return parts;
- }
-
-
- /// <summary>
- /// Adds credit card fields to an item from the ImportedCreditcard model.
- /// Each importer is responsible for populating the Creditcard property.
- /// </summary>
- private static void AddCreditCardFields(Item item, ImportedCredential credential, DateTime createdAt, DateTime updatedAt)
- {
- if (credential.Creditcard == null)
- {
- return;
- }
-
- var card = credential.Creditcard;
- AddFieldValueIfNotEmpty(item, FieldKey.CardCardholderName, card.CardholderName, createdAt, updatedAt);
- AddFieldValueIfNotEmpty(item, FieldKey.CardNumber, card.Number, createdAt, updatedAt);
- AddFieldValueIfNotEmpty(item, FieldKey.CardCvv, card.Cvv, createdAt, updatedAt);
- AddFieldValueIfNotEmpty(item, FieldKey.CardPin, card.Pin, createdAt, updatedAt);
- AddFieldValueIfNotEmpty(item, FieldKey.CardExpiryMonth, card.ExpiryMonth, createdAt, updatedAt);
- AddFieldValueIfNotEmpty(item, FieldKey.CardExpiryYear, card.ExpiryYear, createdAt, updatedAt);
- }
-
- /// <summary>
- /// Adds URL field values to an item, supporting multiple URLs with proper weight ordering.
- /// </summary>
- /// <param name="item">The item to add the field values to.</param>
- /// <param name="urls">The list of URLs to add.</param>
- /// <param name="createdAt">The created timestamp.</param>
- /// <param name="updatedAt">The updated timestamp.</param>
- private static void AddUrlFieldValues(Item item, List<string>? urls, DateTime createdAt, DateTime updatedAt)
- {
- if (urls == null || urls.Count == 0)
- {
- return;
- }
-
- var weight = 0;
- foreach (var url in urls)
- {
- if (!string.IsNullOrEmpty(url))
- {
- item.FieldValues.Add(new FieldValue
- {
- Id = Guid.NewGuid(),
- ItemId = item.Id,
- FieldKey = FieldKey.LoginUrl,
- Value = url,
- Weight = weight++,
- CreatedAt = createdAt,
- UpdatedAt = updatedAt,
- });
- }
- }
- }
-
- /// <summary>
- /// Adds a field value to an item if the value is not empty.
- /// </summary>
- /// <param name="item">The item to add the field value to.</param>
- /// <param name="fieldKey">The field key.</param>
- /// <param name="value">The field value.</param>
- /// <param name="createdAt">The created timestamp.</param>
- /// <param name="updatedAt">The updated timestamp.</param>
- private static void AddFieldValueIfNotEmpty(Item item, string fieldKey, string? value, DateTime createdAt, DateTime updatedAt)
- {
- if (string.IsNullOrEmpty(value))
- {
- return;
- }
-
- item.FieldValues.Add(new FieldValue
- {
- Id = Guid.NewGuid(),
- ItemId = item.Id,
- FieldKey = fieldKey,
- Value = value,
- Weight = 0,
- CreatedAt = createdAt,
- UpdatedAt = updatedAt,
- });
- }
-
- /// <summary>
- /// Formats a Unix timestamp as a date string in ISO 8601 format (yyyy-MM-dd).
- /// Returns null when the timestamp falls outside the supported range so a corrupt value
- /// in a single field doesn't crash the importer.
- /// </summary>
- /// <param name="unixTimestamp">The Unix timestamp (seconds since epoch).</param>
- /// <returns>The formatted date string, or null when the value is out of range.</returns>
- public static string? FormatUnixTimestampAsDate(long unixTimestamp)
- {
- var date = TryFromUnixTimeSeconds(unixTimestamp);
- return date?.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
- }
-
- /// <summary>
- /// Safely converts a Unix-seconds timestamp to a UTC DateTime.
- /// </summary>
- /// <param name="unixTimestamp">The Unix timestamp (seconds since epoch).</param>
- /// <returns>The converted DateTime, or null when out of range.</returns>
- public static DateTime? TryFromUnixTimeSeconds(long? unixTimestamp)
- {
- if (!unixTimestamp.HasValue)
- {
- return null;
- }
-
- try
- {
- return DateTimeOffset.FromUnixTimeSeconds(unixTimestamp.Value).UtcDateTime;
- }
- catch (ArgumentOutOfRangeException)
- {
- return null;
- }
- }
-
- /// <summary>
- /// Formats a month/year value (YYYYMM format) as a date string (YYYY-MM).
- /// </summary>
- /// <param name="monthYear">The month/year value in YYYYMM format.</param>
- /// <returns>The formatted date string, or null if the format is invalid.</returns>
- public static string? FormatMonthYear(int monthYear)
- {
- var monthYearStr = monthYear.ToString(CultureInfo.InvariantCulture);
- if (monthYearStr.Length == 6) // YYYYMM
- {
- return $"{monthYearStr.Substring(0, 4)}-{monthYearStr.Substring(4, 2)}";
- }
-
- return null;
- }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Importers/BitwardenImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/BitwardenImporter.cs
deleted file mode 100644
index 6bbe9f24c..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Importers/BitwardenImporter.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="BitwardenImporter.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 AliasVault.ImportExport.Models;
-using AliasVault.ImportExport.Models.Imports;
-using CsvHelper;
-using CsvHelper.Configuration;
-using System.Globalization;
-
-/// <summary>
-/// Imports credentials from Bitwarden.
-/// </summary>
-public static class BitwardenImporter
-{
- /// <summary>
- /// Imports Bitwarden 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)
- {
- var records = await BaseImporter.ImportCsvDataAsync<BitwardenCsvRecord>(fileContent);
-
- var credentials = new List<ImportedCredential>();
- foreach (var record in records)
- {
- var credential = new ImportedCredential
- {
- ServiceName = record.Title,
- ServiceUrls = BaseImporter.ParseUrls(record.URL),
- Username = record.Username,
- Password = record.Password,
- TwoFactorSecret = record.OTPAuth,
- Notes = record.Notes,
- FolderPath = string.IsNullOrWhiteSpace(record.Folder) ? null : record.Folder,
- ItemType = MapBitwardenType(record.Type),
- };
-
- credentials.Add(credential);
- }
-
- return credentials;
- }
-
- /// <summary>
- /// Maps Bitwarden type values to ImportedItemType.
- /// Bitwarden types: login, note, card, identity.
- /// </summary>
- private static ImportedItemType? MapBitwardenType(string? bitwardenType)
- {
- if (string.IsNullOrWhiteSpace(bitwardenType))
- {
- return null;
- }
-
- return bitwardenType.ToLowerInvariant() switch
- {
- "login" => ImportedItemType.Login,
- "note" or "securenote" => ImportedItemType.Note,
- "card" => ImportedItemType.Creditcard,
- "identity" => ImportedItemType.Alias,
- _ => ImportedItemType.Login,
- };
- }
-}
\ No newline at end of file
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Importers/BitwardenZipImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/BitwardenZipImporter.cs
deleted file mode 100644
index 37198887f..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Importers/BitwardenZipImporter.cs
+++ /dev/null
@@ -1,456 +0,0 @@
-//-----------------------------------------------------------------------
-// <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 System.Text.Json;
-using AliasClientDb.Models;
-using AliasVault.ImportExport.Exceptions;
-using AliasVault.ImportExport.Models;
-using AliasVault.ImportExport.Models.Imports;
-
-/// <summary>
-/// Imports credentials from Bitwarden .zip export format (with attachments).
-/// </summary>
-public class BitwardenZipImporter : BaseArchiveImporter
-{
- private static readonly JsonSerializerOptions ItemDeserializerOptions = new()
- {
- PropertyNameCaseInsensitive = true,
- };
-
- /// <inheritdoc/>
- protected override string? GetAttachmentPathPattern() => "attachments/";
-
- /// <inheritdoc/>
- protected override async Task<List<ImportedCredential>> ProcessArchiveAsync(
- ZipArchive archive,
- Dictionary<string, byte[]> attachmentMap,
- Dictionary<string, byte[]> logoMap,
- List<ImportFailure> failures)
- {
- // Extract the main JSON manifest.
- var exportData = await ReadJsonFromArchiveAsync<BitwardenJsonExport>(archive, "data.json");
-
- // Validate the export
- ValidateExport(exportData);
-
- // Build folder lookup
- var folderLookup = BuildFolderLookup(exportData.Folders);
-
- var credentials = new List<ImportedCredential>();
-
- for (var i = 0; i < exportData.Items.Count; i++)
- {
- var itemElement = exportData.Items[i];
- BitwardenItem? item = null;
- try
- {
- item = itemElement.Deserialize<BitwardenItem>(ItemDeserializerOptions);
- if (item == null)
- {
- failures.Add(new ImportFailure
- {
- Index = i,
- ItemTitle = TryGetItemName(itemElement),
- ExceptionType = nameof(JsonException),
- Message = "Item JSON deserialized to null",
- });
- continue;
- }
-
- var credential = ConvertBitwardenItemToCredential(item, folderLookup, attachmentMap);
- credentials.Add(credential);
- }
- catch (Exception ex)
- {
- failures.Add(BuildItemFailure(i, item?.Name ?? TryGetItemName(itemElement), ex));
- }
- }
-
- return credentials;
- }
-
- /// <summary>
- /// Best-effort extraction of an item's name directly from the raw JSON, so failures can still
- /// be attributed to a recognisable item even when typed deserialization throws.
- /// </summary>
- private static string? TryGetItemName(JsonElement itemElement)
- {
- if (itemElement.ValueKind != JsonValueKind.Object)
- {
- return null;
- }
-
- if (!itemElement.TryGetProperty("name", out var name) || name.ValueKind != JsonValueKind.String)
- {
- return null;
- }
-
- return name.GetString();
- }
-
- /// <summary>
- /// Validates the Bitwarden export data.
- /// </summary>
- /// <param name="exportData">The export data to validate.</param>
- /// <exception cref="ImportException">Thrown when the export is encrypted or invalid.</exception>
- private static void ValidateExport(BitwardenJsonExport exportData)
- {
- if (exportData.Encrypted)
- {
- throw new ImportException(ImportStage.Parse, "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.
- // Bitwarden field types:
- // 0 = Text (plaintext)
- // 1 = Hidden (password/sensitive)
- // 2 = Boolean (true/false)
- // 3 = Linked (reference to another field - not supported, skipped)
- if (!string.IsNullOrWhiteSpace(field.Value))
- {
- var fieldType = field.Type == 1 ? FieldTypeKind.Hidden : FieldTypeKind.Text;
- BaseImporter.AddCustomField(
- credential,
- field.Name,
- field.Value,
- fieldType);
- }
- }
- }
-
- /// <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/Importers/ChromeImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/ChromeImporter.cs
deleted file mode 100644
index f0c039db8..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Importers/ChromeImporter.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="ChromeImporter.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 AliasVault.ImportExport.Models;
-using AliasVault.ImportExport.Models.Imports;
-using CsvHelper;
-using CsvHelper.Configuration;
-using System.Globalization;
-
-/// <summary>
-/// Imports credentials from Chrome Password Manager.
-/// </summary>
-public static class ChromeImporter
-{
- /// <summary>
- /// Imports Chrome 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)
- {
- var records = await BaseImporter.ImportCsvDataAsync<ChromeCsvRecord>(fileContent);
-
- var credentials = new List<ImportedCredential>();
- foreach (var record in records)
- {
- var credential = new ImportedCredential
- {
- ServiceName = record.Name,
- ServiceUrls = BaseImporter.ParseUrls(record.Url),
- Username = record.Username,
- Password = record.Password,
- Notes = record.Note
- };
-
- credentials.Add(credential);
- }
-
- return credentials;
- }
-}
\ No newline at end of file
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Importers/DashlaneImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/DashlaneImporter.cs
deleted file mode 100644
index 566fcc514..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Importers/DashlaneImporter.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="DashlaneImporter.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 AliasVault.ImportExport.Models;
-using AliasVault.ImportExport.Models.Imports;
-
-/// <summary>
-/// Imports credentials from Dashlane.
-/// </summary>
-public static class DashlaneImporter
-{
- /// <summary>
- /// Imports Dashlane 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)
- {
- var records = await BaseImporter.ImportCsvDataAsync<DashlaneCsvRecord>(fileContent);
-
- var credentials = new List<ImportedCredential>();
- foreach (var record in records)
- {
- var credential = new ImportedCredential
- {
- ServiceName = record.Title,
- ServiceUrls = BaseImporter.ParseUrls(record.URL),
- Username = record.Username,
- Password = record.Password,
- TwoFactorSecret = record.OTPUrl,
- Notes = BuildNotes(record),
- FolderPath = string.IsNullOrWhiteSpace(record.Category) ? null : record.Category,
- };
-
- credentials.Add(credential);
- }
-
- return credentials;
- }
-
- private static string? BuildNotes(DashlaneCsvRecord record)
- {
- var notes = new List<string>();
-
- if (!string.IsNullOrEmpty(record.Note))
- {
- notes.Add(record.Note);
- }
-
- if (!string.IsNullOrEmpty(record.Username2))
- {
- notes.Add($"Alternative username 1: {record.Username2}");
- }
-
- if (!string.IsNullOrEmpty(record.Username3))
- {
- notes.Add($"Alternative username 2: {record.Username3}");
- }
-
- return notes.Count > 0 ? string.Join(Environment.NewLine, notes) : null;
- }
-}
\ No newline at end of file
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Importers/DropboxImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/DropboxImporter.cs
deleted file mode 100644
index 05b72b4f1..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Importers/DropboxImporter.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="DropboxImporter.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 AliasVault.ImportExport.Models;
-using AliasVault.ImportExport.Models.Imports;
-
-/// <summary>
-/// Imports credentials from Dropbox Passwords.
-/// </summary>
-public static class DropboxImporter
-{
- /// <summary>
- /// Imports Dropbox 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)
- {
- var records = await BaseImporter.ImportCsvDataAsync<DropboxCsvRecord>(fileContent);
-
- var credentials = new List<ImportedCredential>();
- foreach (var record in records)
- {
- // Skip empty records (records with no title)
- if (string.IsNullOrWhiteSpace(record.Name))
- {
- continue;
- }
-
- var credential = new ImportedCredential
- {
- ServiceName = record.Name,
- ServiceUrls = BaseImporter.ParseUrls(record.Url),
- Username = record.Username,
- Password = record.Password,
- Notes = record.Notes
- };
-
- credentials.Add(credential);
- }
-
- return credentials;
- }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Importers/EdgeImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/EdgeImporter.cs
deleted file mode 100644
index 74b5503db..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Importers/EdgeImporter.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="EdgeImporter.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 AliasVault.ImportExport.Models;
-using AliasVault.ImportExport.Models.Imports;
-
-/// <summary>
-/// Imports credentials from Microsoft Edge Password Manager.
-/// </summary>
-public static class EdgeImporter
-{
- /// <summary>
- /// Imports Edge 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)
- {
- var records = await BaseImporter.ImportCsvDataAsync<EdgeCsvRecord>(fileContent);
-
- var credentials = new List<ImportedCredential>();
- foreach (var record in records)
- {
- var credential = new ImportedCredential
- {
- ServiceName = record.Name,
- ServiceUrls = BaseImporter.ParseUrls(record.Url),
- Username = record.Username,
- Password = record.Password,
- Notes = record.Note,
- };
-
- credentials.Add(credential);
- }
-
- return credentials;
- }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Importers/EnpassImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/EnpassImporter.cs
deleted file mode 100644
index 4f50528d8..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Importers/EnpassImporter.cs
+++ /dev/null
@@ -1,298 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="EnpassImporter.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 AliasVault.ImportExport.Models;
-using CsvHelper;
-using CsvHelper.Configuration;
-using System.Globalization;
-
-/// <summary>
-/// Imports credentials from Enpass Password Manager.
-/// Enpass uses a unique CSV format where each row contains alternating key-value pairs
-/// instead of traditional column headers.
-/// </summary>
-public static class EnpassImporter
-{
- /// <summary>
- /// Imports Enpass 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)
- {
- var credentials = new List<ImportedCredential>();
-
- var config = new CsvConfiguration(CultureInfo.InvariantCulture)
- {
- HasHeaderRecord = false,
- BadDataFound = null,
- MissingFieldFound = null,
- };
-
- using var reader = new StringReader(fileContent);
- using var csv = new CsvReader(reader, config);
-
- while (await csv.ReadAsync())
- {
- var fields = new List<string>();
-
- // Get the parser to access raw field data
- var parser = csv.Parser;
- var record = parser.Record;
-
- if (record == null || record.Length < 1)
- {
- continue;
- }
-
- foreach (var field in record)
- {
- fields.Add(field ?? string.Empty);
- }
-
- var credential = ParseEnpassRow(fields);
- if (credential != null)
- {
- credentials.Add(credential);
- }
- }
-
- return credentials;
- }
-
- /// <summary>
- /// Parses a single Enpass CSV row into an ImportedCredential.
- /// The first field is the item name/type, followed by alternating key-value pairs.
- /// </summary>
- /// <param name="fields">The list of fields from the CSV row.</param>
- /// <returns>The parsed ImportedCredential, or null if parsing fails.</returns>
- private static ImportedCredential? ParseEnpassRow(List<string> fields)
- {
- if (fields.Count < 1)
- {
- return null;
- }
-
- var itemName = fields[0];
-
- // Build a dictionary of field name -> field value from alternating pairs
- var fieldDict = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
- for (int i = 1; i < fields.Count - 1; i += 2)
- {
- var key = fields[i].Trim();
- var value = fields[i + 1];
-
- // Skip empty keys or section headers (all caps with no value)
- if (string.IsNullOrWhiteSpace(key) || string.IsNullOrWhiteSpace(value))
- {
- continue;
- }
-
- // Remove leading asterisk from field names (Enpass marks sensitive fields with *)
- if (key.StartsWith("*"))
- {
- key = key.Substring(1);
- }
-
- // Store the first occurrence of each key (some may repeat)
- if (!fieldDict.ContainsKey(key))
- {
- fieldDict[key] = value;
- }
- }
-
- // Determine item type based on name and available fields
- var itemType = DetermineItemType(itemName, fieldDict);
-
- var credential = new ImportedCredential
- {
- ServiceName = itemName,
- ItemType = itemType,
- };
-
- // Extract common fields
- credential.Username = GetFirstMatch(fieldDict, "Username", "Login", "E-mail");
- credential.Password = GetFirstMatch(fieldDict, "Password", "Login password");
- credential.Email = GetFirstMatch(fieldDict, "E-mail", "Email");
- credential.Notes = BuildNotes(fieldDict);
-
- // Extract URL
- var url = GetFirstMatch(fieldDict, "Website", "URL");
- if (!string.IsNullOrWhiteSpace(url))
- {
- credential.ServiceUrls = BaseImporter.ParseUrls(url);
- }
-
- // Extract TOTP
- credential.TwoFactorSecret = GetFirstMatch(fieldDict, "One-time code", "TOTP", "OTP");
-
- // Handle credit card
- if (itemType == ImportedItemType.Creditcard)
- {
- credential.Creditcard = ParseCreditCard(fieldDict);
- }
-
- // Handle identity/alias
- if (itemType == ImportedItemType.Alias)
- {
- credential.Alias = ParseAlias(fieldDict);
- }
-
- // Handle secure note (the second field is the note content if only 2 fields)
- if (itemType == ImportedItemType.Note && fields.Count == 2)
- {
- credential.Notes = fields[1];
- }
-
- return credential;
- }
-
- /// <summary>
- /// Determines the item type based on the item name and available fields.
- /// </summary>
- private static ImportedItemType DetermineItemType(string itemName, Dictionary<string, string> fields)
- {
- var lowerName = itemName.ToLowerInvariant();
-
- if (lowerName.Contains("credit card") || lowerName.Contains("creditcard") ||
- fields.ContainsKey("CVC") || fields.ContainsKey("Cardholder"))
- {
- return ImportedItemType.Creditcard;
- }
-
- if (lowerName == "identity" || fields.ContainsKey("First name") ||
- fields.ContainsKey("Social Security Number"))
- {
- return ImportedItemType.Alias;
- }
-
- if (lowerName == "securenote" || lowerName == "secure note" || lowerName == "note")
- {
- return ImportedItemType.Note;
- }
-
- // Default to login for Password entries and anything with login credentials
- return ImportedItemType.Login;
- }
-
- /// <summary>
- /// Gets the first matching value from a dictionary given multiple possible keys.
- /// </summary>
- private static string? GetFirstMatch(Dictionary<string, string> dict, params string[] keys)
- {
- foreach (var key in keys)
- {
- if (dict.TryGetValue(key, out var value) && !string.IsNullOrWhiteSpace(value))
- {
- return value;
- }
- }
-
- return null;
- }
-
- /// <summary>
- /// Builds notes from miscellaneous fields that don't map to standard credential fields.
- /// </summary>
- private static string? BuildNotes(Dictionary<string, string> fields)
- {
- var notesBuilder = new List<string>();
-
- // Fields that might contain notes
- var noteKeys = new[] { "Note", "Notes", "Security question", "Security answer", "Secret question", "Secret answer" };
-
- foreach (var key in noteKeys)
- {
- if (fields.TryGetValue(key, out var value) && !string.IsNullOrWhiteSpace(value))
- {
- notesBuilder.Add($"{key}: {value}");
- }
- }
-
- // Check for fields ending in "notes"
- foreach (var kvp in fields)
- {
- if (kvp.Key.EndsWith("notes", StringComparison.OrdinalIgnoreCase) &&
- !string.IsNullOrWhiteSpace(kvp.Value))
- {
- notesBuilder.Add(kvp.Value);
- }
- }
-
- return notesBuilder.Count > 0 ? string.Join("\n", notesBuilder) : null;
- }
-
- /// <summary>
- /// Parses credit card information from the field dictionary.
- /// </summary>
- private static ImportedCreditcard ParseCreditCard(Dictionary<string, string> fields)
- {
- var card = new ImportedCreditcard
- {
- CardholderName = GetFirstMatch(fields, "Cardholder", "Cardholder Name", "Name on Card"),
- Number = GetFirstMatch(fields, "Number", "Card Number"),
- Cvv = GetFirstMatch(fields, "CVC", "CVV", "Security Code"),
- Pin = GetFirstMatch(fields, "PIN"),
- };
-
- // Parse expiry date (format: MM/YY or MM/YYYY)
- var expiry = GetFirstMatch(fields, "Expiry date", "Expiry", "Expires", "Valid thru");
- if (!string.IsNullOrWhiteSpace(expiry))
- {
- var parts = expiry.Split('/');
- if (parts.Length == 2)
- {
- card.ExpiryMonth = parts[0].Trim();
- var year = parts[1].Trim();
- // Convert 2-digit year to 2-digit format (keep as-is)
- card.ExpiryYear = year.Length == 4 ? year.Substring(2) : year;
- }
- }
-
- return card;
- }
-
- /// <summary>
- /// Parses identity/alias information from the field dictionary.
- /// </summary>
- private static ImportedAlias ParseAlias(Dictionary<string, string> fields)
- {
- var alias = new ImportedAlias
- {
- FirstName = GetFirstMatch(fields, "First name", "Firstname"),
- LastName = GetFirstMatch(fields, "Last name", "Lastname"),
- Gender = GetFirstMatch(fields, "Gender"),
- };
-
- // Parse birth date (format: DD-MM-YYYY or similar)
- var birthDate = GetFirstMatch(fields, "Birth date", "Birthdate", "Birthday", "Date of birth");
- if (!string.IsNullOrWhiteSpace(birthDate))
- {
- if (DateTime.TryParse(birthDate, CultureInfo.InvariantCulture, DateTimeStyles.None, out var date))
- {
- alias.BirthDate = date;
- }
- else
- {
- // Try parsing DD-MM-YYYY format
- var formats = new[] { "dd-MM-yyyy", "MM-dd-yyyy", "dd/MM/yyyy", "MM/dd/yyyy" };
- foreach (var format in formats)
- {
- if (DateTime.TryParseExact(birthDate, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out date))
- {
- alias.BirthDate = date;
- break;
- }
- }
- }
- }
-
- return alias;
- }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Importers/FirefoxImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/FirefoxImporter.cs
deleted file mode 100644
index 36f884828..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Importers/FirefoxImporter.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="FirefoxImporter.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 AliasVault.ImportExport.Models;
-using AliasVault.ImportExport.Models.Imports;
-using CsvHelper;
-using CsvHelper.Configuration;
-using System.Globalization;
-
-/// <summary>
-/// Imports credentials from Firefox Password Manager.
-/// </summary>
-public static class FirefoxImporter
-{
- /// <summary>
- /// Imports Firefox 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)
- {
- var records = await BaseImporter.ImportCsvDataAsync<FirefoxCsvRecord>(fileContent);
-
- var credentials = new List<ImportedCredential>();
- foreach (var record in records)
- {
- // Extract service name from URL, e.g. https://example.com/path -> example.com.
- var uri = new Uri(record.Url);
- var serviceName = uri.Host.StartsWith("www.") ? uri.Host[4..] : uri.Host;
-
- var credential = new ImportedCredential
- {
- ServiceName = serviceName,
- ServiceUrls = BaseImporter.ParseUrls(record.Url),
- Username = record.Username,
- Password = record.Password
- };
-
- credentials.Add(credential);
- }
-
- return credentials;
- }
-}
\ No newline at end of file
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Importers/GenericCsvImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/GenericCsvImporter.cs
deleted file mode 100644
index da407901e..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Importers/GenericCsvImporter.cs
+++ /dev/null
@@ -1,110 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="GenericCsvImporter.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 AliasVault.ImportExport.Models;
-using AliasVault.ImportExport.Models.Imports;
-using System.Text;
-
-/// <summary>
-/// Imports credentials from a generic CSV format designed for AliasVault.
-/// </summary>
-public static class GenericCsvImporter
-{
- /// <summary>
- /// Gets the CSV template structure as a string that users can download.
- /// </summary>
- /// <returns>A CSV template with headers and example data.</returns>
- public static string GetCsvTemplate()
- {
- var template = new StringBuilder();
-
- // Add headers
- template.AppendLine("service_name,url,username,password,totp_secret,notes,folder");
-
- // Add example rows
- template.AppendLine("Gmail,https://gmail.com,[email protected],your_password,,Important email account,Personal");
- template.AppendLine("Facebook,https://facebook.com,your.username,your_password,,Social media account,Personal/Social");
- template.AppendLine("GitHub,https://github.com,developer_username,your_password,your_totp_secret_here,Development platform,Work");
- template.AppendLine("Secure Note,,,,,\"Important information or notes without login credentials\",");
-
- return template.ToString();
- }
-
- /// <summary>
- /// Gets the CSV template as a byte array for download.
- /// </summary>
- /// <returns>A byte array containing the CSV template.</returns>
- public static byte[] GetCsvTemplateBytes()
- {
- return Encoding.UTF8.GetBytes(GetCsvTemplate());
- }
-
- /// <summary>
- /// Imports generic 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)
- {
- var records = await BaseImporter.ImportCsvDataAsync<GenericCsvRecord>(fileContent);
-
- var credentials = new List<ImportedCredential>();
- foreach (var record in records)
- {
- // Skip records with no service name
- if (string.IsNullOrWhiteSpace(record.ServiceName))
- {
- continue;
- }
-
- var credential = new ImportedCredential
- {
- ServiceName = record.ServiceName.Trim(),
- ServiceUrls = BaseImporter.ParseUrls(NormalizeUrl(record.Url)),
- Username = record.Username?.Trim(),
- Password = record.Password?.Trim(),
- TwoFactorSecret = record.TotpSecret?.Trim(),
- Notes = record.Notes?.Trim(),
- FolderPath = string.IsNullOrWhiteSpace(record.Folder) ? null : record.Folder.Trim(),
- };
-
- credentials.Add(credential);
- }
-
- if (credentials.Count == 0)
- {
- throw new InvalidOperationException("No valid records found in the CSV file. Please ensure the CSV has the correct headers and at least one row with a service name.");
- }
-
- return credentials;
- }
-
- /// <summary>
- /// Normalizes URL values from the CSV.
- /// </summary>
- /// <param name="url">The URL from the CSV record.</param>
- /// <returns>The normalized URL or null if empty.</returns>
- private static string? NormalizeUrl(string? url)
- {
- if (string.IsNullOrWhiteSpace(url))
- {
- return null;
- }
-
- var trimmedUrl = url.Trim();
-
- // Return null for common placeholder values
- if (trimmedUrl == "http://" || trimmedUrl == "https://" || trimmedUrl == "N/A" || trimmedUrl == "n/a")
- {
- return null;
- }
-
- return trimmedUrl;
- }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Importers/KeePassImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/KeePassImporter.cs
deleted file mode 100644
index e94093d73..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Importers/KeePassImporter.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="KeePassImporter.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 AliasVault.ImportExport.Models;
-using AliasVault.ImportExport.Models.Imports;
-using CsvHelper;
-using CsvHelper.Configuration;
-using System.Globalization;
-using System.Text.RegularExpressions;
-
-/// <summary>
-/// Imports credentials from KeePass.
-/// </summary>
-public static class KeePassImporter
-{
- /// <summary>
- /// Decodes KeePass 1.x specific field encoding.
- /// KeePass 1.x rules: Quotes (") in strings are encoded as \" (two characters).
- /// Backslashes (\) are encoded as \\ (two characters).
- /// </summary>
- /// <param name="value">The field value to decode.</param>
- /// <returns>The decoded value.</returns>
- private static string DecodeKeePassField(string value)
- {
- if (string.IsNullOrEmpty(value))
- return value;
-
- var decoded = value;
-
- // Handle standard CSV-style escaped quotes first (two consecutive quotes) -> single quote
- decoded = decoded.Replace("\"\"", "\"");
-
- // Handle KeePass 1.x specific encoding rules
- // Backslashes (\) are encoded as \\ -> \
- decoded = decoded.Replace("\\\\", "\\");
-
- // Quotes (") in strings are encoded as \" -> "
- decoded = decoded.Replace("\\\"", "\"");
-
- // Special handling for the case where the CSV parser has already partially processed
- // the escaped quotes, leaving single backslashes that should be quotes
- // This handles the case where \with should become "with
- if (decoded.Contains('\\'))
- {
- // Look for standalone backslashes that should be quotes
- // This is a fallback for malformed or partially-parsed KeePass data
- decoded = Regex.Replace(decoded, @"\\(?![\\\""])", "\"", RegexOptions.None, TimeSpan.FromMilliseconds(100));
- }
-
- // Handle edge case where CSV parser incorrectly includes trailing quotes
- // This happens when the CSV parser gets confused by escaped quotes inside quoted fields
- if (decoded.EndsWith('"') && decoded.Length > 1 && !decoded.EndsWith("\"\""))
- {
- // Check if this is likely a CSV parsing error (trailing quote that shouldn't be there)
- // Look for patterns like: some content" at the end
- decoded = decoded.Substring(0, decoded.Length - 1);
- }
-
- return decoded;
- }
-
- /// <summary>
- /// Imports KeePass 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)
- {
- // Use KeePass-specific field decoder for proper handling of KeePass 1.x encoding
- var records = await BaseImporter.ImportCsvDataAsync<KeePassCsvRecord>(fileContent, DecodeKeePassField);
-
- var credentials = new List<ImportedCredential>();
- foreach (var record in records)
- {
- var credential = new ImportedCredential
- {
- ServiceName = record.Account ?? string.Empty,
- ServiceUrls = BaseImporter.ParseUrls(record.Website),
- Username = record.LoginName,
- Password = record.Password,
- Notes = record.Comments
- };
-
- credentials.Add(credential);
- }
-
- return credentials;
- }
-}
\ No newline at end of file
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Importers/KeePassXcImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/KeePassXcImporter.cs
deleted file mode 100644
index 5faf3f1f5..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Importers/KeePassXcImporter.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="KeePassXcImporter.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 AliasVault.ImportExport.Models;
-using AliasVault.ImportExport.Models.Imports;
-
-/// <summary>
-/// Imports credentials from KeePassXC.
-/// </summary>
-public static class KeePassXcImporter
-{
- /// <summary>
- /// Imports KeePassXC 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)
- {
- var records = await BaseImporter.ImportCsvDataAsync<KeepassXcCsvRecord>(fileContent);
-
- var credentials = new List<ImportedCredential>();
- foreach (var record in records)
- {
- var credential = new ImportedCredential
- {
- ServiceName = record.Title,
- ServiceUrls = BaseImporter.ParseUrls(record.URL),
- Username = record.Username,
- Password = record.Password,
- TwoFactorSecret = record.TOTP,
- Notes = record.Notes,
- FolderPath = string.IsNullOrWhiteSpace(record.Group) ? null : record.Group,
- };
-
- credentials.Add(credential);
- }
-
- return credentials;
- }
-}
\ No newline at end of file
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Importers/LastPassImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/LastPassImporter.cs
deleted file mode 100644
index 44f49fd59..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Importers/LastPassImporter.cs
+++ /dev/null
@@ -1,178 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="LastPassImporter.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 AliasVault.ImportExport.Models;
-using AliasVault.ImportExport.Models.Imports;
-
-/// <summary>
-/// Imports credentials from LastPass.
-/// </summary>
-public static class LastPassImporter
-{
- /// <summary>
- /// Imports LastPass 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)
- {
- var records = await BaseImporter.ImportCsvDataAsync<LastPassCsvRecord>(fileContent);
-
- var credentials = new List<ImportedCredential>();
- foreach (var record in records)
- {
- // Skip empty records (records with no name/title)
- if (string.IsNullOrWhiteSpace(record.Title))
- {
- continue;
- }
-
- // Normalize URL - LastPass uses "http://sn" for secure notes and "http://" for entries without URLs
- var normalizedUrl = string.IsNullOrWhiteSpace(record.URL) || record.URL == "http://" || record.URL == "http://sn"
- ? null
- : record.URL;
-
- // Determine item type and parse structured data inline
- ImportedItemType? itemType = null;
- ImportedCreditcard? creditcard = null;
- string? notes = record.Extra;
-
- // Check for credit card (structured data in Extra field)
- if (!string.IsNullOrEmpty(record.Extra) && record.Extra.Contains("NoteType:Credit Card"))
- {
- itemType = ImportedItemType.Creditcard;
- creditcard = ParseCreditcardFromNotes(record.Extra);
- notes = ExtractNotesFromCreditcard(record.Extra);
- }
- // Check for secure note: URL is "http://sn" and no username/password
- else if (record.URL == "http://sn" &&
- string.IsNullOrEmpty(record.Username) &&
- string.IsNullOrEmpty(record.Password))
- {
- itemType = ImportedItemType.Note;
- }
-
- var credential = new ImportedCredential
- {
- ServiceName = record.Title,
- ServiceUrls = BaseImporter.ParseUrls(normalizedUrl),
- Username = record.Username,
- Password = record.Password,
- TwoFactorSecret = record.TwoFactorSecret,
- Notes = notes,
- FolderPath = string.IsNullOrWhiteSpace(record.Grouping) ? null : record.Grouping,
- ItemType = itemType,
- Creditcard = creditcard,
- };
-
- credentials.Add(credential);
- }
-
- return credentials;
- }
-
- /// <summary>
- /// Parses credit card data from LastPass structured notes format.
- /// </summary>
- private static ImportedCreditcard ParseCreditcardFromNotes(string notes)
- {
- var creditcard = new ImportedCreditcard();
- var lines = notes.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
-
- foreach (var line in lines)
- {
- var colonIndex = line.IndexOf(':');
- if (colonIndex <= 0)
- {
- continue;
- }
-
- var key = line[..colonIndex].Trim();
- var value = line[(colonIndex + 1)..].Trim();
-
- if (string.IsNullOrEmpty(value))
- {
- continue;
- }
-
- switch (key)
- {
- case "Name on Card":
- creditcard.CardholderName = value;
- break;
- case "Number":
- creditcard.Number = value;
- break;
- case "Security Code":
- creditcard.Cvv = value;
- break;
- case "Expiration Date":
- // LastPass format: "May,2028"
- var parts = value.Split(',');
- if (parts.Length == 2)
- {
- creditcard.ExpiryMonth = parts[0].Trim().ToLowerInvariant() switch
- {
- "january" => "01",
- "february" => "02",
- "march" => "03",
- "april" => "04",
- "may" => "05",
- "june" => "06",
- "july" => "07",
- "august" => "08",
- "september" => "09",
- "october" => "10",
- "november" => "11",
- "december" => "12",
- _ => null,
- };
- creditcard.ExpiryYear = parts[1].Trim();
- }
-
- break;
- }
- }
-
- return creditcard;
- }
-
- /// <summary>
- /// Extracts the actual notes from a LastPass credit card structured note.
- /// The notes section is after the "Notes:" line.
- /// </summary>
- private static string? ExtractNotesFromCreditcard(string structuredNotes)
- {
- var lines = structuredNotes.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
- var foundNotesSection = false;
- var noteLines = new List<string>();
-
- foreach (var line in lines)
- {
- if (line.StartsWith("Notes:"))
- {
- foundNotesSection = true;
- var noteValue = line["Notes:".Length..].Trim();
- if (!string.IsNullOrEmpty(noteValue))
- {
- noteLines.Add(noteValue);
- }
-
- continue;
- }
-
- if (foundNotesSection)
- {
- noteLines.Add(line);
- }
- }
-
- return noteLines.Count > 0 ? string.Join(Environment.NewLine, noteLines) : null;
- }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Importers/NordPassImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/NordPassImporter.cs
deleted file mode 100644
index 07df56aeb..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Importers/NordPassImporter.cs
+++ /dev/null
@@ -1,150 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="NordPassImporter.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 AliasVault.ImportExport.Models;
-using AliasVault.ImportExport.Models.Imports;
-
-/// <summary>
-/// Imports credentials from NordPass.
-/// </summary>
-public static class NordPassImporter
-{
- /// <summary>
- /// Imports NordPass 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)
- {
- var records = await BaseImporter.ImportCsvDataAsync<NordPassCsvRecord>(fileContent);
-
- var credentials = new List<ImportedCredential>();
- foreach (var record in records)
- {
- // Skip folder entries - NordPass exports folder rows with type "folder" which are not credentials.
- if (string.Equals(record.Type, "folder", StringComparison.OrdinalIgnoreCase))
- {
- continue;
- }
-
- var itemType = MapNordPassType(record.Type);
- ImportedCreditcard? creditcard = null;
-
- // Parse credit card data if any credit card fields are present.
- if (HasCreditcardData(record))
- {
- creditcard = ParseCreditcard(record);
- itemType ??= ImportedItemType.Creditcard;
- }
-
- // Build notes, appending custom fields if present.
- var notes = record.Note;
- if (!string.IsNullOrWhiteSpace(record.CustomFields))
- {
- notes = string.IsNullOrWhiteSpace(notes)
- ? record.CustomFields
- : notes + Environment.NewLine + record.CustomFields;
- }
-
- var credential = new ImportedCredential
- {
- ServiceName = record.Name,
- ServiceUrls = BaseImporter.ParseUrls(record.Url),
- Email = record.Email,
- Username = record.Username,
- Password = record.Password,
- Notes = notes,
- FolderPath = string.IsNullOrWhiteSpace(record.Folder) ? null : record.Folder,
- ItemType = itemType,
- Creditcard = creditcard,
- };
-
- credentials.Add(credential);
- }
-
- return credentials;
- }
-
- /// <summary>
- /// Maps NordPass type values to ImportedItemType.
- /// NordPass types: password, note, credit_card, identity.
- /// </summary>
- private static ImportedItemType? MapNordPassType(string? nordPassType)
- {
- if (string.IsNullOrWhiteSpace(nordPassType))
- {
- return null;
- }
-
- return nordPassType.ToLowerInvariant() switch
- {
- "password" => ImportedItemType.Login,
- "note" => ImportedItemType.Note,
- "credit_card" => ImportedItemType.Creditcard,
- "identity" => ImportedItemType.Alias,
- _ => ImportedItemType.Login,
- };
- }
-
- /// <summary>
- /// Checks whether the NordPass record contains credit card data.
- /// </summary>
- private static bool HasCreditcardData(NordPassCsvRecord record)
- {
- return !string.IsNullOrWhiteSpace(record.CardNumber) ||
- !string.IsNullOrWhiteSpace(record.CardholderName) ||
- !string.IsNullOrWhiteSpace(record.Cvc) ||
- !string.IsNullOrWhiteSpace(record.ExpiryDate);
- }
-
- /// <summary>
- /// Parses credit card data from a NordPass record.
- /// </summary>
- private static ImportedCreditcard ParseCreditcard(NordPassCsvRecord record)
- {
- var creditcard = new ImportedCreditcard
- {
- CardholderName = record.CardholderName,
- Number = record.CardNumber,
- Cvv = record.Cvc,
- Pin = record.Pin,
- };
-
- // Parse expiry date - NordPass uses various formats, commonly "MM/YYYY" or "MMYYYY".
- if (!string.IsNullOrWhiteSpace(record.ExpiryDate))
- {
- ParseExpiryDate(record.ExpiryDate, creditcard);
- }
-
- return creditcard;
- }
-
- /// <summary>
- /// Parses NordPass expiry date string into month and year components.
- /// Handles formats like "MM/YYYY", "MM/YY", and "MMYYYY".
- /// </summary>
- private static void ParseExpiryDate(string expiryDate, ImportedCreditcard creditcard)
- {
- if (expiryDate.Contains('/'))
- {
- var parts = expiryDate.Split('/');
- if (parts.Length == 2)
- {
- creditcard.ExpiryMonth = parts[0].Trim().PadLeft(2, '0');
- creditcard.ExpiryYear = parts[1].Trim();
- }
- }
- else if (expiryDate.Length == 6)
- {
- // Format: MMYYYY
- creditcard.ExpiryMonth = expiryDate[..2];
- creditcard.ExpiryYear = expiryDate[2..];
- }
- }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Importers/OnePassword1puxImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/OnePassword1puxImporter.cs
deleted file mode 100644
index 4b794f21a..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Importers/OnePassword1puxImporter.cs
+++ /dev/null
@@ -1,655 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="OnePassword1puxImporter.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 System.Text.Json;
-using AliasClientDb.Models;
-using AliasVault.ImportExport.Exceptions;
-using AliasVault.ImportExport.Models;
-using AliasVault.ImportExport.Models.Imports;
-
-/// <summary>
-/// Imports credentials from 1Password .1pux export format.
-/// </summary>
-public class OnePassword1puxImporter : BaseArchiveImporter
-{
- private static readonly JsonSerializerOptions ItemDeserializerOptions = new()
- {
- PropertyNameCaseInsensitive = true,
- };
-
- /// <inheritdoc/>
- protected override string? GetAttachmentPathPattern() => "files/";
-
- /// <inheritdoc/>
- protected override async Task<List<ImportedCredential>> ProcessArchiveAsync(ZipArchive archive, Dictionary<string, byte[]> attachmentMap, Dictionary<string, byte[]> logoMap, List<ImportFailure> failures)
- {
- var attributes = await TryReadJsonFromArchiveAsync<OnePassword1puxAttributes>(archive, "export.attributes");
- if (attributes != null && attributes.Version != 3)
- {
- throw new ImportException(ImportStage.Parse, $"Unsupported 1Password export version: {attributes.Version}. Expected version 3.");
- }
-
- // Read the main export data.
- var credentials = new List<ImportedCredential>();
- var exportData = await ReadJsonFromArchiveAsync<OnePassword1puxData>(archive, "export.data");
-
- // Determine which vault should be promoted to root (if any)
- var rootVaultName = DetermineRootVault(exportData);
-
- // Process all accounts and vaults
- var itemIndex = 0;
- foreach (var account in exportData.Accounts)
- {
- foreach (var vault in account.Vaults)
- {
- var vaultName = vault.Attrs?.Name;
-
- // If this vault should be promoted to root, use null as folder path
- var folderPath = (vaultName != null && vaultName.Equals(rootVaultName, StringComparison.OrdinalIgnoreCase))
- ? null
- : vaultName;
-
- foreach (var itemElement in vault.Items)
- {
- OnePasswordItem? item = null;
- try
- {
- item = itemElement.Deserialize<OnePasswordItem>(ItemDeserializerOptions);
- if (item == null)
- {
- failures.Add(new ImportFailure
- {
- Index = itemIndex,
- ItemTitle = TryGetItemTitle(itemElement),
- ExceptionType = nameof(JsonException),
- Message = "Item JSON deserialized to null",
- });
- continue;
- }
-
- var credential = ConvertOnePasswordItemToCredential(item, folderPath, attachmentMap);
- credentials.Add(credential);
- }
- catch (Exception ex)
- {
- failures.Add(BuildItemFailure(itemIndex, item?.Overview?.Title ?? TryGetItemTitle(itemElement), ex));
- }
- finally
- {
- itemIndex++;
- }
- }
- }
- }
-
- return credentials;
- }
-
- /// <summary>
- /// Best-effort extraction of an item's title directly from the raw JSON, so failures can still
- /// be attributed to a recognisable item even when typed deserialization throws.
- /// </summary>
- private static string? TryGetItemTitle(JsonElement itemElement)
- {
- if (itemElement.ValueKind != JsonValueKind.Object)
- {
- return null;
- }
-
- if (!itemElement.TryGetProperty("overview", out var overview) || overview.ValueKind != JsonValueKind.Object)
- {
- return null;
- }
-
- if (!overview.TryGetProperty("title", out var title) || title.ValueKind != JsonValueKind.String)
- {
- return null;
- }
-
- return title.GetString();
- }
-
- /// <summary>
- /// Determines which vault (if any) should be promoted to root level.
- /// Only 1Password's default/reserved vault names ("Private", "Personal", "Employee") are promoted to root.
- /// Custom vault names are always preserved as folders, regardless of item count.
- /// This provides predictable behavior: default vaults go to root, custom vaults become folders.
- /// </summary>
- /// <param name="exportData">The 1Password export data.</param>
- /// <returns>The name of the vault to promote to root, or null if none should be promoted.</returns>
- private static string? DetermineRootVault(OnePassword1puxData exportData)
- {
- // Known 1Password default/reserved vault names (case-insensitive)
- // These are the built-in vaults that cannot be renamed or deleted
- var defaultVaultNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
- {
- "Private",
- "Personal",
- "Employee",
- };
-
- // Find the first vault that matches a default name or has type "P" (Personal)
- foreach (var account in exportData.Accounts)
- {
- foreach (var vault in account.Vaults)
- {
- var vaultName = vault.Attrs?.Name;
- var vaultType = vault.Attrs?.Type;
- var itemCount = vault.Items?.Count ?? 0;
-
- // Only promote if it's a default vault with items
- if (itemCount > 0 && !string.IsNullOrWhiteSpace(vaultName))
- {
- if (defaultVaultNames.Contains(vaultName) || vaultType == "P")
- {
- return vaultName;
- }
- }
- }
- }
-
- // No default vault found, keep all vaults as folders
- return null;
- }
-
- /// <summary>
- /// Converts a 1Password item to an ImportedCredential.
- /// </summary>
- /// <param name="item">The 1Password item.</param>
- /// <param name="vaultName">The vault name (used as folder).</param>
- /// <param name="attachmentMap">Dictionary mapping attachment paths to file data.</param>
- /// <returns>The imported credential.</returns>
- private static ImportedCredential ConvertOnePasswordItemToCredential(
- OnePasswordItem item,
- string? vaultName,
- Dictionary<string, byte[]> attachmentMap)
- {
- var credential = new ImportedCredential
- {
- ServiceName = item.Overview?.Title,
- Notes = item.Details?.NotesPlain,
- FolderPath = vaultName,
- };
-
- // Set timestamps — TryFromUnixTimeSeconds returns null for out-of-range / corrupt values
- // rather than throwing, so a junk timestamp on a single item doesn't fail the whole item.
- credential.CreatedAt = BaseImporter.TryFromUnixTimeSeconds(item.CreatedAt);
- credential.UpdatedAt = BaseImporter.TryFromUnixTimeSeconds(item.UpdatedAt);
-
- // Extract URLs
- if (item.Overview?.Urls != null && item.Overview.Urls.Count > 0)
- {
- credential.ServiceUrls = item.Overview.Urls
- .Where(u => !string.IsNullOrWhiteSpace(u.Url))
- .Select(u => u.Url!)
- .ToList();
- }
-
- // Add tags if present (tags can be an array)
- if (item.Overview?.Tags != null && item.Overview.Tags.Count > 0)
- {
- credential.Tags = item.Overview.Tags
- .Where(t => !string.IsNullOrWhiteSpace(t))
- .ToList();
- }
-
- // Map category to item type and extract type-specific data
- credential.ItemType = MapCategoryToItemType(item.CategoryUuid);
- ExtractItemData(credential, item, attachmentMap);
-
- // Extract attachments (both from documentAttributes and item UUID-based files)
- ExtractAttachments(credential, item, attachmentMap);
-
- return credential;
- }
-
- /// <summary>
- /// Maps a 1Password category UUID to an ImportedItemType.
- /// </summary>
- /// <param name="categoryUuid">The category UUID.</param>
- /// <returns>The corresponding ImportedItemType.</returns>
- private static ImportedItemType MapCategoryToItemType(string? categoryUuid)
- {
- return categoryUuid switch
- {
- "001" => ImportedItemType.Login, // Login
- "002" => ImportedItemType.Creditcard, // Credit Card
- "003" => ImportedItemType.Note, // Secure Note
- "004" => ImportedItemType.Alias, // Identity
- "005" => ImportedItemType.Login, // Password
- "006" => ImportedItemType.Note, // Document
- _ => ImportedItemType.Login, // Default to Login for all other types
- };
- }
-
- /// <summary>
- /// Extracts data from a 1Password item based on its type.
- /// </summary>
- /// <param name="credential">The credential to populate.</param>
- /// <param name="item">The 1Password item.</param>
- /// <param name="attachmentMap">Dictionary mapping attachment paths to file data.</param>
- private static void ExtractItemData(ImportedCredential credential, OnePasswordItem item, Dictionary<string, byte[]> attachmentMap)
- {
- if (item.Details == null)
- {
- return;
- }
-
- // Extract login fields
- if (item.Details.LoginFields != null)
- {
- foreach (var field in item.Details.LoginFields)
- {
- if (field.Designation == "username" && !string.IsNullOrWhiteSpace(field.Value))
- {
- credential.Username = field.Value;
- }
- else if (field.Designation == "password" && !string.IsNullOrWhiteSpace(field.Value))
- {
- credential.Password = field.Value;
- }
- }
- }
-
- // Extract sections (custom fields and additional data)
- if (item.Details.Sections != null)
- {
- ExtractSections(credential, item.Details.Sections, attachmentMap);
- }
- }
-
- /// <summary>
- /// Extracts data from 1Password sections.
- /// </summary>
- /// <param name="credential">The credential to populate.</param>
- /// <param name="sections">The list of sections.</param>
- /// <param name="attachmentMap">Dictionary mapping attachment paths to file data.</param>
- private static void ExtractSections(ImportedCredential credential, List<OnePasswordSection> sections, Dictionary<string, byte[]> attachmentMap)
- {
- foreach (var section in sections)
- {
- if (section.Fields == null || section.Fields.Count == 0)
- {
- continue;
- }
-
- foreach (var field in section.Fields)
- {
- if (field.Value == null)
- {
- continue;
- }
-
- // Check for file attachments
- if (field.Value.File != null &&
- !string.IsNullOrWhiteSpace(field.Value.File.DocumentId) &&
- !string.IsNullOrWhiteSpace(field.Value.File.FileName))
- {
- var filePath = $"files/{field.Value.File.DocumentId}__{field.Value.File.FileName}";
- if (attachmentMap.TryGetValue(filePath, out var fileData))
- {
- AddAttachment(credential, field.Value.File.FileName, fileData);
- }
-
- continue;
- }
-
- // Skip fields with no title for non-file fields
- if (string.IsNullOrWhiteSpace(field.Title))
- {
- continue;
- }
-
- // Check for TOTP
- if (!string.IsNullOrWhiteSpace(field.Value.Totp))
- {
- credential.TwoFactorSecret = field.Value.Totp;
- continue;
- }
-
- // Handle identity data
- if (credential.ItemType == ImportedItemType.Alias)
- {
- ExtractIdentityField(credential, field);
- }
-
- // Handle credit card data
- if (credential.ItemType == ImportedItemType.Creditcard)
- {
- ExtractCreditCardField(credential, field);
- }
-
- // Add other fields as custom fields.
- var resolved = ResolveFieldValue(field.Value);
- if (!string.IsNullOrWhiteSpace(resolved.Value))
- {
- BaseImporter.AddCustomField(
- credential,
- field.Title,
- resolved.Value,
- resolved.FieldType);
- }
- }
- }
- }
-
- /// <summary>
- /// Extracts identity-specific fields.
- /// </summary>
- /// <param name="credential">The credential to populate.</param>
- /// <param name="field">The field to extract.</param>
- private static void ExtractIdentityField(ImportedCredential credential, OnePasswordField field)
- {
- credential.Alias ??= new ImportedAlias();
-
- var fieldValue = GetFieldValueAsString(field.Value!);
- if (string.IsNullOrWhiteSpace(fieldValue))
- {
- return;
- }
-
- var titleLower = field.Title?.ToLowerInvariant();
- switch (titleLower)
- {
- case "first name":
- case "firstname":
- credential.Alias.FirstName = fieldValue;
- break;
-
- case "last name":
- case "lastname":
- credential.Alias.LastName = fieldValue;
- break;
-
- case "gender":
- case "sex":
- credential.Alias.Gender = fieldValue;
- break;
-
- case "birth date":
- case "birthdate":
- case "date of birth":
- credential.Alias.BirthDate = BaseImporter.TryFromUnixTimeSeconds(field.Value?.Date);
- break;
- }
- }
-
- /// <summary>
- /// Extracts credit card-specific fields.
- /// </summary>
- /// <param name="credential">The credential to populate.</param>
- /// <param name="field">The field to extract.</param>
- private static void ExtractCreditCardField(ImportedCredential credential, OnePasswordField field)
- {
- credential.Creditcard ??= new ImportedCreditcard();
-
- var titleLower = field.Title?.ToLowerInvariant();
-
- // Handle different value types based on field
- switch (titleLower)
- {
- case "cardholder name":
- case "cardholder":
- case "name on card":
- if (TryGetFieldValueAsString(field.Value, out var cardholderName))
- {
- credential.Creditcard.CardholderName = cardholderName;
- }
-
- break;
-
- case "number":
- case "card number":
- case "cardnumber":
- // Credit card numbers are in the creditCardNumber field
- if (!string.IsNullOrWhiteSpace(field.Value?.CreditCardNumber))
- {
- credential.Creditcard.Number = field.Value.CreditCardNumber;
- }
- else if (TryGetFieldValueAsString(field.Value, out var numberValue))
- {
- credential.Creditcard.Number = numberValue;
- }
-
- break;
-
- case "cvv":
- case "verification number":
- case "security code":
- case "cvc":
- if (TryGetFieldValueAsString(field.Value, out var cvv))
- {
- credential.Creditcard.Cvv = cvv;
- }
-
- break;
-
- case "pin":
- case "pin code":
- if (TryGetFieldValueAsString(field.Value, out var pin))
- {
- credential.Creditcard.Pin = pin;
- }
-
- break;
-
- case "expiry date":
- case "expiration date":
- case "expires":
- // Parse month/year from the MonthYear field
- if (field.Value?.MonthYear.HasValue == true)
- {
- var monthYear = field.Value.MonthYear.Value.ToString();
- if (monthYear.Length == 6) // YYYYMM
- {
- credential.Creditcard.ExpiryYear = monthYear.Substring(0, 4);
- credential.Creditcard.ExpiryMonth = monthYear.Substring(4, 2);
- }
- }
-
- break;
- }
- }
-
- /// <summary>
- /// Resolves a 1Password field value to both its string value representation and the matching field type.
- /// </summary>
- /// <param name="fieldValue">The field value object.</param>
- /// <returns>The resolved value and its AliasVault field type. The value is null when empty.</returns>
- private static ResolvedFieldValue ResolveFieldValue(OnePasswordFieldValue fieldValue)
- {
- if (!string.IsNullOrWhiteSpace(fieldValue.String))
- {
- return new ResolvedFieldValue(fieldValue.String, FieldTypeKind.Text);
- }
-
- if (!string.IsNullOrWhiteSpace(fieldValue.Concealed))
- {
- return new ResolvedFieldValue(fieldValue.Concealed, FieldTypeKind.Hidden);
- }
-
- if (!string.IsNullOrWhiteSpace(fieldValue.Url))
- {
- return new ResolvedFieldValue(fieldValue.Url, FieldTypeKind.URL);
- }
-
- if (!string.IsNullOrWhiteSpace(fieldValue.CreditCardNumber))
- {
- return new ResolvedFieldValue(fieldValue.CreditCardNumber, FieldTypeKind.Text);
- }
-
- if (!string.IsNullOrWhiteSpace(fieldValue.Menu))
- {
- return new ResolvedFieldValue(fieldValue.Menu, FieldTypeKind.Text);
- }
-
- if (!string.IsNullOrWhiteSpace(fieldValue.Phone))
- {
- return new ResolvedFieldValue(fieldValue.Phone, FieldTypeKind.Phone);
- }
-
- if (fieldValue.Email?.EmailAddress != null)
- {
- return new ResolvedFieldValue(fieldValue.Email.EmailAddress, FieldTypeKind.Email);
- }
-
- if (fieldValue.Address != null)
- {
- return new ResolvedFieldValue(FormatAddress(fieldValue.Address), FieldTypeKind.Text);
- }
-
- if (fieldValue.Date.HasValue)
- {
- // FormatUnixTimestampAsDate emits an ISO yyyy-MM-dd string, which the Date field renders as-is.
- return new ResolvedFieldValue(BaseImporter.FormatUnixTimestampAsDate(fieldValue.Date.Value), FieldTypeKind.Date);
- }
-
- if (fieldValue.MonthYear.HasValue)
- {
- // MonthYear is only a yyyy-MM partial date, so keep it as plain text rather than a Date field.
- return new ResolvedFieldValue(BaseImporter.FormatMonthYear(fieldValue.MonthYear.Value), FieldTypeKind.Text);
- }
-
- return new ResolvedFieldValue(null, FieldTypeKind.Text);
- }
-
- /// <summary>
- /// Gets a field value as a string.
- /// </summary>
- /// <param name="fieldValue">The field value object.</param>
- /// <returns>The value as a string, or null if empty.</returns>
- private static string? GetFieldValueAsString(OnePasswordFieldValue fieldValue)
- {
- return ResolveFieldValue(fieldValue).Value;
- }
-
- /// <summary>
- /// Tries to get a field value as a string.
- /// </summary>
- /// <param name="fieldValue">The field value object.</param>
- /// <param name="result">The resulting string value.</param>
- /// <returns>True if a non-empty value was extracted; otherwise false.</returns>
- private static bool TryGetFieldValueAsString(OnePasswordFieldValue? fieldValue, out string? result)
- {
- result = null;
- if (fieldValue == null)
- {
- return false;
- }
-
- result = GetFieldValueAsString(fieldValue);
- return !string.IsNullOrWhiteSpace(result);
- }
-
- /// <summary>
- /// Formats an address value as a string.
- /// </summary>
- /// <param name="address">The address value.</param>
- /// <returns>A formatted address string.</returns>
- private static string? FormatAddress(OnePasswordAddressValue address)
- {
- var parts = new List<string>();
-
- if (!string.IsNullOrWhiteSpace(address.Street))
- {
- parts.Add(address.Street);
- }
-
- if (!string.IsNullOrWhiteSpace(address.City))
- {
- parts.Add(address.City);
- }
-
- if (!string.IsNullOrWhiteSpace(address.State))
- {
- parts.Add(address.State);
- }
-
- if (!string.IsNullOrWhiteSpace(address.Zip))
- {
- parts.Add(address.Zip);
- }
-
- if (!string.IsNullOrWhiteSpace(address.Country))
- {
- parts.Add(address.Country);
- }
-
- return parts.Count > 0 ? string.Join(", ", parts) : null;
- }
-
- /// <summary>
- /// Extracts attachments for a 1Password item.
- /// Supports both document items (via documentAttributes) and regular items with attached files.
- /// 1Password stores files as: files/&lt;documentId or itemUuid&gt;__&lt;filename&gt; (double underscore separator).
- /// </summary>
- /// <param name="credential">The credential to add attachments to.</param>
- /// <param name="item">The 1Password item.</param>
- /// <param name="attachmentMap">Dictionary mapping attachment paths to file data.</param>
- private static void ExtractAttachments(
- ImportedCredential credential,
- OnePasswordItem item,
- Dictionary<string, byte[]> attachmentMap)
- {
- // Try document attributes first (for Document category items)
- if (item.Details?.DocumentAttributes != null &&
- !string.IsNullOrWhiteSpace(item.Details.DocumentAttributes.DocumentId) &&
- !string.IsNullOrWhiteSpace(item.Details.DocumentAttributes.FileName))
- {
- var docPath = $"files/{item.Details.DocumentAttributes.DocumentId}__{item.Details.DocumentAttributes.FileName}";
- if (attachmentMap.TryGetValue(docPath, out var docData))
- {
- AddAttachment(credential, item.Details.DocumentAttributes.FileName, docData);
- }
- }
-
- // Also check for item UUID-based attachments (for regular items with attached files)
- // 1Password can attach files to any item type using: files/<itemUuid>__<filename>
- if (!string.IsNullOrWhiteSpace(item.Uuid))
- {
- var attachmentPrefix = $"files/{item.Uuid}__";
-
- var itemAttachments = attachmentMap
- .Where(kvp => kvp.Key.StartsWith(attachmentPrefix, StringComparison.OrdinalIgnoreCase))
- .ToList();
-
- foreach (var attachmentEntry in itemAttachments)
- {
- // Extract filename (everything after the double underscore)
- var filename = attachmentEntry.Key.Substring(attachmentPrefix.Length);
- AddAttachment(credential, filename, attachmentEntry.Value);
- }
- }
- }
-
- /// <summary>
- /// Helper method to add an attachment to a credential.
- /// </summary>
- /// <param name="credential">The credential to add the attachment to.</param>
- /// <param name="filename">The filename of the attachment.</param>
- /// <param name="fileData">The file data.</param>
- private static void AddAttachment(ImportedCredential credential, string filename, byte[] fileData)
- {
- credential.Attachments ??= new List<ImportedAttachment>();
-
- credential.Attachments.Add(new ImportedAttachment
- {
- Filename = filename,
- Blob = fileData,
- });
- }
-
- /// <summary>
- /// A 1Password field value resolved to its string value representation and matching field type.
- /// </summary>
- /// <param name="Value">The value as a string, or null when the field is empty.</param>
- /// <param name="FieldType">The field type the value maps to.</param>
- private readonly record struct ResolvedFieldValue(string? Value, FieldTypeKind FieldType);
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Importers/OnePasswordImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/OnePasswordImporter.cs
deleted file mode 100644
index 7abbfe8b6..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Importers/OnePasswordImporter.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="OnePasswordImporter.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 AliasVault.ImportExport.Models;
-using AliasVault.ImportExport.Models.Imports;
-
-/// <summary>
-/// Imports credentials from 1Password.
-/// </summary>
-public static class OnePasswordImporter
-{
- /// <summary>
- /// Imports 1Password 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)
- {
- var records = await BaseImporter.ImportCsvDataAsync<OnePasswordCsvRecord>(fileContent);
-
- var credentials = new List<ImportedCredential>();
- foreach (var record in records)
- {
- var credential = new ImportedCredential
- {
- ServiceName = record.Title,
- ServiceUrls = BaseImporter.ParseUrls(record.Url),
- Username = record.Username,
- Password = record.Password,
- TwoFactorSecret = record.OTPAuth,
- Notes = record.Notes,
- FolderPath = string.IsNullOrWhiteSpace(record.Tags) ? null : record.Tags,
- };
-
- credentials.Add(credential);
- }
-
- return credentials;
- }
-}
\ No newline at end of file
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Importers/ProtonPassImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/ProtonPassImporter.cs
deleted file mode 100644
index 94f4955c5..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Importers/ProtonPassImporter.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="ProtonPassImporter.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 AliasVault.ImportExport.Models;
-using AliasVault.ImportExport.Models.Imports;
-
-/// <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)
- {
- var records = await BaseImporter.ImportCsvDataAsync<ProtonPassCsvRecord>(fileContent);
-
- var credentials = new List<ImportedCredential>();
- foreach (var record in records)
- {
- var credential = new ImportedCredential
- {
- ServiceName = record.Name,
- ServiceUrls = BaseImporter.ParseUrls(record.Url),
- Email = record.Email,
- Username = record.Username,
- Password = record.Password,
- Notes = record.Note,
- TwoFactorSecret = record.Totp,
- FolderPath = string.IsNullOrWhiteSpace(record.Vault) ? null : record.Vault,
- ItemType = MapProtonPassType(record.Type),
- };
-
- credentials.Add(credential);
- }
-
- return credentials;
- }
-
- /// <summary>
- /// Maps ProtonPass type values to ImportedItemType.
- /// ProtonPass types: login, note, alias, creditCard.
- /// </summary>
- private static ImportedItemType? MapProtonPassType(string? protonPassType)
- {
- if (string.IsNullOrWhiteSpace(protonPassType))
- {
- return null;
- }
-
- return protonPassType.ToLowerInvariant() switch
- {
- "login" => ImportedItemType.Login,
- "note" => ImportedItemType.Note,
- "alias" => ImportedItemType.Login, // ProtonPass alias is email alias, not identity alias
- "creditcard" => ImportedItemType.Creditcard,
- _ => ImportedItemType.Login,
- };
- }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Importers/ProtonPassZipImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/ProtonPassZipImporter.cs
deleted file mode 100644
index 6bdeaa76a..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Importers/ProtonPassZipImporter.cs
+++ /dev/null
@@ -1,471 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="ProtonPassZipImporter.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 System.Text.Json;
-using AliasClientDb.Models;
-using AliasVault.ImportExport.Exceptions;
-using AliasVault.ImportExport.Models;
-using AliasVault.ImportExport.Models.Imports;
-
-/// <summary>
-/// Imports credentials from a Proton Pass .zip export.
-/// </summary>
-public class ProtonPassZipImporter : BaseArchiveImporter
-{
- private const string DataJsonPath = "Proton Pass/data.json";
- private const string EncryptedDataPath = "Proton Pass/data.pgp";
- private const string FilesPath = "Proton Pass/files/";
-
- /// <summary>
- /// Default Proton Pass vault name. When an export contains only this vault,
- /// its items are promoted to the root folder to avoid an unnecessary "Personal" folder.
- /// </summary>
- private const string DefaultVaultName = "Personal";
-
- private static readonly JsonSerializerOptions ItemDeserializerOptions = new()
- {
- PropertyNameCaseInsensitive = true,
- };
-
- /// <inheritdoc/>
- protected override string? GetAttachmentPathPattern() => FilesPath;
-
- /// <inheritdoc/>
- protected override async Task<List<ImportedCredential>> ProcessArchiveAsync(
- ZipArchive archive,
- Dictionary<string, byte[]> attachmentMap,
- Dictionary<string, byte[]> logoMap,
- List<ImportFailure> failures)
- {
- // Reject encrypted exports up-front with a clear message.
- if (archive.GetEntry(EncryptedDataPath) != null)
- {
- throw new ImportException(ImportStage.Parse, "Encrypted Proton Pass exports (data.pgp) are not supported.");
- }
-
- // Items are kept as raw JsonElements and deserialized one-by-one below so that a single
- // malformed item (unexpected sub-object shape, new field type, etc.) doesn't abort the import.
- var exportData = await ReadJsonFromArchiveAsync<ProtonPassJsonExport>(archive, DataJsonPath);
-
- if (exportData.Encrypted)
- {
- throw new ImportException(ImportStage.Parse, "Encrypted Proton Pass exports are not supported. Please export without a password.");
- }
-
- var rootVaultId = DetermineRootVaultId(exportData);
-
- var credentials = new List<ImportedCredential>();
-
- var itemIndex = 0;
- foreach (var (vaultId, vault) in exportData.Vaults)
- {
- var folderPath = vaultId == rootVaultId ? null : vault.Name;
-
- foreach (var itemElement in vault.Items)
- {
- ProtonPassItem? item = null;
- try
- {
- item = itemElement.Deserialize<ProtonPassItem>(ItemDeserializerOptions);
- if (item == null)
- {
- failures.Add(new ImportFailure
- {
- Index = itemIndex,
- ItemTitle = TryGetItemName(itemElement),
- ExceptionType = nameof(JsonException),
- Message = "Item JSON deserialized to null",
- });
- continue;
- }
-
- // Skip trashed items. State == 2 is "trashed"; other values (null/0/1) are treated
- // as active since older envelope versions may omit the field entirely.
- if (item.State == 2)
- {
- continue;
- }
-
- var credential = ConvertItemToCredential(item, folderPath, attachmentMap);
- if (credential != null)
- {
- credentials.Add(credential);
- }
- }
- catch (Exception ex)
- {
- failures.Add(BuildItemFailure(itemIndex, item?.Data?.Metadata?.Name ?? TryGetItemName(itemElement), ex));
- }
- finally
- {
- itemIndex++;
- }
- }
- }
-
- return credentials;
- }
-
- /// <summary>
- /// Extracts the item name from the JSON element.
- /// </summary>
- private static string? TryGetItemName(JsonElement itemElement)
- {
- if (itemElement.ValueKind != JsonValueKind.Object)
- {
- return null;
- }
-
- if (!itemElement.TryGetProperty("data", out var data) || data.ValueKind != JsonValueKind.Object)
- {
- return null;
- }
-
- if (!data.TryGetProperty("metadata", out var metadata) || metadata.ValueKind != JsonValueKind.Object)
- {
- return null;
- }
-
- if (!metadata.TryGetProperty("name", out var name) || name.ValueKind != JsonValueKind.String)
- {
- return null;
- }
-
- return name.GetString();
- }
-
- /// <summary>
- /// Picks a vault to promote to the root folder. Only the single default "Personal" vault
- /// is promoted; custom vaults are always preserved as folders so users keep their structure.
- /// </summary>
- /// <param name="exportData">The Proton Pass export data.</param>
- /// <returns>The vault ID to promote, or null if none should be promoted.</returns>
- private static string? DetermineRootVaultId(ProtonPassJsonExport exportData)
- {
- foreach (var (vaultId, vault) in exportData.Vaults)
- {
- if (!string.IsNullOrWhiteSpace(vault.Name) && vault.Name.Equals(DefaultVaultName, StringComparison.OrdinalIgnoreCase))
- {
- return vaultId;
- }
- }
-
- return null;
- }
-
- /// <summary>
- /// Converts a Proton Pass item to an ImportedCredential.
- /// </summary>
- /// <param name="item">The Proton Pass item.</param>
- /// <param name="folderPath">The folder path to assign (vault name or null for root).</param>
- /// <param name="attachmentMap">Dictionary mapping attachment paths to file data.</param>
- /// <returns>The imported credential, or null if the item has no data payload.</returns>
- private static ImportedCredential? ConvertItemToCredential(ProtonPassItem item, string? folderPath, Dictionary<string, byte[]> attachmentMap)
- {
- if (item.Data == null)
- {
- return null;
- }
-
- var credential = new ImportedCredential
- {
- ServiceName = item.Data.Metadata?.Name,
- Notes = item.Data.Metadata?.Note,
- FolderPath = folderPath,
- };
-
- credential.CreatedAt = BaseImporter.TryFromUnixTimeSeconds(item.CreateTime);
- credential.UpdatedAt = BaseImporter.TryFromUnixTimeSeconds(item.ModifyTime);
-
- credential.ItemType = MapItemType(item.Data.Type);
-
- ExtractTypeSpecificData(credential, item);
- ExtractExtraFields(credential, item.Data.ExtraFields);
- ExtractAttachments(credential, item.Files, attachmentMap);
-
- return credential;
- }
-
- /// <summary>
- /// Maps a Proton Pass item type to an ImportedItemType.
- /// Proton Pass aliases are email aliases (not identity aliases) so they are mapped to Login
- /// to remain consistent with the existing Proton Pass CSV importer.
- /// </summary>
- /// <param name="type">The Proton Pass type string.</param>
- /// <returns>The corresponding ImportedItemType.</returns>
- private static ImportedItemType MapItemType(string? type)
- {
- if (string.IsNullOrWhiteSpace(type))
- {
- return ImportedItemType.Login;
- }
-
- return type.ToLowerInvariant() switch
- {
- "login" => ImportedItemType.Login,
- "note" => ImportedItemType.Note,
- "alias" => ImportedItemType.Login,
- "creditcard" => ImportedItemType.Creditcard,
- "identity" => ImportedItemType.Alias,
- _ => ImportedItemType.Login,
- };
- }
-
- /// <summary>
- /// Extracts type-specific data into the credential.
- /// </summary>
- /// <param name="credential">The credential to populate.</param>
- /// <param name="item">The source Proton Pass item.</param>
- private static void ExtractTypeSpecificData(ImportedCredential credential, ProtonPassItem item)
- {
- var type = item.Data?.Type?.ToLowerInvariant();
- var content = item.Data?.Content;
-
- switch (type)
- {
- case "login":
- ExtractLoginContent(credential, content);
- break;
-
- case "alias":
- // Proton Pass alias items keep the generated email at the envelope level.
- credential.Email = item.AliasEmail;
- credential.Username = item.AliasEmail;
- break;
-
- case "creditcard":
- ExtractCreditCardContent(credential, content);
- break;
-
- case "identity":
- ExtractIdentityContent(credential, content);
- break;
-
- case "note":
- default:
- // Secure notes and unknown types only use metadata (name + note).
- break;
- }
- }
-
- /// <summary>
- /// Extracts login-specific content.
- /// </summary>
- /// <param name="credential">The credential to populate.</param>
- /// <param name="content">The login content payload.</param>
- private static void ExtractLoginContent(ImportedCredential credential, ProtonPassContent? content)
- {
- if (content == null)
- {
- return;
- }
-
- credential.Username = string.IsNullOrWhiteSpace(content.ItemUsername) ? null : content.ItemUsername;
- credential.Email = string.IsNullOrWhiteSpace(content.ItemEmail) ? null : content.ItemEmail;
- credential.Password = string.IsNullOrWhiteSpace(content.Password) ? null : content.Password;
- credential.TwoFactorSecret = string.IsNullOrWhiteSpace(content.TotpUri) ? null : content.TotpUri;
-
- if (content.Urls != null && content.Urls.Count > 0)
- {
- credential.ServiceUrls = content.Urls
- .Where(u => !string.IsNullOrWhiteSpace(u))
- .ToList();
- }
- }
-
- /// <summary>
- /// Extracts credit-card-specific content.
- /// </summary>
- /// <param name="credential">The credential to populate.</param>
- /// <param name="content">The credit card content payload.</param>
- private static void ExtractCreditCardContent(ImportedCredential credential, ProtonPassContent? content)
- {
- if (content == null)
- {
- return;
- }
-
- var card = new ImportedCreditcard
- {
- CardholderName = string.IsNullOrWhiteSpace(content.CardholderName) ? null : content.CardholderName,
- Number = string.IsNullOrWhiteSpace(content.Number) ? null : content.Number,
- Cvv = string.IsNullOrWhiteSpace(content.VerificationNumber) ? null : content.VerificationNumber,
- Pin = string.IsNullOrWhiteSpace(content.Pin) ? null : content.Pin,
- };
-
- // Proton Pass stores the expiration as "YYYY-MM" (seen in the JSON export).
- if (!string.IsNullOrWhiteSpace(content.ExpirationDate))
- {
- ParseExpirationDate(content.ExpirationDate, card);
- }
-
- credential.Creditcard = card;
- }
-
- /// <summary>
- /// Parses a Proton Pass credit card expiration string into month/year fields.
- /// Supports "YYYY-MM" and "MMYY" formats.
- /// </summary>
- /// <param name="expirationDate">The expiration string.</param>
- /// <param name="card">The target credit card to populate.</param>
- private static void ParseExpirationDate(string expirationDate, ImportedCreditcard card)
- {
- var value = expirationDate.Trim();
-
- if (value.Contains('-'))
- {
- // "YYYY-MM"
- var parts = value.Split('-');
- if (parts.Length == 2 && parts[0].Length == 4 && parts[1].Length is 1 or 2)
- {
- card.ExpiryYear = parts[0];
- card.ExpiryMonth = parts[1].PadLeft(2, '0');
- }
-
- return;
- }
-
- // "MMYY" (4 digits, no separator)
- if (value.Length == 4 && value.All(char.IsDigit))
- {
- card.ExpiryMonth = value.Substring(0, 2);
- card.ExpiryYear = "20" + value.Substring(2, 2);
- }
- }
-
- /// <summary>
- /// Extracts identity-specific content (Proton Pass "identity" item type).
- /// </summary>
- /// <param name="credential">The credential to populate.</param>
- /// <param name="content">The identity content payload.</param>
- private static void ExtractIdentityContent(ImportedCredential credential, ProtonPassContent? content)
- {
- if (content == null)
- {
- return;
- }
-
- var firstName = content.FirstName;
- var lastName = content.LastName;
-
- // If firstName/lastName aren't set but fullName is, split on the first space.
- if (string.IsNullOrWhiteSpace(firstName) && string.IsNullOrWhiteSpace(lastName) &&
- !string.IsNullOrWhiteSpace(content.FullName))
- {
- var parts = content.FullName.Split(' ', 2, StringSplitOptions.RemoveEmptyEntries);
- firstName = parts.Length > 0 ? parts[0] : null;
- lastName = parts.Length > 1 ? parts[1] : null;
- }
-
- credential.Alias = new ImportedAlias
- {
- FirstName = string.IsNullOrWhiteSpace(firstName) ? null : firstName,
- LastName = string.IsNullOrWhiteSpace(lastName) ? null : lastName,
- };
-
- if (!string.IsNullOrWhiteSpace(content.Email))
- {
- credential.Email = content.Email;
- }
- }
-
- /// <summary>
- /// Extracts Proton Pass custom fields (extraFields) into the credential.
- /// </summary>
- /// <param name="credential">The credential to populate.</param>
- /// <param name="extraFields">The list of extra fields from the item data.</param>
- private static void ExtractExtraFields(ImportedCredential credential, List<ProtonPassExtraField>? extraFields)
- {
- if (extraFields == null || extraFields.Count == 0)
- {
- return;
- }
-
- foreach (var field in extraFields)
- {
- if (string.IsNullOrWhiteSpace(field.FieldName))
- {
- continue;
- }
-
- var value = field.Data?.Content;
- if (string.IsNullOrWhiteSpace(value))
- {
- continue;
- }
-
- var type = field.Type?.ToLowerInvariant();
- var isOtpAuthUri = value.StartsWith("otpauth://", StringComparison.OrdinalIgnoreCase);
-
- // Promote any field that is either explicitly a TOTP field or whose value is
- // an otpauth:// URI, but only when the login doesn't already have a 2FA secret
- // from its built-in content.totpUri slot.
- if ((type == "totp" || isOtpAuthUri) && string.IsNullOrWhiteSpace(credential.TwoFactorSecret))
- {
- credential.TwoFactorSecret = value;
- continue;
- }
-
- // Proton Pass custom fields can have type "hidden" for concealed fields.
- // Other known types include "text", "totp", and "date".
- BaseImporter.AddCustomField(
- credential,
- field.FieldName,
- value,
- type == "hidden" ? FieldTypeKind.Hidden : FieldTypeKind.Text);
- }
- }
-
- /// <summary>
- /// Extracts attachments referenced by an item's files array. Proton Pass stores
- /// file blobs under "Proton Pass/files/&lt;fileId&gt;" within the archive.
- /// </summary>
- /// <param name="credential">The credential to populate.</param>
- /// <param name="files">The item's referenced files.</param>
- /// <param name="attachmentMap">Dictionary mapping archive paths to file data.</param>
- private static void ExtractAttachments(ImportedCredential credential, List<ProtonPassFile>? files, Dictionary<string, byte[]> attachmentMap)
- {
- if (files == null || files.Count == 0 || attachmentMap.Count == 0)
- {
- return;
- }
-
- foreach (var file in files)
- {
- if (string.IsNullOrWhiteSpace(file.FileId))
- {
- continue;
- }
-
- // Match either an exact path (files/<id>) or a path that starts with the id
- // (files/<id>/<filename>, files/<id>.<ext>, etc.) — the exact layout isn't
- // publicly documented, so we handle both.
- var match = attachmentMap.FirstOrDefault(kvp =>
- {
- var relative = kvp.Key.Substring(FilesPath.Length);
- return relative.Equals(file.FileId, StringComparison.OrdinalIgnoreCase) ||
- relative.StartsWith(file.FileId + "/", StringComparison.OrdinalIgnoreCase) ||
- relative.StartsWith(file.FileId + ".", StringComparison.OrdinalIgnoreCase);
- });
-
- if (match.Value == null)
- {
- continue;
- }
-
- credential.Attachments ??= new List<ImportedAttachment>();
- credential.Attachments.Add(new ImportedAttachment
- {
- Filename = !string.IsNullOrWhiteSpace(file.Name) ? file.Name : file.FileId,
- Blob = match.Value,
- });
- }
- }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Importers/RoboformImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/RoboformImporter.cs
deleted file mode 100644
index 71ce112e5..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Importers/RoboformImporter.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="RoboformImporter.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 AliasVault.ImportExport.Models;
-using AliasVault.ImportExport.Models.Imports;
-
-/// <summary>
-/// Imports credentials from RoboForm.
-/// </summary>
-public static class RoboformImporter
-{
- /// <summary>
- /// Imports RoboForm 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)
- {
- var records = await BaseImporter.ImportCsvDataAsync<RoboformCsvRecord>(fileContent);
-
- var credentials = new List<ImportedCredential>();
- foreach (var record in records)
- {
- var itemType = DetermineItemType(record);
-
- var credential = new ImportedCredential
- {
- ServiceName = record.Name,
- ServiceUrls = BaseImporter.ParseUrls(record.Url),
- Username = record.Login,
- Password = record.Password,
- Notes = record.Note,
- FolderPath = NormalizeFolderPath(record.Folder),
- ItemType = itemType,
- };
-
- credentials.Add(credential);
- }
-
- return credentials;
- }
-
- /// <summary>
- /// Normalizes the folder path from RoboForm format.
- /// RoboForm uses paths like "/Business" - we remove the leading slash.
- /// </summary>
- /// <param name="folder">The folder path from RoboForm.</param>
- /// <returns>The normalized folder path, or null if empty.</returns>
- private static string? NormalizeFolderPath(string? folder)
- {
- if (string.IsNullOrWhiteSpace(folder))
- {
- return null;
- }
-
- // Remove leading slash if present
- var normalized = folder.TrimStart('/');
- return string.IsNullOrWhiteSpace(normalized) ? null : normalized;
- }
-
- /// <summary>
- /// Determines the item type based on the RoboForm record.
- /// RoboForm marks secure notes by having no URL, login, or password.
- /// </summary>
- /// <param name="record">The RoboForm CSV record.</param>
- /// <returns>The determined item type.</returns>
- private static ImportedItemType DetermineItemType(RoboformCsvRecord record)
- {
- // If there's no URL, login, and password, it's likely a secure note
- if (string.IsNullOrWhiteSpace(record.Url) &&
- string.IsNullOrWhiteSpace(record.Login) &&
- string.IsNullOrWhiteSpace(record.Password) &&
- !string.IsNullOrWhiteSpace(record.Note))
- {
- return ImportedItemType.Note;
- }
-
- return ImportedItemType.Login;
- }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Importers/StrongboxImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/StrongboxImporter.cs
deleted file mode 100644
index ad60ec792..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Importers/StrongboxImporter.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="StrongboxImporter.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 AliasVault.ImportExport.Models;
-using AliasVault.ImportExport.Models.Imports;
-
-/// <summary>
-/// Imports credentials from Strongbox.
-/// </summary>
-public static class StrongboxImporter
-{
- /// <summary>
- /// Imports KeePass 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)
- {
- var records = await BaseImporter.ImportCsvDataAsync<StrongboxCsvRecord>(fileContent);
-
- var credentials = new List<ImportedCredential>();
- foreach (var record in records)
- {
- var credential = new ImportedCredential
- {
- ServiceName = record.Title,
- ServiceUrls = BaseImporter.ParseUrls(record.URL),
- Username = record.Username,
- Password = record.Password,
- TwoFactorSecret = record.OTPAuth,
- Notes = record.Notes
- };
-
- credentials.Add(credential);
- }
-
- return credentials;
- }
-}
\ No newline at end of file
diff --git a/apps/server/Utilities/AliasVault.ImportExport/ItemCsvService.cs b/apps/server/Utilities/AliasVault.ImportExport/ItemCsvService.cs
deleted file mode 100644
index 6e07f42d3..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/ItemCsvService.cs
+++ /dev/null
@@ -1,380 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="ItemCsvService.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;
-
-using AliasClientDb;
-using AliasClientDb.Models;
-using AliasVault.ImportExport.Importers;
-using AliasVault.ImportExport.Models;
-using AliasVault.TotpGenerator;
-using CsvHelper;
-using CsvHelper.Configuration;
-using System.Globalization;
-
-/// <summary>
-/// Exports and imports Item objects to and from CSV files.
-/// </summary>
-public static class ItemCsvService
-{
- /// <summary>
- /// Export list of items to CSV file.
- /// </summary>
- /// <param name="items">List of items to export.</param>
- /// <returns>CSV file as byte array.</returns>
- public static byte[] ExportItemsToCsv(List<Item> items)
- {
- var records = new List<ItemCsvRecord>();
-
- foreach (var item in items)
- {
- var record = new ItemCsvRecord
- {
- ServiceName = item.Name ?? string.Empty,
- FolderPath = BuildFolderPath(item.Folder),
- ServiceUrl = GetJoinedFieldValues(item, FieldKey.LoginUrl),
- Username = GetFieldValue(item, FieldKey.LoginUsername),
- CurrentPassword = GetFieldValue(item, FieldKey.LoginPassword),
- AliasEmail = GetFieldValue(item, FieldKey.LoginEmail),
- TwoFactorSecret = FormatTwoFactorSecret(item.TotpCodes.FirstOrDefault(t => !t.IsDeleted)),
- AliasGender = GetFieldValue(item, FieldKey.AliasGender),
- AliasFirstName = GetFieldValue(item, FieldKey.AliasFirstName),
- AliasLastName = GetFieldValue(item, FieldKey.AliasLastName),
- AliasNickName = string.Empty, // NickName is no longer stored as a separate field
- AliasBirthDate = ParseBirthDate(GetFieldValue(item, FieldKey.AliasBirthdate)),
- Notes = GetFieldValue(item, FieldKey.NotesContent),
- CreatedAt = item.CreatedAt,
- UpdatedAt = item.UpdatedAt,
- CardholderName = GetFieldValue(item, FieldKey.CardCardholderName),
- CardNumber = GetFieldValue(item, FieldKey.CardNumber),
- CardExpiryMonth = GetFieldValue(item, FieldKey.CardExpiryMonth),
- CardExpiryYear = GetFieldValue(item, FieldKey.CardExpiryYear),
- CardCvv = GetFieldValue(item, FieldKey.CardCvv),
- CardPin = GetFieldValue(item, FieldKey.CardPin),
- };
-
- records.Add(record);
- }
-
- using var memoryStream = new MemoryStream();
- using var writer = new StreamWriter(memoryStream);
- using var csv = new CsvWriter(writer, new CsvConfiguration(CultureInfo.InvariantCulture));
-
- csv.WriteRecords(records);
- writer.Flush();
- return memoryStream.ToArray();
- }
-
- /// <summary>
- /// Imports Item objects from a CSV file.
- /// </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>> ImportItemsFromCsv(string fileContent)
- {
- using var reader = new StringReader(fileContent);
- var config = new CsvConfiguration(CultureInfo.InvariantCulture)
- {
- // Allow missing headers - fields that don't exist will be skipped
- HeaderValidated = null,
- MissingFieldFound = null,
- };
- using var csv = new CsvReader(reader, config);
-
- var records = new List<ItemCsvRecord>();
- await foreach (var record in csv.GetRecordsAsync<ItemCsvRecord>())
- {
- records.Add(record);
- }
-
- if (records.Count == 0)
- {
- throw new InvalidOperationException("No records found in the CSV file.");
- }
-
- var credentials = new List<ImportedCredential>();
-
- foreach (var record in records)
- {
- var credential = new ImportedCredential
- {
- ServiceName = record.ServiceName,
- ServiceUrls = BaseImporter.ParseUrls(record.ServiceUrl),
- Username = record.Username,
- Password = record.CurrentPassword,
- Email = record.AliasEmail,
- Notes = record.Notes,
- Alias = new ImportedAlias
- {
- Gender = record.AliasGender,
- FirstName = record.AliasFirstName,
- LastName = record.AliasLastName,
- NickName = record.AliasNickName,
- BirthDate = record.AliasBirthDate,
- CreatedAt = record.CreatedAt,
- UpdatedAt = record.UpdatedAt,
- },
- TwoFactorSecret = record.TwoFactorSecret,
- CreatedAt = record.CreatedAt,
- UpdatedAt = record.UpdatedAt,
- FolderPath = string.IsNullOrWhiteSpace(record.FolderPath) ? null : record.FolderPath,
- };
-
- if (HasCardData(record))
- {
- credential.ItemType = ImportedItemType.Creditcard;
- credential.Creditcard = new ImportedCreditcard
- {
- CardholderName = record.CardholderName,
- Number = record.CardNumber,
- ExpiryMonth = record.CardExpiryMonth,
- ExpiryYear = record.CardExpiryYear,
- Cvv = record.CardCvv,
- Pin = record.CardPin,
- };
- }
-
- credentials.Add(credential);
- }
-
- return credentials;
- }
-
- /// <summary>
- /// Formats an item's TOTP code for the single CSV secret column. Codes using the RFC 6238 defaults
- /// export as a bare secret so the column stays interchangeable with other password managers; codes
- /// with non-default parameters export as a full otpauth:// URI, which every importer understands.
- /// </summary>
- /// <param name="totpCode">The item's first non-deleted TOTP code, if any.</param>
- /// <returns>The secret or an otpauth:// URI.</returns>
- private static string FormatTwoFactorSecret(TotpCode? totpCode)
- {
- if (totpCode is null)
- {
- return string.Empty;
- }
-
- var algorithm = TotpParameters.NormalizeAlgorithm(totpCode.Algorithm);
- var digits = TotpParameters.NormalizeDigits(totpCode.Digits);
- var period = TotpParameters.NormalizePeriod(totpCode.Period);
-
- if (algorithm == TotpParameters.DefaultAlgorithm && digits == TotpParameters.DefaultDigits && period == TotpParameters.DefaultPeriod)
- {
- return totpCode.SecretKey;
- }
-
- var label = Uri.EscapeDataString(string.IsNullOrWhiteSpace(totpCode.Name) ? "AliasVault" : totpCode.Name);
- return $"otpauth://totp/{label}?secret={totpCode.SecretKey}&algorithm={algorithm}&digits={digits}&period={period}";
- }
-
- /// <summary>
- /// Builds the full hierarchical path for a folder by traversing parent folders.
- /// </summary>
- /// <param name="folder">The folder to build the path for.</param>
- /// <returns>The full hierarchical path (e.g., "Work/Projects/Active"), or empty string if null.</returns>
- private static string BuildFolderPath(Folder? folder)
- {
- if (folder == null)
- {
- return string.Empty;
- }
-
- var pathParts = new List<string>();
- var currentFolder = folder;
-
- // Traverse up the folder hierarchy
- while (currentFolder != null)
- {
- pathParts.Insert(0, currentFolder.Name);
- currentFolder = currentFolder.ParentFolder;
- }
-
- return string.Join("/", pathParts);
- }
-
- /// <summary>
- /// Gets a field value from an item by field key.
- /// </summary>
- /// <param name="item">The item to get the field value from.</param>
- /// <param name="fieldKey">The field key to look up.</param>
- /// <returns>The field value, or empty string if not found.</returns>
- private static string GetFieldValue(Item item, string fieldKey)
- {
- return item.FieldValues
- .FirstOrDefault(fv => fv.FieldKey == fieldKey && !fv.IsDeleted)
- ?.Value ?? string.Empty;
- }
-
- /// <summary>
- /// Gets all values of a multi-value field from an item as a single comma separated string, ordered by weight.
- /// </summary>
- /// <param name="item">The item to get the field values from.</param>
- /// <param name="fieldKey">The field key to look up.</param>
- /// <returns>The comma separated field values, or empty string if none are found.</returns>
- private static string GetJoinedFieldValues(Item item, string fieldKey)
- {
- var values = item.FieldValues
- .Where(fv => fv.FieldKey == fieldKey && !fv.IsDeleted && !string.IsNullOrWhiteSpace(fv.Value))
- .OrderBy(fv => fv.Weight)
- .Select(fv => fv.Value!.Trim());
-
- return string.Join(",", values);
- }
-
- /// <summary>
- /// Returns true if the CSV record has any credit card field populated.
- /// </summary>
- /// <param name="record">The CSV record to inspect.</param>
- /// <returns>True if any card field has a non-empty value.</returns>
- private static bool HasCardData(ItemCsvRecord record)
- {
- return !string.IsNullOrWhiteSpace(record.CardholderName)
- || !string.IsNullOrWhiteSpace(record.CardNumber)
- || !string.IsNullOrWhiteSpace(record.CardExpiryMonth)
- || !string.IsNullOrWhiteSpace(record.CardExpiryYear)
- || !string.IsNullOrWhiteSpace(record.CardCvv)
- || !string.IsNullOrWhiteSpace(record.CardPin);
- }
-
- /// <summary>
- /// Parses a birth date string to a DateTime.
- /// </summary>
- /// <param name="birthDateStr">The birth date string in yyyy-MM-dd format.</param>
- /// <returns>The parsed DateTime, or null if the string is empty or invalid.</returns>
- private static DateTime? ParseBirthDate(string birthDateStr)
- {
- if (string.IsNullOrEmpty(birthDateStr))
- {
- return null;
- }
-
- if (DateTime.TryParseExact(birthDateStr, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var date))
- {
- return date;
- }
-
- return null;
- }
-}
-
-/// <summary>
-/// CSV record for Item objects.
-/// </summary>
-public class ItemCsvRecord
-{
- /// <summary>
- /// Gets or sets the service name.
- /// </summary>
- public string ServiceName { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the folder path.
- /// Added in version 1.7.0.
- /// </summary>
- public string FolderPath { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the service URL(s). Multiple URLs are stored as a comma separated string.
- /// </summary>
- public string ServiceUrl { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the username.
- /// </summary>
- public string Username { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the current password.
- /// </summary>
- public string CurrentPassword { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the alias email.
- /// </summary>
- public string AliasEmail { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the two-factor secret.
- /// </summary>
- public string TwoFactorSecret { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the alias gender.
- /// </summary>
- public string AliasGender { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the alias first name.
- /// </summary>
- public string AliasFirstName { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the alias last name.
- /// </summary>
- public string AliasLastName { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the alias nickname (legacy field, no longer used).
- /// </summary>
- public string AliasNickName { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the alias birth date.
- /// </summary>
- public DateTime? AliasBirthDate { get; set; } = null;
-
- /// <summary>
- /// Gets or sets the credit card cardholder name.
- /// Empty for non-credit-card items.
- /// </summary>
- public string CardholderName { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the credit card number.
- /// Empty for non-credit-card items.
- /// </summary>
- public string CardNumber { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the credit card expiry month (01-12).
- /// Empty for non-credit-card items.
- /// </summary>
- public string CardExpiryMonth { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the credit card expiry year (e.g., "2028").
- /// Empty for non-credit-card items.
- /// </summary>
- public string CardExpiryYear { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the credit card CVV.
- /// Empty for non-credit-card items.
- /// </summary>
- public string CardCvv { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the credit card PIN.
- /// Empty for non-credit-card items.
- /// </summary>
- public string CardPin { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the notes.
- /// </summary>
- public string Notes { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the created timestamp.
- /// </summary>
- public DateTime CreatedAt { get; set; } = DateTime.MinValue;
-
- /// <summary>
- /// Gets or sets the updated timestamp.
- /// </summary>
- public DateTime UpdatedAt { get; set; } = DateTime.MinValue;
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvexHeader.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvexHeader.cs
deleted file mode 100644
index ceeb727a5..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvexHeader.cs
+++ /dev/null
@@ -1,100 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="AvexHeader.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.Exports;
-
-using AliasVault.ImportExport.Constants;
-
-/// <summary>
-/// Represents the header for an .avex (encrypted export) file.
-/// </summary>
-public class AvexHeader
-{
- /// <summary>
- /// Gets or sets the file format identifier.
- /// </summary>
- public string Format { get; set; } = AvexConstants.FormatIdentifier;
-
- /// <summary>
- /// Gets or sets the .avex container format version (not the app version).
- /// </summary>
- public string Version { get; set; } = AvexConstants.FormatVersion;
-
- /// <summary>
- /// Gets or sets the key derivation function parameters.
- /// </summary>
- public KdfParams Kdf { get; set; } = new();
-
- /// <summary>
- /// Gets or sets the encryption parameters.
- /// </summary>
- public EncryptionParams Encryption { get; set; } = new();
-
- /// <summary>
- /// Gets or sets the export metadata.
- /// </summary>
- public AvexMetadata Metadata { get; set; } = new();
-}
-
-/// <summary>
-/// Key derivation function parameters.
-/// </summary>
-public class KdfParams
-{
- /// <summary>
- /// Gets or sets the KDF algorithm type.
- /// </summary>
- public string Type { get; set; } = "Argon2id";
-
- /// <summary>
- /// Gets or sets the salt value (base64-encoded).
- /// </summary>
- public string Salt { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the algorithm-specific parameters.
- /// </summary>
- public Dictionary<string, int> Params { get; set; } = new();
-}
-
-/// <summary>
-/// Encryption algorithm parameters.
-/// </summary>
-public class EncryptionParams
-{
- /// <summary>
- /// Gets or sets the encryption algorithm name.
- /// </summary>
- public string Algorithm { get; set; } = "AES-256-GCM";
-
- /// <summary>
- /// Gets or sets the byte offset where encrypted data begins.
- /// </summary>
- public long EncryptedDataOffset { get; set; }
-}
-
-/// <summary>
-/// Metadata about the export.
-/// </summary>
-public class AvexMetadata
-{
- /// <summary>
- /// Gets or sets the timestamp when the export was created.
- /// </summary>
- public DateTime ExportedAt { get; set; }
-
- /// <summary>
- /// Gets or sets the username who created the export.
- /// </summary>
- public string ExportedBy { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the AliasVault application version that created this export.
- /// This helps with troubleshooting and understanding which version generated the export.
- /// </summary>
- public string? AppVersion { get; set; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxAttachment.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxAttachment.cs
deleted file mode 100644
index ac084ba06..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxAttachment.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="AvuxAttachment.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.Exports;
-
-/// <summary>
-/// Represents an attachment in an item.
-/// </summary>
-public class AvuxAttachment
-{
- /// <summary>
- /// Gets or sets the attachment ID.
- /// </summary>
- public Guid Id { get; set; }
-
- /// <summary>
- /// Gets or sets the filename.
- /// </summary>
- public string Filename { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the relative path in the .avux archive.
- /// </summary>
- public string RelativePath { get; set; } = string.Empty;
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxFieldDefinition.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxFieldDefinition.cs
deleted file mode 100644
index 55f6f86c1..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxFieldDefinition.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="AvuxFieldDefinition.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.Exports;
-
-/// <summary>
-/// Represents a custom field definition.
-/// </summary>
-public class AvuxFieldDefinition
-{
- /// <summary>
- /// Gets or sets the field definition ID.
- /// </summary>
- public Guid Id { get; set; }
-
- /// <summary>
- /// Gets or sets the field type.
- /// </summary>
- public string FieldType { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the field label.
- /// </summary>
- public string Label { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets a value indicating whether this field supports multiple values.
- /// </summary>
- public bool IsMultiValue { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether this field is hidden.
- /// </summary>
- public bool IsHidden { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether history is enabled for this field.
- /// </summary>
- public bool EnableHistory { get; set; }
-
- /// <summary>
- /// Gets or sets the display order weight.
- /// </summary>
- public int Weight { get; set; }
-
- /// <summary>
- /// Gets or sets the item types this field applies to (JSON array).
- /// </summary>
- public string? ApplicableToTypes { get; set; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxFieldValue.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxFieldValue.cs
deleted file mode 100644
index 816c7e406..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxFieldValue.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="AvuxFieldValue.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.Exports;
-
-/// <summary>
-/// Represents a field value in an item.
-/// </summary>
-public class AvuxFieldValue
-{
- /// <summary>
- /// Gets or sets the field value ID.
- /// </summary>
- public Guid Id { get; set; }
-
- /// <summary>
- /// Gets or sets the field key (e.g., "login.username").
- /// </summary>
- public string? FieldKey { get; set; }
-
- /// <summary>
- /// Gets or sets the custom field definition ID (if this is a custom field).
- /// </summary>
- public Guid? FieldDefinitionId { get; set; }
-
- /// <summary>
- /// Gets or sets the field value.
- /// </summary>
- public string? Value { get; set; }
-
- /// <summary>
- /// Gets or sets the display order weight.
- /// </summary>
- public int Weight { get; set; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxFolder.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxFolder.cs
deleted file mode 100644
index dfc0958d3..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxFolder.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="AvuxFolder.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.Exports;
-
-/// <summary>
-/// Represents a folder.
-/// </summary>
-public class AvuxFolder
-{
- /// <summary>
- /// Gets or sets the folder ID.
- /// </summary>
- public Guid Id { get; set; }
-
- /// <summary>
- /// Gets or sets the folder name.
- /// </summary>
- public string Name { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the parent folder ID (null for root folders).
- /// </summary>
- public Guid? ParentFolderId { get; set; }
-
- /// <summary>
- /// Gets or sets the display order weight.
- /// </summary>
- public int Weight { get; set; }
-
- /// <summary>
- /// Gets or sets the creation timestamp.
- /// </summary>
- public DateTime CreatedAt { get; set; }
-
- /// <summary>
- /// Gets or sets the last update timestamp.
- /// </summary>
- public DateTime UpdatedAt { get; set; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxItem.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxItem.cs
deleted file mode 100644
index 51ae36bae..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxItem.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="AvuxItem.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.Exports;
-
-/// <summary>
-/// Represents an item in the .avux export.
-/// </summary>
-public class AvuxItem
-{
- /// <summary>
- /// Gets or sets the item ID.
- /// </summary>
- public Guid Id { get; set; }
-
- /// <summary>
- /// Gets or sets the item name.
- /// </summary>
- public string? Name { get; set; }
-
- /// <summary>
- /// Gets or sets the item type (Login, Alias, CreditCard, Note).
- /// </summary>
- public string ItemType { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the creation timestamp.
- /// </summary>
- public DateTime CreatedAt { get; set; }
-
- /// <summary>
- /// Gets or sets the last update timestamp.
- /// </summary>
- public DateTime UpdatedAt { get; set; }
-
- /// <summary>
- /// Gets or sets the folder ID this item belongs to.
- /// </summary>
- public Guid? FolderId { get; set; }
-
- /// <summary>
- /// Gets or sets the logo ID this item uses.
- /// </summary>
- public Guid? LogoId { get; set; }
-
- /// <summary>
- /// Gets or sets the list of field values for this item.
- /// </summary>
- public List<AvuxFieldValue> FieldValues { get; set; } = new();
-
- /// <summary>
- /// Gets or sets the list of attachments for this item.
- /// </summary>
- public List<AvuxAttachment> Attachments { get; set; } = new();
-
- /// <summary>
- /// Gets or sets the list of TOTP codes for this item.
- /// </summary>
- public List<AvuxTotpCode> TotpCodes { get; set; } = new();
-
- /// <summary>
- /// Gets or sets the list of passkeys for this item.
- /// </summary>
- public List<AvuxPasskey> Passkeys { get; set; } = new();
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxItemTag.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxItemTag.cs
deleted file mode 100644
index 5017ca937..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxItemTag.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="AvuxItemTag.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.Exports;
-
-/// <summary>
-/// Represents an item-tag association.
-/// </summary>
-public class AvuxItemTag
-{
- /// <summary>
- /// Gets or sets the association ID.
- /// </summary>
- public Guid Id { get; set; }
-
- /// <summary>
- /// Gets or sets the item ID.
- /// </summary>
- public Guid ItemId { get; set; }
-
- /// <summary>
- /// Gets or sets the tag ID.
- /// </summary>
- public Guid TagId { get; set; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxLogo.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxLogo.cs
deleted file mode 100644
index e73b0e10a..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxLogo.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="AvuxLogo.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.Exports;
-
-/// <summary>
-/// Represents a logo in the .avux export.
-/// Logos are deduplicated by source domain.
-/// </summary>
-public class AvuxLogo
-{
- /// <summary>
- /// Gets or sets the logo ID.
- /// </summary>
- public Guid Id { get; set; }
-
- /// <summary>
- /// Gets or sets the source domain (e.g., 'github.com').
- /// </summary>
- public string Source { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the MIME type of the logo.
- /// </summary>
- public string? MimeType { get; set; }
-
- /// <summary>
- /// Gets or sets the timestamp when the logo was fetched.
- /// </summary>
- public DateTime? FetchedAt { get; set; }
-
- /// <summary>
- /// Gets or sets the relative path to the logo file in the .avux archive.
- /// </summary>
- public string RelativePath { get; set; } = string.Empty;
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxManifest.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxManifest.cs
deleted file mode 100644
index 2d773030f..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxManifest.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="AvuxManifest.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.Exports;
-
-/// <summary>
-/// Represents the complete manifest for an .avux export file.
-/// </summary>
-public class AvuxManifest
-{
- /// <summary>
- /// Gets or sets the export format version.
- /// </summary>
- public string Version { get; set; } = "1.0.0";
-
- /// <summary>
- /// Gets or sets the export timestamp.
- /// </summary>
- public DateTime ExportedAt { get; set; }
-
- /// <summary>
- /// Gets or sets the username who created the export.
- /// </summary>
- public string ExportedBy { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the list of items in the vault.
- /// </summary>
- public List<AvuxItem> Items { get; set; } = new();
-
- /// <summary>
- /// Gets or sets the list of folders.
- /// </summary>
- public List<AvuxFolder> Folders { get; set; } = new();
-
- /// <summary>
- /// Gets or sets the list of tags.
- /// </summary>
- public List<AvuxTag> Tags { get; set; } = new();
-
- /// <summary>
- /// Gets or sets the list of item-tag associations.
- /// </summary>
- public List<AvuxItemTag> ItemTags { get; set; } = new();
-
- /// <summary>
- /// Gets or sets the list of custom field definitions.
- /// </summary>
- public List<AvuxFieldDefinition> FieldDefinitions { get; set; } = new();
-
- /// <summary>
- /// Gets or sets the list of logos (deduplicated by source domain).
- /// </summary>
- public List<AvuxLogo> Logos { get; set; } = new();
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxPasskey.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxPasskey.cs
deleted file mode 100644
index 304e488be..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxPasskey.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="AvuxPasskey.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.Exports;
-
-/// <summary>
-/// Represents a passkey in an item.
-/// </summary>
-public class AvuxPasskey
-{
- /// <summary>
- /// Gets or sets the passkey ID (GUID).
- /// The WebAuthn credential ID is derived from this GUID at runtime using base64url encoding.
- /// </summary>
- public Guid Id { get; set; }
-
- /// <summary>
- /// Gets or sets the relying party ID.
- /// </summary>
- public string RpId { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the user handle (base64-encoded).
- /// </summary>
- public string? UserHandle { get; set; }
-
- /// <summary>
- /// Gets or sets the public key (JWK format).
- /// </summary>
- public string PublicKey { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the private key (JWK format).
- /// </summary>
- public string PrivateKey { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the PRF key (base64-encoded).
- /// </summary>
- public string? PrfKey { get; set; }
-
- /// <summary>
- /// Gets or sets the display name.
- /// </summary>
- public string DisplayName { get; set; } = string.Empty;
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxTag.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxTag.cs
deleted file mode 100644
index 630e2c102..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxTag.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="AvuxTag.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.Exports;
-
-/// <summary>
-/// Represents a tag.
-/// </summary>
-public class AvuxTag
-{
- /// <summary>
- /// Gets or sets the tag ID.
- /// </summary>
- public Guid Id { get; set; }
-
- /// <summary>
- /// Gets or sets the tag name.
- /// </summary>
- public string Name { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the tag color.
- /// </summary>
- public string? Color { get; set; }
-
- /// <summary>
- /// Gets or sets the display order.
- /// </summary>
- public int DisplayOrder { get; set; }
-
- /// <summary>
- /// Gets or sets the creation timestamp.
- /// </summary>
- public DateTime CreatedAt { get; set; }
-
- /// <summary>
- /// Gets or sets the last update timestamp.
- /// </summary>
- public DateTime UpdatedAt { get; set; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxTotpCode.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxTotpCode.cs
deleted file mode 100644
index 43f68f158..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Exports/AvuxTotpCode.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="AvuxTotpCode.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.Exports;
-
-using AliasVault.TotpGenerator;
-
-/// <summary>
-/// Represents a TOTP code in an item.
-/// </summary>
-public class AvuxTotpCode
-{
- /// <summary>
- /// Gets or sets the TOTP code ID.
- /// </summary>
- public Guid Id { get; set; }
-
- /// <summary>
- /// Gets or sets the TOTP code name.
- /// </summary>
- public string Name { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the TOTP secret key.
- /// </summary>
- public string SecretKey { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the HMAC algorithm: SHA1, SHA256 or SHA512.
- /// </summary>
- public string Algorithm { get; set; } = TotpParameters.DefaultAlgorithm;
-
- /// <summary>
- /// Gets or sets the number of digits in the generated code.
- /// </summary>
- public int Digits { get; set; } = TotpParameters.DefaultDigits;
-
- /// <summary>
- /// Gets or sets the time step in seconds a code stays valid for.
- /// </summary>
- public int Period { get; set; } = TotpParameters.DefaultPeriod;
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/ImportFailure.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/ImportFailure.cs
deleted file mode 100644
index 90a2fda8a..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/ImportFailure.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="ImportFailure.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;
-
-/// <summary>
-/// Represents a single item that failed to be parsed during an import.
-/// Captured alongside successfully imported credentials so the user can see which entries were skipped.
-/// </summary>
-public class ImportFailure
-{
- /// <summary>
- /// Gets or sets the zero-based index of the item within the source export.
- /// </summary>
- public int Index { get; set; }
-
- /// <summary>
- /// Gets or sets the title of the failing item, if it could be read.
- /// </summary>
- public string? ItemTitle { get; set; }
-
- /// <summary>
- /// Gets or sets the exception type name (e.g., "JsonException").
- /// </summary>
- public string ExceptionType { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the exception message describing what went wrong.
- /// </summary>
- public string Message { get; set; } = string.Empty;
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/ImportFileResult.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/ImportFileResult.cs
deleted file mode 100644
index b84f7b2f3..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/ImportFileResult.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="ImportFileResult.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;
-
-/// <summary>
-/// Result returned by an import file processor. Contains the credentials that were
-/// successfully parsed plus a list of per-item failures that were skipped.
-/// </summary>
-public class ImportFileResult
-{
- /// <summary>
- /// Gets the credentials that were successfully parsed from the file.
- /// </summary>
- public List<ImportedCredential> Credentials { get; init; } = new();
-
- /// <summary>
- /// Gets the list of items that could not be parsed and were skipped.
- /// </summary>
- public List<ImportFailure> FailedItems { get; init; } = new();
-
- /// <summary>
- /// Implicit conversion from a plain credential list. Lets importers that don't support
- /// per-item failure collection (CSV imports, etc.) return a List directly without boilerplate.
- /// </summary>
- /// <param name="credentials">The credentials to wrap.</param>
- public static implicit operator ImportFileResult(List<ImportedCredential> credentials) =>
- new() { Credentials = credentials };
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/ImportedAlias.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/ImportedAlias.cs
deleted file mode 100644
index 2c5042cbb..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/ImportedAlias.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="ImportedAlias.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;
-
-/// <summary>
-/// Represents an alias in an intermediary format that is imported from various sources.
-/// This model is designed to be flexible enough to handle different import formats while
-/// maintaining all the essential fields needed for AliasVault aliases.
-/// </summary>
-public class ImportedAlias
-{
- /// <summary>
- /// Gets or sets the gender.
- /// </summary>
- public string? Gender { get; set; }
-
- /// <summary>
- /// Gets or sets the first name.
- /// </summary>
- public string? FirstName { get; set; }
-
- /// <summary>
- /// Gets or sets the last name.
- /// </summary>
- public string? LastName { get; set; }
-
- /// <summary>
- /// Gets or sets the nickname.
- /// </summary>
- public string? NickName { get; set; }
-
- /// <summary>
- /// Gets or sets the birth date.
- /// </summary>
- public DateTime? BirthDate { get; set; }
-
- /// <summary>
- /// Gets or sets the creation date.
- /// </summary>
- public DateTime? CreatedAt { get; set; }
-
- /// <summary>
- /// Gets or sets the last update date.
- /// </summary>
- public DateTime? UpdatedAt { get; set; }
-}
\ No newline at end of file
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/ImportedAttachment.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/ImportedAttachment.cs
deleted file mode 100644
index 626ac0738..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/ImportedAttachment.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="ImportedAttachment.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;
-
-/// <summary>
-/// Represents an attachment in an intermediary format that is imported from various sources.
-/// </summary>
-public class ImportedAttachment
-{
- /// <summary>
- /// Gets or sets the filename.
- /// </summary>
- public string Filename { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the file blob data.
- /// </summary>
- public byte[] Blob { get; set; } = Array.Empty<byte>();
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/ImportedCredential.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/ImportedCredential.cs
deleted file mode 100644
index afb01351c..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/ImportedCredential.cs
+++ /dev/null
@@ -1,110 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="ImportCredential.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;
-
-/// <summary>
-/// Represents a credential in an intermediary format that is imported from various sources.
-/// This model is designed to be flexible enough to handle different import formats while
-/// maintaining all the essential fields needed for AliasVault credentials.
-/// </summary>
-public class ImportedCredential
-{
- /// <summary>
- /// Gets or sets the service name (e.g., "Facebook", "Gmail").
- /// </summary>
- public string? ServiceName { get; set; }
-
- /// <summary>
- /// Gets or sets the service URLs.
- /// </summary>
- public List<string>? ServiceUrls { get; set; }
-
- /// <summary>
- /// Gets or sets the username or email.
- /// </summary>
- public string? Username { get; set; }
-
- /// <summary>
- /// Gets or sets the password.
- /// </summary>
- public string? Password { get; set; }
-
- /// <summary>
- /// Gets or sets the email address.
- /// </summary>
- public string? Email { get; set; }
-
- /// <summary>
- /// Gets or sets the 2FA secret key.
- /// </summary>
- public string? TwoFactorSecret { get; set; }
-
- /// <summary>
- /// Gets or sets any additional notes.
- /// </summary>
- public string? Notes { get; set; }
-
- /// <summary>
- /// Gets or sets the creation date of the credential.
- /// </summary>
- public DateTime? CreatedAt { get; set; }
-
- /// <summary>
- /// Gets or sets the last modified date of the credential.
- /// </summary>
- public DateTime? UpdatedAt { get; set; }
-
- /// <summary>
- /// Gets or sets the favicon bytes.
- /// This can be populated from .avux imports or other sources that provide logo data.
- /// </summary>
- public byte[]? FaviconBytes { get; set; }
-
- /// <summary>
- /// Gets or sets the alias information.
- /// </summary>
- public ImportedAlias? Alias { get; set; }
-
- /// <summary>
- /// Gets or sets the folder path from the source (e.g., "Business" or "Personal/Work").
- /// For multi-level paths, the deepest folder will be used during import.
- /// </summary>
- public string? FolderPath { get; set; }
-
- /// <summary>
- /// Gets or sets the item type. Each importer is responsible for setting this based on the source data.
- /// If null, defaults to Login or Alias (if alias data is present).
- /// </summary>
- public ImportedItemType? ItemType { get; set; }
-
- /// <summary>
- /// Gets or sets credit card information if the item is a credit card type.
- /// Each importer should populate this from its own format.
- /// </summary>
- public ImportedCreditcard? Creditcard { get; set; }
-
- /// <summary>
- /// Gets or sets the list of passkeys associated with this credential.
- /// </summary>
- public List<ImportedPasskey>? Passkeys { get; set; }
-
- /// <summary>
- /// Gets or sets the list of tags associated with this credential.
- /// </summary>
- public List<string>? Tags { get; set; }
-
- /// <summary>
- /// Gets or sets the list of attachments associated with this credential.
- /// </summary>
- public List<ImportedAttachment>? Attachments { get; set; }
-
- /// <summary>
- /// Gets or sets the custom (user-defined) field values for this credential.
- /// </summary>
- public List<ImportedCustomField>? CustomFieldValues { get; set; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/ImportedCreditcard.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/ImportedCreditcard.cs
deleted file mode 100644
index 3dd8f2421..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/ImportedCreditcard.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="ImportedCreditcard.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;
-
-/// <summary>
-/// Represents credit card information in an intermediary format that is imported from various sources.
-/// Each importer is responsible for populating this from its own format.
-/// </summary>
-public class ImportedCreditcard
-{
- /// <summary>
- /// Gets or sets the cardholder name.
- /// </summary>
- public string? CardholderName { get; set; }
-
- /// <summary>
- /// Gets or sets the card number.
- /// </summary>
- public string? Number { get; set; }
-
- /// <summary>
- /// Gets or sets the expiry month (01-12).
- /// </summary>
- public string? ExpiryMonth { get; set; }
-
- /// <summary>
- /// Gets or sets the expiry year (e.g., "2028").
- /// </summary>
- public string? ExpiryYear { get; set; }
-
- /// <summary>
- /// Gets or sets the CVV/security code.
- /// </summary>
- public string? Cvv { get; set; }
-
- /// <summary>
- /// Gets or sets the PIN.
- /// </summary>
- public string? Pin { get; set; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/ImportedCustomField.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/ImportedCustomField.cs
deleted file mode 100644
index 857c1ce3a..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/ImportedCustomField.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="ImportedCustomField.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;
-
-/// <summary>
-/// Represents a single custom (user-defined) field value with the metadata of its
-/// field definition.
-/// </summary>
-public class ImportedCustomField
-{
- /// <summary>
- /// Gets or sets the source field definition ID. Multiple values that belong to the same
- /// multi-value field definition share this ID so they can be grouped under a single
- /// recreated <c>FieldDefinition</c> during import.
- /// </summary>
- public Guid DefinitionId { get; set; }
-
- /// <summary>
- /// Gets or sets the field label (display name).
- /// </summary>
- public string Label { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the field value.
- /// </summary>
- public string? Value { get; set; }
-
- /// <summary>
- /// Gets or sets the field type.
- /// </summary>
- public AliasClientDb.Models.FieldTypeKind FieldType { get; set; } = AliasClientDb.Models.FieldTypeKind.Text;
-
- /// <summary>
- /// Gets or sets a value indicating whether this field supports multiple values.
- /// </summary>
- public bool IsMultiValue { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether the field value is hidden (masked) by default in the UI.
- /// </summary>
- public bool IsHidden { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether history tracking is enabled for this field.
- /// </summary>
- public bool EnableHistory { get; set; }
-
- /// <summary>
- /// Gets or sets the display order weight of the field definition (custom field ordering in the UI).
- /// </summary>
- public int Weight { get; set; }
-
- /// <summary>
- /// Gets or sets the display order weight of this individual value (ordering within a multi-value field).
- /// </summary>
- public int ValueWeight { get; set; }
-
- /// <summary>
- /// Gets or sets the applicable item types as a JSON array (e.g., '["Login","Identity"]').
- /// Null means applicable to all types.
- /// </summary>
- public string? ApplicableToTypes { get; set; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/ImportedItemType.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/ImportedItemType.cs
deleted file mode 100644
index 474f3c0a1..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/ImportedItemType.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="ImportedItemType.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;
-
-/// <summary>
-/// Represents the type of item being imported from a password manager.
-/// Each importer is responsible for mapping its source types to these values.
-/// </summary>
-public enum ImportedItemType
-{
- /// <summary>
- /// Standard login credentials (username/password).
- /// </summary>
- Login,
-
- /// <summary>
- /// Secure note without login credentials.
- /// </summary>
- Note,
-
- /// <summary>
- /// Credit card information.
- /// </summary>
- Creditcard,
-
- /// <summary>
- /// Identity/alias information (name, birthdate, etc).
- /// </summary>
- Alias,
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/ImportedPasskey.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/ImportedPasskey.cs
deleted file mode 100644
index 1f0a2a735..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/ImportedPasskey.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="ImportedPasskey.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;
-
-/// <summary>
-/// Represents a passkey in an intermediary format that is imported from various sources.
-/// </summary>
-public class ImportedPasskey
-{
- /// <summary>
- /// Gets or sets the passkey ID (GUID from the original database record).
- /// This is used to preserve the credential ID during import/export.
- /// </summary>
- public Guid? Id { get; set; }
-
- /// <summary>
- /// Gets or sets the relying party ID.
- /// </summary>
- public string RpId { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the user handle (user ID provided by relying party).
- /// </summary>
- public byte[]? UserHandle { get; set; }
-
- /// <summary>
- /// Gets or sets the public key (JWK format).
- /// </summary>
- public string PublicKey { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the private key (JWK format).
- /// </summary>
- public string PrivateKey { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the PRF key (optional).
- /// </summary>
- public byte[]? PrfKey { get; set; }
-
- /// <summary>
- /// Gets or sets the display name for the passkey.
- /// </summary>
- public string DisplayName { get; set; } = string.Empty;
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/BitwardenCsvRecord.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/BitwardenCsvRecord.cs
deleted file mode 100644
index 4e601295d..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/BitwardenCsvRecord.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="BitwardenCsvRecord.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>
-//-----------------------------------------------------------------------
-
-using AliasVault.ImportExport.Converters;
-using CsvHelper.Configuration.Attributes;
-
-namespace AliasVault.ImportExport.Models.Imports;
-
-/// <summary>
-/// Represents a Bitwarden CSV record that is being imported from a Bitwarden CSV export file.
-/// </summary>
-public class BitwardenCsvRecord
-{
- /// <summary>
- /// Gets or sets the folder name.
- /// </summary>
- [Name("folder")]
- public string Folder { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets whether the item is favorited.
- /// </summary>
- [Name("favorite")]
- [TypeConverter(typeof(BooleanConverter))]
- public bool Favorite { get; set; } = false;
-
- /// <summary>
- /// Gets or sets the type of the item.
- /// </summary>
- [Name("type")]
- public string Type { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the title/service name (e.g., "Facebook", "Gmail").
- /// </summary>
- [Name("name")]
- public string Title { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets any additional notes.
- /// </summary>
- [Name("notes")]
- public string? Notes { get; set; }
-
- /// <summary>
- /// Gets or sets custom fields.
- /// </summary>
- [Name("fields")]
- public string? Fields { get; set; }
-
- /// <summary>
- /// Gets or sets whether to reprompt for the master password.
- /// </summary>
- [Name("reprompt")]
- public bool Reprompt { get; set; }
-
- /// <summary>
- /// Gets or sets the service URL.
- /// </summary>
- [Name("login_uri")]
- public string? URL { get; set; }
-
- /// <summary>
- /// Gets or sets the username.
- /// </summary>
- [Name("login_username")]
- public string? Username { get; set; }
-
- /// <summary>
- /// Gets or sets the password.
- /// </summary>
- [Name("login_password")]
- public string? Password { get; set; }
-
- /// <summary>
- /// Gets or sets the OTP (One-Time Password) authentication secret.
- /// </summary>
- [Name("login_totp")]
- public string? OTPAuth { get; set; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/BitwardenJson.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/BitwardenJson.cs
deleted file mode 100644
index f7bd96f0d..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/BitwardenJson.cs
+++ /dev/null
@@ -1,451 +0,0 @@
-//-----------------------------------------------------------------------
-// <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;
-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 as raw JSON elements.
- /// </summary>
- [JsonPropertyName("items")]
- public List<JsonElement> 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; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/ChromeCsvRecord.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/ChromeCsvRecord.cs
deleted file mode 100644
index 67315983f..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/ChromeCsvRecord.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="ChromeCsvRecord.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 CsvHelper.Configuration.Attributes;
-
-/// <summary>
-/// Represents a Chrome CSV record that is being imported from a Chrome CSV export file.
-/// </summary>
-public class ChromeCsvRecord
-{
- /// <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 username of the item.
- /// </summary>
- [Name("username")]
- public string Username { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the username 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; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/DashlaneCsvRecord.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/DashlaneCsvRecord.cs
deleted file mode 100644
index f0664042e..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/DashlaneCsvRecord.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="DashlaneCsvRecord.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>
-//-----------------------------------------------------------------------
-
-using AliasVault.ImportExport.Converters;
-using CsvHelper.Configuration.Attributes;
-
-namespace AliasVault.ImportExport.Models.Imports;
-
-/// <summary>
-/// Represents a Dashlane CSV record that is being imported from a Dashlane CSV export file.
-/// </summary>
-public class DashlaneCsvRecord
-{
- /// <summary>
- /// Gets or sets the primary username.
- /// </summary>
- [Name("username")]
- public string Username { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the second username.
- /// </summary>
- [Name("username2")]
- public string? Username2 { get; set; }
-
- /// <summary>
- /// Gets or sets the third username.
- /// </summary>
- [Name("username3")]
- public string? Username3 { get; set; }
-
- /// <summary>
- /// Gets or sets the title/service name.
- /// </summary>
- [Name("title")]
- public string Title { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the password.
- /// </summary>
- [Name("password")]
- public string? Password { get; set; }
-
- /// <summary>
- /// Gets or sets any additional notes.
- /// </summary>
- [Name("note")]
- public string? Note { get; set; }
-
- /// <summary>
- /// Gets or sets the service URL.
- /// </summary>
- [Name("url")]
- public string? URL { get; set; }
-
- /// <summary>
- /// Gets or sets the category.
- /// </summary>
- [Name("category")]
- public string? Category { get; set; }
-
- /// <summary>
- /// Gets or sets the OTP URL.
- /// </summary>
- [Name("otpUrl")]
- public string? OTPUrl { get; set; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/DropboxCsvRecord.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/DropboxCsvRecord.cs
deleted file mode 100644
index 573c5adf8..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/DropboxCsvRecord.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="DropboxCsvRecord.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>
-//-----------------------------------------------------------------------
-
-using CsvHelper.Configuration.Attributes;
-
-namespace AliasVault.ImportExport.Models.Imports;
-
-/// <summary>
-/// Represents a Dropbox CSV record that is being imported from a Dropbox CSV export file.
-/// </summary>
-public class DropboxCsvRecord
-{
- /// <summary>
- /// Gets or sets the title/service name (e.g., "Facebook", "Gmail").
- /// </summary>
- [Name("Name")]
- public string Name { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the service URL.
- /// </summary>
- [Name("URL")]
- public string? Url { get; set; }
-
- /// <summary>
- /// Gets or sets the username/login.
- /// </summary>
- [Name("Username")]
- public string? Username { get; set; }
-
- /// <summary>
- /// Gets or sets the password.
- /// </summary>
- [Name("Password")]
- public string? Password { get; set; }
-
- /// <summary>
- /// Gets or sets any additional notes.
- /// </summary>
- [Name("Notes")]
- public string? Notes { get; set; }
-}
\ No newline at end of file
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/EdgeCsvRecord.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/EdgeCsvRecord.cs
deleted file mode 100644
index 9bcabdb50..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/EdgeCsvRecord.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="EdgeCsvRecord.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 CsvHelper.Configuration.Attributes;
-
-/// <summary>
-/// Represents an Edge CSV record that is being imported from a Microsoft Edge Password Manager CSV export file.
-/// </summary>
-public class EdgeCsvRecord
-{
- /// <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 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; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/FirefoxCsvRecord.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/FirefoxCsvRecord.cs
deleted file mode 100644
index c53e6a302..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/FirefoxCsvRecord.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="FirefoxCsvRecord.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 CsvHelper.Configuration.Attributes;
-
-/// <summary>
-/// Represents a Firefox CSV record that is being imported from a Firefox CSV export file.
-/// </summary>
-public class FirefoxCsvRecord
-{
- /// <summary>
- /// Gets or sets the URL of the item.
- /// </summary>
- [Name("url")]
- public string Url { 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 the HTTP realm for authentication.
- /// </summary>
- [Name("httpRealm")]
- public string? HttpRealm { get; set; }
-
- /// <summary>
- /// Gets or sets the form action origin URL.
- /// </summary>
- [Name("formActionOrigin")]
- public string? FormActionOrigin { get; set; }
-
- /// <summary>
- /// Gets or sets the GUID of the password entry.
- /// </summary>
- [Name("guid")]
- public string? Guid { get; set; }
-
- /// <summary>
- /// Gets or sets the timestamp when the password was created.
- /// </summary>
- [Name("timeCreated")]
- public string? TimeCreated { get; set; }
-
- /// <summary>
- /// Gets or sets the timestamp when the password was last used.
- /// </summary>
- [Name("timeLastUsed")]
- public string? TimeLastUsed { get; set; }
-
- /// <summary>
- /// Gets or sets the timestamp when the password was last changed.
- /// </summary>
- [Name("timePasswordChanged")]
- public string? TimePasswordChanged { get; set; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/GenericCsvRecord.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/GenericCsvRecord.cs
deleted file mode 100644
index 3cb700fac..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/GenericCsvRecord.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="GenericCsvRecord.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>
-//-----------------------------------------------------------------------
-
-using CsvHelper.Configuration.Attributes;
-
-namespace AliasVault.ImportExport.Models.Imports;
-
-/// <summary>
-/// Represents a generic CSV record for importing credentials into AliasVault.
-/// This provides a simple template structure for users who want to import from other sources.
-/// </summary>
-public class GenericCsvRecord
-{
- /// <summary>
- /// Gets or sets the service name (e.g., "Gmail", "Facebook").
- /// </summary>
- [Name("service_name")]
- public string ServiceName { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the service URL (optional).
- /// </summary>
- [Name("url")]
- public string? Url { get; set; }
-
- /// <summary>
- /// Gets or sets the username.
- /// </summary>
- [Name("username")]
- public string? Username { get; set; }
-
- /// <summary>
- /// Gets or sets the password.
- /// </summary>
- [Name("password")]
- public string? Password { get; set; }
-
- /// <summary>
- /// Gets or sets the two-factor authentication secret (TOTP).
- /// </summary>
- [Name("totp_secret")]
- public string? TotpSecret { get; set; }
-
- /// <summary>
- /// Gets or sets any additional notes.
- /// </summary>
- [Name("notes")]
- public string? Notes { get; set; }
-
- /// <summary>
- /// Gets or sets the folder path (optional). Supports multi-level paths separated by "/" (e.g., "Personal/Social").
- /// </summary>
- [Name("folder")]
- public string? Folder { get; set; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/KeePassCsvRecord.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/KeePassCsvRecord.cs
deleted file mode 100644
index 3d107c6c7..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/KeePassCsvRecord.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="KeePassCsvRecord.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 CsvHelper.Configuration.Attributes;
-
-/// <summary>
-/// Represents a KeePass CSV record that is being imported from a KeePass CSV export file.
-/// </summary>
-public class KeePassCsvRecord
-{
- /// <summary>
- /// Gets or sets the title/service name (e.g., "Facebook", "Gmail").
- /// </summary>
- [Name("Account")]
- public string Account { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the login name.
- /// </summary>
- [Name("Login Name")]
- public string? LoginName { get; set; }
-
- /// <summary>
- /// Gets or sets the password.
- /// </summary>
- [Name("Password")]
- public string? Password { get; set; }
-
- /// <summary>
- /// Gets or sets the web site.
- /// </summary>
- [Name("Web Site")]
- public string? Website { get; set; }
-
- /// <summary>
- /// Gets or sets the comments.
- /// </summary>
- [Name("Comments")]
- public string? Comments { get; set; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/KeePassXcCsvRecord.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/KeePassXcCsvRecord.cs
deleted file mode 100644
index 29e926aff..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/KeePassXcCsvRecord.cs
+++ /dev/null
@@ -1,76 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="KeepassXcCsvRecord.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 CsvHelper.Configuration.Attributes;
-
-/// <summary>
-/// Represents a KeePassXC CSV record that is being imported from a KeePassXC CSV export file.
-/// </summary>
-public class KeepassXcCsvRecord
-{
- /// <summary>
- /// Gets or sets the group.
- /// </summary>
- [Name("Group")]
- public string Group { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the title.
- /// </summary>
- [Name("Title")]
- public string Title { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the username.
- /// </summary>
- [Name("Username")]
- public string? Username { get; set; }
-
- /// <summary>
- /// Gets or sets the password.
- /// </summary>
- [Name("Password")]
- public string? Password { get; set; }
-
- /// <summary>
- /// Gets or sets the web site.
- /// </summary>
- [Name("URL")]
- public string? URL { get; set; }
-
- /// <summary>
- /// Gets or sets the notes.
- /// </summary>
- [Name("Notes")]
- public string? Notes { get; set; }
-
- /// <summary>
- /// Gets or sets the TOTP (Time-based One-Time Password).
- /// </summary>
- [Name("TOTP")]
- public string? TOTP { get; set; }
-
- /// <summary>
- /// Gets or sets the icon (integer value representing built-in KeePassXC icon index)
- /// </summary>
- [Name("Icon")]
- public string? Icon { get; set; }
-
- /// <summary>
- /// Gets or sets the last modified date.
- /// </summary>
- [Name("Last Modified")]
- public string? LastModified { get; set; }
-
- /// <summary>
- /// Gets or sets the created date.
- /// </summary>
- [Name("Created")]
- public string? Created { get; set; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/LastPassCsvRecord.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/LastPassCsvRecord.cs
deleted file mode 100644
index 0479257a5..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/LastPassCsvRecord.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="LastPassCsvRecord.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>
-//-----------------------------------------------------------------------
-
-using CsvHelper.Configuration.Attributes;
-
-namespace AliasVault.ImportExport.Models.Imports;
-
-/// <summary>
-/// Represents a LastPass CSV record that is being imported from a LastPass CSV export file.
-/// </summary>
-public class LastPassCsvRecord
-{
- /// <summary>
- /// Gets or sets the service URL.
- /// </summary>
- [Name("url")]
- public string? URL { get; set; }
-
- /// <summary>
- /// Gets or sets the username.
- /// </summary>
- [Name("username")]
- public string? Username { get; set; }
-
- /// <summary>
- /// Gets or sets the password.
- /// </summary>
- [Name("password")]
- public string? Password { get; set; }
-
- /// <summary>
- /// Gets or sets the two-factor authentication secret.
- /// </summary>
- [Name("totp")]
- public string? TwoFactorSecret { get; set; }
-
- /// <summary>
- /// Gets or sets any additional extra fields.
- /// </summary>
- [Name("extra")]
- public string? Extra { get; set; }
-
- /// <summary>
- /// Gets or sets the title/service name (e.g., "Facebook", "Gmail").
- /// </summary>
- [Name("name")]
- public string Title { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the grouping (folder name).
- /// </summary>
- [Name("grouping")]
- public string? Grouping { get; set; }
-
- /// <summary>
- /// Gets or sets whether the item is favorited.
- /// </summary>
- [Name("fav")]
- public string? Favorite { get; set; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/NordPassCsvRecord.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/NordPassCsvRecord.cs
deleted file mode 100644
index 7bfaa6e20..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/NordPassCsvRecord.cs
+++ /dev/null
@@ -1,154 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="NordPassCsvRecord.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 CsvHelper.Configuration.Attributes;
-
-/// <summary>
-/// Represents a NordPass CSV record that is being imported from a NordPass CSV export file.
-/// </summary>
-public class NordPassCsvRecord
-{
- /// <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 additional URLs of the item.
- /// </summary>
- [Name("additional_urls")]
- public string? AdditionalUrls { get; set; }
-
- /// <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 cardholder name (for credit card items).
- /// </summary>
- [Name("cardholdername")]
- public string? CardholderName { get; set; }
-
- /// <summary>
- /// Gets or sets the card number (for credit card items).
- /// </summary>
- [Name("cardnumber")]
- public string? CardNumber { get; set; }
-
- /// <summary>
- /// Gets or sets the CVC/CVV code (for credit card items).
- /// </summary>
- [Name("cvc")]
- public string? Cvc { get; set; }
-
- /// <summary>
- /// Gets or sets the PIN (for credit card items).
- /// </summary>
- [Name("pin")]
- public string? Pin { get; set; }
-
- /// <summary>
- /// Gets or sets the expiry date (for credit card items).
- /// </summary>
- [Name("expirydate")]
- public string? ExpiryDate { get; set; }
-
- /// <summary>
- /// Gets or sets the zip code (for identity items).
- /// </summary>
- [Name("zipcode")]
- public string? ZipCode { get; set; }
-
- /// <summary>
- /// Gets or sets the folder name.
- /// </summary>
- [Name("folder")]
- public string? Folder { get; set; }
-
- /// <summary>
- /// Gets or sets the full name (for identity items).
- /// </summary>
- [Name("full_name")]
- public string? FullName { get; set; }
-
- /// <summary>
- /// Gets or sets the phone number (for identity items).
- /// </summary>
- [Name("phone_number")]
- public string? PhoneNumber { get; set; }
-
- /// <summary>
- /// Gets or sets the email address (for identity items).
- /// </summary>
- [Name("email")]
- public string? Email { get; set; }
-
- /// <summary>
- /// Gets or sets the first address line (for identity items).
- /// </summary>
- [Name("address1")]
- public string? Address1 { get; set; }
-
- /// <summary>
- /// Gets or sets the second address line (for identity items).
- /// </summary>
- [Name("address2")]
- public string? Address2 { get; set; }
-
- /// <summary>
- /// Gets or sets the city (for identity items).
- /// </summary>
- [Name("city")]
- public string? City { get; set; }
-
- /// <summary>
- /// Gets or sets the country (for identity items).
- /// </summary>
- [Name("country")]
- public string? Country { get; set; }
-
- /// <summary>
- /// Gets or sets the state (for identity items).
- /// </summary>
- [Name("state")]
- public string? State { get; set; }
-
- /// <summary>
- /// Gets or sets the type of the item (e.g., password, note, card, identity).
- /// </summary>
- [Name("type")]
- public string? Type { get; set; }
-
- /// <summary>
- /// Gets or sets custom fields as a JSON or delimited string.
- /// </summary>
- [Name("custom_fields")]
- public string? CustomFields { get; set; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/OnePassword1pux.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/OnePassword1pux.cs
deleted file mode 100644
index 9e57a1a25..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/OnePassword1pux.cs
+++ /dev/null
@@ -1,609 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="OnePassword1pux.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;
-using System.Text.Json.Serialization;
-
-/// <summary>
-/// Root structure of a 1Password .1pux export (export.data file).
-/// </summary>
-public class OnePassword1puxData
-{
- /// <summary>
- /// Gets or sets the list of accounts.
- /// </summary>
- [JsonPropertyName("accounts")]
- public List<OnePasswordAccount> Accounts { get; set; } = new();
-}
-
-/// <summary>
-/// Represents export attributes (export.attributes file).
-/// </summary>
-public class OnePassword1puxAttributes
-{
- /// <summary>
- /// Gets or sets the format version.
- /// </summary>
- [JsonPropertyName("version")]
- public int Version { get; set; }
-
- /// <summary>
- /// Gets or sets the description.
- /// </summary>
- [JsonPropertyName("description")]
- public string? Description { get; set; }
-
- /// <summary>
- /// Gets or sets the creation timestamp.
- /// </summary>
- [JsonPropertyName("createdAt")]
- public long CreatedAt { get; set; }
-}
-
-/// <summary>
-/// Represents a 1Password account.
-/// </summary>
-public class OnePasswordAccount
-{
- /// <summary>
- /// Gets or sets the account attributes.
- /// </summary>
- [JsonPropertyName("attrs")]
- public OnePasswordAccountAttrs? Attrs { get; set; }
-
- /// <summary>
- /// Gets or sets the list of vaults.
- /// </summary>
- [JsonPropertyName("vaults")]
- public List<OnePasswordVault> Vaults { get; set; } = new();
-}
-
-/// <summary>
-/// Represents account attributes.
-/// </summary>
-public class OnePasswordAccountAttrs
-{
- /// <summary>
- /// Gets or sets the account name.
- /// </summary>
- [JsonPropertyName("accountName")]
- public string? AccountName { get; set; }
-
- /// <summary>
- /// Gets or sets the user name.
- /// </summary>
- [JsonPropertyName("name")]
- public string? Name { get; set; }
-
- /// <summary>
- /// Gets or sets the avatar.
- /// </summary>
- [JsonPropertyName("avatar")]
- public string? Avatar { get; set; }
-
- /// <summary>
- /// Gets or sets the email.
- /// </summary>
- [JsonPropertyName("email")]
- public string? Email { get; set; }
-
- /// <summary>
- /// Gets or sets the UUID.
- /// </summary>
- [JsonPropertyName("uuid")]
- public string? Uuid { get; set; }
-
- /// <summary>
- /// Gets or sets the domain.
- /// </summary>
- [JsonPropertyName("domain")]
- public string? Domain { get; set; }
-}
-
-/// <summary>
-/// Represents a 1Password vault.
-/// </summary>
-public class OnePasswordVault
-{
- /// <summary>
- /// Gets or sets the vault attributes.
- /// </summary>
- [JsonPropertyName("attrs")]
- public OnePasswordVaultAttrs? Attrs { get; set; }
-
- /// <summary>
- /// Gets or sets the list of items as raw JSON elements.
- /// </summary>
- [JsonPropertyName("items")]
- public List<JsonElement> Items { get; set; } = new();
-}
-
-/// <summary>
-/// Represents vault attributes.
-/// </summary>
-public class OnePasswordVaultAttrs
-{
- /// <summary>
- /// Gets or sets the vault UUID.
- /// </summary>
- [JsonPropertyName("uuid")]
- public string? Uuid { get; set; }
-
- /// <summary>
- /// Gets or sets the description.
- /// </summary>
- [JsonPropertyName("desc")]
- public string? Desc { get; set; }
-
- /// <summary>
- /// Gets or sets the avatar.
- /// </summary>
- [JsonPropertyName("avatar")]
- public string? Avatar { get; set; }
-
- /// <summary>
- /// Gets or sets the name.
- /// </summary>
- [JsonPropertyName("name")]
- public string? Name { get; set; }
-
- /// <summary>
- /// Gets or sets the vault type (P=Personal, E=Everyone, U=User Created).
- /// </summary>
- [JsonPropertyName("type")]
- public string? Type { get; set; }
-}
-
-/// <summary>
-/// Represents a 1Password item.
-/// </summary>
-public class OnePasswordItem
-{
- /// <summary>
- /// Gets or sets the item UUID.
- /// </summary>
- [JsonPropertyName("uuid")]
- public string? Uuid { get; set; }
-
- /// <summary>
- /// Gets or sets the favorite index.
- /// </summary>
- [JsonPropertyName("favIndex")]
- public int? FavIndex { get; set; }
-
- /// <summary>
- /// Gets or sets the creation timestamp.
- /// </summary>
- [JsonPropertyName("createdAt")]
- public long? CreatedAt { get; set; }
-
- /// <summary>
- /// Gets or sets the update timestamp.
- /// </summary>
- [JsonPropertyName("updatedAt")]
- public long? UpdatedAt { get; set; }
-
- /// <summary>
- /// Gets or sets the state (active or archived).
- /// </summary>
- [JsonPropertyName("state")]
- public string? State { get; set; }
-
- /// <summary>
- /// Gets or sets the category UUID.
- /// </summary>
- [JsonPropertyName("categoryUuid")]
- public string? CategoryUuid { get; set; }
-
- /// <summary>
- /// Gets or sets the overview.
- /// </summary>
- [JsonPropertyName("overview")]
- public OnePasswordOverview? Overview { get; set; }
-
- /// <summary>
- /// Gets or sets the details.
- /// </summary>
- [JsonPropertyName("details")]
- public OnePasswordDetails? Details { get; set; }
-}
-
-/// <summary>
-/// Represents item overview.
-/// </summary>
-public class OnePasswordOverview
-{
- /// <summary>
- /// Gets or sets the subtitle.
- /// </summary>
- [JsonPropertyName("subtitle")]
- public string? Subtitle { get; set; }
-
- /// <summary>
- /// Gets or sets the URLs.
- /// </summary>
- [JsonPropertyName("urls")]
- public List<OnePasswordUrl>? Urls { get; set; }
-
- /// <summary>
- /// Gets or sets the title.
- /// </summary>
- [JsonPropertyName("title")]
- public string? Title { get; set; }
-
- /// <summary>
- /// Gets or sets the URL.
- /// </summary>
- [JsonPropertyName("url")]
- public string? Url { get; set; }
-
- /// <summary>
- /// Gets or sets the password strength.
- /// </summary>
- [JsonPropertyName("ps")]
- public int? Ps { get; set; }
-
- /// <summary>
- /// Gets or sets tags as an array.
- /// </summary>
- [JsonPropertyName("tags")]
- public List<string>? Tags { get; set; }
-}
-
-/// <summary>
-/// Represents a URL in the overview.
-/// </summary>
-public class OnePasswordUrl
-{
- /// <summary>
- /// Gets or sets the label.
- /// </summary>
- [JsonPropertyName("label")]
- public string? Label { get; set; }
-
- /// <summary>
- /// Gets or sets the URL.
- /// </summary>
- [JsonPropertyName("url")]
- public string? Url { get; set; }
-}
-
-/// <summary>
-/// Represents item details.
-/// </summary>
-public class OnePasswordDetails
-{
- /// <summary>
- /// Gets or sets the login fields.
- /// </summary>
- [JsonPropertyName("loginFields")]
- public List<OnePasswordLoginField>? LoginFields { get; set; }
-
- /// <summary>
- /// Gets or sets the notes (plain text).
- /// </summary>
- [JsonPropertyName("notesPlain")]
- public string? NotesPlain { get; set; }
-
- /// <summary>
- /// Gets or sets the sections.
- /// </summary>
- [JsonPropertyName("sections")]
- public List<OnePasswordSection>? Sections { get; set; }
-
- /// <summary>
- /// Gets or sets the password history.
- /// </summary>
- [JsonPropertyName("passwordHistory")]
- public List<OnePasswordPasswordHistory>? PasswordHistory { get; set; }
-
- /// <summary>
- /// Gets or sets document attributes (for document items).
- /// </summary>
- [JsonPropertyName("documentAttributes")]
- public OnePasswordDocumentAttributes? DocumentAttributes { get; set; }
-}
-
-/// <summary>
-/// Represents a login field.
-/// </summary>
-public class OnePasswordLoginField
-{
- /// <summary>
- /// Gets or sets the value.
- /// </summary>
- [JsonPropertyName("value")]
- public string? Value { get; set; }
-
- /// <summary>
- /// Gets or sets the field ID.
- /// </summary>
- [JsonPropertyName("id")]
- public string? Id { get; set; }
-
- /// <summary>
- /// Gets or sets the field name.
- /// </summary>
- [JsonPropertyName("name")]
- public string? Name { get; set; }
-
- /// <summary>
- /// Gets or sets the field type (T=Text, E=Email, U=URL, P=Password, etc.).
- /// </summary>
- [JsonPropertyName("fieldType")]
- public string? FieldType { get; set; }
-
- /// <summary>
- /// Gets or sets the designation (username, password, etc.).
- /// </summary>
- [JsonPropertyName("designation")]
- public string? Designation { get; set; }
-}
-
-/// <summary>
-/// Represents a section.
-/// </summary>
-public class OnePasswordSection
-{
- /// <summary>
- /// Gets or sets the title.
- /// </summary>
- [JsonPropertyName("title")]
- public string? Title { get; set; }
-
- /// <summary>
- /// Gets or sets the name.
- /// </summary>
- [JsonPropertyName("name")]
- public string? Name { get; set; }
-
- /// <summary>
- /// Gets or sets the fields.
- /// </summary>
- [JsonPropertyName("fields")]
- public List<OnePasswordField>? Fields { get; set; }
-}
-
-/// <summary>
-/// Represents a field within a section.
-/// </summary>
-public class OnePasswordField
-{
- /// <summary>
- /// Gets or sets the title.
- /// </summary>
- [JsonPropertyName("title")]
- public string? Title { get; set; }
-
- /// <summary>
- /// Gets or sets the field ID.
- /// </summary>
- [JsonPropertyName("id")]
- public string? Id { get; set; }
-
- /// <summary>
- /// Gets or sets the value.
- /// </summary>
- [JsonPropertyName("value")]
- public OnePasswordFieldValue? Value { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether the field is guarded.
- /// </summary>
- [JsonPropertyName("guarded")]
- public bool Guarded { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether the field is multiline.
- /// </summary>
- [JsonPropertyName("multiline")]
- public bool Multiline { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether password generation should be disabled.
- /// </summary>
- [JsonPropertyName("dontGenerate")]
- public bool DontGenerate { get; set; }
-}
-
-/// <summary>
-/// Represents a field value (can be string, concealed, date, etc.).
-/// </summary>
-public class OnePasswordFieldValue
-{
- /// <summary>
- /// Gets or sets the string value.
- /// </summary>
- [JsonPropertyName("string")]
- public string? String { get; set; }
-
- /// <summary>
- /// Gets or sets the concealed value.
- /// </summary>
- [JsonPropertyName("concealed")]
- public string? Concealed { get; set; }
-
- /// <summary>
- /// Gets or sets the date value (Unix timestamp).
- /// </summary>
- [JsonPropertyName("date")]
- public long? Date { get; set; }
-
- /// <summary>
- /// Gets or sets the month/year value (YYYYMM format).
- /// </summary>
- [JsonPropertyName("monthYear")]
- public int? MonthYear { get; set; }
-
- /// <summary>
- /// Gets or sets the TOTP value (otpauth:// URI).
- /// </summary>
- [JsonPropertyName("totp")]
- public string? Totp { get; set; }
-
- /// <summary>
- /// Gets or sets the URL value.
- /// </summary>
- [JsonPropertyName("url")]
- public string? Url { get; set; }
-
- /// <summary>
- /// Gets or sets the credit card number value.
- /// </summary>
- [JsonPropertyName("creditCardNumber")]
- public string? CreditCardNumber { get; set; }
-
- /// <summary>
- /// Gets or sets the menu value (for dropdown/selection fields).
- /// </summary>
- [JsonPropertyName("menu")]
- public string? Menu { get; set; }
-
- /// <summary>
- /// Gets or sets the file value (for file attachment fields).
- /// </summary>
- [JsonPropertyName("file")]
- public OnePasswordFileValue? File { get; set; }
-
- /// <summary>
- /// Gets or sets the email value (for email fields).
- /// </summary>
- [JsonPropertyName("email")]
- public OnePasswordEmailValue? Email { get; set; }
-
- /// <summary>
- /// Gets or sets the phone value (for phone fields).
- /// </summary>
- [JsonPropertyName("phone")]
- public string? Phone { get; set; }
-
- /// <summary>
- /// Gets or sets the address value (for address fields).
- /// </summary>
- [JsonPropertyName("address")]
- public OnePasswordAddressValue? Address { get; set; }
-}
-
-/// <summary>
-/// Represents password history.
-/// </summary>
-public class OnePasswordPasswordHistory
-{
- /// <summary>
- /// Gets or sets the value.
- /// </summary>
- [JsonPropertyName("value")]
- public string? Value { get; set; }
-
- /// <summary>
- /// Gets or sets the timestamp.
- /// </summary>
- [JsonPropertyName("time")]
- public long? Time { get; set; }
-}
-
-/// <summary>
-/// Represents document attributes.
-/// </summary>
-public class OnePasswordDocumentAttributes
-{
- /// <summary>
- /// Gets or sets the filename.
- /// </summary>
- [JsonPropertyName("fileName")]
- public string? FileName { get; set; }
-
- /// <summary>
- /// Gets or sets the document ID.
- /// </summary>
- [JsonPropertyName("documentId")]
- public string? DocumentId { get; set; }
-
- /// <summary>
- /// Gets or sets the decrypted size.
- /// </summary>
- [JsonPropertyName("decryptedSize")]
- public long? DecryptedSize { get; set; }
-}
-
-/// <summary>
-/// Represents a file attachment value.
-/// </summary>
-public class OnePasswordFileValue
-{
- /// <summary>
- /// Gets or sets the filename.
- /// </summary>
- [JsonPropertyName("fileName")]
- public string? FileName { get; set; }
-
- /// <summary>
- /// Gets or sets the document ID.
- /// </summary>
- [JsonPropertyName("documentId")]
- public string? DocumentId { get; set; }
-
- /// <summary>
- /// Gets or sets the decrypted size.
- /// </summary>
- [JsonPropertyName("decryptedSize")]
- public long? DecryptedSize { get; set; }
-}
-
-/// <summary>
-/// Represents an email value.
-/// </summary>
-public class OnePasswordEmailValue
-{
- /// <summary>
- /// Gets or sets the email address.
- /// </summary>
- [JsonPropertyName("email_address")]
- public string? EmailAddress { get; set; }
-
- // Note: 1Password also emits a "provider" sub-field here for masked-email integration metadata
- // we don't read it (anymore) as the type varies between exports (string vs object) which can
- // break JSON deserialization.
-}
-
-/// <summary>
-/// Represents an address value.
-/// </summary>
-public class OnePasswordAddressValue
-{
- /// <summary>
- /// Gets or sets the street address.
- /// </summary>
- [JsonPropertyName("street")]
- public string? Street { get; set; }
-
- /// <summary>
- /// Gets or sets the city.
- /// </summary>
- [JsonPropertyName("city")]
- public string? City { get; set; }
-
- /// <summary>
- /// Gets or sets the country.
- /// </summary>
- [JsonPropertyName("country")]
- public string? Country { get; set; }
-
- /// <summary>
- /// Gets or sets the zip/postal code.
- /// </summary>
- [JsonPropertyName("zip")]
- public string? Zip { get; set; }
-
- /// <summary>
- /// Gets or sets the state/province.
- /// </summary>
- [JsonPropertyName("state")]
- public string? State { get; set; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/OnePasswordCsvRecord.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/OnePasswordCsvRecord.cs
deleted file mode 100644
index 34e6c4fdb..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/OnePasswordCsvRecord.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="BitwardenCsvRecord.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>
-//-----------------------------------------------------------------------
-
-using AliasVault.ImportExport.Converters;
-using CsvHelper.Configuration.Attributes;
-
-namespace AliasVault.ImportExport.Models.Imports;
-
-/// <summary>
-/// Represents a 1Password CSV record that is being imported from a 1Password CSV export file.
-/// </summary>
-public class OnePasswordCsvRecord
-{
- /// <summary>
- /// Gets or sets the title of the item.
- /// </summary>
- [Name("Title")]
- public string Title { 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 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 the OTP (One-Time Password) authentication secret.
- /// </summary>
- [Name("OTPAuth")]
- public string? OTPAuth { get; set; }
-
- /// <summary>
- /// Gets or sets whether the item is favorited.
- /// </summary>
- [Name("Favorite")]
- [TypeConverter(typeof(BooleanConverter))]
- public bool Favorite { get; set; }
-
- /// <summary>
- /// Gets or sets whether the item is archived.
- /// </summary>
- [Name("Archived")]
- [TypeConverter(typeof(BooleanConverter))]
- public bool Archived { get; set; }
-
- /// <summary>
- /// Gets or sets the service URL.
- /// </summary>
- [Name("Tags")]
- public string? Tags { get; set; }
-
- /// <summary>
- /// Gets or sets any additional notes.
- /// </summary>
- [Name("Notes")]
- public string? Notes { get; set; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/ProtonPassCsvRecord.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/ProtonPassCsvRecord.cs
deleted file mode 100644
index b5306a2e6..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/ProtonPassCsvRecord.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="ProtonPassCsvRecord.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 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;
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/ProtonPassJson.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/ProtonPassJson.cs
deleted file mode 100644
index f6ca79b45..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/ProtonPassJson.cs
+++ /dev/null
@@ -1,420 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="ProtonPassJson.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;
-using System.Text.Json.Serialization;
-
-/// <summary>
-/// Root structure of a Proton Pass JSON export (data.json file inside a "Proton Pass/" folder in the ZIP).
-/// </summary>
-public class ProtonPassJsonExport
-{
- /// <summary>
- /// Gets or sets the user ID.
- /// </summary>
- [JsonPropertyName("userId")]
- public string? UserId { get; set; }
-
- /// <summary>
- /// Gets or sets the exporter version.
- /// </summary>
- [JsonPropertyName("version")]
- public string? Version { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether the export payload is encrypted.
- /// When true, the export contains an encrypted PGP payload which is not supported.
- /// </summary>
- [JsonPropertyName("encrypted")]
- public bool Encrypted { get; set; }
-
- /// <summary>
- /// Gets or sets the vaults, keyed by vault ID.
- /// </summary>
- [JsonPropertyName("vaults")]
- public Dictionary<string, ProtonPassVault> Vaults { get; set; } = new();
-}
-
-/// <summary>
-/// Represents a Proton Pass vault.
-/// </summary>
-public class ProtonPassVault
-{
- /// <summary>
- /// Gets or sets the vault name.
- /// </summary>
- [JsonPropertyName("name")]
- public string? Name { get; set; }
-
- /// <summary>
- /// Gets or sets the vault description.
- /// </summary>
- [JsonPropertyName("description")]
- public string? Description { get; set; }
-
- /// <summary>
- /// Gets or sets the display settings (color, icon).
- /// </summary>
- [JsonPropertyName("display")]
- public ProtonPassDisplay? Display { get; set; }
-
- /// <summary>
- /// Gets or sets the items in this vault as raw JSON elements.
- /// </summary>
- [JsonPropertyName("items")]
- public List<JsonElement> Items { get; set; } = new();
-}
-
-/// <summary>
-/// Represents vault display settings.
-/// </summary>
-public class ProtonPassDisplay
-{
- /// <summary>
- /// Gets or sets the color index.
- /// </summary>
- [JsonPropertyName("color")]
- public int Color { get; set; }
-
- /// <summary>
- /// Gets or sets the icon index.
- /// </summary>
- [JsonPropertyName("icon")]
- public int Icon { get; set; }
-}
-
-/// <summary>
-/// Represents an item envelope in a Proton Pass vault.
-/// </summary>
-public class ProtonPassItem
-{
- /// <summary>
- /// Gets or sets the item ID.
- /// </summary>
- [JsonPropertyName("itemId")]
- public string? ItemId { get; set; }
-
- /// <summary>
- /// Gets or sets the share ID.
- /// </summary>
- [JsonPropertyName("shareId")]
- public string? ShareId { get; set; }
-
- /// <summary>
- /// Gets or sets the item data payload.
- /// </summary>
- [JsonPropertyName("data")]
- public ProtonPassItemData? Data { get; set; }
-
- /// <summary>
- /// Gets or sets the item state (1 = active, 2 = trashed).
- /// Nullable because older Proton Pass export envelopes may omit this field.
- /// </summary>
- [JsonPropertyName("state")]
- public int? State { get; set; }
-
- /// <summary>
- /// Gets or sets the alias email (populated for items of type "alias").
- /// </summary>
- [JsonPropertyName("aliasEmail")]
- public string? AliasEmail { get; set; }
-
- /// <summary>
- /// Gets or sets the content format version.
- /// Nullable because older export envelopes (v1.8.0-era) may omit this field,
- /// and the importer does not gate behaviour on its value.
- /// </summary>
- [JsonPropertyName("contentFormatVersion")]
- public int? ContentFormatVersion { get; set; }
-
- /// <summary>
- /// Gets or sets the creation timestamp (Unix seconds).
- /// </summary>
- [JsonPropertyName("createTime")]
- public long? CreateTime { get; set; }
-
- /// <summary>
- /// Gets or sets the last modification timestamp (Unix seconds).
- /// </summary>
- [JsonPropertyName("modifyTime")]
- public long? ModifyTime { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether the item is pinned.
- /// </summary>
- [JsonPropertyName("pinned")]
- public bool Pinned { get; set; }
-
- /// <summary>
- /// Gets or sets the number of shares for this item.
- /// </summary>
- [JsonPropertyName("shareCount")]
- public int ShareCount { get; set; }
-
- /// <summary>
- /// Gets or sets the attached files.
- /// </summary>
- [JsonPropertyName("files")]
- public List<ProtonPassFile>? Files { get; set; }
-}
-
-/// <summary>
-/// Represents the typed data payload of a Proton Pass item.
-/// </summary>
-public class ProtonPassItemData
-{
- /// <summary>
- /// Gets or sets the item metadata (name, note, uuid).
- /// </summary>
- [JsonPropertyName("metadata")]
- public ProtonPassMetadata? Metadata { get; set; }
-
- /// <summary>
- /// Gets or sets the custom fields defined on the item.
- /// </summary>
- [JsonPropertyName("extraFields")]
- public List<ProtonPassExtraField>? ExtraFields { get; set; }
-
- /// <summary>
- /// Gets or sets the item type (e.g., "login", "note", "alias", "creditCard", "identity").
- /// </summary>
- [JsonPropertyName("type")]
- public string? Type { get; set; }
-
- /// <summary>
- /// Gets or sets the type-specific content payload.
- /// </summary>
- [JsonPropertyName("content")]
- public ProtonPassContent? Content { get; set; }
-}
-
-/// <summary>
-/// Represents Proton Pass item metadata.
-/// </summary>
-public class ProtonPassMetadata
-{
- /// <summary>
- /// Gets or sets the display name.
- /// </summary>
- [JsonPropertyName("name")]
- public string? Name { get; set; }
-
- /// <summary>
- /// Gets or sets the note.
- /// </summary>
- [JsonPropertyName("note")]
- public string? Note { get; set; }
-
- /// <summary>
- /// Gets or sets the item UUID.
- /// </summary>
- [JsonPropertyName("itemUuid")]
- public string? ItemUuid { get; set; }
-}
-
-/// <summary>
-/// Represents the content payload of a Proton Pass item.
-/// Fields are a union across item types; only a subset will be populated for any given item.
-/// </summary>
-public class ProtonPassContent
-{
- /// <summary>
- /// Gets or sets the username (login items).
- /// </summary>
- [JsonPropertyName("itemUsername")]
- public string? ItemUsername { get; set; }
-
- /// <summary>
- /// Gets or sets the email address stored on the login (login items).
- /// </summary>
- [JsonPropertyName("itemEmail")]
- public string? ItemEmail { get; set; }
-
- /// <summary>
- /// Gets or sets the password (login items).
- /// </summary>
- [JsonPropertyName("password")]
- public string? Password { get; set; }
-
- /// <summary>
- /// Gets or sets the URLs (login items).
- /// </summary>
- [JsonPropertyName("urls")]
- public List<string>? Urls { get; set; }
-
- /// <summary>
- /// Gets or sets the TOTP URI (login items).
- /// </summary>
- [JsonPropertyName("totpUri")]
- public string? TotpUri { get; set; }
-
- /// <summary>
- /// Gets or sets the passkeys (login items).
- /// </summary>
- [JsonPropertyName("passkeys")]
- public List<ProtonPassPasskey>? Passkeys { get; set; }
-
- /// <summary>
- /// Gets or sets the cardholder name (credit card items).
- /// </summary>
- [JsonPropertyName("cardholderName")]
- public string? CardholderName { get; set; }
-
- /// <summary>
- /// Gets or sets the card number (credit card items).
- /// </summary>
- [JsonPropertyName("number")]
- public string? Number { get; set; }
-
- /// <summary>
- /// Gets or sets the verification number / CVV (credit card items).
- /// </summary>
- [JsonPropertyName("verificationNumber")]
- public string? VerificationNumber { get; set; }
-
- /// <summary>
- /// Gets or sets the card PIN (credit card items).
- /// </summary>
- [JsonPropertyName("pin")]
- public string? Pin { get; set; }
-
- /// <summary>
- /// Gets or sets the expiration date (credit card items, usually "YYYY-MM" or "MMYY").
- /// </summary>
- [JsonPropertyName("expirationDate")]
- public string? ExpirationDate { get; set; }
-
- /// <summary>
- /// Gets or sets the card type (credit card items).
- /// </summary>
- [JsonPropertyName("cardType")]
- public int? CardType { get; set; }
-
- /// <summary>
- /// Gets or sets the identity's first name (identity items).
- /// </summary>
- [JsonPropertyName("firstName")]
- public string? FirstName { get; set; }
-
- /// <summary>
- /// Gets or sets the identity's last name (identity items).
- /// </summary>
- [JsonPropertyName("lastName")]
- public string? LastName { get; set; }
-
- /// <summary>
- /// Gets or sets the identity's full name (identity items).
- /// </summary>
- [JsonPropertyName("fullName")]
- public string? FullName { get; set; }
-
- /// <summary>
- /// Gets or sets the identity's primary email (identity items).
- /// </summary>
- [JsonPropertyName("email")]
- public string? Email { get; set; }
-}
-
-/// <summary>
-/// Represents a passkey associated with a Proton Pass login item.
-/// </summary>
-public class ProtonPassPasskey
-{
- /// <summary>
- /// Gets or sets the credential ID.
- /// </summary>
- [JsonPropertyName("credentialId")]
- public string? CredentialId { get; set; }
-
- /// <summary>
- /// Gets or sets the relying party ID (domain).
- /// </summary>
- [JsonPropertyName("rpId")]
- public string? RpId { get; set; }
-
- /// <summary>
- /// Gets or sets the relying party name.
- /// </summary>
- [JsonPropertyName("rpName")]
- public string? RpName { get; set; }
-
- /// <summary>
- /// Gets or sets the username associated with the passkey.
- /// </summary>
- [JsonPropertyName("userName")]
- public string? UserName { get; set; }
-}
-
-/// <summary>
-/// Represents a Proton Pass custom field entry.
-/// Types observed in public Proton Pass exports: "text", "hidden", "totp".
-/// </summary>
-public class ProtonPassExtraField
-{
- /// <summary>
- /// Gets or sets the label/name of the custom field.
- /// </summary>
- [JsonPropertyName("fieldName")]
- public string? FieldName { get; set; }
-
- /// <summary>
- /// Gets or sets the field type (e.g., "text", "hidden", "totp").
- /// </summary>
- [JsonPropertyName("type")]
- public string? Type { get; set; }
-
- /// <summary>
- /// Gets or sets the field data (content wrapper keyed by type).
- /// </summary>
- [JsonPropertyName("data")]
- public ProtonPassExtraFieldData? Data { get; set; }
-}
-
-/// <summary>
-/// Represents the inner data payload of a Proton Pass custom field.
-/// </summary>
-public class ProtonPassExtraFieldData
-{
- /// <summary>
- /// Gets or sets the field value.
- /// </summary>
- [JsonPropertyName("content")]
- public string? Content { get; set; }
-}
-
-/// <summary>
-/// Represents a reference to a file attached to a Proton Pass item.
-/// The binary payload is stored elsewhere in the ZIP archive.
-/// </summary>
-public class ProtonPassFile
-{
- /// <summary>
- /// Gets or sets the file ID.
- /// </summary>
- [JsonPropertyName("fileID")]
- public string? FileId { get; set; }
-
- /// <summary>
- /// Gets or sets the file name.
- /// </summary>
- [JsonPropertyName("name")]
- public string? Name { get; set; }
-
- /// <summary>
- /// Gets or sets the MIME type.
- /// </summary>
- [JsonPropertyName("mimeType")]
- public string? MimeType { get; set; }
-
- /// <summary>
- /// Gets or sets the file size in bytes.
- /// </summary>
- [JsonPropertyName("size")]
- public long? Size { get; set; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/RoboformCsvRecord.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/RoboformCsvRecord.cs
deleted file mode 100644
index 860dbb676..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/RoboformCsvRecord.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="RoboformCsvRecord.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 CsvHelper.Configuration.Attributes;
-
-/// <summary>
-/// Represents a RoboForm CSV record that is being imported from a RoboForm CSV export file.
-/// </summary>
-public class RoboformCsvRecord
-{
- /// <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; }
-
- /// <summary>
- /// Gets or sets the match URL used for auto-fill matching.
- /// </summary>
- [Name("MatchUrl")]
- public string? MatchUrl { get; set; }
-
- /// <summary>
- /// Gets or sets the login/username.
- /// </summary>
- [Name("Login")]
- public string? Login { get; set; }
-
- /// <summary>
- /// Gets or sets the password.
- /// </summary>
- [Name("Pwd")]
- public string? Password { get; set; }
-
- /// <summary>
- /// Gets or sets any notes.
- /// </summary>
- [Name("Note")]
- public string? Note { get; set; }
-
- /// <summary>
- /// Gets or sets the folder path (e.g., "/Business").
- /// </summary>
- [Name("Folder")]
- public string? Folder { get; set; }
-
- /// <summary>
- /// Gets or sets the RoboForm fields version 2 data.
- /// This contains additional custom fields in a specific format.
- /// </summary>
- [Name("RfFieldsV2")]
- [Optional]
- public string? RfFieldsV2 { get; set; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/StrongboxCsvRecord.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/StrongboxCsvRecord.cs
deleted file mode 100644
index 4cf41fc9d..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/StrongboxCsvRecord.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="StrongboxCsvRecord.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;
-
-/// <summary>
-/// Represents a Strongbox CSV record that is being imported from a Strongbox CSV export file.
-/// </summary>
-public class StrongboxCsvRecord
-{
- /// <summary>
- /// Gets or sets the title/service name (e.g., "Facebook", "Gmail").
- /// </summary>
- public string Title { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the username.
- /// </summary>
- public string? Username { get; set; }
-
- /// <summary>
- /// Gets or sets the email address.
- /// </summary>
- public string? Email { get; set; }
-
- /// <summary>
- /// Gets or sets the password.
- /// </summary>
- public string? Password { get; set; }
-
- /// <summary>
- /// Gets or sets the service URL.
- /// </summary>
- public string? URL { get; set; }
-
- /// <summary>
- /// Gets or sets the OTP (One-Time Password) authentication secret.
- /// </summary>
- public string? OTPAuth { get; set; }
-
- /// <summary>
- /// Gets or sets any additional notes.
- /// </summary>
- public string? Notes { get; set; }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/VaultExportService.cs b/apps/server/Utilities/AliasVault.ImportExport/VaultExportService.cs
deleted file mode 100644
index 98a9ff58e..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/VaultExportService.cs
+++ /dev/null
@@ -1,329 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="VaultExportService.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;
-
-using System.IO.Compression;
-using System.Text;
-using System.Text.Json;
-using AliasClientDb;
-using AliasVault.ImportExport.Models.Exports;
-
-/// <summary>
-/// Service for exporting vault data to .avux format.
-/// </summary>
-public static class VaultExportService
-{
- /// <summary>
- /// Exports vault data to .avux (AliasVault Unencrypted eXport) format.
- /// This creates a ZIP archive containing a manifest.json file and all attachments.
- /// </summary>
- /// <param name="items">The items to export.</param>
- /// <param name="folders">The folders to export.</param>
- /// <param name="tags">The tags to export.</param>
- /// <param name="itemTags">The item-tag associations to export.</param>
- /// <param name="fieldDefinitions">The custom field definitions to export.</param>
- /// <param name="logos">The logos to export.</param>
- /// <param name="username">The username creating the export.</param>
- /// <returns>A byte array containing the .avux ZIP file.</returns>
- public static async Task<byte[]> ExportToAvuxAsync(
- List<Item> items,
- List<Folder> folders,
- List<Tag> tags,
- List<ItemTag> itemTags,
- List<FieldDefinition> fieldDefinitions,
- List<Logo> logos,
- string username)
- {
- var manifest = CreateManifest(items, folders, tags, itemTags, fieldDefinitions, logos, username);
- var attachmentMap = ExtractAttachments(items);
- var logoMap = ExtractLogos(logos);
-
- return await PackageAsZipAsync(manifest, attachmentMap, logoMap);
- }
-
- /// <summary>
- /// Creates the manifest object from vault entities.
- /// </summary>
- private static AvuxManifest CreateManifest(
- List<Item> items,
- List<Folder> folders,
- List<Tag> tags,
- List<ItemTag> itemTags,
- List<FieldDefinition> fieldDefinitions,
- List<Logo> logos,
- string username)
- {
- var manifest = new AvuxManifest
- {
- Version = "1.0.0",
- ExportedAt = DateTime.UtcNow,
- ExportedBy = username,
- Items = items.Where(i => !i.IsDeleted).Select(MapItemToAvux).ToList(),
- Folders = folders.Where(f => !f.IsDeleted).Select(MapFolderToAvux).ToList(),
- Tags = tags.Where(t => !t.IsDeleted).Select(MapTagToAvux).ToList(),
- ItemTags = itemTags.Where(it => !it.IsDeleted).Select(MapItemTagToAvux).ToList(),
- FieldDefinitions = fieldDefinitions.Where(fd => !fd.IsDeleted).Select(MapFieldDefinitionToAvux).ToList(),
- Logos = logos.Where(l => !l.IsDeleted).Select(MapLogoToAvux).ToList(),
- };
-
- return manifest;
- }
-
- /// <summary>
- /// Maps an Item entity to AvuxItem.
- /// </summary>
- private static AvuxItem MapItemToAvux(Item item)
- {
- return new AvuxItem
- {
- Id = item.Id,
- Name = item.Name,
- ItemType = item.ItemType,
- CreatedAt = item.CreatedAt,
- UpdatedAt = item.UpdatedAt,
- FolderId = item.FolderId,
- LogoId = item.LogoId,
- FieldValues = item.FieldValues
- .Where(fv => !fv.IsDeleted)
- .Select(MapFieldValueToAvux)
- .ToList(),
- Attachments = item.Attachments
- .Where(a => !a.IsDeleted)
- .Select(MapAttachmentToAvux)
- .ToList(),
- TotpCodes = item.TotpCodes
- .Where(tc => !tc.IsDeleted)
- .Select(MapTotpCodeToAvux)
- .ToList(),
- Passkeys = item.Passkeys
- .Where(p => !p.IsDeleted)
- .Select(MapPasskeyToAvux)
- .ToList(),
- };
- }
-
- /// <summary>
- /// Maps a FieldValue entity to AvuxFieldValue.
- /// </summary>
- private static AvuxFieldValue MapFieldValueToAvux(FieldValue fieldValue)
- {
- return new AvuxFieldValue
- {
- Id = fieldValue.Id,
- FieldKey = fieldValue.FieldKey,
- FieldDefinitionId = fieldValue.FieldDefinitionId,
- Value = fieldValue.Value,
- Weight = fieldValue.Weight,
- };
- }
-
- /// <summary>
- /// Maps an Attachment entity to AvuxAttachment.
- /// </summary>
- private static AvuxAttachment MapAttachmentToAvux(Attachment attachment)
- {
- var relativePath = $"attachments/{attachment.ItemId}_{attachment.Id}_{attachment.Filename}";
- return new AvuxAttachment
- {
- Id = attachment.Id,
- Filename = attachment.Filename,
- RelativePath = relativePath,
- };
- }
-
- /// <summary>
- /// Maps a TotpCode entity to AvuxTotpCode.
- /// </summary>
- private static AvuxTotpCode MapTotpCodeToAvux(TotpCode totpCode)
- {
- return new AvuxTotpCode
- {
- Id = totpCode.Id,
- Name = totpCode.Name,
- SecretKey = totpCode.SecretKey,
- Algorithm = totpCode.Algorithm,
- Digits = totpCode.Digits,
- Period = totpCode.Period,
- };
- }
-
- /// <summary>
- /// Maps a Passkey entity to AvuxPasskey.
- /// </summary>
- private static AvuxPasskey MapPasskeyToAvux(Passkey passkey)
- {
- return new AvuxPasskey
- {
- Id = passkey.Id,
- RpId = passkey.RpId,
- UserHandle = passkey.UserHandle != null ? Convert.ToBase64String(passkey.UserHandle) : null,
- PublicKey = passkey.PublicKey,
- PrivateKey = passkey.PrivateKey,
- PrfKey = passkey.PrfKey != null ? Convert.ToBase64String(passkey.PrfKey) : null,
- DisplayName = passkey.DisplayName,
- };
- }
-
- /// <summary>
- /// Maps a Folder entity to AvuxFolder.
- /// </summary>
- private static AvuxFolder MapFolderToAvux(Folder folder)
- {
- return new AvuxFolder
- {
- Id = folder.Id,
- Name = folder.Name,
- ParentFolderId = folder.ParentFolderId,
- Weight = folder.Weight,
- CreatedAt = folder.CreatedAt,
- UpdatedAt = folder.UpdatedAt,
- };
- }
-
- /// <summary>
- /// Maps a Tag entity to AvuxTag.
- /// </summary>
- private static AvuxTag MapTagToAvux(Tag tag)
- {
- return new AvuxTag
- {
- Id = tag.Id,
- Name = tag.Name,
- Color = tag.Color,
- DisplayOrder = tag.DisplayOrder,
- CreatedAt = tag.CreatedAt,
- UpdatedAt = tag.UpdatedAt,
- };
- }
-
- /// <summary>
- /// Maps an ItemTag entity to AvuxItemTag.
- /// </summary>
- private static AvuxItemTag MapItemTagToAvux(ItemTag itemTag)
- {
- return new AvuxItemTag
- {
- Id = Guid.NewGuid(),
- ItemId = itemTag.ItemId,
- TagId = itemTag.TagId,
- };
- }
-
- /// <summary>
- /// Maps a FieldDefinition entity to AvuxFieldDefinition.
- /// </summary>
- private static AvuxFieldDefinition MapFieldDefinitionToAvux(FieldDefinition fieldDefinition)
- {
- return new AvuxFieldDefinition
- {
- Id = fieldDefinition.Id,
- FieldType = fieldDefinition.FieldType,
- Label = fieldDefinition.Label,
- IsMultiValue = fieldDefinition.IsMultiValue,
- IsHidden = fieldDefinition.IsHidden,
- EnableHistory = fieldDefinition.EnableHistory,
- Weight = fieldDefinition.Weight,
- ApplicableToTypes = fieldDefinition.ApplicableToTypes,
- };
- }
-
- /// <summary>
- /// Maps a Logo entity to AvuxLogo.
- /// </summary>
- private static AvuxLogo MapLogoToAvux(Logo logo)
- {
- var relativePath = $"logos/{logo.Source}_{logo.Id}.png";
- return new AvuxLogo
- {
- Id = logo.Id,
- Source = logo.Source,
- MimeType = logo.MimeType,
- FetchedAt = logo.FetchedAt,
- RelativePath = relativePath,
- };
- }
-
- /// <summary>
- /// Extracts attachments from items and creates a mapping of relative paths to blob data.
- /// </summary>
- private static Dictionary<string, byte[]> ExtractAttachments(List<Item> items)
- {
- var attachmentMap = new Dictionary<string, byte[]>();
-
- foreach (var item in items.Where(i => !i.IsDeleted))
- {
- foreach (var attachment in item.Attachments.Where(a => !a.IsDeleted))
- {
- var relativePath = $"attachments/{item.Id}_{attachment.Id}_{attachment.Filename}";
- attachmentMap[relativePath] = attachment.Blob;
- }
- }
-
- return attachmentMap;
- }
-
- /// <summary>
- /// Extracts logos and creates a mapping of relative paths to file data.
- /// Logos are deduplicated by source domain.
- /// </summary>
- private static Dictionary<string, byte[]> ExtractLogos(List<Logo> logos)
- {
- var logoMap = new Dictionary<string, byte[]>();
-
- foreach (var logo in logos.Where(l => !l.IsDeleted && l.FileData != null))
- {
- var relativePath = $"logos/{logo.Source}_{logo.Id}.png";
- logoMap[relativePath] = logo.FileData!;
- }
-
- return logoMap;
- }
-
- /// <summary>
- /// Packages the manifest, attachments, and logos into a ZIP archive.
- /// </summary>
- private static async Task<byte[]> PackageAsZipAsync(AvuxManifest manifest, Dictionary<string, byte[]> attachments, Dictionary<string, byte[]> logos)
- {
- using var memoryStream = new MemoryStream();
- using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
- {
- // Add manifest.json
- var manifestEntry = archive.CreateEntry("manifest.json");
- using (var entryStream = manifestEntry.Open())
- {
- var jsonOptions = new JsonSerializerOptions
- {
- WriteIndented = true,
- PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
- };
-
- var json = JsonSerializer.Serialize(manifest, jsonOptions);
- var bytes = Encoding.UTF8.GetBytes(json);
- await entryStream.WriteAsync(bytes);
- }
-
- // Add attachments
- foreach (var (path, data) in attachments)
- {
- var attachmentEntry = archive.CreateEntry(path);
- using var entryStream = attachmentEntry.Open();
- await entryStream.WriteAsync(data);
- }
-
- // Add logos
- foreach (var (path, data) in logos)
- {
- var logoEntry = archive.CreateEntry(path);
- using var entryStream = logoEntry.Open();
- await entryStream.WriteAsync(data);
- }
- }
-
- return memoryStream.ToArray();
- }
-}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/VaultImportService.cs b/apps/server/Utilities/AliasVault.ImportExport/VaultImportService.cs
deleted file mode 100644
index 5fd1f25b9..000000000
--- a/apps/server/Utilities/AliasVault.ImportExport/VaultImportService.cs
+++ /dev/null
@@ -1,395 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="VaultImportService.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;
-
-using System.IO.Compression;
-using System.Text.Json;
-using AliasVault.ImportExport.Models;
-using AliasVault.ImportExport.Models.Exports;
-
-/// <summary>
-/// Service for importing vault data from .avux format.
-/// </summary>
-public static class VaultImportService
-{
- /// <summary>
- /// Imports vault data from .avux (AliasVault Unencrypted eXport) format.
- /// This parses a ZIP archive containing a manifest.json file, all attachments, and logos.
- /// Logos are embedded directly into the FaviconBytes property of each credential.
- /// </summary>
- /// <param name="zipBytes">The .avux file as a byte array.</param>
- /// <returns>A list of ImportedCredential objects with embedded logo data.</returns>
- public static async Task<List<ImportedCredential>> ImportFromAvuxAsync(byte[] zipBytes)
- {
- using var zipStream = new MemoryStream(zipBytes);
- using var archive = new ZipArchive(zipStream, ZipArchiveMode.Read);
-
- // Extract manifest.json
- var manifestEntry = archive.GetEntry("manifest.json");
- if (manifestEntry == null)
- {
- throw new InvalidOperationException("Invalid .avux file: manifest.json not found");
- }
-
- string manifestJson;
- using (var reader = new StreamReader(manifestEntry.Open()))
- {
- manifestJson = await reader.ReadToEndAsync();
- }
-
- var jsonOptions = new JsonSerializerOptions
- {
- PropertyNameCaseInsensitive = true,
- };
-
- var manifest = JsonSerializer.Deserialize<AvuxManifest>(manifestJson, jsonOptions);
- if (manifest == null)
- {
- throw new InvalidOperationException("Failed to parse manifest.json");
- }
-
- // Validate version
- if (manifest.Version != "1.0.0")
- {
- throw new InvalidOperationException($"Unsupported .avux version: {manifest.Version}. Expected 1.0.0.");
- }
-
- // Extract attachments
- var attachmentMap = ExtractAttachmentsFromZip(archive);
-
- // Extract logos
- var logoMap = ExtractLogosFromZip(archive);
-
- // Build logo ID -> file data lookup
- var logoDataById = new Dictionary<Guid, byte[]>();
- foreach (var logo in manifest.Logos)
- {
- if (logoMap.TryGetValue(logo.RelativePath, out var fileData))
- {
- logoDataById[logo.Id] = fileData;
- }
- }
-
- // Convert to ImportedCredential format with embedded logos
- var credentials = ConvertManifestToImportedCredentials(manifest, attachmentMap, logoDataById);
-
- return credentials;
- }
-
- /// <summary>
- /// Extracts all attachments from the ZIP archive.
- /// </summary>
- private static Dictionary<string, byte[]> ExtractAttachmentsFromZip(ZipArchive archive)
- {
- var map = new Dictionary<string, byte[]>();
-
- foreach (var entry in archive.Entries)
- {
- if (entry.FullName.StartsWith("attachments/"))
- {
- using var stream = entry.Open();
- using var ms = new MemoryStream();
- stream.CopyTo(ms);
- map[entry.FullName] = ms.ToArray();
- }
- }
-
- return map;
- }
-
- /// <summary>
- /// Extracts all logos from the ZIP archive.
- /// </summary>
- private static Dictionary<string, byte[]> ExtractLogosFromZip(ZipArchive archive)
- {
- var map = new Dictionary<string, byte[]>();
-
- foreach (var entry in archive.Entries)
- {
- if (entry.FullName.StartsWith("logos/"))
- {
- using var stream = entry.Open();
- using var ms = new MemoryStream();
- stream.CopyTo(ms);
- map[entry.FullName] = ms.ToArray();
- }
- }
-
- return map;
- }
-
- /// <summary>
- /// Converts the manifest and attachments to ImportedCredential objects.
- /// </summary>
- private static List<ImportedCredential> ConvertManifestToImportedCredentials(
- AvuxManifest manifest,
- Dictionary<string, byte[]> attachmentMap,
- Dictionary<Guid, byte[]> logoDataById)
- {
- var credentials = new List<ImportedCredential>();
- var folderMap = BuildFolderPathMap(manifest.Folders);
- var fieldDefinitionsById = manifest.FieldDefinitions.ToDictionary(fd => fd.Id);
-
- foreach (var item in manifest.Items)
- {
- var credential = new ImportedCredential
- {
- ServiceName = item.Name,
- CreatedAt = item.CreatedAt,
- UpdatedAt = item.UpdatedAt,
- ItemType = MapItemType(item.ItemType),
- };
-
- if (item.LogoId.HasValue && logoDataById.TryGetValue(item.LogoId.Value, out var logoBytes))
- {
- credential.FaviconBytes = logoBytes;
- }
-
- // Get folder path
- if (item.FolderId.HasValue && folderMap.TryGetValue(item.FolderId.Value, out var folderPath))
- {
- credential.FolderPath = folderPath;
- }
-
- // Extract field values
- ExtractFieldValues(credential, item.FieldValues, fieldDefinitionsById);
-
- // Add TOTP codes
- if (item.TotpCodes.Count > 0)
- {
- // For now, we only support one TOTP per item in the import format
- credential.TwoFactorSecret = item.TotpCodes.First().SecretKey;
- }
-
- // Add passkeys
- if (item.Passkeys.Count > 0)
- {
- credential.Passkeys = item.Passkeys.Select(MapAvuxPasskeyToImported).ToList();
- }
-
- // Add attachments
- if (item.Attachments.Count > 0)
- {
- credential.Attachments = item.Attachments.Select(a => MapAvuxAttachmentToImported(a, attachmentMap)).ToList();
- }
-
- credentials.Add(credential);
- }
-
- return credentials;
- }
-
- /// <summary>
- /// Builds a map of folder IDs to their full hierarchical paths.
- /// </summary>
- /// <param name="folders">The list of folders from the manifest.</param>
- /// <returns>A dictionary mapping folder IDs to full paths (e.g., "Work/Projects/Active").</returns>
- private static Dictionary<Guid, string> BuildFolderPathMap(List<AvuxFolder> folders)
- {
- var folderMap = new Dictionary<Guid, string>();
- var folderById = folders.ToDictionary(f => f.Id);
-
- foreach (var folder in folders)
- {
- var path = BuildFolderPath(folder, folderById);
- folderMap[folder.Id] = path;
- }
-
- return folderMap;
- }
-
- /// <summary>
- /// Recursively builds the full path for a folder by traversing parent folders.
- /// </summary>
- /// <param name="folder">The folder to build the path for.</param>
- /// <param name="folderById">Dictionary of all folders by ID.</param>
- /// <returns>The full hierarchical path (e.g., "Work/Projects/Active").</returns>
- private static string BuildFolderPath(AvuxFolder folder, Dictionary<Guid, AvuxFolder> folderById)
- {
- var pathParts = new List<string>();
- var currentFolder = folder;
-
- // Traverse up the folder hierarchy
- while (currentFolder != null)
- {
- pathParts.Insert(0, currentFolder.Name);
-
- if (currentFolder.ParentFolderId.HasValue && folderById.TryGetValue(currentFolder.ParentFolderId.Value, out var parentFolder))
- {
- currentFolder = parentFolder;
- }
- else
- {
- break;
- }
- }
-
- return string.Join("/", pathParts);
- }
-
- /// <summary>
- /// Extracts field values from the AvuxItem and populates the ImportedCredential.
- /// </summary>
- /// <param name="credential">The credential to populate.</param>
- /// <param name="fieldValues">The field values from the AvuxItem.</param>
- /// <param name="fieldDefinitionsById">Lookup of custom field definitions keyed by their ID.</param>
- private static void ExtractFieldValues(ImportedCredential credential, List<AvuxFieldValue> fieldValues, Dictionary<Guid, AvuxFieldDefinition> fieldDefinitionsById)
- {
- foreach (var fieldValue in fieldValues)
- {
- if (string.IsNullOrEmpty(fieldValue.FieldKey))
- {
- // Custom fields are imported as ImportedCustomField objects.
- if (fieldValue.FieldDefinitionId.HasValue
- && fieldDefinitionsById.TryGetValue(fieldValue.FieldDefinitionId.Value, out var definition))
- {
- credential.CustomFieldValues ??= new List<ImportedCustomField>();
- credential.CustomFieldValues.Add(new ImportedCustomField
- {
- DefinitionId = definition.Id,
- Label = definition.Label,
- Value = fieldValue.Value,
- FieldType = AliasClientDb.Models.FieldTypeKindExtensions.ToFieldTypeKind(definition.FieldType),
- IsMultiValue = definition.IsMultiValue,
- IsHidden = definition.IsHidden,
- EnableHistory = definition.EnableHistory,
- Weight = definition.Weight,
- ValueWeight = fieldValue.Weight,
- ApplicableToTypes = definition.ApplicableToTypes,
- });
- }
-
- continue;
- }
-
- // Map system fields to ImportedCredential properties
- switch (fieldValue.FieldKey)
- {
- case "login.username":
- credential.Username = fieldValue.Value;
- break;
- case "login.password":
- credential.Password = fieldValue.Value;
- break;
- case "login.email":
- credential.Email = fieldValue.Value;
- break;
- case "login.url":
- credential.ServiceUrls ??= new List<string>();
- if (!string.IsNullOrEmpty(fieldValue.Value))
- {
- credential.ServiceUrls.Add(fieldValue.Value);
- }
-
- break;
- case "notes.content":
- credential.Notes = fieldValue.Value;
- break;
- case "alias.first_name":
- credential.Alias ??= new ImportedAlias();
- credential.Alias.FirstName = fieldValue.Value;
- break;
- case "alias.last_name":
- credential.Alias ??= new ImportedAlias();
- credential.Alias.LastName = fieldValue.Value;
- break;
- case "alias.gender":
- credential.Alias ??= new ImportedAlias();
- credential.Alias.Gender = fieldValue.Value;
- break;
- case "alias.birthdate":
- credential.Alias ??= new ImportedAlias();
- if (DateTime.TryParse(fieldValue.Value, out var birthdate))
- {
- credential.Alias.BirthDate = birthdate;
- }
-
- break;
- case "card.number":
- credential.Creditcard ??= new ImportedCreditcard();
- credential.Creditcard.Number = fieldValue.Value;
- break;
- case "card.cardholder_name":
- credential.Creditcard ??= new ImportedCreditcard();
- credential.Creditcard.CardholderName = fieldValue.Value;
- break;
- case "card.expiry_month":
- credential.Creditcard ??= new ImportedCreditcard();
- credential.Creditcard.ExpiryMonth = fieldValue.Value;
- break;
- case "card.expiry_year":
- credential.Creditcard ??= new ImportedCreditcard();
- credential.Creditcard.ExpiryYear = fieldValue.Value;
- break;
- case "card.cvv":
- credential.Creditcard ??= new ImportedCreditcard();
- credential.Creditcard.Cvv = fieldValue.Value;
- break;
- case "card.pin":
- credential.Creditcard ??= new ImportedCreditcard();
- credential.Creditcard.Pin = fieldValue.Value;
- break;
- }
- }
- }
-
- /// <summary>
- /// Maps an item type string to ImportedItemType enum.
- /// </summary>
- private static ImportedItemType? MapItemType(string itemType)
- {
- return itemType switch
- {
- "Login" => ImportedItemType.Login,
- "Alias" => ImportedItemType.Alias,
- "CreditCard" => ImportedItemType.Creditcard,
- "Note" => ImportedItemType.Note,
- _ => ImportedItemType.Login,
- };
- }
-
- /// <summary>
- /// Maps an AvuxPasskey to ImportedPasskey.
- /// </summary>
- private static ImportedPasskey MapAvuxPasskeyToImported(AvuxPasskey avuxPasskey)
- {
- return new ImportedPasskey
- {
- Id = avuxPasskey.Id,
- RpId = avuxPasskey.RpId,
- UserHandle = !string.IsNullOrEmpty(avuxPasskey.UserHandle)
- ? Convert.FromBase64String(avuxPasskey.UserHandle)
- : null,
- PublicKey = avuxPasskey.PublicKey,
- PrivateKey = avuxPasskey.PrivateKey,
- PrfKey = !string.IsNullOrEmpty(avuxPasskey.PrfKey)
- ? Convert.FromBase64String(avuxPasskey.PrfKey)
- : null,
- DisplayName = avuxPasskey.DisplayName,
- };
- }
-
- /// <summary>
- /// Maps an AvuxAttachment to ImportedAttachment.
- /// </summary>
- private static ImportedAttachment MapAvuxAttachmentToImported(
- AvuxAttachment avuxAttachment,
- Dictionary<string, byte[]> attachmentMap)
- {
- // Get the blob data from the attachment map
- var blob = attachmentMap.TryGetValue(avuxAttachment.RelativePath, out var data)
- ? data
- : Array.Empty<byte>();
-
- return new ImportedAttachment
- {
- Filename = avuxAttachment.Filename,
- Blob = blob,
- };
- }
-}
diff --git a/apps/server/aliasvault.sln b/apps/server/aliasvault.sln
index 4138fc60c..c50481233 100644
--- a/apps/server/aliasvault.sln
+++ b/apps/server/aliasvault.sln
@@ -29,8 +29,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AliasVault.E2ETests.Client.
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Server", "Server", "{607945F3-9896-4544-99EC-F3496CF4D36B}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AliasVault.ImportExport", "Utilities\AliasVault.ImportExport\AliasVault.ImportExport.csproj", "{A9C9A606-C87E-4298-AB32-09B1884D7487}"
-EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Services", "Services", "{8A477241-B96C-4174-968D-D40CB77F1ECD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AliasVault.SmtpService", "Services\AliasVault.SmtpService\AliasVault.SmtpService.csproj", "{B095A174-E528-4D38-BEC1-D1D38B3B30C0}"
@@ -107,10 +105,6 @@ Global
{DD1F496F-CF10-47D1-A57F-5FA256479332}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD1F496F-CF10-47D1-A57F-5FA256479332}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD1F496F-CF10-47D1-A57F-5FA256479332}.Release|Any CPU.Build.0 = Release|Any CPU
- {A9C9A606-C87E-4298-AB32-09B1884D7487}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A9C9A606-C87E-4298-AB32-09B1884D7487}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A9C9A606-C87E-4298-AB32-09B1884D7487}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A9C9A606-C87E-4298-AB32-09B1884D7487}.Release|Any CPU.Build.0 = Release|Any CPU
{B095A174-E528-4D38-BEC1-D1D38B3B30C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B095A174-E528-4D38-BEC1-D1D38B3B30C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B095A174-E528-4D38-BEC1-D1D38B3B30C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -180,7 +174,6 @@ Global
{FE10F294-817F-477E-A24F-8597A15AF0B5} = {5F7417F6-4388-49CC-9511-ED63C4A6488A}
{DD1F496F-CF10-47D1-A57F-5FA256479332} = {607945F3-9896-4544-99EC-F3496CF4D36B}
{607945F3-9896-4544-99EC-F3496CF4D36B} = {29DE523D-EEF2-41E9-AC12-F20D8D02BEBB}
- {A9C9A606-C87E-4298-AB32-09B1884D7487} = {01AB9389-2F89-4F8E-A688-BF4BF1FC42C8}
{B095A174-E528-4D38-BEC1-D1D38B3B30C0} = {8A477241-B96C-4174-968D-D40CB77F1ECD}
{1C7C8DE9-5F2A-43DB-A25E-33319E80A509} = {29DE523D-EEF2-41E9-AC12-F20D8D02BEBB}
{857BCD0E-753F-437A-AF75-B995B4D9A5FE} = {01AB9389-2F89-4F8E-A688-BF4BF1FC42C8}