From 3e62efce453cb8d63a39f9cc35896bc7a1ecd567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Gonz=C3=A1lez?= Date: Tue, 8 Apr 2025 11:25:54 +0200 Subject: [PATCH 1/6] chore: remove dead `censor_strings` code --- packages/app-lib/src/launcher/mod.rs | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/packages/app-lib/src/launcher/mod.rs b/packages/app-lib/src/launcher/mod.rs index d3e9d90b9..264004503 100644 --- a/packages/app-lib/src/launcher/mod.rs +++ b/packages/app-lib/src/launcher/mod.rs @@ -16,7 +16,6 @@ use daedalus::minecraft::{LoggingSide, RuleAction, VersionInfo}; use daedalus::modded::LoaderVersion; use serde::Deserialize; use st::Profile; -use std::collections::HashMap; use std::path::PathBuf; use tokio::process::Command; @@ -694,31 +693,6 @@ pub async fn launch_minecraft( }) .await?; - let mut censor_strings = HashMap::new(); - let username = whoami::username(); - censor_strings - .insert(format!("/{username}/"), "/{COMPUTER_USERNAME}/".to_string()); - censor_strings.insert( - format!("\\{username}\\"), - "\\{COMPUTER_USERNAME}\\".to_string(), - ); - censor_strings.insert( - credentials.access_token.clone(), - "{MINECRAFT_ACCESS_TOKEN}".to_string(), - ); - censor_strings.insert( - credentials.username.clone(), - "{MINECRAFT_USERNAME}".to_string(), - ); - censor_strings.insert( - credentials.id.as_simple().to_string(), - "{MINECRAFT_UUID}".to_string(), - ); - censor_strings.insert( - credentials.id.as_hyphenated().to_string(), - "{MINECRAFT_UUID}".to_string(), - ); - // If in tauri, and the 'minimize on launch' setting is enabled, minimize the window #[cfg(feature = "tauri")] { From 0563ca9aec1252ec88e0eda080664805026de911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Gonz=C3=A1lez?= Date: Fri, 11 Apr 2025 23:26:23 +0200 Subject: [PATCH 2/6] chore: typo fix and formatting tidyups --- packages/app-lib/src/launcher/mod.rs | 2 +- packages/app-lib/src/state/minecraft_auth.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/app-lib/src/launcher/mod.rs b/packages/app-lib/src/launcher/mod.rs index 264004503..d6bd4eb25 100644 --- a/packages/app-lib/src/launcher/mod.rs +++ b/packages/app-lib/src/launcher/mod.rs @@ -654,7 +654,7 @@ pub async fn launch_minecraft( if std::env::var("CARGO").is_ok() { command.env_remove("DYLD_FALLBACK_LIBRARY_PATH"); } - // Java options should be set in instance options (the existence of _JAVA_OPTIONS overwites them) + // Java options should be set in instance options (the existence of _JAVA_OPTIONS overwrites them) command.env_remove("_JAVA_OPTIONS"); command.envs(env_args); diff --git a/packages/app-lib/src/state/minecraft_auth.rs b/packages/app-lib/src/state/minecraft_auth.rs index 96b3044ba..bdc0b7d0d 100644 --- a/packages/app-lib/src/state/minecraft_auth.rs +++ b/packages/app-lib/src/state/minecraft_auth.rs @@ -23,7 +23,7 @@ use uuid::Uuid; #[derive(Debug, Clone, Copy)] pub enum MinecraftAuthStep { GetDeviceToken, - SisuAuthenicate, + SisuAuthenticate, GetOAuthToken, RefreshOAuthToken, SisuAuthorize, @@ -639,7 +639,7 @@ async fn sisu_authenticate( "TitleId": "1794566092", }), key, - MinecraftAuthStep::SisuAuthenicate, + MinecraftAuthStep::SisuAuthenticate, current_date, ) .await?; @@ -967,7 +967,7 @@ async fn minecraft_entitlements( .bearer_auth(token) .send() }) - .await.map_err(|source| MinecraftAuthenticationError::Request { source, step: MinecraftAuthStep::MinecraftEntitlements })?; + .await.map_err(|source| MinecraftAuthenticationError::Request { source, step: MinecraftAuthStep::MinecraftEntitlements })?; let status = res.status(); let text = res.text().await.map_err(|source| { From 2cf157130803dbe450a087bf90e65b01f44177fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Gonz=C3=A1lez?= Date: Sat, 12 Apr 2025 12:40:55 +0200 Subject: [PATCH 3/6] refactor(theseus): extend auth subsystem to fetch complete user profiles --- Cargo.lock | 1 + Cargo.toml | 1 + .../src/components/ui/AccountsCard.vue | 26 +- .../src/components/ui/ErrorModal.vue | 2 +- apps/app-playground/src/main.rs | 5 +- packages/app-lib/Cargo.toml | 1 + packages/app-lib/src/api/logs.rs | 20 +- packages/app-lib/src/api/minecraft_auth.rs | 4 +- packages/app-lib/src/launcher/args.rs | 17 +- packages/app-lib/src/launcher/mod.rs | 3 +- .../app-lib/src/state/legacy_converter.rs | 17 +- packages/app-lib/src/state/minecraft_auth.rs | 514 +++++++++++++++--- 12 files changed, 496 insertions(+), 115 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e840ed110..1da86669b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8877,6 +8877,7 @@ dependencies = [ "flate2", "fs4", "futures", + "heck 0.5.0", "hickory-resolver", "indicatif", "notify", diff --git a/Cargo.toml b/Cargo.toml index 10fba76e4..96477b8d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -91,6 +91,7 @@ rand = "=0.8.5" # Locked on 0.8 until argon2 and p256 update to 0.9 rand_chacha = "=0.3.1" # Locked on 0.3 until we can update rand to 0.9 redis = "=0.29.5" # Locked on 0.29 until deadpool-redis updates to 0.30 regex = "1.11.1" +heck = "0.5.0" reqwest = { version = "0.12.15", default-features = false } rust-s3 = { version = "0.35.1", default-features = false, features = [ "fail-on-err", diff --git a/apps/app-frontend/src/components/ui/AccountsCard.vue b/apps/app-frontend/src/components/ui/AccountsCard.vue index fe1defb0f..2a33c2a6f 100644 --- a/apps/app-frontend/src/components/ui/AccountsCard.vue +++ b/apps/app-frontend/src/components/ui/AccountsCard.vue @@ -10,12 +10,12 @@ size="36px" :src=" selectedAccount - ? `https://mc-heads.net/avatar/${selectedAccount.id}/128` + ? `https://mc-heads.net/avatar/${selectedAccount.profile.id}/128` : 'https://launcher-files.modrinth.com/assets/steve_head.png' " />
- {{ selectedAccount ? selectedAccount.username : 'Select account' }} + {{ selectedAccount ? selectedAccount.profile.name : 'Select account' }} Minecraft account
@@ -28,12 +28,12 @@ :class="{ expanded: mode === 'expanded', isolated: mode === 'isolated' }" > @@ -44,12 +44,12 @@ From ad8a288515024fcdb727acb777106143bce27e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Gonz=C3=A1lez?= Date: Mon, 14 Apr 2025 20:52:01 +0200 Subject: [PATCH 5/6] chore: document differences between similar `Credentials` methods --- packages/app-lib/src/state/minecraft_auth.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/app-lib/src/state/minecraft_auth.rs b/packages/app-lib/src/state/minecraft_auth.rs index a34cc492c..debec56e5 100644 --- a/packages/app-lib/src/state/minecraft_auth.rs +++ b/packages/app-lib/src/state/minecraft_auth.rs @@ -404,6 +404,8 @@ impl Credentials { ) } + /// Like [`get_active`](Self::get_active), but enforces credentials to be + /// successfully refreshed unless the network is unreachable or times out. #[tracing::instrument] pub async fn get_default_credential( exec: impl sqlx::Executor<'_, Database = sqlx::Sqlite> + Copy, @@ -436,6 +438,8 @@ impl Credentials { } } + /// Fetches the currently selected credentials from the database, attempting + /// to refresh them if they are expired. pub async fn get_active( exec: impl sqlx::Executor<'_, Database = sqlx::Sqlite> + Copy, ) -> crate::Result> { From e1e8a2b36242476a9e501c638f364308c571c10b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Gonz=C3=A1lez?= Date: Sat, 26 Apr 2025 20:44:49 +0200 Subject: [PATCH 6/6] chore: remove dead `profile_run_credentials` plugin command --- apps/app/build.rs | 1 - apps/app/src/api/profile.rs | 17 ----------------- packages/app-lib/src/api/profile/mod.rs | 3 +-- 3 files changed, 1 insertion(+), 20 deletions(-) diff --git a/apps/app/build.rs b/apps/app/build.rs index 644d22b68..4fe82cfbc 100644 --- a/apps/app/build.rs +++ b/apps/app/build.rs @@ -151,7 +151,6 @@ fn main() { "profile_update_managed_modrinth_version", "profile_repair_managed_modrinth", "profile_run", - "profile_run_credentials", "profile_kill", "profile_edit", "profile_edit_icon", diff --git a/apps/app/src/api/profile.rs b/apps/app/src/api/profile.rs index db979be35..1d812639e 100644 --- a/apps/app/src/api/profile.rs +++ b/apps/app/src/api/profile.rs @@ -28,7 +28,6 @@ pub fn init() -> tauri::plugin::TauriPlugin { profile_update_managed_modrinth_version, profile_repair_managed_modrinth, profile_run, - profile_run_credentials, profile_kill, profile_edit, profile_edit_icon, @@ -256,22 +255,6 @@ pub async fn profile_run(path: &str) -> Result { Ok(process) } -// Run Minecraft using a profile using chosen credentials -// Returns the UUID, which can be used to poll -// for the actual Child in the state. -// invoke('plugin:profile|profile_run_credentials', {path, credentials})') -#[tauri::command] -pub async fn profile_run_credentials( - path: &str, - credentials: Credentials, -) -> Result { - let process = - profile::run_credentials(path, &credentials, &QuickPlayType::None) - .await?; - - Ok(process) -} - #[tauri::command] pub async fn profile_kill(path: &str) -> Result<()> { profile::kill(path).await?; diff --git a/packages/app-lib/src/api/profile/mod.rs b/packages/app-lib/src/api/profile/mod.rs index b1c21207d..540f779e4 100644 --- a/packages/app-lib/src/api/profile/mod.rs +++ b/packages/app-lib/src/api/profile/mod.rs @@ -642,10 +642,9 @@ pub async fn run( } /// Run Minecraft using a profile, and credentials for authentication -/// Returns Arc pointer to RwLock to Child #[tracing::instrument(skip(credentials))] -pub async fn run_credentials( +async fn run_credentials( path: &str, credentials: &Credentials, quick_play_type: &QuickPlayType,