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 b3ee4b098c..a96c6a68e0 100644 --- a/apps/browser/src/background/main.background.ts +++ b/apps/browser/src/background/main.background.ts @@ -202,6 +202,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"; @@ -233,8 +235,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 702aa17073..4bb7e82fba 100644 --- a/apps/browser/src/manifest.json +++ b/apps/browser/src/manifest.json @@ -101,7 +101,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 96d95cb164..3f3e2747cc 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/popup/app-routing.module.ts b/apps/browser/src/popup/app-routing.module.ts index 934bf0759a..97008ab96d 100644 --- a/apps/browser/src/popup/app-routing.module.ts +++ b/apps/browser/src/popup/app-routing.module.ts @@ -40,6 +40,7 @@ import { AboutPageV2Component } from "../tools/popup/settings/about-page/about-p import { AboutPageComponent } from "../tools/popup/settings/about-page/about-page.component"; import { MoreFromBitwardenPageV2Component } from "../tools/popup/settings/about-page/more-from-bitwarden-page-v2.component"; import { MoreFromBitwardenPageComponent } from "../tools/popup/settings/about-page/more-from-bitwarden-page.component"; +import { ExportBrowserV2Component } from "../tools/popup/settings/export/export-browser-v2.component"; import { ExportBrowserComponent } from "../tools/popup/settings/export/export-browser.component"; import { ImportBrowserV2Component } from "../tools/popup/settings/import/import-browser-v2.component"; import { ImportBrowserComponent } from "../tools/popup/settings/import/import-browser.component"; @@ -243,12 +244,11 @@ const routes: Routes = [ canActivate: [AuthGuard], data: { state: "import" }, }), - { + ...extensionRefreshSwap(ExportBrowserComponent, ExportBrowserV2Component, { path: "export", - component: ExportBrowserComponent, canActivate: [AuthGuard], data: { state: "export" }, - }, + }), { path: "autofill", component: AutofillComponent, diff --git a/apps/browser/src/tools/popup/settings/export/export-browser-v2.component.html b/apps/browser/src/tools/popup/settings/export/export-browser-v2.component.html new file mode 100644 index 0000000000..9ad6ed3683 --- /dev/null +++ b/apps/browser/src/tools/popup/settings/export/export-browser-v2.component.html @@ -0,0 +1,27 @@ + + + + + + + + + + + + + diff --git a/apps/browser/src/tools/popup/settings/export/export-browser-v2.component.ts b/apps/browser/src/tools/popup/settings/export/export-browser-v2.component.ts new file mode 100644 index 0000000000..cbb66cbcf5 --- /dev/null +++ b/apps/browser/src/tools/popup/settings/export/export-browser-v2.component.ts @@ -0,0 +1,40 @@ +import { CommonModule } from "@angular/common"; +import { Component } from "@angular/core"; +import { Router, RouterLink } from "@angular/router"; + +import { JslibModule } from "@bitwarden/angular/jslib.module"; +import { AsyncActionsModule, ButtonModule, DialogModule } from "@bitwarden/components"; +import { ExportComponent } from "@bitwarden/vault-export-ui"; + +import { PopOutComponent } from "../../../../platform/popup/components/pop-out.component"; +import { PopupFooterComponent } from "../../../../platform/popup/layout/popup-footer.component"; +import { PopupHeaderComponent } from "../../../../platform/popup/layout/popup-header.component"; +import { PopupPageComponent } from "../../../../platform/popup/layout/popup-page.component"; + +@Component({ + templateUrl: "export-browser-v2.component.html", + standalone: true, + imports: [ + CommonModule, + RouterLink, + JslibModule, + DialogModule, + AsyncActionsModule, + ButtonModule, + ExportComponent, + PopupPageComponent, + PopupFooterComponent, + PopupHeaderComponent, + PopOutComponent, + ], +}) +export class ExportBrowserV2Component { + protected disabled = false; + protected loading = false; + + constructor(private router: Router) {} + + protected async onSuccessfulExport(organizationId: string): Promise { + await this.router.navigate(["/vault-settings"]); + } +} 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 83388f9ca6..299a9cdfa1 100644 --- a/apps/browser/webpack.config.js +++ b/apps/browser/webpack.config.js @@ -170,8 +170,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/inline-menu/pages/button/bootstrap-autofill-inline-menu-button.ts", @@ -283,8 +283,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 {