damus-io / notedeck

A multiplatform nostr client
Other
47 stars 9 forks source link

impl linux credential storage #115

Open kernelkind opened 4 days ago

kernelkind commented 4 days ago

See the test_basic() test in linux_key_storage.rs. I ran it successfully on my MacOS machine and a linux VM. The BasicFileStorage impl just stores each Keypair as a SerializableKeypair json object with the file name as the public key hex in ~/.notedeck_credentials. The SerializableKeypair uses the nip49 EncryptedSecretKey, but we just use an empty string as the password for now.

The BasicFileStorage impl works in MacOS, but it only conditionally compiles to linux for simplicity.

pub enum KeyStorageResponse<R> {
    Waiting,
    ReceivedResult(Result<R, KeyStorageError>),
}

This is used as a response so that it's possible for the storage impl to be async, since secret_service is async. It seems that secret_service would allow for a more robust linux key storage impl so I went ahead and made the API compatible with an async impl.