1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-14 23:33:31 +00:00

Feat PM-19877 System Notification Processing (#15611)

* feat(notification-processing): [PM-19877] System Notification Implementation - Minor changes to popup logic and removed content in login component.

* docs(notification-processing): [PM-19877] System Notification Implementation - Added more docs.

* docs(notification-processing): [PM-19877] System Notification Implementation - Added markdown document.

* fix(notification-processing): [PM-19877] System Notification Implementation - Updated condition for if notification is supported.

* fix(notification-processing): [PM-19877] System Notification Implementation - Updated services module with correct platform utils service.
This commit is contained in:
Patrick-Pimentel-Bitwarden
2025-08-20 12:42:16 -04:00
committed by GitHub
parent bcd73a9c00
commit 719a43d050
55 changed files with 420 additions and 132 deletions

View File

@@ -7,7 +7,7 @@ import {
VaultTimeoutSettingsService,
VaultTimeoutStringType,
} from "@bitwarden/common/key-management/vault-timeout";
import { NotificationsService } from "@bitwarden/common/platform/notifications";
import { ServerNotificationsService } from "@bitwarden/common/platform/server-notifications";
const IdleInterval = 60 * 5; // 5 minutes
@@ -18,7 +18,7 @@ export default class IdleBackground {
constructor(
private vaultTimeoutService: VaultTimeoutService,
private notificationsService: NotificationsService,
private serverNotificationsService: ServerNotificationsService,
private accountService: AccountService,
private vaultTimeoutSettingsService: VaultTimeoutSettingsService,
) {
@@ -32,9 +32,9 @@ export default class IdleBackground {
const idleHandler = (newState: string) => {
if (newState === "active") {
this.notificationsService.reconnectFromActivity();
this.serverNotificationsService.reconnectFromActivity();
} else {
this.notificationsService.disconnectFromInactivity();
this.serverNotificationsService.disconnectFromInactivity();
}
};
if (this.idle.onStateChanged && this.idle.setDetectionInterval) {

View File

@@ -111,21 +111,22 @@ import {
ObservableStorageService,
} from "@bitwarden/common/platform/abstractions/storage.service";
import { SystemService as SystemServiceAbstraction } from "@bitwarden/common/platform/abstractions/system.service";
import { ActionsService } from "@bitwarden/common/platform/actions/actions-service";
import { IpcService } from "@bitwarden/common/platform/ipc";
import { Message, MessageListener, MessageSender } from "@bitwarden/common/platform/messaging";
// eslint-disable-next-line no-restricted-imports -- Used for dependency creation
import { SubjectMessageSender } from "@bitwarden/common/platform/messaging/internal";
import { Lazy } from "@bitwarden/common/platform/misc/lazy";
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
import { NotificationsService } from "@bitwarden/common/platform/notifications";
import { ServerNotificationsService } from "@bitwarden/common/platform/server-notifications";
// eslint-disable-next-line no-restricted-imports -- Needed for service creation
import {
DefaultNotificationsService,
DefaultServerNotificationsService,
SignalRConnectionService,
UnsupportedWebPushConnectionService,
WebPushNotificationsApiService,
WorkerWebPushConnectionService,
} from "@bitwarden/common/platform/notifications/internal";
} from "@bitwarden/common/platform/server-notifications/internal";
import { AppIdService } from "@bitwarden/common/platform/services/app-id.service";
import { ConfigApiService } from "@bitwarden/common/platform/services/config/config-api.service";
import { DefaultConfigService } from "@bitwarden/common/platform/services/config/default-config.service";
@@ -164,6 +165,8 @@ import { WindowStorageService } from "@bitwarden/common/platform/storage/window-
import { SyncService } from "@bitwarden/common/platform/sync";
// eslint-disable-next-line no-restricted-imports -- Needed for service creation
import { DefaultSyncService } from "@bitwarden/common/platform/sync/internal";
import { SystemNotificationsService } from "@bitwarden/common/platform/system-notifications/";
import { UnsupportedSystemNotificationsService } from "@bitwarden/common/platform/system-notifications/unsupported-system-notifications.service";
import { DefaultThemeStateService } from "@bitwarden/common/platform/theming/theme-state.service";
import { ApiService } from "@bitwarden/common/services/api.service";
import { AuditService } from "@bitwarden/common/services/audit.service";
@@ -264,6 +267,7 @@ import { InlineMenuFieldQualificationService } from "../autofill/services/inline
import { SafariApp } from "../browser/safariApp";
import { BackgroundBrowserBiometricsService } from "../key-management/biometrics/background-browser-biometrics.service";
import VaultTimeoutService from "../key-management/vault-timeout/vault-timeout.service";
import { BrowserActionsService } from "../platform/actions/browser-actions.service";
import { DefaultBadgeBrowserApi } from "../platform/badge/badge-browser-api";
import { BadgeService } from "../platform/badge/badge.service";
import { BrowserApi } from "../platform/browser/browser-api";
@@ -292,6 +296,7 @@ import { BackgroundMemoryStorageService } from "../platform/storage/background-m
import { BrowserStorageServiceProvider } from "../platform/storage/browser-storage-service.provider";
import { OffscreenStorageService } from "../platform/storage/offscreen-storage.service";
import { SyncServiceListener } from "../platform/sync/sync-service.listener";
import { BrowserSystemNotificationService } from "../platform/system-notifications/browser-system-notification.service";
import { fromChromeRuntimeMessaging } from "../platform/utils/from-chrome-runtime-messaging";
import { VaultFilterService } from "../vault/services/vault-filter.service";
@@ -337,7 +342,9 @@ export default class MainBackground {
importService: ImportServiceAbstraction;
exportService: VaultExportServiceAbstraction;
searchService: SearchServiceAbstraction;
notificationsService: NotificationsService;
serverNotificationsService: ServerNotificationsService;
systemNotificationService: SystemNotificationsService;
actionsService: ActionsService;
stateService: StateServiceAbstraction;
userNotificationSettingsService: UserNotificationSettingsServiceAbstraction;
autofillSettingsService: AutofillSettingsServiceAbstraction;
@@ -439,7 +446,6 @@ export default class MainBackground {
private webRequestBackground: WebRequestBackground;
private syncTimeout: any;
private isSafari: boolean;
private nativeMessagingBackground: NativeMessagingBackground;
private popupViewCacheBackgroundService: PopupViewCacheBackgroundService;
@@ -1109,7 +1115,18 @@ export default class MainBackground {
this.webPushConnectionService = new UnsupportedWebPushConnectionService();
}
this.notificationsService = new DefaultNotificationsService(
this.actionsService = new BrowserActionsService(this.logService, this.platformUtilsService);
if ("notifications" in chrome) {
this.systemNotificationService = new BrowserSystemNotificationService(
this.logService,
this.platformUtilsService,
);
} else {
this.systemNotificationService = new UnsupportedSystemNotificationsService();
}
this.serverNotificationsService = new DefaultServerNotificationsService(
this.logService,
this.syncService,
this.appIdService,
@@ -1163,9 +1180,6 @@ export default class MainBackground {
this.logService,
);
// Other fields
this.isSafari = this.platformUtilsService.isSafari();
// Background
this.fido2Background = new Fido2Background(
@@ -1183,7 +1197,6 @@ export default class MainBackground {
this,
this.autofillService,
this.platformUtilsService as BrowserPlatformUtilsService,
this.notificationsService,
this.autofillSettingsService,
this.processReloadService,
this.environmentService,
@@ -1222,7 +1235,7 @@ export default class MainBackground {
this.apiService,
this.organizationService,
this.authService,
this.notificationsService,
this.serverNotificationsService,
messageListener,
);
@@ -1296,7 +1309,7 @@ export default class MainBackground {
this.idleBackground = new IdleBackground(
this.vaultTimeoutService,
this.notificationsService,
this.serverNotificationsService,
this.accountService,
this.vaultTimeoutSettingsService,
);
@@ -1354,7 +1367,7 @@ export default class MainBackground {
this.endUserNotificationService = new DefaultEndUserNotificationService(
this.stateProvider,
this.apiService,
this.notificationsService,
this.serverNotificationsService,
this.authService,
this.logService,
);
@@ -1433,7 +1446,7 @@ export default class MainBackground {
setTimeout(async () => {
await this.fullSync(false);
this.backgroundSyncService.init();
this.notificationsService.startListening();
this.serverNotificationsService.startListening();
this.taskService.listenForTaskNotifications();
this.endUserNotificationService.listenForEndUserNotifications();
@@ -1656,6 +1669,11 @@ export default class MainBackground {
);
}
/**
* Opens the popup.
*
* @deprecated Migrating to the browser actions service.
*/
async openPopup() {
const browserAction = BrowserApi.getBrowserAction();
@@ -1664,7 +1682,7 @@ export default class MainBackground {
return;
}
if (this.isSafari) {
if (this.platformUtilsService.isSafari()) {
await SafariApp.sendMessageToApp("showPopover", null, true);
}
}
@@ -1691,7 +1709,9 @@ export default class MainBackground {
/**
* Opens the popup to the given page
*
* @default ExtensionPageUrls.Index
* @deprecated Migrating to the browser actions service.
*/
async openTheExtensionToPage(url: ExtensionPageUrls = ExtensionPageUrls.Index) {
const isValidUrl = Object.values(ExtensionPageUrls).includes(url);

View File

@@ -15,7 +15,6 @@ import { MessagingService } from "@bitwarden/common/platform/abstractions/messag
import { MessageListener, isExternalMessage } from "@bitwarden/common/platform/messaging";
import { devFlagEnabled } from "@bitwarden/common/platform/misc/flags";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { NotificationsService } from "@bitwarden/common/platform/notifications";
import { CipherType } from "@bitwarden/common/vault/enums";
import { VaultMessages } from "@bitwarden/common/vault/enums/vault-messages.enum";
import { BiometricsCommands } from "@bitwarden/key-management";
@@ -46,7 +45,6 @@ export default class RuntimeBackground {
private main: MainBackground,
private autofillService: AutofillService,
private platformUtilsService: BrowserPlatformUtilsService,
private notificationsService: NotificationsService,
private autofillSettingsService: AutofillSettingsServiceAbstraction,
private processReloadService: ProcessReloadServiceAbstraction,
private environmentService: BrowserEnvironmentService,
@@ -424,6 +422,11 @@ export default class RuntimeBackground {
return await BrowserApi.tabsQuery({ url: `${urlObj.href}*` });
}
/**
* Opens the popup.
*
* @deprecated Migrating to the browser actions service.
*/
private async openPopup() {
await this.main.openPopup();
}
@@ -450,7 +453,7 @@ export default class RuntimeBackground {
/** Sends a message to each tab that the popup was opened */
private announcePopupOpen() {
const announceToAllTabs = async () => {
const isOpen = await this.platformUtilsService.isViewOpen();
const isOpen = await this.platformUtilsService.isPopupOpen();
const tabs = await this.getBwTabs();
if (isOpen && tabs.length > 0) {

View File

@@ -0,0 +1,48 @@
import { DeviceType } from "@bitwarden/common/enums";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { ActionsService } from "@bitwarden/common/platform/actions/actions-service";
import { LogService } from "@bitwarden/logging";
import { SafariApp } from "../../browser/safariApp";
import { BrowserApi } from "../browser/browser-api";
export class BrowserActionsService implements ActionsService {
constructor(
private logService: LogService,
private platformUtilsService: PlatformUtilsService,
) {}
async openPopup(): Promise<void> {
const deviceType = this.platformUtilsService.getDevice();
try {
switch (deviceType) {
case DeviceType.FirefoxExtension:
case DeviceType.ChromeExtension: {
const browserAction = BrowserApi.getBrowserAction();
if ("openPopup" in browserAction && typeof browserAction.openPopup === "function") {
await browserAction.openPopup();
return;
} else {
this.logService.warning(
`No openPopup function found on browser actions. On browser: ${deviceType} and manifest version: ${BrowserApi.manifestVersion}`,
);
}
break;
}
case DeviceType.SafariExtension:
await SafariApp.sendMessageToApp("showPopover", null, true);
return;
default:
this.logService.warning(
`Tried to open the popup from an unsupported device type: ${deviceType}`,
);
}
} catch (e) {
this.logService.error(
`Failed to open the popup on ${DeviceType[deviceType]} with manifest ${BrowserApi.manifestVersion} and error: ${e}`,
);
}
}
}

View File

@@ -1,5 +1,3 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { Observable } from "rxjs";
import { BrowserApi } from "./browser-api";
@@ -26,13 +24,13 @@ export function fromChromeEvent<T extends unknown[]>(
event: chrome.events.Event<(...args: T) => void>,
): Observable<T> {
return new Observable<T>((subscriber) => {
const handler = (...args: T) => {
const handler = (...args: readonly unknown[]) => {
if (chrome.runtime.lastError) {
subscriber.error(chrome.runtime.lastError);
return;
}
subscriber.next(args);
subscriber.next(args as T);
};
BrowserApi.addListener(event, handler);

View File

@@ -2,12 +2,12 @@ import { Observable, Subscription } from "rxjs";
import { NotificationResponse } from "@bitwarden/common/models/response/notification.response";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { NotificationsService } from "@bitwarden/common/platform/notifications";
import { ServerNotificationsService } from "@bitwarden/common/platform/server-notifications";
import { UserId } from "@bitwarden/common/types/guid";
// Eventually if we want to support listening to notifications from browser foreground we
// Eventually if we want to support listening to server notifications from browser foreground we
// will only ever create a single SignalR connection, likely messaging to the background to reuse its connection.
export class ForegroundNotificationsService implements NotificationsService {
export class ForegroundServerNotificationsService implements ServerNotificationsService {
notifications$: Observable<readonly [NotificationResponse, UserId]>;
constructor(private readonly logService: LogService) {

View File

@@ -150,7 +150,7 @@ describe("Browser Utils Service", () => {
callback(undefined);
});
const isViewOpen = await browserPlatformUtilsService.isViewOpen();
const isViewOpen = await browserPlatformUtilsService.isPopupOpen();
expect(isViewOpen).toBe(false);
});
@@ -160,7 +160,7 @@ describe("Browser Utils Service", () => {
callback(message.command === "checkVaultPopupHeartbeat");
});
const isViewOpen = await browserPlatformUtilsService.isViewOpen();
const isViewOpen = await browserPlatformUtilsService.isPopupOpen();
expect(isViewOpen).toBe(true);
});
@@ -173,7 +173,7 @@ describe("Browser Utils Service", () => {
callback(undefined);
});
const isViewOpen = await browserPlatformUtilsService.isViewOpen();
const isViewOpen = await browserPlatformUtilsService.isPopupOpen();
expect(isViewOpen).toBe(false);

View File

@@ -150,7 +150,7 @@ export abstract class BrowserPlatformUtilsService implements PlatformUtilsServic
* message to the popup and waiting for a response. If a response is received,
* the view is open.
*/
async isViewOpen(): Promise<boolean> {
async isPopupOpen(): Promise<boolean> {
if (this.isSafari()) {
// Query views on safari since chrome.runtime.sendMessage does not timeout and will hang.
return BrowserApi.isPopupOpen();

View File

@@ -0,0 +1,60 @@
import { map, merge, Observable } from "rxjs";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import {
ButtonLocation,
SystemNotificationClearInfo,
SystemNotificationCreateInfo,
SystemNotificationEvent,
SystemNotificationsService,
} from "@bitwarden/common/platform/system-notifications/system-notifications.service";
import { fromChromeEvent } from "../browser/from-chrome-event";
export class BrowserSystemNotificationService implements SystemNotificationsService {
notificationClicked$: Observable<SystemNotificationEvent>;
constructor(
private logService: LogService,
private platformUtilsService: PlatformUtilsService,
) {
this.notificationClicked$ = merge(
fromChromeEvent(chrome.notifications.onButtonClicked).pipe(
map(([notificationId, buttonIndex]) => ({
id: notificationId,
buttonIdentifier: buttonIndex,
})),
),
fromChromeEvent(chrome.notifications.onClicked).pipe(
map(([notificationId]: [string]) => ({
id: notificationId,
buttonIdentifier: ButtonLocation.NotificationButton,
})),
),
);
}
async create(createInfo: SystemNotificationCreateInfo): Promise<string> {
return new Promise<string>((resolve) => {
chrome.notifications.create(
{
iconUrl: chrome.runtime.getURL("images/icon128.png"),
message: createInfo.body,
type: "basic",
title: createInfo.title,
buttons: createInfo.buttons.map((value) => ({ title: value.title })),
},
(notificationId) => resolve(notificationId),
);
});
}
async clear(clearInfo: SystemNotificationClearInfo): Promise<undefined> {
chrome.notifications.clear(clearInfo.id);
}
isSupported(): boolean {
return "notifications" in chrome;
}
}

View File

@@ -92,12 +92,13 @@ import {
AbstractStorageService,
ObservableStorageService,
} from "@bitwarden/common/platform/abstractions/storage.service";
import { ActionsService } from "@bitwarden/common/platform/actions";
import { Message, MessageListener, MessageSender } from "@bitwarden/common/platform/messaging";
// eslint-disable-next-line no-restricted-imports -- Used for dependency injection
import { SubjectMessageSender } from "@bitwarden/common/platform/messaging/internal";
import { flagEnabled } from "@bitwarden/common/platform/misc/flags";
import { NotificationsService } from "@bitwarden/common/platform/notifications";
import { TaskSchedulerService } from "@bitwarden/common/platform/scheduling";
import { ServerNotificationsService } from "@bitwarden/common/platform/server-notifications";
import { ConsoleLogService } from "@bitwarden/common/platform/services/console-log.service";
import { ContainerService } from "@bitwarden/common/platform/services/container.service";
import { DefaultSdkClientFactory } from "@bitwarden/common/platform/services/sdk/default-sdk-client-factory";
@@ -113,6 +114,7 @@ import { InlineDerivedStateProvider } from "@bitwarden/common/platform/state/imp
import { PrimarySecondaryStorageService } from "@bitwarden/common/platform/storage/primary-secondary-storage.service";
import { WindowStorageService } from "@bitwarden/common/platform/storage/window-storage.service";
import { SyncService } from "@bitwarden/common/platform/sync";
import { SystemNotificationsService } from "@bitwarden/common/platform/system-notifications/system-notifications.service";
import { SendApiService } from "@bitwarden/common/tools/send/services/send-api.service.abstraction";
import { InternalSendService } from "@bitwarden/common/tools/send/services/send.service.abstraction";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
@@ -160,13 +162,14 @@ import { InlineMenuFieldQualificationService } from "../../autofill/services/inl
import { ForegroundBrowserBiometricsService } from "../../key-management/biometrics/foreground-browser-biometrics";
import { ExtensionLockComponentService } from "../../key-management/lock/services/extension-lock-component.service";
import { ForegroundVaultTimeoutService } from "../../key-management/vault-timeout/foreground-vault-timeout.service";
import { BrowserActionsService } from "../../platform/actions/browser-actions.service";
import { BrowserApi } from "../../platform/browser/browser-api";
import { runInsideAngular } from "../../platform/browser/run-inside-angular.operator";
/* eslint-disable no-restricted-imports */
import { ZonedMessageListenerService } from "../../platform/browser/zoned-message-listener.service";
import { ChromeMessageSender } from "../../platform/messaging/chrome-message.sender";
/* eslint-enable no-restricted-imports */
import { ForegroundNotificationsService } from "../../platform/notifications/foreground-notifications.service";
import { ForegroundServerNotificationsService } from "../../platform/notifications/foreground-server-notifications.service";
import { OffscreenDocumentService } from "../../platform/offscreen-document/abstractions/offscreen-document";
import { DefaultOffscreenDocumentService } from "../../platform/offscreen-document/offscreen-document.service";
import { PopupCompactModeService } from "../../platform/popup/layout/popup-compact-mode.service";
@@ -184,6 +187,7 @@ import { ForegroundTaskSchedulerService } from "../../platform/services/task-sch
import { BrowserStorageServiceProvider } from "../../platform/storage/browser-storage-service.provider";
import { ForegroundMemoryStorageService } from "../../platform/storage/foreground-memory-storage.service";
import { ForegroundSyncService } from "../../platform/sync/foreground-sync.service";
import { BrowserSystemNotificationService } from "../../platform/system-notifications/browser-system-notification.service";
import { fromChromeRuntimeMessaging } from "../../platform/utils/from-chrome-runtime-messaging";
import { FilePopoutUtilsService } from "../../tools/popup/services/file-popout-utils.service";
import { Fido2UserVerificationService } from "../../vault/services/fido2-user-verification.service";
@@ -253,6 +257,11 @@ const safeProviders: SafeProvider[] = [
},
deps: [GlobalStateProvider],
}),
safeProvider({
provide: ActionsService,
useClass: BrowserActionsService,
deps: [LogService, PlatformUtilsService],
}),
safeProvider({
provide: KeyService,
useFactory: (
@@ -609,6 +618,11 @@ const safeProviders: SafeProvider[] = [
useClass: SsoUrlService,
deps: [],
}),
safeProvider({
provide: SystemNotificationsService,
useClass: BrowserSystemNotificationService,
deps: [LogService, PlatformUtilsService],
}),
safeProvider({
provide: LoginComponentService,
useClass: ExtensionLoginComponentService,
@@ -674,8 +688,8 @@ const safeProviders: SafeProvider[] = [
deps: [KeyService, MasterPasswordApiService, InternalMasterPasswordServiceAbstraction, WINDOW],
}),
safeProvider({
provide: NotificationsService,
useClass: ForegroundNotificationsService,
provide: ServerNotificationsService,
useClass: ForegroundServerNotificationsService,
deps: [LogService],
}),
safeProvider({

View File

@@ -75,7 +75,7 @@ export class CliPlatformUtilsService implements PlatformUtilsService {
return false;
}
isViewOpen() {
isPopupOpen() {
return Promise.resolve(false);
}

View File

@@ -62,7 +62,7 @@ import { MessagingService } from "@bitwarden/common/platform/abstractions/messag
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
import { SystemService } from "@bitwarden/common/platform/abstractions/system.service";
import { NotificationsService } from "@bitwarden/common/platform/notifications";
import { ServerNotificationsService } from "@bitwarden/common/platform/server-notifications";
import { StateEventRunnerService } from "@bitwarden/common/platform/state";
import { SyncService } from "@bitwarden/common/platform/sync";
import { UserId } from "@bitwarden/common/types/guid";
@@ -155,7 +155,7 @@ export class AppComponent implements OnInit, OnDestroy {
private messagingService: MessagingService,
private collectionService: CollectionService,
private searchService: SearchService,
private notificationsService: NotificationsService,
private notificationsService: ServerNotificationsService,
private platformUtilsService: PlatformUtilsService,
private systemService: SystemService,
private processReloadService: ProcessReloadServiceAbstraction,

View File

@@ -13,7 +13,7 @@ import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/platfor
import { PlatformUtilsService as PlatformUtilsServiceAbstraction } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { SdkLoadService } from "@bitwarden/common/platform/abstractions/sdk/sdk-load.service";
import { StateService as StateServiceAbstraction } from "@bitwarden/common/platform/abstractions/state.service";
import { NotificationsService } from "@bitwarden/common/platform/notifications";
import { ServerNotificationsService } from "@bitwarden/common/platform/server-notifications";
import { ContainerService } from "@bitwarden/common/platform/services/container.service";
import { MigrationRunner } from "@bitwarden/common/platform/services/migration-runner";
import { UserAutoUnlockKeyService } from "@bitwarden/common/platform/services/user-auto-unlock-key.service";
@@ -38,7 +38,7 @@ export class InitService {
private i18nService: I18nServiceAbstraction,
private eventUploadService: EventUploadServiceAbstraction,
private twoFactorService: TwoFactorServiceAbstraction,
private notificationsService: NotificationsService,
private notificationsService: ServerNotificationsService,
private platformUtilsService: PlatformUtilsServiceAbstraction,
private stateService: StateServiceAbstraction,
private keyService: KeyServiceAbstraction,

View File

@@ -59,7 +59,7 @@ export class ElectronPlatformUtilsService implements PlatformUtilsService {
return ipc.platform.isMacAppStore;
}
isViewOpen(): Promise<boolean> {
isPopupOpen(): Promise<boolean> {
return Promise.resolve(false);
}

View File

@@ -22,7 +22,7 @@ import { ConfigService } from "@bitwarden/common/platform/abstractions/config/co
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
import { NotificationsService } from "@bitwarden/common/platform/notifications";
import { ServerNotificationsService } from "@bitwarden/common/platform/server-notifications";
import { StateEventRunnerService } from "@bitwarden/common/platform/state";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { InternalFolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
@@ -76,7 +76,7 @@ export class AppComponent implements OnDestroy, OnInit {
private keyService: KeyService,
private collectionService: CollectionService,
private searchService: SearchService,
private notificationsService: NotificationsService,
private serverNotificationsService: ServerNotificationsService,
private stateService: StateService,
private eventUploadService: EventUploadService,
protected policyListService: PolicyListService,
@@ -88,14 +88,14 @@ export class AppComponent implements OnDestroy, OnInit {
private accountService: AccountService,
private processReloadService: ProcessReloadServiceAbstraction,
private deviceTrustToastService: DeviceTrustToastService,
private readonly destoryRef: DestroyRef,
private readonly destroy: DestroyRef,
private readonly documentLangSetter: DocumentLangSetter,
private readonly tokenService: TokenService,
) {
this.deviceTrustToastService.setupListeners$.pipe(takeUntilDestroyed()).subscribe();
const langSubscription = this.documentLangSetter.start();
this.destoryRef.onDestroy(() => langSubscription.unsubscribe());
this.destroy.onDestroy(() => langSubscription.unsubscribe());
}
ngOnInit() {
@@ -347,9 +347,9 @@ export class AppComponent implements OnDestroy, OnInit {
private idleStateChanged() {
if (this.isIdle) {
this.notificationsService.disconnectFromInactivity();
this.serverNotificationsService.disconnectFromInactivity();
} else {
this.notificationsService.reconnectFromActivity();
this.serverNotificationsService.reconnectFromActivity();
}
}
}

View File

@@ -84,7 +84,7 @@ import { IpcService } from "@bitwarden/common/platform/ipc";
import {
UnsupportedWebPushConnectionService,
WebPushConnectionService,
} from "@bitwarden/common/platform/notifications/internal";
} from "@bitwarden/common/platform/server-notifications/internal";
import { AppIdService as DefaultAppIdService } from "@bitwarden/common/platform/services/app-id.service";
import { MemoryStorageService } from "@bitwarden/common/platform/services/memory-storage.service";
import { MigrationBuilderService } from "@bitwarden/common/platform/services/migration-builder.service";

View File

@@ -12,7 +12,7 @@ import { DefaultVaultTimeoutService } from "@bitwarden/common/key-management/vau
import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/platform/abstractions/i18n.service";
import { SdkLoadService } from "@bitwarden/common/platform/abstractions/sdk/sdk-load.service";
import { IpcService } from "@bitwarden/common/platform/ipc";
import { NotificationsService } from "@bitwarden/common/platform/notifications";
import { ServerNotificationsService } from "@bitwarden/common/platform/server-notifications";
import { ContainerService } from "@bitwarden/common/platform/services/container.service";
import { MigrationRunner } from "@bitwarden/common/platform/services/migration-runner";
import { UserAutoUnlockKeyService } from "@bitwarden/common/platform/services/user-auto-unlock-key.service";
@@ -26,7 +26,7 @@ import { VersionService } from "../platform/version.service";
export class InitService {
constructor(
@Inject(WINDOW) private win: Window,
private notificationsService: NotificationsService,
private serverNotificationsService: ServerNotificationsService,
private vaultTimeoutService: DefaultVaultTimeoutService,
private i18nService: I18nServiceAbstraction,
private eventUploadService: EventUploadServiceAbstraction,
@@ -56,7 +56,7 @@ export class InitService {
await this.userAutoUnlockKeyService.setUserKeyInMemoryIfAutoUserKeySet(activeAccount.id);
}
this.notificationsService.startListening();
this.serverNotificationsService.startListening();
await this.vaultTimeoutService.init(true);
await this.i18nService.init();
(this.eventUploadService as EventUploadService).init(true);

View File

@@ -98,7 +98,7 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
return false;
}
isViewOpen(): Promise<boolean> {
isPopupOpen(): Promise<boolean> {
return Promise.resolve(false);
}

View File

@@ -5,7 +5,7 @@ import { SupportStatus } from "@bitwarden/common/platform/misc/support-status";
import {
WebPushConnector,
WorkerWebPushConnectionService,
} from "@bitwarden/common/platform/notifications/internal";
} from "@bitwarden/common/platform/server-notifications/internal";
import { UserId } from "@bitwarden/common/types/guid";
export class PermissionsWebPushConnectionService extends WorkerWebPushConnectionService {

View File

@@ -565,7 +565,7 @@ export class VaultComponent<C extends CipherViewLike> implements OnInit, OnDestr
this.refreshing = false;
// Explicitly mark for check to ensure the view is updated
// Some sources are not always emitted within the Angular zone (e.g. ciphers updated via WS notifications)
// Some sources are not always emitted within the Angular zone (e.g. ciphers updated via WS server notifications)
this.changeDetectorRef.markForCheck();
},
);