From bcb2d55b9500076d558ba7206a28981143d624f5 Mon Sep 17 00:00:00 2001 From: Pauline Date: Sat, 27 Jul 2024 02:52:25 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20fix=20client=20id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 2 +- apps/desktop/Cargo.toml | 2 +- apps/desktop/build.rs | 6 ----- apps/desktop/package.json | 6 ++--- apps/frontend/package.json | 5 ++-- apps/testing/package.json | 4 ++-- apps/testing/src/main.rs | 24 +++++++++---------- eslint.config.js | 2 +- package.json | 9 ++++--- packages/client/package.json | 2 +- packages/core/Cargo.toml | 3 ++- packages/core/package.json | 3 +-- .../core/src/api/package/content/modrinth.rs | 1 - packages/core/src/constants.rs | 16 +++++++------ packages/core/src/store/minecraft.rs | 22 ++++++++--------- packages/distribution/package.json | 3 +-- packages/scripts/package.json | 2 +- 17 files changed, 53 insertions(+), 59 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6f144685..7a58de43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ authors = [ "Polyfrost", "Polyfrost Contributors" ] -version = "1.0.0" +version = "1.0.0-alpha.1" [workspace.dependencies] onelauncher = { path = "./packages/core" } diff --git a/apps/desktop/Cargo.toml b/apps/desktop/Cargo.toml index bb33dea4..90b8970e 100644 --- a/apps/desktop/Cargo.toml +++ b/apps/desktop/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "onelauncher_gui" description = "Next-generation open source Minecraft launcher" -version = "1.0.0" # todo: make it so tauri works with the ws +version = "1.0.0-alpha.1" # todo: make it so tauri works with the ws license = { workspace = true } edition = { workspace = true } repository = { workspace = true } diff --git a/apps/desktop/build.rs b/apps/desktop/build.rs index 6ffb9b23..05964c47 100644 --- a/apps/desktop/build.rs +++ b/apps/desktop/build.rs @@ -11,31 +11,25 @@ fn main() { "get_users", "get_user", "remove_user", - // Cluster "create_cluster", "remove_cluster", "get_cluster", "get_clusters", "run_cluster", - // Processor "get_running_clusters", "get_processes_by_path", "kill_process", - // Settings "get_settings", "set_settings", - // Metadata "get_minecraft_versions", - // Package "random_mods", "get_mod", "download_mod", - // Other "get_program_info", ]), diff --git a/apps/desktop/package.json b/apps/desktop/package.json index 5cc939e5..b6fc337c 100644 --- a/apps/desktop/package.json +++ b/apps/desktop/package.json @@ -1,7 +1,8 @@ { "name": "@onelauncher/desktop", "type": "module", - "version": "1.0.0", + "version": "1.0.0-alpha.1", + "private": true, "description": "Next-generation open source Minecraft launcher", "license": "GPL-3.0-only", "repository": { @@ -11,8 +12,7 @@ }, "scripts": { "build": "tauri build", - "dev": "tauri dev", - "tauri": "tauri" + "dev": "tauri dev" }, "dependencies": { "@onelauncher/core": "workspace:*", diff --git a/apps/frontend/package.json b/apps/frontend/package.json index 87d4ab45..47c21305 100644 --- a/apps/frontend/package.json +++ b/apps/frontend/package.json @@ -1,7 +1,8 @@ { "name": "@onelauncher/frontend", "type": "module", - "version": "1.0.0", + "version": "1.0.0-alpha.1", + "private": true, "description": "Next-generation open source Minecraft launcher frontend", "license": "GPL-3.0-only", "repository": { @@ -10,7 +11,7 @@ "directory": "apps/frontend" }, "scripts": { - "dev": "vite dev", + "dev": "vite", "build": "vite build" }, "dependencies": { diff --git a/apps/testing/package.json b/apps/testing/package.json index 21137fe0..07aa3488 100644 --- a/apps/testing/package.json +++ b/apps/testing/package.json @@ -1,7 +1,7 @@ { "name": "@onelauncher/testing", - "type": "module", - "version": "1.0.0", + "version": "1.0.0-alpha.1", + "private": true, "description": "Next-generation open source Minecraft launcher playground", "license": "GPL-3.0-only", "repository": { diff --git a/apps/testing/src/main.rs b/apps/testing/src/main.rs index 38ca240b..61530679 100644 --- a/apps/testing/src/main.rs +++ b/apps/testing/src/main.rs @@ -4,9 +4,19 @@ )] use onelauncher::cluster::create::create_cluster; -use onelauncher::package::content::{self, Providers}; +use onelauncher::package::content::Providers; use onelauncher::prelude::*; +#[tokio::main] +async fn main() -> onelauncher::Result<()> { + let _logger = onelauncher::start_logger(); + let _state = State::get().await?; + + modrinth().await?; + + Ok(()) +} + pub async fn authenticate_mc() -> onelauncher::Result { println!("a browser will open, follow login flow"); let login = minecraft::begin().await?; @@ -35,18 +45,8 @@ pub async fn authenticate_mc() -> onelauncher::Result { Ok(creds) } -#[tokio::main] -async fn main() -> onelauncher::Result<()> { - let _logger = onelauncher::start_logger(); - let state = State::get().await?; - - modrinth().await?; - - Ok(()) -} - async fn modrinth() -> onelauncher::Result<()> { - let state = State::get().await?; + let _state = State::get().await?; let provider = Providers::Modrinth; let result = provider.get("oneconfig").await?; println!("{:#?}", result); diff --git a/eslint.config.js b/eslint.config.js index 52e354f9..b18e9abc 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -21,6 +21,6 @@ export default petal({ '*.rs', 'pnpm-lock.yaml', '**/node_modules', - 'apps/desktop/src/bindings.ts', + 'apps/frontend/src/bindings.ts', ], }); diff --git a/package.json b/package.json index 128c7ddf..7f4dcda7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,8 @@ { "name": "@onelauncher/root", "type": "module", - "version": "1.0.0", + "version": "1.0.0-alpha.1", + "private": true, "packageManager": "pnpm@9.6.0", "description": "Next-generation open source Minecraft launcher and tools for interacting with Polyfrost", "license": "GPL-3.0-only", @@ -22,18 +23,16 @@ "frontend": "pnpm --filter @onelauncher/frontend -- ", "client": "pnpm --filter @onelauncher/client -- ", "desktop": "pnpm --filter @onelauncher/desktop -- ", - "core": "cd packages/core && cargo", "testing": "cd apps/testing && cargo", "tauri": "cd apps/desktop && cargo", "format": "pnpm format:es && pnpm format:rs", "lint": "pnpm lint:es && pnpm lint:rs", - - "lint:es": "pnpm eslint . --cache", + "lint:es": "eslint . --cache", "format:es": "pnpm lint:es --fix", "lint:rs": "cargo +nightly fmt --check && cargo clippy -- -D warnings", "format:rs": "cargo +nightly fmt && cargo clippy --fix", - "release:node": "pnpm bumpp -r" + "release:node": "bumpp -r" }, "devDependencies": { "@flowr/eslint-config": "^3.10.1", diff --git a/packages/client/package.json b/packages/client/package.json index 1dc907fe..2c2d271e 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,7 +1,7 @@ { "name": "@onelauncher/client", "type": "module", - "version": "1.0.0", + "version": "1.0.0-alpha.1", "private": true, "description": "RSPC Client for OneLauncher", "license": "GPL-3.0-only", diff --git a/packages/core/Cargo.toml b/packages/core/Cargo.toml index 0dd48e2c..b83d347e 100644 --- a/packages/core/Cargo.toml +++ b/packages/core/Cargo.toml @@ -17,8 +17,9 @@ default = [] tauri = [ "dep:tauri", "dep:tauri-specta", - "dep:specta" + "specta" ] +specta = [ "dep:specta" ] cli = [ "dep:indicatif" ] [dependencies] diff --git a/packages/core/package.json b/packages/core/package.json index 6e1569a7..fa222332 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,7 +1,6 @@ { "name": "@onelauncher/core", - "type": "module", - "version": "1.0.0", + "version": "1.0.0-alpha.1", "description": "Next-generation open source Minecraft launcher core", "license": "GPL-3.0-only", "repository": { diff --git a/packages/core/src/api/package/content/modrinth.rs b/packages/core/src/api/package/content/modrinth.rs index 2b334e7e..3fa72b9c 100644 --- a/packages/core/src/api/package/content/modrinth.rs +++ b/packages/core/src/api/package/content/modrinth.rs @@ -4,7 +4,6 @@ use crate::store::{ManagedVersionFile, PackageFile, PackageSide}; use crate::utils::http::fetch; use crate::{Result, State}; -use anyhow::anyhow; use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use serde_json::Value; diff --git a/packages/core/src/constants.rs b/packages/core/src/constants.rs index 37b6f578..2ecbfb22 100644 --- a/packages/core/src/constants.rs +++ b/packages/core/src/constants.rs @@ -7,18 +7,20 @@ /// The name of the launcher. pub const NAME: &str = "OneLauncher"; /// The version of the launcher -pub const VERSION: &str = "1.0.0"; // todo: env +pub const VERSION: &str = "1.0.0-alpha.1"; // todo: env // =========== Authentication =========== /// The Discord RPC client ID. pub const DISCORD_RPC_CLIENT_ID: &str = "1234567890000000"; -/// Microsoft client ID. -pub const MICROSOFT_CLIENT_ID: &str = "00000000402b5328"; -/// Microsoft login redirect URI. -pub const REDIRECT_URL: &str = "https://login.live.com/oauth20_desktop.srf"; -/// Microsoft login xboxlive scopes to get tokens. -pub const SCOPES: &str = "service::user.auth.xboxlive.com::MBI_SSL"; +/// Our Microsoft client ID. +pub const MICROSOFT_CLIENT_ID: &str = "9eac3a4e-8cdd-43ef-863e-49cd601b1f03"; +/// Mojang/Microsoft client ID. +pub const MINECRAFT_CLIENT_ID: &str = "00000000402b5328"; +/// Mojang/Microsoft login redirect URI. +pub const MINECRAFT_REDIRECT_URL: &str = "https://login.live.com/oauth20_desktop.srf"; +/// Mojang/Microsoft login xboxlive scopes to get tokens. +pub const MINECRAFT_SCOPES: &str = "service::user.auth.xboxlive.com::MBI_SSL"; // =========== Hacky Mojang-spec OS constants =========== #[cfg(target_os = "windows")] diff --git a/packages/core/src/store/minecraft.rs b/packages/core/src/store/minecraft.rs index 01eb7bad..64f6801a 100644 --- a/packages/core/src/store/minecraft.rs +++ b/packages/core/src/store/minecraft.rs @@ -13,7 +13,7 @@ use std::collections::HashMap; use std::fmt::Write; use uuid::Uuid; -use crate::constants::{MICROSOFT_CLIENT_ID, REDIRECT_URL, SCOPES}; +use crate::constants::{MINECRAFT_CLIENT_ID, MINECRAFT_REDIRECT_URL, MINECRAFT_SCOPES}; const AUTH_STORE: &str = "authentication.json"; @@ -447,16 +447,16 @@ async fn sisu_authenticate( "https://sisu.xboxlive.com/authenticate", "/authenticate", json!({ - "AppId": MICROSOFT_CLIENT_ID, + "AppId": MINECRAFT_CLIENT_ID, "DeviceToken": token, - "Offers": [SCOPES], + "Offers": [MINECRAFT_SCOPES], "Query": { "code_challenge": challenge, "code_challenge_method": "S256", "state": generate_oauth_challenge(), "prompt": "select_account" }, - "RedirectUri": REDIRECT_URL, + "RedirectUri": MINECRAFT_REDIRECT_URL, "Sandbox": "RETAIL", "TokenType": "code", "TitleId": "1794566092" @@ -500,12 +500,12 @@ async fn oauth_token( verify: &str, ) -> Result, MinecraftAuthError> { let mut query = HashMap::new(); - query.insert("client_id", MICROSOFT_CLIENT_ID); + query.insert("client_id", MINECRAFT_CLIENT_ID); query.insert("code", code); query.insert("code_verifier", verify); query.insert("grant_type", "authorization_code"); - query.insert("redirect_uri", REDIRECT_URL); - query.insert("scope", SCOPES); + query.insert("redirect_uri", MINECRAFT_REDIRECT_URL); + query.insert("scope", MINECRAFT_SCOPES); let res = auth_retry(|| { crate::utils::http::REQWEST_CLIENT .post("https://login.live.com/oauth20_token.srf") @@ -548,11 +548,11 @@ async fn oauth_refresh( refresh_token: &str, ) -> Result, MinecraftAuthError> { let mut query = HashMap::new(); - query.insert("client_id", MICROSOFT_CLIENT_ID); + query.insert("client_id", MINECRAFT_CLIENT_ID); query.insert("refresh_token", refresh_token); query.insert("grant_type", "refresh_token"); - query.insert("redirect_uri", REDIRECT_URL); - query.insert("scope", SCOPES); + query.insert("redirect_uri", MINECRAFT_REDIRECT_URL); + query.insert("scope", MINECRAFT_SCOPES); let res = auth_retry(|| { crate::utils::http::REQWEST_CLIENT .post("https://login.live.com/oauth20_token.srf") @@ -615,7 +615,7 @@ async fn sisu_authorize( "/authorize", json!({ "AccessToken": format!("t={access_token}"), - "AppId": MICROSOFT_CLIENT_ID, + "AppId": MINECRAFT_CLIENT_ID, "DeviceToken": device_token, "ProofKey": { // kibty (kty) diff --git a/packages/distribution/package.json b/packages/distribution/package.json index 4c43f780..52a470b5 100644 --- a/packages/distribution/package.json +++ b/packages/distribution/package.json @@ -1,7 +1,6 @@ { "name": "@onelauncher/distribution", - "type": "module", - "version": "1.0.0", + "version": "1.0.0-alpha.1", "private": true, "description": "distribution files for OneLauncher", "license": "GPL-3.0-only", diff --git a/packages/scripts/package.json b/packages/scripts/package.json index 79ed3262..80bcbc81 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -1,7 +1,7 @@ { "name": "@onelauncher/scripts", "type": "module", - "version": "1.0.0", + "version": "1.0.0-alpha.1", "private": true, "description": "Scripts for developing OneLauncher", "license": "GPL-3.0-only",