1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-05 19:23:19 +00:00

fix(browser-approval): [PM-23620] Auth Request Answering Service - Moved subscribing to main.background.ts.

This commit is contained in:
Patrick Pimentel
2025-08-07 17:18:30 -04:00
parent dd0e053d7d
commit 7484433604
3 changed files with 15 additions and 15 deletions

View File

@@ -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,

View File

@@ -4,8 +4,5 @@ import { UserId } from "@bitwarden/user-core";
export abstract class AuthRequestAnsweringServiceAbstraction {
abstract receivedPendingAuthRequest(userId: UserId, notificationId: string): Promise<void>;
abstract handleAuthRequestNotificationClicked(
event: SystemNotificationEvent,
authRequestId: string,
): Promise<void>;
abstract handleAuthRequestNotificationClicked(event: SystemNotificationEvent): Promise<void>;
}

View File

@@ -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<void> {
if (event.buttonIdentifier === ButtonLocation.NotificationButton) {
// await this.systemNotificationsService.clear({