2024-02-21 19:47:10 +01:00
|
|
|
import { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
|
|
|
|
|
2024-02-09 20:05:34 +01:00
|
|
|
import { NotificationQueueMessageTypes } from "../../enums/notification-queue-message-type.enum";
|
2024-02-21 19:47:10 +01:00
|
|
|
import AutofillPageDetails from "../../models/autofill-page-details";
|
2024-02-09 20:05:34 +01:00
|
|
|
|
|
|
|
interface NotificationQueueMessage {
|
|
|
|
type: NotificationQueueMessageTypes;
|
|
|
|
domain: string;
|
|
|
|
tab: chrome.tabs.Tab;
|
|
|
|
expires: Date;
|
|
|
|
wasVaultLocked: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface AddChangePasswordQueueMessage extends NotificationQueueMessage {
|
|
|
|
type: "change";
|
|
|
|
cipherId: string;
|
|
|
|
newPassword: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface AddLoginQueueMessage extends NotificationQueueMessage {
|
|
|
|
type: "add";
|
|
|
|
username: string;
|
|
|
|
password: string;
|
|
|
|
uri: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface AddUnlockVaultQueueMessage extends NotificationQueueMessage {
|
|
|
|
type: "unlock";
|
|
|
|
}
|
|
|
|
|
|
|
|
interface AddRequestFilelessImportQueueMessage extends NotificationQueueMessage {
|
|
|
|
type: "fileless-import";
|
|
|
|
importType?: string;
|
|
|
|
}
|
2023-12-22 21:03:21 +01:00
|
|
|
|
|
|
|
type NotificationQueueMessageItem =
|
|
|
|
| AddLoginQueueMessage
|
|
|
|
| AddChangePasswordQueueMessage
|
|
|
|
| AddUnlockVaultQueueMessage
|
|
|
|
| AddRequestFilelessImportQueueMessage;
|
|
|
|
|
2024-02-09 20:05:34 +01:00
|
|
|
type LockedVaultPendingNotificationsData = {
|
|
|
|
commandToRetry: {
|
|
|
|
message: {
|
|
|
|
command: string;
|
|
|
|
contextMenuOnClickData?: chrome.contextMenus.OnClickData;
|
|
|
|
folder?: string;
|
|
|
|
edit?: boolean;
|
|
|
|
};
|
|
|
|
sender: chrome.runtime.MessageSender;
|
|
|
|
};
|
|
|
|
target: string;
|
|
|
|
};
|
|
|
|
|
2024-02-21 19:47:10 +01:00
|
|
|
type AdjustNotificationBarMessageData = {
|
|
|
|
height: number;
|
|
|
|
};
|
|
|
|
|
2024-02-09 20:05:34 +01:00
|
|
|
type ChangePasswordMessageData = {
|
|
|
|
currentPassword: string;
|
|
|
|
newPassword: string;
|
|
|
|
url: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
type AddLoginMessageData = {
|
|
|
|
username: string;
|
|
|
|
password: string;
|
|
|
|
url: string;
|
|
|
|
};
|
|
|
|
|
2024-02-21 19:47:10 +01:00
|
|
|
type UnlockVaultMessageData = {
|
|
|
|
skipNotification?: boolean;
|
|
|
|
};
|
|
|
|
|
|
|
|
type NotificationBackgroundExtensionMessage = {
|
|
|
|
[key: string]: any;
|
|
|
|
command: string;
|
|
|
|
data?: Partial<LockedVaultPendingNotificationsData> &
|
|
|
|
Partial<AdjustNotificationBarMessageData> &
|
|
|
|
Partial<ChangePasswordMessageData> &
|
|
|
|
Partial<UnlockVaultMessageData>;
|
|
|
|
login?: AddLoginMessageData;
|
|
|
|
folder?: string;
|
|
|
|
edit?: boolean;
|
|
|
|
details?: AutofillPageDetails;
|
|
|
|
tab?: chrome.tabs.Tab;
|
|
|
|
sender?: string;
|
|
|
|
notificationType?: string;
|
|
|
|
};
|
|
|
|
|
2024-02-23 17:50:11 +01:00
|
|
|
type SaveOrUpdateCipherResult = undefined | { error: string };
|
|
|
|
|
2024-02-21 19:47:10 +01:00
|
|
|
type BackgroundMessageParam = { message: NotificationBackgroundExtensionMessage };
|
|
|
|
type BackgroundSenderParam = { sender: chrome.runtime.MessageSender };
|
|
|
|
type BackgroundOnMessageHandlerParams = BackgroundMessageParam & BackgroundSenderParam;
|
|
|
|
|
|
|
|
type NotificationBackgroundExtensionMessageHandlers = {
|
|
|
|
[key: string]: CallableFunction;
|
|
|
|
unlockCompleted: ({ message, sender }: BackgroundOnMessageHandlerParams) => Promise<void>;
|
|
|
|
bgGetFolderData: ({ message, sender }: BackgroundOnMessageHandlerParams) => Promise<FolderView[]>;
|
|
|
|
bgCloseNotificationBar: ({ sender }: BackgroundSenderParam) => Promise<void>;
|
|
|
|
bgAdjustNotificationBar: ({ message, sender }: BackgroundOnMessageHandlerParams) => Promise<void>;
|
|
|
|
bgAddLogin: ({ message, sender }: BackgroundOnMessageHandlerParams) => Promise<void>;
|
|
|
|
bgChangedPassword: ({ message, sender }: BackgroundOnMessageHandlerParams) => Promise<void>;
|
|
|
|
bgRemoveTabFromNotificationQueue: ({ sender }: BackgroundSenderParam) => void;
|
|
|
|
bgSaveCipher: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
|
|
|
|
bgNeverSave: ({ sender }: BackgroundSenderParam) => Promise<void>;
|
|
|
|
bgUnlockPopoutOpened: ({ message, sender }: BackgroundOnMessageHandlerParams) => Promise<void>;
|
|
|
|
bgReopenUnlockPopout: ({ sender }: BackgroundSenderParam) => Promise<void>;
|
|
|
|
checkNotificationQueue: ({ sender }: BackgroundSenderParam) => Promise<void>;
|
|
|
|
collectPageDetailsResponse: ({ message }: BackgroundMessageParam) => Promise<void>;
|
2024-03-04 20:12:23 +01:00
|
|
|
bgGetEnableChangedPasswordPrompt: () => Promise<boolean>;
|
|
|
|
bgGetEnableAddedLoginPrompt: () => Promise<boolean>;
|
2024-03-04 15:01:59 +01:00
|
|
|
getWebVaultUrlForNotification: () => string;
|
2024-02-21 19:47:10 +01:00
|
|
|
};
|
|
|
|
|
2024-02-09 20:05:34 +01:00
|
|
|
export {
|
|
|
|
AddChangePasswordQueueMessage,
|
|
|
|
AddLoginQueueMessage,
|
|
|
|
AddUnlockVaultQueueMessage,
|
|
|
|
AddRequestFilelessImportQueueMessage,
|
|
|
|
NotificationQueueMessageItem,
|
|
|
|
LockedVaultPendingNotificationsData,
|
2024-02-21 19:47:10 +01:00
|
|
|
AdjustNotificationBarMessageData,
|
2024-02-09 20:05:34 +01:00
|
|
|
ChangePasswordMessageData,
|
2024-02-21 19:47:10 +01:00
|
|
|
UnlockVaultMessageData,
|
2024-02-09 20:05:34 +01:00
|
|
|
AddLoginMessageData,
|
2024-02-23 17:50:11 +01:00
|
|
|
SaveOrUpdateCipherResult,
|
2024-02-21 19:47:10 +01:00
|
|
|
NotificationBackgroundExtensionMessage,
|
|
|
|
NotificationBackgroundExtensionMessageHandlers,
|
2024-02-09 20:05:34 +01:00
|
|
|
};
|