Add a packaged-client runtime boundary so the shared UI can talk to local, desktop, remote, and VS Code runtimes through the right transport instead of assuming one same-origin web server. Centralize OpenChamber-owned API access behind RuntimeAPIs, runtimeFetch, and runtime URL helpers, while keeping official OpenCode traffic on the SDK path. Support runtime switching, remote host selection, desktop client credentials, and headless connection links for pairing packaged clients with remote OpenChamber servers. Harden the new auth model by moving long-lived client tokens out of browser URLs, introducing short-lived scoped URL tokens for browser-owned transports, restricting URL-token access to explicit readable/realtime routes, and making client-token management session-scoped or self-scoped as appropriate. Update browser-owned assets and preview proxy flows to work with the split runtime model, including authenticated project icons, preview token propagation, CSP-safe preview bridge injection, and preview proxy auth that survives short-lived URL-token expiry. Tighten Electron security boundaries for packaged clients by gating privileged preload state to trusted origins and requiring explicit confirmation before connect deep-links import or switch remote runtimes. Also refresh agent guidance and project skills so future runtime/API, auth, preview, UI, CLI, settings, locale, and drag-to-reorder work follows the new architecture.
92 lines
2.5 KiB
JavaScript
92 lines
2.5 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
/**
|
|
* Fix for http-proxy package util._extend deprecation warning
|
|
* This script patches the http-proxy package to use Object.assign instead of util._extend
|
|
*/
|
|
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
function fixHttpProxyDeprecation() {
|
|
try {
|
|
const candidateDirs = [
|
|
path.join(__dirname, 'node_modules', 'http-proxy', 'lib', 'http-proxy'),
|
|
];
|
|
|
|
const bunStoreDir = path.join(__dirname, 'node_modules', '.bun');
|
|
if (fs.existsSync(bunStoreDir)) {
|
|
for (const entry of fs.readdirSync(bunStoreDir, { withFileTypes: true })) {
|
|
if (!entry.isDirectory() || !entry.name.startsWith('http-proxy@')) continue;
|
|
candidateDirs.push(path.join(bunStoreDir, entry.name, 'node_modules', 'http-proxy', 'lib', 'http-proxy'));
|
|
}
|
|
}
|
|
|
|
for (const httpProxyDir of candidateDirs) {
|
|
patchHttpProxyDir(httpProxyDir);
|
|
}
|
|
} catch {
|
|
// Silently handle errors - functionality is not affected
|
|
}
|
|
}
|
|
|
|
function patchHttpProxyDir(httpProxyDir) {
|
|
const indexPath = path.join(httpProxyDir, 'index.js');
|
|
const commonPath = path.join(httpProxyDir, 'common.js');
|
|
|
|
if (!fs.existsSync(indexPath) || !fs.existsSync(commonPath)) {
|
|
return;
|
|
}
|
|
|
|
if (fs.existsSync(indexPath)) {
|
|
let content = fs.readFileSync(indexPath, 'utf8');
|
|
|
|
let indexPatched = false;
|
|
|
|
if (content.includes("require('util')._extend")) {
|
|
content = content.replace(
|
|
/extend\s*=\s*require\('util'\)\._extend,/,
|
|
"extend = Object.assign,"
|
|
);
|
|
indexPatched = true;
|
|
}
|
|
|
|
if (content.includes("require('util').inherits")) {
|
|
content = content.replace(
|
|
/require\('util'\)\.inherits\((\w+),\s*(\w+)\);/,
|
|
"Object.setPrototypeOf($1.prototype, $2.prototype);"
|
|
);
|
|
indexPatched = true;
|
|
}
|
|
|
|
if (indexPatched) {
|
|
fs.writeFileSync(indexPath, content, 'utf8');
|
|
}
|
|
}
|
|
|
|
if (fs.existsSync(commonPath)) {
|
|
let content = fs.readFileSync(commonPath, 'utf8');
|
|
|
|
let commonPatched = false;
|
|
|
|
if (content.includes("require('util')._extend")) {
|
|
content = content.replace(
|
|
/extend\s*=\s*require\('util'\)\._extend,/,
|
|
"extend = Object.assign,"
|
|
);
|
|
commonPatched = true;
|
|
}
|
|
|
|
if (commonPatched) {
|
|
fs.writeFileSync(commonPath, content, 'utf8');
|
|
}
|
|
}
|
|
}
|
|
|
|
// Run the fix
|
|
fixHttpProxyDeprecation();
|