-
Notifications
You must be signed in to change notification settings - Fork 198
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
react-native support #80
Comments
With Expo and react-native, you can patch the new version of It's not the best solution but it work. |
I forgot to answer this, but that was fine because I didn't have an answer, and @aussedatlo has provided us with a potential solution here that I don't understand either. @KoalaSat any insight here? |
Yes, I hacked it for Nostros by forking the At that point I'm just downloading it on my package https://github.com/KoalaSat/nostros/blob/main/package.json#L22 As a little bit of background, the issue is that |
you might also have problems with Buffer, let me know if it's your case @dyegolara |
In the newest nostr-tools version there is no usage of Buffer anymore. |
I wasn't aware of that then maybe I'll try to get rid of the hack for Nostros 👍 |
what's the status of this issue, does nostr-tools support react native now? |
Try this. import * as secp256k1 from "@noble/secp256k1";
import { randomBytes } from 'react-native-randombytes'
secp256k1.utils.randomBytes = function (bytesLength = 32) {
return Uint8Array.from(randomBytes(bytesLength));
} |
@Eosxx even with randomBytes working, |
looks like other projects just don't use the libs from nostr-tools instead.... https://github.com/KoalaSat/nostros/blob/main/frontend/lib/nostr/Nip04/index.ts. im having some luck with isomorphic-webcrypto. everything works but the randomBytes. going to patch it up soon, and then release a new version (maintainer unresponsive). don't like "rolling my own". nostr-tools has more eyeballs. |
Any news on this? trying to implement a client with expo react-native and functions such as getSignature and generatePrivateKey do not seem to work. I have had a quick fix for generatePrivate key such as
Any tips on getting around this? |
i use this: https://github.com/earonesty/isomorphic-webcrypto + expo-crypto works fine to get you all the stuff you need. working on a faster one. will have it up in a week or so |
So you are currently working on a PR to add react native support? Or the solution you say is to use those libraries and emulate the functions from nostr tools? |
I am getting |
Is there any react native proj using nostr-tools? the getRandomValues is also undefined. |
I use nostr-tools in my RN project the following way:
|
I used react-native-get-random-values to polyfill |
Using a SimplePool instance doesn't work for me in react native though. I haven't been able to figure out why. I've tried both |
Someone can use nostr-tools in React Native? I have the next problems: |
Can your share the code please, i have a bare react native app with Expo modules and it doesn't work for me |
Try using https://github.com/wavlake/mobile/blob/467b0824c5adde4da556e86e478ee9a6a1b4cb61/utils/nostr.ts#L4-L5 |
It works fine, but the moment I set up React navigation it stopped working. What can i do? I'm presenting the same problem that i received before |
Did you upgrade nostr-tools? Later versions are even less compatible with react-native. Here is what works for all the projects that I work on:
|
I have tried to polyfill my react-native app so it could use the
crypto
native module, but then I realized that this library is meant to be used by clients, a lot of which doesn't support node's nativecrypto
module.May I suggest using some library instead, like https://github.com/entronad/crypto-es ?
Do you think it would be possible?
The text was updated successfully, but these errors were encountered: