diff --git a/apps/browser/src/vault/popup/components/vault-v2/view-v2/view-v2.component.ts b/apps/browser/src/vault/popup/components/vault-v2/view-v2/view-v2.component.ts index e8aab69dbe..b2ef6701b4 100644 --- a/apps/browser/src/vault/popup/components/vault-v2/view-v2/view-v2.component.ts +++ b/apps/browser/src/vault/popup/components/vault-v2/view-v2/view-v2.component.ts @@ -20,17 +20,15 @@ import { CollectionView } from "@bitwarden/common/vault/models/view/collection.v import { FolderView } from "@bitwarden/common/vault/models/view/folder.view"; import { AsyncActionsModule, - SearchModule, ButtonModule, - IconButtonModule, DialogService, + IconButtonModule, + SearchModule, ToastService, } from "@bitwarden/components"; -import { TotpCaptureService } from "@bitwarden/vault"; import { CipherViewComponent } from "../../../../../../../../libs/vault/src/cipher-view"; import { PopOutComponent } from "../../../../../platform/popup/components/pop-out.component"; -import { BrowserTotpCaptureService } from "../../../services/browser-totp-capture.service"; import { PopupFooterComponent } from "./../../../../../platform/popup/layout/popup-footer.component"; import { PopupHeaderComponent } from "./../../../../../platform/popup/layout/popup-header.component"; @@ -41,7 +39,6 @@ import { VaultPopupAutofillService } from "./../../../services/vault-popup-autof selector: "app-view-v2", templateUrl: "view-v2.component.html", standalone: true, - providers: [{ provide: TotpCaptureService, useClass: BrowserTotpCaptureService }], imports: [ CommonModule, SearchModule, diff --git a/apps/browser/src/vault/popup/services/browser-totp-capture.service.spec.ts b/apps/browser/src/vault/popup/services/browser-totp-capture.service.spec.ts index e790735dc5..2c9afacffd 100644 --- a/apps/browser/src/vault/popup/services/browser-totp-capture.service.spec.ts +++ b/apps/browser/src/vault/popup/services/browser-totp-capture.service.spec.ts @@ -13,15 +13,10 @@ describe("BrowserTotpCaptureService", () => { let testBed: TestBed; let service: BrowserTotpCaptureService; let mockCaptureVisibleTab: jest.SpyInstance; - let createNewTabSpy: jest.SpyInstance; const validTotpUrl = "otpauth://totp/label?secret=123"; beforeEach(() => { - const tabReturn = new Promise((resolve) => - resolve({ url: "google.com", active: true } as chrome.tabs.Tab), - ); - createNewTabSpy = jest.spyOn(BrowserApi, "createNewTab").mockReturnValue(tabReturn); mockCaptureVisibleTab = jest.spyOn(BrowserApi, "captureVisibleTab"); mockCaptureVisibleTab.mockResolvedValue("screenshot"); @@ -71,10 +66,4 @@ describe("BrowserTotpCaptureService", () => { expect(result).toBeNull(); }); - - it("should call BrowserApi.createNewTab with a given loginURI", async () => { - await service.openAutofillNewTab("www.google.com"); - - expect(createNewTabSpy).toHaveBeenCalledWith("www.google.com"); - }); }); diff --git a/apps/browser/src/vault/popup/services/browser-totp-capture.service.ts b/apps/browser/src/vault/popup/services/browser-totp-capture.service.ts index 8f93db45c0..3f8ba61ed3 100644 --- a/apps/browser/src/vault/popup/services/browser-totp-capture.service.ts +++ b/apps/browser/src/vault/popup/services/browser-totp-capture.service.ts @@ -20,8 +20,4 @@ export class BrowserTotpCaptureService implements TotpCaptureService { } return null; } - - async openAutofillNewTab(loginUri: string) { - await BrowserApi.createNewTab(loginUri); - } } diff --git a/libs/vault/src/cipher-form/abstractions/totp-capture.service.ts b/libs/vault/src/cipher-form/abstractions/totp-capture.service.ts index ad0b03be82..d6d9556586 100644 --- a/libs/vault/src/cipher-form/abstractions/totp-capture.service.ts +++ b/libs/vault/src/cipher-form/abstractions/totp-capture.service.ts @@ -1,8 +1,3 @@ -/** - * TODO: PM-10727 - Rename and Refactor this service - * This service is being used in both CipherForm and CipherView. Update this service to reflect that - */ - /** * Service to capture TOTP secret from a client application. */ @@ -11,5 +6,4 @@ export abstract class TotpCaptureService { * Captures a TOTP secret and returns it as a string. Returns null if no TOTP secret was found. */ abstract captureTotpSecret(): Promise; - abstract openAutofillNewTab(loginUri: string): void; } diff --git a/libs/vault/src/cipher-view/autofill-options/autofill-options-view.component.ts b/libs/vault/src/cipher-view/autofill-options/autofill-options-view.component.ts index 84f25a146c..b7708b5aa9 100644 --- a/libs/vault/src/cipher-view/autofill-options/autofill-options-view.component.ts +++ b/libs/vault/src/cipher-view/autofill-options/autofill-options-view.component.ts @@ -2,18 +2,17 @@ import { CommonModule } from "@angular/common"; import { Component, Input } from "@angular/core"; import { JslibModule } from "@bitwarden/angular/jslib.module"; +import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { LoginUriView } from "@bitwarden/common/vault/models/view/login-uri.view"; import { CardComponent, FormFieldModule, + IconButtonModule, SectionComponent, SectionHeaderComponent, TypographyModule, - IconButtonModule, } from "@bitwarden/components"; -import { TotpCaptureService } from "../../cipher-form"; - @Component({ selector: "app-autofill-options-view", templateUrl: "autofill-options-view.component.html", @@ -32,9 +31,9 @@ import { TotpCaptureService } from "../../cipher-form"; export class AutofillOptionsViewComponent { @Input() loginUris: LoginUriView[]; - constructor(private totpCaptureService: TotpCaptureService) {} + constructor(private platformUtilsService: PlatformUtilsService) {} - async openWebsite(selectedUri: string) { - await this.totpCaptureService.openAutofillNewTab(selectedUri); + openWebsite(selectedUri: string) { + this.platformUtilsService.launchUri(selectedUri); } }