@gethashd/bytecave-browser 1.0.22 → 1.0.24

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,14 +5705,44 @@ 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: Dialing store protocol...");
5708
+ console.log("[ByteCave P2P] Step 1: Checking existing connections to peer", peerId.slice(0, 12));
5709
+ const existingConns = this.node.getConnections(peerIdObj);
5710
+ console.log("[ByteCave P2P] Existing connections:", existingConns.length);
5711
+ existingConns.forEach((conn, idx) => {
5712
+ console.log(`[ByteCave P2P] Connection ${idx}:`, {
5713
+ remoteAddr: conn.remoteAddr.toString(),
5714
+ status: conn.status,
5715
+ direction: conn.direction,
5716
+ timeline: conn.timeline
5717
+ });
5718
+ });
5719
+ console.log("[ByteCave P2P] Step 2: Dialing store protocol /bytecave/store/1.0.0...");
5720
+ const dialStart = Date.now();
5721
+ try {
5722
+ const stream2 = await this.node.dialProtocol(peerIdObj, "/bytecave/store/1.0.0");
5723
+ const dialDuration = Date.now() - dialStart;
5724
+ console.log("[ByteCave P2P] Step 3: Stream established in", dialDuration, "ms");
5725
+ console.log("[ByteCave P2P] Stream details:", {
5726
+ protocol: stream2.protocol,
5727
+ direction: stream2.direction,
5728
+ timeline: stream2.timeline
5729
+ });
5730
+ } catch (dialError) {
5731
+ const dialDuration = Date.now() - dialStart;
5732
+ console.error("[ByteCave P2P] dialProtocol FAILED after", dialDuration, "ms:", {
5733
+ error: dialError.message,
5734
+ code: dialError.code,
5735
+ name: dialError.name,
5736
+ stack: dialError.stack?.split("\n").slice(0, 3)
5737
+ });
5738
+ throw dialError;
5739
+ }
5709
5740
  const stream = await this.node.dialProtocol(peerIdObj, "/bytecave/store/1.0.0");
5710
- console.log("[ByteCave P2P] Step 2: Stream established");
5711
5741
  const dataCopy = new Uint8Array(ciphertext);
5712
5742
  const hashBuffer = await crypto.subtle.digest("SHA-256", dataCopy);
5713
5743
  const hashArray = Array.from(new Uint8Array(hashBuffer));
5714
5744
  const cid = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
5715
- console.log("[ByteCave P2P] Step 3: CID generated:", cid.slice(0, 16) + "...");
5745
+ console.log("[ByteCave P2P] Step 4: CID generated:", cid.slice(0, 16) + "...");
5716
5746
  const request = {
5717
5747
  cid,
5718
5748
  mimeType,
@@ -5725,11 +5755,18 @@ var P2PProtocolClient = class {
5725
5755
  };
5726
5756
  console.log("[ByteCave P2P] Step 4: Request prepared, size:", JSON.stringify(request).length, "bytes");
5727
5757
  console.log("[ByteCave P2P] Step 5: Writing message to stream...");
5758
+ const writeStart = Date.now();
5728
5759
  await this.writeMessage(stream, request);
5729
- console.log("[ByteCave P2P] Step 6: Message written, waiting for response...");
5760
+ const writeDuration = Date.now() - writeStart;
5761
+ console.log("[ByteCave P2P] Request written in", writeDuration, "ms");
5762
+ console.log("[ByteCave P2P] Step 6: Waiting for response from node...");
5763
+ const readStart = Date.now();
5730
5764
  const response = await this.readMessage(stream);
5731
- console.log("[ByteCave P2P] Step 7: Response received:", response);
5765
+ const readDuration = Date.now() - readStart;
5766
+ console.log("[ByteCave P2P] Response received in", readDuration, "ms:", response);
5767
+ console.log("[ByteCave P2P] Step 7: Closing stream...");
5732
5768
  await stream.close();
5769
+ console.log("[ByteCave P2P] Stream closed successfully");
5733
5770
  if (response?.success) {
5734
5771
  return { success: true, cid };
5735
5772
  } else {
@@ -6677,7 +6714,12 @@ Nonce: ${nonce}`;
6677
6714
  blobCount: announcement.blobCount,
6678
6715
  timestamp: announcement.timestamp,
6679
6716
  multiaddrs: announcement.multiaddrs,
6680
- relayAddrs: announcement.relayAddrs || existing?.relayAddrs
6717
+ relayAddrs: announcement.relayAddrs || existing?.relayAddrs,
6718
+ // Store on-chain registration status
6719
+ registeredOnChain: announcement.registeredOnChain || false,
6720
+ onChainNodeId: announcement.onChainNodeId || existing?.onChainNodeId,
6721
+ // Store relay flag
6722
+ isRelay: announcement.isRelay || false
6681
6723
  };
6682
6724
  this.knownPeers.set(announcement.peerId, peerInfo);
6683
6725
  this.emit("peerAnnounce", peerInfo);
package/dist/index.cjs CHANGED
@@ -5773,14 +5773,44 @@ 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: Dialing store protocol...");
5776
+ console.log("[ByteCave P2P] Step 1: Checking existing connections to peer", peerId.slice(0, 12));
5777
+ const existingConns = this.node.getConnections(peerIdObj);
5778
+ console.log("[ByteCave P2P] Existing connections:", existingConns.length);
5779
+ existingConns.forEach((conn, idx) => {
5780
+ console.log(`[ByteCave P2P] Connection ${idx}:`, {
5781
+ remoteAddr: conn.remoteAddr.toString(),
5782
+ status: conn.status,
5783
+ direction: conn.direction,
5784
+ timeline: conn.timeline
5785
+ });
5786
+ });
5787
+ console.log("[ByteCave P2P] Step 2: Dialing store protocol /bytecave/store/1.0.0...");
5788
+ const dialStart = Date.now();
5789
+ try {
5790
+ const stream2 = await this.node.dialProtocol(peerIdObj, "/bytecave/store/1.0.0");
5791
+ const dialDuration = Date.now() - dialStart;
5792
+ console.log("[ByteCave P2P] Step 3: Stream established in", dialDuration, "ms");
5793
+ console.log("[ByteCave P2P] Stream details:", {
5794
+ protocol: stream2.protocol,
5795
+ direction: stream2.direction,
5796
+ timeline: stream2.timeline
5797
+ });
5798
+ } catch (dialError) {
5799
+ const dialDuration = Date.now() - dialStart;
5800
+ console.error("[ByteCave P2P] dialProtocol FAILED after", dialDuration, "ms:", {
5801
+ error: dialError.message,
5802
+ code: dialError.code,
5803
+ name: dialError.name,
5804
+ stack: dialError.stack?.split("\n").slice(0, 3)
5805
+ });
5806
+ throw dialError;
5807
+ }
5777
5808
  const stream = await this.node.dialProtocol(peerIdObj, "/bytecave/store/1.0.0");
5778
- console.log("[ByteCave P2P] Step 2: Stream established");
5779
5809
  const dataCopy = new Uint8Array(ciphertext);
5780
5810
  const hashBuffer = await crypto.subtle.digest("SHA-256", dataCopy);
5781
5811
  const hashArray = Array.from(new Uint8Array(hashBuffer));
5782
5812
  const cid = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
5783
- console.log("[ByteCave P2P] Step 3: CID generated:", cid.slice(0, 16) + "...");
5813
+ console.log("[ByteCave P2P] Step 4: CID generated:", cid.slice(0, 16) + "...");
5784
5814
  const request = {
5785
5815
  cid,
5786
5816
  mimeType,
@@ -5793,11 +5823,18 @@ var P2PProtocolClient = class {
5793
5823
  };
5794
5824
  console.log("[ByteCave P2P] Step 4: Request prepared, size:", JSON.stringify(request).length, "bytes");
5795
5825
  console.log("[ByteCave P2P] Step 5: Writing message to stream...");
5826
+ const writeStart = Date.now();
5796
5827
  await this.writeMessage(stream, request);
5797
- console.log("[ByteCave P2P] Step 6: Message written, waiting for response...");
5828
+ const writeDuration = Date.now() - writeStart;
5829
+ console.log("[ByteCave P2P] Request written in", writeDuration, "ms");
5830
+ console.log("[ByteCave P2P] Step 6: Waiting for response from node...");
5831
+ const readStart = Date.now();
5798
5832
  const response = await this.readMessage(stream);
5799
- console.log("[ByteCave P2P] Step 7: Response received:", response);
5833
+ const readDuration = Date.now() - readStart;
5834
+ console.log("[ByteCave P2P] Response received in", readDuration, "ms:", response);
5835
+ console.log("[ByteCave P2P] Step 7: Closing stream...");
5800
5836
  await stream.close();
5837
+ console.log("[ByteCave P2P] Stream closed successfully");
5801
5838
  if (response?.success) {
5802
5839
  return { success: true, cid };
5803
5840
  } else {
@@ -6730,7 +6767,12 @@ Nonce: ${nonce}`;
6730
6767
  blobCount: announcement.blobCount,
6731
6768
  timestamp: announcement.timestamp,
6732
6769
  multiaddrs: announcement.multiaddrs,
6733
- relayAddrs: announcement.relayAddrs || existing?.relayAddrs
6770
+ relayAddrs: announcement.relayAddrs || existing?.relayAddrs,
6771
+ // Store on-chain registration status
6772
+ registeredOnChain: announcement.registeredOnChain || false,
6773
+ onChainNodeId: announcement.onChainNodeId || existing?.onChainNodeId,
6774
+ // Store relay flag
6775
+ isRelay: announcement.isRelay || false
6734
6776
  };
6735
6777
  this.knownPeers.set(announcement.peerId, peerInfo);
6736
6778
  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-ZFKOXO6W.js";
16
+ } from "./chunk-TT75S7TA.js";
17
17
  import {
18
18
  clearHashdCache,
19
19
  createHashdUrl,
@@ -6028,14 +6028,44 @@ 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: Dialing store protocol...");
6031
+ console.log("[ByteCave P2P] Step 1: Checking existing connections to peer", peerId.slice(0, 12));
6032
+ const existingConns = this.node.getConnections(peerIdObj);
6033
+ console.log("[ByteCave P2P] Existing connections:", existingConns.length);
6034
+ existingConns.forEach((conn, idx) => {
6035
+ console.log(`[ByteCave P2P] Connection ${idx}:`, {
6036
+ remoteAddr: conn.remoteAddr.toString(),
6037
+ status: conn.status,
6038
+ direction: conn.direction,
6039
+ timeline: conn.timeline
6040
+ });
6041
+ });
6042
+ console.log("[ByteCave P2P] Step 2: Dialing store protocol /bytecave/store/1.0.0...");
6043
+ const dialStart = Date.now();
6044
+ try {
6045
+ const stream2 = await this.node.dialProtocol(peerIdObj, "/bytecave/store/1.0.0");
6046
+ const dialDuration = Date.now() - dialStart;
6047
+ console.log("[ByteCave P2P] Step 3: Stream established in", dialDuration, "ms");
6048
+ console.log("[ByteCave P2P] Stream details:", {
6049
+ protocol: stream2.protocol,
6050
+ direction: stream2.direction,
6051
+ timeline: stream2.timeline
6052
+ });
6053
+ } catch (dialError) {
6054
+ const dialDuration = Date.now() - dialStart;
6055
+ console.error("[ByteCave P2P] dialProtocol FAILED after", dialDuration, "ms:", {
6056
+ error: dialError.message,
6057
+ code: dialError.code,
6058
+ name: dialError.name,
6059
+ stack: dialError.stack?.split("\n").slice(0, 3)
6060
+ });
6061
+ throw dialError;
6062
+ }
6032
6063
  const stream = await this.node.dialProtocol(peerIdObj, "/bytecave/store/1.0.0");
6033
- console.log("[ByteCave P2P] Step 2: Stream established");
6034
6064
  const dataCopy = new Uint8Array(ciphertext);
6035
6065
  const hashBuffer = await crypto.subtle.digest("SHA-256", dataCopy);
6036
6066
  const hashArray = Array.from(new Uint8Array(hashBuffer));
6037
6067
  const cid = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
6038
- console.log("[ByteCave P2P] Step 3: CID generated:", cid.slice(0, 16) + "...");
6068
+ console.log("[ByteCave P2P] Step 4: CID generated:", cid.slice(0, 16) + "...");
6039
6069
  const request = {
6040
6070
  cid,
6041
6071
  mimeType,
@@ -6048,11 +6078,18 @@ var P2PProtocolClient = class {
6048
6078
  };
6049
6079
  console.log("[ByteCave P2P] Step 4: Request prepared, size:", JSON.stringify(request).length, "bytes");
6050
6080
  console.log("[ByteCave P2P] Step 5: Writing message to stream...");
6081
+ const writeStart = Date.now();
6051
6082
  await this.writeMessage(stream, request);
6052
- console.log("[ByteCave P2P] Step 6: Message written, waiting for response...");
6083
+ const writeDuration = Date.now() - writeStart;
6084
+ console.log("[ByteCave P2P] Request written in", writeDuration, "ms");
6085
+ console.log("[ByteCave P2P] Step 6: Waiting for response from node...");
6086
+ const readStart = Date.now();
6053
6087
  const response = await this.readMessage(stream);
6054
- console.log("[ByteCave P2P] Step 7: Response received:", response);
6088
+ const readDuration = Date.now() - readStart;
6089
+ console.log("[ByteCave P2P] Response received in", readDuration, "ms:", response);
6090
+ console.log("[ByteCave P2P] Step 7: Closing stream...");
6055
6091
  await stream.close();
6092
+ console.log("[ByteCave P2P] Stream closed successfully");
6056
6093
  if (response?.success) {
6057
6094
  return { success: true, cid };
6058
6095
  } else {
@@ -8,7 +8,7 @@ import {
8
8
  useHashdImage,
9
9
  useHashdMedia,
10
10
  useHashdUrl
11
- } from "../chunk-ZFKOXO6W.js";
11
+ } from "../chunk-TT75S7TA.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.22",
3
+ "version": "1.0.24",
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
@@ -881,7 +881,12 @@ Nonce: ${nonce}`;
881
881
  blobCount: announcement.blobCount,
882
882
  timestamp: announcement.timestamp,
883
883
  multiaddrs: announcement.multiaddrs,
884
- relayAddrs: announcement.relayAddrs || (existing as any)?.relayAddrs
884
+ relayAddrs: announcement.relayAddrs || (existing as any)?.relayAddrs,
885
+ // Store on-chain registration status
886
+ registeredOnChain: announcement.registeredOnChain || false,
887
+ onChainNodeId: announcement.onChainNodeId || (existing as any)?.onChainNodeId,
888
+ // Store relay flag
889
+ isRelay: announcement.isRelay || false
885
890
  };
886
891
 
887
892
  this.knownPeers.set(announcement.peerId, peerInfo);
@@ -124,17 +124,47 @@ 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: Dialing store protocol...');
128
- // dialProtocol will upgrade limited relay connections to full connections automatically
127
+ console.log('[ByteCave P2P] Step 1: Checking existing connections to peer', peerId.slice(0, 12));
128
+ const existingConns = this.node!.getConnections(peerIdObj);
129
+ console.log('[ByteCave P2P] Existing connections:', existingConns.length);
130
+ existingConns.forEach((conn, idx) => {
131
+ console.log(`[ByteCave P2P] Connection ${idx}:`, {
132
+ remoteAddr: conn.remoteAddr.toString(),
133
+ status: conn.status,
134
+ direction: conn.direction,
135
+ timeline: conn.timeline
136
+ });
137
+ });
138
+
139
+ console.log('[ByteCave P2P] Step 2: Dialing store protocol /bytecave/store/1.0.0...');
140
+ const dialStart = Date.now();
141
+ try {
142
+ const stream = await this.node!.dialProtocol(peerIdObj, '/bytecave/store/1.0.0');
143
+ const dialDuration = Date.now() - dialStart;
144
+ console.log('[ByteCave P2P] Step 3: Stream established in', dialDuration, 'ms');
145
+ console.log('[ByteCave P2P] Stream details:', {
146
+ protocol: stream.protocol,
147
+ direction: stream.direction,
148
+ timeline: stream.timeline
149
+ });
150
+ } catch (dialError: any) {
151
+ const dialDuration = Date.now() - dialStart;
152
+ console.error('[ByteCave P2P] dialProtocol FAILED after', dialDuration, 'ms:', {
153
+ error: dialError.message,
154
+ code: dialError.code,
155
+ name: dialError.name,
156
+ stack: dialError.stack?.split('\n').slice(0, 3)
157
+ });
158
+ throw dialError;
159
+ }
129
160
  const stream = await this.node!.dialProtocol(peerIdObj, '/bytecave/store/1.0.0');
130
- console.log('[ByteCave P2P] Step 2: Stream established');
131
161
 
132
162
  // Generate CID using SHA-256 (matches bytecave-core format: 64-char hex)
133
163
  const dataCopy = new Uint8Array(ciphertext);
134
164
  const hashBuffer = await crypto.subtle.digest('SHA-256', dataCopy);
135
165
  const hashArray = Array.from(new Uint8Array(hashBuffer));
136
166
  const cid = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
137
- console.log('[ByteCave P2P] Step 3: CID generated:', cid.slice(0, 16) + '...');
167
+ console.log('[ByteCave P2P] Step 4: CID generated:', cid.slice(0, 16) + '...');
138
168
 
139
169
  const request: StoreRequest = {
140
170
  cid,
@@ -149,12 +179,20 @@ export class P2PProtocolClient {
149
179
  console.log('[ByteCave P2P] Step 4: Request prepared, size:', JSON.stringify(request).length, 'bytes');
150
180
 
151
181
  console.log('[ByteCave P2P] Step 5: Writing message to stream...');
182
+ const writeStart = Date.now();
152
183
  await this.writeMessage(stream, request);
153
- console.log('[ByteCave P2P] Step 6: Message written, waiting for response...');
184
+ const writeDuration = Date.now() - writeStart;
185
+ console.log('[ByteCave P2P] Request written in', writeDuration, 'ms');
186
+
187
+ console.log('[ByteCave P2P] Step 6: Waiting for response from node...');
188
+ const readStart = Date.now();
154
189
  const response = await this.readMessage<StoreResponse>(stream);
155
- console.log('[ByteCave P2P] Step 7: Response received:', response);
190
+ const readDuration = Date.now() - readStart;
191
+ console.log('[ByteCave P2P] Response received in', readDuration, 'ms:', response);
156
192
 
193
+ console.log('[ByteCave P2P] Step 7: Closing stream...');
157
194
  await stream.close();
195
+ console.log('[ByteCave P2P] Stream closed successfully');
158
196
 
159
197
  if (response?.success) {
160
198
  return { success: true, cid };