A relay on jai (server/bubble_relay.py, stdlib + SQLite, tailscale address only, bearer token) carries sealed blobs between the desktop and the Rabbit: AES-256-GCM with a key the desktop makes and hands over USB (Sync to Rabbit), so jai can neither read nor forge anything. It deletes what's been picked up, and anything after 14 days. - Desktop (src/main/relay.ts): "Rabbit SIM" is a number to text from, groups included; the SIM's history and new texts arrive; older photos are fetched when shown; names and read/unread/archived go both ways. Settings → Rabbit relay connects it. - Rabbit (Relay.java, RelayJob): no timer of its own for the battery; it rides along with the background checks, plus one network job after a text, a send or a swipe. Each send from the desktop goes out at most once and not after a day. Plain http only to jai and localhost (network_security_config). - scripts/deploy-jai.sh; tests: server unit tests, an end-to-end relay test, and DEVICE=1 relay.device.test.ts against the dev app.
65 lines
3.6 KiB
TypeScript
65 lines
3.6 KiB
TypeScript
import { contextBridge, ipcRenderer, type IpcRendererEvent } from 'electron'
|
|
import type { Api } from '@shared/api'
|
|
|
|
function on<T extends unknown[]>(channel: string, cb: (...args: T) => void): () => void {
|
|
const listener = (_e: IpcRendererEvent, ...args: unknown[]): void => cb(...(args as T))
|
|
ipcRenderer.on(channel, listener)
|
|
return () => ipcRenderer.removeListener(channel, listener)
|
|
}
|
|
|
|
const api: Api = {
|
|
getState: () => ipcRenderer.invoke('getState'),
|
|
testCredentials: (creds) => ipcRenderer.invoke('testCredentials', creds),
|
|
saveSetup: (creds, settings) => ipcRenderer.invoke('saveSetup', creds, settings),
|
|
updateSettings: (settings) => ipcRenderer.invoke('updateSettings', settings),
|
|
setTheme: (theme) => ipcRenderer.invoke('setTheme', theme),
|
|
setIcon: (icon) => ipcRenderer.invoke('setIcon', icon),
|
|
signOut: () => ipcRenderer.invoke('signOut'),
|
|
connectGoogleVoice: () => ipcRenderer.invoke('connectGoogleVoice'),
|
|
connectGoogleVoiceCookies: (text) => ipcRenderer.invoke('connectGoogleVoiceCookies', text),
|
|
disconnectGoogleVoice: () => ipcRenderer.invoke('disconnectGoogleVoice'),
|
|
rabbitStatus: () => ipcRenderer.invoke('rabbitStatus'),
|
|
rabbitInstall: (mode) => ipcRenderer.invoke('rabbitInstall', mode),
|
|
rabbitSync: () => ipcRenderer.invoke('rabbitSync'),
|
|
onRabbitProgress: (cb) => on('rabbitProgress', cb),
|
|
relayStatus: () => ipcRenderer.invoke('relayStatus'),
|
|
relayConnect: (url, token) => ipcRenderer.invoke('relayConnect', url, token),
|
|
relayDisconnect: () => ipcRenderer.invoke('relayDisconnect'),
|
|
onRelayStatus: (cb) => on('relayStatus', cb),
|
|
|
|
listContacts: () => ipcRenderer.invoke('listContacts'),
|
|
listAddressBooks: () => ipcRenderer.invoke('listAddressBooks'),
|
|
addContact: (c) => ipcRenderer.invoke('addContact', c),
|
|
listConversations: () => ipcRenderer.invoke('listConversations'),
|
|
getMessages: (did, contact) => ipcRenderer.invoke('getMessages', did, contact),
|
|
markRead: (did, contact) => ipcRenderer.invoke('markRead', did, contact),
|
|
markUnread: (did, contact) => ipcRenderer.invoke('markUnread', did, contact),
|
|
setArchived: (did, contact, archived) => ipcRenderer.invoke('setArchived', did, contact, archived),
|
|
setName: (did, contact, name) => ipcRenderer.invoke('setName', did, contact, name),
|
|
getDrafts: () => ipcRenderer.invoke('getDrafts'),
|
|
setDraft: (contact, text) => ipcRenderer.invoke('setDraft', contact, text),
|
|
search: (query, scope) => ipcRenderer.invoke('search', query, scope),
|
|
send: (did, contact, text, attachments) => ipcRenderer.invoke('send', did, contact, text, attachments),
|
|
deleteFailed: (id) => ipcRenderer.invoke('deleteFailed', id),
|
|
retryFailed: (id) => ipcRenderer.invoke('retryFailed', id),
|
|
saveMedia: (id, index) => ipcRenderer.invoke('saveMedia', id, index),
|
|
exportChat: (did, contact, opts) => ipcRenderer.invoke('exportChat', did, contact, opts),
|
|
readMedia: (id, index) => ipcRenderer.invoke('readMedia', id, index),
|
|
copyImage: (png) => ipcRenderer.invoke('copyImage', png),
|
|
|
|
syncStatus: () => ipcRenderer.invoke('syncStatus'),
|
|
pollNow: () => ipcRenderer.invoke('pollNow'),
|
|
openDataFolder: () => ipcRenderer.invoke('openDataFolder'),
|
|
snapshotNow: () => ipcRenderer.invoke('snapshotNow'),
|
|
chooseDataDir: () => ipcRenderer.invoke('chooseDataDir'),
|
|
|
|
onMessages: (cb) => on('messages', cb),
|
|
onConversationsChanged: (cb) => on('conversationsChanged', cb),
|
|
onSyncStatus: (cb) => on('syncStatus', cb),
|
|
onContactsChanged: (cb) => on('contactsChanged', cb),
|
|
onStateChanged: (cb) => on('stateChanged', cb),
|
|
onOpenConversation: (cb) => on('openConversation', cb)
|
|
}
|
|
|
|
contextBridge.exposeInMainWorld('api', api)
|