Milkshiift / GoofCord

:shield: Take control of your Discord experience with GoofCord – a highly configurable and privacy minded discord client.
Open Software License 3.0
178 stars 7 forks source link

[BUG] Encryption passwords not saved due to error in safeStorage.encryptString #33

Closed jmath3912 closed 1 month ago

jmath3912 commented 1 month ago

Description

When running the AppImage version of GoofCord 1.5.0 and going to the GoofCord settings to enable message encryption, encryption passwords do not actually get saved anywhere.

Steps to Reproduce

  1. Start GoofCord from the terminal via the AppImage file, keeping the terminal open
  2. Navigate to the GoofCord settings (Ctrl + Shift + ')
  3. Enable Message Encryption
  4. Type a password in the "Encryption passwords" text box
  5. Click outside of the text box to save your input, taking note of error messages printed in the terminal
  6. Restart GoofCord and go back into the settings to confirm that the password did not get saved

Expected Behavior

Following the steps above, one would expect the encryption passwords to be encrypted and saved to their respective location on the system.

Actual Behavior

While monitoring the program output in the terminal, the following error message gets printed to the screen upon entering a password:

Error occurred in handler for 'encryptSafeStorage': Error: Error while encrypting the text provided to safeStorage.encryptString. Encryption is not available.
    at /tmp/.mount_GoofCo1eDO1i/resources/app.asar/ts-out/main.js:53:11535
    at WebContents.<anonymous> (node:electron/js2c/browser_init:2:82871)
    at WebContents.emit (node:events:519:28)

It looks like the IPC handler for encryptSafeStorage fails at the call to encryptString because encryption is supposedly not available. I am unsure if this is a GoofCord issue or a system issue.

Environment

Milkshiift commented 1 month ago

The passwords are encrypted for storage using a system keyring. Unlike Windows and macOS, a Linux system does not always have an implementation of it, which is what the error tells you about. Install gnome-keyring and encryption should start working. Most desktop environments have it installed by default.

jmath3912 commented 1 month ago

That's the exact issue I'm having though. I've had gnome-keyring and libsecret (the replacement for libgnome-keyring) installed already, but even then I'm still running into the same "Encryption is not available" error.

Milkshiift commented 1 month ago

Still an environment issue. Some sort of misconfiguration, perhaps. Electron's documentation on safeStorage may be helpful https://www.electronjs.org/docs/latest/api/safe-storage I can't provide much support for this since this is not directly a bug of GoofCord.

cd-FileX commented 1 month ago

Seems like it is not directly directly but can be fixed by goofcord: https://code.visualstudio.com/docs/editor/settings-sync#_other-linux-desktop-environments https://github.com/microsoft/vscode/issues/189672

Most likely a problem of not correctly asking for permission. (at least for my KDE case) The Vscode code could be worth a look.

If setting the encryption storage to kwallet5 the following error appears on opening goofcord settings:

[2:0727/211428.194600:ERROR:object_proxy.cc(576)] Failed to call method: org.kde.KWallet.isEnabled: object_path= /modules/kwalletd5: org.freedesktop.DBus.Error.ServiceUnknown: org.freedesktop.DBus.Error.ServiceUnknown
[2:0727/211428.194642:ERROR:kwallet_dbus.cc(112)] Error contacting kwalletd5 (isEnabled)
[2:0727/211428.195302:ERROR:object_proxy.cc(576)] Failed to call method: org.kde.KLauncher.start_service_by_desktop_name: object_path= /KLauncher: org.freedesktop.DBus.Error.ServiceUnknown: org.freedesktop.DBus.Error.ServiceUnknown
[2:0727/211428.195343:ERROR:kwallet_dbus.cc(81)] Error contacting klauncher to start kwalletd5
[2:0727/211428.195807:ERROR:object_proxy.cc(576)] Failed to call method: org.kde.KWallet.close: object_path= /modules/kwalletd5: org.freedesktop.DBus.Error.ServiceUnknown: org.freedesktop.DBus.Error.ServiceUnknown
[2:0727/211428.195827:ERROR:kwallet_dbus.cc(502)] Error contacting kwalletd5 (close)

If setting to gnome-libsecret nothing appears but the error consists. The same with basic.

Milkshiift commented 1 month ago

Actually, this seems to be caused by flatpak sandboxing. On the same machine, flatpak version of GoofCord fails to save passwords, while non-flatpak successfully saves them

Milkshiift commented 1 month ago

Updated flatpak manifest with a fix https://github.com/flathub/io.github.milkshiift.GoofCord/commit/092ca9425337c72427603d2fe9a10bd6038324e0. Update GoofCord and you should be able to save encryption passwords