mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-21 11:35:34 +01:00
[PM-4031] Add libs/importer to browser and desktop (#6373)
* Import libs/importer and instantiate ImportService * Create ImportApi and ImportService factories * Add libs/importer to desktop * [PM-4075] Setup Feature Flag for Browser Fileless Import (#6391) * Update apps/browser/src/tools/background/service_factories/import-api-service.factory.ts Co-authored-by: ✨ Audrey ✨ <ajensen@bitwarden.com> * Created non-exported ServiceCache-type for ImportApiServiceFactory --------- Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com> Co-authored-by: Cesar Gonzalez <cesar.a.gonzalezcs@gmail.com> Co-authored-by: ✨ Audrey ✨ <ajensen@bitwarden.com>
This commit is contained in:
parent
512af1e923
commit
0dd1aeba9f
@ -103,6 +103,12 @@ import {
|
|||||||
VaultExportService,
|
VaultExportService,
|
||||||
VaultExportServiceAbstraction,
|
VaultExportServiceAbstraction,
|
||||||
} from "@bitwarden/exporter/vault-export";
|
} from "@bitwarden/exporter/vault-export";
|
||||||
|
import {
|
||||||
|
ImportApiServiceAbstraction,
|
||||||
|
ImportApiService,
|
||||||
|
ImportServiceAbstraction,
|
||||||
|
ImportService,
|
||||||
|
} from "@bitwarden/importer";
|
||||||
|
|
||||||
import { BrowserOrganizationService } from "../admin-console/services/browser-organization.service";
|
import { BrowserOrganizationService } from "../admin-console/services/browser-organization.service";
|
||||||
import { BrowserPolicyService } from "../admin-console/services/browser-policy.service";
|
import { BrowserPolicyService } from "../admin-console/services/browser-policy.service";
|
||||||
@ -172,6 +178,8 @@ export default class MainBackground {
|
|||||||
containerService: ContainerService;
|
containerService: ContainerService;
|
||||||
auditService: AuditServiceAbstraction;
|
auditService: AuditServiceAbstraction;
|
||||||
authService: AuthServiceAbstraction;
|
authService: AuthServiceAbstraction;
|
||||||
|
importApiService: ImportApiServiceAbstraction;
|
||||||
|
importService: ImportServiceAbstraction;
|
||||||
exportService: VaultExportServiceAbstraction;
|
exportService: VaultExportServiceAbstraction;
|
||||||
searchService: SearchServiceAbstraction;
|
searchService: SearchServiceAbstraction;
|
||||||
notificationsService: NotificationsServiceAbstraction;
|
notificationsService: NotificationsServiceAbstraction;
|
||||||
@ -527,6 +535,18 @@ export default class MainBackground {
|
|||||||
this.userVerificationService
|
this.userVerificationService
|
||||||
);
|
);
|
||||||
this.auditService = new AuditService(this.cryptoFunctionService, this.apiService);
|
this.auditService = new AuditService(this.cryptoFunctionService, this.apiService);
|
||||||
|
|
||||||
|
this.importApiService = new ImportApiService(this.apiService);
|
||||||
|
|
||||||
|
this.importService = new ImportService(
|
||||||
|
this.cipherService,
|
||||||
|
this.folderService,
|
||||||
|
this.importApiService,
|
||||||
|
this.i18nService,
|
||||||
|
this.collectionService,
|
||||||
|
this.cryptoService
|
||||||
|
);
|
||||||
|
|
||||||
this.exportService = new VaultExportService(
|
this.exportService = new VaultExportService(
|
||||||
this.folderService,
|
this.folderService,
|
||||||
this.cipherService,
|
this.cipherService,
|
||||||
|
@ -85,6 +85,7 @@ import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.serv
|
|||||||
import { FolderApiService } from "@bitwarden/common/vault/services/folder/folder-api.service";
|
import { FolderApiService } from "@bitwarden/common/vault/services/folder/folder-api.service";
|
||||||
import { DialogService } from "@bitwarden/components";
|
import { DialogService } from "@bitwarden/components";
|
||||||
import { VaultExportServiceAbstraction } from "@bitwarden/exporter/vault-export";
|
import { VaultExportServiceAbstraction } from "@bitwarden/exporter/vault-export";
|
||||||
|
import { ImportServiceAbstraction } from "@bitwarden/importer";
|
||||||
|
|
||||||
import { BrowserOrganizationService } from "../../admin-console/services/browser-organization.service";
|
import { BrowserOrganizationService } from "../../admin-console/services/browser-organization.service";
|
||||||
import { BrowserPolicyService } from "../../admin-console/services/browser-policy.service";
|
import { BrowserPolicyService } from "../../admin-console/services/browser-policy.service";
|
||||||
@ -368,6 +369,11 @@ function getBgService<T>(service: keyof MainBackground) {
|
|||||||
useFactory: getBgService<AutofillService>("autofillService"),
|
useFactory: getBgService<AutofillService>("autofillService"),
|
||||||
deps: [],
|
deps: [],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
provide: ImportServiceAbstraction,
|
||||||
|
useFactory: getBgService<ImportServiceAbstraction>("importService"),
|
||||||
|
deps: [],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
provide: VaultExportServiceAbstraction,
|
provide: VaultExportServiceAbstraction,
|
||||||
useFactory: getBgService<VaultExportServiceAbstraction>("exportService"),
|
useFactory: getBgService<VaultExportServiceAbstraction>("exportService"),
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
import { ImportApiService, ImportApiServiceAbstraction } from "@bitwarden/importer";
|
||||||
|
|
||||||
|
import {
|
||||||
|
ApiServiceInitOptions,
|
||||||
|
apiServiceFactory,
|
||||||
|
} from "../../../platform/background/service-factories/api-service.factory";
|
||||||
|
import {
|
||||||
|
FactoryOptions,
|
||||||
|
CachedServices,
|
||||||
|
factory,
|
||||||
|
} from "../../../platform/background/service-factories/factory-options";
|
||||||
|
|
||||||
|
export type ImportApiServiceInitOptions = FactoryOptions & ApiServiceInitOptions;
|
||||||
|
type ServiceCache = { importApiService?: ImportApiServiceAbstraction } & CachedServices;
|
||||||
|
|
||||||
|
export function importApiServiceFactory(
|
||||||
|
cache: ServiceCache,
|
||||||
|
opts: ImportApiServiceInitOptions
|
||||||
|
): Promise<ImportApiServiceAbstraction> {
|
||||||
|
return factory(
|
||||||
|
cache,
|
||||||
|
"importApiService",
|
||||||
|
opts,
|
||||||
|
async () => new ImportApiService(await apiServiceFactory(cache, opts))
|
||||||
|
);
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
import { ImportService, ImportServiceAbstraction } from "@bitwarden/importer";
|
||||||
|
|
||||||
|
import {
|
||||||
|
cryptoServiceFactory,
|
||||||
|
CryptoServiceInitOptions,
|
||||||
|
} from "../../../platform/background/service-factories/crypto-service.factory";
|
||||||
|
import {
|
||||||
|
CachedServices,
|
||||||
|
factory,
|
||||||
|
FactoryOptions,
|
||||||
|
} from "../../../platform/background/service-factories/factory-options";
|
||||||
|
import {
|
||||||
|
i18nServiceFactory,
|
||||||
|
I18nServiceInitOptions,
|
||||||
|
} from "../../../platform/background/service-factories/i18n-service.factory";
|
||||||
|
import {
|
||||||
|
cipherServiceFactory,
|
||||||
|
CipherServiceInitOptions,
|
||||||
|
} from "../../../vault/background/service_factories/cipher-service.factory";
|
||||||
|
import {
|
||||||
|
collectionServiceFactory,
|
||||||
|
CollectionServiceInitOptions,
|
||||||
|
} from "../../../vault/background/service_factories/collection-service.factory";
|
||||||
|
import {
|
||||||
|
folderServiceFactory,
|
||||||
|
FolderServiceInitOptions,
|
||||||
|
} from "../../../vault/background/service_factories/folder-service.factory";
|
||||||
|
|
||||||
|
import { importApiServiceFactory, ImportApiServiceInitOptions } from "./import-api-service.factory";
|
||||||
|
|
||||||
|
type ImportServiceFactoryOptions = FactoryOptions;
|
||||||
|
|
||||||
|
export type ImportServiceInitOptions = ImportServiceFactoryOptions &
|
||||||
|
CipherServiceInitOptions &
|
||||||
|
FolderServiceInitOptions &
|
||||||
|
ImportApiServiceInitOptions &
|
||||||
|
I18nServiceInitOptions &
|
||||||
|
CollectionServiceInitOptions &
|
||||||
|
CryptoServiceInitOptions;
|
||||||
|
|
||||||
|
export function importServiceFactory(
|
||||||
|
cache: {
|
||||||
|
importService?: ImportServiceAbstraction;
|
||||||
|
} & CachedServices,
|
||||||
|
opts: ImportServiceInitOptions
|
||||||
|
): Promise<ImportServiceAbstraction> {
|
||||||
|
return factory(
|
||||||
|
cache,
|
||||||
|
"importService",
|
||||||
|
opts,
|
||||||
|
async () =>
|
||||||
|
new ImportService(
|
||||||
|
await cipherServiceFactory(cache, opts),
|
||||||
|
await folderServiceFactory(cache, opts),
|
||||||
|
await importApiServiceFactory(cache, opts),
|
||||||
|
await i18nServiceFactory(cache, opts),
|
||||||
|
await collectionServiceFactory(cache, opts),
|
||||||
|
await cryptoServiceFactory(cache, opts)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
@ -15,6 +15,7 @@
|
|||||||
"@bitwarden/common/*": ["../../libs/common/src/*"],
|
"@bitwarden/common/*": ["../../libs/common/src/*"],
|
||||||
"@bitwarden/components": ["../../libs/components/src"],
|
"@bitwarden/components": ["../../libs/components/src"],
|
||||||
"@bitwarden/exporter/*": ["../../libs/exporter/src/*"],
|
"@bitwarden/exporter/*": ["../../libs/exporter/src/*"],
|
||||||
|
"@bitwarden/importer": ["../../libs/importer/src"],
|
||||||
"@bitwarden/vault": ["../../libs/auth/src"]
|
"@bitwarden/vault": ["../../libs/auth/src"]
|
||||||
},
|
},
|
||||||
"useDefineForClassFields": false
|
"useDefineForClassFields": false
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
"@bitwarden/common/*": ["../../libs/common/src/*"],
|
"@bitwarden/common/*": ["../../libs/common/src/*"],
|
||||||
"@bitwarden/components": ["../../libs/components/src"],
|
"@bitwarden/components": ["../../libs/components/src"],
|
||||||
"@bitwarden/exporter/*": ["../../libs/exporter/src/*"],
|
"@bitwarden/exporter/*": ["../../libs/exporter/src/*"],
|
||||||
|
"@bitwarden/importer": ["../../libs/importer/src"],
|
||||||
"@bitwarden/vault": ["../../libs/vault/src"]
|
"@bitwarden/vault": ["../../libs/vault/src"]
|
||||||
},
|
},
|
||||||
"useDefineForClassFields": false
|
"useDefineForClassFields": false
|
||||||
|
@ -150,6 +150,12 @@ import {
|
|||||||
VaultExportService,
|
VaultExportService,
|
||||||
VaultExportServiceAbstraction,
|
VaultExportServiceAbstraction,
|
||||||
} from "@bitwarden/exporter/vault-export";
|
} from "@bitwarden/exporter/vault-export";
|
||||||
|
import {
|
||||||
|
ImportApiService,
|
||||||
|
ImportApiServiceAbstraction,
|
||||||
|
ImportService,
|
||||||
|
ImportServiceAbstraction,
|
||||||
|
} from "@bitwarden/importer";
|
||||||
|
|
||||||
import { AuthGuard } from "../auth/guards/auth.guard";
|
import { AuthGuard } from "../auth/guards/auth.guard";
|
||||||
import { UnauthGuard } from "../auth/guards/unauth.guard";
|
import { UnauthGuard } from "../auth/guards/unauth.guard";
|
||||||
@ -485,6 +491,23 @@ import { AbstractThemingService } from "./theming/theming.service.abstraction";
|
|||||||
STATE_SERVICE_USE_CACHE,
|
STATE_SERVICE_USE_CACHE,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
provide: ImportApiServiceAbstraction,
|
||||||
|
useClass: ImportApiService,
|
||||||
|
deps: [ApiServiceAbstraction],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
provide: ImportServiceAbstraction,
|
||||||
|
useClass: ImportService,
|
||||||
|
deps: [
|
||||||
|
CipherServiceAbstraction,
|
||||||
|
FolderServiceAbstraction,
|
||||||
|
ImportApiServiceAbstraction,
|
||||||
|
I18nServiceAbstraction,
|
||||||
|
CollectionServiceAbstraction,
|
||||||
|
CryptoServiceAbstraction,
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
provide: VaultExportServiceAbstraction,
|
provide: VaultExportServiceAbstraction,
|
||||||
useClass: VaultExportService,
|
useClass: VaultExportService,
|
||||||
|
@ -3,6 +3,7 @@ export enum FeatureFlag {
|
|||||||
DisplayLowKdfIterationWarningFlag = "display-kdf-iteration-warning",
|
DisplayLowKdfIterationWarningFlag = "display-kdf-iteration-warning",
|
||||||
TrustedDeviceEncryption = "trusted-device-encryption",
|
TrustedDeviceEncryption = "trusted-device-encryption",
|
||||||
AutofillV2 = "autofill-v2",
|
AutofillV2 = "autofill-v2",
|
||||||
|
BrowserFilelessImport = "browser-fileless-import",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace this with a type safe lookup of the feature flag values in PM-2282
|
// Replace this with a type safe lookup of the feature flag values in PM-2282
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
"@bitwarden/common/*": ["./libs/common/src/*"],
|
"@bitwarden/common/*": ["./libs/common/src/*"],
|
||||||
"@bitwarden/components": ["./libs/components/src"],
|
"@bitwarden/components": ["./libs/components/src"],
|
||||||
"@bitwarden/exporter/*": ["./libs/exporter/src/*"],
|
"@bitwarden/exporter/*": ["./libs/exporter/src/*"],
|
||||||
|
"@bitwarden/importer": ["./libs/importer/src"],
|
||||||
"@bitwarden/node/*": ["./libs/node/src/*"],
|
"@bitwarden/node/*": ["./libs/node/src/*"],
|
||||||
"@bitwarden/vault": ["./libs/vault/src"]
|
"@bitwarden/vault": ["./libs/vault/src"]
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user