1
0
mirror of https://github.com/bitwarden/browser synced 2026-03-01 02:51:24 +00:00

feat(notification-processing): [PM-19877] System Notification Implementation - Initial changeset

This commit is contained in:
Patrick Pimentel
2025-07-16 15:01:24 -04:00
parent 70b65a20dd
commit ca43e923ce
34 changed files with 255 additions and 141 deletions

View File

@@ -22,7 +22,7 @@ export abstract class PlatformUtilsService {
abstract isVivaldi(): boolean;
abstract isSafari(): boolean;
abstract isMacAppStore(): boolean;
abstract isViewOpen(): Promise<boolean>;
abstract isPopupOpen(): Promise<boolean>;
abstract launchUri(uri: string, options?: any): void;
abstract getApplicationVersion(): Promise<string>;
abstract getApplicationVersionNumber(): Promise<string>;

View File

@@ -0,0 +1,3 @@
export abstract class ActionsService {
abstract openPopup(): Promise<void>;
}

View File

@@ -0,0 +1 @@
export { ActionsService } from "./actions-service";

View File

@@ -0,0 +1,7 @@
import { ActionsService } from "./actions-service";
export class UnsupportedActionsService implements ActionsService {
openPopup(): Promise<void> {
return Promise.resolve(undefined);
}
}

View File

@@ -1 +1 @@
export { NotificationsService } from "./notifications.service";
export { ServerNotificationsService } from "./server-notifications-service";

View File

@@ -32,7 +32,7 @@ import { EnvironmentService } from "../../abstractions/environment.service";
import { LogService } from "../../abstractions/log.service";
import { MessagingService } from "../../abstractions/messaging.service";
import { supportSwitch } from "../../misc/support-status";
import { NotificationsService as NotificationsServiceAbstraction } from "../notifications.service";
import { ServerNotificationsService as NotificationsServiceAbstraction } from "../server-notifications-service";
import { ReceiveMessage, SignalRConnectionService } from "./signalr-connection.service";
import { WebPushConnectionService } from "./webpush-connection.service";
@@ -188,7 +188,6 @@ export class DefaultNotificationsService implements NotificationsServiceAbstract
case NotificationType.SyncCiphers:
case NotificationType.SyncSettings:
await this.syncService.fullSync(false);
break;
case NotificationType.SyncOrganizations:
// An organization update may not have bumped the user's account revision date, so force a sync
@@ -214,11 +213,9 @@ export class DefaultNotificationsService implements NotificationsServiceAbstract
await this.syncService.syncDeleteSend(notification.payload as SyncSendNotification);
break;
case NotificationType.AuthRequest:
{
this.messagingService.send("openLoginApproval", {
notificationId: notification.payload.id,
});
}
this.messagingService.send("openLoginApproval", {
notificationId: notification.payload.id,
});
break;
case NotificationType.SyncOrganizationStatusChanged:
await this.syncService.fullSync(true);

View File

@@ -4,9 +4,9 @@ import { NotificationResponse } from "@bitwarden/common/models/response/notifica
import { UserId } from "@bitwarden/common/types/guid";
import { LogService } from "../../abstractions/log.service";
import { NotificationsService } from "../notifications.service";
import { ServerNotificationsService } from "../server-notifications-service";
export class NoopNotificationsService implements NotificationsService {
export class NoopNotificationsService implements ServerNotificationsService {
notifications$: Observable<readonly [NotificationResponse, UserId]> = new Subject();
constructor(private logService: LogService) {}

View File

@@ -9,7 +9,7 @@ import type { DefaultNotificationsService } from "./internal";
/**
* A service offering abilities to interact with push notifications from the server.
*/
export abstract class NotificationsService {
export abstract class ServerNotificationsService {
/**
* @deprecated This method should not be consumed, an observable to listen to server
* notifications will be available one day but it is not ready to be consumed generally.

View File

@@ -9,11 +9,11 @@ export type ButtonActionsKeys = (typeof ButtonActions)[keyof typeof ButtonAction
// This is currently tailored for chrome extension's api, if safari works
// differently where clicking a notification button produces a different
// identifier we need to reconcile that here.
export const ButtonLocation = {
export const ButtonLocation = Object.freeze({
FirstOptionalButton: 0, // this is the first optional button we can set
SecondOptionalButton: 1, // this is the second optional button we can set
NotificationButton: 2, // this is when you click the notification as a whole
};
});
export type ButtonLocationKeys = (typeof ButtonLocation)[keyof typeof ButtonLocation];