Skip to content
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

[Question] Compatibility with react-native — DONE ✅ #737

Closed
rytyr opened this issue Oct 29, 2020 · 15 comments
Closed

[Question] Compatibility with react-native — DONE ✅ #737

rytyr opened this issue Oct 29, 2020 · 15 comments
Labels
O-ReactNative ⚛️ ReactNative platform question W-WasmThemis 🌐 Wrapper: WasmThemis, JavaScript API, npm packages

Comments

@rytyr
Copy link

rytyr commented Oct 29, 2020

I have googled around, read through on issues and could not find any related info nor guides for using themis on React-Native.

Does themis supported in react-native?

Thanks

@ilammy
Copy link
Collaborator

ilammy commented Oct 29, 2020

Hi @rytyr, thanks for your interest in Themis!

We have not been testing Themis with React Native specifically, but I strongly expect WasmThemis to be compatible with React Native. It's available as wasm-themis in the npm.js repositories. Here's the API guide too. You can try it out.

We will check React Native compatibility too and will post our results in this issue as well.

@ilammy ilammy added question W-WasmThemis 🌐 Wrapper: WasmThemis, JavaScript API, npm packages labels Oct 29, 2020
@vixentael vixentael added the O-ReactNative ⚛️ ReactNative platform label Oct 29, 2020
@tschanz-pcv
Copy link

Would be great to get Themis for React Native. If possible using the native iOS/Android/(Windows) libraries as a RN Native Module and not just the JS version.

I'm not sure that wasm will work. From all that I could gather, wasm is sadly not supported on RN. Alternatively it could be compiled to asm.js?

I guess the NodeJS version uses many NodeJS platform APIs? If not maybe the documentation could be extended with what needs to be polyfilled.

@maxammann
Copy link
Contributor

We are currently writing a period tracker using themis. We use the Android bindings currently and use NativeModules: https://github.com/cyla-app/cyla-app

The downside is ofc that you have to implement some logic in android and ios. iOS is still missing.

@snehapatil90
Copy link

Hi everyone,

Can anyone confirm what is the compatible library for this in react native ?

@maxammann
Copy link
Contributor

Hi everyone,

Can anyone confirm what is the compatible library for this in react native ?

Sadly it is not really compatible. You have to use the android and ios bindings. The wasm bindings wont work. We wrote some bindings manually in  https://github.com/cyla-app/cyla-app

It is not yet compatible with iOS.

@vixentael
Copy link
Contributor

Currently, Themis doesn't ship ready-to-use React Native wrapper. But as @maxammann mentioned, they wrote bindings and use Themis successfully.

@maxammann correct me if I'm wrong, this is the bindings file, right?
https://github.com/cyla-app/cyla-app/blob/main/frontend/android/app/src/main/java/app/cyla/util/Themis.kt

@maxammann
Copy link
Contributor

Not really, there we are just implementing some code which uses themis for android.
We did not expose the whole themis library there, but decided to implement some "business logic" which requires android in Kotlin and just send data between RN and the native side.

So this is not really reusable, but shows how it could be done.

@vixentael
Copy link
Contributor

So yeah, you build bindings between Themis Android and RN side for Secure Cell

@maxammann
Copy link
Contributor

maxammann commented Oct 20, 2021

Should we close this?
Themis does not support RN yet, but it is possible to build bindings :)

@gaodeng
Copy link

gaodeng commented Feb 23, 2022

@vixentael any news?

@vixentael
Copy link
Contributor

vixentael commented Mar 1, 2022

Hi! Themis React Native package is now in beta. It's working, and is fully compatible with other Themis wrappers (native iOS, native Android, python, Go, etc). We tested Themis RN with different iOS and Android apps, and can confirm it will be awesome :)

@radetsky is doing great job!

We are on the latest stage before public release.

Here is the temporary home of Themis RN:
https://github.com/radetsky/react-native-themis

Our plans:

[x] write product docs how to use Themis RN
[ ] merge Themis RN into the main Themis repository (here)
[ ] polish examples etc

But the basics are working :)
You can try https://www.npmjs.com/package/react-native-themis but please disregard the readme.

@vixentael
Copy link
Contributor

Status update: Themis RN docs are available:
https://docs.cossacklabs.com/themis/languages/react-native/

Our plans:

[x] write product docs how to use Themis RN
>—— we are here ——<
[ ] merge Themis RN into the main Themis repository (here)
[ ] polish examples etc

@maxencehenneron
Copy link

Hi, I appreciate the work that has been done. But wouldn't it be much faster with the new TurboModules architecture?

Basically, currently, the native side calls the Themis C library and then returns the information to the JS side via a bridge. It creates overhead and slows the operation.

Turbomodules skip the native and bridge part entirely and establish direct communication between C++ and JS. It's also more cross-platform as you do not have to write java and obj-c code.

@vixentael
Copy link
Contributor

Status update:

Themis RN docs are available:
https://docs.cossacklabs.com/themis/languages/react-native/

npm package is here
https://www.npmjs.com/package/react-native-themis

tag is here
https://github.com/cossacklabs/themis/releases/tag/0.14.4

Our plans:

[x] write product docs how to use Themis RN
[x] merge Themis RN into the main Themis repository (here)
[x] polish examples etc
>—— we are here ——<

@vixentael vixentael changed the title [Question] Compatibility with react-native [Question] Compatibility with react-native — DONE ✅ Apr 6, 2022
@vixentael
Copy link
Contributor

@maxencehenneron hi Maxence! Yes, you are right regarding performance issues. No one likes all these back-n-forth through language runtimes.

We are looking into TurboModules, but honestly, they feel "too raw" as this moment. Themis is a complicated construction and we'd like to avoid extra bugs that we cannot control. As for now, we see many issues like react-native-community/discussions-and-proposals#40 (comment) Also, we follow TurboModules development closely, but it's a bit unclear how API will be changing in the nearest versions.

Our current plan is to wait for 0.70 probably and then try to migrate to TurboModules. Depending on how it will work, we might do a separate package for Themis with Turbo modules until we are sure that it's stable. The last thing we want is to create a package that will require constant fixing and will frustrate users. Cryptography is already frustrating enough, hehe.

If you have any good examples of complex libraries that use TurboModules approach, could you please point us there?

cc @radetsky @ilammy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-ReactNative ⚛️ ReactNative platform question W-WasmThemis 🌐 Wrapper: WasmThemis, JavaScript API, npm packages
Projects
None yet
Development

No branches or pull requests

8 participants