1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-09 13:10:17 +00:00

[PM-19814] Clean up

This commit is contained in:
Jimmy Vo
2025-04-11 17:28:25 -04:00
parent a156a74416
commit 86cfc6eb7f
2 changed files with 11 additions and 85 deletions

View File

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

View File

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