diff --git a/jslib b/jslib index e372bf24..92a65b7b 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit e372bf242b24f55c1142e33693ad2c801ab74c93 +Subproject commit 92a65b7b368a8dbf55350657674c90169b04c30b diff --git a/src/app/services/services.module.ts b/src/app/services/services.module.ts index 58ebdba1..b6bf212d 100644 --- a/src/app/services/services.module.ts +++ b/src/app/services/services.module.ts @@ -45,7 +45,10 @@ import { StateMigrationService } from "../../services/stateMigration.service"; import { Account } from "../../models/account"; -import { AccountFactory } from "jslib-common/models/domain/account"; +import { GlobalStateFactory } from "jslib-common/factories/globalStateFactory"; +import { StateFactory } from "jslib-common/factories/stateFactory"; + +import { GlobalState } from "jslib-common/models/domain/globalState"; function refreshTokenCallback(injector: Injector) { return () => { @@ -196,7 +199,15 @@ export function initFactory( LaunchGuardService, { provide: StateMigrationServiceAbstraction, - useClass: StateMigrationService, + useFactory: ( + storageService: StorageServiceAbstraction, + secureStorageService: StorageServiceAbstraction + ) => + new StateMigrationService( + storageService, + secureStorageService, + new GlobalStateFactory(GlobalState) + ), deps: [StorageServiceAbstraction, "SECURE_STORAGE"], }, { @@ -213,7 +224,7 @@ export function initFactory( logService, stateMigrationService, true, // TODO: It seems like we aren't applying this from settings anywhere. Is toggling secure storage working? - new AccountFactory(Account) + new StateFactory(GlobalState, Account) ), deps: [ StorageServiceAbstraction, diff --git a/src/bwdc.ts b/src/bwdc.ts index 8978daa9..3697662b 100644 --- a/src/bwdc.ts +++ b/src/bwdc.ts @@ -40,10 +40,13 @@ import { StorageService as StorageServiceAbstraction } from "jslib-common/abstra import { Program } from "./program"; -import { AccountFactory } from "jslib-common/models/domain/account"; - import { Account } from "./models/account"; +import { GlobalStateFactory } from "jslib-common/factories/globalStateFactory"; +import { StateFactory } from "jslib-common/factories/stateFactory"; + +import { GlobalState } from "jslib-common/models/domain/globalState"; + // tslint:disable-next-line const packageJson = require("./package.json"); @@ -123,7 +126,8 @@ export class Main { this.stateMigrationService = new StateMigrationService( this.storageService, - this.secureStorageService + this.secureStorageService, + new GlobalStateFactory(GlobalState) ); this.stateService = new StateService( @@ -132,7 +136,7 @@ export class Main { this.logService, this.stateMigrationService, process.env.BITWARDENCLI_CONNECTOR_PLAINTEXT_SECRETS !== "true", - new AccountFactory(Account) + new StateFactory(GlobalState, Account) ); this.cryptoService = new CryptoService( diff --git a/src/main.ts b/src/main.ts index df31d76a..77c956f0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -15,10 +15,12 @@ import { WindowMain } from "jslib-electron/window.main"; import { StateService } from "./services/state.service"; -import { AccountFactory } from "jslib-common/models/domain/account"; - import { Account } from "./models/account"; +import { StateFactory } from "jslib-common/factories/stateFactory"; + +import { GlobalState } from "jslib-common/models/domain/globalState"; + export class Main { logService: ElectronLogService; i18nService: I18nService; @@ -64,7 +66,7 @@ export class Main { this.logService, null, true, - new AccountFactory(Account) + new StateFactory(GlobalState, Account) ); this.windowMain = new WindowMain( diff --git a/src/services/state.service.ts b/src/services/state.service.ts index 4edefeee..8f761180 100644 --- a/src/services/state.service.ts +++ b/src/services/state.service.ts @@ -1,8 +1,10 @@ import { StateService as BaseStateService } from "jslib-common/services/state.service"; -import { AccountFactory } from "jslib-common/models/domain/account"; +import { GlobalState } from "jslib-common/models/domain/globalState"; import { StorageOptions } from "jslib-common/models/domain/storageOptions"; +import { StateFactory } from "jslib-common/factories/stateFactory"; + import { Account } from "src/models/account"; import { AzureConfiguration } from "src/models/azureConfiguration"; import { GSuiteConfiguration } from "src/models/gsuiteConfiguration"; @@ -48,9 +50,9 @@ export class StateService extends BaseStateService implements StateServ protected logService: LogService, protected stateMigrationService: StateMigrationService, private useSecureStorageForSecrets = true, - protected accountFactory: AccountFactory + protected stateFactory: StateFactory ) { - super(storageService, secureStorageService, logService, stateMigrationService, accountFactory); + super(storageService, secureStorageService, logService, stateMigrationService, stateFactory); } async getDirectory(type: DirectoryType): Promise {