1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-10 21:33:27 +00:00

[SG 623] Send Service Refactor (#4327)

* Split out api methods into sendApiService

* Move SendService and abstraction

* Libs updates

* Web updates

* CLI updates

* Desktop updates

* libs send service fixes

* browser factory additions

* Browser updates

* Fix service injection for CLI SendReceiveCommand

* Deprecate directly calling send state service methods

* SendService observables updates

* Update components to use new observables

* Modify CLI to use state service instead of observables

* Remove unnecessary await on get()

* Move delete() to InternalSendService

* SendService unit tests

* Split fileUploadService by send and cipher

* send and cipher service factory updates

* Add file upload methods to get around circular dependency issues

* Move api methods from sendService to sendApiService

* Update cipherService to use fileApi methods

* libs service injection and component changes

* browser service injection and component changes

* Desktop component changes

* Web component changes

* cipher service test fix

* Fix file capitalization

* CLI service import and command updates

* Remove extra abstract fileUploadService

* WIP: Condense callbacks for file upload

Co-authored-by: Robyn MacCallum <robyntmaccallum@gmail.com>

* Send callbacks for file upload

* Fix circular service dependencies

* Fix response return on upload

* Fix function definitions

* Service injection fixes and bug fixes

* Fix folder casing

* Service injection cleanup

* Remove deleted file from capital letters whitelist

* Create new SendApiService for popup

* Move cipherFileUploadService to vault

* Move SendFileUploadService methods into SendApiService

* Rename methods to remove 'WithServer'

* Properly subscribe to sendViews

* Fix Send serialization

* Implement fromJSON on sendFile and sendText

* [PM-1347] Fix send key serialization (#4989)

* Properly serialize key on send fromJSON

* Remove call that nulled out decrypted sends

* Fix null checks in fromJSON methods for models

* lint fixes

---------

Co-authored-by: Matt Gibson <mgibson@bitwarden.com>
This commit is contained in:
Robyn MacCallum
2023-03-28 12:37:40 -04:00
committed by GitHub
parent c2bfb2497b
commit d799529428
58 changed files with 1333 additions and 663 deletions

View File

@@ -8,14 +8,15 @@ import { EncryptService } from "@bitwarden/common/abstractions/encrypt.service";
import { EventCollectionService as EventCollectionServiceAbstraction } from "@bitwarden/common/abstractions/event/event-collection.service";
import { EventUploadService as EventUploadServiceAbstraction } from "@bitwarden/common/abstractions/event/event-upload.service";
import { ExportService as ExportServiceAbstraction } from "@bitwarden/common/abstractions/export.service";
import { FileUploadService as FileUploadServiceAbstraction } from "@bitwarden/common/abstractions/fileUpload.service";
import { FileUploadService as FileUploadServiceAbstraction } from "@bitwarden/common/abstractions/file-upload/file-upload.service";
import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/abstractions/i18n.service";
import { LogService as LogServiceAbstraction } from "@bitwarden/common/abstractions/log.service";
import { MessagingService as MessagingServiceAbstraction } from "@bitwarden/common/abstractions/messaging.service";
import { NotificationsService as NotificationsServiceAbstraction } from "@bitwarden/common/abstractions/notifications.service";
import { PlatformUtilsService as PlatformUtilsServiceAbstraction } from "@bitwarden/common/abstractions/platformUtils.service";
import { SearchService as SearchServiceAbstraction } from "@bitwarden/common/abstractions/search.service";
import { SendService as SendServiceAbstraction } from "@bitwarden/common/abstractions/send.service";
import { SendApiService as SendApiServiceAbstraction } from "@bitwarden/common/abstractions/send/send-api.service.abstraction";
import { InternalSendService as InternalSendServiceAbstraction } from "@bitwarden/common/abstractions/send/send.service.abstraction";
import { SettingsService as SettingsServiceAbstraction } from "@bitwarden/common/abstractions/settings.service";
import {
AbstractMemoryStorageService,
@@ -58,11 +59,11 @@ import { MultithreadEncryptServiceImplementation } from "@bitwarden/common/servi
import { EventCollectionService } from "@bitwarden/common/services/event/event-collection.service";
import { EventUploadService } from "@bitwarden/common/services/event/event-upload.service";
import { ExportService } from "@bitwarden/common/services/export.service";
import { FileUploadService } from "@bitwarden/common/services/fileUpload.service";
import { FileUploadService } from "@bitwarden/common/services/file-upload/file-upload.service";
import { MemoryStorageService } from "@bitwarden/common/services/memoryStorage.service";
import { NotificationsService } from "@bitwarden/common/services/notifications.service";
import { SearchService } from "@bitwarden/common/services/search.service";
import { SendService } from "@bitwarden/common/services/send.service";
import { SendApiService } from "@bitwarden/common/services/send/send-api.service";
import { StateMigrationService } from "@bitwarden/common/services/stateMigration.service";
import { SystemService } from "@bitwarden/common/services/system.service";
import { TotpService } from "@bitwarden/common/services/totp.service";
@@ -77,12 +78,14 @@ import {
UsernameGenerationServiceAbstraction,
} from "@bitwarden/common/tools/generator/username";
import { CipherService as CipherServiceAbstraction } from "@bitwarden/common/vault/abstractions/cipher.service";
import { CipherFileUploadService as CipherFileUploadServiceAbstraction } from "@bitwarden/common/vault/abstractions/file-upload/cipher-file-upload.service";
import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
import { InternalFolderService as InternalFolderServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
import { SyncNotifierService as SyncNotifierServiceAbstraction } from "@bitwarden/common/vault/abstractions/sync/sync-notifier.service.abstraction";
import { SyncService as SyncServiceAbstraction } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { CipherService } from "@bitwarden/common/vault/services/cipher.service";
import { CipherFileUploadService } from "@bitwarden/common/vault/services/file-upload/cipher-file-upload.service";
import { FolderApiService } from "@bitwarden/common/vault/services/folder/folder-api.service";
import { SyncNotifierService } from "@bitwarden/common/vault/services/sync/sync-notifier.service";
import { SyncService } from "@bitwarden/common/vault/services/sync/sync.service";
@@ -105,6 +108,7 @@ import { Account } from "../models/account";
import { BrowserStateService as StateServiceAbstraction } from "../services/abstractions/browser-state.service";
import { BrowserEnvironmentService } from "../services/browser-environment.service";
import { BrowserI18nService } from "../services/browser-i18n.service";
import { BrowserSendService } from "../services/browser-send.service";
import { BrowserSettingsService } from "../services/browser-settings.service";
import { BrowserStateService } from "../services/browser-state.service";
import { BrowserCryptoService } from "../services/browserCrypto.service";
@@ -160,8 +164,9 @@ export default class MainBackground {
eventCollectionService: EventCollectionServiceAbstraction;
eventUploadService: EventUploadServiceAbstraction;
policyService: InternalPolicyServiceAbstraction;
sendService: SendServiceAbstraction;
sendService: InternalSendServiceAbstraction;
fileUploadService: FileUploadServiceAbstraction;
cipherFileUploadService: CipherFileUploadServiceAbstraction;
organizationService: InternalOrganizationServiceAbstraction;
providerService: ProviderServiceAbstraction;
keyConnectorService: KeyConnectorServiceAbstraction;
@@ -172,6 +177,7 @@ export default class MainBackground {
encryptService: EncryptService;
folderApiService: FolderApiServiceAbstraction;
policyApiService: PolicyApiServiceAbstraction;
sendApiService: SendApiServiceAbstraction;
userVerificationApiService: UserVerificationApiServiceAbstraction;
syncNotifierService: SyncNotifierServiceAbstraction;
avatarUpdateService: AvatarUpdateServiceAbstraction;
@@ -292,17 +298,21 @@ export default class MainBackground {
(expired: boolean) => this.logout(expired)
);
this.settingsService = new BrowserSettingsService(this.stateService);
this.fileUploadService = new FileUploadService(this.logService, this.apiService);
this.fileUploadService = new FileUploadService(this.logService);
this.cipherFileUploadService = new CipherFileUploadService(
this.apiService,
this.fileUploadService
);
this.cipherService = new CipherService(
this.cryptoService,
this.settingsService,
this.apiService,
this.fileUploadService,
this.i18nService,
() => this.searchService,
this.logService,
this.stateService,
this.encryptService
this.encryptService,
this.cipherFileUploadService
);
this.folderService = new BrowserFolderService(
this.cryptoService,
@@ -317,14 +327,6 @@ export default class MainBackground {
this.stateService
);
this.searchService = new SearchService(this.cipherService, this.logService, this.i18nService);
this.sendService = new SendService(
this.cryptoService,
this.apiService,
this.fileUploadService,
this.i18nService,
this.cryptoFunctionService,
this.stateService
);
this.syncNotifierService = new SyncNotifierService();
this.organizationService = new BrowserOrganizationService(this.stateService);
this.policyService = new BrowserPolicyService(this.stateService, this.organizationService);
@@ -401,7 +403,18 @@ export default class MainBackground {
lockedCallback,
logoutCallback
);
this.containerService = new ContainerService(this.cryptoService, this.encryptService);
this.sendService = new BrowserSendService(
this.cryptoService,
this.i18nService,
this.cryptoFunctionService,
this.stateService
);
this.sendApiService = new SendApiService(
this.apiService,
this.fileUploadService,
this.sendService
);
this.providerService = new ProviderService(this.stateService);
this.syncService = new SyncService(
this.apiService,
@@ -419,6 +432,7 @@ export default class MainBackground {
this.providerService,
this.folderApiService,
this.organizationService,
this.sendApiService,
logoutCallback
);
this.eventUploadService = new EventUploadService(
@@ -446,7 +460,6 @@ export default class MainBackground {
this.logService,
this.settingsService
);
this.containerService = new ContainerService(this.cryptoService, this.encryptService);
this.auditService = new AuditService(this.cryptoFunctionService, this.apiService);
this.exportService = new ExportService(
this.folderService,

View File

@@ -0,0 +1,31 @@
import { CipherFileUploadService as CipherFileUploadServiceAbstraction } from "@bitwarden/common/vault/abstractions/file-upload/cipher-file-upload.service";
import { CipherFileUploadService } from "@bitwarden/common/vault/services/file-upload/cipher-file-upload.service";
import { apiServiceFactory, ApiServiceInitOptions } from "./api-service.factory";
import { FactoryOptions, CachedServices, factory } from "./factory-options";
import {
fileUploadServiceFactory,
FileUploadServiceInitOptions,
} from "./file-upload-service.factory";
type CipherFileUploadServiceFactoyOptions = FactoryOptions;
export type CipherFileUploadServiceInitOptions = CipherFileUploadServiceFactoyOptions &
ApiServiceInitOptions &
FileUploadServiceInitOptions;
export function cipherFileUploadServiceFactory(
cache: { cipherFileUploadService?: CipherFileUploadServiceAbstraction } & CachedServices,
opts: CipherFileUploadServiceInitOptions
): Promise<CipherFileUploadServiceAbstraction> {
return factory(
cache,
"cipherFileUploadService",
opts,
async () =>
new CipherFileUploadService(
await apiServiceFactory(cache, opts),
await fileUploadServiceFactory(cache, opts)
)
);
}

View File

@@ -0,0 +1,31 @@
import { CipherFileUploadService as CipherFileUploadServiceAbstraction } from "@bitwarden/common/vault/abstractions/file-upload/cipher-file-upload.service";
import { CipherFileUploadService } from "@bitwarden/common/vault/services/file-upload/cipher-file-upload.service";
import { apiServiceFactory, ApiServiceInitOptions } from "./api-service.factory";
import { FactoryOptions, CachedServices, factory } from "./factory-options";
import {
fileUploadServiceFactory,
FileUploadServiceInitOptions,
} from "./file-upload-service.factory";
type CipherFileUploadServiceFactoyOptions = FactoryOptions;
export type CipherFileUploadServiceInitOptions = CipherFileUploadServiceFactoyOptions &
ApiServiceInitOptions &
FileUploadServiceInitOptions;
export function cipherFileUploadServiceFactory(
cache: { cipherFileUploadService?: CipherFileUploadServiceAbstraction } & CachedServices,
opts: CipherFileUploadServiceInitOptions
): Promise<CipherFileUploadServiceAbstraction> {
return factory(
cache,
"cipherFileUploadService",
opts,
async () =>
new CipherFileUploadService(
await apiServiceFactory(cache, opts),
await fileUploadServiceFactory(cache, opts)
)
);
}

View File

@@ -1,28 +1,21 @@
import { FileUploadService as AbstractFileUploadService } from "@bitwarden/common/abstractions/fileUpload.service";
import { FileUploadService } from "@bitwarden/common/services/fileUpload.service";
import { FileUploadService as FileUploadServiceAbstraction } from "@bitwarden/common/abstractions/file-upload/file-upload.service";
import { FileUploadService } from "@bitwarden/common/services/file-upload/file-upload.service";
import { apiServiceFactory, ApiServiceInitOptions } from "./api-service.factory";
import { FactoryOptions, CachedServices, factory } from "./factory-options";
import { CachedServices, factory, FactoryOptions } from "./factory-options";
import { logServiceFactory, LogServiceInitOptions } from "./log-service.factory";
type FileUploadServiceFactoyOptions = FactoryOptions;
type FileUploadServiceFactoryOptions = FactoryOptions;
export type FileUploadServiceInitOptions = FileUploadServiceFactoyOptions &
LogServiceInitOptions &
ApiServiceInitOptions;
export type FileUploadServiceInitOptions = FileUploadServiceFactoryOptions & LogServiceInitOptions;
export function fileUploadServiceFactory(
cache: { fileUploadService?: AbstractFileUploadService } & CachedServices,
cache: { fileUploadService?: FileUploadServiceAbstraction } & CachedServices,
opts: FileUploadServiceInitOptions
): Promise<AbstractFileUploadService> {
): Promise<FileUploadServiceAbstraction> {
return factory(
cache,
"fileUploadService",
opts,
async () =>
new FileUploadService(
await logServiceFactory(cache, opts),
await apiServiceFactory(cache, opts)
)
async () => new FileUploadService(await logServiceFactory(cache, opts))
);
}

View File

@@ -0,0 +1,34 @@
import { InternalSendService } from "@bitwarden/common/abstractions/send/send.service.abstraction";
import { BrowserSendService } from "../../services/browser-send.service";
import { cryptoFunctionServiceFactory } from "./crypto-function-service.factory";
import { cryptoServiceFactory, CryptoServiceInitOptions } from "./crypto-service.factory";
import { FactoryOptions, CachedServices, factory } from "./factory-options";
import { i18nServiceFactory, I18nServiceInitOptions } from "./i18n-service.factory";
import { stateServiceFactory, StateServiceInitOptions } from "./state-service.factory";
type SendServiceFactoryOptions = FactoryOptions;
export type SendServiceInitOptions = SendServiceFactoryOptions &
CryptoServiceInitOptions &
I18nServiceInitOptions &
StateServiceInitOptions;
export function sendServiceFactory(
cache: { sendService?: InternalSendService } & CachedServices,
opts: SendServiceInitOptions
): Promise<InternalSendService> {
return factory(
cache,
"sendService",
opts,
async () =>
new BrowserSendService(
await cryptoServiceFactory(cache, opts),
await i18nServiceFactory(cache, opts),
await cryptoFunctionServiceFactory(cache, opts),
await stateServiceFactory(cache, opts)
)
);
}

View File

@@ -9,7 +9,8 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { SendService } from "@bitwarden/common/abstractions/send.service";
import { SendApiService } from "@bitwarden/common/abstractions/send/send-api.service.abstraction";
import { SendService } from "@bitwarden/common/abstractions/send/send.service.abstraction";
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
import { BrowserStateService } from "../../services/abstractions/browser-state.service";
@@ -43,7 +44,8 @@ export class SendAddEditComponent extends BaseAddEditComponent {
private router: Router,
private location: Location,
private popupUtilsService: PopupUtilsService,
logService: LogService
logService: LogService,
sendApiService: SendApiService
) {
super(
i18nService,
@@ -54,7 +56,8 @@ export class SendAddEditComponent extends BaseAddEditComponent {
messagingService,
policyService,
logService,
stateService
stateService,
sendApiService
);
}

View File

@@ -8,7 +8,8 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { SearchService } from "@bitwarden/common/abstractions/search.service";
import { SendService } from "@bitwarden/common/abstractions/send.service";
import { SendApiService } from "@bitwarden/common/abstractions/send/send-api.service.abstraction";
import { SendService } from "@bitwarden/common/abstractions/send/send.service.abstraction";
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
import { SendType } from "@bitwarden/common/enums/sendType";
import { SendView } from "@bitwarden/common/models/view/send.view";
@@ -47,7 +48,8 @@ export class SendGroupingsComponent extends BaseSendComponent {
private syncService: SyncService,
private changeDetectorRef: ChangeDetectorRef,
private broadcasterService: BroadcasterService,
logService: LogService
logService: LogService,
sendApiService: SendApiService
) {
super(
sendService,
@@ -57,7 +59,8 @@ export class SendGroupingsComponent extends BaseSendComponent {
ngZone,
searchService,
policyService,
logService
logService,
sendApiService
);
super.onSuccessfulLoad = async () => {
this.calculateTypeCounts();

View File

@@ -10,7 +10,8 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { SearchService } from "@bitwarden/common/abstractions/search.service";
import { SendService } from "@bitwarden/common/abstractions/send.service";
import { SendApiService } from "@bitwarden/common/abstractions/send/send-api.service.abstraction";
import { SendService } from "@bitwarden/common/abstractions/send/send.service.abstraction";
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
import { SendType } from "@bitwarden/common/enums/sendType";
import { SendView } from "@bitwarden/common/models/view/send.view";
@@ -47,7 +48,8 @@ export class SendTypeComponent extends BaseSendComponent {
private changeDetectorRef: ChangeDetectorRef,
private broadcasterService: BroadcasterService,
private router: Router,
logService: LogService
logService: LogService,
sendApiService: SendApiService
) {
super(
sendService,
@@ -57,7 +59,8 @@ export class SendTypeComponent extends BaseSendComponent {
ngZone,
searchService,
policyService,
logService
logService,
sendApiService
);
super.onSuccessfulLoad = async () => {
this.selectType(this.type);

View File

@@ -18,15 +18,19 @@ import { EnvironmentService } from "@bitwarden/common/abstractions/environment.s
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
import { EventUploadService } from "@bitwarden/common/abstractions/event/event-upload.service";
import { ExportService } from "@bitwarden/common/abstractions/export.service";
import { FileUploadService } from "@bitwarden/common/abstractions/file-upload/file-upload.service";
import { FileDownloadService } from "@bitwarden/common/abstractions/fileDownload/fileDownload.service";
import { FileUploadService } from "@bitwarden/common/abstractions/fileUpload.service";
import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/abstractions/i18n.service";
import { LogService as LogServiceAbstraction } from "@bitwarden/common/abstractions/log.service";
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
import { NotificationsService } from "@bitwarden/common/abstractions/notifications.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { SearchService as SearchServiceAbstraction } from "@bitwarden/common/abstractions/search.service";
import { SendService } from "@bitwarden/common/abstractions/send.service";
import { SendApiService as SendApiServiceAbstraction } from "@bitwarden/common/abstractions/send/send-api.service.abstraction";
import {
InternalSendService as InternalSendServiceAbstraction,
SendService,
} from "@bitwarden/common/abstractions/send/send.service.abstraction";
import { SettingsService } from "@bitwarden/common/abstractions/settings.service";
import {
StateService as BaseStateServiceAbstraction,
@@ -62,9 +66,11 @@ import { GlobalState } from "@bitwarden/common/models/domain/global-state";
import { ConsoleLogService } from "@bitwarden/common/services/consoleLog.service";
import { ContainerService } from "@bitwarden/common/services/container.service";
import { SearchService } from "@bitwarden/common/services/search.service";
import { SendApiService } from "@bitwarden/common/services/send/send-api.service";
import { PasswordGenerationServiceAbstraction } from "@bitwarden/common/tools/generator/password";
import { UsernameGenerationServiceAbstraction } from "@bitwarden/common/tools/generator/username";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { CipherFileUploadService } from "@bitwarden/common/vault/abstractions/file-upload/cipher-file-upload.service";
import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
import {
FolderService,
@@ -85,6 +91,7 @@ import { BrowserStateService as StateServiceAbstraction } from "../../services/a
import { BrowserConfigService } from "../../services/browser-config.service";
import { BrowserEnvironmentService } from "../../services/browser-environment.service";
import { BrowserI18nService } from "../../services/browser-i18n.service";
import { BrowserSendService } from "../../services/browser-send.service";
import { BrowserSettingsService } from "../../services/browser-settings.service";
import { BrowserStateService } from "../../services/browser-state.service";
import { BrowserFileDownloadService } from "../../services/browserFileDownloadService";
@@ -173,8 +180,8 @@ function getBgService<T>(service: keyof MainBackground) {
},
{ provide: AuditService, useFactory: getBgService<AuditService>("auditService"), deps: [] },
{
provide: FileUploadService,
useFactory: getBgService<FileUploadService>("fileUploadService"),
provide: CipherFileUploadService,
useFactory: getBgService<CipherFileUploadService>("cipherFileUploadService"),
deps: [],
},
{ provide: CipherService, useFactory: getBgService<CipherService>("cipherService"), deps: [] },
@@ -183,6 +190,10 @@ function getBgService<T>(service: keyof MainBackground) {
useFactory: getBgService<CryptoFunctionService>("cryptoFunctionService"),
deps: [],
},
{
provide: FileUploadService,
useFactory: getBgService<FileUploadService>("fileUploadService"),
},
{
provide: FolderService,
useFactory: (
@@ -285,6 +296,38 @@ function getBgService<T>(service: keyof MainBackground) {
deps: [],
},
{ provide: ApiService, useFactory: getBgService<ApiService>("apiService"), deps: [] },
{
provide: SendService,
useFactory: (
cryptoService: CryptoService,
i18nService: I18nServiceAbstraction,
cryptoFunctionService: CryptoFunctionService,
stateServiceAbstraction: StateServiceAbstraction
) => {
return new BrowserSendService(
cryptoService,
i18nService,
cryptoFunctionService,
stateServiceAbstraction
);
},
deps: [CryptoService, I18nServiceAbstraction, CryptoFunctionService, 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>("syncService"), deps: [] },
{
provide: SettingsService,
@@ -305,7 +348,6 @@ function getBgService<T>(service: keyof MainBackground) {
deps: [],
},
{ provide: ExportService, useFactory: getBgService<ExportService>("exportService"), deps: [] },
{ provide: SendService, useFactory: getBgService<SendService>("sendService"), deps: [] },
{
provide: KeyConnectorService,
useFactory: getBgService<KeyConnectorService>("keyConnectorService"),

View File

@@ -0,0 +1,15 @@
import { BehaviorSubject } from "rxjs";
import { Send } from "@bitwarden/common/models/domain/send";
import { SendView } from "@bitwarden/common/models/view/send.view";
import { SendService } from "@bitwarden/common/services/send/send.service";
import { browserSession, sessionSync } from "../decorators/session-sync-observable";
@browserSession
export class BrowserSendService extends SendService {
@sessionSync({ initializer: Send.fromJSON, initializeAs: "array" })
protected _sends: BehaviorSubject<Send[]>;
@sessionSync({ initializer: SendView.fromJSON, initializeAs: "array" })
protected _sendViews: BehaviorSubject<SendView[]>;
}

View File

@@ -6,6 +6,10 @@ import {
apiServiceFactory,
ApiServiceInitOptions,
} from "../../../background/service_factories/api-service.factory";
import {
CipherFileUploadServiceInitOptions,
cipherFileUploadServiceFactory,
} from "../../../background/service_factories/cipher-file-upload-service.factory";
import {
cryptoServiceFactory,
CryptoServiceInitOptions,
@@ -19,10 +23,6 @@ import {
factory,
FactoryOptions,
} from "../../../background/service_factories/factory-options";
import {
FileUploadServiceInitOptions,
fileUploadServiceFactory,
} from "../../../background/service_factories/file-upload-service.factory";
import {
i18nServiceFactory,
I18nServiceInitOptions,
@@ -50,7 +50,7 @@ export type CipherServiceInitOptions = CipherServiceFactoryOptions &
CryptoServiceInitOptions &
SettingsServiceInitOptions &
ApiServiceInitOptions &
FileUploadServiceInitOptions &
CipherFileUploadServiceInitOptions &
I18nServiceInitOptions &
LogServiceInitOptions &
StateServiceInitOptions &
@@ -69,14 +69,14 @@ export function cipherServiceFactory(
await cryptoServiceFactory(cache, opts),
await settingsServiceFactory(cache, opts),
await apiServiceFactory(cache, opts),
await fileUploadServiceFactory(cache, opts),
await i18nServiceFactory(cache, opts),
opts.cipherServiceOptions?.searchServiceFactory === undefined
? () => cache.searchService as SearchService
: opts.cipherServiceOptions.searchServiceFactory,
await logServiceFactory(cache, opts),
await stateServiceFactory(cache, opts),
await encryptServiceFactory(cache, opts)
await encryptServiceFactory(cache, opts),
await cipherFileUploadServiceFactory(cache, opts)
)
);
}

View File

@@ -10,6 +10,7 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { SendApiService } from "@bitwarden/common/abstractions/send/send-api.service.abstraction";
import { StateService } from "@bitwarden/common/abstractions/state.service";
import { CollectionService } from "@bitwarden/common/admin-console/abstractions/collection.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
@@ -51,7 +52,8 @@ export class AddEditComponent extends BaseAddEditComponent {
private popupUtilsService: PopupUtilsService,
organizationService: OrganizationService,
passwordRepromptService: PasswordRepromptService,
logService: LogService
logService: LogService,
sendApiService: SendApiService
) {
super(
cipherService,
@@ -66,7 +68,8 @@ export class AddEditComponent extends BaseAddEditComponent {
policyService,
logService,
passwordRepromptService,
organizationService
organizationService,
sendApiService
);
}

View File

@@ -31,12 +31,13 @@ import { CryptoService } from "@bitwarden/common/services/crypto.service";
import { EncryptServiceImplementation } from "@bitwarden/common/services/cryptography/encrypt.service.implementation";
import { EnvironmentService } from "@bitwarden/common/services/environment.service";
import { ExportService } from "@bitwarden/common/services/export.service";
import { FileUploadService } from "@bitwarden/common/services/fileUpload.service";
import { FileUploadService } from "@bitwarden/common/services/file-upload/file-upload.service";
import { MemoryStorageService } from "@bitwarden/common/services/memoryStorage.service";
import { NoopMessagingService } from "@bitwarden/common/services/noopMessaging.service";
import { OrganizationUserServiceImplementation } from "@bitwarden/common/services/organization-user/organization-user.service.implementation";
import { SearchService } from "@bitwarden/common/services/search.service";
import { SendService } from "@bitwarden/common/services/send.service";
import { SendApiService } from "@bitwarden/common/services/send/send-api.service";
import { SendService } from "@bitwarden/common/services/send/send.service";
import { SettingsService } from "@bitwarden/common/services/settings.service";
import { StateService } from "@bitwarden/common/services/state.service";
import { StateMigrationService } from "@bitwarden/common/services/stateMigration.service";
@@ -49,6 +50,7 @@ import {
} from "@bitwarden/common/tools/generator/password";
import { InternalFolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
import { CipherService } from "@bitwarden/common/vault/services/cipher.service";
import { CipherFileUploadService } from "@bitwarden/common/vault/services/file-upload/cipher-file-upload.service";
import { FolderApiService } from "@bitwarden/common/vault/services/folder/folder-api.service";
import { FolderService } from "@bitwarden/common/vault/services/folder/folder.service";
import { SyncNotifierService } from "@bitwarden/common/vault/services/sync/sync-notifier.service";
@@ -115,6 +117,7 @@ export class Main {
logService: ConsoleLogService;
sendService: SendService;
fileUploadService: FileUploadService;
cipherFileUploadService: CipherFileUploadService;
keyConnectorService: KeyConnectorService;
userVerificationService: UserVerificationService;
stateService: StateService;
@@ -127,6 +130,7 @@ export class Main {
userVerificationApiService: UserVerificationApiService;
organizationApiService: OrganizationApiServiceAbstraction;
syncNotifierService: SyncNotifierService;
sendApiService: SendApiService;
constructor() {
let p = null;
@@ -217,18 +221,36 @@ export class Main {
this.settingsService = new SettingsService(this.stateService);
this.fileUploadService = new FileUploadService(this.logService, this.apiService);
this.fileUploadService = new FileUploadService(this.logService);
this.sendService = new SendService(
this.cryptoService,
this.i18nService,
this.cryptoFunctionService,
this.stateService
);
this.cipherFileUploadService = new CipherFileUploadService(
this.apiService,
this.fileUploadService
);
this.sendApiService = this.sendApiService = new SendApiService(
this.apiService,
this.fileUploadService,
this.sendService
);
this.cipherService = new CipherService(
this.cryptoService,
this.settingsService,
this.apiService,
this.fileUploadService,
this.i18nService,
null,
this.logService,
this.stateService,
this.encryptService
this.encryptService,
this.cipherFileUploadService
);
this.broadcasterService = new BroadcasterService();
@@ -258,15 +280,6 @@ export class Main {
this.policyService = new PolicyService(this.stateService, this.organizationService);
this.sendService = new SendService(
this.cryptoService,
this.apiService,
this.fileUploadService,
this.i18nService,
this.cryptoFunctionService,
this.stateService
);
this.keyConnectorService = new KeyConnectorService(
this.stateService,
this.cryptoService,
@@ -338,6 +351,7 @@ export class Main {
this.providerService,
this.folderApiService,
this.organizationService,
this.sendApiService,
async (expired: boolean) => await this.logout()
);

View File

@@ -2,7 +2,8 @@ import * as fs from "fs";
import * as path from "path";
import { EnvironmentService } from "@bitwarden/common/abstractions/environment.service";
import { SendService } from "@bitwarden/common/abstractions/send.service";
import { SendApiService } from "@bitwarden/common/abstractions/send/send-api.service.abstraction";
import { SendService } from "@bitwarden/common/abstractions/send/send.service.abstraction";
import { StateService } from "@bitwarden/common/abstractions/state.service";
import { SendType } from "@bitwarden/common/enums/sendType";
import { NodeUtils } from "@bitwarden/common/misc/nodeUtils";
@@ -16,7 +17,8 @@ export class SendCreateCommand {
constructor(
private sendService: SendService,
private stateService: StateService,
private environmentService: EnvironmentService
private environmentService: EnvironmentService,
private sendApiService: SendApiService
) {}
async run(requestJson: any, cmdOptions: Record<string, any>) {
@@ -120,8 +122,8 @@ export class SendCreateCommand {
encSend.deletionDate = sendView.deletionDate;
encSend.expirationDate = sendView.expirationDate;
await this.sendService.saveWithServer([encSend, fileData]);
const newSend = await this.sendService.get(encSend.id);
await this.sendApiService.save([encSend, fileData]);
const newSend = await this.sendService.getFromState(encSend.id);
const decSend = await newSend.decrypt();
const res = new SendResponse(decSend, this.environmentService.getWebVaultUrl());
return Response.success(res);

View File

@@ -1,19 +1,20 @@
import { SendService } from "@bitwarden/common/abstractions/send.service";
import { SendApiService } from "@bitwarden/common/abstractions/send/send-api.service.abstraction";
import { SendService } from "@bitwarden/common/abstractions/send/send.service.abstraction";
import { Response } from "../../models/response";
export class SendDeleteCommand {
constructor(private sendService: SendService) {}
constructor(private sendService: SendService, private sendApiService: SendApiService) {}
async run(id: string) {
const send = await this.sendService.get(id);
const send = await this.sendService.getFromState(id);
if (send == null) {
return Response.notFound();
}
try {
await this.sendService.deleteWithServer(id);
await this.sendApiService.delete(id);
return Response.success();
} catch (e) {
return Response.error(e);

View File

@@ -1,4 +1,5 @@
import { SendService } from "@bitwarden/common/abstractions/send.service";
import { SendApiService } from "@bitwarden/common/abstractions/send/send-api.service.abstraction";
import { SendService } from "@bitwarden/common/abstractions/send/send.service.abstraction";
import { StateService } from "@bitwarden/common/abstractions/state.service";
import { SendType } from "@bitwarden/common/enums/sendType";
@@ -12,7 +13,8 @@ export class SendEditCommand {
constructor(
private sendService: SendService,
private stateService: StateService,
private getCommand: SendGetCommand
private getCommand: SendGetCommand,
private sendApiService: SendApiService
) {}
async run(requestJson: string, cmdOptions: Record<string, any>): Promise<Response> {
@@ -45,7 +47,7 @@ export class SendEditCommand {
req.id = req.id.toLowerCase();
}
const send = await this.sendService.get(req.id);
const send = await this.sendService.getFromState(req.id);
if (send == null) {
return Response.notFound();
@@ -72,7 +74,7 @@ export class SendEditCommand {
encSend.deletionDate = sendView.deletionDate;
encSend.expirationDate = sendView.expirationDate;
await this.sendService.saveWithServer([encSend, encFileData]);
await this.sendApiService.save([encSend, encFileData]);
} catch (e) {
return Response.error(e);
}

View File

@@ -3,7 +3,7 @@ import * as program from "commander";
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
import { EnvironmentService } from "@bitwarden/common/abstractions/environment.service";
import { SearchService } from "@bitwarden/common/abstractions/search.service";
import { SendService } from "@bitwarden/common/abstractions/send.service";
import { SendService } from "@bitwarden/common/abstractions/send/send.service.abstraction";
import { Utils } from "@bitwarden/common/misc/utils";
import { SendView } from "@bitwarden/common/models/view/send.view";
@@ -66,12 +66,12 @@ export class SendGetCommand extends DownloadCommand {
private async getSendView(id: string): Promise<SendView | SendView[]> {
if (Utils.isGuid(id)) {
const send = await this.sendService.get(id);
const send = await this.sendService.getFromState(id);
if (send != null) {
return await send.decrypt();
}
} else if (id.trim() !== "") {
let sends = await this.sendService.getAllDecrypted();
let sends = await this.sendService.getAllDecryptedFromState();
sends = this.searchService.searchSends(sends, id);
if (sends.length > 1) {
return sends;

View File

@@ -1,6 +1,6 @@
import { EnvironmentService } from "@bitwarden/common/abstractions/environment.service";
import { SearchService } from "@bitwarden/common/abstractions/search.service";
import { SendService } from "@bitwarden/common/abstractions/send.service";
import { SendService } from "@bitwarden/common/abstractions/send/send.service.abstraction";
import { Response } from "../../models/response";
import { ListResponse } from "../../models/response/list.response";
@@ -14,7 +14,7 @@ export class SendListCommand {
) {}
async run(cmdOptions: Record<string, any>): Promise<Response> {
let sends = await this.sendService.getAllDecrypted();
let sends = await this.sendService.getAllDecryptedFromState();
const normalizedOptions = new Options(cmdOptions);
if (normalizedOptions.search != null && normalizedOptions.search.trim() !== "") {

View File

@@ -6,6 +6,7 @@ import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
import { CryptoFunctionService } from "@bitwarden/common/abstractions/cryptoFunction.service";
import { EnvironmentService } from "@bitwarden/common/abstractions/environment.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { SendApiService } from "@bitwarden/common/abstractions/send/send-api.service.abstraction";
import { SendType } from "@bitwarden/common/enums/sendType";
import { NodeUtils } from "@bitwarden/common/misc/nodeUtils";
import { Utils } from "@bitwarden/common/misc/utils";
@@ -29,7 +30,8 @@ export class SendReceiveCommand extends DownloadCommand {
cryptoService: CryptoService,
private cryptoFunctionService: CryptoFunctionService,
private platformUtilsService: PlatformUtilsService,
private environmentService: EnvironmentService
private environmentService: EnvironmentService,
private sendApiService: SendApiService
) {
super(cryptoService);
}
@@ -84,7 +86,7 @@ export class SendReceiveCommand extends DownloadCommand {
process.stdout.write(response?.text?.text);
return Response.success();
case SendType.File: {
const downloadData = await this.apiService.getSendFileDownloadData(
const downloadData = await this.sendApiService.getSendFileDownloadData(
response,
this.sendAccessRequest,
apiUrl
@@ -135,7 +137,11 @@ export class SendReceiveCommand extends DownloadCommand {
key: ArrayBuffer
): Promise<Response | SendAccessView> {
try {
const sendResponse = await this.apiService.postSendAccess(id, this.sendAccessRequest, url);
const sendResponse = await this.sendApiService.postSendAccess(
id,
this.sendAccessRequest,
url
);
const sendAccess = new SendAccess(sendResponse);
this.decKey = await this.cryptoService.makeSendKey(key);

View File

@@ -1,14 +1,15 @@
import { SendService } from "@bitwarden/common/abstractions/send.service";
import { SendApiService } from "@bitwarden/common/abstractions/send/send-api.service.abstraction";
import { SendService } from "@bitwarden/common/abstractions/send/send.service.abstraction";
import { Response } from "../../models/response";
import { SendResponse } from "../../models/response/send.response";
export class SendRemovePasswordCommand {
constructor(private sendService: SendService) {}
constructor(private sendService: SendService, private sendApiService: SendApiService) {}
async run(id: string) {
try {
await this.sendService.removePasswordWithServer(id);
await this.sendApiService.removePassword(id);
const updatedSend = await this.sendService.get(id);
const decSend = await updatedSend.decrypt();

View File

@@ -133,9 +133,10 @@ export class ServeCommand {
this.sendCreateCommand = new SendCreateCommand(
this.main.sendService,
this.main.stateService,
this.main.environmentService
this.main.environmentService,
this.main.sendApiService
);
this.sendDeleteCommand = new SendDeleteCommand(this.main.sendService);
this.sendDeleteCommand = new SendDeleteCommand(this.main.sendService, this.main.sendApiService);
this.sendGetCommand = new SendGetCommand(
this.main.sendService,
this.main.environmentService,
@@ -145,14 +146,18 @@ export class ServeCommand {
this.sendEditCommand = new SendEditCommand(
this.main.sendService,
this.main.stateService,
this.sendGetCommand
this.sendGetCommand,
this.main.sendApiService
);
this.sendListCommand = new SendListCommand(
this.main.sendService,
this.main.environmentService,
this.main.searchService
);
this.sendRemovePasswordCommand = new SendRemovePasswordCommand(this.main.sendService);
this.sendRemovePasswordCommand = new SendRemovePasswordCommand(
this.main.sendService,
this.main.sendApiService
);
}
async run(options: program.OptionValues) {

View File

@@ -109,7 +109,8 @@ export class SendProgram extends Program {
this.main.cryptoService,
this.main.cryptoFunctionService,
this.main.platformUtilsService,
this.main.environmentService
this.main.environmentService,
this.main.sendApiService
);
const response = await cmd.run(url, options);
this.processResponse(response);
@@ -259,7 +260,12 @@ export class SendProgram extends Program {
this.main.searchService,
this.main.cryptoService
);
const cmd = new SendEditCommand(this.main.sendService, this.main.stateService, getCmd);
const cmd = new SendEditCommand(
this.main.sendService,
this.main.stateService,
getCmd,
this.main.sendApiService
);
const response = await cmd.run(encodedJson, options);
this.processResponse(response);
});
@@ -273,7 +279,7 @@ export class SendProgram extends Program {
})
.action(async (id: string) => {
await this.exitIfLocked();
const cmd = new SendDeleteCommand(this.main.sendService);
const cmd = new SendDeleteCommand(this.main.sendService, this.main.sendApiService);
const response = await cmd.run(id);
this.processResponse(response);
});
@@ -287,7 +293,7 @@ export class SendProgram extends Program {
})
.action(async (id: string) => {
await this.exitIfLocked();
const cmd = new SendRemovePasswordCommand(this.main.sendService);
const cmd = new SendRemovePasswordCommand(this.main.sendService, this.main.sendApiService);
const response = await cmd.run(id);
this.processResponse(response);
});
@@ -327,7 +333,8 @@ export class SendProgram extends Program {
const cmd = new SendCreateCommand(
this.main.sendService,
this.main.stateService,
this.main.environmentService
this.main.environmentService,
this.main.sendApiService
);
return await cmd.run(encodedJson, options);
}

View File

@@ -7,7 +7,8 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { SendService } from "@bitwarden/common/abstractions/send.service";
import { SendApiService } from "@bitwarden/common/abstractions/send/send-api.service.abstraction";
import { SendService } from "@bitwarden/common/abstractions/send/send.service.abstraction";
import { StateService } from "@bitwarden/common/abstractions/state.service";
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
@@ -25,7 +26,8 @@ export class AddEditComponent extends BaseAddEditComponent {
stateService: StateService,
messagingService: MessagingService,
policyService: PolicyService,
logService: LogService
logService: LogService,
sendApiService: SendApiService
) {
super(
i18nService,
@@ -36,7 +38,8 @@ export class AddEditComponent extends BaseAddEditComponent {
messagingService,
policyService,
logService,
stateService
stateService,
sendApiService
);
}

View File

@@ -7,7 +7,8 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { SearchService } from "@bitwarden/common/abstractions/search.service";
import { SendService } from "@bitwarden/common/abstractions/send.service";
import { SendApiService } from "@bitwarden/common/abstractions/send/send-api.service.abstraction";
import { SendService } from "@bitwarden/common/abstractions/send/send.service.abstraction";
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
import { SendView } from "@bitwarden/common/models/view/send.view";
@@ -44,7 +45,8 @@ export class SendComponent extends BaseSendComponent implements OnInit, OnDestro
searchService: SearchService,
policyService: PolicyService,
private searchBarService: SearchBarService,
logService: LogService
logService: LogService,
sendApiService: SendApiService
) {
super(
sendService,
@@ -54,7 +56,8 @@ export class SendComponent extends BaseSendComponent implements OnInit, OnDestro
ngZone,
searchService,
policyService,
logService
logService,
sendApiService
);
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
this.searchBarService.searchText$.subscribe((searchText) => {

View File

@@ -9,6 +9,7 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { SendApiService } from "@bitwarden/common/abstractions/send/send-api.service.abstraction";
import { StateService } from "@bitwarden/common/abstractions/state.service";
import { CollectionService } from "@bitwarden/common/admin-console/abstractions/collection.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
@@ -41,7 +42,8 @@ export class AddEditComponent extends BaseAddEditComponent implements OnChanges,
private broadcasterService: BroadcasterService,
private ngZone: NgZone,
logService: LogService,
organizationService: OrganizationService
organizationService: OrganizationService,
sendApiService: SendApiService
) {
super(
cipherService,
@@ -56,7 +58,8 @@ export class AddEditComponent extends BaseAddEditComponent implements OnChanges,
policyService,
logService,
passwordRepromptService,
organizationService
organizationService,
sendApiService
);
}

View File

@@ -7,6 +7,7 @@ import { CryptoFunctionService } from "@bitwarden/common/abstractions/cryptoFunc
import { FileDownloadService } from "@bitwarden/common/abstractions/fileDownload/fileDownload.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { SendApiService } from "@bitwarden/common/abstractions/send/send-api.service.abstraction";
import { SEND_KDF_ITERATIONS } from "@bitwarden/common/enums/kdfType";
import { SendType } from "@bitwarden/common/enums/sendType";
import { Utils } from "@bitwarden/common/misc/utils";
@@ -48,7 +49,8 @@ export class AccessComponent implements OnInit {
private platformUtilsService: PlatformUtilsService,
private route: ActivatedRoute,
private cryptoService: CryptoService,
private fileDownloadService: FileDownloadService
private fileDownloadService: FileDownloadService,
private sendApiService: SendApiService
) {}
get sendText() {
@@ -93,7 +95,7 @@ export class AccessComponent implements OnInit {
return;
}
const downloadData = await this.apiService.getSendFileDownloadData(
const downloadData = await this.sendApiService.getSendFileDownloadData(
this.send,
this.accessRequest
);
@@ -157,9 +159,9 @@ export class AccessComponent implements OnInit {
try {
let sendResponse: SendAccessResponse = null;
if (this.loading) {
sendResponse = await this.apiService.postSendAccess(this.id, this.accessRequest);
sendResponse = await this.sendApiService.postSendAccess(this.id, this.accessRequest);
} else {
this.formPromise = this.apiService.postSendAccess(this.id, this.accessRequest);
this.formPromise = this.sendApiService.postSendAccess(this.id, this.accessRequest);
sendResponse = await this.formPromise;
}
this.passwordRequired = false;

View File

@@ -7,7 +7,8 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { SendService } from "@bitwarden/common/abstractions/send.service";
import { SendApiService } from "@bitwarden/common/abstractions/send/send-api.service.abstraction";
import { SendService } from "@bitwarden/common/abstractions/send/send.service.abstraction";
import { StateService } from "@bitwarden/common/abstractions/state.service";
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
@@ -27,7 +28,8 @@ export class AddEditComponent extends BaseAddEditComponent {
stateService: StateService,
messagingService: MessagingService,
policyService: PolicyService,
logService: LogService
logService: LogService,
sendApiService: SendApiService
) {
super(
i18nService,
@@ -38,7 +40,8 @@ export class AddEditComponent extends BaseAddEditComponent {
messagingService,
policyService,
logService,
stateService
stateService,
sendApiService
);
}

View File

@@ -8,7 +8,8 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { SearchService } from "@bitwarden/common/abstractions/search.service";
import { SendService } from "@bitwarden/common/abstractions/send.service";
import { SendApiService } from "@bitwarden/common/abstractions/send/send-api.service.abstraction";
import { SendService } from "@bitwarden/common/abstractions/send/send.service.abstraction";
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
import { SendView } from "@bitwarden/common/models/view/send.view";
import { Icons } from "@bitwarden/components";
@@ -36,7 +37,8 @@ export class SendComponent extends BaseSendComponent {
policyService: PolicyService,
private modalService: ModalService,
private broadcasterService: BroadcasterService,
logService: LogService
logService: LogService,
sendApiService: SendApiService
) {
super(
sendService,
@@ -46,7 +48,8 @@ export class SendComponent extends BaseSendComponent {
ngZone,
searchService,
policyService,
logService
logService,
sendApiService
);
}

View File

@@ -11,7 +11,7 @@ import { MessagingService } from "@bitwarden/common/abstractions/messaging.servi
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import { OrganizationUserResetPasswordEnrollmentRequest } from "@bitwarden/common/abstractions/organization-user/requests";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { SendService } from "@bitwarden/common/abstractions/send.service";
import { SendService } from "@bitwarden/common/abstractions/send/send.service.abstraction";
import { StateService } from "@bitwarden/common/abstractions/state.service";
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization-api.service.abstraction";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
@@ -240,7 +240,7 @@ export class ChangePasswordComponent extends BaseChangePasswordComponent {
request.ciphers.push(new CipherWithIdRequest(cipher));
}
const sends = await this.sendService.getAll();
const sends = await firstValueFrom(this.sendService.sends$);
await Promise.all(
sends.map(async (send) => {
const cryptoKey = await this.cryptoService.decryptToBytes(send.key, null);

View File

@@ -7,6 +7,7 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { SendApiService } from "@bitwarden/common/abstractions/send/send-api.service.abstraction";
import { StateService } from "@bitwarden/common/abstractions/state.service";
import { TotpService } from "@bitwarden/common/abstractions/totp.service";
import { CollectionService } from "@bitwarden/common/admin-console/abstractions/collection.service";
@@ -56,7 +57,8 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit, On
protected policyService: PolicyService,
organizationService: OrganizationService,
logService: LogService,
passwordRepromptService: PasswordRepromptService
passwordRepromptService: PasswordRepromptService,
sendApiService: SendApiService
) {
super(
cipherService,
@@ -71,7 +73,8 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit, On
policyService,
logService,
passwordRepromptService,
organizationService
organizationService,
sendApiService
);
}

View File

@@ -7,6 +7,7 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { SendApiService } from "@bitwarden/common/abstractions/send/send-api.service.abstraction";
import { StateService } from "@bitwarden/common/abstractions/state.service";
import { TotpService } from "@bitwarden/common/abstractions/totp.service";
import { CollectionService } from "@bitwarden/common/admin-console/abstractions/collection.service";
@@ -47,7 +48,8 @@ export class AddEditComponent extends BaseAddEditComponent {
policyService: PolicyService,
logService: LogService,
passwordRepromptService: PasswordRepromptService,
organizationService: OrganizationService
organizationService: OrganizationService,
sendApiService: SendApiService
) {
super(
cipherService,
@@ -64,7 +66,8 @@ export class AddEditComponent extends BaseAddEditComponent {
policyService,
organizationService,
logService,
passwordRepromptService
passwordRepromptService,
sendApiService
);
}

View File

@@ -6,6 +6,7 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { SendApiService } from "@bitwarden/common/abstractions/send/send-api.service.abstraction";
import { StateService } from "@bitwarden/common/abstractions/state.service";
import { TotpService } from "@bitwarden/common/abstractions/totp.service";
import { CollectionService } from "@bitwarden/common/admin-console/abstractions/collection.service";
@@ -43,7 +44,8 @@ export class EmergencyAddEditComponent extends BaseAddEditComponent {
policyService: PolicyService,
passwordRepromptService: PasswordRepromptService,
organizationService: OrganizationService,
logService: LogService
logService: LogService,
sendApiService: SendApiService
) {
super(
cipherService,
@@ -60,7 +62,8 @@ export class EmergencyAddEditComponent extends BaseAddEditComponent {
policyService,
organizationService,
logService,
passwordRepromptService
passwordRepromptService,
sendApiService
);
}