From b64efa9db7bf21a1bd82a29d74e58f573b5b026d Mon Sep 17 00:00:00 2001 From: Patrick Pimentel Date: Wed, 13 Aug 2025 09:40:24 -0400 Subject: [PATCH] feat(browser-approval): [PM-23620] Auth Request Answering Service - Added in feature flag. --- apps/browser/src/background/main.background.ts | 3 ++- .../src/services/jslib-services.module.ts | 1 + .../default-server-notifications.service.ts | 18 ++++++++++++++---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/apps/browser/src/background/main.background.ts b/apps/browser/src/background/main.background.ts index 5a90e747ffa..357eb47cc37 100644 --- a/apps/browser/src/background/main.background.ts +++ b/apps/browser/src/background/main.background.ts @@ -170,6 +170,7 @@ 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 { SystemNotificationPrefixes } from "@bitwarden/common/platform/system-notifications/system-notifications.service"; 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"; @@ -308,7 +309,6 @@ import CommandsBackground from "./commands.background"; import IdleBackground from "./idle.background"; import { NativeMessagingBackground } from "./nativeMessaging.background"; import RuntimeBackground from "./runtime.background"; -import { SystemNotificationPrefixes } from "@bitwarden/common/platform/system-notifications/system-notifications.service"; export default class MainBackground { messagingService: MessageSender; @@ -1161,6 +1161,7 @@ export default class MainBackground { this.authService, this.webPushConnectionService, this.authRequestAnsweringService, + this.configService, ); this.fido2UserInterfaceService = new BrowserFido2UserInterfaceService(this.authService); diff --git a/libs/angular/src/services/jslib-services.module.ts b/libs/angular/src/services/jslib-services.module.ts index 1e2f9d83ba4..6111e64d30e 100644 --- a/libs/angular/src/services/jslib-services.module.ts +++ b/libs/angular/src/services/jslib-services.module.ts @@ -993,6 +993,7 @@ const safeProviders: SafeProvider[] = [ AuthServiceAbstraction, WebPushConnectionService, AuthRequestAnsweringServiceAbstraction, + ConfigService, ], }), safeProvider({ diff --git a/libs/common/src/platform/server-notifications/internal/default-server-notifications.service.ts b/libs/common/src/platform/server-notifications/internal/default-server-notifications.service.ts index bd5c4f0f345..69442a91630 100644 --- a/libs/common/src/platform/server-notifications/internal/default-server-notifications.service.ts +++ b/libs/common/src/platform/server-notifications/internal/default-server-notifications.service.ts @@ -4,6 +4,7 @@ import { distinctUntilChanged, EMPTY, filter, + firstValueFrom, map, mergeMap, Observable, @@ -15,6 +16,8 @@ import { // eslint-disable-next-line no-restricted-imports import { LogoutReason } from "@bitwarden/auth/common"; import { AuthRequestAnsweringServiceAbstraction } from "@bitwarden/common/auth/abstractions/auth-request-answering/auth-request-answering.service.abstraction"; +import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; +import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { AccountService } from "../../../auth/abstractions/account.service"; import { AuthService } from "../../../auth/abstractions/auth.service"; @@ -57,6 +60,7 @@ export class DefaultServerNotificationsService implements ServerNotificationsSer private readonly authService: AuthService, private readonly webPushConnectionService: WebPushConnectionService, private readonly authRequestAnsweringService: AuthRequestAnsweringServiceAbstraction, + private readonly configService: ConfigService, ) { this.notifications$ = this.accountService.activeAccount$.pipe( map((account) => account?.id), @@ -215,10 +219,16 @@ export class DefaultServerNotificationsService implements ServerNotificationsSer await this.syncService.syncDeleteSend(notification.payload as SyncSendNotification); break; case NotificationType.AuthRequest: - await this.authRequestAnsweringService.receivedPendingAuthRequest( - notification.payload.userId, - notification.payload.id, - ); + if ( + await firstValueFrom( + this.configService.getFeatureFlag$(FeatureFlag.PM14938_BrowserExtensionLoginApproval), + ) + ) { + await this.authRequestAnsweringService.receivedPendingAuthRequest( + notification.payload.userId, + notification.payload.id, + ); + } this.messagingService.send("openLoginApproval", { notificationId: notification.payload.id, });