-
Notifications
You must be signed in to change notification settings - Fork 284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[2.6] crypto package: bcrypto dependency's "lib/node/bn.js" breaks front-end application in Safari and iOS #3423
Comments
Thanks for opening this issue! A maintainer will review this in the next few days and explicitly select labels so you know what's going on. If no reviewer appears after a week, a reminder will be sent out. |
I'm currently running into the same problem. I'm using the |
Same issue here. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been closed. If you wish to re-open it please provide additional information. |
Hi @deanpress, how does this solve Safari "BigInt" incompatibility? |
The
@arkecosystem/crypto
package currently breaks front-end applications in Safari and on all browsers in iOS devices.The reason is that crypto's
bcrypto
dependencylib/node/bn.js
uses literals which isn't supported in some browsers and can't be transpiled in Babel.bcrypto
has three versions ofbn.js
in its package. The correct version to use for browsers is the only located inlib/js/bn.js
instead of the defaultlib/node/bn.js
.You can select the package you want to use using env vars (where setting
NODE_BACKEND=js
should allow the package to) but it appears that in many cases thenode
version is still included in the compiled bundle (I haven't been able to figure out how to get it to build without forking).This is a known issue with the bcrypto package. See: bcoin-org/bcrypto#32 bcoin-org/bcrypto#14
Possible Solution
Fork bcrypto and apply this PR: bcoin-org/bcrypto#33
This PR solves the issue and lowers the size of the package. It basically replaces
lib/node/bn.js
withlib/js/bn.js
since BigInt works in both browser and node, and saves people the headache of having to figure this out when using the crypto package for a front-end app.It also saves ~20% of the dependency's build size.
Steps to Reproduce (for bugs)
@arkecosystem/crypto : "2.6-next.9"
in a browser app."No identifiers allowed directly after numeric literal"
SyntaxError: D:\nos\web-wallet-svelte\node_modules\bcrypto\lib\node\bn.js: Identifier directly after number (46:17)
Your Environment
The text was updated successfully, but these errors were encountered: