[PS-2320] Import API service refactor (#4529)

* Extract import methods from ApiService

Removed methods from ApiService impl and abstraction
Create import-api.service impl and abstraction
Moved import.service into abstractions/import/import.service.abstraction
Moved import.service into services/import/import.service
Change imports to use new services

* Fix import for tests

* Fix imports for CLI

* Fix imports for web

* Fix ModuleImports and dependencies

* Mark ImportApiService methods as async
This commit is contained in:
Daniel James Smith 2023-01-30 20:03:12 +01:00 committed by GitHub
parent 4584583691
commit b7d38f0f72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 155 additions and 127 deletions

View File

@ -5,6 +5,7 @@ import * as program from "commander";
import * as jsdom from "jsdom";
import { InternalFolderService } from "@bitwarden/common/abstractions/folder/folder.service.abstraction";
import { ImportApiServiceAbstraction } from "@bitwarden/common/abstractions/import/import-api.service.abstraction";
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
import { ClientType } from "@bitwarden/common/enums/clientType";
@ -27,7 +28,8 @@ import { ExportService } from "@bitwarden/common/services/export.service";
import { FileUploadService } from "@bitwarden/common/services/fileUpload.service";
import { FolderApiService } from "@bitwarden/common/services/folder/folder-api.service";
import { FolderService } from "@bitwarden/common/services/folder/folder.service";
import { ImportService } from "@bitwarden/common/services/import.service";
import { ImportApiService } from "@bitwarden/common/services/import/import-api.service";
import { ImportService } from "@bitwarden/common/services/import/import.service";
import { KeyConnectorService } from "@bitwarden/common/services/keyConnector.service";
import { MemoryStorageService } from "@bitwarden/common/services/memoryStorage.service";
import { NoopMessagingService } from "@bitwarden/common/services/noopMessaging.service";
@ -94,6 +96,7 @@ export class Main {
containerService: ContainerService;
auditService: AuditService;
importService: ImportService;
importApiService: ImportApiServiceAbstraction;
exportService: ExportService;
searchService: SearchService;
cryptoFunctionService: NodeCryptoFunctionService;
@ -339,10 +342,12 @@ export class Main {
this.totpService = new TotpService(this.cryptoFunctionService, this.logService);
this.importApiService = new ImportApiService(this.apiService);
this.importService = new ImportService(
this.cipherService,
this.folderService,
this.apiService,
this.importApiService,
this.i18nService,
this.collectionService,
this.cryptoService

View File

@ -1,7 +1,7 @@
import * as program from "commander";
import * as inquirer from "inquirer";
import { ImportService } from "@bitwarden/common/abstractions/import.service";
import { ImportService } from "@bitwarden/common/abstractions/import/import.service.abstraction";
import { OrganizationService } from "@bitwarden/common/abstractions/organization/organization.service.abstraction";
import { ImportType } from "@bitwarden/common/enums/importOptions";
import { Importer } from "@bitwarden/common/importers/importer";

View File

@ -6,8 +6,10 @@ import { CollectionService } from "@bitwarden/common/abstractions/collection.ser
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
import { FolderService } from "@bitwarden/common/abstractions/folder/folder.service.abstraction";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { ImportService as ImportServiceAbstraction } from "@bitwarden/common/abstractions/import.service";
import { ImportService } from "@bitwarden/common/services/import.service";
import { ImportApiServiceAbstraction } from "@bitwarden/common/abstractions/import/import-api.service.abstraction";
import { ImportService as ImportServiceAbstraction } from "@bitwarden/common/abstractions/import/import.service.abstraction";
import { ImportApiService } from "@bitwarden/common/services/import/import-api.service";
import { ImportService } from "@bitwarden/common/services/import/import.service";
import { LooseComponentsModule, SharedModule } from "../../../shared";
@ -19,13 +21,18 @@ import { OrganizationImportComponent } from "./org-import.component";
imports: [SharedModule, LooseComponentsModule, OrganizationImportExportRoutingModule],
declarations: [OrganizationImportComponent, OrganizationExportComponent],
providers: [
{
provide: ImportApiServiceAbstraction,
useClass: ImportApiService,
deps: [ApiService],
},
{
provide: ImportServiceAbstraction,
useClass: ImportService,
deps: [
CipherService,
FolderService,
ApiService,
ImportApiServiceAbstraction,
I18nService,
CollectionService,
CryptoService,

View File

@ -3,7 +3,7 @@ import { ActivatedRoute, Router } from "@angular/router";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { ImportService } from "@bitwarden/common/abstractions/import.service";
import { ImportService } from "@bitwarden/common/abstractions/import/import.service.abstraction";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { OrganizationService } from "@bitwarden/common/abstractions/organization/organization.service.abstraction";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";

View File

@ -6,8 +6,10 @@ import { CollectionService } from "@bitwarden/common/abstractions/collection.ser
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
import { FolderService } from "@bitwarden/common/abstractions/folder/folder.service.abstraction";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { ImportService as ImportServiceAbstraction } from "@bitwarden/common/abstractions/import.service";
import { ImportService } from "@bitwarden/common/services/import.service";
import { ImportApiServiceAbstraction } from "@bitwarden/common/abstractions/import/import-api.service.abstraction";
import { ImportService as ImportServiceAbstraction } from "@bitwarden/common/abstractions/import/import.service.abstraction";
import { ImportApiService } from "@bitwarden/common/services/import/import-api.service";
import { ImportService } from "@bitwarden/common/services/import/import.service";
import { LooseComponentsModule, SharedModule } from "../../shared";
@ -20,13 +22,18 @@ import { ImportComponent } from "./import.component";
imports: [SharedModule, LooseComponentsModule, ImportExportRoutingModule],
declarations: [ImportComponent, ExportComponent, FilePasswordPromptComponent],
providers: [
{
provide: ImportApiServiceAbstraction,
useClass: ImportApiService,
deps: [ApiService],
},
{
provide: ImportServiceAbstraction,
useClass: ImportService,
deps: [
CipherService,
FolderService,
ApiService,
ImportApiServiceAbstraction,
I18nService,
CollectionService,
CryptoService,

View File

@ -6,7 +6,7 @@ import Swal, { SweetAlertIcon } from "sweetalert2";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { ImportService } from "@bitwarden/common/abstractions/import.service";
import { ImportService } from "@bitwarden/common/abstractions/import/import.service.abstraction";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";

View File

@ -1,22 +1,22 @@
// eslint-disable-next-line no-restricted-imports
import { Substitute, SubstituteOf } from "@fluffy-spoon/substitute";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { CipherService } from "@bitwarden/common/abstractions/cipher.service";
import { CollectionService } from "@bitwarden/common/abstractions/collection.service";
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
import { FolderService } from "@bitwarden/common/abstractions/folder/folder.service.abstraction";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { ImportApiServiceAbstraction } from "@bitwarden/common/abstractions/import/import-api.service.abstraction";
import { BitwardenPasswordProtectedImporter } from "@bitwarden/common/importers/bitwarden-password-protected-importer";
import { Importer } from "@bitwarden/common/importers/importer";
import { Utils } from "@bitwarden/common/misc/utils";
import { ImportService } from "@bitwarden/common/services/import.service";
import { ImportService } from "@bitwarden/common/services/import/import.service";
describe("ImportService", () => {
let importService: ImportService;
let cipherService: SubstituteOf<CipherService>;
let folderService: SubstituteOf<FolderService>;
let apiService: SubstituteOf<ApiService>;
let importApiService: SubstituteOf<ImportApiServiceAbstraction>;
let i18nService: SubstituteOf<I18nService>;
let collectionService: SubstituteOf<CollectionService>;
let cryptoService: SubstituteOf<CryptoService>;
@ -24,7 +24,7 @@ describe("ImportService", () => {
beforeEach(() => {
cipherService = Substitute.for<CipherService>();
folderService = Substitute.for<FolderService>();
apiService = Substitute.for<ApiService>();
importApiService = Substitute.for<ImportApiServiceAbstraction>();
i18nService = Substitute.for<I18nService>();
collectionService = Substitute.for<CollectionService>();
cryptoService = Substitute.for<CryptoService>();
@ -32,7 +32,7 @@ describe("ImportService", () => {
importService = new ImportService(
cipherService,
folderService,
apiService,
importApiService,
i18nService,
collectionService,
cryptoService

View File

@ -27,8 +27,6 @@ import { IapCheckRequest } from "../models/request/iap-check.request";
import { PasswordTokenRequest } from "../models/request/identity-token/password-token.request";
import { SsoTokenRequest } from "../models/request/identity-token/sso-token.request";
import { UserApiTokenRequest } from "../models/request/identity-token/user-api-token.request";
import { ImportCiphersRequest } from "../models/request/import-ciphers.request";
import { ImportOrganizationCiphersRequest } from "../models/request/import-organization-ciphers.request";
import { KdfRequest } from "../models/request/kdf.request";
import { KeyConnectorUserKeyRequest } from "../models/request/key-connector-user-key.request";
import { KeysRequest } from "../models/request/keys.request";
@ -260,11 +258,6 @@ export abstract class ApiService {
putCipherCollections: (id: string, request: CipherCollectionsRequest) => Promise<any>;
putCipherCollectionsAdmin: (id: string, request: CipherCollectionsRequest) => Promise<any>;
postPurgeCiphers: (request: SecretVerificationRequest, organizationId?: string) => Promise<any>;
postImportCiphers: (request: ImportCiphersRequest) => Promise<any>;
postImportOrganizationCiphers: (
organizationId: string,
request: ImportOrganizationCiphersRequest
) => Promise<any>;
putDeleteCipher: (id: string) => Promise<any>;
putDeleteCipherAdmin: (id: string) => Promise<any>;
putDeleteManyCiphers: (request: CipherBulkDeleteRequest) => Promise<any>;

View File

@ -0,0 +1,10 @@
import { ImportCiphersRequest } from "../../models/request/import-ciphers.request";
import { ImportOrganizationCiphersRequest } from "../../models/request/import-organization-ciphers.request";
export abstract class ImportApiServiceAbstraction {
postImportCiphers: (request: ImportCiphersRequest) => Promise<any>;
postImportOrganizationCiphers: (
organizationId: string,
request: ImportOrganizationCiphersRequest
) => Promise<any>;
}

View File

@ -1,6 +1,6 @@
import { ImportOption, ImportType } from "../enums/importOptions";
import { ImportError } from "../importers/import-error";
import { Importer } from "../importers/importer";
import { ImportOption, ImportType } from "../../enums/importOptions";
import { ImportError } from "../../importers/import-error";
import { Importer } from "../../importers/importer";
export abstract class ImportService {
featuredImportOptions: readonly ImportOption[];

View File

@ -35,8 +35,6 @@ import { PasswordTokenRequest } from "../models/request/identity-token/password-
import { SsoTokenRequest } from "../models/request/identity-token/sso-token.request";
import { TokenTwoFactorRequest } from "../models/request/identity-token/token-two-factor.request";
import { UserApiTokenRequest } from "../models/request/identity-token/user-api-token.request";
import { ImportCiphersRequest } from "../models/request/import-ciphers.request";
import { ImportOrganizationCiphersRequest } from "../models/request/import-organization-ciphers.request";
import { KdfRequest } from "../models/request/kdf.request";
import { KeyConnectorUserKeyRequest } from "../models/request/key-connector-user-key.request";
import { KeysRequest } from "../models/request/keys.request";
@ -662,23 +660,6 @@ export class ApiService implements ApiServiceAbstraction {
return this.send("POST", path, request, true, false);
}
postImportCiphers(request: ImportCiphersRequest): Promise<any> {
return this.send("POST", "/ciphers/import", request, true, false);
}
postImportOrganizationCiphers(
organizationId: string,
request: ImportOrganizationCiphersRequest
): Promise<any> {
return this.send(
"POST",
"/ciphers/import-organization?organizationId=" + organizationId,
request,
true,
false
);
}
putDeleteCipher(id: string): Promise<any> {
return this.send("PUT", "/ciphers/" + id + "/delete", null, true, false);
}

View File

@ -0,0 +1,25 @@
import { ApiService } from "../../abstractions/api.service";
import { ImportApiServiceAbstraction } from "../../abstractions/import/import-api.service.abstraction";
import { ImportCiphersRequest } from "../../models/request/import-ciphers.request";
import { ImportOrganizationCiphersRequest } from "../../models/request/import-organization-ciphers.request";
export class ImportApiService implements ImportApiServiceAbstraction {
constructor(private apiService: ApiService) {}
async postImportCiphers(request: ImportCiphersRequest): Promise<any> {
return await this.apiService.send("POST", "/ciphers/import", request, true, false);
}
async postImportOrganizationCiphers(
organizationId: string,
request: ImportOrganizationCiphersRequest
): Promise<any> {
return await this.apiService.send(
"POST",
"/ciphers/import-organization?organizationId=" + organizationId,
request,
true,
false
);
}
}

View File

@ -1,87 +1,87 @@
import { ApiService } from "../abstractions/api.service";
import { CipherService } from "../abstractions/cipher.service";
import { CollectionService } from "../abstractions/collection.service";
import { CryptoService } from "../abstractions/crypto.service";
import { FolderService } from "../abstractions/folder/folder.service.abstraction";
import { I18nService } from "../abstractions/i18n.service";
import { ImportService as ImportServiceAbstraction } from "../abstractions/import.service";
import { CipherType } from "../enums/cipherType";
import { CipherService } from "../../abstractions/cipher.service";
import { CollectionService } from "../../abstractions/collection.service";
import { CryptoService } from "../../abstractions/crypto.service";
import { FolderService } from "../../abstractions/folder/folder.service.abstraction";
import { I18nService } from "../../abstractions/i18n.service";
import { ImportApiServiceAbstraction } from "../../abstractions/import/import-api.service.abstraction";
import { ImportService as ImportServiceAbstraction } from "../../abstractions/import/import.service.abstraction";
import { CipherType } from "../../enums/cipherType";
import {
featuredImportOptions,
ImportOption,
ImportType,
regularImportOptions,
} from "../enums/importOptions";
import { AscendoCsvImporter } from "../importers/ascendo-csv-importer";
import { AvastCsvImporter } from "../importers/avast-csv-importer";
import { AvastJsonImporter } from "../importers/avast-json-importer";
import { AviraCsvImporter } from "../importers/avira-csv-importer";
import { BitwardenCsvImporter } from "../importers/bitwarden-csv-importer";
import { BitwardenJsonImporter } from "../importers/bitwarden-json-importer";
import { BitwardenPasswordProtectedImporter } from "../importers/bitwarden-password-protected-importer";
import { BlackBerryCsvImporter } from "../importers/blackberry-csv-importer";
import { BlurCsvImporter } from "../importers/blur-csv-importer";
import { ButtercupCsvImporter } from "../importers/buttercup-csv-importer";
import { ChromeCsvImporter } from "../importers/chrome-csv-importer";
import { ClipperzHtmlImporter } from "../importers/clipperz-html-importer";
import { CodebookCsvImporter } from "../importers/codebook-csv-importer";
import { DashlaneCsvImporter } from "../importers/dashlane/dashlane-csv-importer";
import { DashlaneJsonImporter } from "../importers/dashlane/dashlane-json-importer";
import { EncryptrCsvImporter } from "../importers/encryptr-csv-importer";
import { EnpassCsvImporter } from "../importers/enpass/enpass-csv-importer";
import { EnpassJsonImporter } from "../importers/enpass/enpass-json-importer";
import { FirefoxCsvImporter } from "../importers/firefox-csv-importer";
import { FSecureFskImporter } from "../importers/fsecure/fsecure-fsk-importer";
import { GnomeJsonImporter } from "../importers/gnome-json-importer";
import { ImportError } from "../importers/import-error";
import { Importer } from "../importers/importer";
import { KasperskyTxtImporter } from "../importers/kaspersky-txt-importer";
import { KeePass2XmlImporter } from "../importers/keepass2-xml-importer";
import { KeePassXCsvImporter } from "../importers/keepassx-csv-importer";
import { KeeperCsvImporter } from "../importers/keeper/keeper-csv-importer";
import { LastPassCsvImporter } from "../importers/lastpass-csv-importer";
import { LogMeOnceCsvImporter } from "../importers/logmeonce-csv-importer";
import { MeldiumCsvImporter } from "../importers/meldium-csv-importer";
import { MSecureCsvImporter } from "../importers/msecure-csv-importer";
import { MykiCsvImporter } from "../importers/myki-csv-importer";
import { NordPassCsvImporter } from "../importers/nordpass-csv-importer";
import { OnePassword1PifImporter } from "../importers/onepassword/onepassword-1pif-importer";
import { OnePassword1PuxImporter } from "../importers/onepassword/onepassword-1pux-importer";
import { OnePasswordMacCsvImporter } from "../importers/onepassword/onepassword-mac-csv-importer";
import { OnePasswordWinCsvImporter } from "../importers/onepassword/onepassword-win-csv-importer";
import { PadlockCsvImporter } from "../importers/padlock-csv-importer";
import { PassKeepCsvImporter } from "../importers/passkeep-csv-importer";
import { PasskyJsonImporter } from "../importers/passky/passky-json-importer";
import { PassmanJsonImporter } from "../importers/passman-json-importer";
import { PasspackCsvImporter } from "../importers/passpack-csv-importer";
import { PasswordAgentCsvImporter } from "../importers/passwordagent-csv-importer";
import { PasswordBossJsonImporter } from "../importers/passwordboss-json-importer";
import { PasswordDragonXmlImporter } from "../importers/passworddragon-xml-importer";
import { PasswordSafeXmlImporter } from "../importers/passwordsafe-xml-importer";
import { PasswordWalletTxtImporter } from "../importers/passwordwallet-txt-importer";
import { PsonoJsonImporter } from "../importers/psono/psono-json-importer";
import { RememBearCsvImporter } from "../importers/remembear-csv-importer";
import { RoboFormCsvImporter } from "../importers/roboform-csv-importer";
import { SafariCsvImporter } from "../importers/safari-csv-importer";
import { SafeInCloudXmlImporter } from "../importers/safeincloud-xml-importer";
import { SaferPassCsvImporter } from "../importers/saferpass-csv-importer";
import { SecureSafeCsvImporter } from "../importers/securesafe-csv-importer";
import { SplashIdCsvImporter } from "../importers/splashid-csv-importer";
import { StickyPasswordXmlImporter } from "../importers/stickypassword-xml-importer";
import { TrueKeyCsvImporter } from "../importers/truekey-csv-importer";
import { UpmCsvImporter } from "../importers/upm-csv-importer";
import { YotiCsvImporter } from "../importers/yoti-csv-importer";
import { ZohoVaultCsvImporter } from "../importers/zohovault-csv-importer";
import { Utils } from "../misc/utils";
import { ImportResult } from "../models/domain/import-result";
import { CipherRequest } from "../models/request/cipher.request";
import { CollectionRequest } from "../models/request/collection.request";
import { FolderRequest } from "../models/request/folder.request";
import { ImportCiphersRequest } from "../models/request/import-ciphers.request";
import { ImportOrganizationCiphersRequest } from "../models/request/import-organization-ciphers.request";
import { KvpRequest } from "../models/request/kvp.request";
import { ErrorResponse } from "../models/response/error.response";
import { CipherView } from "../models/view/cipher.view";
} from "../../enums/importOptions";
import { AscendoCsvImporter } from "../../importers/ascendo-csv-importer";
import { AvastCsvImporter } from "../../importers/avast-csv-importer";
import { AvastJsonImporter } from "../../importers/avast-json-importer";
import { AviraCsvImporter } from "../../importers/avira-csv-importer";
import { BitwardenCsvImporter } from "../../importers/bitwarden-csv-importer";
import { BitwardenJsonImporter } from "../../importers/bitwarden-json-importer";
import { BitwardenPasswordProtectedImporter } from "../../importers/bitwarden-password-protected-importer";
import { BlackBerryCsvImporter } from "../../importers/blackberry-csv-importer";
import { BlurCsvImporter } from "../../importers/blur-csv-importer";
import { ButtercupCsvImporter } from "../../importers/buttercup-csv-importer";
import { ChromeCsvImporter } from "../../importers/chrome-csv-importer";
import { ClipperzHtmlImporter } from "../../importers/clipperz-html-importer";
import { CodebookCsvImporter } from "../../importers/codebook-csv-importer";
import { DashlaneCsvImporter } from "../../importers/dashlane/dashlane-csv-importer";
import { DashlaneJsonImporter } from "../../importers/dashlane/dashlane-json-importer";
import { EncryptrCsvImporter } from "../../importers/encryptr-csv-importer";
import { EnpassCsvImporter } from "../../importers/enpass/enpass-csv-importer";
import { EnpassJsonImporter } from "../../importers/enpass/enpass-json-importer";
import { FirefoxCsvImporter } from "../../importers/firefox-csv-importer";
import { FSecureFskImporter } from "../../importers/fsecure/fsecure-fsk-importer";
import { GnomeJsonImporter } from "../../importers/gnome-json-importer";
import { ImportError } from "../../importers/import-error";
import { Importer } from "../../importers/importer";
import { KasperskyTxtImporter } from "../../importers/kaspersky-txt-importer";
import { KeePass2XmlImporter } from "../../importers/keepass2-xml-importer";
import { KeePassXCsvImporter } from "../../importers/keepassx-csv-importer";
import { KeeperCsvImporter } from "../../importers/keeper/keeper-csv-importer";
import { LastPassCsvImporter } from "../../importers/lastpass-csv-importer";
import { LogMeOnceCsvImporter } from "../../importers/logmeonce-csv-importer";
import { MeldiumCsvImporter } from "../../importers/meldium-csv-importer";
import { MSecureCsvImporter } from "../../importers/msecure-csv-importer";
import { MykiCsvImporter } from "../../importers/myki-csv-importer";
import { NordPassCsvImporter } from "../../importers/nordpass-csv-importer";
import { OnePassword1PifImporter } from "../../importers/onepassword/onepassword-1pif-importer";
import { OnePassword1PuxImporter } from "../../importers/onepassword/onepassword-1pux-importer";
import { OnePasswordMacCsvImporter } from "../../importers/onepassword/onepassword-mac-csv-importer";
import { OnePasswordWinCsvImporter } from "../../importers/onepassword/onepassword-win-csv-importer";
import { PadlockCsvImporter } from "../../importers/padlock-csv-importer";
import { PassKeepCsvImporter } from "../../importers/passkeep-csv-importer";
import { PasskyJsonImporter } from "../../importers/passky/passky-json-importer";
import { PassmanJsonImporter } from "../../importers/passman-json-importer";
import { PasspackCsvImporter } from "../../importers/passpack-csv-importer";
import { PasswordAgentCsvImporter } from "../../importers/passwordagent-csv-importer";
import { PasswordBossJsonImporter } from "../../importers/passwordboss-json-importer";
import { PasswordDragonXmlImporter } from "../../importers/passworddragon-xml-importer";
import { PasswordSafeXmlImporter } from "../../importers/passwordsafe-xml-importer";
import { PasswordWalletTxtImporter } from "../../importers/passwordwallet-txt-importer";
import { PsonoJsonImporter } from "../../importers/psono/psono-json-importer";
import { RememBearCsvImporter } from "../../importers/remembear-csv-importer";
import { RoboFormCsvImporter } from "../../importers/roboform-csv-importer";
import { SafariCsvImporter } from "../../importers/safari-csv-importer";
import { SafeInCloudXmlImporter } from "../../importers/safeincloud-xml-importer";
import { SaferPassCsvImporter } from "../../importers/saferpass-csv-importer";
import { SecureSafeCsvImporter } from "../../importers/securesafe-csv-importer";
import { SplashIdCsvImporter } from "../../importers/splashid-csv-importer";
import { StickyPasswordXmlImporter } from "../../importers/stickypassword-xml-importer";
import { TrueKeyCsvImporter } from "../../importers/truekey-csv-importer";
import { UpmCsvImporter } from "../../importers/upm-csv-importer";
import { YotiCsvImporter } from "../../importers/yoti-csv-importer";
import { ZohoVaultCsvImporter } from "../../importers/zohovault-csv-importer";
import { Utils } from "../../misc/utils";
import { ImportResult } from "../../models/domain/import-result";
import { CipherRequest } from "../../models/request/cipher.request";
import { CollectionRequest } from "../../models/request/collection.request";
import { FolderRequest } from "../../models/request/folder.request";
import { ImportCiphersRequest } from "../../models/request/import-ciphers.request";
import { ImportOrganizationCiphersRequest } from "../../models/request/import-organization-ciphers.request";
import { KvpRequest } from "../../models/request/kvp.request";
import { ErrorResponse } from "../../models/response/error.response";
import { CipherView } from "../../models/view/cipher.view";
export class ImportService implements ImportServiceAbstraction {
featuredImportOptions = featuredImportOptions as readonly ImportOption[];
@ -91,7 +91,7 @@ export class ImportService implements ImportServiceAbstraction {
constructor(
private cipherService: CipherService,
private folderService: FolderService,
private apiService: ApiService,
private importApiService: ImportApiServiceAbstraction,
private i18nService: I18nService,
private collectionService: CollectionService,
private cryptoService: CryptoService
@ -308,7 +308,7 @@ export class ImportService implements ImportServiceAbstraction {
request.folderRelationships.push(new KvpRequest(r[0], r[1]))
);
}
return await this.apiService.postImportCiphers(request);
return await this.importApiService.postImportCiphers(request);
} else {
const request = new ImportOrganizationCiphersRequest();
for (let i = 0; i < importResult.ciphers.length; i++) {
@ -328,7 +328,7 @@ export class ImportService implements ImportServiceAbstraction {
request.collectionRelationships.push(new KvpRequest(r[0], r[1]))
);
}
return await this.apiService.postImportOrganizationCiphers(organizationId, request);
return await this.importApiService.postImportOrganizationCiphers(organizationId, request);
}
}