mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-24 16:49:26 +01:00
passkeep csv importer
This commit is contained in:
parent
06682e2672
commit
e5d060c80b
39
src/importers/passkeepCsvImporter.ts
Normal file
39
src/importers/passkeepCsvImporter.ts
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import { BaseImporter } from './baseImporter';
|
||||||
|
import { Importer } from './importer';
|
||||||
|
|
||||||
|
import { ImportResult } from '../models/domain/importResult';
|
||||||
|
|
||||||
|
export class PassKeepCsvImporter 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
results.forEach((value) => {
|
||||||
|
this.processFolder(result, this.getValue('category', value));
|
||||||
|
const cipher = this.initLoginCipher();
|
||||||
|
cipher.notes = this.getValue('description', value);
|
||||||
|
cipher.name = this.getValueOrDefault(this.getValue('title', value), '--');
|
||||||
|
cipher.login.username = this.getValue('username', value);
|
||||||
|
cipher.login.password = this.getValue('password', value);
|
||||||
|
cipher.login.uris = this.makeUriArray(this.getValue('site', value));
|
||||||
|
this.processKvp(cipher, 'Password 2', this.getValue('password2', value));
|
||||||
|
this.cleanupCipher(cipher);
|
||||||
|
result.ciphers.push(cipher);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (this.organization) {
|
||||||
|
this.moveFoldersToCollections(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
result.success = true;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private getValue(key: string, value: any) {
|
||||||
|
return this.getValueOrDefault(value[key], this.getValueOrDefault(value[(' ' + key)]));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user