2018-08-06 15:37:56 +02:00
|
|
|
import { ApiService } from '../abstractions/api.service';
|
|
|
|
import { CipherService } from '../abstractions/cipher.service';
|
2018-08-06 17:39:55 +02:00
|
|
|
import { CollectionService } from '../abstractions/collection.service';
|
2018-08-06 15:37:56 +02:00
|
|
|
import { FolderService } from '../abstractions/folder.service';
|
|
|
|
import { I18nService } from '../abstractions/i18n.service';
|
|
|
|
import {
|
2018-08-06 16:37:57 +02:00
|
|
|
ImportOption,
|
2018-08-06 15:37:56 +02:00
|
|
|
ImportService as ImportServiceAbstraction,
|
|
|
|
} from '../abstractions/import.service';
|
|
|
|
|
|
|
|
import { ImportResult } from '../models/domain/importResult';
|
|
|
|
|
2019-01-25 15:30:21 +01:00
|
|
|
import { CipherType } from '../enums/cipherType';
|
|
|
|
|
|
|
|
import { Utils } from '../misc/utils';
|
|
|
|
|
2018-08-06 15:37:56 +02:00
|
|
|
import { CipherRequest } from '../models/request/cipherRequest';
|
2018-08-06 17:39:55 +02:00
|
|
|
import { CollectionRequest } from '../models/request/collectionRequest';
|
2018-08-06 15:37:56 +02:00
|
|
|
import { FolderRequest } from '../models/request/folderRequest';
|
|
|
|
import { ImportCiphersRequest } from '../models/request/importCiphersRequest';
|
2018-08-06 17:39:55 +02:00
|
|
|
import { ImportOrganizationCiphersRequest } from '../models/request/importOrganizationCiphersRequest';
|
2018-08-06 15:37:56 +02:00
|
|
|
import { KvpRequest } from '../models/request/kvpRequest';
|
|
|
|
|
|
|
|
import { CipherView } from '../models/view/cipherView';
|
|
|
|
|
|
|
|
import { AscendoCsvImporter } from '../importers/ascendoCsvImporter';
|
2018-12-31 18:39:59 +01:00
|
|
|
import { AvastCsvImporter } from '../importers/avastCsvImporter';
|
2019-12-20 19:29:56 +01:00
|
|
|
import { AvastJsonImporter } from '../importers/avastJsonImporter';
|
2018-08-06 15:37:56 +02:00
|
|
|
import { AviraCsvImporter } from '../importers/aviraCsvImporter';
|
|
|
|
import { BitwardenCsvImporter } from '../importers/bitwardenCsvImporter';
|
2018-12-17 19:21:06 +01:00
|
|
|
import { BitwardenJsonImporter } from '../importers/bitwardenJsonImporter';
|
2019-09-11 23:05:29 +02:00
|
|
|
import { BlackBerryCsvImporter } from '../importers/blackBerryCsvImporter';
|
2018-08-06 15:37:56 +02:00
|
|
|
import { BlurCsvImporter } from '../importers/blurCsvImporter';
|
2019-10-04 16:11:26 +02:00
|
|
|
import { ButtercupCsvImporter } from '../importers/buttercupCsvImporter';
|
2018-08-06 15:37:56 +02:00
|
|
|
import { ChromeCsvImporter } from '../importers/chromeCsvImporter';
|
|
|
|
import { ClipperzHtmlImporter } from '../importers/clipperzHtmlImporter';
|
2019-11-25 22:10:51 +01:00
|
|
|
import { CodebookCsvImporter } from '../importers/codebookCsvImporter';
|
2018-12-12 23:06:13 +01:00
|
|
|
import { DashlaneJsonImporter } from '../importers/dashlaneJsonImporter';
|
2020-02-19 20:51:46 +01:00
|
|
|
import { EncryptrCsvImporter } from '../importers/encryptrCsvImporter';
|
2018-08-06 15:37:56 +02:00
|
|
|
import { EnpassCsvImporter } from '../importers/enpassCsvImporter';
|
2018-12-13 20:34:37 +01:00
|
|
|
import { EnpassJsonImporter } from '../importers/enpassJsonImporter';
|
2018-08-06 15:37:56 +02:00
|
|
|
import { FirefoxCsvImporter } from '../importers/firefoxCsvImporter';
|
2019-01-03 15:58:37 +01:00
|
|
|
import { FSecureFskImporter } from '../importers/fsecureFskImporter';
|
2018-08-06 15:37:56 +02:00
|
|
|
import { GnomeJsonImporter } from '../importers/gnomeJsonImporter';
|
|
|
|
import { Importer } from '../importers/importer';
|
2019-01-28 15:20:51 +01:00
|
|
|
import { KasperskyTxtImporter } from '../importers/kasperskyTxtImporter';
|
2018-08-06 15:37:56 +02:00
|
|
|
import { KeePass2XmlImporter } from '../importers/keepass2XmlImporter';
|
|
|
|
import { KeePassXCsvImporter } from '../importers/keepassxCsvImporter';
|
|
|
|
import { KeeperCsvImporter } from '../importers/keeperCsvImporter';
|
|
|
|
import { LastPassCsvImporter } from '../importers/lastpassCsvImporter';
|
2019-08-26 16:06:20 +02:00
|
|
|
import { LogMeOnceCsvImporter } from '../importers/logMeOnceCsvImporter';
|
2018-08-06 15:37:56 +02:00
|
|
|
import { MeldiumCsvImporter } from '../importers/meldiumCsvImporter';
|
|
|
|
import { MSecureCsvImporter } from '../importers/msecureCsvImporter';
|
2019-06-29 05:17:13 +02:00
|
|
|
import { MykiCsvImporter } from '../importers/mykiCsvImporter';
|
2018-08-06 15:37:56 +02:00
|
|
|
import { OnePassword1PifImporter } from '../importers/onepassword1PifImporter';
|
|
|
|
import { OnePasswordWinCsvImporter } from '../importers/onepasswordWinCsvImporter';
|
|
|
|
import { PadlockCsvImporter } from '../importers/padlockCsvImporter';
|
|
|
|
import { PassKeepCsvImporter } from '../importers/passkeepCsvImporter';
|
2018-10-08 21:41:32 +02:00
|
|
|
import { PassmanJsonImporter } from '../importers/passmanJsonImporter';
|
2018-10-08 23:54:54 +02:00
|
|
|
import { PasspackCsvImporter } from '../importers/passpackCsvImporter';
|
2018-08-06 15:37:56 +02:00
|
|
|
import { PasswordAgentCsvImporter } from '../importers/passwordAgentCsvImporter';
|
|
|
|
import { PasswordBossJsonImporter } from '../importers/passwordBossJsonImporter';
|
|
|
|
import { PasswordDragonXmlImporter } from '../importers/passwordDragonXmlImporter';
|
|
|
|
import { PasswordSafeXmlImporter } from '../importers/passwordSafeXmlImporter';
|
2019-04-27 02:51:53 +02:00
|
|
|
import { PasswordWalletTxtImporter } from '../importers/passwordWalletTxtImporter';
|
2019-02-13 21:32:25 +01:00
|
|
|
import { RememBearCsvImporter } from '../importers/rememBearCsvImporter';
|
2018-08-06 15:37:56 +02:00
|
|
|
import { RoboFormCsvImporter } from '../importers/roboformCsvImporter';
|
|
|
|
import { SafeInCloudXmlImporter } from '../importers/safeInCloudXmlImporter';
|
|
|
|
import { SaferPassCsvImporter } from '../importers/saferpassCsvImport';
|
2019-08-22 05:13:08 +02:00
|
|
|
import { SecureSafeCsvImporter } from '../importers/secureSafeCsvImporter';
|
2018-08-06 15:37:56 +02:00
|
|
|
import { SplashIdCsvImporter } from '../importers/splashIdCsvImporter';
|
|
|
|
import { StickyPasswordXmlImporter } from '../importers/stickyPasswordXmlImporter';
|
|
|
|
import { TrueKeyCsvImporter } from '../importers/truekeyCsvImporter';
|
|
|
|
import { UpmCsvImporter } from '../importers/upmCsvImporter';
|
2020-08-24 18:21:17 +02:00
|
|
|
import { YotiCsvImporter } from '../importers/yotiCsvImporter';
|
2018-08-06 15:37:56 +02:00
|
|
|
import { ZohoVaultCsvImporter } from '../importers/zohoVaultCsvImporter';
|
|
|
|
|
|
|
|
export class ImportService implements ImportServiceAbstraction {
|
2018-08-06 17:39:55 +02:00
|
|
|
featuredImportOptions = [
|
2018-12-17 19:21:06 +01:00
|
|
|
{ id: 'bitwardenjson', name: 'Bitwarden (json)' },
|
2018-08-06 15:37:56 +02:00
|
|
|
{ id: 'bitwardencsv', name: 'Bitwarden (csv)' },
|
|
|
|
{ id: 'lastpasscsv', name: 'LastPass (csv)' },
|
|
|
|
{ id: 'chromecsv', name: 'Chrome (csv)' },
|
|
|
|
{ id: 'firefoxcsv', name: 'Firefox (csv)' },
|
|
|
|
{ id: 'keepass2xml', name: 'KeePass 2 (xml)' },
|
|
|
|
{ id: '1password1pif', name: '1Password (1pif)' },
|
2018-12-12 23:06:13 +01:00
|
|
|
{ id: 'dashlanejson', name: 'Dashlane (json)' },
|
2018-08-06 17:39:55 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
regularImportOptions: ImportOption[] = [
|
2018-08-06 15:37:56 +02:00
|
|
|
{ id: 'keepassxcsv', name: 'KeePassX (csv)' },
|
|
|
|
{ id: '1passwordwincsv', name: '1Password 6 and 7 Windows (csv)' },
|
|
|
|
{ id: 'roboformcsv', name: 'RoboForm (csv)' },
|
|
|
|
{ id: 'keepercsv', name: 'Keeper (csv)' },
|
|
|
|
{ id: 'enpasscsv', name: 'Enpass (csv)' },
|
2018-12-13 20:34:37 +01:00
|
|
|
{ id: 'enpassjson', name: 'Enpass (json)' },
|
2018-08-06 15:37:56 +02:00
|
|
|
{ id: 'safeincloudxml', name: 'SafeInCloud (xml)' },
|
|
|
|
{ id: 'pwsafexml', name: 'Password Safe (xml)' },
|
|
|
|
{ id: 'stickypasswordxml', name: 'Sticky Password (xml)' },
|
|
|
|
{ id: 'msecurecsv', name: 'mSecure (csv)' },
|
|
|
|
{ id: 'truekeycsv', name: 'True Key (csv)' },
|
|
|
|
{ id: 'passwordbossjson', name: 'Password Boss (json)' },
|
|
|
|
{ id: 'zohovaultcsv', name: 'Zoho Vault (csv)' },
|
|
|
|
{ id: 'splashidcsv', name: 'SplashID (csv)' },
|
|
|
|
{ id: 'passworddragonxml', name: 'Password Dragon (xml)' },
|
|
|
|
{ id: 'padlockcsv', name: 'Padlock (csv)' },
|
|
|
|
{ id: 'passboltcsv', name: 'Passbolt (csv)' },
|
|
|
|
{ id: 'clipperzhtml', name: 'Clipperz (html)' },
|
|
|
|
{ id: 'aviracsv', name: 'Avira (csv)' },
|
|
|
|
{ id: 'saferpasscsv', name: 'SaferPass (csv)' },
|
|
|
|
{ id: 'upmcsv', name: 'Universal Password Manager (csv)' },
|
|
|
|
{ id: 'ascendocsv', name: 'Ascendo DataVault (csv)' },
|
|
|
|
{ id: 'meldiumcsv', name: 'Meldium (csv)' },
|
|
|
|
{ id: 'passkeepcsv', name: 'PassKeep (csv)' },
|
2018-08-06 17:39:55 +02:00
|
|
|
{ id: 'operacsv', name: 'Opera (csv)' },
|
|
|
|
{ id: 'vivaldicsv', name: 'Vivaldi (csv)' },
|
|
|
|
{ id: 'gnomejson', name: 'GNOME Passwords and Keys/Seahorse (json)' },
|
|
|
|
{ id: 'blurcsv', name: 'Blur (csv)' },
|
|
|
|
{ id: 'passwordagentcsv', name: 'Password Agent (csv)' },
|
2018-09-21 19:54:06 +02:00
|
|
|
{ id: 'passpackcsv', name: 'Passpack (csv)' },
|
2018-10-08 21:41:32 +02:00
|
|
|
{ id: 'passmanjson', name: 'Passman (json)' },
|
2018-12-31 18:39:59 +01:00
|
|
|
{ id: 'avastcsv', name: 'Avast Passwords (csv)' },
|
2019-12-20 19:29:56 +01:00
|
|
|
{ id: 'avastjson', name: 'Avast Passwords (json)' },
|
2019-01-03 15:58:37 +01:00
|
|
|
{ id: 'fsecurefsk', name: 'F-Secure KEY (fsk)' },
|
2019-01-28 15:20:51 +01:00
|
|
|
{ id: 'kasperskytxt', name: 'Kaspersky Password Manager (txt)' },
|
2019-02-13 21:32:25 +01:00
|
|
|
{ id: 'remembearcsv', name: 'RememBear (csv)' },
|
2019-04-27 02:51:53 +02:00
|
|
|
{ id: 'passwordwallettxt', name: 'PasswordWallet (txt)' },
|
2019-06-29 05:17:13 +02:00
|
|
|
{ id: 'mykicsv', name: 'Myki (csv)' },
|
2019-08-22 05:13:08 +02:00
|
|
|
{ id: 'securesafecsv', name: 'SecureSafe (csv)' },
|
2019-08-26 16:06:20 +02:00
|
|
|
{ id: 'logmeoncecsv', name: 'LogMeOnce (csv)' },
|
2019-09-11 23:05:29 +02:00
|
|
|
{ id: 'blackberrycsv', name: 'BlackBerry Password Keeper (csv)' },
|
2019-10-04 16:11:26 +02:00
|
|
|
{ id: 'buttercupcsv', name: 'Buttercup (csv)' },
|
2019-11-25 22:10:51 +01:00
|
|
|
{ id: 'codebookcsv', name: 'Codebook (csv)' },
|
2020-02-19 20:51:46 +01:00
|
|
|
{ id: 'encryptrcsv', name: 'Encryptr (csv)' },
|
2020-08-24 18:21:17 +02:00
|
|
|
{ id: 'yoticsv', name: 'Yoti (csv)' },
|
2018-08-06 15:37:56 +02:00
|
|
|
];
|
|
|
|
|
2018-08-06 17:39:55 +02:00
|
|
|
constructor(private cipherService: CipherService, private folderService: FolderService,
|
|
|
|
private apiService: ApiService, private i18nService: I18nService,
|
|
|
|
private collectionService: CollectionService) { }
|
2018-08-06 15:37:56 +02:00
|
|
|
|
2018-08-06 17:39:55 +02:00
|
|
|
getImportOptions(): ImportOption[] {
|
|
|
|
return this.featuredImportOptions.concat(this.regularImportOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
async import(importer: Importer, fileContents: string, organizationId: string = null): Promise<Error> {
|
2018-08-06 15:37:56 +02:00
|
|
|
const importResult = await importer.parse(fileContents);
|
|
|
|
if (importResult.success) {
|
|
|
|
if (importResult.folders.length === 0 && importResult.ciphers.length === 0) {
|
2018-08-06 17:39:55 +02:00
|
|
|
return new Error(this.i18nService.t('importNothingError'));
|
2018-08-06 15:37:56 +02:00
|
|
|
} else if (importResult.ciphers.length > 0) {
|
|
|
|
const halfway = Math.floor(importResult.ciphers.length / 2);
|
|
|
|
const last = importResult.ciphers.length - 1;
|
|
|
|
|
|
|
|
if (this.badData(importResult.ciphers[0]) &&
|
|
|
|
this.badData(importResult.ciphers[halfway]) &&
|
|
|
|
this.badData(importResult.ciphers[last])) {
|
2018-08-06 17:39:55 +02:00
|
|
|
return new Error(this.i18nService.t('importFormatError'));
|
2018-08-06 15:37:56 +02:00
|
|
|
}
|
|
|
|
}
|
2018-08-06 17:39:55 +02:00
|
|
|
await this.postImport(importResult, organizationId);
|
|
|
|
return null;
|
2018-08-06 15:37:56 +02:00
|
|
|
} else {
|
2018-08-06 17:39:55 +02:00
|
|
|
return new Error(this.i18nService.t('importFormatError'));
|
2018-08-06 15:37:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-05 03:05:11 +01:00
|
|
|
getImporter(format: string, organizationId: string = null): Importer {
|
2018-08-06 17:39:55 +02:00
|
|
|
const importer = this.getImporterInstance(format);
|
|
|
|
if (importer == null) {
|
|
|
|
return null;
|
|
|
|
}
|
2020-12-05 03:05:11 +01:00
|
|
|
importer.organizationId = organizationId;
|
2018-08-06 17:39:55 +02:00
|
|
|
return importer;
|
|
|
|
}
|
|
|
|
|
|
|
|
private getImporterInstance(format: string) {
|
2018-08-06 15:37:56 +02:00
|
|
|
if (format == null || format === '') {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (format) {
|
|
|
|
case 'bitwardencsv':
|
|
|
|
return new BitwardenCsvImporter();
|
2018-12-17 19:21:06 +01:00
|
|
|
case 'bitwardenjson':
|
|
|
|
return new BitwardenJsonImporter();
|
2018-08-06 15:37:56 +02:00
|
|
|
case 'lastpasscsv':
|
|
|
|
case 'passboltcsv':
|
|
|
|
return new LastPassCsvImporter();
|
|
|
|
case 'keepassxcsv':
|
|
|
|
return new KeePassXCsvImporter();
|
|
|
|
case 'aviracsv':
|
|
|
|
return new AviraCsvImporter();
|
|
|
|
case 'blurcsv':
|
|
|
|
return new BlurCsvImporter();
|
|
|
|
case 'safeincloudxml':
|
|
|
|
return new SafeInCloudXmlImporter();
|
|
|
|
case 'padlockcsv':
|
|
|
|
return new PadlockCsvImporter();
|
|
|
|
case 'keepass2xml':
|
|
|
|
return new KeePass2XmlImporter();
|
|
|
|
case 'chromecsv':
|
|
|
|
case 'operacsv':
|
|
|
|
case 'vivaldicsv':
|
|
|
|
return new ChromeCsvImporter();
|
|
|
|
case 'firefoxcsv':
|
|
|
|
return new FirefoxCsvImporter();
|
|
|
|
case 'upmcsv':
|
|
|
|
return new UpmCsvImporter();
|
|
|
|
case 'saferpasscsv':
|
|
|
|
return new SaferPassCsvImporter();
|
|
|
|
case 'meldiumcsv':
|
|
|
|
return new MeldiumCsvImporter();
|
|
|
|
case '1password1pif':
|
|
|
|
return new OnePassword1PifImporter();
|
|
|
|
case '1passwordwincsv':
|
|
|
|
return new OnePasswordWinCsvImporter();
|
|
|
|
case 'keepercsv':
|
|
|
|
return new KeeperCsvImporter();
|
|
|
|
case 'passworddragonxml':
|
|
|
|
return new PasswordDragonXmlImporter();
|
|
|
|
case 'enpasscsv':
|
|
|
|
return new EnpassCsvImporter();
|
2018-12-13 20:34:37 +01:00
|
|
|
case 'enpassjson':
|
|
|
|
return new EnpassJsonImporter();
|
2018-08-06 15:37:56 +02:00
|
|
|
case 'pwsafexml':
|
|
|
|
return new PasswordSafeXmlImporter();
|
2018-12-12 23:06:13 +01:00
|
|
|
case 'dashlanejson':
|
|
|
|
return new DashlaneJsonImporter();
|
2018-08-06 15:37:56 +02:00
|
|
|
case 'msecurecsv':
|
|
|
|
return new MSecureCsvImporter();
|
|
|
|
case 'stickypasswordxml':
|
|
|
|
return new StickyPasswordXmlImporter();
|
|
|
|
case 'truekeycsv':
|
|
|
|
return new TrueKeyCsvImporter();
|
|
|
|
case 'clipperzhtml':
|
|
|
|
return new ClipperzHtmlImporter();
|
|
|
|
case 'roboformcsv':
|
|
|
|
return new RoboFormCsvImporter();
|
|
|
|
case 'ascendocsv':
|
|
|
|
return new AscendoCsvImporter();
|
|
|
|
case 'passwordbossjson':
|
|
|
|
return new PasswordBossJsonImporter();
|
|
|
|
case 'zohovaultcsv':
|
|
|
|
return new ZohoVaultCsvImporter();
|
|
|
|
case 'splashidcsv':
|
|
|
|
return new SplashIdCsvImporter();
|
|
|
|
case 'passkeepcsv':
|
|
|
|
return new PassKeepCsvImporter();
|
|
|
|
case 'gnomejson':
|
|
|
|
return new GnomeJsonImporter();
|
|
|
|
case 'passwordagentcsv':
|
|
|
|
return new PasswordAgentCsvImporter();
|
2018-09-21 19:54:06 +02:00
|
|
|
case 'passpackcsv':
|
|
|
|
return new PasspackCsvImporter();
|
2018-10-08 21:41:32 +02:00
|
|
|
case 'passmanjson':
|
|
|
|
return new PassmanJsonImporter();
|
2018-12-31 18:39:59 +01:00
|
|
|
case 'avastcsv':
|
|
|
|
return new AvastCsvImporter();
|
2019-12-20 19:29:56 +01:00
|
|
|
case 'avastjson':
|
|
|
|
return new AvastJsonImporter();
|
2019-01-03 15:58:37 +01:00
|
|
|
case 'fsecurefsk':
|
|
|
|
return new FSecureFskImporter();
|
2019-01-28 15:20:51 +01:00
|
|
|
case 'kasperskytxt':
|
|
|
|
return new KasperskyTxtImporter();
|
2019-02-13 21:32:25 +01:00
|
|
|
case 'remembearcsv':
|
|
|
|
return new RememBearCsvImporter();
|
2019-04-27 02:51:53 +02:00
|
|
|
case 'passwordwallettxt':
|
|
|
|
return new PasswordWalletTxtImporter();
|
2019-06-29 05:17:13 +02:00
|
|
|
case 'mykicsv':
|
|
|
|
return new MykiCsvImporter();
|
2019-08-22 05:13:08 +02:00
|
|
|
case 'securesafecsv':
|
|
|
|
return new SecureSafeCsvImporter();
|
2019-08-26 16:06:20 +02:00
|
|
|
case 'logmeoncecsv':
|
|
|
|
return new LogMeOnceCsvImporter();
|
2019-09-11 23:05:29 +02:00
|
|
|
case 'blackberrycsv':
|
|
|
|
return new BlackBerryCsvImporter();
|
2019-10-04 16:11:26 +02:00
|
|
|
case 'buttercupcsv':
|
|
|
|
return new ButtercupCsvImporter();
|
2019-11-25 22:10:51 +01:00
|
|
|
case 'codebookcsv':
|
|
|
|
return new CodebookCsvImporter();
|
2020-02-19 20:51:46 +01:00
|
|
|
case 'encryptrcsv':
|
|
|
|
return new EncryptrCsvImporter();
|
2020-08-24 18:21:17 +02:00
|
|
|
case 'yoticsv':
|
|
|
|
return new YotiCsvImporter();
|
2018-08-06 15:37:56 +02:00
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-06 17:39:55 +02:00
|
|
|
private async postImport(importResult: ImportResult, organizationId: string = null) {
|
|
|
|
if (organizationId == null) {
|
|
|
|
const request = new ImportCiphersRequest();
|
|
|
|
for (let i = 0; i < importResult.ciphers.length; i++) {
|
|
|
|
const c = await this.cipherService.encrypt(importResult.ciphers[i]);
|
|
|
|
request.ciphers.push(new CipherRequest(c));
|
2018-08-06 15:37:56 +02:00
|
|
|
}
|
2018-08-06 17:39:55 +02:00
|
|
|
if (importResult.folders != null) {
|
|
|
|
for (let i = 0; i < importResult.folders.length; i++) {
|
|
|
|
const f = await this.folderService.encrypt(importResult.folders[i]);
|
|
|
|
request.folders.push(new FolderRequest(f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (importResult.folderRelationships != null) {
|
|
|
|
importResult.folderRelationships.forEach((r) =>
|
|
|
|
request.folderRelationships.push(new KvpRequest(r[0], r[1])));
|
|
|
|
}
|
|
|
|
return await this.apiService.postImportCiphers(request);
|
|
|
|
} else {
|
|
|
|
const request = new ImportOrganizationCiphersRequest();
|
|
|
|
for (let i = 0; i < importResult.ciphers.length; i++) {
|
|
|
|
importResult.ciphers[i].organizationId = organizationId;
|
|
|
|
const c = await this.cipherService.encrypt(importResult.ciphers[i]);
|
|
|
|
request.ciphers.push(new CipherRequest(c));
|
|
|
|
}
|
|
|
|
if (importResult.collections != null) {
|
|
|
|
for (let i = 0; i < importResult.collections.length; i++) {
|
|
|
|
importResult.collections[i].organizationId = organizationId;
|
|
|
|
const c = await this.collectionService.encrypt(importResult.collections[i]);
|
|
|
|
request.collections.push(new CollectionRequest(c));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (importResult.collectionRelationships != null) {
|
|
|
|
importResult.collectionRelationships.forEach((r) =>
|
|
|
|
request.collectionRelationships.push(new KvpRequest(r[0], r[1])));
|
|
|
|
}
|
|
|
|
return await this.apiService.postImportOrganizationCiphers(organizationId, request);
|
2018-08-06 15:37:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private badData(c: CipherView) {
|
|
|
|
return (c.name == null || c.name === '--') &&
|
2019-01-25 15:30:21 +01:00
|
|
|
(c.type === CipherType.Login && c.login != null && Utils.isNullOrWhitespace(c.login.password));
|
2018-08-06 15:37:56 +02:00
|
|
|
}
|
|
|
|
}
|