firstfloorsoftware / flutter_sodium

Flutter bindings for libsodium
BSD 3-Clause "New" or "Revised" License
102 stars 47 forks source link

Support for Desktop Platforms (Linux, Windows, macOS) #62

Open felix-barz-brickmakers opened 3 years ago

Sunbreak commented 3 years ago

Interested to help. Could someone elaborate the usecase?

felix-barz-brickmakers commented 3 years ago

Well, the usecase is to simply be able to use this library for the desktop platforms, which are in beta now and will become stable soon. So, my personal usecase is to be able to develop a flutter app that needs encryption for all of the platforms.

More specificly, I found out that we already have a somewhat support for desktop: In lib/src/bindings/libsodium.dart The library can already be loaded on the desktop platforms. However, there are two things to improve here, so we can easily use the library on desktop:

  1. Make the path configurable. /usr/local/lib/libsodium.so might work for Ubuntu, but not for other distros. And someone might want to statically link or distribute the library with the final app. So a Sodium.setNativeLib("path/to/libsodium.so") or similar would be very nice.
  2. Distribute libsodium for desktop with the package, just like you do for Android/iOS. This should be easy for Windows and macOS but more complicated for linux. However, as long as we have Option 1, it is not really neccessary.
Sunbreak commented 3 years ago

More specificly, I found out that we already have a somewhat support for desktop: In lib/src/bindings/libsodium.dart The library can already be loaded on the desktop platforms.

https://github.com/firstfloorsoftware/flutter_sodium/tree/master/lib/src/bindings is code manually or generated?

  1. Distribute libsodium for desktop with the package, just like you do for Android/iOS. This should be easy for Windows and macOS but more complicated for linux. However, as long as we have Option 1, it is not really neccessary.

What about the architecture of https://github.com/woodemi/quick_usb?

  1. Make the path configurable. /usr/local/lib/libsodium.so might work for Ubuntu, but not for other distros. And someone might want to statically link or distribute the library with the final app. So a Sodium.setNativeLib("path/to/libsodium.so") or similar would be very nice.

Maybe a workaround https://github.com/woodemi/quick_usb/issues/14#issuecomment-809996205 ?

j0chn1 commented 2 years ago

If it is possible you could load the library with a relative path. I am not experience in this area. But I try to publish my app to flathub and have no access to /usr. The library is stored in /app/lib and could be found if linked dynamically.

Ezwen commented 2 years ago

I confirm this is a problem for flatpaks.

j0chn1 commented 2 years ago

Can we excpect any changes to this topic? Would be nice to get an answer so we can decide to wait or find another solution. Thank you!

Skycoder42 commented 2 years ago

In lack of a better solution, I created my own sodium wrappers here: https://github.com/Skycoder42/libsodium_dart_bindings They support all platforms (mobile, desktop and web), for dart and for flutter out of the box.

j0chn1 commented 2 years ago

I just saw that flutter_sodium actually uses a dynamic call

DynamicLibrary.open("libsodium.so.23").

But the pub.dev plugin is not updated yet.