diff --git a/angular/src/services/jslib-services.module.ts b/angular/src/services/jslib-services.module.ts index 8aeec5ed..b8cbd197 100644 --- a/angular/src/services/jslib-services.module.ts +++ b/angular/src/services/jslib-services.module.ts @@ -308,16 +308,7 @@ import { ValidationService } from "./validation.service"; }, { provide: StateMigrationServiceAbstraction, - useFactory: ( - storageService: StorageServiceAbstraction, - secureStorageService: StorageServiceAbstraction - ) => - new StateMigrationService( - storageService, - secureStorageService, - new StateFactory(GlobalState, Account) - ), - deps: [StorageServiceAbstraction, "SECURE_STORAGE"], + useClass: StateMigrationService }, { provide: ExportServiceAbstraction, diff --git a/common/src/abstractions/injectionTokens.ts b/common/src/abstractions/injectionTokens.ts index f69abe22..a1497646 100644 --- a/common/src/abstractions/injectionTokens.ts +++ b/common/src/abstractions/injectionTokens.ts @@ -1,5 +1,7 @@ import { InjectionToken } from '@angular/core'; import { StateFactory } from '../factories/stateFactory'; +import { StorageService } from './storage.service'; export const STATE_SERVICE_USE_CACHE = new InjectionToken('STATE_SERVICE_USE_CACHE'); export const STATE_FACTORY = new InjectionToken('STATE_FACTORY'); +export const SECURE_STORAGE = new InjectionToken('SECURE_STORAGE'); diff --git a/common/src/services/state.service.ts b/common/src/services/state.service.ts index 0a438949..432e1755 100644 --- a/common/src/services/state.service.ts +++ b/common/src/services/state.service.ts @@ -34,7 +34,7 @@ import { CollectionView } from "../models/view/collectionView"; import { FolderView } from "../models/view/folderView"; import { SendView } from "../models/view/sendView"; -import { STATE_FACTORY, STATE_SERVICE_USE_CACHE } from "../abstractions/injectionTokens"; +import { SECURE_STORAGE, STATE_FACTORY, STATE_SERVICE_USE_CACHE } from "../abstractions/injectionTokens"; const keys = { global: "global", @@ -69,7 +69,7 @@ export class StateService< constructor( protected storageService: StorageService, - @Inject("SECURE_STORAGE") protected secureStorageService: StorageService, + @Inject(SECURE_STORAGE) protected secureStorageService: StorageService, protected logService: LogService, protected stateMigrationService: StateMigrationService, @Inject(STATE_FACTORY) protected stateFactory: StateFactory, diff --git a/common/src/services/stateMigration.service.ts b/common/src/services/stateMigration.service.ts index 2b299898..56fbb408 100644 --- a/common/src/services/stateMigration.service.ts +++ b/common/src/services/stateMigration.service.ts @@ -1,3 +1,5 @@ +import { Inject, Injectable } from '@angular/core'; +import { SECURE_STORAGE, STATE_FACTORY } from '../abstractions/injectionTokens'; import { StorageService } from "../abstractions/storage.service"; import { HtmlStorageLocation } from "../enums/htmlStorageLocation"; import { KdfType } from "../enums/kdfType"; @@ -127,14 +129,15 @@ const partialKeys = { masterKey: "_masterkey", }; +@Injectable() export class StateMigrationService< TGlobalState extends GlobalState = GlobalState, TAccount extends Account = Account > { constructor( protected storageService: StorageService, - protected secureStorageService: StorageService, - protected stateFactory: StateFactory + @Inject(SECURE_STORAGE) protected secureStorageService: StorageService, + @Inject(STATE_FACTORY) protected stateFactory: StateFactory ) {} async needsMigration(): Promise {