mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
* [deps] Autofill: Update prettier to v3 * prettier formatting updates --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jonathan Prusik <jprusik@classynemesis.com>
23 lines
804 B
TypeScript
23 lines
804 B
TypeScript
import { Jsonify } from "type-fest";
|
|
|
|
import { Cipher } from "../../../vault/models/domain/cipher";
|
|
import { CipherView } from "../../../vault/models/view/cipher.view";
|
|
import { InitializerMetadata } from "../../interfaces/initializer-metadata.interface";
|
|
|
|
import { InitializerKey } from "./initializer-key";
|
|
|
|
/**
|
|
* Internal reference of classes so we can reconstruct objects properly.
|
|
* Each entry should be keyed using the Decryptable.initializerKey property
|
|
*/
|
|
const classInitializers: Record<InitializerKey, (obj: any) => any> = {
|
|
[InitializerKey.Cipher]: Cipher.fromJSON,
|
|
[InitializerKey.CipherView]: CipherView.fromJSON,
|
|
};
|
|
|
|
export function getClassInitializer<T extends InitializerMetadata>(
|
|
className: InitializerKey,
|
|
): (obj: Jsonify<T>) => T {
|
|
return classInitializers[className];
|
|
}
|