mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 17:23:37 +00:00
* Rename all importer related files Renamed all files based on our naming convention which we decided on with https://github.com/bitwarden/adr/blob/master/decisions/0012-angular-filename-convention.md * Removed entries from whitelist-capital-letters.txt * Rename missing safeInCloud test data * Fix broken import * Renamed folders (removed capital letters) * Fix filename of BitwardenCsvImporter * Fix imports of onepassword mac/win importer tests * Remove already renamed folders from whitelist * Rename dashlaneImporters to dashlane Rename the folder Fix all the imports Remove dashlaneImporters from white-list * Rename keeperImporters to keeper Rename the folder Fix all the imports Remove keeperImporters from white-list * Rename onepasswordImporters to onepassword Rename the folder Fix all the imports Remove onepasswordImporters from white-list * Rename safeinCloud test data folder * Fix onepassword importer type imports
69 lines
2.5 KiB
TypeScript
69 lines
2.5 KiB
TypeScript
import { CipherType } from "../enums/cipherType";
|
|
import { SecureNoteType } from "../enums/secureNoteType";
|
|
import { ImportResult } from "../models/domain/import-result";
|
|
|
|
import { BaseImporter } from "./base-importer";
|
|
import { Importer } from "./importer";
|
|
|
|
export class AvastJsonImporter extends BaseImporter implements Importer {
|
|
parse(data: string): Promise<ImportResult> {
|
|
const result = new ImportResult();
|
|
const results = JSON.parse(data);
|
|
if (results == null) {
|
|
result.success = false;
|
|
return Promise.resolve(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 Promise.resolve(result);
|
|
}
|
|
}
|