From ba824c87d1b1a18af419b1c1fa33ddb532fe0fb8 Mon Sep 17 00:00:00 2001 From: Todd Martin Date: Fri, 9 May 2025 20:38:24 -0400 Subject: [PATCH] Added feature support property for sync domains --- .../browser-platform-utils.service.ts | 4 +++ .../services/cli-platform-utils.service.ts | 4 +++ .../electron-platform-utils.service.ts | 4 +++ .../app/core/web-platform-utils.service.ts | 4 +++ .../abstractions/platform-utils.service.ts | 1 + libs/common/src/services/api.service.ts | 26 ++++--------------- 6 files changed, 22 insertions(+), 21 deletions(-) diff --git a/apps/browser/src/platform/services/platform-utils/browser-platform-utils.service.ts b/apps/browser/src/platform/services/platform-utils/browser-platform-utils.service.ts index c9200ecc1a4..0fb9af7921f 100644 --- a/apps/browser/src/platform/services/platform-utils/browser-platform-utils.service.ts +++ b/apps/browser/src/platform/services/platform-utils/browser-platform-utils.service.ts @@ -221,6 +221,10 @@ export abstract class BrowserPlatformUtilsService implements PlatformUtilsServic return true; } + supportsSyncDomains(): boolean { + return true; + } + abstract showToast( type: "error" | "success" | "warning" | "info", title: string, diff --git a/apps/cli/src/platform/services/cli-platform-utils.service.ts b/apps/cli/src/platform/services/cli-platform-utils.service.ts index 87b1a79435c..ca6197f3d24 100644 --- a/apps/cli/src/platform/services/cli-platform-utils.service.ts +++ b/apps/cli/src/platform/services/cli-platform-utils.service.ts @@ -108,6 +108,10 @@ export class CliPlatformUtilsService implements PlatformUtilsService { return false; } + supportsSyncDomains(): boolean { + return false; + } + showToast( type: "error" | "success" | "warning" | "info", title: string, diff --git a/apps/desktop/src/platform/services/electron-platform-utils.service.ts b/apps/desktop/src/platform/services/electron-platform-utils.service.ts index b7c82f4e5db..2b3ab814f0d 100644 --- a/apps/desktop/src/platform/services/electron-platform-utils.service.ts +++ b/apps/desktop/src/platform/services/electron-platform-utils.service.ts @@ -86,6 +86,10 @@ export class ElectronPlatformUtilsService implements PlatformUtilsService { return true; } + supportsSyncDomains(): boolean { + return false; + } + showToast( type: "error" | "success" | "warning" | "info", title: string, diff --git a/apps/web/src/app/core/web-platform-utils.service.ts b/apps/web/src/app/core/web-platform-utils.service.ts index f7d58e72ded..34579307635 100644 --- a/apps/web/src/app/core/web-platform-utils.service.ts +++ b/apps/web/src/app/core/web-platform-utils.service.ts @@ -125,6 +125,10 @@ export class WebPlatformUtilsService implements PlatformUtilsService { return true; } + supportsSyncDomains(): boolean { + return false; + } + showToast( type: "error" | "success" | "warning" | "info", title: string, diff --git a/libs/common/src/platform/abstractions/platform-utils.service.ts b/libs/common/src/platform/abstractions/platform-utils.service.ts index fa0fc8f2501..f1e26ed7da3 100644 --- a/libs/common/src/platform/abstractions/platform-utils.service.ts +++ b/libs/common/src/platform/abstractions/platform-utils.service.ts @@ -28,6 +28,7 @@ export abstract class PlatformUtilsService { abstract getApplicationVersionNumber(): Promise; abstract supportsWebAuthn(win: Window): boolean; abstract supportsDuo(): boolean; + abstract supportsSyncDomains(): boolean; /** * @deprecated use `@bitwarden/components/ToastService.showToast` instead * diff --git a/libs/common/src/services/api.service.ts b/libs/common/src/services/api.service.ts index fb4d08db81c..27ee94864a3 100644 --- a/libs/common/src/services/api.service.ts +++ b/libs/common/src/services/api.service.ts @@ -94,7 +94,7 @@ import { PaymentResponse } from "../billing/models/response/payment.response"; import { PlanResponse } from "../billing/models/response/plan.response"; import { SubscriptionResponse } from "../billing/models/response/subscription.response"; import { TaxInfoResponse } from "../billing/models/response/tax-info.response"; -import { DeviceType } from "../enums"; +import { ClientType, DeviceType } from "../enums"; import { KeyConnectorUserKeyRequest } from "../key-management/key-connector/models/key-connector-user-key.request"; import { SetKeyConnectorKeyRequest } from "../key-management/key-connector/models/set-key-connector-key.request"; import { VaultTimeoutSettingsService } from "../key-management/vault-timeout"; @@ -147,8 +147,6 @@ import { OptionalCipherResponse } from "../vault/models/response/optional-cipher export class ApiService implements ApiServiceAbstraction { private device: DeviceType; private deviceType: string; - private isWebClient = false; - private isDesktopClient = false; private refreshTokenPromise: Promise | undefined; /** @@ -170,22 +168,6 @@ export class ApiService implements ApiServiceAbstraction { ) { this.device = platformUtilsService.getDevice(); this.deviceType = this.device.toString(); - this.isWebClient = - this.device === DeviceType.IEBrowser || - this.device === DeviceType.ChromeBrowser || - this.device === DeviceType.EdgeBrowser || - this.device === DeviceType.FirefoxBrowser || - this.device === DeviceType.OperaBrowser || - this.device === DeviceType.SafariBrowser || - this.device === DeviceType.UnknownBrowser || - this.device === DeviceType.VivaldiBrowser; - this.isDesktopClient = - this.device === DeviceType.WindowsDesktop || - this.device === DeviceType.MacOsDesktop || - this.device === DeviceType.LinuxDesktop || - this.device === DeviceType.WindowsCLI || - this.device === DeviceType.MacOsCLI || - this.device === DeviceType.LinuxCLI; } // Auth APIs @@ -875,7 +857,9 @@ export class ApiService implements ApiServiceAbstraction { // Sync APIs async getSync(): Promise { - const path = this.isDesktopClient || this.isWebClient ? "/sync?excludeDomains=true" : "/sync"; + const path = !this.platformUtilsService.supportsSyncDomains() + ? "/sync?excludeDomains=true" + : "/sync"; const r = await this.send("GET", path, null, true, true); return new SyncResponse(r); } @@ -1919,7 +1903,7 @@ export class ApiService implements ApiServiceAbstraction { private async getCredentials(): Promise { const env = await firstValueFrom(this.environmentService.environment$); - if (!this.isWebClient || env.hasBaseUrl()) { + if (this.platformUtilsService.getClientType() !== ClientType.Web || env.hasBaseUrl()) { return "include"; } return undefined;