mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-27 12:36:14 +01:00
codebook csv importer
This commit is contained in:
parent
57e49207e9
commit
05c36b300d
46
src/importers/codebookCsvImporter.ts
Normal file
46
src/importers/codebookCsvImporter.ts
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import { BaseImporter } from './baseImporter';
|
||||||
|
import { Importer } from './importer';
|
||||||
|
|
||||||
|
import { ImportResult } from '../models/domain/importResult';
|
||||||
|
|
||||||
|
export class CodebookCsvImporter 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.getValueOrDefault(value.Category));
|
||||||
|
|
||||||
|
const cipher = this.initLoginCipher();
|
||||||
|
cipher.favorite = this.getValueOrDefault(value.Favorite) === 'True';
|
||||||
|
cipher.name = this.getValueOrDefault(value.Entry, '--');
|
||||||
|
cipher.notes = this.getValueOrDefault(value.Note);
|
||||||
|
cipher.login.username = this.getValueOrDefault(value.Username, value.Email);
|
||||||
|
cipher.login.password = this.getValueOrDefault(value.Password);
|
||||||
|
cipher.login.totp = this.getValueOrDefault(value.TOTP);
|
||||||
|
cipher.login.uris = this.makeUriArray(value.Website);
|
||||||
|
|
||||||
|
if (!this.isNullOrWhitespace(value.Username)) {
|
||||||
|
this.processKvp(cipher, 'Email', value.Email);
|
||||||
|
}
|
||||||
|
this.processKvp(cipher, 'Phone', value.Phone);
|
||||||
|
this.processKvp(cipher, 'PIN', value.PIN);
|
||||||
|
this.processKvp(cipher, 'Account', value.Account);
|
||||||
|
this.processKvp(cipher, 'Date', value.Date);
|
||||||
|
|
||||||
|
this.cleanupCipher(cipher);
|
||||||
|
result.ciphers.push(cipher);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (this.organization) {
|
||||||
|
this.moveFoldersToCollections(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
result.success = true;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
@ -33,6 +33,7 @@ import { BlurCsvImporter } from '../importers/blurCsvImporter';
|
|||||||
import { ButtercupCsvImporter } from '../importers/buttercupCsvImporter';
|
import { ButtercupCsvImporter } from '../importers/buttercupCsvImporter';
|
||||||
import { ChromeCsvImporter } from '../importers/chromeCsvImporter';
|
import { ChromeCsvImporter } from '../importers/chromeCsvImporter';
|
||||||
import { ClipperzHtmlImporter } from '../importers/clipperzHtmlImporter';
|
import { ClipperzHtmlImporter } from '../importers/clipperzHtmlImporter';
|
||||||
|
import { CodebookCsvImporter } from '../importers/codebookCsvImporter';
|
||||||
import { DashlaneJsonImporter } from '../importers/dashlaneJsonImporter';
|
import { DashlaneJsonImporter } from '../importers/dashlaneJsonImporter';
|
||||||
import { EnpassCsvImporter } from '../importers/enpassCsvImporter';
|
import { EnpassCsvImporter } from '../importers/enpassCsvImporter';
|
||||||
import { EnpassJsonImporter } from '../importers/enpassJsonImporter';
|
import { EnpassJsonImporter } from '../importers/enpassJsonImporter';
|
||||||
@ -125,6 +126,7 @@ export class ImportService implements ImportServiceAbstraction {
|
|||||||
{ id: 'logmeoncecsv', name: 'LogMeOnce (csv)' },
|
{ id: 'logmeoncecsv', name: 'LogMeOnce (csv)' },
|
||||||
{ id: 'blackberrycsv', name: 'BlackBerry Password Keeper (csv)' },
|
{ id: 'blackberrycsv', name: 'BlackBerry Password Keeper (csv)' },
|
||||||
{ id: 'buttercupcsv', name: 'Buttercup (csv)' },
|
{ id: 'buttercupcsv', name: 'Buttercup (csv)' },
|
||||||
|
{ id: 'codebookcsv', name: 'Codebook (csv)' },
|
||||||
];
|
];
|
||||||
|
|
||||||
constructor(private cipherService: CipherService, private folderService: FolderService,
|
constructor(private cipherService: CipherService, private folderService: FolderService,
|
||||||
@ -267,6 +269,8 @@ export class ImportService implements ImportServiceAbstraction {
|
|||||||
return new BlackBerryCsvImporter();
|
return new BlackBerryCsvImporter();
|
||||||
case 'buttercupcsv':
|
case 'buttercupcsv':
|
||||||
return new ButtercupCsvImporter();
|
return new ButtercupCsvImporter();
|
||||||
|
case 'codebookcsv':
|
||||||
|
return new CodebookCsvImporter();
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user