mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 17:53:39 +00:00
* add server url to account switcher tab * add serverUrl to SwitcherAccount(s) * refactor serverUrl getter * cleanup urls * adjust styling * remove SwitcherAccount class * remove authenticationStatus from AccountProfile * rename to inactiveAccounts for clarity * move business logic to environmentService * use tokenService instead of stateService * cleanup type and comments * remove unused property * replace magic strings * remove unused function * minor refactoring * refactor to use environmentService insead of getServerConfig * use Utils.getHost() instead of Utils.getDomain() * create getHost() method * remove comment * get base url as fallback * resolve eslint error * Update apps/desktop/src/app/layout/account-switcher.component.html Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> --------- Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com>
70 lines
1.6 KiB
TypeScript
70 lines
1.6 KiB
TypeScript
import { Observable } from "rxjs";
|
|
|
|
export type Urls = {
|
|
base?: string;
|
|
webVault?: string;
|
|
api?: string;
|
|
identity?: string;
|
|
icons?: string;
|
|
notifications?: string;
|
|
events?: string;
|
|
keyConnector?: string;
|
|
scim?: string;
|
|
};
|
|
|
|
export type PayPalConfig = {
|
|
businessId?: string;
|
|
buttonAction?: string;
|
|
};
|
|
|
|
export enum Region {
|
|
US = "US",
|
|
EU = "EU",
|
|
SelfHosted = "Self-hosted",
|
|
}
|
|
|
|
export enum RegionDomain {
|
|
US = "bitwarden.com",
|
|
EU = "bitwarden.eu",
|
|
USQA = "bitwarden.pw",
|
|
}
|
|
|
|
export abstract class EnvironmentService {
|
|
urls: Observable<void>;
|
|
usUrls: Urls;
|
|
euUrls: Urls;
|
|
selectedRegion?: Region;
|
|
initialized = true;
|
|
|
|
hasBaseUrl: () => boolean;
|
|
getNotificationsUrl: () => string;
|
|
getWebVaultUrl: () => string;
|
|
/**
|
|
* Retrieves the URL of the cloud web vault app.
|
|
*
|
|
* @returns {string} The URL of the cloud web vault app.
|
|
* @remarks Use this method only in views exclusive to self-host instances.
|
|
*/
|
|
getCloudWebVaultUrl: () => string;
|
|
/**
|
|
* Sets the URL of the cloud web vault app based on the region parameter.
|
|
*
|
|
* @param {Region} region - The region of the cloud web vault app.
|
|
*/
|
|
setCloudWebVaultUrl: (region: Region) => void;
|
|
getSendUrl: () => string;
|
|
getIconsUrl: () => string;
|
|
getApiUrl: () => string;
|
|
getIdentityUrl: () => string;
|
|
getEventsUrl: () => string;
|
|
getKeyConnectorUrl: () => string;
|
|
getScimUrl: () => string;
|
|
setUrlsFromStorage: () => Promise<void>;
|
|
setUrls: (urls: Urls) => Promise<Urls>;
|
|
getHost: (userId?: string) => Promise<string>;
|
|
setRegion: (region: Region) => Promise<void>;
|
|
getUrls: () => Urls;
|
|
isCloud: () => boolean;
|
|
isEmpty: () => boolean;
|
|
}
|