gun-eth 1.3.5 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. package/README.md +18 -207
  2. package/dist/gun-eth-protocol.cjs.js +11528 -0
  3. package/dist/gun-eth-protocol.esm.js +11503 -0
  4. package/dist/gun-eth-protocol.js +18 -0
  5. package/dist/gun-eth-protocol.react.js +11503 -0
  6. package/dist/gun-eth-protocol.umd.js +18 -0
  7. package/jsdoc.json +7 -0
  8. package/package.json +28 -25
  9. package/rollup.config.js +80 -0
  10. package/src/index.js +160 -512
  11. package/src/lib/authentication/index.js +13 -0
  12. package/src/lib/authentication/isAuthenticated.js +20 -0
  13. package/src/lib/authentication/login.js +25 -0
  14. package/src/lib/authentication/register.js +58 -0
  15. package/src/lib/blockchain/ethereum.js +74 -0
  16. package/src/lib/blockchain/shine.js +204 -0
  17. package/src/lib/certificates/friendsCertificates.js +92 -0
  18. package/src/lib/certificates/index.js +44 -0
  19. package/src/lib/certificates/messagingCertificates.js +94 -0
  20. package/src/lib/friends/acceptFriendRequest.js +69 -0
  21. package/src/lib/friends/addFriendRequest.js +49 -0
  22. package/src/lib/friends/friendRequests.js +51 -0
  23. package/src/lib/friends/friendsList.js +57 -0
  24. package/src/lib/friends/index.js +36 -0
  25. package/src/lib/friends/rejectFriendRequest.js +31 -0
  26. package/src/lib/messaging/chatsList.js +42 -0
  27. package/src/lib/messaging/createChat.js +132 -0
  28. package/src/lib/messaging/index.js +36 -0
  29. package/src/lib/messaging/messageList.js +106 -0
  30. package/src/lib/messaging/sendMessage.js +132 -0
  31. package/src/lib/messaging/sendVoiceMessage.js +119 -0
  32. package/src/lib/notes/createNote.js +41 -0
  33. package/src/lib/notes/deleteNote.js +12 -0
  34. package/src/lib/notes/getNote.js +25 -0
  35. package/src/lib/notes/getUserNote.js +59 -0
  36. package/src/lib/notes/index.js +8 -0
  37. package/src/lib/notes/updateNotes.js +35 -0
  38. package/src/lib/post/createPost.js +17 -0
  39. package/src/lib/post/decryptPost.js +14 -0
  40. package/src/lib/post/deletePost.js +13 -0
  41. package/src/lib/post/encryptPost,js +16 -0
  42. package/src/lib/post/getPost.js +36 -0
  43. package/src/lib/post/index.js +9 -0
  44. package/src/lib/post/updatePost.js +16 -0
  45. package/src/state/gun.js +33 -0
  46. package/types/types.d.ts +244 -0
  47. package/TUTORIAL.md +0 -103
  48. package/src/examples/eth2gun.html +0 -163
  49. package/src/examples/gun2eth.html +0 -164
  50. package/src/examples/shine.html +0 -256
  51. /package/src/{abis → lib/blockchain/abis}/SHINE.json +0 -0
  52. /package/src/{contracts → lib/blockchain/contracts}/SHINE.sol +0 -0
package/README.md CHANGED
@@ -1,207 +1,18 @@
1
- # GUN-ETH
2
-
3
- <img src="https://imgs.search.brave.com/RM76D4wyToxCzGffJLw33O_L3glhpIVS3KLvXehpMt8/rs:fit:500:0:0:0/g:ce/aHR0cHM6Ly93d3cu/dXNlcmxvZ29zLm9y/Zy9maWxlcy9sb2dv/cy9mZXJuYW5kb3Nh/bnR1Y2NpLzI5NDY5/X2d1bmRiLWxvZ28u/cG5n" alt="gun" width="200"/>
4
- <img src="https://imgs.search.brave.com/kQyriTMPqw42DEhIQj3eEKIcLZu_C4nNIVR8KtAn3lo/rs:fit:500:0:0:0/g:ce/aHR0cHM6Ly93d3cu/bG9nby53aW5lL2Ev/bG9nby9FdGhlcmV1/bS9FdGhlcmV1bS1E/aWFtb25kLUxvZ28u/d2luZS5zdmc" alt="eth" width="200"/>
5
-
6
- ## Table of Contents
7
-
8
- 1. [DESCRIPTION](#description)
9
- 2. [SMART CONTRACT](#smart-contract)
10
- 3. [KEY FEATURES](#key-features)
11
- 4. [HOW TO INSTALL](#how-to-install)
12
- 5. [HOW TO USE](#how-to-use)
13
- 6. [HOW IT WORKS](#how-it-works)
14
- 7. [CORE FUNCTIONS](#core-functions)
15
- 8. [SHINE](#shine)
16
- 9. [STANDALONE MODE](#standalone-mode)
17
- 10. [SECURITY CONSIDERATIONS](#security-considerations)
18
- 11. [CONTRIBUTING](#contributing)
19
- 12. [LICENSE](#license)
20
- 13. [CONTACT](#contact)
21
-
22
- ## DESCRIPTION
23
-
24
- Gun-eth is a plugin for GunDB that integrates Ethereum and Web3 functionality. This plugin extends GunDB's capabilities by allowing interaction with the Ethereum blockchain and providing cryptographic and signature management features.
25
-
26
- ## SMART CONTRACT
27
-
28
- SHINE Smart Contract deployed on Optimism Sepolia: [0x43D838b683F772F08f321E5FA265ad3e333BE9C2](https://sepolia-optimism.etherscan.io/address/0x43D838b683F772F08f321E5FA265ad3e333BE9C2)
29
-
30
- Currently, the contract is deployed only on Optimism Sepolia. In the future, it will be deployed on multiple chains.
31
-
32
- ## No time? Check the [TUTORIAL](./TUTORIAL.md)
33
-
34
- ## KEY FEATURES
35
-
36
- - **Ethereum Signature Verification**: Verify Ethereum signatures for messages.
37
- - **Password Generation**: Generate secure passwords from Ethereum signatures.
38
- - **Signature Creation**: Create Ethereum signatures for messages.
39
- - **Encrypted Key Pair Management**: Create, store, and retrieve encrypted key pairs.
40
- - **SHINE Implementation**: Implement the SHINE for data verification on the blockchain.
41
- - **Custom Token Management**: Set and retrieve custom tokens for Gun operations.
42
-
43
- ## HOW TO INSTALL
44
-
45
- ```bash
46
- npm install gun-eth
47
- ```
48
-
49
- ```javascript
50
- import gun from "gun";
51
- import "gun-eth";
52
-
53
- const gun = Gun();
54
-
55
- await gun.generatePassword("YOUR_SIGNATURE");
56
- ```
57
-
58
- ## HOW TO USE
59
-
60
- Learn more about Gun.js [here](https://gun.eco/docs/Getting-Started).
61
-
62
- Learn more about plugin implementation [here](https://github.com/amark/gun/wiki/Adding-Methods-to-the-Gun-Chain#abstraction-layers).
63
-
64
-
65
- ## HOW IT WORKS
66
-
67
- ### Create KeyPair
68
-
69
-
70
- [![](https://mermaid.ink/img/pako:eNpdUUtuwjAQvcrIGzZwgSwqJSRQhEorwqZNWLjxkFgkduSPEAJu1Fv0Yp0khaj1wh6P3s_jCyu0QBawQ61PRcWNg12cKxhWmK2T97dwtYVlskm24W71utnDbP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TBXvHfM4LVHTfut18x5i-M9spBadskjvsXWjEWL4yVNHXe7j00vSWe1YmXYbD2nw7Uvkrn8NWAmmLeLxZNwQYsQ8q4FOX4FNVRxOwRM4yYV_4KTqeI1dvqXmK5s3p7VQnzLDkcMNLucGReys-mrFwuuEVf8gPx7LGLQlpNq2ZC60EdsJyrH607zP0f6c7pXw?type=png)](https://mermaid.live/edit#pako:eNplUsluwjAQ_ZWRz_ADObQCEiggOLAc2iQHN56ABbGjsU2FAv_erBBBLs7Yb5lnT8ESLZB5LD3rv-TIycLOjxSU3yjc7kabnQcbtCTxgrDEa84lxTAcfsC42BskyElfpEADXAhCU65KgJEHxa0j_Lw3WuOKcvtGc4NJ-NBDldA1tyjg1ChDSjqDmVP-OG6Ik9rLL4J3qHZKdPr-Uz8IfayxD6QzUh26RnvNtRZBbTEtWprUCoxLkjJL6s6dwfRpMKsCOFIg8KWnuI9d6xt8dVAk0uTBXvHfM4LVHTfut18x5i-M9spBadskjvsXWjEWL4yVNHXe7j00vSWe1YmXYbD2nw7Uvkrn8NWAmmLeLxZNwQYsQ8q4FOX4FNVRxOwRM4yYV_4KTqeI1dvqXmK5s3p7VQnzLDkcMNLucGReys-mrFwuuEVf8gPx7LGLQlpNq2ZC60EdsJyrH607zP0f6c7pXw)
76
-
77
- ## CORE FUNCTIONS
78
-
79
- - `verifySignature(message, signature)`: Verifies an Ethereum signature for a given message.
80
-
81
- ```javascript
82
- const recoveredAddress = await gun.verifySignature(message, signature);
83
- ```
84
-
85
- - `generatePassword(signature)`: Generates a password from an Ethereum signature.
86
-
87
- ```javascript
88
- const password = gun.generatePassword(signature);
89
- ```
90
-
91
- - `createSignature(message)`: Creates an Ethereum signature for a message.
92
-
93
- ```javascript
94
- const signature = await gun.createSignature(message);
95
- ```
96
-
97
- - `createAndStoreEncryptedPair(address, signature)`: Creates and stores an encrypted key pair.
98
-
99
- ```javascript
100
- await gun.createAndStoreEncryptedPair(address, signature);
101
- ```
102
-
103
- - `getAndDecryptPair(address, signature)`: Retrieves and decrypts a stored key pair.
104
-
105
- ```javascript
106
- const decryptedPair = await gun.getAndDecryptPair(address, signature);
107
- ```
108
-
109
- - `shine(chain, nodeId, data, callback)`: Implements SHINE for data verification and storage on the blockchain.
110
-
111
- ```javascript
112
- gun.shine("optimismSepolia", nodeId, data, callback);
113
- ```
114
-
115
- ## SHINE
116
-
117
- SHINE (Secure Hash Integrity Network Ethereum) provides a mechanism for verifying data integrity using Ethereum and Gun.js.
118
-
119
-
120
- [![](https://mermaid.ink/img/pako:eNplk1GTmjAQx79KJs_oICAiD9epQoX25Dq1006LPqRkPTMHiRODdx763S8Ez7N3PCXZ__73txvS4EJQwCFel-Kx2BCp0M9oyZH-PucL1e4XSZrF6BdItmYFUUzwFer1btCkSfm2ViHi2iGln05d2qQNHv_A7oim-Q9QksEeECWKoLUUFZrVPJqsOu3UGEVNZKKi5heX6M0lzuMnJUmhUCG4Aq4SstusrmWZOKIvecxpiIwTF6pzO6tiU2aWmx4OHYvgPd0u42fJzEiSjmRPSkYvilek5A0pzWegUEkU7BSSUAhJu-b-laJ4uPZNLoBf3wHuzUDhlTE1AN-uRO8E19Nt_W41AwepGRCHx_MlnLW3xmyeTyW08Y9zmxtBpm9YSECM_3crmQne5b8l08mCf-zqzii-d7CZrm5GumvN6ApbuAJZEUb1b9W0CUusNlDBEod6SYl8WGJzzE9aS2olFgde4FDJGiwsRX2_weGalDu9q7faGiJG7iWpLqdbwnHY4Ccc9pxxf-wEA9exPc92A384tPABh8NB33WDwdCxfcfxAy84WfhZCG0x6HuuZ49HI98PRjpojywMlGn2efcSzIMwNf6ahBbr9AJRuPoz?type=png)](https://mermaid.live/edit#pako:eNplk1GTmjAQx79KJs_oICAiD9epQoX25Dq1006LPqRkPTMHiRODdx763S8Ez7N3PCXZ__73txvS4EJQwCFel-Kx2BCp0M9oyZH-PucL1e4XSZrF6BdItmYFUUzwFer1btCkSfm2ViHi2iGln05d2qQNHv_A7oim-Q9QksEeECWKoLUUFZrVPJqsOu3UGEVNZKKi5heX6M0lzuMnJUmhUCG4Aq4SstusrmWZOKIvecxpiIwTF6pzO6tiU2aWmx4OHYvgPd0u42fJzEiSjmRPSkYvilek5A0pzWegUEkU7BSSUAhJu-b-laJ4uPZNLoBf3wHuzUDhlTE1AN-uRO8E19Nt_W41AwepGRCHx_MlnLW3xmyeTyW08Y9zmxtBpm9YSECM_3crmQne5b8l08mCf-zqzii-d7CZrm5GumvN6ApbuAJZEUb1b9W0CUusNlDBEod6SYl8WGJzzE9aS2olFgde4FDJGiwsRX2_weGalDu9q7faGiJG7iWpLqdbwnHY4Ccc9pxxf-wEA9exPc92A384tPABh8NB33WDwdCxfcfxAy84WfhZCG0x6HuuZ49HI98PRjpojywMlGn2efcSzIMwNf6ahBbr9AJRuPoz)
121
-
122
-
123
-
124
- #### SHINE Contract Configuration
125
-
126
- Currently, SHINE supports only the Optimism Sepolia network. The contract address is managed internally:
127
-
128
- ```javascript
129
- const SHINE_OPTIMISM_SEPOLIA = "0x43D838b683F772F08f321E5FA265ad3e333BE9C2";
130
- ```
131
-
132
- To support other chains in the future, the plugin will select the appropriate address based on the `chain` parameter provided to the `shine` function.
133
-
134
- #### SHINE Helper Functions
135
-
136
- SHINE uses several internal helper functions to interact with the blockchain:
137
-
138
- - `getSigner()`: Retrieves an Ethereum signer from the browser provider (e.g., MetaMask).
139
- - `verifyOnChain(nodeId, contentHash)`: Verifies data integrity on the blockchain.
140
- - `writeOnChain(nodeId, contentHash)`: Writes the content hash to the blockchain.
141
- - `getLatestRecord(nodeId)`: Retrieves the latest record associated with a nodeId from the blockchain.
142
-
143
- These functions are used internally by the `shine` method and are not directly exposed to the user.
144
-
145
- ### Usage Examples
146
-
147
- #### Verifying Data by NodeId
148
-
149
- ```javascript
150
- const nodeId = "your-node-id-here";
151
-
152
- gun.shine("optimismSepolia", nodeId, null, (ack) => {
153
- if (ack.ok) {
154
- console.log("Data verified on blockchain", ack);
155
- console.log("Timestamp:", ack.timestamp);
156
- console.log("Updater:", ack.updater);
157
- console.log("Latest Record:", ack.latestRecord);
158
- } else {
159
- console.log("Data not verified or not found", ack);
160
- }
161
- });
162
- ```
163
-
164
- #### Storing New Data
165
-
166
- ```javascript
167
- const data = { message: "Hello, blockchain!" };
168
-
169
- gun.shine("optimismSepolia", null, data, (ack) => {
170
- if (ack.ok) {
171
- console.log("Data stored on Gun.js and blockchain", ack);
172
- console.log("New Node ID:", ack.nodeId);
173
- console.log("Transaction Hash:", ack.txHash);
174
- } else {
175
- console.log("Error storing data", ack);
176
- }
177
- });
178
- ```
179
-
180
- ## STANDALONE MODE
181
-
182
- For users who want to run the plugin without a browser wallet, you can use the standalone mode. This requires setting up an RPC URL and a private key:
183
-
184
- ```javascript
185
- gun.setStandaloneConfig("https://your-rpc-url", "your-private-key");
186
- ```
187
-
188
- Make sure to keep your private key secure and never expose it in client-side code.
189
-
190
- ### Security Considerations
191
-
192
- - Use a secure Ethereum provider (e.g., MetaMask) when interacting with functions that require signatures.
193
- - Generated passwords and key pairs are sensitive. Handle them carefully and avoid exposing them.
194
- - Keep Gun.js and Ethereum dependencies up to date for security.
195
- - Be aware of gas costs associated with blockchain interactions when using SHINE.
196
-
197
- ## Contributing
198
-
199
- We welcome contributions! Please open an issue or submit a pull request on GitHub.
200
-
201
- ## License
202
-
203
- This project is released under the MIT license.
204
-
205
- ## Contact
206
-
207
- For questions or support, please open an issue on GitHub: https://github.com/scobru/gun-eth
1
+ # LoneWolf Messenger
2
+
3
+ Welcome to LoneWolf Messenger. LoneWolf Messenger is built to be decentralized and end-to-end encrypted. This means that your data is not in one place and the messages you send to your friends will be encrypted only for you and them to read.
4
+
5
+ # Features
6
+
7
+ - [x] Authentication
8
+ - [x] Profile Management
9
+ - [x] Appearance Settings
10
+ - [x] Friend Requests
11
+ - [x] Accept Friend Request
12
+ - [x] Reject Friend Request
13
+ - [x] Friend List
14
+ - [x] Chat Creation
15
+ - [x] Chat List
16
+ - [x] Messaging
17
+ - [x] End-To-End Messaging
18
+ - [ ] Group Messaging