mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
* wip ts-strict * wip ts-strict * wip * cleanup * cleanup * fix story * fix story * fix story * wip * clean up CollectionAdminView construction * fix deprecated function call * fix cli * clean up * fix story * wip * fix cli * requested changes * clean up, fixing minor bugs, more type saftey * assign props in static ctor, clean up
30 lines
846 B
TypeScript
30 lines
846 B
TypeScript
import { Jsonify } from "type-fest";
|
|
|
|
import {
|
|
COLLECTION_DISK,
|
|
COLLECTION_MEMORY,
|
|
UserKeyDefinition,
|
|
} from "@bitwarden/common/platform/state";
|
|
import { CollectionId } from "@bitwarden/common/types/guid";
|
|
|
|
import { CollectionData, CollectionView } from "../models";
|
|
|
|
export const ENCRYPTED_COLLECTION_DATA_KEY = UserKeyDefinition.record<CollectionData, CollectionId>(
|
|
COLLECTION_DISK,
|
|
"collections",
|
|
{
|
|
deserializer: (jsonData: Jsonify<CollectionData>) => CollectionData.fromJSON(jsonData),
|
|
clearOn: ["logout"],
|
|
},
|
|
);
|
|
|
|
export const DECRYPTED_COLLECTION_DATA_KEY = new UserKeyDefinition<CollectionView[] | null>(
|
|
COLLECTION_MEMORY,
|
|
"decryptedCollections",
|
|
{
|
|
deserializer: (obj: Jsonify<CollectionView[] | null>) =>
|
|
obj?.map((f) => CollectionView.fromJSON(f)) ?? null,
|
|
clearOn: ["logout", "lock"],
|
|
},
|
|
);
|