1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-02 17:53:41 +00:00

Apply prettier

This commit is contained in:
Bernd Schoolmann
2025-10-27 17:58:16 +01:00
parent e59df2fbf8
commit e278511ed0
13 changed files with 88 additions and 33 deletions

View File

@@ -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(

View File

@@ -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<T> = ConditionalKeys<ConditionalExcept<T, Function>, EncString>;
/** @deprecated */
export type DecryptedObject<

View File

@@ -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<SendText>();
text.decrypt.mockResolvedValue("textView" as any);

View File

@@ -120,7 +120,7 @@ describe("Attachment", () => {
it("gets an organization key if required", async () => {
const orgKey = mock<OrgKey>();
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<OrgKey>() }));
keyService.orgKeys$.mockReturnValue(of({ orgId: mock<OrgKey>() }));
const userKey = new SymmetricCryptoKey(makeStaticByteArray(64));
keyService.userKey$.mockReturnValue(of(userKey as UserKey));

View File

@@ -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");

View File

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

View File

@@ -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");

View File

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

View File

@@ -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();

View File

@@ -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 () => {

View File

@@ -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<LoginUri>;
const loginUriView = new LoginUriView();

View File

@@ -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");

View File

@@ -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");