🐛 fix: fix some code
This commit is contained in:
parent
cf85f478f0
commit
060f1faa10
16 changed files with 699 additions and 451 deletions
|
|
@ -29,7 +29,7 @@
|
|||
"@tauri-apps/plugin-clipboard-manager": "2.1.0-beta.5",
|
||||
"@tauri-apps/plugin-shell": "github:tauri-apps/tauri-plugin-shell#v2",
|
||||
"@thisbeyond/solid-dnd": "^0.7.5",
|
||||
"@unocss/reset": "^0.61.3",
|
||||
"@unocss/reset": "^0.61.4",
|
||||
"@untitled-theme/icons-solid": "^0.10.4",
|
||||
"overlayscrollbars": "^2.9.2",
|
||||
"overlayscrollbars-solid": "^0.5.5",
|
||||
|
|
@ -44,7 +44,7 @@
|
|||
"@types/uuid": "^10.0.0",
|
||||
"jsdom": "^24.1.0",
|
||||
"sass": "^1.77.8",
|
||||
"unocss": "^0.61.3",
|
||||
"unocss": "^0.61.4",
|
||||
"vite-plugin-solid": "^2.10.2",
|
||||
"vite-plugin-solid-svg": "^0.8.1",
|
||||
"vite-tsconfig-paths": "^4.3.2"
|
||||
|
|
|
|||
|
|
@ -226,7 +226,9 @@ pub(crate) async fn get_loader_version(
|
|||
_ => return Err(CreateClusterError::MissingManifest(loader.to_string()).into()),
|
||||
};
|
||||
|
||||
let loader_meta = loader_meta.to_owned().ok_or(anyhow::anyhow!("couldn't get game versions"))?;
|
||||
let loader_meta = loader_meta
|
||||
.to_owned()
|
||||
.ok_or(anyhow::anyhow!("couldn't get game versions"))?;
|
||||
|
||||
let loaders = &loader_meta
|
||||
.game_versions
|
||||
|
|
|
|||
|
|
@ -313,7 +313,10 @@ pub async fn get_optimal_java_version(path: &ClusterPath) -> crate::Result<Optio
|
|||
let state = State::get().await?;
|
||||
if let Some(cluster) = get(path, None).await? {
|
||||
let metadata = state.metadata.read().await;
|
||||
let minecraft_metadata = metadata.minecraft.to_owned().ok_or(anyhow::anyhow!("couldn't get minecraft metadata"))?;
|
||||
let minecraft_metadata = metadata
|
||||
.minecraft
|
||||
.to_owned()
|
||||
.ok_or(anyhow::anyhow!("couldn't get minecraft metadata"))?;
|
||||
|
||||
let version = minecraft_metadata
|
||||
.versions
|
||||
|
|
|
|||
|
|
@ -8,7 +8,13 @@ pub use interpulse::api::modded::Manifest;
|
|||
#[tracing::instrument]
|
||||
pub async fn get_minecraft_versions() -> crate::Result<VersionManifest> {
|
||||
let state = State::get().await?;
|
||||
let meta = state.metadata.read().await.minecraft.clone().ok_or(anyhow::anyhow!("couldn't get minecraft metadata"))?;
|
||||
let meta = state
|
||||
.metadata
|
||||
.read()
|
||||
.await
|
||||
.minecraft
|
||||
.clone()
|
||||
.ok_or(anyhow::anyhow!("couldn't get minecraft metadata"))?;
|
||||
|
||||
Ok(meta)
|
||||
}
|
||||
|
|
@ -17,7 +23,13 @@ pub async fn get_minecraft_versions() -> crate::Result<VersionManifest> {
|
|||
#[tracing::instrument]
|
||||
pub async fn get_fabric_versions() -> crate::Result<Manifest> {
|
||||
let state = State::get().await?;
|
||||
let meta = state.metadata.read().await.fabric.clone().ok_or(anyhow::anyhow!("couldn't get fabric metadata"))?;
|
||||
let meta = state
|
||||
.metadata
|
||||
.read()
|
||||
.await
|
||||
.fabric
|
||||
.clone()
|
||||
.ok_or(anyhow::anyhow!("couldn't get fabric metadata"))?;
|
||||
|
||||
Ok(meta)
|
||||
}
|
||||
|
|
@ -26,7 +38,13 @@ pub async fn get_fabric_versions() -> crate::Result<Manifest> {
|
|||
#[tracing::instrument]
|
||||
pub async fn get_quilt_versions() -> crate::Result<Manifest> {
|
||||
let state = State::get().await?;
|
||||
let meta = state.metadata.read().await.quilt.clone().ok_or(anyhow::anyhow!("couldn't get quilt metadata"))?;
|
||||
let meta = state
|
||||
.metadata
|
||||
.read()
|
||||
.await
|
||||
.quilt
|
||||
.clone()
|
||||
.ok_or(anyhow::anyhow!("couldn't get quilt metadata"))?;
|
||||
|
||||
Ok(meta)
|
||||
}
|
||||
|
|
@ -35,7 +53,13 @@ pub async fn get_quilt_versions() -> crate::Result<Manifest> {
|
|||
#[tracing::instrument]
|
||||
pub async fn get_forge_versions() -> crate::Result<Manifest> {
|
||||
let state = State::get().await?;
|
||||
let meta = state.metadata.read().await.forge.clone().ok_or(anyhow::anyhow!("couldn't get forge metadata"))?;
|
||||
let meta = state
|
||||
.metadata
|
||||
.read()
|
||||
.await
|
||||
.forge
|
||||
.clone()
|
||||
.ok_or(anyhow::anyhow!("couldn't get forge metadata"))?;
|
||||
|
||||
Ok(meta)
|
||||
}
|
||||
|
|
@ -44,7 +68,13 @@ pub async fn get_forge_versions() -> crate::Result<Manifest> {
|
|||
#[tracing::instrument]
|
||||
pub async fn get_neoforge_versions() -> crate::Result<Manifest> {
|
||||
let state = State::get().await?;
|
||||
let meta = state.metadata.read().await.neoforge.clone().ok_or(anyhow::anyhow!("couldn't get neoforge metadata"))?;
|
||||
let meta = state
|
||||
.metadata
|
||||
.read()
|
||||
.await
|
||||
.neoforge
|
||||
.clone()
|
||||
.ok_or(anyhow::anyhow!("couldn't get neoforge metadata"))?;
|
||||
|
||||
Ok(meta)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
//! Launcher Import: Modrinth App
|
||||
//! Source Code available at https://github.com/modrinth/code
|
||||
|
||||
use std::path::PathBuf;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::prelude::ClusterPath;
|
||||
use crate::utils::io;
|
||||
|
|
|
|||
|
|
@ -3,19 +3,26 @@
|
|||
//! Public constant variables and strings that are used throughout the launcher.
|
||||
//! Can be shared publically, any encrypted secrets should be stored in [`crate::store::credentials`].
|
||||
|
||||
// Basic Metadata
|
||||
// =========== Core Metadata ===========
|
||||
/// The name of the launcher.
|
||||
pub const NAME: &str = "OneLauncher";
|
||||
pub const VERSION: &str = "0.1.0";
|
||||
/// The version of the launcher
|
||||
pub const VERSION: &str = "0.1.0"; // todo: env
|
||||
/// The ID of the launcher.
|
||||
pub const ID: &str = "org.polyfrost.launcher";
|
||||
|
||||
// Authentication and HTTP (TODO: env?)
|
||||
pub const APP_CONFIG_DIR: &str = "org.polyfrost.launcher";
|
||||
// =========== Authentication ===========
|
||||
/// The Discord RPC client ID.
|
||||
pub const DISCORD_RPC_CLIENT_ID: &str = "1234567890000000";
|
||||
|
||||
// Microsoft Authentication
|
||||
pub const CLIENT_ID: &str = "9419b7ee-1448-4d1b-b52a-550d8f36ab56";
|
||||
/// Microsoft client ID.
|
||||
pub const MICROSOFT_CLIENT_ID: &str = "";
|
||||
/// 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";
|
||||
|
||||
// OS constants which match Minecraft's/Mojang's scheme
|
||||
// =========== Hacky Mojang-spec OS constants ===========
|
||||
#[cfg(target_os = "windows")]
|
||||
pub const TARGET_OS: &str = "windows";
|
||||
|
||||
|
|
@ -31,13 +38,7 @@ pub const NATIVE_ARCH: &str = "32";
|
|||
#[cfg(target_arch = "x86_64")]
|
||||
pub const NATIVE_ARCH: &str = "64";
|
||||
|
||||
// TODO: Add more architectures
|
||||
#[cfg(all(not(target_arch = "x86_64"), not(target_arch = "x86")))]
|
||||
pub const NATIVE_ARCH: &str = "64";
|
||||
|
||||
// Minecraft library splitter
|
||||
#[cfg(target_os = "windows")]
|
||||
pub const LIBRARY_SPLITTER: &str = ";";
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
pub const LIBRARY_SPLITTER: &str = ":";
|
||||
// TODO: Add more architectures
|
||||
|
|
|
|||
|
|
@ -207,9 +207,10 @@ fn parse_minecraft_argument(
|
|||
.replace("${auth_player_name}", username)
|
||||
.replace("${auth_xuid}", "10")
|
||||
.replace("${auth_uuid}", &uuid.simple().to_string())
|
||||
.replace("${client_id}", crate::constants::CLIENT_ID)
|
||||
.replace("${uuid}", &uuid.simple().to_string())
|
||||
.replace("${clientid}", crate::constants::MICROSOFT_CLIENT_ID)
|
||||
.replace("${user_properties}", "{}")
|
||||
.replace("${user_type", "msa")
|
||||
.replace("${user_type}", "msa")
|
||||
.replace("${version_name}", version)
|
||||
.replace("${asset_index_name}", asset_index)
|
||||
.replace(
|
||||
|
|
|
|||
|
|
@ -72,11 +72,9 @@ pub async fn install_minecraft(
|
|||
let metadata = state.metadata.read().await;
|
||||
|
||||
let version_manifest = metadata.minecraft.to_owned();
|
||||
let versions = version_manifest
|
||||
.ok_or(anyhow::anyhow!(
|
||||
"couldn't get minecraft manifest"
|
||||
))?
|
||||
.versions;
|
||||
let versions = version_manifest
|
||||
.ok_or(anyhow::anyhow!("couldn't get minecraft manifest"))?
|
||||
.versions;
|
||||
|
||||
let version_idx = versions
|
||||
.iter()
|
||||
|
|
@ -87,11 +85,7 @@ pub async fn install_minecraft(
|
|||
))?;
|
||||
|
||||
let version = &versions[version_idx];
|
||||
let updated = version_idx
|
||||
<= versions
|
||||
.iter()
|
||||
.position(|g| g.id == "22w16a")
|
||||
.unwrap_or(0); // LWJGL patching
|
||||
let updated = version_idx <= versions.iter().position(|g| g.id == "22w16a").unwrap_or(0); // LWJGL patching
|
||||
let version_jar = cluster
|
||||
.meta
|
||||
.loader_version
|
||||
|
|
@ -277,9 +271,9 @@ pub async fn launch_minecraft(
|
|||
let instance_path = &io::canonicalize(instance_path)?;
|
||||
|
||||
let version_manifest = metadata.minecraft.to_owned();
|
||||
let versions = version_manifest
|
||||
.ok_or(anyhow::anyhow!("couldn't get minecraft manifest"))?
|
||||
.versions;
|
||||
let versions = version_manifest
|
||||
.ok_or(anyhow::anyhow!("couldn't get minecraft manifest"))?
|
||||
.versions;
|
||||
|
||||
let version_index = versions
|
||||
.iter()
|
||||
|
|
@ -290,11 +284,7 @@ pub async fn launch_minecraft(
|
|||
))?;
|
||||
|
||||
let version = &versions[version_index];
|
||||
let updated = version_index
|
||||
<= versions
|
||||
.iter()
|
||||
.position(|x| x.id == "22w16a")
|
||||
.unwrap_or(0);
|
||||
let updated = version_index <= versions.iter().position(|x| x.id == "22w16a").unwrap_or(0);
|
||||
let version_jar = cluster
|
||||
.meta
|
||||
.loader_version
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ impl Directories {
|
|||
/// Bootstrap the initial settings directory on first startup.
|
||||
pub fn init_settings_dir() -> Option<PathBuf> {
|
||||
Self::env_path("ONELAUNCHER_CONFIG")
|
||||
.or_else(|| Some(dirs::config_dir()?.join(constants::APP_CONFIG_DIR)))
|
||||
.or_else(|| Some(dirs::config_dir()?.join(constants::ID)))
|
||||
}
|
||||
|
||||
/// Bootstrap the initial settings directory on first startup.
|
||||
|
|
|
|||
|
|
@ -36,61 +36,61 @@ impl Metadata {
|
|||
format!("{METADATA_URL}/{name}/v{version}/manifest.json")
|
||||
}
|
||||
|
||||
/// Fetch all available metadata types that are currently [`None`] and get a new [`Metadata`] structure.
|
||||
/// Useful for when reading from cache and a certain object not existing
|
||||
pub async fn fetch_errored(&mut self, semaphore: &FetchSemaphore) -> crate::Result<bool> {
|
||||
let mut did_change = false;
|
||||
if self.minecraft.is_none() {
|
||||
self.minecraft = Self::fetch_minecraft(semaphore).await;
|
||||
/// Fetch all available metadata types that are currently [`None`] and get a new [`Metadata`] structure.
|
||||
/// Useful for when reading from cache and a certain object not existing
|
||||
pub async fn fetch_errored(&mut self, semaphore: &FetchSemaphore) -> crate::Result<bool> {
|
||||
let mut did_change = false;
|
||||
if self.minecraft.is_none() {
|
||||
self.minecraft = Self::fetch_minecraft(semaphore).await;
|
||||
|
||||
if self.minecraft.is_some() {
|
||||
did_change = true;
|
||||
}
|
||||
}
|
||||
if self.minecraft.is_some() {
|
||||
did_change = true;
|
||||
}
|
||||
}
|
||||
|
||||
if self.fabric.is_none() {
|
||||
self.fabric = Self::fetch_fabric(semaphore).await;
|
||||
if self.fabric.is_none() {
|
||||
self.fabric = Self::fetch_fabric(semaphore).await;
|
||||
|
||||
if self.fabric.is_some() {
|
||||
did_change = true;
|
||||
}
|
||||
}
|
||||
if self.fabric.is_some() {
|
||||
did_change = true;
|
||||
}
|
||||
}
|
||||
|
||||
if self.quilt.is_none() {
|
||||
self.quilt = Self::fetch_quilt(semaphore).await;
|
||||
if self.quilt.is_none() {
|
||||
self.quilt = Self::fetch_quilt(semaphore).await;
|
||||
|
||||
if self.quilt.is_some() {
|
||||
did_change = true;
|
||||
}
|
||||
}
|
||||
if self.quilt.is_some() {
|
||||
did_change = true;
|
||||
}
|
||||
}
|
||||
|
||||
if self.neoforge.is_none() {
|
||||
self.neoforge = Self::fetch_neoforge(semaphore).await;
|
||||
if self.neoforge.is_none() {
|
||||
self.neoforge = Self::fetch_neoforge(semaphore).await;
|
||||
|
||||
if self.neoforge.is_some() {
|
||||
did_change = true;
|
||||
}
|
||||
}
|
||||
if self.neoforge.is_some() {
|
||||
did_change = true;
|
||||
}
|
||||
}
|
||||
|
||||
if self.forge.is_none() {
|
||||
self.forge = Self::fetch_forge(semaphore).await;
|
||||
if self.forge.is_none() {
|
||||
self.forge = Self::fetch_forge(semaphore).await;
|
||||
|
||||
if self.forge.is_some() {
|
||||
did_change = true;
|
||||
}
|
||||
}
|
||||
if self.forge.is_some() {
|
||||
did_change = true;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(did_change)
|
||||
}
|
||||
Ok(did_change)
|
||||
}
|
||||
|
||||
/// Fetch all available metadata types and get a new [`Metadata`] structure.
|
||||
pub async fn fetch(semaphore: &FetchSemaphore) -> crate::Result<Self> {
|
||||
let (minecraft, fabric, quilt, neoforge, forge) = tokio::join! {
|
||||
Self::fetch_minecraft(semaphore),
|
||||
Self::fetch_fabric(semaphore),
|
||||
Self::fetch_quilt(semaphore),
|
||||
Self::fetch_neoforge(semaphore),
|
||||
Self::fetch_forge(semaphore)
|
||||
Self::fetch_fabric(semaphore),
|
||||
Self::fetch_quilt(semaphore),
|
||||
Self::fetch_neoforge(semaphore),
|
||||
Self::fetch_forge(semaphore)
|
||||
};
|
||||
|
||||
Ok(Self {
|
||||
|
|
@ -102,30 +102,45 @@ impl Metadata {
|
|||
})
|
||||
}
|
||||
|
||||
async fn fetch_minecraft(semaphore: &FetchSemaphore) -> Option<MinecraftManifest> {
|
||||
let url = Self::get_manifest("minecraft", interpulse::api::minecraft::CURRENT_FORMAT_VERSION);
|
||||
fetch_version_manifest(Some(&url), semaphore).await.ok()
|
||||
}
|
||||
async fn fetch_minecraft(semaphore: &FetchSemaphore) -> Option<MinecraftManifest> {
|
||||
let url = Self::get_manifest(
|
||||
"minecraft",
|
||||
interpulse::api::minecraft::CURRENT_FORMAT_VERSION,
|
||||
);
|
||||
fetch_version_manifest(Some(&url), semaphore).await.ok()
|
||||
}
|
||||
|
||||
async fn fetch_fabric(semaphore: &FetchSemaphore) -> Option<ModdedManifest> {
|
||||
let url = Self::get_manifest("fabric", interpulse::api::modded::CURRENT_FABRIC_FORMAT_VERSION);
|
||||
fetch_modded_manifest(&url, semaphore).await.ok()
|
||||
}
|
||||
|
||||
async fn fetch_quilt(semaphore: &FetchSemaphore) -> Option<ModdedManifest> {
|
||||
let url = Self::get_manifest("quilt", interpulse::api::modded::CURRENT_QUILT_FORMAT_VERSION);
|
||||
fetch_modded_manifest(&url, semaphore).await.ok()
|
||||
}
|
||||
async fn fetch_fabric(semaphore: &FetchSemaphore) -> Option<ModdedManifest> {
|
||||
let url = Self::get_manifest(
|
||||
"fabric",
|
||||
interpulse::api::modded::CURRENT_FABRIC_FORMAT_VERSION,
|
||||
);
|
||||
fetch_modded_manifest(&url, semaphore).await.ok()
|
||||
}
|
||||
|
||||
async fn fetch_neoforge(semaphore: &FetchSemaphore) -> Option<ModdedManifest> {
|
||||
let url = Self::get_manifest("neoforge", interpulse::api::modded::CURRENT_NEOFORGE_FORMAT_VERSION);
|
||||
fetch_modded_manifest(&url, semaphore).await.ok()
|
||||
}
|
||||
async fn fetch_quilt(semaphore: &FetchSemaphore) -> Option<ModdedManifest> {
|
||||
let url = Self::get_manifest(
|
||||
"quilt",
|
||||
interpulse::api::modded::CURRENT_QUILT_FORMAT_VERSION,
|
||||
);
|
||||
fetch_modded_manifest(&url, semaphore).await.ok()
|
||||
}
|
||||
|
||||
async fn fetch_forge(semaphore: &FetchSemaphore) -> Option<ModdedManifest> {
|
||||
let url = Self::get_manifest("forge", interpulse::api::modded::CURRENT_FORGE_FORMAT_VERSION);
|
||||
fetch_modded_manifest(&url, semaphore).await.ok()
|
||||
}
|
||||
async fn fetch_neoforge(semaphore: &FetchSemaphore) -> Option<ModdedManifest> {
|
||||
let url = Self::get_manifest(
|
||||
"neoforge",
|
||||
interpulse::api::modded::CURRENT_NEOFORGE_FORMAT_VERSION,
|
||||
);
|
||||
fetch_modded_manifest(&url, semaphore).await.ok()
|
||||
}
|
||||
|
||||
async fn fetch_forge(semaphore: &FetchSemaphore) -> Option<ModdedManifest> {
|
||||
let url = Self::get_manifest(
|
||||
"forge",
|
||||
interpulse::api::modded::CURRENT_FORGE_FORMAT_VERSION,
|
||||
);
|
||||
fetch_modded_manifest(&url, semaphore).await.ok()
|
||||
}
|
||||
|
||||
/// Initialize the core Metadata manager.
|
||||
#[tracing::instrument(skip(io_semaphore, fetch_semaphore))]
|
||||
|
|
@ -134,21 +149,21 @@ impl Metadata {
|
|||
dirs: &Directories,
|
||||
online: bool,
|
||||
io_semaphore: &IoSemaphore,
|
||||
fetch_semaphore: &FetchSemaphore,
|
||||
fetch_semaphore: &FetchSemaphore,
|
||||
) -> crate::Result<Self> {
|
||||
let mut metadata = None;
|
||||
let path = dirs.caches_dir().await.join("metadata.json");
|
||||
let backup = dirs.caches_dir().await.join("metadata.json.bak");
|
||||
let mut should_write = false;
|
||||
let mut should_write = false;
|
||||
|
||||
if let Ok(mut metadata_json) = read_json::<Metadata>(&path, io_semaphore).await {
|
||||
should_write = metadata_json.fetch_errored(fetch_semaphore).await?;
|
||||
should_write = metadata_json.fetch_errored(fetch_semaphore).await?;
|
||||
|
||||
metadata = Some(metadata_json);
|
||||
} else if online {
|
||||
let res = async {
|
||||
let fetch_data = Self::fetch(fetch_semaphore).await?;
|
||||
should_write = true;
|
||||
should_write = true;
|
||||
|
||||
metadata = Some(fetch_data);
|
||||
Ok::<(), crate::Error>(())
|
||||
|
|
@ -166,18 +181,20 @@ impl Metadata {
|
|||
copy(&backup, &path).await?;
|
||||
}
|
||||
|
||||
if should_write {
|
||||
write(
|
||||
&path,
|
||||
&serde_json::to_vec(&metadata).unwrap_or_default(),
|
||||
io_semaphore,
|
||||
).await?;
|
||||
write(
|
||||
&backup,
|
||||
&serde_json::to_vec(&metadata).unwrap_or_default(),
|
||||
io_semaphore,
|
||||
).await?;
|
||||
}
|
||||
if should_write {
|
||||
write(
|
||||
&path,
|
||||
&serde_json::to_vec(&metadata).unwrap_or_default(),
|
||||
io_semaphore,
|
||||
)
|
||||
.await?;
|
||||
write(
|
||||
&backup,
|
||||
&serde_json::to_vec(&metadata).unwrap_or_default(),
|
||||
io_semaphore,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
if let Some(meta) = metadata {
|
||||
Ok(meta)
|
||||
|
|
@ -189,7 +206,7 @@ impl Metadata {
|
|||
/// Update and backup all available metadata.
|
||||
pub async fn update() {
|
||||
let res = async {
|
||||
let state = State::get().await?;
|
||||
let state = State::get().await?;
|
||||
let fetch_data = Metadata::fetch(&state.fetch_semaphore).await?;
|
||||
|
||||
let path = state.directories.caches_dir().await.join("metadata.json");
|
||||
|
|
@ -230,13 +247,12 @@ async fn fetch_version_manifest(
|
|||
url: Option<&str>,
|
||||
semaphore: &FetchSemaphore,
|
||||
) -> crate::Result<MinecraftManifest> {
|
||||
let url = url.unwrap_or(interpulse::api::minecraft::VERSION_MANIFEST_URL);
|
||||
let url = url.unwrap_or(interpulse::api::minecraft::VERSION_MANIFEST_URL);
|
||||
Ok(serde_json::from_slice(
|
||||
&fetch(url, None, semaphore).await
|
||||
.map_err(|err| {
|
||||
tracing::error!("couldn't fetch version manifest at '{}'", url);
|
||||
err
|
||||
})?,
|
||||
&fetch(url, None, semaphore).await.map_err(|err| {
|
||||
tracing::error!("couldn't fetch version manifest at '{}'", url);
|
||||
err
|
||||
})?,
|
||||
)?)
|
||||
}
|
||||
|
||||
|
|
@ -245,10 +261,9 @@ async fn fetch_modded_manifest(
|
|||
semaphore: &FetchSemaphore,
|
||||
) -> crate::Result<ModdedManifest> {
|
||||
Ok(serde_json::from_slice(
|
||||
&fetch(url, None, semaphore).await
|
||||
.map_err(|err| {
|
||||
tracing::error!("couldn't fetch modded manifest at '{}'", url);
|
||||
err
|
||||
})?
|
||||
)?)
|
||||
&fetch(url, None, semaphore).await.map_err(|err| {
|
||||
tracing::error!("couldn't fetch modded manifest at '{}'", url);
|
||||
err
|
||||
})?,
|
||||
)?)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ use std::collections::HashMap;
|
|||
use std::fmt::Write;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::constants::{MICROSOFT_CLIENT_ID, SCOPES, REDIRECT_URL};
|
||||
|
||||
const AUTH_STORE: &str = "authentication.json";
|
||||
|
||||
/// The core state of Microsoft authentication for the launcher
|
||||
|
|
@ -310,11 +312,6 @@ impl MinecraftState {
|
|||
}
|
||||
}
|
||||
|
||||
/// Microsoft login redirect URI.
|
||||
const REDIRECT_URL: &str = "https://login.live.com/oauth20_desktop.srf";
|
||||
/// Microsoft login xboxlive scopes to get tokens.
|
||||
const SCOPES: &str = "service::user.auth.xboxlive.com::MBI_SSL";
|
||||
|
||||
/// A [`reqwest::Request`] with a [`DateTime<Utc>`] attached to it.
|
||||
struct RequestWithDate<T> {
|
||||
pub date: DateTime<Utc>,
|
||||
|
|
@ -450,7 +447,7 @@ async fn sisu_authenticate(
|
|||
"https://sisu.xboxlive.com/authenticate",
|
||||
"/authenticate",
|
||||
json!({
|
||||
"AppId": crate::constants::MICROSOFT_CLIENT_ID,
|
||||
"AppId": MICROSOFT_CLIENT_ID,
|
||||
"DeviceToken": token,
|
||||
"Offers": [SCOPES],
|
||||
"Query": {
|
||||
|
|
@ -503,7 +500,7 @@ async fn oauth_token(
|
|||
verify: &str,
|
||||
) -> Result<RequestWithDate<OAuthToken>, MinecraftAuthError> {
|
||||
let mut query = HashMap::new();
|
||||
query.insert("client_id", crate::constants::MICROSOFT_CLIENT_ID);
|
||||
query.insert("client_id", MICROSOFT_CLIENT_ID);
|
||||
query.insert("code", code);
|
||||
query.insert("code_verifier", verify);
|
||||
query.insert("grant_type", "authorization_code");
|
||||
|
|
@ -551,7 +548,7 @@ async fn oauth_refresh(
|
|||
refresh_token: &str,
|
||||
) -> Result<RequestWithDate<OAuthToken>, MinecraftAuthError> {
|
||||
let mut query = HashMap::new();
|
||||
query.insert("client_id", crate::constants::MICROSOFT_CLIENT_ID);
|
||||
query.insert("client_id", MICROSOFT_CLIENT_ID);
|
||||
query.insert("refresh_token", refresh_token);
|
||||
query.insert("grant_type", "refresh_token");
|
||||
query.insert("redirect_uri", REDIRECT_URL);
|
||||
|
|
@ -618,7 +615,7 @@ async fn sisu_authorize(
|
|||
"/authorize",
|
||||
json!({
|
||||
"AccessToken": format!("t={access_token}"),
|
||||
"AppId": crate::constants::MICROSOFT_CLIENT_ID,
|
||||
"AppId": MICROSOFT_CLIENT_ID,
|
||||
"DeviceToken": device_token,
|
||||
"ProofKey": {
|
||||
// kibty (kty)
|
||||
|
|
|
|||
|
|
@ -131,8 +131,9 @@ impl State {
|
|||
|
||||
let is_offline = !http::check_internet_connection(3).await;
|
||||
|
||||
// TODO: Make this run in the background, this delays launcher startup by a couple seconds
|
||||
let metadata_in = Metadata::initialize(&directories, !is_offline, &io_semaphore, &fetch_semaphore);
|
||||
// TODO: Make this run in the background, this delays launcher startup by a couple seconds
|
||||
let metadata_in =
|
||||
Metadata::initialize(&directories, !is_offline, &io_semaphore, &fetch_semaphore);
|
||||
let clusters_in = Clusters::initialize(&directories, &mut watcher);
|
||||
let users_in = MinecraftState::initialize(&directories, &io_semaphore);
|
||||
let (metadata, clusters, users) = crate::ingress_join! {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use uuid::Uuid;
|
|||
/// Wrapper over an [`async_tungstenite::WebSocketStream`] to connect to the OneConfig server.
|
||||
pub struct OneConfig {
|
||||
/// The public tokio socket connection.
|
||||
socket: async_tungstenite::WebSocketStream<async_tungstenite::tokio::ConnectStream>,
|
||||
pub socket: async_tungstenite::WebSocketStream<async_tungstenite::tokio::ConnectStream>,
|
||||
}
|
||||
|
||||
/// A WebSocket packet while updating a mod to display a GUI in game.
|
||||
|
|
@ -23,7 +23,7 @@ pub struct ModUpdatePacket {
|
|||
|
||||
impl OneConfig {
|
||||
/// Initializes a OneConfig socket connection on localhost port `4023`.
|
||||
pub async fn new(cluster: ClusterPath) -> crate::Result<Self> {
|
||||
pub async fn initialize(cluster: ClusterPath) -> crate::Result<Self> {
|
||||
let (socket, _) = async_tungstenite::tokio::connect_async(format!(
|
||||
"wss://localhost:4023/oneconfig/ws?cluster={cluster}"
|
||||
))
|
||||
|
|
|
|||
|
|
@ -22,17 +22,17 @@
|
|||
"release:node": "pnpm bumpp -r"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@flowr/eslint-config": "^3.8.7",
|
||||
"@flowr/eslint-config": "^3.8.8",
|
||||
"@types/node": "^20.14.10",
|
||||
"@vitest/ui": "^2.0.2",
|
||||
"@vitest/ui": "^2.0.3",
|
||||
"bumpp": "^9.4.1",
|
||||
"eslint": "^9.7.0",
|
||||
"eslint-plugin-solid": "^0.14.1",
|
||||
"ts-node": "^10.9.2",
|
||||
"tsx": "^4.16.2",
|
||||
"typescript": "^5.5.3",
|
||||
"vite": "^5.3.3",
|
||||
"vitest": "^2.0.2"
|
||||
"vite": "^5.3.4",
|
||||
"vitest": "^2.0.3"
|
||||
},
|
||||
"pnpm": {
|
||||
"patchDependencies": {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
"tauri": "tsx tauri.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@flowr/utils": "^3.8.7",
|
||||
"@flowr/utils": "^3.8.8",
|
||||
"@iarna/toml": "^2.2.5",
|
||||
"execa": "^9.3.0",
|
||||
"semver": "^7.6.2",
|
||||
|
|
|
|||
804
pnpm-lock.yaml
generated
804
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue