@gethashd/bytecave-browser 1.0.24 → 1.0.25
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-TT75S7TA.js → chunk-MVXA47HN.js} +36 -22
- package/dist/index.cjs +36 -22
- package/dist/index.js +1 -1
- package/dist/react/index.cjs +36 -22
- package/dist/react/index.js +1 -1
- package/package.json +1 -1
- package/src/p2p-protocols.ts +41 -22
|
@@ -5718,31 +5718,45 @@ var P2PProtocolClient = class {
|
|
|
5718
5718
|
});
|
|
5719
5719
|
console.log("[ByteCave P2P] Step 2: Dialing store protocol /bytecave/store/1.0.0...");
|
|
5720
5720
|
const dialStart = Date.now();
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5721
|
+
let stream;
|
|
5722
|
+
let lastError;
|
|
5723
|
+
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
5724
|
+
try {
|
|
5725
|
+
console.log(`[ByteCave P2P] Dial attempt ${attempt}/3...`);
|
|
5726
|
+
stream = await this.node.dialProtocol(peerIdObj, "/bytecave/store/1.0.0");
|
|
5727
|
+
const dialDuration = Date.now() - dialStart;
|
|
5728
|
+
console.log("[ByteCave P2P] Step 3: Stream established in", dialDuration, "ms");
|
|
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
|
+
}
|
|
5744
|
+
}
|
|
5745
|
+
if (!stream) {
|
|
5731
5746
|
const dialDuration = Date.now() - dialStart;
|
|
5732
|
-
console.error("[ByteCave P2P]
|
|
5733
|
-
error:
|
|
5734
|
-
code:
|
|
5735
|
-
name:
|
|
5736
|
-
stack:
|
|
5747
|
+
console.error("[ByteCave P2P] All dial attempts FAILED after", dialDuration, "ms:", {
|
|
5748
|
+
error: lastError.message,
|
|
5749
|
+
code: lastError.code,
|
|
5750
|
+
name: lastError.name,
|
|
5751
|
+
stack: lastError.stack?.split("\n").slice(0, 3)
|
|
5737
5752
|
});
|
|
5738
|
-
throw
|
|
5753
|
+
throw lastError;
|
|
5739
5754
|
}
|
|
5740
|
-
const stream = await this.node.dialProtocol(peerIdObj, "/bytecave/store/1.0.0");
|
|
5741
5755
|
const dataCopy = new Uint8Array(ciphertext);
|
|
5742
5756
|
const hashBuffer = await crypto.subtle.digest("SHA-256", dataCopy);
|
|
5743
5757
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
5744
5758
|
const cid = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
5745
|
-
console.log("[ByteCave P2P] Step
|
|
5759
|
+
console.log("[ByteCave P2P] Step 5: CID generated:", cid.slice(0, 16) + "...");
|
|
5746
5760
|
const request = {
|
|
5747
5761
|
cid,
|
|
5748
5762
|
mimeType,
|
|
@@ -5753,18 +5767,18 @@ var P2PProtocolClient = class {
|
|
|
5753
5767
|
timestamp: authorization?.timestamp || Date.now(),
|
|
5754
5768
|
authorization
|
|
5755
5769
|
};
|
|
5756
|
-
console.log("[ByteCave P2P] Step
|
|
5757
|
-
console.log("[ByteCave P2P] Step
|
|
5770
|
+
console.log("[ByteCave P2P] Step 5: Request prepared, size:", JSON.stringify(request).length, "bytes");
|
|
5771
|
+
console.log("[ByteCave P2P] Step 6: Writing message to stream...");
|
|
5758
5772
|
const writeStart = Date.now();
|
|
5759
5773
|
await this.writeMessage(stream, request);
|
|
5760
5774
|
const writeDuration = Date.now() - writeStart;
|
|
5761
5775
|
console.log("[ByteCave P2P] Request written in", writeDuration, "ms");
|
|
5762
|
-
console.log("[ByteCave P2P] Step
|
|
5776
|
+
console.log("[ByteCave P2P] Step 7: Waiting for response from node...");
|
|
5763
5777
|
const readStart = Date.now();
|
|
5764
5778
|
const response = await this.readMessage(stream);
|
|
5765
5779
|
const readDuration = Date.now() - readStart;
|
|
5766
5780
|
console.log("[ByteCave P2P] Response received in", readDuration, "ms:", response);
|
|
5767
|
-
console.log("[ByteCave P2P] Step
|
|
5781
|
+
console.log("[ByteCave P2P] Step 8: Closing stream...");
|
|
5768
5782
|
await stream.close();
|
|
5769
5783
|
console.log("[ByteCave P2P] Stream closed successfully");
|
|
5770
5784
|
if (response?.success) {
|
package/dist/index.cjs
CHANGED
|
@@ -5786,31 +5786,45 @@ var P2PProtocolClient = class {
|
|
|
5786
5786
|
});
|
|
5787
5787
|
console.log("[ByteCave P2P] Step 2: Dialing store protocol /bytecave/store/1.0.0...");
|
|
5788
5788
|
const dialStart = Date.now();
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5789
|
+
let stream;
|
|
5790
|
+
let lastError;
|
|
5791
|
+
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
5792
|
+
try {
|
|
5793
|
+
console.log(`[ByteCave P2P] Dial attempt ${attempt}/3...`);
|
|
5794
|
+
stream = await this.node.dialProtocol(peerIdObj, "/bytecave/store/1.0.0");
|
|
5795
|
+
const dialDuration = Date.now() - dialStart;
|
|
5796
|
+
console.log("[ByteCave P2P] Step 3: Stream established in", dialDuration, "ms");
|
|
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
|
+
}
|
|
5812
|
+
}
|
|
5813
|
+
if (!stream) {
|
|
5799
5814
|
const dialDuration = Date.now() - dialStart;
|
|
5800
|
-
console.error("[ByteCave P2P]
|
|
5801
|
-
error:
|
|
5802
|
-
code:
|
|
5803
|
-
name:
|
|
5804
|
-
stack:
|
|
5815
|
+
console.error("[ByteCave P2P] All dial attempts FAILED after", dialDuration, "ms:", {
|
|
5816
|
+
error: lastError.message,
|
|
5817
|
+
code: lastError.code,
|
|
5818
|
+
name: lastError.name,
|
|
5819
|
+
stack: lastError.stack?.split("\n").slice(0, 3)
|
|
5805
5820
|
});
|
|
5806
|
-
throw
|
|
5821
|
+
throw lastError;
|
|
5807
5822
|
}
|
|
5808
|
-
const stream = await this.node.dialProtocol(peerIdObj, "/bytecave/store/1.0.0");
|
|
5809
5823
|
const dataCopy = new Uint8Array(ciphertext);
|
|
5810
5824
|
const hashBuffer = await crypto.subtle.digest("SHA-256", dataCopy);
|
|
5811
5825
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
5812
5826
|
const cid = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
5813
|
-
console.log("[ByteCave P2P] Step
|
|
5827
|
+
console.log("[ByteCave P2P] Step 5: CID generated:", cid.slice(0, 16) + "...");
|
|
5814
5828
|
const request = {
|
|
5815
5829
|
cid,
|
|
5816
5830
|
mimeType,
|
|
@@ -5821,18 +5835,18 @@ var P2PProtocolClient = class {
|
|
|
5821
5835
|
timestamp: authorization?.timestamp || Date.now(),
|
|
5822
5836
|
authorization
|
|
5823
5837
|
};
|
|
5824
|
-
console.log("[ByteCave P2P] Step
|
|
5825
|
-
console.log("[ByteCave P2P] Step
|
|
5838
|
+
console.log("[ByteCave P2P] Step 5: Request prepared, size:", JSON.stringify(request).length, "bytes");
|
|
5839
|
+
console.log("[ByteCave P2P] Step 6: Writing message to stream...");
|
|
5826
5840
|
const writeStart = Date.now();
|
|
5827
5841
|
await this.writeMessage(stream, request);
|
|
5828
5842
|
const writeDuration = Date.now() - writeStart;
|
|
5829
5843
|
console.log("[ByteCave P2P] Request written in", writeDuration, "ms");
|
|
5830
|
-
console.log("[ByteCave P2P] Step
|
|
5844
|
+
console.log("[ByteCave P2P] Step 7: Waiting for response from node...");
|
|
5831
5845
|
const readStart = Date.now();
|
|
5832
5846
|
const response = await this.readMessage(stream);
|
|
5833
5847
|
const readDuration = Date.now() - readStart;
|
|
5834
5848
|
console.log("[ByteCave P2P] Response received in", readDuration, "ms:", response);
|
|
5835
|
-
console.log("[ByteCave P2P] Step
|
|
5849
|
+
console.log("[ByteCave P2P] Step 8: Closing stream...");
|
|
5836
5850
|
await stream.close();
|
|
5837
5851
|
console.log("[ByteCave P2P] Stream closed successfully");
|
|
5838
5852
|
if (response?.success) {
|
package/dist/index.js
CHANGED
package/dist/react/index.cjs
CHANGED
|
@@ -6041,31 +6041,45 @@ var P2PProtocolClient = class {
|
|
|
6041
6041
|
});
|
|
6042
6042
|
console.log("[ByteCave P2P] Step 2: Dialing store protocol /bytecave/store/1.0.0...");
|
|
6043
6043
|
const dialStart = Date.now();
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6044
|
+
let stream;
|
|
6045
|
+
let lastError;
|
|
6046
|
+
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
6047
|
+
try {
|
|
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
|
+
}
|
|
6067
|
+
}
|
|
6068
|
+
if (!stream) {
|
|
6054
6069
|
const dialDuration = Date.now() - dialStart;
|
|
6055
|
-
console.error("[ByteCave P2P]
|
|
6056
|
-
error:
|
|
6057
|
-
code:
|
|
6058
|
-
name:
|
|
6059
|
-
stack:
|
|
6070
|
+
console.error("[ByteCave P2P] All dial attempts FAILED after", dialDuration, "ms:", {
|
|
6071
|
+
error: lastError.message,
|
|
6072
|
+
code: lastError.code,
|
|
6073
|
+
name: lastError.name,
|
|
6074
|
+
stack: lastError.stack?.split("\n").slice(0, 3)
|
|
6060
6075
|
});
|
|
6061
|
-
throw
|
|
6076
|
+
throw lastError;
|
|
6062
6077
|
}
|
|
6063
|
-
const stream = await this.node.dialProtocol(peerIdObj, "/bytecave/store/1.0.0");
|
|
6064
6078
|
const dataCopy = new Uint8Array(ciphertext);
|
|
6065
6079
|
const hashBuffer = await crypto.subtle.digest("SHA-256", dataCopy);
|
|
6066
6080
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
6067
6081
|
const cid = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
6068
|
-
console.log("[ByteCave P2P] Step
|
|
6082
|
+
console.log("[ByteCave P2P] Step 5: CID generated:", cid.slice(0, 16) + "...");
|
|
6069
6083
|
const request = {
|
|
6070
6084
|
cid,
|
|
6071
6085
|
mimeType,
|
|
@@ -6076,18 +6090,18 @@ var P2PProtocolClient = class {
|
|
|
6076
6090
|
timestamp: authorization?.timestamp || Date.now(),
|
|
6077
6091
|
authorization
|
|
6078
6092
|
};
|
|
6079
|
-
console.log("[ByteCave P2P] Step
|
|
6080
|
-
console.log("[ByteCave P2P] Step
|
|
6093
|
+
console.log("[ByteCave P2P] Step 5: Request prepared, size:", JSON.stringify(request).length, "bytes");
|
|
6094
|
+
console.log("[ByteCave P2P] Step 6: Writing message to stream...");
|
|
6081
6095
|
const writeStart = Date.now();
|
|
6082
6096
|
await this.writeMessage(stream, request);
|
|
6083
6097
|
const writeDuration = Date.now() - writeStart;
|
|
6084
6098
|
console.log("[ByteCave P2P] Request written in", writeDuration, "ms");
|
|
6085
|
-
console.log("[ByteCave P2P] Step
|
|
6099
|
+
console.log("[ByteCave P2P] Step 7: Waiting for response from node...");
|
|
6086
6100
|
const readStart = Date.now();
|
|
6087
6101
|
const response = await this.readMessage(stream);
|
|
6088
6102
|
const readDuration = Date.now() - readStart;
|
|
6089
6103
|
console.log("[ByteCave P2P] Response received in", readDuration, "ms:", response);
|
|
6090
|
-
console.log("[ByteCave P2P] Step
|
|
6104
|
+
console.log("[ByteCave P2P] Step 8: Closing stream...");
|
|
6091
6105
|
await stream.close();
|
|
6092
6106
|
console.log("[ByteCave P2P] Stream closed successfully");
|
|
6093
6107
|
if (response?.success) {
|
package/dist/react/index.js
CHANGED
package/package.json
CHANGED
package/src/p2p-protocols.ts
CHANGED
|
@@ -136,35 +136,54 @@ export class P2PProtocolClient {
|
|
|
136
136
|
});
|
|
137
137
|
});
|
|
138
138
|
|
|
139
|
+
// Step 2: Dial store protocol with retry (node may need time to register handlers after startup)
|
|
139
140
|
console.log('[ByteCave P2P] Step 2: Dialing store protocol /bytecave/store/1.0.0...');
|
|
140
141
|
const dialStart = Date.now();
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
142
|
+
let stream;
|
|
143
|
+
let lastError;
|
|
144
|
+
|
|
145
|
+
// Retry up to 3 times with 1s delay - gives node time to register protocol handlers
|
|
146
|
+
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
147
|
+
try {
|
|
148
|
+
console.log(`[ByteCave P2P] Dial attempt ${attempt}/3...`);
|
|
149
|
+
stream = await this.node!.dialProtocol(peerIdObj, '/bytecave/store/1.0.0');
|
|
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
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (!stream) {
|
|
151
171
|
const dialDuration = Date.now() - dialStart;
|
|
152
|
-
console.error('[ByteCave P2P]
|
|
153
|
-
error:
|
|
154
|
-
code:
|
|
155
|
-
name:
|
|
156
|
-
stack:
|
|
172
|
+
console.error('[ByteCave P2P] All dial attempts FAILED after', dialDuration, 'ms:', {
|
|
173
|
+
error: lastError.message,
|
|
174
|
+
code: lastError.code,
|
|
175
|
+
name: lastError.name,
|
|
176
|
+
stack: lastError.stack?.split('\n').slice(0, 3)
|
|
157
177
|
});
|
|
158
|
-
throw
|
|
178
|
+
throw lastError;
|
|
159
179
|
}
|
|
160
|
-
const stream = await this.node!.dialProtocol(peerIdObj, '/bytecave/store/1.0.0');
|
|
161
180
|
|
|
162
181
|
// Generate CID using SHA-256 (matches bytecave-core format: 64-char hex)
|
|
163
182
|
const dataCopy = new Uint8Array(ciphertext);
|
|
164
183
|
const hashBuffer = await crypto.subtle.digest('SHA-256', dataCopy);
|
|
165
184
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
166
185
|
const cid = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
|
167
|
-
console.log('[ByteCave P2P] Step
|
|
186
|
+
console.log('[ByteCave P2P] Step 5: CID generated:', cid.slice(0, 16) + '...');
|
|
168
187
|
|
|
169
188
|
const request: StoreRequest = {
|
|
170
189
|
cid,
|
|
@@ -176,21 +195,21 @@ export class P2PProtocolClient {
|
|
|
176
195
|
timestamp: authorization?.timestamp || Date.now(),
|
|
177
196
|
authorization
|
|
178
197
|
};
|
|
179
|
-
console.log('[ByteCave P2P] Step
|
|
198
|
+
console.log('[ByteCave P2P] Step 5: Request prepared, size:', JSON.stringify(request).length, 'bytes');
|
|
180
199
|
|
|
181
|
-
console.log('[ByteCave P2P] Step
|
|
200
|
+
console.log('[ByteCave P2P] Step 6: Writing message to stream...');
|
|
182
201
|
const writeStart = Date.now();
|
|
183
202
|
await this.writeMessage(stream, request);
|
|
184
203
|
const writeDuration = Date.now() - writeStart;
|
|
185
204
|
console.log('[ByteCave P2P] Request written in', writeDuration, 'ms');
|
|
186
205
|
|
|
187
|
-
console.log('[ByteCave P2P] Step
|
|
206
|
+
console.log('[ByteCave P2P] Step 7: Waiting for response from node...');
|
|
188
207
|
const readStart = Date.now();
|
|
189
208
|
const response = await this.readMessage<StoreResponse>(stream);
|
|
190
209
|
const readDuration = Date.now() - readStart;
|
|
191
210
|
console.log('[ByteCave P2P] Response received in', readDuration, 'ms:', response);
|
|
192
211
|
|
|
193
|
-
console.log('[ByteCave P2P] Step
|
|
212
|
+
console.log('[ByteCave P2P] Step 8: Closing stream...');
|
|
194
213
|
await stream.close();
|
|
195
214
|
console.log('[ByteCave P2P] Stream closed successfully');
|
|
196
215
|
|