flutter_sodium icon indicating copy to clipboard operation
flutter_sodium copied to clipboard

Support for Desktop Platforms (Linux, Windows, macOS)

Open felix-barz-brickmakers opened this issue 3 years ago • 8 comments

felix-barz-brickmakers avatar Mar 25 '21 07:03 felix-barz-brickmakers

Interested to help. Could someone elaborate the usecase?

Sunbreak avatar Mar 30 '21 09:03 Sunbreak

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.

felix-barz-brickmakers avatar Mar 30 '21 09:03 felix-barz-brickmakers

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 ?

Sunbreak avatar Mar 30 '21 10:03 Sunbreak

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.

j0chn1 avatar Jan 12 '22 21:01 j0chn1

I confirm this is a problem for flatpaks.

Ezwen avatar Jan 13 '22 08:01 Ezwen

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!

j0chn1 avatar Jan 13 '22 19:01 j0chn1

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.

Skycoder42 avatar Jan 14 '22 05:01 Skycoder42

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.

j0chn1 avatar Jan 15 '22 20:01 j0chn1