@gethashd/bytecave-browser 1.0.50 → 1.0.51

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.
@@ -6352,37 +6352,21 @@ var StorageWebTransportClient = class {
6352
6352
  }
6353
6353
  /**
6354
6354
  * Convert libp2p multihash cert hash to SHA-256 ArrayBuffer for WebTransport
6355
- * The certhash in multiaddr is base58-encoded multihash, we need to decode it
6355
+ * The certhash in multiaddr format is: uEi<hex-hash>
6356
+ * where 'u' = base32 multibase, 'Ei' = multihash prefix for SHA-256
6356
6357
  */
6357
6358
  async certHashToSHA256(multihash) {
6358
6359
  try {
6359
- const base58Data = multihash.startsWith("uEi") ? multihash.slice(3) : multihash;
6360
- const hexHash = this.base58ToHex(base58Data);
6360
+ let hexHash = multihash.startsWith("uEi") ? multihash.slice(3) : multihash;
6361
6361
  const bytes = new Uint8Array(hexHash.match(/.{1,2}/g).map((byte) => parseInt(byte, 16)));
6362
+ console.log("[WebTransport] Decoded certificate hash:", hexHash);
6363
+ console.log("[WebTransport] Hash bytes length:", bytes.length);
6362
6364
  return bytes.buffer;
6363
6365
  } catch (error) {
6364
6366
  console.error("[WebTransport] Failed to convert cert hash:", error);
6365
- return new Uint8Array(32).buffer;
6367
+ throw new Error("Failed to decode certificate hash");
6366
6368
  }
6367
6369
  }
6368
- /**
6369
- * Simple base58 to hex converter (simplified version)
6370
- */
6371
- base58ToHex(base58) {
6372
- const alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
6373
- let num = BigInt(0);
6374
- for (let i = 0; i < base58.length; i++) {
6375
- const char = base58[i];
6376
- const value = alphabet.indexOf(char);
6377
- if (value === -1) {
6378
- throw new Error(`Invalid base58 character: ${char}`);
6379
- }
6380
- num = num * BigInt(58) + BigInt(value);
6381
- }
6382
- let hex = num.toString(16);
6383
- if (hex.length % 2) hex = "0" + hex;
6384
- return hex;
6385
- }
6386
6370
  };
6387
6371
 
6388
6372
  // src/contracts/ContentRegistry.ts
package/dist/index.cjs CHANGED
@@ -6405,37 +6405,21 @@ var StorageWebTransportClient = class {
6405
6405
  }
6406
6406
  /**
6407
6407
  * Convert libp2p multihash cert hash to SHA-256 ArrayBuffer for WebTransport
6408
- * The certhash in multiaddr is base58-encoded multihash, we need to decode it
6408
+ * The certhash in multiaddr format is: uEi<hex-hash>
6409
+ * where 'u' = base32 multibase, 'Ei' = multihash prefix for SHA-256
6409
6410
  */
6410
6411
  async certHashToSHA256(multihash) {
6411
6412
  try {
6412
- const base58Data = multihash.startsWith("uEi") ? multihash.slice(3) : multihash;
6413
- const hexHash = this.base58ToHex(base58Data);
6413
+ let hexHash = multihash.startsWith("uEi") ? multihash.slice(3) : multihash;
6414
6414
  const bytes = new Uint8Array(hexHash.match(/.{1,2}/g).map((byte) => parseInt(byte, 16)));
6415
+ console.log("[WebTransport] Decoded certificate hash:", hexHash);
6416
+ console.log("[WebTransport] Hash bytes length:", bytes.length);
6415
6417
  return bytes.buffer;
6416
6418
  } catch (error) {
6417
6419
  console.error("[WebTransport] Failed to convert cert hash:", error);
6418
- return new Uint8Array(32).buffer;
6420
+ throw new Error("Failed to decode certificate hash");
6419
6421
  }
6420
6422
  }
6421
- /**
6422
- * Simple base58 to hex converter (simplified version)
6423
- */
6424
- base58ToHex(base58) {
6425
- const alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
6426
- let num = BigInt(0);
6427
- for (let i = 0; i < base58.length; i++) {
6428
- const char = base58[i];
6429
- const value = alphabet.indexOf(char);
6430
- if (value === -1) {
6431
- throw new Error(`Invalid base58 character: ${char}`);
6432
- }
6433
- num = num * BigInt(58) + BigInt(value);
6434
- }
6435
- let hex = num.toString(16);
6436
- if (hex.length % 2) hex = "0" + hex;
6437
- return hex;
6438
- }
6439
6423
  };
6440
6424
 
6441
6425
  // src/contracts/ContentRegistry.ts
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  useHashdImage,
14
14
  useHashdMedia,
15
15
  useHashdUrl
16
- } from "./chunk-2FNF5T75.js";
16
+ } from "./chunk-KU6ZO2QD.js";
17
17
  import {
18
18
  clearHashdCache,
19
19
  createHashdUrl,
@@ -8,7 +8,7 @@ import {
8
8
  useHashdImage,
9
9
  useHashdMedia,
10
10
  useHashdUrl
11
- } from "../chunk-2FNF5T75.js";
11
+ } from "../chunk-KU6ZO2QD.js";
12
12
  import "../chunk-EEZWRIUI.js";
13
13
  export {
14
14
  HashdAudio,
@@ -40,11 +40,8 @@ export declare class StorageWebTransportClient {
40
40
  private extractCertHash;
41
41
  /**
42
42
  * Convert libp2p multihash cert hash to SHA-256 ArrayBuffer for WebTransport
43
- * The certhash in multiaddr is base58-encoded multihash, we need to decode it
43
+ * The certhash in multiaddr format is: uEi<hex-hash>
44
+ * where 'u' = base32 multibase, 'Ei' = multihash prefix for SHA-256
44
45
  */
45
46
  private certHashToSHA256;
46
- /**
47
- * Simple base58 to hex converter (simplified version)
48
- */
49
- private base58ToHex;
50
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gethashd/bytecave-browser",
3
- "version": "1.0.50",
3
+ "version": "1.0.51",
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",
@@ -192,55 +192,25 @@ export class StorageWebTransportClient {
192
192
 
193
193
  /**
194
194
  * Convert libp2p multihash cert hash to SHA-256 ArrayBuffer for WebTransport
195
- * The certhash in multiaddr is base58-encoded multihash, we need to decode it
195
+ * The certhash in multiaddr format is: uEi<hex-hash>
196
+ * where 'u' = base32 multibase, 'Ei' = multihash prefix for SHA-256
196
197
  */
197
198
  private async certHashToSHA256(multihash: string): Promise<ArrayBuffer> {
198
199
  try {
199
- // The multihash format is: uEi<base58-encoded-data>
200
- // For WebTransport, we need the raw SHA-256 hash bytes
200
+ // Remove 'uEi' prefix to get the raw hex hash
201
+ // Format: uEi733dc9ebf43a04ad3bc692f104cf6ccc228a062fcd7aa43fc370f9c3c67e3bfc
202
+ let hexHash = multihash.startsWith('uEi') ? multihash.slice(3) : multihash;
201
203
 
202
- // Remove 'uEi' prefix (multibase + multihash prefix for SHA-256)
203
- const base58Data = multihash.startsWith('uEi') ? multihash.slice(3) : multihash;
204
-
205
- // Decode base58 to get the raw hash
206
- // For now, we'll convert the hex fingerprint to ArrayBuffer
207
- // The fingerprint format is: "73:3d:c9:eb:f4:3a:04:ad:..."
208
- // We need to convert this to raw bytes
209
-
210
- // Since we don't have the original fingerprint here, we'll decode the base58
211
- // This is a simplified approach - in production, use a proper base58 decoder
212
- const hexHash = this.base58ToHex(base58Data);
204
+ // The hash after uEi is already in hex format, just convert to bytes
213
205
  const bytes = new Uint8Array(hexHash.match(/.{1,2}/g)!.map(byte => parseInt(byte, 16)));
214
206
 
207
+ console.log('[WebTransport] Decoded certificate hash:', hexHash);
208
+ console.log('[WebTransport] Hash bytes length:', bytes.length);
209
+
215
210
  return bytes.buffer;
216
211
  } catch (error) {
217
212
  console.error('[WebTransport] Failed to convert cert hash:', error);
218
- // Fallback: create a dummy hash (this won't work but prevents crash)
219
- return new Uint8Array(32).buffer;
220
- }
221
- }
222
-
223
- /**
224
- * Simple base58 to hex converter (simplified version)
225
- */
226
- private base58ToHex(base58: string): string {
227
- // This is a simplified implementation
228
- // In production, use a proper base58 decoding library
229
- const alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
230
- let num = BigInt(0);
231
-
232
- for (let i = 0; i < base58.length; i++) {
233
- const char = base58[i];
234
- const value = alphabet.indexOf(char);
235
- if (value === -1) {
236
- throw new Error(`Invalid base58 character: ${char}`);
237
- }
238
- num = num * BigInt(58) + BigInt(value);
213
+ throw new Error('Failed to decode certificate hash');
239
214
  }
240
-
241
- let hex = num.toString(16);
242
- if (hex.length % 2) hex = '0' + hex;
243
-
244
- return hex;
245
215
  }
246
216
  }