1
0
mirror of https://github.com/bitwarden/browser synced 2026-03-02 11:31:44 +00:00

[Pm-13097] Rename cryptoservice to keyservice and move it to km ownership (#11358)

* Rename cryptoservice to keyservice

* Rename cryptoservice to keyservice

* Move key service to key management ownership

* Remove accidentally added file

* Fix cli build

* Fix browser build

* Run prettier

* Fix builds

* Fix cli build

* Fix tests

* Fix incorrect renames

* Rename webauthn-login-crypto-service

* Fix build errors due to merge conflicts

* Fix linting
This commit is contained in:
Bernd Schoolmann
2024-10-24 19:41:30 +02:00
committed by GitHub
parent 554171b688
commit b486fcc689
229 changed files with 1385 additions and 1446 deletions

View File

@@ -3,16 +3,16 @@ import {
OrganizationUserConfirmRequest,
} from "@bitwarden/admin-console/common";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { KeyService } from "@bitwarden/key-management";
import { Response } from "../../models/response";
export class ConfirmCommand {
constructor(
private apiService: ApiService,
private cryptoService: CryptoService,
private keyService: KeyService,
private encryptService: EncryptService,
private organizationUserApiService: OrganizationUserApiService,
) {}
@@ -42,7 +42,7 @@ export class ConfirmCommand {
return Response.badRequest("`" + options.organizationId + "` is not a GUID.");
}
try {
const orgKey = await this.cryptoService.getOrgKey(options.organizationId);
const orgKey = await this.keyService.getOrgKey(options.organizationId);
if (orgKey == null) {
throw new Error("No encryption key for this organization.");
}

View File

@@ -29,7 +29,6 @@ import { TwoFactorEmailRequest } from "@bitwarden/common/auth/models/request/two
import { UpdateTempPasswordRequest } from "@bitwarden/common/auth/models/request/update-temp-password.request";
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
@@ -38,6 +37,7 @@ import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/sym
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
import { KeyService } from "@bitwarden/key-management";
import { NodeUtils } from "@bitwarden/node/node-utils";
import { Response } from "../../models/response";
@@ -61,7 +61,7 @@ export class LoginCommand {
protected passwordStrengthService: PasswordStrengthServiceAbstraction,
protected platformUtilsService: PlatformUtilsService,
protected accountService: AccountService,
protected cryptoService: CryptoService,
protected keyService: KeyService,
protected policyService: PolicyService,
protected twoFactorService: TwoFactorService,
protected syncService: SyncService,
@@ -421,7 +421,7 @@ export class LoginCommand {
);
const request = new PasswordRequest();
request.masterPasswordHash = await this.cryptoService.hashMasterKey(currentPassword, null);
request.masterPasswordHash = await this.keyService.hashMasterKey(currentPassword, null);
request.masterPasswordHint = hint;
request.newMasterPasswordHash = newPasswordHash;
request.key = newUserKey[1].encryptedString;
@@ -570,21 +570,21 @@ export class LoginCommand {
const kdfConfig = await this.kdfConfigService.getKdfConfig();
// Create new key and hash new password
const newMasterKey = await this.cryptoService.makeMasterKey(
const newMasterKey = await this.keyService.makeMasterKey(
masterPassword,
this.email.trim().toLowerCase(),
kdfConfig,
);
const newPasswordHash = await this.cryptoService.hashMasterKey(masterPassword, newMasterKey);
const newPasswordHash = await this.keyService.hashMasterKey(masterPassword, newMasterKey);
// Grab user key
const userKey = await this.cryptoService.getUserKey();
const userKey = await this.keyService.getUserKey();
if (!userKey) {
throw new Error("User key not found.");
}
// Re-encrypt user key with new master key
const newUserKey = await this.cryptoService.encryptUserKeyWithMasterKey(newMasterKey, userKey);
const newUserKey = await this.keyService.encryptUserKeyWithMasterKey(newMasterKey, userKey);
return { newPasswordHash, newUserKey: newUserKey, hint: masterPasswordHint };
}

View File

@@ -8,12 +8,12 @@ import { UserVerificationService } from "@bitwarden/common/auth/abstractions/use
import { VerificationType } from "@bitwarden/common/auth/enums/verification-type";
import { MasterPasswordVerification } from "@bitwarden/common/auth/types/verification";
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { ConsoleLogService } from "@bitwarden/common/platform/services/console-log.service";
import { MasterKey } from "@bitwarden/common/types/key";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { KeyService } from "@bitwarden/key-management";
import { ConvertToKeyConnectorCommand } from "../../commands/convert-to-key-connector.command";
import { Response } from "../../models/response";
@@ -24,7 +24,7 @@ export class UnlockCommand {
constructor(
private accountService: AccountService,
private masterPasswordService: InternalMasterPasswordServiceAbstraction,
private cryptoService: CryptoService,
private keyService: KeyService,
private userVerificationService: UserVerificationService,
private cryptoFunctionService: CryptoFunctionService,
private logService: ConsoleLogService,
@@ -69,7 +69,7 @@ export class UnlockCommand {
}
const userKey = await this.masterPasswordService.decryptUserKeyWithMasterKey(masterKey);
await this.cryptoService.setUserKey(userKey, userId);
await this.keyService.setUserKey(userKey, userId);
if (await this.keyConnectorService.getConvertAccountRequired()) {
const convertToKeyConnectorCommand = new ConvertToKeyConnectorCommand(

View File

@@ -171,7 +171,7 @@ export abstract class BaseProgram {
const command = new UnlockCommand(
this.serviceContainer.accountService,
this.serviceContainer.masterPasswordService,
this.serviceContainer.cryptoService,
this.serviceContainer.keyService,
this.serviceContainer.userVerificationService,
this.serviceContainer.cryptoFunctionService,
this.serviceContainer.logService,

View File

@@ -7,12 +7,12 @@ import { AccountService } from "@bitwarden/common/auth/abstractions/account.serv
import { CipherExport } from "@bitwarden/common/models/export/cipher.export";
import { CollectionExport } from "@bitwarden/common/models/export/collection.export";
import { FolderExport } from "@bitwarden/common/models/export/folder.export";
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
import { KeyService } from "@bitwarden/key-management";
import { OrganizationCollectionRequest } from "../admin-console/models/request/organization-collection.request";
import { OrganizationCollectionResponse } from "../admin-console/models/response/organization-collection.response";
@@ -25,7 +25,7 @@ export class EditCommand {
constructor(
private cipherService: CipherService,
private folderService: FolderService,
private cryptoService: CryptoService,
private keyService: KeyService,
private encryptService: EncryptService,
private apiService: ApiService,
private folderApiService: FolderApiServiceAbstraction,
@@ -143,7 +143,7 @@ export class EditCommand {
folderView = FolderExport.toView(req, folderView);
const activeUserId = await firstValueFrom(this.accountService.activeAccount$);
const userKey = await this.cryptoService.getUserKeyWithLegacySupport(activeUserId.id);
const userKey = await this.keyService.getUserKeyWithLegacySupport(activeUserId.id);
const encFolder = await this.folderService.encrypt(folderView, userKey);
try {
await this.folderApiService.save(encFolder);
@@ -174,7 +174,7 @@ export class EditCommand {
return Response.badRequest("`organizationid` option does not match request object.");
}
try {
const orgKey = await this.cryptoService.getOrgKey(req.organizationId);
const orgKey = await this.keyService.getOrgKey(req.organizationId);
if (orgKey == null) {
throw new Error("No encryption key for this organization.");
}

View File

@@ -20,7 +20,6 @@ import { LoginUriExport } from "@bitwarden/common/models/export/login-uri.export
import { LoginExport } from "@bitwarden/common/models/export/login.export";
import { SecureNoteExport } from "@bitwarden/common/models/export/secure-note.export";
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
@@ -33,6 +32,7 @@ import { TotpService } from "@bitwarden/common/vault/abstractions/totp.service";
import { CipherType } from "@bitwarden/common/vault/enums";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
import { KeyService } from "@bitwarden/key-management";
import { OrganizationCollectionRequest } from "../admin-console/models/request/organization-collection.request";
import { OrganizationCollectionResponse } from "../admin-console/models/response/organization-collection.response";
@@ -56,7 +56,7 @@ export class GetCommand extends DownloadCommand {
private collectionService: CollectionService,
private totpService: TotpService,
private auditService: AuditService,
private cryptoService: CryptoService,
private keyService: KeyService,
encryptService: EncryptService,
private stateService: StateService,
private searchService: SearchService,
@@ -377,7 +377,7 @@ export class GetCommand extends DownloadCommand {
const key =
attachments[0].key != null
? attachments[0].key
: await this.cryptoService.getOrgKey(cipher.organizationId);
: await this.keyService.getOrgKey(cipher.organizationId);
return await this.saveAttachmentToFile(url, key, attachments[0].fileName, options.output);
}
@@ -411,7 +411,7 @@ export class GetCommand extends DownloadCommand {
if (Utils.isGuid(id)) {
const collection = await this.collectionService.get(id);
if (collection != null) {
const orgKeys = await firstValueFrom(this.cryptoService.activeUserOrgKeys$);
const orgKeys = await firstValueFrom(this.keyService.activeUserOrgKeys$);
decCollection = await collection.decrypt(
orgKeys[collection.organizationId as OrganizationId],
);
@@ -445,7 +445,7 @@ export class GetCommand extends DownloadCommand {
return Response.badRequest("`" + options.organizationId + "` is not a GUID.");
}
try {
const orgKey = await this.cryptoService.getOrgKey(options.organizationId);
const orgKey = await this.keyService.getOrgKey(options.organizationId);
if (orgKey == null) {
throw new Error("No encryption key for this organization.");
}
@@ -553,13 +553,13 @@ export class GetCommand extends DownloadCommand {
const activeUserId = await firstValueFrom(
this.accountService.activeAccount$.pipe(map((a) => a?.id)),
);
const publicKey = await firstValueFrom(this.cryptoService.userPublicKey$(activeUserId));
fingerprint = await this.cryptoService.getFingerprint(activeUserId, publicKey);
const publicKey = await firstValueFrom(this.keyService.userPublicKey$(activeUserId));
fingerprint = await this.keyService.getFingerprint(activeUserId, publicKey);
} else if (Utils.isGuid(id)) {
try {
const response = await this.apiService.getUserPublicKey(id);
const pubKey = Utils.fromB64ToArray(response.publicKey);
fingerprint = await this.cryptoService.getFingerprint(id, pubKey);
fingerprint = await this.keyService.getFingerprint(id, pubKey);
} catch {
// eslint-disable-next-line
}

View File

@@ -56,7 +56,7 @@ export class OssServeConfigurator {
this.serviceContainer.collectionService,
this.serviceContainer.totpService,
this.serviceContainer.auditService,
this.serviceContainer.cryptoService,
this.serviceContainer.keyService,
this.serviceContainer.encryptService,
this.serviceContainer.stateService,
this.serviceContainer.searchService,
@@ -79,7 +79,7 @@ export class OssServeConfigurator {
this.createCommand = new CreateCommand(
this.serviceContainer.cipherService,
this.serviceContainer.folderService,
this.serviceContainer.cryptoService,
this.serviceContainer.keyService,
this.serviceContainer.encryptService,
this.serviceContainer.apiService,
this.serviceContainer.folderApiService,
@@ -90,7 +90,7 @@ export class OssServeConfigurator {
this.editCommand = new EditCommand(
this.serviceContainer.cipherService,
this.serviceContainer.folderService,
this.serviceContainer.cryptoService,
this.serviceContainer.keyService,
this.serviceContainer.encryptService,
this.serviceContainer.apiService,
this.serviceContainer.folderApiService,
@@ -117,7 +117,7 @@ export class OssServeConfigurator {
);
this.confirmCommand = new ConfirmCommand(
this.serviceContainer.apiService,
this.serviceContainer.cryptoService,
this.serviceContainer.keyService,
this.serviceContainer.encryptService,
this.serviceContainer.organizationUserApiService,
);
@@ -130,7 +130,7 @@ export class OssServeConfigurator {
this.unlockCommand = new UnlockCommand(
this.serviceContainer.accountService,
this.serviceContainer.masterPasswordService,
this.serviceContainer.cryptoService,
this.serviceContainer.keyService,
this.serviceContainer.userVerificationService,
this.serviceContainer.cryptoFunctionService,
this.serviceContainer.logService,
@@ -399,7 +399,7 @@ export class OssServeConfigurator {
this.processResponse(res, Response.error("You are not logged in."));
return true;
}
if (await this.serviceContainer.cryptoService.hasUserKey()) {
if (await this.serviceContainer.keyService.hasUserKey()) {
return false;
}
this.processResponse(res, Response.error("Vault is locked."));

View File

@@ -150,7 +150,7 @@ export class Program extends BaseProgram {
this.serviceContainer.passwordStrengthService,
this.serviceContainer.platformUtilsService,
this.serviceContainer.accountService,
this.serviceContainer.cryptoService,
this.serviceContainer.keyService,
this.serviceContainer.policyService,
this.serviceContainer.twoFactorService,
this.serviceContainer.syncService,
@@ -258,7 +258,7 @@ export class Program extends BaseProgram {
const command = new UnlockCommand(
this.serviceContainer.accountService,
this.serviceContainer.masterPasswordService,
this.serviceContainer.cryptoService,
this.serviceContainer.keyService,
this.serviceContainer.userVerificationService,
this.serviceContainer.cryptoFunctionService,
this.serviceContainer.logService,

View File

@@ -79,7 +79,6 @@ import { AppIdService } from "@bitwarden/common/platform/services/app-id.service
import { ConfigApiService } from "@bitwarden/common/platform/services/config/config-api.service";
import { DefaultConfigService } from "@bitwarden/common/platform/services/config/default-config.service";
import { ContainerService } from "@bitwarden/common/platform/services/container.service";
import { CryptoService } from "@bitwarden/common/platform/services/crypto.service";
import { EncryptServiceImplementation } from "@bitwarden/common/platform/services/cryptography/encrypt.service.implementation";
import { FallbackBulkEncryptService } from "@bitwarden/common/platform/services/cryptography/fallback-bulk-encrypt.service";
import { DefaultEnvironmentService } from "@bitwarden/common/platform/services/default-environment.service";
@@ -127,6 +126,7 @@ import {
import { SendApiService } from "@bitwarden/common/tools/send/services/send-api.service";
import { SendStateProvider } from "@bitwarden/common/tools/send/services/send-state.provider";
import { SendService } from "@bitwarden/common/tools/send/services/send.service";
import { UserId } from "@bitwarden/common/types/guid";
import { VaultTimeoutStringType } from "@bitwarden/common/types/vault-timeout.type";
import { InternalFolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
import {
@@ -148,7 +148,11 @@ import {
ImportService,
ImportServiceAbstraction,
} from "@bitwarden/importer/core";
import { BiometricStateService, DefaultBiometricStateService } from "@bitwarden/key-management";
import {
DefaultKeyService as KeyService,
BiometricStateService,
DefaultBiometricStateService,
} from "@bitwarden/key-management";
import { NodeCryptoFunctionService } from "@bitwarden/node/services/node-crypto-function.service";
import {
IndividualVaultExportService,
@@ -187,7 +191,7 @@ export class ServiceContainer {
memoryStorageForStateProviders: MemoryStorageServiceForStateProviders;
i18nService: I18nService;
platformUtilsService: CliPlatformUtilsService;
cryptoService: CryptoService;
keyService: KeyService;
tokenService: TokenService;
appIdService: AppIdService;
apiService: NodeApiService;
@@ -416,7 +420,7 @@ export class ServiceContainer {
this.stateService,
);
this.cryptoService = new CryptoService(
this.keyService = new KeyService(
this.pinService,
this.masterPasswordService,
this.keyGenerationService,
@@ -449,7 +453,7 @@ export class ServiceContainer {
this.accountService,
this.pinService,
this.userDecryptionOptionsService,
this.cryptoService,
this.keyService,
this.tokenService,
this.policyService,
this.biometricStateService,
@@ -474,7 +478,7 @@ export class ServiceContainer {
customUserAgent,
);
this.containerService = new ContainerService(this.cryptoService, this.encryptService);
this.containerService = new ContainerService(this.keyService, this.encryptService);
this.domainSettingsService = new DefaultDomainSettingsService(this.stateProvider);
@@ -483,7 +487,7 @@ export class ServiceContainer {
this.sendStateProvider = new SendStateProvider(this.stateProvider);
this.sendService = new SendService(
this.cryptoService,
this.keyService,
this.i18nService,
this.keyGenerationService,
this.sendStateProvider,
@@ -504,7 +508,7 @@ export class ServiceContainer {
this.searchService = new SearchService(this.logService, this.i18nService, this.stateProvider);
this.collectionService = new DefaultCollectionService(
this.cryptoService,
this.keyService,
this.encryptService,
this.i18nService,
this.stateProvider,
@@ -517,7 +521,7 @@ export class ServiceContainer {
this.keyConnectorService = new KeyConnectorService(
this.accountService,
this.masterPasswordService,
this.cryptoService,
this.keyService,
this.apiService,
this.tokenService,
this.logService,
@@ -542,7 +546,7 @@ export class ServiceContainer {
this.platformUtilsService,
this.accountService,
this.kdfConfigService,
this.cryptoService,
this.keyService,
this.apiService,
customUserAgent,
);
@@ -551,7 +555,7 @@ export class ServiceContainer {
this.passwordGenerationService = legacyPasswordGenerationServiceFactory(
this.encryptService,
this.cryptoService,
this.keyService,
this.policyService,
this.accountService,
this.stateProvider,
@@ -561,7 +565,7 @@ export class ServiceContainer {
this.appIdService,
this.accountService,
this.masterPasswordService,
this.cryptoService,
this.keyService,
this.encryptService,
this.apiService,
this.stateProvider,
@@ -576,7 +580,7 @@ export class ServiceContainer {
this.authService = new AuthService(
this.accountService,
this.messagingService,
this.cryptoService,
this.keyService,
this.apiService,
this.stateService,
this.tokenService,
@@ -596,7 +600,7 @@ export class ServiceContainer {
this.deviceTrustService = new DeviceTrustService(
this.keyGenerationService,
this.cryptoFunctionService,
this.cryptoService,
this.keyService,
this.encryptService,
this.appIdService,
this.devicesApiService,
@@ -612,7 +616,7 @@ export class ServiceContainer {
this.loginStrategyService = new LoginStrategyService(
this.accountService,
this.masterPasswordService,
this.cryptoService,
this.keyService,
this.apiService,
this.tokenService,
this.appIdService,
@@ -644,7 +648,7 @@ export class ServiceContainer {
);
this.cipherService = new CipherService(
this.cryptoService,
this.keyService,
this.domainSettingsService,
this.apiService,
this.i18nService,
@@ -660,7 +664,7 @@ export class ServiceContainer {
);
this.folderService = new FolderService(
this.cryptoService,
this.keyService,
this.encryptService,
this.i18nService,
this.cipherService,
@@ -670,12 +674,12 @@ export class ServiceContainer {
this.folderApiService = new FolderApiService(this.folderService, this.apiService);
const lockedCallback = async (userId?: string) =>
await this.cryptoService.clearStoredUserKey(KeySuffixOptions.Auto);
await this.keyService.clearStoredUserKey(KeySuffixOptions.Auto);
this.userVerificationApiService = new UserVerificationApiService(this.apiService);
this.userVerificationService = new UserVerificationService(
this.cryptoService,
this.keyService,
this.accountService,
this.masterPasswordService,
this.i18nService,
@@ -716,7 +720,7 @@ export class ServiceContainer {
this.domainSettingsService,
this.folderService,
this.cipherService,
this.cryptoService,
this.keyService,
this.collectionService,
this.messagingService,
this.policyService,
@@ -747,7 +751,7 @@ export class ServiceContainer {
this.importApiService,
this.i18nService,
this.collectionService,
this.cryptoService,
this.keyService,
this.encryptService,
this.pinService,
this.accountService,
@@ -757,7 +761,7 @@ export class ServiceContainer {
this.folderService,
this.cipherService,
this.pinService,
this.cryptoService,
this.keyService,
this.encryptService,
this.cryptoFunctionService,
this.kdfConfigService,
@@ -768,7 +772,7 @@ export class ServiceContainer {
this.cipherService,
this.apiService,
this.pinService,
this.cryptoService,
this.keyService,
this.encryptService,
this.cryptoFunctionService,
this.collectionService,
@@ -781,7 +785,7 @@ export class ServiceContainer {
this.organizationExportService,
);
this.userAutoUnlockKeyService = new UserAutoUnlockKeyService(this.cryptoService);
this.userAutoUnlockKeyService = new UserAutoUnlockKeyService(this.keyService);
this.auditService = new AuditService(this.cryptoFunctionService, this.apiService);
@@ -823,17 +827,17 @@ export class ServiceContainer {
});
const userId = await firstValueFrom(this.accountService.activeAccount$.pipe(map((a) => a?.id)));
await Promise.all([
this.eventUploadService.uploadEvents(userId),
this.cryptoService.clearKeys(),
this.eventUploadService.uploadEvents(userId as UserId),
this.keyService.clearKeys(),
this.cipherService.clear(userId),
this.folderService.clear(userId),
this.collectionService.clear(userId),
]);
await this.stateEventRunnerService.handleEvent("logout", userId);
await this.stateEventRunnerService.handleEvent("logout", userId as UserId);
await this.stateService.clean();
await this.accountService.clean(userId);
await this.accountService.clean(userId as UserId);
await this.accountService.switchAccount(null);
process.env.BW_SESSION = undefined;
}

View File

@@ -4,7 +4,6 @@ import { firstValueFrom } from "rxjs";
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
@@ -15,6 +14,7 @@ import { SendAccess } from "@bitwarden/common/tools/send/models/domain/send-acce
import { SendAccessRequest } from "@bitwarden/common/tools/send/models/request/send-access.request";
import { SendAccessView } from "@bitwarden/common/tools/send/models/view/send-access.view";
import { SendApiService } from "@bitwarden/common/tools/send/services/send-api.service.abstraction";
import { KeyService } from "@bitwarden/key-management";
import { NodeUtils } from "@bitwarden/node/node-utils";
import { DownloadCommand } from "../../../commands/download.command";
@@ -27,7 +27,7 @@ export class SendReceiveCommand extends DownloadCommand {
private sendAccessRequest: SendAccessRequest;
constructor(
private cryptoService: CryptoService,
private keyService: KeyService,
encryptService: EncryptService,
private cryptoFunctionService: CryptoFunctionService,
private platformUtilsService: PlatformUtilsService,
@@ -146,7 +146,7 @@ export class SendReceiveCommand extends DownloadCommand {
);
const sendAccess = new SendAccess(sendResponse);
this.decKey = await this.cryptoService.makeSendKey(key);
this.decKey = await this.keyService.makeSendKey(key);
return await sendAccess.decrypt(this.decKey);
} catch (e) {
if (e instanceof ErrorResponse) {

View File

@@ -100,7 +100,7 @@ export class SendProgram extends BaseProgram {
})
.action(async (url: string, options: OptionValues) => {
const cmd = new SendReceiveCommand(
this.serviceContainer.cryptoService,
this.serviceContainer.keyService,
this.serviceContainer.encryptService,
this.serviceContainer.cryptoFunctionService,
this.serviceContainer.platformUtilsService,
@@ -142,7 +142,7 @@ export class SendProgram extends BaseProgram {
this.serviceContainer.collectionService,
this.serviceContainer.totpService,
this.serviceContainer.auditService,
this.serviceContainer.cryptoService,
this.serviceContainer.keyService,
this.serviceContainer.encryptService,
this.serviceContainer.stateService,
this.serviceContainer.searchService,

View File

@@ -177,7 +177,7 @@ export class VaultProgram extends BaseProgram {
this.serviceContainer.collectionService,
this.serviceContainer.totpService,
this.serviceContainer.auditService,
this.serviceContainer.cryptoService,
this.serviceContainer.keyService,
this.serviceContainer.encryptService,
this.serviceContainer.stateService,
this.serviceContainer.searchService,
@@ -224,7 +224,7 @@ export class VaultProgram extends BaseProgram {
const command = new CreateCommand(
this.serviceContainer.cipherService,
this.serviceContainer.folderService,
this.serviceContainer.cryptoService,
this.serviceContainer.keyService,
this.serviceContainer.encryptService,
this.serviceContainer.apiService,
this.serviceContainer.folderApiService,
@@ -273,7 +273,7 @@ export class VaultProgram extends BaseProgram {
const command = new EditCommand(
this.serviceContainer.cipherService,
this.serviceContainer.folderService,
this.serviceContainer.cryptoService,
this.serviceContainer.keyService,
this.serviceContainer.encryptService,
this.serviceContainer.apiService,
this.serviceContainer.folderApiService,
@@ -415,7 +415,7 @@ export class VaultProgram extends BaseProgram {
await this.exitIfLocked();
const command = new ConfirmCommand(
this.serviceContainer.apiService,
this.serviceContainer.cryptoService,
this.serviceContainer.keyService,
this.serviceContainer.encryptService,
this.serviceContainer.organizationUserApiService,
);

View File

@@ -12,12 +12,12 @@ import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abs
import { CipherExport } from "@bitwarden/common/models/export/cipher.export";
import { CollectionExport } from "@bitwarden/common/models/export/collection.export";
import { FolderExport } from "@bitwarden/common/models/export/folder.export";
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
import { KeyService } from "@bitwarden/key-management";
import { OrganizationCollectionRequest } from "../admin-console/models/request/organization-collection.request";
import { OrganizationCollectionResponse } from "../admin-console/models/response/organization-collection.response";
@@ -31,7 +31,7 @@ export class CreateCommand {
constructor(
private cipherService: CipherService,
private folderService: FolderService,
private cryptoService: CryptoService,
private keyService: KeyService,
private encryptService: EncryptService,
private apiService: ApiService,
private folderApiService: FolderApiServiceAbstraction,
@@ -141,7 +141,7 @@ export class CreateCommand {
return Response.error("Premium status is required to use this feature.");
}
const userKey = await this.cryptoService.getUserKey();
const userKey = await this.keyService.getUserKey();
if (userKey == null) {
return Response.error(
"You must update your encryption key before you can use this feature. " +
@@ -170,7 +170,7 @@ export class CreateCommand {
private async createFolder(req: FolderExport) {
const activeAccountId = await firstValueFrom(this.accountService.activeAccount$);
const userKey = await this.cryptoService.getUserKeyWithLegacySupport(activeAccountId.id);
const userKey = await this.keyService.getUserKeyWithLegacySupport(activeAccountId.id);
const folder = await this.folderService.encrypt(FolderExport.toView(req), userKey);
try {
await this.folderApiService.save(folder);
@@ -194,7 +194,7 @@ export class CreateCommand {
return Response.badRequest("`organizationid` option does not match request object.");
}
try {
const orgKey = await this.cryptoService.getOrgKey(req.organizationId);
const orgKey = await this.keyService.getOrgKey(req.organizationId);
if (orgKey == null) {
throw new Error("No encryption key for this organization.");
}