diff --git a/apps/browser/src/autofill/background/overlay-notifications.background.ts b/apps/browser/src/autofill/background/overlay-notifications.background.ts index 594f5aec4c9..e3ca6258590 100644 --- a/apps/browser/src/autofill/background/overlay-notifications.background.ts +++ b/apps/browser/src/autofill/background/overlay-notifications.background.ts @@ -1,8 +1,9 @@ // FIXME: Update this file to be type safe and remove this and next line // @ts-strict-ignore -import { Subject, switchMap, timer } from "rxjs"; +import { firstValueFrom, Subject, switchMap, timer } from "rxjs"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; +import { getOptionalUserId } from "@bitwarden/common/auth/services/account.service"; import { CLEAR_NOTIFICATION_LOGIN_DATA_DURATION } from "@bitwarden/common/autofill/constants"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { UserId } from "@bitwarden/common/types/guid"; @@ -445,6 +446,30 @@ export class OverlayNotificationsBackground implements OverlayNotificationsBackg this.clearCompletedWebRequest(requestId, tab); return; } + + const activeUserId = await firstValueFrom( + this.accountService.activeAccount$.pipe(getOptionalUserId), + ); + const { cipher, securityTask } = await this.getSecurityTaskAndCipherForLoginData( + modifyLoginData, + activeUserId, + ); + const shouldTriggerAtRiskPasswordNotification: boolean = typeof securityTask !== "undefined"; + + if (shouldTriggerAtRiskPasswordNotification) { + await this.notificationBackground.openAtRisksPasswordNotification( + { + command: "bgOpenAtRisksPasswordNotification", + data: { + activeUserId, + cipher, + securityTask, + }, + }, + { tab }, + ); + this.clearCompletedWebRequest(requestId, tab); + } }; /** diff --git a/apps/browser/src/autofill/notification/bar.ts b/apps/browser/src/autofill/notification/bar.ts index 3ea071cf61d..0c9d22a0e43 100644 --- a/apps/browser/src/autofill/notification/bar.ts +++ b/apps/browser/src/autofill/notification/bar.ts @@ -7,6 +7,7 @@ import type { FolderView } from "@bitwarden/common/vault/models/view/folder.view import { AdjustNotificationBarMessageData } from "../background/abstractions/notification.background"; import { NotificationCipherData } from "../content/components/cipher/types"; import { CollectionView, OrgView } from "../content/components/common-types"; +import { AtRiskNotification } from "../content/components/notification/at-risk-password/container"; import { NotificationConfirmationContainer } from "../content/components/notification/confirmation/container"; import { NotificationContainer } from "../content/components/notification/container"; import { selectedFolder as selectedFolderSignal } from "../content/components/signals/selected-folder"; @@ -176,6 +177,22 @@ async function initNotificationBar(message: NotificationBarWindowMessage) { ); } + // Handle AtRiskPasswordNotification render + if (notificationBarIframeInitData.type === NotificationTypes.AtRiskPassword) { + return render( + AtRiskNotification({ + ...notificationBarIframeInitData, + type: notificationBarIframeInitData.type as NotificationType, + theme: resolvedTheme, + i18n, + params: initData.params, + handleCloseNotification, + }), + document.body, + ); + } + + // Default scenario: add or update password const orgId = selectedVaultSignal.get(); await Promise.all([