Replies: 13 comments 2 replies
-
I ended up getting past the build error by adding I'm now however stuck with the importing of the |
Beta Was this translation helpful? Give feedback.
-
Hey @poltak 👋 I don't know much about React Native, but if it behaves more like a browser than like Node.js, you might have better luck trying to convince OpenPGP.js that it's running in a browser rather than that it's running in Node.js. Probably you could do this by replacing |
Beta Was this translation helpful? Give feedback.
-
From what I understand, it behaves different to both node and browser. You're missing lots of APIs that are available in both/either node and browsers. There seem to be lots of ports of certain APIs available for React Native, like with the streams, crypto, and buffer libs that I've linked. Unfortunately I haven't got those all working properly with this implementation of OpenPGP. There are some other implementations of OpenPGP available for React Native, though they don't seem to be up to this project's standard of being tried-and-true. So far I've found these ones:
Unfortunately this didn't have any effect, but thanks for the suggestion. |
Beta Was this translation helpful? Give feedback.
-
Hey @poltak , Did you ever manage to resolve this issue ? |
Beta Was this translation helpful? Give feedback.
-
@poltak @gabidi First of all, as I know, you will end up with 1 binary (index.bundle or something else) if you are using React Native, and the license of this library is LGPL, so it will be required to open source all of your js code with LGPL. Could you let me know if you know any workaround for this. I also wanted to use this functionality in RN, but I couldn't as the license. |
Beta Was this translation helpful? Give feedback.
-
@openpgpjs I want to use this library at React Native, but as above reason, I cannot use right now. Is there any chance for you to change LICENSE? |
Beta Was this translation helpful? Give feedback.
-
@ken0x0a Open sourcing the application is part of our product roadmap and is not an issue for me. Thank you for taking the time to raise that flag, I do appreciate it. |
Beta Was this translation helpful? Give feedback.
-
The library LGPL license is not preventing it from being used inside proprietary software: |
Beta Was this translation helpful? Give feedback.
-
@chesnokovilya Thank you for your answer! Can I ask further more about it? What you told me means:
Is it correct? |
Beta Was this translation helpful? Give feedback.
-
I think it is not correct. |
Beta Was this translation helpful? Give feedback.
-
@chesnokovilya Thank you for the reply! As I understand, I can use this library for my work. As I found another libraries with clear license, so I should use them. Thank you so much for your help and time 🙏 |
Beta Was this translation helpful? Give feedback.
-
I got this library to work together with react-native by doing some steps. Right now my solution will only work by modifying a library which is needed. I opened this PR to address that. Basically, my solution is to use https://www.npmjs.com/package/rn-nodeify to make sure react-native has (almost) every API as normal Node.js. To get it working you can follow these steps:
(It might be that you dont actually need all of the listed shims, this is simply what I have in my project)
At this point you already have every needed Node Functionality available. But there still is one catch, this is where my PR mentioned above comes in to play.
Go to
|
Beta Was this translation helpful? Give feedback.
-
Hi 👋 Thanks for looking into it! It seems this uses the browserify-crypto implementation of the Node.js crypto API in pure JS. For performance and security, I would recommend using the native web crypto API instead, if possible. react-native-webview-crypto seems to be an attempt at that (though the interface seems to add some overhead, so I'm not sure if it's actually more performant, but it should at least be constant-time). You could try using that, together with react-native-get-random-values, and then use the browser build of OpenPGP.js (instead of the Node.js build). That seems like a more straightforward way to go, but I haven't tested it, so I'm not sure if it works. The other advantage of that would be that you'd get the asmcrypto.js fallbacks for algorithms that aren't natively supported in Web Crypto, rather than the browserify-crypto implementations. The former are probably more performant, but again, I haven't benchmarked the latter so YMMV. |
Beta Was this translation helpful? Give feedback.
-
Hi there.
Has anyone had success getting this lib to work on React Native?
Adding it straight into the RN project I'm working on immediately crashes the app at load, saying it can't resolve the
crypto
module.Looking deeper into this package I found that both the use of
crypto
andstreams
APIs seem to not be available on RN.For
crypto
, there is a RN port here: https://github.com/tradle/react-native-cryptoFor
streams
,readable-stream
seems RN-compatible: https://github.com/nodejs/readable-streamI ended up creating a fork of this repo, replacing the importing of the above libs with the RN-compatible ones.
This got me past some of these errors, however I realized the
react-native-crypto
leads to an error when running the NPMbuild
script, which I presume is something to do with the current grunt setup:I also saw some of the code to switch between using certain deps depending on whether or not it is being run in node or the browser. Perhaps adding proper support for React Native would also need an update to this code to factor in a environment.
I will add to this with further findings.
What else does anyone know that is stopping this from just working with React Native?
Beta Was this translation helpful? Give feedback.
All reactions