mirror of
https://github.com/bitwarden/browser
synced 2026-02-02 17:53:41 +00:00
Apply prettier
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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<
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user