@gethashd/bytecave-browser 1.0.34 → 1.0.36
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-EDVNOZ7Q.js → chunk-6WXUCYSA.js} +9 -7
- package/dist/client.d.ts +1 -1
- package/dist/contracts/ContentRegistry.d.ts +1 -1
- package/dist/index.cjs +9 -7
- package/dist/index.js +1 -1
- package/dist/provider.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/package.json +1 -1
- package/src/client.ts +6 -2
- package/src/contracts/ContentRegistry.ts +2 -2
- package/src/provider.tsx +3 -3
|
@@ -6168,8 +6168,8 @@ var StorageWebSocketClient = class {
|
|
|
6168
6168
|
|
|
6169
6169
|
// src/contracts/ContentRegistry.ts
|
|
6170
6170
|
var CONTENT_REGISTRY_ABI = [
|
|
6171
|
-
"function registerContent(bytes32 cid, address owner, bytes32 appId) external",
|
|
6172
|
-
"function registerContent(string cid, string appId) external",
|
|
6171
|
+
"function registerContent(bytes32 cid, address owner, bytes32 appId, uint256 hashIdToken) external",
|
|
6172
|
+
"function registerContent(string cid, string appId, uint256 hashIdToken) external",
|
|
6173
6173
|
"function isContentRegistered(bytes32 cid) external view returns (bool)",
|
|
6174
6174
|
"function getContentRecord(bytes32 cid) external view returns (tuple(address owner, bytes32 appId, uint256 timestamp))"
|
|
6175
6175
|
];
|
|
@@ -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:
|
|
@@ -6657,7 +6659,7 @@ Nonce: ${nonce}`;
|
|
|
6657
6659
|
* Register content in ContentRegistry contract (on-chain)
|
|
6658
6660
|
* This must be called before storing content that requires on-chain verification
|
|
6659
6661
|
*/
|
|
6660
|
-
async registerContent(cid, appId, signer) {
|
|
6662
|
+
async registerContent(cid, appId, hashIdToken, signer) {
|
|
6661
6663
|
if (!this.config.contentRegistryAddress) {
|
|
6662
6664
|
return {
|
|
6663
6665
|
success: false,
|
|
@@ -6677,7 +6679,7 @@ Nonce: ${nonce}`;
|
|
|
6677
6679
|
CONTENT_REGISTRY_ABI,
|
|
6678
6680
|
signer
|
|
6679
6681
|
);
|
|
6680
|
-
const tx = await contract.registerContent(cid, appId);
|
|
6682
|
+
const tx = await contract.registerContent(cid, appId, hashIdToken);
|
|
6681
6683
|
console.log("[ByteCave] ContentRegistry transaction sent:", tx.hash);
|
|
6682
6684
|
const receipt = await tx.wait();
|
|
6683
6685
|
console.log("[ByteCave] ContentRegistry registration confirmed:", receipt.hash);
|
|
@@ -7103,11 +7105,11 @@ function ByteCaveProvider({
|
|
|
7103
7105
|
}
|
|
7104
7106
|
return globalClient.getNodeHealth(peerId);
|
|
7105
7107
|
};
|
|
7106
|
-
const registerContent = async (cid, appId2, signer) => {
|
|
7108
|
+
const registerContent = async (cid, appId2, hashIdToken, signer) => {
|
|
7107
7109
|
if (!globalClient) {
|
|
7108
7110
|
return { success: false, error: "Client not initialized" };
|
|
7109
7111
|
}
|
|
7110
|
-
return globalClient.registerContent(cid, appId2, signer);
|
|
7112
|
+
return globalClient.registerContent(cid, appId2, hashIdToken, signer);
|
|
7111
7113
|
};
|
|
7112
7114
|
const value = {
|
|
7113
7115
|
connectionState,
|
package/dist/client.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export declare class ByteCaveClient {
|
|
|
45
45
|
* Register content in ContentRegistry contract (on-chain)
|
|
46
46
|
* This must be called before storing content that requires on-chain verification
|
|
47
47
|
*/
|
|
48
|
-
registerContent(cid: string, appId: string, signer: ethers.Signer): Promise<{
|
|
48
|
+
registerContent(cid: string, appId: string, hashIdToken: string, signer: ethers.Signer): Promise<{
|
|
49
49
|
success: boolean;
|
|
50
50
|
txHash?: string;
|
|
51
51
|
error?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const CONTENT_REGISTRY_ABI: readonly ["function registerContent(bytes32 cid, address owner, bytes32 appId) external", "function registerContent(string cid, string appId) external", "function isContentRegistered(bytes32 cid) external view returns (bool)", "function getContentRecord(bytes32 cid) external view returns (tuple(address owner, bytes32 appId, uint256 timestamp))"];
|
|
1
|
+
export declare const CONTENT_REGISTRY_ABI: readonly ["function registerContent(bytes32 cid, address owner, bytes32 appId, uint256 hashIdToken) external", "function registerContent(string cid, string appId, uint256 hashIdToken) external", "function isContentRegistered(bytes32 cid) external view returns (bool)", "function getContentRecord(bytes32 cid) external view returns (tuple(address owner, bytes32 appId, uint256 timestamp))"];
|
package/dist/index.cjs
CHANGED
|
@@ -6221,8 +6221,8 @@ var StorageWebSocketClient = class {
|
|
|
6221
6221
|
|
|
6222
6222
|
// src/contracts/ContentRegistry.ts
|
|
6223
6223
|
var CONTENT_REGISTRY_ABI = [
|
|
6224
|
-
"function registerContent(bytes32 cid, address owner, bytes32 appId) external",
|
|
6225
|
-
"function registerContent(string cid, string appId) external",
|
|
6224
|
+
"function registerContent(bytes32 cid, address owner, bytes32 appId, uint256 hashIdToken) external",
|
|
6225
|
+
"function registerContent(string cid, string appId, uint256 hashIdToken) external",
|
|
6226
6226
|
"function isContentRegistered(bytes32 cid) external view returns (bool)",
|
|
6227
6227
|
"function getContentRecord(bytes32 cid) external view returns (tuple(address owner, bytes32 appId, uint256 timestamp))"
|
|
6228
6228
|
];
|
|
@@ -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:
|
|
@@ -6710,7 +6712,7 @@ Nonce: ${nonce}`;
|
|
|
6710
6712
|
* Register content in ContentRegistry contract (on-chain)
|
|
6711
6713
|
* This must be called before storing content that requires on-chain verification
|
|
6712
6714
|
*/
|
|
6713
|
-
async registerContent(cid, appId, signer) {
|
|
6715
|
+
async registerContent(cid, appId, hashIdToken, signer) {
|
|
6714
6716
|
if (!this.config.contentRegistryAddress) {
|
|
6715
6717
|
return {
|
|
6716
6718
|
success: false,
|
|
@@ -6730,7 +6732,7 @@ Nonce: ${nonce}`;
|
|
|
6730
6732
|
CONTENT_REGISTRY_ABI,
|
|
6731
6733
|
signer
|
|
6732
6734
|
);
|
|
6733
|
-
const tx = await contract.registerContent(cid, appId);
|
|
6735
|
+
const tx = await contract.registerContent(cid, appId, hashIdToken);
|
|
6734
6736
|
console.log("[ByteCave] ContentRegistry transaction sent:", tx.hash);
|
|
6735
6737
|
const receipt = await tx.wait();
|
|
6736
6738
|
console.log("[ByteCave] ContentRegistry registration confirmed:", receipt.hash);
|
|
@@ -7156,11 +7158,11 @@ function ByteCaveProvider({
|
|
|
7156
7158
|
}
|
|
7157
7159
|
return globalClient.getNodeHealth(peerId);
|
|
7158
7160
|
};
|
|
7159
|
-
const registerContent = async (cid, appId2, signer) => {
|
|
7161
|
+
const registerContent = async (cid, appId2, hashIdToken, signer) => {
|
|
7160
7162
|
if (!globalClient) {
|
|
7161
7163
|
return { success: false, error: "Client not initialized" };
|
|
7162
7164
|
}
|
|
7163
|
-
return globalClient.registerContent(cid, appId2, signer);
|
|
7165
|
+
return globalClient.registerContent(cid, appId2, hashIdToken, signer);
|
|
7164
7166
|
};
|
|
7165
7167
|
const value = {
|
|
7166
7168
|
connectionState,
|
package/dist/index.js
CHANGED
package/dist/provider.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ interface ByteCaveContextValue {
|
|
|
37
37
|
disconnect: () => Promise<void>;
|
|
38
38
|
store: (data: Uint8Array, mimeType?: string, signer?: any) => Promise<StoreResult>;
|
|
39
39
|
retrieve: (cid: string) => Promise<RetrieveResult>;
|
|
40
|
-
registerContent: (cid: string, appId: string, signer: any) => Promise<{
|
|
40
|
+
registerContent: (cid: string, appId: string, hashIdToken: string, signer: any) => Promise<{
|
|
41
41
|
success: boolean;
|
|
42
42
|
txHash?: string;
|
|
43
43
|
error?: string;
|
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);
|
|
@@ -644,6 +647,7 @@ Nonce: ${nonce}`;
|
|
|
644
647
|
async registerContent(
|
|
645
648
|
cid: string,
|
|
646
649
|
appId: string,
|
|
650
|
+
hashIdToken: string,
|
|
647
651
|
signer: ethers.Signer
|
|
648
652
|
): Promise<{ success: boolean; txHash?: string; error?: string }> {
|
|
649
653
|
if (!this.config.contentRegistryAddress) {
|
|
@@ -669,7 +673,7 @@ Nonce: ${nonce}`;
|
|
|
669
673
|
signer
|
|
670
674
|
);
|
|
671
675
|
|
|
672
|
-
const tx = await contract.registerContent(cid, appId);
|
|
676
|
+
const tx = await contract.registerContent(cid, appId, hashIdToken);
|
|
673
677
|
console.log('[ByteCave] ContentRegistry transaction sent:', tx.hash);
|
|
674
678
|
|
|
675
679
|
const receipt = await tx.wait();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const CONTENT_REGISTRY_ABI = [
|
|
2
|
-
"function registerContent(bytes32 cid, address owner, bytes32 appId) external",
|
|
3
|
-
"function registerContent(string cid, string appId) external",
|
|
2
|
+
"function registerContent(bytes32 cid, address owner, bytes32 appId, uint256 hashIdToken) external",
|
|
3
|
+
"function registerContent(string cid, string appId, uint256 hashIdToken) external",
|
|
4
4
|
"function isContentRegistered(bytes32 cid) external view returns (bool)",
|
|
5
5
|
"function getContentRecord(bytes32 cid) external view returns (tuple(address owner, bytes32 appId, uint256 timestamp))"
|
|
6
6
|
] as const;
|
package/src/provider.tsx
CHANGED
|
@@ -41,7 +41,7 @@ interface ByteCaveContextValue {
|
|
|
41
41
|
disconnect: () => Promise<void>;
|
|
42
42
|
store: (data: Uint8Array, mimeType?: string, signer?: any) => Promise<StoreResult>;
|
|
43
43
|
retrieve: (cid: string) => Promise<RetrieveResult>;
|
|
44
|
-
registerContent: (cid: string, appId: string, signer: any) => Promise<{ success: boolean; txHash?: string; error?: string }>;
|
|
44
|
+
registerContent: (cid: string, appId: string, hashIdToken: string, signer: any) => Promise<{ success: boolean; txHash?: string; error?: string }>;
|
|
45
45
|
getNodeHealth: (peerId: string) => Promise<NodeHealth | null>;
|
|
46
46
|
error: string | null;
|
|
47
47
|
}
|
|
@@ -245,11 +245,11 @@ export function ByteCaveProvider({
|
|
|
245
245
|
return (globalClient as any).getNodeHealth(peerId);
|
|
246
246
|
};
|
|
247
247
|
|
|
248
|
-
const registerContent = async (cid: string, appId: string, signer: any): Promise<{ success: boolean; txHash?: string; error?: string }> => {
|
|
248
|
+
const registerContent = async (cid: string, appId: string, hashIdToken: string, signer: any): Promise<{ success: boolean; txHash?: string; error?: string }> => {
|
|
249
249
|
if (!globalClient) {
|
|
250
250
|
return { success: false, error: 'Client not initialized' };
|
|
251
251
|
}
|
|
252
|
-
return globalClient.registerContent(cid, appId, signer);
|
|
252
|
+
return globalClient.registerContent(cid, appId, hashIdToken, signer);
|
|
253
253
|
};
|
|
254
254
|
|
|
255
255
|
const value: ByteCaveContextValue = {
|