[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>pull/6467/head
parent
512af1e923
commit
0dd1aeba9f
@ -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)
|
||||
)
|
||||
);
|
||||
}
|
||||
Loading…
Reference in new issue