@gethashd/bytecave-browser 1.0.18 → 1.0.20

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.
@@ -5705,9 +5705,15 @@ 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: 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");
5708
+ console.log("[ByteCave P2P] Step 1: Getting existing connection...");
5709
+ const connections = this.node.getConnections(peerIdObj);
5710
+ if (connections.length === 0) {
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");
5711
5717
  const dataCopy = new Uint8Array(ciphertext);
5712
5718
  const hashBuffer = await crypto.subtle.digest("SHA-256", dataCopy);
5713
5719
  const hashArray = Array.from(new Uint8Array(hashBuffer));
@@ -5985,6 +5991,7 @@ import { floodsub } from "@libp2p/floodsub";
5985
5991
  import { identify } from "@libp2p/identify";
5986
5992
  import { bootstrap } from "@libp2p/bootstrap";
5987
5993
  import { circuitRelayTransport } from "@libp2p/circuit-relay-v2";
5994
+ import { dcutr } from "@libp2p/dcutr";
5988
5995
  import { multiaddr } from "@multiformats/multiaddr";
5989
5996
  import { fromString, toString } from "uint8arrays";
5990
5997
  import { ethers as ethers2 } from "ethers";
@@ -6053,7 +6060,8 @@ var ByteCaveClient = class {
6053
6060
  streamMuxers: [yamux()],
6054
6061
  services: {
6055
6062
  identify: identify(),
6056
- pubsub: floodsub()
6063
+ pubsub: floodsub(),
6064
+ dcutr: dcutr()
6057
6065
  },
6058
6066
  connectionGater: {
6059
6067
  denyDialMultiaddr: () => false,
package/dist/index.cjs CHANGED
@@ -67,6 +67,7 @@ var import_floodsub = require("@libp2p/floodsub");
67
67
  var import_identify = require("@libp2p/identify");
68
68
  var import_bootstrap = require("@libp2p/bootstrap");
69
69
  var import_circuit_relay_v2 = require("@libp2p/circuit-relay-v2");
70
+ var import_dcutr = require("@libp2p/dcutr");
70
71
  var import_multiaddr = require("@multiformats/multiaddr");
71
72
  var import_uint8arrays = require("uint8arrays");
72
73
  var import_ethers2 = require("ethers");
@@ -5772,9 +5773,15 @@ var P2PProtocolClient = class {
5772
5773
  const timeoutMs = 3e4 + fileSizeMB * 1e4;
5773
5774
  console.log(`[ByteCave P2P] Store timeout: ${Math.round(timeoutMs / 1e3)}s for ${fileSizeMB.toFixed(2)}MB`);
5774
5775
  const storePromise = (async () => {
5775
- console.log("[ByteCave P2P] Step 1: Dialing store protocol...");
5776
- const stream = await this.node.dialProtocol(peerIdObj, "/bytecave/store/1.0.0");
5777
- console.log("[ByteCave P2P] Step 2: Stream established");
5776
+ console.log("[ByteCave P2P] Step 1: Getting existing connection...");
5777
+ const connections = this.node.getConnections(peerIdObj);
5778
+ if (connections.length === 0) {
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");
5778
5785
  const dataCopy = new Uint8Array(ciphertext);
5779
5786
  const hashBuffer = await crypto.subtle.digest("SHA-256", dataCopy);
5780
5787
  const hashArray = Array.from(new Uint8Array(hashBuffer));
@@ -6106,7 +6113,8 @@ var ByteCaveClient = class {
6106
6113
  streamMuxers: [(0, import_libp2p_yamux.yamux)()],
6107
6114
  services: {
6108
6115
  identify: (0, import_identify.identify)(),
6109
- pubsub: (0, import_floodsub.floodsub)()
6116
+ pubsub: (0, import_floodsub.floodsub)(),
6117
+ dcutr: (0, import_dcutr.dcutr)()
6110
6118
  },
6111
6119
  connectionGater: {
6112
6120
  denyDialMultiaddr: () => false,
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  useHashdImage,
14
14
  useHashdMedia,
15
15
  useHashdUrl
16
- } from "./chunk-XTS56CBL.js";
16
+ } from "./chunk-6ITKYT45.js";
17
17
  import {
18
18
  clearHashdCache,
19
19
  createHashdUrl,
@@ -402,6 +402,7 @@ var import_floodsub = require("@libp2p/floodsub");
402
402
  var import_identify = require("@libp2p/identify");
403
403
  var import_bootstrap = require("@libp2p/bootstrap");
404
404
  var import_circuit_relay_v2 = require("@libp2p/circuit-relay-v2");
405
+ var import_dcutr = require("@libp2p/dcutr");
405
406
  var import_multiaddr = require("@multiformats/multiaddr");
406
407
  var import_uint8arrays = require("uint8arrays");
407
408
  var import_ethers2 = require("ethers");
@@ -6027,9 +6028,15 @@ var P2PProtocolClient = class {
6027
6028
  const timeoutMs = 3e4 + fileSizeMB * 1e4;
6028
6029
  console.log(`[ByteCave P2P] Store timeout: ${Math.round(timeoutMs / 1e3)}s for ${fileSizeMB.toFixed(2)}MB`);
6029
6030
  const storePromise = (async () => {
6030
- console.log("[ByteCave P2P] Step 1: Dialing store protocol...");
6031
- const stream = await this.node.dialProtocol(peerIdObj, "/bytecave/store/1.0.0");
6032
- console.log("[ByteCave P2P] Step 2: Stream established");
6031
+ console.log("[ByteCave P2P] Step 1: Getting existing connection...");
6032
+ const connections = this.node.getConnections(peerIdObj);
6033
+ if (connections.length === 0) {
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");
6033
6040
  const dataCopy = new Uint8Array(ciphertext);
6034
6041
  const hashBuffer = await crypto.subtle.digest("SHA-256", dataCopy);
6035
6042
  const hashArray = Array.from(new Uint8Array(hashBuffer));
@@ -8,7 +8,7 @@ import {
8
8
  useHashdImage,
9
9
  useHashdMedia,
10
10
  useHashdUrl
11
- } from "../chunk-XTS56CBL.js";
11
+ } from "../chunk-6ITKYT45.js";
12
12
  import "../chunk-EEZWRIUI.js";
13
13
  export {
14
14
  HashdAudio,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gethashd/bytecave-browser",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "ByteCave browser client for WebRTC P2P connections to storage nodes",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
package/src/client.ts CHANGED
@@ -13,6 +13,7 @@ import { floodsub } from '@libp2p/floodsub';
13
13
  import { identify } from '@libp2p/identify';
14
14
  import { bootstrap } from '@libp2p/bootstrap';
15
15
  import { circuitRelayTransport } from '@libp2p/circuit-relay-v2';
16
+ import { dcutr } from '@libp2p/dcutr';
16
17
  import { multiaddr } from '@multiformats/multiaddr';
17
18
  import { peerIdFromString } from '@libp2p/peer-id';
18
19
  import { fromString, toString } from 'uint8arrays';
@@ -104,7 +105,8 @@ export class ByteCaveClient {
104
105
  streamMuxers: [yamux()],
105
106
  services: {
106
107
  identify: identify(),
107
- pubsub: floodsub()
108
+ pubsub: floodsub(),
109
+ dcutr: dcutr() as any
108
110
  },
109
111
  connectionGater: {
110
112
  denyDialMultiaddr: () => false,
@@ -124,10 +124,16 @@ 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: Dialing store protocol...');
128
- // Use the store protocol for browser-to-node storage (with authorization)
129
- const stream = await this.node!.dialProtocol(peerIdObj, '/bytecave/store/1.0.0');
130
- console.log('[ByteCave P2P] Step 2: Stream established');
127
+ console.log('[ByteCave P2P] Step 1: Getting existing connection...');
128
+ // Get existing connection (relay circuit) instead of dialing new connection
129
+ const connections = this.node!.getConnections(peerIdObj);
130
+ if (connections.length === 0) {
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');
131
137
 
132
138
  // Generate CID using SHA-256 (matches bytecave-core format: 64-char hex)
133
139
  const dataCopy = new Uint8Array(ciphertext);