mirror of
https://github.com/bitwarden/browser
synced 2025-12-20 10:13:31 +00:00
Tools/specify-clearon-conditions (#8596)
* Specify user clear events for event upload * Specify generator clear events * Specify clear events for user send data * Specify generic clear on logout for encrypted secret state * Allow `clearOn`event to be passed into secret state * Match current data persistence rules * Clear ui memory on lock + logout
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
import { GENERATOR_DISK } from "../../../platform/state";
|
||||
import { GENERATOR_DISK, UserKeyDefinitionOptions } from "../../../platform/state";
|
||||
|
||||
import { SecretClassifier } from "./secret-classifier";
|
||||
import { SecretKeyDefinition } from "./secret-key-definition";
|
||||
|
||||
describe("SecretKeyDefinition", () => {
|
||||
const classifier = SecretClassifier.allSecret<{ foo: boolean }>();
|
||||
const options = { deserializer: (v: any) => v };
|
||||
const options: UserKeyDefinitionOptions<any> = { deserializer: (v: any) => v, clearOn: [] };
|
||||
|
||||
it("toEncryptedStateKey returns a key", () => {
|
||||
const expectedOptions = {
|
||||
const expectedOptions: UserKeyDefinitionOptions<any> = {
|
||||
deserializer: (v: any) => v,
|
||||
cleanupDelayMs: 100,
|
||||
clearOn: ["logout", "lock"],
|
||||
};
|
||||
const definition = SecretKeyDefinition.value(
|
||||
GENERATOR_DISK,
|
||||
@@ -26,6 +27,7 @@ describe("SecretKeyDefinition", () => {
|
||||
expect(result.stateDefinition).toEqual(GENERATOR_DISK);
|
||||
expect(result.key).toBe("key");
|
||||
expect(result.cleanupDelayMs).toBe(expectedOptions.cleanupDelayMs);
|
||||
expect(result.clearOn).toEqual(expectedOptions.clearOn);
|
||||
expect(deserializerResult).toBe(expectedDeserializerResult);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user