@gethashd/bytecave-browser 1.0.36 → 1.0.38
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-6WXUCYSA.js → chunk-CIBPIU23.js} +10 -5
- package/dist/client.d.ts +2 -1
- package/dist/index.cjs +10 -5
- package/dist/index.js +1 -1
- package/dist/p2p-protocols.d.ts +2 -1
- package/dist/provider.d.ts +1 -1
- package/dist/react/index.cjs +2 -1
- package/dist/react/index.js +1 -1
- package/dist/storage-websocket.d.ts +1 -0
- package/package.json +1 -1
- package/src/client.ts +5 -2
- package/src/p2p-protocols.ts +4 -1
- package/src/provider.tsx +3 -3
- package/src/storage-websocket.ts +3 -0
|
@@ -5695,7 +5695,7 @@ var P2PProtocolClient = class {
|
|
|
5695
5695
|
/**
|
|
5696
5696
|
* Store a blob on a peer via P2P stream
|
|
5697
5697
|
*/
|
|
5698
|
-
async storeToPeer(peerId, ciphertext, mimeType, authorization, shouldVerifyOnChain) {
|
|
5698
|
+
async storeToPeer(peerId, ciphertext, mimeType, authorization, shouldVerifyOnChain, hashIdToken) {
|
|
5699
5699
|
if (!this.node) {
|
|
5700
5700
|
return { success: false, error: "P2P node not initialized" };
|
|
5701
5701
|
}
|
|
@@ -5791,6 +5791,7 @@ var P2PProtocolClient = class {
|
|
|
5791
5791
|
shouldVerifyOnChain: shouldVerifyOnChain ?? false,
|
|
5792
5792
|
sender: authorization?.sender,
|
|
5793
5793
|
timestamp: authorization?.timestamp || Date.now(),
|
|
5794
|
+
hashIdToken,
|
|
5794
5795
|
authorization
|
|
5795
5796
|
};
|
|
5796
5797
|
console.log("[ByteCave P2P] Step 5: Request prepared, size:", JSON.stringify(request).length, "bytes");
|
|
@@ -6132,6 +6133,7 @@ var StorageWebSocketClient = class {
|
|
|
6132
6133
|
requestId,
|
|
6133
6134
|
data: base64Data,
|
|
6134
6135
|
contentType: options.contentType,
|
|
6136
|
+
hashIdToken: options.hashIdToken,
|
|
6135
6137
|
authorization: options.authorization
|
|
6136
6138
|
};
|
|
6137
6139
|
return new Promise((resolve, reject) => {
|
|
@@ -6491,8 +6493,9 @@ var ByteCaveClient = class {
|
|
|
6491
6493
|
* @param data - Data to store
|
|
6492
6494
|
* @param mimeType - MIME type (optional, defaults to 'application/octet-stream')
|
|
6493
6495
|
* @param signer - Ethers signer for authorization (optional, but required for most nodes)
|
|
6496
|
+
* @param hashIdToken - HashID NFT token ID (optional, for content attribution)
|
|
6494
6497
|
*/
|
|
6495
|
-
async store(data, mimeType, signer) {
|
|
6498
|
+
async store(data, mimeType, signer, hashIdToken) {
|
|
6496
6499
|
const dataArray = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
|
|
6497
6500
|
const MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
6498
6501
|
if (dataArray.length > MAX_FILE_SIZE) {
|
|
@@ -6548,6 +6551,7 @@ Nonce: ${nonce}`;
|
|
|
6548
6551
|
const result = await this.storageWsClient.store({
|
|
6549
6552
|
data: dataArray,
|
|
6550
6553
|
contentType: mimeType || "application/octet-stream",
|
|
6554
|
+
hashIdToken,
|
|
6551
6555
|
authorization: wsAuth,
|
|
6552
6556
|
timeout: 3e4
|
|
6553
6557
|
});
|
|
@@ -6585,8 +6589,9 @@ Nonce: ${nonce}`;
|
|
|
6585
6589
|
dataArray,
|
|
6586
6590
|
mimeType || "application/octet-stream",
|
|
6587
6591
|
authorization,
|
|
6588
|
-
false
|
|
6592
|
+
false,
|
|
6589
6593
|
// shouldVerifyOnChain - false for browser test storage
|
|
6594
|
+
hashIdToken
|
|
6590
6595
|
);
|
|
6591
6596
|
if (result.success && result.cid) {
|
|
6592
6597
|
console.log("[ByteCave] \u2713 P2P store successful:", result.cid);
|
|
@@ -7087,11 +7092,11 @@ function ByteCaveProvider({
|
|
|
7087
7092
|
setError(err.message);
|
|
7088
7093
|
}
|
|
7089
7094
|
};
|
|
7090
|
-
const store = async (data, mimeType, signer) => {
|
|
7095
|
+
const store = async (data, mimeType, signer, hashIdToken) => {
|
|
7091
7096
|
if (!globalClient) {
|
|
7092
7097
|
return { success: false, error: "Client not initialized" };
|
|
7093
7098
|
}
|
|
7094
|
-
return globalClient.store(data, mimeType, signer);
|
|
7099
|
+
return globalClient.store(data, mimeType, signer, hashIdToken);
|
|
7095
7100
|
};
|
|
7096
7101
|
const retrieve = async (cid) => {
|
|
7097
7102
|
if (!globalClient) {
|
package/dist/client.d.ts
CHANGED
|
@@ -35,8 +35,9 @@ export declare class ByteCaveClient {
|
|
|
35
35
|
* @param data - Data to store
|
|
36
36
|
* @param mimeType - MIME type (optional, defaults to 'application/octet-stream')
|
|
37
37
|
* @param signer - Ethers signer for authorization (optional, but required for most nodes)
|
|
38
|
+
* @param hashIdToken - HashID NFT token ID (optional, for content attribution)
|
|
38
39
|
*/
|
|
39
|
-
store(data: Uint8Array | ArrayBuffer, mimeType?: string, signer?: any): Promise<StoreResult>;
|
|
40
|
+
store(data: Uint8Array | ArrayBuffer, mimeType?: string, signer?: any, hashIdToken?: number): Promise<StoreResult>;
|
|
40
41
|
/**
|
|
41
42
|
* Retrieve ciphertext from a node via P2P only (no HTTP fallback)
|
|
42
43
|
*/
|
package/dist/index.cjs
CHANGED
|
@@ -5763,7 +5763,7 @@ var P2PProtocolClient = class {
|
|
|
5763
5763
|
/**
|
|
5764
5764
|
* Store a blob on a peer via P2P stream
|
|
5765
5765
|
*/
|
|
5766
|
-
async storeToPeer(peerId, ciphertext, mimeType, authorization, shouldVerifyOnChain) {
|
|
5766
|
+
async storeToPeer(peerId, ciphertext, mimeType, authorization, shouldVerifyOnChain, hashIdToken) {
|
|
5767
5767
|
if (!this.node) {
|
|
5768
5768
|
return { success: false, error: "P2P node not initialized" };
|
|
5769
5769
|
}
|
|
@@ -5859,6 +5859,7 @@ var P2PProtocolClient = class {
|
|
|
5859
5859
|
shouldVerifyOnChain: shouldVerifyOnChain ?? false,
|
|
5860
5860
|
sender: authorization?.sender,
|
|
5861
5861
|
timestamp: authorization?.timestamp || Date.now(),
|
|
5862
|
+
hashIdToken,
|
|
5862
5863
|
authorization
|
|
5863
5864
|
};
|
|
5864
5865
|
console.log("[ByteCave P2P] Step 5: Request prepared, size:", JSON.stringify(request).length, "bytes");
|
|
@@ -6185,6 +6186,7 @@ var StorageWebSocketClient = class {
|
|
|
6185
6186
|
requestId,
|
|
6186
6187
|
data: base64Data,
|
|
6187
6188
|
contentType: options.contentType,
|
|
6189
|
+
hashIdToken: options.hashIdToken,
|
|
6188
6190
|
authorization: options.authorization
|
|
6189
6191
|
};
|
|
6190
6192
|
return new Promise((resolve, reject) => {
|
|
@@ -6544,8 +6546,9 @@ var ByteCaveClient = class {
|
|
|
6544
6546
|
* @param data - Data to store
|
|
6545
6547
|
* @param mimeType - MIME type (optional, defaults to 'application/octet-stream')
|
|
6546
6548
|
* @param signer - Ethers signer for authorization (optional, but required for most nodes)
|
|
6549
|
+
* @param hashIdToken - HashID NFT token ID (optional, for content attribution)
|
|
6547
6550
|
*/
|
|
6548
|
-
async store(data, mimeType, signer) {
|
|
6551
|
+
async store(data, mimeType, signer, hashIdToken) {
|
|
6549
6552
|
const dataArray = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
|
|
6550
6553
|
const MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
6551
6554
|
if (dataArray.length > MAX_FILE_SIZE) {
|
|
@@ -6601,6 +6604,7 @@ Nonce: ${nonce}`;
|
|
|
6601
6604
|
const result = await this.storageWsClient.store({
|
|
6602
6605
|
data: dataArray,
|
|
6603
6606
|
contentType: mimeType || "application/octet-stream",
|
|
6607
|
+
hashIdToken,
|
|
6604
6608
|
authorization: wsAuth,
|
|
6605
6609
|
timeout: 3e4
|
|
6606
6610
|
});
|
|
@@ -6638,8 +6642,9 @@ Nonce: ${nonce}`;
|
|
|
6638
6642
|
dataArray,
|
|
6639
6643
|
mimeType || "application/octet-stream",
|
|
6640
6644
|
authorization,
|
|
6641
|
-
false
|
|
6645
|
+
false,
|
|
6642
6646
|
// shouldVerifyOnChain - false for browser test storage
|
|
6647
|
+
hashIdToken
|
|
6643
6648
|
);
|
|
6644
6649
|
if (result.success && result.cid) {
|
|
6645
6650
|
console.log("[ByteCave] \u2713 P2P store successful:", result.cid);
|
|
@@ -7140,11 +7145,11 @@ function ByteCaveProvider({
|
|
|
7140
7145
|
setError(err.message);
|
|
7141
7146
|
}
|
|
7142
7147
|
};
|
|
7143
|
-
const store = async (data, mimeType, signer) => {
|
|
7148
|
+
const store = async (data, mimeType, signer, hashIdToken) => {
|
|
7144
7149
|
if (!globalClient) {
|
|
7145
7150
|
return { success: false, error: "Client not initialized" };
|
|
7146
7151
|
}
|
|
7147
|
-
return globalClient.store(data, mimeType, signer);
|
|
7152
|
+
return globalClient.store(data, mimeType, signer, hashIdToken);
|
|
7148
7153
|
};
|
|
7149
7154
|
const retrieve = async (cid) => {
|
|
7150
7155
|
if (!globalClient) {
|
package/dist/index.js
CHANGED
package/dist/p2p-protocols.d.ts
CHANGED
|
@@ -65,6 +65,7 @@ export interface StoreRequest {
|
|
|
65
65
|
shouldVerifyOnChain?: boolean;
|
|
66
66
|
sender?: string;
|
|
67
67
|
timestamp?: number;
|
|
68
|
+
hashIdToken?: number;
|
|
68
69
|
metadata?: Record<string, any>;
|
|
69
70
|
authorization?: any;
|
|
70
71
|
}
|
|
@@ -82,7 +83,7 @@ export declare class P2PProtocolClient {
|
|
|
82
83
|
/**
|
|
83
84
|
* Store a blob on a peer via P2P stream
|
|
84
85
|
*/
|
|
85
|
-
storeToPeer(peerId: string, ciphertext: Uint8Array, mimeType: string, authorization?: any, shouldVerifyOnChain?: boolean): Promise<StoreResponse>;
|
|
86
|
+
storeToPeer(peerId: string, ciphertext: Uint8Array, mimeType: string, authorization?: any, shouldVerifyOnChain?: boolean, hashIdToken?: number): Promise<StoreResponse>;
|
|
86
87
|
/**
|
|
87
88
|
* Retrieve a blob from a peer via P2P stream
|
|
88
89
|
*/
|
package/dist/provider.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ interface ByteCaveContextValue {
|
|
|
35
35
|
appId: string;
|
|
36
36
|
connect: () => Promise<void>;
|
|
37
37
|
disconnect: () => Promise<void>;
|
|
38
|
-
store: (data: Uint8Array, mimeType?: string, signer?: any) => Promise<StoreResult>;
|
|
38
|
+
store: (data: Uint8Array, mimeType?: string, signer?: any, hashIdToken?: number) => Promise<StoreResult>;
|
|
39
39
|
retrieve: (cid: string) => Promise<RetrieveResult>;
|
|
40
40
|
registerContent: (cid: string, appId: string, hashIdToken: string, signer: any) => Promise<{
|
|
41
41
|
success: boolean;
|
package/dist/react/index.cjs
CHANGED
|
@@ -6018,7 +6018,7 @@ var P2PProtocolClient = class {
|
|
|
6018
6018
|
/**
|
|
6019
6019
|
* Store a blob on a peer via P2P stream
|
|
6020
6020
|
*/
|
|
6021
|
-
async storeToPeer(peerId, ciphertext, mimeType, authorization, shouldVerifyOnChain) {
|
|
6021
|
+
async storeToPeer(peerId, ciphertext, mimeType, authorization, shouldVerifyOnChain, hashIdToken) {
|
|
6022
6022
|
if (!this.node) {
|
|
6023
6023
|
return { success: false, error: "P2P node not initialized" };
|
|
6024
6024
|
}
|
|
@@ -6114,6 +6114,7 @@ var P2PProtocolClient = class {
|
|
|
6114
6114
|
shouldVerifyOnChain: shouldVerifyOnChain ?? false,
|
|
6115
6115
|
sender: authorization?.sender,
|
|
6116
6116
|
timestamp: authorization?.timestamp || Date.now(),
|
|
6117
|
+
hashIdToken,
|
|
6117
6118
|
authorization
|
|
6118
6119
|
};
|
|
6119
6120
|
console.log("[ByteCave P2P] Step 5: Request prepared, size:", JSON.stringify(request).length, "bytes");
|
package/dist/react/index.js
CHANGED
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -423,8 +423,9 @@ export class ByteCaveClient {
|
|
|
423
423
|
* @param data - Data to store
|
|
424
424
|
* @param mimeType - MIME type (optional, defaults to 'application/octet-stream')
|
|
425
425
|
* @param signer - Ethers signer for authorization (optional, but required for most nodes)
|
|
426
|
+
* @param hashIdToken - HashID NFT token ID (optional, for content attribution)
|
|
426
427
|
*/
|
|
427
|
-
async store(data: Uint8Array | ArrayBuffer, mimeType?: string, signer?: any): Promise<StoreResult> {
|
|
428
|
+
async store(data: Uint8Array | ArrayBuffer, mimeType?: string, signer?: any, hashIdToken?: number): Promise<StoreResult> {
|
|
428
429
|
const dataArray = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
|
|
429
430
|
|
|
430
431
|
// Validate file size (5MB limit)
|
|
@@ -496,6 +497,7 @@ Nonce: ${nonce}`;
|
|
|
496
497
|
const result = await this.storageWsClient.store({
|
|
497
498
|
data: dataArray,
|
|
498
499
|
contentType: mimeType || 'application/octet-stream',
|
|
500
|
+
hashIdToken,
|
|
499
501
|
authorization: wsAuth,
|
|
500
502
|
timeout: 30000
|
|
501
503
|
});
|
|
@@ -551,7 +553,8 @@ Nonce: ${nonce}`;
|
|
|
551
553
|
dataArray,
|
|
552
554
|
mimeType || 'application/octet-stream',
|
|
553
555
|
authorization,
|
|
554
|
-
false // shouldVerifyOnChain - false for browser test storage
|
|
556
|
+
false, // shouldVerifyOnChain - false for browser test storage
|
|
557
|
+
hashIdToken
|
|
555
558
|
);
|
|
556
559
|
|
|
557
560
|
if (result.success && result.cid) {
|
package/src/p2p-protocols.ts
CHANGED
|
@@ -78,6 +78,7 @@ export interface StoreRequest {
|
|
|
78
78
|
shouldVerifyOnChain?: boolean;
|
|
79
79
|
sender?: string;
|
|
80
80
|
timestamp?: number;
|
|
81
|
+
hashIdToken?: number;
|
|
81
82
|
metadata?: Record<string, any>;
|
|
82
83
|
authorization?: any;
|
|
83
84
|
}
|
|
@@ -106,7 +107,8 @@ export class P2PProtocolClient {
|
|
|
106
107
|
ciphertext: Uint8Array,
|
|
107
108
|
mimeType: string,
|
|
108
109
|
authorization?: any,
|
|
109
|
-
shouldVerifyOnChain?: boolean
|
|
110
|
+
shouldVerifyOnChain?: boolean,
|
|
111
|
+
hashIdToken?: number
|
|
110
112
|
): Promise<StoreResponse> {
|
|
111
113
|
if (!this.node) {
|
|
112
114
|
return { success: false, error: 'P2P node not initialized' };
|
|
@@ -227,6 +229,7 @@ export class P2PProtocolClient {
|
|
|
227
229
|
shouldVerifyOnChain: shouldVerifyOnChain ?? false,
|
|
228
230
|
sender: authorization?.sender,
|
|
229
231
|
timestamp: authorization?.timestamp || Date.now(),
|
|
232
|
+
hashIdToken,
|
|
230
233
|
authorization
|
|
231
234
|
};
|
|
232
235
|
console.log('[ByteCave P2P] Step 5: Request prepared, size:', JSON.stringify(request).length, 'bytes');
|
package/src/provider.tsx
CHANGED
|
@@ -39,7 +39,7 @@ interface ByteCaveContextValue {
|
|
|
39
39
|
appId: string;
|
|
40
40
|
connect: () => Promise<void>;
|
|
41
41
|
disconnect: () => Promise<void>;
|
|
42
|
-
store: (data: Uint8Array, mimeType?: string, signer?: any) => Promise<StoreResult>;
|
|
42
|
+
store: (data: Uint8Array, mimeType?: string, signer?: any, hashIdToken?: number) => Promise<StoreResult>;
|
|
43
43
|
retrieve: (cid: string) => Promise<RetrieveResult>;
|
|
44
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>;
|
|
@@ -224,11 +224,11 @@ export function ByteCaveProvider({
|
|
|
224
224
|
}
|
|
225
225
|
};
|
|
226
226
|
|
|
227
|
-
const store = async (data: Uint8Array, mimeType?: string, signer?: any): Promise<StoreResult> => {
|
|
227
|
+
const store = async (data: Uint8Array, mimeType?: string, signer?: any, hashIdToken?: number): Promise<StoreResult> => {
|
|
228
228
|
if (!globalClient) {
|
|
229
229
|
return { success: false, error: 'Client not initialized' };
|
|
230
230
|
}
|
|
231
|
-
return (globalClient as any).store(data, mimeType, signer);
|
|
231
|
+
return (globalClient as any).store(data, mimeType, signer, hashIdToken);
|
|
232
232
|
};
|
|
233
233
|
|
|
234
234
|
const retrieve = async (cid: string): Promise<RetrieveResult> => {
|
package/src/storage-websocket.ts
CHANGED
|
@@ -8,6 +8,7 @@ interface StorageRequestMessage {
|
|
|
8
8
|
requestId: string;
|
|
9
9
|
data: string; // base64
|
|
10
10
|
contentType: string;
|
|
11
|
+
hashIdToken?: number;
|
|
11
12
|
authorization?: {
|
|
12
13
|
signature: string;
|
|
13
14
|
address: string;
|
|
@@ -31,6 +32,7 @@ type Message = StorageRequestMessage | StorageResponseMessage;
|
|
|
31
32
|
export interface StoreViaWebSocketOptions {
|
|
32
33
|
data: Uint8Array;
|
|
33
34
|
contentType: string;
|
|
35
|
+
hashIdToken?: number;
|
|
34
36
|
authorization?: {
|
|
35
37
|
signature: string;
|
|
36
38
|
address: string;
|
|
@@ -124,6 +126,7 @@ export class StorageWebSocketClient {
|
|
|
124
126
|
requestId,
|
|
125
127
|
data: base64Data,
|
|
126
128
|
contentType: options.contentType,
|
|
129
|
+
hashIdToken: options.hashIdToken,
|
|
127
130
|
authorization: options.authorization
|
|
128
131
|
};
|
|
129
132
|
|