From 86cfc6eb7f2091a384aa6a9aeb24a82f143d5627 Mon Sep 17 00:00:00 2001 From: Jimmy Vo Date: Fri, 11 Apr 2025 17:28:25 -0400 Subject: [PATCH] [PM-19814] Clean up --- .../browser/src/background/main.background.ts | 12 ++- .../phishing-detection-browser.service.ts | 84 ------------------- 2 files changed, 11 insertions(+), 85 deletions(-) diff --git a/apps/browser/src/background/main.background.ts b/apps/browser/src/background/main.background.ts index 2e0db947a59..f4f5eab9ef1 100644 --- a/apps/browser/src/background/main.background.ts +++ b/apps/browser/src/background/main.background.ts @@ -72,6 +72,7 @@ import { ClientType } from "@bitwarden/common/enums"; import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; import { ProcessReloadServiceAbstraction } from "@bitwarden/common/key-management/abstractions/process-reload.service"; import { EncryptService } from "@bitwarden/common/key-management/crypto/abstractions/encrypt.service"; +import { BulkEncryptServiceImplementation } from "@bitwarden/common/key-management/crypto/services/bulk-encrypt.service.implementation"; import { EncryptServiceImplementation } from "@bitwarden/common/key-management/crypto/services/encrypt.service.implementation"; import { FallbackBulkEncryptService } from "@bitwarden/common/key-management/crypto/services/fallback-bulk-encrypt.service"; import { MultithreadEncryptServiceImplementation } from "@bitwarden/common/key-management/crypto/services/multithread-encrypt.service.implementation"; @@ -1374,10 +1375,19 @@ export default class MainBackground { this.commandsBackground.init(); this.contextMenusBackground?.init(); this.idleBackground.init(); - await this.webRequestBackground?.startListening(); + this.webRequestBackground?.startListening(); this.syncServiceListener?.listener$().subscribe(); await this.autoSubmitLoginBackground.init(); + if ( + BrowserApi.isManifestVersion(2) && + (await this.configService.getFeatureFlag(FeatureFlag.PM4154_BulkEncryptionService)) + ) { + await this.bulkEncryptService.setFeatureFlagEncryptService( + new BulkEncryptServiceImplementation(this.cryptoFunctionService, this.logService), + ); + } + // If the user is logged out, switch to the next account const active = await firstValueFrom(this.accountService.activeAccount$); if (active != null) { diff --git a/apps/browser/src/phishing-detection/content/phishing-detection-browser.service.ts b/apps/browser/src/phishing-detection/content/phishing-detection-browser.service.ts index 6aba81d2172..ec3a2265388 100644 --- a/apps/browser/src/phishing-detection/content/phishing-detection-browser.service.ts +++ b/apps/browser/src/phishing-detection/content/phishing-detection-browser.service.ts @@ -1,88 +1,4 @@ export class PhishingDetectionBrowserService { - static notifyUser(url: string) { - const phishingDivId = "phishing-notification-dialog"; - const message = `${url} is a known phishing site `; - - // Remove existing notification to prevent duplicates - const existingDialog = document.getElementById(phishingDivId); - if (existingDialog) { - existingDialog.remove(); - } - - // Create the backdrop (dark overlay) - const backdrop = document.createElement("div"); - backdrop.id = "phishing-dialog-backdrop"; - backdrop.style.position = "fixed"; - backdrop.style.top = "0"; - backdrop.style.left = "0"; - backdrop.style.width = "100vw"; - backdrop.style.height = "100vh"; - backdrop.style.backgroundColor = "rgba(0, 0, 0, 0.6)"; // Semi-transparent dark background - backdrop.style.zIndex = "9999"; - backdrop.style.display = "flex"; - backdrop.style.justifyContent = "center"; - backdrop.style.alignItems = "center"; - - // Create the dialog box - const dialog = document.createElement("div"); - dialog.id = phishingDivId; - dialog.style.backgroundColor = "#b00020"; // Danger red - dialog.style.color = "#ffffff"; - dialog.style.borderRadius = "12px"; - dialog.style.padding = "20px 30px"; - dialog.style.maxWidth = "450px"; - dialog.style.textAlign = "center"; - dialog.style.boxShadow = "0 6px 12px rgba(0, 0, 0, 0.3)"; - dialog.style.display = "flex"; - dialog.style.flexDirection = "column"; - dialog.style.alignItems = "center"; - - // Warning icon - const icon = document.createElement("i"); - icon.classList.add("bwi", "bwi-fw", "bwi-warning"); - icon.setAttribute("aria-hidden", "true"); - icon.style.fontSize = "32px"; - icon.style.marginBottom = "10px"; - - // Alert message - const messageElement = document.createElement("span"); - messageElement.style.fontSize = "18px"; - messageElement.style.fontWeight = "bold"; - messageElement.style.marginBottom = "15px"; - messageElement.textContent = message; - - // "Exit the page" button - const exitButton = document.createElement("button"); - exitButton.type = "button"; - exitButton.style.backgroundColor = "#ffffff"; - exitButton.style.color = "#b00020"; - exitButton.style.fontSize = "16px"; - exitButton.style.fontWeight = "bold"; - exitButton.style.padding = "10px 20px"; - exitButton.style.border = "none"; - exitButton.style.borderRadius = "8px"; - exitButton.style.cursor = "pointer"; - exitButton.style.marginTop = "10px"; - exitButton.textContent = "Exit Page"; - exitButton.addEventListener("click", () => { - window.history.back(); - }); - - // Append elements - dialog.appendChild(icon); - dialog.appendChild(messageElement); - dialog.appendChild(exitButton); - backdrop.appendChild(dialog); - document.body.appendChild(backdrop); - - // Auto-remove after 10 seconds - setTimeout(() => { - if (document.body.contains(backdrop)) { - document.body.removeChild(backdrop); - } - }, 10000); - } - static getActiveUrl() { return window?.location?.href; }