aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2024-08-15 23:33:23 +0000
committermat <git@matdoes.dev>2024-08-15 23:33:23 +0000
commite485cf550183445e5f063c6da078c97e9b66497f (patch)
tree17827909e5785733e82e7d0279515bd6aa9209e9
parent74831abbe4f9d2a2eabbfe0a3a44874d9f49135b (diff)
downloadazalea-drasl-e485cf550183445e5f063c6da078c97e9b66497f.tar.xz
fix incorrect comment in with_microsoft_access_token docs
-rwxr-xr-xazalea-auth/src/auth.rs27
-rwxr-xr-xazalea-auth/src/cache.rs5
-rw-r--r--azalea-auth/src/certs.rs3
-rwxr-xr-xazalea-chat/src/translatable_component.rs6
-rwxr-xr-xazalea-client/src/account.rs5
-rw-r--r--azalea-client/src/client.rs2
6 files changed, 26 insertions, 22 deletions
diff --git a/azalea-auth/src/auth.rs b/azalea-auth/src/auth.rs
index 08d2d3a8..667c9062 100755
--- a/azalea-auth/src/auth.rs
+++ b/azalea-auth/src/auth.rs
@@ -10,6 +10,7 @@ use std::{
time::{Instant, SystemTime, UNIX_EPOCH},
};
use thiserror::Error;
+use tracing::{error, trace};
use uuid::Uuid;
#[derive(Default)]
@@ -92,7 +93,7 @@ pub async fn auth<'a>(email: &str, opts: AuthOpts<'a>) -> Result<AuthResult, Aut
interactive_get_ms_auth_token(&client, email, Some(client_id), Some(scope)).await?
};
if msa.is_expired() {
- tracing::trace!("refreshing Microsoft auth token");
+ trace!("refreshing Microsoft auth token");
match refresh_ms_auth_token(
&client,
&msa.data.refresh_token,
@@ -104,7 +105,7 @@ pub async fn auth<'a>(email: &str, opts: AuthOpts<'a>) -> Result<AuthResult, Aut
Ok(new_msa) => msa = new_msa,
Err(e) => {
// can't refresh, ask the user to auth again
- tracing::error!("Error refreshing Microsoft auth token: {}", e);
+ error!("Error refreshing Microsoft auth token: {}", e);
msa =
interactive_get_ms_auth_token(&client, email, Some(client_id), Some(scope))
.await?;
@@ -113,7 +114,7 @@ pub async fn auth<'a>(email: &str, opts: AuthOpts<'a>) -> Result<AuthResult, Aut
}
let msa_token = &msa.data.access_token;
- tracing::trace!("Got access token: {msa_token}");
+ trace!("Got access token: {msa_token}");
let res = get_minecraft_token(&client, msa_token).await?;
@@ -140,7 +141,7 @@ pub async fn auth<'a>(email: &str, opts: AuthOpts<'a>) -> Result<AuthResult, Aut
)
.await
{
- tracing::error!("{}", e);
+ error!("{}", e);
}
}
@@ -356,7 +357,7 @@ pub async fn get_ms_auth_token(
while Instant::now() < login_expires_at {
tokio::time::sleep(std::time::Duration::from_secs(res.interval)).await;
- tracing::trace!("Polling to check if user has logged in...");
+ trace!("Polling to check if user has logged in...");
if let Ok(access_token_response) = client
.post(format!(
"https://login.live.com/oauth20_token.srf?client_id={client_id}"
@@ -371,7 +372,7 @@ pub async fn get_ms_auth_token(
.json::<AccessTokenResponse>()
.await
{
- tracing::trace!("access_token_response: {:?}", access_token_response);
+ trace!("access_token_response: {:?}", access_token_response);
let expires_at = SystemTime::now()
+ std::time::Duration::from_secs(access_token_response.expires_in);
return Ok(ExpiringValue {
@@ -397,7 +398,7 @@ pub async fn interactive_get_ms_auth_token(
scope: Option<&str>,
) -> Result<ExpiringValue<AccessTokenResponse>, GetMicrosoftAuthTokenError> {
let res = get_ms_link_code(client, client_id, scope).await?;
- tracing::trace!("Device code response: {:?}", res);
+ trace!("Device code response: {:?}", res);
println!(
"Go to \x1b[1m{}\x1b[m and enter the code \x1b[1m{}\x1b[m for \x1b[1m{}\x1b[m",
res.verification_uri, res.user_code, email
@@ -473,7 +474,7 @@ async fn auth_with_xbox_live(
"TokenType": "JWT"
});
let payload = auth_json.to_string();
- tracing::trace!("auth_json: {:#?}", auth_json);
+ trace!("auth_json: {:#?}", auth_json);
let res = client
.post("https://user.auth.xboxlive.com/user/authenticate")
.header("Content-Type", "application/json")
@@ -486,7 +487,7 @@ async fn auth_with_xbox_live(
.await?
.json::<XboxLiveAuthResponse>()
.await?;
- tracing::trace!("Xbox Live auth response: {:?}", res);
+ trace!("Xbox Live auth response: {:?}", res);
// not_after looks like 2020-12-21T19:52:08.4463796Z
let expires_at = DateTime::parse_from_rfc3339(&res.not_after)
@@ -527,7 +528,7 @@ async fn obtain_xsts_for_minecraft(
.await?
.json::<XboxLiveAuthResponse>()
.await?;
- tracing::trace!("Xbox Live auth response (for XSTS): {:?}", res);
+ trace!("Xbox Live auth response (for XSTS): {:?}", res);
Ok(res.token)
}
@@ -553,7 +554,7 @@ async fn auth_with_minecraft(
.await?
.json::<MinecraftAuthResponse>()
.await?;
- tracing::trace!("{:?}", res);
+ trace!("{:?}", res);
let expires_at = SystemTime::now() + std::time::Duration::from_secs(res.expires_in);
Ok(ExpiringValue {
@@ -580,7 +581,7 @@ pub async fn check_ownership(
.await?
.json::<GameOwnershipResponse>()
.await?;
- tracing::trace!("{:?}", res);
+ trace!("{:?}", res);
// vanilla checks here to make sure the signatures are right, but it's not
// actually required so we just don't
@@ -605,7 +606,7 @@ pub async fn get_profile(
.await?
.json::<ProfileResponse>()
.await?;
- tracing::trace!("{:?}", res);
+ trace!("{:?}", res);
Ok(res)
}
diff --git a/azalea-auth/src/cache.rs b/azalea-auth/src/cache.rs
index 85d25f93..210dbab6 100755
--- a/azalea-auth/src/cache.rs
+++ b/azalea-auth/src/cache.rs
@@ -6,6 +6,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
use thiserror::Error;
use tokio::fs::File;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
+use tracing::{debug, trace};
#[derive(Debug, Error)]
pub enum CacheError {
@@ -82,13 +83,13 @@ async fn get_entire_cache(cache_file: &Path) -> Result<Vec<CachedAccount>, Cache
Ok(cache)
}
async fn set_entire_cache(cache_file: &Path, cache: Vec<CachedAccount>) -> Result<(), CacheError> {
- tracing::trace!("saving cache: {:?}", cache);
+ trace!("saving cache: {:?}", cache);
if !cache_file.exists() {
let cache_file_parent = cache_file
.parent()
.expect("Cache file is root directory and also doesn't exist.");
- tracing::debug!(
+ debug!(
"Making cache file parent directory at {}",
cache_file_parent.to_string_lossy()
);
diff --git a/azalea-auth/src/certs.rs b/azalea-auth/src/certs.rs
index 6214142b..9f9147a8 100644
--- a/azalea-auth/src/certs.rs
+++ b/azalea-auth/src/certs.rs
@@ -3,6 +3,7 @@ use chrono::{DateTime, Utc};
use rsa::{pkcs8::DecodePrivateKey, RsaPrivateKey};
use serde::Deserialize;
use thiserror::Error;
+use tracing::trace;
#[derive(Debug, Error)]
pub enum FetchCertificatesError {
@@ -26,7 +27,7 @@ pub async fn fetch_certificates(
.await?
.json::<CertificatesResponse>()
.await?;
- tracing::trace!("{:?}", res);
+ trace!("{:?}", res);
// using RsaPrivateKey::from_pkcs8_pem gives an error with decoding base64 so we
// just decode it ourselves
diff --git a/azalea-chat/src/translatable_component.rs b/azalea-chat/src/translatable_component.rs
index 912271ae..82c84d85 100755
--- a/azalea-chat/src/translatable_component.rs
+++ b/azalea-chat/src/translatable_component.rs
@@ -51,6 +51,8 @@ fn serialize_args_as_nbt(args: &[StringOrComponent]) -> simdnbt::owned::NbtList
// if it's all components then make it a compound list
// if it's a mix then return an error
+ use tracing::debug;
+
let mut string_list = Vec::new();
let mut compound_list = Vec::new();
@@ -68,9 +70,7 @@ fn serialize_args_as_nbt(args: &[StringOrComponent]) -> simdnbt::owned::NbtList
if !string_list.is_empty() && !compound_list.is_empty() {
// i'm actually not sure what vanilla does here, so i just made it return the
// string list
- tracing::debug!(
- "Tried to serialize a TranslatableComponent with a mix of strings and components."
- );
+ debug!("Tried to serialize a TranslatableComponent with a mix of strings and components.");
return string_list.into();
}
diff --git a/azalea-client/src/account.rs b/azalea-client/src/account.rs
index 24023d5b..87573de0 100755
--- a/azalea-client/src/account.rs
+++ b/azalea-client/src/account.rs
@@ -7,6 +7,7 @@ use azalea_auth::AccessTokenResponse;
use bevy_ecs::component::Component;
use parking_lot::Mutex;
use thiserror::Error;
+use tracing::trace;
use uuid::Uuid;
/// Something that can join Minecraft servers.
@@ -135,7 +136,7 @@ impl Account {
/// the authentication process (like doing your own caching or
/// displaying the Microsoft user code to the user in a different way).
///
- /// Note that this will not refresh the token when it expires.
+ /// This will refresh the given token if it's expired.
///
/// ```
/// # use azalea_client::Account;
@@ -170,7 +171,7 @@ impl Account {
let client = reqwest::Client::new();
if msa.is_expired() {
- tracing::trace!("refreshing Microsoft auth token");
+ trace!("refreshing Microsoft auth token");
msa = azalea_auth::refresh_ms_auth_token(
&client,
&msa.data.refresh_token,
diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs
index 02d400fd..6cb590df 100644
--- a/azalea-client/src/client.rs
+++ b/azalea-client/src/client.rs
@@ -601,7 +601,7 @@ impl Client {
}
if self.logged_in() {
- tracing::debug!(
+ debug!(
"Sending client information (already logged in): {:?}",
client_information
);