bitchan / eccrypto

JavaScript Elliptic curve cryptography library
Creative Commons Zero v1.0 Universal
302 stars 99 forks source link

Return statement error #97

Open Vitomir2 opened 5 months ago

Vitomir2 commented 5 months ago

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch eccrypto@1.1.6 for the project I'm working on.

So, there was a problem with the require statement of the ecdh package and the return statement. There is no function, so, we have to delete the return statement and just leave the module exports in the index.js.

Here is the diff that solved my problem (keep in mind that the real path is not exposed):

diff --git a/node_modules/eccrypto/index.js b/node_modules/eccrypto/index.js
index a63218b..e6383b4 100644
--- a/node_modules/eccrypto/index.js
+++ b/node_modules/eccrypto/index.js
@@ -15,13 +15,13 @@ var crypto = require("crypto");
 // try to use secp256k1, fallback to browser implementation
 try {
   var secp256k1 = require("secp256k1");
-  var ecdh = require("./build/Release/ecdh");
+  var ecdh = require("ecdh");
 } catch (e) {
   if (process.env.ECCRYPTO_NO_FALLBACK) {
     throw e;
   } else {
     console.info('secp256k1 unavailable, reverting to browser version');
-    return (module.exports = require("./browser"));
+    module.exports = require("./browser");
   }
 }

This issue body was partially generated by patch-package.