travist / jsencrypt

A zero-dependency Javascript library to perform OpenSSL RSA Encryption, Decryption, and Key Generation.
http://www.travistidwell.com/jsencrypt
Other
6.65k stars 2.01k forks source link

[BUG] - process is undefined on Angular #267

Closed pl4yradam closed 1 year ago

pl4yradam commented 1 year ago

When running Angular projects now using the package, the latest 3.3 fix from this commit breaks it

https://github.com/travist/jsencrypt/commit/29921465b881eb6512daa8385f9752ea90285f82

Angular runs in the browser and doesn't have a concept of process. Can this be reverted?

Temporary solutions:

Error dump: Uncaught ReferenceError: process is not defined at 5006 (JSEncrypt.js:3:15) at __webpack_require__ (bootstrap:19:1) at 1287 (JSEncryptRSAKey.js:320:28) at __webpack_require__ (bootstrap:19:1) at 1677 (router.mjs:6124:1) at __webpack_require__ (bootstrap:19:1) at 6747 (app.component.html:5:7) at __webpack_require__ (bootstrap:19:1) at 4431 (environment.ts:14:3) at __webpack_require__ (bootstrap:19:1)

heyixing commented 1 year ago

also in vue, someone add process vars in the latest version 3.30

lribeirodev commented 1 year ago

We noticed this error on the project too, after doing some search about it, I found a workaround and added the following code inside to /src/polyfills.ts

(window as any).process = {env: {}}; // added global env variable

resolved the problem!

pl4yradam commented 1 year ago

We noticed this error on the project too, after doing some search about it, I found a workaround and added the following code inside to /src/polyfills.ts

(window as any).process = {env: {}}; // added global env variable

resolved the problem!

This shouldnt be needed for client side development, overwriting global behavior is a plaster not a fix

lribeirodev commented 1 year ago

We noticed this error on the project too, after doing some search about it, I found a workaround and added the following code inside to /src/polyfills.ts

(window as any).process = {env: {}}; // added global env variable

resolved the problem!

This shouldnt be needed for client side development, overwriting global behavior is a plaster not a fix

I Agree with you, my friend found a better solution, setting the version of the lib in package.json without the bug is better, have a great day!

pl4yradam commented 1 year ago

We noticed this error on the project too, after doing some search about it, I found a workaround and added the following code inside to /src/polyfills.ts (window as any).process = {env: {}}; // added global env variable resolved the problem!

This shouldnt be needed for client side development, overwriting global behavior is a plaster not a fix

I Agree with you, my friend found a better solution, setting the version of the lib in angular.json without the bug is better, have a great day!

That will indeed work on a per project basis e.g. setting package.json to "jsencrypt": "3.2.1" this will allow it to work, however with peer dependencies working on multiple projects at one with internal packages, this will break.

Glad that solution has worked for you 👍 Reverting the version is a good short term fix