OpenSignLabs / OpenSign

🔥 The free & Open Source DocuSign alternative
https://www.opensignlabs.com
Other
3.42k stars 274 forks source link

Getting error [ERR_REQUIRE_ESM]: require() of ES Module /usr/src/app/cloud/main.js from /usr/src/app/node_modules/parse-server/lib/ParseServer.js not supported. #119

Closed Dhara-ZYMR closed 1 year ago

Dhara-ZYMR commented 1 year ago

I am setting up the server on my VM. After doing docker-compose up -d, the server is not starting up. On checking logs, I found the below error:

Error [ERR_REQUIRE_ESM]: require() of ES Module /usr/src/app/cloud/main.js from /usr/src/app/node_modules/parse-server/lib/ParseServer.js not supported.
Instead change the require of main.js in /usr/src/app/node_modules/parse-server/lib/ParseServer.js to a dynamic import() which is available in all CommonJS modules.
    at ParseServer.start (/usr/src/app/node_modules/parse-server/lib/ParseServer.js:138:13)
    at async file:///usr/src/app/index.js:132:3 {
  code: 'ERR_REQUIRE_ESM'
}
/usr/src/app/node_modules/parse-server/lib/ParseServer.js:138
            require(path.resolve(process.cwd(), cloud));
            ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /usr/src/app/cloud/main.js from /usr/src/app/node_modules/parse-server/lib/ParseServer.js not supported.
Instead change the require of main.js in /usr/src/app/node_modules/parse-server/lib/ParseServer.js to a dynamic import() which is available in all CommonJS modules.
    at ParseServer.start (/usr/src/app/node_modules/parse-server/lib/ParseServer.js:138:13)
    at async file:///usr/src/app/index.js:132:3 {
  code: 'ERR_REQUIRE_ESM'
}

Getting this error on Node 16 and 18.

rishabjasrotia commented 1 year ago

Hello @Dhara-ZYMR I have raised PR #103 which fix all local environment issues including one you have raised.

nxglabs commented 1 year ago

@Dhara-ZYMR I have merged the @rishabjasrotia 's pull request to staging branch. Can you try it again using make build command after freshly cloning the repo.

Dhara-ZYMR commented 1 year ago

@rishabjasrotia @nxglabs I tried it again using make build command. I was set up flawlessly. Thanks for the fixes!

After login, I tried to upload the file, the local upload server gave an error. So I have replaced it with AWS creds.

The file gets uploaded, but after adding the signature, the signPdf API is giving error Encrypted files are currently not supported!

Is this related to any setup config or something else? Help would be appreciated. Thanks

nxglabs commented 1 year ago

Can you share the pdf file that is not supported with us if it's not confidential on hello@opensignlabs.com ?

Dhara-ZYMR commented 1 year ago

I am using the sample dummy.pdf file dummy.pdf

Also, I found the following error in logs:

Error: Too few bytes to parse DER.
    at _checkBufferLength (/usr/src/app/node_modules/node-forge/lib/asn1.js:357:17)
    at _fromDer (/usr/src/app/node_modules/node-forge/lib/asn1.js:483:3)
    at Object.asn1.fromDer (/usr/src/app/node_modules/node-forge/lib/asn1.js:458:15)
    at SignPdf.sign (/usr/src/app/node_modules/node-signpdf/dist/signpdf.js:105:45)
    at SignPDF.signPDF (/usr/src/app/cloud/parsefunction/pdf/SignPDF.min.cjs:1:140)
    at PDF (file:///usr/src/app/cloud/parsefunction/pdf/PDF.min.js:177:41)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  available: 0,
  remaining: 0,
  requested: 2
}

This might help to debug the issue. Also, the page just shows the loading spinner and does not get updated.

nxglabs commented 1 year ago

I tried signing the same file on prod. Its working properly. Looks like the problem is in local setup.

rishabjasrotia commented 1 year ago

I will have a look into this error.

rishabjasrotia commented 1 year ago

Hello @Dhara-ZYMR issue is not reproduceable at my local environment too!

Can you add some steps or video?

rishabjasrotia commented 1 year ago

Hello @Dhara-ZYMR, The issue is due to missing PFX_BASE64 environment value which you need to set.

rishabjasrotia commented 1 year ago

Hello @Dhara-ZYMR @nxglabs Issue was due to missing PFX_BASE64 env value. I have updated the document to generate self signed certificates and also updated installation document.

PR #139

rishabjasrotia commented 1 year ago

@andrew-opensignlabs @nxglabs I also found that we have hardcoded passphrase in code for the PFX certificate in SignPDF.min.cjs. This also lead to problem we cannot use another passphrases.

Suggestion: Above coding method is not good we should not expose credentials.

andrew-opensignlabs commented 1 year ago

@rishabjasrotia having the hard coded passphrase is a human error that need to be fixed ASAP. It might not be that big of a security issue right now as it's of no use without the actual certificate base64 string. But it's certainly something from Which we need to learn and avoid putting anything hardcoded in the code. Assigning it to @prafull-opensignlabs he will fix is at the earliest.

prafull-opensignlabs commented 1 year ago

I have raise PR #145 for it

Dhara-ZYMR commented 1 year ago

@rishabjasrotia after adding the PFX_BASE64 value the issue was fixed. Thanks for the quick help.

Just one question: can we use SMTP for sending mail instead of MailGun?

prafull-opensignlabs commented 1 year ago

Currently, we only support Mailgun; however, we plan to add other mail sending services in the future.