mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 13:23:34 +00:00
* added master password unlock and decryption option fields into identity token connect response * incorrect master password unlock response parsing * use sdk * use sdk * better type checking on response parsing * not using sdk * revert of bad merge conflicts * revert of bad merge conflicts * master password unlock setter in state * unit test coverage for responses processing * master password unlock in identity user decryption options * unit test coverage * unit test coverage * unit test coverage * unit test coverage * lint error * set master password unlock data in state on identity response and sync response * revert change in auth's user decryption options * remove unnecessary cast * better docs * change to relative imports * MasterPasswordUnlockData serialization issue * explicit undefined type for `syncUserDecryption` * incorrect identity token response tests
48 lines
1.8 KiB
TypeScript
48 lines
1.8 KiB
TypeScript
// eslint-disable-next-line no-restricted-imports
|
|
import { KdfType } from "@bitwarden/key-management";
|
|
|
|
import { makeEncString } from "../../../../../spec";
|
|
|
|
import { UserDecryptionOptionsResponse } from "./user-decryption-options.response";
|
|
|
|
describe("UserDecryptionOptionsResponse", () => {
|
|
it("should create response when master password unlock is present", () => {
|
|
const salt = "test@example.com";
|
|
const encryptedUserKey = makeEncString("testUserKey");
|
|
|
|
const response = new UserDecryptionOptionsResponse({
|
|
HasMasterPassword: true,
|
|
MasterPasswordUnlock: {
|
|
Salt: salt,
|
|
Kdf: {
|
|
KdfType: KdfType.PBKDF2_SHA256,
|
|
Iterations: 600_000,
|
|
},
|
|
MasterKeyEncryptedUserKey: encryptedUserKey.encryptedString,
|
|
},
|
|
});
|
|
|
|
expect(response.hasMasterPassword).toBe(true);
|
|
expect(response.masterPasswordUnlock).toBeDefined();
|
|
expect(response.masterPasswordUnlock!.salt).toEqual(salt);
|
|
expect(response.masterPasswordUnlock!.kdf.kdfType).toEqual(KdfType.PBKDF2_SHA256);
|
|
expect(response.masterPasswordUnlock!.kdf.iterations).toEqual(600_000);
|
|
expect(response.masterPasswordUnlock!.masterKeyWrappedUserKey).toEqual(encryptedUserKey);
|
|
expect(response.trustedDeviceOption).toBeUndefined();
|
|
expect(response.keyConnectorOption).toBeUndefined();
|
|
expect(response.webAuthnPrfOption).toBeUndefined();
|
|
});
|
|
|
|
it("should create response when master password unlock is not present", () => {
|
|
const response = new UserDecryptionOptionsResponse({
|
|
HasMasterPassword: false,
|
|
});
|
|
|
|
expect(response.hasMasterPassword).toBe(false);
|
|
expect(response.masterPasswordUnlock).toBeUndefined();
|
|
expect(response.trustedDeviceOption).toBeUndefined();
|
|
expect(response.keyConnectorOption).toBeUndefined();
|
|
expect(response.webAuthnPrfOption).toBeUndefined();
|
|
});
|
|
});
|