1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-06 03:33:30 +00:00

feat(browser-approval): [PM-23620] Auth Request Answering Service - Added in feature flag.

This commit is contained in:
Patrick Pimentel
2025-08-13 09:40:24 -04:00
parent 1cec126c5a
commit b64efa9db7
3 changed files with 17 additions and 5 deletions

View File

@@ -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);

View File

@@ -993,6 +993,7 @@ const safeProviders: SafeProvider[] = [
AuthServiceAbstraction,
WebPushConnectionService,
AuthRequestAnsweringServiceAbstraction,
ConfigService,
],
}),
safeProvider({

View File

@@ -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,
});