@claude-flow/plugin-agent-federation 1.0.0-alpha.9 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/a2a/agent-card.d.ts +130 -0
- package/dist/a2a/agent-card.d.ts.map +1 -0
- package/dist/a2a/agent-card.js +239 -0
- package/dist/a2a/agent-card.js.map +1 -0
- package/dist/a2a/consume.d.ts +34 -0
- package/dist/a2a/consume.d.ts.map +1 -0
- package/dist/a2a/consume.js +69 -0
- package/dist/a2a/consume.js.map +1 -0
- package/dist/a2a/planner-descriptor.d.ts +40 -0
- package/dist/a2a/planner-descriptor.d.ts.map +1 -0
- package/dist/a2a/planner-descriptor.js +100 -0
- package/dist/a2a/planner-descriptor.js.map +1 -0
- package/dist/a2a/well-known.d.ts +46 -0
- package/dist/a2a/well-known.d.ts.map +1 -0
- package/dist/a2a/well-known.js +84 -0
- package/dist/a2a/well-known.js.map +1 -0
- package/dist/application/claim-checker.d.ts +27 -0
- package/dist/application/claim-checker.d.ts.map +1 -0
- package/dist/application/claim-checker.js +46 -0
- package/dist/application/claim-checker.js.map +1 -0
- package/dist/application/federation-breaker-service.d.ts +11 -1
- package/dist/application/federation-breaker-service.d.ts.map +1 -1
- package/dist/application/federation-breaker-service.js +12 -10
- package/dist/application/federation-breaker-service.js.map +1 -1
- package/dist/application/federation-coordinator.d.ts +48 -3
- package/dist/application/federation-coordinator.d.ts.map +1 -1
- package/dist/application/federation-coordinator.js +112 -23
- package/dist/application/federation-coordinator.js.map +1 -1
- package/dist/application/inbound-dispatcher.d.ts +114 -0
- package/dist/application/inbound-dispatcher.d.ts.map +1 -0
- package/dist/application/inbound-dispatcher.js +356 -0
- package/dist/application/inbound-dispatcher.js.map +1 -0
- package/dist/application/spend-reporter.d.ts +77 -0
- package/dist/application/spend-reporter.d.ts.map +1 -1
- package/dist/application/spend-reporter.js +76 -0
- package/dist/application/spend-reporter.js.map +1 -1
- package/dist/application/trust-evaluator.d.ts +32 -0
- package/dist/application/trust-evaluator.d.ts.map +1 -1
- package/dist/application/trust-evaluator.js +47 -0
- package/dist/application/trust-evaluator.js.map +1 -1
- package/dist/bin.d.ts +1 -1
- package/dist/bin.js +2 -2
- package/dist/bin.js.map +1 -1
- package/dist/cli-commands.d.ts.map +1 -1
- package/dist/cli-commands.js +125 -6
- package/dist/cli-commands.js.map +1 -1
- package/dist/domain/services/discovery-service.d.ts +18 -1
- package/dist/domain/services/discovery-service.d.ts.map +1 -1
- package/dist/domain/services/discovery-service.js +21 -0
- package/dist/domain/services/discovery-service.js.map +1 -1
- package/dist/domain/services/handshake-service.d.ts +10 -0
- package/dist/domain/services/handshake-service.d.ts.map +1 -1
- package/dist/domain/services/handshake-service.js +28 -0
- package/dist/domain/services/handshake-service.js.map +1 -1
- package/dist/domain/services/routing-service.d.ts +3 -0
- package/dist/domain/services/routing-service.d.ts.map +1 -1
- package/dist/domain/services/routing-service.js +4 -1
- package/dist/domain/services/routing-service.js.map +1 -1
- package/dist/domain/services/wg-firewall-service.d.ts +71 -0
- package/dist/domain/services/wg-firewall-service.d.ts.map +1 -0
- package/dist/domain/services/wg-firewall-service.js +194 -0
- package/dist/domain/services/wg-firewall-service.js.map +1 -0
- package/dist/domain/services/wg-mesh-service.d.ts +156 -0
- package/dist/domain/services/wg-mesh-service.d.ts.map +1 -0
- package/dist/domain/services/wg-mesh-service.js +292 -0
- package/dist/domain/services/wg-mesh-service.js.map +1 -0
- package/dist/domain/services/wg-witness-service.d.ts +98 -0
- package/dist/domain/services/wg-witness-service.d.ts.map +1 -0
- package/dist/domain/services/wg-witness-service.js +122 -0
- package/dist/domain/services/wg-witness-service.js.map +1 -0
- package/dist/domain/value-objects/wg-config.d.ts +70 -0
- package/dist/domain/value-objects/wg-config.d.ts.map +1 -0
- package/dist/domain/value-objects/wg-config.js +104 -0
- package/dist/domain/value-objects/wg-config.js.map +1 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp-tools.d.ts +3 -1
- package/dist/mcp-tools.d.ts.map +1 -1
- package/dist/mcp-tools.js +114 -18
- package/dist/mcp-tools.js.map +1 -1
- package/dist/plugin.d.ts +2 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +174 -15
- package/dist/plugin.js.map +1 -1
- package/dist/transport/midstream-aware-loader.d.ts +72 -0
- package/dist/transport/midstream-aware-loader.d.ts.map +1 -0
- package/dist/transport/midstream-aware-loader.js +269 -0
- package/dist/transport/midstream-aware-loader.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/package.json +21 -5
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADR-111 Phase 4 — Trust-graded firewall projection.
|
|
3
|
+
*
|
|
4
|
+
* Projects the WG_NETWORK_GATES table (defined in wg-mesh-service.ts) into
|
|
5
|
+
* concrete kernel-firewall rules. Two backends:
|
|
6
|
+
*
|
|
7
|
+
* - `nftables` for Linux — atomic `nft -f <file>` loader, family `inet`,
|
|
8
|
+
* hook `input` (interface-scoped to the WG iface).
|
|
9
|
+
* - `pf` for macOS — `pfctl -a ruflo-fed -f <file>`, anchor-scoped so
|
|
10
|
+
* ruflo's rules don't collide with the operator's main pf ruleset.
|
|
11
|
+
*
|
|
12
|
+
* Like Phase 2's WgMeshService this is a **pure-projection** service: it
|
|
13
|
+
* returns rule strings + the shell command the operator runs. It never
|
|
14
|
+
* shells out or modifies kernel state itself. Operator review is mandatory
|
|
15
|
+
* because `pf` / `nft` reloads atomically replace the active ruleset for
|
|
16
|
+
* the targeted scope — a typo here can drop ssh.
|
|
17
|
+
*
|
|
18
|
+
* v1 scope: the four trust levels VERIFIED/ATTESTED/TRUSTED/PRIVILEGED.
|
|
19
|
+
* UNTRUSTED peers are never in the mesh (excluded by WgMeshService) so
|
|
20
|
+
* they don't need a firewall rule either — implicit drop policy.
|
|
21
|
+
*/
|
|
22
|
+
import { FederationNode } from '../entities/federation-node.js';
|
|
23
|
+
export type WgFirewallPlatform = 'linux-nftables' | 'darwin-pf';
|
|
24
|
+
export interface WgFirewallServiceConfig {
|
|
25
|
+
/** Target platform. Default: auto-detect from process.platform. */
|
|
26
|
+
readonly platform?: WgFirewallPlatform;
|
|
27
|
+
/** WG interface name to scope rules to. Defaults to `ruflo-fed`. */
|
|
28
|
+
readonly interfaceName?: string;
|
|
29
|
+
/** Where the operator should write the rule file. Used for the load-command string. */
|
|
30
|
+
readonly rulePath?: string;
|
|
31
|
+
/** pf anchor (macOS only). Defaults to `ruflo-fed`. */
|
|
32
|
+
readonly pfAnchor?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface WgFirewallRuleSet {
|
|
35
|
+
/** The full rule-file content the operator writes to disk. */
|
|
36
|
+
readonly content: string;
|
|
37
|
+
/** The shell command the operator runs to load it. */
|
|
38
|
+
readonly loadCmd: string;
|
|
39
|
+
/** Recommended file path (informational — the operator decides). */
|
|
40
|
+
readonly rulePath: string;
|
|
41
|
+
/** Per-peer rule projections for audit/inspection. */
|
|
42
|
+
readonly peerProjections: ReadonlyArray<{
|
|
43
|
+
readonly nodeId: string;
|
|
44
|
+
readonly trustLabel: string;
|
|
45
|
+
readonly meshIP: string;
|
|
46
|
+
readonly rules: readonly string[];
|
|
47
|
+
}>;
|
|
48
|
+
}
|
|
49
|
+
export declare class WgFirewallService {
|
|
50
|
+
private readonly platform;
|
|
51
|
+
private readonly interfaceName;
|
|
52
|
+
private readonly rulePath;
|
|
53
|
+
private readonly pfAnchor;
|
|
54
|
+
constructor(config?: WgFirewallServiceConfig);
|
|
55
|
+
getPlatform(): WgFirewallPlatform;
|
|
56
|
+
/**
|
|
57
|
+
* Project the current peer set into a complete rule file (nftables or pf)
|
|
58
|
+
* scoped to the WG interface.
|
|
59
|
+
*
|
|
60
|
+
* Peers below WG_MIN_MESH_TRUST (UNTRUSTED) are dropped — they have no
|
|
61
|
+
* mesh IP and shouldn't appear in firewall allow rules anyway. Peers
|
|
62
|
+
* without `metadata.wgMeshIP` are skipped (a stale manifest with no WG
|
|
63
|
+
* block; the mesh layer already excludes them).
|
|
64
|
+
*/
|
|
65
|
+
projectRules(peers: readonly FederationNode[]): WgFirewallRuleSet;
|
|
66
|
+
private renderNftables;
|
|
67
|
+
private renderPf;
|
|
68
|
+
private defaultRulePath;
|
|
69
|
+
private trustLabel;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=wg-firewall-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wg-firewall-service.d.ts","sourceRoot":"","sources":["../../../src/domain/services/wg-firewall-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAIhE,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,GAAG,WAAW,CAAC;AAEhE,MAAM,WAAW,uBAAuB;IACtC,mEAAmE;IACnE,QAAQ,CAAC,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IACvC,oEAAoE;IACpE,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,uFAAuF;IACvF,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,uDAAuD;IACvD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,iBAAiB;IAChC,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,sDAAsD;IACtD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,sDAAsD;IACtD,QAAQ,CAAC,eAAe,EAAE,aAAa,CAAC;QACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;KACnC,CAAC,CAAC;CACJ;AAwDD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqB;IAC9C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;gBAEtB,MAAM,GAAE,uBAA4B;IAShD,WAAW,IAAI,kBAAkB;IAIjC;;;;;;;;OAQG;IACH,YAAY,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE,GAAG,iBAAiB;IAsCjE,OAAO,CAAC,cAAc;IAmCtB,OAAO,CAAC,QAAQ;IAyBhB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,UAAU;CASnB"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADR-111 Phase 4 — Trust-graded firewall projection.
|
|
3
|
+
*
|
|
4
|
+
* Projects the WG_NETWORK_GATES table (defined in wg-mesh-service.ts) into
|
|
5
|
+
* concrete kernel-firewall rules. Two backends:
|
|
6
|
+
*
|
|
7
|
+
* - `nftables` for Linux — atomic `nft -f <file>` loader, family `inet`,
|
|
8
|
+
* hook `input` (interface-scoped to the WG iface).
|
|
9
|
+
* - `pf` for macOS — `pfctl -a ruflo-fed -f <file>`, anchor-scoped so
|
|
10
|
+
* ruflo's rules don't collide with the operator's main pf ruleset.
|
|
11
|
+
*
|
|
12
|
+
* Like Phase 2's WgMeshService this is a **pure-projection** service: it
|
|
13
|
+
* returns rule strings + the shell command the operator runs. It never
|
|
14
|
+
* shells out or modifies kernel state itself. Operator review is mandatory
|
|
15
|
+
* because `pf` / `nft` reloads atomically replace the active ruleset for
|
|
16
|
+
* the targeted scope — a typo here can drop ssh.
|
|
17
|
+
*
|
|
18
|
+
* v1 scope: the four trust levels VERIFIED/ATTESTED/TRUSTED/PRIVILEGED.
|
|
19
|
+
* UNTRUSTED peers are never in the mesh (excluded by WgMeshService) so
|
|
20
|
+
* they don't need a firewall rule either — implicit drop policy.
|
|
21
|
+
*/
|
|
22
|
+
import { TrustLevel } from '../entities/trust-level.js';
|
|
23
|
+
import { WG_NETWORK_GATES, WG_MIN_MESH_TRUST } from './wg-mesh-service.js';
|
|
24
|
+
const DEFAULT_INTERFACE = 'ruflo-fed';
|
|
25
|
+
const DEFAULT_PF_ANCHOR = 'ruflo-fed';
|
|
26
|
+
function autoDetectPlatform() {
|
|
27
|
+
switch (process.platform) {
|
|
28
|
+
case 'linux': return 'linux-nftables';
|
|
29
|
+
case 'darwin': return 'darwin-pf';
|
|
30
|
+
default:
|
|
31
|
+
// Other platforms (win32/freebsd) — fall back to linux-nftables since
|
|
32
|
+
// most production federation hosts are linux. The operator can
|
|
33
|
+
// override via config.platform.
|
|
34
|
+
return 'linux-nftables';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Defense-in-depth: every value spliced into a rule line goes through this
|
|
39
|
+
* filter. Allows the chars `nft`/`pf` syntax actually needs and refuses
|
|
40
|
+
* anything else — a poisoned manifest can't escape the rule string.
|
|
41
|
+
*/
|
|
42
|
+
function assertSafeRuleArg(s, label) {
|
|
43
|
+
if (!/^[A-Za-z0-9_./:-]+$/.test(s)) {
|
|
44
|
+
throw new Error(`WgFirewallService: refusing unsafe ${label}: ${JSON.stringify(s)}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function projectRuleNftables(rule, srcIP) {
|
|
48
|
+
if (rule.proto === 'all') {
|
|
49
|
+
return ` ip saddr ${srcIP} accept`;
|
|
50
|
+
}
|
|
51
|
+
if (rule.port !== undefined) {
|
|
52
|
+
return ` ip saddr ${srcIP} ${rule.proto} dport ${rule.port} accept`;
|
|
53
|
+
}
|
|
54
|
+
if (rule.portRange) {
|
|
55
|
+
const [lo, hi] = rule.portRange;
|
|
56
|
+
return ` ip saddr ${srcIP} ${rule.proto} dport ${lo}-${hi} accept`;
|
|
57
|
+
}
|
|
58
|
+
throw new Error(`projectRuleNftables: rule missing port/portRange/all: ${JSON.stringify(rule)}`);
|
|
59
|
+
}
|
|
60
|
+
function projectRulePf(rule, iface, srcIP) {
|
|
61
|
+
if (rule.proto === 'all') {
|
|
62
|
+
return `pass in on ${iface} from ${srcIP} to any keep state`;
|
|
63
|
+
}
|
|
64
|
+
if (rule.port !== undefined) {
|
|
65
|
+
return `pass in on ${iface} proto ${rule.proto} from ${srcIP} to any port ${rule.port} keep state`;
|
|
66
|
+
}
|
|
67
|
+
if (rule.portRange) {
|
|
68
|
+
const [lo, hi] = rule.portRange;
|
|
69
|
+
return `pass in on ${iface} proto ${rule.proto} from ${srcIP} to any port ${lo}:${hi} keep state`;
|
|
70
|
+
}
|
|
71
|
+
throw new Error(`projectRulePf: rule missing port/portRange/all: ${JSON.stringify(rule)}`);
|
|
72
|
+
}
|
|
73
|
+
export class WgFirewallService {
|
|
74
|
+
platform;
|
|
75
|
+
interfaceName;
|
|
76
|
+
rulePath;
|
|
77
|
+
pfAnchor;
|
|
78
|
+
constructor(config = {}) {
|
|
79
|
+
this.platform = config.platform ?? autoDetectPlatform();
|
|
80
|
+
this.interfaceName = config.interfaceName ?? DEFAULT_INTERFACE;
|
|
81
|
+
assertSafeRuleArg(this.interfaceName, 'interfaceName');
|
|
82
|
+
this.pfAnchor = config.pfAnchor ?? DEFAULT_PF_ANCHOR;
|
|
83
|
+
assertSafeRuleArg(this.pfAnchor, 'pfAnchor');
|
|
84
|
+
this.rulePath = config.rulePath ?? this.defaultRulePath();
|
|
85
|
+
}
|
|
86
|
+
getPlatform() {
|
|
87
|
+
return this.platform;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Project the current peer set into a complete rule file (nftables or pf)
|
|
91
|
+
* scoped to the WG interface.
|
|
92
|
+
*
|
|
93
|
+
* Peers below WG_MIN_MESH_TRUST (UNTRUSTED) are dropped — they have no
|
|
94
|
+
* mesh IP and shouldn't appear in firewall allow rules anyway. Peers
|
|
95
|
+
* without `metadata.wgMeshIP` are skipped (a stale manifest with no WG
|
|
96
|
+
* block; the mesh layer already excludes them).
|
|
97
|
+
*/
|
|
98
|
+
projectRules(peers) {
|
|
99
|
+
const eligible = peers.filter(p => {
|
|
100
|
+
if (p.trustLevel < WG_MIN_MESH_TRUST)
|
|
101
|
+
return false;
|
|
102
|
+
const meshIP = p.metadata.wgMeshIP;
|
|
103
|
+
return typeof meshIP === 'string' && meshIP.length > 0;
|
|
104
|
+
});
|
|
105
|
+
const peerProjections = eligible.map(peer => {
|
|
106
|
+
const meshIP = peer.metadata.wgMeshIP.replace(/\/32$/, '');
|
|
107
|
+
assertSafeRuleArg(meshIP, 'meshIP');
|
|
108
|
+
const ruleSpecs = WG_NETWORK_GATES[peer.trustLevel];
|
|
109
|
+
const rules = ruleSpecs.map(r => this.platform === 'linux-nftables'
|
|
110
|
+
? projectRuleNftables(r, meshIP)
|
|
111
|
+
: projectRulePf(r, this.interfaceName, meshIP));
|
|
112
|
+
return {
|
|
113
|
+
nodeId: peer.nodeId,
|
|
114
|
+
trustLabel: this.trustLabel(peer.trustLevel),
|
|
115
|
+
meshIP: peer.metadata.wgMeshIP,
|
|
116
|
+
rules,
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
const content = this.platform === 'linux-nftables'
|
|
120
|
+
? this.renderNftables(peerProjections)
|
|
121
|
+
: this.renderPf(peerProjections);
|
|
122
|
+
return {
|
|
123
|
+
content,
|
|
124
|
+
loadCmd: this.platform === 'linux-nftables'
|
|
125
|
+
? `nft -f ${this.rulePath}`
|
|
126
|
+
: `pfctl -a ${this.pfAnchor} -f ${this.rulePath}`,
|
|
127
|
+
rulePath: this.rulePath,
|
|
128
|
+
peerProjections,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
renderNftables(projections) {
|
|
132
|
+
// Atomic nft script. The `flush` clears existing rules in the table
|
|
133
|
+
// before reload — same atomicity property nft itself guarantees.
|
|
134
|
+
// Default policy DROP so anything not explicitly allowed is rejected.
|
|
135
|
+
const lines = [];
|
|
136
|
+
lines.push('#!/usr/sbin/nft -f');
|
|
137
|
+
lines.push('# Generated by ruflo federation plugin — ADR-111 Phase 4.');
|
|
138
|
+
lines.push('# Operator MUST review before `nft -f`. A typo here can drop ssh.');
|
|
139
|
+
lines.push('# This file is overwritten on every peer-set change; do not hand-edit.');
|
|
140
|
+
lines.push('');
|
|
141
|
+
lines.push('table inet ruflo_fed {');
|
|
142
|
+
lines.push(' chain wg_input {');
|
|
143
|
+
lines.push(` type filter hook input priority 0; policy drop;`);
|
|
144
|
+
lines.push(` iifname "${this.interfaceName}" jump wg_peer_rules`);
|
|
145
|
+
lines.push(' }');
|
|
146
|
+
lines.push(' chain wg_peer_rules {');
|
|
147
|
+
if (projections.length === 0) {
|
|
148
|
+
lines.push(' # No ATTESTED+ peers in mesh.');
|
|
149
|
+
}
|
|
150
|
+
for (const p of projections) {
|
|
151
|
+
lines.push(` # peer ${p.nodeId} — trust=${p.trustLabel} mesh=${p.meshIP}`);
|
|
152
|
+
for (const rule of p.rules) {
|
|
153
|
+
lines.push(rule);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
lines.push(' }');
|
|
157
|
+
lines.push('}');
|
|
158
|
+
return lines.join('\n');
|
|
159
|
+
}
|
|
160
|
+
renderPf(projections) {
|
|
161
|
+
const lines = [];
|
|
162
|
+
lines.push('# Generated by ruflo federation plugin — ADR-111 Phase 4.');
|
|
163
|
+
lines.push('# Operator MUST review before `pfctl -f`. A typo here can drop ssh.');
|
|
164
|
+
lines.push(`# This anchor is scoped to ${this.pfAnchor}; main pf ruleset stays untouched.`);
|
|
165
|
+
lines.push('');
|
|
166
|
+
// Default within the anchor: pass nothing not explicitly allowed.
|
|
167
|
+
// The main ruleset's policy still applies; the anchor only adds allows.
|
|
168
|
+
if (projections.length === 0) {
|
|
169
|
+
lines.push('# No ATTESTED+ peers in mesh.');
|
|
170
|
+
}
|
|
171
|
+
for (const p of projections) {
|
|
172
|
+
lines.push(`# peer ${p.nodeId} — trust=${p.trustLabel} mesh=${p.meshIP}`);
|
|
173
|
+
for (const rule of p.rules) {
|
|
174
|
+
lines.push(rule);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return lines.join('\n');
|
|
178
|
+
}
|
|
179
|
+
defaultRulePath() {
|
|
180
|
+
return this.platform === 'linux-nftables'
|
|
181
|
+
? '/etc/nftables.d/ruflo-fed.nft'
|
|
182
|
+
: `/etc/pf.anchors/${this.pfAnchor}`;
|
|
183
|
+
}
|
|
184
|
+
trustLabel(level) {
|
|
185
|
+
switch (level) {
|
|
186
|
+
case TrustLevel.UNTRUSTED: return 'UNTRUSTED';
|
|
187
|
+
case TrustLevel.VERIFIED: return 'VERIFIED';
|
|
188
|
+
case TrustLevel.ATTESTED: return 'ATTESTED';
|
|
189
|
+
case TrustLevel.TRUSTED: return 'TRUSTED';
|
|
190
|
+
case TrustLevel.PRIVILEGED: return 'PRIVILEGED';
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=wg-firewall-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wg-firewall-service.js","sourceRoot":"","sources":["../../../src/domain/services/wg-firewall-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAmB,MAAM,sBAAsB,CAAC;AA+B5F,MAAM,iBAAiB,GAAG,WAAW,CAAC;AACtC,MAAM,iBAAiB,GAAG,WAAW,CAAC;AAEtC,SAAS,kBAAkB;IACzB,QAAQ,OAAO,CAAC,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AE,CAAC;IACzC,CAAC;IAEO,UAAU,CAAC,KAAiB;QAClC,QAAQ,KAAK,EAAE,CAAC;YACd,KAAK,UAAU,CAAC,SAAS,CAAC,CAAC,OAAO,WAAW,CAAC;YAC9C,KAAK,UAAU,CAAC,QAAQ,CAAC,CAAC,OAAO,UAAU,CAAC;YAC5C,KAAK,UAAU,CAAC,QAAQ,CAAC,CAAC,OAAO,UAAU,CAAC;YAC5C,KAAK,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,SAAS,CAAC;YAC1C,KAAK,UAAU,CAAC,UAAU,CAAC,CAAC,OAAO,YAAY,CAAC;QAClD,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADR-111 Phase 2 — WgMeshService.
|
|
3
|
+
*
|
|
4
|
+
* Pure-projection service: takes the federation peer registry + local
|
|
5
|
+
* WG identity and produces (a) a `wg-quick`-compatible config string,
|
|
6
|
+
* (b) per-peer `wg set` commands the operator runs to converge an
|
|
7
|
+
* already-running interface, and (c) the AllowedIPs slice that maps to
|
|
8
|
+
* each peer's trust level.
|
|
9
|
+
*
|
|
10
|
+
* Deliberately does NOT shell out. Bringing up a network interface
|
|
11
|
+
* requires root and modifies system state — per CLAUDE.md's
|
|
12
|
+
* destructive-actions guidance the service emits the commands; the
|
|
13
|
+
* operator (or a thin shell wrapper they audit) runs them.
|
|
14
|
+
*
|
|
15
|
+
* Phase 3 (breaker integration) consumes this service: peer state
|
|
16
|
+
* transitions invoke removeAllowedIPs/removePeer/restoreAllowedIPs,
|
|
17
|
+
* which produce commands without side effects.
|
|
18
|
+
*/
|
|
19
|
+
import { TrustLevel } from '../entities/trust-level.js';
|
|
20
|
+
import { FederationNode } from '../entities/federation-node.js';
|
|
21
|
+
import type { WgLocalKey } from '../value-objects/wg-config.js';
|
|
22
|
+
export interface WgPortRule {
|
|
23
|
+
readonly proto: 'tcp' | 'udp' | 'all';
|
|
24
|
+
readonly port?: number;
|
|
25
|
+
readonly portRange?: readonly [number, number];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Trust-level → reachability. ADR-111's `WG_NETWORK_GATES`.
|
|
29
|
+
*
|
|
30
|
+
* Note: WireGuard's `AllowedIPs` is L3 routing, not L4 ACL — these port
|
|
31
|
+
* rules describe what the L4 firewall (Phase 4: nftables/pf) should
|
|
32
|
+
* enforce. v1 (this phase) only produces the rules; Phase 4 projects
|
|
33
|
+
* them into kernel firewall syntax. Until then, callers using v1
|
|
34
|
+
* fall back to the simpler "AllowedIPs = peer's mesh IP" model (option
|
|
35
|
+
* (b) in the ADR — app-layer auth carries the access decision).
|
|
36
|
+
*/
|
|
37
|
+
export declare const WG_NETWORK_GATES: Record<TrustLevel, readonly WgPortRule[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Minimum trust level whose peers get a `[Peer]` block in the WG config.
|
|
40
|
+
* UNTRUSTED stays out of the mesh entirely — it's the explicit drop bucket.
|
|
41
|
+
*/
|
|
42
|
+
export declare const WG_MIN_MESH_TRUST: TrustLevel;
|
|
43
|
+
export interface WgPeerFields {
|
|
44
|
+
readonly wgPublicKey: string;
|
|
45
|
+
readonly wgMeshIP: string;
|
|
46
|
+
readonly wgEndpoint: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Return the validated peer wg fields, or null if any is malformed or
|
|
50
|
+
* out-of-range. Callers treat null as "peer not eligible for mesh" — the
|
|
51
|
+
* peer stays in the federation discovery registry but is excluded from
|
|
52
|
+
* the wg config and any wg commands.
|
|
53
|
+
*/
|
|
54
|
+
export declare function readSafePeerWgFields(peer: FederationNode): WgPeerFields | null;
|
|
55
|
+
export interface WgMeshServiceConfig {
|
|
56
|
+
/** Local interface name. Defaults to `ruflo-fed`. */
|
|
57
|
+
readonly interfaceName?: string;
|
|
58
|
+
/** Local UDP listen port. WireGuard's standard is 51820. */
|
|
59
|
+
readonly listenPort?: number;
|
|
60
|
+
/** Mesh subnet for AllowedIPs filtering. Defaults to DEFAULT_MESH_SUBNET. */
|
|
61
|
+
readonly meshSubnet?: string;
|
|
62
|
+
}
|
|
63
|
+
export interface WgPeerSummary {
|
|
64
|
+
readonly nodeId: string;
|
|
65
|
+
readonly trustLevel: TrustLevel;
|
|
66
|
+
readonly trustLabel: string;
|
|
67
|
+
readonly meshIP: string;
|
|
68
|
+
readonly endpoint: string;
|
|
69
|
+
readonly publicKey: string;
|
|
70
|
+
readonly state: 'active' | 'suspended' | 'evicted';
|
|
71
|
+
readonly allowedIPs: readonly string[];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A planned `wg(8)` mutation. Service consumers either execute these or
|
|
75
|
+
* surface them to the operator. Strings are validated for shell metachars
|
|
76
|
+
* before being formatted into a command — callers should still review.
|
|
77
|
+
*/
|
|
78
|
+
export interface WgCommand {
|
|
79
|
+
readonly verb: 'set-allowed-ips' | 'remove-allowed-ips' | 'remove-peer' | 'add-peer';
|
|
80
|
+
/** Public key of the peer this command targets. */
|
|
81
|
+
readonly peerPublicKey: string;
|
|
82
|
+
/** Render to a `wg set <iface> peer <pk> ...` shell-ready string. */
|
|
83
|
+
readonly cmd: string;
|
|
84
|
+
/** Human-readable rationale for audit logs. */
|
|
85
|
+
readonly rationale: string;
|
|
86
|
+
}
|
|
87
|
+
export declare class WgMeshService {
|
|
88
|
+
private readonly interfaceName;
|
|
89
|
+
private readonly listenPort;
|
|
90
|
+
private readonly meshSubnet;
|
|
91
|
+
private localKey;
|
|
92
|
+
private localMeshIP;
|
|
93
|
+
/** Per-peer AllowedIPs after the last applyTrustLevelToAllowedIPs() call. Drives restore from breaker. */
|
|
94
|
+
private readonly lastAppliedAllowedIPs;
|
|
95
|
+
/** Peer-pubkey → suspended flag for breaker integration. */
|
|
96
|
+
private readonly suspended;
|
|
97
|
+
/** Peer-pubkey → evicted flag. */
|
|
98
|
+
private readonly evicted;
|
|
99
|
+
constructor(config?: WgMeshServiceConfig);
|
|
100
|
+
/** Bind the local WG identity. Required before buildInterfaceConfig(). */
|
|
101
|
+
setLocalIdentity(key: WgLocalKey, meshIP: string): void;
|
|
102
|
+
getInterfaceName(): string;
|
|
103
|
+
getMeshSubnet(): string;
|
|
104
|
+
/**
|
|
105
|
+
* Build a `wg-quick`-compatible config string from current peers.
|
|
106
|
+
*
|
|
107
|
+
* Peers below WG_MIN_MESH_TRUST (UNTRUSTED) are excluded entirely.
|
|
108
|
+
* Suspended peers stay in the config but with `AllowedIPs =` empty
|
|
109
|
+
* (soft-block). Evicted peers are dropped completely.
|
|
110
|
+
*
|
|
111
|
+
* Operator writes this to `/etc/wireguard/<interface>.conf` and runs
|
|
112
|
+
* `wg-quick up <interface>`.
|
|
113
|
+
*/
|
|
114
|
+
buildInterfaceConfig(peers: readonly FederationNode[]): string;
|
|
115
|
+
/**
|
|
116
|
+
* Compute the AllowedIPs slice for a peer at its current trust level.
|
|
117
|
+
* v1: each peer gets its own /32 mesh IP. Phase 4 will narrow this
|
|
118
|
+
* further via firewall rules; v1 keeps L3 broad and relies on the app
|
|
119
|
+
* layer + trust gates for access decisions.
|
|
120
|
+
*/
|
|
121
|
+
computeAllowedIPs(peer: FederationNode, meshIP: string): readonly string[];
|
|
122
|
+
/**
|
|
123
|
+
* Apply trust level → AllowedIPs as a `wg set` command for an
|
|
124
|
+
* already-running interface. Used when a peer joins or its trust level
|
|
125
|
+
* changes without needing a full config rewrite.
|
|
126
|
+
*/
|
|
127
|
+
applyTrustLevelToAllowedIPs(peer: FederationNode, meshIP: string, pubkey: string): WgCommand;
|
|
128
|
+
/**
|
|
129
|
+
* Phase 3 hook — peer SUSPENDED. Clear AllowedIPs (soft-block: keeps
|
|
130
|
+
* the peer's public key registered with the interface but blocks all
|
|
131
|
+
* routing to/from it).
|
|
132
|
+
*/
|
|
133
|
+
removeAllowedIPs(peer: FederationNode, pubkey: string, reason?: string): WgCommand;
|
|
134
|
+
/**
|
|
135
|
+
* Phase 3 hook — peer reactivated. Restore the AllowedIPs slice that
|
|
136
|
+
* was active before suspension. Returns null if the peer was never
|
|
137
|
+
* suspended (idempotent).
|
|
138
|
+
*/
|
|
139
|
+
restoreAllowedIPs(peer: FederationNode, meshIP: string, pubkey: string): WgCommand | null;
|
|
140
|
+
/**
|
|
141
|
+
* Phase 3 hook — peer EVICTED. Terminal removal from the mesh; the
|
|
142
|
+
* peer's `[Peer]` block is dropped on next config rebuild and an
|
|
143
|
+
* immediate `wg set <iface> peer <pk> remove` is emitted to flush
|
|
144
|
+
* runtime state without a config reload.
|
|
145
|
+
*/
|
|
146
|
+
removePeer(peer: FederationNode, pubkey: string, reason?: string): WgCommand;
|
|
147
|
+
/** Summarize the mesh state for `federation_wg_status` (Phase 6) and audit. */
|
|
148
|
+
summarize(peers: readonly FederationNode[]): readonly WgPeerSummary[];
|
|
149
|
+
/**
|
|
150
|
+
* Defense-in-depth: validate that all bits we splice into a shell
|
|
151
|
+
* command are alphanumeric / base64 / WG-allowed chars. Refuses the
|
|
152
|
+
* command rather than ship a substring that might escape its slot.
|
|
153
|
+
*/
|
|
154
|
+
private formatCmd;
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=wg-mesh-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wg-mesh-service.d.ts","sourceRoot":"","sources":["../../../src/domain/services/wg-mesh-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,UAAU,EAAsB,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,KAAK,EAAqB,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAGnF,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;IACtC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC,MAAM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