diff --git a/apps/browser/src/vault/fido2/background/abstractions/fido2.background.ts b/apps/browser/src/autofill/fido2/background/abstractions/fido2.background.ts similarity index 100% rename from apps/browser/src/vault/fido2/background/abstractions/fido2.background.ts rename to apps/browser/src/autofill/fido2/background/abstractions/fido2.background.ts diff --git a/apps/browser/src/vault/fido2/background/fido2.background.spec.ts b/apps/browser/src/autofill/fido2/background/fido2.background.spec.ts similarity index 99% rename from apps/browser/src/vault/fido2/background/fido2.background.spec.ts rename to apps/browser/src/autofill/fido2/background/fido2.background.spec.ts index 2cf6d3011a..f0c5fc5695 100644 --- a/apps/browser/src/vault/fido2/background/fido2.background.spec.ts +++ b/apps/browser/src/autofill/fido2/background/fido2.background.spec.ts @@ -18,7 +18,7 @@ import { } from "../../../autofill/spec/testing-utils"; import { BrowserApi } from "../../../platform/browser/browser-api"; import { BrowserScriptInjectorService } from "../../../platform/services/browser-script-injector.service"; -import { AbortManager } from "../../background/abort-manager"; +import { AbortManager } from "../../../vault/background/abort-manager"; import { Fido2ContentScript, Fido2ContentScriptId } from "../enums/fido2-content-script.enum"; import { Fido2PortName } from "../enums/fido2-port-name.enum"; diff --git a/apps/browser/src/vault/fido2/background/fido2.background.ts b/apps/browser/src/autofill/fido2/background/fido2.background.ts similarity index 99% rename from apps/browser/src/vault/fido2/background/fido2.background.ts rename to apps/browser/src/autofill/fido2/background/fido2.background.ts index 0666f804f2..a58d32da16 100644 --- a/apps/browser/src/vault/fido2/background/fido2.background.ts +++ b/apps/browser/src/autofill/fido2/background/fido2.background.ts @@ -13,7 +13,7 @@ import { VaultSettingsService } from "@bitwarden/common/vault/abstractions/vault import { BrowserApi } from "../../../platform/browser/browser-api"; import { ScriptInjectorService } from "../../../platform/services/abstractions/script-injector.service"; -import { AbortManager } from "../../background/abort-manager"; +import { AbortManager } from "../../../vault/background/abort-manager"; import { Fido2ContentScript, Fido2ContentScriptId } from "../enums/fido2-content-script.enum"; import { Fido2PortName } from "../enums/fido2-port-name.enum"; diff --git a/apps/browser/src/vault/fido2/content/content-script.spec.ts b/apps/browser/src/autofill/fido2/content/fido2-content-script.spec.ts similarity index 95% rename from apps/browser/src/vault/fido2/content/content-script.spec.ts rename to apps/browser/src/autofill/fido2/content/fido2-content-script.spec.ts index c9f970a30c..94bef354a7 100644 --- a/apps/browser/src/vault/fido2/content/content-script.spec.ts +++ b/apps/browser/src/autofill/fido2/content/fido2-content-script.spec.ts @@ -60,7 +60,7 @@ describe("Fido2 Content Script", () => { chrome.runtime.connect = jest.fn(() => portSpy); it("destroys the messenger when the port is disconnected", () => { - require("./content-script"); + require("./fido2-content-script"); triggerPortOnDisconnectEvent(portSpy); @@ -75,7 +75,7 @@ describe("Fido2 Content Script", () => { const mockResult = { credentialId: "mock" } as CreateCredentialResult; jest.spyOn(chrome.runtime, "sendMessage").mockResolvedValue(mockResult); - require("./content-script"); + require("./fido2-content-script"); const response = await messenger.handler!(message, new AbortController()); @@ -99,7 +99,7 @@ describe("Fido2 Content Script", () => { data: mock(), }); - require("./content-script"); + require("./fido2-content-script"); await messenger.handler!(message, new AbortController()); @@ -121,7 +121,7 @@ describe("Fido2 Content Script", () => { const abortController = new AbortController(); const abortSpy = jest.spyOn(abortController.signal, "removeEventListener"); - require("./content-script"); + require("./fido2-content-script"); await messenger.handler!(message, abortController); @@ -141,7 +141,7 @@ describe("Fido2 Content Script", () => { abortController.abort(); }); - require("./content-script"); + require("./fido2-content-script"); await messenger.handler!(message, abortController); @@ -161,7 +161,7 @@ describe("Fido2 Content Script", () => { const abortController = new AbortController(); jest.spyOn(chrome.runtime, "sendMessage").mockResolvedValue({ error: errorMessage }); - require("./content-script"); + require("./fido2-content-script"); const result = messenger.handler!(message, abortController); await expect(result).rejects.toEqual(errorMessage); @@ -175,7 +175,7 @@ describe("Fido2 Content Script", () => { contentType: "application/json", })); - require("./content-script"); + require("./fido2-content-script"); expect(messengerForDOMCommunicationSpy).not.toHaveBeenCalled(); }); @@ -193,7 +193,7 @@ describe("Fido2 Content Script", () => { }, })); - require("./content-script"); + require("./fido2-content-script"); expect(messengerForDOMCommunicationSpy).not.toHaveBeenCalled(); }); diff --git a/apps/browser/src/vault/fido2/content/content-script.ts b/apps/browser/src/autofill/fido2/content/fido2-content-script.ts similarity index 100% rename from apps/browser/src/vault/fido2/content/content-script.ts rename to apps/browser/src/autofill/fido2/content/fido2-content-script.ts diff --git a/apps/browser/src/vault/fido2/content/page-script-append.mv2.spec.ts b/apps/browser/src/autofill/fido2/content/fido2-page-script-append.mv2.spec.ts similarity index 93% rename from apps/browser/src/vault/fido2/content/page-script-append.mv2.spec.ts rename to apps/browser/src/autofill/fido2/content/fido2-page-script-append.mv2.spec.ts index d40a725a1f..d53d9e685e 100644 --- a/apps/browser/src/vault/fido2/content/page-script-append.mv2.spec.ts +++ b/apps/browser/src/autofill/fido2/content/fido2-page-script-append.mv2.spec.ts @@ -13,7 +13,7 @@ describe("FIDO2 page-script for manifest v2", () => { it("skips appending the `page-script.js` file if the document contentType is not `text/html`", () => { Object.defineProperty(window.document, "contentType", { value: "text/plain", writable: true }); - require("./page-script-append.mv2"); + require("./fido2-page-script-append.mv2"); expect(window.document.createElement).not.toHaveBeenCalled(); }); @@ -24,7 +24,7 @@ describe("FIDO2 page-script for manifest v2", () => { return node; }); - require("./page-script-append.mv2"); + require("./fido2-page-script-append.mv2"); expect(window.document.createElement).toHaveBeenCalledWith("script"); expect(chrome.runtime.getURL).toHaveBeenCalledWith(Fido2ContentScript.PageScript); @@ -42,7 +42,7 @@ describe("FIDO2 page-script for manifest v2", () => { return node; }); - require("./page-script-append.mv2"); + require("./fido2-page-script-append.mv2"); expect(window.document.createElement).toHaveBeenCalledWith("script"); expect(chrome.runtime.getURL).toHaveBeenCalledWith(Fido2ContentScript.PageScript); @@ -59,7 +59,7 @@ describe("FIDO2 page-script for manifest v2", () => { return createdScriptElement; }); - require("./page-script-append.mv2"); + require("./fido2-page-script-append.mv2"); jest.spyOn(createdScriptElement, "remove"); createdScriptElement.dispatchEvent(new Event("load")); diff --git a/apps/browser/src/vault/fido2/content/page-script-append.mv2.ts b/apps/browser/src/autofill/fido2/content/fido2-page-script-append.mv2.ts similarity index 100% rename from apps/browser/src/vault/fido2/content/page-script-append.mv2.ts rename to apps/browser/src/autofill/fido2/content/fido2-page-script-append.mv2.ts diff --git a/apps/browser/src/vault/fido2/content/page-script.ts b/apps/browser/src/autofill/fido2/content/fido2-page-script.ts similarity index 99% rename from apps/browser/src/vault/fido2/content/page-script.ts rename to apps/browser/src/autofill/fido2/content/fido2-page-script.ts index 5898dbd04d..cf14471359 100644 --- a/apps/browser/src/vault/fido2/content/page-script.ts +++ b/apps/browser/src/autofill/fido2/content/fido2-page-script.ts @@ -1,6 +1,6 @@ import { FallbackRequestedError } from "@bitwarden/common/platform/abstractions/fido2/fido2-client.service.abstraction"; -import { WebauthnUtils } from "../webauthn-utils"; +import { WebauthnUtils } from "../../../vault/fido2/webauthn-utils"; import { MessageType } from "./messaging/message"; import { Messenger } from "./messaging/messenger"; diff --git a/apps/browser/src/vault/fido2/content/page-script.webauthn-supported.spec.ts b/apps/browser/src/autofill/fido2/content/fido2-page-script.webauthn-supported.spec.ts similarity index 96% rename from apps/browser/src/vault/fido2/content/page-script.webauthn-supported.spec.ts rename to apps/browser/src/autofill/fido2/content/fido2-page-script.webauthn-supported.spec.ts index 3044d51fa7..46ef4d60d6 100644 --- a/apps/browser/src/vault/fido2/content/page-script.webauthn-supported.spec.ts +++ b/apps/browser/src/autofill/fido2/content/fido2-page-script.webauthn-supported.spec.ts @@ -5,7 +5,7 @@ import { createCredentialRequestOptionsMock, setupMockedWebAuthnSupport, } from "../../../autofill/spec/fido2-testing-utils"; -import { WebauthnUtils } from "../webauthn-utils"; +import { WebauthnUtils } from "../../../vault/fido2/webauthn-utils"; import { MessageType } from "./messaging/message"; import { Messenger } from "./messaging/messenger"; @@ -40,7 +40,7 @@ jest.mock("./messaging/messenger", () => { }, }; }); -jest.mock("../webauthn-utils"); +jest.mock("../../../vault/fido2/webauthn-utils"); describe("Fido2 page script with native WebAuthn support", () => { (jest.spyOn(globalThis, "document", "get") as jest.Mock).mockImplementation( @@ -54,7 +54,7 @@ describe("Fido2 page script with native WebAuthn support", () => { setupMockedWebAuthnSupport(); beforeAll(() => { - require("./page-script"); + require("./fido2-page-script"); }); afterEach(() => { @@ -154,7 +154,7 @@ describe("Fido2 page script with native WebAuthn support", () => { contentType: "json/application", })); - require("./content-script"); + require("./fido2-content-script"); expect(Messenger.forDOMCommunication).not.toHaveBeenCalled(); }); @@ -172,7 +172,7 @@ describe("Fido2 page script with native WebAuthn support", () => { }, })); - require("./content-script"); + require("./fido2-content-script"); expect(Messenger.forDOMCommunication).not.toHaveBeenCalled(); }); diff --git a/apps/browser/src/vault/fido2/content/page-script.webauthn-unsupported.spec.ts b/apps/browser/src/autofill/fido2/content/fido2-page-script.webauthn-unsupported.spec.ts similarity index 96% rename from apps/browser/src/vault/fido2/content/page-script.webauthn-unsupported.spec.ts rename to apps/browser/src/autofill/fido2/content/fido2-page-script.webauthn-unsupported.spec.ts index 4b1f839a1d..a1e7006b04 100644 --- a/apps/browser/src/vault/fido2/content/page-script.webauthn-unsupported.spec.ts +++ b/apps/browser/src/autofill/fido2/content/fido2-page-script.webauthn-unsupported.spec.ts @@ -4,7 +4,7 @@ import { createCredentialCreationOptionsMock, createCredentialRequestOptionsMock, } from "../../../autofill/spec/fido2-testing-utils"; -import { WebauthnUtils } from "../webauthn-utils"; +import { WebauthnUtils } from "../../../vault/fido2/webauthn-utils"; import { MessageType } from "./messaging/message"; import { Messenger } from "./messaging/messenger"; @@ -39,7 +39,7 @@ jest.mock("./messaging/messenger", () => { }, }; }); -jest.mock("../webauthn-utils"); +jest.mock("../../../vault/fido2/webauthn-utils"); describe("Fido2 page script without native WebAuthn support", () => { (jest.spyOn(globalThis, "document", "get") as jest.Mock).mockImplementation( @@ -50,7 +50,7 @@ describe("Fido2 page script without native WebAuthn support", () => { const mockCreateCredentialsResult = createCreateCredentialResultMock(); const mockCredentialRequestOptions = createCredentialRequestOptionsMock(); const mockCredentialAssertResult = createAssertCredentialResultMock(); - require("./page-script"); + require("./fido2-page-script"); afterEach(() => { jest.resetModules(); diff --git a/apps/browser/src/vault/fido2/content/messaging/message.ts b/apps/browser/src/autofill/fido2/content/messaging/message.ts similarity index 100% rename from apps/browser/src/vault/fido2/content/messaging/message.ts rename to apps/browser/src/autofill/fido2/content/messaging/message.ts diff --git a/apps/browser/src/vault/fido2/content/messaging/messenger.spec.ts b/apps/browser/src/autofill/fido2/content/messaging/messenger.spec.ts similarity index 100% rename from apps/browser/src/vault/fido2/content/messaging/messenger.spec.ts rename to apps/browser/src/autofill/fido2/content/messaging/messenger.spec.ts diff --git a/apps/browser/src/vault/fido2/content/messaging/messenger.ts b/apps/browser/src/autofill/fido2/content/messaging/messenger.ts similarity index 100% rename from apps/browser/src/vault/fido2/content/messaging/messenger.ts rename to apps/browser/src/autofill/fido2/content/messaging/messenger.ts diff --git a/apps/browser/src/vault/fido2/enums/fido2-content-script.enum.ts b/apps/browser/src/autofill/fido2/enums/fido2-content-script.enum.ts similarity index 55% rename from apps/browser/src/vault/fido2/enums/fido2-content-script.enum.ts rename to apps/browser/src/autofill/fido2/enums/fido2-content-script.enum.ts index 287de6804b..14e629b412 100644 --- a/apps/browser/src/vault/fido2/enums/fido2-content-script.enum.ts +++ b/apps/browser/src/autofill/fido2/enums/fido2-content-script.enum.ts @@ -1,7 +1,7 @@ export const Fido2ContentScript = { - PageScript: "content/fido2/page-script.js", - PageScriptAppend: "content/fido2/page-script-append-mv2.js", - ContentScript: "content/fido2/content-script.js", + PageScript: "content/fido2-page-script.js", + PageScriptAppend: "content/fido2-page-script-append-mv2.js", + ContentScript: "content/fido2-content-script.js", } as const; export const Fido2ContentScriptId = { diff --git a/apps/browser/src/vault/fido2/enums/fido2-port-name.enum.ts b/apps/browser/src/autofill/fido2/enums/fido2-port-name.enum.ts similarity index 100% rename from apps/browser/src/vault/fido2/enums/fido2-port-name.enum.ts rename to apps/browser/src/autofill/fido2/enums/fido2-port-name.enum.ts diff --git a/apps/browser/src/background/main.background.ts b/apps/browser/src/background/main.background.ts index 63f2f38113..22158d9115 100644 --- a/apps/browser/src/background/main.background.ts +++ b/apps/browser/src/background/main.background.ts @@ -203,6 +203,8 @@ import WebRequestBackground from "../autofill/background/web-request.background" import { CipherContextMenuHandler } from "../autofill/browser/cipher-context-menu-handler"; import { ContextMenuClickedHandler } from "../autofill/browser/context-menu-clicked-handler"; import { MainContextMenuHandler } from "../autofill/browser/main-context-menu-handler"; +import { Fido2Background as Fido2BackgroundAbstraction } from "../autofill/fido2/background/abstractions/fido2.background"; +import { Fido2Background } from "../autofill/fido2/background/fido2.background"; import { AutofillService as AutofillServiceAbstraction } from "../autofill/services/abstractions/autofill.service"; import AutofillService from "../autofill/services/autofill.service"; import { SafariApp } from "../browser/safariApp"; @@ -237,8 +239,6 @@ import { SyncServiceListener } from "../platform/sync/sync-service.listener"; import { fromChromeRuntimeMessaging } from "../platform/utils/from-chrome-runtime-messaging"; import VaultTimeoutService from "../services/vault-timeout/vault-timeout.service"; import FilelessImporterBackground from "../tools/background/fileless-importer.background"; -import { Fido2Background as Fido2BackgroundAbstraction } from "../vault/fido2/background/abstractions/fido2.background"; -import { Fido2Background } from "../vault/fido2/background/fido2.background"; import { BrowserFido2UserInterfaceService } from "../vault/fido2/browser-fido2-user-interface.service"; import { VaultFilterService } from "../vault/services/vault-filter.service"; diff --git a/apps/browser/src/background/runtime.background.ts b/apps/browser/src/background/runtime.background.ts index 7ddd5302ac..a1a5de54d2 100644 --- a/apps/browser/src/background/runtime.background.ts +++ b/apps/browser/src/background/runtime.background.ts @@ -20,11 +20,11 @@ import { openTwoFactorAuthPopout, } from "../auth/popup/utils/auth-popout-window"; import { LockedVaultPendingNotificationsData } from "../autofill/background/abstractions/notification.background"; +import { Fido2Background } from "../autofill/fido2/background/abstractions/fido2.background"; import { AutofillService } from "../autofill/services/abstractions/autofill.service"; import { BrowserApi } from "../platform/browser/browser-api"; import { BrowserEnvironmentService } from "../platform/services/browser-environment.service"; import { BrowserPlatformUtilsService } from "../platform/services/platform-utils/browser-platform-utils.service"; -import { Fido2Background } from "../vault/fido2/background/abstractions/fido2.background"; import MainBackground from "./main.background"; diff --git a/apps/browser/src/manifest.json b/apps/browser/src/manifest.json index 740b58ddf2..a4768b1ba6 100644 --- a/apps/browser/src/manifest.json +++ b/apps/browser/src/manifest.json @@ -102,7 +102,7 @@ } }, "web_accessible_resources": [ - "content/fido2/page-script.js", + "content/fido2-page-script.js", "content/lp-suppress-import-download.js", "notification/bar.html", "images/icon38.png", diff --git a/apps/browser/src/manifest.v3.json b/apps/browser/src/manifest.v3.json index 61c5d2ce3c..4a806a4c88 100644 --- a/apps/browser/src/manifest.v3.json +++ b/apps/browser/src/manifest.v3.json @@ -108,7 +108,7 @@ "web_accessible_resources": [ { "resources": [ - "content/fido2/page-script.js", + "content/fido2-page-script.js", "notification/bar.html", "images/icon38.png", "images/icon38_locked.png", diff --git a/apps/browser/src/vault/fido2/webauthn-utils.ts b/apps/browser/src/vault/fido2/webauthn-utils.ts index 618e692aad..df8e5a8fb2 100644 --- a/apps/browser/src/vault/fido2/webauthn-utils.ts +++ b/apps/browser/src/vault/fido2/webauthn-utils.ts @@ -7,7 +7,7 @@ import { Fido2Utils } from "@bitwarden/common/platform/services/fido2/fido2-util import { InsecureAssertCredentialParams, InsecureCreateCredentialParams, -} from "./content/messaging/message"; +} from "../../autofill/fido2/content/messaging/message"; export class WebauthnUtils { static mapCredentialCreationOptions( diff --git a/apps/browser/webpack.config.js b/apps/browser/webpack.config.js index a0b86f06d5..eb1244bc26 100644 --- a/apps/browser/webpack.config.js +++ b/apps/browser/webpack.config.js @@ -165,8 +165,8 @@ const mainConfig = { "content/notificationBar": "./src/autofill/content/notification-bar.ts", "content/contextMenuHandler": "./src/autofill/content/context-menu-handler.ts", "content/content-message-handler": "./src/autofill/content/content-message-handler.ts", - "content/fido2/content-script": "./src/vault/fido2/content/content-script.ts", - "content/fido2/page-script": "./src/vault/fido2/content/page-script.ts", + "content/fido2-content-script": "./src/autofill/fido2/content/fido2-content-script.ts", + "content/fido2-page-script": "./src/autofill/fido2/content/fido2-page-script.ts", "notification/bar": "./src/autofill/notification/bar.ts", "overlay/button": "./src/autofill/overlay/pages/button/bootstrap-autofill-overlay-button.ts", "overlay/list": "./src/autofill/overlay/pages/list/bootstrap-autofill-overlay-list.ts", @@ -274,8 +274,8 @@ if (manifestVersion == 2) { mainConfig.entry.background = "./src/platform/background.ts"; mainConfig.entry["content/lp-suppress-import-download-script-append-mv2"] = "./src/tools/content/lp-suppress-import-download-script-append.mv2.ts"; - mainConfig.entry["content/fido2/page-script-append-mv2"] = - "./src/vault/fido2/content/page-script-append.mv2.ts"; + mainConfig.entry["content/fido2-page-script-append-mv2"] = + "./src/autofill/fido2/content/fido2-page-script-append.mv2.ts"; configs.push(mainConfig); } else {