@gethashd/bytecave-browser 1.0.43 → 1.0.45
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-AS5ZERB4.js → chunk-LTSO3FCE.js} +16 -3
- package/dist/index.cjs +16 -3
- package/dist/index.js +1 -1
- package/dist/react/index.js +1 -1
- package/package.json +1 -1
- package/src/client.ts +11 -1
- package/src/storage-websocket.ts +13 -2
|
@@ -6077,12 +6077,14 @@ var StorageWebSocketClient = class {
|
|
|
6077
6077
|
}
|
|
6078
6078
|
async connect() {
|
|
6079
6079
|
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
|
6080
|
+
console.log("[Storage WS] Already connected");
|
|
6080
6081
|
return;
|
|
6081
6082
|
}
|
|
6083
|
+
console.log("[Storage WS] Connecting to relay:", this.relayUrl);
|
|
6082
6084
|
return new Promise((resolve, reject) => {
|
|
6083
6085
|
this.ws = new WebSocket(this.relayUrl);
|
|
6084
6086
|
this.ws.onopen = () => {
|
|
6085
|
-
console.log("[Storage WS] Connected to relay");
|
|
6087
|
+
console.log("[Storage WS] \u2713 Connected to relay");
|
|
6086
6088
|
resolve();
|
|
6087
6089
|
};
|
|
6088
6090
|
this.ws.onmessage = (event) => {
|
|
@@ -6139,10 +6141,13 @@ var StorageWebSocketClient = class {
|
|
|
6139
6141
|
}
|
|
6140
6142
|
}
|
|
6141
6143
|
async store(options) {
|
|
6144
|
+
console.log("[Storage WS] store() called, data size:", options.data.length, "bytes");
|
|
6142
6145
|
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
|
|
6146
|
+
console.log("[Storage WS] Not connected, connecting now...");
|
|
6143
6147
|
await this.connect();
|
|
6144
6148
|
}
|
|
6145
6149
|
const requestId = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
6150
|
+
console.log("[Storage WS] Converting data to base64...");
|
|
6146
6151
|
const chunkSize = 8192;
|
|
6147
6152
|
let binaryString = "";
|
|
6148
6153
|
for (let i = 0; i < options.data.length; i += chunkSize) {
|
|
@@ -6150,6 +6155,7 @@ var StorageWebSocketClient = class {
|
|
|
6150
6155
|
binaryString += String.fromCharCode(...chunk);
|
|
6151
6156
|
}
|
|
6152
6157
|
const base64Data = btoa(binaryString);
|
|
6158
|
+
console.log("[Storage WS] Base64 data length:", base64Data.length);
|
|
6153
6159
|
const request = {
|
|
6154
6160
|
type: "storage-request",
|
|
6155
6161
|
requestId,
|
|
@@ -6158,16 +6164,20 @@ var StorageWebSocketClient = class {
|
|
|
6158
6164
|
hashIdToken: options.hashIdToken,
|
|
6159
6165
|
authorization: options.authorization
|
|
6160
6166
|
};
|
|
6167
|
+
console.log("[Storage WS] Creating promise for request:", requestId);
|
|
6161
6168
|
return new Promise((resolve, reject) => {
|
|
6162
6169
|
const timeout = setTimeout(() => {
|
|
6170
|
+
console.error("[Storage WS] Request timed out:", requestId);
|
|
6163
6171
|
this.pendingRequests.delete(requestId);
|
|
6164
6172
|
reject(new Error("Storage request timeout"));
|
|
6165
6173
|
}, options.timeout || 3e4);
|
|
6166
6174
|
this.pendingRequests.set(requestId, { resolve, reject, timeout });
|
|
6167
6175
|
try {
|
|
6176
|
+
console.log("[Storage WS] Sending request to relay, WS state:", this.ws?.readyState);
|
|
6168
6177
|
this.ws.send(JSON.stringify(request));
|
|
6169
|
-
console.log("[Storage WS] Sent storage request:", requestId);
|
|
6178
|
+
console.log("[Storage WS] \u2713 Sent storage request:", requestId);
|
|
6170
6179
|
} catch (error) {
|
|
6180
|
+
console.error("[Storage WS] Failed to send request:", error.message);
|
|
6171
6181
|
clearTimeout(timeout);
|
|
6172
6182
|
this.pendingRequests.delete(requestId);
|
|
6173
6183
|
reject(error);
|
|
@@ -6672,7 +6682,10 @@ Nonce: ${nonce}`;
|
|
|
6672
6682
|
CONTENT_REGISTRY_ABI,
|
|
6673
6683
|
signer
|
|
6674
6684
|
);
|
|
6675
|
-
const
|
|
6685
|
+
const cidBytes32 = "0x" + cid;
|
|
6686
|
+
const appIdBytes32 = ethers2.keccak256(ethers2.toUtf8Bytes(appId));
|
|
6687
|
+
const owner = await signer.getAddress();
|
|
6688
|
+
const tx = await contract.registerContent(cidBytes32, owner, appIdBytes32, hashIdToken);
|
|
6676
6689
|
console.log("[ByteCave] ContentRegistry transaction sent:", tx.hash);
|
|
6677
6690
|
const receipt = await tx.wait();
|
|
6678
6691
|
console.log("[ByteCave] ContentRegistry registration confirmed:", receipt.hash);
|
package/dist/index.cjs
CHANGED
|
@@ -6130,12 +6130,14 @@ var StorageWebSocketClient = class {
|
|
|
6130
6130
|
}
|
|
6131
6131
|
async connect() {
|
|
6132
6132
|
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
|
6133
|
+
console.log("[Storage WS] Already connected");
|
|
6133
6134
|
return;
|
|
6134
6135
|
}
|
|
6136
|
+
console.log("[Storage WS] Connecting to relay:", this.relayUrl);
|
|
6135
6137
|
return new Promise((resolve, reject) => {
|
|
6136
6138
|
this.ws = new WebSocket(this.relayUrl);
|
|
6137
6139
|
this.ws.onopen = () => {
|
|
6138
|
-
console.log("[Storage WS] Connected to relay");
|
|
6140
|
+
console.log("[Storage WS] \u2713 Connected to relay");
|
|
6139
6141
|
resolve();
|
|
6140
6142
|
};
|
|
6141
6143
|
this.ws.onmessage = (event) => {
|
|
@@ -6192,10 +6194,13 @@ var StorageWebSocketClient = class {
|
|
|
6192
6194
|
}
|
|
6193
6195
|
}
|
|
6194
6196
|
async store(options) {
|
|
6197
|
+
console.log("[Storage WS] store() called, data size:", options.data.length, "bytes");
|
|
6195
6198
|
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
|
|
6199
|
+
console.log("[Storage WS] Not connected, connecting now...");
|
|
6196
6200
|
await this.connect();
|
|
6197
6201
|
}
|
|
6198
6202
|
const requestId = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
6203
|
+
console.log("[Storage WS] Converting data to base64...");
|
|
6199
6204
|
const chunkSize = 8192;
|
|
6200
6205
|
let binaryString = "";
|
|
6201
6206
|
for (let i = 0; i < options.data.length; i += chunkSize) {
|
|
@@ -6203,6 +6208,7 @@ var StorageWebSocketClient = class {
|
|
|
6203
6208
|
binaryString += String.fromCharCode(...chunk);
|
|
6204
6209
|
}
|
|
6205
6210
|
const base64Data = btoa(binaryString);
|
|
6211
|
+
console.log("[Storage WS] Base64 data length:", base64Data.length);
|
|
6206
6212
|
const request = {
|
|
6207
6213
|
type: "storage-request",
|
|
6208
6214
|
requestId,
|
|
@@ -6211,16 +6217,20 @@ var StorageWebSocketClient = class {
|
|
|
6211
6217
|
hashIdToken: options.hashIdToken,
|
|
6212
6218
|
authorization: options.authorization
|
|
6213
6219
|
};
|
|
6220
|
+
console.log("[Storage WS] Creating promise for request:", requestId);
|
|
6214
6221
|
return new Promise((resolve, reject) => {
|
|
6215
6222
|
const timeout = setTimeout(() => {
|
|
6223
|
+
console.error("[Storage WS] Request timed out:", requestId);
|
|
6216
6224
|
this.pendingRequests.delete(requestId);
|
|
6217
6225
|
reject(new Error("Storage request timeout"));
|
|
6218
6226
|
}, options.timeout || 3e4);
|
|
6219
6227
|
this.pendingRequests.set(requestId, { resolve, reject, timeout });
|
|
6220
6228
|
try {
|
|
6229
|
+
console.log("[Storage WS] Sending request to relay, WS state:", this.ws?.readyState);
|
|
6221
6230
|
this.ws.send(JSON.stringify(request));
|
|
6222
|
-
console.log("[Storage WS] Sent storage request:", requestId);
|
|
6231
|
+
console.log("[Storage WS] \u2713 Sent storage request:", requestId);
|
|
6223
6232
|
} catch (error) {
|
|
6233
|
+
console.error("[Storage WS] Failed to send request:", error.message);
|
|
6224
6234
|
clearTimeout(timeout);
|
|
6225
6235
|
this.pendingRequests.delete(requestId);
|
|
6226
6236
|
reject(error);
|
|
@@ -6725,7 +6735,10 @@ Nonce: ${nonce}`;
|
|
|
6725
6735
|
CONTENT_REGISTRY_ABI,
|
|
6726
6736
|
signer
|
|
6727
6737
|
);
|
|
6728
|
-
const
|
|
6738
|
+
const cidBytes32 = "0x" + cid;
|
|
6739
|
+
const appIdBytes32 = import_ethers2.ethers.keccak256(import_ethers2.ethers.toUtf8Bytes(appId));
|
|
6740
|
+
const owner = await signer.getAddress();
|
|
6741
|
+
const tx = await contract.registerContent(cidBytes32, owner, appIdBytes32, hashIdToken);
|
|
6729
6742
|
console.log("[ByteCave] ContentRegistry transaction sent:", tx.hash);
|
|
6730
6743
|
const receipt = await tx.wait();
|
|
6731
6744
|
console.log("[ByteCave] ContentRegistry registration confirmed:", receipt.hash);
|
package/dist/index.js
CHANGED
package/dist/react/index.js
CHANGED
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -589,7 +589,17 @@ Nonce: ${nonce}`;
|
|
|
589
589
|
signer
|
|
590
590
|
);
|
|
591
591
|
|
|
592
|
-
|
|
592
|
+
// Convert CID to bytes32 (CID is already a SHA-256 hash, don't double-hash it)
|
|
593
|
+
const cidBytes32 = '0x' + cid;
|
|
594
|
+
|
|
595
|
+
// Hash appId to bytes32
|
|
596
|
+
const appIdBytes32 = ethers.keccak256(ethers.toUtf8Bytes(appId));
|
|
597
|
+
|
|
598
|
+
// Get signer address for owner parameter
|
|
599
|
+
const owner = await signer.getAddress();
|
|
600
|
+
|
|
601
|
+
// Use bytes32 overload to avoid double-hashing the CID
|
|
602
|
+
const tx = await contract.registerContent(cidBytes32, owner, appIdBytes32, hashIdToken);
|
|
593
603
|
console.log('[ByteCave] ContentRegistry transaction sent:', tx.hash);
|
|
594
604
|
|
|
595
605
|
const receipt = await tx.wait();
|
package/src/storage-websocket.ts
CHANGED
|
@@ -71,14 +71,16 @@ export class StorageWebSocketClient {
|
|
|
71
71
|
|
|
72
72
|
async connect(): Promise<void> {
|
|
73
73
|
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
|
74
|
+
console.log('[Storage WS] Already connected');
|
|
74
75
|
return;
|
|
75
76
|
}
|
|
76
77
|
|
|
78
|
+
console.log('[Storage WS] Connecting to relay:', this.relayUrl);
|
|
77
79
|
return new Promise((resolve, reject) => {
|
|
78
80
|
this.ws = new WebSocket(this.relayUrl);
|
|
79
81
|
|
|
80
82
|
this.ws.onopen = () => {
|
|
81
|
-
console.log('[Storage WS] Connected to relay');
|
|
83
|
+
console.log('[Storage WS] ✓ Connected to relay');
|
|
82
84
|
resolve();
|
|
83
85
|
};
|
|
84
86
|
|
|
@@ -144,13 +146,17 @@ export class StorageWebSocketClient {
|
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
async store(options: StoreViaWebSocketOptions): Promise<{ success: boolean; cid?: string; error?: string }> {
|
|
149
|
+
console.log('[Storage WS] store() called, data size:', options.data.length, 'bytes');
|
|
150
|
+
|
|
147
151
|
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
|
|
152
|
+
console.log('[Storage WS] Not connected, connecting now...');
|
|
148
153
|
await this.connect();
|
|
149
154
|
}
|
|
150
155
|
|
|
151
156
|
const requestId = Math.random().toString(36).substring(2, 15) +
|
|
152
157
|
Math.random().toString(36).substring(2, 15);
|
|
153
158
|
|
|
159
|
+
console.log('[Storage WS] Converting data to base64...');
|
|
154
160
|
// Convert Uint8Array to base64
|
|
155
161
|
// Chunk the data to avoid stack overflow with large files
|
|
156
162
|
const chunkSize = 8192;
|
|
@@ -160,6 +166,7 @@ export class StorageWebSocketClient {
|
|
|
160
166
|
binaryString += String.fromCharCode(...chunk);
|
|
161
167
|
}
|
|
162
168
|
const base64Data = btoa(binaryString);
|
|
169
|
+
console.log('[Storage WS] Base64 data length:', base64Data.length);
|
|
163
170
|
|
|
164
171
|
const request: StorageRequestMessage = {
|
|
165
172
|
type: 'storage-request',
|
|
@@ -170,8 +177,10 @@ export class StorageWebSocketClient {
|
|
|
170
177
|
authorization: options.authorization
|
|
171
178
|
};
|
|
172
179
|
|
|
180
|
+
console.log('[Storage WS] Creating promise for request:', requestId);
|
|
173
181
|
return new Promise((resolve, reject) => {
|
|
174
182
|
const timeout = setTimeout(() => {
|
|
183
|
+
console.error('[Storage WS] Request timed out:', requestId);
|
|
175
184
|
this.pendingRequests.delete(requestId);
|
|
176
185
|
reject(new Error('Storage request timeout'));
|
|
177
186
|
}, options.timeout || 30000);
|
|
@@ -179,9 +188,11 @@ export class StorageWebSocketClient {
|
|
|
179
188
|
this.pendingRequests.set(requestId, { resolve, reject, timeout });
|
|
180
189
|
|
|
181
190
|
try {
|
|
191
|
+
console.log('[Storage WS] Sending request to relay, WS state:', this.ws?.readyState);
|
|
182
192
|
this.ws!.send(JSON.stringify(request));
|
|
183
|
-
console.log('[Storage WS] Sent storage request:', requestId);
|
|
193
|
+
console.log('[Storage WS] ✓ Sent storage request:', requestId);
|
|
184
194
|
} catch (error: any) {
|
|
195
|
+
console.error('[Storage WS] Failed to send request:', error.message);
|
|
185
196
|
clearTimeout(timeout);
|
|
186
197
|
this.pendingRequests.delete(requestId);
|
|
187
198
|
reject(error);
|