@gethashd/bytecave-browser 1.0.20 → 1.0.22
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-6ITKYT45.js → chunk-ZFKOXO6W.js} +6 -20
- package/dist/index.cjs +6 -20
- package/dist/index.js +1 -1
- package/dist/react/index.cjs +3 -9
- package/dist/react/index.js +1 -1
- package/package.json +1 -1
- package/src/client.ts +4 -14
- package/src/p2p-protocols.ts +4 -10
|
@@ -5705,15 +5705,9 @@ 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:
|
|
5709
|
-
const
|
|
5710
|
-
|
|
5711
|
-
throw new Error("No connection to peer");
|
|
5712
|
-
}
|
|
5713
|
-
const connection = connections[0];
|
|
5714
|
-
console.log("[ByteCave P2P] Step 2: Opening stream on existing connection...");
|
|
5715
|
-
const stream = await connection.newStream("/bytecave/store/1.0.0");
|
|
5716
|
-
console.log("[ByteCave P2P] Step 3: Stream established");
|
|
5708
|
+
console.log("[ByteCave P2P] Step 1: Dialing store protocol...");
|
|
5709
|
+
const stream = await this.node.dialProtocol(peerIdObj, "/bytecave/store/1.0.0");
|
|
5710
|
+
console.log("[ByteCave P2P] Step 2: Stream established");
|
|
5717
5711
|
const dataCopy = new Uint8Array(ciphertext);
|
|
5718
5712
|
const hashBuffer = await crypto.subtle.digest("SHA-256", dataCopy);
|
|
5719
5713
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
@@ -6327,16 +6321,13 @@ var ByteCaveClient = class {
|
|
|
6327
6321
|
return { success: false, error: "P2P node not initialized" };
|
|
6328
6322
|
}
|
|
6329
6323
|
const allPeers = this.node.getPeers();
|
|
6330
|
-
const connectedPeerIds = allPeers.map((p) => p.toString())
|
|
6331
|
-
const peerInfo = this.knownPeers.get(peerId);
|
|
6332
|
-
return !peerInfo?.isRelay;
|
|
6333
|
-
});
|
|
6324
|
+
const connectedPeerIds = allPeers.map((p) => p.toString());
|
|
6334
6325
|
console.log("[ByteCave] Store - connected storage peers:", connectedPeerIds.length);
|
|
6335
6326
|
console.log("[ByteCave] Store - knownPeers with registration info:", this.knownPeers.size);
|
|
6336
6327
|
if (connectedPeerIds.length === 0) {
|
|
6337
6328
|
return { success: false, error: "No storage peers available" };
|
|
6338
6329
|
}
|
|
6339
|
-
const registeredPeerIds = Array.from(this.knownPeers.values()).filter((p) => p.isRegistered &&
|
|
6330
|
+
const registeredPeerIds = Array.from(this.knownPeers.values()).filter((p) => p.isRegistered && connectedPeerIds.includes(p.peerId)).map((p) => p.peerId);
|
|
6340
6331
|
const storagePeerIds = registeredPeerIds.length > 0 ? [...registeredPeerIds, ...connectedPeerIds.filter((id) => !registeredPeerIds.includes(id))] : connectedPeerIds;
|
|
6341
6332
|
console.log(
|
|
6342
6333
|
"[ByteCave] Store - peer order (registered first):",
|
|
@@ -6686,12 +6677,7 @@ Nonce: ${nonce}`;
|
|
|
6686
6677
|
blobCount: announcement.blobCount,
|
|
6687
6678
|
timestamp: announcement.timestamp,
|
|
6688
6679
|
multiaddrs: announcement.multiaddrs,
|
|
6689
|
-
relayAddrs: announcement.relayAddrs || existing?.relayAddrs
|
|
6690
|
-
// Store on-chain registration status
|
|
6691
|
-
registeredOnChain: announcement.registeredOnChain || false,
|
|
6692
|
-
onChainNodeId: announcement.onChainNodeId || existing?.onChainNodeId,
|
|
6693
|
-
// Store relay flag so we can filter out relays from storage attempts
|
|
6694
|
-
isRelay: announcement.isRelay || false
|
|
6680
|
+
relayAddrs: announcement.relayAddrs || existing?.relayAddrs
|
|
6695
6681
|
};
|
|
6696
6682
|
this.knownPeers.set(announcement.peerId, peerInfo);
|
|
6697
6683
|
this.emit("peerAnnounce", peerInfo);
|
package/dist/index.cjs
CHANGED
|
@@ -5773,15 +5773,9 @@ 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:
|
|
5777
|
-
const
|
|
5778
|
-
|
|
5779
|
-
throw new Error("No connection to peer");
|
|
5780
|
-
}
|
|
5781
|
-
const connection = connections[0];
|
|
5782
|
-
console.log("[ByteCave P2P] Step 2: Opening stream on existing connection...");
|
|
5783
|
-
const stream = await connection.newStream("/bytecave/store/1.0.0");
|
|
5784
|
-
console.log("[ByteCave P2P] Step 3: Stream established");
|
|
5776
|
+
console.log("[ByteCave P2P] Step 1: Dialing store protocol...");
|
|
5777
|
+
const stream = await this.node.dialProtocol(peerIdObj, "/bytecave/store/1.0.0");
|
|
5778
|
+
console.log("[ByteCave P2P] Step 2: Stream established");
|
|
5785
5779
|
const dataCopy = new Uint8Array(ciphertext);
|
|
5786
5780
|
const hashBuffer = await crypto.subtle.digest("SHA-256", dataCopy);
|
|
5787
5781
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
@@ -6380,16 +6374,13 @@ var ByteCaveClient = class {
|
|
|
6380
6374
|
return { success: false, error: "P2P node not initialized" };
|
|
6381
6375
|
}
|
|
6382
6376
|
const allPeers = this.node.getPeers();
|
|
6383
|
-
const connectedPeerIds = allPeers.map((p) => p.toString())
|
|
6384
|
-
const peerInfo = this.knownPeers.get(peerId);
|
|
6385
|
-
return !peerInfo?.isRelay;
|
|
6386
|
-
});
|
|
6377
|
+
const connectedPeerIds = allPeers.map((p) => p.toString());
|
|
6387
6378
|
console.log("[ByteCave] Store - connected storage peers:", connectedPeerIds.length);
|
|
6388
6379
|
console.log("[ByteCave] Store - knownPeers with registration info:", this.knownPeers.size);
|
|
6389
6380
|
if (connectedPeerIds.length === 0) {
|
|
6390
6381
|
return { success: false, error: "No storage peers available" };
|
|
6391
6382
|
}
|
|
6392
|
-
const registeredPeerIds = Array.from(this.knownPeers.values()).filter((p) => p.isRegistered &&
|
|
6383
|
+
const registeredPeerIds = Array.from(this.knownPeers.values()).filter((p) => p.isRegistered && connectedPeerIds.includes(p.peerId)).map((p) => p.peerId);
|
|
6393
6384
|
const storagePeerIds = registeredPeerIds.length > 0 ? [...registeredPeerIds, ...connectedPeerIds.filter((id) => !registeredPeerIds.includes(id))] : connectedPeerIds;
|
|
6394
6385
|
console.log(
|
|
6395
6386
|
"[ByteCave] Store - peer order (registered first):",
|
|
@@ -6739,12 +6730,7 @@ Nonce: ${nonce}`;
|
|
|
6739
6730
|
blobCount: announcement.blobCount,
|
|
6740
6731
|
timestamp: announcement.timestamp,
|
|
6741
6732
|
multiaddrs: announcement.multiaddrs,
|
|
6742
|
-
relayAddrs: announcement.relayAddrs || existing?.relayAddrs
|
|
6743
|
-
// Store on-chain registration status
|
|
6744
|
-
registeredOnChain: announcement.registeredOnChain || false,
|
|
6745
|
-
onChainNodeId: announcement.onChainNodeId || existing?.onChainNodeId,
|
|
6746
|
-
// Store relay flag so we can filter out relays from storage attempts
|
|
6747
|
-
isRelay: announcement.isRelay || false
|
|
6733
|
+
relayAddrs: announcement.relayAddrs || existing?.relayAddrs
|
|
6748
6734
|
};
|
|
6749
6735
|
this.knownPeers.set(announcement.peerId, peerInfo);
|
|
6750
6736
|
this.emit("peerAnnounce", peerInfo);
|
package/dist/index.js
CHANGED
package/dist/react/index.cjs
CHANGED
|
@@ -6028,15 +6028,9 @@ 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:
|
|
6032
|
-
const
|
|
6033
|
-
|
|
6034
|
-
throw new Error("No connection to peer");
|
|
6035
|
-
}
|
|
6036
|
-
const connection = connections[0];
|
|
6037
|
-
console.log("[ByteCave P2P] Step 2: Opening stream on existing connection...");
|
|
6038
|
-
const stream = await connection.newStream("/bytecave/store/1.0.0");
|
|
6039
|
-
console.log("[ByteCave P2P] Step 3: Stream established");
|
|
6031
|
+
console.log("[ByteCave P2P] Step 1: Dialing store protocol...");
|
|
6032
|
+
const stream = await this.node.dialProtocol(peerIdObj, "/bytecave/store/1.0.0");
|
|
6033
|
+
console.log("[ByteCave P2P] Step 2: Stream established");
|
|
6040
6034
|
const dataCopy = new Uint8Array(ciphertext);
|
|
6041
6035
|
const hashBuffer = await crypto.subtle.digest("SHA-256", dataCopy);
|
|
6042
6036
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
package/dist/react/index.js
CHANGED
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -427,14 +427,9 @@ export class ByteCaveClient {
|
|
|
427
427
|
return { success: false, error: 'P2P node not initialized' };
|
|
428
428
|
}
|
|
429
429
|
|
|
430
|
-
// Get all connected peers
|
|
430
|
+
// Get all connected peers
|
|
431
431
|
const allPeers = this.node.getPeers();
|
|
432
|
-
const connectedPeerIds = allPeers.map(p => p.toString())
|
|
433
|
-
.filter(peerId => {
|
|
434
|
-
const peerInfo = this.knownPeers.get(peerId) as any;
|
|
435
|
-
// Filter out relay peers - they announce with isRelay: true
|
|
436
|
-
return !peerInfo?.isRelay;
|
|
437
|
-
});
|
|
432
|
+
const connectedPeerIds = allPeers.map(p => p.toString());
|
|
438
433
|
|
|
439
434
|
console.log('[ByteCave] Store - connected storage peers:', connectedPeerIds.length);
|
|
440
435
|
console.log('[ByteCave] Store - knownPeers with registration info:', this.knownPeers.size);
|
|
@@ -446,7 +441,7 @@ export class ByteCaveClient {
|
|
|
446
441
|
// Prioritize registered peers from knownPeers (populated via floodsub announcements)
|
|
447
442
|
// If no registered peers known yet, use all connected peers
|
|
448
443
|
const registeredPeerIds = Array.from(this.knownPeers.values())
|
|
449
|
-
.filter(p => p.isRegistered &&
|
|
444
|
+
.filter(p => p.isRegistered && connectedPeerIds.includes(p.peerId))
|
|
450
445
|
.map(p => p.peerId);
|
|
451
446
|
|
|
452
447
|
const storagePeerIds = registeredPeerIds.length > 0
|
|
@@ -886,12 +881,7 @@ Nonce: ${nonce}`;
|
|
|
886
881
|
blobCount: announcement.blobCount,
|
|
887
882
|
timestamp: announcement.timestamp,
|
|
888
883
|
multiaddrs: announcement.multiaddrs,
|
|
889
|
-
relayAddrs: announcement.relayAddrs || (existing as any)?.relayAddrs
|
|
890
|
-
// Store on-chain registration status
|
|
891
|
-
registeredOnChain: announcement.registeredOnChain || false,
|
|
892
|
-
onChainNodeId: announcement.onChainNodeId || (existing as any)?.onChainNodeId,
|
|
893
|
-
// Store relay flag so we can filter out relays from storage attempts
|
|
894
|
-
isRelay: announcement.isRelay || false
|
|
884
|
+
relayAddrs: announcement.relayAddrs || (existing as any)?.relayAddrs
|
|
895
885
|
};
|
|
896
886
|
|
|
897
887
|
this.knownPeers.set(announcement.peerId, peerInfo);
|
package/src/p2p-protocols.ts
CHANGED
|
@@ -124,16 +124,10 @@ 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
|
-
//
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
throw new Error('No connection to peer');
|
|
132
|
-
}
|
|
133
|
-
const connection = connections[0];
|
|
134
|
-
console.log('[ByteCave P2P] Step 2: Opening stream on existing connection...');
|
|
135
|
-
const stream = await connection.newStream('/bytecave/store/1.0.0');
|
|
136
|
-
console.log('[ByteCave P2P] Step 3: Stream established');
|
|
127
|
+
console.log('[ByteCave P2P] Step 1: Dialing store protocol...');
|
|
128
|
+
// dialProtocol will upgrade limited relay connections to full connections automatically
|
|
129
|
+
const stream = await this.node!.dialProtocol(peerIdObj, '/bytecave/store/1.0.0');
|
|
130
|
+
console.log('[ByteCave P2P] Step 2: Stream established');
|
|
137
131
|
|
|
138
132
|
// Generate CID using SHA-256 (matches bytecave-core format: 64-char hex)
|
|
139
133
|
const dataCopy = new Uint8Array(ciphertext);
|