diff --git a/protocol/Cargo.toml b/protocol/Cargo.toml index ce52bef3..b35bef2b 100644 --- a/protocol/Cargo.toml +++ b/protocol/Cargo.toml @@ -4,6 +4,12 @@ version = "0.0.1" authors = [ "Thinkofdeath ", "iceiix " ] edition = "2021" +[features] +# Enables support for authenticating with Mojang servers. +auth = ["reqwest"] + +default = ["auth"] + [dependencies] serde = "1.0.132" serde_json = "1.0.73" @@ -26,4 +32,4 @@ path = "../std_or_web" version = "0" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -reqwest = { version = "0.11.8", features = [ "blocking" ]} +reqwest = { version = "0.11.8", features = [ "blocking" ], optional = true } diff --git a/protocol/src/protocol/mod.rs b/protocol/src/protocol/mod.rs index 9c9d81b0..a2b9210b 100644 --- a/protocol/src/protocol/mod.rs +++ b/protocol/src/protocol/mod.rs @@ -1019,6 +1019,7 @@ pub enum Error { Disconnect(format::Component), IOError(io::Error), Json(serde_json::Error), + #[cfg(feature = "auth")] #[cfg(not(target_arch = "wasm32"))] Reqwest(reqwest::Error), } @@ -1035,6 +1036,7 @@ impl convert::From for Error { } } +#[cfg(feature = "auth")] #[cfg(not(target_arch = "wasm32"))] impl convert::From for Error { fn from(e: reqwest::Error) -> Error { @@ -1051,6 +1053,7 @@ impl ::std::fmt::Display for Error { Error::Disconnect(ref val) => write!(f, "{}", val), Error::IOError(ref e) => e.fmt(f), Error::Json(ref e) => e.fmt(f), + #[cfg(feature = "auth")] #[cfg(not(target_arch = "wasm32"))] Error::Reqwest(ref e) => e.fmt(f), } diff --git a/protocol/src/protocol/mojang.rs b/protocol/src/protocol/mojang.rs index 0c852e65..1f7de9bf 100644 --- a/protocol/src/protocol/mojang.rs +++ b/protocol/src/protocol/mojang.rs @@ -28,6 +28,7 @@ const LOGIN_URL: &str = "https://authserver.mojang.com/authenticate"; const REFRESH_URL: &str = "https://authserver.mojang.com/refresh"; const VALIDATE_URL: &str = "https://authserver.mojang.com/validate"; +#[cfg(feature = "auth")] #[cfg(not(target_arch = "wasm32"))] impl Profile { pub fn login(username: &str, password: &str, token: &str) -> Result {