From 117a5499ec96d11dabd5bb16a3d89635bf06152d Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Mon, 1 Sep 2025 14:20:10 +0200 Subject: [PATCH] Fix build --- .../browser/src/background/main.background.ts | 3 --- apps/web/src/app/core/init.service.ts | 4 ---- .../default-collection.service.spec.ts | 7 ------- .../crypto/models/enc-string.spec.ts | 12 ------------ .../src/tools/send/models/domain/send.spec.ts | 3 --- .../tools/send/services/send.service.spec.ts | 3 --- .../vault/models/domain/attachment.spec.ts | 3 --- .../src/vault/models/domain/cipher.spec.ts | 19 ------------------- .../src/vault/services/cipher.service.spec.ts | 3 --- ...symmetric-key-regeneration.service.spec.ts | 2 -- 10 files changed, 59 deletions(-) diff --git a/apps/browser/src/background/main.background.ts b/apps/browser/src/background/main.background.ts index 4a305eaada2..9b9cfad5122 100644 --- a/apps/browser/src/background/main.background.ts +++ b/apps/browser/src/background/main.background.ts @@ -134,7 +134,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 { ConsoleLogService } from "@bitwarden/common/platform/services/console-log.service"; -import { ContainerService } from "@bitwarden/common/platform/services/container.service"; import { Fido2ActiveRequestManager } from "@bitwarden/common/platform/services/fido2/fido2-active-request-manager"; import { Fido2AuthenticatorService } from "@bitwarden/common/platform/services/fido2/fido2-authenticator.service"; import { Fido2ClientService } from "@bitwarden/common/platform/services/fido2/fido2-client.service"; @@ -337,7 +336,6 @@ export default class MainBackground { passwordStrengthService: PasswordStrengthServiceAbstraction; totpService: TotpServiceAbstraction; autofillService: AutofillServiceAbstraction; - containerService: ContainerService; auditService: AuditServiceAbstraction; authService: AuthServiceAbstraction; loginEmailService: LoginEmailServiceAbstraction; @@ -946,7 +944,6 @@ export default class MainBackground { lockedCallback, logoutCallback, ); - this.containerService = new ContainerService(this.keyService, this.encryptService); this.sendStateProvider = new SendStateProvider(this.stateProvider); this.sendService = new SendService( diff --git a/apps/web/src/app/core/init.service.ts b/apps/web/src/app/core/init.service.ts index db7b819a0ef..7f36c9d8f3b 100644 --- a/apps/web/src/app/core/init.service.ts +++ b/apps/web/src/app/core/init.service.ts @@ -7,7 +7,6 @@ import { WINDOW } from "@bitwarden/angular/services/injection-tokens"; import { EventUploadService as EventUploadServiceAbstraction } from "@bitwarden/common/abstractions/event/event-upload.service"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { TwoFactorService as TwoFactorServiceAbstraction } from "@bitwarden/common/auth/abstractions/two-factor.service"; -import { EncryptService } from "@bitwarden/common/key-management/crypto/abstractions/encrypt.service"; import { DefaultVaultTimeoutService } from "@bitwarden/common/key-management/vault-timeout"; import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/platform/abstractions/i18n.service"; import { SdkLoadService } from "@bitwarden/common/platform/abstractions/sdk/sdk-load.service"; @@ -17,7 +16,6 @@ import { MigrationRunner } from "@bitwarden/common/platform/services/migration-r import { UserAutoUnlockKeyService } from "@bitwarden/common/platform/services/user-auto-unlock-key.service"; import { EventUploadService } from "@bitwarden/common/services/event/event-upload.service"; import { TaskService } from "@bitwarden/common/vault/tasks"; -import { KeyService as KeyServiceAbstraction } from "@bitwarden/key-management"; import { VersionService } from "../platform/version.service"; @@ -30,9 +28,7 @@ export class InitService { private i18nService: I18nServiceAbstraction, private eventUploadService: EventUploadServiceAbstraction, private twoFactorService: TwoFactorServiceAbstraction, - private keyService: KeyServiceAbstraction, private themingService: AbstractThemingService, - private encryptService: EncryptService, private userAutoUnlockKeyService: UserAutoUnlockKeyService, private accountService: AccountService, private versionService: VersionService, diff --git a/libs/admin-console/src/common/collections/services/default-collection.service.spec.ts b/libs/admin-console/src/common/collections/services/default-collection.service.spec.ts index a0332cfb501..d8ec2570a4f 100644 --- a/libs/admin-console/src/common/collections/services/default-collection.service.spec.ts +++ b/libs/admin-console/src/common/collections/services/default-collection.service.spec.ts @@ -6,7 +6,6 @@ import { EncString } from "@bitwarden/common/key-management/crypto/models/enc-st import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { Utils } from "@bitwarden/common/platform/misc/utils"; import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key"; -import { ContainerService } from "@bitwarden/common/platform/services/container.service"; import { FakeStateProvider, makeEncString, @@ -52,8 +51,6 @@ describe("DefaultCollectionService", () => { Promise.resolve(encString.data.replace("ENC_", "DEC_")), ); - (window as any).bitwardenContainerService = new ContainerService(keyService, encryptService); - // Arrange i18nService so that sorting algorithm doesn't throw i18nService.collator = null; @@ -65,10 +62,6 @@ describe("DefaultCollectionService", () => { ); }); - afterEach(() => { - delete (window as any).bitwardenContainerService; - }); - describe("decryptedCollections$", () => { it("emits decrypted collections from state", async () => { // Arrange test data diff --git a/libs/common/src/key-management/crypto/models/enc-string.spec.ts b/libs/common/src/key-management/crypto/models/enc-string.spec.ts index 1be28d58963..8f3093378f5 100644 --- a/libs/common/src/key-management/crypto/models/enc-string.spec.ts +++ b/libs/common/src/key-management/crypto/models/enc-string.spec.ts @@ -7,7 +7,6 @@ import { KeyService } from "@bitwarden/key-management"; import { makeStaticByteArray } from "../../../../spec"; import { EncryptionType } from "../../../platform/enums"; import { SymmetricCryptoKey } from "../../../platform/models/domain/symmetric-crypto-key"; -import { ContainerService } from "../../../platform/services/container.service"; import { UserKey, OrgKey } from "../../../types/key"; import { EncryptService } from "../abstractions/encrypt.service"; @@ -92,13 +91,6 @@ describe("EncString", () => { .calledWith(encString, expect.anything()) .mockResolvedValue("decrypted"); - beforeEach(() => { - (window as any).bitwardenContainerService = new ContainerService( - keyService, - encryptService, - ); - }); - it("decrypts correctly", async () => { const decrypted = await encString.decrypt(null); @@ -258,15 +250,11 @@ describe("EncString", () => { keyService = mock(); encryptService = mock(); encString = new EncString(null); - - (window as any).bitwardenContainerService = new ContainerService(keyService, encryptService); }); it("handles value it can't decrypt", async () => { encryptService.decryptString.mockRejectedValue("error"); - (window as any).bitwardenContainerService = new ContainerService(keyService, encryptService); - const decrypted = await encString.decrypt(null); expect(decrypted).toBe("[error: cannot decrypt]"); diff --git a/libs/common/src/tools/send/models/domain/send.spec.ts b/libs/common/src/tools/send/models/domain/send.spec.ts index e9b0ae7b3b8..2fb4fee54d4 100644 --- a/libs/common/src/tools/send/models/domain/send.spec.ts +++ b/libs/common/src/tools/send/models/domain/send.spec.ts @@ -7,7 +7,6 @@ import { KeyService } from "@bitwarden/key-management"; import { makeStaticByteArray, mockEnc } from "../../../../../spec"; import { EncryptService } from "../../../../key-management/crypto/abstractions/encrypt.service"; import { SymmetricCryptoKey } from "../../../../platform/models/domain/symmetric-crypto-key"; -import { ContainerService } from "../../../../platform/services/container.service"; import { UserKey } from "../../../../types/key"; import { SendType } from "../../enums/send-type"; import { SendData } from "../data/send.data"; @@ -122,8 +121,6 @@ describe("Send", () => { keyService.makeSendKey.mockResolvedValue("cryptoKey" as any); keyService.getUserKey.mockResolvedValue(userKey); - (window as any).bitwardenContainerService = new ContainerService(keyService, encryptService); - const view = await send.decrypt(); expect(text.decrypt).toHaveBeenNthCalledWith(1, "cryptoKey"); diff --git a/libs/common/src/tools/send/services/send.service.spec.ts b/libs/common/src/tools/send/services/send.service.spec.ts index 8b080089c3c..279363e083b 100644 --- a/libs/common/src/tools/send/services/send.service.spec.ts +++ b/libs/common/src/tools/send/services/send.service.spec.ts @@ -19,7 +19,6 @@ import { EnvironmentService } from "../../../platform/abstractions/environment.s import { I18nService } from "../../../platform/abstractions/i18n.service"; import { Utils } from "../../../platform/misc/utils"; import { SymmetricCryptoKey } from "../../../platform/models/domain/symmetric-crypto-key"; -import { ContainerService } from "../../../platform/services/container.service"; import { SelfHostedEnvironment } from "../../../platform/services/default-environment.service"; import { UserId } from "../../../types/guid"; import { UserKey } from "../../../types/key"; @@ -67,8 +66,6 @@ describe("SendService", () => { get: () => of(new SelfHostedEnvironment({ webVault: "https://example.com" })), }); - (window as any).bitwardenContainerService = new ContainerService(keyService, encryptService); - accountService.activeAccountSubject.next({ id: mockUserId, email: "email", diff --git a/libs/common/src/vault/models/domain/attachment.spec.ts b/libs/common/src/vault/models/domain/attachment.spec.ts index 93f693f14c0..5ad8d9506d9 100644 --- a/libs/common/src/vault/models/domain/attachment.spec.ts +++ b/libs/common/src/vault/models/domain/attachment.spec.ts @@ -8,7 +8,6 @@ import { makeStaticByteArray, mockEnc, mockFromJson } from "../../../../spec"; import { EncryptService } from "../../../key-management/crypto/abstractions/encrypt.service"; import { EncryptedString, EncString } from "../../../key-management/crypto/models/enc-string"; import { SymmetricCryptoKey } from "../../../platform/models/domain/symmetric-crypto-key"; -import { ContainerService } from "../../../platform/services/container.service"; import { OrgKey, UserKey } from "../../../types/key"; import { AttachmentData } from "../../models/data/attachment.data"; import { Attachment } from "../../models/domain/attachment"; @@ -66,8 +65,6 @@ describe("Attachment", () => { beforeEach(() => { keyService = mock(); encryptService = mock(); - - (window as any).bitwardenContainerService = new ContainerService(keyService, encryptService); }); it("expected output", async () => { diff --git a/libs/common/src/vault/models/domain/cipher.spec.ts b/libs/common/src/vault/models/domain/cipher.spec.ts index 8afd6824379..592468899e0 100644 --- a/libs/common/src/vault/models/domain/cipher.spec.ts +++ b/libs/common/src/vault/models/domain/cipher.spec.ts @@ -2,9 +2,6 @@ import { mock } from "jest-mock-extended"; import { Jsonify } from "type-fest"; import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key"; -// This import has been flagged as unallowed for this class. It may be involved in a circular dependency loop. -// eslint-disable-next-line no-restricted-imports -import { KeyService } from "@bitwarden/key-management"; import { CipherType as SdkCipherType, UriMatchType, @@ -18,7 +15,6 @@ import { makeStaticByteArray, mockEnc, mockFromJson } from "../../../../spec/uti import { EncryptService } from "../../../key-management/crypto/abstractions/encrypt.service"; import { EncString } from "../../../key-management/crypto/models/enc-string"; import { UriMatchStrategy } from "../../../models/domain/domain-service"; -import { ContainerService } from "../../../platform/services/container.service"; import { InitializerKey } from "../../../platform/services/cryptography/initializer-key"; import { UserId } from "../../../types/guid"; import { CipherService } from "../../abstractions/cipher.service"; @@ -97,14 +93,11 @@ describe("Cipher DTO", () => { login.decrypt.mockResolvedValue(loginView); cipher.login = login; - const keyService = mock(); const encryptService = mock(); const cipherService = mock(); encryptService.unwrapSymmetricKey.mockRejectedValue(new Error("Failed to unwrap key")); - (window as any).bitwardenContainerService = new ContainerService(keyService, encryptService); - const cipherView = await cipher.decrypt( await cipherService.getKeyForCipherKeyDecryption(cipher, mockUserId), ); @@ -315,7 +308,6 @@ describe("Cipher DTO", () => { login.decrypt.mockResolvedValue(loginView); cipher.login = login; - const keyService = mock(); const encryptService = mock(); const cipherService = mock(); @@ -323,8 +315,6 @@ describe("Cipher DTO", () => { new SymmetricCryptoKey(makeStaticByteArray(64)), ); - (window as any).bitwardenContainerService = new ContainerService(keyService, encryptService); - const cipherView = await cipher.decrypt( await cipherService.getKeyForCipherKeyDecryption(cipher, mockUserId), ); @@ -438,7 +428,6 @@ describe("Cipher DTO", () => { cipher.key = mockEnc("EncKey"); cipher.permissions = new CipherPermissionsApi(); - const keyService = mock(); const encryptService = mock(); const cipherService = mock(); @@ -446,8 +435,6 @@ describe("Cipher DTO", () => { new SymmetricCryptoKey(makeStaticByteArray(64)), ); - (window as any).bitwardenContainerService = new ContainerService(keyService, encryptService); - const cipherView = await cipher.decrypt( await cipherService.getKeyForCipherKeyDecryption(cipher, mockUserId), ); @@ -579,7 +566,6 @@ describe("Cipher DTO", () => { card.decrypt.mockResolvedValue(cardView); cipher.card = card; - const keyService = mock(); const encryptService = mock(); const cipherService = mock(); @@ -587,8 +573,6 @@ describe("Cipher DTO", () => { new SymmetricCryptoKey(makeStaticByteArray(64)), ); - (window as any).bitwardenContainerService = new ContainerService(keyService, encryptService); - const cipherView = await cipher.decrypt( await cipherService.getKeyForCipherKeyDecryption(cipher, mockUserId), ); @@ -744,7 +728,6 @@ describe("Cipher DTO", () => { identity.decrypt.mockResolvedValue(identityView); cipher.identity = identity; - const keyService = mock(); const encryptService = mock(); const cipherService = mock(); @@ -752,8 +735,6 @@ describe("Cipher DTO", () => { new SymmetricCryptoKey(makeStaticByteArray(64)), ); - (window as any).bitwardenContainerService = new ContainerService(keyService, encryptService); - const cipherView = await cipher.decrypt( await cipherService.getKeyForCipherKeyDecryption(cipher, mockUserId), ); diff --git a/libs/common/src/vault/services/cipher.service.spec.ts b/libs/common/src/vault/services/cipher.service.spec.ts index 2088f50d1cc..60c863f9186 100644 --- a/libs/common/src/vault/services/cipher.service.spec.ts +++ b/libs/common/src/vault/services/cipher.service.spec.ts @@ -23,7 +23,6 @@ import { I18nService } from "../../platform/abstractions/i18n.service"; import { Utils } from "../../platform/misc/utils"; import { EncArrayBuffer } from "../../platform/models/domain/enc-array-buffer"; import { SymmetricCryptoKey } from "../../platform/models/domain/symmetric-crypto-key"; -import { ContainerService } from "../../platform/services/container.service"; import { CipherId, UserId, OrganizationId, CollectionId } from "../../types/guid"; import { CipherKey, OrgKey, UserKey } from "../../types/key"; import { CipherEncryptionService } from "../abstractions/cipher-encryption.service"; @@ -117,8 +116,6 @@ describe("Cipher Service", () => { encryptService.encryptFileData.mockReturnValue(Promise.resolve(ENCRYPTED_BYTES)); encryptService.encryptString.mockReturnValue(Promise.resolve(new EncString(ENCRYPTED_TEXT))); - (window as any).bitwardenContainerService = new ContainerService(keyService, encryptService); - cipherService = new CipherService( keyService, domainSettingsService, diff --git a/libs/key-management/src/user-asymmetric-key-regeneration/services/default-user-asymmetric-key-regeneration.service.spec.ts b/libs/key-management/src/user-asymmetric-key-regeneration/services/default-user-asymmetric-key-regeneration.service.spec.ts index e57ab74de6b..94456184d74 100644 --- a/libs/key-management/src/user-asymmetric-key-regeneration/services/default-user-asymmetric-key-regeneration.service.spec.ts +++ b/libs/key-management/src/user-asymmetric-key-regeneration/services/default-user-asymmetric-key-regeneration.service.spec.ts @@ -7,7 +7,6 @@ import { EncryptedString } from "@bitwarden/common/key-management/crypto/models/ import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key"; -import { ContainerService } from "@bitwarden/common/platform/services/container.service"; import { MockSdkService } from "@bitwarden/common/platform/spec/mock-sdk.service"; import { makeStaticByteArray, mockEnc } from "@bitwarden/common/spec"; import { CsprngArray } from "@bitwarden/common/types/csprng"; @@ -55,7 +54,6 @@ function setupUserKeyValidation( new SymmetricCryptoKey(makeStaticByteArray(64)), ); encryptService.decryptString.mockResolvedValue("mockDecryptedString"); - (window as any).bitwardenContainerService = new ContainerService(keyService, encryptService); } describe("regenerateIfNeeded", () => {