@gethashd/bytecave-browser 1.0.26 → 1.0.28
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-XMU2N2NN.js → chunk-OV4Q3HIT.js} +48 -32
- package/dist/index.cjs +48 -32
- package/dist/index.js +1 -1
- package/dist/react/index.cjs +48 -32
- package/dist/react/index.js +1 -1
- package/package.json +1 -1
- package/src/p2p-protocols.ts +57 -35
|
@@ -5726,41 +5726,57 @@ var P2PProtocolClient = class {
|
|
|
5726
5726
|
} catch (e) {
|
|
5727
5727
|
console.warn("[ByteCave P2P] Could not get peer info from peerStore:", e);
|
|
5728
5728
|
}
|
|
5729
|
-
console.log("[ByteCave P2P] Step 2:
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
} catch (dialError) {
|
|
5746
|
-
lastError = dialError;
|
|
5747
|
-
const dialDuration = Date.now() - dialStart;
|
|
5748
|
-
console.warn(`[ByteCave P2P] Dial attempt ${attempt} failed after ${dialDuration}ms:`, dialError.message);
|
|
5749
|
-
if (attempt < 3) {
|
|
5750
|
-
console.log("[ByteCave P2P] Waiting 1s before retry (node may still be registering handlers)...");
|
|
5751
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
5752
|
-
}
|
|
5729
|
+
console.log("[ByteCave P2P] Step 2: Checking if connection upgrade needed...");
|
|
5730
|
+
if (existingConns.length === 0) {
|
|
5731
|
+
throw new Error("No connection to peer - cannot open protocol stream");
|
|
5732
|
+
}
|
|
5733
|
+
let connection = existingConns[0];
|
|
5734
|
+
const isRelayCircuit = connection.remoteAddr.toString().includes("/p2p-circuit");
|
|
5735
|
+
console.log("[ByteCave P2P] Connection type:", isRelayCircuit ? "relay circuit (limited)" : "direct");
|
|
5736
|
+
console.log("[ByteCave P2P] Connection address:", connection.remoteAddr.toString());
|
|
5737
|
+
if (isRelayCircuit) {
|
|
5738
|
+
console.log("[ByteCave P2P] Waiting for DCUtR to upgrade relay circuit to direct WebRTC...");
|
|
5739
|
+
const upgradeStart = Date.now();
|
|
5740
|
+
const hasDirectConnection = await this.waitForDirectConnection(peerId, 5e3);
|
|
5741
|
+
const upgradeDuration = Date.now() - upgradeStart;
|
|
5742
|
+
if (!hasDirectConnection) {
|
|
5743
|
+
console.error("[ByteCave P2P] DCUtR upgrade failed after", upgradeDuration, "ms");
|
|
5744
|
+
throw new Error("Cannot use storage protocol - relay circuit upgrade to WebRTC failed");
|
|
5753
5745
|
}
|
|
5746
|
+
console.log("[ByteCave P2P] DCUtR upgrade successful after", upgradeDuration, "ms");
|
|
5747
|
+
const directConns = this.node.getConnections(peerIdObj);
|
|
5748
|
+
const directConn = directConns.find((conn) => !conn.remoteAddr.toString().includes("/p2p-circuit"));
|
|
5749
|
+
if (!directConn) {
|
|
5750
|
+
throw new Error("DCUtR reported success but no direct connection found");
|
|
5751
|
+
}
|
|
5752
|
+
connection = directConn;
|
|
5753
|
+
console.log("[ByteCave P2P] Using direct connection:", connection.remoteAddr.toString());
|
|
5754
5754
|
}
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5755
|
+
console.log("[ByteCave P2P] Step 3: Opening protocol stream...");
|
|
5756
|
+
const streamStart = Date.now();
|
|
5757
|
+
let stream;
|
|
5758
|
+
try {
|
|
5759
|
+
console.log("[ByteCave P2P] Calling connection.newStream with protocol /bytecave/store/1.0.0...");
|
|
5760
|
+
stream = await connection.newStream("/bytecave/store/1.0.0");
|
|
5761
|
+
const streamDuration = Date.now() - streamStart;
|
|
5762
|
+
console.log("[ByteCave P2P] Step 4: Protocol stream opened in", streamDuration, "ms");
|
|
5763
|
+
console.log("[ByteCave P2P] Stream details:", {
|
|
5764
|
+
protocol: stream.protocol,
|
|
5765
|
+
direction: stream.direction,
|
|
5766
|
+
id: stream.id,
|
|
5767
|
+
timeline: stream.timeline
|
|
5768
|
+
});
|
|
5769
|
+
} catch (streamError) {
|
|
5770
|
+
const streamDuration = Date.now() - streamStart;
|
|
5771
|
+
console.error("[ByteCave P2P] Failed to open protocol stream after", streamDuration, "ms:", {
|
|
5772
|
+
error: streamError.message,
|
|
5773
|
+
code: streamError.code,
|
|
5774
|
+
name: streamError.name,
|
|
5775
|
+
connectionStatus: connection.status,
|
|
5776
|
+
connectionStreams: connection.streams.length,
|
|
5777
|
+
stack: streamError.stack?.split("\n").slice(0, 3)
|
|
5762
5778
|
});
|
|
5763
|
-
throw
|
|
5779
|
+
throw streamError;
|
|
5764
5780
|
}
|
|
5765
5781
|
const dataCopy = new Uint8Array(ciphertext);
|
|
5766
5782
|
const hashBuffer = await crypto.subtle.digest("SHA-256", dataCopy);
|
package/dist/index.cjs
CHANGED
|
@@ -5794,41 +5794,57 @@ var P2PProtocolClient = class {
|
|
|
5794
5794
|
} catch (e) {
|
|
5795
5795
|
console.warn("[ByteCave P2P] Could not get peer info from peerStore:", e);
|
|
5796
5796
|
}
|
|
5797
|
-
console.log("[ByteCave P2P] Step 2:
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
} catch (dialError) {
|
|
5814
|
-
lastError = dialError;
|
|
5815
|
-
const dialDuration = Date.now() - dialStart;
|
|
5816
|
-
console.warn(`[ByteCave P2P] Dial attempt ${attempt} failed after ${dialDuration}ms:`, dialError.message);
|
|
5817
|
-
if (attempt < 3) {
|
|
5818
|
-
console.log("[ByteCave P2P] Waiting 1s before retry (node may still be registering handlers)...");
|
|
5819
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
5820
|
-
}
|
|
5797
|
+
console.log("[ByteCave P2P] Step 2: Checking if connection upgrade needed...");
|
|
5798
|
+
if (existingConns.length === 0) {
|
|
5799
|
+
throw new Error("No connection to peer - cannot open protocol stream");
|
|
5800
|
+
}
|
|
5801
|
+
let connection = existingConns[0];
|
|
5802
|
+
const isRelayCircuit = connection.remoteAddr.toString().includes("/p2p-circuit");
|
|
5803
|
+
console.log("[ByteCave P2P] Connection type:", isRelayCircuit ? "relay circuit (limited)" : "direct");
|
|
5804
|
+
console.log("[ByteCave P2P] Connection address:", connection.remoteAddr.toString());
|
|
5805
|
+
if (isRelayCircuit) {
|
|
5806
|
+
console.log("[ByteCave P2P] Waiting for DCUtR to upgrade relay circuit to direct WebRTC...");
|
|
5807
|
+
const upgradeStart = Date.now();
|
|
5808
|
+
const hasDirectConnection = await this.waitForDirectConnection(peerId, 5e3);
|
|
5809
|
+
const upgradeDuration = Date.now() - upgradeStart;
|
|
5810
|
+
if (!hasDirectConnection) {
|
|
5811
|
+
console.error("[ByteCave P2P] DCUtR upgrade failed after", upgradeDuration, "ms");
|
|
5812
|
+
throw new Error("Cannot use storage protocol - relay circuit upgrade to WebRTC failed");
|
|
5821
5813
|
}
|
|
5814
|
+
console.log("[ByteCave P2P] DCUtR upgrade successful after", upgradeDuration, "ms");
|
|
5815
|
+
const directConns = this.node.getConnections(peerIdObj);
|
|
5816
|
+
const directConn = directConns.find((conn) => !conn.remoteAddr.toString().includes("/p2p-circuit"));
|
|
5817
|
+
if (!directConn) {
|
|
5818
|
+
throw new Error("DCUtR reported success but no direct connection found");
|
|
5819
|
+
}
|
|
5820
|
+
connection = directConn;
|
|
5821
|
+
console.log("[ByteCave P2P] Using direct connection:", connection.remoteAddr.toString());
|
|
5822
5822
|
}
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5823
|
+
console.log("[ByteCave P2P] Step 3: Opening protocol stream...");
|
|
5824
|
+
const streamStart = Date.now();
|
|
5825
|
+
let stream;
|
|
5826
|
+
try {
|
|
5827
|
+
console.log("[ByteCave P2P] Calling connection.newStream with protocol /bytecave/store/1.0.0...");
|
|
5828
|
+
stream = await connection.newStream("/bytecave/store/1.0.0");
|
|
5829
|
+
const streamDuration = Date.now() - streamStart;
|
|
5830
|
+
console.log("[ByteCave P2P] Step 4: Protocol stream opened in", streamDuration, "ms");
|
|
5831
|
+
console.log("[ByteCave P2P] Stream details:", {
|
|
5832
|
+
protocol: stream.protocol,
|
|
5833
|
+
direction: stream.direction,
|
|
5834
|
+
id: stream.id,
|
|
5835
|
+
timeline: stream.timeline
|
|
5836
|
+
});
|
|
5837
|
+
} catch (streamError) {
|
|
5838
|
+
const streamDuration = Date.now() - streamStart;
|
|
5839
|
+
console.error("[ByteCave P2P] Failed to open protocol stream after", streamDuration, "ms:", {
|
|
5840
|
+
error: streamError.message,
|
|
5841
|
+
code: streamError.code,
|
|
5842
|
+
name: streamError.name,
|
|
5843
|
+
connectionStatus: connection.status,
|
|
5844
|
+
connectionStreams: connection.streams.length,
|
|
5845
|
+
stack: streamError.stack?.split("\n").slice(0, 3)
|
|
5830
5846
|
});
|
|
5831
|
-
throw
|
|
5847
|
+
throw streamError;
|
|
5832
5848
|
}
|
|
5833
5849
|
const dataCopy = new Uint8Array(ciphertext);
|
|
5834
5850
|
const hashBuffer = await crypto.subtle.digest("SHA-256", dataCopy);
|
package/dist/index.js
CHANGED
package/dist/react/index.cjs
CHANGED
|
@@ -6049,41 +6049,57 @@ var P2PProtocolClient = class {
|
|
|
6049
6049
|
} catch (e) {
|
|
6050
6050
|
console.warn("[ByteCave P2P] Could not get peer info from peerStore:", e);
|
|
6051
6051
|
}
|
|
6052
|
-
console.log("[ByteCave P2P] Step 2:
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
} catch (dialError) {
|
|
6069
|
-
lastError = dialError;
|
|
6070
|
-
const dialDuration = Date.now() - dialStart;
|
|
6071
|
-
console.warn(`[ByteCave P2P] Dial attempt ${attempt} failed after ${dialDuration}ms:`, dialError.message);
|
|
6072
|
-
if (attempt < 3) {
|
|
6073
|
-
console.log("[ByteCave P2P] Waiting 1s before retry (node may still be registering handlers)...");
|
|
6074
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
6075
|
-
}
|
|
6052
|
+
console.log("[ByteCave P2P] Step 2: Checking if connection upgrade needed...");
|
|
6053
|
+
if (existingConns.length === 0) {
|
|
6054
|
+
throw new Error("No connection to peer - cannot open protocol stream");
|
|
6055
|
+
}
|
|
6056
|
+
let connection = existingConns[0];
|
|
6057
|
+
const isRelayCircuit = connection.remoteAddr.toString().includes("/p2p-circuit");
|
|
6058
|
+
console.log("[ByteCave P2P] Connection type:", isRelayCircuit ? "relay circuit (limited)" : "direct");
|
|
6059
|
+
console.log("[ByteCave P2P] Connection address:", connection.remoteAddr.toString());
|
|
6060
|
+
if (isRelayCircuit) {
|
|
6061
|
+
console.log("[ByteCave P2P] Waiting for DCUtR to upgrade relay circuit to direct WebRTC...");
|
|
6062
|
+
const upgradeStart = Date.now();
|
|
6063
|
+
const hasDirectConnection = await this.waitForDirectConnection(peerId, 5e3);
|
|
6064
|
+
const upgradeDuration = Date.now() - upgradeStart;
|
|
6065
|
+
if (!hasDirectConnection) {
|
|
6066
|
+
console.error("[ByteCave P2P] DCUtR upgrade failed after", upgradeDuration, "ms");
|
|
6067
|
+
throw new Error("Cannot use storage protocol - relay circuit upgrade to WebRTC failed");
|
|
6076
6068
|
}
|
|
6069
|
+
console.log("[ByteCave P2P] DCUtR upgrade successful after", upgradeDuration, "ms");
|
|
6070
|
+
const directConns = this.node.getConnections(peerIdObj);
|
|
6071
|
+
const directConn = directConns.find((conn) => !conn.remoteAddr.toString().includes("/p2p-circuit"));
|
|
6072
|
+
if (!directConn) {
|
|
6073
|
+
throw new Error("DCUtR reported success but no direct connection found");
|
|
6074
|
+
}
|
|
6075
|
+
connection = directConn;
|
|
6076
|
+
console.log("[ByteCave P2P] Using direct connection:", connection.remoteAddr.toString());
|
|
6077
6077
|
}
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6078
|
+
console.log("[ByteCave P2P] Step 3: Opening protocol stream...");
|
|
6079
|
+
const streamStart = Date.now();
|
|
6080
|
+
let stream;
|
|
6081
|
+
try {
|
|
6082
|
+
console.log("[ByteCave P2P] Calling connection.newStream with protocol /bytecave/store/1.0.0...");
|
|
6083
|
+
stream = await connection.newStream("/bytecave/store/1.0.0");
|
|
6084
|
+
const streamDuration = Date.now() - streamStart;
|
|
6085
|
+
console.log("[ByteCave P2P] Step 4: Protocol stream opened in", streamDuration, "ms");
|
|
6086
|
+
console.log("[ByteCave P2P] Stream details:", {
|
|
6087
|
+
protocol: stream.protocol,
|
|
6088
|
+
direction: stream.direction,
|
|
6089
|
+
id: stream.id,
|
|
6090
|
+
timeline: stream.timeline
|
|
6091
|
+
});
|
|
6092
|
+
} catch (streamError) {
|
|
6093
|
+
const streamDuration = Date.now() - streamStart;
|
|
6094
|
+
console.error("[ByteCave P2P] Failed to open protocol stream after", streamDuration, "ms:", {
|
|
6095
|
+
error: streamError.message,
|
|
6096
|
+
code: streamError.code,
|
|
6097
|
+
name: streamError.name,
|
|
6098
|
+
connectionStatus: connection.status,
|
|
6099
|
+
connectionStreams: connection.streams.length,
|
|
6100
|
+
stack: streamError.stack?.split("\n").slice(0, 3)
|
|
6085
6101
|
});
|
|
6086
|
-
throw
|
|
6102
|
+
throw streamError;
|
|
6087
6103
|
}
|
|
6088
6104
|
const dataCopy = new Uint8Array(ciphertext);
|
|
6089
6105
|
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
|
@@ -148,46 +148,68 @@ export class P2PProtocolClient {
|
|
|
148
148
|
console.warn('[ByteCave P2P] Could not get peer info from peerStore:', e);
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
// Step 2:
|
|
152
|
-
console.log('[ByteCave P2P] Step 2:
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
151
|
+
// Step 2: Wait for connection upgrade from limited relay circuit to full WebRTC
|
|
152
|
+
console.log('[ByteCave P2P] Step 2: Checking if connection upgrade needed...');
|
|
153
|
+
|
|
154
|
+
if (existingConns.length === 0) {
|
|
155
|
+
throw new Error('No connection to peer - cannot open protocol stream');
|
|
156
|
+
}
|
|
156
157
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
const dialDuration = Date.now() - dialStart;
|
|
173
|
-
console.warn(`[ByteCave P2P] Dial attempt ${attempt} failed after ${dialDuration}ms:`, dialError.message);
|
|
174
|
-
|
|
175
|
-
if (attempt < 3) {
|
|
176
|
-
console.log('[ByteCave P2P] Waiting 1s before retry (node may still be registering handlers)...');
|
|
177
|
-
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
178
|
-
}
|
|
158
|
+
let connection = existingConns[0];
|
|
159
|
+
const isRelayCircuit = connection.remoteAddr.toString().includes('/p2p-circuit');
|
|
160
|
+
console.log('[ByteCave P2P] Connection type:', isRelayCircuit ? 'relay circuit (limited)' : 'direct');
|
|
161
|
+
console.log('[ByteCave P2P] Connection address:', connection.remoteAddr.toString());
|
|
162
|
+
|
|
163
|
+
// If it's a relay circuit, wait for DCUtR to upgrade to direct WebRTC
|
|
164
|
+
if (isRelayCircuit) {
|
|
165
|
+
console.log('[ByteCave P2P] Waiting for DCUtR to upgrade relay circuit to direct WebRTC...');
|
|
166
|
+
const upgradeStart = Date.now();
|
|
167
|
+
const hasDirectConnection = await this.waitForDirectConnection(peerId, 5000);
|
|
168
|
+
const upgradeDuration = Date.now() - upgradeStart;
|
|
169
|
+
|
|
170
|
+
if (!hasDirectConnection) {
|
|
171
|
+
console.error('[ByteCave P2P] DCUtR upgrade failed after', upgradeDuration, 'ms');
|
|
172
|
+
throw new Error('Cannot use storage protocol - relay circuit upgrade to WebRTC failed');
|
|
179
173
|
}
|
|
174
|
+
|
|
175
|
+
console.log('[ByteCave P2P] DCUtR upgrade successful after', upgradeDuration, 'ms');
|
|
176
|
+
|
|
177
|
+
// Get the new direct connection
|
|
178
|
+
const directConns = this.node!.getConnections(peerIdObj);
|
|
179
|
+
const directConn = directConns.find(conn => !conn.remoteAddr.toString().includes('/p2p-circuit'));
|
|
180
|
+
if (!directConn) {
|
|
181
|
+
throw new Error('DCUtR reported success but no direct connection found');
|
|
182
|
+
}
|
|
183
|
+
connection = directConn;
|
|
184
|
+
console.log('[ByteCave P2P] Using direct connection:', connection.remoteAddr.toString());
|
|
180
185
|
}
|
|
181
186
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
// Step 3: Open protocol stream on the connection
|
|
188
|
+
console.log('[ByteCave P2P] Step 3: Opening protocol stream...');
|
|
189
|
+
const streamStart = Date.now();
|
|
190
|
+
let stream;
|
|
191
|
+
try {
|
|
192
|
+
console.log('[ByteCave P2P] Calling connection.newStream with protocol /bytecave/store/1.0.0...');
|
|
193
|
+
stream = await connection.newStream('/bytecave/store/1.0.0');
|
|
194
|
+
const streamDuration = Date.now() - streamStart;
|
|
195
|
+
console.log('[ByteCave P2P] Step 4: Protocol stream opened in', streamDuration, 'ms');
|
|
196
|
+
console.log('[ByteCave P2P] Stream details:', {
|
|
197
|
+
protocol: stream.protocol,
|
|
198
|
+
direction: stream.direction,
|
|
199
|
+
id: stream.id,
|
|
200
|
+
timeline: stream.timeline
|
|
201
|
+
});
|
|
202
|
+
} catch (streamError: any) {
|
|
203
|
+
const streamDuration = Date.now() - streamStart;
|
|
204
|
+
console.error('[ByteCave P2P] Failed to open protocol stream after', streamDuration, 'ms:', {
|
|
205
|
+
error: streamError.message,
|
|
206
|
+
code: streamError.code,
|
|
207
|
+
name: streamError.name,
|
|
208
|
+
connectionStatus: connection.status,
|
|
209
|
+
connectionStreams: connection.streams.length,
|
|
210
|
+
stack: streamError.stack?.split('\n').slice(0, 3)
|
|
189
211
|
});
|
|
190
|
-
throw
|
|
212
|
+
throw streamError;
|
|
191
213
|
}
|
|
192
214
|
|
|
193
215
|
// Generate CID using SHA-256 (matches bytecave-core format: 64-char hex)
|