mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-06 09:20:43 +01:00
roboform csv importer
This commit is contained in:
parent
1660d7570b
commit
4d702f4de3
44
src/importers/roboformCsvImporter.ts
Normal file
44
src/importers/roboformCsvImporter.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import { BaseImporter } from './baseImporter';
|
||||||
|
import { Importer } from './importer';
|
||||||
|
|
||||||
|
import { ImportResult } from '../models/domain/importResult';
|
||||||
|
|
||||||
|
export class RoboFormCsvImporter extends BaseImporter implements Importer {
|
||||||
|
parse(data: string): ImportResult {
|
||||||
|
const result = new ImportResult();
|
||||||
|
const results = this.parseCsv(data, true);
|
||||||
|
if (results == null) {
|
||||||
|
result.success = false;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
let i = 1;
|
||||||
|
results.forEach((value) => {
|
||||||
|
const folder = !this.isNullOrWhitespace(value.Folder) && value.Folder.startsWith('/') ?
|
||||||
|
value.Folder.replace('/', '') : value.Folder;
|
||||||
|
const folderName = !this.isNullOrWhitespace(folder) ? folder.split('/').join(' > ') : null;
|
||||||
|
this.processFolder(result, folderName);
|
||||||
|
|
||||||
|
const cipher = this.initLoginCipher();
|
||||||
|
cipher.notes = this.getValueOrDefault(value.Note);
|
||||||
|
cipher.name = this.getValueOrDefault(value.Name, '--');
|
||||||
|
cipher.login.username = this.getValueOrDefault(value.Login);
|
||||||
|
cipher.login.password = this.getValueOrDefault(value.Pwd);
|
||||||
|
cipher.login.uris = this.makeUriArray(value.Url);
|
||||||
|
this.cleanupCipher(cipher);
|
||||||
|
|
||||||
|
if (i === results.length && cipher.name === '--' && this.isNullOrWhitespace(cipher.login.password)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
result.ciphers.push(cipher);
|
||||||
|
i++;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (this.organization) {
|
||||||
|
this.moveFoldersToCollections(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
result.success = true;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user