From 913f109ffae61c840d576f550a85713c99a075be Mon Sep 17 00:00:00 2001 From: Daniel James Smith <2670567+djsmith85@users.noreply.github.com> Date: Wed, 13 Nov 2024 15:11:53 +0100 Subject: [PATCH] Fix totp import on Dashlane csv importer (#11747) Co-authored-by: Daniel James Smith --- libs/importer/spec/dashlane-csv-importer.spec.ts | 9 +++++++++ .../test-data/dashlane-csv/credentials-otpurl.csv.ts | 2 ++ .../src/importers/dashlane/dashlane-csv-importer.ts | 2 +- .../src/importers/dashlane/types/dashlane-csv-types.ts | 3 ++- 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 libs/importer/spec/test-data/dashlane-csv/credentials-otpurl.csv.ts diff --git a/libs/importer/spec/dashlane-csv-importer.spec.ts b/libs/importer/spec/dashlane-csv-importer.spec.ts index e76a4d4cb3..1d76396022 100644 --- a/libs/importer/spec/dashlane-csv-importer.spec.ts +++ b/libs/importer/spec/dashlane-csv-importer.spec.ts @@ -2,6 +2,7 @@ import { CipherType } from "@bitwarden/common/vault/enums"; import { DashlaneCsvImporter } from "../src/importers"; +import { credentialsData_otpUrl } from "./test-data/dashlane-csv/credentials-otpurl.csv"; import { credentialsData } from "./test-data/dashlane-csv/credentials.csv"; import { identityData } from "./test-data/dashlane-csv/id.csv"; import { multiplePersonalInfoData } from "./test-data/dashlane-csv/multiple-personal-info.csv"; @@ -30,6 +31,14 @@ describe("Dashlane CSV Importer", () => { expect(cipher.notes).toEqual("some note for example.com"); }); + it("should parse login with totp when given otpUrl instead of otpSecret", async () => { + const result = await importer.parse(credentialsData_otpUrl); + expect(result != null).toBe(true); + + const cipher = result.ciphers.shift(); + expect(cipher.login.totp).toEqual("anotherTOTPSeed"); + }); + it("should parse an item and create a folder", async () => { const result = await importer.parse(credentialsData); diff --git a/libs/importer/spec/test-data/dashlane-csv/credentials-otpurl.csv.ts b/libs/importer/spec/test-data/dashlane-csv/credentials-otpurl.csv.ts new file mode 100644 index 0000000000..9506a98bad --- /dev/null +++ b/libs/importer/spec/test-data/dashlane-csv/credentials-otpurl.csv.ts @@ -0,0 +1,2 @@ +export const credentialsData_otpUrl = `username,username2,username3,title,password,note,url,category,otpUrl +jdoe,,,example.com,somePassword,some note for example.com,https://www.example.com,Entertainment,anotherTOTPSeed`; diff --git a/libs/importer/src/importers/dashlane/dashlane-csv-importer.ts b/libs/importer/src/importers/dashlane/dashlane-csv-importer.ts index 888aeb823e..94bc23c5fa 100644 --- a/libs/importer/src/importers/dashlane/dashlane-csv-importer.ts +++ b/libs/importer/src/importers/dashlane/dashlane-csv-importer.ts @@ -119,7 +119,7 @@ export class DashlaneCsvImporter extends BaseImporter implements Importer { cipher.notes = row.note; cipher.login.username = row.username; cipher.login.password = row.password; - cipher.login.totp = row.otpSecret; + cipher.login.totp = Object.keys(row).includes("otpUrl") ? row.otpUrl : row.otpSecret; cipher.login.uris = this.makeUriArray(row.url); this.importUnmappedFields(cipher, row, _mappedCredentialsColumns); diff --git a/libs/importer/src/importers/dashlane/types/dashlane-csv-types.ts b/libs/importer/src/importers/dashlane/types/dashlane-csv-types.ts index cb321c56da..c17aa8bf0e 100644 --- a/libs/importer/src/importers/dashlane/types/dashlane-csv-types.ts +++ b/libs/importer/src/importers/dashlane/types/dashlane-csv-types.ts @@ -8,7 +8,8 @@ export class CredentialsRecord { note: string; url: string; category: string; - otpSecret: string; + otpSecret?: string; + otpUrl?: string; // Likely introduced by Dashlane as a replacement for `otpSecret` } export class PaymentsRecord {