Register `StateProvider` in non DI clients (#7280)
* Add StateProvider and All to Browser Background * Add State Provider and All to CLI * Move EncryptService above its first usage
This commit is contained in:
parent
23969573fc
commit
c16d0b29fa
|
@ -63,9 +63,20 @@ import { MultithreadEncryptServiceImplementation } from "@bitwarden/common/platf
|
||||||
import { FileUploadService } from "@bitwarden/common/platform/services/file-upload/file-upload.service";
|
import { FileUploadService } from "@bitwarden/common/platform/services/file-upload/file-upload.service";
|
||||||
import { SystemService } from "@bitwarden/common/platform/services/system.service";
|
import { SystemService } from "@bitwarden/common/platform/services/system.service";
|
||||||
import { WebCryptoFunctionService } from "@bitwarden/common/platform/services/web-crypto-function.service";
|
import { WebCryptoFunctionService } from "@bitwarden/common/platform/services/web-crypto-function.service";
|
||||||
import { GlobalStateProvider } from "@bitwarden/common/platform/state";
|
import {
|
||||||
|
ActiveUserStateProvider,
|
||||||
|
GlobalStateProvider,
|
||||||
|
SingleUserStateProvider,
|
||||||
|
StateProvider,
|
||||||
|
} from "@bitwarden/common/platform/state";
|
||||||
|
// eslint-disable-next-line import/no-restricted-paths -- We need the implementation to inject, but generally this should not be accessed
|
||||||
|
import { DefaultActiveUserStateProvider } from "@bitwarden/common/platform/state/implementations/default-active-user-state.provider";
|
||||||
// eslint-disable-next-line import/no-restricted-paths -- We need the implementation to inject, but generally this should not be accessed
|
// eslint-disable-next-line import/no-restricted-paths -- We need the implementation to inject, but generally this should not be accessed
|
||||||
import { DefaultGlobalStateProvider } from "@bitwarden/common/platform/state/implementations/default-global-state.provider";
|
import { DefaultGlobalStateProvider } from "@bitwarden/common/platform/state/implementations/default-global-state.provider";
|
||||||
|
// eslint-disable-next-line import/no-restricted-paths -- We need the implementation to inject, but generally this should not be accessed
|
||||||
|
import { DefaultSingleUserStateProvider } from "@bitwarden/common/platform/state/implementations/default-single-user-state.provider";
|
||||||
|
// eslint-disable-next-line import/no-restricted-paths -- We need the implementation to inject, but generally this should not be accessed
|
||||||
|
import { DefaultStateProvider } from "@bitwarden/common/platform/state/implementations/default-state.provider";
|
||||||
import { AvatarUpdateService } from "@bitwarden/common/services/account/avatar-update.service";
|
import { AvatarUpdateService } from "@bitwarden/common/services/account/avatar-update.service";
|
||||||
import { ApiService } from "@bitwarden/common/services/api.service";
|
import { ApiService } from "@bitwarden/common/services/api.service";
|
||||||
import { AuditService } from "@bitwarden/common/services/audit.service";
|
import { AuditService } from "@bitwarden/common/services/audit.service";
|
||||||
|
@ -234,6 +245,9 @@ export default class MainBackground {
|
||||||
authRequestCryptoService: AuthRequestCryptoServiceAbstraction;
|
authRequestCryptoService: AuthRequestCryptoServiceAbstraction;
|
||||||
accountService: AccountServiceAbstraction;
|
accountService: AccountServiceAbstraction;
|
||||||
globalStateProvider: GlobalStateProvider;
|
globalStateProvider: GlobalStateProvider;
|
||||||
|
singleUserStateProvider: SingleUserStateProvider;
|
||||||
|
activeUserStateProvider: ActiveUserStateProvider;
|
||||||
|
stateProvider: StateProvider;
|
||||||
fido2Service: Fido2ServiceAbstraction;
|
fido2Service: Fido2ServiceAbstraction;
|
||||||
|
|
||||||
// Passed to the popup for Safari to workaround issues with theming, downloading, etc.
|
// Passed to the popup for Safari to workaround issues with theming, downloading, etc.
|
||||||
|
@ -294,11 +308,36 @@ export default class MainBackground {
|
||||||
this.memoryStorageService as BackgroundMemoryStorageService,
|
this.memoryStorageService as BackgroundMemoryStorageService,
|
||||||
this.storageService as BrowserLocalStorageService,
|
this.storageService as BrowserLocalStorageService,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.encryptService = flagEnabled("multithreadDecryption")
|
||||||
|
? new MultithreadEncryptServiceImplementation(
|
||||||
|
this.cryptoFunctionService,
|
||||||
|
this.logService,
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
: new EncryptServiceImplementation(this.cryptoFunctionService, this.logService, true);
|
||||||
|
|
||||||
|
this.singleUserStateProvider = new DefaultSingleUserStateProvider(
|
||||||
|
this.encryptService,
|
||||||
|
this.memoryStorageService as BackgroundMemoryStorageService,
|
||||||
|
this.storageService as BrowserLocalStorageService,
|
||||||
|
);
|
||||||
this.accountService = new AccountServiceImplementation(
|
this.accountService = new AccountServiceImplementation(
|
||||||
this.messagingService,
|
this.messagingService,
|
||||||
this.logService,
|
this.logService,
|
||||||
this.globalStateProvider,
|
this.globalStateProvider,
|
||||||
);
|
);
|
||||||
|
this.activeUserStateProvider = new DefaultActiveUserStateProvider(
|
||||||
|
this.accountService,
|
||||||
|
this.encryptService,
|
||||||
|
this.memoryStorageService as BackgroundMemoryStorageService,
|
||||||
|
this.storageService as BrowserLocalStorageService,
|
||||||
|
);
|
||||||
|
this.stateProvider = new DefaultStateProvider(
|
||||||
|
this.activeUserStateProvider,
|
||||||
|
this.singleUserStateProvider,
|
||||||
|
this.globalStateProvider,
|
||||||
|
);
|
||||||
this.stateService = new BrowserStateService(
|
this.stateService = new BrowserStateService(
|
||||||
this.storageService,
|
this.storageService,
|
||||||
this.secureStorageService,
|
this.secureStorageService,
|
||||||
|
@ -330,13 +369,7 @@ export default class MainBackground {
|
||||||
window,
|
window,
|
||||||
);
|
);
|
||||||
this.i18nService = new BrowserI18nService(BrowserApi.getUILanguage(), this.stateService);
|
this.i18nService = new BrowserI18nService(BrowserApi.getUILanguage(), this.stateService);
|
||||||
this.encryptService = flagEnabled("multithreadDecryption")
|
|
||||||
? new MultithreadEncryptServiceImplementation(
|
|
||||||
this.cryptoFunctionService,
|
|
||||||
this.logService,
|
|
||||||
true,
|
|
||||||
)
|
|
||||||
: new EncryptServiceImplementation(this.cryptoFunctionService, this.logService, true);
|
|
||||||
this.cryptoService = new BrowserCryptoService(
|
this.cryptoService = new BrowserCryptoService(
|
||||||
this.cryptoFunctionService,
|
this.cryptoFunctionService,
|
||||||
this.encryptService,
|
this.encryptService,
|
||||||
|
|
|
@ -46,9 +46,20 @@ import { FileUploadService } from "@bitwarden/common/platform/services/file-uplo
|
||||||
import { MemoryStorageService } from "@bitwarden/common/platform/services/memory-storage.service";
|
import { MemoryStorageService } from "@bitwarden/common/platform/services/memory-storage.service";
|
||||||
import { NoopMessagingService } from "@bitwarden/common/platform/services/noop-messaging.service";
|
import { NoopMessagingService } from "@bitwarden/common/platform/services/noop-messaging.service";
|
||||||
import { StateService } from "@bitwarden/common/platform/services/state.service";
|
import { StateService } from "@bitwarden/common/platform/services/state.service";
|
||||||
import { GlobalStateProvider } from "@bitwarden/common/platform/state";
|
import {
|
||||||
|
ActiveUserStateProvider,
|
||||||
|
GlobalStateProvider,
|
||||||
|
SingleUserStateProvider,
|
||||||
|
StateProvider,
|
||||||
|
} from "@bitwarden/common/platform/state";
|
||||||
|
// eslint-disable-next-line import/no-restricted-paths -- We need the implementation to inject, but generally this should not be accessed
|
||||||
|
import { DefaultActiveUserStateProvider } from "@bitwarden/common/platform/state/implementations/default-active-user-state.provider";
|
||||||
// eslint-disable-next-line import/no-restricted-paths -- We need the implementation to inject, but generally this should not be accessed
|
// eslint-disable-next-line import/no-restricted-paths -- We need the implementation to inject, but generally this should not be accessed
|
||||||
import { DefaultGlobalStateProvider } from "@bitwarden/common/platform/state/implementations/default-global-state.provider";
|
import { DefaultGlobalStateProvider } from "@bitwarden/common/platform/state/implementations/default-global-state.provider";
|
||||||
|
// eslint-disable-next-line import/no-restricted-paths -- We need the implementation to inject, but generally this should not be accessed
|
||||||
|
import { DefaultSingleUserStateProvider } from "@bitwarden/common/platform/state/implementations/default-single-user-state.provider";
|
||||||
|
// eslint-disable-next-line import/no-restricted-paths -- We need the implementation to inject, but generally this should not be accessed
|
||||||
|
import { DefaultStateProvider } from "@bitwarden/common/platform/state/implementations/default-state.provider";
|
||||||
import { AuditService } from "@bitwarden/common/services/audit.service";
|
import { AuditService } from "@bitwarden/common/services/audit.service";
|
||||||
import { EventCollectionService } from "@bitwarden/common/services/event/event-collection.service";
|
import { EventCollectionService } from "@bitwarden/common/services/event/event-collection.service";
|
||||||
import { EventUploadService } from "@bitwarden/common/services/event/event-upload.service";
|
import { EventUploadService } from "@bitwarden/common/services/event/event-upload.service";
|
||||||
|
@ -166,6 +177,9 @@ export class Main {
|
||||||
configService: CliConfigService;
|
configService: CliConfigService;
|
||||||
accountService: AccountService;
|
accountService: AccountService;
|
||||||
globalStateProvider: GlobalStateProvider;
|
globalStateProvider: GlobalStateProvider;
|
||||||
|
singleUserStateProvider: SingleUserStateProvider;
|
||||||
|
activeUserStateProvider: ActiveUserStateProvider;
|
||||||
|
stateProvider: StateProvider;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
let p = null;
|
let p = null;
|
||||||
|
@ -210,6 +224,12 @@ export class Main {
|
||||||
this.storageService,
|
this.storageService,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.singleUserStateProvider = new DefaultSingleUserStateProvider(
|
||||||
|
this.encryptService,
|
||||||
|
this.memoryStorageService,
|
||||||
|
this.storageService,
|
||||||
|
);
|
||||||
|
|
||||||
this.messagingService = new NoopMessagingService();
|
this.messagingService = new NoopMessagingService();
|
||||||
|
|
||||||
this.accountService = new AccountServiceImplementation(
|
this.accountService = new AccountServiceImplementation(
|
||||||
|
@ -218,6 +238,19 @@ export class Main {
|
||||||
this.globalStateProvider,
|
this.globalStateProvider,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.activeUserStateProvider = new DefaultActiveUserStateProvider(
|
||||||
|
this.accountService,
|
||||||
|
this.encryptService,
|
||||||
|
this.memoryStorageService,
|
||||||
|
this.storageService,
|
||||||
|
);
|
||||||
|
|
||||||
|
this.stateProvider = new DefaultStateProvider(
|
||||||
|
this.activeUserStateProvider,
|
||||||
|
this.singleUserStateProvider,
|
||||||
|
this.globalStateProvider,
|
||||||
|
);
|
||||||
|
|
||||||
this.stateService = new StateService(
|
this.stateService = new StateService(
|
||||||
this.storageService,
|
this.storageService,
|
||||||
this.secureStorageService,
|
this.secureStorageService,
|
||||||
|
|
Loading…
Reference in New Issue