diff --git a/apps/browser/src/autofill/background/notification.background.ts b/apps/browser/src/autofill/background/notification.background.ts index 6b5f1a8297..44decc01a9 100644 --- a/apps/browser/src/autofill/background/notification.background.ts +++ b/apps/browser/src/autofill/background/notification.background.ts @@ -4,6 +4,7 @@ import { PolicyService } from "@bitwarden/common/admin-console/abstractions/poli import { PolicyType } from "@bitwarden/common/admin-console/enums"; import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service"; import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status"; +import { NOTIFICATION_BAR_LIFESPAN_MS } from "@bitwarden/common/autofill/constants"; import { UserNotificationSettingsServiceAbstraction } from "@bitwarden/common/autofill/services/user-notification-settings.service"; import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; @@ -19,7 +20,6 @@ import { openUnlockPopout } from "../../auth/popup/utils/auth-popout-window"; import { BrowserApi } from "../../platform/browser/browser-api"; import { BrowserStateService } from "../../platform/services/abstractions/browser-state.service"; import { openAddEditVaultItemPopout } from "../../vault/popup/utils/vault-popout-window"; -import { NOTIFICATION_BAR_LIFESPAN_MS } from "../constants"; import { NotificationQueueMessageType } from "../enums/notification-queue-message-type.enum"; import { AutofillService } from "../services/abstractions/autofill.service"; diff --git a/apps/browser/src/autofill/background/overlay.background.spec.ts b/apps/browser/src/autofill/background/overlay.background.spec.ts index 2820ed6cd1..c19505118b 100644 --- a/apps/browser/src/autofill/background/overlay.background.spec.ts +++ b/apps/browser/src/autofill/background/overlay.background.spec.ts @@ -2,6 +2,10 @@ import { mock, mockReset } from "jest-mock-extended"; import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status"; import { AuthService } from "@bitwarden/common/auth/services/auth.service"; +import { + SHOW_AUTOFILL_BUTTON, + AutofillOverlayVisibility, +} from "@bitwarden/common/autofill/constants"; import { AutofillSettingsService } from "@bitwarden/common/autofill/services/autofill-settings.service"; import { ThemeType } from "@bitwarden/common/platform/enums"; import { EnvironmentService } from "@bitwarden/common/platform/services/environment.service"; @@ -15,7 +19,6 @@ import { CipherService } from "@bitwarden/common/vault/services/cipher.service"; import { BrowserApi } from "../../platform/browser/browser-api"; import BrowserPlatformUtilsService from "../../platform/services/browser-platform-utils.service"; import { BrowserStateService } from "../../platform/services/browser-state.service"; -import { SHOW_AUTOFILL_BUTTON } from "../constants"; import { AutofillService } from "../services/abstractions/autofill.service"; import { createAutofillPageDetailsMock, @@ -28,7 +31,6 @@ import { flushPromises, sendExtensionRuntimeMessage, sendPortMessage } from "../ import { AutofillOverlayElement, AutofillOverlayPort, - AutofillOverlayVisibility, RedirectFocusDirection, } from "../utils/autofill-overlay.enum"; diff --git a/apps/browser/src/autofill/background/overlay.background.ts b/apps/browser/src/autofill/background/overlay.background.ts index 583e22fbe8..49d27391cf 100644 --- a/apps/browser/src/autofill/background/overlay.background.ts +++ b/apps/browser/src/autofill/background/overlay.background.ts @@ -3,7 +3,9 @@ import { firstValueFrom } from "rxjs"; import { SettingsService } from "@bitwarden/common/abstractions/settings.service"; import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service"; import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status"; +import { SHOW_AUTOFILL_BUTTON } from "@bitwarden/common/autofill/constants"; import { AutofillSettingsServiceAbstraction } from "@bitwarden/common/autofill/services/autofill-settings.service"; +import { InlineMenuVisibilitySetting } from "@bitwarden/common/autofill/types"; import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; @@ -22,13 +24,8 @@ import { openViewVaultItemPopout, openAddEditVaultItemPopout, } from "../../vault/popup/utils/vault-popout-window"; -import { SHOW_AUTOFILL_BUTTON } from "../constants"; import { AutofillService, PageDetail } from "../services/abstractions/autofill.service"; -import { - InlineMenuVisibilitySetting, - AutofillOverlayElement, - AutofillOverlayPort, -} from "../utils/autofill-overlay.enum"; +import { AutofillOverlayElement, AutofillOverlayPort } from "../utils/autofill-overlay.enum"; import { LockedVaultPendingNotificationsData } from "./abstractions/notification.background"; import { diff --git a/apps/browser/src/autofill/browser/context-menu-clicked-handler.spec.ts b/apps/browser/src/autofill/browser/context-menu-clicked-handler.spec.ts index f2312a0d66..e54f37489b 100644 --- a/apps/browser/src/autofill/browser/context-menu-clicked-handler.spec.ts +++ b/apps/browser/src/autofill/browser/context-menu-clicked-handler.spec.ts @@ -3,14 +3,6 @@ import { mock, MockProxy } from "jest-mock-extended"; import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service"; import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service"; import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction"; -import { StateService } from "@bitwarden/common/platform/abstractions/state.service"; -import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; -import { TotpService } from "@bitwarden/common/vault/abstractions/totp.service"; -import { CipherType } from "@bitwarden/common/vault/enums"; -import { CipherRepromptType } from "@bitwarden/common/vault/enums/cipher-reprompt-type"; -import { Cipher } from "@bitwarden/common/vault/models/domain/cipher"; -import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; - import { AUTOFILL_ID, COPY_PASSWORD_ID, @@ -18,7 +10,14 @@ import { COPY_VERIFICATION_CODE_ID, GENERATE_PASSWORD_ID, NOOP_COMMAND_SUFFIX, -} from "../constants"; +} from "@bitwarden/common/autofill/constants"; +import { StateService } from "@bitwarden/common/platform/abstractions/state.service"; +import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; +import { TotpService } from "@bitwarden/common/vault/abstractions/totp.service"; +import { CipherType } from "@bitwarden/common/vault/enums"; +import { CipherRepromptType } from "@bitwarden/common/vault/enums/cipher-reprompt-type"; +import { Cipher } from "@bitwarden/common/vault/models/domain/cipher"; +import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { CopyToClipboardAction, diff --git a/apps/browser/src/autofill/browser/context-menu-clicked-handler.ts b/apps/browser/src/autofill/browser/context-menu-clicked-handler.ts index 21ff91c02d..760b833044 100644 --- a/apps/browser/src/autofill/browser/context-menu-clicked-handler.ts +++ b/apps/browser/src/autofill/browser/context-menu-clicked-handler.ts @@ -2,6 +2,20 @@ import { EventCollectionService } from "@bitwarden/common/abstractions/event/eve import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service"; import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction"; import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status"; +import { + AUTOFILL_CARD_ID, + AUTOFILL_ID, + AUTOFILL_IDENTITY_ID, + COPY_IDENTIFIER_ID, + COPY_PASSWORD_ID, + COPY_USERNAME_ID, + COPY_VERIFICATION_CODE_ID, + CREATE_CARD_ID, + CREATE_IDENTITY_ID, + CREATE_LOGIN_ID, + GENERATE_PASSWORD_ID, + NOOP_COMMAND_SUFFIX, +} from "@bitwarden/common/autofill/constants"; import { EventType } from "@bitwarden/common/enums"; import { StateService } from "@bitwarden/common/platform/abstractions/state.service"; import { StateFactory } from "@bitwarden/common/platform/factories/state-factory"; @@ -38,20 +52,6 @@ import { LockedVaultPendingNotificationsData } from "../background/abstractions/ import { autofillServiceFactory } from "../background/service_factories/autofill-service.factory"; import { copyToClipboard, GeneratePasswordToClipboardCommand } from "../clipboard"; import { AutofillTabCommand } from "../commands/autofill-tab-command"; -import { - AUTOFILL_CARD_ID, - AUTOFILL_ID, - AUTOFILL_IDENTITY_ID, - COPY_IDENTIFIER_ID, - COPY_PASSWORD_ID, - COPY_USERNAME_ID, - COPY_VERIFICATION_CODE_ID, - CREATE_CARD_ID, - CREATE_IDENTITY_ID, - CREATE_LOGIN_ID, - GENERATE_PASSWORD_ID, - NOOP_COMMAND_SUFFIX, -} from "../constants"; import { AutofillCipherTypeId } from "../types"; export type CopyToClipboardOptions = { text: string; tab: chrome.tabs.Tab }; diff --git a/apps/browser/src/autofill/browser/main-context-menu-handler.spec.ts b/apps/browser/src/autofill/browser/main-context-menu-handler.spec.ts index 9e115749e8..f2b17d2f08 100644 --- a/apps/browser/src/autofill/browser/main-context-menu-handler.spec.ts +++ b/apps/browser/src/autofill/browser/main-context-menu-handler.spec.ts @@ -1,5 +1,6 @@ import { mock, MockProxy } from "jest-mock-extended"; +import { NOOP_COMMAND_SUFFIX } from "@bitwarden/common/autofill/constants"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { CipherType } from "@bitwarden/common/vault/enums"; @@ -7,7 +8,6 @@ import { Cipher } from "@bitwarden/common/vault/models/domain/cipher"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { BrowserStateService } from "../../platform/services/abstractions/browser-state.service"; -import { NOOP_COMMAND_SUFFIX } from "../constants"; import { MainContextMenuHandler } from "./main-context-menu-handler"; diff --git a/apps/browser/src/autofill/browser/main-context-menu-handler.ts b/apps/browser/src/autofill/browser/main-context-menu-handler.ts index 0051c69154..19154fbfb8 100644 --- a/apps/browser/src/autofill/browser/main-context-menu-handler.ts +++ b/apps/browser/src/autofill/browser/main-context-menu-handler.ts @@ -1,3 +1,19 @@ +import { + AUTOFILL_CARD_ID, + AUTOFILL_ID, + AUTOFILL_IDENTITY_ID, + COPY_IDENTIFIER_ID, + COPY_PASSWORD_ID, + COPY_USERNAME_ID, + COPY_VERIFICATION_CODE_ID, + CREATE_CARD_ID, + CREATE_IDENTITY_ID, + CREATE_LOGIN_ID, + GENERATE_PASSWORD_ID, + NOOP_COMMAND_SUFFIX, + ROOT_ID, + SEPARATOR_ID, +} from "@bitwarden/common/autofill/constants"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { StateFactory } from "@bitwarden/common/platform/factories/state-factory"; @@ -21,22 +37,6 @@ import { StateServiceInitOptions, } from "../../platform/background/service-factories/state-service.factory"; import { BrowserStateService } from "../../platform/services/abstractions/browser-state.service"; -import { - AUTOFILL_CARD_ID, - AUTOFILL_ID, - AUTOFILL_IDENTITY_ID, - COPY_IDENTIFIER_ID, - COPY_PASSWORD_ID, - COPY_USERNAME_ID, - COPY_VERIFICATION_CODE_ID, - CREATE_CARD_ID, - CREATE_IDENTITY_ID, - CREATE_LOGIN_ID, - GENERATE_PASSWORD_ID, - NOOP_COMMAND_SUFFIX, - ROOT_ID, - SEPARATOR_ID, -} from "../constants"; import { InitContextMenuItems } from "./abstractions/main-context-menu-handler"; diff --git a/apps/browser/src/autofill/content/autofill-init.spec.ts b/apps/browser/src/autofill/content/autofill-init.spec.ts index 65854c463e..8912a8c0ba 100644 --- a/apps/browser/src/autofill/content/autofill-init.spec.ts +++ b/apps/browser/src/autofill/content/autofill-init.spec.ts @@ -1,12 +1,13 @@ import { mock } from "jest-mock-extended"; import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status"; +import { AutofillOverlayVisibility } from "@bitwarden/common/autofill/constants"; import AutofillPageDetails from "../models/autofill-page-details"; import AutofillScript from "../models/autofill-script"; import AutofillOverlayContentService from "../services/autofill-overlay-content.service"; import { flushPromises, sendExtensionRuntimeMessage } from "../spec/testing-utils"; -import { AutofillOverlayVisibility, RedirectFocusDirection } from "../utils/autofill-overlay.enum"; +import { RedirectFocusDirection } from "../utils/autofill-overlay.enum"; import { AutofillExtensionMessage } from "./abstractions/autofill-init"; import AutofillInit from "./autofill-init"; diff --git a/apps/browser/src/autofill/overlay/iframe-content/autofill-overlay-iframe.service.spec.ts b/apps/browser/src/autofill/overlay/iframe-content/autofill-overlay-iframe.service.spec.ts index 5ab7988157..a7c11ea472 100644 --- a/apps/browser/src/autofill/overlay/iframe-content/autofill-overlay-iframe.service.spec.ts +++ b/apps/browser/src/autofill/overlay/iframe-content/autofill-overlay-iframe.service.spec.ts @@ -1,8 +1,8 @@ import { mock } from "jest-mock-extended"; +import { EVENTS } from "@bitwarden/common/autofill/constants"; import { ThemeType } from "@bitwarden/common/platform/enums"; -import { EVENTS } from "../../constants"; import { createPortSpyMock } from "../../spec/autofill-mocks"; import { flushPromises, diff --git a/apps/browser/src/autofill/overlay/iframe-content/autofill-overlay-iframe.service.ts b/apps/browser/src/autofill/overlay/iframe-content/autofill-overlay-iframe.service.ts index 4512070ff7..0ec7db131c 100644 --- a/apps/browser/src/autofill/overlay/iframe-content/autofill-overlay-iframe.service.ts +++ b/apps/browser/src/autofill/overlay/iframe-content/autofill-overlay-iframe.service.ts @@ -1,6 +1,6 @@ +import { EVENTS } from "@bitwarden/common/autofill/constants"; import { ThemeType } from "@bitwarden/common/platform/enums"; -import { EVENTS } from "../../constants"; import { setElementStyles } from "../../utils"; import { BackgroundPortMessageHandlers, diff --git a/apps/browser/src/autofill/overlay/pages/button/autofill-overlay-button.ts b/apps/browser/src/autofill/overlay/pages/button/autofill-overlay-button.ts index 12c4f2540f..0d68b37e2f 100644 --- a/apps/browser/src/autofill/overlay/pages/button/autofill-overlay-button.ts +++ b/apps/browser/src/autofill/overlay/pages/button/autofill-overlay-button.ts @@ -1,8 +1,8 @@ import "@webcomponents/custom-elements"; import "lit/polyfill-support.js"; import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status"; +import { EVENTS } from "@bitwarden/common/autofill/constants"; -import { EVENTS } from "../../../constants"; import { buildSvgDomElement } from "../../../utils"; import { logoIcon, logoLockedIcon } from "../../../utils/svg-icons"; import { diff --git a/apps/browser/src/autofill/overlay/pages/list/autofill-overlay-list.ts b/apps/browser/src/autofill/overlay/pages/list/autofill-overlay-list.ts index 6feb31533e..305a230e5c 100644 --- a/apps/browser/src/autofill/overlay/pages/list/autofill-overlay-list.ts +++ b/apps/browser/src/autofill/overlay/pages/list/autofill-overlay-list.ts @@ -1,9 +1,9 @@ import "@webcomponents/custom-elements"; import "lit/polyfill-support.js"; import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status"; +import { EVENTS } from "@bitwarden/common/autofill/constants"; import { OverlayCipherData } from "../../../background/abstractions/overlay.background"; -import { EVENTS } from "../../../constants"; import { buildSvgDomElement } from "../../../utils"; import { globeIcon, lockIcon, plusIcon, viewCipherIcon } from "../../../utils/svg-icons"; import { diff --git a/apps/browser/src/autofill/overlay/pages/shared/autofill-overlay-page-element.ts b/apps/browser/src/autofill/overlay/pages/shared/autofill-overlay-page-element.ts index d556e5d52a..34f115f401 100644 --- a/apps/browser/src/autofill/overlay/pages/shared/autofill-overlay-page-element.ts +++ b/apps/browser/src/autofill/overlay/pages/shared/autofill-overlay-page-element.ts @@ -1,4 +1,5 @@ -import { EVENTS } from "../../../constants"; +import { EVENTS } from "@bitwarden/common/autofill/constants"; + import { RedirectFocusDirection } from "../../../utils/autofill-overlay.enum"; import { AutofillOverlayPageElementWindowMessage, diff --git a/apps/browser/src/autofill/popup/settings/autofill.component.ts b/apps/browser/src/autofill/popup/settings/autofill.component.ts index 9e951e280d..857442d309 100644 --- a/apps/browser/src/autofill/popup/settings/autofill.component.ts +++ b/apps/browser/src/autofill/popup/settings/autofill.component.ts @@ -2,7 +2,9 @@ import { Component, OnInit } from "@angular/core"; import { firstValueFrom } from "rxjs"; import { SettingsService } from "@bitwarden/common/abstractions/settings.service"; +import { AutofillOverlayVisibility } from "@bitwarden/common/autofill/constants"; import { AutofillSettingsServiceAbstraction } from "@bitwarden/common/autofill/services/autofill-settings.service"; +import { InlineMenuVisibilitySetting } from "@bitwarden/common/autofill/types"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { StateService } from "@bitwarden/common/platform/abstractions/state.service"; @@ -12,10 +14,6 @@ import { DialogService } from "@bitwarden/components"; import { BrowserApi } from "../../../platform/browser/browser-api"; import { enableAccountSwitching } from "../../../platform/flags"; import { AutofillService } from "../../services/abstractions/autofill.service"; -import { - AutofillOverlayVisibility, - InlineMenuVisibilitySetting, -} from "../../utils/autofill-overlay.enum"; @Component({ selector: "app-autofill", diff --git a/apps/browser/src/autofill/services/autofill-overlay-content.service.spec.ts b/apps/browser/src/autofill/services/autofill-overlay-content.service.spec.ts index e2bc787d3b..4b3641208b 100644 --- a/apps/browser/src/autofill/services/autofill-overlay-content.service.spec.ts +++ b/apps/browser/src/autofill/services/autofill-overlay-content.service.spec.ts @@ -1,17 +1,13 @@ import { mock } from "jest-mock-extended"; import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status"; +import { EVENTS, AutofillOverlayVisibility } from "@bitwarden/common/autofill/constants"; -import { EVENTS } from "../constants"; import AutofillField from "../models/autofill-field"; import { createAutofillFieldMock } from "../spec/autofill-mocks"; import { flushPromises } from "../spec/testing-utils"; import { ElementWithOpId, FormFieldElement } from "../types"; -import { - AutofillOverlayElement, - AutofillOverlayVisibility, - RedirectFocusDirection, -} from "../utils/autofill-overlay.enum"; +import { AutofillOverlayElement, RedirectFocusDirection } from "../utils/autofill-overlay.enum"; import { AutoFillConstants } from "./autofill-constants"; import AutofillOverlayContentService from "./autofill-overlay-content.service"; diff --git a/apps/browser/src/autofill/services/autofill-overlay-content.service.ts b/apps/browser/src/autofill/services/autofill-overlay-content.service.ts index 21baf9a3cd..efbc9732b6 100644 --- a/apps/browser/src/autofill/services/autofill-overlay-content.service.ts +++ b/apps/browser/src/autofill/services/autofill-overlay-content.service.ts @@ -3,9 +3,9 @@ import "lit/polyfill-support.js"; import { FocusableElement, tabbable } from "tabbable"; import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status"; +import { EVENTS, AutofillOverlayVisibility } from "@bitwarden/common/autofill/constants"; import { FocusedFieldData } from "../background/abstractions/overlay.background"; -import { EVENTS } from "../constants"; import AutofillField from "../models/autofill-field"; import AutofillOverlayButtonIframe from "../overlay/iframe-content/autofill-overlay-button-iframe"; import AutofillOverlayListIframe from "../overlay/iframe-content/autofill-overlay-list-iframe"; @@ -16,11 +16,7 @@ import { sendExtensionMessage, setElementStyles, } from "../utils"; -import { - AutofillOverlayElement, - RedirectFocusDirection, - AutofillOverlayVisibility, -} from "../utils/autofill-overlay.enum"; +import { AutofillOverlayElement, RedirectFocusDirection } from "../utils/autofill-overlay.enum"; import { AutofillOverlayContentService as AutofillOverlayContentServiceInterface, diff --git a/apps/browser/src/autofill/services/autofill.service.spec.ts b/apps/browser/src/autofill/services/autofill.service.spec.ts index 055e92a31c..4be338da8e 100644 --- a/apps/browser/src/autofill/services/autofill.service.spec.ts +++ b/apps/browser/src/autofill/services/autofill.service.spec.ts @@ -1,6 +1,7 @@ import { mock, mockReset } from "jest-mock-extended"; import { UserVerificationService } from "@bitwarden/common/auth/services/user-verification/user-verification.service"; +import { AutofillOverlayVisibility } from "@bitwarden/common/autofill/constants"; import { AutofillSettingsService } from "@bitwarden/common/autofill/services/autofill-settings.service"; import { EventType } from "@bitwarden/common/enums"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; @@ -37,7 +38,6 @@ import { createGenerateFillScriptOptionsMock, } from "../spec/autofill-mocks"; import { triggerTestFailure } from "../spec/testing-utils"; -import { AutofillOverlayVisibility } from "../utils/autofill-overlay.enum"; import { AutoFillOptions, diff --git a/apps/browser/src/autofill/services/autofill.service.ts b/apps/browser/src/autofill/services/autofill.service.ts index 80d8c4f77f..4357a9cb6c 100644 --- a/apps/browser/src/autofill/services/autofill.service.ts +++ b/apps/browser/src/autofill/services/autofill.service.ts @@ -4,6 +4,7 @@ import { EventCollectionService } from "@bitwarden/common/abstractions/event/eve import { SettingsService } from "@bitwarden/common/abstractions/settings.service"; import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction"; import { AutofillSettingsServiceAbstraction } from "@bitwarden/common/autofill/services/autofill-settings.service"; +import { InlineMenuVisibilitySetting } from "@bitwarden/common/autofill/types"; import { EventType } from "@bitwarden/common/enums"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; @@ -20,7 +21,6 @@ import { AutofillPort } from "../enums/autofill-port.enums"; import AutofillField from "../models/autofill-field"; import AutofillPageDetails from "../models/autofill-page-details"; import AutofillScript from "../models/autofill-script"; -import { InlineMenuVisibilitySetting } from "../utils/autofill-overlay.enum"; import { AutoFillOptions, diff --git a/apps/browser/src/autofill/services/insert-autofill-content.service.spec.ts b/apps/browser/src/autofill/services/insert-autofill-content.service.spec.ts index b137d2cd7c..c63d25c364 100644 --- a/apps/browser/src/autofill/services/insert-autofill-content.service.spec.ts +++ b/apps/browser/src/autofill/services/insert-autofill-content.service.spec.ts @@ -1,4 +1,5 @@ -import { EVENTS } from "../constants"; +import { EVENTS } from "@bitwarden/common/autofill/constants"; + import AutofillScript, { FillScript, FillScriptActions } from "../models/autofill-script"; import { FillableFormFieldElement, FormElementWithAttribute, FormFieldElement } from "../types"; diff --git a/apps/browser/src/autofill/services/insert-autofill-content.service.ts b/apps/browser/src/autofill/services/insert-autofill-content.service.ts index 32cf76f1a3..c5b763d77d 100644 --- a/apps/browser/src/autofill/services/insert-autofill-content.service.ts +++ b/apps/browser/src/autofill/services/insert-autofill-content.service.ts @@ -1,4 +1,5 @@ -import { EVENTS, TYPE_CHECK } from "../constants"; +import { EVENTS, TYPE_CHECK } from "@bitwarden/common/autofill/constants"; + import AutofillScript, { AutofillInsertActions, FillScript } from "../models/autofill-script"; import { FormFieldElement } from "../types"; import { diff --git a/apps/browser/src/autofill/utils/autofill-overlay.enum.ts b/apps/browser/src/autofill/utils/autofill-overlay.enum.ts index 92723f01f9..486d68f754 100644 --- a/apps/browser/src/autofill/utils/autofill-overlay.enum.ts +++ b/apps/browser/src/autofill/utils/autofill-overlay.enum.ts @@ -14,19 +14,4 @@ const RedirectFocusDirection = { Next: "next", } as const; -const AutofillOverlayVisibility = { - Off: 0, - OnButtonClick: 1, - OnFieldFocus: 2, -} as const; - -type InlineMenuVisibilitySetting = - (typeof AutofillOverlayVisibility)[keyof typeof AutofillOverlayVisibility]; - -export { - AutofillOverlayElement, - AutofillOverlayPort, - RedirectFocusDirection, - AutofillOverlayVisibility, - InlineMenuVisibilitySetting, -}; +export { AutofillOverlayElement, AutofillOverlayPort, RedirectFocusDirection }; diff --git a/apps/browser/src/background/runtime.background.ts b/apps/browser/src/background/runtime.background.ts index fd735966fb..88d0e3f90a 100644 --- a/apps/browser/src/background/runtime.background.ts +++ b/apps/browser/src/background/runtime.background.ts @@ -1,4 +1,5 @@ import { NotificationsService } from "@bitwarden/common/abstractions/notifications.service"; +import { AutofillOverlayVisibility } from "@bitwarden/common/autofill/constants"; import { AutofillSettingsServiceAbstraction } from "@bitwarden/common/autofill/services/autofill-settings.service"; import { ConfigServiceAbstraction } from "@bitwarden/common/platform/abstractions/config/config.service.abstraction"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; @@ -15,7 +16,6 @@ import { } from "../auth/popup/utils/auth-popout-window"; import { LockedVaultPendingNotificationsData } from "../autofill/background/abstractions/notification.background"; import { AutofillService } from "../autofill/services/abstractions/autofill.service"; -import { AutofillOverlayVisibility } from "../autofill/utils/autofill-overlay.enum"; import { BrowserApi } from "../platform/browser/browser-api"; import { BrowserStateService } from "../platform/services/abstractions/browser-state.service"; import { BrowserEnvironmentService } from "../platform/services/browser-environment.service"; diff --git a/apps/browser/src/popup/settings/options.component.ts b/apps/browser/src/popup/settings/options.component.ts index d798714b5f..ac416a3493 100644 --- a/apps/browser/src/popup/settings/options.component.ts +++ b/apps/browser/src/popup/settings/options.component.ts @@ -6,6 +6,7 @@ import { SettingsService } from "@bitwarden/common/abstractions/settings.service import { AutofillSettingsServiceAbstraction } from "@bitwarden/common/autofill/services/autofill-settings.service"; import { BadgeSettingsServiceAbstraction } from "@bitwarden/common/autofill/services/badge-settings.service"; import { UserNotificationSettingsServiceAbstraction } from "@bitwarden/common/autofill/services/user-notification-settings.service"; +import { ClearClipboardDelaySetting } from "@bitwarden/common/autofill/types"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service"; import { StateService } from "@bitwarden/common/platform/abstractions/state.service"; @@ -13,7 +14,6 @@ import { ThemeType } from "@bitwarden/common/platform/enums"; import { VaultSettingsService } from "@bitwarden/common/vault/abstractions/vault-settings/vault-settings.service"; import { UriMatchType } from "@bitwarden/common/vault/enums"; -import { ClearClipboardDelaySetting } from "../../../../../apps/browser/src/autofill/constants"; import { enableAccountSwitching } from "../../platform/flags"; @Component({ diff --git a/apps/browser/src/vault/popup/components/vault/current-tab.component.ts b/apps/browser/src/vault/popup/components/vault/current-tab.component.ts index 5bf770a218..d1fcb5d439 100644 --- a/apps/browser/src/vault/popup/components/vault/current-tab.component.ts +++ b/apps/browser/src/vault/popup/components/vault/current-tab.component.ts @@ -5,6 +5,7 @@ import { debounceTime, takeUntil } from "rxjs/operators"; import { SearchService } from "@bitwarden/common/abstractions/search.service"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; +import { AutofillOverlayVisibility } from "@bitwarden/common/autofill/constants"; import { AutofillSettingsServiceAbstraction } from "@bitwarden/common/autofill/services/autofill-settings.service"; import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; @@ -19,7 +20,6 @@ import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { PasswordRepromptService } from "@bitwarden/vault"; import { AutofillService } from "../../../../autofill/services/abstractions/autofill.service"; -import { AutofillOverlayVisibility } from "../../../../autofill/utils/autofill-overlay.enum"; import { BrowserApi } from "../../../../platform/browser/browser-api"; import BrowserPopupUtils from "../../../../platform/popup/browser-popup-utils"; import { VaultFilterService } from "../../../services/vault-filter.service"; @@ -123,15 +123,32 @@ export class CurrentTabComponent implements OnInit, OnDestroy { .pipe(debounceTime(500), takeUntil(this.destroy$)) .subscribe(() => this.searchVault()); - // activate autofill on page load if policy is set - if (await this.getActivateAutofillOnPageLoadFromPolicy()) { + const autofillOnPageLoadOrgPolicy = await firstValueFrom( + this.autofillSettingsService.activateAutofillOnPageLoadFromPolicy$, + ); + const autofillOnPageLoadPolicyToastHasDisplayed = await firstValueFrom( + this.autofillSettingsService.autofillOnPageLoadPolicyToastHasDisplayed$, + ); + + // If the org "autofill on page load" policy is set, set the user setting to match it + // @TODO override user setting instead of overwriting + if (autofillOnPageLoadOrgPolicy === true) { await this.autofillSettingsService.setAutofillOnPageLoad(true); - await this.autofillSettingsService.setActivateAutofillOnPageLoadFromPolicy(false); - this.platformUtilsService.showToast( - "info", - null, - this.i18nService.t("autofillPageLoadPolicyActivated"), - ); + + if (!autofillOnPageLoadPolicyToastHasDisplayed) { + this.platformUtilsService.showToast( + "info", + null, + this.i18nService.t("autofillPageLoadPolicyActivated"), + ); + + await this.autofillSettingsService.setAutofillOnPageLoadPolicyToastHasDisplayed(true); + } + } + + // If the org policy is ever disabled after being enabled, reset the toast notification + if (!autofillOnPageLoadOrgPolicy && autofillOnPageLoadPolicyToastHasDisplayed) { + await this.autofillSettingsService.setAutofillOnPageLoadPolicyToastHasDisplayed(false); } } @@ -303,10 +320,6 @@ export class CurrentTabComponent implements OnInit, OnDestroy { this.router.navigate(["autofill"]); } - private async getActivateAutofillOnPageLoadFromPolicy(): Promise { - return await firstValueFrom(this.autofillSettingsService.activateAutofillOnPageLoadFromPolicy$); - } - async dismissCallout() { await this.autofillSettingsService.setAutofillOnPageLoadCalloutIsDismissed(true); this.showHowToAutofill = false; diff --git a/apps/browser/tsconfig.json b/apps/browser/tsconfig.json index 442e153ef2..a4176be0b0 100644 --- a/apps/browser/tsconfig.json +++ b/apps/browser/tsconfig.json @@ -31,5 +31,9 @@ "strictTemplates": true, "preserveWhitespaces": true }, - "include": ["src", "../../libs/common/src/platform/services/**/*.worker.ts"] + "include": [ + "src", + "../../libs/common/src/platform/services/**/*.worker.ts", + "../../libs/common/src/autofill/constants" + ] } diff --git a/apps/browser/src/autofill/constants.ts b/libs/common/src/autofill/constants/index.ts similarity index 93% rename from apps/browser/src/autofill/constants.ts rename to libs/common/src/autofill/constants/index.ts index da4bae0183..6d5af41a17 100644 --- a/apps/browser/src/autofill/constants.ts +++ b/libs/common/src/autofill/constants/index.ts @@ -32,9 +32,6 @@ export const ClearClipboardDelay = { FiveMinutes: 300, } as const; -export type ClearClipboardDelaySetting = - (typeof ClearClipboardDelay)[keyof typeof ClearClipboardDelay]; - /* Context Menu item Ids */ export const AUTOFILL_CARD_ID = "autofill-card"; export const AUTOFILL_ID = "autofill"; @@ -53,3 +50,9 @@ export const ROOT_ID = "root"; export const SEPARATOR_ID = "separator"; export const NOTIFICATION_BAR_LIFESPAN_MS = 150000; // 150 seconds + +export const AutofillOverlayVisibility = { + Off: 0, + OnButtonClick: 1, + OnFieldFocus: 2, +} as const; diff --git a/libs/common/src/autofill/services/autofill-settings.service.ts b/libs/common/src/autofill/services/autofill-settings.service.ts index 7311617957..7a06eed6fa 100644 --- a/libs/common/src/autofill/services/autofill-settings.service.ts +++ b/libs/common/src/autofill/services/autofill-settings.service.ts @@ -1,16 +1,7 @@ -import { filter, switchMap, tap, firstValueFrom, map, Observable } from "rxjs"; +import { map, Observable } from "rxjs"; -import { - ClearClipboardDelaySetting, - ClearClipboardDelay, -} from "../../../../../apps/browser/src/autofill/constants"; -import { - AutofillOverlayVisibility, - InlineMenuVisibilitySetting, -} from "../../../../../apps/browser/src/autofill/utils/autofill-overlay.enum"; import { PolicyService } from "../../admin-console/abstractions/policy/policy.service.abstraction"; -import { PolicyType } from "../../admin-console/enums/index"; -import { Policy } from "../../admin-console/models/domain/policy"; +import { PolicyType } from "../../admin-console/enums"; import { AUTOFILL_SETTINGS_DISK, AUTOFILL_SETTINGS_DISK_LOCAL, @@ -19,6 +10,8 @@ import { KeyDefinition, StateProvider, } from "../../platform/state"; +import { ClearClipboardDelay, AutofillOverlayVisibility } from "../constants"; +import { ClearClipboardDelaySetting, InlineMenuVisibilitySetting } from "../types"; const AUTOFILL_ON_PAGE_LOAD = new KeyDefinition(AUTOFILL_SETTINGS_DISK, "autofillOnPageLoad", { deserializer: (value: boolean) => value ?? false, @@ -32,10 +25,6 @@ const AUTOFILL_ON_PAGE_LOAD_DEFAULT = new KeyDefinition( }, ); -const AUTO_COPY_TOTP = new KeyDefinition(AUTOFILL_SETTINGS_DISK, "autoCopyTotp", { - deserializer: (value: boolean) => value ?? false, -}); - const AUTOFILL_ON_PAGE_LOAD_CALLOUT_DISMISSED = new KeyDefinition( AUTOFILL_SETTINGS_DISK, "autofillOnPageLoadCalloutIsDismissed", @@ -44,14 +33,18 @@ const AUTOFILL_ON_PAGE_LOAD_CALLOUT_DISMISSED = new KeyDefinition( }, ); -const ACTIVATE_AUTOFILL_ON_PAGE_LOAD_FROM_POLICY = new KeyDefinition( - AUTOFILL_SETTINGS_DISK_LOCAL, - "activateAutofillOnPageLoadFromPolicy", +const AUTOFILL_ON_PAGE_LOAD_POLICY_TOAST_HAS_DISPLAYED = new KeyDefinition( + AUTOFILL_SETTINGS_DISK, + "autofillOnPageLoadPolicyToastHasDisplayed", { deserializer: (value: boolean) => value ?? false, }, ); +const AUTO_COPY_TOTP = new KeyDefinition(AUTOFILL_SETTINGS_DISK, "autoCopyTotp", { + deserializer: (value: boolean) => value ?? false, +}); + const INLINE_MENU_VISIBILITY = new KeyDefinition( AUTOFILL_SETTINGS_DISK_LOCAL, "inlineMenuVisibility", @@ -73,17 +66,17 @@ export abstract class AutofillSettingsServiceAbstraction { setAutofillOnPageLoad: (newValue: boolean) => Promise; autofillOnPageLoadDefault$: Observable; setAutofillOnPageLoadDefault: (newValue: boolean) => Promise; - autoCopyTotp$: Observable; - setAutoCopyTotp: (newValue: boolean) => Promise; autofillOnPageLoadCalloutIsDismissed$: Observable; setAutofillOnPageLoadCalloutIsDismissed: (newValue: boolean) => Promise; activateAutofillOnPageLoadFromPolicy$: Observable; - setActivateAutofillOnPageLoadFromPolicy: (newValue: boolean) => Promise; + setAutofillOnPageLoadPolicyToastHasDisplayed: (newValue: boolean) => Promise; + autofillOnPageLoadPolicyToastHasDisplayed$: Observable; + autoCopyTotp$: Observable; + setAutoCopyTotp: (newValue: boolean) => Promise; inlineMenuVisibility$: Observable; setInlineMenuVisibility: (newValue: InlineMenuVisibilitySetting) => Promise; clearClipboardDelay$: Observable; setClearClipboardDelay: (newValue: ClearClipboardDelaySetting) => Promise; - handleActivateAutofillPolicy: (policies: Observable) => Observable; } export class AutofillSettingsService implements AutofillSettingsServiceAbstraction { @@ -93,15 +86,17 @@ export class AutofillSettingsService implements AutofillSettingsServiceAbstracti private autofillOnPageLoadDefaultState: ActiveUserState; readonly autofillOnPageLoadDefault$: Observable; - private autoCopyTotpState: ActiveUserState; - readonly autoCopyTotp$: Observable; - private autofillOnPageLoadCalloutIsDismissedState: ActiveUserState; readonly autofillOnPageLoadCalloutIsDismissed$: Observable; - private activateAutofillOnPageLoadFromPolicyState: ActiveUserState; readonly activateAutofillOnPageLoadFromPolicy$: Observable; + private autofillOnPageLoadPolicyToastHasDisplayedState: ActiveUserState; + readonly autofillOnPageLoadPolicyToastHasDisplayed$: Observable; + + private autoCopyTotpState: ActiveUserState; + readonly autoCopyTotp$: Observable; + private inlineMenuVisibilityState: GlobalState; readonly inlineMenuVisibility$: Observable; @@ -110,7 +105,7 @@ export class AutofillSettingsService implements AutofillSettingsServiceAbstracti constructor( private stateProvider: StateProvider, - policyService: PolicyService, + private policyService: PolicyService, ) { this.autofillOnPageLoadState = this.stateProvider.getActive(AUTOFILL_ON_PAGE_LOAD); this.autofillOnPageLoad$ = this.autofillOnPageLoadState.state$.pipe(map((x) => x ?? false)); @@ -122,20 +117,25 @@ export class AutofillSettingsService implements AutofillSettingsServiceAbstracti map((x) => x ?? true), ); - this.autoCopyTotpState = this.stateProvider.getActive(AUTO_COPY_TOTP); - this.autoCopyTotp$ = this.autoCopyTotpState.state$.pipe(map((x) => x ?? false)); - this.autofillOnPageLoadCalloutIsDismissedState = this.stateProvider.getActive( AUTOFILL_ON_PAGE_LOAD_CALLOUT_DISMISSED, ); this.autofillOnPageLoadCalloutIsDismissed$ = this.autofillOnPageLoadCalloutIsDismissedState.state$.pipe(map((x) => x ?? false)); - this.activateAutofillOnPageLoadFromPolicyState = this.stateProvider.getActive( - ACTIVATE_AUTOFILL_ON_PAGE_LOAD_FROM_POLICY, + this.activateAutofillOnPageLoadFromPolicy$ = this.policyService.policyAppliesToActiveUser$( + PolicyType.ActivateAutofill, ); - this.activateAutofillOnPageLoadFromPolicy$ = - this.activateAutofillOnPageLoadFromPolicyState.state$.pipe(map((x) => x ?? false)); + + this.autofillOnPageLoadPolicyToastHasDisplayedState = this.stateProvider.getActive( + AUTOFILL_ON_PAGE_LOAD_POLICY_TOAST_HAS_DISPLAYED, + ); + this.autofillOnPageLoadPolicyToastHasDisplayed$ = this.autofillOnPageLoadState.state$.pipe( + map((x) => x ?? false), + ); + + this.autoCopyTotpState = this.stateProvider.getActive(AUTO_COPY_TOTP); + this.autoCopyTotp$ = this.autoCopyTotpState.state$.pipe(map((x) => x ?? false)); this.inlineMenuVisibilityState = this.stateProvider.getGlobal(INLINE_MENU_VISIBILITY); this.inlineMenuVisibility$ = this.inlineMenuVisibilityState.state$.pipe( @@ -146,8 +146,6 @@ export class AutofillSettingsService implements AutofillSettingsServiceAbstracti this.clearClipboardDelay$ = this.clearClipboardDelayState.state$.pipe( map((x) => x ?? ClearClipboardDelay.Never), ); - - policyService.policies$.pipe(this.handleActivateAutofillPolicy.bind(this)).subscribe(); } async setAutofillOnPageLoad(newValue: boolean): Promise { @@ -158,16 +156,16 @@ export class AutofillSettingsService implements AutofillSettingsServiceAbstracti await this.autofillOnPageLoadDefaultState.update(() => newValue); } - async setAutoCopyTotp(newValue: boolean): Promise { - await this.autoCopyTotpState.update(() => newValue); - } - async setAutofillOnPageLoadCalloutIsDismissed(newValue: boolean): Promise { await this.autofillOnPageLoadCalloutIsDismissedState.update(() => newValue); } - async setActivateAutofillOnPageLoadFromPolicy(newValue: boolean): Promise { - await this.activateAutofillOnPageLoadFromPolicyState.update(() => newValue); + async setAutofillOnPageLoadPolicyToastHasDisplayed(newValue: boolean): Promise { + await this.autofillOnPageLoadPolicyToastHasDisplayedState.update(() => newValue); + } + + async setAutoCopyTotp(newValue: boolean): Promise { + await this.autoCopyTotpState.update(() => newValue); } async setInlineMenuVisibility(newValue: InlineMenuVisibilitySetting): Promise { @@ -177,24 +175,4 @@ export class AutofillSettingsService implements AutofillSettingsServiceAbstracti async setClearClipboardDelay(newValue: ClearClipboardDelaySetting): Promise { await this.clearClipboardDelayState.update(() => newValue); } - - /** - * If the ActivateAutofill policy is enabled, save a flag indicating if we need to - * enable Autofill on page load. - */ - handleActivateAutofillPolicy(policies$: Observable): Observable { - return policies$.pipe( - map((policies) => policies.find((p) => p.type == PolicyType.ActivateAutofill && p.enabled)), - filter((p) => p != null), - switchMap(async (_) => [ - await firstValueFrom(this.activateAutofillOnPageLoadFromPolicy$), - await firstValueFrom(this.autofillOnPageLoad$), - ]), - tap(([activated, autofillEnabled]) => { - if (activated === undefined) { - void this.setActivateAutofillOnPageLoadFromPolicy(!autofillEnabled); - } - }), - ); - } } diff --git a/libs/common/src/autofill/types/index.ts b/libs/common/src/autofill/types/index.ts new file mode 100644 index 0000000000..be5d98f4e0 --- /dev/null +++ b/libs/common/src/autofill/types/index.ts @@ -0,0 +1,7 @@ +import { ClearClipboardDelay, AutofillOverlayVisibility } from "../constants"; + +export type ClearClipboardDelaySetting = + (typeof ClearClipboardDelay)[keyof typeof ClearClipboardDelay]; + +export type InlineMenuVisibilitySetting = + (typeof AutofillOverlayVisibility)[keyof typeof AutofillOverlayVisibility]; diff --git a/libs/common/src/state-migrations/migrations/18-move-autofill-settings-to-state-providers.ts b/libs/common/src/state-migrations/migrations/18-move-autofill-settings-to-state-providers.ts index bbd09ae83d..b70e89f9c0 100644 --- a/libs/common/src/state-migrations/migrations/18-move-autofill-settings-to-state-providers.ts +++ b/libs/common/src/state-migrations/migrations/18-move-autofill-settings-to-state-providers.ts @@ -1,7 +1,15 @@ -import { InlineMenuVisibilitySetting } from "../../../../../apps/browser/src/autofill/utils/autofill-overlay.enum"; import { StateDefinitionLike, MigrationHelper } from "../migration-helper"; import { Migrator } from "../migrator"; +const AutofillOverlayVisibility = { + Off: 0, + OnButtonClick: 1, + OnFieldFocus: 2, +} as const; + +type InlineMenuVisibilitySetting = + (typeof AutofillOverlayVisibility)[keyof typeof AutofillOverlayVisibility]; + type ExpectedAccountState = { settings?: { autoFillOnPageLoadDefault?: boolean; diff --git a/libs/common/src/state-migrations/migrations/25-move-clear-clipboard-to-autofill-settings-state-provider.ts b/libs/common/src/state-migrations/migrations/25-move-clear-clipboard-to-autofill-settings-state-provider.ts index fde7ea9037..31c7bc25c7 100644 --- a/libs/common/src/state-migrations/migrations/25-move-clear-clipboard-to-autofill-settings-state-provider.ts +++ b/libs/common/src/state-migrations/migrations/25-move-clear-clipboard-to-autofill-settings-state-provider.ts @@ -1,7 +1,18 @@ -import { ClearClipboardDelaySetting } from "../../../../../apps/browser/src/autofill/constants"; import { StateDefinitionLike, MigrationHelper } from "../migration-helper"; import { Migrator } from "../migrator"; +const ClearClipboardDelay = { + Never: null as null, + TenSeconds: 10, + TwentySeconds: 20, + ThirtySeconds: 30, + OneMinute: 60, + TwoMinutes: 120, + FiveMinutes: 300, +} as const; + +type ClearClipboardDelaySetting = (typeof ClearClipboardDelay)[keyof typeof ClearClipboardDelay]; + type ExpectedAccountState = { settings?: { clearClipboard?: ClearClipboardDelaySetting;