1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-23 03:22:50 +02:00

[Beeep] [PM-10767] Improve username importing on protonpass importer (#10471)

* Improve username importing on protonpass importer

* Conditionally write proton importer custom fields
This commit is contained in:
Bernd Schoolmann 2024-08-12 20:42:04 +02:00 committed by GitHub
parent a7adf952db
commit 6bc0ffc930
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 6 deletions

View File

@ -31,8 +31,8 @@ describe("Protonpass Json Importer", () => {
expect(uriView.uri).toEqual("https://example.com/");
expect(cipher.notes).toEqual("My login secure note.");
expect(cipher.fields.at(0).name).toEqual("itemUsername");
expect(cipher.fields.at(0).value).toEqual("someOtherUsername");
expect(cipher.fields.at(0).name).toEqual("email");
expect(cipher.fields.at(0).value).toEqual("Email");
expect(cipher.fields.at(3).name).toEqual("second 2fa secret");
expect(cipher.fields.at(3).value).toEqual("TOTPCODE");

View File

@ -49,12 +49,12 @@ export const testData: ProtonPassJsonFile = {
],
type: "login",
content: {
itemEmail: "Username",
itemEmail: "Email",
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",
itemUsername: "Username",
},
},
state: 1,

View File

@ -48,10 +48,17 @@ 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.itemUsername);
// if the cipher has no username then the email is used as the username
if (cipher.login.username == null) {
cipher.login.username = this.getValueOrDefault(loginContent.itemEmail);
} else {
this.processKvp(cipher, "email", 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,