Can't resolve crypto in react application
mgug01 opened this issue · 3 comments
- [ X] I have checked that the SDK documentation doesn't solve my issue.
- [ X] I have checked that the API documentation doesn't solve my issue.
- [ X] I have searched the Box Developer Forums and my issue isn't already reported (or if it has been reported, I have attached a link to it, for reference).
- [X ] I have searched Issues in this repo and my issue isn't already reported.
Description of the Issue
Is it possible to eliminate the use of crypto
?
We are unable to import the sdk on our create-react-app because of the following error. We tried a few workarounds relating to react-scripts and crypto, but were unable to reach a resolution. Below is the error received:
Module not found: Error: Can't resolve 'crypto' in '/Users/michael.gugliuzza/Documents/GitHub/Sales-Enablement-Studio/web/node_modules/box-typescript-sdk-gen/lib'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
Steps to Reproduce
Currently running on react: 18.2.0
, react-scripts: 5.0.1
Simply imported const { OAuth, OAuthConfig } = require("box-typescript-sdk-gen/lib/oauth.js");
Error Message, Including Stack Trace
Module not found: Error: Can't resolve 'crypto' in '/Users/michael.gugliuzza/Documents/GitHub/Sales-Enablement-Studio/web/node_modules/box-typescript-sdk-gen/lib'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
Versions Used
Typescript SDK: "box-typescript-sdk-gen": "^0.1.0",
Hi @mgug01
First of all, thank you for using the beta version of Box Typescript SDK. For now, we are not supporting this SDK running in browser side yet, but it's in our target.
We will work on it soon and supporting it in the near future.
We are also looking forward to hearing more feedback from you.
Best regards,
Minh
Hi @mgug01 - I resolved the same bug by installing crypto-browserify and stream-browserify working in angular 15 following this stackoverflow item: https://stackoverflow.com/questions/54162297/module-not-found-error-cant-resolve-crypto/67076572#67076572
Hi @mgug01
We have just made an adjustment, so if the TS SDK is running in node, it will use crypto and WebCrypto API in browser.
But before this SDK is fully compatible for frontend projects, we also need to replace stream
,buffer
and process
.
We will let you know when it's ready for use.
Regards,
Minh