peerpigeon 0.1.0 → 1.0.0

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.
Files changed (72) hide show
  1. package/README.md +141 -1365
  2. package/cli.js +1382 -0
  3. package/dist/peerpigeon-browser.js +12290 -0
  4. package/dist/peerpigeon-browser.js.map +7 -0
  5. package/docs/API_DOCUMENTATION.md +1945 -0
  6. package/docs/BOOTSTRAP_HUBS.md +319 -0
  7. package/docs/CLI_README.md +371 -0
  8. package/docs/DOCUMENTATION_REORGANIZATION.md +172 -0
  9. package/docs/HUB_QUICK_REF.md +107 -0
  10. package/docs/HUB_SCRIPTS.md +331 -0
  11. package/docs/HUB_SYSTEM.md +552 -0
  12. package/docs/MIGRATION_COMPLETE.md +93 -0
  13. package/docs/NETWORK_NAMESPACES.md +212 -0
  14. package/docs/README.md +107 -0
  15. package/docs/SELECTIVE_STREAMING_GUIDE.md +427 -0
  16. package/docs/TEST_CLEANUP_COMPLETE.md +80 -0
  17. package/examples/bootstrap-hub-example.js +292 -0
  18. package/examples/browser/README.md +278 -0
  19. package/examples/browser/app.js +2426 -49
  20. package/examples/browser/index.html +482 -543
  21. package/examples/browser/minimal/README.md +55 -0
  22. package/examples/browser/minimal/index.html +75 -0
  23. package/examples/browser/minimal/minimal.js +234 -0
  24. package/examples/browser/styles.css +687 -1425
  25. package/examples/browser/test-bundle.html +35 -0
  26. package/examples/browser-2/index.html +30 -0
  27. package/examples/browser-2/package.json +21 -0
  28. package/examples/browser-2/src/App-simple.vue +21 -0
  29. package/examples/browser-2/src/App.vue +420 -0
  30. package/examples/browser-2/src/components/CryptoView.vue +1661 -0
  31. package/examples/browser-2/src/components/DHTView.vue +1281 -0
  32. package/examples/browser-2/src/components/DebugView.vue +1773 -0
  33. package/examples/browser-2/src/components/MediaView.vue +1048 -0
  34. package/examples/browser-2/src/components/MessagingView.vue +775 -0
  35. package/examples/browser-2/src/components/NetworkView.vue +930 -0
  36. package/examples/browser-2/src/components/StorageView.vue +1376 -0
  37. package/examples/browser-2/src/main.js +5 -0
  38. package/examples/browser-2/src/stores/peerpigeon.js +895 -0
  39. package/examples/browser-2/vite.config.js +6 -0
  40. package/examples/hub-example.js +186 -0
  41. package/examples/multi-hub-test.js +186 -0
  42. package/examples/node/README.md +2 -2
  43. package/examples/node/storage-test.js +141 -6
  44. package/examples/selective-streaming-demo.html +698 -0
  45. package/examples/standard-events-demo.js +126 -0
  46. package/package.json +33 -16
  47. package/server/index.js +1032 -98
  48. package/server/start.js +49 -0
  49. package/src/ConnectionManager.js +239 -225
  50. package/src/CryptoManager.js +147 -18
  51. package/src/DebugLogger.js +0 -7
  52. package/src/DistributedStorageManager.js +245 -205
  53. package/src/EnvironmentDetector.js +109 -2
  54. package/src/EventEmitter.js +79 -1
  55. package/src/EvictionManager.js +10 -9
  56. package/src/GossipManager.js +163 -11
  57. package/src/LexicalStorageInterface.js +332 -0
  58. package/src/PeerConnection.js +333 -310
  59. package/src/PeerPigeonMesh.js +577 -135
  60. package/src/SignalingClient.js +14 -243
  61. package/src/SignalingHandler.js +31 -10
  62. package/src/StorageManager.js +0 -39
  63. package/src/WebDHT-Simple.js +389 -0
  64. package/src/WebDHT.js +363 -1165
  65. package/src/browser-entry.js +40 -0
  66. package/examples/browser/assets/images/favicon.png +0 -0
  67. package/examples/browser/assets/images/pigeon.png +0 -0
  68. package/examples/browser/crypto-test.html +0 -427
  69. package/examples/browser/ui-old.js +0 -1926
  70. package/examples/browser/ui.js +0 -3010
  71. package/websocket-server/README.md +0 -247
  72. package/websocket-server/server.js +0 -391
@@ -3,662 +3,601 @@
3
3
  <head>
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>PeerPigeon - WebRTC P2P Mesh</title>
6
+ <title>PeerPigeon - Complete API Testing Suite</title>
7
7
  <link rel="stylesheet" href="styles.css">
8
- <link rel="icon" type="image/png" sizes="32x32" href="assets/images/favicon.png">
9
- <link rel="icon" type="image/png" sizes="16x16" href="assets/images/favicon.png">
10
- <link rel="apple-touch-icon" href="assets/images/favicon.png">
11
- <link rel="shortcut icon" href="assets/images/favicon.png">
12
- <!-- Load unsea crypto library from CDN for browser environment -->
13
- <script src="https://cdn.jsdelivr.net/npm/unsea@1.3.0/dist/sea.min.js"></script>
8
+ <link rel="icon" type="image/png" sizes="32x32" href="../browser/assets/images/favicon.png">
14
9
  </head>
15
10
  <body>
16
11
  <div class="container">
17
12
  <header>
18
- <h1><img src="assets/images/favicon.png" alt="PeerPigeon Logo" style="height: 2.5em; width: auto; vertical-align: middle; margin-right: 0.5em;"> PeerPigeon</h1>
19
- <p>WebRTC P2P mesh networking with XOR-based routing</p>
20
- <div class="usage-hint">
21
- <strong>Tip:</strong> You can pass the API Gateway URL via query parameter:<br>
22
- <code>?api=ws://localhost:3000</code>
13
+ <h1>🐦 PeerPigeon - Complete API Testing Suite</h1>
14
+ <p>Comprehensive browser-based tool for testing all PeerPigeon features</p>
15
+ <div class="peer-info">
16
+ <span><strong>Peer ID:</strong> <code id="peer-id">Initializing...</code></span>
17
+ <span><strong>Status:</strong> <span id="status" class="status disconnected">Disconnected</span></span>
23
18
  </div>
24
19
  </header>
25
20
 
26
- <main>
27
- <div class="peer-info">
28
- <h2>Peer Information</h2>
29
- <div class="info-group">
30
- <label>Your Peer ID:</label>
31
- <code id="peer-id">Generating...</code>
21
+ <nav class="feature-tabs">
22
+ <button class="tab-btn active" data-tab="connection">Connection</button>
23
+ <button class="tab-btn" data-tab="messaging">Messaging</button>
24
+ <button class="tab-btn" data-tab="media">Media</button>
25
+ <button class="tab-btn" data-tab="dht">WebDHT & Storage</button>
26
+ <button class="tab-btn" data-tab="crypto">Encryption</button>
27
+ <button class="tab-btn" data-tab="network">Network Info</button>
28
+ <button class="tab-btn" data-tab="testing">API Testing</button>
29
+ </nav>
30
+
31
+ <!-- Global Message History - Visible across all tabs -->
32
+ <section class="global-message-history">
33
+ <div class="card">
34
+ <h3>📬 Message History</h3>
35
+ <div class="message-filters">
36
+ <select id="message-filter">
37
+ <option value="all">All Messages</option>
38
+ <option value="sent">Sent Messages</option>
39
+ <option value="received">Received Messages</option>
40
+ <option value="broadcast">Broadcast Messages</option>
41
+ <option value="direct">Direct Messages</option>
42
+ <option value="group">Group Messages</option>
43
+ </select>
44
+ <button id="export-messages-btn" class="btn tertiary">📥 Export History</button>
32
45
  </div>
33
- <div class="info-group">
34
- <label>Status:</label>
35
- <span id="status" class="status disconnected">Disconnected</span>
46
+ <div id="message-history" class="message-history">
47
+ <p class="empty-state">No messages yet</p>
36
48
  </div>
37
- </div>
38
-
39
- <div class="connection-controls">
40
- <h2>Connection</h2>
41
49
  <div class="button-group">
42
- <button id="connect-btn" class="btn primary">Connect</button>
43
- <button id="disconnect-btn" class="btn secondary" disabled>Disconnect</button>
44
- <button id="cleanup-btn" class="btn tertiary" disabled>Clean Signaling Data</button>
45
- <button id="health-check-btn" class="btn quaternary" disabled>Health Check</button>
46
- <button id="refresh-btn" class="btn quaternary">🔄 Refresh Page</button>
50
+ <button id="clear-messages-btn" class="btn tertiary">Clear History</button>
51
+ <button id="refresh-messages-btn" class="btn tertiary">Refresh</button>
47
52
  </div>
53
+ </div>
54
+ </section>
55
+
56
+ <main>
57
+ <!-- Connection Management Tab -->
58
+ <section id="connection-tab" class="tab-content active">
59
+ <h2>🌐 Connection Management</h2>
48
60
 
49
- <div class="system-messages-container">
50
- <div id="system-messages" class="system-messages"></div>
61
+ <div class="card">
62
+ <h3>🌐 Network & Signaling Server</h3>
63
+ <div class="input-group">
64
+ <label for="network-name">Network Name:</label>
65
+ <input type="text" id="network-name" value="global" placeholder="global (e.g., 'gaming', 'work', 'family')">
66
+ <small>Create isolated networks or use 'global' for default mesh</small>
67
+ </div>
68
+ <div class="input-group">
69
+ <label for="signaling-url">Server URL:</label>
70
+ <input type="text" id="signaling-url" value="ws://localhost:3000" placeholder="ws://localhost:3000">
71
+ </div>
72
+ <div class="checkbox-group">
73
+ <label><input type="checkbox" id="allow-global-fallback" checked> Allow Global Fallback</label>
74
+ <small>Automatically fallback to global network when current network is empty</small>
75
+ </div>
76
+ <div class="button-group">
77
+ <button id="connect-btn" class="btn primary">Connect</button>
78
+ <button id="disconnect-btn" class="btn secondary" disabled>Disconnect</button>
79
+ <button id="cleanup-btn" class="btn tertiary">Cleanup Stale Data</button>
80
+ </div>
81
+ <div id="network-status" class="network-status" style="display: none;">
82
+ <div class="status-info">
83
+ <span><strong>Current Network:</strong> <span id="current-network">global</span></span>
84
+ <span id="fallback-indicator" style="display: none;" class="fallback-badge">Fallback Mode</span>
85
+ </div>
86
+ <div class="status-info" id="original-network-info" style="display: none;">
87
+ <span><strong>Original Network:</strong> <span id="original-network"></span></span>
88
+ </div>
89
+ </div>
51
90
  </div>
52
- </div>
53
91
 
54
- <div class="connected-peers" aria-expanded="false">
55
- <div class="section-header">
56
- <h2>
57
- <button id="connected-peers-toggle" class="toggle-btn" aria-expanded="false">
58
- ▶ Connected Peers
59
- </button>
60
- <span id="connected-peers-count" class="count-badge">0</span>
61
- </h2>
92
+ <div class="card">
93
+ <h3>🎯 Quick Network Switch</h3>
94
+ <p class="description">Quickly switch between common networks (only when disconnected)</p>
95
+ <div class="quick-networks">
96
+ <button class="btn tertiary network-btn" data-network="global">Global</button>
97
+ <button class="btn tertiary network-btn" data-network="gaming">Gaming</button>
98
+ <button class="btn tertiary network-btn" data-network="work">Work</button>
99
+ <button class="btn tertiary network-btn" data-network="family">Family</button>
100
+ <button class="btn tertiary network-btn" data-network="test">Test</button>
101
+ </div>
62
102
  </div>
63
- <div id="connected-peers-content" class="collapsible-content" style="display: none;">
103
+
104
+ <div class="card">
105
+ <h3>Mesh Configuration</h3>
106
+ <div class="config-grid">
107
+ <div class="input-group">
108
+ <label for="max-peers">Max Peers:</label>
109
+ <input type="number" id="max-peers" value="3" min="1" max="10">
110
+ </div>
111
+ <div class="input-group">
112
+ <label for="min-peers">Min Peers:</label>
113
+ <input type="number" id="min-peers" value="2" min="1" max="10">
114
+ </div>
115
+ <div class="checkbox-group">
116
+ <label><input type="checkbox" id="auto-connect" checked> Auto Connect</label>
117
+ <label><input type="checkbox" id="auto-discovery" checked> Auto Discovery</label>
118
+ <label><input type="checkbox" id="eviction-strategy" checked> Eviction Strategy</label>
119
+ <label><input type="checkbox" id="xor-routing" checked> XOR Routing</label>
120
+ </div>
121
+ <div class="checkbox-group">
122
+ <label><input type="checkbox" id="enable-crypto" checked> Enable Crypto</label>
123
+ <label><input type="checkbox" id="enable-webdht" checked> Enable WebDHT</label>
124
+ <label><input type="checkbox" id="enable-distributed-storage" checked> Enable Distributed Storage</label>
125
+ </div>
126
+ <div class="checkbox-group">
127
+ <label><input type="checkbox" id="enable-gossip"> Disable Gossip Protocol</label>
128
+ <label><input type="checkbox" id="enable-hole-punching"> Disable Hole Punching</label>
129
+ <label><input type="checkbox" id="enable-backup-connections"> Disable Backup Connections</label>
130
+ </div>
131
+ </div>
132
+ <button id="apply-config-btn" class="btn tertiary">Apply Configuration</button>
133
+ <button id="get-current-config-btn" class="btn tertiary">Show Current Config</button>
134
+ </div>
135
+
136
+ <div class="card">
137
+ <h3>Connected Peers (<span id="peer-count">0</span>)</h3>
64
138
  <div id="peers-list" class="peers-list">
65
139
  <p class="empty-state">No peers connected</p>
66
140
  </div>
141
+ <div class="peer-actions">
142
+ <input type="text" id="manual-peer-id" placeholder="Enter peer ID to connect">
143
+ <button id="connect-peer-btn" class="btn tertiary">Connect to Peer</button>
144
+ <button id="force-connect-all-btn" class="btn tertiary">Force Connect All</button>
145
+ </div>
67
146
  </div>
68
- </div>
147
+ </section>
69
148
 
70
- <div class="media" aria-expanded="false">
71
- <div class="section-header">
72
- <h2>
73
- <button id="media-toggle" class="toggle-btn" aria-expanded="false">
74
- ▶ Video/Audio
75
- </button>
76
- </h2>
77
- </div>
78
- <div id="media-content" class="collapsible-content" style="display: none;">
79
- <div class="media-controls">
149
+ <!-- Messaging Tab -->
150
+ <section id="messaging-tab" class="tab-content">
151
+ <h2>💬 Messaging & Communication</h2>
152
+
153
+ <div class="card">
154
+ <h3>📢 Broadcast Messages</h3>
155
+ <p class="description">Send messages to all connected peers in the mesh</p>
156
+ <div class="message-input">
80
157
  <div class="input-group">
81
- <label>Media Types:</label>
82
- <div class="checkbox-group">
83
- <label class="checkbox-label">
84
- <input type="checkbox" id="enable-video">
85
- <span class="checkmark"></span>
86
- Enable Video
87
- </label>
88
- <label class="checkbox-label">
89
- <input type="checkbox" id="enable-audio">
90
- <span class="checkmark"></span>
91
- Enable Audio
92
- </label>
93
- </div>
158
+ <label for="broadcast-message">Broadcast Message:</label>
159
+ <textarea id="broadcast-message" placeholder="Enter your broadcast message..." rows="3"></textarea>
160
+ </div>
161
+ <div class="message-options">
162
+ <label><input type="checkbox" id="encrypt-broadcast" checked> Encrypt Message</label>
163
+ <label><input type="checkbox" id="high-priority-broadcast"> High Priority</label>
94
164
  </div>
165
+ <div class="button-group">
166
+ <button id="send-broadcast-btn" class="btn primary">📢 Send Broadcast</button>
167
+ <button id="send-anonymous-btn" class="btn secondary">🎭 Send Anonymous</button>
168
+ </div>
169
+ </div>
170
+ </div>
95
171
 
172
+ <div class="card">
173
+ <h3>📧 Direct Messages</h3>
174
+ <p class="description">Send private messages to specific peers</p>
175
+ <div class="message-input">
96
176
  <div class="input-group">
97
- <label for="camera-select">Camera:</label>
98
- <select id="camera-select" disabled>
99
- <option value="">Select camera...</option>
177
+ <label for="target-peer">Target Peer:</label>
178
+ <select id="target-peer-select">
179
+ <option value="">Select a connected peer...</option>
100
180
  </select>
181
+ <input type="text" id="target-peer" placeholder="Or enter peer ID manually">
101
182
  </div>
102
-
103
183
  <div class="input-group">
104
- <label for="microphone-select">Microphone:</label>
105
- <select id="microphone-select" disabled>
106
- <option value="">Select microphone...</option>
107
- </select>
184
+ <label for="direct-message">Private Message:</label>
185
+ <textarea id="direct-message" placeholder="Enter your direct message..." rows="3"></textarea>
186
+ </div>
187
+ <div class="message-options">
188
+ <label><input type="checkbox" id="encrypt-direct" checked> Encrypt Message</label>
189
+ <label><input type="checkbox" id="request-receipt"> Request Read Receipt</label>
190
+ <label><input type="checkbox" id="ephemeral-message"> Ephemeral (Auto-delete)</label>
108
191
  </div>
109
-
110
192
  <div class="button-group">
111
- <button id="start-media-btn" class="btn primary" disabled>Start Media</button>
112
- <button id="stop-media-btn" class="btn secondary" disabled>Stop Media</button>
113
- <button id="toggle-video-btn" class="btn tertiary" disabled>Toggle Video</button>
114
- <button id="toggle-audio-btn" class="btn tertiary" disabled>Toggle Audio</button>
115
- <button id="test-audio-btn" class="btn warning">🔊 Test Audio</button>
193
+ <button id="send-direct-btn" class="btn primary">📧 Send Direct Message</button>
194
+ <button id="send-file-btn" class="btn secondary">📎 Send File</button>
116
195
  </div>
196
+ </div>
197
+ </div>
117
198
 
118
- <div class="local-video">
119
- <h4>Your Video</h4>
120
- <div id="local-video-container" class="video-container">
121
- <p class="video-placeholder">No video stream</p>
122
- </div>
199
+ <div class="card">
200
+ <h3>💬 Group Chat</h3>
201
+ <p class="description">Create and manage group conversations</p>
202
+ <div class="group-controls">
203
+ <div class="input-group">
204
+ <label for="group-name">Group Name:</label>
205
+ <input type="text" id="group-name" placeholder="Enter group name">
123
206
  </div>
124
-
125
- <div class="remote-videos">
126
- <h4>Peer Videos</h4>
127
- <div id="remote-videos-container" class="videos-grid">
128
- <p class="video-placeholder">No remote video streams</p>
129
- </div>
207
+ <div class="input-group">
208
+ <label for="group-members">Members (comma-separated peer IDs):</label>
209
+ <textarea id="group-members" placeholder="peer1,peer2,peer3..." rows="2"></textarea>
210
+ </div>
211
+ <div class="button-group">
212
+ <button id="create-group-btn" class="btn primary">Create Group</button>
213
+ <button id="join-group-btn" class="btn secondary">Join Group</button>
214
+ <button id="leave-group-btn" class="btn tertiary">Leave Group</button>
215
+ </div>
216
+ <div class="input-group">
217
+ <label for="group-message">Group Message:</label>
218
+ <textarea id="group-message" placeholder="Enter group message..." rows="3"></textarea>
219
+ <button id="send-group-btn" class="btn primary">Send to Group</button>
130
220
  </div>
131
221
  </div>
132
222
  </div>
133
- </div>
223
+ </section>
134
224
 
135
- <div class="discovered-peers" aria-expanded="false">
136
- <div class="section-header">
137
- <h2>
138
- <button id="discovered-peers-toggle" class="toggle-btn" aria-expanded="false">
139
- ▶ Discovered Peers
140
- </button>
141
- <span id="discovered-peers-count" class="count-badge">0</span>
142
- </h2>
143
- </div>
144
- <div id="discovered-peers-content" class="collapsible-content" style="display: none;">
145
- <div id="discovered-peers-list" class="discovered-peers-list">
146
- <p class="empty-state">No peers discovered</p>
225
+ <!-- Media Tab -->
226
+ <section id="media-tab" class="tab-content">
227
+ <h2>🎥 Media Management</h2>
228
+
229
+ <div class="card">
230
+ <h3>Local Media</h3>
231
+ <div class="media-controls">
232
+ <div class="checkbox-group">
233
+ <label><input type="checkbox" id="enable-video"> Enable Video</label>
234
+ <label><input type="checkbox" id="enable-audio"> Enable Audio</label>
235
+ </div>
236
+ <div class="device-selectors">
237
+ <div class="input-group">
238
+ <label for="camera-select">Camera:</label>
239
+ <select id="camera-select">
240
+ <option value="">Select camera...</option>
241
+ </select>
242
+ </div>
243
+ <div class="input-group">
244
+ <label for="microphone-select">Microphone:</label>
245
+ <select id="microphone-select">
246
+ <option value="">Select microphone...</option>
247
+ </select>
248
+ </div>
249
+ </div>
250
+ <div class="button-group">
251
+ <button id="start-media-btn" class="btn primary">Start Media</button>
252
+ <button id="stop-media-btn" class="btn secondary" disabled>Stop Media</button>
253
+ <button id="enumerate-devices-btn" class="btn tertiary">Refresh Devices</button>
254
+ </div>
255
+ <div class="media-toggle">
256
+ <button id="toggle-video-btn" class="btn tertiary" disabled>Toggle Video</button>
257
+ <button id="toggle-audio-btn" class="btn tertiary" disabled>Toggle Audio</button>
258
+ </div>
259
+ </div>
260
+ <div class="media-preview">
261
+ <video id="local-video" autoplay muted playsinline style="display: none;"></video>
262
+ <div id="media-status" class="media-status">No active media stream</div>
147
263
  </div>
148
264
  </div>
149
- </div>
150
265
 
151
- <div class="manual-connection" aria-expanded="false">
152
- <div class="section-header">
153
- <h2>
154
- <button id="manual-connection-toggle" class="toggle-btn" aria-expanded="false">
155
- ▶ Manual Connection
156
- </button>
157
- </h2>
158
- </div>
159
- <div id="manual-connection-content" class="collapsible-content" style="display: none;">
160
- <div class="input-group">
161
- <label for="target-peer">Target Peer ID (40-character SHA-1 hash):</label>
162
- <div class="input-group horizontal">
163
- <input type="text" id="target-peer"
164
- placeholder="Enter 40-character SHA-1 hash"
165
- maxlength="40"
166
- pattern="[a-fA-F0-9]{40}">
167
- <button id="connect-peer-btn" class="btn secondary">Connect to Peer</button>
168
- </div>
169
- <small class="input-help">
170
- Manually connect to a specific peer ID
171
- </small>
266
+ <div class="card">
267
+ <h3>Remote Streams</h3>
268
+ <div id="remote-streams" class="remote-streams">
269
+ <p class="empty-state">No remote streams</p>
172
270
  </div>
173
271
  </div>
174
- </div>
175
272
 
176
- <div class="settings" aria-expanded="false">
177
- <div class="section-header">
178
- <h2>
179
- <button id="settings-toggle" class="toggle-btn" aria-expanded="false">
180
- ▶ Settings
181
- </button>
182
- </h2>
183
- </div>
184
- <div id="settings-content" class="collapsible-content" style="display: none;">
185
- <div class="input-group">
186
- <label for="signaling-url">Signaling Server URL:</label>
187
- <input type="url" id="signaling-url"
188
- placeholder="ws://localhost:3000">
189
- <small class="input-help">
190
- Auto-populated from ?api, ?url, or ?signaling query parameters. Enter base API Gateway URL (without /signaling path).
191
- </small>
192
- </div>
193
- <div class="input-group">
194
- <label for="min-peers">Minimum Peers:</label>
195
- <input type="number" id="min-peers"
196
- min="0" max="49" value="2"
197
- placeholder="Minimum peer connections to maintain">
198
- <small class="input-help">
199
- Minimum peer connections to maintain (0-49, default: 2)
200
- </small>
201
- </div>
202
- <div class="input-group">
203
- <label for="max-peers">Maximum Peers:</label>
204
- <input type="number" id="max-peers"
205
- min="1" max="50" value="10"
206
- placeholder="Maximum number of peer connections">
207
- <small class="input-help">
208
- Limit concurrent peer connections (1-50, default: 10)
209
- </small>
210
- </div>
211
- <div class="auto-discovery-control">
212
- <label class="checkbox-label">
213
- <input type="checkbox" id="xor-routing-toggle" checked>
214
- <span class="checkmark"></span>
215
- Enable XOR-based routing
216
- </label>
217
- <small class="input-help">
218
- Use XOR distance for peer selection and routing optimization
219
- </small>
220
- </div>
221
- <div class="auto-discovery-control">
222
- <label class="checkbox-label">
223
- <input type="checkbox" id="auto-discovery-toggle" checked>
224
- <span class="checkmark"></span>
225
- Enable automatic peer discovery
226
- </label>
227
- <small class="input-help">
228
- Automatically discover and connect to nearby peers
229
- </small>
230
- </div>
231
- <div class="auto-discovery-control">
232
- <label class="checkbox-label">
233
- <input type="checkbox" id="eviction-strategy-toggle" checked>
234
- <span class="checkmark"></span>
235
- Enable smart eviction strategy
236
- </label>
237
- <small class="input-help">
238
- Automatically manage peer connections when at capacity
239
- </small>
240
- </div>
241
- <div class="auto-discovery-control">
242
- <label class="checkbox-label">
243
- <input type="checkbox" id="webdht-toggle" checked disabled>
244
- <span class="checkmark"></span>
245
- Enable WebDHT (Distributed Hash Table)
246
- </label>
247
- <small class="input-help">
248
- WebDHT status (configured at startup, restart required to change)
249
- </small>
250
- </div>
273
+ <div class="card">
274
+ <h3>Media Information</h3>
275
+ <div id="media-info" class="info-display">
276
+ <div>Local Stream: <span id="local-stream-status">None</span></div>
277
+ <div>Video Enabled: <span id="video-enabled-status">No</span></div>
278
+ <div>Audio Enabled: <span id="audio-enabled-status">No</span></div>
279
+ <div>Active Camera: <span id="active-camera">None</span></div>
280
+ <div>Active Microphone: <span id="active-microphone">None</span></div>
281
+ </div>
251
282
  </div>
252
- </div>
283
+ </section>
253
284
 
254
- <div class="dht" aria-expanded="false">
255
- <div class="section-header">
256
- <h2>
257
- <button id="dht-toggle" class="toggle-btn" aria-expanded="false">
258
- ▶ WebDHT - Distributed Hash Table
259
- </button>
260
- </h2>
261
- </div>
262
- <div id="dht-content" class="collapsible-content" style="display: none;">
263
- <div class="dht-actions">
264
- <h3>Store Data</h3>
285
+ <!-- WebDHT & Storage Tab -->
286
+ <section id="dht-tab" class="tab-content">
287
+ <h2>🗄️ WebDHT (Low-Level DHT)</h2>
288
+ <p class="description">Low-level distributed hash table for raw key-value storage without encryption or access control</p>
289
+
290
+ <div class="card">
291
+ <h3>Store Raw Data</h3>
292
+ <div class="dht-form">
265
293
  <div class="input-group">
266
294
  <label for="dht-key">Key:</label>
267
- <input type="text" id="dht-key" placeholder="Enter key (e.g., 'user:123', 'config:theme')">
295
+ <input type="text" id="dht-key" placeholder="Enter raw storage key">
268
296
  </div>
269
297
  <div class="input-group">
270
- <label for="dht-value">Value:</label>
271
- <textarea id="dht-value" placeholder="Enter value (JSON, text, etc.)" rows="3"></textarea>
298
+ <label for="dht-value">Value (JSON):</label>
299
+ <textarea id="dht-value" placeholder='{"example": "data"}' rows="3"></textarea>
272
300
  </div>
273
301
  <div class="input-group">
274
- <label class="checkbox-label">
275
- <input type="checkbox" id="dht-enable-ttl">
276
- <span class="checkmark"></span>
277
- Enable expiration (TTL)
278
- </label>
279
- <small class="input-help">
280
- Check to set an expiration time, unchecked = records persist forever
281
- </small>
282
- </div>
283
- <div class="input-group" id="dht-ttl-group" style="display: none;">
284
- <label for="dht-ttl">TTL (seconds):</label>
285
- <input type="number" id="dht-ttl" placeholder="Time to live" min="1" max="2592000" value="3600">
286
- <small class="input-help">
287
- Time until record expires (e.g., 3600 = 1 hour, 86400 = 1 day)
288
- </small>
302
+ <label for="dht-ttl">TTL (ms, optional):</label>
303
+ <input type="number" id="dht-ttl" placeholder="Time to live in milliseconds">
289
304
  </div>
290
305
  <div class="button-group">
291
- <button id="dht-put-btn" class="btn primary">Store in DHT</button>
292
- <button id="dht-update-btn" class="btn secondary">Update in DHT</button>
306
+ <button id="dht-put-btn" class="btn primary">Store Data</button>
307
+ <button id="dht-update-btn" class="btn secondary">Update Data</button>
293
308
  </div>
294
309
  </div>
310
+ </div>
295
311
 
296
- <div class="dht-actions">
297
- <h3>Retrieve Data</h3>
298
- <div class="input-group horizontal">
299
- <input type="text" id="dht-get-key" placeholder="Enter key to retrieve">
300
- <button id="dht-get-btn" class="btn secondary">Get from DHT</button>
301
- </div>
312
+ <div class="card">
313
+ <h3>Retrieve Data</h3>
314
+ <div class="input-group">
315
+ <label for="dht-get-key">Key:</label>
316
+ <input type="text" id="dht-get-key" placeholder="Enter key to retrieve">
302
317
  </div>
303
-
304
- <div class="dht-actions">
305
- <h3>Subscribe to Changes</h3>
306
- <div class="input-group horizontal">
307
- <input type="text" id="dht-subscribe-key" placeholder="Key to watch for changes">
308
- <div class="button-group">
309
- <button id="dht-subscribe-btn" class="btn tertiary">Subscribe</button>
310
- <button id="dht-clear-subscriptions-btn" class="btn quaternary">Clear All</button>
311
- </div>
312
- </div>
313
- <div id="dht-subscriptions" class="dht-subscriptions">
314
- <h4>Active Subscriptions:</h4>
315
- <div id="dht-subscriptions-list" class="subscriptions-list">
316
- <p class="empty-state">No active subscriptions</p>
317
- </div>
318
- </div>
318
+ <div class="button-group">
319
+ <button id="dht-get-btn" class="btn primary">Get Data</button>
320
+ <button id="dht-delete-btn" class="btn danger">Delete Key</button>
319
321
  </div>
322
+ <div id="dht-result" class="result-display"></div>
323
+ </div>
320
324
 
321
- <div class="dht-results">
322
- <h3>DHT Operations Log</h3>
323
- <div id="dht-log" class="dht-log"></div>
325
+ <div class="card">
326
+ <h3>Subscriptions</h3>
327
+ <div class="input-group">
328
+ <label for="dht-subscribe-key">Key to Subscribe:</label>
329
+ <input type="text" id="dht-subscribe-key" placeholder="Enter key to monitor">
330
+ </div>
331
+ <div class="button-group">
332
+ <button id="dht-subscribe-btn" class="btn primary">Subscribe</button>
333
+ <button id="dht-unsubscribe-btn" class="btn secondary">Unsubscribe</button>
334
+ </div>
335
+ <div id="dht-subscriptions" class="subscriptions-list">
336
+ <p class="empty-state">No active subscriptions</p>
324
337
  </div>
325
338
  </div>
326
- </div>
327
339
 
328
- <div class="crypto" aria-expanded="false">
329
- <div class="section-header">
330
- <h2>
331
- <button id="crypto-toggle" class="toggle-btn" aria-expanded="false">
332
- ▶ Crypto - End-to-End Encryption
333
- </button>
334
- </h2>
335
- </div>
336
- <div id="crypto-content" class="collapsible-content" style="display: none;">
337
- <!-- Crypto Status -->
338
- <div class="crypto-status">
339
- <h3>Crypto Status</h3>
340
- <div class="info-group">
341
- <label>Encryption:</label>
342
- <span id="crypto-status" class="status">Disabled</span>
343
- </div>
344
- <div class="info-group">
345
- <label>Public Key:</label>
346
- <code id="crypto-public-key">None</code>
347
- </div>
348
- <div class="info-group">
349
- <label>Peer Keys:</label>
350
- <span id="crypto-peer-count">0</span>
351
- </div>
340
+ <div class="card">
341
+ <h3>DHT Activity Log</h3>
342
+ <div id="dht-log" class="activity-log">
343
+ <p class="empty-state">No DHT activity yet</p>
352
344
  </div>
345
+ <button id="clear-dht-log-btn" class="btn tertiary">Clear Log</button>
346
+ </div>
353
347
 
354
- <!-- Key Management -->
355
- <div class="crypto-keys">
356
- <h3>Key Management</h3>
348
+ <div class="card">
349
+ <h3>🗃️ Distributed Storage (High-Level)</h3>
350
+ <p class="description">High-level storage with encryption, access control, and storage spaces - built on top of WebDHT</p>
351
+
352
+ <div class="storage-controls">
357
353
  <div class="button-group">
358
- <button id="crypto-generate-btn" class="btn primary">Generate New Keypair</button>
359
- <button id="crypto-reset-btn" class="btn warning">Reset Crypto</button>
360
- <button id="crypto-self-test-btn" class="btn tertiary">Run Self Test</button>
354
+ <button id="storage-enable-btn" class="btn primary">Enable Storage</button>
355
+ <button id="storage-disable-btn" class="btn secondary">Disable Storage</button>
356
+ <button id="storage-status-btn" class="btn tertiary">Get Status</button>
361
357
  </div>
362
358
 
363
- <div class="crypto-user-auth">
364
- <h4>User Authentication (Optional)</h4>
359
+ <div class="storage-form">
365
360
  <div class="input-group">
366
- <label for="crypto-alias">Alias:</label>
367
- <input type="text" id="crypto-alias" placeholder="Your username/alias">
361
+ <label for="storage-key">Storage Key:</label>
362
+ <input type="text" id="storage-key" placeholder="Enter unique storage key">
368
363
  </div>
369
364
  <div class="input-group">
370
- <label for="crypto-password">Password:</label>
371
- <input type="password" id="crypto-password" placeholder="Your password">
365
+ <label for="storage-data">Data (JSON):</label>
366
+ <textarea id="storage-data" placeholder='{"persistent": "data"}' rows="3"></textarea>
367
+ </div>
368
+ <div class="input-group">
369
+ <label for="storage-space">Storage Space:</label>
370
+ <select id="storage-space">
371
+ <option value="private">Private (encrypted, owner-only)</option>
372
+ <option value="public">Public (unencrypted, readable by all)</option>
373
+ <option value="frozen">Frozen (immutable, readable by all)</option>
374
+ </select>
372
375
  </div>
373
376
  <div class="button-group">
374
- <button id="crypto-login-btn" class="btn secondary">Login/Create Account</button>
377
+ <button id="storage-put-btn" class="btn primary">Store Data</button>
378
+ <button id="storage-get-btn" class="btn secondary">Retrieve Data</button>
379
+ <button id="storage-delete-btn" class="btn danger">Delete Data</button>
375
380
  </div>
376
381
  </div>
377
- </div>
378
-
379
- <!-- Message Encryption -->
380
- <div class="crypto-messaging">
381
- <h3>Encrypted Messaging</h3>
382
- <div class="input-group">
383
- <label class="checkbox-label">
384
- <input type="checkbox" id="crypto-auto-encrypt">
385
- <span class="checkmark"></span>
386
- Auto-encrypt outgoing messages
387
- </label>
388
- </div>
389
382
 
390
- <div class="crypto-test-messaging">
391
- <h4>Test Encrypted Messages</h4>
392
- <div class="input-group horizontal">
393
- <input type="text" id="crypto-test-message" placeholder="Test message to encrypt">
394
- <input type="text" id="crypto-test-peer" placeholder="Target peer ID" maxlength="40">
395
- <button id="crypto-send-encrypted-btn" class="btn primary">Send Encrypted</button>
383
+ <div class="storage-management">
384
+ <div class="button-group">
385
+ <button id="storage-list-btn" class="btn tertiary">List All Keys</button>
386
+ <button id="storage-stats-btn" class="btn tertiary">Storage Stats</button>
387
+ <button id="storage-clear-btn" class="btn danger">Clear All Storage</button>
396
388
  </div>
397
389
  </div>
398
390
  </div>
399
-
400
- <!-- Group Encryption -->
401
- <div class="crypto-groups">
402
- <h3>Group Encryption</h3>
403
- <div class="input-group horizontal">
404
- <input type="text" id="crypto-group-id" placeholder="Group ID (e.g., 'chat-room-1')">
405
- <button id="crypto-create-group-btn" class="btn secondary">Create Group Key</button>
406
- </div>
407
-
408
- <div class="crypto-group-messaging">
409
- <div class="input-group horizontal">
410
- <input type="text" id="crypto-group-message" placeholder="Group message">
411
- <select id="crypto-group-select">
412
- <option value="">Select group...</option>
413
- </select>
414
- <button id="crypto-send-group-btn" class="btn primary">Send to Group</button>
415
- </div>
416
- </div>
417
-
418
- <div id="crypto-groups-list" class="crypto-groups-list">
419
- <h4>Active Groups:</h4>
420
- <div class="empty-state">No groups created</div>
421
- </div>
391
+
392
+ <div id="storage-result" class="result-display"></div>
393
+
394
+ <div class="card">
395
+ <h4>Storage Activity Log</h4>
396
+ <div id="storage-log" class="activity-log">
397
+ <p class="empty-state">No storage activity yet</p>
398
+ </div>
399
+ <button id="clear-storage-log-btn" class="btn tertiary">Clear Storage Log</button>
422
400
  </div>
401
+ </div>
402
+ </section>
423
403
 
424
- <!-- Performance Stats -->
425
- <div class="crypto-stats">
426
- <h3>Performance Statistics</h3>
427
- <div class="stats-grid">
428
- <div class="stat-item">
429
- <label>Messages Encrypted:</label>
430
- <span id="crypto-stats-encrypted">0</span>
431
- </div>
432
- <div class="stat-item">
433
- <label>Messages Decrypted:</label>
434
- <span id="crypto-stats-decrypted">0</span>
435
- </div>
436
- <div class="stat-item">
437
- <label>Encryption Time (avg):</label>
438
- <span id="crypto-stats-encrypt-time">0ms</span>
439
- </div>
440
- <div class="stat-item">
441
- <label>Decryption Time (avg):</label>
442
- <span id="crypto-stats-decrypt-time">0ms</span>
443
- </div>
444
- <div class="stat-item">
445
- <label>Key Exchanges:</label>
446
- <span id="crypto-stats-key-exchanges">0</span>
447
- </div>
448
- </div>
404
+ <!-- Encryption Tab -->
405
+ <section id="crypto-tab" class="tab-content">
406
+ <h2>🔐 Encryption & Security</h2>
407
+
408
+ <div class="card">
409
+ <h3>Crypto Status</h3>
410
+ <div id="crypto-status" class="info-display">
411
+ <div>Crypto Enabled: <span id="crypto-enabled-status">Unknown</span></div>
412
+ <div>Public Key: <span id="public-key-display">Not available</span></div>
413
+ <div>Key Exchanges: <span id="key-exchanges-count">0</span></div>
449
414
  </div>
450
-
451
- <!-- Test Results -->
452
- <div class="crypto-test-results">
453
- <h3>Test Results</h3>
454
- <div id="crypto-test-log" class="test-log">
455
- <p class="empty-state">No tests run yet</p>
456
- </div>
415
+ <div class="button-group">
416
+ <button id="refresh-crypto-status-btn" class="btn tertiary">Refresh Status</button>
417
+ <button id="force-crypto-init-btn" class="btn secondary">Force Crypto Init</button>
418
+ <button id="exchange-keys-btn" class="btn primary">Exchange Keys</button>
457
419
  </div>
420
+ </div>
458
421
 
459
- <!-- Advanced Operations -->
460
- <div class="crypto-advanced">
461
- <h3>Advanced Operations</h3>
462
- <div class="button-group">
463
- <button id="crypto-export-key-btn" class="btn quaternary">Export Public Key</button>
464
- <button id="crypto-import-peer-key-btn" class="btn quaternary">Import Peer Key</button>
465
- <button id="crypto-benchmark-btn" class="btn tertiary">Run Benchmark</button>
466
- </div>
467
-
468
- <!-- Import peer key form -->
469
- <div id="crypto-import-form" class="crypto-import-form" style="display: none;">
470
- <div class="input-group">
471
- <label for="crypto-import-peer-id">Peer ID:</label>
472
- <input type="text" id="crypto-import-peer-id" placeholder="40-character peer ID" maxlength="40">
473
- </div>
474
- <div class="input-group">
475
- <label for="crypto-import-public-key">Public Key:</label>
476
- <textarea id="crypto-import-public-key" placeholder="Paste public key here" rows="3"></textarea>
477
- </div>
478
- <div class="button-group">
479
- <button id="crypto-import-confirm-btn" class="btn primary">Import Key</button>
480
- <button id="crypto-import-cancel-btn" class="btn secondary">Cancel</button>
481
- </div>
482
- </div>
422
+ <div class="card">
423
+ <h3>Encrypted Messaging</h3>
424
+ <div class="input-group">
425
+ <label for="encrypted-message">Message:</label>
426
+ <textarea id="encrypted-message" placeholder="Enter message to encrypt and broadcast..." rows="3"></textarea>
427
+ </div>
428
+ <div class="input-group">
429
+ <label for="group-id">Group ID (optional):</label>
430
+ <input type="text" id="group-id" placeholder="Enter group encryption key ID">
483
431
  </div>
432
+ <button id="send-encrypted-btn" class="btn primary">Send Encrypted Broadcast</button>
484
433
  </div>
485
- </div>
486
434
 
487
- <div class="storage" aria-expanded="false">
488
- <div class="section-header">
489
- <h2>
490
- <button id="storage-toggle" class="toggle-btn" aria-expanded="false">
491
- ▶ Distributed Storage - Encrypted P2P Storage Layer
492
- </button>
493
- </h2>
435
+ <div class="card">
436
+ <h3>Key Exchange</h3>
437
+ <div class="input-group">
438
+ <label for="key-exchange-peer">Peer ID:</label>
439
+ <input type="text" id="key-exchange-peer" placeholder="Enter peer ID for key exchange">
440
+ </div>
441
+ <button id="exchange-keys-btn" class="btn primary">Exchange Keys</button>
494
442
  </div>
495
- <div id="storage-content" class="collapsible-content" style="display: none;">
496
- <!-- Storage Status -->
497
- <div class="storage-status">
498
- <h3>Storage Status</h3>
499
- <div class="info-group">
500
- <label>Storage Layer:</label>
501
- <span id="storage-status">Disabled</span>
502
- </div>
503
- <div class="info-group">
504
- <label>Stored Items:</label>
505
- <span id="storage-item-count">0</span>
506
- </div>
507
- <div class="info-group">
508
- <label>Total Size:</label>
509
- <span id="storage-total-size">0 bytes</span>
510
- </div>
443
+
444
+ <div class="card">
445
+ <h3>Manual Key Management</h3>
446
+ <div class="input-group">
447
+ <label for="manual-peer-id">Peer ID:</label>
448
+ <input type="text" id="manual-peer-id" placeholder="Enter peer ID">
449
+ </div>
450
+ <div class="input-group">
451
+ <label for="manual-public-key">Public Key:</label>
452
+ <textarea id="manual-public-key" placeholder="Enter peer's public key..." rows="3"></textarea>
511
453
  </div>
454
+ <button id="add-peer-key-btn" class="btn primary">Add Peer Key</button>
455
+ </div>
512
456
 
513
- <!-- Storage Controls -->
514
- <div class="storage-controls">
515
- <h3>Storage Controls</h3>
516
- <div class="button-group">
517
- <button id="storage-enable-btn" class="btn primary">Enable Storage</button>
518
- <button id="storage-disable-btn" class="btn warning">Disable Storage</button>
519
- <button id="storage-clear-btn" class="btn quaternary">Clear All</button>
520
- </div>
457
+ <div class="card">
458
+ <h3>Encryption Activity Log</h3>
459
+ <div id="crypto-log" class="activity-log">
460
+ <p class="empty-state">No encryption activity yet</p>
521
461
  </div>
462
+ <button id="clear-crypto-log-btn" class="btn tertiary">Clear Log</button>
463
+ </div>
464
+ </section>
522
465
 
523
- <!-- Store Data -->
524
- <div class="storage-operations">
525
- <h3>Store Data</h3>
526
- <div class="input-group">
527
- <label for="storage-key">Key:</label>
528
- <input type="text" id="storage-key" placeholder="Storage key">
466
+ <!-- Network Information Tab -->
467
+ <section id="network-tab" class="tab-content">
468
+ <h2>📊 Network Information & Monitoring</h2>
469
+
470
+ <div class="card">
471
+ <h3>Network Status</h3>
472
+ <div id="network-status" class="status-grid">
473
+ <div class="status-item">
474
+ <label>Connected:</label>
475
+ <span id="network-connected">No</span>
529
476
  </div>
530
- <div class="input-group">
531
- <label for="storage-value">Value:</label>
532
- <textarea id="storage-value" placeholder="Data to store (JSON or text)" rows="3"></textarea>
477
+ <div class="status-item">
478
+ <label>Connected Peers:</label>
479
+ <span id="network-peer-count">0</span>
533
480
  </div>
534
-
535
- <!-- Storage Options -->
536
- <div class="storage-options">
537
- <h4>Storage Options</h4>
538
- <div class="input-group">
539
- <label class="checkbox-label">
540
- <input type="checkbox" id="storage-encrypt" checked>
541
- <span class="checkmark"></span>
542
- Encrypt data
543
- </label>
544
- </div>
545
- <div class="input-group">
546
- <label class="checkbox-label">
547
- <input type="checkbox" id="storage-public">
548
- <span class="checkmark"></span>
549
- Public access (readable by anyone)
550
- </label>
551
- </div>
552
- <div class="input-group">
553
- <label class="checkbox-label">
554
- <input type="checkbox" id="storage-immutable">
555
- <span class="checkmark"></span>
556
- Immutable (cannot be updated)
557
- </label>
558
- </div>
559
- <div class="input-group">
560
- <label class="checkbox-label">
561
- <input type="checkbox" id="storage-crdt">
562
- <span class="checkmark"></span>
563
- Enable CRDT (conflict-free updates)
564
- </label>
565
- </div>
566
- <div class="input-group">
567
- <label for="storage-ttl">TTL (seconds, 0 = no expiration):</label>
568
- <input type="number" id="storage-ttl" value="0" min="0">
569
- </div>
481
+ <div class="status-item">
482
+ <label>Discovered Peers:</label>
483
+ <span id="network-discovered-count">0</span>
570
484
  </div>
571
-
572
- <div class="button-group">
573
- <button id="storage-store-btn" class="btn primary">Store Data</button>
574
- <button id="storage-update-btn" class="btn secondary">Update Data</button>
485
+ <div class="status-item">
486
+ <label>Signaling URL:</label>
487
+ <span id="network-signaling-url">None</span>
488
+ </div>
489
+ <div class="status-item">
490
+ <label>Uptime:</label>
491
+ <span id="network-uptime">0s</span>
492
+ </div>
493
+ <div class="status-item">
494
+ <label>Can Accept More:</label>
495
+ <span id="network-can-accept">Unknown</span>
575
496
  </div>
576
497
  </div>
498
+ <button id="refresh-status-btn" class="btn tertiary">Refresh Status</button>
499
+ </div>
577
500
 
578
- <!-- Retrieve Data -->
579
- <div class="storage-retrieve">
580
- <h3>Retrieve Data</h3>
581
- <div class="input-group horizontal">
582
- <input type="text" id="storage-get-key" placeholder="Key to retrieve">
583
- <button id="storage-get-btn" class="btn secondary">Get Data</button>
584
- <button id="storage-delete-btn" class="btn warning">Delete</button>
585
- </div>
501
+ <div class="card">
502
+ <h3>Peer State Summary</h3>
503
+ <div id="peer-state-summary" class="peer-states">
504
+ <p class="empty-state">No peer state information available</p>
586
505
  </div>
506
+ <button id="get-peer-states-btn" class="btn tertiary">Get Peer States</button>
507
+ </div>
587
508
 
588
- <!-- Access Control -->
589
- <div class="storage-access">
590
- <h3>Access Control</h3>
591
- <div class="input-group horizontal">
592
- <input type="text" id="storage-access-key" placeholder="Key for access control">
593
- <input type="text" id="storage-access-peer" placeholder="Peer ID to grant access">
594
- <select id="storage-access-level">
595
- <option value="read">Read</option>
596
- <option value="write">Write</option>
597
- <option value="admin">Admin</option>
598
- </select>
599
- <button id="storage-grant-access-btn" class="btn tertiary">Grant Access</button>
600
- </div>
601
- <div class="input-group horizontal">
602
- <input type="text" id="storage-revoke-key" placeholder="Key for access revocation">
603
- <input type="text" id="storage-revoke-peer" placeholder="Peer ID to revoke access">
604
- <button id="storage-revoke-access-btn" class="btn quaternary">Revoke Access</button>
605
- </div>
509
+ <div class="card">
510
+ <h3>Connection Monitoring</h3>
511
+ <div class="button-group">
512
+ <button id="start-monitoring-btn" class="btn primary">Start Monitoring</button>
513
+ <button id="stop-monitoring-btn" class="btn secondary" disabled>Stop Monitoring</button>
514
+ <button id="debug-connectivity-btn" class="btn tertiary">Debug Connectivity</button>
606
515
  </div>
516
+ <div id="connection-stats" class="stats-display">
517
+ <p class="empty-state">No monitoring data available</p>
518
+ </div>
519
+ </div>
607
520
 
608
- <!-- Bulk Operations -->
609
- <div class="storage-bulk">
610
- <h3>Bulk Operations</h3>
611
- <div class="input-group horizontal">
612
- <input type="text" id="storage-prefix" placeholder="Key prefix for bulk operations">
613
- <button id="storage-list-btn" class="btn tertiary">List Keys</button>
614
- <button id="storage-bulk-delete-btn" class="btn warning">Bulk Delete</button>
615
- </div>
521
+ <div class="card">
522
+ <h3>Discovered Peers</h3>
523
+ <div id="discovered-peers" class="discovered-peers-list">
524
+ <p class="empty-state">No peers discovered</p>
616
525
  </div>
526
+ </div>
527
+ </section>
617
528
 
618
- <!-- Search -->
619
- <div class="storage-search">
620
- <h3>Search</h3>
621
- <div class="input-group horizontal">
622
- <input type="text" id="storage-search-query" placeholder="Search query">
623
- <select id="storage-search-type">
624
- <option value="key">Search Keys</option>
625
- <option value="value">Search Values</option>
626
- <option value="metadata">Search Metadata</option>
627
- </select>
628
- <button id="storage-search-btn" class="btn tertiary">Search</button>
629
- </div>
529
+ <!-- API Testing Tab -->
530
+ <section id="testing-tab" class="tab-content">
531
+ <h2>🧪 API Testing & Utilities</h2>
532
+
533
+ <div class="card">
534
+ <h3>Utility Functions</h3>
535
+ <div class="button-group">
536
+ <button id="validate-peer-id-btn" class="btn primary">Validate Peer ID</button>
537
+ <button id="force-connect-all-api-btn" class="btn secondary">Force Connect All Peers</button>
538
+ <button id="cleanup-stale-btn" class="btn tertiary">Cleanup Stale Data</button>
539
+ </div>
540
+ <div class="input-group">
541
+ <label for="test-peer-id">Peer ID to Validate:</label>
542
+ <input type="text" id="test-peer-id" placeholder="Enter 40-character hex peer ID">
630
543
  </div>
544
+ <div id="utility-results" class="result-display"></div>
545
+ </div>
631
546
 
632
- <!-- Backup/Restore -->
633
- <div class="storage-backup">
634
- <h3>Backup & Restore</h3>
635
- <div class="button-group">
636
- <button id="storage-backup-btn" class="btn tertiary">Create Backup</button>
637
- <button id="storage-restore-btn" class="btn tertiary">Restore from Backup</button>
638
- </div>
639
- <input type="file" id="storage-restore-file" accept=".json" style="display: none;">
547
+ <div class="card">
548
+ <h3>Performance Testing</h3>
549
+ <div class="input-group">
550
+ <label for="test-message-count">Number of Messages:</label>
551
+ <input type="number" id="test-message-count" value="10" min="1" max="100">
552
+ </div>
553
+ <div class="input-group">
554
+ <label for="test-message-size">Message Size (chars):</label>
555
+ <input type="number" id="test-message-size" value="100" min="1" max="10000">
640
556
  </div>
557
+ <div class="button-group">
558
+ <button id="performance-test-btn" class="btn primary">Run Performance Test</button>
559
+ <button id="stress-test-btn" class="btn danger">Run Stress Test</button>
560
+ </div>
561
+ <div id="performance-results" class="result-display"></div>
562
+ </div>
641
563
 
642
- <!-- Storage Log -->
643
- <div class="storage-results">
644
- <h3>Storage Operations Log</h3>
645
- <div id="storage-log" class="storage-log"></div>
564
+ <div class="card">
565
+ <h3>Test Results & Logs</h3>
566
+ <div id="test-log" class="test-log">
567
+ <p class="empty-state">No test results yet</p>
568
+ </div>
569
+ <div class="button-group">
570
+ <button id="export-logs-btn" class="btn tertiary">Export Logs</button>
571
+ <button id="clear-test-log-btn" class="btn tertiary">Clear Test Log</button>
646
572
  </div>
647
573
  </div>
648
- </div>
649
574
 
650
- <div class="messages">
651
- <h2>Messages</h2>
652
- <div class="input-group horizontal">
653
- <input type="text" id="message-input" placeholder="Enter message">
654
- <input type="text" id="dm-target-input" placeholder="Peer ID for DM (leave blank to broadcast)" maxlength="40" pattern="[a-fA-F0-9]{40}">
655
- <button id="send-message-btn" class="btn primary">Send</button>
575
+ <div class="card">
576
+ <h3>Error Testing</h3>
577
+ <div class="button-group">
578
+ <button id="test-invalid-peer-btn" class="btn danger">Test Invalid Peer Connection</button>
579
+ <button id="test-malformed-message-btn" class="btn danger">Test Malformed Message</button>
580
+ <button id="test-dht-limits-btn" class="btn danger">Test DHT Limits</button>
581
+ </div>
582
+ <div id="error-test-results" class="result-display"></div>
583
+ </div>
584
+ </section>
585
+ </main>
586
+
587
+ <footer>
588
+ <div class="system-log">
589
+ <h3>System Log</h3>
590
+ <div id="system-log" class="log-display">
591
+ <p class="empty-state">System log will appear here...</p>
656
592
  </div>
657
- <small class="input-help">To send a direct message, enter a 40-character peer ID. Leave blank to broadcast.</small>
658
- <div id="messages-log" class="messages-log"></div>
593
+ <button id="clear-log-btn" class="btn tertiary">Clear Log</button>
659
594
  </div>
595
+ </footer>
660
596
  </div>
661
597
 
662
- <script type="module" src="app.js?v=20250704"></script>
598
+ <!-- Load PeerPigeon library -->
599
+ <script src="../../dist/peerpigeon-browser.js"></script>
600
+ <!-- Load our application -->
601
+ <script src="app.js"></script>
663
602
  </body>
664
603
  </html>