1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

[PM-6032] Run migrations in main process (#7795)

* Run Migrations in Desktop Main Process

* Add `waitForMigrations` method

* Add `InitOptions`

* Fix Destructuring
This commit is contained in:
Justin Baur
2024-02-06 12:01:12 -05:00
committed by GitHub
parent 166269520c
commit f64092cc90
5 changed files with 79 additions and 7 deletions

View File

@@ -36,6 +36,20 @@ import { EncString } from "../models/domain/enc-string";
import { StorageOptions } from "../models/domain/storage-options";
import { SymmetricCryptoKey } from "../models/domain/symmetric-crypto-key";
/**
* Options for customizing the initiation behavior.
*/
export type InitOptions = {
/**
* Whether or not to run state migrations as part of the init process. Defaults to true.
*
* If false, the init method will instead wait for migrations to complete before doing its
* other init operations. Make sure migrations have either already completed, or will complete
* before calling {@link StateService.init} with `runMigrations: false`.
*/
runMigrations?: boolean;
};
export abstract class StateService<T extends Account = Account> {
accounts$: Observable<{ [userId: string]: T }>;
activeAccount$: Observable<string>;
@@ -44,7 +58,7 @@ export abstract class StateService<T extends Account = Account> {
addAccount: (account: T) => Promise<void>;
setActiveUser: (userId: string) => Promise<void>;
clean: (options?: StorageOptions) => Promise<UserId>;
init: () => Promise<void>;
init: (initOptions?: InitOptions) => Promise<void>;
getAccessToken: (options?: StorageOptions) => Promise<string>;
setAccessToken: (value: string, options?: StorageOptions) => Promise<void>;