mirror of
https://github.com/bitwarden/browser
synced 2025-12-20 10:13:31 +00:00
Auth/PM-13114 - WebEnvService Refactor + Unit Tests to support QA Env Selector (#11397)
* PM-13114 - WebEnvSvc - use hostname vs domain check for init and setEnv (tests TODO) * PM-13114 - WebEnvSvc + URLs webpack config - use expected string variable on process.env.URLS to ensure tests can properly mock the WebEnvSvc * PM-13114 - WebEnvSvc - setEnvironment - fix issue with returning currentRegion urls instead of currentEnv urls. * PM-13114 - WebEnvSvc - setEnv - refactor names to improve clarity. * PM-13114 - WebEnvSvc spec file - Test all prod scenarios * PM-13144 - Work with Justin to move process.env.Urls access into injection token and remove webpack string type conversion. * PM-13114 - WIP on getting additionalRegionConfigs injected via injection token to default env service. * PM-13114 - Update all background inits to pass process.env.ADDITIONAL_REGIONS as unknown as RegionConfig[] to env service. * PM-13114 - WebEnvSvc - adjust order of constructor deps * PM-13114 - WebEnvSvc - add WebRegionConfig to extend RegionConfig type and be accurate for what the WebEnvSvc uses. * PM-13114 - WebEnvSvc Tests - US QA tested * PM-13114 - WebEnvSvc tests - refactor QA naming to make it more clear. * PM-13114 - WebEnvSvc - test QA EU * PM-13114 - WebEnvSvc - remove promise resolve per PR feedback.
This commit is contained in:
@@ -11,6 +11,7 @@ import { SafeProvider, safeProvider } from "@bitwarden/angular/platform/utils/sa
|
||||
import {
|
||||
CLIENT_TYPE,
|
||||
DEFAULT_VAULT_TIMEOUT,
|
||||
ENV_ADDITIONAL_REGIONS,
|
||||
LOCALES_DIRECTORY,
|
||||
MEMORY_STORAGE,
|
||||
OBSERVABLE_DISK_LOCAL_STORAGE,
|
||||
@@ -42,7 +43,10 @@ import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.ser
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { CryptoService as CryptoServiceAbstraction } from "@bitwarden/common/platform/abstractions/crypto.service";
|
||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||
import {
|
||||
EnvironmentService,
|
||||
Urls,
|
||||
} from "@bitwarden/common/platform/abstractions/environment.service";
|
||||
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
||||
import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
@@ -84,6 +88,7 @@ import { WebStorageServiceProvider } from "../platform/web-storage-service.provi
|
||||
|
||||
import { EventService } from "./event.service";
|
||||
import { InitService } from "./init.service";
|
||||
import { ENV_URLS } from "./injection-tokens";
|
||||
import { ModalService } from "./modal.service";
|
||||
import { RouterService } from "./router.service";
|
||||
import { WebFileDownloadService } from "./web-file-download.service";
|
||||
@@ -173,10 +178,14 @@ const safeProviders: SafeProvider[] = [
|
||||
useClass: WebMigrationRunner,
|
||||
deps: [AbstractStorageService, LogService, MigrationBuilderService, WindowStorageService],
|
||||
}),
|
||||
safeProvider({
|
||||
provide: ENV_URLS,
|
||||
useValue: process.env.URLS as Urls,
|
||||
}),
|
||||
safeProvider({
|
||||
provide: EnvironmentService,
|
||||
useClass: WebEnvironmentService,
|
||||
deps: [WINDOW, StateProvider, AccountService, Router],
|
||||
deps: [WINDOW, StateProvider, AccountService, ENV_ADDITIONAL_REGIONS, Router, ENV_URLS],
|
||||
}),
|
||||
safeProvider({
|
||||
provide: BiometricsService,
|
||||
|
||||
10
apps/web/src/app/core/injection-tokens.ts
Normal file
10
apps/web/src/app/core/injection-tokens.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
// Put web specific injection tokens here
|
||||
import { SafeInjectionToken } from "@bitwarden/angular/services/injection-tokens";
|
||||
import { Urls } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||
|
||||
/**
|
||||
* Injection token for injecting the NodeJS process.env urls into services.
|
||||
* Using an injection token allows services to be tested without needing to
|
||||
* mock the process.env.
|
||||
*/
|
||||
export const ENV_URLS = new SafeInjectionToken<Urls>("ENV_URLS");
|
||||
Reference in New Issue
Block a user