bitwarden-estensione-browser/src/importers/secureSafeCsvImporter.ts

30 lines
1.1 KiB
TypeScript
Raw Normal View History

2019-08-22 05:13:08 +02:00
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { ImportResult } from '../models/domain/importResult';
export class SecureSafeCsvImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
2019-08-22 05:13:08 +02:00
const result = new ImportResult();
const results = this.parseCsv(data, true);
if (results == null) {
result.success = false;
return Promise.resolve(result);
2019-08-22 05:13:08 +02:00
}
results.forEach((value) => {
const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value.Title);
cipher.notes = this.getValueOrDefault(value.Comment);
cipher.login.uris = this.makeUriArray(value.Url);
cipher.login.password = this.getValueOrDefault(value.Password);
cipher.login.username = this.getValueOrDefault(value.Username);
this.cleanupCipher(cipher);
result.ciphers.push(cipher);
});
result.success = true;
return Promise.resolve(result);
2019-08-22 05:13:08 +02:00
}
}