From 74844336040b60d1f438ecbac0d7c4006f8cc2db Mon Sep 17 00:00:00 2001 From: Patrick Pimentel Date: Thu, 7 Aug 2025 17:18:30 -0400 Subject: [PATCH] fix(browser-approval): [PM-23620] Auth Request Answering Service - Moved subscribing to main.background.ts. --- apps/browser/src/background/main.background.ts | 12 +++++++++++- .../auth-request-answering.service.abstraction.ts | 5 +---- .../auth-request-answering.service.ts | 13 +++---------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/browser/src/background/main.background.ts b/apps/browser/src/background/main.background.ts index 3a1e8e6119a..77494826095 100644 --- a/apps/browser/src/background/main.background.ts +++ b/apps/browser/src/background/main.background.ts @@ -2,7 +2,7 @@ // @ts-strict-ignore import "core-js/proposals/explicit-resource-management"; -import { filter, firstValueFrom, map, merge, Subject, timeout } from "rxjs"; +import { filter, firstValueFrom, map, merge, Subject, switchMap, timeout } from "rxjs"; import { CollectionService, DefaultCollectionService } from "@bitwarden/admin-console/common"; import { @@ -1148,6 +1148,16 @@ export default class MainBackground { this.systemNotificationService, ); + this.systemNotificationService.notificationClicked$ + .pipe( + filter((n) => n.id.startsWith("authRequest_")), + map((n) => ({ event: n, authRequestId: n.id.split("_")[1] })), + switchMap(({ event }) => + this.authRequestAnsweringService.handleAuthRequestNotificationClicked(event), + ), + ) + .subscribe(); + this.serverNotificationsService = new DefaultServerNotificationsService( this.logService, this.syncService, diff --git a/libs/common/src/auth/abstractions/auth-request-answering/auth-request-answering.service.abstraction.ts b/libs/common/src/auth/abstractions/auth-request-answering/auth-request-answering.service.abstraction.ts index ea166abd879..f992b8c738e 100644 --- a/libs/common/src/auth/abstractions/auth-request-answering/auth-request-answering.service.abstraction.ts +++ b/libs/common/src/auth/abstractions/auth-request-answering/auth-request-answering.service.abstraction.ts @@ -4,8 +4,5 @@ import { UserId } from "@bitwarden/user-core"; export abstract class AuthRequestAnsweringServiceAbstraction { abstract receivedPendingAuthRequest(userId: UserId, notificationId: string): Promise; - abstract handleAuthRequestNotificationClicked( - event: SystemNotificationEvent, - authRequestId: string, - ): Promise; + abstract handleAuthRequestNotificationClicked(event: SystemNotificationEvent): Promise; } diff --git a/libs/common/src/auth/services/auth-request-answering/auth-request-answering.service.ts b/libs/common/src/auth/services/auth-request-answering/auth-request-answering.service.ts index 0c1ef862cb1..7b0dfe39f36 100644 --- a/libs/common/src/auth/services/auth-request-answering/auth-request-answering.service.ts +++ b/libs/common/src/auth/services/auth-request-answering/auth-request-answering.service.ts @@ -1,4 +1,4 @@ -import { filter, firstValueFrom, map, switchMap } from "rxjs"; +import { firstValueFrom } from "rxjs"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service"; @@ -25,15 +25,8 @@ export class AuthRequestAnsweringService implements AuthRequestAnsweringServiceA private readonly masterPasswordService: MasterPasswordServiceAbstraction, private readonly platformUtilsService: PlatformUtilsService, private readonly systemNotificationsService: SystemNotificationsService, - ) { - this.systemNotificationsService.notificationClicked$ - .pipe( - filter((n) => n.id.startsWith("authRequest_")), - map((n) => ({ event: n, authRequestId: n.id.split("_")[1] })), - switchMap(({ event }) => this.handleAuthRequestNotificationClicked(event)), - ) - .subscribe(); - } + ) {} + async handleAuthRequestNotificationClicked(event: SystemNotificationEvent): Promise { if (event.buttonIdentifier === ButtonLocation.NotificationButton) { // await this.systemNotificationsService.clear({