1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +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

@@ -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;
}