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

Add Error Handling for keytarSet and keytarGet #804

Open
3 tasks done
hellodword opened this issue Jul 4, 2024 · 4 comments
Open
3 tasks done

Add Error Handling for keytarSet and keytarGet #804

hellodword opened this issue Jul 4, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@hellodword
Copy link
Contributor

hellodword commented Jul 4, 2024

Have you read a contributing guide?

  • I have read CONTRIBUTING.md
  • I have searched the existing issues and didn't find any that were similar
  • I have considered creating a pull request with fixes instead of a bug report and want to proceed

Current Behavior

On Linux, anytype uses keytar/libsecret to call org.freedesktop.secrets dbus for reading and storing the mnemonic.

However, as far as I can see, there is no error handling in the code when calling WalletCreate and WalletRecover directly.

This might be the cause of this issue.

Expected Behavior

I am not sure whether we should prevent users from creating keys and entering Space if org.freedesktop.secrets dbus is unavailable, but I think there should at least be a notification.

Steps To Reproduce

  1. Remove or disable services like gnome-keyring on your computer, or ensure they require a password to use.

  2. Open anytype and create a key.

  3. You will proceed to the next step without any error notification, but the mnemonic will not be displayed, and it will not be saved successfully. Upon exiting, you will be unable to re-enter the wallet and will need to create it again.

Environment

- OS: NixOS
- Version: 0.41.1

Anything else?

No response

@hellodword hellodword added the bug Something isn't working label Jul 4, 2024
@hellodword
Copy link
Contributor Author

hellodword commented Jul 27, 2024

I think we should consider about finding an alternative to the keytar package, as it is no longer maintained.

How about using the safeStorage from Electron?

I noticed that VSCode has moved from keytar to safeStorage: https://code.visualstudio.com/docs/editor/settings-sync#_troubleshooting-keychain-issues

The benefits I can identify are:

  1. All the advantages of getting rid of an unmaintained dependency.
  2. It will make package maintainers happier, for instance: https://github.com/squalus/anytype-flake/blob/181bd21e80edcb6c6c72b814ab7ba082baee0ccd/anytype/default.nix#L70-L74
  3. Easier cross-platform and architecture support.

@ra3orblade

@hellodword
Copy link
Contributor Author

hellodword commented Jul 27, 2024

While developing anytype-ts in a devcontainer, it's difficult to get org.freebsd.secrets functioning properly. The safeStorage feature provides plaintext storage if no secret store is available.

if (!developerMode && !safeStorage.isEncryptionAvailable()) {
    // warn and exit
}

@ra3orblade
Copy link
Contributor

I think we should consider about finding an alternative to the keytar package, as it is no longer maintained.

How about using the safeStorage from Electron?

I noticed that VSCode has moved from keytar to safeStorage: https://code.visualstudio.com/docs/editor/settings-sync#_troubleshooting-keychain-issues

The benefits I can identify are:

  1. All the advantages of getting rid of an unmaintained dependency.
  2. It will make package maintainers happier, for instance: https://github.com/squalus/anytype-flake/blob/181bd21e80edcb6c6c72b814ab7ba082baee0ccd/anytype/default.nix#L70-L74
  3. Easier cross-platform and architecture support.

@ra3orblade

Last time I've checked safeStorage in some article it described it as not so safe compared to keytar, but maybe something changed in latest versions. I think we can switch to it eventually, but need to understand how to properly migrate so users won't need to enter their phrase manually.

@ra3orblade
Copy link
Contributor

Thanks for links, I'll add the issue to the Linear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants