Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

refactor(core): isolate unchanged relay origin validation [H5]

Corey Olsonf59b806076b6
diff --git a/src/relay-origin.js b/src/relay-origin.js
new file mode 100644
index 00000000..e2cf0eba
--- /dev/null
+++ b/src/relay-origin.js
@@ -0,0 +1,13 @@
+/** Validate relay origins independently of link state or transport [H5]. */
+import { Refused } from './refused.js';
+
+/** Require a trusted origin; HTTP exists only for loopback development and test relays. */
+export function relayOrigin(address) {
+ let url;
+ try { url = new URL(address); } catch { throw new Refused('RELAY_URL', 'use an HTTPS relay address, such as https://app.pullboard.dev'); }
+ if (url.username || url.password || url.search || url.hash || url.pathname !== '/' ||
+ (url.protocol !== 'https:' && !(url.protocol === 'http:' && ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname)))) {
+ throw new Refused('RELAY_URL', 'use an HTTPS origin without credentials, a path, query or fragment; loopback HTTP is allowed for a local relay');
+ }
+ return url.origin;
+}
diff --git a/src/relay.js b/src/relay.js
index b1c1a9bb..4bb74bfd 100644
--- a/src/relay.js
+++ b/src/relay.js
@@ -111,6 +111,8 @@ import {
import { stampCoordinatorHolder } from './coordinator-hold.js';
import { Refused } from './refused.js';
import { landingRelayCallbacks } from './landing-relay.js';
+import { relayOrigin } from './relay-origin.js';
+export { relayOrigin };
import { refusalFromReceipt } from './recorded-refusal.js';
import { relayNotices } from './relay-notices.js';
import {
@@ -157,16 +159,6 @@ const DELETION_NOTICES = new WeakSet();
const ORDERED_MOVE_COMMANDS = new Set(['add', 'edit', 'fact', 'escalate', 'run', 'sweep', 'next', 'claim', 'hold', 'release',
'submit', 'done', 'verify', 'merged', 'land', 'withdraw', 'refreeze', 'shout', 'answer', 'pass', 'import', 'milestone', 'takeover', 'forget', 'join', 'worktree']);
-/** Require a trusted origin; HTTP exists only for loopback development and test relays. */
-export function relayOrigin(address) {
- let url;
- try { url = new URL(address); } catch { throw new Refused('RELAY_URL', 'use an HTTPS relay address, such as https://app.pullboard.dev'); }
- if (url.username || url.password || url.search || url.hash || url.pathname !== '/' ||
- (url.protocol !== 'https:' && !(url.protocol === 'http:' && ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname)))) {
- throw new Refused('RELAY_URL', 'use an HTTPS origin without credentials, a path, query or fragment; loopback HTTP is allowed for a local relay');
- }
- return url.origin;
-}
/** Resolve the actual GitHub origin; optional discovery leaves ineligible local projects alone. */
export function originRepository(root, { optional = false } = {}) {
const remote = tryGit(root, ['remote', 'get-url', 'origin']);