aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--Cargo.lock129
-rw-r--r--Cargo.toml13
-rw-r--r--azalea-auth/Cargo.toml6
-rw-r--r--azalea-auth/src/lib.rs11
-rw-r--r--azalea-auth/src/sessionserver.rs1
-rw-r--r--azalea-client/Cargo.toml11
-rw-r--r--azalea-client/src/account.rs30
-rw-r--r--azalea-client/src/plugins/chat/handler.rs13
-rw-r--r--azalea-client/src/plugins/chat_signing.rs4
-rw-r--r--azalea-client/src/plugins/disconnect.rs7
-rw-r--r--azalea-client/src/plugins/login.rs94
-rw-r--r--azalea-client/src/plugins/mod.rs8
-rw-r--r--azalea-protocol/Cargo.toml3
-rw-r--r--azalea-protocol/src/connect.rs8
-rw-r--r--azalea/Cargo.toml4
16 files changed, 208 insertions, 136 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ad88fbf5..a17fda99 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ is breaking anyways, semantic versioning is not followed.
- Add `Client::query_entity` and `try_query_entity` to complement `query_self`.
- Add `Client::entity_interact` and `EntityInteractEvent` to interact with entities without checking that they're in the crosshair.
- Implement initial support for mob effects, including jump boost, haste, conduit power, and mining fatigue. (@ShayBox)
+- Allow disabling dependencies related to Microsoft auth with the `online-mode` cargo feature.
### Changed
@@ -40,7 +41,6 @@ is breaking anyways, semantic versioning is not followed.
- The WritableBookContent and ResolvableProfile data components had the wrong protocol implementations.
- Resolving server addresses shouldn't be recursive.
-
## [0.14.0+mc1.21.8] - 2025-09-28
### Added
diff --git a/Cargo.lock b/Cargo.lock
index de403e1a..5c182c0f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -81,22 +81,22 @@ dependencies = [
[[package]]
name = "anstyle-query"
-version = "1.1.4"
+version = "1.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2"
+checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
dependencies = [
- "windows-sys 0.60.2",
+ "windows-sys 0.61.2",
]
[[package]]
name = "anstyle-wincon"
-version = "3.0.10"
+version = "3.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a"
+checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
dependencies = [
"anstyle",
"once_cell_polyfill",
- "windows-sys 0.60.2",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -591,9 +591,9 @@ checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba"
[[package]]
name = "bevy_app"
-version = "0.17.2"
+version = "0.17.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9f582409b4ed3850d9b66ee94e71a0e2c20e7068121d372530060c4dfcba66fa"
+checksum = "8e4fc5dfe9d1d9b8233e1878353b5e66a3f5910c2131d3abf68f9a4116b2d433"
dependencies = [
"bevy_derive",
"bevy_ecs",
@@ -614,9 +614,9 @@ dependencies = [
[[package]]
name = "bevy_derive"
-version = "0.17.2"
+version = "0.17.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b8c733807158f8fcac68e23222e69ed91a6492ae9410fc2c145b9bb182cfd63e"
+checksum = "f9396b256b366a43d7f61d1f230cdab0a512fb4712cbf7d688f3d6fce4c5ea8a"
dependencies = [
"bevy_macro_utils",
"quote",
@@ -625,9 +625,9 @@ dependencies = [
[[package]]
name = "bevy_ecs"
-version = "0.17.2"
+version = "0.17.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "69d929d32190cfcde6efd2df493601c4dbc18a691fd9775a544c951c3c112e1a"
+checksum = "a7dd5229dd00d00e70ac6b2fc0a139961252f6ce07d3d268cfcac0da86d5bde4"
dependencies = [
"arrayvec",
"bevy_ecs_macros",
@@ -653,9 +653,9 @@ dependencies = [
[[package]]
name = "bevy_ecs_macros"
-version = "0.17.2"
+version = "0.17.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6eeddfb80a2e000663e87be9229c26b4da92bddbc06c8776bc0d1f4a7f679079"
+checksum = "c4d83bdd2285af4867e76c691406e0a4b55611b583d0c45b6ac7bcec1b45fd48"
dependencies = [
"bevy_macro_utils",
"proc-macro2",
@@ -665,9 +665,9 @@ dependencies = [
[[package]]
name = "bevy_log"
-version = "0.17.2"
+version = "0.17.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4ae217a035714a37b779487f82edc4c7c1223f7088d7ad94054f29f524d61c51"
+checksum = "b1a2d4ea086ac4663ab9dfb056c7b85eee39e18f7e3e9a4ae6e39897eaa155c5"
dependencies = [
"android_log-sys",
"bevy_app",
@@ -683,9 +683,9 @@ dependencies = [
[[package]]
name = "bevy_macro_utils"
-version = "0.17.2"
+version = "0.17.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "17dbc3f8948da58b3c17767d20fd3cd35fe4721ed19a9a3204a6f1d6c9951bdd"
+checksum = "62d984f9f8bd0f0d9fb020492a955e641e30e7a425f3588bf346cb3e61fec3c3"
dependencies = [
"parking_lot",
"proc-macro2",
@@ -696,9 +696,9 @@ dependencies = [
[[package]]
name = "bevy_platform"
-version = "0.17.2"
+version = "0.17.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "10cf8cda162688c95250e74cffaa1c3a04597f105d4ca35554106f107308ea57"
+checksum = "4691af6d7cfd1b5deb2fc926a43a180a546cdc3fe1e5a013fcee60db9bb2c81f"
dependencies = [
"critical-section",
"foldhash",
@@ -717,15 +717,15 @@ dependencies = [
[[package]]
name = "bevy_ptr"
-version = "0.17.2"
+version = "0.17.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "28ab4074e7b781bab84e9b0a41ede245d673d1f75646ce0db27643aedcfb3a85"
+checksum = "17d24d7906c7de556033168b3485de36c59049fbaef0c2c44c715a23e0329b10"
[[package]]
name = "bevy_reflect"
-version = "0.17.2"
+version = "0.17.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "333df3f5947b7e62728eb5c0b51d679716b16c7c5283118fed4563f13230954e"
+checksum = "b5472b91928c0f3e4e3988c0d036b00719f19520f53a0c3f8c2af72f00e693c5"
dependencies = [
"assert_type_match",
"bevy_platform",
@@ -749,9 +749,9 @@ dependencies = [
[[package]]
name = "bevy_reflect_derive"
-version = "0.17.2"
+version = "0.17.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0205dce9c5a4d8d041b263bcfd96e9d9d6f3d49416e12db347ab5778b3071fe1"
+checksum = "083784255162fa39960aa3cf3c23af0e515db2daa7f2e796ae34df993f4d3f6c"
dependencies = [
"bevy_macro_utils",
"indexmap",
@@ -763,9 +763,9 @@ dependencies = [
[[package]]
name = "bevy_tasks"
-version = "0.17.2"
+version = "0.17.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "18839182775f30d26f0f84d9de85d25361bb593c99517a80b64ede6cbaf41adc"
+checksum = "bcbbfa5a58a16c4228434d3018c23fde3d78dcd76ec5f5b2b482a21f4b158dd3"
dependencies = [
"async-channel",
"async-executor",
@@ -782,9 +782,9 @@ dependencies = [
[[package]]
name = "bevy_time"
-version = "0.17.2"
+version = "0.17.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1a52edd3d30ed94074f646ba1c9914e407af9abe5b6fb7a4322c855341a536cc"
+checksum = "32835c3dbe082fbbe7d4f2f37f655073421f2882d4320ac2d59f922474260de4"
dependencies = [
"bevy_app",
"bevy_ecs",
@@ -797,9 +797,9 @@ dependencies = [
[[package]]
name = "bevy_utils"
-version = "0.17.2"
+version = "0.17.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "080254083c74d5f6eb0649d7cd6181bda277e8fe3c509ec68990a5d56ec23f24"
+checksum = "789d04f88c764877a4552e07745b402dbc45f5d0545e6d102558f2f1752a1d89"
dependencies = [
"bevy_platform",
"disqualified",
@@ -876,9 +876,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "bytes"
-version = "1.10.1"
+version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
+checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3"
[[package]]
name = "cast"
@@ -897,9 +897,9 @@ dependencies = [
[[package]]
name = "cc"
-version = "1.2.45"
+version = "1.2.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "35900b6c8d709fb1d854671ae27aeaa9eec2f8b01b364e1619a40da3e6fe2afe"
+checksum = "cd405d82c84ff7f35739f175f67d8b9fb7687a0e84ccdc78bd3568839827cf07"
dependencies = [
"find-msvc-tools",
"shlex",
@@ -980,24 +980,24 @@ version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
dependencies = [
- "crypto-common 0.1.6",
+ "crypto-common 0.1.7",
"inout",
]
[[package]]
name = "clap"
-version = "4.5.51"
+version = "4.5.53"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4c26d721170e0295f191a69bd9a1f93efcdb0aff38684b61ab5750468972e5f5"
+checksum = "c9e340e012a1bf4935f5282ed1436d1489548e8f72308207ea5df0e23d2d03f8"
dependencies = [
"clap_builder",
]
[[package]]
name = "clap_builder"
-version = "4.5.51"
+version = "4.5.53"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "75835f0c7bf681bfd05abe44e965760fea999a5286c6eb2d59883634fd02011a"
+checksum = "d76b5d13eaa18c901fd2f7fca939fefe3a0727a953561fefdf3b2922b8569d00"
dependencies = [
"anstyle",
"clap_lex",
@@ -1186,9 +1186,9 @@ dependencies = [
[[package]]
name = "crypto-common"
-version = "0.1.6"
+version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
+checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
dependencies = [
"generic-array",
"typenum",
@@ -1270,7 +1270,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
dependencies = [
"block-buffer 0.10.4",
- "crypto-common 0.1.6",
+ "crypto-common 0.1.7",
]
[[package]]
@@ -1406,9 +1406,9 @@ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
[[package]]
name = "find-msvc-tools"
-version = "0.1.4"
+version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127"
+checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844"
[[package]]
name = "fixedbitset"
@@ -1558,9 +1558,9 @@ dependencies = [
[[package]]
name = "generic-array"
-version = "0.14.9"
+version = "0.14.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2"
+checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
dependencies = [
"typenum",
"version_check",
@@ -1630,12 +1630,13 @@ dependencies = [
[[package]]
name = "hashbrown"
-version = "0.16.0"
+version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d"
+checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
dependencies = [
"equivalent",
"serde",
+ "serde_core",
]
[[package]]
@@ -1752,9 +1753,9 @@ dependencies = [
[[package]]
name = "hyper"
-version = "1.8.0"
+version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1744436df46f0bde35af3eda22aeaba453aada65d8f1c171cd8a5f59030bd69f"
+checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11"
dependencies = [
"atomic-waker",
"bytes",
@@ -1790,9 +1791,9 @@ dependencies = [
[[package]]
name = "hyper-util"
-version = "0.1.17"
+version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3c6995591a8f1380fcb4ba966a252a4b29188d51d2b89e3a252f5305be65aea8"
+checksum = "52e9a2a24dc5c6821e71a7030e1e14b7b632acac55c40e9d2e082c621261bb56"
dependencies = [
"base64",
"bytes",
@@ -1916,9 +1917,9 @@ dependencies = [
[[package]]
name = "indexmap"
-version = "2.12.0"
+version = "2.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f"
+checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2"
dependencies = [
"equivalent",
"hashbrown",
@@ -2730,9 +2731,9 @@ dependencies = [
[[package]]
name = "resolv-conf"
-version = "0.7.5"
+version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6b3789b30bd25ba102de4beabd95d21ac45b69b1be7d14522bab988c526d6799"
+checksum = "1e061d1b48cb8d38042de4ae0a7a6401009d6143dc80d2e2d6f31f0bdd6470c7"
[[package]]
name = "ring"
@@ -2972,9 +2973,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "signal-hook-registry"
-version = "1.4.6"
+version = "1.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b"
+checksum = "7664a098b8e616bdfcc2dc0e9ac44eb231eedf41db4e9fe95d8d32ec728dedad"
dependencies = [
"libc",
]
@@ -4008,18 +4009,18 @@ dependencies = [
[[package]]
name = "zerocopy"
-version = "0.8.27"
+version = "0.8.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c"
+checksum = "43fa6694ed34d6e57407afbccdeecfa268c470a7d2a5b0cf49ce9fcc345afb90"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
-version = "0.8.27"
+version = "0.8.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831"
+checksum = "c640b22cd9817fae95be82f0d2f90b11f7605f6c319d16705c459b27ac2cbc26"
dependencies = [
"proc-macro2",
"quote",
diff --git a/Cargo.toml b/Cargo.toml
index ec8c3136..09a12269 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -44,8 +44,10 @@ chrono = { version = "0.4.42", default-features = false }
compact_str = "0.9.0"
crc32c = "0.6.8"
criterion = "0.7.0"
-crypto-bigint = "=0.7.0-rc.10" # TODO: Remove when rsa is fixed.
-crypto-primes = "=0.7.0-pre.4" # TODO: Remove when rsa is fixed.
+# TODO: Remove when rsa is fixed.
+crypto-bigint = "=0.7.0-rc.10"
+# TODO: Remove when rsa is fixed.
+crypto-primes = "=0.7.0-pre.4"
derive_more = "2.0.1"
enum-as-inner = "0.6.1"
env_logger = "0.11.8"
@@ -74,7 +76,8 @@ serde = "1.0.228"
serde_json = "1.0.145"
sha1 = "0.11.0-rc.3"
sha2 = "0.11.0-rc.3"
-signature = "=3.0.0-rc.5" # TODO: Remove when rsa is fixed.
+# TODO: Remove when rsa is fixed.
+signature = "=3.0.0-rc.5"
simdnbt = { version = "0.8.0", git = "https://github.com/azalea-rs/simdnbt" }
socks5-impl = "0.7.2"
syn = "2.0.110"
@@ -87,7 +90,7 @@ uuid = "1.18.1"
azalea-block-macros = { path = "azalea-block/azalea-block-macros", version = "0.14.0" }
azalea-block = { path = "azalea-block", version = "0.14.0" }
-azalea-auth = { path = "azalea-auth", version = "0.14.0" }
+azalea-auth = { path = "azalea-auth", version = "0.14.0", default-features = false }
azalea-brigadier = { path = "azalea-brigadier", version = "0.14.0" }
azalea-buf-macros = { path = "azalea-buf/azalea-buf-macros", version = "0.14.0" }
azalea-buf = { path = "azalea-buf", version = "0.14.0" }
@@ -101,7 +104,7 @@ azalea-inventory = { path = "azalea-inventory", version = "0.14.0" }
azalea-language = { path = "azalea-language", version = "0.14.0" }
azalea-physics = { path = "azalea-physics", version = "0.14.0" }
azalea-protocol-macros = { path = "azalea-protocol/azalea-protocol-macros", version = "0.14.0" }
-azalea-protocol = { path = "azalea-protocol", version = "0.14.0" }
+azalea-protocol = { path = "azalea-protocol", version = "0.14.0", default-features = false }
azalea-registry-macros = { path = "azalea-registry/azalea-registry-macros", version = "0.14.0" }
azalea-registry = { path = "azalea-registry", version = "0.14.0" }
azalea-world = { path = "azalea-world", version = "0.14.0" }
diff --git a/azalea-auth/Cargo.toml b/azalea-auth/Cargo.toml
index c33945df..84b06884 100644
--- a/azalea-auth/Cargo.toml
+++ b/azalea-auth/Cargo.toml
@@ -15,7 +15,7 @@ crypto-bigint.workspace = true # TODO: Remove when rsa is fixed.
crypto-primes.workspace = true # TODO: Remove when rsa is fixed.
indexmap.workspace = true
md-5.workspace = true
-reqwest = { workspace = true, default-features = false, features = [
+reqwest = { workspace = true, optional = true, default-features = false, features = [
"json",
"rustls-tls",
] }
@@ -32,5 +32,9 @@ uuid = { workspace = true, features = ["serde", "v3"] }
env_logger.workspace = true
tokio = { workspace = true, features = ["full"] }
+[features]
+default = ["online-mode"]
+online-mode = ["dep:reqwest"]
+
[lints]
workspace = true
diff --git a/azalea-auth/src/lib.rs b/azalea-auth/src/lib.rs
index 1643bf04..a024f4d5 100644
--- a/azalea-auth/src/lib.rs
+++ b/azalea-auth/src/lib.rs
@@ -1,10 +1,15 @@
#![doc = include_str!("../README.md")]
+#[cfg(feature = "online-mode")]
mod auth;
+#[cfg(feature = "online-mode")]
pub mod cache;
+#[cfg(feature = "online-mode")]
pub mod certs;
-pub mod game_profile;
-pub mod offline;
+#[cfg(feature = "online-mode")]
pub mod sessionserver;
-
+#[cfg(feature = "online-mode")]
pub use auth::*;
+
+pub mod game_profile;
+pub mod offline;
diff --git a/azalea-auth/src/sessionserver.rs b/azalea-auth/src/sessionserver.rs
index 317d09fa..e8ab5de7 100644
--- a/azalea-auth/src/sessionserver.rs
+++ b/azalea-auth/src/sessionserver.rs
@@ -1,4 +1,5 @@
//! Tell Mojang you're joining a multiplayer server.
+
use std::sync::LazyLock;
use reqwest::StatusCode;
diff --git a/azalea-client/Cargo.toml b/azalea-client/Cargo.toml
index 1dba73c1..a237804a 100644
--- a/azalea-client/Cargo.toml
+++ b/azalea-client/Cargo.toml
@@ -17,7 +17,7 @@ azalea-crypto.workspace = true
azalea-entity.workspace = true
azalea-inventory.workspace = true
azalea-physics.workspace = true
-azalea-protocol.workspace = true
+azalea-protocol = { workspace = true, features = ["packets", "connecting"] }
azalea-registry.workspace = true
azalea-world.workspace = true
bevy_app.workspace = true
@@ -32,7 +32,7 @@ minecraft_folder_path.workspace = true
parking_lot.workspace = true
pastey.workspace = true
regex.workspace = true
-reqwest.workspace = true
+reqwest = { workspace = true, optional = true }
simdnbt.workspace = true
thiserror.workspace = true
tokio = { workspace = true, features = ["sync"] }
@@ -43,10 +43,15 @@ uuid.workspace = true
anyhow.workspace = true
[features]
-default = ["log", "packet-event"]
+default = ["log", "packet-event", "online-mode"]
# enables bevy_log::LogPlugin by default
log = ["bevy_log"]
packet-event = []
+online-mode = [
+ "azalea-auth/online-mode",
+ "azalea-protocol/online-mode",
+ "dep:reqwest",
+]
[lints]
workspace = true
diff --git a/azalea-client/src/account.rs b/azalea-client/src/account.rs
index ab8e8e65..847029c9 100644
--- a/azalea-client/src/account.rs
+++ b/azalea-client/src/account.rs
@@ -2,14 +2,14 @@
use std::sync::Arc;
-use azalea_auth::{
- AccessTokenResponse,
- certs::{Certificates, FetchCertificatesError},
-};
+#[cfg(feature = "online-mode")]
+use azalea_auth::AccessTokenResponse;
+#[cfg(feature = "online-mode")]
+use azalea_auth::certs::{Certificates, FetchCertificatesError};
use bevy_ecs::component::Component;
use parking_lot::Mutex;
+#[cfg(feature = "online-mode")]
use thiserror::Error;
-use tracing::trace;
use uuid::Uuid;
/// Something that can join Minecraft servers.
@@ -58,6 +58,7 @@ pub struct Account {
///
/// This is set when you call [`Self::request_certs`], but you only
/// need to if the servers you're joining require it.
+ #[cfg(feature = "online-mode")]
pub certs: Arc<Mutex<Option<Certificates>>>,
}
@@ -67,9 +68,11 @@ pub enum AccountOpts {
Offline {
username: String,
},
+ #[cfg(feature = "online-mode")]
Microsoft {
email: String,
},
+ #[cfg(feature = "online-mode")]
MicrosoftWithAccessToken {
msa: Arc<Mutex<azalea_auth::cache::ExpiringValue<AccessTokenResponse>>>,
},
@@ -88,6 +91,7 @@ impl Account {
account_opts: AccountOpts::Offline {
username: username.to_string(),
},
+ #[cfg(feature = "online-mode")]
certs: Arc::new(Mutex::new(None)),
}
}
@@ -97,6 +101,7 @@ impl Account {
///
/// The cache key is used for avoiding having to log in every time. This is
/// typically set to the account email, but it can be any string.
+ #[cfg(feature = "online-mode")]
pub async fn microsoft(cache_key: &str) -> Result<Self, azalea_auth::AuthError> {
Self::microsoft_with_custom_client_id_and_scope(cache_key, None, None).await
}
@@ -105,6 +110,7 @@ impl Account {
/// and `scope`.
///
/// Pass `None` if you want to use default ones.
+ #[cfg(feature = "online-mode")]
pub async fn microsoft_with_custom_client_id_and_scope(
cache_key: &str,
client_id: Option<&str>,
@@ -162,6 +168,7 @@ impl Account {
/// # Ok(())
/// # }
/// ```
+ #[cfg(feature = "online-mode")]
pub async fn with_microsoft_access_token(
msa: azalea_auth::cache::ExpiringValue<AccessTokenResponse>,
) -> Result<Self, azalea_auth::AuthError> {
@@ -170,6 +177,7 @@ impl Account {
/// Similar to [`Account::with_microsoft_access_token`] but you can use
/// custom `client_id` and `scope`.
+ #[cfg(feature = "online-mode")]
pub async fn with_microsoft_access_token_and_custom_client_id_and_scope(
mut msa: azalea_auth::cache::ExpiringValue<AccessTokenResponse>,
client_id: Option<&str>,
@@ -178,6 +186,8 @@ impl Account {
let client = reqwest::Client::new();
if msa.is_expired() {
+ use tracing::trace;
+
trace!("refreshing Microsoft auth token");
msa = azalea_auth::refresh_ms_auth_token(
&client,
@@ -209,6 +219,7 @@ impl Account {
/// This requires the `auth_opts` field to be set correctly (which is done
/// by default if you used the constructor functions). Note that if the
/// Account is offline-mode then this function won't do anything.
+ #[cfg(feature = "online-mode")]
pub async fn refresh(&self) -> Result<(), azalea_auth::AuthError> {
match &self.account_opts {
// offline mode doesn't need to refresh so just don't do anything lol
@@ -240,6 +251,13 @@ impl Account {
}
}
+ /// Stub function that does nothing when the `online-mode` feature is
+ /// disabled.
+ #[cfg(not(feature = "online-mode"))]
+ pub async fn refresh(&self) -> Result<(), ()> {
+ Ok(())
+ }
+
/// Get the UUID of this account.
///
/// If the `uuid` field is None, the UUID will be determined by using
@@ -250,6 +268,7 @@ impl Account {
}
}
+#[cfg(feature = "online-mode")]
#[derive(Error, Debug)]
pub enum RequestCertError {
#[error("Failed to fetch certificates")]
@@ -261,6 +280,7 @@ pub enum RequestCertError {
impl Account {
/// Request the certificates used for chat signing and set it in
/// [`Self::certs`].
+ #[cfg(feature = "online-mode")]
pub async fn request_certs(&mut self) -> Result<(), RequestCertError> {
let access_token = self
.access_token
diff --git a/azalea-client/src/plugins/chat/handler.rs b/azalea-client/src/plugins/chat/handler.rs
index 5a2a065c..49f27209 100644
--- a/azalea-client/src/plugins/chat/handler.rs
+++ b/azalea-client/src/plugins/chat/handler.rs
@@ -1,6 +1,5 @@
use std::time::{SystemTime, UNIX_EPOCH};
-use azalea_crypto::SignChatMessageOptions;
use azalea_protocol::packets::{
Packet,
game::{ServerboundChat, ServerboundChatCommand, s_chat::LastSeenMessagesUpdate},
@@ -8,7 +7,9 @@ use azalea_protocol::packets::{
use bevy_ecs::prelude::*;
use super::ChatKind;
-use crate::{Account, chat_signing::ChatSigningSession, packet::game::SendGamePacketEvent};
+use crate::packet::game::SendGamePacketEvent;
+#[cfg(feature = "online-mode")]
+use crate::{Account, chat_signing::ChatSigningSession};
/// Send a chat packet to the server of a specific kind (chat message or
/// command). Usually you just want [`SendChatEvent`] instead.
@@ -31,7 +32,7 @@ pub struct SendChatKindEvent {
pub fn handle_send_chat_kind_event(
mut events: MessageReader<SendChatKindEvent>,
mut commands: Commands,
- mut query: Query<(&Account, &mut ChatSigningSession)>,
+ #[cfg(feature = "online-mode")] mut query: Query<(&Account, &mut ChatSigningSession)>,
) {
for event in events.read() {
let content = event
@@ -47,6 +48,7 @@ pub fn handle_send_chat_kind_event(
ChatKind::Message => {
let salt = azalea_crypto::make_salt();
+ #[cfg(feature = "online-mode")]
let signature = if let Ok((account, mut chat_session)) = query.get_mut(event.entity)
{
Some(create_signature(
@@ -59,6 +61,8 @@ pub fn handle_send_chat_kind_event(
} else {
None
};
+ #[cfg(not(feature = "online-mode"))]
+ let signature = None;
ServerboundChat {
message: content,
@@ -85,6 +89,7 @@ pub fn handle_send_chat_kind_event(
}
}
+#[cfg(feature = "online-mode")]
pub fn create_signature(
account: &Account,
chat_session: &mut ChatSigningSession,
@@ -92,6 +97,8 @@ pub fn create_signature(
timestamp: SystemTime,
message: &str,
) -> azalea_crypto::MessageSignature {
+ use azalea_crypto::SignChatMessageOptions;
+
let certs = account.certs.lock();
let certs = certs.as_ref().expect("certs shouldn't be set back to None");
diff --git a/azalea-client/src/plugins/chat_signing.rs b/azalea-client/src/plugins/chat_signing.rs
index 612383c2..8e612f5b 100644
--- a/azalea-client/src/plugins/chat_signing.rs
+++ b/azalea-client/src/plugins/chat_signing.rs
@@ -43,8 +43,8 @@ pub struct RequestCertsTask(pub Task<Result<Certificates, FetchCertificatesError
pub struct OnlyRefreshCertsAfter {
pub refresh_at: Instant,
}
-/// A component that's present when that this client has sent its certificates
-/// to the server.
+/// A component that's present when this client has sent its certificates to the
+/// server.
///
/// This should be removed if you want to re-send the certs.
///
diff --git a/azalea-client/src/plugins/disconnect.rs b/azalea-client/src/plugins/disconnect.rs
index 95950ae9..08fe3807 100644
--- a/azalea-client/src/plugins/disconnect.rs
+++ b/azalea-client/src/plugins/disconnect.rs
@@ -11,9 +11,11 @@ use derive_more::Deref;
use tracing::info;
use super::login::IsAuthenticated;
+#[cfg(feature = "online-mode")]
+use crate::chat_signing;
use crate::{
- chat_signing, client::JoinedClientBundle, connection::RawConnection,
- local_player::InstanceHolder, tick_counter::TicksConnected,
+ client::JoinedClientBundle, connection::RawConnection, local_player::InstanceHolder,
+ tick_counter::TicksConnected,
};
pub struct DisconnectPlugin;
@@ -69,6 +71,7 @@ pub struct RemoveOnDisconnectBundle {
/// This makes it not send [`DisconnectEvent`] again.
pub is_connection_alive: IsConnectionAlive,
/// Resend our chat signing certs next time.
+ #[cfg(feature = "online-mode")]
pub chat_signing_session: chat_signing::ChatSigningSession,
/// They're not authenticated anymore if they disconnected.
pub is_authenticated: IsAuthenticated,
diff --git a/azalea-client/src/plugins/login.rs b/azalea-client/src/plugins/login.rs
index 25919c8c..46ff8ea9 100644
--- a/azalea-client/src/plugins/login.rs
+++ b/azalea-client/src/plugins/login.rs
@@ -1,3 +1,4 @@
+#[cfg(feature = "online-mode")]
use azalea_auth::sessionserver::ClientSessionServerError;
use azalea_protocol::packets::login::{
ClientboundHello, ServerboundCustomQueryAnswer, ServerboundKey,
@@ -80,8 +81,10 @@ pub struct AuthTask(Task<Result<(ServerboundKey, PrivateKey), AuthWithAccountErr
pub enum AuthWithAccountError {
#[error("Failed to encrypt the challenge from the server for {0:?}")]
Encryption(ClientboundHello),
+ #[cfg(feature = "online-mode")]
#[error("{0}")]
SessionServer(#[from] ClientSessionServerError),
+ #[cfg(feature = "online-mode")]
#[error("Couldn't refresh access token: {0}")]
Auth(#[from] azalea_auth::AuthError),
}
@@ -99,49 +102,56 @@ pub async fn auth_with_account(
};
let private_key = encrypt_res.secret_key;
- let Some(access_token) = &account.access_token else {
- // offline mode account, no need to do auth
- return Ok((key_packet, private_key));
- };
-
- // keep track of the number of times we tried authenticating so we can give up
- // after too many
- let mut attempts: usize = 1;
-
- while let Err(err) = {
- let access_token = access_token.lock().clone();
-
- let uuid = &account
- .uuid
- .expect("Uuid must be present if access token is present.");
-
- // this is necessary since reqwest usually depends on tokio and we're using
- // `futures` here
- async_compat::Compat::new(azalea_auth::sessionserver::join(
- &access_token,
- &packet.public_key,
- &private_key,
- uuid,
- &packet.server_id,
- ))
- .await
- } {
- if attempts >= 2 {
- // if this is the second attempt and we failed
- // both times, give up
- return Err(err.into());
- }
- if matches!(
- err,
- ClientSessionServerError::InvalidSession | ClientSessionServerError::ForbiddenOperation
- ) {
- // uh oh, we got an invalid session and have
- // to reauthenticate now
- async_compat::Compat::new(account.refresh()).await?;
- } else {
- return Err(err.into());
+ #[cfg(not(feature = "online-mode"))]
+ let _ = account;
+
+ #[cfg(feature = "online-mode")]
+ if packet.should_authenticate {
+ let Some(access_token) = &account.access_token else {
+ // offline mode account, no need to do auth
+ return Ok((key_packet, private_key));
+ };
+
+ // keep track of the number of times we tried authenticating so we can give up
+ // after too many
+ let mut attempts: usize = 1;
+
+ while let Err(err) = {
+ let access_token = access_token.lock().clone();
+
+ let uuid = &account
+ .uuid
+ .expect("Uuid must be present if access token is present.");
+
+ // this is necessary since reqwest usually depends on tokio and we're using
+ // `futures` here
+ async_compat::Compat::new(azalea_auth::sessionserver::join(
+ &access_token,
+ &packet.public_key,
+ &private_key,
+ uuid,
+ &packet.server_id,
+ ))
+ .await
+ } {
+ if attempts >= 2 {
+ // if this is the second attempt and we failed
+ // both times, give up
+ return Err(err.into());
+ }
+ if matches!(
+ err,
+ ClientSessionServerError::InvalidSession
+ | ClientSessionServerError::ForbiddenOperation
+ ) {
+ // uh oh, we got an invalid session and have
+ // to reauthenticate now
+ async_compat::Compat::new(account.refresh()).await?;
+ } else {
+ return Err(err.into());
+ }
+ attempts += 1;
}
- attempts += 1;
}
Ok((key_packet, private_key))
diff --git a/azalea-client/src/plugins/mod.rs b/azalea-client/src/plugins/mod.rs
index a12d69cb..54f577e3 100644
--- a/azalea-client/src/plugins/mod.rs
+++ b/azalea-client/src/plugins/mod.rs
@@ -5,6 +5,7 @@ pub mod auto_reconnect;
pub mod block_update;
pub mod brand;
pub mod chat;
+#[cfg(feature = "online-mode")]
pub mod chat_signing;
pub mod chunks;
pub mod client_information;
@@ -62,8 +63,11 @@ impl PluginGroup for DefaultPlugins {
.add(connection::ConnectionPlugin)
.add(login::LoginPlugin)
.add(join::JoinPlugin)
- .add(auto_reconnect::AutoReconnectPlugin)
- .add(chat_signing::ChatSigningPlugin);
+ .add(auto_reconnect::AutoReconnectPlugin);
+ #[cfg(feature = "online-mode")]
+ {
+ group = group.add(chat_signing::ChatSigningPlugin);
+ }
#[cfg(feature = "log")]
{
group = group.add(bevy_log::LogPlugin::default());
diff --git a/azalea-protocol/Cargo.toml b/azalea-protocol/Cargo.toml
index 1ab25a12..4128faae 100644
--- a/azalea-protocol/Cargo.toml
+++ b/azalea-protocol/Cargo.toml
@@ -43,9 +43,10 @@ uuid.workspace = true
indexmap.workspace = true
[features]
+default = ["packets", "online-mode"]
connecting = []
-default = ["packets"]
packets = ["connecting", "dep:azalea-core"]
+online-mode = ["azalea-auth/online-mode"]
[lints]
workspace = true
diff --git a/azalea-protocol/src/connect.rs b/azalea-protocol/src/connect.rs
index febb2337..556f0f1c 100644
--- a/azalea-protocol/src/connect.rs
+++ b/azalea-protocol/src/connect.rs
@@ -7,6 +7,7 @@ use std::{
net::SocketAddr,
};
+#[cfg(feature = "online-mode")]
use azalea_auth::{
game_profile::GameProfile,
sessionserver::{ClientSessionServerError, ServerSessionServerError},
@@ -21,15 +22,18 @@ use tokio::{
},
};
use tracing::{error, info};
+#[cfg(feature = "online-mode")]
use uuid::Uuid;
+#[cfg(feature = "online-mode")]
+use crate::packets::login::ClientboundHello;
use crate::{
packets::{
ProtocolPacket,
config::{ClientboundConfigPacket, ServerboundConfigPacket},
game::{ClientboundGamePacket, ServerboundGamePacket},
handshake::{ClientboundHandshakePacket, ServerboundHandshakePacket},
- login::{ClientboundLoginPacket, ServerboundLoginPacket, c_hello::ClientboundHello},
+ login::{ClientboundLoginPacket, ServerboundLoginPacket},
status::{ClientboundStatusPacket, ServerboundStatusPacket},
},
read::{ReadPacketError, deserialize_packet, read_raw_packet, try_read_raw_packet},
@@ -453,6 +457,7 @@ impl Connection<ClientboundLoginPacket, ServerboundLoginPacket> {
/// # Ok(())
/// # }
/// ```
+ #[cfg(feature = "online-mode")]
pub async fn authenticate(
&self,
access_token: &str,
@@ -526,6 +531,7 @@ impl Connection<ServerboundLoginPacket, ClientboundLoginPacket> {
/// Verify connecting clients have authenticated with Minecraft's servers.
/// This must happen after the client sends a `ServerboundLoginPacket::Key`
/// packet.
+ #[cfg(feature = "online-mode")]
pub async fn authenticate(
&self,
username: &str,
diff --git a/azalea/Cargo.toml b/azalea/Cargo.toml
index b711d8a0..15627bc1 100644
--- a/azalea/Cargo.toml
+++ b/azalea/Cargo.toml
@@ -43,6 +43,7 @@ tokio.workspace = true
tracing.workspace = true
uuid.workspace = true
+
[dev-dependencies]
criterion.workspace = true
parking_lot = { workspace = true, features = ["deadlock_detection"] }
@@ -51,11 +52,12 @@ anyhow.workspace = true
bevy_log.workspace = true
[features]
-default = ["log", "serde", "packet-event"]
+default = ["log", "serde", "packet-event", "online-mode"]
# enables bevy_log::LogPlugin by default
log = ["azalea-client/log"]
serde = ["dep:serde", "azalea-registry/serde", "azalea-world/serde"]
packet-event = ["azalea-client/packet-event"]
+online-mode = ["azalea-client/online-mode"]
[[bench]]
name = "pathfinder"