175 lines
5.9 KiB
TypeScript
175 lines
5.9 KiB
TypeScript
import { CipherType } from "@bitwarden/common/vault/enums";
|
|
import { CipherRepromptType } from "@bitwarden/common/vault/enums/cipher-reprompt-type";
|
|
|
|
import AutofillPageDetails from "../../models/autofill-page-details";
|
|
import { PageDetail } from "../../services/abstractions/autofill.service";
|
|
|
|
import { LockedVaultPendingNotificationsData } from "./notification.background";
|
|
|
|
type PageDetailsForTab = Record<
|
|
chrome.runtime.MessageSender["tab"]["id"],
|
|
Map<chrome.runtime.MessageSender["frameId"], PageDetail>
|
|
>;
|
|
|
|
type SubFrameOffsetData = {
|
|
frameId?: number;
|
|
url?: string;
|
|
top: number;
|
|
left: number;
|
|
} | null;
|
|
|
|
type SubFrameOffsetsForTab = Record<
|
|
chrome.runtime.MessageSender["tab"]["id"],
|
|
Map<chrome.runtime.MessageSender["frameId"], SubFrameOffsetData>
|
|
>;
|
|
|
|
type WebsiteIconData = {
|
|
imageEnabled: boolean;
|
|
image: string;
|
|
fallbackImage: string;
|
|
icon: string;
|
|
};
|
|
|
|
type OverlayAddNewItemMessage = {
|
|
login?: {
|
|
uri?: string;
|
|
hostname: string;
|
|
username: string;
|
|
password: string;
|
|
};
|
|
};
|
|
|
|
type FocusedFieldData = {
|
|
focusedFieldStyles: Partial<CSSStyleDeclaration>;
|
|
focusedFieldRects: Partial<DOMRect>;
|
|
tabId?: number;
|
|
frameId?: number;
|
|
};
|
|
|
|
type OverlayBackgroundExtensionMessage = {
|
|
command: string;
|
|
portKey?: string;
|
|
tab?: chrome.tabs.Tab;
|
|
sender?: string;
|
|
details?: AutofillPageDetails;
|
|
overlayElement?: string;
|
|
forceCloseAutofillInlineMenu?: boolean;
|
|
isAutofillInlineMenuHidden?: boolean;
|
|
setTransparentOverlay?: boolean;
|
|
isFieldCurrentlyFocused?: boolean;
|
|
isFieldCurrentlyFilling?: boolean;
|
|
subFrameData?: SubFrameOffsetData;
|
|
focusedFieldData?: FocusedFieldData;
|
|
styles?: Partial<CSSStyleDeclaration>;
|
|
data?: LockedVaultPendingNotificationsData;
|
|
} & OverlayAddNewItemMessage;
|
|
|
|
type OverlayPortMessage = {
|
|
[key: string]: any;
|
|
command: string;
|
|
direction?: string;
|
|
overlayCipherId?: string;
|
|
};
|
|
|
|
type OverlayCipherData = {
|
|
id: string;
|
|
name: string;
|
|
type: CipherType;
|
|
reprompt: CipherRepromptType;
|
|
favorite: boolean;
|
|
icon: WebsiteIconData;
|
|
login?: { username: string };
|
|
card?: string;
|
|
};
|
|
|
|
type BackgroundMessageParam = {
|
|
message: OverlayBackgroundExtensionMessage;
|
|
};
|
|
type BackgroundSenderParam = {
|
|
sender: chrome.runtime.MessageSender;
|
|
};
|
|
type BackgroundOnMessageHandlerParams = BackgroundMessageParam & BackgroundSenderParam;
|
|
|
|
type OverlayBackgroundExtensionMessageHandlers = {
|
|
[key: string]: CallableFunction;
|
|
openAutofillInlineMenu: () => void;
|
|
closeAutofillInlineMenu: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
|
|
autofillOverlayElementClosed: ({ message }: BackgroundMessageParam) => void;
|
|
autofillOverlayAddNewVaultItem: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
|
|
getAutofillInlineMenuVisibility: () => void;
|
|
checkAutofillInlineMenuFocused: () => void;
|
|
focusAutofillInlineMenuList: () => void;
|
|
updateAutofillInlineMenuPosition: ({
|
|
message,
|
|
sender,
|
|
}: BackgroundOnMessageHandlerParams) => Promise<void>;
|
|
updateAutofillInlineMenuHidden: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
|
|
updateFocusedFieldData: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
|
|
updateIsFieldCurrentlyFocused: ({ message }: BackgroundMessageParam) => void;
|
|
checkIsFieldCurrentlyFocused: () => boolean;
|
|
updateIsFieldCurrentlyFilling: ({ message }: BackgroundMessageParam) => void;
|
|
checkIsFieldCurrentlyFilling: () => boolean;
|
|
checkIsAutofillInlineMenuButtonVisible: ({ sender }: BackgroundSenderParam) => void;
|
|
checkIsAutofillInlineMenuListVisible: ({ sender }: BackgroundSenderParam) => void;
|
|
checkIsOverlayLoginCiphersPopulated: ({ sender }: BackgroundSenderParam) => void;
|
|
updateSubFrameData: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
|
|
rebuildSubFrameOffsets: ({ sender }: BackgroundSenderParam) => void;
|
|
collectPageDetailsResponse: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
|
|
unlockCompleted: ({ message }: BackgroundMessageParam) => void;
|
|
addEditCipherSubmitted: () => void;
|
|
deletedCipher: () => void;
|
|
};
|
|
|
|
type PortMessageParam = {
|
|
message: OverlayPortMessage;
|
|
};
|
|
type PortConnectionParam = {
|
|
port: chrome.runtime.Port;
|
|
};
|
|
type PortOnMessageHandlerParams = PortMessageParam & PortConnectionParam;
|
|
|
|
type InlineMenuButtonPortMessageHandlers = {
|
|
[key: string]: CallableFunction;
|
|
autofillInlineMenuButtonClicked: ({ port }: PortConnectionParam) => void;
|
|
closeAutofillInlineMenu: ({ port }: PortConnectionParam) => void;
|
|
forceCloseAutofillInlineMenu: ({ port }: PortConnectionParam) => void;
|
|
autofillInlineMenuBlurred: () => void;
|
|
redirectAutofillInlineMenuFocusOut: ({ message, port }: PortOnMessageHandlerParams) => void;
|
|
updateAutofillInlineMenuColorScheme: () => void;
|
|
};
|
|
|
|
type InlineMenuListPortMessageHandlers = {
|
|
[key: string]: CallableFunction;
|
|
checkAutofillInlineMenuButtonFocused: () => void;
|
|
forceCloseAutofillInlineMenu: ({ port }: PortConnectionParam) => void;
|
|
autofillInlineMenuBlurred: () => void;
|
|
unlockVault: ({ port }: PortConnectionParam) => void;
|
|
fillSelectedAutofillInlineMenuListItem: ({ message, port }: PortOnMessageHandlerParams) => void;
|
|
addNewVaultItem: ({ port }: PortConnectionParam) => void;
|
|
viewSelectedCipher: ({ message, port }: PortOnMessageHandlerParams) => void;
|
|
redirectAutofillInlineMenuFocusOut: ({ message, port }: PortOnMessageHandlerParams) => void;
|
|
updateAutofillInlineMenuListHeight: ({ message, port }: PortOnMessageHandlerParams) => void;
|
|
};
|
|
|
|
interface OverlayBackground {
|
|
init(): Promise<void>;
|
|
removePageDetails(tabId: number): void;
|
|
updateOverlayCiphers(): void;
|
|
}
|
|
|
|
export {
|
|
PageDetailsForTab,
|
|
SubFrameOffsetData,
|
|
SubFrameOffsetsForTab,
|
|
WebsiteIconData,
|
|
OverlayBackgroundExtensionMessage,
|
|
OverlayPortMessage,
|
|
FocusedFieldData,
|
|
OverlayCipherData,
|
|
OverlayAddNewItemMessage,
|
|
OverlayBackgroundExtensionMessageHandlers,
|
|
InlineMenuButtonPortMessageHandlers,
|
|
InlineMenuListPortMessageHandlers,
|
|
OverlayBackground,
|
|
};
|