bitwarden-estensione-browser/libs/common/src/importers/blackBerryCsvImporter.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
1.2 KiB
TypeScript
Raw Normal View History

2022-02-22 15:39:11 +01:00
import { ImportResult } from "../models/domain/importResult";
2019-09-11 23:05:29 +02:00
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
export class BlackBerryCsvImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
2019-09-11 23:05:29 +02:00
const result = new ImportResult();
const results = this.parseCsv(data, true);
if (results == null) {
result.success = false;
return Promise.resolve(result);
2019-09-11 23:05:29 +02:00
}
results.forEach((value) => {
2019-09-11 23:05:29 +02:00
if (value.grouping === "list") {
return;
}
const cipher = this.initLoginCipher();
cipher.favorite = value.fav === "1";
cipher.name = this.getValueOrDefault(value.name);
cipher.notes = this.getValueOrDefault(value.extra);
if (value.grouping !== "note") {
cipher.login.uris = this.makeUriArray(value.url);
cipher.login.password = this.getValueOrDefault(value.password);
cipher.login.username = this.getValueOrDefault(value.username);
}
this.convertToNoteIfNeeded(cipher);
this.cleanupCipher(cipher);
result.ciphers.push(cipher);
});
result.success = true;
return Promise.resolve(result);
2019-09-11 23:05:29 +02:00
}
}