gun-eth 2.0.0 → 3.0.0
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/README.md +386 -18
- package/dist/gun-eth.bundle.js +6806 -0
- package/dist/gun-eth.cjs +2465 -0
- package/dist/types/browser.d.ts +6 -0
- package/dist/types/config/local.d.ts +7 -0
- package/dist/types/constants/abis.d.ts +37 -0
- package/dist/types/constants/index.d.ts +1 -0
- package/dist/types/core/gun-eth.d.ts +419 -0
- package/dist/types/features/bubbles/client/bubble-client.d.ts +184 -0
- package/dist/types/features/bubbles/providers/base-bubble-provider.d.ts +303 -0
- package/dist/types/features/bubbles/providers/gun-bubble-provider.d.ts +173 -0
- package/dist/types/features/bubbles/providers/hybrid-bubble-provider.d.ts +124 -0
- package/dist/types/features/proof/ProofChain.d.ts +225 -0
- package/dist/types/features/stealth/StealthChain.d.ts +200 -0
- package/dist/types/index.d.ts +61 -0
- package/dist/types/utils/common.d.ts +11 -0
- package/dist/types/utils/encryption.d.ts +32 -0
- package/package.json +110 -26
- package/dist/gun-eth-protocol.cjs.js +0 -11528
- package/dist/gun-eth-protocol.esm.js +0 -11503
- package/dist/gun-eth-protocol.js +0 -18
- package/dist/gun-eth-protocol.react.js +0 -11503
- package/dist/gun-eth-protocol.umd.js +0 -18
- package/jsdoc.json +0 -7
- package/rollup.config.js +0 -80
- package/src/index.js +0 -181
- package/src/lib/authentication/index.js +0 -13
- package/src/lib/authentication/isAuthenticated.js +0 -20
- package/src/lib/authentication/login.js +0 -25
- package/src/lib/authentication/register.js +0 -58
- package/src/lib/blockchain/abis/SHINE.json +0 -262
- package/src/lib/blockchain/contracts/SHINE.sol +0 -52
- package/src/lib/blockchain/ethereum.js +0 -74
- package/src/lib/blockchain/shine.js +0 -204
- package/src/lib/certificates/friendsCertificates.js +0 -92
- package/src/lib/certificates/index.js +0 -44
- package/src/lib/certificates/messagingCertificates.js +0 -94
- package/src/lib/friends/acceptFriendRequest.js +0 -69
- package/src/lib/friends/addFriendRequest.js +0 -49
- package/src/lib/friends/friendRequests.js +0 -51
- package/src/lib/friends/friendsList.js +0 -57
- package/src/lib/friends/index.js +0 -36
- package/src/lib/friends/rejectFriendRequest.js +0 -31
- package/src/lib/messaging/chatsList.js +0 -42
- package/src/lib/messaging/createChat.js +0 -132
- package/src/lib/messaging/index.js +0 -36
- package/src/lib/messaging/messageList.js +0 -106
- package/src/lib/messaging/sendMessage.js +0 -132
- package/src/lib/messaging/sendVoiceMessage.js +0 -119
- package/src/lib/notes/createNote.js +0 -41
- package/src/lib/notes/deleteNote.js +0 -12
- package/src/lib/notes/getNote.js +0 -25
- package/src/lib/notes/getUserNote.js +0 -59
- package/src/lib/notes/index.js +0 -8
- package/src/lib/notes/updateNotes.js +0 -35
- package/src/lib/post/createPost.js +0 -17
- package/src/lib/post/decryptPost.js +0 -14
- package/src/lib/post/deletePost.js +0 -13
- package/src/lib/post/encryptPost,js +0 -16
- package/src/lib/post/getPost.js +0 -36
- package/src/lib/post/index.js +0 -9
- package/src/lib/post/updatePost.js +0 -16
- package/src/state/gun.js +0 -33
- package/types/types.d.ts +0 -244
@@ -0,0 +1,303 @@
|
|
1
|
+
/**
|
2
|
+
* @typedef {Object} BubbleProviderOptions
|
3
|
+
* @property {string} rpcUrl - RPC URL for the provider
|
4
|
+
* @property {string} chain - Chain name (e.g. 'localhost', 'optimismSepolia')
|
5
|
+
* @property {Object} gun - Gun instance
|
6
|
+
* @property {Object} keypair - Keypair for encryption
|
7
|
+
* @property {string} keypair.epub - Public encryption key
|
8
|
+
* @property {string} keypair.epriv - Private encryption key
|
9
|
+
* @property {string} [contractAddress] - Optional custom contract address
|
10
|
+
* @property {Object} [contractAbi] - Optional custom contract ABI
|
11
|
+
*/
|
12
|
+
/**
|
13
|
+
* @typedef {Object} BubbleDetails
|
14
|
+
* @property {string} id - Bubble ID
|
15
|
+
* @property {string} name - Bubble name
|
16
|
+
* @property {string} owner - Owner's Ethereum address
|
17
|
+
* @property {boolean} isPrivate - Whether the bubble is private
|
18
|
+
* @property {number} createdAt - Creation timestamp
|
19
|
+
*/
|
20
|
+
/**
|
21
|
+
* @typedef {Object} FileMetadata
|
22
|
+
* @property {string} name - File name
|
23
|
+
* @property {string} owner - File owner
|
24
|
+
* @property {string} filePath - File path
|
25
|
+
* @property {number} created - Creation timestamp
|
26
|
+
* @property {number} updated - Last update timestamp
|
27
|
+
* @property {number} size - File size in bytes
|
28
|
+
* @property {Object} encryptionInfo - Encryption info
|
29
|
+
* @property {string} encryptionInfo.ownerEpub - Owner's public key
|
30
|
+
* @property {string} encryptionInfo.ownerAddress - Owner's address
|
31
|
+
*/
|
32
|
+
/**
|
33
|
+
* @typedef {Object} DeleteResult
|
34
|
+
* @property {boolean} success - Whether deletion was successful
|
35
|
+
* @property {string} [message] - Optional status message
|
36
|
+
*/
|
37
|
+
/**
|
38
|
+
* @typedef {Object} DeleteBubbleResult
|
39
|
+
* @property {boolean} success - Whether deletion was successful
|
40
|
+
* @property {string} [message] - Optional status message
|
41
|
+
*/
|
42
|
+
/**
|
43
|
+
* Base class for bubble storage providers
|
44
|
+
*/
|
45
|
+
export class BaseBubbleProvider {
|
46
|
+
/**
|
47
|
+
* Creates a new bubble provider instance
|
48
|
+
* @param {BubbleProviderOptions} options - Provider configuration options
|
49
|
+
*/
|
50
|
+
constructor(options: BubbleProviderOptions);
|
51
|
+
provider: ethers.JsonRpcProvider;
|
52
|
+
/** @type {BubbleRegistryContract} */
|
53
|
+
contract: BubbleRegistryContract;
|
54
|
+
gun: any;
|
55
|
+
keypair: {
|
56
|
+
/**
|
57
|
+
* - Public encryption key
|
58
|
+
*/
|
59
|
+
epub: string;
|
60
|
+
/**
|
61
|
+
* - Private encryption key
|
62
|
+
*/
|
63
|
+
epriv: string;
|
64
|
+
};
|
65
|
+
bubbleRoot: any;
|
66
|
+
keyPairs: Map<any, any>;
|
67
|
+
/**
|
68
|
+
* Verifies request signature
|
69
|
+
* @param {string} address - Ethereum address of the requester
|
70
|
+
* @param {string} message - Message that was signed
|
71
|
+
* @param {string} signature - Signature of the message
|
72
|
+
* @returns {Promise<boolean>} - Whether the signature is valid
|
73
|
+
*/
|
74
|
+
verifyRequest(address: string, message: string, signature: string): Promise<boolean>;
|
75
|
+
/**
|
76
|
+
* Manages user keys
|
77
|
+
* @param {string} address - Ethereum address of the user
|
78
|
+
* @returns {Promise<Object>} - Key pair of the user
|
79
|
+
*/
|
80
|
+
getUserKeyPair(address: string): Promise<any>;
|
81
|
+
/**
|
82
|
+
* Verifies bubble access
|
83
|
+
* @param {string} bubbleId - ID of the bubble
|
84
|
+
* @param {string} userAddress - Ethereum address of the user
|
85
|
+
* @returns {Promise<boolean>} - Whether the user has access to the bubble
|
86
|
+
*/
|
87
|
+
verifyBubbleAccess(bubbleId: string, userAddress: string): Promise<boolean>;
|
88
|
+
/**
|
89
|
+
* Verifies bubble ownership
|
90
|
+
* @param {string} bubbleId - ID of the bubble
|
91
|
+
* @param {string} ownerAddress - Ethereum address of the owner
|
92
|
+
* @returns {Promise<boolean>} - Whether the user is the owner of the bubble
|
93
|
+
*/
|
94
|
+
verifyBubbleOwnership(bubbleId: string, ownerAddress: string): Promise<boolean>;
|
95
|
+
/**
|
96
|
+
* Grants on-chain access to a target address
|
97
|
+
* @param {string} bubbleId - ID of the bubble
|
98
|
+
* @param {string} targetAddress - Ethereum address to grant access to
|
99
|
+
* @returns {Promise<void>}
|
100
|
+
*/
|
101
|
+
grantOnChainAccess(bubbleId: string, targetAddress: string): Promise<void>;
|
102
|
+
/**
|
103
|
+
* Puts data into GunDB
|
104
|
+
* @param {string} path - Path in GunDB
|
105
|
+
* @param {Object} data - Data to put
|
106
|
+
* @param {number} [maxRetries=3] - Maximum number of retries
|
107
|
+
* @returns {Promise<void>}
|
108
|
+
*/
|
109
|
+
putGunData(path: string, data: any, maxRetries?: number): Promise<void>;
|
110
|
+
/**
|
111
|
+
* Gets a node from GunDB
|
112
|
+
* @typedef {Object} GunNode
|
113
|
+
* @property {Object} data - Data of the node (if any)
|
114
|
+
* @property {string} err - Error message if any
|
115
|
+
* @property {any} content - Content of the node
|
116
|
+
* @param {string} path - Path in GunDB
|
117
|
+
* @param {number} [maxRetries=3] - Maximum number of retries
|
118
|
+
* @returns {Promise<GunNode>} - Node data
|
119
|
+
*/
|
120
|
+
getGunNode(path: string, maxRetries?: number): Promise<{
|
121
|
+
/**
|
122
|
+
* - Data of the node (if any)
|
123
|
+
*/
|
124
|
+
data: any;
|
125
|
+
/**
|
126
|
+
* - Error message if any
|
127
|
+
*/
|
128
|
+
err: string;
|
129
|
+
/**
|
130
|
+
* - Content of the node
|
131
|
+
*/
|
132
|
+
content: any;
|
133
|
+
}>;
|
134
|
+
/**
|
135
|
+
* Handles bubble creation
|
136
|
+
* @param {Object} params - Parameters for bubble creation
|
137
|
+
* @param {string} params.name - Name of the bubble
|
138
|
+
* @param {boolean} params.isPrivate - Whether the bubble is private
|
139
|
+
* @param {string} params.userAddress - Ethereum address of the user
|
140
|
+
* @returns {Promise<BubbleDetails>} - Metadata of the created bubble
|
141
|
+
*/
|
142
|
+
handleCreateBubble(params: {
|
143
|
+
name: string;
|
144
|
+
isPrivate: boolean;
|
145
|
+
userAddress: string;
|
146
|
+
}): Promise<BubbleDetails>;
|
147
|
+
/**
|
148
|
+
* Handles granting permission to a bubble
|
149
|
+
* @param {string} bubbleId - ID of the bubble
|
150
|
+
* @param {string} targetAddress - Ethereum address of the target user
|
151
|
+
* @param {string} granterAddress - Ethereum address of the granter
|
152
|
+
* @param {Object} options - Additional options
|
153
|
+
* @param {string} options.granteeEpub - Public encryption key of the grantee
|
154
|
+
* @returns {Promise<Object>} - Result of the permission grant
|
155
|
+
*/
|
156
|
+
handleGrantPermission(bubbleId: string, targetAddress: string, granterAddress: string, options: {
|
157
|
+
granteeEpub: string;
|
158
|
+
}): Promise<any>;
|
159
|
+
/**
|
160
|
+
* Handles file upload to a bubble
|
161
|
+
* @abstract
|
162
|
+
* @param {string} bubbleId - ID of the bubble
|
163
|
+
* @param {string} fileName - Name of the file
|
164
|
+
* @param {string} content - File content
|
165
|
+
* @param {string} userAddress - Ethereum address of the uploader
|
166
|
+
* @returns {Promise<FileMetadata>} - Metadata of the uploaded file
|
167
|
+
*/
|
168
|
+
handleFileUpload(bubbleId: string, fileName: string, content: string, userAddress: string): Promise<FileMetadata>;
|
169
|
+
/**
|
170
|
+
* Handles file deletion from a bubble
|
171
|
+
* @abstract
|
172
|
+
* @param {string} bubbleId - ID of the bubble
|
173
|
+
* @param {string} fileName - Name of the file
|
174
|
+
* @param {string} userAddress - Ethereum address of the user
|
175
|
+
* @returns {Promise<DeleteResult>} - Result of the deletion
|
176
|
+
*/
|
177
|
+
handleDeleteFile(bubbleId: string, fileName: string, userAddress: string): Promise<DeleteResult>;
|
178
|
+
/**
|
179
|
+
* Handles file download from a bubble
|
180
|
+
* @abstract
|
181
|
+
* @param {string} bubbleId - ID of the bubble
|
182
|
+
* @param {string} fileName - Name of the file
|
183
|
+
* @param {string} userAddress - Ethereum address of the user
|
184
|
+
* @returns {Promise<{content: any, metadata: Object}>} - File content and metadata
|
185
|
+
*/
|
186
|
+
handleFileDownload(bubbleId: string, fileName: string, userAddress: string): Promise<{
|
187
|
+
content: any;
|
188
|
+
metadata: any;
|
189
|
+
}>;
|
190
|
+
/**
|
191
|
+
* Handles bubble deletion
|
192
|
+
* @abstract
|
193
|
+
* @param {string} bubbleId - ID of the bubble
|
194
|
+
* @param {string} userAddress - Ethereum address of the user
|
195
|
+
* @returns {Promise<DeleteBubbleResult>} - Result of the deletion
|
196
|
+
*/
|
197
|
+
handleDeleteBubble(bubbleId: string, userAddress: string): Promise<DeleteBubbleResult>;
|
198
|
+
}
|
199
|
+
export type BubbleProviderOptions = {
|
200
|
+
/**
|
201
|
+
* - RPC URL for the provider
|
202
|
+
*/
|
203
|
+
rpcUrl: string;
|
204
|
+
/**
|
205
|
+
* - Chain name (e.g. 'localhost', 'optimismSepolia')
|
206
|
+
*/
|
207
|
+
chain: string;
|
208
|
+
/**
|
209
|
+
* - Gun instance
|
210
|
+
*/
|
211
|
+
gun: any;
|
212
|
+
/**
|
213
|
+
* - Keypair for encryption
|
214
|
+
*/
|
215
|
+
keypair: {
|
216
|
+
epub: string;
|
217
|
+
epriv: string;
|
218
|
+
};
|
219
|
+
/**
|
220
|
+
* - Optional custom contract address
|
221
|
+
*/
|
222
|
+
contractAddress?: string;
|
223
|
+
/**
|
224
|
+
* - Optional custom contract ABI
|
225
|
+
*/
|
226
|
+
contractAbi?: any;
|
227
|
+
};
|
228
|
+
export type BubbleDetails = {
|
229
|
+
/**
|
230
|
+
* - Bubble ID
|
231
|
+
*/
|
232
|
+
id: string;
|
233
|
+
/**
|
234
|
+
* - Bubble name
|
235
|
+
*/
|
236
|
+
name: string;
|
237
|
+
/**
|
238
|
+
* - Owner's Ethereum address
|
239
|
+
*/
|
240
|
+
owner: string;
|
241
|
+
/**
|
242
|
+
* - Whether the bubble is private
|
243
|
+
*/
|
244
|
+
isPrivate: boolean;
|
245
|
+
/**
|
246
|
+
* - Creation timestamp
|
247
|
+
*/
|
248
|
+
createdAt: number;
|
249
|
+
};
|
250
|
+
export type FileMetadata = {
|
251
|
+
/**
|
252
|
+
* - File name
|
253
|
+
*/
|
254
|
+
name: string;
|
255
|
+
/**
|
256
|
+
* - File owner
|
257
|
+
*/
|
258
|
+
owner: string;
|
259
|
+
/**
|
260
|
+
* - File path
|
261
|
+
*/
|
262
|
+
filePath: string;
|
263
|
+
/**
|
264
|
+
* - Creation timestamp
|
265
|
+
*/
|
266
|
+
created: number;
|
267
|
+
/**
|
268
|
+
* - Last update timestamp
|
269
|
+
*/
|
270
|
+
updated: number;
|
271
|
+
/**
|
272
|
+
* - File size in bytes
|
273
|
+
*/
|
274
|
+
size: number;
|
275
|
+
/**
|
276
|
+
* - Encryption info
|
277
|
+
*/
|
278
|
+
encryptionInfo: {
|
279
|
+
ownerEpub: string;
|
280
|
+
ownerAddress: string;
|
281
|
+
};
|
282
|
+
};
|
283
|
+
export type DeleteResult = {
|
284
|
+
/**
|
285
|
+
* - Whether deletion was successful
|
286
|
+
*/
|
287
|
+
success: boolean;
|
288
|
+
/**
|
289
|
+
* - Optional status message
|
290
|
+
*/
|
291
|
+
message?: string;
|
292
|
+
};
|
293
|
+
export type DeleteBubbleResult = {
|
294
|
+
/**
|
295
|
+
* - Whether deletion was successful
|
296
|
+
*/
|
297
|
+
success: boolean;
|
298
|
+
/**
|
299
|
+
* - Optional status message
|
300
|
+
*/
|
301
|
+
message?: string;
|
302
|
+
};
|
303
|
+
import { ethers } from 'ethers';
|
@@ -0,0 +1,173 @@
|
|
1
|
+
export class GUNBubbleProvider extends BaseBubbleProvider {
|
2
|
+
constructor(options: any);
|
3
|
+
user: any;
|
4
|
+
/**
|
5
|
+
* @typedef {Object} FileDownloadParams
|
6
|
+
* @property {string} bubbleId - ID of the bubble
|
7
|
+
* @property {string} fileName - Name of the file to download
|
8
|
+
* @property {string} userAddress - Ethereum address of the user
|
9
|
+
*/
|
10
|
+
/**
|
11
|
+
* Handles file download
|
12
|
+
* @param {string} bubbleId - ID of the bubble
|
13
|
+
* @param {string} fileName - Name of the file to download
|
14
|
+
* @param {string} userAddress - Ethereum address of the user
|
15
|
+
*/
|
16
|
+
handleFileDownload(bubbleId: string, fileName: string, userAddress: string): Promise<{
|
17
|
+
content: any;
|
18
|
+
metadata: {
|
19
|
+
name: any;
|
20
|
+
owner: any;
|
21
|
+
filePath: any;
|
22
|
+
created: any;
|
23
|
+
updated: any;
|
24
|
+
size: any;
|
25
|
+
readOnly: any;
|
26
|
+
encryptionInfo: any;
|
27
|
+
};
|
28
|
+
}>;
|
29
|
+
/**
|
30
|
+
* @typedef {Object} FileUploadOptions
|
31
|
+
* @property {string} bubbleId - ID of the bubble
|
32
|
+
* @property {string} fileName - Name of the file
|
33
|
+
* @property {string} content - Content of the file
|
34
|
+
* @property {string} userAddress - Address of the user
|
35
|
+
*/
|
36
|
+
handleFileUpload(bubbleId: any, fileName: any, content: any, userAddress: any): Promise<any>;
|
37
|
+
/**
|
38
|
+
* @typedef {Object} GrantPermissionOptions
|
39
|
+
* @property {string} granteeEpub - Public encryption key of grantee
|
40
|
+
*/
|
41
|
+
handleGrantPermission(bubbleId: any, targetAddress: any, granterAddress: any, options?: {}): Promise<{
|
42
|
+
success: boolean;
|
43
|
+
}>;
|
44
|
+
/**
|
45
|
+
* @typedef {Object} BubbleParams
|
46
|
+
* @property {string} name - The name of the bubble
|
47
|
+
* @property {boolean} isPrivate - Whether the bubble is private
|
48
|
+
* @property {string} userAddress - The address of the user creating the bubble
|
49
|
+
*/
|
50
|
+
/**
|
51
|
+
* Handles the creation of a new bubble.
|
52
|
+
* @param {BubbleParams} params - The parameters for bubble creation
|
53
|
+
*/
|
54
|
+
handleCreateBubble(params: {
|
55
|
+
/**
|
56
|
+
* - The name of the bubble
|
57
|
+
*/
|
58
|
+
name: string;
|
59
|
+
/**
|
60
|
+
* - Whether the bubble is private
|
61
|
+
*/
|
62
|
+
isPrivate: boolean;
|
63
|
+
/**
|
64
|
+
* - The address of the user creating the bubble
|
65
|
+
*/
|
66
|
+
userAddress: string;
|
67
|
+
}): Promise<{
|
68
|
+
id: any;
|
69
|
+
name: string;
|
70
|
+
owner: string;
|
71
|
+
isPrivate: boolean;
|
72
|
+
createdAt: number;
|
73
|
+
}>;
|
74
|
+
/**
|
75
|
+
* @typedef {Object} DeleteFileOptions
|
76
|
+
* @property {string} bubbleId - The ID of the bubble
|
77
|
+
* @property {string} fileName - The name of the file to delete
|
78
|
+
* @property {string} userAddress - The address of the user requesting the deletion
|
79
|
+
*/
|
80
|
+
handleDeleteFile(bubbleId: any, fileName: any, userAddress: any): Promise<any>;
|
81
|
+
/**
|
82
|
+
* @typedef {Object} DeleteBubbleResult
|
83
|
+
* @property {boolean} success - Indicates if the bubble was successfully deleted
|
84
|
+
*/
|
85
|
+
/**
|
86
|
+
* Deletes a bubble and all its contents.
|
87
|
+
* @param {string} bubbleId - The ID of the bubble to delete.
|
88
|
+
* @param {string} userAddress - The address of the user requesting the deletion.
|
89
|
+
* @returns {Promise<DeleteBubbleResult>} - The result of the deletion operation.
|
90
|
+
*/
|
91
|
+
handleDeleteBubble(bubbleId: string, userAddress: string): Promise<{
|
92
|
+
/**
|
93
|
+
* - Indicates if the bubble was successfully deleted
|
94
|
+
*/
|
95
|
+
success: boolean;
|
96
|
+
}>;
|
97
|
+
}
|
98
|
+
export type FileMetadata = {
|
99
|
+
/**
|
100
|
+
* - Name of the file
|
101
|
+
*/
|
102
|
+
name: string;
|
103
|
+
/**
|
104
|
+
* - Address of file owner
|
105
|
+
*/
|
106
|
+
owner: string;
|
107
|
+
/**
|
108
|
+
* - Creation timestamp
|
109
|
+
*/
|
110
|
+
created: number;
|
111
|
+
/**
|
112
|
+
* - Last update timestamp
|
113
|
+
*/
|
114
|
+
updated: number;
|
115
|
+
/**
|
116
|
+
* - File path
|
117
|
+
*/
|
118
|
+
filePath: string;
|
119
|
+
/**
|
120
|
+
* - File size
|
121
|
+
*/
|
122
|
+
size: number;
|
123
|
+
/**
|
124
|
+
* - Encryption info
|
125
|
+
*/
|
126
|
+
encryptionInfo: {
|
127
|
+
ownerEpub: string;
|
128
|
+
ownerAddress: string;
|
129
|
+
};
|
130
|
+
/**
|
131
|
+
* - Whether file is read-only
|
132
|
+
*/
|
133
|
+
readOnly: boolean;
|
134
|
+
};
|
135
|
+
export type BubbleMetadata = {
|
136
|
+
/**
|
137
|
+
* - Unique bubble ID
|
138
|
+
*/
|
139
|
+
id: string;
|
140
|
+
/**
|
141
|
+
* - Name of the bubble
|
142
|
+
*/
|
143
|
+
name: string;
|
144
|
+
/**
|
145
|
+
* - Address of bubble owner
|
146
|
+
*/
|
147
|
+
owner: string;
|
148
|
+
/**
|
149
|
+
* - Whether bubble is private
|
150
|
+
*/
|
151
|
+
isPrivate: boolean;
|
152
|
+
/**
|
153
|
+
* - Creation timestamp
|
154
|
+
*/
|
155
|
+
createdAt: number;
|
156
|
+
};
|
157
|
+
export type FileDownloadResult = {
|
158
|
+
/**
|
159
|
+
* - Decrypted file content
|
160
|
+
*/
|
161
|
+
content: string;
|
162
|
+
/**
|
163
|
+
* - File metadata
|
164
|
+
*/
|
165
|
+
metadata: FileMetadata;
|
166
|
+
};
|
167
|
+
export type GrantPermissionOptions = {
|
168
|
+
/**
|
169
|
+
* - Public encryption key of grantee
|
170
|
+
*/
|
171
|
+
granteeEpub: string;
|
172
|
+
};
|
173
|
+
import { BaseBubbleProvider } from './base-bubble-provider.js';
|
@@ -0,0 +1,124 @@
|
|
1
|
+
/**
|
2
|
+
* Options for initializing a HybridBubbleProvider
|
3
|
+
* @typedef {Object} HybridBubbleProviderOptions
|
4
|
+
* @property {string} rpcUrl - RPC URL for the provider
|
5
|
+
* @property {string} contractAddress - Address of the bubble registry contract
|
6
|
+
* @property {Object} [contractAbi] - ABI of the bubble registry contract
|
7
|
+
* @property {Object} gun - Gun instance
|
8
|
+
* @property {Object} keypair - Key pair for encryption
|
9
|
+
*/
|
10
|
+
/**
|
11
|
+
* Extended Gun node with additional file metadata
|
12
|
+
* @typedef {Object} ExtendedGunNode
|
13
|
+
* @property {string} filePath - Path to the file on disk
|
14
|
+
* @property {string} owner - Address of file owner
|
15
|
+
* @property {string} content - Encrypted file content
|
16
|
+
* @property {string} [name] - File name
|
17
|
+
* @property {number} [created] - Creation timestamp
|
18
|
+
* @property {number} [updated] - Last update timestamp
|
19
|
+
* @property {number} [size] - File size in bytes
|
20
|
+
* @property {{ ownerEpub: string, ownerAddress: string }} [encryptionInfo] - Encryption metadata
|
21
|
+
*/
|
22
|
+
/** @typedef {import('./base-bubble-provider.js').BubbleProviderOptions} BubbleProviderOptions */
|
23
|
+
/** @typedef {import('./base-bubble-provider.js').FileMetadata} FileMetadata */
|
24
|
+
/** @typedef {import('./gun-bubble-provider.js').FileDownloadResult} FileDownloadResult */
|
25
|
+
/** @typedef {import('./base-bubble-provider.js').DeleteResult} DeleteResult */
|
26
|
+
/** @typedef {Object} GunNode */
|
27
|
+
/** @typedef {GunNode & ExtendedGunNode} FileGunNode */
|
28
|
+
export class HybridBubbleProvider extends BaseBubbleProvider {
|
29
|
+
/**
|
30
|
+
* @param {import("fs").PathLike} dir
|
31
|
+
*/
|
32
|
+
ensureDirectory(dir: import("fs").PathLike): Promise<void>;
|
33
|
+
getFilePath(bubbleId: any, fileName: any): string;
|
34
|
+
/**
|
35
|
+
* Handles file download
|
36
|
+
* @param {string} bubbleId
|
37
|
+
* @param {string} fileName
|
38
|
+
* @param {string} userAddress
|
39
|
+
* @returns {Promise<FileDownloadResult>}
|
40
|
+
*/
|
41
|
+
handleFileDownload(bubbleId: string, fileName: string, userAddress: string): Promise<FileDownloadResult>;
|
42
|
+
handleGrantPermission(bubbleId: any, targetAddress: any, granterAddress: any, options?: {}): Promise<{
|
43
|
+
success: boolean;
|
44
|
+
}>;
|
45
|
+
handleCreateBubble(params: any): Promise<{
|
46
|
+
id: any;
|
47
|
+
name: any;
|
48
|
+
owner: any;
|
49
|
+
isPrivate: boolean;
|
50
|
+
createdAt: number;
|
51
|
+
}>;
|
52
|
+
}
|
53
|
+
/**
|
54
|
+
* Options for initializing a HybridBubbleProvider
|
55
|
+
*/
|
56
|
+
export type HybridBubbleProviderOptions = {
|
57
|
+
/**
|
58
|
+
* - RPC URL for the provider
|
59
|
+
*/
|
60
|
+
rpcUrl: string;
|
61
|
+
/**
|
62
|
+
* - Address of the bubble registry contract
|
63
|
+
*/
|
64
|
+
contractAddress: string;
|
65
|
+
/**
|
66
|
+
* - ABI of the bubble registry contract
|
67
|
+
*/
|
68
|
+
contractAbi?: any;
|
69
|
+
/**
|
70
|
+
* - Gun instance
|
71
|
+
*/
|
72
|
+
gun: any;
|
73
|
+
/**
|
74
|
+
* - Key pair for encryption
|
75
|
+
*/
|
76
|
+
keypair: any;
|
77
|
+
};
|
78
|
+
/**
|
79
|
+
* Extended Gun node with additional file metadata
|
80
|
+
*/
|
81
|
+
export type ExtendedGunNode = {
|
82
|
+
/**
|
83
|
+
* - Path to the file on disk
|
84
|
+
*/
|
85
|
+
filePath: string;
|
86
|
+
/**
|
87
|
+
* - Address of file owner
|
88
|
+
*/
|
89
|
+
owner: string;
|
90
|
+
/**
|
91
|
+
* - Encrypted file content
|
92
|
+
*/
|
93
|
+
content: string;
|
94
|
+
/**
|
95
|
+
* - File name
|
96
|
+
*/
|
97
|
+
name?: string;
|
98
|
+
/**
|
99
|
+
* - Creation timestamp
|
100
|
+
*/
|
101
|
+
created?: number;
|
102
|
+
/**
|
103
|
+
* - Last update timestamp
|
104
|
+
*/
|
105
|
+
updated?: number;
|
106
|
+
/**
|
107
|
+
* - File size in bytes
|
108
|
+
*/
|
109
|
+
size?: number;
|
110
|
+
/**
|
111
|
+
* - Encryption metadata
|
112
|
+
*/
|
113
|
+
encryptionInfo?: {
|
114
|
+
ownerEpub: string;
|
115
|
+
ownerAddress: string;
|
116
|
+
};
|
117
|
+
};
|
118
|
+
export type BubbleProviderOptions = import("./base-bubble-provider.js").BubbleProviderOptions;
|
119
|
+
export type FileMetadata = import("./base-bubble-provider.js").FileMetadata;
|
120
|
+
export type FileDownloadResult = import("./gun-bubble-provider.js").FileDownloadResult;
|
121
|
+
export type DeleteResult = import("./base-bubble-provider.js").DeleteResult;
|
122
|
+
export type GunNode = any;
|
123
|
+
export type FileGunNode = GunNode & ExtendedGunNode;
|
124
|
+
import { BaseBubbleProvider } from './base-bubble-provider.js';
|