omniwire 3.0.1 → 3.1.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.
@@ -0,0 +1,85 @@
1
+ export interface OmniMeshPeer {
2
+ readonly id: string;
3
+ readonly publicKey: string;
4
+ readonly endpoint?: string;
5
+ readonly meshIp: string;
6
+ readonly allowedIps: string;
7
+ readonly latestHandshake?: number;
8
+ readonly transferRx?: number;
9
+ readonly transferTx?: number;
10
+ readonly keepalive?: number;
11
+ readonly os: 'linux' | 'windows' | 'darwin';
12
+ readonly tags?: readonly string[];
13
+ readonly online?: boolean;
14
+ }
15
+ export interface OmniMeshConfig {
16
+ readonly interfaceName: string;
17
+ readonly meshSubnet: string;
18
+ readonly listenPort: number;
19
+ readonly dns?: readonly string[];
20
+ readonly mtu?: number;
21
+ readonly fwmark?: number;
22
+ readonly preUp?: string;
23
+ readonly postUp?: string;
24
+ readonly preDown?: string;
25
+ readonly postDown?: string;
26
+ }
27
+ export interface OmniMeshStatus {
28
+ readonly interfaceName: string;
29
+ readonly publicKey: string;
30
+ readonly listenPort: number;
31
+ readonly peers: readonly OmniMeshPeer[];
32
+ readonly meshIp: string;
33
+ readonly uptime: string;
34
+ }
35
+ export interface KeyPair {
36
+ readonly privateKey: string;
37
+ readonly publicKey: string;
38
+ readonly presharedKey?: string;
39
+ }
40
+ export declare function detectOS(): 'linux' | 'windows' | 'darwin';
41
+ /** Generate WireGuard key pair commands per OS */
42
+ export declare function genKeysCmd(os: 'linux' | 'windows' | 'darwin'): string;
43
+ /** Parse key generation output */
44
+ export declare function parseKeys(stdout: string): KeyPair;
45
+ /** Build WireGuard config file content */
46
+ export declare function buildWgConfig(localPeer: {
47
+ privateKey: string;
48
+ meshIp: string;
49
+ listenPort: number;
50
+ }, peers: readonly OmniMeshPeer[], config?: Partial<OmniMeshConfig>, presharedKeys?: Record<string, string>): string;
51
+ /** Get WireGuard config path per OS */
52
+ export declare function wgConfigPath(os: 'linux' | 'windows' | 'darwin', iface: string): string;
53
+ /** Build command to bring interface up */
54
+ export declare function bringUpCmd(os: 'linux' | 'windows' | 'darwin', iface: string): string;
55
+ /** Build command to bring interface down */
56
+ export declare function bringDownCmd(os: 'linux' | 'windows' | 'darwin', iface: string): string;
57
+ /** Build command to get WireGuard status */
58
+ export declare function statusCmd(os: 'linux' | 'windows' | 'darwin', iface: string): string;
59
+ /** Parse `wg show` output into structured peers */
60
+ export declare function parseWgShow(stdout: string): OmniMeshStatus;
61
+ /** Build command to add a peer dynamically (no restart) */
62
+ export declare function addPeerCmd(iface: string, peer: OmniMeshPeer, psk?: string): string;
63
+ /** Build command to remove a peer dynamically */
64
+ export declare function removePeerCmd(iface: string, publicKey: string): string;
65
+ /** Build command to install WireGuard per OS */
66
+ export declare function installCmd(os: 'linux' | 'windows' | 'darwin'): string;
67
+ /** Build command to check if WireGuard is installed */
68
+ export declare function checkInstalledCmd(os: 'linux' | 'windows' | 'darwin'): string;
69
+ /** Build NAT traversal PostUp rules (iptables/nftables) */
70
+ export declare function natTraversalPostUp(iface: string, publicIface?: string): string;
71
+ /** Build NAT traversal PostDown rules */
72
+ export declare function natTraversalPostDown(iface: string, publicIface?: string): string;
73
+ /** Build command to rotate keys for a peer */
74
+ export declare function rotateKeyCmd(iface: string, os: 'linux' | 'windows' | 'darwin'): string;
75
+ /** Build monitoring/health check command */
76
+ export declare function healthCheckCmd(iface: string, peers: readonly string[]): string;
77
+ /** Build STUN/endpoint discovery command for NAT'd peers */
78
+ export declare function stunDiscoverCmd(): string;
79
+ /** Generate a mesh topology config for N peers (hub-and-spoke or full-mesh) */
80
+ export declare function generateMeshTopology(peers: readonly {
81
+ id: string;
82
+ meshIp: string;
83
+ publicKey: string;
84
+ endpoint?: string;
85
+ }[], topology?: 'full-mesh' | 'hub-spoke', hubId?: string): Map<string, OmniMeshPeer[]>;
@@ -0,0 +1,307 @@
1
+ // OmniMesh — Cross-platform WireGuard mesh network for OmniWire
2
+ // Manages peer discovery, key rotation, NAT traversal, and mesh topology
3
+ // Supports: Linux (wg-quick/networkd), Windows (wireguard.exe), macOS (wg-quick/brew)
4
+ // --- Cross-platform command builders ---
5
+ export function detectOS() {
6
+ const p = process.platform;
7
+ if (p === 'win32')
8
+ return 'windows';
9
+ if (p === 'darwin')
10
+ return 'darwin';
11
+ return 'linux';
12
+ }
13
+ /** Generate WireGuard key pair commands per OS */
14
+ export function genKeysCmd(os) {
15
+ if (os === 'windows') {
16
+ // wireguard.exe uses wg.exe for keygen on Windows
17
+ return [
18
+ 'cd %TEMP%',
19
+ 'wg genkey > omnimesh_priv.key',
20
+ 'type omnimesh_priv.key | wg pubkey > omnimesh_pub.key',
21
+ 'wg genpsk > omnimesh_psk.key',
22
+ 'echo PRIV: & type omnimesh_priv.key',
23
+ 'echo PUB: & type omnimesh_pub.key',
24
+ 'echo PSK: & type omnimesh_psk.key',
25
+ ].join(' && ');
26
+ }
27
+ // Linux/macOS
28
+ return [
29
+ 'priv=$(wg genkey)',
30
+ 'pub=$(echo "$priv" | wg pubkey)',
31
+ 'psk=$(wg genpsk)',
32
+ 'echo "PRIV:$priv"',
33
+ 'echo "PUB:$pub"',
34
+ 'echo "PSK:$psk"',
35
+ ].join('; ');
36
+ }
37
+ /** Parse key generation output */
38
+ export function parseKeys(stdout) {
39
+ const lines = stdout.split('\n').map((l) => l.trim()).filter(Boolean);
40
+ let privateKey = '', publicKey = '', presharedKey = '';
41
+ for (const line of lines) {
42
+ if (line.startsWith('PRIV:'))
43
+ privateKey = line.slice(5).trim();
44
+ else if (line.startsWith('PUB:'))
45
+ publicKey = line.slice(4).trim();
46
+ else if (line.startsWith('PSK:'))
47
+ presharedKey = line.slice(4).trim();
48
+ }
49
+ return { privateKey, publicKey, presharedKey: presharedKey || undefined };
50
+ }
51
+ /** Build WireGuard config file content */
52
+ export function buildWgConfig(localPeer, peers, config = {}, presharedKeys) {
53
+ const lines = ['[Interface]'];
54
+ lines.push(`PrivateKey = ${localPeer.privateKey}`);
55
+ lines.push(`Address = ${localPeer.meshIp}/24`);
56
+ lines.push(`ListenPort = ${localPeer.listenPort}`);
57
+ if (config.dns?.length)
58
+ lines.push(`DNS = ${config.dns.join(', ')}`);
59
+ if (config.mtu)
60
+ lines.push(`MTU = ${config.mtu}`);
61
+ if (config.fwmark)
62
+ lines.push(`FwMark = ${config.fwmark}`);
63
+ if (config.postUp)
64
+ lines.push(`PostUp = ${config.postUp}`);
65
+ if (config.postDown)
66
+ lines.push(`PostDown = ${config.postDown}`);
67
+ if (config.preUp)
68
+ lines.push(`PreUp = ${config.preUp}`);
69
+ if (config.preDown)
70
+ lines.push(`PreDown = ${config.preDown}`);
71
+ for (const peer of peers) {
72
+ lines.push('');
73
+ lines.push('[Peer]');
74
+ lines.push(`# ${peer.id}`);
75
+ lines.push(`PublicKey = ${peer.publicKey}`);
76
+ const psk = presharedKeys?.[peer.id];
77
+ if (psk)
78
+ lines.push(`PresharedKey = ${psk}`);
79
+ lines.push(`AllowedIPs = ${peer.allowedIps}`);
80
+ if (peer.endpoint)
81
+ lines.push(`Endpoint = ${peer.endpoint}`);
82
+ lines.push(`PersistentKeepalive = ${peer.keepalive ?? 25}`);
83
+ }
84
+ return lines.join('\n') + '\n';
85
+ }
86
+ /** Get WireGuard config path per OS */
87
+ export function wgConfigPath(os, iface) {
88
+ switch (os) {
89
+ case 'linux': return `/etc/wireguard/${iface}.conf`;
90
+ case 'darwin': return `/usr/local/etc/wireguard/${iface}.conf`;
91
+ case 'windows': return `C:\\Program Files\\WireGuard\\Data\\Configurations\\${iface}.conf.dpapi`;
92
+ }
93
+ }
94
+ /** Build command to bring interface up */
95
+ export function bringUpCmd(os, iface) {
96
+ switch (os) {
97
+ case 'linux': return `wg-quick up ${iface} 2>&1 || (systemctl start wg-quick@${iface} 2>&1)`;
98
+ case 'darwin': return `wg-quick up ${iface} 2>&1`;
99
+ case 'windows': return `"C:\\Program Files\\WireGuard\\wireguard.exe" /installtunnelservice ${iface} 2>&1`;
100
+ }
101
+ }
102
+ /** Build command to bring interface down */
103
+ export function bringDownCmd(os, iface) {
104
+ switch (os) {
105
+ case 'linux': return `wg-quick down ${iface} 2>&1 || (systemctl stop wg-quick@${iface} 2>&1)`;
106
+ case 'darwin': return `wg-quick down ${iface} 2>&1`;
107
+ case 'windows': return `"C:\\Program Files\\WireGuard\\wireguard.exe" /uninstalltunnelservice ${iface} 2>&1`;
108
+ }
109
+ }
110
+ /** Build command to get WireGuard status */
111
+ export function statusCmd(os, iface) {
112
+ if (os === 'windows') {
113
+ return `wg show ${iface} 2>&1`;
114
+ }
115
+ return `wg show ${iface} 2>&1; echo "---addr---"; ip -4 addr show ${iface} 2>/dev/null || ifconfig ${iface} 2>/dev/null`;
116
+ }
117
+ /** Parse `wg show` output into structured peers */
118
+ export function parseWgShow(stdout) {
119
+ const lines = stdout.split('\n');
120
+ let interfaceName = '', publicKey = '', listenPort = 0, meshIp = '';
121
+ const peers = [];
122
+ let currentPeer = null;
123
+ for (const line of lines) {
124
+ const trimmed = line.trim();
125
+ if (trimmed.startsWith('interface:'))
126
+ interfaceName = trimmed.split(':')[1]?.trim() ?? '';
127
+ else if (trimmed.startsWith('public key:') && !currentPeer)
128
+ publicKey = trimmed.split(':').slice(1).join(':').trim();
129
+ else if (trimmed.startsWith('listening port:'))
130
+ listenPort = parseInt(trimmed.split(':')[1]?.trim() ?? '0');
131
+ else if (trimmed.startsWith('peer:')) {
132
+ if (currentPeer?.publicKey)
133
+ peers.push(currentPeer);
134
+ currentPeer = { publicKey: trimmed.split(':').slice(1).join(':').trim(), os: 'linux', id: '', meshIp: '', allowedIps: '' };
135
+ }
136
+ else if (currentPeer) {
137
+ if (trimmed.startsWith('endpoint:'))
138
+ currentPeer.endpoint = trimmed.split(':').slice(1).join(':').trim();
139
+ else if (trimmed.startsWith('allowed ips:')) {
140
+ const ips = trimmed.split(':').slice(1).join(':').trim();
141
+ currentPeer.allowedIps = ips;
142
+ currentPeer.meshIp = ips.split('/')[0] ?? '';
143
+ }
144
+ else if (trimmed.startsWith('latest handshake:'))
145
+ currentPeer.latestHandshake = Date.now();
146
+ else if (trimmed.startsWith('transfer:')) {
147
+ const parts = trimmed.split(':')[1]?.trim().split(',') ?? [];
148
+ currentPeer.transferRx = parseTransferBytes(parts[0] ?? '');
149
+ currentPeer.transferTx = parseTransferBytes(parts[1] ?? '');
150
+ }
151
+ else if (trimmed.startsWith('persistent keepalive:')) {
152
+ currentPeer.keepalive = parseInt(trimmed.split(':')[1]?.trim() ?? '25');
153
+ }
154
+ }
155
+ // Parse address from ip addr output
156
+ if (trimmed.startsWith('inet ') && trimmed.includes('/')) {
157
+ meshIp = trimmed.split(' ')[1]?.split('/')[0] ?? '';
158
+ }
159
+ }
160
+ if (currentPeer?.publicKey)
161
+ peers.push(currentPeer);
162
+ return { interfaceName, publicKey, listenPort, peers, meshIp, uptime: '' };
163
+ }
164
+ function parseTransferBytes(s) {
165
+ const trimmed = s.trim();
166
+ const match = trimmed.match(/([\d.]+)\s*(B|KiB|MiB|GiB|TiB)/);
167
+ if (!match)
168
+ return 0;
169
+ const val = parseFloat(match[1]);
170
+ const unit = match[2];
171
+ const multipliers = { B: 1, KiB: 1024, MiB: 1048576, GiB: 1073741824, TiB: 1099511627776 };
172
+ return Math.round(val * (multipliers[unit] ?? 1));
173
+ }
174
+ /** Build command to add a peer dynamically (no restart) */
175
+ export function addPeerCmd(iface, peer, psk) {
176
+ const parts = [`wg set ${iface} peer ${peer.publicKey}`];
177
+ parts.push(`allowed-ips ${peer.allowedIps}`);
178
+ if (peer.endpoint)
179
+ parts.push(`endpoint ${peer.endpoint}`);
180
+ parts.push(`persistent-keepalive ${peer.keepalive ?? 25}`);
181
+ if (psk)
182
+ parts.push(`preshared-key <(echo "${psk}")`);
183
+ return parts.join(' ');
184
+ }
185
+ /** Build command to remove a peer dynamically */
186
+ export function removePeerCmd(iface, publicKey) {
187
+ return `wg set ${iface} peer ${publicKey} remove`;
188
+ }
189
+ /** Build command to install WireGuard per OS */
190
+ export function installCmd(os) {
191
+ switch (os) {
192
+ case 'linux': return 'apt-get update && apt-get install -y wireguard wireguard-tools 2>&1 || yum install -y wireguard-tools 2>&1 || dnf install -y wireguard-tools 2>&1 || pacman -S --noconfirm wireguard-tools 2>&1';
193
+ case 'darwin': return 'brew install wireguard-tools 2>&1';
194
+ case 'windows': return 'winget install WireGuard.WireGuard --accept-source-agreements --accept-package-agreements 2>&1 || choco install wireguard -y 2>&1';
195
+ }
196
+ }
197
+ /** Build command to check if WireGuard is installed */
198
+ export function checkInstalledCmd(os) {
199
+ if (os === 'windows')
200
+ return 'where wg 2>NUL && echo "INSTALLED" || echo "NOT_INSTALLED"';
201
+ return 'which wg >/dev/null 2>&1 && echo "INSTALLED" || echo "NOT_INSTALLED"';
202
+ }
203
+ /** Build NAT traversal PostUp rules (iptables/nftables) */
204
+ export function natTraversalPostUp(iface, publicIface = 'eth0') {
205
+ return [
206
+ `iptables -A FORWARD -i ${iface} -j ACCEPT`,
207
+ `iptables -A FORWARD -o ${iface} -j ACCEPT`,
208
+ `iptables -t nat -A POSTROUTING -o ${publicIface} -j MASQUERADE`,
209
+ ].join('; ');
210
+ }
211
+ /** Build NAT traversal PostDown rules */
212
+ export function natTraversalPostDown(iface, publicIface = 'eth0') {
213
+ return [
214
+ `iptables -D FORWARD -i ${iface} -j ACCEPT`,
215
+ `iptables -D FORWARD -o ${iface} -j ACCEPT`,
216
+ `iptables -t nat -D POSTROUTING -o ${publicIface} -j MASQUERADE`,
217
+ ].join('; ');
218
+ }
219
+ /** Build command to rotate keys for a peer */
220
+ export function rotateKeyCmd(iface, os) {
221
+ if (os === 'windows') {
222
+ return 'echo "Key rotation on Windows requires config file update + tunnel restart"';
223
+ }
224
+ return [
225
+ 'NEW_PRIV=$(wg genkey)',
226
+ 'NEW_PUB=$(echo "$NEW_PRIV" | wg pubkey)',
227
+ `wg set ${iface} private-key <(echo "$NEW_PRIV")`,
228
+ 'echo "PRIV:$NEW_PRIV"',
229
+ 'echo "PUB:$NEW_PUB"',
230
+ ].join('; ');
231
+ }
232
+ /** Build monitoring/health check command */
233
+ export function healthCheckCmd(iface, peers) {
234
+ const pings = peers.map((ip) => `(ping -c1 -W2 ${ip} >/dev/null 2>&1 && echo "OK ${ip}" || echo "FAIL ${ip}")`);
235
+ return [
236
+ `wg show ${iface} latest-handshakes 2>/dev/null`,
237
+ `echo "---pings---"`,
238
+ ...pings,
239
+ `echo "---transfer---"`,
240
+ `wg show ${iface} transfer 2>/dev/null`,
241
+ ].join('; ');
242
+ }
243
+ /** Build STUN/endpoint discovery command for NAT'd peers */
244
+ export function stunDiscoverCmd() {
245
+ return [
246
+ '# Discover public endpoint via STUN',
247
+ 'stun_servers="stun.l.google.com:19302 stun1.l.google.com:19302 stun.cloudflare.com:3478"',
248
+ 'for s in $stun_servers; do',
249
+ ' result=$(stun $s 2>/dev/null | grep -i "mapped" | head -1)',
250
+ ' [ -n "$result" ] && { echo "STUN:$result"; break; }',
251
+ 'done',
252
+ '# Fallback: curl-based IP detection',
253
+ 'echo "PUBLIC_IP:$(curl -s --max-time 3 https://api.ipify.org 2>/dev/null || curl -s --max-time 3 https://ifconfig.me 2>/dev/null)"',
254
+ ].join('\n');
255
+ }
256
+ /** Generate a mesh topology config for N peers (hub-and-spoke or full-mesh) */
257
+ export function generateMeshTopology(peers, topology = 'full-mesh', hubId) {
258
+ const result = new Map();
259
+ if (topology === 'full-mesh') {
260
+ // Every peer connects to every other peer
261
+ for (const peer of peers) {
262
+ const others = peers
263
+ .filter((p) => p.id !== peer.id)
264
+ .map((p) => ({
265
+ id: p.id,
266
+ publicKey: p.publicKey,
267
+ endpoint: p.endpoint,
268
+ meshIp: p.meshIp,
269
+ allowedIps: `${p.meshIp}/32`,
270
+ keepalive: 25,
271
+ os: 'linux',
272
+ }));
273
+ result.set(peer.id, others);
274
+ }
275
+ }
276
+ else {
277
+ // Hub-and-spoke: only hub connects to all, spokes connect only to hub
278
+ const hub = peers.find((p) => p.id === (hubId ?? peers[0]?.id));
279
+ if (!hub)
280
+ return result;
281
+ const spokes = peers.filter((p) => p.id !== hub.id);
282
+ // Hub gets all spokes
283
+ result.set(hub.id, spokes.map((s) => ({
284
+ id: s.id,
285
+ publicKey: s.publicKey,
286
+ endpoint: s.endpoint,
287
+ meshIp: s.meshIp,
288
+ allowedIps: `${s.meshIp}/32`,
289
+ keepalive: 25,
290
+ os: 'linux',
291
+ })));
292
+ // Each spoke gets only the hub
293
+ for (const spoke of spokes) {
294
+ result.set(spoke.id, [{
295
+ id: hub.id,
296
+ publicKey: hub.publicKey,
297
+ endpoint: hub.endpoint,
298
+ meshIp: hub.meshIp,
299
+ allowedIps: '10.10.0.0/24', // Route all mesh traffic through hub
300
+ keepalive: 25,
301
+ os: 'linux',
302
+ }]);
303
+ }
304
+ }
305
+ return result;
306
+ }
307
+ //# sourceMappingURL=omnimesh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"omnimesh.js","sourceRoot":"","sources":["../../src/mesh/omnimesh.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,yEAAyE;AACzE,sFAAsF;AAiDtF,0CAA0C;AAE1C,MAAM,UAAU,QAAQ;IACtB,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC;IAC3B,IAAI,CAAC,KAAK,OAAO;QAAE,OAAO,SAAS,CAAC;IACpC,IAAI,CAAC,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IACpC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,UAAU,CAAC,EAAkC;IAC3D,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QACrB,kDAAkD;QAClD,OAAO;YACL,WAAW;YACX,+BAA+B;YAC/B,uDAAuD;YACvD,8BAA8B;YAC9B,qCAAqC;YACrC,mCAAmC;YACnC,mCAAmC;SACpC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjB,CAAC;IACD,cAAc;IACd,OAAO;QACL,mBAAmB;QACnB,iCAAiC;QACjC,kB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update.d.ts CHANGED
@@ -1,17 +1,38 @@
1
- interface UpdateResult {
1
+ export type UpdateSource = 'npm' | 'github' | 'auto';
2
+ export interface UpdateResult {
2
3
  readonly currentVersion: string;
3
4
  readonly latestVersion: string;
4
5
  readonly updated: boolean;
5
6
  readonly message: string;
7
+ readonly source?: UpdateSource;
6
8
  }
7
- /** Check if a newer version is available on npm */
8
- export declare function checkForUpdate(): Promise<{
9
+ interface UpdateState {
10
+ lastCheck: number;
11
+ lastVersion: string;
12
+ autoUpdateEnabled: boolean;
13
+ source: UpdateSource;
14
+ checkIntervalMs: number;
15
+ }
16
+ /** Check for update from best available source */
17
+ export declare function checkForUpdate(source?: UpdateSource): Promise<{
9
18
  current: string;
10
19
  latest: string;
11
20
  updateAvailable: boolean;
21
+ source: UpdateSource;
12
22
  }>;
13
23
  /** Self-update OmniWire to the latest version */
14
- export declare function selfUpdate(): Promise<UpdateResult>;
24
+ export declare function selfUpdate(source?: UpdateSource): Promise<UpdateResult>;
25
+ /** Start auto-update background checker */
26
+ export declare function startAutoUpdate(intervalMs?: number, onUpdate?: (result: UpdateResult) => void): void;
27
+ /** Stop auto-update background checker */
28
+ export declare function stopAutoUpdate(): void;
29
+ /** Check if auto-update is enabled */
30
+ export declare function isAutoUpdateEnabled(): boolean;
31
+ /** Get auto-update state info */
32
+ export declare function getAutoUpdateState(): UpdateState & {
33
+ currentVersion: string;
34
+ timerActive: boolean;
35
+ };
15
36
  /** Get system info for diagnostics */
16
37
  export declare function getSystemInfo(): Record<string, string>;
17
38
  export {};