mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 06:13:38 +00:00
Generate password triggers notifications (#15874)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { NeverDomains } from "@bitwarden/common/models/domain/domain-service";
|
import { NeverDomains } from "@bitwarden/common/models/domain/domain-service";
|
||||||
import { ServerConfig } from "@bitwarden/common/platform/abstractions/config/server-config";
|
import { ServerConfig } from "@bitwarden/common/platform/abstractions/config/server-config";
|
||||||
|
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||||
import { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
|
import { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
|
||||||
|
|
||||||
import { CollectionView } from "../../content/components/common-types";
|
import { CollectionView } from "../../content/components/common-types";
|
||||||
@@ -17,7 +18,7 @@ interface NotificationQueueMessage {
|
|||||||
|
|
||||||
interface AddChangePasswordQueueMessage extends NotificationQueueMessage {
|
interface AddChangePasswordQueueMessage extends NotificationQueueMessage {
|
||||||
type: "change";
|
type: "change";
|
||||||
cipherId: string;
|
cipherId: CipherView["id"];
|
||||||
newPassword: string;
|
newPassword: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,19 +28,12 @@ export type ModifyLoginCipherFormData = {
|
|||||||
newPassword: string;
|
newPassword: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ModifyLoginCipherFormDataForTab = Map<
|
export type ModifyLoginCipherFormDataForTab = Map<chrome.tabs.Tab["id"], ModifyLoginCipherFormData>;
|
||||||
chrome.tabs.Tab["id"],
|
|
||||||
{ uri: string; username: string; password: string; newPassword: string }
|
|
||||||
>;
|
|
||||||
|
|
||||||
export type OverlayNotificationsExtensionMessage = {
|
export type OverlayNotificationsExtensionMessage = {
|
||||||
command: string;
|
command: string;
|
||||||
uri?: string;
|
|
||||||
username?: string;
|
|
||||||
password?: string;
|
|
||||||
newPassword?: string;
|
|
||||||
details?: AutofillPageDetails;
|
details?: AutofillPageDetails;
|
||||||
};
|
} & ModifyLoginCipherFormData;
|
||||||
|
|
||||||
type OverlayNotificationsMessageParams = { message: OverlayNotificationsExtensionMessage };
|
type OverlayNotificationsMessageParams = { message: OverlayNotificationsExtensionMessage };
|
||||||
type OverlayNotificationSenderParams = { sender: chrome.runtime.MessageSender };
|
type OverlayNotificationSenderParams = { sender: chrome.runtime.MessageSender };
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
import { mock, MockProxy } from "jest-mock-extended";
|
import { mock, MockProxy } from "jest-mock-extended";
|
||||||
|
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
|
||||||
import { CLEAR_NOTIFICATION_LOGIN_DATA_DURATION } from "@bitwarden/common/autofill/constants";
|
import { CLEAR_NOTIFICATION_LOGIN_DATA_DURATION } from "@bitwarden/common/autofill/constants";
|
||||||
import { ServerConfig } from "@bitwarden/common/platform/abstractions/config/server-config";
|
import { ServerConfig } from "@bitwarden/common/platform/abstractions/config/server-config";
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||||
import { EnvironmentServerConfigData } from "@bitwarden/common/platform/models/data/server-config.data";
|
import { EnvironmentServerConfigData } from "@bitwarden/common/platform/models/data/server-config.data";
|
||||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
|
||||||
import { TaskService } from "@bitwarden/common/vault/tasks";
|
|
||||||
|
|
||||||
import { BrowserApi } from "../../platform/browser/browser-api";
|
import { BrowserApi } from "../../platform/browser/browser-api";
|
||||||
import AutofillField from "../models/autofill-field";
|
import AutofillField from "../models/autofill-field";
|
||||||
@@ -27,9 +24,6 @@ import { OverlayNotificationsBackground } from "./overlay-notifications.backgrou
|
|||||||
describe("OverlayNotificationsBackground", () => {
|
describe("OverlayNotificationsBackground", () => {
|
||||||
let logService: MockProxy<LogService>;
|
let logService: MockProxy<LogService>;
|
||||||
let notificationBackground: NotificationBackground;
|
let notificationBackground: NotificationBackground;
|
||||||
let taskService: TaskService;
|
|
||||||
let accountService: AccountService;
|
|
||||||
let cipherService: CipherService;
|
|
||||||
let getEnableChangedPasswordPromptSpy: jest.SpyInstance;
|
let getEnableChangedPasswordPromptSpy: jest.SpyInstance;
|
||||||
let getEnableAddedLoginPromptSpy: jest.SpyInstance;
|
let getEnableAddedLoginPromptSpy: jest.SpyInstance;
|
||||||
let overlayNotificationsBackground: OverlayNotificationsBackground;
|
let overlayNotificationsBackground: OverlayNotificationsBackground;
|
||||||
@@ -38,9 +32,6 @@ describe("OverlayNotificationsBackground", () => {
|
|||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
logService = mock<LogService>();
|
logService = mock<LogService>();
|
||||||
notificationBackground = mock<NotificationBackground>();
|
notificationBackground = mock<NotificationBackground>();
|
||||||
taskService = mock<TaskService>();
|
|
||||||
accountService = mock<AccountService>();
|
|
||||||
cipherService = mock<CipherService>();
|
|
||||||
getEnableChangedPasswordPromptSpy = jest
|
getEnableChangedPasswordPromptSpy = jest
|
||||||
.spyOn(notificationBackground, "getEnableChangedPasswordPrompt")
|
.spyOn(notificationBackground, "getEnableChangedPasswordPrompt")
|
||||||
.mockResolvedValue(true);
|
.mockResolvedValue(true);
|
||||||
@@ -50,9 +41,6 @@ describe("OverlayNotificationsBackground", () => {
|
|||||||
overlayNotificationsBackground = new OverlayNotificationsBackground(
|
overlayNotificationsBackground = new OverlayNotificationsBackground(
|
||||||
logService,
|
logService,
|
||||||
notificationBackground,
|
notificationBackground,
|
||||||
taskService,
|
|
||||||
accountService,
|
|
||||||
cipherService,
|
|
||||||
);
|
);
|
||||||
await overlayNotificationsBackground.init();
|
await overlayNotificationsBackground.init();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,11 +2,8 @@
|
|||||||
// @ts-strict-ignore
|
// @ts-strict-ignore
|
||||||
import { Subject, switchMap, timer } from "rxjs";
|
import { Subject, switchMap, timer } from "rxjs";
|
||||||
|
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
|
||||||
import { CLEAR_NOTIFICATION_LOGIN_DATA_DURATION } from "@bitwarden/common/autofill/constants";
|
import { CLEAR_NOTIFICATION_LOGIN_DATA_DURATION } from "@bitwarden/common/autofill/constants";
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
|
||||||
import { TaskService } from "@bitwarden/common/vault/tasks";
|
|
||||||
|
|
||||||
import { BrowserApi } from "../../platform/browser/browser-api";
|
import { BrowserApi } from "../../platform/browser/browser-api";
|
||||||
import { NotificationType, NotificationTypes } from "../notification/abstractions/notification-bar";
|
import { NotificationType, NotificationTypes } from "../notification/abstractions/notification-bar";
|
||||||
@@ -31,6 +28,8 @@ export class OverlayNotificationsBackground implements OverlayNotificationsBackg
|
|||||||
private notificationFallbackTimeout: number | NodeJS.Timeout | null;
|
private notificationFallbackTimeout: number | NodeJS.Timeout | null;
|
||||||
private readonly formSubmissionRequestMethods: Set<string> = new Set(["POST", "PUT", "PATCH"]);
|
private readonly formSubmissionRequestMethods: Set<string> = new Set(["POST", "PUT", "PATCH"]);
|
||||||
private readonly extensionMessageHandlers: OverlayNotificationsExtensionMessageHandlers = {
|
private readonly extensionMessageHandlers: OverlayNotificationsExtensionMessageHandlers = {
|
||||||
|
generatedPasswordFilled: ({ message, sender }) =>
|
||||||
|
this.storeModifiedLoginFormData(message, sender),
|
||||||
formFieldSubmitted: ({ message, sender }) => this.storeModifiedLoginFormData(message, sender),
|
formFieldSubmitted: ({ message, sender }) => this.storeModifiedLoginFormData(message, sender),
|
||||||
collectPageDetailsResponse: ({ message, sender }) =>
|
collectPageDetailsResponse: ({ message, sender }) =>
|
||||||
this.handleCollectPageDetailsResponse(message, sender),
|
this.handleCollectPageDetailsResponse(message, sender),
|
||||||
@@ -39,9 +38,6 @@ export class OverlayNotificationsBackground implements OverlayNotificationsBackg
|
|||||||
constructor(
|
constructor(
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private notificationBackground: NotificationBackground,
|
private notificationBackground: NotificationBackground,
|
||||||
private taskService: TaskService,
|
|
||||||
private accountService: AccountService,
|
|
||||||
private cipherService: CipherService,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -442,7 +438,7 @@ export class OverlayNotificationsBackground implements OverlayNotificationsBackg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.clearCompletedWebRequest(requestId, tab);
|
this.clearCompletedWebRequest(requestId, tab.id);
|
||||||
return results.join(" ");
|
return results.join(" ");
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -482,11 +478,11 @@ export class OverlayNotificationsBackground implements OverlayNotificationsBackg
|
|||||||
*/
|
*/
|
||||||
private clearCompletedWebRequest = (
|
private clearCompletedWebRequest = (
|
||||||
requestId: chrome.webRequest.ResourceRequest["requestId"],
|
requestId: chrome.webRequest.ResourceRequest["requestId"],
|
||||||
tab: chrome.tabs.Tab,
|
tabId: chrome.tabs.Tab["id"],
|
||||||
) => {
|
) => {
|
||||||
this.activeFormSubmissionRequests.delete(requestId);
|
this.activeFormSubmissionRequests.delete(requestId);
|
||||||
this.modifyLoginCipherFormData.delete(tab.id);
|
this.modifyLoginCipherFormData.delete(tabId);
|
||||||
this.websiteOriginsWithFields.delete(tab.id);
|
this.websiteOriginsWithFields.delete(tabId);
|
||||||
this.setupWebRequestsListeners();
|
this.setupWebRequestsListeners();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ import {
|
|||||||
MAX_SUB_FRAME_DEPTH,
|
MAX_SUB_FRAME_DEPTH,
|
||||||
RedirectFocusDirection,
|
RedirectFocusDirection,
|
||||||
} from "../enums/autofill-overlay.enum";
|
} from "../enums/autofill-overlay.enum";
|
||||||
import { InlineMenuFormFieldData } from "../services/abstractions/autofill-overlay-content.service";
|
|
||||||
import { AutofillService } from "../services/abstractions/autofill.service";
|
import { AutofillService } from "../services/abstractions/autofill.service";
|
||||||
import { InlineMenuFieldQualificationService } from "../services/inline-menu-field-qualification.service";
|
import { InlineMenuFieldQualificationService } from "../services/inline-menu-field-qualification.service";
|
||||||
import {
|
import {
|
||||||
@@ -71,6 +70,7 @@ import {
|
|||||||
triggerWebRequestOnCompletedEvent,
|
triggerWebRequestOnCompletedEvent,
|
||||||
} from "../spec/testing-utils";
|
} from "../spec/testing-utils";
|
||||||
|
|
||||||
|
import { ModifyLoginCipherFormData } from "./abstractions/overlay-notifications.background";
|
||||||
import {
|
import {
|
||||||
FocusedFieldData,
|
FocusedFieldData,
|
||||||
InlineMenuPosition,
|
InlineMenuPosition,
|
||||||
@@ -2076,7 +2076,7 @@ describe("OverlayBackground", () => {
|
|||||||
const tab = createChromeTabMock({ id: 2 });
|
const tab = createChromeTabMock({ id: 2 });
|
||||||
const sender = mock<chrome.runtime.MessageSender>({ tab, frameId: 100 });
|
const sender = mock<chrome.runtime.MessageSender>({ tab, frameId: 100 });
|
||||||
let focusedFieldData: FocusedFieldData;
|
let focusedFieldData: FocusedFieldData;
|
||||||
let formData: InlineMenuFormFieldData;
|
let formData: ModifyLoginCipherFormData;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await initOverlayElementPorts();
|
await initOverlayElementPorts();
|
||||||
@@ -3651,6 +3651,18 @@ describe("OverlayBackground", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("sends a message to the tab to store modify login change when a password is generated", async () => {
|
||||||
|
jest.useFakeTimers();
|
||||||
|
|
||||||
|
sendPortMessage(listMessageConnectorSpy, { command: "fillGeneratedPassword", portKey });
|
||||||
|
|
||||||
|
await flushPromises();
|
||||||
|
jest.advanceTimersByTime(400);
|
||||||
|
await flushPromises();
|
||||||
|
|
||||||
|
expect(tabsSendMessageSpy.mock.lastCall[1].command).toBe("generatedPasswordModifyLogin");
|
||||||
|
});
|
||||||
|
|
||||||
it("filters the page details to only include the new password fields before filling", async () => {
|
it("filters the page details to only include the new password fields before filling", async () => {
|
||||||
sendPortMessage(listMessageConnectorSpy, { command: "fillGeneratedPassword", portKey });
|
sendPortMessage(listMessageConnectorSpy, { command: "fillGeneratedPassword", portKey });
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
@@ -3663,31 +3675,6 @@ describe("OverlayBackground", () => {
|
|||||||
allowTotpAutofill: false,
|
allowTotpAutofill: false,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("opens the inline menu for fields that fill a generated password", async () => {
|
|
||||||
jest.useFakeTimers();
|
|
||||||
const formData = {
|
|
||||||
uri: "https://example.com",
|
|
||||||
username: "username",
|
|
||||||
password: "password",
|
|
||||||
newPassword: "newPassword",
|
|
||||||
};
|
|
||||||
tabsSendMessageSpy.mockImplementation((_tab, message) => {
|
|
||||||
if (message.command === "getInlineMenuFormFieldData") {
|
|
||||||
return Promise.resolve(formData);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.resolve();
|
|
||||||
});
|
|
||||||
const openInlineMenuSpy = jest.spyOn(overlayBackground as any, "openInlineMenu");
|
|
||||||
|
|
||||||
sendPortMessage(listMessageConnectorSpy, { command: "fillGeneratedPassword", portKey });
|
|
||||||
await flushPromises();
|
|
||||||
jest.advanceTimersByTime(400);
|
|
||||||
await flushPromises();
|
|
||||||
|
|
||||||
expect(openInlineMenuSpy).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ import {
|
|||||||
MAX_SUB_FRAME_DEPTH,
|
MAX_SUB_FRAME_DEPTH,
|
||||||
} from "../enums/autofill-overlay.enum";
|
} from "../enums/autofill-overlay.enum";
|
||||||
import AutofillField from "../models/autofill-field";
|
import AutofillField from "../models/autofill-field";
|
||||||
import { InlineMenuFormFieldData } from "../services/abstractions/autofill-overlay-content.service";
|
|
||||||
import { AutofillService, PageDetail } from "../services/abstractions/autofill.service";
|
import { AutofillService, PageDetail } from "../services/abstractions/autofill.service";
|
||||||
import { InlineMenuFieldQualificationService } from "../services/abstractions/inline-menu-field-qualifications.service";
|
import { InlineMenuFieldQualificationService } from "../services/abstractions/inline-menu-field-qualifications.service";
|
||||||
import {
|
import {
|
||||||
@@ -82,6 +81,7 @@ import {
|
|||||||
} from "../utils";
|
} from "../utils";
|
||||||
|
|
||||||
import { LockedVaultPendingNotificationsData } from "./abstractions/notification.background";
|
import { LockedVaultPendingNotificationsData } from "./abstractions/notification.background";
|
||||||
|
import { ModifyLoginCipherFormData } from "./abstractions/overlay-notifications.background";
|
||||||
import {
|
import {
|
||||||
BuildCipherDataParams,
|
BuildCipherDataParams,
|
||||||
CloseInlineMenuMessage,
|
CloseInlineMenuMessage,
|
||||||
@@ -1857,10 +1857,16 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
});
|
});
|
||||||
|
|
||||||
globalThis.setTimeout(async () => {
|
globalThis.setTimeout(async () => {
|
||||||
if (await this.shouldShowSaveLoginInlineMenuList(port.sender.tab)) {
|
await BrowserApi.tabSendMessage(
|
||||||
await this.openInlineMenu(port.sender, true);
|
port.sender.tab,
|
||||||
}
|
{
|
||||||
}, 300);
|
command: "generatedPasswordModifyLogin",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
frameId: this.focusedFieldData.frameId || 0,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}, 150);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1891,7 +1897,9 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
*
|
*
|
||||||
* @param tab - The tab to get the form field data from
|
* @param tab - The tab to get the form field data from
|
||||||
*/
|
*/
|
||||||
private async getInlineMenuFormFieldData(tab: chrome.tabs.Tab): Promise<InlineMenuFormFieldData> {
|
private async getInlineMenuFormFieldData(
|
||||||
|
tab: chrome.tabs.Tab,
|
||||||
|
): Promise<ModifyLoginCipherFormData> {
|
||||||
return await BrowserApi.tabSendMessage(
|
return await BrowserApi.tabSendMessage(
|
||||||
tab,
|
tab,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { ModifyLoginCipherFormData } from "../../background/abstractions/overlay-notifications.background";
|
||||||
import { SubFrameOffsetData } from "../../background/abstractions/overlay.background";
|
import { SubFrameOffsetData } from "../../background/abstractions/overlay.background";
|
||||||
import { AutofillExtensionMessageParam } from "../../content/abstractions/autofill-init";
|
import { AutofillExtensionMessageParam } from "../../content/abstractions/autofill-init";
|
||||||
import AutofillField from "../../models/autofill-field";
|
import AutofillField from "../../models/autofill-field";
|
||||||
@@ -8,13 +9,6 @@ export type SubFrameDataFromWindowMessage = SubFrameOffsetData & {
|
|||||||
subFrameDepth: number;
|
subFrameDepth: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type InlineMenuFormFieldData = {
|
|
||||||
uri: string;
|
|
||||||
username: string;
|
|
||||||
password: string;
|
|
||||||
newPassword: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type AutofillOverlayContentExtensionMessageHandlers = {
|
export type AutofillOverlayContentExtensionMessageHandlers = {
|
||||||
[key: string]: CallableFunction;
|
[key: string]: CallableFunction;
|
||||||
addNewVaultItemFromOverlay: ({ message }: AutofillExtensionMessageParam) => void;
|
addNewVaultItemFromOverlay: ({ message }: AutofillExtensionMessageParam) => void;
|
||||||
@@ -32,7 +26,7 @@ export type AutofillOverlayContentExtensionMessageHandlers = {
|
|||||||
destroyAutofillInlineMenuListeners: () => void;
|
destroyAutofillInlineMenuListeners: () => void;
|
||||||
getInlineMenuFormFieldData: ({
|
getInlineMenuFormFieldData: ({
|
||||||
message,
|
message,
|
||||||
}: AutofillExtensionMessageParam) => Promise<InlineMenuFormFieldData>;
|
}: AutofillExtensionMessageParam) => Promise<ModifyLoginCipherFormData>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface AutofillOverlayContentService {
|
export interface AutofillOverlayContentService {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { mock, MockProxy } from "jest-mock-extended";
|
|||||||
import { EVENTS } from "@bitwarden/common/autofill/constants";
|
import { EVENTS } from "@bitwarden/common/autofill/constants";
|
||||||
import { CipherType } from "@bitwarden/common/vault/enums";
|
import { CipherType } from "@bitwarden/common/vault/enums";
|
||||||
|
|
||||||
|
import { ModifyLoginCipherFormData } from "../background/abstractions/overlay-notifications.background";
|
||||||
import AutofillInit from "../content/autofill-init";
|
import AutofillInit from "../content/autofill-init";
|
||||||
import {
|
import {
|
||||||
AutofillOverlayElement,
|
AutofillOverlayElement,
|
||||||
@@ -1750,6 +1751,29 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("extension onMessage handlers", () => {
|
describe("extension onMessage handlers", () => {
|
||||||
|
describe("generatedPasswordModifyLogin", () => {
|
||||||
|
it("relays a message regarding password generation to store modified login data", async () => {
|
||||||
|
const formFieldData: ModifyLoginCipherFormData = {
|
||||||
|
newPassword: "newPassword",
|
||||||
|
password: "password",
|
||||||
|
uri: "http://localhost/",
|
||||||
|
username: "username",
|
||||||
|
};
|
||||||
|
|
||||||
|
jest
|
||||||
|
.spyOn(autofillOverlayContentService as any, "getFormFieldData")
|
||||||
|
.mockResolvedValue(formFieldData);
|
||||||
|
|
||||||
|
sendMockExtensionMessage({
|
||||||
|
command: "generatedPasswordModifyLogin",
|
||||||
|
});
|
||||||
|
await flushPromises();
|
||||||
|
|
||||||
|
const resolvedValue = await sendExtensionMessageSpy.mock.calls[0][1];
|
||||||
|
expect(resolvedValue).toEqual(formFieldData);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("addNewVaultItemFromOverlay message handler", () => {
|
describe("addNewVaultItemFromOverlay message handler", () => {
|
||||||
it("skips sending the message if the overlay list is not visible", async () => {
|
it("skips sending the message if the overlay list is not visible", async () => {
|
||||||
jest
|
jest
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
} from "@bitwarden/common/autofill/constants";
|
} from "@bitwarden/common/autofill/constants";
|
||||||
import { CipherType } from "@bitwarden/common/vault/enums";
|
import { CipherType } from "@bitwarden/common/vault/enums";
|
||||||
|
|
||||||
|
import { ModifyLoginCipherFormData } from "../background/abstractions/overlay-notifications.background";
|
||||||
import {
|
import {
|
||||||
FocusedFieldData,
|
FocusedFieldData,
|
||||||
NewCardCipherData,
|
NewCardCipherData,
|
||||||
@@ -48,7 +49,6 @@ import {
|
|||||||
import {
|
import {
|
||||||
AutofillOverlayContentExtensionMessageHandlers,
|
AutofillOverlayContentExtensionMessageHandlers,
|
||||||
AutofillOverlayContentService as AutofillOverlayContentServiceInterface,
|
AutofillOverlayContentService as AutofillOverlayContentServiceInterface,
|
||||||
InlineMenuFormFieldData,
|
|
||||||
SubFrameDataFromWindowMessage,
|
SubFrameDataFromWindowMessage,
|
||||||
} from "./abstractions/autofill-overlay-content.service";
|
} from "./abstractions/autofill-overlay-content.service";
|
||||||
import { DomElementVisibilityService } from "./abstractions/dom-element-visibility.service";
|
import { DomElementVisibilityService } from "./abstractions/dom-element-visibility.service";
|
||||||
@@ -95,6 +95,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
destroyAutofillInlineMenuListeners: () => this.destroy(),
|
destroyAutofillInlineMenuListeners: () => this.destroy(),
|
||||||
getInlineMenuFormFieldData: ({ message }) =>
|
getInlineMenuFormFieldData: ({ message }) =>
|
||||||
this.handleGetInlineMenuFormFieldDataMessage(message),
|
this.handleGetInlineMenuFormFieldDataMessage(message),
|
||||||
|
generatedPasswordModifyLogin: () => this.sendGeneratedPasswordModifyLogin(),
|
||||||
};
|
};
|
||||||
private readonly loginFieldQualifiers: Record<string, CallableFunction> = {
|
private readonly loginFieldQualifiers: Record<string, CallableFunction> = {
|
||||||
[AutofillFieldQualifier.username]: this.inlineMenuFieldQualificationService.isUsernameField,
|
[AutofillFieldQualifier.username]: this.inlineMenuFieldQualificationService.isUsernameField,
|
||||||
@@ -235,6 +236,13 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On password generation, send form field data i.e. modified login data
|
||||||
|
*/
|
||||||
|
sendGeneratedPasswordModifyLogin = async () => {
|
||||||
|
await this.sendExtensionMessage("generatedPasswordFilled", this.getFormFieldData());
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats any found user filled fields for a login cipher and sends a message
|
* Formats any found user filled fields for a login cipher and sends a message
|
||||||
* to the background script to add a new cipher.
|
* to the background script to add a new cipher.
|
||||||
@@ -637,7 +645,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
/**
|
/**
|
||||||
* Returns the form field data used for add login and change password notifications.
|
* Returns the form field data used for add login and change password notifications.
|
||||||
*/
|
*/
|
||||||
private getFormFieldData = (): InlineMenuFormFieldData => {
|
private getFormFieldData = (): ModifyLoginCipherFormData => {
|
||||||
return {
|
return {
|
||||||
uri: globalThis.document.URL,
|
uri: globalThis.document.URL,
|
||||||
username: this.userFilledFields["username"]?.value || "",
|
username: this.userFilledFields["username"]?.value || "",
|
||||||
|
|||||||
@@ -1258,9 +1258,6 @@ export default class MainBackground {
|
|||||||
this.overlayNotificationsBackground = new OverlayNotificationsBackground(
|
this.overlayNotificationsBackground = new OverlayNotificationsBackground(
|
||||||
this.logService,
|
this.logService,
|
||||||
this.notificationBackground,
|
this.notificationBackground,
|
||||||
this.taskService,
|
|
||||||
this.accountService,
|
|
||||||
this.cipherService,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
this.autoSubmitLoginBackground = new AutoSubmitLoginBackground(
|
this.autoSubmitLoginBackground = new AutoSubmitLoginBackground(
|
||||||
|
|||||||
Reference in New Issue
Block a user