Open fitouch opened 2 years ago
Missed this when I was gone, sorry @fitouch .
I'm also going to use it for RN compile issues that @aethiop is helping @3210jr @basic-bhavya @yokowasis with.
Like I mentioned before, the new version of GUN released the last month is designed for better support in different environments, including native (better buffer detection and less polyfill conflict), however since I can't get xcode to work on my machine, I wasn't able to test it. I was hoping it'd magically work out of the box lol, but this should just be some easy/simple typo we're able to change - so let's schedule a screencall to investigate.
@amark The current issue people are facing is mostly because of your custom require function which is conditional and isnt supported in react native see how I changed the require in GoodDollar/gun
@sirpy can you link to the file with the changes on GoodDollar/gun? I am looking through the sea.js file and the use of the require function is the same.
Thanks
for example if you look at sea.js https://github.com/amark/gun/blob/3b8eb16960967ea547d9e6d6210045efa73a70c3/sea.js#L188 it uses the 'USE' to import text-encoding and not simply 'require'
simply search in gooddollar/gun/sea.js for usage of 'require'
Right @sirpy !
I don't know how I missed it. I completely replaced the USE function locally to get it to work, but using the requires directly is way easier.
Thanks!
I can confirm that simply replacing the USE
calls with explicit requires such as:
try{ global.Buffer = require("buffer").Buffer }
and const { TextEncoder, TextDecoder } = require('text-encoding')
works perfectly!
Old errors gone! However, there are some new warnings from React Native when trying to create a new user with alias, and password:
LOG [TypeError: Cannot read property 'importKey' of undefined]
LOG [TypeError: Cannot read property 'generateKey' of undefined]
WARN Possible Unhandled Promise Rejection (id: 1):
TypeError: Cannot read property 'pub' of undefined
TypeError: Cannot read property 'pub' of undefined
Tried looking around but not sure where to start. Any pointers are greatly appreciated!
This looks like issues in the webview-crypto pollyfill (ie importKey and generateKey are webcrypto api) Have you installed react-native-webview-crypto correctly? latest version?
@sirpy there was an installation error! A quick fresh install of node_modules fixed the error! However, when creating a new user:
gun.user().create('test', 'password ', ack => {
console.log(ack);
});
results in a warning:
WARN [webview-crypto] error in `parse` of message: "%7B%22id%22%3A%225260-fe3a-aa6f-b99a-71a7-d500-f592-108c%22%2C%22value%22%3A%7B%22__serializer_id%22%3A%22CryptoKey%22%2C%22value%22%3A%7B%22serialized%22%3Atrue%2C%22_import%22%3A%7B%22format%22%3A%22raw%22%2C%22keyData%22%3A%7B%22__serializer_id%22%3A%22ArrayBufferView%22%2C%22value%22%3A%7B%22name%22%3A%22Uint8Array%22%2C%22buffer%22%3A%7B%22__serializer_id%22%3A%22ArrayBuffer%22%2C%22value%22%3A%22Fz%25aRtd%40W5c2%22%7D%7D%7D%7D%2C%22type%22%3A%22secret%22%2C%22extractable%22%3Afalse%2C%22algorithm%22%3A%7B%22name%22%3A%22PBKDF2%22%7D%2C%22usages%22%3A%5B%22deriveBits%22%5D%7D%7D%7D" reason: {"name":"ReferenceError","message":"Property 'abvs' doesn't exist","stack":"ReferenceError: Property 'abvs' doesn't exist\n at eval (JavaScript:1:16)\n at anonymous ...
Thanks for the support @sirpy ! I'll put all challenges and solutions in a public gist or make a PR afterwards!
Can you test it on Android emulator or iOS simulator < 15? I take it you are on iOS 15?
I'm on Android version 11 on my device. Also just tried with android emulator on computer, same warnings.
hmmm I dont have any ideas. can you try the example project on the GoodDollar org repo? search for gun react you'll need to update the webview versions and make sure it uses a gun version with fixed requires otherwise it should work. (maybe also define a gun url)
@amark I had it working with the new version a while ago I haven't tested the code now but it was working fine before...https://github.com/aethiop/bite
@3210jr also it might be a good idea to also try and test with GoodDollar/gun instead of amark/gun to rule out amark/gun as the source of the issue
My issue with the warnings from webview-crypto
are now solved with recent push by @sirpy . Not sure about the original issue, I am unable to reproduce it on my end.
I'm developing a react native app and I have iOS version 15.0. I got an error {"message": "undefined is not an object (evaluating 'a.subtle()[f]')", "name": "TypeError", "stack": "@user-script:38:1:2168n@user-script:38:1:1326a@user-script:38:1:407promiseReactionJob@[native code]"} when I used SEA.secret(...). It was working in 14.* version.