gun-eth 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gun-eth",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "A GunDB plugin for Ethereum, and Web3",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -10,7 +10,7 @@
10
10
  <!-- Include Ethers.js -->
11
11
  <script src="https://cdnjs.cloudflare.com/ajax/libs/ethers/6.7.0/ethers.umd.min.js"></script>
12
12
  <!-- Include the Gun-Eth plugin -->
13
- <script src="../gun-eth.js"></script>
13
+ <script src="https://cdn.jsdelivr.net/npm/gun-eth/src/gun-eth.js""></script>
14
14
  <style>
15
15
  body {
16
16
  font-family: Arial, sans-serif;
@@ -10,7 +10,7 @@
10
10
  <!-- Include Ethers.js -->
11
11
  <script src="https://cdnjs.cloudflare.com/ajax/libs/ethers/6.7.0/ethers.umd.min.js"></script>
12
12
  <!-- Include the Gun-Eth plugin -->
13
- <script src="../gun-eth.js"></script>
13
+ <script src="https://cdn.jsdelivr.net/npm/gun-eth/src/gun-eth.js""></script>
14
14
  <style>
15
15
  body {
16
16
  font-family: Arial, sans-serif;
package/src/gun-eth.js CHANGED
@@ -9,6 +9,7 @@
9
9
  })(typeof self !== "undefined" ? self : this, function (Gun, SEA, ethers) {
10
10
  console.log('Factory del plugin Gun-Eth chiamata');
11
11
 
12
+ const MESSAGE_TO_SIGN = "Accesso a GunDB con Ethereum";
12
13
 
13
14
 
14
15
  // Funzione per verificare se ethers è disponibile
@@ -291,6 +292,10 @@
291
292
  */
292
293
  Gun.chain.createSignature = async function (message) {
293
294
  try {
295
+ // Verifica se il messaggio è uguale a MESSAGE_TO_SIGN
296
+ if (message !== MESSAGE_TO_SIGN) {
297
+ throw new Error("Invalid message, valid message is: " + MESSAGE_TO_SIGN);
298
+ }
294
299
  const signer = await getSigner();
295
300
  const signature = await signer.signMessage(message);
296
301
  console.log("Signature created:", signature);
package/src/index.js CHANGED
@@ -12,6 +12,8 @@ let customToken = "";
12
12
  let rpcUrl = "";
13
13
  let privateKey = "";
14
14
 
15
+ const MESSAGE_TO_SIGN = "Accesso a GunDB con Ethereum";
16
+
15
17
  /**
16
18
  * Funzione per ottenere il signer
17
19
  * @returns {Promise<ethers.Signer>} Il signer.
@@ -119,6 +121,10 @@ Gun.chain.generatePassword = function (signature) {
119
121
  */
120
122
  Gun.chain.createSignature = async function (message) {
121
123
  try {
124
+ // Verifica se il messaggio è uguale a MESSAGE_TO_SIGN
125
+ if (message !== MESSAGE_TO_SIGN) {
126
+ throw new Error("Invalid message, valid message is: " + MESSAGE_TO_SIGN);
127
+ }
122
128
  const signer = await getSigner();
123
129
  const signature = await signer.signMessage(message);
124
130
  console.log("Signature created:", signature);