mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-21 11:35:34 +01:00
[PM-4163] Fix protonpass importer when totp field is not a URL (#6474)
* Fix protonpass importer when totp field is not a URL * Simplify ProtonPass importer totp handling * Use getValueOrDefault for totp import in ProtonPass importer * Use getValueOrDefault for other ProtonPass importer fields --------- Co-authored-by: ttalty <144813356+ttalty@users.noreply.github.com>
This commit is contained in:
parent
91e7a45ee4
commit
77ee09540e
@ -159,7 +159,7 @@ export const testData: ProtonPassJsonFile = {
|
|||||||
username: "other vault username",
|
username: "other vault username",
|
||||||
password: "other vault password",
|
password: "other vault password",
|
||||||
urls: [],
|
urls: [],
|
||||||
totpUri: "",
|
totpUri: "JBSWY3DPEHPK3PXP",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
state: 1,
|
state: 1,
|
||||||
|
@ -42,18 +42,16 @@ export class ProtonPassJsonImporter extends BaseImporter implements Importer {
|
|||||||
this.processFolder(result, vault.name);
|
this.processFolder(result, vault.name);
|
||||||
|
|
||||||
const cipher = this.initLoginCipher();
|
const cipher = this.initLoginCipher();
|
||||||
cipher.name = item.data.metadata.name;
|
cipher.name = this.getValueOrDefault(item.data.metadata.name, "--");
|
||||||
cipher.notes = item.data.metadata.note;
|
cipher.notes = this.getValueOrDefault(item.data.metadata.note);
|
||||||
|
|
||||||
switch (item.data.type) {
|
switch (item.data.type) {
|
||||||
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 = loginContent.username;
|
cipher.login.username = this.getValueOrDefault(loginContent.username);
|
||||||
cipher.login.password = loginContent.password;
|
cipher.login.password = this.getValueOrDefault(loginContent.password);
|
||||||
if (loginContent.totpUri != "") {
|
cipher.login.totp = this.getValueOrDefault(loginContent.totpUri);
|
||||||
cipher.login.totp = new URL(loginContent.totpUri).searchParams.get("secret");
|
|
||||||
}
|
|
||||||
for (const extraField of item.data.extraFields) {
|
for (const extraField of item.data.extraFields) {
|
||||||
this.processKvp(
|
this.processKvp(
|
||||||
cipher,
|
cipher,
|
||||||
@ -73,10 +71,10 @@ export class ProtonPassJsonImporter extends BaseImporter implements Importer {
|
|||||||
const creditCardContent = item.data.content as ProtonPassCreditCardItemContent;
|
const creditCardContent = item.data.content as ProtonPassCreditCardItemContent;
|
||||||
cipher.type = CipherType.Card;
|
cipher.type = CipherType.Card;
|
||||||
cipher.card = new CardView();
|
cipher.card = new CardView();
|
||||||
cipher.card.cardholderName = creditCardContent.cardholderName;
|
cipher.card.cardholderName = this.getValueOrDefault(creditCardContent.cardholderName);
|
||||||
cipher.card.number = creditCardContent.number;
|
cipher.card.number = this.getValueOrDefault(creditCardContent.number);
|
||||||
cipher.card.brand = CardView.getCardBrandByPatterns(creditCardContent.number);
|
cipher.card.brand = CardView.getCardBrandByPatterns(creditCardContent.number);
|
||||||
cipher.card.code = creditCardContent.verificationNumber;
|
cipher.card.code = this.getValueOrDefault(creditCardContent.verificationNumber);
|
||||||
|
|
||||||
if (!this.isNullOrWhitespace(creditCardContent.expirationDate)) {
|
if (!this.isNullOrWhitespace(creditCardContent.expirationDate)) {
|
||||||
cipher.card.expMonth = creditCardContent.expirationDate.substring(0, 2);
|
cipher.card.expMonth = creditCardContent.expirationDate.substring(0, 2);
|
||||||
|
Loading…
Reference in New Issue
Block a user