diff --git a/common/src/abstractions/state.service.ts b/common/src/abstractions/state.service.ts index 5dd3da2e87..693feb7eb3 100644 --- a/common/src/abstractions/state.service.ts +++ b/common/src/abstractions/state.service.ts @@ -14,6 +14,7 @@ import { SendData } from "../models/data/sendData"; import { Account } from "../models/domain/account"; import { EncString } from "../models/domain/encString"; +import { EnvironmentUrls } from "../models/domain/environmentUrls"; import { GeneratedPasswordHistory } from "../models/domain/generatedPasswordHistory"; import { Policy } from "../models/domain/policy"; import { StorageOptions } from "../models/domain/storageOptions"; @@ -213,8 +214,8 @@ export abstract class StateService { setEntityId: (value: string, options?: StorageOptions) => Promise; getEntityType: (options?: StorageOptions) => Promise; setEntityType: (value: string, options?: StorageOptions) => Promise; - getEnvironmentUrls: (options?: StorageOptions) => Promise; - setEnvironmentUrls: (value: any, options?: StorageOptions) => Promise; + getEnvironmentUrls: (options?: StorageOptions) => Promise; + setEnvironmentUrls: (value: EnvironmentUrls, options?: StorageOptions) => Promise; getEquivalentDomains: (options?: StorageOptions) => Promise; setEquivalentDomains: (value: string, options?: StorageOptions) => Promise; getEventCollection: (options?: StorageOptions) => Promise; diff --git a/common/src/models/domain/environmentUrls.ts b/common/src/models/domain/environmentUrls.ts index c80265924c..d4fd173c83 100644 --- a/common/src/models/domain/environmentUrls.ts +++ b/common/src/models/domain/environmentUrls.ts @@ -1,10 +1,10 @@ export class EnvironmentUrls { - base: string; - api: string; - identity: string; - icons: string; - notifications: string; - events: string; - webVault: string; - keyConnector: string; + base: string = null; + api: string = null; + identity: string = null; + icons: string = null; + notifications: string = null; + events: string = null; + webVault: string = null; + keyConnector: string = null; } diff --git a/common/src/services/state.service.ts b/common/src/services/state.service.ts index aefdf6652a..0f6b1c9e3e 100644 --- a/common/src/services/state.service.ts +++ b/common/src/services/state.service.ts @@ -1361,15 +1361,15 @@ export class StateService ); } - async getEnvironmentUrls(options?: StorageOptions): Promise { - options = this.reconcileOptions(options, await this.defaultOnDiskOptions()); + async getEnvironmentUrls(options?: StorageOptions): Promise { if (this.state.activeUserId == null) { - return (await this.getGlobals(options)).environmentUrls ?? new EnvironmentUrls(); + return await this.getGlobalEnvironmentUrls(options); } + options = this.reconcileOptions(options, await this.defaultOnDiskOptions()); return (await this.getAccount(options))?.settings?.environmentUrls ?? new EnvironmentUrls(); } - async setEnvironmentUrls(value: any, options?: StorageOptions): Promise { + async setEnvironmentUrls(value: EnvironmentUrls, options?: StorageOptions): Promise { // Global values are set on each change and the current global settings are passed to any newly authed accounts. // This is to allow setting environement values before an account is active, while still allowing individual accounts to have their own environments. const globals = await this.getGlobals( @@ -2377,7 +2377,12 @@ export class StateService } protected async setAccountEnvironmentUrls(account: TAccount): Promise { - account.settings.environmentUrls = await this.getEnvironmentUrls(); + account.settings.environmentUrls = await this.getGlobalEnvironmentUrls(); return account; } + + protected async getGlobalEnvironmentUrls(options?: StorageOptions): Promise { + options = this.reconcileOptions(options, await this.defaultOnDiskOptions()); + return (await this.getGlobals(options)).environmentUrls ?? new EnvironmentUrls(); + } }