@gethashd/bytecave-browser 1.0.33 → 1.0.35
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.
|
@@ -6507,7 +6507,9 @@ var ByteCaveClient = class {
|
|
|
6507
6507
|
try {
|
|
6508
6508
|
const { ethers: ethers3 } = await import("ethers");
|
|
6509
6509
|
const sender = await signer.getAddress();
|
|
6510
|
-
const
|
|
6510
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", dataArray);
|
|
6511
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
6512
|
+
const contentHash = "0x" + hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
6511
6513
|
const timestamp = Date.now();
|
|
6512
6514
|
const nonce = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
6513
6515
|
const message2 = `ByteCave Storage Request for:
|
|
@@ -6539,7 +6541,9 @@ Nonce: ${nonce}`;
|
|
|
6539
6541
|
signature: authorization.signature,
|
|
6540
6542
|
address: authorization.sender,
|
|
6541
6543
|
timestamp: authorization.timestamp,
|
|
6542
|
-
nonce: authorization.nonce
|
|
6544
|
+
nonce: authorization.nonce,
|
|
6545
|
+
appId: authorization.appId,
|
|
6546
|
+
contentHash: authorization.contentHash
|
|
6543
6547
|
} : void 0;
|
|
6544
6548
|
const result = await this.storageWsClient.store({
|
|
6545
6549
|
data: dataArray,
|
package/dist/index.cjs
CHANGED
|
@@ -6560,7 +6560,9 @@ var ByteCaveClient = class {
|
|
|
6560
6560
|
try {
|
|
6561
6561
|
const { ethers: ethers3 } = await import("ethers");
|
|
6562
6562
|
const sender = await signer.getAddress();
|
|
6563
|
-
const
|
|
6563
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", dataArray);
|
|
6564
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
6565
|
+
const contentHash = "0x" + hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
6564
6566
|
const timestamp = Date.now();
|
|
6565
6567
|
const nonce = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
6566
6568
|
const message2 = `ByteCave Storage Request for:
|
|
@@ -6592,7 +6594,9 @@ Nonce: ${nonce}`;
|
|
|
6592
6594
|
signature: authorization.signature,
|
|
6593
6595
|
address: authorization.sender,
|
|
6594
6596
|
timestamp: authorization.timestamp,
|
|
6595
|
-
nonce: authorization.nonce
|
|
6597
|
+
nonce: authorization.nonce,
|
|
6598
|
+
appId: authorization.appId,
|
|
6599
|
+
contentHash: authorization.contentHash
|
|
6596
6600
|
} : void 0;
|
|
6597
6601
|
const result = await this.storageWsClient.store({
|
|
6598
6602
|
data: dataArray,
|
package/dist/index.js
CHANGED
package/dist/react/index.js
CHANGED
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -445,7 +445,10 @@ export class ByteCaveClient {
|
|
|
445
445
|
const { ethers } = await import('ethers');
|
|
446
446
|
|
|
447
447
|
const sender = await signer.getAddress();
|
|
448
|
-
|
|
448
|
+
// Use SHA-256 to match what the node calculates
|
|
449
|
+
const hashBuffer = await crypto.subtle.digest('SHA-256', dataArray as BufferSource);
|
|
450
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
451
|
+
const contentHash = '0x' + hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
|
449
452
|
const timestamp = Date.now();
|
|
450
453
|
const nonce = Math.random().toString(36).substring(2, 15) +
|
|
451
454
|
Math.random().toString(36).substring(2, 15);
|
|
@@ -485,7 +488,9 @@ Nonce: ${nonce}`;
|
|
|
485
488
|
signature: authorization.signature,
|
|
486
489
|
address: authorization.sender,
|
|
487
490
|
timestamp: authorization.timestamp,
|
|
488
|
-
nonce: authorization.nonce
|
|
491
|
+
nonce: authorization.nonce,
|
|
492
|
+
appId: authorization.appId,
|
|
493
|
+
contentHash: authorization.contentHash
|
|
489
494
|
} : undefined;
|
|
490
495
|
|
|
491
496
|
const result = await this.storageWsClient.store({
|
package/src/storage-websocket.ts
CHANGED
|
@@ -13,6 +13,8 @@ interface StorageRequestMessage {
|
|
|
13
13
|
address: string;
|
|
14
14
|
timestamp: number;
|
|
15
15
|
nonce: string;
|
|
16
|
+
appId: string;
|
|
17
|
+
contentHash: string;
|
|
16
18
|
};
|
|
17
19
|
}
|
|
18
20
|
|
|
@@ -34,6 +36,8 @@ export interface StoreViaWebSocketOptions {
|
|
|
34
36
|
address: string;
|
|
35
37
|
timestamp: number;
|
|
36
38
|
nonce: string;
|
|
39
|
+
appId: string;
|
|
40
|
+
contentHash: string;
|
|
37
41
|
};
|
|
38
42
|
timeout?: number;
|
|
39
43
|
}
|