From e98d29d2c83ed5b9a77e51ccecad470a81eb73f1 Mon Sep 17 00:00:00 2001 From: Tom <144813356+ttalty@users.noreply.github.com> Date: Wed, 27 Mar 2024 12:34:15 -0400 Subject: [PATCH] [PM-5593] Removing BrowserSendService from services (#8512) * Removing send service from services, removed browser send, and pointed to send services * Make linter happy --------- Co-authored-by: Daniel James Smith --- .../browser/src/background/main.background.ts | 4 +- .../service-factories/send-service.factory.ts | 4 +- .../src/popup/services/services.module.ts | 42 ------------------- .../src/services/browser-send.service.ts | 15 ------- 4 files changed, 4 insertions(+), 61 deletions(-) delete mode 100644 apps/browser/src/services/browser-send.service.ts diff --git a/apps/browser/src/background/main.background.ts b/apps/browser/src/background/main.background.ts index 14ded13c3e..73c4356f69 100644 --- a/apps/browser/src/background/main.background.ts +++ b/apps/browser/src/background/main.background.ts @@ -143,6 +143,7 @@ import { } from "@bitwarden/common/tools/password-strength"; import { SendApiService } from "@bitwarden/common/tools/send/services/send-api.service"; import { SendApiService as SendApiServiceAbstraction } from "@bitwarden/common/tools/send/services/send-api.service.abstraction"; +import { SendService } from "@bitwarden/common/tools/send/services/send.service"; import { InternalSendService as InternalSendServiceAbstraction } from "@bitwarden/common/tools/send/services/send.service.abstraction"; import { UserId } from "@bitwarden/common/types/guid"; import { CipherService as CipherServiceAbstraction } from "@bitwarden/common/vault/abstractions/cipher.service"; @@ -213,7 +214,6 @@ import { BackgroundPlatformUtilsService } from "../platform/services/platform-ut import { BrowserPlatformUtilsService } from "../platform/services/platform-utils/browser-platform-utils.service"; import { BackgroundDerivedStateProvider } from "../platform/state/background-derived-state.provider"; import { BackgroundMemoryStorageService } from "../platform/storage/background-memory-storage.service"; -import { BrowserSendService } from "../services/browser-send.service"; import VaultTimeoutService from "../services/vault-timeout/vault-timeout.service"; import FilelessImporterBackground from "../tools/background/fileless-importer.background"; import { BrowserFido2UserInterfaceService } from "../vault/fido2/browser-fido2-user-interface.service"; @@ -698,7 +698,7 @@ export default class MainBackground { logoutCallback, ); this.containerService = new ContainerService(this.cryptoService, this.encryptService); - this.sendService = new BrowserSendService( + this.sendService = new SendService( this.cryptoService, this.i18nService, this.keyGenerationService, diff --git a/apps/browser/src/background/service-factories/send-service.factory.ts b/apps/browser/src/background/service-factories/send-service.factory.ts index bca46b4703..7c64bc076a 100644 --- a/apps/browser/src/background/service-factories/send-service.factory.ts +++ b/apps/browser/src/background/service-factories/send-service.factory.ts @@ -1,3 +1,4 @@ +import { SendService } from "@bitwarden/common/tools/send/services/send.service"; import { InternalSendService } from "@bitwarden/common/tools/send/services/send.service.abstraction"; import { @@ -21,7 +22,6 @@ import { stateServiceFactory, StateServiceInitOptions, } from "../../platform/background/service-factories/state-service.factory"; -import { BrowserSendService } from "../../services/browser-send.service"; type SendServiceFactoryOptions = FactoryOptions; @@ -40,7 +40,7 @@ export function sendServiceFactory( "sendService", opts, async () => - new BrowserSendService( + new SendService( await cryptoServiceFactory(cache, opts), await i18nServiceFactory(cache, opts), await keyGenerationServiceFactory(cache, opts), diff --git a/apps/browser/src/popup/services/services.module.ts b/apps/browser/src/popup/services/services.module.ts index 33fe6a52af..25db6f78ca 100644 --- a/apps/browser/src/popup/services/services.module.ts +++ b/apps/browser/src/popup/services/services.module.ts @@ -16,7 +16,6 @@ import { AuthRequestServiceAbstraction, LoginStrategyServiceAbstraction, } from "@bitwarden/auth/common"; -import { ApiService } from "@bitwarden/common/abstractions/api.service"; import { NotificationsService } from "@bitwarden/common/abstractions/notifications.service"; import { SearchService as SearchServiceAbstraction } from "@bitwarden/common/abstractions/search.service"; import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout-settings.service"; @@ -53,9 +52,7 @@ import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.se import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service"; import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service"; import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service"; -import { FileUploadService } from "@bitwarden/common/platform/abstractions/file-upload/file-upload.service"; import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/platform/abstractions/i18n.service"; -import { KeyGenerationService } from "@bitwarden/common/platform/abstractions/key-generation.service"; import { LogService, LogService as LogServiceAbstraction, @@ -82,12 +79,6 @@ import { import { SearchService } from "@bitwarden/common/services/search.service"; import { PasswordGenerationServiceAbstraction } from "@bitwarden/common/tools/generator/password"; import { UsernameGenerationServiceAbstraction } from "@bitwarden/common/tools/generator/username"; -import { SendApiService } from "@bitwarden/common/tools/send/services/send-api.service"; -import { SendApiService as SendApiServiceAbstraction } from "@bitwarden/common/tools/send/services/send-api.service.abstraction"; -import { - InternalSendService as InternalSendServiceAbstraction, - SendService, -} from "@bitwarden/common/tools/send/services/send.service.abstraction"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { CollectionService } from "@bitwarden/common/vault/abstractions/collection.service"; import { CipherFileUploadService } from "@bitwarden/common/vault/abstractions/file-upload/cipher-file-upload.service"; @@ -115,7 +106,6 @@ import I18nService from "../../platform/services/i18n.service"; import { ForegroundPlatformUtilsService } from "../../platform/services/platform-utils/foreground-platform-utils.service"; import { ForegroundDerivedStateProvider } from "../../platform/state/foreground-derived-state.provider"; import { ForegroundMemoryStorageService } from "../../platform/storage/foreground-memory-storage.service"; -import { BrowserSendService } from "../../services/browser-send.service"; import { FilePopoutUtilsService } from "../../tools/popup/services/file-popout-utils.service"; import { VaultFilterService } from "../../vault/services/vault-filter.service"; @@ -295,38 +285,6 @@ function getBgService(service: keyof MainBackground) { useFactory: getBgService("passwordGenerationService"), deps: [], }, - { - provide: SendService, - useFactory: ( - cryptoService: CryptoService, - i18nService: I18nServiceAbstraction, - keyGenerationService: KeyGenerationService, - stateServiceAbstraction: StateServiceAbstraction, - ) => { - return new BrowserSendService( - cryptoService, - i18nService, - keyGenerationService, - stateServiceAbstraction, - ); - }, - deps: [CryptoService, I18nServiceAbstraction, KeyGenerationService, StateServiceAbstraction], - }, - { - provide: InternalSendServiceAbstraction, - useExisting: SendService, - }, - { - provide: SendApiServiceAbstraction, - useFactory: ( - apiService: ApiService, - fileUploadService: FileUploadService, - sendService: InternalSendServiceAbstraction, - ) => { - return new SendApiService(apiService, fileUploadService, sendService); - }, - deps: [ApiService, FileUploadService, InternalSendServiceAbstraction], - }, { provide: SyncService, useFactory: getBgService("syncService"), deps: [] }, { provide: DomainSettingsService, diff --git a/apps/browser/src/services/browser-send.service.ts b/apps/browser/src/services/browser-send.service.ts deleted file mode 100644 index 8a197444a9..0000000000 --- a/apps/browser/src/services/browser-send.service.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { BehaviorSubject } from "rxjs"; - -import { Send } from "@bitwarden/common/tools/send/models/domain/send"; -import { SendView } from "@bitwarden/common/tools/send/models/view/send.view"; -import { SendService } from "@bitwarden/common/tools/send/services/send.service"; - -import { browserSession, sessionSync } from "../platform/decorators/session-sync-observable"; - -@browserSession -export class BrowserSendService extends SendService { - @sessionSync({ initializer: Send.fromJSON, initializeAs: "array" }) - protected _sends: BehaviorSubject; - @sessionSync({ initializer: SendView.fromJSON, initializeAs: "array" }) - protected _sendViews: BehaviorSubject; -}