mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-27 12:36:14 +01:00
feat: add an importer for Safari (CSV) (#512)
* feat(importers/safariCsvImporter): add the importer for Safari (CSV) * Revert changes to package-lock.json Co-authored-by: Thomas Rittson <trittson@bitwarden.com>
This commit is contained in:
parent
71f8ef601f
commit
257de6517c
29
common/src/importers/safariCsvImporter.ts
Normal file
29
common/src/importers/safariCsvImporter.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { BaseImporter } from './baseImporter';
|
||||
import { Importer } from './importer';
|
||||
|
||||
import { ImportResult } from '../models/domain/importResult';
|
||||
|
||||
export class SafariCsvImporter extends BaseImporter implements Importer {
|
||||
parse(data: string): Promise<ImportResult> {
|
||||
const result = new ImportResult();
|
||||
const results = this.parseCsv(data, true);
|
||||
if (results == null) {
|
||||
result.success = false;
|
||||
return Promise.resolve(result);
|
||||
}
|
||||
|
||||
results.forEach(value => {
|
||||
const cipher = this.initLoginCipher();
|
||||
cipher.name = this.getValueOrDefault(value.Title, '--');
|
||||
cipher.login.username = this.getValueOrDefault(value.Username);
|
||||
cipher.login.password = this.getValueOrDefault(value.Password);
|
||||
cipher.login.uris = this.makeUriArray(value.Url);
|
||||
cipher.login.totp = this.getValueOrDefault(value.OTPAuth);
|
||||
this.cleanupCipher(cipher);
|
||||
result.ciphers.push(cipher);
|
||||
});
|
||||
|
||||
result.success = true;
|
||||
return Promise.resolve(result);
|
||||
}
|
||||
}
|
@ -70,6 +70,7 @@ import { PasswordSafeXmlImporter } from '../importers/passwordSafeXmlImporter';
|
||||
import { PasswordWalletTxtImporter } from '../importers/passwordWalletTxtImporter';
|
||||
import { RememBearCsvImporter } from '../importers/rememBearCsvImporter';
|
||||
import { RoboFormCsvImporter } from '../importers/roboformCsvImporter';
|
||||
import { SafariCsvImporter } from '../importers/safariCsvImporter';
|
||||
import { SafeInCloudXmlImporter } from '../importers/safeInCloudXmlImporter';
|
||||
import { SaferPassCsvImporter } from '../importers/saferpassCsvImport';
|
||||
import { SecureSafeCsvImporter } from '../importers/secureSafeCsvImporter';
|
||||
@ -87,6 +88,7 @@ export class ImportService implements ImportServiceAbstraction {
|
||||
{ id: 'lastpasscsv', name: 'LastPass (csv)' },
|
||||
{ id: 'chromecsv', name: 'Chrome (csv)' },
|
||||
{ id: 'firefoxcsv', name: 'Firefox (csv)' },
|
||||
{ id: 'safaricsv', name: 'Safari (csv)' },
|
||||
{ id: 'keepass2xml', name: 'KeePass 2 (xml)' },
|
||||
{ id: '1password1pif', name: '1Password (1pif)' },
|
||||
{ id: 'dashlanejson', name: 'Dashlane (json)' },
|
||||
@ -226,6 +228,8 @@ export class ImportService implements ImportServiceAbstraction {
|
||||
return new UpmCsvImporter();
|
||||
case 'saferpasscsv':
|
||||
return new SaferPassCsvImporter();
|
||||
case 'safaricsv':
|
||||
return new SafariCsvImporter();
|
||||
case 'meldiumcsv':
|
||||
return new MeldiumCsvImporter();
|
||||
case '1password1pif':
|
||||
|
Loading…
Reference in New Issue
Block a user