gun-eth 2.0.1 → 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 +320 -141
- 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,225 @@
|
|
1
|
+
/**
|
2
|
+
* Result of proof verification
|
3
|
+
* @typedef {Object} ProofResult
|
4
|
+
* @property {boolean} isValid - Whether the data is valid
|
5
|
+
* @property {number} timestamp - Verification timestamp
|
6
|
+
* @property {string} updater - Address of last update
|
7
|
+
*/
|
8
|
+
/**
|
9
|
+
* Latest record
|
10
|
+
* @typedef {Object} LatestRecord
|
11
|
+
* @property {string} contentHash - Content hash
|
12
|
+
* @property {number} timestamp - Last update timestamp
|
13
|
+
* @property {string} updater - Address of last updater
|
14
|
+
*/
|
15
|
+
/**
|
16
|
+
* Callback for proof operations
|
17
|
+
* @typedef {Object} ProofCallback
|
18
|
+
* @property {boolean} [ok] - Whether operation was successful
|
19
|
+
* @property {string} [message] - Success/error message
|
20
|
+
* @property {string} [err] - Error message
|
21
|
+
* @property {number} [timestamp] - Operation timestamp
|
22
|
+
* @property {string} [updater] - Updater address
|
23
|
+
* @property {LatestRecord} [latestRecord] - Latest record
|
24
|
+
* @property {string} [nodeId] - Created node ID
|
25
|
+
* @property {string} [txHash] - Transaction hash
|
26
|
+
*/
|
27
|
+
/**
|
28
|
+
* Options for proof transactions
|
29
|
+
* @typedef {Object} ProofOptions
|
30
|
+
* @property {number} [gasLimit] - Gas limit for transaction
|
31
|
+
* @property {number} [gasPrice] - Gas price
|
32
|
+
*/
|
33
|
+
/**
|
34
|
+
* Extended Gun with additional methods
|
35
|
+
* @typedef {import('gun').IGun & { get: (path: string) => any }} ExtendedGun
|
36
|
+
*/
|
37
|
+
/**
|
38
|
+
* Extended transaction with additional methods
|
39
|
+
* @typedef {import('ethers').ContractTransaction & { wait: () => Promise<any>, hash: string }} ExtendedTransaction
|
40
|
+
*/
|
41
|
+
/**
|
42
|
+
* Configuration for ProofChain
|
43
|
+
* @typedef {Object} ProofChainConfig
|
44
|
+
* @property {string} [contractAddress] - Address of deployed ProofOfIntegrity contract
|
45
|
+
* @property {string} [abi] - ABI of the contract (optional, defaults to PROOF_OF_INTEGRITY_ABI)
|
46
|
+
*/
|
47
|
+
/**
|
48
|
+
* Class for handling blockchain proof of integrity
|
49
|
+
* @class
|
50
|
+
*/
|
51
|
+
export class ProofChain {
|
52
|
+
/**
|
53
|
+
* Extends Gun with proof methods
|
54
|
+
* @param {typeof Gun} Gun - Gun constructor
|
55
|
+
*/
|
56
|
+
static extendGun(Gun: import("gun").IGun): void;
|
57
|
+
/**
|
58
|
+
* Creates a new ProofChain instance
|
59
|
+
* @param {Gun} gun - Gun instance
|
60
|
+
* @param {ProofChainConfig} [config] - Optional configuration
|
61
|
+
*/
|
62
|
+
constructor(gun: import("gun").IGun, config?: ProofChainConfig);
|
63
|
+
/** @type {ExtendedGun} */
|
64
|
+
gun: ExtendedGun;
|
65
|
+
contractAddress: string;
|
66
|
+
contractAbi: any;
|
67
|
+
/**
|
68
|
+
* Gets contract instance for the specified chain
|
69
|
+
* @param {string} chain - Chain identifier
|
70
|
+
* @returns {Promise<Contract>} Contract instance
|
71
|
+
*/
|
72
|
+
getContract(chain: string): Promise<Contract>;
|
73
|
+
/**
|
74
|
+
* Converts an ID to bytes32
|
75
|
+
* @param {ethers.BytesLike} id - ID to convert
|
76
|
+
* @returns {string} ID converted to bytes32
|
77
|
+
*/
|
78
|
+
convertToBytes32(id: ethers.BytesLike): string;
|
79
|
+
/**
|
80
|
+
* Verifies data on-chain
|
81
|
+
* @param {string} chain - Chain identifier
|
82
|
+
* @param {string} nodeId - Node ID to verify
|
83
|
+
* @param {string} contentHash - Content hash to verify
|
84
|
+
* @returns {Promise<ProofResult>} Verification result
|
85
|
+
*/
|
86
|
+
verifyOnChain(chain: string, nodeId: string, contentHash: string): Promise<ProofResult>;
|
87
|
+
/**
|
88
|
+
* Writes data on-chain
|
89
|
+
* @param {string} chain - Chain identifier
|
90
|
+
* @param {string} nodeId - Node ID to write
|
91
|
+
* @param {string} contentHash - Content hash to write
|
92
|
+
* @param {Object} options - Transaction options
|
93
|
+
* @returns {Promise<ExtendedTransaction>} Resulting transaction
|
94
|
+
*/
|
95
|
+
writeOnChain(chain: string, nodeId: string, contentHash: string, options?: any): Promise<ExtendedTransaction>;
|
96
|
+
/**
|
97
|
+
* Gets the latest record
|
98
|
+
* @param {string} chain - Chain name
|
99
|
+
* @param {ethers.BytesLike} nodeId - Node ID
|
100
|
+
* @returns {Promise<LatestRecord>} Latest record
|
101
|
+
*/
|
102
|
+
getLatestRecord(chain: string, nodeId: ethers.BytesLike): Promise<LatestRecord>;
|
103
|
+
/**
|
104
|
+
* Verifies or writes data with proof of integrity
|
105
|
+
* @param {string} chain - Chain name
|
106
|
+
* @param {string} nodeId - Node ID (for verification)
|
107
|
+
* @param {object} data - Data to write
|
108
|
+
* @param {function} callback - Callback function
|
109
|
+
* @param {object} options - Transaction options
|
110
|
+
* @returns {Promise<this>} Current instance
|
111
|
+
*/
|
112
|
+
proof(chain: string, nodeId: string, data: object, callback: Function, options?: object): Promise<this>;
|
113
|
+
}
|
114
|
+
/**
|
115
|
+
* Result of proof verification
|
116
|
+
*/
|
117
|
+
export type ProofResult = {
|
118
|
+
/**
|
119
|
+
* - Whether the data is valid
|
120
|
+
*/
|
121
|
+
isValid: boolean;
|
122
|
+
/**
|
123
|
+
* - Verification timestamp
|
124
|
+
*/
|
125
|
+
timestamp: number;
|
126
|
+
/**
|
127
|
+
* - Address of last update
|
128
|
+
*/
|
129
|
+
updater: string;
|
130
|
+
};
|
131
|
+
/**
|
132
|
+
* Latest record
|
133
|
+
*/
|
134
|
+
export type LatestRecord = {
|
135
|
+
/**
|
136
|
+
* - Content hash
|
137
|
+
*/
|
138
|
+
contentHash: string;
|
139
|
+
/**
|
140
|
+
* - Last update timestamp
|
141
|
+
*/
|
142
|
+
timestamp: number;
|
143
|
+
/**
|
144
|
+
* - Address of last updater
|
145
|
+
*/
|
146
|
+
updater: string;
|
147
|
+
};
|
148
|
+
/**
|
149
|
+
* Callback for proof operations
|
150
|
+
*/
|
151
|
+
export type ProofCallback = {
|
152
|
+
/**
|
153
|
+
* - Whether operation was successful
|
154
|
+
*/
|
155
|
+
ok?: boolean;
|
156
|
+
/**
|
157
|
+
* - Success/error message
|
158
|
+
*/
|
159
|
+
message?: string;
|
160
|
+
/**
|
161
|
+
* - Error message
|
162
|
+
*/
|
163
|
+
err?: string;
|
164
|
+
/**
|
165
|
+
* - Operation timestamp
|
166
|
+
*/
|
167
|
+
timestamp?: number;
|
168
|
+
/**
|
169
|
+
* - Updater address
|
170
|
+
*/
|
171
|
+
updater?: string;
|
172
|
+
/**
|
173
|
+
* - Latest record
|
174
|
+
*/
|
175
|
+
latestRecord?: LatestRecord;
|
176
|
+
/**
|
177
|
+
* - Created node ID
|
178
|
+
*/
|
179
|
+
nodeId?: string;
|
180
|
+
/**
|
181
|
+
* - Transaction hash
|
182
|
+
*/
|
183
|
+
txHash?: string;
|
184
|
+
};
|
185
|
+
/**
|
186
|
+
* Options for proof transactions
|
187
|
+
*/
|
188
|
+
export type ProofOptions = {
|
189
|
+
/**
|
190
|
+
* - Gas limit for transaction
|
191
|
+
*/
|
192
|
+
gasLimit?: number;
|
193
|
+
/**
|
194
|
+
* - Gas price
|
195
|
+
*/
|
196
|
+
gasPrice?: number;
|
197
|
+
};
|
198
|
+
/**
|
199
|
+
* Extended Gun with additional methods
|
200
|
+
*/
|
201
|
+
export type ExtendedGun = import("gun").IGun & {
|
202
|
+
get: (path: string) => any;
|
203
|
+
};
|
204
|
+
/**
|
205
|
+
* Extended transaction with additional methods
|
206
|
+
*/
|
207
|
+
export type ExtendedTransaction = import("ethers").ContractTransaction & {
|
208
|
+
wait: () => Promise<any>;
|
209
|
+
hash: string;
|
210
|
+
};
|
211
|
+
/**
|
212
|
+
* Configuration for ProofChain
|
213
|
+
*/
|
214
|
+
export type ProofChainConfig = {
|
215
|
+
/**
|
216
|
+
* - Address of deployed ProofOfIntegrity contract
|
217
|
+
*/
|
218
|
+
contractAddress?: string;
|
219
|
+
/**
|
220
|
+
* - ABI of the contract (optional, defaults to PROOF_OF_INTEGRITY_ABI)
|
221
|
+
*/
|
222
|
+
abi?: string;
|
223
|
+
};
|
224
|
+
import { Contract } from "ethers";
|
225
|
+
import { ethers } from 'ethers';
|
@@ -0,0 +1,200 @@
|
|
1
|
+
/**
|
2
|
+
* Extended Gun with additional methods
|
3
|
+
* @typedef {import('gun').IGun & {
|
4
|
+
* get: (path: string) => any,
|
5
|
+
* verifySignature: (message: string, signature: string) => Promise<string>,
|
6
|
+
* put: (data: any) => void,
|
7
|
+
* set: (data: any) => void,
|
8
|
+
* map: () => any,
|
9
|
+
* once: (callback: (data: any, key: string) => void) => void
|
10
|
+
* }} ExtendedGun
|
11
|
+
*/
|
12
|
+
/**
|
13
|
+
* @typedef {Object} StealthAddressResult
|
14
|
+
* @property {string} stealthPrivateKey - The private key of the stealth address
|
15
|
+
* @property {string} stealthAddress - The stealth address
|
16
|
+
* @property {ethers.Wallet} wallet - The stealth wallet
|
17
|
+
*/
|
18
|
+
/**
|
19
|
+
* @typedef {Object} StealthAddressGenerationResult
|
20
|
+
* @property {string} stealthAddress - The generated stealth address
|
21
|
+
* @property {string} senderPublicKey - The public key of the sender
|
22
|
+
* @property {string} spendingPublicKey - The spending public key of the recipient
|
23
|
+
*/
|
24
|
+
/**
|
25
|
+
* @typedef {Object} StealthPaymentOptions
|
26
|
+
* @property {boolean} [onChain] - If true, announce on-chain, otherwise off-chain
|
27
|
+
* @property {string} [chain] - The chain to announce on (if onChain=true)
|
28
|
+
*/
|
29
|
+
/**
|
30
|
+
* @typedef {Object} StealthPaymentResult
|
31
|
+
* @property {ethers.Wallet} wallet - The recovered wallet
|
32
|
+
* @property {string} address - The recovered address
|
33
|
+
*/
|
34
|
+
/**
|
35
|
+
* @typedef {Object} PublicKeysResult
|
36
|
+
* @property {string} viewingPublicKey - The viewing public key
|
37
|
+
* @property {string} spendingPublicKey - The spending public key
|
38
|
+
*/
|
39
|
+
/**
|
40
|
+
* Configuration for StealthChain
|
41
|
+
* @typedef {Object} StealthChainConfig
|
42
|
+
* @property {string} [contractAddress] - Address of deployed StealthAnnouncer contract
|
43
|
+
* @property {string} [abi] - ABI of the contract (optional, defaults to STEALTH_ANNOUNCER_ABI)
|
44
|
+
*/
|
45
|
+
export class StealthChain {
|
46
|
+
/**
|
47
|
+
* Creates a new StealthChain instance
|
48
|
+
* @param {ExtendedGun} gun - Gun instance
|
49
|
+
* @param {StealthChainConfig} [config] - Optional configuration
|
50
|
+
*/
|
51
|
+
constructor(gun: ExtendedGun, config?: StealthChainConfig);
|
52
|
+
/** @type {ExtendedGun} */
|
53
|
+
gun: ExtendedGun;
|
54
|
+
/** @type {string | undefined} */
|
55
|
+
contractAddress: string | undefined;
|
56
|
+
/** @type {any} */
|
57
|
+
contractAbi: any;
|
58
|
+
/**
|
59
|
+
* Gets contract instance for the specified chain
|
60
|
+
* @param {string} chain - Chain identifier
|
61
|
+
* @returns {Promise<ethers.Contract>} Contract instance
|
62
|
+
*/
|
63
|
+
getContract(chain: string): Promise<ethers.Contract>;
|
64
|
+
/**
|
65
|
+
* Derives a stealth address from shared secret and spending public key
|
66
|
+
* @param {string} sharedSecret - The shared secret
|
67
|
+
* @param {string} spendingPublicKey - The spending public key
|
68
|
+
* @returns {StealthAddressResult} The derived stealth address details
|
69
|
+
*/
|
70
|
+
deriveStealthAddress(sharedSecret: string, spendingPublicKey: string): StealthAddressResult;
|
71
|
+
/**
|
72
|
+
* Generates a stealth address for a recipient
|
73
|
+
* @param {string} recipientAddress - The recipient's address
|
74
|
+
* @param {string} signature - The signature
|
75
|
+
* @param {Object} options - Additional options
|
76
|
+
* @returns {Promise<StealthAddressGenerationResult>} The generated stealth address details
|
77
|
+
*/
|
78
|
+
generateStealthAddress(recipientAddress: string, signature: string, options?: any): Promise<StealthAddressGenerationResult>;
|
79
|
+
/**
|
80
|
+
* Announces a stealth payment on-chain or off-chain
|
81
|
+
* @param {string} stealthAddress - The stealth address of the recipient
|
82
|
+
* @param {string} senderPublicKey - The sender's public key
|
83
|
+
* @param {string} spendingPublicKey - The recipient's spending public key
|
84
|
+
* @param {string} signature - The sender's signature
|
85
|
+
* @param {StealthPaymentOptions} options - Additional options
|
86
|
+
* @returns {Promise<{stealthAddress: string, senderPublicKey: string, spendingPublicKey: string, timestamp: number, source: string}>}
|
87
|
+
*/
|
88
|
+
announceStealthPayment(stealthAddress: string, senderPublicKey: string, spendingPublicKey: string, signature: string, options?: StealthPaymentOptions): Promise<{
|
89
|
+
stealthAddress: string;
|
90
|
+
senderPublicKey: string;
|
91
|
+
spendingPublicKey: string;
|
92
|
+
timestamp: number;
|
93
|
+
source: string;
|
94
|
+
}>;
|
95
|
+
/**
|
96
|
+
* Retrieves stealth payments
|
97
|
+
* @param {string} signature - The signature
|
98
|
+
* @param {Object} options - Additional options
|
99
|
+
* @returns {Promise<Array>} The list of stealth payments
|
100
|
+
*/
|
101
|
+
getStealthPayments(signature: string, options?: any): Promise<any[]>;
|
102
|
+
/**
|
103
|
+
* Recovers stealth funds
|
104
|
+
* @param {string} stealthAddress - The stealth address
|
105
|
+
* @param {string} senderPublicKey - The sender's public key
|
106
|
+
* @param {string} signature - The signature
|
107
|
+
* @param {string} spendingPublicKey - The spending public key
|
108
|
+
* @returns {Promise<StealthPaymentResult>} The recovered funds details
|
109
|
+
*/
|
110
|
+
recoverStealthFunds(stealthAddress: string, senderPublicKey: string, signature: string, spendingPublicKey: string): Promise<StealthPaymentResult>;
|
111
|
+
/**
|
112
|
+
* Publishes user's stealth keys
|
113
|
+
* @param {string} signature - The signature
|
114
|
+
* @returns {Promise<PublicKeysResult>} The published public keys
|
115
|
+
*/
|
116
|
+
publishStealthKeys(signature: string): Promise<PublicKeysResult>;
|
117
|
+
}
|
118
|
+
/**
|
119
|
+
* Extended Gun with additional methods
|
120
|
+
*/
|
121
|
+
export type ExtendedGun = import("gun").IGun & {
|
122
|
+
get: (path: string) => any;
|
123
|
+
verifySignature: (message: string, signature: string) => Promise<string>;
|
124
|
+
put: (data: any) => void;
|
125
|
+
set: (data: any) => void;
|
126
|
+
map: () => any;
|
127
|
+
once: (callback: (data: any, key: string) => void) => void;
|
128
|
+
};
|
129
|
+
export type StealthAddressResult = {
|
130
|
+
/**
|
131
|
+
* - The private key of the stealth address
|
132
|
+
*/
|
133
|
+
stealthPrivateKey: string;
|
134
|
+
/**
|
135
|
+
* - The stealth address
|
136
|
+
*/
|
137
|
+
stealthAddress: string;
|
138
|
+
/**
|
139
|
+
* - The stealth wallet
|
140
|
+
*/
|
141
|
+
wallet: ethers.Wallet;
|
142
|
+
};
|
143
|
+
export type StealthAddressGenerationResult = {
|
144
|
+
/**
|
145
|
+
* - The generated stealth address
|
146
|
+
*/
|
147
|
+
stealthAddress: string;
|
148
|
+
/**
|
149
|
+
* - The public key of the sender
|
150
|
+
*/
|
151
|
+
senderPublicKey: string;
|
152
|
+
/**
|
153
|
+
* - The spending public key of the recipient
|
154
|
+
*/
|
155
|
+
spendingPublicKey: string;
|
156
|
+
};
|
157
|
+
export type StealthPaymentOptions = {
|
158
|
+
/**
|
159
|
+
* - If true, announce on-chain, otherwise off-chain
|
160
|
+
*/
|
161
|
+
onChain?: boolean;
|
162
|
+
/**
|
163
|
+
* - The chain to announce on (if onChain=true)
|
164
|
+
*/
|
165
|
+
chain?: string;
|
166
|
+
};
|
167
|
+
export type StealthPaymentResult = {
|
168
|
+
/**
|
169
|
+
* - The recovered wallet
|
170
|
+
*/
|
171
|
+
wallet: ethers.Wallet;
|
172
|
+
/**
|
173
|
+
* - The recovered address
|
174
|
+
*/
|
175
|
+
address: string;
|
176
|
+
};
|
177
|
+
export type PublicKeysResult = {
|
178
|
+
/**
|
179
|
+
* - The viewing public key
|
180
|
+
*/
|
181
|
+
viewingPublicKey: string;
|
182
|
+
/**
|
183
|
+
* - The spending public key
|
184
|
+
*/
|
185
|
+
spendingPublicKey: string;
|
186
|
+
};
|
187
|
+
/**
|
188
|
+
* Configuration for StealthChain
|
189
|
+
*/
|
190
|
+
export type StealthChainConfig = {
|
191
|
+
/**
|
192
|
+
* - Address of deployed StealthAnnouncer contract
|
193
|
+
*/
|
194
|
+
contractAddress?: string;
|
195
|
+
/**
|
196
|
+
* - ABI of the contract (optional, defaults to STEALTH_ANNOUNCER_ABI)
|
197
|
+
*/
|
198
|
+
abi?: string;
|
199
|
+
};
|
200
|
+
import { ethers } from "ethers";
|
@@ -0,0 +1,61 @@
|
|
1
|
+
export type BubbleProviderOptions = {
|
2
|
+
/**
|
3
|
+
* - RPC URL for the provider
|
4
|
+
*/
|
5
|
+
rpcUrl: string;
|
6
|
+
/**
|
7
|
+
* - Contract address
|
8
|
+
*/
|
9
|
+
contractAddress: string;
|
10
|
+
/**
|
11
|
+
* - Contract ABI
|
12
|
+
*/
|
13
|
+
contractAbi?: any;
|
14
|
+
/**
|
15
|
+
* - Gun instance
|
16
|
+
*/
|
17
|
+
gun: any;
|
18
|
+
/**
|
19
|
+
* - Encryption keypair
|
20
|
+
*/
|
21
|
+
keypair: {
|
22
|
+
epub: string;
|
23
|
+
epriv: string;
|
24
|
+
};
|
25
|
+
};
|
26
|
+
export type GunNode = {
|
27
|
+
name?: string;
|
28
|
+
owner?: string;
|
29
|
+
filePath?: string;
|
30
|
+
content?: string;
|
31
|
+
created?: number;
|
32
|
+
updated?: number;
|
33
|
+
size?: number;
|
34
|
+
readOnly?: boolean;
|
35
|
+
encryptionInfo?: {
|
36
|
+
ownerEpub: string;
|
37
|
+
ownerAddress: string;
|
38
|
+
};
|
39
|
+
};
|
40
|
+
export type EthereumProvider = {
|
41
|
+
request: (request: {
|
42
|
+
method: string;
|
43
|
+
params?: any[] | Record<string, any>;
|
44
|
+
}) => Promise<any>;
|
45
|
+
chainId?: string;
|
46
|
+
isMetaMask?: boolean;
|
47
|
+
};
|
48
|
+
export type FileMetadata = {
|
49
|
+
name: string;
|
50
|
+
owner: string;
|
51
|
+
filePath: string;
|
52
|
+
created: number;
|
53
|
+
updated: number;
|
54
|
+
size: number;
|
55
|
+
readOnly: boolean;
|
56
|
+
};
|
57
|
+
import { GunEth } from "./core/gun-eth.js";
|
58
|
+
import { ProofChain } from "./features/proof/ProofChain.js";
|
59
|
+
import { StealthChain } from "./features/stealth/StealthChain.js";
|
60
|
+
import { GUNBubbleProvider } from "./features/bubbles/providers/gun-bubble-provider.js";
|
61
|
+
export { GunEth, ProofChain, StealthChain, GUNBubbleProvider };
|
@@ -0,0 +1,11 @@
|
|
1
|
+
export function generateRandomId(): string;
|
2
|
+
export function getContractAddresses(chain?: string): {
|
3
|
+
PROOF_OF_INTEGRITY_ADDRESS: string;
|
4
|
+
STEALTH_ANNOUNCER_ADDRESS: string;
|
5
|
+
};
|
6
|
+
export function setSigner(newRpcUrl: any, newPrivateKey: any): any;
|
7
|
+
export function getSigner(chain?: string): Promise<any>;
|
8
|
+
export type EthereumProvider = import("ethers").Eip1193Provider;
|
9
|
+
export type WindowWithEthereum = Window & {
|
10
|
+
ethereum?: EthereumProvider;
|
11
|
+
};
|
@@ -0,0 +1,32 @@
|
|
1
|
+
/**
|
2
|
+
* @typedef {Object|string} KeyPair
|
3
|
+
* @property {string} [epriv] - Private encryption key
|
4
|
+
* @property {string} [epub] - Public encryption key
|
5
|
+
* @property {string} [pub] - Optional public key
|
6
|
+
* @property {string} [priv] - Optional private key
|
7
|
+
*/
|
8
|
+
/**
|
9
|
+
* Encrypts data using SEA encryption
|
10
|
+
* @param {string|Object} data - Data to encrypt
|
11
|
+
* @param {KeyPair} keypair - Keypair for encryption
|
12
|
+
* @returns {Promise<string>} Encrypted data
|
13
|
+
* @throws {Error} If encryption fails
|
14
|
+
*/
|
15
|
+
export function encrypt(data: string | any, keypair: KeyPair): Promise<string>;
|
16
|
+
/**
|
17
|
+
* Decrypts data using SEA decryption
|
18
|
+
* @param {string} data - Encrypted data to decrypt
|
19
|
+
* @param {KeyPair} keypair - Keypair for decryption
|
20
|
+
* @returns {Promise<string|Object>} Decrypted data
|
21
|
+
* @throws {Error} If decryption fails
|
22
|
+
*/
|
23
|
+
export function decrypt(data: string, keypair: KeyPair): Promise<string | any>;
|
24
|
+
/**
|
25
|
+
* Derives a shared secret key between two keypairs
|
26
|
+
* @param {string} recipientEpub - Recipient's public encryption key
|
27
|
+
* @param {KeyPair} senderKeypair - Sender's keypair
|
28
|
+
* @returns {Promise<string>} Derived shared key
|
29
|
+
* @throws {Error} If key derivation fails
|
30
|
+
*/
|
31
|
+
export function deriveSharedKey(recipientEpub: string, senderKeypair: KeyPair): Promise<string>;
|
32
|
+
export type KeyPair = any | string;
|
package/package.json
CHANGED
@@ -1,36 +1,120 @@
|
|
1
1
|
{
|
2
2
|
"name": "gun-eth",
|
3
|
-
"version": "
|
3
|
+
"version": "3.0.0",
|
4
|
+
"type": "module",
|
5
|
+
"main": "./dist/gun-eth.cjs",
|
6
|
+
"module": "./dist/gun-eth.mjs",
|
7
|
+
"browser": "./dist/gun-eth.browser.mjs",
|
8
|
+
"types": "./dist/types/index.d.ts",
|
9
|
+
"exports": {
|
10
|
+
".": {
|
11
|
+
"import": {
|
12
|
+
"browser": "./dist/gun-eth.browser.mjs",
|
13
|
+
"default": "./dist/gun-eth.mjs"
|
14
|
+
},
|
15
|
+
"require": "./dist/gun-eth.cjs"
|
16
|
+
}
|
17
|
+
},
|
4
18
|
"description": "A GunDB plugin for Ethereum, and Web3",
|
5
|
-
"
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
19
|
+
"scripts": {
|
20
|
+
"test": "hardhat test",
|
21
|
+
"compile": "hardhat compile",
|
22
|
+
"start-node": "hardhat node",
|
23
|
+
"deploy-local": "hardhat run scripts/start-local-node.cjs --network localhost",
|
24
|
+
"deploy-contracts": "hardhat run scripts/deploy-contracts.cjs",
|
25
|
+
"test-stealth": "cross-env NODE_ENV=development node --experimental-json-modules test/stealth-example.js",
|
26
|
+
"test-proof": "cross-env NODE_ENV=development node --experimental-json-modules test/proof-example.js",
|
27
|
+
"test-bubble": "cross-env NODE_ENV=development node --experimental-json-modules test/bubble-test.js",
|
28
|
+
"test-contracts": "npx hardhat test ./test/index.test.cjs --config hardhat.config.cjs",
|
29
|
+
"test-all": "npm run test-stealth && npm run test-proof && npm run test-bubble && npm run test-contracts",
|
30
|
+
"build": "rollup -c",
|
31
|
+
"prepare": "npm run build",
|
32
|
+
"clean": "rimraf dist",
|
33
|
+
"start-provider": "node ./templates/template-bubble-provider.js",
|
34
|
+
"start-client": "node ./templates/template-bubble-client.js"
|
35
|
+
},
|
12
36
|
"dependencies": {
|
13
|
-
"
|
14
|
-
"
|
15
|
-
"
|
16
|
-
"
|
17
|
-
"
|
18
|
-
"
|
19
|
-
"
|
20
|
-
"
|
37
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
38
|
+
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
39
|
+
"@nomiclabs/hardhat-waffle": "^2.0.6",
|
40
|
+
"@openzeppelin/contracts": "^5.1.0",
|
41
|
+
"@peculiar/webcrypto": "^1.5.0",
|
42
|
+
"@scobru/mogu": "^4.0.7",
|
43
|
+
"cors": "^2.8.5",
|
44
|
+
"ethereum-waffle": "^4.0.10",
|
45
|
+
"ethers": "^6.0.0",
|
46
|
+
"express": "^4.21.1",
|
47
|
+
"gun": "^0.2020.1239",
|
48
|
+
"hardhat-verify": "^1.0.0",
|
49
|
+
"node-fetch": "^3.3.2",
|
50
|
+
"text-encoding": "^0.7.0"
|
21
51
|
},
|
22
52
|
"devDependencies": {
|
23
|
-
"@
|
24
|
-
"@
|
25
|
-
"
|
26
|
-
"
|
53
|
+
"@babel/core": "^7.23.2",
|
54
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
55
|
+
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
56
|
+
"@babel/preset-env": "^7.23.2",
|
57
|
+
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
|
58
|
+
"@nomicfoundation/hardhat-ethers": "^3.0.0",
|
59
|
+
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
|
60
|
+
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
|
61
|
+
"@nomicfoundation/hardhat-verify": "^2.0.12",
|
62
|
+
"@nomiclabs/hardhat-ethers": "^2.2.3",
|
63
|
+
"@rollup/plugin-babel": "^6.0.0",
|
64
|
+
"@rollup/plugin-commonjs": "^25.0.0",
|
65
|
+
"@rollup/plugin-json": "^6.0.0",
|
66
|
+
"@rollup/plugin-node-resolve": "^15.0.0",
|
67
|
+
"@rollup/plugin-replace": "^5.0.0",
|
68
|
+
"@typechain/ethers-v6": "^0.4.0",
|
69
|
+
"@typechain/hardhat": "^8.0.0",
|
70
|
+
"@types/chai": "^4.2.0",
|
71
|
+
"@types/mocha": "^10.0.1",
|
72
|
+
"assert": "^2.1.0",
|
73
|
+
"buffer": "^6.0.3",
|
74
|
+
"chai": "^4.3.7",
|
75
|
+
"core-js": "3",
|
76
|
+
"cross-env": "^7.0.3",
|
77
|
+
"crypto-browserify": "^3.12.1",
|
78
|
+
"file-loader": "^6.2.0",
|
79
|
+
"hardhat": "^2.22.16",
|
80
|
+
"hardhat-gas-reporter": "^1.0.8",
|
81
|
+
"path-browserify": "^1.0.1",
|
82
|
+
"process": "^0.11.10",
|
83
|
+
"rimraf": "^5.0.0",
|
84
|
+
"rollup": "^3.0.0",
|
27
85
|
"rollup-plugin-terser": "^7.0.2",
|
28
|
-
"
|
86
|
+
"solidity-coverage": "^0.8.1",
|
87
|
+
"stream-browserify": "^3.0.0",
|
88
|
+
"terser-webpack-plugin": "^5.3.9",
|
89
|
+
"ts-node": "^10.9.1",
|
90
|
+
"typechain": "^8.2.0",
|
91
|
+
"typescript": "^5.0.0",
|
92
|
+
"url": "^0.11.0",
|
93
|
+
"util": "^0.12.4",
|
94
|
+
"webpack": "^5.0.0",
|
95
|
+
"webpack-cli": "^4.0.0"
|
29
96
|
},
|
30
|
-
"
|
31
|
-
|
32
|
-
"
|
33
|
-
"
|
97
|
+
"author": "scobru",
|
98
|
+
"repository": {
|
99
|
+
"type": "git",
|
100
|
+
"url": "git+https://github.com/scobru/gun-eth.git"
|
101
|
+
},
|
102
|
+
"license": "MIT",
|
103
|
+
"keywords": [
|
104
|
+
"gundb",
|
105
|
+
"web3",
|
106
|
+
"evm",
|
107
|
+
"ethereum",
|
108
|
+
"decentralized",
|
109
|
+
"storage",
|
110
|
+
"gun",
|
111
|
+
"db"
|
112
|
+
],
|
113
|
+
"bugs": {
|
114
|
+
"url": "https://github.com/scobru/gun-eth/issues"
|
34
115
|
},
|
35
|
-
"
|
116
|
+
"homepage": "https://github.com/scobru/gun-eth#readme",
|
117
|
+
"files": [
|
118
|
+
"dist"
|
119
|
+
]
|
36
120
|
}
|