mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-22 16:29:09 +01:00
[PM-7610] [MV3] Guard overlay visibility and autofill on page load settings from awaiting indefinitely when there is no active account (#8833)
* guard overlay visibility and autofill on page load settings from awaiting indefinitely when there is no active account * cleanup
This commit is contained in:
parent
395ed3f5d4
commit
ec1af0cf9f
@ -1,3 +1,7 @@
|
|||||||
|
import {
|
||||||
|
accountServiceFactory,
|
||||||
|
AccountServiceInitOptions,
|
||||||
|
} from "../../../auth/background/service-factories/account-service.factory";
|
||||||
import {
|
import {
|
||||||
UserVerificationServiceInitOptions,
|
UserVerificationServiceInitOptions,
|
||||||
userVerificationServiceFactory,
|
userVerificationServiceFactory,
|
||||||
@ -50,7 +54,8 @@ export type AutoFillServiceInitOptions = AutoFillServiceOptions &
|
|||||||
LogServiceInitOptions &
|
LogServiceInitOptions &
|
||||||
UserVerificationServiceInitOptions &
|
UserVerificationServiceInitOptions &
|
||||||
DomainSettingsServiceInitOptions &
|
DomainSettingsServiceInitOptions &
|
||||||
BrowserScriptInjectorServiceInitOptions;
|
BrowserScriptInjectorServiceInitOptions &
|
||||||
|
AccountServiceInitOptions;
|
||||||
|
|
||||||
export function autofillServiceFactory(
|
export function autofillServiceFactory(
|
||||||
cache: { autofillService?: AbstractAutoFillService } & CachedServices,
|
cache: { autofillService?: AbstractAutoFillService } & CachedServices,
|
||||||
@ -71,6 +76,7 @@ export function autofillServiceFactory(
|
|||||||
await userVerificationServiceFactory(cache, opts),
|
await userVerificationServiceFactory(cache, opts),
|
||||||
await billingAccountProfileStateServiceFactory(cache, opts),
|
await billingAccountProfileStateServiceFactory(cache, opts),
|
||||||
await browserScriptInjectorServiceFactory(cache, opts),
|
await browserScriptInjectorServiceFactory(cache, opts),
|
||||||
|
await accountServiceFactory(cache, opts),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,7 @@ describe("AutofillService", () => {
|
|||||||
userVerificationService,
|
userVerificationService,
|
||||||
billingAccountProfileStateService,
|
billingAccountProfileStateService,
|
||||||
scriptInjectorService,
|
scriptInjectorService,
|
||||||
|
accountService,
|
||||||
);
|
);
|
||||||
|
|
||||||
domainSettingsService = new DefaultDomainSettingsService(fakeStateProvider);
|
domainSettingsService = new DefaultDomainSettingsService(fakeStateProvider);
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import { firstValueFrom } from "rxjs";
|
import { firstValueFrom } from "rxjs";
|
||||||
|
|
||||||
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
|
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
|
||||||
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
||||||
|
import { AutofillOverlayVisibility } from "@bitwarden/common/autofill/constants";
|
||||||
import { AutofillSettingsServiceAbstraction } from "@bitwarden/common/autofill/services/autofill-settings.service";
|
import { AutofillSettingsServiceAbstraction } from "@bitwarden/common/autofill/services/autofill-settings.service";
|
||||||
import { DomainSettingsService } from "@bitwarden/common/autofill/services/domain-settings.service";
|
import { DomainSettingsService } from "@bitwarden/common/autofill/services/domain-settings.service";
|
||||||
import { InlineMenuVisibilitySetting } from "@bitwarden/common/autofill/types";
|
import { InlineMenuVisibilitySetting } from "@bitwarden/common/autofill/types";
|
||||||
@ -57,6 +59,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
private userVerificationService: UserVerificationService,
|
private userVerificationService: UserVerificationService,
|
||||||
private billingAccountProfileStateService: BillingAccountProfileStateService,
|
private billingAccountProfileStateService: BillingAccountProfileStateService,
|
||||||
private scriptInjectorService: ScriptInjectorService,
|
private scriptInjectorService: ScriptInjectorService,
|
||||||
|
private accountService: AccountService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -104,13 +107,26 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
frameId = 0,
|
frameId = 0,
|
||||||
triggeringOnPageLoad = true,
|
triggeringOnPageLoad = true,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const mainAutofillScript = (await this.getOverlayVisibility())
|
// Autofill settings loaded from state can await the active account state indefinitely if
|
||||||
|
// not guarded by an active account check (e.g. the user is logged in)
|
||||||
|
const activeAccount = await firstValueFrom(this.accountService.activeAccount$);
|
||||||
|
|
||||||
|
// These settings are not available until the user logs in
|
||||||
|
let overlayVisibility: InlineMenuVisibilitySetting = AutofillOverlayVisibility.Off;
|
||||||
|
let autoFillOnPageLoadIsEnabled = false;
|
||||||
|
|
||||||
|
if (activeAccount) {
|
||||||
|
overlayVisibility = await this.getOverlayVisibility();
|
||||||
|
}
|
||||||
|
const mainAutofillScript = overlayVisibility
|
||||||
? "bootstrap-autofill-overlay.js"
|
? "bootstrap-autofill-overlay.js"
|
||||||
: "bootstrap-autofill.js";
|
: "bootstrap-autofill.js";
|
||||||
|
|
||||||
const injectedScripts = [mainAutofillScript];
|
const injectedScripts = [mainAutofillScript];
|
||||||
|
|
||||||
const autoFillOnPageLoadIsEnabled = await this.getAutofillOnPageLoad();
|
if (activeAccount) {
|
||||||
|
autoFillOnPageLoadIsEnabled = await this.getAutofillOnPageLoad();
|
||||||
|
}
|
||||||
|
|
||||||
if (triggeringOnPageLoad && autoFillOnPageLoadIsEnabled) {
|
if (triggeringOnPageLoad && autoFillOnPageLoadIsEnabled) {
|
||||||
injectedScripts.push("autofiller.js");
|
injectedScripts.push("autofiller.js");
|
||||||
|
@ -29,6 +29,7 @@ import { PolicyService } from "@bitwarden/common/admin-console/services/policy/p
|
|||||||
import { ProviderService } from "@bitwarden/common/admin-console/services/provider.service";
|
import { ProviderService } from "@bitwarden/common/admin-console/services/provider.service";
|
||||||
import { AccountService as AccountServiceAbstraction } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService as AccountServiceAbstraction } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
import { AuthService as AuthServiceAbstraction } from "@bitwarden/common/auth/abstractions/auth.service";
|
import { AuthService as AuthServiceAbstraction } from "@bitwarden/common/auth/abstractions/auth.service";
|
||||||
|
import { AvatarService as AvatarServiceAbstraction } from "@bitwarden/common/auth/abstractions/avatar.service";
|
||||||
import { DeviceTrustCryptoServiceAbstraction } from "@bitwarden/common/auth/abstractions/device-trust-crypto.service.abstraction";
|
import { DeviceTrustCryptoServiceAbstraction } from "@bitwarden/common/auth/abstractions/device-trust-crypto.service.abstraction";
|
||||||
import { DevicesServiceAbstraction } from "@bitwarden/common/auth/abstractions/devices/devices.service.abstraction";
|
import { DevicesServiceAbstraction } from "@bitwarden/common/auth/abstractions/devices/devices.service.abstraction";
|
||||||
import { DevicesApiServiceAbstraction } from "@bitwarden/common/auth/abstractions/devices-api.service.abstraction";
|
import { DevicesApiServiceAbstraction } from "@bitwarden/common/auth/abstractions/devices-api.service.abstraction";
|
||||||
@ -137,7 +138,6 @@ import { EventUploadService } from "@bitwarden/common/services/event/event-uploa
|
|||||||
import { NotificationsService } from "@bitwarden/common/services/notifications.service";
|
import { NotificationsService } from "@bitwarden/common/services/notifications.service";
|
||||||
import { SearchService } from "@bitwarden/common/services/search.service";
|
import { SearchService } from "@bitwarden/common/services/search.service";
|
||||||
import { VaultTimeoutSettingsService } from "@bitwarden/common/services/vault-timeout/vault-timeout-settings.service";
|
import { VaultTimeoutSettingsService } from "@bitwarden/common/services/vault-timeout/vault-timeout-settings.service";
|
||||||
import { AvatarService as AvatarServiceAbstraction } from "@bitwarden/common/src/auth/abstractions/avatar.service";
|
|
||||||
import {
|
import {
|
||||||
PasswordGenerationService,
|
PasswordGenerationService,
|
||||||
PasswordGenerationServiceAbstraction,
|
PasswordGenerationServiceAbstraction,
|
||||||
@ -807,6 +807,7 @@ export default class MainBackground {
|
|||||||
this.userVerificationService,
|
this.userVerificationService,
|
||||||
this.billingAccountProfileStateService,
|
this.billingAccountProfileStateService,
|
||||||
this.scriptInjectorService,
|
this.scriptInjectorService,
|
||||||
|
this.accountService,
|
||||||
);
|
);
|
||||||
this.auditService = new AuditService(this.cryptoFunctionService, this.apiService);
|
this.auditService = new AuditService(this.cryptoFunctionService, this.apiService);
|
||||||
|
|
||||||
|
@ -312,6 +312,7 @@ const safeProviders: SafeProvider[] = [
|
|||||||
UserVerificationService,
|
UserVerificationService,
|
||||||
BillingAccountProfileStateService,
|
BillingAccountProfileStateService,
|
||||||
ScriptInjectorService,
|
ScriptInjectorService,
|
||||||
|
AccountServiceAbstraction,
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
safeProvider({
|
safeProvider({
|
||||||
|
Loading…
Reference in New Issue
Block a user