diff --git a/apps/web/src/app/auth/emergency-access/services/emergency-access.service.spec.ts b/apps/web/src/app/auth/emergency-access/services/emergency-access.service.spec.ts index 3c60e671991..0fd9b642b09 100644 --- a/apps/web/src/app/auth/emergency-access/services/emergency-access.service.spec.ts +++ b/apps/web/src/app/auth/emergency-access/services/emergency-access.service.spec.ts @@ -203,8 +203,14 @@ describe("EmergencyAccessService", () => { { id: "cipher1", decrypted: true }, { id: "cipher2", decrypted: true }, ]); - expect(mockEncryptedCipher1.decrypt).toHaveBeenCalledWith(mockGrantorUserKey, params.activeUserId); - expect(mockEncryptedCipher2.decrypt).toHaveBeenCalledWith(mockGrantorUserKey, params.activeUserId); + expect(mockEncryptedCipher1.decrypt).toHaveBeenCalledWith( + mockGrantorUserKey, + params.activeUserId, + ); + expect(mockEncryptedCipher2.decrypt).toHaveBeenCalledWith( + mockGrantorUserKey, + params.activeUserId, + ); expect(emergencyAccessApiService.postEmergencyAccessView).toHaveBeenCalledWith(params.id); expect(keyService.userPrivateKey$).toHaveBeenCalledWith(params.activeUserId); expect(encryptService.decapsulateKeyUnsigned).toHaveBeenCalledWith( diff --git a/libs/common/src/platform/models/domain/domain-base.ts b/libs/common/src/platform/models/domain/domain-base.ts index 578d3bd55b0..d9c4dccc5e3 100644 --- a/libs/common/src/platform/models/domain/domain-base.ts +++ b/libs/common/src/platform/models/domain/domain-base.ts @@ -10,8 +10,8 @@ import { Utils } from "../../misc/utils"; import { SymmetricCryptoKey } from "./symmetric-crypto-key"; - /** @deprecated */ +// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type type EncStringKeys = ConditionalKeys, EncString>; /** @deprecated */ export type DecryptedObject< 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 5a7c5699d81..56a59742d80 100644 --- a/libs/common/src/tools/send/models/domain/send.spec.ts +++ b/libs/common/src/tools/send/models/domain/send.spec.ts @@ -3,7 +3,12 @@ import { of } from "rxjs"; import mock from "@bitwarden/common/platform/spec/mock-deep"; import { emptyGuid, UserId } from "@bitwarden/common/types/guid"; -import { mockEnc, makeStaticByteArray, mockContainerService, makeSymmetricCryptoKey } from "../../../../../spec"; +import { + mockEnc, + makeStaticByteArray, + mockContainerService, + makeSymmetricCryptoKey, +} from "../../../../../spec"; import { SendType } from "../../enums/send-type"; import { SendData } from "../data/send.data"; @@ -91,13 +96,13 @@ describe("Send", () => { it("Decrypt", async () => { const containerService = mockContainerService(); containerService.getKeyService().userKey$.mockReturnValue(of(makeSymmetricCryptoKey(64))); - containerService.getEncryptService() - .decryptString - .mockResolvedValueOnce("name") + containerService + .getEncryptService() + .decryptString.mockResolvedValueOnce("name") .mockResolvedValueOnce("notes"); - containerService.getEncryptService() - .decryptBytes - .mockResolvedValueOnce(makeStaticByteArray(32)); + containerService + .getEncryptService() + .decryptBytes.mockResolvedValueOnce(makeStaticByteArray(32)); const text = mock(); text.decrypt.mockResolvedValue("textView" as any); diff --git a/libs/common/src/vault/models/domain/attachment.spec.ts b/libs/common/src/vault/models/domain/attachment.spec.ts index 74fd5c546b9..b4872512629 100644 --- a/libs/common/src/vault/models/domain/attachment.spec.ts +++ b/libs/common/src/vault/models/domain/attachment.spec.ts @@ -120,7 +120,7 @@ describe("Attachment", () => { it("gets an organization key if required", async () => { const orgKey = mock(); - keyService.orgKeys$.mockReturnValue(of({ "orgId": orgKey })); + keyService.orgKeys$.mockReturnValue(of({ orgId: orgKey })); await attachment.decrypt(null, "orgId", "", null); @@ -129,7 +129,7 @@ describe("Attachment", () => { }); it("gets the user's decryption key if required", async () => { - keyService.orgKeys$.mockReturnValue(of({ "orgId": mock() })); + keyService.orgKeys$.mockReturnValue(of({ orgId: mock() })); const userKey = new SymmetricCryptoKey(makeStaticByteArray(64)); keyService.userKey$.mockReturnValue(of(userKey as UserKey)); diff --git a/libs/common/src/vault/models/domain/card.spec.ts b/libs/common/src/vault/models/domain/card.spec.ts index f6e3c40fd55..6f59e117750 100644 --- a/libs/common/src/vault/models/domain/card.spec.ts +++ b/libs/common/src/vault/models/domain/card.spec.ts @@ -2,7 +2,12 @@ import { of } from "rxjs"; import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key"; -import { makeSymmetricCryptoKey, mockContainerService, mockEnc, mockFromJson } from "../../../../spec"; +import { + makeSymmetricCryptoKey, + mockContainerService, + mockEnc, + mockFromJson, +} from "../../../../spec"; import { EncryptedString, EncString } from "../../../key-management/crypto/models/enc-string"; import { CardData } from "../../../vault/models/data/card.data"; import { Card } from "../../models/domain/card"; @@ -60,7 +65,7 @@ describe("Card", () => { .getEncryptService() .decryptString.mockImplementation(async (encString: EncString, key: SymmetricCryptoKey) => { return encString.data; - }) + }); const card = new Card(); card.cardholderName = mockEnc("cardHolder"); diff --git a/libs/common/src/vault/models/domain/cipher.spec.ts b/libs/common/src/vault/models/domain/cipher.spec.ts index de399032455..731e2409ab7 100644 --- a/libs/common/src/vault/models/domain/cipher.spec.ts +++ b/libs/common/src/vault/models/domain/cipher.spec.ts @@ -15,7 +15,13 @@ import { EncString as SdkEncString, } from "@bitwarden/sdk-internal"; -import { makeStaticByteArray, makeSymmetricCryptoKey, mockContainerService, mockEnc, mockFromJson } from "../../../../spec/utils"; +import { + makeStaticByteArray, + makeSymmetricCryptoKey, + mockContainerService, + mockEnc, + mockFromJson, +} from "../../../../spec/utils"; 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"; @@ -76,7 +82,7 @@ describe("Cipher DTO", () => { .getEncryptService() .decryptString.mockImplementation(async (encString: EncString, key: SymmetricCryptoKey) => { return encString.data; - }) + }); const cipher = new Cipher(); cipher.id = "id"; diff --git a/libs/common/src/vault/models/domain/fido2-credential.spec.ts b/libs/common/src/vault/models/domain/fido2-credential.spec.ts index 95b4ac26ea6..bf729e11b01 100644 --- a/libs/common/src/vault/models/domain/fido2-credential.spec.ts +++ b/libs/common/src/vault/models/domain/fido2-credential.spec.ts @@ -98,7 +98,7 @@ describe("Fido2Credential", () => { .getEncryptService() .decryptString.mockImplementation(async (encString: EncString, key: SymmetricCryptoKey) => { return encString.data; - }) + }); const credential = new Fido2Credential(); credential.credentialId = mockEnc("credentialId"); diff --git a/libs/common/src/vault/models/domain/field.spec.ts b/libs/common/src/vault/models/domain/field.spec.ts index 64197b9e9bd..cd8297d938b 100644 --- a/libs/common/src/vault/models/domain/field.spec.ts +++ b/libs/common/src/vault/models/domain/field.spec.ts @@ -8,7 +8,12 @@ import { IdentityLinkedIdType, } from "@bitwarden/sdk-internal"; -import { makeSymmetricCryptoKey, mockContainerService, mockEnc, mockFromJson } from "../../../../spec"; +import { + makeSymmetricCryptoKey, + mockContainerService, + mockEnc, + mockFromJson, +} from "../../../../spec"; import { EncryptedString, EncString } from "../../../key-management/crypto/models/enc-string"; import { CardLinkedId, IdentityLinkedId, LoginLinkedId } from "../../enums"; import { FieldData } from "../../models/data/field.data"; @@ -57,7 +62,8 @@ describe("Field", () => { it("Decrypt", async () => { const containerService = mockContainerService(); containerService.getKeyService().userKey$.mockReturnValue(of(makeSymmetricCryptoKey(64))); - containerService.getEncryptService() + containerService + .getEncryptService() .decryptString.mockImplementation(async (encString: EncString, key: any) => { return encString.data; }); diff --git a/libs/common/src/vault/models/domain/identity.spec.ts b/libs/common/src/vault/models/domain/identity.spec.ts index e15a9853064..51b84f3604a 100644 --- a/libs/common/src/vault/models/domain/identity.spec.ts +++ b/libs/common/src/vault/models/domain/identity.spec.ts @@ -2,7 +2,12 @@ import { of } from "rxjs"; import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key"; -import { makeSymmetricCryptoKey, mockContainerService, mockEnc, mockFromJson } from "../../../../spec"; +import { + makeSymmetricCryptoKey, + mockContainerService, + mockEnc, + mockFromJson, +} from "../../../../spec"; import { EncryptedString, EncString } from "../../../key-management/crypto/models/enc-string"; import { IdentityData } from "../../models/data/identity.data"; import { Identity } from "../../models/domain/identity"; @@ -96,7 +101,7 @@ describe("Identity", () => { .getEncryptService() .decryptString.mockImplementation(async (encString: EncString, key: SymmetricCryptoKey) => { return encString.data; - }) + }); const identity = new Identity(); diff --git a/libs/common/src/vault/models/domain/login-uri.spec.ts b/libs/common/src/vault/models/domain/login-uri.spec.ts index 6baac552842..3b705b01901 100644 --- a/libs/common/src/vault/models/domain/login-uri.spec.ts +++ b/libs/common/src/vault/models/domain/login-uri.spec.ts @@ -6,7 +6,12 @@ import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/sym import { UserKey } from "@bitwarden/common/types/key"; import { UriMatchType } from "@bitwarden/sdk-internal"; -import { makeSymmetricCryptoKey, mockContainerService, mockEnc, mockFromJson } from "../../../../spec"; +import { + makeSymmetricCryptoKey, + mockContainerService, + mockEnc, + mockFromJson, +} from "../../../../spec"; 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"; @@ -53,12 +58,14 @@ describe("LoginUri", () => { it("Decrypt", async () => { const containerService = mockContainerService(); - containerService.getKeyService().userKey$.mockReturnValue(of(makeSymmetricCryptoKey(64) as UserKey)); + containerService + .getKeyService() + .userKey$.mockReturnValue(of(makeSymmetricCryptoKey(64) as UserKey)); containerService .getEncryptService() .decryptString.mockImplementation(async (encString: EncString, key: SymmetricCryptoKey) => { return encString.data; - }) + }); const loginUri = new LoginUri(); loginUri.match = UriMatchStrategy.Exact; @@ -79,12 +86,14 @@ describe("LoginUri", () => { const containerService = mockContainerService(); encryptService = containerService.getEncryptService(); - containerService.getKeyService().userKey$.mockReturnValue(of(makeSymmetricCryptoKey(64) as UserKey)); + containerService + .getKeyService() + .userKey$.mockReturnValue(of(makeSymmetricCryptoKey(64) as UserKey)); containerService .getEncryptService() .decryptString.mockImplementation(async (encString: EncString, key: SymmetricCryptoKey) => { return encString.data; - }) + }); }); it("returns true if checksums match", async () => { diff --git a/libs/common/src/vault/models/domain/login.spec.ts b/libs/common/src/vault/models/domain/login.spec.ts index 9076727900f..fbd3a1ffe99 100644 --- a/libs/common/src/vault/models/domain/login.spec.ts +++ b/libs/common/src/vault/models/domain/login.spec.ts @@ -3,7 +3,12 @@ import { of } from "rxjs"; import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key"; -import { makeSymmetricCryptoKey, mockContainerService, mockEnc, mockFromJson } from "../../../../spec"; +import { + makeSymmetricCryptoKey, + mockContainerService, + mockEnc, + mockFromJson, +} from "../../../../spec"; import { EncryptedString, EncString } from "../../../key-management/crypto/models/enc-string"; import { UriMatchStrategy } from "../../../models/domain/domain-service"; import { LoginData } from "../../models/data/login.data"; @@ -73,7 +78,7 @@ describe("Login DTO", () => { .getEncryptService() .decryptString.mockImplementation(async (encString: EncString, key: SymmetricCryptoKey) => { return encString.data; - }) + }); let loginUri: MockProxy; const loginUriView = new LoginUriView(); diff --git a/libs/common/src/vault/models/domain/password.spec.ts b/libs/common/src/vault/models/domain/password.spec.ts index 3ec9b69f6ce..9d845d8b2c3 100644 --- a/libs/common/src/vault/models/domain/password.spec.ts +++ b/libs/common/src/vault/models/domain/password.spec.ts @@ -1,8 +1,16 @@ import { of } from "rxjs"; -import { EncString, EncryptedString } from "@bitwarden/common/key-management/crypto/models/enc-string"; +import { + EncString, + EncryptedString, +} from "@bitwarden/common/key-management/crypto/models/enc-string"; -import { mockEnc, mockFromJson, makeSymmetricCryptoKey, mockContainerService } from "../../../../spec"; +import { + mockEnc, + mockFromJson, + makeSymmetricCryptoKey, + mockContainerService, +} from "../../../../spec"; import { PasswordHistoryData } from "../../models/data/password-history.data"; import { Password } from "../../models/domain/password"; @@ -42,8 +50,7 @@ describe("Password", () => { it("Decrypt", async () => { const containerService = mockContainerService(); containerService.getKeyService().userKey$.mockReturnValue(of(makeSymmetricCryptoKey(64))); - containerService.getEncryptService() - .decryptString.mockResolvedValue("password"); + containerService.getEncryptService().decryptString.mockResolvedValue("password"); const password = new Password(); password.password = mockEnc("password"); diff --git a/libs/common/src/vault/models/domain/ssh-key.spec.ts b/libs/common/src/vault/models/domain/ssh-key.spec.ts index cf233c9302e..941a85526e1 100644 --- a/libs/common/src/vault/models/domain/ssh-key.spec.ts +++ b/libs/common/src/vault/models/domain/ssh-key.spec.ts @@ -49,7 +49,8 @@ describe("Sshkey", () => { it("Decrypt", async () => { const containerService = mockContainerService(); containerService.getKeyService().userKey$.mockReturnValue(of(makeSymmetricCryptoKey(64))); - containerService.getEncryptService() + containerService + .getEncryptService() .decryptString.mockResolvedValueOnce("privateKey") .mockResolvedValueOnce("publicKey") .mockResolvedValueOnce("keyFingerprint");