mirror of
https://github.com/bitwarden/browser
synced 2025-12-21 10:43:35 +00:00
* 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>
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
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);
|
|
}
|
|
}
|
|
}
|