@gethashd/bytecave-browser 1.0.8 → 1.0.10

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.
@@ -6081,21 +6081,8 @@ var ByteCaveClient = class {
6081
6081
  }
6082
6082
  }
6083
6083
  if (connected) {
6084
- console.log("[ByteCave] Waiting for connection upgrade...");
6085
- await new Promise((resolve) => setTimeout(resolve, 2e3));
6086
- const health = await p2pProtocolClient.getHealthFromPeer(peer.peerId);
6087
- if (health) {
6088
- this.knownPeers.set(peer.peerId, {
6089
- peerId: peer.peerId,
6090
- publicKey: health.publicKey || "",
6091
- contentTypes: health.contentTypes || "all",
6092
- connected: true,
6093
- nodeId: health.nodeId
6094
- });
6095
- console.log("[ByteCave] \u2713 Discovered peer via HTTP relay:", health.nodeId || peer.peerId.slice(0, 12));
6096
- } else {
6097
- console.warn("[ByteCave] Health query returned null for peer:", peer.peerId.slice(0, 12));
6098
- }
6084
+ console.log("[ByteCave] \u2713 Connected to peer via HTTP relay:", peer.peerId.slice(0, 12));
6085
+ console.log("[ByteCave] Waiting for peer announcement with health data...");
6099
6086
  }
6100
6087
  } catch (err) {
6101
6088
  console.warn("[ByteCave] Failed to process peer from HTTP relay:", err.message);
@@ -6601,15 +6588,17 @@ Nonce: ${nonce}`;
6601
6588
  const existing = this.knownPeers.get(announcement.peerId);
6602
6589
  const peerInfo = {
6603
6590
  peerId: announcement.peerId,
6604
- publicKey: existing?.publicKey || "",
6591
+ publicKey: announcement.publicKey || existing?.publicKey || "",
6605
6592
  contentTypes: announcement.contentTypes || "all",
6606
- connected: this.node?.getPeers().some((p) => p.toString() === announcement.peerId) || false
6593
+ connected: this.node?.getPeers().some((p) => p.toString() === announcement.peerId) || false,
6594
+ nodeId: announcement.nodeId || existing?.nodeId,
6595
+ // Store all health data from announcement
6596
+ availableStorage: announcement.availableStorage,
6597
+ blobCount: announcement.blobCount,
6598
+ timestamp: announcement.timestamp,
6599
+ multiaddrs: announcement.multiaddrs,
6600
+ relayAddrs: announcement.relayAddrs || existing?.relayAddrs
6607
6601
  };
6608
- if (announcement.relayAddrs && announcement.relayAddrs.length > 0) {
6609
- peerInfo.relayAddrs = announcement.relayAddrs;
6610
- } else if (existing && existing.relayAddrs) {
6611
- peerInfo.relayAddrs = existing.relayAddrs;
6612
- }
6613
6602
  this.knownPeers.set(announcement.peerId, peerInfo);
6614
6603
  this.emit("peerAnnounce", peerInfo);
6615
6604
  }
package/dist/index.cjs CHANGED
@@ -6134,21 +6134,8 @@ var ByteCaveClient = class {
6134
6134
  }
6135
6135
  }
6136
6136
  if (connected) {
6137
- console.log("[ByteCave] Waiting for connection upgrade...");
6138
- await new Promise((resolve) => setTimeout(resolve, 2e3));
6139
- const health = await p2pProtocolClient.getHealthFromPeer(peer.peerId);
6140
- if (health) {
6141
- this.knownPeers.set(peer.peerId, {
6142
- peerId: peer.peerId,
6143
- publicKey: health.publicKey || "",
6144
- contentTypes: health.contentTypes || "all",
6145
- connected: true,
6146
- nodeId: health.nodeId
6147
- });
6148
- console.log("[ByteCave] \u2713 Discovered peer via HTTP relay:", health.nodeId || peer.peerId.slice(0, 12));
6149
- } else {
6150
- console.warn("[ByteCave] Health query returned null for peer:", peer.peerId.slice(0, 12));
6151
- }
6137
+ console.log("[ByteCave] \u2713 Connected to peer via HTTP relay:", peer.peerId.slice(0, 12));
6138
+ console.log("[ByteCave] Waiting for peer announcement with health data...");
6152
6139
  }
6153
6140
  } catch (err) {
6154
6141
  console.warn("[ByteCave] Failed to process peer from HTTP relay:", err.message);
@@ -6654,15 +6641,17 @@ Nonce: ${nonce}`;
6654
6641
  const existing = this.knownPeers.get(announcement.peerId);
6655
6642
  const peerInfo = {
6656
6643
  peerId: announcement.peerId,
6657
- publicKey: existing?.publicKey || "",
6644
+ publicKey: announcement.publicKey || existing?.publicKey || "",
6658
6645
  contentTypes: announcement.contentTypes || "all",
6659
- connected: this.node?.getPeers().some((p) => p.toString() === announcement.peerId) || false
6646
+ connected: this.node?.getPeers().some((p) => p.toString() === announcement.peerId) || false,
6647
+ nodeId: announcement.nodeId || existing?.nodeId,
6648
+ // Store all health data from announcement
6649
+ availableStorage: announcement.availableStorage,
6650
+ blobCount: announcement.blobCount,
6651
+ timestamp: announcement.timestamp,
6652
+ multiaddrs: announcement.multiaddrs,
6653
+ relayAddrs: announcement.relayAddrs || existing?.relayAddrs
6660
6654
  };
6661
- if (announcement.relayAddrs && announcement.relayAddrs.length > 0) {
6662
- peerInfo.relayAddrs = announcement.relayAddrs;
6663
- } else if (existing && existing.relayAddrs) {
6664
- peerInfo.relayAddrs = existing.relayAddrs;
6665
- }
6666
6655
  this.knownPeers.set(announcement.peerId, peerInfo);
6667
6656
  this.emit("peerAnnounce", peerInfo);
6668
6657
  }
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  useHashdImage,
14
14
  useHashdMedia,
15
15
  useHashdUrl
16
- } from "./chunk-DSL42Z3Z.js";
16
+ } from "./chunk-DJDKXTUN.js";
17
17
  import {
18
18
  clearHashdCache,
19
19
  createHashdUrl,
@@ -8,7 +8,7 @@ import {
8
8
  useHashdImage,
9
9
  useHashdMedia,
10
10
  useHashdUrl
11
- } from "../chunk-DSL42Z3Z.js";
11
+ } from "../chunk-DJDKXTUN.js";
12
12
  import "../chunk-EEZWRIUI.js";
13
13
  export {
14
14
  HashdAudio,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gethashd/bytecave-browser",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "ByteCave browser client for WebRTC P2P connections to storage nodes",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
package/src/client.ts CHANGED
@@ -181,24 +181,9 @@ export class ByteCaveClient {
181
181
  }
182
182
 
183
183
  if (connected) {
184
- // Wait for DCUtR to upgrade connection from relay circuit to direct WebRTC
185
- console.log('[ByteCave] Waiting for connection upgrade...');
186
- await new Promise(resolve => setTimeout(resolve, 2000));
187
-
188
- // Fetch health data
189
- const health = await p2pProtocolClient.getHealthFromPeer(peer.peerId);
190
- if (health) {
191
- this.knownPeers.set(peer.peerId, {
192
- peerId: peer.peerId,
193
- publicKey: health.publicKey || '',
194
- contentTypes: health.contentTypes || 'all',
195
- connected: true,
196
- nodeId: health.nodeId
197
- });
198
- console.log('[ByteCave] ✓ Discovered peer via HTTP relay:', health.nodeId || peer.peerId.slice(0, 12));
199
- } else {
200
- console.warn('[ByteCave] Health query returned null for peer:', peer.peerId.slice(0, 12));
201
- }
184
+ // Just mark as discovered - floodsub announcements will provide full health data
185
+ console.log('[ByteCave] Connected to peer via HTTP relay:', peer.peerId.slice(0, 12));
186
+ console.log('[ByteCave] Waiting for peer announcement with health data...');
202
187
  }
203
188
  } catch (err: any) {
204
189
  console.warn('[ByteCave] Failed to process peer from HTTP relay:', err.message);
@@ -825,30 +810,26 @@ Nonce: ${nonce}`;
825
810
  });
826
811
  }
827
812
 
828
- private async handlePeerAnnouncement(announcement: {
829
- peerId: string;
830
- timestamp?: number;
831
- relayAddrs?: string[];
832
- contentTypes?: string[] | 'all';
833
- }): Promise<void> {
813
+ private async handlePeerAnnouncement(announcement: any): Promise<void> {
834
814
  console.log('[ByteCave] Received announcement from peer:', announcement.peerId.slice(0, 12), announcement);
835
815
 
836
816
  const existing = this.knownPeers.get(announcement.peerId);
837
817
 
838
- const peerInfo: PeerInfo = {
818
+ // Store ALL announcement data, not just PeerInfo fields
819
+ const peerInfo: any = {
839
820
  peerId: announcement.peerId,
840
- publicKey: existing?.publicKey || '',
821
+ publicKey: announcement.publicKey || existing?.publicKey || '',
841
822
  contentTypes: announcement.contentTypes || 'all',
842
- connected: this.node?.getPeers().some(p => p.toString() === announcement.peerId) || false
823
+ connected: this.node?.getPeers().some(p => p.toString() === announcement.peerId) || false,
824
+ nodeId: announcement.nodeId || existing?.nodeId,
825
+ // Store all health data from announcement
826
+ availableStorage: announcement.availableStorage,
827
+ blobCount: announcement.blobCount,
828
+ timestamp: announcement.timestamp,
829
+ multiaddrs: announcement.multiaddrs,
830
+ relayAddrs: announcement.relayAddrs || (existing as any)?.relayAddrs
843
831
  };
844
832
 
845
- // Preserve relay addresses from existing peer info if new announcement doesn't have them
846
- if (announcement.relayAddrs && announcement.relayAddrs.length > 0) {
847
- (peerInfo as any).relayAddrs = announcement.relayAddrs;
848
- } else if (existing && (existing as any).relayAddrs) {
849
- (peerInfo as any).relayAddrs = (existing as any).relayAddrs;
850
- }
851
-
852
833
  this.knownPeers.set(announcement.peerId, peerInfo);
853
834
 
854
835
  this.emit('peerAnnounce', peerInfo);