1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 10:13:31 +00:00

[PM-6146] generator history (#8497)

* introduce `GeneratorHistoryService` abstraction
* implement generator history service with `LocalGeneratorHistoryService` 
* cache decrypted data using `ReplaySubject` instead of `DerivedState`
* move Jsonification from `DataPacker` to `SecretClassifier` because the classifier 
  is the only component that has full type information. The data packer still handles 
  stringification.
This commit is contained in:
✨ Audrey ✨
2024-03-28 12:19:12 -04:00
committed by GitHub
parent 65353ae71d
commit df058ba399
22 changed files with 691 additions and 212 deletions

View File

@@ -7,6 +7,28 @@ describe("SecretKeyDefinition", () => {
const classifier = SecretClassifier.allSecret<{ foo: boolean }>();
const options = { deserializer: (v: any) => v };
it("toEncryptedStateKey returns a key", () => {
const expectedOptions = {
deserializer: (v: any) => v,
cleanupDelayMs: 100,
};
const definition = SecretKeyDefinition.value(
GENERATOR_DISK,
"key",
classifier,
expectedOptions,
);
const expectedDeserializerResult = {} as any;
const result = definition.toEncryptedStateKey();
const deserializerResult = result.deserializer(expectedDeserializerResult);
expect(result.stateDefinition).toEqual(GENERATOR_DISK);
expect(result.key).toBe("key");
expect(result.cleanupDelayMs).toBe(expectedOptions.cleanupDelayMs);
expect(deserializerResult).toBe(expectedDeserializerResult);
});
describe("value", () => {
it("returns an initialized SecretKeyDefinition", () => {
const definition = SecretKeyDefinition.value(GENERATOR_DISK, "key", classifier, options);