add gpg support

This commit is contained in:
Clément DOUIN 2023-08-05 12:10:25 +02:00
parent 183c0272cc
commit 0eed8f355d
No known key found for this signature in database
GPG key ID: 353E4A18EE0FAB72
4 changed files with 147 additions and 7 deletions

139
Cargo.lock generated
View file

@ -251,6 +251,12 @@ version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40e38929add23cdf8a366df9b0e088953150724bcbe5fc330b0d8eb3b328eec8" checksum = "40e38929add23cdf8a366df9b0e088953150724bcbe5fc330b0d8eb3b328eec8"
[[package]]
name = "build-rs"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b00b8763668c99f8d9101b8a0dd82106f58265464531a79b2cef0d9a30c17dd2"
[[package]] [[package]]
name = "bumpalo" name = "bumpalo"
version = "3.11.1" version = "3.11.1"
@ -327,6 +333,16 @@ dependencies = [
"cipher", "cipher",
] ]
[[package]]
name = "cfg-expr"
version = "0.15.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b40ccee03b5175c18cde8f37e7d2a33bcef6f8ec8f7cc0d81090d1bb380949c9"
dependencies = [
"smallvec",
"target-lexicon",
]
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
version = "0.1.10" version = "0.1.10"
@ -502,6 +518,15 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
[[package]]
name = "conv"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ff10625fd0ac447827aa30ea8b861fead473bb60aeb73af6c1c58caf0d1299"
dependencies = [
"custom_derive",
]
[[package]] [[package]]
name = "convert_case" name = "convert_case"
version = "0.5.0" version = "0.5.0"
@ -628,6 +653,16 @@ dependencies = [
"typenum", "typenum",
] ]
[[package]]
name = "cstr-argument"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6bd9c8e659a473bce955ae5c35b116af38af11a7acb0b480e01f3ed348aeb40"
dependencies = [
"cfg-if 1.0.0",
"memchr 2.5.0",
]
[[package]] [[package]]
name = "curve25519-dalek" name = "curve25519-dalek"
version = "3.2.0" version = "3.2.0"
@ -669,6 +704,12 @@ dependencies = [
"syn 2.0.15", "syn 2.0.15",
] ]
[[package]]
name = "custom_derive"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef8ae57c4978a2acd8b869ce6b9ca1dfe817bff704c220209fdef2c0b75a01b9"
[[package]] [[package]]
name = "cxx" name = "cxx"
version = "1.0.82" version = "1.0.82"
@ -1268,6 +1309,47 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "gpg-error"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d89aaeddbfb92313378c58e98abadaaa34082b3855f1d455576eeeda08bd592c"
dependencies = [
"libgpg-error-sys",
]
[[package]]
name = "gpgme"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57539732fbe58eacdb984734b72b470ed0bca3ab7a49813271878567025ac44f"
dependencies = [
"bitflags 1.3.2",
"cfg-if 1.0.0",
"conv",
"cstr-argument",
"gpg-error",
"gpgme-sys",
"libc",
"memoffset",
"once_cell",
"smallvec",
"static_assertions",
]
[[package]]
name = "gpgme-sys"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "509223d659c06e4a26229437d6ac917723f02d31917c86c6ecd50e8369741cf7"
dependencies = [
"build-rs",
"libc",
"libgpg-error-sys",
"system-deps",
"winreg",
]
[[package]] [[package]]
name = "group" name = "group"
version = "0.13.0" version = "0.13.0"
@ -1760,6 +1842,17 @@ version = "0.2.137"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89"
[[package]]
name = "libgpg-error-sys"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c97079310f39c835d3bd73578379d040f779614bb331c7ffbb6630fee6420290"
dependencies = [
"build-rs",
"system-deps",
"winreg",
]
[[package]] [[package]]
name = "libm" name = "libm"
version = "0.2.7" version = "0.2.7"
@ -2413,7 +2506,7 @@ dependencies = [
[[package]] [[package]]
name = "pimalaya-email" name = "pimalaya-email"
version = "0.14.1-beta" version = "0.14.1-beta"
source = "git+https://git.sr.ht/~soywod/pimalaya#86ed502bba59fa70e3f3352b40c0552a5a870c01" source = "git+https://git.sr.ht/~soywod/pimalaya#5241ece85e1ed8837bec4076664604c566d45bff"
dependencies = [ dependencies = [
"advisory-lock", "advisory-lock",
"ammonia", "ammonia",
@ -2460,10 +2553,11 @@ dependencies = [
[[package]] [[package]]
name = "pimalaya-email-tpl" name = "pimalaya-email-tpl"
version = "0.3.2-beta" version = "0.3.2-beta"
source = "git+https://git.sr.ht/~soywod/pimalaya#86ed502bba59fa70e3f3352b40c0552a5a870c01" source = "git+https://git.sr.ht/~soywod/pimalaya#5241ece85e1ed8837bec4076664604c566d45bff"
dependencies = [ dependencies = [
"async-recursion", "async-recursion",
"chumsky 0.9.0", "chumsky 0.9.0",
"gpgme",
"log", "log",
"mail-builder", "mail-builder",
"mail-parser", "mail-parser",
@ -2479,7 +2573,7 @@ dependencies = [
[[package]] [[package]]
name = "pimalaya-keyring" name = "pimalaya-keyring"
version = "0.0.6-beta" version = "0.0.6-beta"
source = "git+https://git.sr.ht/~soywod/pimalaya#86ed502bba59fa70e3f3352b40c0552a5a870c01" source = "git+https://git.sr.ht/~soywod/pimalaya#5241ece85e1ed8837bec4076664604c566d45bff"
dependencies = [ dependencies = [
"keyring", "keyring",
"log", "log",
@ -2489,7 +2583,7 @@ dependencies = [
[[package]] [[package]]
name = "pimalaya-oauth2" name = "pimalaya-oauth2"
version = "0.0.5-beta" version = "0.0.5-beta"
source = "git+https://git.sr.ht/~soywod/pimalaya#86ed502bba59fa70e3f3352b40c0552a5a870c01" source = "git+https://git.sr.ht/~soywod/pimalaya#5241ece85e1ed8837bec4076664604c566d45bff"
dependencies = [ dependencies = [
"log", "log",
"oauth2", "oauth2",
@ -2502,7 +2596,7 @@ dependencies = [
[[package]] [[package]]
name = "pimalaya-pgp" name = "pimalaya-pgp"
version = "0.0.1" version = "0.0.1"
source = "git+https://git.sr.ht/~soywod/pimalaya#86ed502bba59fa70e3f3352b40c0552a5a870c01" source = "git+https://git.sr.ht/~soywod/pimalaya#5241ece85e1ed8837bec4076664604c566d45bff"
dependencies = [ dependencies = [
"async-recursion", "async-recursion",
"futures", "futures",
@ -2522,7 +2616,7 @@ dependencies = [
[[package]] [[package]]
name = "pimalaya-process" name = "pimalaya-process"
version = "0.0.6-beta" version = "0.0.6-beta"
source = "git+https://git.sr.ht/~soywod/pimalaya#86ed502bba59fa70e3f3352b40c0552a5a870c01" source = "git+https://git.sr.ht/~soywod/pimalaya#5241ece85e1ed8837bec4076664604c566d45bff"
dependencies = [ dependencies = [
"log", "log",
"thiserror", "thiserror",
@ -2532,7 +2626,7 @@ dependencies = [
[[package]] [[package]]
name = "pimalaya-secret" name = "pimalaya-secret"
version = "0.0.6-beta" version = "0.0.6-beta"
source = "git+https://git.sr.ht/~soywod/pimalaya#86ed502bba59fa70e3f3352b40c0552a5a870c01" source = "git+https://git.sr.ht/~soywod/pimalaya#5241ece85e1ed8837bec4076664604c566d45bff"
dependencies = [ dependencies = [
"log", "log",
"pimalaya-keyring", "pimalaya-keyring",
@ -3305,6 +3399,12 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]] [[package]]
name = "string_cache" name = "string_cache"
version = "0.8.4" version = "0.8.4"
@ -3371,6 +3471,25 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "system-deps"
version = "6.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30c2de8a4d8f4b823d634affc9cd2a74ec98c53a756f317e529a48046cbf71f3"
dependencies = [
"cfg-expr",
"heck",
"pkg-config",
"toml",
"version-compare",
]
[[package]]
name = "target-lexicon"
version = "0.12.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a"
[[package]] [[package]]
name = "tempfile" name = "tempfile"
version = "3.3.0" version = "3.3.0"
@ -3799,6 +3918,12 @@ version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "version-compare"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29"
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.4" version = "0.9.4"

View file

@ -20,6 +20,7 @@ default = ["imap-backend", "smtp-sender"]
# backends # backends
imap-backend = ["pimalaya-email/imap-backend"] imap-backend = ["pimalaya-email/imap-backend"]
notmuch-backend = ["pimalaya-email/notmuch-backend"] notmuch-backend = ["pimalaya-email/notmuch-backend"]
gpg = ["pimalaya-email/gpg"]
# senders # senders
smtp-sender = ["pimalaya-email/smtp-sender"] smtp-sender = ["pimalaya-email/smtp-sender"]

View file

@ -35,6 +35,7 @@
in in
{ {
default = pkgs.mkShell { default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [ pkg-config ];
buildInputs = with pkgs; [ buildInputs = with pkgs; [
# Nix env # Nix env
rnix-lsp rnix-lsp
@ -45,6 +46,9 @@
# notmuch # notmuch
notmuch notmuch
# gpg
gpgme
]; ];
}; };
}; };

View file

@ -1,3 +1,5 @@
#[cfg(feature = "gpg")]
use pimalaya_email::account::GpgConfig;
#[cfg(feature = "notmuch-backend")] #[cfg(feature = "notmuch-backend")]
use pimalaya_email::backend::NotmuchConfig; use pimalaya_email::backend::NotmuchConfig;
#[cfg(feature = "imap-backend")] #[cfg(feature = "imap-backend")]
@ -398,6 +400,9 @@ pub enum PgpConfigDef {
None, None,
#[serde(with = "PgpNativeConfigDef")] #[serde(with = "PgpNativeConfigDef")]
Native(PgpNativeConfig), Native(PgpNativeConfig),
#[cfg(feature = "gpg")]
#[serde(with = "GpgConfigDef")]
Gpg(GpgConfig),
} }
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
@ -424,3 +429,8 @@ pub enum PgpNativeSecretKeyDef {
#[serde(with = "EntryDef")] #[serde(with = "EntryDef")]
Keyring(Entry), Keyring(Entry),
} }
#[cfg(feature = "gpg")]
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
#[serde(remote = "GpgConfig", rename_all = "kebab-case")]
pub struct GpgConfigDef;