mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-27 12:36:14 +01:00
avast json importer
This commit is contained in:
parent
a7517a3621
commit
98c7dc1626
69
src/importers/avastJsonImporter.ts
Normal file
69
src/importers/avastJsonImporter.ts
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
import { BaseImporter } from './baseImporter';
|
||||||
|
import { Importer } from './importer';
|
||||||
|
|
||||||
|
import { ImportResult } from '../models/domain/importResult';
|
||||||
|
|
||||||
|
import { CipherType } from '../enums/cipherType';
|
||||||
|
import { SecureNoteType } from '../enums/secureNoteType';
|
||||||
|
|
||||||
|
export class AvastJsonImporter extends BaseImporter implements Importer {
|
||||||
|
parse(data: string): ImportResult {
|
||||||
|
const result = new ImportResult();
|
||||||
|
const results = JSON.parse(data);
|
||||||
|
if (results == null) {
|
||||||
|
result.success = false;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (results.logins != null) {
|
||||||
|
results.logins.forEach((value: any) => {
|
||||||
|
const cipher = this.initLoginCipher();
|
||||||
|
cipher.name = this.getValueOrDefault(value.custName);
|
||||||
|
cipher.notes = this.getValueOrDefault(value.note);
|
||||||
|
cipher.login.uris = this.makeUriArray(value.url);
|
||||||
|
cipher.login.password = this.getValueOrDefault(value.pwd);
|
||||||
|
cipher.login.username = this.getValueOrDefault(value.loginName);
|
||||||
|
this.cleanupCipher(cipher);
|
||||||
|
result.ciphers.push(cipher);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (results.notes != null) {
|
||||||
|
results.notes.forEach((value: any) => {
|
||||||
|
const cipher = this.initLoginCipher();
|
||||||
|
cipher.type = CipherType.SecureNote;
|
||||||
|
cipher.secureNote.type = SecureNoteType.Generic;
|
||||||
|
cipher.name = this.getValueOrDefault(value.label);
|
||||||
|
cipher.notes = this.getValueOrDefault(value.text);
|
||||||
|
this.cleanupCipher(cipher);
|
||||||
|
result.ciphers.push(cipher);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (results.cards != null) {
|
||||||
|
results.cards.forEach((value: any) => {
|
||||||
|
const cipher = this.initLoginCipher();
|
||||||
|
cipher.type = CipherType.Card;
|
||||||
|
cipher.name = this.getValueOrDefault(value.custName);
|
||||||
|
cipher.notes = this.getValueOrDefault(value.note);
|
||||||
|
cipher.card.cardholderName = this.getValueOrDefault(value.holderName);
|
||||||
|
cipher.card.number = this.getValueOrDefault(value.cardNumber);
|
||||||
|
cipher.card.code = this.getValueOrDefault(value.cvv);
|
||||||
|
cipher.card.brand = this.getCardBrand(cipher.card.number);
|
||||||
|
if (value.expirationDate != null) {
|
||||||
|
if (value.expirationDate.month != null) {
|
||||||
|
cipher.card.expMonth = value.expirationDate.month + '';
|
||||||
|
}
|
||||||
|
if (value.expirationDate.year != null) {
|
||||||
|
cipher.card.expYear = value.expirationDate.year + '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.cleanupCipher(cipher);
|
||||||
|
result.ciphers.push(cipher);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
result.success = true;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
@ -25,6 +25,7 @@ import { CipherView } from '../models/view/cipherView';
|
|||||||
|
|
||||||
import { AscendoCsvImporter } from '../importers/ascendoCsvImporter';
|
import { AscendoCsvImporter } from '../importers/ascendoCsvImporter';
|
||||||
import { AvastCsvImporter } from '../importers/avastCsvImporter';
|
import { AvastCsvImporter } from '../importers/avastCsvImporter';
|
||||||
|
import { AvastJsonImporter } from '../importers/avastJsonImporter';
|
||||||
import { AviraCsvImporter } from '../importers/aviraCsvImporter';
|
import { AviraCsvImporter } from '../importers/aviraCsvImporter';
|
||||||
import { BitwardenCsvImporter } from '../importers/bitwardenCsvImporter';
|
import { BitwardenCsvImporter } from '../importers/bitwardenCsvImporter';
|
||||||
import { BitwardenJsonImporter } from '../importers/bitwardenJsonImporter';
|
import { BitwardenJsonImporter } from '../importers/bitwardenJsonImporter';
|
||||||
@ -117,6 +118,7 @@ export class ImportService implements ImportServiceAbstraction {
|
|||||||
{ id: 'passpackcsv', name: 'Passpack (csv)' },
|
{ id: 'passpackcsv', name: 'Passpack (csv)' },
|
||||||
{ id: 'passmanjson', name: 'Passman (json)' },
|
{ id: 'passmanjson', name: 'Passman (json)' },
|
||||||
{ id: 'avastcsv', name: 'Avast Passwords (csv)' },
|
{ id: 'avastcsv', name: 'Avast Passwords (csv)' },
|
||||||
|
{ id: 'avastjson', name: 'Avast Passwords (json)' },
|
||||||
{ id: 'fsecurefsk', name: 'F-Secure KEY (fsk)' },
|
{ id: 'fsecurefsk', name: 'F-Secure KEY (fsk)' },
|
||||||
{ id: 'kasperskytxt', name: 'Kaspersky Password Manager (txt)' },
|
{ id: 'kasperskytxt', name: 'Kaspersky Password Manager (txt)' },
|
||||||
{ id: 'remembearcsv', name: 'RememBear (csv)' },
|
{ id: 'remembearcsv', name: 'RememBear (csv)' },
|
||||||
@ -251,6 +253,8 @@ export class ImportService implements ImportServiceAbstraction {
|
|||||||
return new PassmanJsonImporter();
|
return new PassmanJsonImporter();
|
||||||
case 'avastcsv':
|
case 'avastcsv':
|
||||||
return new AvastCsvImporter();
|
return new AvastCsvImporter();
|
||||||
|
case 'avastjson':
|
||||||
|
return new AvastJsonImporter();
|
||||||
case 'fsecurefsk':
|
case 'fsecurefsk':
|
||||||
return new FSecureFskImporter();
|
return new FSecureFskImporter();
|
||||||
case 'kasperskytxt':
|
case 'kasperskytxt':
|
||||||
|
Loading…
Reference in New Issue
Block a user