[PM-7247] Update AutofillService reference within Angular DI to remove the getBgService call (#8591)

* [PM-7247] Update AutofillService dependency reference within Angular to remove getBgService call

* [PM-7247] Update AutofillService reference within Angular DI to remove the getBgService call
This commit is contained in:
Cesar Gonzalez 2024-04-03 14:03:10 -05:00 committed by GitHub
parent b579bc8f96
commit daa9e742e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 18 additions and 15 deletions

View File

@ -16,10 +16,6 @@ import {
logServiceFactory, logServiceFactory,
LogServiceInitOptions, LogServiceInitOptions,
} from "../../../platform/background/service-factories/log-service.factory"; } from "../../../platform/background/service-factories/log-service.factory";
import {
stateServiceFactory,
StateServiceInitOptions,
} from "../../../platform/background/service-factories/state-service.factory";
import { import {
cipherServiceFactory, cipherServiceFactory,
CipherServiceInitOptions, CipherServiceInitOptions,
@ -44,7 +40,6 @@ type AutoFillServiceOptions = FactoryOptions;
export type AutoFillServiceInitOptions = AutoFillServiceOptions & export type AutoFillServiceInitOptions = AutoFillServiceOptions &
CipherServiceInitOptions & CipherServiceInitOptions &
StateServiceInitOptions &
AutofillSettingsServiceInitOptions & AutofillSettingsServiceInitOptions &
TotpServiceInitOptions & TotpServiceInitOptions &
EventCollectionServiceInitOptions & EventCollectionServiceInitOptions &
@ -63,7 +58,6 @@ export function autofillServiceFactory(
async () => async () =>
new AutofillService( new AutofillService(
await cipherServiceFactory(cache, opts), await cipherServiceFactory(cache, opts),
await stateServiceFactory(cache, opts),
await autofillSettingsServiceFactory(cache, opts), await autofillSettingsServiceFactory(cache, opts),
await totpServiceFactory(cache, opts), await totpServiceFactory(cache, opts),
await eventCollectionServiceFactory(cache, opts), await eventCollectionServiceFactory(cache, opts),

View File

@ -32,7 +32,6 @@ import { CipherService } from "@bitwarden/common/vault/services/cipher.service";
import { TotpService } from "@bitwarden/common/vault/services/totp.service"; import { TotpService } from "@bitwarden/common/vault/services/totp.service";
import { BrowserApi } from "../../platform/browser/browser-api"; import { BrowserApi } from "../../platform/browser/browser-api";
import { BrowserStateService } from "../../platform/services/browser-state.service";
import { AutofillPort } from "../enums/autofill-port.enums"; import { AutofillPort } from "../enums/autofill-port.enums";
import AutofillField from "../models/autofill-field"; import AutofillField from "../models/autofill-field";
import AutofillPageDetails from "../models/autofill-page-details"; import AutofillPageDetails from "../models/autofill-page-details";
@ -63,7 +62,6 @@ const mockEquivalentDomains = [
describe("AutofillService", () => { describe("AutofillService", () => {
let autofillService: AutofillService; let autofillService: AutofillService;
const cipherService = mock<CipherService>(); const cipherService = mock<CipherService>();
const stateService = mock<BrowserStateService>();
const autofillSettingsService = mock<AutofillSettingsService>(); const autofillSettingsService = mock<AutofillSettingsService>();
const mockUserId = Utils.newGuid() as UserId; const mockUserId = Utils.newGuid() as UserId;
const accountService: FakeAccountService = mockAccountServiceWith(mockUserId); const accountService: FakeAccountService = mockAccountServiceWith(mockUserId);
@ -78,7 +76,6 @@ describe("AutofillService", () => {
beforeEach(() => { beforeEach(() => {
autofillService = new AutofillService( autofillService = new AutofillService(
cipherService, cipherService,
stateService,
autofillSettingsService, autofillSettingsService,
totpService, totpService,
eventCollectionService, eventCollectionService,

View File

@ -20,7 +20,6 @@ import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { FieldView } from "@bitwarden/common/vault/models/view/field.view"; import { FieldView } from "@bitwarden/common/vault/models/view/field.view";
import { BrowserApi } from "../../platform/browser/browser-api"; import { BrowserApi } from "../../platform/browser/browser-api";
import { BrowserStateService } from "../../platform/services/abstractions/browser-state.service";
import { openVaultItemPasswordRepromptPopout } from "../../vault/popup/utils/vault-popout-window"; import { openVaultItemPasswordRepromptPopout } from "../../vault/popup/utils/vault-popout-window";
import { AutofillPort } from "../enums/autofill-port.enums"; import { AutofillPort } from "../enums/autofill-port.enums";
import AutofillField from "../models/autofill-field"; import AutofillField from "../models/autofill-field";
@ -49,7 +48,6 @@ export default class AutofillService implements AutofillServiceInterface {
constructor( constructor(
private cipherService: CipherService, private cipherService: CipherService,
private stateService: BrowserStateService,
private autofillSettingsService: AutofillSettingsServiceAbstraction, private autofillSettingsService: AutofillSettingsServiceAbstraction,
private totpService: TotpService, private totpService: TotpService,
private eventCollectionService: EventCollectionService, private eventCollectionService: EventCollectionService,

View File

@ -767,7 +767,6 @@ export default class MainBackground {
this.autofillService = new AutofillService( this.autofillService = new AutofillService(
this.cipherService, this.cipherService,
this.stateService,
this.autofillSettingsService, this.autofillSettingsService,
this.totpService, this.totpService,
this.eventCollectionService, this.eventCollectionService,

View File

@ -19,6 +19,7 @@ import {
AuthRequestServiceAbstraction, AuthRequestServiceAbstraction,
LoginStrategyServiceAbstraction, LoginStrategyServiceAbstraction,
} from "@bitwarden/auth/common"; } from "@bitwarden/auth/common";
import { EventCollectionService as EventCollectionServiceAbstraction } from "@bitwarden/common/abstractions/event/event-collection.service";
import { NotificationsService } from "@bitwarden/common/abstractions/notifications.service"; import { NotificationsService } from "@bitwarden/common/abstractions/notifications.service";
import { SearchService as SearchServiceAbstraction } from "@bitwarden/common/abstractions/search.service"; import { SearchService as SearchServiceAbstraction } from "@bitwarden/common/abstractions/search.service";
import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout-settings.service"; import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout-settings.service";
@ -47,6 +48,7 @@ import {
UserNotificationSettingsService, UserNotificationSettingsService,
UserNotificationSettingsServiceAbstraction, UserNotificationSettingsServiceAbstraction,
} from "@bitwarden/common/autofill/services/user-notification-settings.service"; } from "@bitwarden/common/autofill/services/user-notification-settings.service";
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service"; import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service"; import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service"; import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
@ -85,7 +87,8 @@ import { DialogService } from "@bitwarden/components";
import { VaultExportServiceAbstraction } from "@bitwarden/vault-export-core"; import { VaultExportServiceAbstraction } from "@bitwarden/vault-export-core";
import { UnauthGuardService } from "../../auth/popup/services"; import { UnauthGuardService } from "../../auth/popup/services";
import { AutofillService } from "../../autofill/services/abstractions/autofill.service"; import { AutofillService as AutofillServiceAbstraction } from "../../autofill/services/abstractions/autofill.service";
import AutofillService from "../../autofill/services/autofill.service";
import MainBackground from "../../background/main.background"; import MainBackground from "../../background/main.background";
import { Account } from "../../models/account"; import { Account } from "../../models/account";
import { BrowserApi } from "../../platform/browser/browser-api"; import { BrowserApi } from "../../platform/browser/browser-api";
@ -312,10 +315,22 @@ const safeProviders: SafeProvider[] = [
useClass: BrowserLocalStorageService, useClass: BrowserLocalStorageService,
deps: [], deps: [],
}), }),
safeProvider({
provide: AutofillServiceAbstraction,
useExisting: AutofillService,
}),
safeProvider({ safeProvider({
provide: AutofillService, provide: AutofillService,
useFactory: getBgService<AutofillService>("autofillService"), deps: [
deps: [], CipherService,
AutofillSettingsServiceAbstraction,
TotpService,
EventCollectionServiceAbstraction,
LogService,
DomainSettingsService,
UserVerificationService,
BillingAccountProfileStateService,
],
}), }),
safeProvider({ safeProvider({
provide: VaultExportServiceAbstraction, provide: VaultExportServiceAbstraction,