mirror of
https://github.com/bitwarden/browser
synced 2025-12-21 18:53:29 +00:00
refactor: introduce @bitwarden/state and other common libs (#15772)
* refactor: introduce @bitwarden/serialization * refactor: introduce @bitwarden/guid * refactor: introduce @bitwaren/client-type * refactor: introduce @bitwarden/core-test-utils * refactor: introduce @bitwarden/state and @bitwarden/state-test-utils Creates initial project structure for centralized application state management. Part of modularization effort to extract state code from common. * Added state provider documentation to README. * Changed callouts to Github format. * Fixed linting on file name. * Forced git to accept rename --------- Co-authored-by: Todd Martin <tmartin@bitwarden.com>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { KeyDefinitionLike, MigrationHelper } from "../migration-helper";
|
||||
import { Migrator } from "../migrator";
|
||||
|
||||
type ExpectedGlobalType = {
|
||||
enablePasskeys?: boolean;
|
||||
};
|
||||
|
||||
const USER_ENABLE_PASSKEYS: KeyDefinitionLike = {
|
||||
key: "enablePasskeys",
|
||||
stateDefinition: {
|
||||
name: "vaultSettings",
|
||||
},
|
||||
};
|
||||
|
||||
export class EnablePasskeysMigrator extends Migrator<16, 17> {
|
||||
async migrate(helper: MigrationHelper): Promise<void> {
|
||||
const global = await helper.get<ExpectedGlobalType>("global");
|
||||
|
||||
if (global?.enablePasskeys != null) {
|
||||
await helper.setToGlobal(USER_ENABLE_PASSKEYS, global.enablePasskeys);
|
||||
delete global?.enablePasskeys;
|
||||
await helper.set("global", global);
|
||||
}
|
||||
}
|
||||
|
||||
async rollback(helper: MigrationHelper): Promise<void> {
|
||||
let global = await helper.get<ExpectedGlobalType>("global");
|
||||
const globalEnablePasskeys = await helper.getFromGlobal<boolean>(USER_ENABLE_PASSKEYS);
|
||||
|
||||
if (globalEnablePasskeys != null) {
|
||||
global = Object.assign(global ?? {}, { enablePasskeys: globalEnablePasskeys });
|
||||
await helper.set("global", global);
|
||||
await helper.setToGlobal(USER_ENABLE_PASSKEYS, undefined);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user