peerpigeon 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -16,7 +16,8 @@
16
16
  - **🧠 Smart Eviction Strategy**: Automatically replaces distant peers with closer ones to optimize mesh topology
17
17
  - **🔍 Auto-Discovery**: Seamlessly connects to peers as they join the network
18
18
  - **⚡ WebSocket Signaling**: Real-time bidirectional communication for optimal performance
19
- - **�️ Distributed Hash Table (WebDHT)**: Store and retrieve data across the mesh with automatic replication
19
+ - **🗄️ Distributed Hash Table (WebDHT)**: Store and retrieve data across the mesh with automatic replication
20
+ - **📦 Distributed Storage Layer**: Encrypted, access-controlled storage with CRDT support for collaborative editing
20
21
  - **🎥 Media Streaming**: Built-in support for audio/video streaming between peers
21
22
  - **💬 Messaging System**: Direct messages and broadcast gossip protocol messaging
22
23
  - **🔧 Modular Architecture**: Clean separation of concerns with event-driven components
@@ -170,6 +171,63 @@ mesh.addEventListener('dhtValueChanged', (data) => {
170
171
  await mesh.dhtUpdate('shared-counter', 42);
171
172
  ```
172
173
 
174
+ ### Distributed Storage Layer Examples
175
+
176
+ ```javascript
177
+ // Enable crypto for encryption support
178
+ const mesh = new PeerPigeonMesh({
179
+ enableCrypto: true,
180
+ enableWebDHT: true
181
+ });
182
+
183
+ await mesh.cryptoManager.init();
184
+ await mesh.connect('ws://localhost:3000');
185
+
186
+ // Store private encrypted data
187
+ await mesh.distributedStorage.store('user:profile', {
188
+ name: 'Alice',
189
+ email: 'alice@example.com'
190
+ }, {
191
+ isPublic: false, // Private (encrypted)
192
+ isImmutable: false // Mutable for owner
193
+ });
194
+
195
+ // Store public data
196
+ await mesh.distributedStorage.store('app:config', {
197
+ version: '1.0.0',
198
+ features: ['chat', 'files']
199
+ }, {
200
+ isPublic: true, // Public (not encrypted)
201
+ isImmutable: true // Immutable for other peers
202
+ });
203
+
204
+ // Store collaborative document with CRDT
205
+ await mesh.distributedStorage.store('doc:shared', {
206
+ title: 'Shared Document',
207
+ content: 'Initial content'
208
+ }, {
209
+ isPublic: true,
210
+ enableCRDT: true // Enable collaborative editing
211
+ });
212
+
213
+ // Grant access to private data
214
+ await mesh.distributedStorage.grantAccess('user:profile', otherPeer.peerId);
215
+
216
+ // Retrieve data
217
+ const profile = await mesh.distributedStorage.retrieve('user:profile');
218
+
219
+ // Update data (owner only, or CRDT-enabled)
220
+ await mesh.distributedStorage.update('user:profile', {
221
+ name: 'Alice Smith',
222
+ email: 'alice.smith@example.com'
223
+ });
224
+
225
+ // Listen for storage events
226
+ mesh.addEventListener('storageDataUpdated', (event) => {
227
+ console.log(`Data updated: ${event.key} (version ${event.version})`);
228
+ });
229
+ ```
230
+
173
231
  ### Media Streaming Examples
174
232
 
175
233
  ```javascript
@@ -892,15 +950,18 @@ open "http://localhost:8080/examples/browser/?api=wss://your-signaling-server.co
892
950
  - Force connection utilities for testing
893
951
  - Real-time peer discovery and connection monitoring
894
952
 
895
- ## 🌐 Browser Compatibility & Requirements
953
+ ## 🌐 Platform Compatibility & Requirements
896
954
 
897
- ### Required Browser Features
898
- - **WebRTC**: RTCPeerConnection and RTCDataChannel support
899
- - **ES6 Modules**: Dynamic imports and module syntax
900
- - **Crypto API**: For cryptographically secure peer ID generation
901
- - **WebSocket API**: For real-time signaling communication
955
+ ### Supported Platforms
902
956
 
903
- ### Supported Browsers & Versions
957
+ | Platform | Environment | WebRTC Support | WebSocket Support | Status |
958
+ |---------|-------------|----------------|-------------------|---------|
959
+ | **Web Browsers** | Modern browsers | ✅ Native | ✅ Native | **Full Support** |
960
+ | **Node.js** | Server-side | ⚠️ Via plugin | ✅ Via 'ws' | **Supported** |
961
+ | **NativeScript** | Mobile apps | ⚠️ Via plugin | ✅ Native/Plugin | **Supported** |
962
+ | **Web Workers** | Browser workers | ✅ Limited | ✅ Yes | **Basic Support** |
963
+
964
+ ### Browser Compatibility
904
965
 
905
966
  | Browser | Minimum Version | WebRTC Support | WebSocket Support | Status |
906
967
  |---------|----------------|----------------|-------------------|---------|
@@ -911,6 +972,38 @@ open "http://localhost:8080/examples/browser/?api=wss://your-signaling-server.co
911
972
  | **Mobile Chrome** | 80+ | ✅ Full | ✅ Yes | **Supported** |
912
973
  | **Mobile Safari** | 14+ | ✅ Full | ✅ Yes | **Supported** |
913
974
 
975
+ ### Required Features
976
+ - **WebRTC**: RTCPeerConnection and RTCDataChannel support
977
+ - **ES6 Modules**: Dynamic imports and module syntax
978
+ - **Crypto API**: For cryptographically secure peer ID generation
979
+ - **WebSocket API**: For real-time signaling communication
980
+
981
+ ### NativeScript Support
982
+
983
+ PeerPigeon includes comprehensive NativeScript support:
984
+
985
+ ```javascript
986
+ // NativeScript usage (same API as browser)
987
+ import { PeerPigeonMesh } from 'peerpigeon';
988
+
989
+ const mesh = new PeerPigeonMesh();
990
+ await mesh.init(); // Automatically detects NativeScript environment
991
+
992
+ // Environment detection
993
+ console.log('Environment:', mesh.environmentReport.runtime);
994
+ // { isNativeScript: true, platform: 'android' }
995
+ ```
996
+
997
+ **NativeScript Features:**
998
+ - ✅ Environment detection with platform info (Android/iOS/visionOS)
999
+ - ✅ WebSocket signaling (native or via plugin)
1000
+ - ✅ Storage management using NativeScript APIs
1001
+ - ✅ Basic mesh networking capabilities
1002
+ - ⚠️ WebRTC requires additional native plugins
1003
+ - ⚠️ Media features require camera/microphone permissions
1004
+
1005
+ See the [NativeScript example](examples/nativescript/) for complete setup instructions.
1006
+
914
1007
  ### Feature Detection
915
1008
 
916
1009
  PeerPigeon automatically detects browser capabilities:
@@ -1321,7 +1414,10 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
1321
1414
 
1322
1415
  **Quick Links:**
1323
1416
  - [Live Demo](http://localhost:8080/examples/browser/) (after starting local server)
1417
+ - [Browser Examples](examples/browser/) - Complete web-based examples
1418
+ - [Node.js Examples](examples/node/) - Server-side examples
1419
+ - [NativeScript Examples](examples/nativescript/) - Mobile app examples
1324
1420
  - [API Documentation](docs/API.md)
1325
- - [Deployment Guide](docs/DEPLOYMENT.md)
1421
+ - [Deployment Guide](docs/DEPLOYMENT.md)
1326
1422
  - [GitHub Issues](https://github.com/danrayadev/pigon/issues)
1327
1423
  - [Contributing Guidelines](CONTRIBUTING.md)
@@ -3,10 +3,11 @@ import { PeerPigeonUI } from './ui.js';
3
3
 
4
4
  class PeerPigeonApp {
5
5
  constructor() {
6
- // Initialize mesh with crypto and WebDHT enabled
6
+ // Initialize mesh with crypto, WebDHT, and distributed storage enabled
7
7
  this.mesh = new PeerPigeonMesh({
8
8
  enableWebDHT: true,
9
- enableCrypto: true
9
+ enableCrypto: true,
10
+ enableDistributedStorage: true
10
11
  });
11
12
 
12
13
  this.ui = new PeerPigeonUI(this.mesh);
@@ -484,6 +484,169 @@
484
484
  </div>
485
485
  </div>
486
486
 
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>
494
+ </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>
511
+ </div>
512
+
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>
521
+ </div>
522
+
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">
529
+ </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>
533
+ </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>
570
+ </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>
575
+ </div>
576
+ </div>
577
+
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>
586
+ </div>
587
+
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>
606
+ </div>
607
+
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>
616
+ </div>
617
+
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>
630
+ </div>
631
+
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;">
640
+ </div>
641
+
642
+ <!-- Storage Log -->
643
+ <div class="storage-results">
644
+ <h3>Storage Operations Log</h3>
645
+ <div id="storage-log" class="storage-log"></div>
646
+ </div>
647
+ </div>
648
+ </div>
649
+
487
650
  <div class="messages">
488
651
  <h2>Messages</h2>
489
652
  <div class="input-group horizontal">