Problem: the hexagonal refactor churns the backend tree for nine more phases; the UI delivery stack (web/ SPA, cmd/desktop Wails wrapper, compose/web image) must move to its own repo first so doc/layout rewrites land once on a backend-only tree. Change: - New repo git.hubris.network/dtoro/oikos-web (v0.33.0): web/, desktop/ (updateURL repointed to oikos-web releases), compose/, own CI (web + desktop jobs), own deploy script (CI-green gate, TOCTOU guard, version-tagged images, prune-to-3), own webhook receiver on :9798 + launchd unit, own compose project publishing the same 8091:80. - Cutover executed on mac-mini in order: oikos stack's web service stopped+removed, oikos-web project brought up on 8091; outer Caddy untouched (targets the published port) — serving + Authentik flow + /wails 404 quirk verified post-cutover. - Stripped from oikos: web/, cmd/desktop/, compose/web/, desktop CI workflow, ci.yml web job, Makefile ui/desktop/desktop-package/install targets, the compose web service, oikos-web from deploy.sh's fallback prune list; wails + go-keyring dropped from go.mod, vendor synced. - README / CONTRIBUTING / AGENTS.md / .agents dev+operations docs now point at the new repo; mbse + mascot design docs carry a path note. Risk: production SPA serving depends on the new pipeline now; rollback is versioned-image re-up of the old web service from a pre-split checkout (port 8091). Desktop builds installed before the split still check dtoro/oikos releases — one manual reinstall, noted in the oikos-web release notes. Verification: go vet, make test (race), make generate-check, golangci (no new findings; baseline down 400→365); post-cutover curls — localhost:8091 200, /wails/runtime.js 404, outer Caddy 302 Authentik.
148 lines
5.9 KiB
JavaScript
148 lines
5.9 KiB
JavaScript
"use strict";
|
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
if (k2 === undefined) k2 = k;
|
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
}
|
|
Object.defineProperty(o, k2, desc);
|
|
}) : (function(o, m, k, k2) {
|
|
if (k2 === undefined) k2 = k;
|
|
o[k2] = m[k];
|
|
}));
|
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
}) : function(o, v) {
|
|
o["default"] = v;
|
|
});
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
if (mod && mod.__esModule) return mod;
|
|
var result = {};
|
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
__setModuleDefault(result, mod);
|
|
return result;
|
|
};
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.HttpProxyAgent = void 0;
|
|
const net = __importStar(require("net"));
|
|
const tls = __importStar(require("tls"));
|
|
const debug_1 = __importDefault(require("debug"));
|
|
const events_1 = require("events");
|
|
const agent_base_1 = require("agent-base");
|
|
const url_1 = require("url");
|
|
const debug = (0, debug_1.default)('http-proxy-agent');
|
|
/**
|
|
* The `HttpProxyAgent` implements an HTTP Agent subclass that connects
|
|
* to the specified "HTTP proxy server" in order to proxy HTTP requests.
|
|
*/
|
|
class HttpProxyAgent extends agent_base_1.Agent {
|
|
constructor(proxy, opts) {
|
|
super(opts);
|
|
this.proxy = typeof proxy === 'string' ? new url_1.URL(proxy) : proxy;
|
|
this.proxyHeaders = opts?.headers ?? {};
|
|
debug('Creating new HttpProxyAgent instance: %o', this.proxy.href);
|
|
// Trim off the brackets from IPv6 addresses
|
|
const host = (this.proxy.hostname || this.proxy.host).replace(/^\[|\]$/g, '');
|
|
const port = this.proxy.port
|
|
? parseInt(this.proxy.port, 10)
|
|
: this.proxy.protocol === 'https:'
|
|
? 443
|
|
: 80;
|
|
this.connectOpts = {
|
|
...(opts ? omit(opts, 'headers') : null),
|
|
host,
|
|
port,
|
|
};
|
|
}
|
|
addRequest(req, opts) {
|
|
req._header = null;
|
|
this.setRequestProps(req, opts);
|
|
// @ts-expect-error `addRequest()` isn't defined in `@types/node`
|
|
super.addRequest(req, opts);
|
|
}
|
|
setRequestProps(req, opts) {
|
|
const { proxy } = this;
|
|
const protocol = opts.secureEndpoint ? 'https:' : 'http:';
|
|
const hostname = req.getHeader('host') || 'localhost';
|
|
const base = `${protocol}//${hostname}`;
|
|
const url = new url_1.URL(req.path, base);
|
|
if (opts.port !== 80) {
|
|
url.port = String(opts.port);
|
|
}
|
|
// Change the `http.ClientRequest` instance's "path" field
|
|
// to the absolute path of the URL that will be requested.
|
|
req.path = String(url);
|
|
// Inject the `Proxy-Authorization` header if necessary.
|
|
const headers = typeof this.proxyHeaders === 'function'
|
|
? this.proxyHeaders()
|
|
: { ...this.proxyHeaders };
|
|
if (proxy.username || proxy.password) {
|
|
const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`;
|
|
headers['Proxy-Authorization'] = `Basic ${Buffer.from(auth).toString('base64')}`;
|
|
}
|
|
if (!headers['Proxy-Connection']) {
|
|
headers['Proxy-Connection'] = this.keepAlive
|
|
? 'Keep-Alive'
|
|
: 'close';
|
|
}
|
|
for (const name of Object.keys(headers)) {
|
|
const value = headers[name];
|
|
if (value) {
|
|
req.setHeader(name, value);
|
|
}
|
|
}
|
|
}
|
|
async connect(req, opts) {
|
|
req._header = null;
|
|
if (!req.path.includes('://')) {
|
|
this.setRequestProps(req, opts);
|
|
}
|
|
// At this point, the http ClientRequest's internal `_header` field
|
|
// might have already been set. If this is the case then we'll need
|
|
// to re-generate the string since we just changed the `req.path`.
|
|
let first;
|
|
let endOfHeaders;
|
|
debug('Regenerating stored HTTP header string for request');
|
|
req._implicitHeader();
|
|
if (req.outputData && req.outputData.length > 0) {
|
|
debug('Patching connection write() output buffer with updated header');
|
|
first = req.outputData[0].data;
|
|
endOfHeaders = first.indexOf('\r\n\r\n') + 4;
|
|
req.outputData[0].data =
|
|
req._header + first.substring(endOfHeaders);
|
|
debug('Output buffer: %o', req.outputData[0].data);
|
|
}
|
|
// Create a socket connection to the proxy server.
|
|
let socket;
|
|
if (this.proxy.protocol === 'https:') {
|
|
debug('Creating `tls.Socket`: %o', this.connectOpts);
|
|
socket = tls.connect(this.connectOpts);
|
|
}
|
|
else {
|
|
debug('Creating `net.Socket`: %o', this.connectOpts);
|
|
socket = net.connect(this.connectOpts);
|
|
}
|
|
// Wait for the socket's `connect` event, so that this `callback()`
|
|
// function throws instead of the `http` request machinery. This is
|
|
// important for i.e. `PacProxyAgent` which determines a failed proxy
|
|
// connection via the `callback()` function throwing.
|
|
await (0, events_1.once)(socket, 'connect');
|
|
return socket;
|
|
}
|
|
}
|
|
HttpProxyAgent.protocols = ['http', 'https'];
|
|
exports.HttpProxyAgent = HttpProxyAgent;
|
|
function omit(obj, ...keys) {
|
|
const ret = {};
|
|
let key;
|
|
for (key in obj) {
|
|
if (!keys.includes(key)) {
|
|
ret[key] = obj[key];
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
//# sourceMappingURL=index.js.map
|