mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +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:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user