notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 59818edd83504cbbf9b8c5a5c2c5d3f3a77f0e2e
parent e04c8821d54363e3930b270f4bd16b26b59cabbe
Author: kernelkind <kernelkind@gmail.com>
Date:   Tue,  7 May 2024 19:57:41 -0400

remove nostr-sdk

Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
MCargo.lock | 532++++---------------------------------------------------------------------------
MCargo.toml | 1-
Msrc/key_parsing.rs | 52+++++++++++++++++++++++++++++-----------------------
Msrc/login_manager.rs | 11++++++-----
4 files changed, 58 insertions(+), 538 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -286,67 +286,6 @@ dependencies = [ ] [[package]] -name = "async-trait" -version = "0.1.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "461abc97219de0eaaf81fe3ef974a540158f3d079c2ab200f891f1a2ef201e85" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "async-utility" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a349201d80b4aa18d17a34a182bdd7f8ddf845e9e57d2ea130a12e10ef1e3a47" -dependencies = [ - "futures-util", - "gloo-timers", - "tokio", - "wasm-bindgen-futures", -] - -[[package]] -name = "async-wsocket" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d253e375ea899cb131b92a474587e217634e7ea927c24d8098eecbcad0c5c97a" -dependencies = [ - "async-utility", - "futures-util", - "thiserror", - "tokio", - "tokio-rustls 0.25.0", - "tokio-socks", - "tokio-tungstenite 0.21.0", - "url", - "wasm-ws", - "webpki-roots 0.26.1", -] - -[[package]] -name = "async_io_stream" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" -dependencies = [ - "futures", - "pharos", - "rustc_version", -] - -[[package]] -name = "atomic-destructor" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4653a42bf04120a1d4e92452e006b4e3af4ab4afff8fb4af0f1bbb98418adf3e" -dependencies = [ - "tracing", -] - -[[package]] name = "atomic-waker" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -405,12 +344,6 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bech32" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" - -[[package]] -name = "bech32" version = "0.10.0-beta" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98f7eed2b2781a6f0b5c903471d48e15f56fb4e1165df8a9a2337fd1a59d45ea" @@ -481,30 +414,16 @@ checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" [[package]] name = "bitcoin" -version = "0.30.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1945a5048598e4189e239d3f809b19bdad4845c4b2ba400d304d2dcf26d2c462" -dependencies = [ - "bech32 0.9.1", - "bitcoin-private", - "bitcoin_hashes 0.12.0", - "hex_lit", - "secp256k1 0.27.0", - "serde", -] - -[[package]] -name = "bitcoin" version = "0.31.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c85783c2fe40083ea54a33aa2f0ba58831d90fcd190f5bdc47e74e84d2a96ae" dependencies = [ - "bech32 0.10.0-beta", + "bech32", "bitcoin-internals", "bitcoin_hashes 0.13.0", "hex-conservative", "hex_lit", - "secp256k1 0.28.2", + "secp256k1", "serde", ] @@ -536,7 +455,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d7066118b13d4b20b23645932dfb3a81ce7e29f95726c2036fa33cd7b092501" dependencies = [ "bitcoin-private", - "serde", ] [[package]] @@ -1000,12 +918,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991" [[package]] -name = "data-encoding" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" - -[[package]] name = "data-url" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1262,7 +1174,7 @@ dependencies = [ "ewebsock", "hex", "log", - "nostr 0.30.0", + "nostr", "serde", "serde_derive", "serde_json", @@ -1393,9 +1305,9 @@ dependencies = [ "futures-util", "js-sys", "tokio", - "tokio-tungstenite 0.17.2", + "tokio-tungstenite", "tracing", - "tungstenite 0.17.3", + "tungstenite", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -1690,18 +1602,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] -name = "gloo-timers" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" -dependencies = [ - "futures-channel", - "futures-core", - "js-sys", - "wasm-bindgen", -] - -[[package]] name = "glow" version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1832,25 +1732,6 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http 0.2.11", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "h2" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "816ec7294445779408f36fe57bc5b7fc1cf59664059096c65f905c1c61f58069" @@ -1981,17 +1862,6 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" -dependencies = [ - "bytes", - "http 0.2.11", - "pin-project-lite", -] - -[[package]] -name = "http-body" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" @@ -2009,7 +1879,7 @@ dependencies = [ "bytes", "futures-core", "http 1.1.0", - "http-body 1.0.0", + "http-body", "pin-project-lite", ] @@ -2020,12 +1890,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] -name = "httpdate" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" - -[[package]] name = "humantime" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2033,30 +1897,6 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2 0.3.25", - "http 0.2.11", - "http-body 0.4.6", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - -[[package]] -name = "hyper" version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" @@ -2064,9 +1904,9 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.4", + "h2", "http 1.1.0", - "http-body 1.0.0", + "http-body", "httparse", "itoa", "pin-project-lite", @@ -2077,27 +1917,13 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" -dependencies = [ - "futures-util", - "http 0.2.11", - "hyper 0.14.28", - "rustls 0.21.10", - "tokio", - "tokio-rustls 0.24.1", -] - -[[package]] -name = "hyper-rustls" version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" dependencies = [ "futures-util", "http 1.1.0", - "hyper 1.3.1", + "hyper", "hyper-util", "rustls 0.22.2", "rustls-pki-types", @@ -2114,7 +1940,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.3.1", + "hyper", "hyper-util", "native-tls", "tokio", @@ -2132,8 +1958,8 @@ dependencies = [ "futures-channel", "futures-util", "http 1.1.0", - "http-body 1.0.0", - "hyper 1.3.1", + "http-body", + "hyper", "pin-project-lite", "socket2", "tokio", @@ -2395,18 +2221,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" [[package]] -name = "lnurl-pay" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b628658116d331c9567f6cb22415d726125ff6e328d1fb1b422b1b58afeaec21" -dependencies = [ - "bech32 0.9.1", - "reqwest 0.11.27", - "serde", - "serde_json", -] - -[[package]] name = "lock_api" version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2423,15 +2237,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] -name = "lru" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" -dependencies = [ - "hashbrown", -] - -[[package]] name = "lz4_flex" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2671,36 +2476,6 @@ dependencies = [ [[package]] name = "nostr" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "255485c2f41cf8f39d4e4a1901199549f54e32def81a71a8afe05f75809f441d" -dependencies = [ - "aes", - "base64 0.21.7", - "bip39", - "bitcoin 0.30.2", - "cbc", - "chacha20", - "chacha20poly1305", - "getrandom", - "instant", - "js-sys", - "negentropy", - "once_cell", - "reqwest 0.11.27", - "scrypt", - "serde", - "serde_json", - "tracing", - "unicode-normalization", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - -[[package]] -name = "nostr" version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a27223888faca0c4ba9b97c2b7dc776e9a33d5f54e3558887471cf17798b5fbf" @@ -2708,7 +2483,7 @@ dependencies = [ "aes", "base64 0.21.7", "bip39", - "bitcoin 0.31.2", + "bitcoin", "cbc", "chacha20", "chacha20poly1305", @@ -2717,7 +2492,7 @@ dependencies = [ "js-sys", "negentropy", "once_cell", - "reqwest 0.12.4", + "reqwest", "scrypt", "serde", "serde_json", @@ -2730,79 +2505,6 @@ dependencies = [ ] [[package]] -name = "nostr-database" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e15ab55f96ea5e560af0c75f1d942b1064266d443d11b2afbe51ca9ad78a018" -dependencies = [ - "async-trait", - "lru", - "nostr 0.29.0", - "thiserror", - "tokio", - "tracing", -] - -[[package]] -name = "nostr-relay-pool" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83b39b3dc3f1fe912a0f530ad8bd2e71c55608679c8c427952f71c13f0a4c545" -dependencies = [ - "async-utility", - "async-wsocket", - "atomic-destructor", - "nostr 0.29.0", - "nostr-database", - "thiserror", - "tokio", - "tracing", -] - -[[package]] -name = "nostr-sdk" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81ed0ab9cbc3b20d3dba99337f2e0739f052ebe32133d690e212022a06a22044" -dependencies = [ - "async-utility", - "lnurl-pay", - "nostr 0.29.0", - "nostr-database", - "nostr-relay-pool", - "nostr-signer", - "nostr-zapper", - "nwc", - "thiserror", - "tokio", - "tracing", -] - -[[package]] -name = "nostr-signer" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307bdc7c26887d7e65632e66872989a19892dfe9f2c6dbd9a1d3f959c5c524d5" -dependencies = [ - "async-utility", - "nostr 0.29.0", - "nostr-relay-pool", - "thiserror", - "tokio", -] - -[[package]] -name = "nostr-zapper" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "061d5eb00b430747a984ea9e41cd82c849832151b4263d8230c9c220dc2c62f8" -dependencies = [ - "async-trait", - "nostr 0.29.0", - "thiserror", -] - -[[package]] name = "nostrdb" version = "0.3.3" source = "git+https://github.com/damus-io/nostrdb-rs?rev=99d8296fcba5957245ed883e2f3b1c0d1cb16397#99d8296fcba5957245ed883e2f3b1c0d1cb16397" @@ -2835,12 +2537,11 @@ dependencies = [ "hex", "image", "log", - "nostr-sdk", "nostrdb", "poll-promise", "puffin", "puffin_egui", - "reqwest 0.12.4", + "reqwest", "serde", "serde_derive", "serde_json", @@ -2953,20 +2654,6 @@ dependencies = [ ] [[package]] -name = "nwc" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1894ffe54a1e5adf8dbb22b5a290c0748ec4a88aa07fa69c4359010edea49ed" -dependencies = [ - "async-utility", - "nostr 0.29.0", - "nostr-relay-pool", - "nostr-zapper", - "thiserror", - "tracing", -] - -[[package]] name = "objc" version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3173,16 +2860,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] -name = "pharos" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" -dependencies = [ - "futures", - "rustc_version", -] - -[[package]] name = "pico-args" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3526,48 +3203,6 @@ checksum = "216080ab382b992234dda86873c18d4c48358f5cfcb70fd693d7f6f2131b628b" [[package]] name = "reqwest" -version = "0.11.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" -dependencies = [ - "base64 0.21.7", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2 0.3.25", - "http 0.2.11", - "http-body 0.4.6", - "hyper 0.14.28", - "hyper-rustls 0.24.2", - "ipnet", - "js-sys", - "log", - "mime", - "once_cell", - "percent-encoding", - "pin-project-lite", - "rustls 0.21.10", - "rustls-pemfile 1.0.4", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper", - "system-configuration", - "tokio", - "tokio-rustls 0.24.1", - "tokio-socks", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "webpki-roots 0.25.4", - "winreg 0.50.0", -] - -[[package]] -name = "reqwest" version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" @@ -3577,12 +3212,12 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2 0.4.4", + "h2", "http 1.1.0", - "http-body 1.0.0", + "http-body", "http-body-util", - "hyper 1.3.1", - "hyper-rustls 0.26.0", + "hyper", + "hyper-rustls", "hyper-tls", "hyper-util", "ipnet", @@ -3594,7 +3229,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rustls 0.22.2", - "rustls-pemfile 2.1.2", + "rustls-pemfile", "rustls-pki-types", "serde", "serde_json", @@ -3611,7 +3246,7 @@ dependencies = [ "wasm-bindgen-futures", "web-sys", "webpki-roots 0.26.1", - "winreg 0.52.0", + "winreg", ] [[package]] @@ -3746,15 +3381,6 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" -dependencies = [ - "base64 0.21.7", -] - -[[package]] -name = "rustls-pemfile" version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" @@ -3878,39 +3504,18 @@ dependencies = [ [[package]] name = "secp256k1" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" -dependencies = [ - "bitcoin_hashes 0.12.0", - "rand", - "secp256k1-sys 0.8.1", - "serde", -] - -[[package]] -name = "secp256k1" version = "0.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10" dependencies = [ "bitcoin_hashes 0.12.0", "rand", - "secp256k1-sys 0.9.2", + "secp256k1-sys", "serde", ] [[package]] name = "secp256k1-sys" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" -dependencies = [ - "cc", -] - -[[package]] -name = "secp256k1-sys" version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5d1746aae42c19d583c3c1a8c646bfad910498e2051c551a7f2e3c0c9fbb7eb" @@ -3948,12 +3553,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" [[package]] -name = "send_wrapper" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" - -[[package]] name = "serde" version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -4009,17 +3608,6 @@ dependencies = [ ] [[package]] -name = "sha1" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - -[[package]] name = "sha2" version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -4469,16 +4057,6 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" -dependencies = [ - "rustls 0.21.10", - "tokio", -] - -[[package]] -name = "tokio-rustls" version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" @@ -4511,28 +4089,12 @@ dependencies = [ "rustls 0.20.9", "tokio", "tokio-rustls 0.23.4", - "tungstenite 0.17.3", + "tungstenite", "webpki", "webpki-roots 0.22.6", ] [[package]] -name = "tokio-tungstenite" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" -dependencies = [ - "futures-util", - "log", - "rustls 0.22.2", - "rustls-pki-types", - "tokio", - "tokio-rustls 0.25.0", - "tungstenite 0.21.0", - "webpki-roots 0.26.1", -] - -[[package]] name = "tokio-util" version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -4705,27 +4267,6 @@ dependencies = [ ] [[package]] -name = "tungstenite" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" -dependencies = [ - "byteorder", - "bytes", - "data-encoding", - "http 1.1.0", - "httparse", - "log", - "rand", - "rustls 0.22.2", - "rustls-pki-types", - "sha1", - "thiserror", - "url", - "utf-8", -] - -[[package]] name = "type-map" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -5010,23 +4551,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" [[package]] -name = "wasm-ws" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5b3a482e27ff54809c0848629d9033179705c5ea2f58e26cf45dc77c34c4984" -dependencies = [ - "async_io_stream", - "futures", - "js-sys", - "pharos", - "send_wrapper", - "thiserror", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - -[[package]] name = "wayland-backend" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -5660,16 +5184,6 @@ dependencies = [ [[package]] name = "winreg" -version = "0.50.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - -[[package]] -name = "winreg" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" diff --git a/Cargo.toml b/Cargo.toml @@ -36,7 +36,6 @@ nostrdb = { git = "https://github.com/damus-io/nostrdb-rs", rev = "99d8296fcba59 #nostrdb = "0.3.3" hex = "0.4.3" base32 = "0.4.0" -nostr-sdk = "0.29.0" strum = "0.26" strum_macros = "0.26" bitflags = "2.5.0" diff --git a/src/key_parsing.rs b/src/key_parsing.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use std::str::FromStr; use crate::Error; -use nostr_sdk::{prelude::Keys, PublicKey, SecretKey}; +use enostr::{Keypair, Pubkey, SecretKey}; use poll_promise::Promise; use reqwest::{Request, Response}; use serde::{Deserialize, Serialize}; @@ -39,16 +39,16 @@ async fn parse_nip05_response(response: Response) -> Result<Nip05Result, Error> } } -fn get_pubkey_from_result(result: Nip05Result, user: String) -> Result<PublicKey, Error> { +fn get_pubkey_from_result(result: Nip05Result, user: String) -> Result<Pubkey, Error> { match result.names.get(&user).to_owned() { - Some(pubkey_str) => PublicKey::from_str(pubkey_str).map_err(|e| { + Some(pubkey_str) => Pubkey::from_hex(pubkey_str).map_err(|e| { Error::Generic("Could not parse pubkey: ".to_string() + e.to_string().as_str()) }), None => Err(Error::Generic("Could not find user in json.".to_string())), } } -async fn get_nip05_pubkey(id: &str) -> Result<PublicKey, Error> { +async fn get_nip05_pubkey(id: &str) -> Result<Pubkey, Error> { let mut parts = id.split('@'); let user = match parts.next() { @@ -95,12 +95,12 @@ fn retrieving_nip05_pubkey(key: &str) -> bool { key.contains('@') } -pub fn perform_key_retrieval(key: &str) -> Promise<Result<Keys, LoginError>> { +pub fn perform_key_retrieval(key: &str) -> Promise<Result<Keypair, LoginError>> { let key_string = String::from(key); Promise::spawn_async(async move { get_login_key(&key_string).await }) } -/// Attempts to turn a string slice key from the user into a Nostr-Sdk Keys object. +/// Attempts to turn a string slice key from the user into a Nostr-Sdk Keypair object. /// The `key` can be in any of the following formats: /// - Public Bech32 key (prefix "npub"): "npub1xyz..." /// - Private Bech32 key (prefix "nsec"): "nsec1xyz..." @@ -108,7 +108,7 @@ pub fn perform_key_retrieval(key: &str) -> Promise<Result<Keys, LoginError>> { /// - Private hex key: "5dab..." /// - NIP-05 address: "example@nostr.com" /// -pub async fn get_login_key(key: &str) -> Result<Keys, LoginError> { +pub async fn get_login_key(key: &str) -> Result<Keypair, LoginError> { let tmp_key: &str = if let Some(stripped) = key.strip_prefix('@') { stripped } else { @@ -117,13 +117,15 @@ pub async fn get_login_key(key: &str) -> Result<Keys, LoginError> { if retrieving_nip05_pubkey(tmp_key) { match get_nip05_pubkey(tmp_key).await { - Ok(pubkey) => Ok(Keys::from_public_key(pubkey)), + Ok(pubkey) => Ok(Keypair::only_pubkey(pubkey)), Err(e) => Err(LoginError::Nip05Failed(e.to_string())), } - } else if let Ok(pubkey) = PublicKey::from_str(tmp_key) { - Ok(Keys::from_public_key(pubkey)) + } else if let Ok(pubkey) = Pubkey::try_from_bech32_string(tmp_key, true) { + Ok(Keypair::only_pubkey(pubkey)) + } else if let Ok(pubkey) = Pubkey::try_from_hex_str_with_verify(tmp_key) { + Ok(Keypair::only_pubkey(pubkey)) } else if let Ok(secret_key) = SecretKey::from_str(tmp_key) { - Ok(Keys::new(secret_key)) + Ok(Keypair::new(secret_key)) } else { Err(LoginError::InvalidKey) } @@ -137,21 +139,23 @@ mod tests { #[tokio::test] async fn test_pubkey_async() { let pubkey_str = "npub1xtscya34g58tk0z605fvr788k263gsu6cy9x0mhnm87echrgufzsevkk5s"; - let expected_pubkey = PublicKey::from_str(pubkey_str).expect("Should not have errored."); + let expected_pubkey = + Pubkey::try_from_bech32_string(pubkey_str, false).expect("Should not have errored."); let login_key_result = get_login_key(pubkey_str).await; - assert_eq!(Ok(Keys::from_public_key(expected_pubkey)), login_key_result); + assert_eq!(Ok(Keypair::only_pubkey(expected_pubkey)), login_key_result); } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_pubkey() { let pubkey_str = "npub1xtscya34g58tk0z605fvr788k263gsu6cy9x0mhnm87echrgufzsevkk5s"; - let expected_pubkey = PublicKey::from_str(pubkey_str).expect("Should not have errored."); + let expected_pubkey = + Pubkey::try_from_bech32_string(pubkey_str, false).expect("Should not have errored."); let login_key_result = perform_key_retrieval(pubkey_str); promise_assert!( assert_eq, - Ok(Keys::from_public_key(expected_pubkey)), + Ok(Keypair::only_pubkey(expected_pubkey)), &login_key_result ); } @@ -159,12 +163,12 @@ mod tests { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_hex_pubkey() { let pubkey_str = "32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245"; - let expected_pubkey = PublicKey::from_str(pubkey_str).expect("Should not have errored."); + let expected_pubkey = Pubkey::from_hex(pubkey_str).expect("Should not have errored."); let login_key_result = perform_key_retrieval(pubkey_str); promise_assert!( assert_eq, - Ok(Keys::from_public_key(expected_pubkey)), + Ok(Keypair::only_pubkey(expected_pubkey)), &login_key_result ); } @@ -177,7 +181,7 @@ mod tests { promise_assert!( assert_eq, - Ok(Keys::new(expected_privkey)), + Ok(Keypair::new(expected_privkey)), &login_key_result ); } @@ -190,7 +194,7 @@ mod tests { promise_assert!( assert_eq, - Ok(Keys::new(expected_privkey)), + Ok(Keypair::new(expected_privkey)), &login_key_result ); } @@ -198,14 +202,16 @@ mod tests { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_nip05() { let nip05_str = "damus@damus.io"; - let expected_pubkey = - PublicKey::from_str("npub18m76awca3y37hkvuneavuw6pjj4525fw90necxmadrvjg0sdy6qsngq955") - .expect("Should not have errored."); + let expected_pubkey = Pubkey::try_from_bech32_string( + "npub18m76awca3y37hkvuneavuw6pjj4525fw90necxmadrvjg0sdy6qsngq955", + false, + ) + .expect("Should not have errored."); let login_key_result = perform_key_retrieval(nip05_str); promise_assert!( assert_eq, - Ok(Keys::from_public_key(expected_pubkey)), + Ok(Keypair::only_pubkey(expected_pubkey)), &login_key_result ); } diff --git a/src/login_manager.rs b/src/login_manager.rs @@ -1,14 +1,14 @@ use crate::key_parsing::perform_key_retrieval; use crate::key_parsing::LoginError; use egui::{TextBuffer, TextEdit}; -use nostr_sdk::Keys; +use enostr::Keypair; use poll_promise::Promise; /// The UI view interface to log in to a nostr account. #[derive(Default)] pub struct LoginManager { login_key: String, - promise_query: Option<(String, Promise<Result<Keys, LoginError>>)>, + promise_query: Option<(String, Promise<Result<Keypair, LoginError>>)>, error: Option<LoginError>, key_on_error: Option<String>, } @@ -67,7 +67,7 @@ impl<'a> LoginManager { } /// Whether to indicate to the user that a successful login occured - pub fn check_for_successful_login(&mut self) -> Option<Keys> { + pub fn check_for_successful_login(&mut self) -> Option<Keypair> { if let Some((_, promise)) = &mut self.promise_query { if promise.ready().is_some() { if let Some((_, promise)) = self.promise_query.take() { @@ -89,15 +89,16 @@ impl<'a> LoginManager { #[cfg(test)] mod tests { + use enostr::Pubkey; + use super::*; - use nostr_sdk::PublicKey; use std::time::{Duration, Instant}; #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_retrieve_key() { let mut manager = LoginManager::new(); let expected_str = "3efdaebb1d8923ebd99c9e7ace3b4194ab45512e2be79c1b7d68d9243e0d2681"; - let expected_key = Keys::from_public_key(PublicKey::from_hex(expected_str).unwrap()); + let expected_key = Keypair::only_pubkey(Pubkey::from_hex(expected_str).unwrap()); let start_time = Instant::now();