1
0
mirror of https://github.com/bitwarden/directory-connector synced 2025-12-05 23:53:21 +00:00

Update jslib and minor fixes for account switching (#204)

* Update jslib

* Update stateMigrationService to use enums

* Remove duplicate subclass method

* Update jslib
This commit is contained in:
Thomas Rittson
2022-01-14 05:59:24 +10:00
committed by GitHub
parent 8a800c6d33
commit 90a7601960
2 changed files with 6 additions and 13 deletions

2
jslib

Submodule jslib updated: 9e26336549...ddcfe23367

View File

@@ -3,6 +3,8 @@ import { State } from "jslib-common/models/domain/state";
import { StateMigrationService as BaseStateMigrationService } from "jslib-common/services/stateMigration.service";
import { StateVersion } from "jslib-common/enums/stateVersion";
import { DirectoryType } from "src/enums/directoryType";
import { Account, DirectoryConfigurations, DirectorySettings } from "src/models/account";
@@ -47,21 +49,12 @@ const ClientKeys: { [key: string]: any } = {
};
export class StateMigrationService extends BaseStateMigrationService {
async needsMigration(): Promise<boolean> {
const currentStateVersion = (
await this.storageService.get<State<Account>>("state", {
htmlStorageLocation: HtmlStorageLocation.Local,
})
)?.globals?.stateVersion;
return currentStateVersion == null || currentStateVersion < this.latestVersion;
}
async migrate(): Promise<void> {
let currentStateVersion =
(await this.storageService.get<State<Account>>("state"))?.globals?.stateVersion ?? 1;
while (currentStateVersion < this.latestVersion) {
(await this.storageService.get<State<Account>>("state"))?.globals?.stateVersion ?? StateVersion.One;
while (currentStateVersion < StateVersion.Latest) {
switch (currentStateVersion) {
case 1:
case StateVersion.One:
await this.migrateClientKeys();
await this.migrateStateFrom1To2();
break;