fix: integrate hardened APT security boundary
This commit is contained in:
+22
-34
@@ -1,38 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
const { contextBridge, ipcRenderer } = require('electron');
|
||||
|
||||
// Expose protected methods that allow the renderer process to use
|
||||
// the ipcRenderer without exposing the entire object
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
getDevices: (params) => ipcRenderer.invoke('api-get-devices', params),
|
||||
getDeviceSites: (params) => ipcRenderer.invoke('api-get-device-sites', params),
|
||||
getAuthInfo: (params) => ipcRenderer.invoke('api-get-auth-info', params),
|
||||
function onConnectionStateChanged(callback) {
|
||||
if (typeof callback !== 'function') return () => {};
|
||||
const listener = (_event, state) => callback(state);
|
||||
ipcRenderer.on('connection-state-changed', listener);
|
||||
return () => ipcRenderer.removeListener('connection-state-changed', listener);
|
||||
}
|
||||
|
||||
// Camera proxy functionality
|
||||
launchCookieCameraProxy: (params) => ipcRenderer.invoke('camera-proxy-cookie-launch', params),
|
||||
stopCameraProxy: (processId) => ipcRenderer.invoke('camera-proxy-stop', { processId }),
|
||||
|
||||
// Extension cookie bridge (push from main process)
|
||||
onExtensionCookie: (callback) => {
|
||||
ipcRenderer.on('extension-cookie-received', (event, data) => {
|
||||
try {
|
||||
callback(data);
|
||||
} catch (error) {
|
||||
console.error('Extension cookie handler error:', error);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// Self-update functionality
|
||||
contextBridge.exposeInMainWorld('electronAPI', Object.freeze({
|
||||
getDevices: () => ipcRenderer.invoke('get-devices'),
|
||||
getDeviceSites: () => ipcRenderer.invoke('get-device-sites'),
|
||||
getAuthInfo: () => ipcRenderer.invoke('get-auth-info'),
|
||||
launchProxy: (deviceId) => ipcRenderer.invoke('launch-proxy', deviceId),
|
||||
stopProxy: (key) => ipcRenderer.invoke('stop-proxy', key),
|
||||
disconnect: () => ipcRenderer.invoke('disconnect'),
|
||||
getConnectionState: () => ipcRenderer.invoke('get-connection-state'),
|
||||
checkForUpdates: () => ipcRenderer.invoke('check-for-updates'),
|
||||
downloadAndInstallUpdate: (params) => ipcRenderer.invoke('download-and-install-update', params),
|
||||
getCurrentVersion: () => ipcRenderer.invoke('get-current-version'),
|
||||
onUpdateDownloadProgress: (callback) => {
|
||||
ipcRenderer.on('update-download-progress', (event, data) => {
|
||||
try {
|
||||
callback(data);
|
||||
} catch (error) {
|
||||
console.error('Update download progress handler error:', error);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
openFixedReleasesPage: () => ipcRenderer.invoke('open-fixed-releases-page'),
|
||||
rotatePairing: () => ipcRenderer.invoke('rotate-pairing'),
|
||||
revokePairing: () => ipcRenderer.invoke('revoke-pairing'),
|
||||
getPairingStatus: () => ipcRenderer.invoke('get-pairing-status'),
|
||||
onConnectionStateChanged,
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user