[PM-9318] Fix username on protonpass import (#9889)

* Fix username field used for ProtonPass import

ProtonPass has changed their export format and userName is not itemEmail

* Import additional field itemUsername

---------

Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
This commit is contained in:
Daniel James Smith 2024-07-08 22:45:02 +02:00 committed by GitHub
parent 6b122ca123
commit 83a32cd179
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 7 deletions

View File

@ -31,9 +31,12 @@ describe("Protonpass Json Importer", () => {
expect(uriView.uri).toEqual("https://example.com/");
expect(cipher.notes).toEqual("My login secure note.");
expect(cipher.fields.at(2).name).toEqual("second 2fa secret");
expect(cipher.fields.at(2).value).toEqual("TOTPCODE");
expect(cipher.fields.at(2).type).toEqual(FieldType.Hidden);
expect(cipher.fields.at(0).name).toEqual("itemUsername");
expect(cipher.fields.at(0).value).toEqual("someOtherUsername");
expect(cipher.fields.at(3).name).toEqual("second 2fa secret");
expect(cipher.fields.at(3).value).toEqual("TOTPCODE");
expect(cipher.fields.at(3).type).toEqual(FieldType.Hidden);
});
it("should parse note data", async () => {

View File

@ -49,11 +49,12 @@ export const testData: ProtonPassJsonFile = {
],
type: "login",
content: {
username: "Username",
itemEmail: "Username",
password: "Password",
urls: ["https://example.com/", "https://example2.com/"],
totpUri:
"otpauth://totp/Test%20Login%20-%20Personal%20Vault:Username?issuer=Test%20Login%20-%20Personal%20Vault&secret=TOTPCODE&algorithm=SHA1&digits=6&period=30",
itemUsername: "someOtherUsername",
},
},
state: 1,
@ -156,10 +157,11 @@ export const testData: ProtonPassJsonFile = {
extraFields: [],
type: "login",
content: {
username: "other vault username",
itemEmail: "other vault username",
password: "other vault password",
urls: [],
totpUri: "JBSWY3DPEHPK3PXP",
itemUsername: "",
},
},
state: 1,

View File

@ -48,9 +48,10 @@ export class ProtonPassJsonImporter extends BaseImporter implements Importer {
case "login": {
const loginContent = item.data.content as ProtonPassLoginItemContent;
cipher.login.uris = this.makeUriArray(loginContent.urls);
cipher.login.username = this.getValueOrDefault(loginContent.username);
cipher.login.username = this.getValueOrDefault(loginContent.itemEmail);
cipher.login.password = this.getValueOrDefault(loginContent.password);
cipher.login.totp = this.getValueOrDefault(loginContent.totpUri);
this.processKvp(cipher, "itemUsername", loginContent.itemUsername);
for (const extraField of item.data.extraFields) {
this.processKvp(
cipher,

View File

@ -56,10 +56,11 @@ export type ProtonPassItemExtraFieldData = {
};
export type ProtonPassLoginItemContent = {
username?: string;
itemEmail?: string;
password?: string;
urls?: string[];
totpUri?: string;
itemUsername?: string;
};
export type ProtonPassCreditCardItemContent = {