@gethashd/bytecave-browser 1.0.25 → 1.0.27
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/dist/{chunk-MVXA47HN.js → chunk-AETVOZYQ.js} +38 -33
- package/dist/index.cjs +38 -33
- package/dist/index.js +1 -1
- package/dist/react/index.cjs +38 -33
- package/dist/react/index.js +1 -1
- package/package.json +1 -1
- package/src/p2p-protocols.ts +43 -36
|
@@ -5706,51 +5706,56 @@ var P2PProtocolClient = class {
|
|
|
5706
5706
|
console.log(`[ByteCave P2P] Store timeout: ${Math.round(timeoutMs / 1e3)}s for ${fileSizeMB.toFixed(2)}MB`);
|
|
5707
5707
|
const storePromise = (async () => {
|
|
5708
5708
|
console.log("[ByteCave P2P] Step 1: Checking existing connections to peer", peerId.slice(0, 12));
|
|
5709
|
+
console.log("[ByteCave P2P] Full peer ID:", peerId);
|
|
5709
5710
|
const existingConns = this.node.getConnections(peerIdObj);
|
|
5710
5711
|
console.log("[ByteCave P2P] Existing connections:", existingConns.length);
|
|
5711
5712
|
existingConns.forEach((conn, idx) => {
|
|
5712
5713
|
console.log(`[ByteCave P2P] Connection ${idx}:`, {
|
|
5713
5714
|
remoteAddr: conn.remoteAddr.toString(),
|
|
5715
|
+
remotePeer: conn.remotePeer.toString(),
|
|
5714
5716
|
status: conn.status,
|
|
5715
5717
|
direction: conn.direction,
|
|
5718
|
+
streams: conn.streams.length,
|
|
5716
5719
|
timeline: conn.timeline
|
|
5717
5720
|
});
|
|
5718
5721
|
});
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
console.log("[ByteCave P2P] Stream details:", {
|
|
5730
|
-
protocol: stream.protocol,
|
|
5731
|
-
direction: stream.direction,
|
|
5732
|
-
timeline: stream.timeline
|
|
5733
|
-
});
|
|
5734
|
-
break;
|
|
5735
|
-
} catch (dialError) {
|
|
5736
|
-
lastError = dialError;
|
|
5737
|
-
const dialDuration = Date.now() - dialStart;
|
|
5738
|
-
console.warn(`[ByteCave P2P] Dial attempt ${attempt} failed after ${dialDuration}ms:`, dialError.message);
|
|
5739
|
-
if (attempt < 3) {
|
|
5740
|
-
console.log("[ByteCave P2P] Waiting 1s before retry (node may still be registering handlers)...");
|
|
5741
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
5742
|
-
}
|
|
5743
|
-
}
|
|
5722
|
+
const peerStore = this.node.peerStore;
|
|
5723
|
+
try {
|
|
5724
|
+
const peer = await peerStore.get(peerIdObj);
|
|
5725
|
+
console.log("[ByteCave P2P] Peer protocols from peerStore:", peer.protocols);
|
|
5726
|
+
} catch (e) {
|
|
5727
|
+
console.warn("[ByteCave P2P] Could not get peer info from peerStore:", e);
|
|
5728
|
+
}
|
|
5729
|
+
console.log("[ByteCave P2P] Step 2: Opening protocol stream on existing connection...");
|
|
5730
|
+
if (existingConns.length === 0) {
|
|
5731
|
+
throw new Error("No connection to peer - cannot open protocol stream");
|
|
5744
5732
|
}
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5733
|
+
const connection = existingConns[0];
|
|
5734
|
+
console.log("[ByteCave P2P] Using connection:", connection.remoteAddr.toString());
|
|
5735
|
+
const streamStart = Date.now();
|
|
5736
|
+
let stream;
|
|
5737
|
+
try {
|
|
5738
|
+
console.log("[ByteCave P2P] Calling connection.newStream with protocol /bytecave/store/1.0.0...");
|
|
5739
|
+
stream = await connection.newStream("/bytecave/store/1.0.0");
|
|
5740
|
+
const streamDuration = Date.now() - streamStart;
|
|
5741
|
+
console.log("[ByteCave P2P] Step 3: Protocol stream opened in", streamDuration, "ms");
|
|
5742
|
+
console.log("[ByteCave P2P] Stream details:", {
|
|
5743
|
+
protocol: stream.protocol,
|
|
5744
|
+
direction: stream.direction,
|
|
5745
|
+
id: stream.id,
|
|
5746
|
+
timeline: stream.timeline
|
|
5747
|
+
});
|
|
5748
|
+
} catch (streamError) {
|
|
5749
|
+
const streamDuration = Date.now() - streamStart;
|
|
5750
|
+
console.error("[ByteCave P2P] Failed to open protocol stream after", streamDuration, "ms:", {
|
|
5751
|
+
error: streamError.message,
|
|
5752
|
+
code: streamError.code,
|
|
5753
|
+
name: streamError.name,
|
|
5754
|
+
connectionStatus: connection.status,
|
|
5755
|
+
connectionStreams: connection.streams.length,
|
|
5756
|
+
stack: streamError.stack?.split("\n").slice(0, 3)
|
|
5752
5757
|
});
|
|
5753
|
-
throw
|
|
5758
|
+
throw streamError;
|
|
5754
5759
|
}
|
|
5755
5760
|
const dataCopy = new Uint8Array(ciphertext);
|
|
5756
5761
|
const hashBuffer = await crypto.subtle.digest("SHA-256", dataCopy);
|
package/dist/index.cjs
CHANGED
|
@@ -5774,51 +5774,56 @@ var P2PProtocolClient = class {
|
|
|
5774
5774
|
console.log(`[ByteCave P2P] Store timeout: ${Math.round(timeoutMs / 1e3)}s for ${fileSizeMB.toFixed(2)}MB`);
|
|
5775
5775
|
const storePromise = (async () => {
|
|
5776
5776
|
console.log("[ByteCave P2P] Step 1: Checking existing connections to peer", peerId.slice(0, 12));
|
|
5777
|
+
console.log("[ByteCave P2P] Full peer ID:", peerId);
|
|
5777
5778
|
const existingConns = this.node.getConnections(peerIdObj);
|
|
5778
5779
|
console.log("[ByteCave P2P] Existing connections:", existingConns.length);
|
|
5779
5780
|
existingConns.forEach((conn, idx) => {
|
|
5780
5781
|
console.log(`[ByteCave P2P] Connection ${idx}:`, {
|
|
5781
5782
|
remoteAddr: conn.remoteAddr.toString(),
|
|
5783
|
+
remotePeer: conn.remotePeer.toString(),
|
|
5782
5784
|
status: conn.status,
|
|
5783
5785
|
direction: conn.direction,
|
|
5786
|
+
streams: conn.streams.length,
|
|
5784
5787
|
timeline: conn.timeline
|
|
5785
5788
|
});
|
|
5786
5789
|
});
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
console.log("[ByteCave P2P] Stream details:", {
|
|
5798
|
-
protocol: stream.protocol,
|
|
5799
|
-
direction: stream.direction,
|
|
5800
|
-
timeline: stream.timeline
|
|
5801
|
-
});
|
|
5802
|
-
break;
|
|
5803
|
-
} catch (dialError) {
|
|
5804
|
-
lastError = dialError;
|
|
5805
|
-
const dialDuration = Date.now() - dialStart;
|
|
5806
|
-
console.warn(`[ByteCave P2P] Dial attempt ${attempt} failed after ${dialDuration}ms:`, dialError.message);
|
|
5807
|
-
if (attempt < 3) {
|
|
5808
|
-
console.log("[ByteCave P2P] Waiting 1s before retry (node may still be registering handlers)...");
|
|
5809
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
5810
|
-
}
|
|
5811
|
-
}
|
|
5790
|
+
const peerStore = this.node.peerStore;
|
|
5791
|
+
try {
|
|
5792
|
+
const peer = await peerStore.get(peerIdObj);
|
|
5793
|
+
console.log("[ByteCave P2P] Peer protocols from peerStore:", peer.protocols);
|
|
5794
|
+
} catch (e) {
|
|
5795
|
+
console.warn("[ByteCave P2P] Could not get peer info from peerStore:", e);
|
|
5796
|
+
}
|
|
5797
|
+
console.log("[ByteCave P2P] Step 2: Opening protocol stream on existing connection...");
|
|
5798
|
+
if (existingConns.length === 0) {
|
|
5799
|
+
throw new Error("No connection to peer - cannot open protocol stream");
|
|
5812
5800
|
}
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5801
|
+
const connection = existingConns[0];
|
|
5802
|
+
console.log("[ByteCave P2P] Using connection:", connection.remoteAddr.toString());
|
|
5803
|
+
const streamStart = Date.now();
|
|
5804
|
+
let stream;
|
|
5805
|
+
try {
|
|
5806
|
+
console.log("[ByteCave P2P] Calling connection.newStream with protocol /bytecave/store/1.0.0...");
|
|
5807
|
+
stream = await connection.newStream("/bytecave/store/1.0.0");
|
|
5808
|
+
const streamDuration = Date.now() - streamStart;
|
|
5809
|
+
console.log("[ByteCave P2P] Step 3: Protocol stream opened in", streamDuration, "ms");
|
|
5810
|
+
console.log("[ByteCave P2P] Stream details:", {
|
|
5811
|
+
protocol: stream.protocol,
|
|
5812
|
+
direction: stream.direction,
|
|
5813
|
+
id: stream.id,
|
|
5814
|
+
timeline: stream.timeline
|
|
5815
|
+
});
|
|
5816
|
+
} catch (streamError) {
|
|
5817
|
+
const streamDuration = Date.now() - streamStart;
|
|
5818
|
+
console.error("[ByteCave P2P] Failed to open protocol stream after", streamDuration, "ms:", {
|
|
5819
|
+
error: streamError.message,
|
|
5820
|
+
code: streamError.code,
|
|
5821
|
+
name: streamError.name,
|
|
5822
|
+
connectionStatus: connection.status,
|
|
5823
|
+
connectionStreams: connection.streams.length,
|
|
5824
|
+
stack: streamError.stack?.split("\n").slice(0, 3)
|
|
5820
5825
|
});
|
|
5821
|
-
throw
|
|
5826
|
+
throw streamError;
|
|
5822
5827
|
}
|
|
5823
5828
|
const dataCopy = new Uint8Array(ciphertext);
|
|
5824
5829
|
const hashBuffer = await crypto.subtle.digest("SHA-256", dataCopy);
|
package/dist/index.js
CHANGED
package/dist/react/index.cjs
CHANGED
|
@@ -6029,51 +6029,56 @@ var P2PProtocolClient = class {
|
|
|
6029
6029
|
console.log(`[ByteCave P2P] Store timeout: ${Math.round(timeoutMs / 1e3)}s for ${fileSizeMB.toFixed(2)}MB`);
|
|
6030
6030
|
const storePromise = (async () => {
|
|
6031
6031
|
console.log("[ByteCave P2P] Step 1: Checking existing connections to peer", peerId.slice(0, 12));
|
|
6032
|
+
console.log("[ByteCave P2P] Full peer ID:", peerId);
|
|
6032
6033
|
const existingConns = this.node.getConnections(peerIdObj);
|
|
6033
6034
|
console.log("[ByteCave P2P] Existing connections:", existingConns.length);
|
|
6034
6035
|
existingConns.forEach((conn, idx) => {
|
|
6035
6036
|
console.log(`[ByteCave P2P] Connection ${idx}:`, {
|
|
6036
6037
|
remoteAddr: conn.remoteAddr.toString(),
|
|
6038
|
+
remotePeer: conn.remotePeer.toString(),
|
|
6037
6039
|
status: conn.status,
|
|
6038
6040
|
direction: conn.direction,
|
|
6041
|
+
streams: conn.streams.length,
|
|
6039
6042
|
timeline: conn.timeline
|
|
6040
6043
|
});
|
|
6041
6044
|
});
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
console.log(`[ByteCave P2P] Dial attempt ${attempt}/3...`);
|
|
6049
|
-
stream = await this.node.dialProtocol(peerIdObj, "/bytecave/store/1.0.0");
|
|
6050
|
-
const dialDuration = Date.now() - dialStart;
|
|
6051
|
-
console.log("[ByteCave P2P] Step 3: Stream established in", dialDuration, "ms");
|
|
6052
|
-
console.log("[ByteCave P2P] Stream details:", {
|
|
6053
|
-
protocol: stream.protocol,
|
|
6054
|
-
direction: stream.direction,
|
|
6055
|
-
timeline: stream.timeline
|
|
6056
|
-
});
|
|
6057
|
-
break;
|
|
6058
|
-
} catch (dialError) {
|
|
6059
|
-
lastError = dialError;
|
|
6060
|
-
const dialDuration = Date.now() - dialStart;
|
|
6061
|
-
console.warn(`[ByteCave P2P] Dial attempt ${attempt} failed after ${dialDuration}ms:`, dialError.message);
|
|
6062
|
-
if (attempt < 3) {
|
|
6063
|
-
console.log("[ByteCave P2P] Waiting 1s before retry (node may still be registering handlers)...");
|
|
6064
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
6065
|
-
}
|
|
6066
|
-
}
|
|
6045
|
+
const peerStore = this.node.peerStore;
|
|
6046
|
+
try {
|
|
6047
|
+
const peer = await peerStore.get(peerIdObj);
|
|
6048
|
+
console.log("[ByteCave P2P] Peer protocols from peerStore:", peer.protocols);
|
|
6049
|
+
} catch (e) {
|
|
6050
|
+
console.warn("[ByteCave P2P] Could not get peer info from peerStore:", e);
|
|
6067
6051
|
}
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6052
|
+
console.log("[ByteCave P2P] Step 2: Opening protocol stream on existing connection...");
|
|
6053
|
+
if (existingConns.length === 0) {
|
|
6054
|
+
throw new Error("No connection to peer - cannot open protocol stream");
|
|
6055
|
+
}
|
|
6056
|
+
const connection = existingConns[0];
|
|
6057
|
+
console.log("[ByteCave P2P] Using connection:", connection.remoteAddr.toString());
|
|
6058
|
+
const streamStart = Date.now();
|
|
6059
|
+
let stream;
|
|
6060
|
+
try {
|
|
6061
|
+
console.log("[ByteCave P2P] Calling connection.newStream with protocol /bytecave/store/1.0.0...");
|
|
6062
|
+
stream = await connection.newStream("/bytecave/store/1.0.0");
|
|
6063
|
+
const streamDuration = Date.now() - streamStart;
|
|
6064
|
+
console.log("[ByteCave P2P] Step 3: Protocol stream opened in", streamDuration, "ms");
|
|
6065
|
+
console.log("[ByteCave P2P] Stream details:", {
|
|
6066
|
+
protocol: stream.protocol,
|
|
6067
|
+
direction: stream.direction,
|
|
6068
|
+
id: stream.id,
|
|
6069
|
+
timeline: stream.timeline
|
|
6070
|
+
});
|
|
6071
|
+
} catch (streamError) {
|
|
6072
|
+
const streamDuration = Date.now() - streamStart;
|
|
6073
|
+
console.error("[ByteCave P2P] Failed to open protocol stream after", streamDuration, "ms:", {
|
|
6074
|
+
error: streamError.message,
|
|
6075
|
+
code: streamError.code,
|
|
6076
|
+
name: streamError.name,
|
|
6077
|
+
connectionStatus: connection.status,
|
|
6078
|
+
connectionStreams: connection.streams.length,
|
|
6079
|
+
stack: streamError.stack?.split("\n").slice(0, 3)
|
|
6075
6080
|
});
|
|
6076
|
-
throw
|
|
6081
|
+
throw streamError;
|
|
6077
6082
|
}
|
|
6078
6083
|
const dataCopy = new Uint8Array(ciphertext);
|
|
6079
6084
|
const hashBuffer = await crypto.subtle.digest("SHA-256", dataCopy);
|
package/dist/react/index.js
CHANGED
package/package.json
CHANGED
package/src/p2p-protocols.ts
CHANGED
|
@@ -125,57 +125,64 @@ export class P2PProtocolClient {
|
|
|
125
125
|
// Wrap the entire operation in a timeout
|
|
126
126
|
const storePromise = (async () => {
|
|
127
127
|
console.log('[ByteCave P2P] Step 1: Checking existing connections to peer', peerId.slice(0, 12));
|
|
128
|
+
console.log('[ByteCave P2P] Full peer ID:', peerId);
|
|
128
129
|
const existingConns = this.node!.getConnections(peerIdObj);
|
|
129
130
|
console.log('[ByteCave P2P] Existing connections:', existingConns.length);
|
|
130
131
|
existingConns.forEach((conn, idx) => {
|
|
131
132
|
console.log(`[ByteCave P2P] Connection ${idx}:`, {
|
|
132
133
|
remoteAddr: conn.remoteAddr.toString(),
|
|
134
|
+
remotePeer: conn.remotePeer.toString(),
|
|
133
135
|
status: conn.status,
|
|
134
136
|
direction: conn.direction,
|
|
137
|
+
streams: conn.streams.length,
|
|
135
138
|
timeline: conn.timeline
|
|
136
139
|
});
|
|
137
140
|
});
|
|
138
141
|
|
|
139
|
-
//
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
// Check what protocols the peer supports
|
|
143
|
+
const peerStore = this.node!.peerStore;
|
|
144
|
+
try {
|
|
145
|
+
const peer = await peerStore.get(peerIdObj);
|
|
146
|
+
console.log('[ByteCave P2P] Peer protocols from peerStore:', peer.protocols);
|
|
147
|
+
} catch (e) {
|
|
148
|
+
console.warn('[ByteCave P2P] Could not get peer info from peerStore:', e);
|
|
149
|
+
}
|
|
144
150
|
|
|
145
|
-
//
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const dialDuration = Date.now() - dialStart;
|
|
151
|
-
console.log('[ByteCave P2P] Step 3: Stream established in', dialDuration, 'ms');
|
|
152
|
-
console.log('[ByteCave P2P] Stream details:', {
|
|
153
|
-
protocol: stream.protocol,
|
|
154
|
-
direction: stream.direction,
|
|
155
|
-
timeline: stream.timeline
|
|
156
|
-
});
|
|
157
|
-
break; // Success!
|
|
158
|
-
} catch (dialError: any) {
|
|
159
|
-
lastError = dialError;
|
|
160
|
-
const dialDuration = Date.now() - dialStart;
|
|
161
|
-
console.warn(`[ByteCave P2P] Dial attempt ${attempt} failed after ${dialDuration}ms:`, dialError.message);
|
|
162
|
-
|
|
163
|
-
if (attempt < 3) {
|
|
164
|
-
console.log('[ByteCave P2P] Waiting 1s before retry (node may still be registering handlers)...');
|
|
165
|
-
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
166
|
-
}
|
|
167
|
-
}
|
|
151
|
+
// Step 2: Open protocol stream on existing connection (relay circuits require explicit stream creation)
|
|
152
|
+
console.log('[ByteCave P2P] Step 2: Opening protocol stream on existing connection...');
|
|
153
|
+
|
|
154
|
+
if (existingConns.length === 0) {
|
|
155
|
+
throw new Error('No connection to peer - cannot open protocol stream');
|
|
168
156
|
}
|
|
169
157
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
158
|
+
const connection = existingConns[0]; // Use first available connection
|
|
159
|
+
console.log('[ByteCave P2P] Using connection:', connection.remoteAddr.toString());
|
|
160
|
+
|
|
161
|
+
const streamStart = Date.now();
|
|
162
|
+
let stream;
|
|
163
|
+
try {
|
|
164
|
+
// Open a new stream on the existing connection with the protocol
|
|
165
|
+
console.log('[ByteCave P2P] Calling connection.newStream with protocol /bytecave/store/1.0.0...');
|
|
166
|
+
stream = await connection.newStream('/bytecave/store/1.0.0');
|
|
167
|
+
const streamDuration = Date.now() - streamStart;
|
|
168
|
+
console.log('[ByteCave P2P] Step 3: Protocol stream opened in', streamDuration, 'ms');
|
|
169
|
+
console.log('[ByteCave P2P] Stream details:', {
|
|
170
|
+
protocol: stream.protocol,
|
|
171
|
+
direction: stream.direction,
|
|
172
|
+
id: stream.id,
|
|
173
|
+
timeline: stream.timeline
|
|
174
|
+
});
|
|
175
|
+
} catch (streamError: any) {
|
|
176
|
+
const streamDuration = Date.now() - streamStart;
|
|
177
|
+
console.error('[ByteCave P2P] Failed to open protocol stream after', streamDuration, 'ms:', {
|
|
178
|
+
error: streamError.message,
|
|
179
|
+
code: streamError.code,
|
|
180
|
+
name: streamError.name,
|
|
181
|
+
connectionStatus: connection.status,
|
|
182
|
+
connectionStreams: connection.streams.length,
|
|
183
|
+
stack: streamError.stack?.split('\n').slice(0, 3)
|
|
177
184
|
});
|
|
178
|
-
throw
|
|
185
|
+
throw streamError;
|
|
179
186
|
}
|
|
180
187
|
|
|
181
188
|
// Generate CID using SHA-256 (matches bytecave-core format: 64-char hex)
|