2023-10-12 02:17:19 +02:00
|
|
|
export type NotificationData = {
|
|
|
|
title: string;
|
|
|
|
dir: NotificationDirection;
|
|
|
|
lang: string;
|
|
|
|
body: string;
|
|
|
|
tag: string;
|
|
|
|
icon: string;
|
|
|
|
data: unknown;
|
2023-12-27 01:34:59 +01:00
|
|
|
close: () => void;
|
2023-10-12 02:17:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export type ClipboardDecrypter = {
|
|
|
|
version: number;
|
|
|
|
key: Uint8Array;
|
|
|
|
pasted: Promise<string>;
|
|
|
|
};
|
|
|
|
|
|
|
|
export type ElectronBridge = {
|
2023-12-27 01:34:59 +01:00
|
|
|
send_event: (eventName: string | symbol, ...args: unknown[]) => boolean;
|
|
|
|
on_event: ((
|
2023-10-12 02:17:19 +02:00
|
|
|
eventName: "logout" | "show-keyboard-shortcuts" | "show-notification-settings",
|
|
|
|
listener: () => void,
|
2023-12-27 01:34:59 +01:00
|
|
|
) => void) &
|
|
|
|
((
|
|
|
|
eventName: "send_notification_reply_message",
|
|
|
|
listener: (message_id: unknown, reply: unknown) => void,
|
|
|
|
) => void);
|
|
|
|
new_notification?: (
|
2023-10-12 02:17:19 +02:00
|
|
|
title: string,
|
|
|
|
options: NotificationOptions,
|
|
|
|
dispatch: (type: string, eventInit: EventInit) => boolean,
|
2023-12-27 01:34:59 +01:00
|
|
|
) => NotificationData;
|
|
|
|
get_idle_on_system?: () => boolean;
|
|
|
|
get_last_active_on_system?: () => number;
|
|
|
|
get_send_notification_reply_message_supported?: () => boolean;
|
|
|
|
set_send_notification_reply_message_supported?: (value: boolean) => void;
|
|
|
|
decrypt_clipboard?: (version: number) => ClipboardDecrypter;
|
2023-10-12 02:17:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
declare global {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
|
|
|
interface Window {
|
2024-10-01 00:04:14 +02:00
|
|
|
electron_bridge?: ElectronBridge | Element;
|
2023-10-12 02:17:19 +02:00
|
|
|
}
|
|
|
|
}
|
2024-10-01 00:04:14 +02:00
|
|
|
|
|
|
|
// Check for Element for extra defense against DOM clobbering attacks
|
|
|
|
export const electron_bridge: ElectronBridge | undefined =
|
|
|
|
window.electron_bridge instanceof Element ? undefined : window.electron_bridge;
|