robosats icon indicating copy to clipboard operation
robosats copied to clipboard

Android Tor Requests

Open KoalaSat opened this issue 3 years ago • 0 comments

Fixes: https://github.com/Reckless-Satoshi/robosats/issues/42

We previously refactor the front-end to have a high level API client we can easily switch https://github.com/Reckless-Satoshi/robosats/pull/242 and create a single component for avatars so static image files can be easily manage https://github.com/Reckless-Satoshi/robosats/pull/251

This PR includes:

  • New client on the front-end that communicates with react-native.
  • Tor client on react-native that listen for requests, fetch and returns them back to webview.
  • Other fixes found related with running the front-end on Android, and closely related to HTTP requests.

Issues found on Android

Details of this list: https://github.com/Reckless-Satoshi/robosats/issues/42#issuecomment-1250668802

  • [x] Fetching internal files Including extra static files on the app will also help to make sure the translation files are on the same version as the JS on the app. My intial approach was to run a static server, but it's not possible because of https://github.com/futurepress/react-native-static-server/issues/115, so I just included i18n on the mobile webpack bundle Solution: https://github.com/Reckless-Satoshi/robosats/pull/247/files#diff-a7def86cc36a2178b4ee07b000c53d49e04068db4bc85967c0758578a2f37700R44
  • [x] External sources Using the request function I manage to do XHR requests and obtain the base64 of external files. Solution: https://github.com/Reckless-Satoshi/robosats/pull/247/files#diff-ab78113fffebdaf893575b9bdd85086680e9553cf9f9f10bec0a1dc0e11e1c35R55
  • [x] MUI Avatar not loading After https://github.com/Reckless-Satoshi/robosats/pull/251 it was way easier to asynchronously manage the image src load, I also implemented an in-memory cache to avoid loading the image everytime the src is requested (only for the Android build). Solution: https://github.com/Reckless-Satoshi/robosats/pull/247/files#diff-35aa11cfb6d388c4d5c62abbc4b3bc0281ea8d19bc1ec800f0a0f47a59fedbfbR47
  • [x] react-native-tor does not implement PUT https://github.com/Sifir-io/react-native-tor/issues/51 We decided to not implement it.
  • [x] react-native-tor crashes Following this workaround seems to fix the issue https://github.com/Sifir-io/react-native-tor/issues/30#issuecomment-891060913 . At least for my case, it also increased considerably the general performance on Tor requests.
  • [ ] Cookies not available on local files

Changes to test on Web frontend

  • Routes
  • User Gen Main Avatar
  • Translations
  • Cookies

Remaining work for a fully functional Android app

  • Comunicate with clipboard
  • Websockets

Further Considerations

  • I'm not sure at all about the security risks on this command but I couldn't find a way to make the JS injection work without it.

KoalaSat avatar Sep 16 '22 19:09 KoalaSat