Skip to content

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

Add individual service import definitions ported from .NET logic (#2413)

Leendert de Borst60f8a018cade
diff --git a/core/client/src/transfer/import/importers/ChromeCsvImporter.ts b/core/client/src/transfer/import/importers/ChromeCsvImporter.ts
new file mode 100644
index 000000000..5b0fe394a
--- /dev/null
+++ b/core/client/src/transfer/import/importers/ChromeCsvImporter.ts
@@ -0,0 +1,29 @@
+import { readImportCsv } from '../readers/CsvImport';
+import { optionalText, text } from '../readers/CsvRecordMapper';
+
+import { parseUrls } from './shared/CredentialHelpers';
+
+import type { ImportedCredential } from '../models/ImportedCredential';
+
+const COLUMNS = {
+ name: text,
+ url: text,
+ username: text,
+ password: text,
+ note: optionalText,
+};
+
+/**
+ * Import a Chrome Password Manager CSV export.
+ * @param fileContent - The CSV file content
+ * @returns The imported credentials
+ */
+export function importChromeCsv(fileContent: string): ImportedCredential[] {
+ return readImportCsv(fileContent, COLUMNS).map(record => ({
+ ServiceName: record.name,
+ ServiceUrls: parseUrls(record.url),
+ Username: record.username,
+ Password: record.password,
+ Notes: record.note,
+ }));
+}
diff --git a/core/client/src/transfer/import/importers/DashlaneCsvImporter.ts b/core/client/src/transfer/import/importers/DashlaneCsvImporter.ts
new file mode 100644
index 000000000..fc93ba7d9
--- /dev/null
+++ b/core/client/src/transfer/import/importers/DashlaneCsvImporter.ts
@@ -0,0 +1,46 @@
+import { nullIfBlank } from '../../shared/StringUtils';
+import { readImportCsv } from '../readers/CsvImport';
+import { optionalText, text } from '../readers/CsvRecordMapper';
+
+import { parseUrls } from './shared/CredentialHelpers';
+
+import type { ImportedCredential } from '../models/ImportedCredential';
+
+const COLUMNS = {
+ username: text,
+ username2: optionalText,
+ username3: optionalText,
+ title: text,
+ password: optionalText,
+ note: optionalText,
+ url: optionalText,
+ category: optionalText,
+ otpUrl: optionalText,
+};
+
+/**
+ * Import a Dashlane CSV export.
+ * @param fileContent - The CSV file content
+ * @returns The imported credentials
+ */
+export function importDashlaneCsv(fileContent: string): ImportedCredential[] {
+ return readImportCsv(fileContent, COLUMNS).map(record => {
+ // The alternative usernames are kept in the notes.
+ const notes = [
+ record.note,
+ record.username2 && `Alternative username 1: ${record.username2}`,
+ record.username3 && `Alternative username 2: ${record.username3}`,
+ ].filter(line => !!line);
+
+ return {
+ ServiceName: record.title,
+ ServiceUrls: parseUrls(record.url),
+ Username: record.username,
+ Password: record.password,
+ TwoFactorSecret: record.otpUrl,
+ Notes: notes.length > 0 ? notes.join('\n') : null,
+ // The Dashlane category becomes the folder.
+ FolderPath: nullIfBlank(record.category),
+ };
+ });
+}
diff --git a/core/client/src/transfer/import/importers/DropboxCsvImporter.ts b/core/client/src/transfer/import/importers/DropboxCsvImporter.ts
new file mode 100644
index 000000000..98329cae6
--- /dev/null
+++ b/core/client/src/transfer/import/importers/DropboxCsvImporter.ts
@@ -0,0 +1,30 @@
+import { isBlank } from '../../shared/StringUtils';
+import { readImportCsv } from '../readers/CsvImport';
+import { optionalText, text } from '../readers/CsvRecordMapper';
+
+import { parseUrls } from './shared/CredentialHelpers';
+
+import type { ImportedCredential } from '../models/ImportedCredential';
+
+const COLUMNS = {
+ Name: text,
+ URL: optionalText,
+ Username: optionalText,
+ Password: optionalText,
+ Notes: optionalText,
+};
+
+/**
+ * Import a Dropbox Passwords CSV export.
+ * @param fileContent - The CSV file content
+ * @returns The imported credentials
+ */
+export function importDropboxCsv(fileContent: string): ImportedCredential[] {
+ return readImportCsv(fileContent, COLUMNS).filter(record => !isBlank(record.Name)).map(record => ({
+ ServiceName: record.Name,
+ ServiceUrls: parseUrls(record.URL),
+ Username: record.Username,
+ Password: record.Password,
+ Notes: record.Notes,
+ }));
+}
diff --git a/core/client/src/transfer/import/importers/EdgeCsvImporter.ts b/core/client/src/transfer/import/importers/EdgeCsvImporter.ts
new file mode 100644
index 000000000..48fa929bd
--- /dev/null
+++ b/core/client/src/transfer/import/importers/EdgeCsvImporter.ts
@@ -0,0 +1,29 @@
+import { readImportCsv } from '../readers/CsvImport';
+import { optionalText, text } from '../readers/CsvRecordMapper';
+
+import { parseUrls } from './shared/CredentialHelpers';
+
+import type { ImportedCredential } from '../models/ImportedCredential';
+
+const COLUMNS = {
+ name: text,
+ url: text,
+ username: text,
+ password: text,
+ note: optionalText,
+};
+
+/**
+ * Import a Microsoft Edge Password Manager CSV export.
+ * @param fileContent - The CSV file content
+ * @returns The imported credentials
+ */
+export function importEdgeCsv(fileContent: string): ImportedCredential[] {
+ return readImportCsv(fileContent, COLUMNS).map(record => ({
+ ServiceName: record.name,
+ ServiceUrls: parseUrls(record.url),
+ Username: record.username,
+ Password: record.password,
+ Notes: record.note,
+ }));
+}
diff --git a/core/client/src/transfer/import/importers/EnpassCsvImporter.ts b/core/client/src/transfer/import/importers/EnpassCsvImporter.ts
new file mode 100644
index 000000000..7df6d5191
--- /dev/null
+++ b/core/client/src/transfer/import/importers/EnpassCsvImporter.ts
@@ -0,0 +1,179 @@
+import { ItemTypes, type ItemType } from '@aliasvault/models/vault';
+
+import { parseDateExact, parseDateTime } from '../../shared/DateTimeUtils';
+import { isBlank } from '../../shared/StringUtils';
+import { parseCsvRows } from '../readers/CsvParser';
+
+import { parseUrls } from './shared/CredentialHelpers';
+
+import type { ImportedAlias } from '../models/ImportedAlias';
+import type { ImportedCredential } from '../models/ImportedCredential';
+import type { ImportedCreditcard } from '../models/ImportedCreditcard';
+
+/**
+ * The fields of one Enpass row, looked up case-insensitively.
+ */
+class EnpassFields {
+ /** Lower case field names to values; the first occurrence of a name wins. */
+ public readonly values = new Map<string, string>();
+
+ /**
+ * Collect the name/value pairs that follow the item name. Pairs with an empty name or value are skipped, and a
+ * leading asterisk (Enpass's marker for sensitive fields) is dropped from the name.
+ * @param fields - The row's fields, starting with the item name
+ */
+ public constructor(fields: string[]) {
+ for (let i = 1; i < fields.length - 1; i += 2) {
+ const name = fields[i].trim().replace(/^\*/, '').toLowerCase();
+ if (name.length > 0 && !isBlank(fields[i + 1]) && !this.values.has(name)) {
+ this.values.set(name, fields[i + 1]);
+ }
+ }
+ }
+
+ /**
+ * Whether a field is present.
+ * @param name - The field name
+ * @returns True when present
+ */
+ public has(name: string): boolean {
+ return this.values.has(name.toLowerCase());
+ }
+
+ /**
+ * The value of the first of the names that is present.
+ * @param names - The field names to try, in order
+ * @returns The value, or null
+ */
+ public first(...names: string[]): string | null {
+ for (const name of names) {
+ const value = this.values.get(name.toLowerCase());
+ if (value !== undefined) {
+ return value;
+ }
+ }
+ return null;
+ }
+}
+
+/** Fields that have no credential property of their own and are kept in the notes as "Name: value". */
+const NOTE_FIELDS = ['Note', 'Notes', 'Security question', 'Security answer', 'Secret question', 'Secret answer'];
+
+/** Birth date layouts tried when the generic date parser fails. */
+const BIRTH_DATE_FORMATS = ['dd-MM-yyyy', 'MM-dd-yyyy', 'dd/MM/yyyy', 'MM/dd/yyyy'] as const;
+
+/**
+ * Import an Enpass CSV export. Enpass writes no header row: each row is the item name followed by alternating
+ * field name and value pairs, and the item type follows from the name and the fields present.
+ * @param fileContent - The CSV file content
+ * @returns The imported credentials
+ */
+export function importEnpassCsv(fileContent: string): ImportedCredential[] {
+ return parseCsvRows(fileContent).filter(row => row.length > 0).map(parseRow);
+}
+
+/**
+ * Parse one Enpass row.
+ * @param row - The row's fields
+ * @returns The credential
+ */
+function parseRow(row: string[]): ImportedCredential {
+ const itemName = row[0];
+ const fields = new EnpassFields(row);
+ const itemType = determineItemType(itemName, fields);
+
+ return {
+ ServiceName: itemName,
+ ItemType: itemType,
+ Username: fields.first('Username', 'Login', 'E-mail'),
+ Password: fields.first('Password', 'Login password'),
+ Email: fields.first('E-mail', 'Email'),
+ // A secure note row holds only the name and the note text.
+ Notes: itemType === ItemTypes.Note && row.length === 2 ? row[1] : buildNotes(fields),
+ ServiceUrls: parseUrls(fields.first('Website', 'URL')),
+ TwoFactorSecret: fields.first('One-time code', 'TOTP', 'OTP'),
+ Creditcard: itemType === ItemTypes.CreditCard ? parseCreditCard(fields) : undefined,
+ Alias: itemType === ItemTypes.Alias ? parseAlias(fields) : undefined,
+ };
+}
+
+/**
+ * Determine the item type from the item name and the fields present.
+ * @param itemName - The item name
+ * @param fields - The row's fields
+ * @returns The item type
+ */
+function determineItemType(itemName: string, fields: EnpassFields): ItemType {
+ const name = itemName.toLowerCase();
+ if (name.includes('credit card') || name.includes('creditcard') || fields.has('CVC') || fields.has('Cardholder')) {
+ return ItemTypes.CreditCard;
+ }
+ if (name === 'identity' || fields.has('First name') || fields.has('Social Security Number')) {
+ return ItemTypes.Alias;
+ }
+ if (name === 'securenote' || name === 'secure note' || name === 'note') {
+ return ItemTypes.Note;
+ }
+ return ItemTypes.Login;
+}
+
+/**
+ * Build the notes from the fields that do not map to a credential property.
+ * @param fields - The row's fields
+ * @returns The notes, or null
+ */
+function buildNotes(fields: EnpassFields): string | null {
+ const notes = NOTE_FIELDS.filter(name => fields.has(name)).map(name => `${name}: ${fields.first(name)}`);
+ for (const [name, value] of fields.values) {
+ if (name.endsWith('notes')) {
+ notes.push(value);
+ }
+ }
+ return notes.length > 0 ? notes.join('\n') : null;
+}
+
+/**
+ * Parse the credit card fields. The expiry is MM/YY or MM/YYYY; a four-digit year keeps its last two digits.
+ * @param fields - The row's fields
+ * @returns The credit card
+ */
+function parseCreditCard(fields: EnpassFields): ImportedCreditcard {
+ const card: ImportedCreditcard = {
+ CardholderName: fields.first('Cardholder', 'Cardholder Name', 'Name on Card'),
+ Number: fields.first('Number', 'Card Number'),
+ Cvv: fields.first('CVC', 'CVV', 'Security Code'),
+ Pin: fields.first('PIN'),
+ };
+
+ const parts = fields.first('Expiry date', 'Expiry', 'Expires', 'Valid thru')?.split('/') ?? [];
+ if (parts.length === 2) {
+ const year = parts[1].trim();
+ card.ExpiryMonth = parts[0].trim();
+ card.ExpiryYear = year.length === 4 ? year.substring(2) : year;
+ }
+
+ return card;
+}
+
+/**
+ * Parse the identity fields.
+ * @param fields - The row's fields
+ * @returns The alias
+ */
+function parseAlias(fields: EnpassFields): ImportedAlias {
+ const alias: ImportedAlias = {
+ FirstName: fields.first('First name', 'Firstname'),
+ LastName: fields.first('Last name', 'Lastname'),
+ Gender: fields.first('Gender'),
+ };
+
+ const birthDate = fields.first('Birth date', 'Birthdate', 'Birthday', 'Date of birth');
+ if (birthDate) {
+ const date = parseDateTime(birthDate) ?? BIRTH_DATE_FORMATS.map(format => parseDateExact(birthDate, format)).find(parsed => parsed !== null);
+ if (date) {
+ alias.BirthDate = date;
+ }
+ }
+
+ return alias;
+}
diff --git a/core/client/src/transfer/import/importers/FirefoxCsvImporter.ts b/core/client/src/transfer/import/importers/FirefoxCsvImporter.ts
new file mode 100644
index 000000000..14a6db980
--- /dev/null
+++ b/core/client/src/transfer/import/importers/FirefoxCsvImporter.ts
@@ -0,0 +1,28 @@
+import { readImportCsv } from '../readers/CsvImport';
+import { text } from '../readers/CsvRecordMapper';
+
+import { parseUrls } from './shared/CredentialHelpers';
+
+import type { ImportedCredential } from '../models/ImportedCredential';
+
+const COLUMNS = {
+ url: text,
+ username: text,
+ password: text,
+};
+
+/**
+ * Import a Firefox Password Manager CSV export.
+ * @param fileContent - The CSV file content
+ * @returns The imported credentials
+ * @throws {TypeError} When a URL cannot be parsed.
+ */
+export function importFirefoxCsv(fileContent: string): ImportedCredential[] {
+ return readImportCsv(fileContent, COLUMNS).map(record => ({
+ // Firefox has no title column, so the host of the URL without "www." names the service.
+ ServiceName: new URL(record.url).hostname.replace(/^www\./, ''),
+ ServiceUrls: parseUrls(record.url),
+ Username: record.username,
+ Password: record.password,
+ }));
+}
diff --git a/core/client/src/transfer/import/importers/GenericCsvImporter.ts b/core/client/src/transfer/import/importers/GenericCsvImporter.ts
new file mode 100644
index 000000000..b1a6a1ca4
--- /dev/null
+++ b/core/client/src/transfer/import/importers/GenericCsvImporter.ts
@@ -0,0 +1,64 @@
+import { isBlank, nullIfBlank } from '../../shared/StringUtils';
+import { readImportCsv } from '../readers/CsvImport';
+import { optionalText, text } from '../readers/CsvRecordMapper';
+
+import { parseUrls } from './shared/CredentialHelpers';
+
+import type { ImportedCredential } from '../models/ImportedCredential';
+
+const COLUMNS = {
+ service_name: text,
+ url: optionalText,
+ username: optionalText,
+ password: optionalText,
+ totp_secret: optionalText,
+ notes: optionalText,
+ folder: optionalText,
+};
+
+/** Common URL placeholders that are considered empty when found in the URL field. */
+const URL_PLACEHOLDERS = new Set(['http://', 'https://', 'N/A', 'n/a']);
+
+/** The template users download: the headers plus example rows. */
+const CSV_TEMPLATE = [
+ 'service_name,url,username,password,totp_secret,notes,folder',
+ 'Gmail,https://gmail.com,[email protected],your_password,,Important email account,Personal',
+ 'Facebook,https://facebook.com,your.username,your_password,,Social media account,Personal/Social',
+ 'GitHub,https://github.com,developer_username,your_password,your_totp_secret_here,Development platform,Work',
+ 'Secure Note,,,,,"Important information or notes without login credentials",',
+].map(line => `${line}\r\n`).join('');
+
+/**
+ * The generic CSV template, for download.
+ * @returns The UTF-8 encoded template
+ */
+export function getGenericCsvTemplate(): Uint8Array {
+ return new TextEncoder().encode(CSV_TEMPLATE);
+}
+
+/**
+ * Import a CSV file in the generic AliasVault template format.
+ * @param fileContent - The CSV file content
+ * @returns The imported credentials
+ * @throws {Error} When the file holds no row with a service name.
+ */
+export function importGenericCsv(fileContent: string): ImportedCredential[] {
+ const credentials = readImportCsv(fileContent, COLUMNS).filter(record => !isBlank(record.service_name)).map((record): ImportedCredential => {
+ const url = nullIfBlank(record.url)?.trim() ?? null;
+ return {
+ ServiceName: record.service_name.trim(),
+ ServiceUrls: url && !URL_PLACEHOLDERS.has(url) ? parseUrls(url) : null,
+ Username: record.username?.trim() ?? null,
+ Password: record.password?.trim() ?? null,
+ TwoFactorSecret: record.totp_secret?.trim() ?? null,
+ Notes: record.notes?.trim() ?? null,
+ FolderPath: nullIfBlank(record.folder)?.trim() ?? null,
+ };
+ });
+
+ if (credentials.length === 0) {
+ throw new Error('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;
+}
diff --git a/core/client/src/transfer/import/importers/KeePassCsvImporter.ts b/core/client/src/transfer/import/importers/KeePassCsvImporter.ts
new file mode 100644
index 000000000..17b11c752
--- /dev/null
+++ b/core/client/src/transfer/import/importers/KeePassCsvImporter.ts
@@ -0,0 +1,38 @@
+import { readImportCsv } from '../readers/CsvImport';
+import { optionalText, text } from '../readers/CsvRecordMapper';
+
+import { parseUrls } from './shared/CredentialHelpers';
+
+import type { ImportedCredential } from '../models/ImportedCredential';
+
+const COLUMNS = {
+ Account: text,
+ LoginName: optionalText,
+ Password: optionalText,
+ WebSite: optionalText,
+ Comments: optionalText,
+};
+
+/**
+ * Import a KeePass 1.x CSV export.
+ * @param fileContent - The CSV file content
+ * @returns The imported credentials
+ */
+export function importKeePassCsv(fileContent: string): ImportedCredential[] {
+ return readImportCsv(fileContent, COLUMNS, decodeKeePassField).map(record => ({
+ ServiceName: record.Account,
+ ServiceUrls: parseUrls(record.WebSite),
+ Username: record.LoginName,
+ Password: record.Password,
+ Notes: record.Comments,
+ }));
+}
+
+/**
+ * Decode KeePass 1.x field encoding, which writes quotes as \" and backslashes as \\.
+ * @param value - The field value
+ * @returns The decoded value
+ */
+function decodeKeePassField(value: string): string {
+ return value.replace(/\\(["\\])/g, '$1');
+}
diff --git a/core/client/src/transfer/import/importers/KeePassXcCsvImporter.ts b/core/client/src/transfer/import/importers/KeePassXcCsvImporter.ts
new file mode 100644
index 000000000..d95fc44d4
--- /dev/null
+++ b/core/client/src/transfer/import/importers/KeePassXcCsvImporter.ts
@@ -0,0 +1,34 @@
+import { nullIfBlank } from '../../shared/StringUtils';
+import { readImportCsv } from '../readers/CsvImport';
+import { optionalText, text } from '../readers/CsvRecordMapper';
+
+import { parseUrls } from './shared/CredentialHelpers';
+
+import type { ImportedCredential } from '../models/ImportedCredential';
+
+const COLUMNS = {
+ Group: text,
+ Title: text,
+ Username: optionalText,
+ Password: optionalText,
+ URL: optionalText,
+ Notes: optionalText,
+ TOTP: optionalText,
+};
+
+/**
+ * Import a KeePassXC CSV export.
+ * @param fileContent - The CSV file content
+ * @returns The imported credentials
+ */
+export function importKeePassXcCsv(fileContent: string): ImportedCredential[] {
+ return readImportCsv(fileContent, COLUMNS).map(record => ({
+ ServiceName: record.Title,
+ ServiceUrls: parseUrls(record.URL),
+ Username: record.Username,
+ Password: record.Password,
+ TwoFactorSecret: record.TOTP,
+ Notes: record.Notes,
+ FolderPath: nullIfBlank(record.Group),
+ }));
+}
diff --git a/core/client/src/transfer/import/importers/LastPassCsvImporter.ts b/core/client/src/transfer/import/importers/LastPassCsvImporter.ts
new file mode 100644
index 000000000..9e4809d9f
--- /dev/null
+++ b/core/client/src/transfer/import/importers/LastPassCsvImporter.ts
@@ -0,0 +1,113 @@
+import { ItemTypes } from '@aliasvault/models/vault';
+
+import { isBlank, nullIfBlank } from '../../shared/StringUtils';
+import { readImportCsv } from '../readers/CsvImport';
+import { optionalText, text } from '../readers/CsvRecordMapper';
+
+import { parseUrls } from './shared/CredentialHelpers';
+
+import type { ImportedCredential } from '../models/ImportedCredential';
+import type { ImportedCreditcard } from '../models/ImportedCreditcard';
+
+const COLUMNS = {
+ url: optionalText,
+ username: optionalText,
+ password: optionalText,
+ totp: optionalText,
+ extra: optionalText,
+ name: text,
+ grouping: optionalText,
+};
+
+/** LastPass writes "http://sn" as the URL of a secure note and "http://" for an entry without one. */
+const SECURE_NOTE_URL = 'http://sn';
+const EMPTY_URL = 'http://';
+
+/** Month names as LastPass writes them in the "Expiration Date" line of a credit card note ("May,2028"). */
+const MONTHS = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'];
+
+/**
+ * Import a LastPass CSV export.
+ * @param fileContent - The CSV file content
+ * @returns The imported credentials
+ */
+export function importLastPassCsv(fileContent: string): ImportedCredential[] {
+ return readImportCsv(fileContent, COLUMNS).filter(record => !isBlank(record.name)).map((record): ImportedCredential => {
+ const credential: ImportedCredential = {
+ ServiceName: record.name,
+ ServiceUrls: record.url === EMPTY_URL || record.url === SECURE_NOTE_URL ? null : parseUrls(record.url),
+ Username: record.username,
+ Password: record.password,
+ TwoFactorSecret: record.totp,
+ Notes: record.extra,
+ FolderPath: nullIfBlank(record.grouping),
+ };
+
+ if (record.extra?.includes('NoteType:Credit Card')) {
+ credential.ItemType = ItemTypes.CreditCard;
+ credential.Creditcard = parseCreditcard(record.extra);
+ credential.Notes = extractCreditcardNotes(record.extra);
+ } else if (record.url === SECURE_NOTE_URL && !record.username && !record.password) {
+ credential.ItemType = ItemTypes.Note;
+ }
+
+ return credential;
+ });
+}
+
+/**
+ * Parse the card fields out of a credit card note's "Key:Value" lines.
+ * @param notes - The credit card note
+ * @returns The credit card
+ */
+function parseCreditcard(notes: string): ImportedCreditcard {
+ const card: ImportedCreditcard = {};
+
+ for (const line of notes.split(/[\r\n]+/)) {
+ const colonIndex = line.indexOf(':');
+ const key = line.substring(0, colonIndex).trim();
+ const value = line.substring(colonIndex + 1).trim();
+ if (colonIndex <= 0 || value.length === 0) {
+ continue;
+ }
+
+ switch (key) {
+ case 'Name on Card':
+ card.CardholderName = value;
+ break;
+ case 'Number':
+ card.Number = value;
+ break;
+ case 'Security Code':
+ card.Cvv = value;
+ break;
+ case 'Expiration Date': {
+ const parts = value.split(',');
+ if (parts.length === 2) {
+ const month = MONTHS.indexOf(parts[0].trim().toLowerCase()) + 1;
+ card.ExpiryMonth = month > 0 ? String(month).padStart(2, '0') : null;
+ card.ExpiryYear = parts[1].trim();
+ }
+ break;
+ }
+ }
+ }
+
+ return card;
+}
+
+/**
+ * Extract the free-text part of a credit card note, everything from the "Notes:" line.
+ * @param notes - The credit card note
+ * @returns The notes, or null when there are none
+ */
+function extractCreditcardNotes(notes: string): string | null {
+ const lines = notes.split(/[\r\n]+/).filter(line => line.length > 0);
+ const start = lines.findIndex(line => line.startsWith('Notes:'));
+ if (start < 0) {
+ return null;
+ }
+
+ const noteLines = [lines[start].substring('Notes:'.length).trim(), ...lines.slice(start + 1)].filter((line, index) => index > 0 || line.length > 0);
+ return noteLines.length > 0 ? noteLines.join('\n') : null;
+}
diff --git a/core/client/src/transfer/import/importers/NordPassCsvImporter.ts b/core/client/src/transfer/import/importers/NordPassCsvImporter.ts
new file mode 100644
index 000000000..8e5451c4c
--- /dev/null
+++ b/core/client/src/transfer/import/importers/NordPassCsvImporter.ts
@@ -0,0 +1,74 @@
+import { ItemTypes } from '@aliasvault/models/vault';
+
+import { isBlank, nonBlank, nullIfBlank } from '../../shared/StringUtils';
+import { readImportCsv } from '../readers/CsvImport';
+import { optionalText, text } from '../readers/CsvRecordMapper';
+
+import { mapItemType, parseUrls } from './shared/CredentialHelpers';
+
+import type { ImportedCredential } from '../models/ImportedCredential';
+import type { ImportedCreditcard } from '../models/ImportedCreditcard';
+
+const COLUMNS = {
+ name: text,
+ url: text,
+ username: text,
+ password: text,
+ note: optionalText,
+ cardholdername: optionalText,
+ cardnumber: optionalText,
+ cvc: optionalText,
+ pin: optionalText,
+ expirydate: optionalText,
+ folder: optionalText,
+ email: optionalText,
+ type: optionalText,
+ custom_fields: optionalText,
+};
+
+const ITEM_TYPES = {
+ password: ItemTypes.Login,
+ note: ItemTypes.Note,
+ credit_card: ItemTypes.CreditCard,
+ identity: ItemTypes.Alias,
+};
+
+/**
+ * Import a NordPass CSV export.
+ * @param fileContent - The CSV file content
+ * @returns The imported credentials
+ */
+export function importNordPassCsv(fileContent: string): ImportedCredential[] {
+ return readImportCsv(fileContent, COLUMNS).filter(record => record.type?.toLowerCase() !== 'folder').map(record => {
+ const hasCard = nonBlank([record.cardnumber, record.cardholdername, record.cvc, record.expirydate]).length > 0;
+ const notes = isBlank(record.custom_fields) ? record.note : nonBlank([record.note]).concat(record.custom_fields).join('\n');
+
+ return {
+ ServiceName: record.name,
+ ServiceUrls: parseUrls(record.url),
+ Email: record.email,
+ Username: record.username,
+ Password: record.password,
+ Notes: notes,
+ FolderPath: nullIfBlank(record.folder),
+ ItemType: mapItemType(record.type, ITEM_TYPES) ?? (hasCard ? ItemTypes.CreditCard : null),
+ Creditcard: hasCard ? { CardholderName: record.cardholdername, Number: record.cardnumber, Cvv: record.cvc, Pin: record.pin, ...parseExpiryDate(record.expirydate) } : null,
+ };
+ });
+}
+
+/**
+ * Parse a NordPass expiry date, written as "MM/YYYY", "MM/YY" or "MMYYYY", into month and year.
+ * @param expiryDate - The expiry date text
+ * @returns The month and year, empty when the format is not recognised
+ */
+function parseExpiryDate(expiryDate: string | null): Pick<ImportedCreditcard, 'ExpiryMonth' | 'ExpiryYear'> {
+ if (expiryDate?.includes('/')) {
+ const parts = expiryDate.split('/');
+ return parts.length === 2 ? { ExpiryMonth: parts[0].trim().padStart(2, '0'), ExpiryYear: parts[1].trim() } : {};
+ }
+ if (expiryDate?.length === 6) {
+ return { ExpiryMonth: expiryDate.substring(0, 2), ExpiryYear: expiryDate.substring(2) };
+ }
+ return {};
+}
diff --git a/core/client/src/transfer/import/importers/RoboformCsvImporter.ts b/core/client/src/transfer/import/importers/RoboformCsvImporter.ts
new file mode 100644
index 000000000..93674e542
--- /dev/null
+++ b/core/client/src/transfer/import/importers/RoboformCsvImporter.ts
@@ -0,0 +1,35 @@
+import { ItemTypes } from '@aliasvault/models/vault';
+
+import { isBlank, nullIfBlank } from '../../shared/StringUtils';
+import { readImportCsv } from '../readers/CsvImport';
+import { optionalText, text } from '../readers/CsvRecordMapper';
+
+import { parseUrls } from './shared/CredentialHelpers';
+
+import type { ImportedCredential } from '../models/ImportedCredential';
+
+const COLUMNS = {
+ Name: text,
+ Url: optionalText,
+ Login: optionalText,
+ Pwd: optionalText,
+ Note: optionalText,
+ Folder: optionalText,
+};
+
+/**
+ * Import a RoboForm CSV export. A item with a note but no URL, login or password is a secure note.
+ * @param fileContent - The CSV file content
+ * @returns The imported credentials
+ */
+export function importRoboformCsv(fileContent: string): ImportedCredential[] {
+ return readImportCsv(fileContent, COLUMNS).map(record => ({
+ ServiceName: record.Name,
+ ServiceUrls: parseUrls(record.Url),
+ Username: record.Login,
+ Password: record.Pwd,
+ Notes: record.Note,
+ FolderPath: nullIfBlank(record.Folder?.replace(/^\/+/, '')),
+ ItemType: isBlank(record.Url) && isBlank(record.Login) && isBlank(record.Pwd) && !isBlank(record.Note) ? ItemTypes.Note : ItemTypes.Login,
+ }));
+}
diff --git a/core/client/src/transfer/import/importers/StrongboxCsvImporter.ts b/core/client/src/transfer/import/importers/StrongboxCsvImporter.ts
new file mode 100644
index 000000000..60155e53b
--- /dev/null
+++ b/core/client/src/transfer/import/importers/StrongboxCsvImporter.ts
@@ -0,0 +1,31 @@
+import { readImportCsv } from '../readers/CsvImport';
+import { optionalText, text } from '../readers/CsvRecordMapper';
+
+import { parseUrls } from './shared/CredentialHelpers';
+
+import type { ImportedCredential } from '../models/ImportedCredential';
+
+const COLUMNS = {
+ Title: text,
+ Username: optionalText,
+ Password: optionalText,
+ URL: optionalText,
+ OTPAuth: optionalText,
+ Notes: optionalText,
+};
+
+/**
+ * Import a Strongbox CSV export.
+ * @param fileContent - The CSV file content
+ * @returns The imported credentials
+ */
+export function importStrongboxCsv(fileContent: string): ImportedCredential[] {
+ return readImportCsv(fileContent, COLUMNS).map(record => ({
+ ServiceName: record.Title,
+ ServiceUrls: parseUrls(record.URL),
+ Username: record.Username,
+ Password: record.Password,
+ TwoFactorSecret: record.OTPAuth,
+ Notes: record.Notes,
+ }));
+}