@gethashd/bytecave-browser 1.0.23 → 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.
- package/dist/{chunk-VICLADDD.js → chunk-TT75S7TA.js} +42 -5
- package/dist/index.cjs +42 -5
- package/dist/index.js +1 -1
- package/dist/react/index.cjs +42 -5
- package/dist/react/index.js +1 -1
- package/package.json +1 -1
- package/src/p2p-protocols.ts +44 -6
|
@@ -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:
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
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:
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
package/dist/index.js
CHANGED
package/dist/react/index.cjs
CHANGED
|
@@ -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:
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
package/dist/react/index.js
CHANGED
package/package.json
CHANGED
package/src/p2p-protocols.ts
CHANGED
|
@@ -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:
|
|
128
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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 };
|