twilio / twilio-node

Node.js helper library
MIT License
1.39k stars 504 forks source link

Dependency on deprecated libraries #619

Closed daaibraanies closed 3 years ago

daaibraanies commented 3 years ago

When importing 'twilio' lib into an empty react-native application and running npm install, the app spits errors such as could not find url module. After manually installing the modules the lib requires, it comes to the 'crypto' module after installation of which the error occurs:

Failed building JavaScript bundle.
While trying to resolve module `crypto` from file `/Users/macbook/Desktop/test_app/TestApp/node_modules/twilio/lib/webhooks/webhooks.js`, the package `/Users/macbook/Desktop/test_app/TestApp/node_modules/crypto/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/macbook/Desktop/test_app/TestApp/node_modules/crypto/index.js`.

If you check installed crypto module folder you will find readme file there saying:

# Deprecated Package
This package is no longer supported and has been deprecated. To avoid malicious use, npm is hanging on to the package name.
It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.
Please contact support@npmjs.com if you have questions about this package.

Could someone help with identifying what causes the problem and perhaps a solution? Much appreciated!

Env. info: System: OS: macOS 10.15.7 CPU: (8) x64 Intel(R) Core(TM) i7-3740QM CPU @ 2.70GHz Memory: 1.08 GB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 14.13.0 - /usr/local/bin/node Yarn: 1.22.5 - /usr/local/bin/yarn npm: 6.14.8 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.9.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 13.6, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2 Android SDK: Not Found IDEs: Android Studio: Not Found Xcode: 11.6/11E708 - /usr/bin/xcodebuild Languages: Java: 1.7.0_79 - /usr/bin/javac Python: 2.7.16 - /usr/bin/python npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: https://github.com/expo/react-native/archive/sdk-39.0.3.tar.gz => 0.63.2 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

philnash commented 3 years ago

Hey @daaibraanies, the issue here is actually that you are trying to use this library inside of a React Native application and that is not supported.

The Twilio Node library requires your API secrets in order to make requests to the Twilio API. However it is not safe to expose those secrets to a client side application as a malicious user could intercept them and use them to abuse your Twilio account.

To make calls to the Twilio API from your React Native application we recommend you build your own server side component that proxies the API call from the app, like in this example of sending an SMS from a React application.