Files
XHChat/Desktop/src/preload.ts
T

16 lines
890 B
TypeScript

import { contextBridge, ipcRenderer } from 'electron'
const apiArgument = process.argv.find((value) => value.startsWith('--xhchat-api='))
contextBridge.exposeInMainWorld('xhchat', {
apiBase: apiArgument?.slice('--xhchat-api='.length),
signChallenge: (username: string, challenge: string) => ipcRenderer.invoke('device:sign', username, challenge),
openBrowser: (url?: string) => ipcRenderer.invoke('browser:open', url),
allowVoiceRecording: () => ipcRenderer.invoke('voice:allow'),
endVoiceRecording: () => ipcRenderer.invoke('voice:end'),
signMls: (username: string, kind: string, user: string, device: string, value: Uint8Array) =>
ipcRenderer.invoke('device:sign-mls', username, kind, user, device, value),
protectMls: (key: string) => ipcRenderer.invoke('device:protect-mls', key),
unprotectMls: (key: string) => ipcRenderer.invoke('device:unprotect-mls', key),
})