Files
seedit/electron/src/preload.ts
Tom (plebeius.eth) dc43aeb993 feat(submit page): add media file upload
On desktop or android, the user can drop or select a media file in the upload box, which automatically uploads it to catbox.moe in the background, and pastes the direct link to the media in the url field.
2025-03-19 21:40:24 +01:00

15 lines
609 B
TypeScript

import { contextBridge, ipcRenderer } from 'electron';
// Expose protected methods that allow the renderer process to use
// the ipcRenderer without exposing the entire object
contextBridge.exposeInMainWorld('electron', {
invoke: (channel: string, ...args: any[]) => {
// whitelist channels
const validChannels = ['plugin:file-uploader:pickAndUploadMedia', 'plugin:file-uploader:uploadMedia', 'plugin:file-uploader:pickMedia'];
if (validChannels.includes(channel)) {
return ipcRenderer.invoke(channel, ...args);
}
throw new Error(`Unauthorized IPC channel: ${channel}`);
},
});