diff --git a/Cargo.lock b/Cargo.lock index 78f97f637..8caf765ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" dependencies = [ "cfg-if", "cipher 0.3.0", - "cpufeatures 0.2.11", + "cpufeatures 0.2.12", "opaque-debug", ] @@ -57,7 +57,7 @@ checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" dependencies = [ "cfg-if", "cipher 0.4.4", - "cpufeatures 0.2.11", + "cpufeatures 0.2.12", ] [[package]] @@ -101,9 +101,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" dependencies = [ "cfg-if", "getrandom", @@ -129,19 +129,19 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "anyhow" -version = "1.0.75" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" [[package]] name = "async-trait" -version = "0.1.74" +version = "0.1.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" +checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -203,9 +203,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.5" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "base64ct" @@ -331,9 +331,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" dependencies = [ "serde", ] @@ -440,7 +440,7 @@ checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" dependencies = [ "cfg-if", "cipher 0.4.4", - "cpufeatures 0.2.11", + "cpufeatures 0.2.12", ] [[package]] @@ -606,9 +606,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] @@ -639,22 +639,18 @@ dependencies = [ [[package]] name = "crossbeam-queue" -version = "0.3.9" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9bcf5bdbfdd6030fb4a1c497b5d5fc5921aa2f60d359a17e249c0e6df3de153" +checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" dependencies = [ - "cfg-if", "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.8.17" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d96137f14f244c37f989d9fff8f95e6c18b918e71f36638f8c49112e4c78f" -dependencies = [ - "cfg-if", -] +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" [[package]] name = "crypto-common" @@ -754,6 +750,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + [[package]] name = "digest" version = "0.9.0" @@ -904,9 +909,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -919,9 +924,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -929,15 +934,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -957,38 +962,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-macro" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] name = "futures-sink" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-channel", "futures-core", @@ -1014,9 +1019,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "libc", @@ -1051,9 +1056,9 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "h2" -version = "0.3.22" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" +checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" dependencies = [ "bytes", "fnv", @@ -1083,7 +1088,7 @@ version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ - "ahash 0.8.6", + "ahash 0.8.7", "allocator-api2", ] @@ -1116,9 +1121,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" [[package]] name = "hex" @@ -1342,9 +1347,9 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "js-sys" -version = "0.3.66" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" dependencies = [ "wasm-bindgen", ] @@ -1393,9 +1398,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.151" +version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" [[package]] name = "libm" @@ -1422,9 +1427,9 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" @@ -1463,9 +1468,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.4" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "minimal-lexical" @@ -1512,7 +1517,7 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cfg-if", "libc", ] @@ -1591,15 +1596,15 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.3", + "hermit-abi 0.3.4", "libc", ] [[package]] name = "object" -version = "0.32.1" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] @@ -1795,7 +1800,7 @@ version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b8fcc794035347fb64beda2d3b462595dd2753e3f268d89c5aae77e8cf2c310" dependencies = [ - "base64 0.21.5", + "base64 0.21.7", "serde", ] @@ -1822,9 +1827,9 @@ checksum = "3637c05577168127568a64e9dc5a6887da720efef07b3d9472d45f63ab191166" [[package]] name = "pest" -version = "2.7.5" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" +checksum = "1f200d8d83c44a45b21764d1916299752ca035d15ecd46faca3e9a2a2bf6ad06" dependencies = [ "memchr", "thiserror", @@ -1833,9 +1838,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.5" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2" +checksum = "bcd6ab1236bbdb3a49027e920e693192ebfe8913f6d60e294de57463a493cfde" dependencies = [ "pest", "pest_generator", @@ -1843,22 +1848,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.5" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227" +checksum = "2a31940305ffc96863a735bef7c7994a00b325a7138fdbc5bda0f1a0476d3275" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] name = "pest_meta" -version = "2.7.5" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6" +checksum = "a7ff62f5259e53b78d1af898941cdcdccfae7385cf7d793a6e55de5d05bb4b7d" dependencies = [ "once_cell", "pest", @@ -1900,9 +1905,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.27" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" [[package]] name = "poly1305" @@ -1910,7 +1915,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" dependencies = [ - "cpufeatures 0.2.11", + "cpufeatures 0.2.12", "opaque-debug", "universal-hash 0.4.1", ] @@ -1921,7 +1926,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" dependencies = [ - "cpufeatures 0.2.11", + "cpufeatures 0.2.12", "opaque-debug", "universal-hash 0.5.1", ] @@ -1933,7 +1938,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" dependencies = [ "cfg-if", - "cpufeatures 0.2.11", + "cpufeatures 0.2.12", "opaque-debug", "universal-hash 0.4.1", ] @@ -1945,11 +1950,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d52cff9d1d4dee5fe6d03729099f4a310a41179e0a10dbf542039873f2e826fb" dependencies = [ "cfg-if", - "cpufeatures 0.2.11", + "cpufeatures 0.2.12", "opaque-debug", "universal-hash 0.5.1", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -1982,18 +1993,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.70" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -2042,7 +2053,7 @@ checksum = "52c4f3084aa3bc7dfbba4eff4fab2a54db4324965d8872ab933565e6fbd83bc6" dependencies = [ "pem", "ring 0.16.20", - "time 0.3.20", + "time 0.3.31", "yasna", ] @@ -2057,14 +2068,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.6" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.9", - "regex-syntax 0.7.5", + "regex-automata 0.4.4", + "regex-syntax 0.8.2", ] [[package]] @@ -2078,13 +2089,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.9" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9" +checksum = "3b7fa1134405e2ec9353fd416b17f8dacd46c473d7d3fd1cf202706a14eb792a" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.5", + "regex-syntax 0.8.2", ] [[package]] @@ -2095,9 +2106,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.5" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "ring" @@ -2177,11 +2188,11 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustix" -version = "0.38.28" +version = "0.38.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "errno", "libc", "linux-raw-sys", @@ -2218,7 +2229,7 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ - "base64 0.21.5", + "base64 0.21.7", ] [[package]] @@ -2239,11 +2250,11 @@ checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "schannel" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -2308,29 +2319,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.193" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" dependencies = [ "itoa", "ryu", @@ -2366,7 +2377,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if", - "cpufeatures 0.2.11", + "cpufeatures 0.2.12", "digest 0.10.7", ] @@ -2378,7 +2389,7 @@ checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ "block-buffer 0.9.0", "cfg-if", - "cpufeatures 0.2.11", + "cpufeatures 0.2.12", "digest 0.9.0", "opaque-debug", ] @@ -2390,7 +2401,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", - "cpufeatures 0.2.11", + "cpufeatures 0.2.12", "digest 0.10.7", ] @@ -2433,9 +2444,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.2" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "socket2" @@ -2502,7 +2513,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d84b0a3c3739e220d94b3239fd69fb1f74bc36e16643423bd99de3b43c21bfbd" dependencies = [ - "ahash 0.8.6", + "ahash 0.8.7", "atoi", "byteorder", "bytes", @@ -2583,8 +2594,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e37195395df71fd068f6e2082247891bc11e3289624bbc776a0cdfa1ca7f1ea4" dependencies = [ "atoi", - "base64 0.21.5", - "bitflags 2.4.1", + "base64 0.21.7", + "bitflags 2.4.2", "byteorder", "bytes", "crc", @@ -2625,8 +2636,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6ac0ac3b7ccd10cc96c7ab29791a7dd236bd94021f31eec7ba3d46a74aa1c24" dependencies = [ "atoi", - "base64 0.21.5", - "bitflags 2.4.1", + "base64 0.21.7", + "bitflags 2.4.2", "byteorder", "crc", "dotenvy", @@ -2716,9 +2727,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.41" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c8b28c477cc3bf0e7966561e3460130e1255f7a1cf71931075f1c5e7a7e269" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -2738,22 +2749,22 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.8.1" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" +checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" dependencies = [ "cfg-if", "fastrand", "redox_syscall", "rustix", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "termcolor" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] @@ -2792,22 +2803,22 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" -version = "1.0.51" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f11c217e1416d6f036b870f14e0413d480dbf28edbee1f877abaf0206af43bb7" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.51" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01742297787513b79cf8e29d1056ede1313e2420b7b3b15d0a768b4921f549df" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -2833,19 +2844,21 @@ dependencies = [ [[package]] name = "time" -version = "0.3.20" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" +checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" dependencies = [ + "deranged", + "powerfmt", "serde", "time-core", ] [[package]] name = "time-core" -version = "0.1.0" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "tinyvec" @@ -2864,9 +2877,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.35.0" +version = "1.35.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841d45b238a16291a4e1584e61820b8ae57d696cc5015c459c229ccc6990cc1c" +checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" dependencies = [ "backtrace", "bytes", @@ -2889,7 +2902,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -2962,7 +2975,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -3024,9 +3037,9 @@ checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" [[package]] name = "unicode-bidi" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" @@ -3093,7 +3106,7 @@ version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8cdd25c339e200129fe4de81451814e5228c9b771d57378817d6117cc2b3f97" dependencies = [ - "base64 0.21.5", + "base64 0.21.7", "flate2", "log", "once_cell", @@ -3162,9 +3175,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -3172,24 +3185,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3197,28 +3210,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" +checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" [[package]] name = "web-sys" -version = "0.3.66" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" +checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" dependencies = [ "js-sys", "wasm-bindgen", @@ -3232,13 +3245,14 @@ checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" [[package]] name = "which" -version = "4.4.0" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" dependencies = [ "either", - "libc", + "home", "once_cell", + "rustix", ] [[package]] @@ -3423,9 +3437,9 @@ dependencies = [ [[package]] name = "xattr" -version = "1.1.3" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7dae5072fe1f8db8f8d29059189ac175196e410e40ba42d5d4684ae2f750995" +checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f" dependencies = [ "libc", "linux-raw-sys", @@ -3447,27 +3461,27 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" dependencies = [ - "time 0.3.20", + "time 0.3.31", ] [[package]] name = "zerocopy" -version = "0.7.31" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c4061bedbb353041c12f413700357bec76df2c7e2ca8e4df8bac24c6bf68e3d" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.31" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3c129550b3e6de3fd0ba67ba5c81818f9805e58b8d7fee80a3a59d2c9fc601a" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -3487,7 +3501,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] diff --git a/payjoin-cli/src/app.rs b/payjoin-cli/src/app.rs index a84e85e2a..0e872acde 100644 --- a/payjoin-cli/src/app.rs +++ b/payjoin-cli/src/app.rs @@ -79,12 +79,12 @@ impl App { let req_ctx = if is_retry { log::debug!("Resuming session"); // Get a reference to RequestContext - session.req_ctx.as_ref().expect("RequestContext is missing") + session.req_ctx.as_mut().expect("RequestContext is missing") } else { let req_ctx = self.create_pj_request(bip21, fee_rate)?; session.write(req_ctx)?; log::debug!("Writing req_ctx"); - session.req_ctx.as_ref().expect("RequestContext is missing") + session.req_ctx.as_mut().expect("RequestContext is missing") }; log::debug!("Awaiting response"); let res = self.long_poll_post(req_ctx).await?; @@ -163,7 +163,7 @@ impl App { log::debug!("Awaiting proposal"); let res = self.long_poll_fallback(&mut enrolled).await?; log::debug!("Received request"); - let payjoin_proposal = self + let mut payjoin_proposal = self .process_v2_proposal(res) .map_err(|e| anyhow!("Failed to process proposal {}", e))?; log::debug!("Posting payjoin back"); @@ -194,7 +194,7 @@ impl App { } #[cfg(feature = "v2")] - async fn long_poll_post(&self, req_ctx: &payjoin::send::RequestContext) -> Result { + async fn long_poll_post(&self, req_ctx: &mut payjoin::send::RequestContext) -> Result { loop { let (req, ctx) = req_ctx.extract_v2(&self.config.ohttp_proxy)?; println!("Sending fallback request to {}", &req.url); diff --git a/payjoin-relay/src/main.rs b/payjoin-relay/src/main.rs index 1b9520a24..c533733d7 100644 --- a/payjoin-relay/src/main.rs +++ b/payjoin-relay/src/main.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use anyhow::Result; use bitcoin::{self, base64}; -use hyper::header::HeaderValue; +use hyper::header::{HeaderValue, ACCESS_CONTROL_ALLOW_ORIGIN, CONTENT_TYPE}; use hyper::server::conn::AddrIncoming; use hyper::server::Builder; use hyper::service::{make_service_fn, service_fn}; @@ -111,7 +111,7 @@ fn init_ohttp() -> Result { encoded_config, base64::Config::new(base64::CharacterSet::UrlSafe, false), ); - info!("ohttp server config base64 UrlSafe: {:?}", b64_config); + info!("ohttp-keys server config base64 UrlSafe: {:?}", b64_config); Ok(ohttp::Server::new(server_config)?) } @@ -128,17 +128,14 @@ async fn handle_ohttp_gateway( debug!("handle_ohttp_gateway: {:?}", &path_segments); let mut response = match (parts.method, path_segments.as_slice()) { (Method::POST, ["", ""]) => handle_ohttp(body, pool, ohttp).await, - (Method::GET, ["", "ohttp-config"]) => - Ok(get_ohttp_config(ohttp_config(&ohttp).await?).await), + (Method::GET, ["", "ohttp-keys"]) => get_ohttp_keys(&ohttp).await, (Method::POST, ["", id]) => post_fallback_v1(id, query, body, pool).await, _ => Ok(not_found()), } .unwrap_or_else(|e| e.to_response()); // Allow CORS for third-party access - response - .headers_mut() - .insert("Access-Control-Allow-Origin", hyper::header::HeaderValue::from_static("*")); + response.headers_mut().insert(ACCESS_CONTROL_ALLOW_ORIGIN, HeaderValue::from_static("*")); Ok(response) } @@ -227,7 +224,7 @@ impl HandlerError { error!("Bad request: Key configuration rejected: {}", e); *res.status_mut() = StatusCode::BAD_REQUEST; res.headers_mut() - .insert("Content-Type", HeaderValue::from_static("application/problem+json")); + .insert(CONTENT_TYPE, HeaderValue::from_static("application/problem+json")); *res.body_mut() = Body::from(OHTTP_KEY_REJECTION_RES_JSON); } HandlerError::BadRequest(e) => { @@ -355,18 +352,17 @@ fn not_found() -> Response { res } -async fn get_ohttp_config(config: String) -> Response { - trace!("GET ohttp config: {:?}", config); +async fn get_ohttp_keys(ohttp: &Arc>) -> Result, HandlerError> { let mut res = Response::default(); - *res.body_mut() = Body::from(config); - res + res.headers_mut().insert(CONTENT_TYPE, HeaderValue::from_static("application/ohttp-keys")); + let ohttp_keys = ohttp + .lock() + .await + .config() + .encode() + .map_err(|e| HandlerError::InternalServerError(e.into()))?; + *res.body_mut() = Body::from(ohttp_keys); + Ok(res) } fn shorten_string(input: &str) -> String { input.chars().take(8).collect() } - -async fn ohttp_config(server: &Arc>) -> Result { - let b64_config = base64::Config::new(base64::CharacterSet::UrlSafe, false); - let server = server.lock().await; - let encoded_config = server.config().encode()?; - Ok(base64::encode_config(encoded_config, b64_config)) -} diff --git a/payjoin/src/lib.rs b/payjoin/src/lib.rs index 269909281..823d09cd6 100644 --- a/payjoin/src/lib.rs +++ b/payjoin/src/lib.rs @@ -29,6 +29,8 @@ pub mod send; #[cfg(feature = "v2")] pub(crate) mod v2; +#[cfg(feature = "v2")] +pub use ohttp::KeyConfig as OhttpKeys; #[cfg(any(feature = "send", feature = "receive"))] pub(crate) mod input_type; diff --git a/payjoin/src/receive/v2.rs b/payjoin/src/receive/v2.rs index 5d872975b..3792a7fc4 100644 --- a/payjoin/src/receive/v2.rs +++ b/payjoin/src/receive/v2.rs @@ -27,7 +27,7 @@ pub struct Request { #[derive(Debug, Clone)] pub struct V2Context { relay_url: url::Url, - ohttp_config: Vec, + ohttp_keys: ohttp::KeyConfig, ohttp_proxy: url::Url, s: bitcoin::secp256k1::KeyPair, e: Option, @@ -36,7 +36,7 @@ pub struct V2Context { #[derive(Debug, Clone)] pub struct Enroller { relay_url: url::Url, - ohttp_config: Vec, + ohttp_keys: ohttp::KeyConfig, ohttp_proxy: url::Url, s: bitcoin::secp256k1::KeyPair, } @@ -49,14 +49,15 @@ impl Enroller { ohttp_proxy_url: &str, ) -> Self { let ohttp_config = base64::decode_config(ohttp_config_base64, base64::URL_SAFE).unwrap(); + let ohttp_keys = ohttp::KeyConfig::decode(&ohttp_config).unwrap(); let ohttp_proxy = url::Url::parse(ohttp_proxy_url).unwrap(); let relay_url = url::Url::parse(relay_url).unwrap(); let secp = bitcoin::secp256k1::Secp256k1::new(); let (sk, _) = secp.generate_keypair(&mut rand::rngs::OsRng); Enroller { - ohttp_config, - ohttp_proxy, relay_url, + ohttp_keys, + ohttp_proxy, s: bitcoin::secp256k1::KeyPair::from_secret_key(&secp, &sk), } } @@ -71,11 +72,12 @@ impl Enroller { pub fn extract_req(&mut self) -> Result<(Request, ohttp::ClientResponse), crate::v2::Error> { let url = self.ohttp_proxy.clone(); + let subdirectory = self.subdirectory(); let (body, ctx) = crate::v2::ohttp_encapsulate( - &self.ohttp_config, + &mut self.ohttp_keys, "POST", self.relay_url.as_str(), - Some(self.subdirectory().as_bytes()), + Some(subdirectory.as_bytes()), )?; let req = Request { url, body }; Ok((req, ctx)) @@ -93,7 +95,7 @@ impl Enroller { let ctx = Enrolled { relay_url: self.relay_url, - ohttp_config: self.ohttp_config, + ohttp_keys: self.ohttp_keys, ohttp_proxy: self.ohttp_proxy, s: self.s, }; @@ -107,22 +109,37 @@ fn subdirectory(pubkey: &bitcoin::secp256k1::PublicKey) -> String { base64::encode_config(pubkey, b64_config) } -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, Clone)] pub struct Enrolled { relay_url: url::Url, - ohttp_config: Vec, + ohttp_keys: ohttp::KeyConfig, ohttp_proxy: url::Url, s: bitcoin::secp256k1::KeyPair, } +impl PartialEq for Enrolled { + fn eq(&self, other: &Self) -> bool { + self.relay_url == other.relay_url + && self.ohttp_keys.encode().unwrap() == other.ohttp_keys.encode().unwrap() + && self.ohttp_proxy == other.ohttp_proxy + && self.s == other.s + } +} + +impl Eq for Enrolled {} + impl Serialize for Enrolled { fn serialize(&self, serializer: S) -> Result where S: Serializer, { + use serde::ser::Error; + let mut state = serializer.serialize_struct("Enrolled", 4)?; state.serialize_field("relay_url", &self.relay_url.to_string())?; - state.serialize_field("ohttp_config", &self.ohttp_config)?; + let ohttp_keys = + self.ohttp_keys.encode().map_err(|_| S::Error::custom("ohttp_key encoding failed"))?; + state.serialize_field("ohttp_keys", &ohttp_keys)?; state.serialize_field("ohttp_proxy", &self.ohttp_proxy.to_string())?; state.serialize_field("s", &self.s.secret_key().secret_bytes())?; @@ -158,7 +175,7 @@ impl<'de> Deserialize<'de> for Enrolled { type Value = Field; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("`relay_url`, `ohttp_config`, `ohttp_proxy`, or `s`") + formatter.write_str("`relay_url`, `ohttp_keys`, `ohttp_proxy`, or `s`") } fn visit_str(self, value: &str) -> Result @@ -167,7 +184,7 @@ impl<'de> Deserialize<'de> for Enrolled { { match value { "relay_url" => Ok(Field::RelayUrl), - "ohttp_config" => Ok(Field::OhttpConfig), + "ohttp_keys" => Ok(Field::OhttpConfig), "ohttp_proxy" => Ok(Field::OhttpProxy), "s" => Ok(Field::S), _ => Err(de::Error::unknown_field(value, FIELDS)), @@ -193,7 +210,7 @@ impl<'de> Deserialize<'de> for Enrolled { V: MapAccess<'de>, { let mut relay_url = None; - let mut ohttp_config = None; + let mut ohttp_keys = None; let mut ohttp_proxy = None; let mut s = None; while let Some(key) = map.next_key()? { @@ -206,10 +223,14 @@ impl<'de> Deserialize<'de> for Enrolled { relay_url = Some(url::Url::parse(&url_str).map_err(de::Error::custom)?); } Field::OhttpConfig => { - if ohttp_config.is_some() { - return Err(de::Error::duplicate_field("ohttp_config")); + if ohttp_keys.is_some() { + return Err(de::Error::duplicate_field("ohttp_keys")); } - ohttp_config = Some(map.next_value()?); + let ohttp_keys_bytes: Vec = map.next_value()?; + ohttp_keys = Some( + ohttp::KeyConfig::decode(&ohttp_keys_bytes) + .map_err(|_| de::Error::custom("ohttp_key decoding failed"))?, + ); } Field::OhttpProxy => { if ohttp_proxy.is_some() { @@ -233,12 +254,12 @@ impl<'de> Deserialize<'de> for Enrolled { } } let relay_url = relay_url.ok_or_else(|| de::Error::missing_field("relay_url"))?; - let ohttp_config = - ohttp_config.ok_or_else(|| de::Error::missing_field("ohttp_config"))?; + let ohttp_keys = + ohttp_keys.ok_or_else(|| de::Error::missing_field("ohttp_keys"))?; let ohttp_proxy = ohttp_proxy.ok_or_else(|| de::Error::missing_field("ohttp_proxy"))?; let s = s.ok_or_else(|| de::Error::missing_field("s"))?; - Ok(Enrolled { relay_url, ohttp_config, ohttp_proxy, s }) + Ok(Enrolled { relay_url, ohttp_keys, ohttp_proxy, s }) } } @@ -248,7 +269,7 @@ impl<'de> Deserialize<'de> for Enrolled { } impl Enrolled { - pub fn extract_req(&self) -> Result<(Request, ohttp::ClientResponse), Error> { + pub fn extract_req(&mut self) -> Result<(Request, ohttp::ClientResponse), Error> { let (body, ohttp_ctx) = self.fallback_req_body()?; let url = self.ohttp_proxy.clone(); let req = Request { url, body }; @@ -275,7 +296,7 @@ impl Enrolled { Ok(proposal) => { let context = V2Context { relay_url: self.relay_url.clone(), - ohttp_config: self.ohttp_config.clone(), + ohttp_keys: self.ohttp_keys.clone(), ohttp_proxy: self.ohttp_proxy.clone(), s: self.s, e: None, @@ -288,7 +309,7 @@ impl Enrolled { log::debug!("Some e: {}", e); let context = V2Context { relay_url: self.relay_url.clone(), - ohttp_config: self.ohttp_config.clone(), + ohttp_keys: self.ohttp_keys.clone(), ohttp_proxy: self.ohttp_proxy.clone(), s: self.s, e: Some(e), @@ -300,10 +321,11 @@ impl Enrolled { } } - fn fallback_req_body(&self) -> Result<(Vec, ohttp::ClientResponse), crate::v2::Error> { + fn fallback_req_body(&mut self) -> Result<(Vec, ohttp::ClientResponse), crate::v2::Error> { let fallback_target = format!("{}{}", &self.relay_url, self.fallback_target()); log::trace!("Fallback request target: {}", fallback_target.as_str()); - crate::v2::ohttp_encapsulate(&self.ohttp_config, "GET", &self.fallback_target(), None) + let fallback_target = self.fallback_target(); + crate::v2::ohttp_encapsulate(&mut self.ohttp_keys, "GET", &fallback_target, None) } pub fn pubkey(&self) -> [u8; 33] { self.s.public_key().serialize() } @@ -544,7 +566,7 @@ impl PayjoinProposal { pub fn extract_v1_req(&self) -> String { base64::encode(self.inner.payjoin_psbt.serialize()) } #[cfg(feature = "v2")] - pub fn extract_v2_req(&self) -> Result<(Request, ohttp::ClientResponse), Error> { + pub fn extract_v2_req(&mut self) -> Result<(Request, ohttp::ClientResponse), Error> { let body = match self.context.e { Some(e) => { let mut payjoin_bytes = self.inner.payjoin_psbt.serialize(); @@ -560,7 +582,7 @@ impl PayjoinProposal { ); log::debug!("Payjoin post target: {}", post_payjoin_target.as_str()); let (body, ctx) = crate::v2::ohttp_encapsulate( - &self.context.ohttp_config, + &mut self.context.ohttp_keys, "POST", &post_payjoin_target, Some(&body), @@ -590,9 +612,16 @@ mod test { #[test] #[cfg(feature = "v2")] fn enrolled_ser_de_roundtrip() { + use ohttp::hpke::{Aead, Kdf, Kem}; + use ohttp::{KeyId, SymmetricSuite}; + const KEY_ID: KeyId = 1; + const KEM: Kem = Kem::X25519Sha256; + const SYMMETRIC: &[SymmetricSuite] = + &[ohttp::SymmetricSuite::new(Kdf::HkdfSha256, Aead::ChaCha20Poly1305)]; + let enrolled = Enrolled { relay_url: url::Url::parse("https://relay.com").unwrap(), - ohttp_config: vec![1, 2, 3], + ohttp_keys: ohttp::KeyConfig::new(KEY_ID, KEM, Vec::from(SYMMETRIC)).unwrap(), ohttp_proxy: url::Url::parse("https://proxy.com").unwrap(), s: bitcoin::secp256k1::KeyPair::from_secret_key( &bitcoin::secp256k1::Secp256k1::new(), @@ -600,7 +629,7 @@ mod test { ), }; let serialized = serde_json::to_string(&enrolled).unwrap(); - let deserialized = serde_json::from_str(&serialized).unwrap(); + let deserialized: Enrolled = serde_json::from_str(&serialized).unwrap(); assert!(enrolled == deserialized); } } diff --git a/payjoin/src/send/mod.rs b/payjoin/src/send/mod.rs index 52decf9d6..e7c08aac1 100644 --- a/payjoin/src/send/mod.rs +++ b/payjoin/src/send/mod.rs @@ -431,7 +431,7 @@ impl RequestContext { /// The `ohttp_proxy` merely passes the encrypted payload to the ohttp gateway of the receiver #[cfg(feature = "v2")] pub fn extract_v2( - &self, + &mut self, ohttp_proxy_url: &str, ) -> Result<(Request, ContextV2), CreateRequestError> { let rs_base64 = crate::v2::subdir(self.endpoint.as_str()).to_string(); @@ -454,12 +454,7 @@ impl RequestContext { let body = crate::v2::encrypt_message_a(body, self.e, rs) .map_err(InternalCreateRequestError::V2)?; let (body, ohttp_res) = crate::v2::ohttp_encapsulate( - &self - .ohttp_config - .as_ref() - .ok_or(InternalCreateRequestError::MissingOhttpConfig)? - .encode() - .map_err(|e| InternalCreateRequestError::V2(e.into()))?, + self.ohttp_config.as_mut().ok_or(InternalCreateRequestError::MissingOhttpConfig)?, "POST", url.as_str(), Some(&body), diff --git a/payjoin/src/v2.rs b/payjoin/src/v2.rs index 55e2cd9de..096df0065 100644 --- a/payjoin/src/v2.rs +++ b/payjoin/src/v2.rs @@ -186,12 +186,12 @@ impl From for Error { } pub fn ohttp_encapsulate( - ohttp_config: &[u8], + ohttp_keys: &mut ohttp::KeyConfig, method: &str, target_resource: &str, body: Option<&[u8]>, ) -> Result<(Vec, ohttp::ClientResponse), Error> { - let ctx = ohttp::ClientRequest::from_encoded_config(ohttp_config)?; + let ctx = ohttp::ClientRequest::from_config(ohttp_keys)?; let url = url::Url::parse(target_resource)?; let mut bhttp_message = bhttp::Message::request( method.as_bytes().to_vec(), diff --git a/payjoin/tests/integration.rs b/payjoin/tests/integration.rs index 451fb95e6..b87d478de 100644 --- a/payjoin/tests/integration.rs +++ b/payjoin/tests/integration.rs @@ -199,7 +199,7 @@ mod integration { use super::*; const PJ_RELAY_URL: &str = "https://localhost:8088"; - const BAD_OHTTP_CONFIG: &str = "AQAg3WpRjS0aqAxQUoLvpas2VYjT2oIg6-3XSiB-QiYI1BAABAABAAM"; + const BAD_OHTTP_KEYS: &str = "AQAg3WpRjS0aqAxQUoLvpas2VYjT2oIg6-3XSiB-QiYI1BAABAABAAM"; const OH_RELAY_URL: &str = "https://localhost:8088"; const LOCAL_CERT_FILE: &str = "localhost.der"; @@ -213,21 +213,31 @@ mod integration { // ********************** // From a connection distinct from the client, perhaps a service provider, or over a VPN or Tor - // get ohttp-config at PJ_RELAY_URL in spawn_blocking + // get ohttp-keys at PJ_RELAY_URL in spawn_blocking let ohttp_config = { - let response = spawn_blocking(move || { - http_agent().get(&format!("{}/ohttp-config", PJ_RELAY_URL)).call() + use std::io::Read; + let resp = spawn_blocking(move || { + http_agent().get(&format!("{}/ohttp-keys", PJ_RELAY_URL)).call() }) .await??; - response.into_string()? + let len = + resp.header("Content-Length").and_then(|s| s.parse::().ok()).unwrap(); + + let mut bytes: Vec = Vec::with_capacity(len); + resp.into_reader().take(10_000_000).read_to_end(&mut bytes)?; + let ohttp_keys = payjoin::OhttpKeys::decode(&bytes)?; + base64::encode_config( + ohttp_keys.encode()?, + base64::Config::new(base64::CharacterSet::UrlSafe, false), + ) }; - debug!("GET'd ohttp-config: {}", ohttp_config); + debug!("GET'd ohttp-keys: {}", ohttp_config); // ********************** // Inside the Receiver: - // Try enroll with bad relay ohttp-config + // Try enroll with bad relay ohttp-keys let mut bad_enroller = - Enroller::from_relay_config(&PJ_RELAY_URL, &BAD_OHTTP_CONFIG, &OH_RELAY_URL); + Enroller::from_relay_config(&PJ_RELAY_URL, &BAD_OHTTP_KEYS, &OH_RELAY_URL); let (req, _ctx) = bad_enroller.extract_req()?; let res = spawn_blocking(move || http_agent().post(req.url.as_str()).send_bytes(&req.body)) @@ -246,7 +256,7 @@ mod integration { spawn_blocking(move || http_agent().post(req.url.as_str()).send_bytes(&req.body)) .await??; assert!(is_success(res.status())); - let enrolled = enroller.process_res(res.into_reader(), ctx)?; + let mut enrolled = enroller.process_res(res.into_reader(), ctx)?; let fallback_target = enrolled.fallback_target(); // Receiver creates the payjoin URI let pj_receiver_address = receiver.get_new_address(None, None)?.assume_checked(); @@ -293,7 +303,7 @@ mod integration { // POST payjoin let proposal = enrolled.process_res(response.into_reader(), ctx)?.unwrap(); - let payjoin_proposal = handle_relay_proposal(receiver, proposal); + let mut payjoin_proposal = handle_relay_proposal(receiver, proposal); let (req, ctx) = payjoin_proposal.extract_v2_req()?; let response = spawn_blocking(move || http_agent().post(req.url.as_str()).send_bytes(&req.body)) @@ -336,13 +346,23 @@ mod integration { // From a connection distinct from the client, perhaps a service provider, or over a VPN or Tor // get ohttp-config at PJ_RELAY_URL in spawn_blocking let ohttp_config = { - let response = spawn_blocking(move || { - http_agent().get(&format!("{}/ohttp-config", PJ_RELAY_URL)).call() + use std::io::Read; + let resp = spawn_blocking(move || { + http_agent().get(&format!("{}/ohttp-keys", PJ_RELAY_URL)).call() }) .await??; - response.into_string()? + let len = + resp.header("Content-Length").and_then(|s| s.parse::().ok()).unwrap(); + + let mut bytes: Vec = Vec::with_capacity(len); + resp.into_reader().take(10_000_000).read_to_end(&mut bytes)?; + let ohttp_keys = payjoin::OhttpKeys::decode(&bytes)?; + base64::encode_config( + ohttp_keys.encode()?, + base64::Config::new(base64::CharacterSet::UrlSafe, false), + ) }; - debug!("GET'd ohttp-config: {}", ohttp_config); + debug!("GET'd ohttp-keys: {}", ohttp_config); // ********************** // Inside the Receiver: @@ -354,7 +374,7 @@ mod integration { spawn_blocking(move || http_agent().post(req.url.as_str()).send_bytes(&req.body)) .await??; assert!(is_success(res.status())); - let enrolled = enroller.process_res(res.into_reader(), ctx)?; + let mut enrolled = enroller.process_res(res.into_reader(), ctx)?; // Receiver creates the payjoin URI let pj_receiver_address = receiver.get_new_address(None, None)?.assume_checked(); @@ -415,7 +435,7 @@ mod integration { }; debug!("handle relay response"); let proposal = enrolled.process_res(response, ctx).unwrap().unwrap(); - let payjoin_proposal = handle_relay_proposal(receiver, proposal); + let mut payjoin_proposal = handle_relay_proposal(receiver, proposal); // Respond with payjoin psbt within the time window the sender is willing to wait // this response would be returned as http response to the sender let (req, ctx) = payjoin_proposal.extract_v2_req().unwrap();