mirror of
https://github.com/bitwarden/browser
synced 2026-02-04 10:43:47 +00:00
initial facade implementation
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
import { SemVer } from "semver";
|
||||
|
||||
import { LogService, LogProvider } from "@bitwarden/logging";
|
||||
import { BitwardenClient } from "@bitwarden/sdk-internal";
|
||||
import { StateProvider } from "@bitwarden/state";
|
||||
|
||||
import { PolicyService } from "../admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { FeatureFlag } from "../enums/feature-flag.enum";
|
||||
import { ConfigService } from "../platform/abstractions/config/config.service";
|
||||
import { PlatformUtilsService } from "../platform/abstractions/platform-utils.service";
|
||||
import { UserId } from "../types/guid";
|
||||
|
||||
import { LegacyEncryptorProvider } from "./cryptography/legacy-encryptor-provider";
|
||||
import { ExtensionRegistry } from "./extension/extension-registry.abstraction";
|
||||
@@ -64,3 +68,139 @@ export function createSystemServiceProvider(
|
||||
environment,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Facade exposing methods from ConfigService and PlatformUtilsService that appear related to environmental awareness
|
||||
*/
|
||||
export class EnvService {
|
||||
constructor(
|
||||
private configService: ConfigService,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
) {}
|
||||
|
||||
/* ConfigService methods */
|
||||
get serverConfig$() {
|
||||
return this.configService.serverConfig$;
|
||||
}
|
||||
|
||||
get serverSettings$() {
|
||||
return this.configService.serverSettings$;
|
||||
}
|
||||
|
||||
get cloudRegion$() {
|
||||
return this.configService.cloudRegion$;
|
||||
}
|
||||
|
||||
getFeatureFlag$<Flag extends FeatureFlag>(key: Flag) {
|
||||
return this.configService.getFeatureFlag$(key);
|
||||
}
|
||||
|
||||
userCachedFeatureFlag$<Flag extends FeatureFlag>(key: Flag, userId: UserId) {
|
||||
return this.configService.userCachedFeatureFlag$(key, userId);
|
||||
}
|
||||
|
||||
getFeatureFlag<Flag extends FeatureFlag>(key: Flag) {
|
||||
return this.configService.getFeatureFlag(key);
|
||||
}
|
||||
|
||||
checkServerMeetsVersionRequirement$(minimumRequiredServerVersion: SemVer) {
|
||||
return this.configService.checkServerMeetsVersionRequirement$(minimumRequiredServerVersion);
|
||||
}
|
||||
|
||||
ensureConfigFetched() {
|
||||
return this.configService.ensureConfigFetched();
|
||||
}
|
||||
|
||||
/* PlatformUtilsService methods */
|
||||
getDevice() {
|
||||
return this.platformUtilsService.getDevice();
|
||||
}
|
||||
|
||||
getDeviceString() {
|
||||
return this.platformUtilsService.getDeviceString();
|
||||
}
|
||||
|
||||
getClientType() {
|
||||
return this.platformUtilsService.getClientType();
|
||||
}
|
||||
|
||||
isFirefox() {
|
||||
return this.platformUtilsService.isFirefox();
|
||||
}
|
||||
|
||||
isChrome() {
|
||||
return this.platformUtilsService.isChrome();
|
||||
}
|
||||
|
||||
isEdge() {
|
||||
return this.platformUtilsService.isEdge();
|
||||
}
|
||||
|
||||
isOpera() {
|
||||
return this.platformUtilsService.isOpera();
|
||||
}
|
||||
|
||||
isVivaldi() {
|
||||
return this.platformUtilsService.isVivaldi();
|
||||
}
|
||||
|
||||
isSafari() {
|
||||
return this.platformUtilsService.isSafari();
|
||||
}
|
||||
|
||||
isChromium() {
|
||||
return this.platformUtilsService.isChromium();
|
||||
}
|
||||
|
||||
isMacAppStore() {
|
||||
return this.platformUtilsService.isMacAppStore();
|
||||
}
|
||||
|
||||
isPopupOpen() {
|
||||
return this.platformUtilsService.isPopupOpen();
|
||||
}
|
||||
|
||||
launchUri(uri: string, options?: any) {
|
||||
return this.platformUtilsService.launchUri(uri, options);
|
||||
}
|
||||
|
||||
getApplicationVersion() {
|
||||
return this.platformUtilsService.getApplicationVersion();
|
||||
}
|
||||
|
||||
getApplicationVersionNumber() {
|
||||
return this.platformUtilsService.getApplicationVersionNumber();
|
||||
}
|
||||
|
||||
supportsWebAuthn(win: Window) {
|
||||
return this.platformUtilsService.supportsWebAuthn(win);
|
||||
}
|
||||
|
||||
supportsDuo() {
|
||||
return this.platformUtilsService.supportsDuo();
|
||||
}
|
||||
|
||||
supportsAutofill() {
|
||||
return this.platformUtilsService.supportsAutofill();
|
||||
}
|
||||
|
||||
supportsFileDownloads() {
|
||||
return this.platformUtilsService.supportsFileDownloads();
|
||||
}
|
||||
|
||||
isDev() {
|
||||
return this.platformUtilsService.isDev();
|
||||
}
|
||||
|
||||
isSelfHost() {
|
||||
return this.platformUtilsService.isSelfHost();
|
||||
}
|
||||
|
||||
supportsSecureStorage() {
|
||||
return this.platformUtilsService.supportsSecureStorage();
|
||||
}
|
||||
|
||||
getAutofillKeyboardShortcut() {
|
||||
return this.platformUtilsService.getAutofillKeyboardShortcut();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user