@gethashd/bytecave-browser 1.0.20 → 1.0.22

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.
@@ -5705,15 +5705,9 @@ var P2PProtocolClient = class {
5705
5705
  const timeoutMs = 3e4 + fileSizeMB * 1e4;
5706
5706
  console.log(`[ByteCave P2P] Store timeout: ${Math.round(timeoutMs / 1e3)}s for ${fileSizeMB.toFixed(2)}MB`);
5707
5707
  const storePromise = (async () => {
5708
- console.log("[ByteCave P2P] Step 1: Getting existing connection...");
5709
- const connections = this.node.getConnections(peerIdObj);
5710
- if (connections.length === 0) {
5711
- throw new Error("No connection to peer");
5712
- }
5713
- const connection = connections[0];
5714
- console.log("[ByteCave P2P] Step 2: Opening stream on existing connection...");
5715
- const stream = await connection.newStream("/bytecave/store/1.0.0");
5716
- console.log("[ByteCave P2P] Step 3: Stream established");
5708
+ console.log("[ByteCave P2P] Step 1: Dialing store protocol...");
5709
+ const stream = await this.node.dialProtocol(peerIdObj, "/bytecave/store/1.0.0");
5710
+ console.log("[ByteCave P2P] Step 2: Stream established");
5717
5711
  const dataCopy = new Uint8Array(ciphertext);
5718
5712
  const hashBuffer = await crypto.subtle.digest("SHA-256", dataCopy);
5719
5713
  const hashArray = Array.from(new Uint8Array(hashBuffer));
@@ -6327,16 +6321,13 @@ var ByteCaveClient = class {
6327
6321
  return { success: false, error: "P2P node not initialized" };
6328
6322
  }
6329
6323
  const allPeers = this.node.getPeers();
6330
- const connectedPeerIds = allPeers.map((p) => p.toString()).filter((peerId) => {
6331
- const peerInfo = this.knownPeers.get(peerId);
6332
- return !peerInfo?.isRelay;
6333
- });
6324
+ const connectedPeerIds = allPeers.map((p) => p.toString());
6334
6325
  console.log("[ByteCave] Store - connected storage peers:", connectedPeerIds.length);
6335
6326
  console.log("[ByteCave] Store - knownPeers with registration info:", this.knownPeers.size);
6336
6327
  if (connectedPeerIds.length === 0) {
6337
6328
  return { success: false, error: "No storage peers available" };
6338
6329
  }
6339
- const registeredPeerIds = Array.from(this.knownPeers.values()).filter((p) => p.isRegistered && !p.isRelay && connectedPeerIds.includes(p.peerId)).map((p) => p.peerId);
6330
+ const registeredPeerIds = Array.from(this.knownPeers.values()).filter((p) => p.isRegistered && connectedPeerIds.includes(p.peerId)).map((p) => p.peerId);
6340
6331
  const storagePeerIds = registeredPeerIds.length > 0 ? [...registeredPeerIds, ...connectedPeerIds.filter((id) => !registeredPeerIds.includes(id))] : connectedPeerIds;
6341
6332
  console.log(
6342
6333
  "[ByteCave] Store - peer order (registered first):",
@@ -6686,12 +6677,7 @@ Nonce: ${nonce}`;
6686
6677
  blobCount: announcement.blobCount,
6687
6678
  timestamp: announcement.timestamp,
6688
6679
  multiaddrs: announcement.multiaddrs,
6689
- relayAddrs: announcement.relayAddrs || existing?.relayAddrs,
6690
- // Store on-chain registration status
6691
- registeredOnChain: announcement.registeredOnChain || false,
6692
- onChainNodeId: announcement.onChainNodeId || existing?.onChainNodeId,
6693
- // Store relay flag so we can filter out relays from storage attempts
6694
- isRelay: announcement.isRelay || false
6680
+ relayAddrs: announcement.relayAddrs || existing?.relayAddrs
6695
6681
  };
6696
6682
  this.knownPeers.set(announcement.peerId, peerInfo);
6697
6683
  this.emit("peerAnnounce", peerInfo);
package/dist/index.cjs CHANGED
@@ -5773,15 +5773,9 @@ var P2PProtocolClient = class {
5773
5773
  const timeoutMs = 3e4 + fileSizeMB * 1e4;
5774
5774
  console.log(`[ByteCave P2P] Store timeout: ${Math.round(timeoutMs / 1e3)}s for ${fileSizeMB.toFixed(2)}MB`);
5775
5775
  const storePromise = (async () => {
5776
- console.log("[ByteCave P2P] Step 1: Getting existing connection...");
5777
- const connections = this.node.getConnections(peerIdObj);
5778
- if (connections.length === 0) {
5779
- throw new Error("No connection to peer");
5780
- }
5781
- const connection = connections[0];
5782
- console.log("[ByteCave P2P] Step 2: Opening stream on existing connection...");
5783
- const stream = await connection.newStream("/bytecave/store/1.0.0");
5784
- console.log("[ByteCave P2P] Step 3: Stream established");
5776
+ console.log("[ByteCave P2P] Step 1: Dialing store protocol...");
5777
+ const stream = await this.node.dialProtocol(peerIdObj, "/bytecave/store/1.0.0");
5778
+ console.log("[ByteCave P2P] Step 2: Stream established");
5785
5779
  const dataCopy = new Uint8Array(ciphertext);
5786
5780
  const hashBuffer = await crypto.subtle.digest("SHA-256", dataCopy);
5787
5781
  const hashArray = Array.from(new Uint8Array(hashBuffer));
@@ -6380,16 +6374,13 @@ var ByteCaveClient = class {
6380
6374
  return { success: false, error: "P2P node not initialized" };
6381
6375
  }
6382
6376
  const allPeers = this.node.getPeers();
6383
- const connectedPeerIds = allPeers.map((p) => p.toString()).filter((peerId) => {
6384
- const peerInfo = this.knownPeers.get(peerId);
6385
- return !peerInfo?.isRelay;
6386
- });
6377
+ const connectedPeerIds = allPeers.map((p) => p.toString());
6387
6378
  console.log("[ByteCave] Store - connected storage peers:", connectedPeerIds.length);
6388
6379
  console.log("[ByteCave] Store - knownPeers with registration info:", this.knownPeers.size);
6389
6380
  if (connectedPeerIds.length === 0) {
6390
6381
  return { success: false, error: "No storage peers available" };
6391
6382
  }
6392
- const registeredPeerIds = Array.from(this.knownPeers.values()).filter((p) => p.isRegistered && !p.isRelay && connectedPeerIds.includes(p.peerId)).map((p) => p.peerId);
6383
+ const registeredPeerIds = Array.from(this.knownPeers.values()).filter((p) => p.isRegistered && connectedPeerIds.includes(p.peerId)).map((p) => p.peerId);
6393
6384
  const storagePeerIds = registeredPeerIds.length > 0 ? [...registeredPeerIds, ...connectedPeerIds.filter((id) => !registeredPeerIds.includes(id))] : connectedPeerIds;
6394
6385
  console.log(
6395
6386
  "[ByteCave] Store - peer order (registered first):",
@@ -6739,12 +6730,7 @@ Nonce: ${nonce}`;
6739
6730
  blobCount: announcement.blobCount,
6740
6731
  timestamp: announcement.timestamp,
6741
6732
  multiaddrs: announcement.multiaddrs,
6742
- relayAddrs: announcement.relayAddrs || existing?.relayAddrs,
6743
- // Store on-chain registration status
6744
- registeredOnChain: announcement.registeredOnChain || false,
6745
- onChainNodeId: announcement.onChainNodeId || existing?.onChainNodeId,
6746
- // Store relay flag so we can filter out relays from storage attempts
6747
- isRelay: announcement.isRelay || false
6733
+ relayAddrs: announcement.relayAddrs || existing?.relayAddrs
6748
6734
  };
6749
6735
  this.knownPeers.set(announcement.peerId, peerInfo);
6750
6736
  this.emit("peerAnnounce", peerInfo);
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  useHashdImage,
14
14
  useHashdMedia,
15
15
  useHashdUrl
16
- } from "./chunk-6ITKYT45.js";
16
+ } from "./chunk-ZFKOXO6W.js";
17
17
  import {
18
18
  clearHashdCache,
19
19
  createHashdUrl,
@@ -6028,15 +6028,9 @@ var P2PProtocolClient = class {
6028
6028
  const timeoutMs = 3e4 + fileSizeMB * 1e4;
6029
6029
  console.log(`[ByteCave P2P] Store timeout: ${Math.round(timeoutMs / 1e3)}s for ${fileSizeMB.toFixed(2)}MB`);
6030
6030
  const storePromise = (async () => {
6031
- console.log("[ByteCave P2P] Step 1: Getting existing connection...");
6032
- const connections = this.node.getConnections(peerIdObj);
6033
- if (connections.length === 0) {
6034
- throw new Error("No connection to peer");
6035
- }
6036
- const connection = connections[0];
6037
- console.log("[ByteCave P2P] Step 2: Opening stream on existing connection...");
6038
- const stream = await connection.newStream("/bytecave/store/1.0.0");
6039
- console.log("[ByteCave P2P] Step 3: Stream established");
6031
+ console.log("[ByteCave P2P] Step 1: Dialing store protocol...");
6032
+ const stream = await this.node.dialProtocol(peerIdObj, "/bytecave/store/1.0.0");
6033
+ console.log("[ByteCave P2P] Step 2: Stream established");
6040
6034
  const dataCopy = new Uint8Array(ciphertext);
6041
6035
  const hashBuffer = await crypto.subtle.digest("SHA-256", dataCopy);
6042
6036
  const hashArray = Array.from(new Uint8Array(hashBuffer));
@@ -8,7 +8,7 @@ import {
8
8
  useHashdImage,
9
9
  useHashdMedia,
10
10
  useHashdUrl
11
- } from "../chunk-6ITKYT45.js";
11
+ } from "../chunk-ZFKOXO6W.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.20",
3
+ "version": "1.0.22",
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
@@ -427,14 +427,9 @@ export class ByteCaveClient {
427
427
  return { success: false, error: 'P2P node not initialized' };
428
428
  }
429
429
 
430
- // Get all connected peers, excluding relay peers (they don't support storage)
430
+ // Get all connected peers
431
431
  const allPeers = this.node.getPeers();
432
- const connectedPeerIds = allPeers.map(p => p.toString())
433
- .filter(peerId => {
434
- const peerInfo = this.knownPeers.get(peerId) as any;
435
- // Filter out relay peers - they announce with isRelay: true
436
- return !peerInfo?.isRelay;
437
- });
432
+ const connectedPeerIds = allPeers.map(p => p.toString());
438
433
 
439
434
  console.log('[ByteCave] Store - connected storage peers:', connectedPeerIds.length);
440
435
  console.log('[ByteCave] Store - knownPeers with registration info:', this.knownPeers.size);
@@ -446,7 +441,7 @@ export class ByteCaveClient {
446
441
  // Prioritize registered peers from knownPeers (populated via floodsub announcements)
447
442
  // If no registered peers known yet, use all connected peers
448
443
  const registeredPeerIds = Array.from(this.knownPeers.values())
449
- .filter(p => p.isRegistered && !(p as any).isRelay && connectedPeerIds.includes(p.peerId))
444
+ .filter(p => p.isRegistered && connectedPeerIds.includes(p.peerId))
450
445
  .map(p => p.peerId);
451
446
 
452
447
  const storagePeerIds = registeredPeerIds.length > 0
@@ -886,12 +881,7 @@ Nonce: ${nonce}`;
886
881
  blobCount: announcement.blobCount,
887
882
  timestamp: announcement.timestamp,
888
883
  multiaddrs: announcement.multiaddrs,
889
- relayAddrs: announcement.relayAddrs || (existing as any)?.relayAddrs,
890
- // Store on-chain registration status
891
- registeredOnChain: announcement.registeredOnChain || false,
892
- onChainNodeId: announcement.onChainNodeId || (existing as any)?.onChainNodeId,
893
- // Store relay flag so we can filter out relays from storage attempts
894
- isRelay: announcement.isRelay || false
884
+ relayAddrs: announcement.relayAddrs || (existing as any)?.relayAddrs
895
885
  };
896
886
 
897
887
  this.knownPeers.set(announcement.peerId, peerInfo);
@@ -124,16 +124,10 @@ export class P2PProtocolClient {
124
124
 
125
125
  // Wrap the entire operation in a timeout
126
126
  const storePromise = (async () => {
127
- console.log('[ByteCave P2P] Step 1: Getting existing connection...');
128
- // Get existing connection (relay circuit) instead of dialing new connection
129
- const connections = this.node!.getConnections(peerIdObj);
130
- if (connections.length === 0) {
131
- throw new Error('No connection to peer');
132
- }
133
- const connection = connections[0];
134
- console.log('[ByteCave P2P] Step 2: Opening stream on existing connection...');
135
- const stream = await connection.newStream('/bytecave/store/1.0.0');
136
- console.log('[ByteCave P2P] Step 3: Stream established');
127
+ console.log('[ByteCave P2P] Step 1: Dialing store protocol...');
128
+ // dialProtocol will upgrade limited relay connections to full connections automatically
129
+ const stream = await this.node!.dialProtocol(peerIdObj, '/bytecave/store/1.0.0');
130
+ console.log('[ByteCave P2P] Step 2: Stream established');
137
131
 
138
132
  // Generate CID using SHA-256 (matches bytecave-core format: 64-char hex)
139
133
  const dataCopy = new Uint8Array(ciphertext);