diff --git a/Cargo.lock b/Cargo.lock index fc885177..e4706760 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1246,15 +1246,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "encoding_rs" -version = "0.8.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" -dependencies = [ - "cfg-if", -] - [[package]] name = "enum-as-inner" version = "0.6.0" @@ -1493,7 +1484,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35bd3cf68c183738046838e300353e4716c674dc5e56890de4826801a6622a28" dependencies = [ "futures-io", - "rustls", + "rustls 0.21.10", ] [[package]] @@ -1989,6 +1980,7 @@ dependencies = [ "itoa", "pin-project-lite", "tokio", + "want", ] [[package]] @@ -2006,16 +1998,19 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.2" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" dependencies = [ "futures-util", - "http 0.2.11", - "hyper 0.14.28", - "rustls", + "http 1.1.0", + "hyper 1.1.0", + "hyper-util", + "rustls 0.22.3", + "rustls-pki-types", "tokio", "tokio-rustls", + "tower-service", ] [[package]] @@ -2025,6 +2020,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" dependencies = [ "bytes", + "futures-channel", "futures-util", "http 1.1.0", "http-body 1.0.0", @@ -2032,6 +2028,9 @@ dependencies = [ "pin-project-lite", "socket2", "tokio", + "tower", + "tower-service", + "tracing", ] [[package]] @@ -2677,7 +2676,7 @@ dependencies = [ "quinn", "rand", "ring 0.16.20", - "rustls", + "rustls 0.21.10", "socket2", "thiserror", "tokio", @@ -2748,8 +2747,8 @@ dependencies = [ "libp2p-identity", "rcgen", "ring 0.16.20", - "rustls", - "rustls-webpki", + "rustls 0.21.10", + "rustls-webpki 0.101.7", "thiserror", "x509-parser", "yasna", @@ -3369,7 +3368,7 @@ dependencies = [ "url", "wasm-bindgen", "wasm-bindgen-test", - "wasm-streams", + "wasm-streams 0.3.0", "web-sys", ] @@ -4130,7 +4129,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls", + "rustls 0.21.10", "thiserror", "tokio", "tracing", @@ -4146,7 +4145,7 @@ dependencies = [ "rand", "ring 0.16.20", "rustc-hash", - "rustls", + "rustls 0.21.10", "slab", "thiserror", "tinyvec", @@ -4292,20 +4291,20 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" -version = "0.11.20" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" +checksum = "2d66674f2b6fb864665eea7a3c1ac4e3dfacd2fda83cf6f935a612e01b0e3338" dependencies = [ "base64", "bytes", - "encoding_rs", "futures-core", "futures-util", - "h2 0.3.24", - "http 0.2.11", - "http-body 0.4.6", - "hyper 0.14.28", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.1.0", "hyper-rustls", + "hyper-util", "ipnet", "js-sys", "log", @@ -4313,11 +4312,13 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls", + "rustls 0.22.3", "rustls-pemfile", + "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", + "sync_wrapper", "tokio", "tokio-rustls", "tokio-util", @@ -4325,7 +4326,7 @@ dependencies = [ "url", "wasm-bindgen", "wasm-bindgen-futures", - "wasm-streams", + "wasm-streams 0.4.0", "web-sys", "webpki-roots", "winreg", @@ -4491,10 +4492,24 @@ checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" dependencies = [ "log", "ring 0.17.7", - "rustls-webpki", + "rustls-webpki 0.101.7", "sct", ] +[[package]] +name = "rustls" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99008d7ad0bbbea527ec27bddbc0e432c5b87d8175178cee68d2eec9c4a1813c" +dependencies = [ + "log", + "ring 0.17.7", + "rustls-pki-types", + "rustls-webpki 0.102.2", + "subtle", + "zeroize", +] + [[package]] name = "rustls-pemfile" version = "1.0.4" @@ -4504,6 +4519,12 @@ dependencies = [ "base64", ] +[[package]] +name = "rustls-pki-types" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "868e20fada228fefaf6b652e00cc73623d54f8171e7352c18bb281571f2d92da" + [[package]] name = "rustls-webpki" version = "0.101.7" @@ -4514,6 +4535,17 @@ dependencies = [ "untrusted 0.9.0", ] +[[package]] +name = "rustls-webpki" +version = "0.102.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" +dependencies = [ + "ring 0.17.7", + "rustls-pki-types", + "untrusted 0.9.0", +] + [[package]] name = "rustversion" version = "1.0.14" @@ -4966,9 +4998,9 @@ dependencies = [ [[package]] name = "subtle" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "symlink" @@ -5189,11 +5221,12 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.24.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" dependencies = [ - "rustls", + "rustls 0.22.3", + "rustls-pki-types", "tokio", ] @@ -5778,6 +5811,19 @@ dependencies = [ "web-sys", ] +[[package]] +name = "wasm-streams" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b65dc4c90b63b118468cf747d8bf3566c1913ef60be765b5730ead9e0a3ba129" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "web-sys" version = "0.3.69" @@ -5800,9 +5846,12 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.4" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" +checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009" +dependencies = [ + "rustls-pki-types", +] [[package]] name = "widestring" diff --git a/Cargo.toml b/Cargo.toml index e5307076..79e82b06 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,7 +60,7 @@ libipld-cbor = { version = "0.16" } libipld-json = { version = "0.16" } pathdiff = { version = "0.2.1" } rand = { version = "0.8" } -reqwest = { version = "=0.11.20", default-features = false, features = ["json", "rustls-tls", "stream"] } +reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls", "stream"] } sentry-tracing = { version = "0.31.8" } serde = { version = "^1" } serde_json = { version = "^1" } diff --git a/rust/noosphere-cli/Cargo.toml b/rust/noosphere-cli/Cargo.toml index cc59992f..075930a6 100644 --- a/rust/noosphere-cli/Cargo.toml +++ b/rust/noosphere-cli/Cargo.toml @@ -28,7 +28,7 @@ observability = ["noosphere-gateway/observability"] vergen = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] -reqwest = { version = "~0.11", default-features = false, features = ["json", "rustls-tls", "stream"] } +reqwest = { workspace = true, default-features = false, features = ["json", "rustls-tls", "stream"] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] tempfile = { workspace = true } diff --git a/rust/noosphere-core/src/api/client.rs b/rust/noosphere-core/src/api/client.rs index 037cee19..045c7aef 100644 --- a/rust/noosphere-core/src/api/client.rs +++ b/rust/noosphere-core/src/api/client.rs @@ -1,7 +1,7 @@ -use std::str::FromStr; - use crate::{ - api::{route::RouteUrl, v0alpha1, v0alpha2, StatusCode}, + api::{route::RouteUrl, v0alpha1, v0alpha2}, + authority::{generate_capability, Author, SphereAbility, SphereReference}, + data::{Link, MemoIpld}, error::NoosphereError, stream::{from_car_stream, memo_history_stream, put_block_stream, to_car_stream}, }; @@ -9,14 +9,10 @@ use anyhow::{anyhow, Result}; use async_stream::try_stream; use bytes::Bytes; use cid::Cid; +use http::StatusCode; use iroh_car::CarReader; use libipld_cbor::DagCborCodec; use noosphere_common::{ConditionalSend, ConditionalSync, UnsharedStream}; - -use crate::{ - authority::{generate_capability, Author, SphereAbility, SphereReference}, - data::{Link, MemoIpld}, -}; use noosphere_storage::{block_deserialize, block_serialize, BlockStore}; use noosphere_ucan::{ builder::UcanBuilder, @@ -26,6 +22,7 @@ use noosphere_ucan::{ ucan::Ucan, }; use reqwest::header::HeaderMap; +use std::str::FromStr; use tokio_stream::{Stream, StreamExt}; use tokio_util::io::StreamReader; use url::Url; @@ -93,7 +90,7 @@ where client.get(url).send().await? }; - match translate_status_code(did_response.status())? { + match did_response.status() { StatusCode::OK => (), _ => return Err(anyhow!("Unable to look up gateway identity")), }; @@ -475,7 +472,7 @@ where v0alpha2::PushError::BrokenUpstream })?; - let status = translate_status_code(response.status())?; + let status = response.status(); trace!("Checking response ({})...", status); if status == StatusCode::CONFLICT { @@ -531,22 +528,3 @@ where Ok(push_response) } } - -/// Both `reqwest` and `axum` re-export `StatusCode` from the `http` crate. -/// -/// We're stuck on reqwest@0.11.20 [1] that uses an older version -/// of `http::StatusCode`, whereas axum >= 0.7 uses the 1.0 release -/// of several HTTP libraries (`http`, `http-body`, `hyper`) [2], which -/// we'd like to use as our canonical representation. -/// -/// This utility converts between the old `reqwest::StatusCode` to the -/// >=1.0 implementation. Notably, we do not pull in all of `axum` -/// into the `noosphere-core` crate, only the common underlying -/// crate `http@1.0.0` (or greater). -/// -/// [1] https://github.com/subconsciousnetwork/noosphere/issues/686 -/// [2] https://github.com/tokio-rs/axum/blob/5b6204168a676497d2f4188af603546d9ebfe20a/axum/CHANGELOG.md#070-27-november-2023 -fn translate_status_code(reqwest_code: reqwest::StatusCode) -> Result { - let code: u16 = reqwest_code.into(); - Ok(code.try_into()?) -} diff --git a/rust/noosphere-core/src/api/mod.rs b/rust/noosphere-core/src/api/mod.rs index 00d014e0..baeab325 100644 --- a/rust/noosphere-core/src/api/mod.rs +++ b/rust/noosphere-core/src/api/mod.rs @@ -11,7 +11,3 @@ pub mod v0alpha2; pub use client::*; pub use data::*; - -// Re-export `http::StatusCode` here as our preferred `StatusCode` instance, -// disambiguating from other crate's implementations. -pub(crate) use http::StatusCode; diff --git a/rust/noosphere-core/src/api/v0alpha1/data.rs b/rust/noosphere-core/src/api/v0alpha1/data.rs index fdf5f6c7..5c4eed95 100644 --- a/rust/noosphere-core/src/api/v0alpha1/data.rs +++ b/rust/noosphere-core/src/api/v0alpha1/data.rs @@ -1,15 +1,11 @@ -use std::fmt::Display; - -use crate::api::{ - data::{empty_string_as_none, AsQuery}, - StatusCode, -}; use crate::{ + api::data::{empty_string_as_none, AsQuery}, authority::{generate_capability, SphereAbility, SPHERE_SEMANTICS}, data::{Bundle, Did, Jwt, Link, MemoIpld}, }; use anyhow::{anyhow, Result}; use cid::Cid; +use http::StatusCode; use noosphere_storage::{base64_decode, base64_encode}; use noosphere_ucan::{ chain::ProofChain, @@ -18,6 +14,7 @@ use noosphere_ucan::{ Ucan, }; use serde::{Deserialize, Serialize}; +use std::fmt::Display; use thiserror::Error; /// The query parameters expected for the "replicate" API route. diff --git a/rust/noosphere-core/src/api/v0alpha2/data.rs b/rust/noosphere-core/src/api/v0alpha2/data.rs index 203d3bbf..b84a529c 100644 --- a/rust/noosphere-core/src/api/v0alpha2/data.rs +++ b/rust/noosphere-core/src/api/v0alpha2/data.rs @@ -1,7 +1,5 @@ -use crate::{ - api::StatusCode, - data::{Did, Jwt, Link, MemoIpld}, -}; +use crate::data::{Did, Jwt, Link, MemoIpld}; +use http::StatusCode; use serde::{Deserialize, Serialize}; use thiserror::Error; diff --git a/rust/noosphere-ipfs/Cargo.toml b/rust/noosphere-ipfs/Cargo.toml index c8a65da4..ea7e66b2 100644 --- a/rust/noosphere-ipfs/Cargo.toml +++ b/rust/noosphere-ipfs/Cargo.toml @@ -31,7 +31,7 @@ async-stream = { workspace = true } libipld-core = { workspace = true } libipld-cbor = { workspace = true } cid = { workspace = true } -reqwest = { version = "~0.11", default-features = false, features = ["json", "rustls-tls", "stream"] } +reqwest = { workspace = true, default-features = false, features = ["json", "rustls-tls", "stream"] } serde = { workspace = true } serde_json = { workspace = true } tokio = { workspace = true, features = ["io-util"] } diff --git a/rust/noosphere-ns/Cargo.toml b/rust/noosphere-ns/Cargo.toml index 25016417..104e414b 100644 --- a/rust/noosphere-ns/Cargo.toml +++ b/rust/noosphere-ns/Cargo.toml @@ -51,7 +51,7 @@ toml = { version = "~0.8", optional = true } # noosphere_ns::server axum = { workspace = true, features = ["json", "macros"], optional = true } axum-tracing-opentelemetry = { workspace = true, optional = true } -reqwest = { version = "~0.11", default-features = false, features = ["json", "rustls-tls"], optional = true } +reqwest = { workspace = true, default-features = false, features = ["json", "rustls-tls"], optional = true } tower-http = { workspace = true, features = ["trace"], optional = true } url = { version = "^2", features = [ "serde" ], optional = true }