2022-06-14 17:10:53 +02:00
|
|
|
import { NotificationsService } from "@bitwarden/common/abstractions/notifications.service";
|
[PM-3285] Autofill v2 Feature Branch (#5939)
* [PM-3285] Autofill v2 Feature Branch
* [PM-2130] - Audit, Modularize, and Refactor Core autofill.js File (#5453)
* split up autofill.ts, first pass
* remove modification tracking comments
* lessen and localize eslint disables
* additional typing and formatting
* update autofill v2 with PR #5364 changes (update/i18n confirm dialogs)
* update autofill v2 with PR #4155 changes (add autofill support for textarea)
Co-Authored-By: Manuel <mr-manuel@outlook.it>
* move commonly used string values to constants
* ts cleanup
* [PM-2130] Starting work to re-architect autofillv2.ts
* [PM-2130] Starting work to re-architect autofillv2.ts
* [PM-2130] Working through autofill collect method
* [PM-2130] Marking Removal of documentUUID as dead code
* [PM-2130] Refining the implementation of collect and moving broken out utils back into class implementation
* [PM-2130] Applying small refactors to AutofillCollect
* [PM-2130] Refining the implementation of getAutofillFieldLabelTag to help with readability of the method
* [PM-2130] Implementing jest tests for AutofillCollect methods
* [PM-2130] Refining implementation for AutofillCollect
* [PM-2200] Unit tests for autofill content script utilities with slight refactors (#5544)
* add unit tests for urlNotSecure
* add test coverage command
* add unit tests for canSeeElementToStyle
* canSeeElementToStyle should not return true if `animateTheFilling` or `currentEl` is false
* add tests for selectAllFromDoc and getElementByOpId
* clean up getElementByOpId
* address some typing issues
* add tests for setValueForElementByEvent, setValueForElement, and doSimpleSetByQuery
* clean up setValueForElement and setValueForElementByEvent
* more typescript cleanup
* add tests for doClickByOpId and touchAllPasswordFields
* add tests for doFocusByOpId and doClickByQuery
* misc fill cleanup
* move functions between collect and fill utils and replace getElementForOPID for duplicate getElementByOpId
* add tests for isKnownTag and isElementVisible
* rename addProp and remove redundant focusElement in favor of doFocusElement
* cleanup
* fix checkNodeType
* add tests for shiftForLeftLabel
* clean up and rename checkNodeType, isKnownTag, and shiftForLeftLabel
* add tests for getFormElements
* clean up getFormElements
* add tests for getElementAttrValue, getElementValue, getSelectElementOptions, getLabelTop, and queryDoc
* clean up and rename queryDoc to queryDocument
* misc cleanup and rename getElementAttrValue to getPropertyOrAttribute
* rebase cleanup
* prettier formatting
* [PM-2130] Fixing linting issues
* [PM-2130] Fixing linting issues
* [PM-2130] Migrating implementation for collect methods and tests for those methods into AutofillCollect context
* [PM-2130] Migrating getPropertyOrAttribute method from utils to AutofillCollect
* [PM-2130] Continuing migration of methods from collect utils into AutofillCollect
* [PM-2130] Rework of isViewable method to better handle behavior for how we identify if an element is currently within the viewport
* [PM-2130] Filling out implementation of autofill-insert
* [PM-2130] Refining AutofillInsert
* [PM-2130] Implementing jest tests for AutofillCollect methods and breaking out visibility related logic to a separate service
* [PM-2130] Fixing jest tests for AutofillCollect
* [PM-2130] Fixing jest tests for AutofillInit
* [PM-2130] Adjusting how the AutofillFieldVisibilityService class is used in AutofillCollect
* [PM-2130] Working through AutofillInsert implementation
* [PM-2130] Migrating methods from fill.ts to AutofillInsert
* [PM-2130] Migrating methods from fill.ts to AutofillInsert
* [PM-2130] Applying fix for IntersectionObserver when triggering behavior in Safari and fixing issue with how we trigger an input event shortly after filling in a field
* [PM-2130] Refactoring AutofillCollect to service CollectAutofillContentService
* [PM-2130] Refactoring AutofillInsert to service InsertAutofillContentService
* [PM-2130] Further organization of implementation
* [PM-2130] Filling out missing jest test for AutofillInit.fillForm method
* [PM-2130] Migrating the last of the collect jest tests to InsertAutofillContentService
* [PM-2130] Further refactoring of elements including typing information
* [PM-2130] Implementing jest tests for InsertAutofillContentService
* [PM-2130] Implementing jest tests for InsertAutofillContentService
* [PM-2130] Organization and refactoring of methods within InsertAutofillContent
* [PM-2130] Implementation of jest tests for InsertAutofillContentService
* [PM-2130] Implementation of Jest Test for IntertAutofillContentService
* [PM-2130] Finalizing migration of methods and jest tests from util files into Autofill serivces
* [PM-2130] Cleaning up dead code comments
* [PM-2130] Removing unnecessary constants
* [PM-2130] Finalizing jest tests for InsertAutofillContentService
* [PM-2130] Refactoring FieldVisibiltyService to DomElementVisibilityService to allow service to act in a more general manner
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Breaking out the callback method used to resolve the IntersectionObserver promise
* [PM-2130] Adding a comment explaining a fix for Safari
* [PM-2130] Adding a comment explaining a fix for Safari
* [PM-2130] Applying changes required for PM-2762 to implementation, and ensuring jest tests exist to validate the behavior
* [PM-2130] Removing usage of IntersectionObserver when identifying element visibility due to broken interactions with React Components
* [PM-2130] Fixing issue found when attempting to capture the elementAtCenterPoint in determining file visibility
* [PM-2100] Create Unit Test Suite for autofill.service.ts (#5371)
* [PM-2100] Create Unit Test Suite for Autofill.service.ts
* [PM-2100] Finishing out tests for the getFormsWithPasswordFields method
* [PM-2100] Implementing tests for the doAutofill method within the autofill service
* [PM-2100] Working through implementation of doAutofill method
* [PM-2100] Working through implementation of doAutofill method
* [PM-2100] Finishing implementatino of isUntrustedIframe method within autofill service
* [PM-2100] Finishing implementation of doAutoFill method within autofill service
* [PM-2100] Finishing implementation of doAutoFillOnTab method within autofill service
* [PM-2100] Working through tests for generateFillScript
* [PM-2100] Finalizing generateFillScript method testing
* [PM-2100] Starting implementation of generateLoginFillScript
* [PM-2100] Working through tests for generateLoginFillScript
* [PM-2100] Finalizing generateLoginFillScript method testing
* [PM-2100] Removing unnecessary jest config file
* [PM-2100] Fixing jest tests based on changes implemented within PM-2130
* [PM-2100] Fixing autofill mocks
* [PM-2100] Fixing AutofillService jest tests
* [PM-2100] Handling missing tests within coverage of AutofillService
* [PM-2100] Handling missing tests within coverage of AutofillService.generateLoginFillScript
* [PM-2100] Writing tests for AutofillService.generateCardFillScript
* [PM-2100] Finalizing tests for AutofillService.generateCardFillScript
* [PM-2100] Adding additional tests to cover changes introduced by TOTOP autofill PR
* [PM-2100] Adding jest tests for Autofill.generateIdentityFillScript
* [PM-2100] Finalizing tests for AutofillService.generateIdentityFillScript
* [PM-2100] Implementing tests for AutofillService
* [PM-2100] Implementing tests for AutofillService.loadPasswordFields
* [PM-2100] Implementing tests for AutofillService.findUsernameField
* [PM-2100] Implementing tests for AutofillService.findTotpField
* [PM-2100] Implementing tests for AutofillService.fieldPropertyIsPrefixMatch
* [PM-2100] Finalizing tests for AutofillService
* [PM-2100] Modyfing placement of autofill-mocks
* [PM-2100] Modyfing placement of autofill-mocks
* [PM-2100] Removal of jest transform declaration
* [PM-2130] Fixing issue with autofill service unit tests
* [PM-2130] Fixing issue with autofill service unit tests
* [PM-2130] Fixing test test for when we need to handle a password reprompt
---------
Co-authored-by: Manuel <mr-manuel@outlook.it>
Co-authored-by: Cesar Gonzalez <cgonzalez@bitwarden.com>
Co-authored-by: Cesar Gonzalez <cesar.a.gonzalezcs@gmail.com>
* [PM-3285] Migrating Changes from PM-1407 into autofill v2 refactor implementation
* [PM-2747] Add Support for Feature Flag of Autofill Version (#5695)
* [PM-2100] Create Unit Test Suite for Autofill.service.ts
* [PM-2100] Finishing out tests for the getFormsWithPasswordFields method
* [PM-2100] Implementing tests for the doAutofill method within the autofill service
* [PM-2100] Working through implementation of doAutofill method
* [PM-2100] Working through implementation of doAutofill method
* [PM-2100] Finishing implementatino of isUntrustedIframe method within autofill service
* [PM-2100] Finishing implementation of doAutoFill method within autofill service
* [PM-2100] Finishing implementation of doAutoFillOnTab method within autofill service
* [PM-2100] Working through tests for generateFillScript
* split up autofill.ts, first pass
* remove modification tracking comments
* lessen and localize eslint disables
* additional typing and formatting
* update autofill v2 with PR #5364 changes (update/i18n confirm dialogs)
* update autofill v2 with PR #4155 changes (add autofill support for textarea)
Co-Authored-By: Manuel <mr-manuel@outlook.it>
* move commonly used string values to constants
* ts cleanup
* [PM-2100] Finalizing generateFillScript method testing
* [PM-2100] Starting implementation of generateLoginFillScript
* [PM-2100] Working through tests for generateLoginFillScript
* [PM-2100] Finalizing generateLoginFillScript method testing
* [PM-2130] Starting work to re-architect autofillv2.ts
* [PM-2130] Starting work to re-architect autofillv2.ts
* [PM-2130] Working through autofill collect method
* [PM-2130] Marking Removal of documentUUID as dead code
* [PM-2130] Refining the implementation of collect and moving broken out utils back into class implementation
* [PM-2130] Applying small refactors to AutofillCollect
* [PM-2130] Refining the implementation of getAutofillFieldLabelTag to help with readability of the method
* [PM-2130] Implementing jest tests for AutofillCollect methods
* [PM-2130] Refining implementation for AutofillCollect
* [PM-2200] Unit tests for autofill content script utilities with slight refactors (#5544)
* add unit tests for urlNotSecure
* add test coverage command
* add unit tests for canSeeElementToStyle
* canSeeElementToStyle should not return true if `animateTheFilling` or `currentEl` is false
* add tests for selectAllFromDoc and getElementByOpId
* clean up getElementByOpId
* address some typing issues
* add tests for setValueForElementByEvent, setValueForElement, and doSimpleSetByQuery
* clean up setValueForElement and setValueForElementByEvent
* more typescript cleanup
* add tests for doClickByOpId and touchAllPasswordFields
* add tests for doFocusByOpId and doClickByQuery
* misc fill cleanup
* move functions between collect and fill utils and replace getElementForOPID for duplicate getElementByOpId
* add tests for isKnownTag and isElementVisible
* rename addProp and remove redundant focusElement in favor of doFocusElement
* cleanup
* fix checkNodeType
* add tests for shiftForLeftLabel
* clean up and rename checkNodeType, isKnownTag, and shiftForLeftLabel
* add tests for getFormElements
* clean up getFormElements
* add tests for getElementAttrValue, getElementValue, getSelectElementOptions, getLabelTop, and queryDoc
* clean up and rename queryDoc to queryDocument
* misc cleanup and rename getElementAttrValue to getPropertyOrAttribute
* rebase cleanup
* prettier formatting
* [PM-2130] Fixing linting issues
* [PM-2130] Fixing linting issues
* [PM-2130] Migrating implementation for collect methods and tests for those methods into AutofillCollect context
* [PM-2130] Migrating getPropertyOrAttribute method from utils to AutofillCollect
* [PM-2130] Continuing migration of methods from collect utils into AutofillCollect
* [PM-2130] Rework of isViewable method to better handle behavior for how we identify if an element is currently within the viewport
* [PM-2130] Filling out implementation of autofill-insert
* [PM-2130] Refining AutofillInsert
* [PM-2130] Implementing jest tests for AutofillCollect methods and breaking out visibility related logic to a separate service
* [PM-2130] Fixing jest tests for AutofillCollect
* [PM-2130] Fixing jest tests for AutofillInit
* [PM-2130] Adjusting how the AutofillFieldVisibilityService class is used in AutofillCollect
* [PM-2130] Working through AutofillInsert implementation
* [PM-2130] Migrating methods from fill.ts to AutofillInsert
* [PM-2130] Migrating methods from fill.ts to AutofillInsert
* [PM-2130] Applying fix for IntersectionObserver when triggering behavior in Safari and fixing issue with how we trigger an input event shortly after filling in a field
* [PM-2130] Refactoring AutofillCollect to service CollectAutofillContentService
* [PM-2130] Refactoring AutofillInsert to service InsertAutofillContentService
* [PM-2130] Further organization of implementation
* [PM-2130] Filling out missing jest test for AutofillInit.fillForm method
* [PM-2130] Migrating the last of the collect jest tests to InsertAutofillContentService
* [PM-2130] Further refactoring of elements including typing information
* [PM-2130] Implementing jest tests for InsertAutofillContentService
* [PM-2130] Implementing jest tests for InsertAutofillContentService
* [PM-2130] Organization and refactoring of methods within InsertAutofillContent
* [PM-2130] Implementation of jest tests for InsertAutofillContentService
* [PM-2130] Implementation of Jest Test for IntertAutofillContentService
* [PM-2130] Finalizing migration of methods and jest tests from util files into Autofill serivces
* [PM-2130] Cleaning up dead code comments
* [PM-2130] Removing unnecessary constants
* [PM-2130] Finalizing jest tests for InsertAutofillContentService
* [PM-2130] Refactoring FieldVisibiltyService to DomElementVisibilityService to allow service to act in a more general manner
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Breaking out the callback method used to resolve the IntersectionObserver promise
* [PM-2100] Removing unnecessary jest config file
* [PM-2100] Fixing jest tests based on changes implemented within PM-2130
* [PM-2100] Fixing autofill mocks
* [PM-2100] Fixing AutofillService jest tests
* [PM-2100] Handling missing tests within coverage of AutofillService
* [PM-2100] Handling missing tests within coverage of AutofillService.generateLoginFillScript
* [PM-2100] Writing tests for AutofillService.generateCardFillScript
* [PM-2100] Finalizing tests for AutofillService.generateCardFillScript
* [PM-2100] Adding additional tests to cover changes introduced by TOTOP autofill PR
* [PM-2100] Adding jest tests for Autofill.generateIdentityFillScript
* [PM-2100] Finalizing tests for AutofillService.generateIdentityFillScript
* [PM-2100] Implementing tests for AutofillService
* [PM-2130] Adding a comment explaining a fix for Safari
* [PM-2130] Adding a comment explaining a fix for Safari
* [PM-2100] Implementing tests for AutofillService.loadPasswordFields
* [PM-2100] Implementing tests for AutofillService.findUsernameField
* [PM-2100] Implementing tests for AutofillService.findTotpField
* [PM-2100] Implementing tests for AutofillService.fieldPropertyIsPrefixMatch
* [PM-2100] Finalizing tests for AutofillService
* [PM-2747] Add Support for Feature Flag of Autofill Version
* [PM-2747] Adding Support for Manifest v3 within the implementation
* [PM-2747] Modifying how the feature flag for autofill is named
* [PM-2747] Modifying main.background.ts to load the ConfigApiService correctly
* [PM-2747] Refactoring trigger of autofill scripts to be a simple immediately invoked function
* [PM-2100] Modyfing placement of autofill-mocks
* [PM-2100] Modyfing placement of autofill-mocks
* [PM-2100] Removal of jest transform declaration
* [PM-2130] Applying changes required for PM-2762 to implementation, and ensuring jest tests exist to validate the behavior
* [PM-2747] Modifying how we inject the autofill scripts to ensure we are injecting into all frames within a page
* [PM-2130] Removing usage of IntersectionObserver when identifying element visibility due to broken interactions with React Components
* [PM-2130] Fixing issue found when attempting to capture the elementAtCenterPoint in determining file visibility
* [PM-2100] Create Unit Test Suite for autofill.service.ts (#5371)
* [PM-2100] Create Unit Test Suite for Autofill.service.ts
* [PM-2100] Finishing out tests for the getFormsWithPasswordFields method
* [PM-2100] Implementing tests for the doAutofill method within the autofill service
* [PM-2100] Working through implementation of doAutofill method
* [PM-2100] Working through implementation of doAutofill method
* [PM-2100] Finishing implementatino of isUntrustedIframe method within autofill service
* [PM-2100] Finishing implementation of doAutoFill method within autofill service
* [PM-2100] Finishing implementation of doAutoFillOnTab method within autofill service
* [PM-2100] Working through tests for generateFillScript
* [PM-2100] Finalizing generateFillScript method testing
* [PM-2100] Starting implementation of generateLoginFillScript
* [PM-2100] Working through tests for generateLoginFillScript
* [PM-2100] Finalizing generateLoginFillScript method testing
* [PM-2100] Removing unnecessary jest config file
* [PM-2100] Fixing jest tests based on changes implemented within PM-2130
* [PM-2100] Fixing autofill mocks
* [PM-2100] Fixing AutofillService jest tests
* [PM-2100] Handling missing tests within coverage of AutofillService
* [PM-2100] Handling missing tests within coverage of AutofillService.generateLoginFillScript
* [PM-2100] Writing tests for AutofillService.generateCardFillScript
* [PM-2100] Finalizing tests for AutofillService.generateCardFillScript
* [PM-2100] Adding additional tests to cover changes introduced by TOTOP autofill PR
* [PM-2100] Adding jest tests for Autofill.generateIdentityFillScript
* [PM-2100] Finalizing tests for AutofillService.generateIdentityFillScript
* [PM-2100] Implementing tests for AutofillService
* [PM-2100] Implementing tests for AutofillService.loadPasswordFields
* [PM-2100] Implementing tests for AutofillService.findUsernameField
* [PM-2100] Implementing tests for AutofillService.findTotpField
* [PM-2100] Implementing tests for AutofillService.fieldPropertyIsPrefixMatch
* [PM-2100] Finalizing tests for AutofillService
* [PM-2100] Modyfing placement of autofill-mocks
* [PM-2100] Modyfing placement of autofill-mocks
* [PM-2100] Removal of jest transform declaration
* [PM-2747] Applying a fix for a race condition that can occur when loading the notification bar and autofiller script login
* [PM-2747] Reverting removal of autofill npm action. Now this will force usage of autofill-v2 regardless of whether a feature flag is set or not
* [PM-2747] Fixing logic error incorporated when merging in master
* [PM-2130] Fixing issue with autofill service unit tests
* [PM-2130] Fixing issue with autofill service unit tests
* [PM-2747] Fixing issue present with notification bar merge
* [PM-2130] Fixing test test for when we need to handle a password reprompt
* [PM-2747] Fixing wording for webpack script
* [PM-2747] Addressing stylistic changes requested from code review
* [PM-2747] Addressing stylistic changes requested from code review
---------
Co-authored-by: Jonathan Prusik <jprusik@classynemesis.com>
Co-authored-by: Manuel <mr-manuel@outlook.it>
Co-authored-by: Jonathan Prusik <jprusik@users.noreply.github.com>
* [PM-3285] Applying stylistic changes suggested by code review for the feature flag implementation
* [PM-3285] Adding temporary console log to validate which version is being used
* [PM-3285] Removing temporary console log indicating which version of autofill the user is currently loading
---------
Co-authored-by: Jonathan Prusik <jprusik@users.noreply.github.com>
Co-authored-by: Manuel <mr-manuel@outlook.it>
Co-authored-by: Jonathan Prusik <jprusik@classynemesis.com>
2023-09-07 22:33:04 +02:00
|
|
|
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
2023-06-06 22:34:53 +02:00
|
|
|
import { ConfigServiceAbstraction } from "@bitwarden/common/platform/abstractions/config/config.service.abstraction";
|
|
|
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
|
|
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
|
|
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
|
|
|
import { SystemService } from "@bitwarden/common/platform/abstractions/system.service";
|
|
|
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
2023-09-29 23:20:41 +02:00
|
|
|
import { CipherType } from "@bitwarden/common/vault/enums/cipher-type";
|
2021-10-21 11:10:46 +02:00
|
|
|
|
2023-01-31 22:08:37 +01:00
|
|
|
import { AutofillService } from "../autofill/services/abstractions/autofill.service";
|
2023-06-06 22:34:53 +02:00
|
|
|
import { BrowserApi } from "../platform/browser/browser-api";
|
2023-08-07 23:06:25 +02:00
|
|
|
import { BrowserPopoutWindowService } from "../platform/popup/abstractions/browser-popout-window.service";
|
2023-06-06 22:34:53 +02:00
|
|
|
import { BrowserEnvironmentService } from "../platform/services/browser-environment.service";
|
|
|
|
import BrowserPlatformUtilsService from "../platform/services/browser-platform-utils.service";
|
2017-12-07 21:36:24 +01:00
|
|
|
|
2017-12-07 21:06:37 +01:00
|
|
|
import MainBackground from "./main.background";
|
2021-10-19 11:20:55 +02:00
|
|
|
import LockedVaultPendingNotificationsItem from "./models/lockedVaultPendingNotificationsItem";
|
2021-10-18 16:41:42 +02:00
|
|
|
|
2017-12-07 21:06:37 +01:00
|
|
|
export default class RuntimeBackground {
|
2018-04-06 17:48:45 +02:00
|
|
|
private autofillTimeout: any;
|
2017-12-07 21:36:24 +01:00
|
|
|
private pageDetailsToAutoFill: any[] = [];
|
2018-01-18 05:21:17 +01:00
|
|
|
private onInstalledReason: string = null;
|
2021-10-19 11:20:55 +02:00
|
|
|
private lockedVaultPendingNotifications: LockedVaultPendingNotificationsItem[] = [];
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2017-12-07 21:36:24 +01:00
|
|
|
constructor(
|
|
|
|
private main: MainBackground,
|
|
|
|
private autofillService: AutofillService,
|
2021-10-15 15:03:25 +02:00
|
|
|
private platformUtilsService: BrowserPlatformUtilsService,
|
2018-08-20 23:40:39 +02:00
|
|
|
private i18nService: I18nService,
|
2021-10-15 15:03:25 +02:00
|
|
|
private notificationsService: NotificationsService,
|
|
|
|
private systemService: SystemService,
|
2022-08-08 13:40:09 +02:00
|
|
|
private environmentService: BrowserEnvironmentService,
|
2021-10-21 11:10:46 +02:00
|
|
|
private messagingService: MessagingService,
|
2023-04-26 16:30:39 +02:00
|
|
|
private logService: LogService,
|
2023-08-07 23:06:25 +02:00
|
|
|
private configService: ConfigServiceAbstraction,
|
|
|
|
private browserPopoutWindowService: BrowserPopoutWindowService
|
2021-10-21 11:10:46 +02:00
|
|
|
) {
|
2018-01-18 05:21:17 +01:00
|
|
|
// onInstalled listener must be wired up before anything else, so we do it in the ctor
|
2021-02-03 20:36:05 +01:00
|
|
|
chrome.runtime.onInstalled.addListener((details: any) => {
|
|
|
|
this.onInstalledReason = details.reason;
|
|
|
|
});
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
|
|
|
|
2017-12-07 21:06:37 +01:00
|
|
|
async init() {
|
2021-02-03 20:36:05 +01:00
|
|
|
if (!chrome.runtime) {
|
2021-12-21 15:43:35 +01:00
|
|
|
return;
|
2020-08-11 22:25:07 +02:00
|
|
|
}
|
|
|
|
|
2017-12-07 21:06:37 +01:00
|
|
|
await this.checkOnInstalled();
|
2022-02-15 23:06:35 +01:00
|
|
|
const backgroundMessageListener = async (
|
|
|
|
msg: any,
|
|
|
|
sender: chrome.runtime.MessageSender,
|
|
|
|
sendResponse: any
|
|
|
|
) => {
|
|
|
|
await this.processMessage(msg, sender, sendResponse);
|
|
|
|
};
|
|
|
|
|
|
|
|
BrowserApi.messageListener("runtime.background", backgroundMessageListener);
|
2022-10-19 15:55:57 +02:00
|
|
|
if (this.main.popupOnlyContext) {
|
2022-02-15 23:06:35 +01:00
|
|
|
(window as any).bitwardenBackgroundMessageListener = backgroundMessageListener;
|
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
|
|
|
|
2023-03-08 23:12:43 +01:00
|
|
|
async processMessage(msg: any, sender: chrome.runtime.MessageSender, sendResponse: any) {
|
2023-08-15 23:27:59 +02:00
|
|
|
const cipherId = msg.data?.cipherId;
|
|
|
|
|
2018-01-12 21:20:19 +01:00
|
|
|
switch (msg.command) {
|
|
|
|
case "loggedIn":
|
2022-02-24 18:14:04 +01:00
|
|
|
case "unlocked": {
|
2021-10-19 11:20:55 +02:00
|
|
|
let item: LockedVaultPendingNotificationsItem;
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2022-02-15 23:06:35 +01:00
|
|
|
if (this.lockedVaultPendingNotifications?.length > 0) {
|
2021-10-18 16:41:42 +02:00
|
|
|
item = this.lockedVaultPendingNotifications.pop();
|
2023-08-15 23:27:59 +02:00
|
|
|
await this.browserPopoutWindowService.closeUnlockPrompt();
|
2017-12-07 21:36:24 +01:00
|
|
|
}
|
|
|
|
|
2022-10-19 15:55:57 +02:00
|
|
|
await this.main.refreshBadge();
|
|
|
|
await this.main.refreshMenu(false);
|
2021-10-18 16:34:14 +02:00
|
|
|
this.notificationsService.updateConnection(msg.command === "unlocked");
|
|
|
|
this.systemService.cancelProcessReload();
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2021-10-18 16:34:14 +02:00
|
|
|
if (item) {
|
2023-05-15 18:42:01 +02:00
|
|
|
await BrowserApi.focusWindow(item.commandToRetry.sender.tab.windowId);
|
|
|
|
await BrowserApi.focusTab(item.commandToRetry.sender.tab.id);
|
2021-10-18 16:34:14 +02:00
|
|
|
await BrowserApi.tabSendMessageData(
|
|
|
|
item.commandToRetry.sender.tab,
|
|
|
|
"unlockCompleted",
|
2021-12-21 15:43:35 +01:00
|
|
|
item
|
|
|
|
);
|
|
|
|
}
|
|
|
|
break;
|
2022-02-24 18:14:04 +01:00
|
|
|
}
|
2021-10-18 16:34:14 +02:00
|
|
|
case "addToLockedVaultPendingNotifications":
|
2021-10-18 16:41:42 +02:00
|
|
|
this.lockedVaultPendingNotifications.push(msg.data);
|
2021-12-21 15:43:35 +01:00
|
|
|
break;
|
2021-10-18 16:34:14 +02:00
|
|
|
case "logout":
|
2022-01-27 22:22:51 +01:00
|
|
|
await this.main.logout(msg.expired, msg.userId);
|
2021-12-21 15:43:35 +01:00
|
|
|
break;
|
2021-10-18 16:34:14 +02:00
|
|
|
case "syncCompleted":
|
|
|
|
if (msg.successfully) {
|
2022-10-19 15:55:57 +02:00
|
|
|
setTimeout(async () => {
|
|
|
|
await this.main.refreshBadge();
|
|
|
|
await this.main.refreshMenu();
|
|
|
|
}, 2000);
|
2023-01-01 16:30:09 +01:00
|
|
|
this.main.avatarUpdateService.loadColorFromState();
|
2023-09-08 16:05:37 +02:00
|
|
|
this.configService.triggerServerConfigFetch();
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
|
|
|
break;
|
2018-01-18 22:17:58 +01:00
|
|
|
case "openPopup":
|
|
|
|
await this.main.openPopup();
|
2021-12-21 15:43:35 +01:00
|
|
|
break;
|
2021-10-08 15:23:37 +02:00
|
|
|
case "promptForLogin":
|
2023-08-07 23:06:25 +02:00
|
|
|
case "bgReopenPromptForLogin":
|
2023-08-15 23:27:59 +02:00
|
|
|
await this.browserPopoutWindowService.openUnlockPrompt(sender.tab?.windowId);
|
|
|
|
break;
|
|
|
|
case "passwordReprompt":
|
|
|
|
if (cipherId) {
|
|
|
|
await this.browserPopoutWindowService.openPasswordRepromptPrompt(sender.tab?.windowId, {
|
|
|
|
cipherId: cipherId,
|
|
|
|
senderTabId: sender.tab.id,
|
|
|
|
action: msg.data?.action,
|
|
|
|
});
|
|
|
|
}
|
2023-03-08 23:12:43 +01:00
|
|
|
break;
|
|
|
|
case "openAddEditCipher": {
|
2023-09-29 23:20:41 +02:00
|
|
|
const isNewCipher = !cipherId;
|
|
|
|
const cipherType = msg.data?.cipherType;
|
|
|
|
const senderTab = sender.tab;
|
|
|
|
|
|
|
|
if (!senderTab) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isNewCipher) {
|
|
|
|
await this.browserPopoutWindowService.openCipherCreation(senderTab.windowId, {
|
|
|
|
cipherType,
|
|
|
|
senderTabId: senderTab.id,
|
|
|
|
senderTabURI: senderTab.url,
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
await this.browserPopoutWindowService.openCipherEdit(senderTab.windowId, {
|
|
|
|
cipherId,
|
|
|
|
senderTabId: senderTab.id,
|
|
|
|
senderTabURI: senderTab.url,
|
|
|
|
});
|
|
|
|
}
|
2023-03-08 23:12:43 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case "closeTab":
|
|
|
|
setTimeout(() => {
|
|
|
|
BrowserApi.closeBitwardenExtensionTab();
|
|
|
|
}, msg.delay ?? 0);
|
2021-12-21 15:43:35 +01:00
|
|
|
break;
|
[PM-3285] Autofill v2 Feature Branch (#5939)
* [PM-3285] Autofill v2 Feature Branch
* [PM-2130] - Audit, Modularize, and Refactor Core autofill.js File (#5453)
* split up autofill.ts, first pass
* remove modification tracking comments
* lessen and localize eslint disables
* additional typing and formatting
* update autofill v2 with PR #5364 changes (update/i18n confirm dialogs)
* update autofill v2 with PR #4155 changes (add autofill support for textarea)
Co-Authored-By: Manuel <mr-manuel@outlook.it>
* move commonly used string values to constants
* ts cleanup
* [PM-2130] Starting work to re-architect autofillv2.ts
* [PM-2130] Starting work to re-architect autofillv2.ts
* [PM-2130] Working through autofill collect method
* [PM-2130] Marking Removal of documentUUID as dead code
* [PM-2130] Refining the implementation of collect and moving broken out utils back into class implementation
* [PM-2130] Applying small refactors to AutofillCollect
* [PM-2130] Refining the implementation of getAutofillFieldLabelTag to help with readability of the method
* [PM-2130] Implementing jest tests for AutofillCollect methods
* [PM-2130] Refining implementation for AutofillCollect
* [PM-2200] Unit tests for autofill content script utilities with slight refactors (#5544)
* add unit tests for urlNotSecure
* add test coverage command
* add unit tests for canSeeElementToStyle
* canSeeElementToStyle should not return true if `animateTheFilling` or `currentEl` is false
* add tests for selectAllFromDoc and getElementByOpId
* clean up getElementByOpId
* address some typing issues
* add tests for setValueForElementByEvent, setValueForElement, and doSimpleSetByQuery
* clean up setValueForElement and setValueForElementByEvent
* more typescript cleanup
* add tests for doClickByOpId and touchAllPasswordFields
* add tests for doFocusByOpId and doClickByQuery
* misc fill cleanup
* move functions between collect and fill utils and replace getElementForOPID for duplicate getElementByOpId
* add tests for isKnownTag and isElementVisible
* rename addProp and remove redundant focusElement in favor of doFocusElement
* cleanup
* fix checkNodeType
* add tests for shiftForLeftLabel
* clean up and rename checkNodeType, isKnownTag, and shiftForLeftLabel
* add tests for getFormElements
* clean up getFormElements
* add tests for getElementAttrValue, getElementValue, getSelectElementOptions, getLabelTop, and queryDoc
* clean up and rename queryDoc to queryDocument
* misc cleanup and rename getElementAttrValue to getPropertyOrAttribute
* rebase cleanup
* prettier formatting
* [PM-2130] Fixing linting issues
* [PM-2130] Fixing linting issues
* [PM-2130] Migrating implementation for collect methods and tests for those methods into AutofillCollect context
* [PM-2130] Migrating getPropertyOrAttribute method from utils to AutofillCollect
* [PM-2130] Continuing migration of methods from collect utils into AutofillCollect
* [PM-2130] Rework of isViewable method to better handle behavior for how we identify if an element is currently within the viewport
* [PM-2130] Filling out implementation of autofill-insert
* [PM-2130] Refining AutofillInsert
* [PM-2130] Implementing jest tests for AutofillCollect methods and breaking out visibility related logic to a separate service
* [PM-2130] Fixing jest tests for AutofillCollect
* [PM-2130] Fixing jest tests for AutofillInit
* [PM-2130] Adjusting how the AutofillFieldVisibilityService class is used in AutofillCollect
* [PM-2130] Working through AutofillInsert implementation
* [PM-2130] Migrating methods from fill.ts to AutofillInsert
* [PM-2130] Migrating methods from fill.ts to AutofillInsert
* [PM-2130] Applying fix for IntersectionObserver when triggering behavior in Safari and fixing issue with how we trigger an input event shortly after filling in a field
* [PM-2130] Refactoring AutofillCollect to service CollectAutofillContentService
* [PM-2130] Refactoring AutofillInsert to service InsertAutofillContentService
* [PM-2130] Further organization of implementation
* [PM-2130] Filling out missing jest test for AutofillInit.fillForm method
* [PM-2130] Migrating the last of the collect jest tests to InsertAutofillContentService
* [PM-2130] Further refactoring of elements including typing information
* [PM-2130] Implementing jest tests for InsertAutofillContentService
* [PM-2130] Implementing jest tests for InsertAutofillContentService
* [PM-2130] Organization and refactoring of methods within InsertAutofillContent
* [PM-2130] Implementation of jest tests for InsertAutofillContentService
* [PM-2130] Implementation of Jest Test for IntertAutofillContentService
* [PM-2130] Finalizing migration of methods and jest tests from util files into Autofill serivces
* [PM-2130] Cleaning up dead code comments
* [PM-2130] Removing unnecessary constants
* [PM-2130] Finalizing jest tests for InsertAutofillContentService
* [PM-2130] Refactoring FieldVisibiltyService to DomElementVisibilityService to allow service to act in a more general manner
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Breaking out the callback method used to resolve the IntersectionObserver promise
* [PM-2130] Adding a comment explaining a fix for Safari
* [PM-2130] Adding a comment explaining a fix for Safari
* [PM-2130] Applying changes required for PM-2762 to implementation, and ensuring jest tests exist to validate the behavior
* [PM-2130] Removing usage of IntersectionObserver when identifying element visibility due to broken interactions with React Components
* [PM-2130] Fixing issue found when attempting to capture the elementAtCenterPoint in determining file visibility
* [PM-2100] Create Unit Test Suite for autofill.service.ts (#5371)
* [PM-2100] Create Unit Test Suite for Autofill.service.ts
* [PM-2100] Finishing out tests for the getFormsWithPasswordFields method
* [PM-2100] Implementing tests for the doAutofill method within the autofill service
* [PM-2100] Working through implementation of doAutofill method
* [PM-2100] Working through implementation of doAutofill method
* [PM-2100] Finishing implementatino of isUntrustedIframe method within autofill service
* [PM-2100] Finishing implementation of doAutoFill method within autofill service
* [PM-2100] Finishing implementation of doAutoFillOnTab method within autofill service
* [PM-2100] Working through tests for generateFillScript
* [PM-2100] Finalizing generateFillScript method testing
* [PM-2100] Starting implementation of generateLoginFillScript
* [PM-2100] Working through tests for generateLoginFillScript
* [PM-2100] Finalizing generateLoginFillScript method testing
* [PM-2100] Removing unnecessary jest config file
* [PM-2100] Fixing jest tests based on changes implemented within PM-2130
* [PM-2100] Fixing autofill mocks
* [PM-2100] Fixing AutofillService jest tests
* [PM-2100] Handling missing tests within coverage of AutofillService
* [PM-2100] Handling missing tests within coverage of AutofillService.generateLoginFillScript
* [PM-2100] Writing tests for AutofillService.generateCardFillScript
* [PM-2100] Finalizing tests for AutofillService.generateCardFillScript
* [PM-2100] Adding additional tests to cover changes introduced by TOTOP autofill PR
* [PM-2100] Adding jest tests for Autofill.generateIdentityFillScript
* [PM-2100] Finalizing tests for AutofillService.generateIdentityFillScript
* [PM-2100] Implementing tests for AutofillService
* [PM-2100] Implementing tests for AutofillService.loadPasswordFields
* [PM-2100] Implementing tests for AutofillService.findUsernameField
* [PM-2100] Implementing tests for AutofillService.findTotpField
* [PM-2100] Implementing tests for AutofillService.fieldPropertyIsPrefixMatch
* [PM-2100] Finalizing tests for AutofillService
* [PM-2100] Modyfing placement of autofill-mocks
* [PM-2100] Modyfing placement of autofill-mocks
* [PM-2100] Removal of jest transform declaration
* [PM-2130] Fixing issue with autofill service unit tests
* [PM-2130] Fixing issue with autofill service unit tests
* [PM-2130] Fixing test test for when we need to handle a password reprompt
---------
Co-authored-by: Manuel <mr-manuel@outlook.it>
Co-authored-by: Cesar Gonzalez <cgonzalez@bitwarden.com>
Co-authored-by: Cesar Gonzalez <cesar.a.gonzalezcs@gmail.com>
* [PM-3285] Migrating Changes from PM-1407 into autofill v2 refactor implementation
* [PM-2747] Add Support for Feature Flag of Autofill Version (#5695)
* [PM-2100] Create Unit Test Suite for Autofill.service.ts
* [PM-2100] Finishing out tests for the getFormsWithPasswordFields method
* [PM-2100] Implementing tests for the doAutofill method within the autofill service
* [PM-2100] Working through implementation of doAutofill method
* [PM-2100] Working through implementation of doAutofill method
* [PM-2100] Finishing implementatino of isUntrustedIframe method within autofill service
* [PM-2100] Finishing implementation of doAutoFill method within autofill service
* [PM-2100] Finishing implementation of doAutoFillOnTab method within autofill service
* [PM-2100] Working through tests for generateFillScript
* split up autofill.ts, first pass
* remove modification tracking comments
* lessen and localize eslint disables
* additional typing and formatting
* update autofill v2 with PR #5364 changes (update/i18n confirm dialogs)
* update autofill v2 with PR #4155 changes (add autofill support for textarea)
Co-Authored-By: Manuel <mr-manuel@outlook.it>
* move commonly used string values to constants
* ts cleanup
* [PM-2100] Finalizing generateFillScript method testing
* [PM-2100] Starting implementation of generateLoginFillScript
* [PM-2100] Working through tests for generateLoginFillScript
* [PM-2100] Finalizing generateLoginFillScript method testing
* [PM-2130] Starting work to re-architect autofillv2.ts
* [PM-2130] Starting work to re-architect autofillv2.ts
* [PM-2130] Working through autofill collect method
* [PM-2130] Marking Removal of documentUUID as dead code
* [PM-2130] Refining the implementation of collect and moving broken out utils back into class implementation
* [PM-2130] Applying small refactors to AutofillCollect
* [PM-2130] Refining the implementation of getAutofillFieldLabelTag to help with readability of the method
* [PM-2130] Implementing jest tests for AutofillCollect methods
* [PM-2130] Refining implementation for AutofillCollect
* [PM-2200] Unit tests for autofill content script utilities with slight refactors (#5544)
* add unit tests for urlNotSecure
* add test coverage command
* add unit tests for canSeeElementToStyle
* canSeeElementToStyle should not return true if `animateTheFilling` or `currentEl` is false
* add tests for selectAllFromDoc and getElementByOpId
* clean up getElementByOpId
* address some typing issues
* add tests for setValueForElementByEvent, setValueForElement, and doSimpleSetByQuery
* clean up setValueForElement and setValueForElementByEvent
* more typescript cleanup
* add tests for doClickByOpId and touchAllPasswordFields
* add tests for doFocusByOpId and doClickByQuery
* misc fill cleanup
* move functions between collect and fill utils and replace getElementForOPID for duplicate getElementByOpId
* add tests for isKnownTag and isElementVisible
* rename addProp and remove redundant focusElement in favor of doFocusElement
* cleanup
* fix checkNodeType
* add tests for shiftForLeftLabel
* clean up and rename checkNodeType, isKnownTag, and shiftForLeftLabel
* add tests for getFormElements
* clean up getFormElements
* add tests for getElementAttrValue, getElementValue, getSelectElementOptions, getLabelTop, and queryDoc
* clean up and rename queryDoc to queryDocument
* misc cleanup and rename getElementAttrValue to getPropertyOrAttribute
* rebase cleanup
* prettier formatting
* [PM-2130] Fixing linting issues
* [PM-2130] Fixing linting issues
* [PM-2130] Migrating implementation for collect methods and tests for those methods into AutofillCollect context
* [PM-2130] Migrating getPropertyOrAttribute method from utils to AutofillCollect
* [PM-2130] Continuing migration of methods from collect utils into AutofillCollect
* [PM-2130] Rework of isViewable method to better handle behavior for how we identify if an element is currently within the viewport
* [PM-2130] Filling out implementation of autofill-insert
* [PM-2130] Refining AutofillInsert
* [PM-2130] Implementing jest tests for AutofillCollect methods and breaking out visibility related logic to a separate service
* [PM-2130] Fixing jest tests for AutofillCollect
* [PM-2130] Fixing jest tests for AutofillInit
* [PM-2130] Adjusting how the AutofillFieldVisibilityService class is used in AutofillCollect
* [PM-2130] Working through AutofillInsert implementation
* [PM-2130] Migrating methods from fill.ts to AutofillInsert
* [PM-2130] Migrating methods from fill.ts to AutofillInsert
* [PM-2130] Applying fix for IntersectionObserver when triggering behavior in Safari and fixing issue with how we trigger an input event shortly after filling in a field
* [PM-2130] Refactoring AutofillCollect to service CollectAutofillContentService
* [PM-2130] Refactoring AutofillInsert to service InsertAutofillContentService
* [PM-2130] Further organization of implementation
* [PM-2130] Filling out missing jest test for AutofillInit.fillForm method
* [PM-2130] Migrating the last of the collect jest tests to InsertAutofillContentService
* [PM-2130] Further refactoring of elements including typing information
* [PM-2130] Implementing jest tests for InsertAutofillContentService
* [PM-2130] Implementing jest tests for InsertAutofillContentService
* [PM-2130] Organization and refactoring of methods within InsertAutofillContent
* [PM-2130] Implementation of jest tests for InsertAutofillContentService
* [PM-2130] Implementation of Jest Test for IntertAutofillContentService
* [PM-2130] Finalizing migration of methods and jest tests from util files into Autofill serivces
* [PM-2130] Cleaning up dead code comments
* [PM-2130] Removing unnecessary constants
* [PM-2130] Finalizing jest tests for InsertAutofillContentService
* [PM-2130] Refactoring FieldVisibiltyService to DomElementVisibilityService to allow service to act in a more general manner
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Breaking out the callback method used to resolve the IntersectionObserver promise
* [PM-2100] Removing unnecessary jest config file
* [PM-2100] Fixing jest tests based on changes implemented within PM-2130
* [PM-2100] Fixing autofill mocks
* [PM-2100] Fixing AutofillService jest tests
* [PM-2100] Handling missing tests within coverage of AutofillService
* [PM-2100] Handling missing tests within coverage of AutofillService.generateLoginFillScript
* [PM-2100] Writing tests for AutofillService.generateCardFillScript
* [PM-2100] Finalizing tests for AutofillService.generateCardFillScript
* [PM-2100] Adding additional tests to cover changes introduced by TOTOP autofill PR
* [PM-2100] Adding jest tests for Autofill.generateIdentityFillScript
* [PM-2100] Finalizing tests for AutofillService.generateIdentityFillScript
* [PM-2100] Implementing tests for AutofillService
* [PM-2130] Adding a comment explaining a fix for Safari
* [PM-2130] Adding a comment explaining a fix for Safari
* [PM-2100] Implementing tests for AutofillService.loadPasswordFields
* [PM-2100] Implementing tests for AutofillService.findUsernameField
* [PM-2100] Implementing tests for AutofillService.findTotpField
* [PM-2100] Implementing tests for AutofillService.fieldPropertyIsPrefixMatch
* [PM-2100] Finalizing tests for AutofillService
* [PM-2747] Add Support for Feature Flag of Autofill Version
* [PM-2747] Adding Support for Manifest v3 within the implementation
* [PM-2747] Modifying how the feature flag for autofill is named
* [PM-2747] Modifying main.background.ts to load the ConfigApiService correctly
* [PM-2747] Refactoring trigger of autofill scripts to be a simple immediately invoked function
* [PM-2100] Modyfing placement of autofill-mocks
* [PM-2100] Modyfing placement of autofill-mocks
* [PM-2100] Removal of jest transform declaration
* [PM-2130] Applying changes required for PM-2762 to implementation, and ensuring jest tests exist to validate the behavior
* [PM-2747] Modifying how we inject the autofill scripts to ensure we are injecting into all frames within a page
* [PM-2130] Removing usage of IntersectionObserver when identifying element visibility due to broken interactions with React Components
* [PM-2130] Fixing issue found when attempting to capture the elementAtCenterPoint in determining file visibility
* [PM-2100] Create Unit Test Suite for autofill.service.ts (#5371)
* [PM-2100] Create Unit Test Suite for Autofill.service.ts
* [PM-2100] Finishing out tests for the getFormsWithPasswordFields method
* [PM-2100] Implementing tests for the doAutofill method within the autofill service
* [PM-2100] Working through implementation of doAutofill method
* [PM-2100] Working through implementation of doAutofill method
* [PM-2100] Finishing implementatino of isUntrustedIframe method within autofill service
* [PM-2100] Finishing implementation of doAutoFill method within autofill service
* [PM-2100] Finishing implementation of doAutoFillOnTab method within autofill service
* [PM-2100] Working through tests for generateFillScript
* [PM-2100] Finalizing generateFillScript method testing
* [PM-2100] Starting implementation of generateLoginFillScript
* [PM-2100] Working through tests for generateLoginFillScript
* [PM-2100] Finalizing generateLoginFillScript method testing
* [PM-2100] Removing unnecessary jest config file
* [PM-2100] Fixing jest tests based on changes implemented within PM-2130
* [PM-2100] Fixing autofill mocks
* [PM-2100] Fixing AutofillService jest tests
* [PM-2100] Handling missing tests within coverage of AutofillService
* [PM-2100] Handling missing tests within coverage of AutofillService.generateLoginFillScript
* [PM-2100] Writing tests for AutofillService.generateCardFillScript
* [PM-2100] Finalizing tests for AutofillService.generateCardFillScript
* [PM-2100] Adding additional tests to cover changes introduced by TOTOP autofill PR
* [PM-2100] Adding jest tests for Autofill.generateIdentityFillScript
* [PM-2100] Finalizing tests for AutofillService.generateIdentityFillScript
* [PM-2100] Implementing tests for AutofillService
* [PM-2100] Implementing tests for AutofillService.loadPasswordFields
* [PM-2100] Implementing tests for AutofillService.findUsernameField
* [PM-2100] Implementing tests for AutofillService.findTotpField
* [PM-2100] Implementing tests for AutofillService.fieldPropertyIsPrefixMatch
* [PM-2100] Finalizing tests for AutofillService
* [PM-2100] Modyfing placement of autofill-mocks
* [PM-2100] Modyfing placement of autofill-mocks
* [PM-2100] Removal of jest transform declaration
* [PM-2747] Applying a fix for a race condition that can occur when loading the notification bar and autofiller script login
* [PM-2747] Reverting removal of autofill npm action. Now this will force usage of autofill-v2 regardless of whether a feature flag is set or not
* [PM-2747] Fixing logic error incorporated when merging in master
* [PM-2130] Fixing issue with autofill service unit tests
* [PM-2130] Fixing issue with autofill service unit tests
* [PM-2747] Fixing issue present with notification bar merge
* [PM-2130] Fixing test test for when we need to handle a password reprompt
* [PM-2747] Fixing wording for webpack script
* [PM-2747] Addressing stylistic changes requested from code review
* [PM-2747] Addressing stylistic changes requested from code review
---------
Co-authored-by: Jonathan Prusik <jprusik@classynemesis.com>
Co-authored-by: Manuel <mr-manuel@outlook.it>
Co-authored-by: Jonathan Prusik <jprusik@users.noreply.github.com>
* [PM-3285] Applying stylistic changes suggested by code review for the feature flag implementation
* [PM-3285] Adding temporary console log to validate which version is being used
* [PM-3285] Removing temporary console log indicating which version of autofill the user is currently loading
---------
Co-authored-by: Jonathan Prusik <jprusik@users.noreply.github.com>
Co-authored-by: Manuel <mr-manuel@outlook.it>
Co-authored-by: Jonathan Prusik <jprusik@classynemesis.com>
2023-09-07 22:33:04 +02:00
|
|
|
case "triggerAutofillScriptInjection":
|
|
|
|
await this.autofillService.injectAutofillScripts(
|
|
|
|
sender,
|
2023-09-08 16:05:37 +02:00
|
|
|
await this.configService.getFeatureFlag<boolean>(FeatureFlag.AutofillV2)
|
[PM-3285] Autofill v2 Feature Branch (#5939)
* [PM-3285] Autofill v2 Feature Branch
* [PM-2130] - Audit, Modularize, and Refactor Core autofill.js File (#5453)
* split up autofill.ts, first pass
* remove modification tracking comments
* lessen and localize eslint disables
* additional typing and formatting
* update autofill v2 with PR #5364 changes (update/i18n confirm dialogs)
* update autofill v2 with PR #4155 changes (add autofill support for textarea)
Co-Authored-By: Manuel <mr-manuel@outlook.it>
* move commonly used string values to constants
* ts cleanup
* [PM-2130] Starting work to re-architect autofillv2.ts
* [PM-2130] Starting work to re-architect autofillv2.ts
* [PM-2130] Working through autofill collect method
* [PM-2130] Marking Removal of documentUUID as dead code
* [PM-2130] Refining the implementation of collect and moving broken out utils back into class implementation
* [PM-2130] Applying small refactors to AutofillCollect
* [PM-2130] Refining the implementation of getAutofillFieldLabelTag to help with readability of the method
* [PM-2130] Implementing jest tests for AutofillCollect methods
* [PM-2130] Refining implementation for AutofillCollect
* [PM-2200] Unit tests for autofill content script utilities with slight refactors (#5544)
* add unit tests for urlNotSecure
* add test coverage command
* add unit tests for canSeeElementToStyle
* canSeeElementToStyle should not return true if `animateTheFilling` or `currentEl` is false
* add tests for selectAllFromDoc and getElementByOpId
* clean up getElementByOpId
* address some typing issues
* add tests for setValueForElementByEvent, setValueForElement, and doSimpleSetByQuery
* clean up setValueForElement and setValueForElementByEvent
* more typescript cleanup
* add tests for doClickByOpId and touchAllPasswordFields
* add tests for doFocusByOpId and doClickByQuery
* misc fill cleanup
* move functions between collect and fill utils and replace getElementForOPID for duplicate getElementByOpId
* add tests for isKnownTag and isElementVisible
* rename addProp and remove redundant focusElement in favor of doFocusElement
* cleanup
* fix checkNodeType
* add tests for shiftForLeftLabel
* clean up and rename checkNodeType, isKnownTag, and shiftForLeftLabel
* add tests for getFormElements
* clean up getFormElements
* add tests for getElementAttrValue, getElementValue, getSelectElementOptions, getLabelTop, and queryDoc
* clean up and rename queryDoc to queryDocument
* misc cleanup and rename getElementAttrValue to getPropertyOrAttribute
* rebase cleanup
* prettier formatting
* [PM-2130] Fixing linting issues
* [PM-2130] Fixing linting issues
* [PM-2130] Migrating implementation for collect methods and tests for those methods into AutofillCollect context
* [PM-2130] Migrating getPropertyOrAttribute method from utils to AutofillCollect
* [PM-2130] Continuing migration of methods from collect utils into AutofillCollect
* [PM-2130] Rework of isViewable method to better handle behavior for how we identify if an element is currently within the viewport
* [PM-2130] Filling out implementation of autofill-insert
* [PM-2130] Refining AutofillInsert
* [PM-2130] Implementing jest tests for AutofillCollect methods and breaking out visibility related logic to a separate service
* [PM-2130] Fixing jest tests for AutofillCollect
* [PM-2130] Fixing jest tests for AutofillInit
* [PM-2130] Adjusting how the AutofillFieldVisibilityService class is used in AutofillCollect
* [PM-2130] Working through AutofillInsert implementation
* [PM-2130] Migrating methods from fill.ts to AutofillInsert
* [PM-2130] Migrating methods from fill.ts to AutofillInsert
* [PM-2130] Applying fix for IntersectionObserver when triggering behavior in Safari and fixing issue with how we trigger an input event shortly after filling in a field
* [PM-2130] Refactoring AutofillCollect to service CollectAutofillContentService
* [PM-2130] Refactoring AutofillInsert to service InsertAutofillContentService
* [PM-2130] Further organization of implementation
* [PM-2130] Filling out missing jest test for AutofillInit.fillForm method
* [PM-2130] Migrating the last of the collect jest tests to InsertAutofillContentService
* [PM-2130] Further refactoring of elements including typing information
* [PM-2130] Implementing jest tests for InsertAutofillContentService
* [PM-2130] Implementing jest tests for InsertAutofillContentService
* [PM-2130] Organization and refactoring of methods within InsertAutofillContent
* [PM-2130] Implementation of jest tests for InsertAutofillContentService
* [PM-2130] Implementation of Jest Test for IntertAutofillContentService
* [PM-2130] Finalizing migration of methods and jest tests from util files into Autofill serivces
* [PM-2130] Cleaning up dead code comments
* [PM-2130] Removing unnecessary constants
* [PM-2130] Finalizing jest tests for InsertAutofillContentService
* [PM-2130] Refactoring FieldVisibiltyService to DomElementVisibilityService to allow service to act in a more general manner
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Breaking out the callback method used to resolve the IntersectionObserver promise
* [PM-2130] Adding a comment explaining a fix for Safari
* [PM-2130] Adding a comment explaining a fix for Safari
* [PM-2130] Applying changes required for PM-2762 to implementation, and ensuring jest tests exist to validate the behavior
* [PM-2130] Removing usage of IntersectionObserver when identifying element visibility due to broken interactions with React Components
* [PM-2130] Fixing issue found when attempting to capture the elementAtCenterPoint in determining file visibility
* [PM-2100] Create Unit Test Suite for autofill.service.ts (#5371)
* [PM-2100] Create Unit Test Suite for Autofill.service.ts
* [PM-2100] Finishing out tests for the getFormsWithPasswordFields method
* [PM-2100] Implementing tests for the doAutofill method within the autofill service
* [PM-2100] Working through implementation of doAutofill method
* [PM-2100] Working through implementation of doAutofill method
* [PM-2100] Finishing implementatino of isUntrustedIframe method within autofill service
* [PM-2100] Finishing implementation of doAutoFill method within autofill service
* [PM-2100] Finishing implementation of doAutoFillOnTab method within autofill service
* [PM-2100] Working through tests for generateFillScript
* [PM-2100] Finalizing generateFillScript method testing
* [PM-2100] Starting implementation of generateLoginFillScript
* [PM-2100] Working through tests for generateLoginFillScript
* [PM-2100] Finalizing generateLoginFillScript method testing
* [PM-2100] Removing unnecessary jest config file
* [PM-2100] Fixing jest tests based on changes implemented within PM-2130
* [PM-2100] Fixing autofill mocks
* [PM-2100] Fixing AutofillService jest tests
* [PM-2100] Handling missing tests within coverage of AutofillService
* [PM-2100] Handling missing tests within coverage of AutofillService.generateLoginFillScript
* [PM-2100] Writing tests for AutofillService.generateCardFillScript
* [PM-2100] Finalizing tests for AutofillService.generateCardFillScript
* [PM-2100] Adding additional tests to cover changes introduced by TOTOP autofill PR
* [PM-2100] Adding jest tests for Autofill.generateIdentityFillScript
* [PM-2100] Finalizing tests for AutofillService.generateIdentityFillScript
* [PM-2100] Implementing tests for AutofillService
* [PM-2100] Implementing tests for AutofillService.loadPasswordFields
* [PM-2100] Implementing tests for AutofillService.findUsernameField
* [PM-2100] Implementing tests for AutofillService.findTotpField
* [PM-2100] Implementing tests for AutofillService.fieldPropertyIsPrefixMatch
* [PM-2100] Finalizing tests for AutofillService
* [PM-2100] Modyfing placement of autofill-mocks
* [PM-2100] Modyfing placement of autofill-mocks
* [PM-2100] Removal of jest transform declaration
* [PM-2130] Fixing issue with autofill service unit tests
* [PM-2130] Fixing issue with autofill service unit tests
* [PM-2130] Fixing test test for when we need to handle a password reprompt
---------
Co-authored-by: Manuel <mr-manuel@outlook.it>
Co-authored-by: Cesar Gonzalez <cgonzalez@bitwarden.com>
Co-authored-by: Cesar Gonzalez <cesar.a.gonzalezcs@gmail.com>
* [PM-3285] Migrating Changes from PM-1407 into autofill v2 refactor implementation
* [PM-2747] Add Support for Feature Flag of Autofill Version (#5695)
* [PM-2100] Create Unit Test Suite for Autofill.service.ts
* [PM-2100] Finishing out tests for the getFormsWithPasswordFields method
* [PM-2100] Implementing tests for the doAutofill method within the autofill service
* [PM-2100] Working through implementation of doAutofill method
* [PM-2100] Working through implementation of doAutofill method
* [PM-2100] Finishing implementatino of isUntrustedIframe method within autofill service
* [PM-2100] Finishing implementation of doAutoFill method within autofill service
* [PM-2100] Finishing implementation of doAutoFillOnTab method within autofill service
* [PM-2100] Working through tests for generateFillScript
* split up autofill.ts, first pass
* remove modification tracking comments
* lessen and localize eslint disables
* additional typing and formatting
* update autofill v2 with PR #5364 changes (update/i18n confirm dialogs)
* update autofill v2 with PR #4155 changes (add autofill support for textarea)
Co-Authored-By: Manuel <mr-manuel@outlook.it>
* move commonly used string values to constants
* ts cleanup
* [PM-2100] Finalizing generateFillScript method testing
* [PM-2100] Starting implementation of generateLoginFillScript
* [PM-2100] Working through tests for generateLoginFillScript
* [PM-2100] Finalizing generateLoginFillScript method testing
* [PM-2130] Starting work to re-architect autofillv2.ts
* [PM-2130] Starting work to re-architect autofillv2.ts
* [PM-2130] Working through autofill collect method
* [PM-2130] Marking Removal of documentUUID as dead code
* [PM-2130] Refining the implementation of collect and moving broken out utils back into class implementation
* [PM-2130] Applying small refactors to AutofillCollect
* [PM-2130] Refining the implementation of getAutofillFieldLabelTag to help with readability of the method
* [PM-2130] Implementing jest tests for AutofillCollect methods
* [PM-2130] Refining implementation for AutofillCollect
* [PM-2200] Unit tests for autofill content script utilities with slight refactors (#5544)
* add unit tests for urlNotSecure
* add test coverage command
* add unit tests for canSeeElementToStyle
* canSeeElementToStyle should not return true if `animateTheFilling` or `currentEl` is false
* add tests for selectAllFromDoc and getElementByOpId
* clean up getElementByOpId
* address some typing issues
* add tests for setValueForElementByEvent, setValueForElement, and doSimpleSetByQuery
* clean up setValueForElement and setValueForElementByEvent
* more typescript cleanup
* add tests for doClickByOpId and touchAllPasswordFields
* add tests for doFocusByOpId and doClickByQuery
* misc fill cleanup
* move functions between collect and fill utils and replace getElementForOPID for duplicate getElementByOpId
* add tests for isKnownTag and isElementVisible
* rename addProp and remove redundant focusElement in favor of doFocusElement
* cleanup
* fix checkNodeType
* add tests for shiftForLeftLabel
* clean up and rename checkNodeType, isKnownTag, and shiftForLeftLabel
* add tests for getFormElements
* clean up getFormElements
* add tests for getElementAttrValue, getElementValue, getSelectElementOptions, getLabelTop, and queryDoc
* clean up and rename queryDoc to queryDocument
* misc cleanup and rename getElementAttrValue to getPropertyOrAttribute
* rebase cleanup
* prettier formatting
* [PM-2130] Fixing linting issues
* [PM-2130] Fixing linting issues
* [PM-2130] Migrating implementation for collect methods and tests for those methods into AutofillCollect context
* [PM-2130] Migrating getPropertyOrAttribute method from utils to AutofillCollect
* [PM-2130] Continuing migration of methods from collect utils into AutofillCollect
* [PM-2130] Rework of isViewable method to better handle behavior for how we identify if an element is currently within the viewport
* [PM-2130] Filling out implementation of autofill-insert
* [PM-2130] Refining AutofillInsert
* [PM-2130] Implementing jest tests for AutofillCollect methods and breaking out visibility related logic to a separate service
* [PM-2130] Fixing jest tests for AutofillCollect
* [PM-2130] Fixing jest tests for AutofillInit
* [PM-2130] Adjusting how the AutofillFieldVisibilityService class is used in AutofillCollect
* [PM-2130] Working through AutofillInsert implementation
* [PM-2130] Migrating methods from fill.ts to AutofillInsert
* [PM-2130] Migrating methods from fill.ts to AutofillInsert
* [PM-2130] Applying fix for IntersectionObserver when triggering behavior in Safari and fixing issue with how we trigger an input event shortly after filling in a field
* [PM-2130] Refactoring AutofillCollect to service CollectAutofillContentService
* [PM-2130] Refactoring AutofillInsert to service InsertAutofillContentService
* [PM-2130] Further organization of implementation
* [PM-2130] Filling out missing jest test for AutofillInit.fillForm method
* [PM-2130] Migrating the last of the collect jest tests to InsertAutofillContentService
* [PM-2130] Further refactoring of elements including typing information
* [PM-2130] Implementing jest tests for InsertAutofillContentService
* [PM-2130] Implementing jest tests for InsertAutofillContentService
* [PM-2130] Organization and refactoring of methods within InsertAutofillContent
* [PM-2130] Implementation of jest tests for InsertAutofillContentService
* [PM-2130] Implementation of Jest Test for IntertAutofillContentService
* [PM-2130] Finalizing migration of methods and jest tests from util files into Autofill serivces
* [PM-2130] Cleaning up dead code comments
* [PM-2130] Removing unnecessary constants
* [PM-2130] Finalizing jest tests for InsertAutofillContentService
* [PM-2130] Refactoring FieldVisibiltyService to DomElementVisibilityService to allow service to act in a more general manner
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Implementing jest tests for DomElementVisibilityService
* [PM-2130] Breaking out the callback method used to resolve the IntersectionObserver promise
* [PM-2100] Removing unnecessary jest config file
* [PM-2100] Fixing jest tests based on changes implemented within PM-2130
* [PM-2100] Fixing autofill mocks
* [PM-2100] Fixing AutofillService jest tests
* [PM-2100] Handling missing tests within coverage of AutofillService
* [PM-2100] Handling missing tests within coverage of AutofillService.generateLoginFillScript
* [PM-2100] Writing tests for AutofillService.generateCardFillScript
* [PM-2100] Finalizing tests for AutofillService.generateCardFillScript
* [PM-2100] Adding additional tests to cover changes introduced by TOTOP autofill PR
* [PM-2100] Adding jest tests for Autofill.generateIdentityFillScript
* [PM-2100] Finalizing tests for AutofillService.generateIdentityFillScript
* [PM-2100] Implementing tests for AutofillService
* [PM-2130] Adding a comment explaining a fix for Safari
* [PM-2130] Adding a comment explaining a fix for Safari
* [PM-2100] Implementing tests for AutofillService.loadPasswordFields
* [PM-2100] Implementing tests for AutofillService.findUsernameField
* [PM-2100] Implementing tests for AutofillService.findTotpField
* [PM-2100] Implementing tests for AutofillService.fieldPropertyIsPrefixMatch
* [PM-2100] Finalizing tests for AutofillService
* [PM-2747] Add Support for Feature Flag of Autofill Version
* [PM-2747] Adding Support for Manifest v3 within the implementation
* [PM-2747] Modifying how the feature flag for autofill is named
* [PM-2747] Modifying main.background.ts to load the ConfigApiService correctly
* [PM-2747] Refactoring trigger of autofill scripts to be a simple immediately invoked function
* [PM-2100] Modyfing placement of autofill-mocks
* [PM-2100] Modyfing placement of autofill-mocks
* [PM-2100] Removal of jest transform declaration
* [PM-2130] Applying changes required for PM-2762 to implementation, and ensuring jest tests exist to validate the behavior
* [PM-2747] Modifying how we inject the autofill scripts to ensure we are injecting into all frames within a page
* [PM-2130] Removing usage of IntersectionObserver when identifying element visibility due to broken interactions with React Components
* [PM-2130] Fixing issue found when attempting to capture the elementAtCenterPoint in determining file visibility
* [PM-2100] Create Unit Test Suite for autofill.service.ts (#5371)
* [PM-2100] Create Unit Test Suite for Autofill.service.ts
* [PM-2100] Finishing out tests for the getFormsWithPasswordFields method
* [PM-2100] Implementing tests for the doAutofill method within the autofill service
* [PM-2100] Working through implementation of doAutofill method
* [PM-2100] Working through implementation of doAutofill method
* [PM-2100] Finishing implementatino of isUntrustedIframe method within autofill service
* [PM-2100] Finishing implementation of doAutoFill method within autofill service
* [PM-2100] Finishing implementation of doAutoFillOnTab method within autofill service
* [PM-2100] Working through tests for generateFillScript
* [PM-2100] Finalizing generateFillScript method testing
* [PM-2100] Starting implementation of generateLoginFillScript
* [PM-2100] Working through tests for generateLoginFillScript
* [PM-2100] Finalizing generateLoginFillScript method testing
* [PM-2100] Removing unnecessary jest config file
* [PM-2100] Fixing jest tests based on changes implemented within PM-2130
* [PM-2100] Fixing autofill mocks
* [PM-2100] Fixing AutofillService jest tests
* [PM-2100] Handling missing tests within coverage of AutofillService
* [PM-2100] Handling missing tests within coverage of AutofillService.generateLoginFillScript
* [PM-2100] Writing tests for AutofillService.generateCardFillScript
* [PM-2100] Finalizing tests for AutofillService.generateCardFillScript
* [PM-2100] Adding additional tests to cover changes introduced by TOTOP autofill PR
* [PM-2100] Adding jest tests for Autofill.generateIdentityFillScript
* [PM-2100] Finalizing tests for AutofillService.generateIdentityFillScript
* [PM-2100] Implementing tests for AutofillService
* [PM-2100] Implementing tests for AutofillService.loadPasswordFields
* [PM-2100] Implementing tests for AutofillService.findUsernameField
* [PM-2100] Implementing tests for AutofillService.findTotpField
* [PM-2100] Implementing tests for AutofillService.fieldPropertyIsPrefixMatch
* [PM-2100] Finalizing tests for AutofillService
* [PM-2100] Modyfing placement of autofill-mocks
* [PM-2100] Modyfing placement of autofill-mocks
* [PM-2100] Removal of jest transform declaration
* [PM-2747] Applying a fix for a race condition that can occur when loading the notification bar and autofiller script login
* [PM-2747] Reverting removal of autofill npm action. Now this will force usage of autofill-v2 regardless of whether a feature flag is set or not
* [PM-2747] Fixing logic error incorporated when merging in master
* [PM-2130] Fixing issue with autofill service unit tests
* [PM-2130] Fixing issue with autofill service unit tests
* [PM-2747] Fixing issue present with notification bar merge
* [PM-2130] Fixing test test for when we need to handle a password reprompt
* [PM-2747] Fixing wording for webpack script
* [PM-2747] Addressing stylistic changes requested from code review
* [PM-2747] Addressing stylistic changes requested from code review
---------
Co-authored-by: Jonathan Prusik <jprusik@classynemesis.com>
Co-authored-by: Manuel <mr-manuel@outlook.it>
Co-authored-by: Jonathan Prusik <jprusik@users.noreply.github.com>
* [PM-3285] Applying stylistic changes suggested by code review for the feature flag implementation
* [PM-3285] Adding temporary console log to validate which version is being used
* [PM-3285] Removing temporary console log indicating which version of autofill the user is currently loading
---------
Co-authored-by: Jonathan Prusik <jprusik@users.noreply.github.com>
Co-authored-by: Manuel <mr-manuel@outlook.it>
Co-authored-by: Jonathan Prusik <jprusik@classynemesis.com>
2023-09-07 22:33:04 +02:00
|
|
|
);
|
|
|
|
break;
|
2018-01-12 21:20:19 +01:00
|
|
|
case "bgCollectPageDetails":
|
|
|
|
await this.main.collectPageDetailsForContentScript(sender.tab, msg.sender, sender.frameId);
|
2021-12-21 15:43:35 +01:00
|
|
|
break;
|
2018-01-12 21:20:19 +01:00
|
|
|
case "bgUpdateContextMenu":
|
2019-01-03 16:22:55 +01:00
|
|
|
case "editedCipher":
|
|
|
|
case "addedCipher":
|
2019-02-22 21:37:05 +01:00
|
|
|
case "deletedCipher":
|
2022-10-19 15:55:57 +02:00
|
|
|
await this.main.refreshBadge();
|
|
|
|
await this.main.refreshMenu();
|
2021-12-21 15:43:35 +01:00
|
|
|
break;
|
2018-10-04 04:46:11 +02:00
|
|
|
case "bgReseedStorage":
|
2019-02-13 17:34:42 +01:00
|
|
|
await this.main.reseedStorage();
|
2021-12-21 15:43:35 +01:00
|
|
|
break;
|
2018-01-12 21:20:19 +01:00
|
|
|
case "collectPageDetailsResponse":
|
|
|
|
switch (msg.sender) {
|
|
|
|
case "autofiller":
|
2022-02-24 18:14:04 +01:00
|
|
|
case "autofill_cmd": {
|
2020-08-12 22:05:12 +02:00
|
|
|
const totpCode = await this.autofillService.doAutoFillActiveTab(
|
2021-12-21 15:43:35 +01:00
|
|
|
[
|
|
|
|
{
|
2018-01-12 21:20:19 +01:00
|
|
|
frameId: sender.frameId,
|
|
|
|
tab: msg.tab,
|
|
|
|
details: msg.details,
|
2021-12-21 15:43:35 +01:00
|
|
|
},
|
|
|
|
],
|
2018-01-12 21:20:19 +01:00
|
|
|
msg.sender === "autofill_cmd"
|
2021-12-21 15:43:35 +01:00
|
|
|
);
|
2018-08-31 03:47:49 +02:00
|
|
|
if (totpCode != null) {
|
2018-01-12 21:20:19 +01:00
|
|
|
this.platformUtilsService.copyToClipboard(totpCode, { window: window });
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
|
|
|
break;
|
2023-09-29 23:20:41 +02:00
|
|
|
}
|
|
|
|
case "autofill_card": {
|
|
|
|
await this.autofillService.doAutoFillActiveTab(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
frameId: sender.frameId,
|
|
|
|
tab: msg.tab,
|
|
|
|
details: msg.details,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
false,
|
|
|
|
CipherType.Card
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case "autofill_identity": {
|
|
|
|
await this.autofillService.doAutoFillActiveTab(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
frameId: sender.frameId,
|
|
|
|
tab: msg.tab,
|
|
|
|
details: msg.details,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
false,
|
|
|
|
CipherType.Identity
|
|
|
|
);
|
|
|
|
break;
|
2022-02-24 18:14:04 +01:00
|
|
|
}
|
2018-01-12 21:20:19 +01:00
|
|
|
case "contextMenu":
|
|
|
|
clearTimeout(this.autofillTimeout);
|
|
|
|
this.pageDetailsToAutoFill.push({
|
|
|
|
frameId: sender.frameId,
|
|
|
|
tab: msg.tab,
|
|
|
|
details: msg.details,
|
2017-12-07 21:06:37 +01:00
|
|
|
});
|
2022-07-21 19:56:09 +02:00
|
|
|
this.autofillTimeout = setTimeout(async () => await this.autofillPage(msg.tab), 300);
|
2021-12-21 15:43:35 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2017-12-07 21:06:37 +01:00
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
break;
|
2022-02-24 18:14:04 +01:00
|
|
|
case "authResult": {
|
2021-07-23 22:32:42 +02:00
|
|
|
const vaultUrl = this.environmentService.getWebVaultUrl();
|
2017-12-07 21:36:24 +01:00
|
|
|
|
2018-01-12 21:20:19 +01:00
|
|
|
if (msg.referrer == null || Utils.getHostname(vaultUrl) !== msg.referrer) {
|
2020-08-24 16:17:15 +02:00
|
|
|
return;
|
2018-01-12 21:20:19 +01:00
|
|
|
}
|
|
|
|
|
2017-12-07 21:36:24 +01:00
|
|
|
try {
|
|
|
|
BrowserApi.createNewTab(
|
2018-04-23 16:02:30 +02:00
|
|
|
"popup/index.html?uilocation=popout#/sso?code=" +
|
2021-11-09 18:26:17 +01:00
|
|
|
encodeURIComponent(msg.code) +
|
2021-12-21 15:43:35 +01:00
|
|
|
"&state=" +
|
2021-11-09 18:26:17 +01:00
|
|
|
encodeURIComponent(msg.state)
|
2021-12-21 15:43:35 +01:00
|
|
|
);
|
2018-04-23 16:02:30 +02:00
|
|
|
} catch {
|
|
|
|
this.logService.error("Unable to open sso popout tab");
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
|
|
|
break;
|
2022-02-24 18:14:04 +01:00
|
|
|
}
|
|
|
|
case "webAuthnResult": {
|
|
|
|
const vaultUrl = this.environmentService.getWebVaultUrl();
|
2017-12-07 21:36:24 +01:00
|
|
|
|
2022-02-24 18:14:04 +01:00
|
|
|
if (msg.referrer == null || Utils.getHostname(vaultUrl) !== msg.referrer) {
|
2018-08-13 15:44:59 +02:00
|
|
|
return;
|
2018-04-23 16:02:30 +02:00
|
|
|
}
|
|
|
|
|
2017-12-07 21:36:24 +01:00
|
|
|
const params =
|
|
|
|
`webAuthnResponse=${encodeURIComponent(msg.data)};` +
|
|
|
|
`remember=${encodeURIComponent(msg.remember)}`;
|
2023-03-08 23:12:43 +01:00
|
|
|
BrowserApi.openBitwardenExtensionTab(`popup/index.html#/2fa;${params}`, false);
|
2021-12-21 15:43:35 +01:00
|
|
|
break;
|
2022-02-24 18:14:04 +01:00
|
|
|
}
|
2021-03-17 22:14:26 +01:00
|
|
|
case "reloadPopup":
|
2017-12-07 21:36:24 +01:00
|
|
|
this.messagingService.send("reloadPopup");
|
2021-12-21 15:43:35 +01:00
|
|
|
break;
|
2021-05-12 05:35:18 +02:00
|
|
|
case "emailVerificationRequired":
|
|
|
|
this.messagingService.send("showDialog", {
|
2023-05-02 18:46:03 +02:00
|
|
|
title: { key: "emailVerificationRequired" },
|
|
|
|
content: { key: "emailVerificationRequiredDesc" },
|
|
|
|
acceptButtonText: { key: "ok" },
|
|
|
|
cancelButtonText: null,
|
2021-05-12 05:35:18 +02:00
|
|
|
type: "info",
|
2021-12-21 15:43:35 +01:00
|
|
|
});
|
|
|
|
break;
|
2017-12-07 21:36:24 +01:00
|
|
|
case "getClickedElementResponse":
|
|
|
|
this.platformUtilsService.copyToClipboard(msg.identifier, { window: window });
|
2022-02-24 18:14:04 +01:00
|
|
|
break;
|
2017-12-07 21:36:24 +01:00
|
|
|
default:
|
2021-12-21 15:43:35 +01:00
|
|
|
break;
|
2017-12-07 21:36:24 +01:00
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
2017-12-07 21:36:24 +01:00
|
|
|
|
2022-07-21 19:56:09 +02:00
|
|
|
private async autofillPage(tabToAutoFill: chrome.tabs.Tab) {
|
2018-01-18 04:42:31 +01:00
|
|
|
const totpCode = await this.autofillService.doAutoFill({
|
2022-07-21 19:56:09 +02:00
|
|
|
tab: tabToAutoFill,
|
2018-01-18 04:42:31 +01:00
|
|
|
cipher: this.main.loginToAutoFill,
|
|
|
|
pageDetails: this.pageDetailsToAutoFill,
|
2021-02-10 16:40:15 +01:00
|
|
|
fillNewPassword: true,
|
2023-06-21 17:18:46 +02:00
|
|
|
allowTotpAutofill: true,
|
2018-01-18 04:42:31 +01:00
|
|
|
});
|
2018-01-18 05:21:17 +01:00
|
|
|
|
|
|
|
if (totpCode != null) {
|
|
|
|
this.platformUtilsService.copyToClipboard(totpCode, { window: window });
|
2018-01-19 17:42:35 +01:00
|
|
|
}
|
|
|
|
|
2018-01-18 04:42:31 +01:00
|
|
|
// reset
|
|
|
|
this.main.loginToAutoFill = null;
|
|
|
|
this.pageDetailsToAutoFill = [];
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
|
|
|
|
2018-01-18 04:42:31 +01:00
|
|
|
private async checkOnInstalled() {
|
2020-04-06 17:40:16 +02:00
|
|
|
setTimeout(async () => {
|
|
|
|
if (this.onInstalledReason != null) {
|
|
|
|
if (this.onInstalledReason === "install") {
|
|
|
|
BrowserApi.createNewTab("https://bitwarden.com/browser-start/");
|
2022-08-08 13:40:09 +02:00
|
|
|
|
|
|
|
if (await this.environmentService.hasManagedEnvironment()) {
|
|
|
|
await this.environmentService.setUrlsToManagedEnvironment();
|
|
|
|
}
|
2020-04-06 17:40:16 +02:00
|
|
|
}
|
|
|
|
|
2018-01-18 05:21:17 +01:00
|
|
|
this.onInstalledReason = null;
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
|
|
|
}, 100);
|
|
|
|
}
|
2017-12-07 21:06:37 +01:00
|
|
|
}
|