peerpigeon 1.0.9 → 1.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,132 @@
1
+ # Cloud Deployment Guide
2
+
3
+ ## Bootstrap Hub Hierarchy
4
+
5
+ For cloud deployments, PeerPigeon uses a hierarchical bootstrap configuration to ensure reliable hub mesh connectivity:
6
+
7
+ ### Hub Roles
8
+
9
+ 1. **Hub B (`pigeonhub-b.fly.dev`)** - Primary Bootstrap Hub
10
+ - Does not connect to any other hubs on startup
11
+ - Acts as the primary bootstrap for all other hubs
12
+ - Should be the most stable/reliable deployment
13
+
14
+ 2. **Hub C (`pigeonhub-c.fly.dev`)** - Secondary Bootstrap Hub
15
+ - Bootstraps from Hub B: `wss://pigeonhub-b.fly.dev`
16
+ - Acts as a secondary bootstrap for other hubs
17
+ - Provides redundancy if Hub B is unreachable
18
+
19
+ 3. **Other Hubs** - Client Hubs
20
+ - Bootstrap from both Hub B and Hub C: `wss://pigeonhub-b.fly.dev`, `wss://pigeonhub-c.fly.dev`
21
+ - Connect to the hub mesh through either bootstrap hub
22
+ - Automatically discover other hubs through the mesh
23
+
24
+ ### Automatic Configuration
25
+
26
+ The `scripts/start-hub.js` script automatically detects the hostname and configures bootstraps:
27
+
28
+ ```bash
29
+ # Hub B (primary) - no bootstraps
30
+ HOSTNAME=pigeonhub-b.fly.dev npm run hub
31
+
32
+ # Hub C (secondary) - bootstraps from B
33
+ HOSTNAME=pigeonhub-c.fly.dev npm run hub
34
+
35
+ # Other hubs - bootstrap from B and C
36
+ HOSTNAME=pigeonhub-d.fly.dev npm run hub
37
+ ```
38
+
39
+ ### Manual Override
40
+
41
+ You can override the automatic configuration with the `BOOTSTRAP_HUBS` environment variable:
42
+
43
+ ```bash
44
+ BOOTSTRAP_HUBS=wss://custom-hub.example.com npm run hub
45
+ ```
46
+
47
+ ### Local Development
48
+
49
+ For local development, use explicit bootstrap configuration:
50
+
51
+ ```bash
52
+ # Primary hub (no bootstrap)
53
+ PORT=3000 npm run hub
54
+
55
+ # Secondary hubs (bootstrap from primary)
56
+ PORT=3001 BOOTSTRAP_HUBS=ws://localhost:3000 npm run hub
57
+ PORT=3002 BOOTSTRAP_HUBS=ws://localhost:3000 npm run hub
58
+ ```
59
+
60
+ ## Deployment Example (Fly.io)
61
+
62
+ ### Hub B Deployment
63
+
64
+ ```toml
65
+ # fly.toml for pigeonhub-b
66
+ app = "pigeonhub-b"
67
+
68
+ [build]
69
+ dockerfile = "Dockerfile"
70
+
71
+ [env]
72
+ PORT = "8080"
73
+ HOST = "0.0.0.0"
74
+
75
+ [[services]]
76
+ internal_port = 8080
77
+ protocol = "tcp"
78
+
79
+ [[services.ports]]
80
+ port = 80
81
+ handlers = ["http"]
82
+
83
+ [[services.ports]]
84
+ port = 443
85
+ handlers = ["tls", "http"]
86
+ ```
87
+
88
+ ### Hub C Deployment
89
+
90
+ ```toml
91
+ # fly.toml for pigeonhub-c
92
+ app = "pigeonhub-c"
93
+
94
+ [build]
95
+ dockerfile = "Dockerfile"
96
+
97
+ [env]
98
+ PORT = "8080"
99
+ HOST = "0.0.0.0"
100
+
101
+ [[services]]
102
+ internal_port = 8080
103
+ protocol = "tcp"
104
+
105
+ [[services.ports]]
106
+ port = 80
107
+ handlers = ["http"]
108
+
109
+ [[services.ports]]
110
+ port = 443
111
+ handlers = ["tls", "http"]
112
+ ```
113
+
114
+ ### Other Hub Deployments
115
+
116
+ Follow the same pattern as Hub C. The bootstrap configuration will be automatic based on the hostname.
117
+
118
+ ## Health Checks
119
+
120
+ All hubs expose health endpoints:
121
+
122
+ - `GET /health` - Basic health check
123
+ - `GET /hubs` - List of connected hubs in the mesh
124
+
125
+ Use these endpoints for monitoring and load balancer health checks.
126
+
127
+ ## WebSocket vs WSS
128
+
129
+ - **Local Development**: Use `ws://` protocol
130
+ - **Production/Cloud**: Use `wss://` protocol (secure WebSocket over TLS)
131
+
132
+ The hub script automatically uses `wss://` for fly.dev/fly.io hostnames.
@@ -0,0 +1,358 @@
1
+ # Hub P2P Mesh System
2
+
3
+ ## Overview
4
+
5
+ PeerPigeon hubs now form a **true peer-to-peer mesh network** using WebRTC connections with XOR-based routing for efficient partial mesh topology. This system automatically migrates from WebSocket connections to P2P connections once the mesh is established, reducing server load and improving scalability.
6
+
7
+ ## Key Features
8
+
9
+ ### 🔗 Automatic P2P Mesh Formation
10
+ - All hubs register as bootstrap nodes
11
+ - Hubs form P2P connections on the `pigeonhub-mesh` namespace
12
+ - Uses XOR distance routing for optimal partial mesh topology
13
+ - Maintains `minPeers` to `maxPeers` connections per hub
14
+
15
+ ### 📊 XOR Routing for Partial Mesh
16
+ - Each hub maintains connections to the closest peers by XOR distance
17
+ - Default: 2-3 P2P connections per hub (configurable)
18
+ - Ensures efficient routing while minimizing connection overhead
19
+ - Automatic peer selection based on peer ID proximity
20
+
21
+ ### 🔄 WebSocket to P2P Migration
22
+ - Hubs initially connect via WebSocket for signaling
23
+ - Once P2P mesh is established, WebSocket connections are closed
24
+ - Automatic migration after configurable delay (default: 10 seconds)
25
+ - Maintains client connections via WebSocket (only hub-to-hub migrates to P2P)
26
+
27
+ ### 🌐 Client Signal Relaying
28
+ - Client signaling messages are relayed through the P2P hub mesh
29
+ - XOR routing ensures efficient path finding
30
+ - Transparent to client applications
31
+ - Automatic fallback to WebSocket if P2P is unavailable
32
+
33
+ ## Architecture
34
+
35
+ ```
36
+ Initial State (WebSocket):
37
+ ┌──────────┐ WS ┌──────────┐ WS ┌──────────┐
38
+ │ Hub A │◄─────────►│ Hub B │◄─────────►│ Hub C │
39
+ │ (3000) │ │ (3001) │ │ (3002) │
40
+ └────┬─────┘ └────┬─────┘ └────┬─────┘
41
+ │ │ │
42
+ Clients Clients Clients
43
+
44
+ After P2P Migration:
45
+ ┌──────────┐ P2P ┌──────────┐ P2P ┌──────────┐
46
+ │ Hub A │◄─────────►│ Hub B │◄─────────►│ Hub C │
47
+ │ (3000) │ WebRTC │ (3001) │ WebRTC │ (3002) │
48
+ └────┬─────┘ └────┬─────┘ └────┬─────┘
49
+ │ WS │ WS │ WS
50
+ Clients Clients Clients
51
+ (unchanged) (unchanged) (unchanged)
52
+ ```
53
+
54
+ ## Configuration
55
+
56
+ ### Hub Server with P2P Mesh
57
+
58
+ ```javascript
59
+ import { PeerPigeonServer } from './server/index.js';
60
+
61
+ const hubServer = new PeerPigeonServer({
62
+ port: 3000,
63
+ host: '0.0.0.0',
64
+ isHub: true,
65
+
66
+ // Hub mesh configuration
67
+ hubMeshNamespace: 'pigeonhub-mesh', // Namespace for hub mesh
68
+ hubMeshMaxPeers: 3, // Max P2P connections (partial mesh)
69
+ hubMeshMinPeers: 2, // Min P2P connections before migration
70
+
71
+ // Bootstrap configuration
72
+ bootstrapHubs: [], // Auto-discover from port 3000
73
+ autoConnect: true, // Auto-connect to bootstrap
74
+
75
+ // Migration timing
76
+ meshMigrationDelay: 10000, // Wait 10s before closing WebSockets
77
+
78
+ // Connection limits
79
+ maxConnections: 1000,
80
+ cleanupInterval: 30000
81
+ });
82
+
83
+ // Listen for P2P mesh events
84
+ hubServer.on('hubP2PConnected', ({ hubPeerId }) => {
85
+ console.log(`P2P connection established with hub: ${hubPeerId}`);
86
+ });
87
+
88
+ hubServer.on('hubMeshReady', ({ p2pConnections, totalHubs }) => {
89
+ console.log(`Hub mesh ready! ${p2pConnections} P2P connections`);
90
+ });
91
+
92
+ hubServer.on('hubMeshMigrated', ({ migratedCount, p2pConnections }) => {
93
+ console.log(`Migrated to P2P: ${migratedCount} WebSocket connections closed`);
94
+ });
95
+
96
+ hubServer.on('hubP2PDisconnected', ({ hubPeerId }) => {
97
+ console.log(`P2P connection lost with hub: ${hubPeerId}`);
98
+ });
99
+
100
+ await hubServer.start();
101
+ ```
102
+
103
+ ### Starting Multiple Hubs
104
+
105
+ #### Primary Hub (Bootstrap Node)
106
+ ```bash
107
+ PORT=3000 npm run hub
108
+ ```
109
+
110
+ #### Secondary Hubs
111
+ ```bash
112
+ # Hub automatically connects to bootstrap on port 3000
113
+ PORT=3001 npm run hub
114
+ PORT=3002 npm run hub
115
+ PORT=3003 npm run hub
116
+ ```
117
+
118
+ #### With Custom Bootstrap Hubs
119
+ ```bash
120
+ BOOTSTRAP_HUBS=ws://hub1.example.com:3000,ws://hub2.example.com:3001 PORT=3002 npm run hub
121
+ ```
122
+
123
+ ## How It Works
124
+
125
+ ### 1. Hub Initialization
126
+ When a hub starts with `isHub: true`:
127
+ 1. Creates a `PeerPigeonMesh` instance for P2P connections
128
+ 2. Connects to its own signaling server
129
+ 3. Announces on the `pigeonhub-mesh` namespace
130
+ 4. Begins discovering other hubs
131
+
132
+ ### 2. Bootstrap Connection
133
+ 1. Hub connects to bootstrap hub(s) via WebSocket
134
+ 2. Announces itself as a hub
135
+ 3. Receives list of other hubs
136
+ 4. Maintains WebSocket for initial signaling
137
+
138
+ ### 3. P2P Mesh Formation
139
+ 1. Hubs use WebSocket signaling to establish WebRTC connections
140
+ 2. XOR routing determines optimal peer selection
141
+ 3. Each hub maintains 2-3 P2P connections (configurable)
142
+ 4. Partial mesh topology forms automatically
143
+
144
+ ### 4. Mesh Readiness Check
145
+ Mesh is considered ready when:
146
+ - Hub has ≥ `hubMeshMinPeers` P2P connections, OR
147
+ - Hub has P2P connections to all available hubs (if less than minPeers exist)
148
+
149
+ ### 5. WebSocket Migration
150
+ Once mesh is ready (after `meshMigrationDelay`):
151
+ 1. Direct hub-to-hub WebSocket connections are closed
152
+ 2. Bootstrap WebSocket connections are closed
153
+ 3. All hub-to-hub communication switches to P2P
154
+ 4. Client WebSocket connections remain active
155
+
156
+ ### 6. Client Signal Relaying
157
+ When a client on Hub A needs to signal a peer on Hub C:
158
+ 1. Client sends signal to Hub A via WebSocket
159
+ 2. Hub A relays signal through P2P mesh using XOR routing
160
+ 3. Hub C receives signal and forwards to local client via WebSocket
161
+ 4. Process is transparent to clients
162
+
163
+ ## XOR Routing Algorithm
164
+
165
+ The system uses XOR distance to determine peer proximity:
166
+
167
+ ```javascript
168
+ // XOR distance calculation
169
+ function xorDistance(peerId1, peerId2) {
170
+ let distance = 0;
171
+ for (let i = 0; i < peerId1.length; i++) {
172
+ const xor = parseInt(peerId1[i], 16) ^ parseInt(peerId2[i], 16);
173
+ distance += xor;
174
+ }
175
+ return distance;
176
+ }
177
+
178
+ // Find closest peers
179
+ function findClosestPeers(targetPeerId, allPeerIds, maxPeers = 3) {
180
+ return allPeerIds
181
+ .map(id => ({ id, distance: xorDistance(targetPeerId, id) }))
182
+ .sort((a, b) => a.distance - b.distance)
183
+ .slice(0, maxPeers)
184
+ .map(item => item.id);
185
+ }
186
+ ```
187
+
188
+ ## Event Flow
189
+
190
+ ### Hub Startup
191
+ ```
192
+ 1. Hub starts
193
+ 2. initializeHubMesh() creates PeerPigeonMesh
194
+ 3. Hub connects to local signaling server
195
+ 4. connectToBootstrapHubs() establishes WebSocket connections
196
+ 5. Hub announces on pigeonhub-mesh namespace
197
+ ```
198
+
199
+ ### P2P Connection Established
200
+ ```
201
+ 1. Hub discovers another hub via signaling
202
+ 2. PeerPigeonMesh initiates WebRTC connection
203
+ 3. 'hubP2PConnected' event fires
204
+ 4. checkMeshReadiness() evaluates if mesh is ready
205
+ ```
206
+
207
+ ### Mesh Ready → Migration
208
+ ```
209
+ 1. Mesh reaches minimum P2P connections
210
+ 2. 'hubMeshReady' event fires
211
+ 3. Timer starts (default 10 seconds)
212
+ 4. migrateToP2POnly() closes WebSocket connections
213
+ 5. 'hubMeshMigrated' event fires
214
+ 6. Hub-to-hub communication now fully P2P
215
+ ```
216
+
217
+ ### Client Signal Relay
218
+ ```
219
+ 1. Client sends signal to local hub (WebSocket)
220
+ 2. Hub checks if target is local
221
+ 3. If not local:
222
+ - forwardSignalToHubMesh() finds closest hubs
223
+ - Signal sent via P2P to 1-2 closest hubs
224
+ - Receiving hub forwards to target client (WebSocket)
225
+ ```
226
+
227
+ ## Benefits
228
+
229
+ ### Scalability
230
+ - **Reduced WebSocket connections**: Hub-to-hub connections migrate to P2P
231
+ - **Partial mesh**: O(log N) connections instead of O(N²) full mesh
232
+ - **Efficient routing**: XOR distance ensures optimal paths
233
+
234
+ ### Reliability
235
+ - **Automatic failover**: Multiple P2P paths available
236
+ - **Bootstrap reconnection**: Hubs reconnect if P2P connections fail
237
+ - **Graceful degradation**: Falls back to WebSocket if P2P unavailable
238
+
239
+ ### Performance
240
+ - **Direct P2P**: Lower latency for hub-to-hub communication
241
+ - **Reduced server load**: No centralized bottleneck
242
+ - **Efficient routing**: Messages take shortest XOR path
243
+
244
+ ### Simplicity
245
+ - **Automatic**: No manual configuration required
246
+ - **Transparent**: Clients don't need to know about hub mesh
247
+ - **Self-organizing**: Mesh forms and optimizes automatically
248
+
249
+ ## Configuration Options
250
+
251
+ | Option | Default | Description |
252
+ |--------|---------|-------------|
253
+ | `isHub` | `false` | Enable hub mode |
254
+ | `hubMeshNamespace` | `'pigeonhub-mesh'` | Namespace for hub P2P mesh |
255
+ | `hubMeshMaxPeers` | `3` | Max P2P connections per hub |
256
+ | `hubMeshMinPeers` | `2` | Min P2P connections before migration |
257
+ | `meshMigrationDelay` | `10000` | Delay before closing WebSockets (ms) |
258
+ | `bootstrapHubs` | `[]` | Array of bootstrap hub URIs |
259
+ | `autoConnect` | `true` | Auto-connect to bootstrap hubs |
260
+ | `reconnectInterval` | `5000` | Bootstrap reconnection delay (ms) |
261
+ | `maxReconnectAttempts` | `10` | Max bootstrap reconnection attempts |
262
+
263
+ ## Monitoring
264
+
265
+ ### Events
266
+
267
+ - `hubP2PConnected`: P2P connection established with another hub
268
+ - `hubP2PDisconnected`: P2P connection lost
269
+ - `hubMeshReady`: P2P mesh has sufficient connections
270
+ - `hubMeshMigrated`: WebSocket connections closed, fully P2P
271
+ - `hubDiscovered`: New hub discovered via bootstrap
272
+ - `bootstrapConnected`: Connected to bootstrap hub
273
+ - `bootstrapDisconnected`: Disconnected from bootstrap hub
274
+
275
+ ### Status Endpoint
276
+
277
+ ```bash
278
+ curl http://localhost:3000/health
279
+ ```
280
+
281
+ Response includes:
282
+ - `isHub`: Whether this is a hub server
283
+ - `connections`: Total WebSocket connections
284
+ - `hubs`: Number of registered hubs
285
+ - Additional hub mesh statistics
286
+
287
+ ## Best Practices
288
+
289
+ ### Network Size
290
+ - **Small (2-5 hubs)**: Use `maxPeers: 2-3` for partial mesh
291
+ - **Medium (6-20 hubs)**: Use `maxPeers: 3-4` for balanced routing
292
+ - **Large (20+ hubs)**: Use `maxPeers: 4-5` for redundancy
293
+
294
+ ### Migration Delay
295
+ - **Fast networks**: `5000-10000ms` (5-10 seconds)
296
+ - **Slow networks**: `15000-30000ms` (15-30 seconds)
297
+ - **Production**: `10000ms` (default) is recommended
298
+
299
+ ### Bootstrap Strategy
300
+ - Run 1-2 dedicated bootstrap hubs on well-known ports
301
+ - Other hubs auto-discover and form P2P mesh
302
+ - Bootstrap hubs should be most stable/reliable servers
303
+
304
+ ### Firewall Configuration
305
+ - WebSocket ports must be accessible (default: 3000-3099)
306
+ - WebRTC requires STUN/TURN for NAT traversal
307
+ - Consider using TURN servers for production deployments
308
+
309
+ ## Troubleshooting
310
+
311
+ ### Hubs not forming P2P connections
312
+ - Check that `isHub: true` is set on all hubs
313
+ - Verify `hubMeshNamespace` is the same across all hubs
314
+ - Ensure bootstrap hubs are reachable
315
+ - Check firewall rules for WebRTC connections
316
+
317
+ ### WebSocket connections not closing
318
+ - Verify P2P connections are established (`hubP2PConnected` events)
319
+ - Check that mesh reached minimum connections
320
+ - Increase `meshMigrationDelay` if connections are slow to establish
321
+
322
+ ### Client signals not being relayed
323
+ - Ensure P2P mesh is ready (`hubMeshReady` event)
324
+ - Check that target hub is in the P2P mesh
325
+ - Verify XOR routing is working (check logs)
326
+
327
+ ## Example: 3-Hub Network
328
+
329
+ ```bash
330
+ # Terminal 1: Bootstrap hub
331
+ PORT=3000 npm run hub
332
+
333
+ # Terminal 2: Secondary hub
334
+ PORT=3001 npm run hub
335
+
336
+ # Terminal 3: Tertiary hub
337
+ PORT=3002 npm run hub
338
+ ```
339
+
340
+ Expected behavior:
341
+ 1. Hub 3000 starts, waiting for connections
342
+ 2. Hub 3001 starts, connects to 3000 via WebSocket
343
+ 3. Hub 3002 starts, connects to 3000 via WebSocket
344
+ 4. All hubs discover each other through bootstrap
345
+ 5. P2P connections form (using XOR routing):
346
+ - Hub 3000 ↔ Hub 3001 (P2P)
347
+ - Hub 3001 ↔ Hub 3002 (P2P)
348
+ - Hub 3000 ↔ Hub 3002 (P2P or indirect via 3001)
349
+ 6. After 10 seconds, WebSocket connections close
350
+ 7. All hub-to-hub communication now via P2P
351
+ 8. Clients can connect to any hub, signals relayed via P2P mesh
352
+
353
+ ## See Also
354
+
355
+ - [Hub System Documentation](./HUB_SYSTEM.md)
356
+ - [Bootstrap Hubs Documentation](./BOOTSTRAP_HUBS.md)
357
+ - [Network Namespaces](./NETWORK_NAMESPACES.md)
358
+ - [XOR Routing in Distributed Systems](https://en.wikipedia.org/wiki/Kademlia)
@@ -43,8 +43,8 @@ class PeerPigeonTestSuite {
43
43
  enableDistributedStorage: true, // Enable distributed storage
44
44
  networkName: 'global', // Default network
45
45
  allowGlobalFallback: true, // Allow fallback to global network
46
- maxPeers: 4,
47
- minPeers: 2,
46
+ maxPeers: 6, // Increased for better cross-hub connectivity
47
+ minPeers: 3, // Increased for partition resistance
48
48
  autoConnect: true,
49
49
  autoDiscovery: true,
50
50
  evictionStrategy: true,
@@ -52,6 +52,20 @@ class PeerPigeonTestSuite {
52
52
  });
53
53
 
54
54
  await this.mesh.init();
55
+
56
+ // CRITICAL: Explicitly set connection manager limits to match test configuration
57
+ if (this.mesh.connectionManager) {
58
+ this.mesh.connectionManager.maxPeers = 6;
59
+ this.mesh.connectionManager.minPeers = 3;
60
+ }
61
+
62
+ // Ensure peer discovery settings match
63
+ if (this.mesh.peerDiscovery) {
64
+ this.mesh.peerDiscovery.maxPeers = 6;
65
+ this.mesh.peerDiscovery.minPeers = 3;
66
+ this.mesh.peerDiscovery.evictionStrategy = true;
67
+ this.mesh.peerDiscovery.xorRouting = true;
68
+ }
55
69
  this.setupEventListeners();
56
70
  this.setupUI();
57
71
  this.updatePeerInfo();
@@ -1607,11 +1621,18 @@ class PeerPigeonTestSuite {
1607
1621
  break;
1608
1622
  case 'disconnected':
1609
1623
  this.log('🔴 Disconnected from signaling server');
1610
- this.updateConnectionButtons(false);
1624
+ // Don't update buttons yet - reconnection will start automatically
1625
+ break;
1626
+ case 'reconnecting':
1627
+ this.log(`🔄 ${data.message}`);
1628
+ // Keep buttons disabled during reconnection
1611
1629
  break;
1612
1630
  case 'connecting':
1613
1631
  this.log('🟡 Connecting to signaling server...');
1614
1632
  break;
1633
+ case 'warning':
1634
+ this.log(`⚠️ ${data.message}`);
1635
+ break;
1615
1636
  case 'error':
1616
1637
  this.log(`❌ ${data.message}`, 'error');
1617
1638
  break;
@@ -1633,11 +1654,24 @@ class PeerPigeonTestSuite {
1633
1654
  if (data.from !== this.mesh.peerId) {
1634
1655
  console.log('🔍 DEBUG handleMessageReceived:', data);
1635
1656
 
1657
+ // Filter out system/signaling messages that shouldn't be displayed
1658
+ const filteredMessageTypes = ['signaling-relay', 'peer-announce-relay', 'bootstrap-keepalive',
1659
+ 'client-peer-announcement', 'cross-bootstrap-signaling', 'gossip',
1660
+ 'dht', 'eviction', 'renegotiation-offer', 'renegotiation-answer',
1661
+ 'signaling', 'binary'];
1662
+
1663
+ // Check if data.data exists (ConnectionManager format) and filter by type
1664
+ if (data.data && data.data.type && filteredMessageTypes.includes(data.data.type)) {
1665
+ console.log('🔇 Filtered system message type:', data.data.type);
1666
+ return;
1667
+ }
1668
+
1636
1669
  const messageType = data.direct ? 'direct' : 'broadcast';
1637
1670
  const sender = data.from.substring(0, 8) + '...';
1638
1671
 
1639
1672
  // Handle content properly - it might be an object or string
1640
- let content = data.content;
1673
+ // Support both data.content (gossip format) and data.data (ConnectionManager format)
1674
+ let content = data.content || (data.data && typeof data.data === 'string' ? data.data : null);
1641
1675
  let isEncrypted = false;
1642
1676
 
1643
1677
  if (typeof content === 'object') {
@@ -1650,12 +1684,26 @@ class PeerPigeonTestSuite {
1650
1684
  } else if (content.broadcast && content.data) {
1651
1685
  content = content.data;
1652
1686
  isEncrypted = content.encrypted || false;
1687
+ } else if (content.event) {
1688
+ // This is likely a media event or system message - don't display it
1689
+ console.log('🔇 Filtered system/media event message:', content);
1690
+ return;
1691
+ } else if (content.type && filteredMessageTypes.includes(content.type)) {
1692
+ // Filter system messages wrapped in content
1693
+ console.log('🔇 Filtered system message in content:', content.type);
1694
+ return;
1653
1695
  } else {
1654
1696
  // Fallback: stringify the object
1655
1697
  content = JSON.stringify(content);
1656
1698
  }
1657
1699
  }
1658
1700
 
1701
+ // Validate that we have actual content to display
1702
+ if (!content || (typeof content === 'string' && content.trim().length === 0)) {
1703
+ console.log('🔇 Filtered empty message from:', sender);
1704
+ return;
1705
+ }
1706
+
1659
1707
  // Also check if data.encrypted flag is set
1660
1708
  if (data.encrypted) {
1661
1709
  isEncrypted = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "peerpigeon",
3
- "version": "1.0.9",
3
+ "version": "1.1.1",
4
4
  "description": "WebRTC-based peer-to-peer mesh networking library with intelligent routing and signaling server",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -29,6 +29,10 @@
29
29
  "lint": "node -c src/*.js examples/**/*.js server/*.js",
30
30
  "lint:fix": "eslint --cache --cache-location .eslintcache src/ examples/ server/ --ext .js --fix",
31
31
  "test": "node test/browser-integration-test.js",
32
+ "test:hub-mesh": "node test/test-hub-mesh.js",
33
+ "test:cross-browser": "npm run build && node test/cross-browser-hub-test.js",
34
+ "test:cross-browser:5": "npm run build && node scripts/run-cross-browser-multiple.js",
35
+ "test:simple-cross": "npm run build && node test/simple-cross-browser-test.js",
32
36
  "test:storage": "node examples/node/storage-test.js",
33
37
  "test:browser:visual": "HEADLESS=false node test/browser-integration-test.js",
34
38
  "test:video": "node test/video-streaming-test.js",
@@ -92,6 +96,7 @@
92
96
  "express": "^4.19.2",
93
97
  "jsdoc": "^4.0.4",
94
98
  "nodemon": "^3.1.10",
99
+ "playwright": "^1.56.1",
95
100
  "puppeteer": "^22.0.0"
96
101
  },
97
102
  "engines": {