1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 00:03:56 +00:00

[PM-19287] Feature flag for encrypt service (#13894)

* Extract getFeatureFlagValue to pure function

Co-authored-by: Matt Gibson <mgibson@bitwarden.com>

* Add broadcasting abstractions and OnServerConfigChange interface.

Co-authored-by: Matt Gibson <mgibson@bitwarden.com>

* Add implementation of onServerConfigChange on encrypt services

Co-authored-by: Matt Gibson <mgibson@bitwarden.com>

* Add onServerConfigChange implementation for encrypt worker

Co-authored-by: Matt Gibson <mgibson@bitwarden.com>

* Wire up broadcasting in dependency injection

Co-authored-by: Matt Gibson <mgibson@bitwarden.com>

* Add unit tests

* Handle subscribing for onServerConfigChange in init services

---------

Co-authored-by: Matt Gibson <mgibson@bitwarden.com>
This commit is contained in:
Thomas Avery
2025-04-01 14:14:00 -05:00
committed by GitHub
parent fa0a7af8ed
commit 17f661e3d1
20 changed files with 722 additions and 58 deletions

View File

@@ -1309,6 +1309,13 @@ export default class MainBackground {
// Only the "true" background should run migrations
await this.stateService.init({ runMigrations: true });
this.configService.serverConfig$.subscribe((newConfig) => {
if (newConfig != null) {
this.encryptService.onServerConfigChange(newConfig);
this.bulkEncryptService.onServerConfigChange(newConfig);
}
});
// This is here instead of in in the InitService b/c we don't plan for
// side effects to run in the Browser InitService.
const accounts = await firstValueFrom(this.accountService.accounts$);

View File

@@ -3,6 +3,9 @@ import { inject, Inject, Injectable } from "@angular/core";
import { AbstractThemingService } from "@bitwarden/angular/platform/services/theming/theming.service.abstraction";
import { TwoFactorService } from "@bitwarden/common/auth/abstractions/two-factor.service";
import { BulkEncryptService } from "@bitwarden/common/key-management/crypto/abstractions/bulk-encrypt.service";
import { EncryptService } from "@bitwarden/common/key-management/crypto/abstractions/encrypt.service";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService as LogServiceAbstraction } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
@@ -27,6 +30,9 @@ export class InitService {
private themingService: AbstractThemingService,
private sdkLoadService: SdkLoadService,
private viewCacheService: PopupViewCacheService,
private configService: ConfigService,
private encryptService: EncryptService,
private bulkEncryptService: BulkEncryptService,
@Inject(DOCUMENT) private document: Document,
) {}
@@ -34,6 +40,12 @@ export class InitService {
return async () => {
await this.sdkLoadService.loadAndInit();
await this.stateService.init({ runMigrations: false }); // Browser background is responsible for migrations
this.configService.serverConfig$.subscribe((newConfig) => {
if (newConfig != null) {
this.encryptService.onServerConfigChange(newConfig);
this.bulkEncryptService.onServerConfigChange(newConfig);
}
});
await this.i18nService.init();
this.twoFactorService.init();
await this.viewCacheService.init();