mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-11 10:10:25 +01: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:
parent
a7adf952db
commit
6bc0ffc930
@ -31,8 +31,8 @@ describe("Protonpass Json Importer", () => {
|
|||||||
expect(uriView.uri).toEqual("https://example.com/");
|
expect(uriView.uri).toEqual("https://example.com/");
|
||||||
expect(cipher.notes).toEqual("My login secure note.");
|
expect(cipher.notes).toEqual("My login secure note.");
|
||||||
|
|
||||||
expect(cipher.fields.at(0).name).toEqual("itemUsername");
|
expect(cipher.fields.at(0).name).toEqual("email");
|
||||||
expect(cipher.fields.at(0).value).toEqual("someOtherUsername");
|
expect(cipher.fields.at(0).value).toEqual("Email");
|
||||||
|
|
||||||
expect(cipher.fields.at(3).name).toEqual("second 2fa secret");
|
expect(cipher.fields.at(3).name).toEqual("second 2fa secret");
|
||||||
expect(cipher.fields.at(3).value).toEqual("TOTPCODE");
|
expect(cipher.fields.at(3).value).toEqual("TOTPCODE");
|
||||||
|
@ -49,12 +49,12 @@ export const testData: ProtonPassJsonFile = {
|
|||||||
],
|
],
|
||||||
type: "login",
|
type: "login",
|
||||||
content: {
|
content: {
|
||||||
itemEmail: "Username",
|
itemEmail: "Email",
|
||||||
password: "Password",
|
password: "Password",
|
||||||
urls: ["https://example.com/", "https://example2.com/"],
|
urls: ["https://example.com/", "https://example2.com/"],
|
||||||
totpUri:
|
totpUri:
|
||||||
"otpauth://totp/Test%20Login%20-%20Personal%20Vault:Username?issuer=Test%20Login%20-%20Personal%20Vault&secret=TOTPCODE&algorithm=SHA1&digits=6&period=30",
|
"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,
|
state: 1,
|
||||||
|
@ -48,10 +48,17 @@ export class ProtonPassJsonImporter extends BaseImporter implements Importer {
|
|||||||
case "login": {
|
case "login": {
|
||||||
const loginContent = item.data.content as ProtonPassLoginItemContent;
|
const loginContent = item.data.content as ProtonPassLoginItemContent;
|
||||||
cipher.login.uris = this.makeUriArray(loginContent.urls);
|
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);
|
cipher.login.username = this.getValueOrDefault(loginContent.itemEmail);
|
||||||
|
} else {
|
||||||
|
this.processKvp(cipher, "email", loginContent.itemEmail);
|
||||||
|
}
|
||||||
|
|
||||||
cipher.login.password = this.getValueOrDefault(loginContent.password);
|
cipher.login.password = this.getValueOrDefault(loginContent.password);
|
||||||
cipher.login.totp = this.getValueOrDefault(loginContent.totpUri);
|
cipher.login.totp = this.getValueOrDefault(loginContent.totpUri);
|
||||||
this.processKvp(cipher, "itemUsername", loginContent.itemUsername);
|
|
||||||
for (const extraField of item.data.extraFields) {
|
for (const extraField of item.data.extraFields) {
|
||||||
this.processKvp(
|
this.processKvp(
|
||||||
cipher,
|
cipher,
|
||||||
|
Loading…
Reference in New Issue
Block a user