Add Chrome extension cookie bridge for session import
Users logged into Alta in Chrome can now send their session cookie to the running Electron app via a local HTTP server on port 18247, eliminating the need for re-authentication. - main.js: HTTP cookie server with CORS, token, domain validation - preload.js: onExtensionCookie push-pattern IPC bridge - renderer.js: handleExtensionCookie sets session, fetches devices - chrome-extension/: Manifest V3 extension with popup UI - CLAUDE.md: updated architecture docs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+43
-2
@@ -996,6 +996,44 @@ async function deleteProfile(profileId) {
|
||||
|
||||
// toggleCookieSection is attached via addEventListener in the event listeners section above
|
||||
|
||||
// Handle cookie received from Chrome extension via local HTTP bridge
|
||||
async function handleExtensionCookie(data) {
|
||||
const { deploymentUrl, cookies, cookieValue } = data;
|
||||
|
||||
// If already connected, disconnect first
|
||||
if (sessionData.isConnected) {
|
||||
handleDisconnect();
|
||||
}
|
||||
|
||||
// Set session state from extension cookie
|
||||
sessionData.deploymentUrl = deploymentUrl;
|
||||
sessionData.cookies = cookies;
|
||||
sessionData.isConnected = true;
|
||||
|
||||
showStatus(connectionStatus, `Connected via Chrome extension to ${deploymentUrl}`, 'success');
|
||||
updateConnectionStatus(true);
|
||||
updateButtonStates();
|
||||
|
||||
// Auto-populate cookie key and expand cookie proxy section
|
||||
cookieKey.value = cookieValue;
|
||||
const cookieContent = document.getElementById('cookieProxyContent');
|
||||
const cookieIcon = document.getElementById('cookieCollapseIcon');
|
||||
if (cookieContent.style.display === 'none') {
|
||||
cookieContent.style.display = 'block';
|
||||
cookieIcon.textContent = '\u25B2';
|
||||
cookieIcon.classList.add('expanded');
|
||||
}
|
||||
updateCookieProxyButtonStates();
|
||||
|
||||
// Fetch devices
|
||||
try {
|
||||
await handleGetDevices();
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch devices after extension cookie:', err);
|
||||
showStatus(deviceStatus, 'Connected, but failed to load devices.', 'warning');
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize the app
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
console.log('Alta Video Camera Proxy loaded');
|
||||
@@ -1003,10 +1041,13 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
// Initialize connection status
|
||||
updateConnectionStatus(false);
|
||||
updateButtonStates();
|
||||
|
||||
|
||||
// Listen for cookies pushed from Chrome extension
|
||||
window.electronAPI.onExtensionCookie(handleExtensionCookie);
|
||||
|
||||
// Load saved profiles
|
||||
await loadProfiles();
|
||||
|
||||
|
||||
// Check camera proxy executable availability
|
||||
await checkCameraProxyAvailability();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user