From 1888ded1d754fe73477c427c44bdb0e792837d7f Mon Sep 17 00:00:00 2001 From: Toasterkitten Date: Sat, 18 Jul 2026 17:12:46 -0400 Subject: [PATCH] First public commit (i had some old stuff i cant publish) --- .gitignore | 3 + Cargo.lock | 1592 +++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 19 + src/auth.rs | 264 ++++++++ src/download.rs | 93 +++ src/fabric.rs | 89 +++ src/instance.rs | 95 +++ src/launch.rs | 104 ++++ src/main.rs | 196 ++++++ src/meta.rs | 179 ++++++ src/mrpack.rs | 172 +++++ src/prism.rs | 81 +++ 12 files changed, 2887 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/auth.rs create mode 100644 src/download.rs create mode 100644 src/fabric.rs create mode 100644 src/instance.rs create mode 100644 src/launch.rs create mode 100644 src/main.rs create mode 100644 src/meta.rs create mode 100644 src/mrpack.rs create mode 100644 src/prism.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f871625 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/target +logs/ +*.mrpack \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..2a8f6fe --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1592 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "aes" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1fc76eaeac4c9164506c466d4ffdd8ec9d0c5bf57ee97177c4d8eceb3a0e138" +dependencies = [ + "cipher", + "cpubits", + "cpufeatures 0.3.0", +] + +[[package]] +name = "anstream" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" + +[[package]] +name = "anstyle-parse" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] + +[[package]] +name = "anyhow" +version = "1.0.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a4385e2e34eb35d6b3efe798b9eb88096925d87726c0798709bf56d9ed84af3" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa" +dependencies = [ + "hybrid-array", + "zeroize", +] + +[[package]] +name = "bumpalo" +version = "3.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" + +[[package]] +name = "bytes" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" + +[[package]] +name = "bzip2" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a53fac24f34a81bc9954b5d6cfce0c21e18ec6959f44f56e8e90e4bb7c346c" +dependencies = [ + "libbz2-rs-sys", +] + +[[package]] +name = "cc" +version = "1.2.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5d6cac793997bd970000024b2934968efe83b382de4fdcf4fcb46b6ee4ad996" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "cipher" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c" +dependencies = [ + "crypto-common 0.2.2", + "inout", +] + +[[package]] +name = "clap" +version = "4.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ddb117e43bbf7dacf0a4190fef4d345b9bad68dfc649cb349e7d17d28428e51" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2ce8604710f6733aa641a2b3731eaa1e8b3d9973d5e3565da11800813f997a9" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" + +[[package]] +name = "cmov" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a" + +[[package]] +name = "colorchoice" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" + +[[package]] +name = "console" +version = "0.16.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fe5f465a4f6fee88fad41b85d990f84c835335e85b5d9e6e63e0d06d28cba7c" +dependencies = [ + "encode_unicode", + "libc", + "unicode-width", + "windows-sys 0.61.2", +] + +[[package]] +name = "const-oid" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c" + +[[package]] +name = "constant_time_eq" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d52eff69cd5e647efe296129160853a42795992097e8af39800e1060caeea9b" + +[[package]] +name = "cookie" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ddef33a339a91ea89fb53151bd0a4689cfce27055c291dfa69945475d22c747" +dependencies = [ + "percent-encoding", + "time", + "version_check", +] + +[[package]] +name = "cookie_store" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15b2c103cf610ec6cae3da84a766285b42fd16aad564758459e6ecf128c75206" +dependencies = [ + "cookie", + "document-features", + "idna", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "time", + "url", +] + +[[package]] +name = "cpubits" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "cpufeatures" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5181e0de7b61eb03a81e347d6dd8797bae9da5146707b51077e2d71a54ec0ceb" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d6914041f254d6e9176c01941b21115dcfb7089e55135a35411081bd106ef3f" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61803da095bee82a81bb1a452ecc25d3b2f1416d1897eb86430c6159ef717c17" + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "crypto-common" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453" +dependencies = [ + "hybrid-array", +] + +[[package]] +name = "ctutils" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d5515a3834141de9eafb9717ad39eea8247b5674e6066c404e8c4b365d2a29e" +dependencies = [ + "cmov", +] + +[[package]] +name = "deflate64" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac6b926516df9c60bfa16e107b21086399f8285a44ca9711344b9e553c5146e2" + +[[package]] +name = "deranged" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common 0.1.7", +] + +[[package]] +name = "digest" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" +dependencies = [ + "block-buffer 0.12.1", + "const-oid", + "crypto-common 0.2.2", + "ctutils", + "zeroize", +] + +[[package]] +name = "displaydoc" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ac70aa55017e108007fbaf5aa0f54b021c98f92ff8af59d42eda9da96e3dd4f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "document-features" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61" +dependencies = [ + "litrs", +] + +[[package]] +name = "either" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e" + +[[package]] +name = "encode_unicode" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "flate2" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c" +dependencies = [ + "crc32fast", + "miniz_oxide", + "zlib-rs", +] + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi", + "wasm-bindgen", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hmac" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f" +dependencies = [ + "digest 0.11.3", +] + +[[package]] +name = "http" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6970f50e31d6fc17d3fa27329444bfa74e196cf62e95052a3f6fee181dba6425" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "hybrid-array" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "818356c5132c1fede50f837ca96afbe78ff42413047f4abb886217845e1b6c8c" +dependencies = [ + "typenum", +] + +[[package]] +name = "icu_collections" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2984d1cd16c883d7935b9e07e44071dca8d917fd52ecc02c04d5fa0b5a3f191c" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92219b62b3e2b4d88ac5119f8904c10f8f61bf7e95b640d25ba3075e6cac2c29" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c56e5ee99d6e3d33bd91c5d85458b6005a22140021cc324cea84dd0e72cff3b4" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da3be0ae77ea334f4da67c12f149704f19f81d1adf7c51cf482943e84a2bad38" + +[[package]] +name = "icu_properties" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bee3b67d0ea5c2cca5003417989af8996f8604e34fb9ddf96208a033901e70de" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2bbb201e0c04f7b4b3e14382af113e17ba4f63e2c9d2ee626b720cbce54a14" + +[[package]] +name = "icu_provider" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139c4cf31c8b5f33d7e199446eff9c1e02decfc2f0eec2c8d71f65befa45b421" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "indicatif" +version = "0.18.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9433806cd6b4ec1aba79c021c7e4c58fb4c3b9977c085062e611ac929998fb0c" +dependencies = [ + "console", + "portable-atomic", + "rayon", + "unicode-width", + "unit-prefix", + "web-time", +] + +[[package]] +name = "inout" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4250ce6452e92010fdf7268ccc5d14faa80bb12fc741938534c58f16804e03c7" +dependencies = [ + "hybrid-array", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "jobserver" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" +dependencies = [ + "getrandom 0.4.3", + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53b44bfcdb3f8d5837a46dae1ca9660a837176eee74a28b229bc626816589102" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "libbz2-rs-sys" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34b357333733e8260735ba5894eb928c02ecc69c78715f01a8019e7fa7f2db4c" + +[[package]] +name = "libc" +version = "0.2.186" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" + +[[package]] +name = "litemap" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0" + +[[package]] +name = "litrs" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092" + +[[package]] +name = "log" +version = "0.4.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" + +[[package]] +name = "lzma-rust2" +version = "0.16.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca93e534d1142d1d0dcca6d25fe302508a5dfb40b302802904577725ea0b695b" +dependencies = [ + "sha2 0.11.0", +] + +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest 0.10.7", +] + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "num-conv" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + +[[package]] +name = "pbkdf2" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112d82ceb8c5bf524d9af484d4e4970c9fd5a0cc15ba14ad93dccd28873b0629" +dependencies = [ + "digest 0.11.3", + "hmac", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pkg-config" +version = "0.3.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" + +[[package]] +name = "portable-atomic" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" + +[[package]] +name = "potential_utf" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0103b1cef7ec0cf76490e969665504990193874ea05c85ff9bab8b911d0a0564" +dependencies = [ + "zerovec", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppmd-rust" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efca4c95a19a79d1c98f791f10aebd5c1363b473244630bb7dbde1dc98455a24" + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rayon" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls" +version = "0.23.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b92b125634d9b795e7beca796cc790df15a7fb38323bf3196fda83292d06b1f" +dependencies = [ + "log", + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "764899a24af3980067ee14bc143654f297b22eaebfe3c7b6b211920a5a59b046" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.150" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "sha1" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aacc4cc499359472b4abe1bf11d0b12e688af9a805fa5e3016f9a386dc2d0214" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.0", + "digest 0.11.3", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "digest 0.10.7", +] + +[[package]] +name = "sha2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "446ba717509524cb3f22f17ecc096f10f4822d76ab5c0b9822c5f9c284e825f4" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.0", + "digest 0.11.3", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "simd-adler32" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "time" +version = "0.3.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" +dependencies = [ + "deranged", + "itoa", + "js-sys", + "num-conv", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" + +[[package]] +name = "time-macros" +version = "0.2.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinystr" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8323304221c2a851516f22236c5722a72eaa19749016521d6dff0824447d96d" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "typed-path" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e28f89b80c87b8fb0cf04ab448d5dd0dd0ade2f8891bae878de66a75a28600e" + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-width" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" + +[[package]] +name = "unit-prefix" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81e544489bf3d8ef66c953931f56617f423cd4b5494be343d9b9d3dda037b9a3" + +[[package]] +name = "untitled-minecraft-launcher" +version = "0.1.0" +dependencies = [ + "anyhow", + "clap", + "indicatif", + "rayon", + "serde", + "serde_json", + "sha2 0.10.9", + "ureq", + "uuid", + "zip", +] + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "ureq" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dea7109cdcd5864d4eeb1b58a1648dc9bf520360d7af16ec26d0a9354bafcfc0" +dependencies = [ + "base64", + "cookie_store", + "flate2", + "log", + "percent-encoding", + "rustls", + "rustls-pki-types", + "serde", + "serde_json", + "ureq-proto", + "utf8-zero", + "webpki-roots", +] + +[[package]] +name = "ureq-proto" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e994ba84b0bd1b1b0cf92878b7ef898a5c1760108fe7b6010327e274917a808c" +dependencies = [ + "base64", + "http", + "httparse", + "log", +] + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8-zero" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8c0a043c9540bae7c578c88f91dda8bd82e59ae27c21baca69c8b191aaf5a6e" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "uuid" +version = "1.23.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf80a72845275afea99e7f2b434723d3bc7e38470fcd1c7ed39a599c73319a53" +dependencies = [ + "js-sys", + "md-5", + "wasm-bindgen", +] + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasm-bindgen" +version = "0.2.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b067c0c11094aef6b7a801c1e34a26affafdf3d051dba08456b868789aaf9a4" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167ce5e579f6bcf889c4f7175a8a5a585de84e8ff93976ce393efa5f2837aab1" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3997c7839262f4ef12cf90b818d6340c18e80f263f1a94bf157d0ec4420380e" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1b4cb0cc549fcf58d7dfc081778139b3d283a081644e833e84682ad71cea24" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf85cb06032201fa7c6f829d7db5a7e5aa45bcc0655327713065f6f0576731bf" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "writeable" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4" + +[[package]] +name = "yoke" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e" + +[[package]] +name = "zerotrie" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f9152d31db0792fa83f70fb2f83148effb5c1f5b8c7686c3459e361d9bc20bf" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90f911cbc359ab6af17377d242225f4d75119aec87ea711a880987b18cd7b239" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zip" +version = "8.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d04a6b5381502aa6087c94c669499eb1602eb9c5e8198e534de571f7154809b" +dependencies = [ + "aes", + "bzip2", + "constant_time_eq", + "crc32fast", + "deflate64", + "flate2", + "getrandom 0.4.3", + "hmac", + "indexmap", + "lzma-rust2", + "memchr", + "pbkdf2", + "ppmd-rust", + "sha1", + "time", + "typed-path", + "zeroize", + "zopfli", + "zstd", +] + +[[package]] +name = "zlib-rs" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b142a20ec14a91d5bc708c1dc21b080c550113d8aa77afa29635673a65dd02c5" + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" + +[[package]] +name = "zopfli" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f05cd8797d63865425ff89b5c4a48804f35ba0ce8d125800027ad6017d2b5249" +dependencies = [ + "bumpalo", + "crc32fast", + "log", + "simd-adler32", +] + +[[package]] +name = "zstd" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "7.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f49c4d5f0abb602a93fb8736af2a4f4dd9512e36f7f570d66e65ff867ed3b9d" +dependencies = [ + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.16+zstd.1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e19ebc2adc8f83e43039e79776e3fda8ca919132d68a1fed6a5faca2683748" +dependencies = [ + "cc", + "pkg-config", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..66b0b71 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "untitled-minecraft-launcher" +version = "0.1.0" +edition = "2024" + +[dependencies] +anyhow = "1.0.103" +clap = { version = "4.6.1", features = ["color", "derive"] } +indicatif = { version = "0.18.6", features = ["rayon"] } +rayon = "1.12.0" +serde = { version = "1.0.228", features = ["derive"] } +serde_json = "1.0.150" +sha2 = { version = "0.10", features = ["std"] } +ureq = { version = "3.3.0", features = ["json"] } +uuid = { version = "1.23.4", features = ["v3"] } +zip = "8.6.0" +[[bin]] +name = "uml" +path = "src/main.rs" diff --git a/src/auth.rs b/src/auth.rs new file mode 100644 index 0000000..48bbd19 --- /dev/null +++ b/src/auth.rs @@ -0,0 +1,264 @@ +use serde::Deserialize; +use std::{ + os::unix::fs::PermissionsExt, + path::{Path, PathBuf}, + thread::sleep, + time::Duration, +}; +use ureq::Agent; + +// to anyone trying to make something similar, you need your own client ID, you can get one from like an azure project or something, and then it won't work and the error code from some later xbox or minecraft api will say to go to another link where you fill a form and hope they let you use the api, i managed to get it, but don't hope on it. +const CLIENT_ID: &str = "daa4feeb-ac95-4ee0-b6e2-2041746b9a50"; +const TOKEN_URL: &str = "https://login.microsoftonline.com/consumers/oauth2/v2.0/token"; +const DEVICECODE_URL: &str = "https://login.microsoftonline.com/consumers/oauth2/v2.0/devicecode"; +const XBL_URL: &str = "https://user.auth.xboxlive.com/user/authenticate"; +const XSTS_URL: &str = "https://xsts.auth.xboxlive.com/xsts/authorize"; +const MC_LOGIN_URL: &str = "https://api.minecraftservices.com/authentication/login_with_xbox"; +const PROFILE_URL: &str = "https://api.minecraftservices.com/minecraft/profile"; +#[derive(Deserialize)] +struct Device { + device_code: String, + user_code: String, + verification_uri: String, + interval: u64, +} +#[derive(Deserialize)] +struct XblResponse { + #[serde(rename = "Token")] + token: String, + #[serde(rename = "DisplayClaims")] + display_claims: DisplayClaims, +} + +#[derive(Deserialize)] +struct DisplayClaims { + xui: Vec, +} + +#[derive(Deserialize)] +struct Xui { + uhs: String, + #[serde(default)] + xid: Option, +} +#[derive(Deserialize)] +struct McTokenResponse { + access_token: String, +} +#[derive(Deserialize)] +struct Profile { + id: String, + name: String, +} +#[derive(Deserialize)] +struct TokenResponse { + access_token: Option, + refresh_token: Option, + error: Option, +} +pub struct Account { + pub name: String, + pub uuid: String, + pub access_token: String, + pub xuid: String, +} + +fn token_path() -> anyhow::Result { + let home = std::env::var("HOME")?; + Ok(Path::new(&home).join(".config").join("uml").join("token")) +} + +fn save_refresh(token: &str) -> anyhow::Result<()> { + let path = token_path()?; + std::fs::create_dir_all(path.parent().unwrap())?; + std::fs::write(&path, token)?; + std::fs::set_permissions(&path, std::fs::Permissions::from_mode(0o600))?; + Ok(()) +} + +fn agent() -> Agent { + Agent::config_builder() + .http_status_as_error(false) + .build() + .new_agent() +} +fn device_code(agent: &Agent) -> anyhow::Result { + let mut res = agent.post(DEVICECODE_URL).send_form([ + ("client_id", CLIENT_ID), + ("scope", "XboxLive.signin offline_access"), + ])?; + if res.status() != 200 { + let body = res.body_mut().read_to_string()?; + anyhow::bail!("device code failed ({}): {body}", res.status()); + } + Ok(res.body_mut().read_json()?) +} +fn refresh(agent: &Agent, refresh: &str) -> anyhow::Result<(String, String)> { + let mut res = agent.post(TOKEN_URL).send_form([ + ("grant_type", "refresh_token"), + ("client_id", CLIENT_ID), + ("refresh_token", refresh), + ])?; + if res.status() != 200 { + let body = res.body_mut().read_to_string()?; + anyhow::bail!("refresh failed ({}): {body}", res.status()); + } + let body: TokenResponse = res.body_mut().read_json()?; + let access = body + .access_token + .ok_or_else(|| anyhow::anyhow!("no access token"))?; + let new_refresh = body + .refresh_token + .ok_or_else(|| anyhow::anyhow!("no refresh token"))?; + Ok((access, new_refresh)) +} +fn poll(agent: &Agent, device: &Device) -> anyhow::Result<(String, String)> { + println!( + "Go to {} and enter code: {}", + device.verification_uri, device.user_code + ); + loop { + sleep(Duration::from_secs(device.interval)); + + let mut res = agent.post(TOKEN_URL).send_form([ + ("grant_type", "urn:ietf:params:oauth:grant-type:device_code"), + ("client_id", CLIENT_ID), + ("device_code", device.device_code.as_str()), + ])?; + let body: TokenResponse = res.body_mut().read_json()?; + + if let Some(token) = body.access_token { + let refresh = body.refresh_token.ok_or_else(|| { + anyhow::anyhow!("no refresh token — was offline_access in the scope?") + })?; + return Ok((token, refresh)); + } + match body.error.as_deref() { + Some("authorization_pending") => continue, + Some("slow_down") => { + sleep(Duration::from_secs(5)); + continue; + } + Some(other) => anyhow::bail!("auth failed: {other}"), + None => anyhow::bail!("unexpected response"), + } + } +} +fn xbl(agent: &Agent, ms_token: &str) -> anyhow::Result { + let mut res = agent.post(XBL_URL).send_json(serde_json::json!({ + "Properties": { + "AuthMethod": "RPS", + "SiteName": "user.auth.xboxlive.com", + "RpsTicket": format!("d={ms_token}") + }, + "RelyingParty": "http://auth.xboxlive.com", + "TokenType": "JWT" + }))?; + if res.status() != 200 { + let body = res.body_mut().read_to_string()?; + anyhow::bail!("xbl failed ({}): {body}", res.status()); + } + Ok(res.body_mut().read_json()?) +} +fn xsts(agent: &Agent, xbl_token: &str) -> anyhow::Result { + let mut res = agent.post(XSTS_URL).send_json(serde_json::json!({ + "Properties": { "SandboxId": "RETAIL", "UserTokens": [xbl_token] }, + "RelyingParty": "rp://api.minecraftservices.com/", + "TokenType": "JWT" + }))?; + if res.status() == 401 { + #[derive(Deserialize)] + struct XErr { + #[serde(rename = "XErr")] + xerr: u64, + } + let e: XErr = res.body_mut().read_json()?; + anyhow::bail!( + "{}", + match e.xerr { + 2148916233 => "no Xbox profile — sign in at minecraft.net once".into(), + 2148916235 => "Xbox Live unavailable in this region".into(), + 2148916237 => "account needs adult verification".into(), + 2148916238 => "child account — must be added to a Family".into(), + other => format!("XSTS failed, XErr {other}"), + } + ); + } + if res.status() != 200 { + let body = res.body_mut().read_to_string()?; + anyhow::bail!("xsts failed ({}): {body}", res.status()); + } + Ok(res.body_mut().read_json()?) +} +fn mc_token(agent: &Agent, uhs: &str, xsts_token: &str) -> anyhow::Result { + let mut res = agent.post(MC_LOGIN_URL).send_json(serde_json::json!({ + "identityToken": format!("XBL3.0 x={uhs};{xsts_token}") + }))?; + if res.status() != 200 { + let body = res.body_mut().read_to_string()?; + anyhow::bail!("mc login failed ({}): {body}", res.status()); + } + let t: McTokenResponse = res.body_mut().read_json()?; + Ok(t.access_token) +} +fn profile(agent: &Agent, mc_token: &str) -> anyhow::Result { + let mut res = agent + .get(PROFILE_URL) + .header("Authorization", &format!("Bearer {mc_token}")) + .call()?; + if res.status() == 404 { + anyhow::bail!("this account doesn't own Minecraft Java"); + } + if res.status() != 200 { + let body = res.body_mut().read_to_string()?; + anyhow::bail!("profile failed ({}): {body}", res.status()); + } + Ok(res.body_mut().read_json()?) +} +pub fn login() -> anyhow::Result { + let agent = agent(); + + let (ms, refresh) = match std::fs::read_to_string(token_path()?) { + Ok(cached) => match refresh(&agent, cached.trim()) { + Ok(pair) => pair, + Err(_) => { + // expired or revoked + let device = device_code(&agent)?; + poll(&agent, &device)? + } + }, + Err(_) => { + // no file yet + let device = device_code(&agent)?; + poll(&agent, &device)? + } + }; + save_refresh(&refresh)?; + let xbl = xbl(&agent, &ms)?; + let uhs = xbl.display_claims.xui[0].uhs.clone(); + let xuid = xbl.display_claims.xui[0].xid.clone().unwrap_or_default(); + + let xsts = xsts(&agent, &xbl.token)?; + let mc = mc_token(&agent, &uhs, &xsts.token)?; + let p = profile(&agent, &mc)?; + + Ok(Account { + name: p.name, + uuid: p.id, + access_token: mc, + xuid, + }) +} + +// pub fn gen_offline(name: &str) -> Account { +// let uuid = uuid::Uuid::new_v3( +// &uuid::Uuid::NAMESPACE_OID, +// format!("OfflinePlayer:{name}").as_bytes(), +// ); +// Account { +// name: name.to_string(), +// uuid: uuid.simple().to_string(), +// access_token: "0".to_string(), +// xuid: String::new(), +// } +// } diff --git a/src/download.rs b/src/download.rs new file mode 100644 index 0000000..c309c54 --- /dev/null +++ b/src/download.rs @@ -0,0 +1,93 @@ +use crate::meta::{AssetObjects, VersionDetail, wanted}; +use indicatif::{ParallelProgressIterator, ProgressBar, ProgressStyle}; +use rayon::prelude::*; +use sha2::Digest; +use std::fs::{File, create_dir_all}; +use std::io::copy; +use std::path::Path; +use ureq::get; +pub fn download(url: &str, path: &Path) -> anyhow::Result<()> { + if let Some(parent) = path.parent() { + create_dir_all(parent)?; + } + let mut res = get(url).call()?; + let mut file = File::create(path)?; + copy(&mut res.body_mut().as_reader(), &mut file)?; + Ok(()) +} + +pub fn client(detail: &VersionDetail, shared_dir: &Path, version_id: &str) -> anyhow::Result<()> { + let out = shared_dir + .join("versions") + .join(version_id) + .join(format!("{version_id}.jar")); + if !out.exists() { + println!("Downloading client: {}...", detail.downloads.client.url); + download(&detail.downloads.client.url, &out)?; + } + Ok(()) +} +pub fn libraries(detail: &VersionDetail, shared_dir: &Path) -> anyhow::Result<()> { + println!("Downloading libraries..."); + let libs_dir = shared_dir.join("libraries"); + let needed: Vec<_> = detail + .libraries + .iter() + .filter(|l| wanted(l)) + .filter(|l| !libs_dir.join(&l.downloads.artifact.path).exists()) + .collect(); + + if !needed.is_empty() { + let pb = ProgressBar::new(needed.len() as u64); + pb.set_style(ProgressStyle::with_template("{bar:40} {pos}/{len} {msg}").unwrap()); + for lib in &needed { + let a = &lib.downloads.artifact; + pb.set_message(a.path.clone()); + download(&a.url, &libs_dir.join(&a.path))?; + pb.inc(1); + } + pb.finish_and_clear(); + } + Ok(()) +} +pub fn assets(detail: &VersionDetail, shared_dir: &Path) -> anyhow::Result<()> { + println!("Downloading assets..."); + let index: AssetObjects = get(&detail.asset_index.url) + .call()? + .body_mut() + .read_json()?; + + let index_path = shared_dir + .join("assets") + .join("indexes") + .join(format!("{}.json", detail.asset_index.id)); + if !index_path.exists() { + download(&detail.asset_index.url, &index_path)?; + } + + let objects_dir = shared_dir.join("assets").join("objects"); + let pb = ProgressBar::new(index.objects.len() as u64); + pb.set_style(ProgressStyle::with_template("{bar:40} {pos}/{len} ({eta})").unwrap()); + index + .objects + .par_iter() + .progress_with(pb) + .try_for_each(|(_, obj)| -> anyhow::Result<()> { + let sub = &obj.hash[..2]; + let url = format!( + "https://resources.download.minecraft.net/{sub}/{}", + obj.hash + ); + let path = objects_dir.join(sub).join(&obj.hash); + if !path.exists() { + download(&url, &path)?; + } + Ok(()) + })?; + Ok(()) +} +pub fn verify_sha512(path: &Path, expected: &str) -> anyhow::Result { + let mut hasher = sha2::Sha512::new(); + std::io::copy(&mut File::open(path)?, &mut hasher)?; + Ok(format!("{:x}", hasher.finalize()) == expected) +} diff --git a/src/fabric.rs b/src/fabric.rs new file mode 100644 index 0000000..24b2e8e --- /dev/null +++ b/src/fabric.rs @@ -0,0 +1,89 @@ +use std::collections::HashSet; + +use crate::meta::{Library, VersionDetail}; +use anyhow::Context; +use serde::Deserialize; +use ureq::get; + +const META: &str = "https://meta.fabricmc.net/v2/versions/loader"; + +#[derive(Deserialize)] +struct LoaderEntry { + loader: LoaderInfo, +} + +#[derive(Deserialize)] +struct LoaderInfo { + version: String, + stable: bool, +} + +#[derive(Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct Profile { + pub main_class: String, + pub libraries: Vec, +} + +#[derive(Deserialize)] +pub struct FabricLibrary { + name: String, + url: String, +} +fn loaders(mc_version: &str) -> anyhow::Result> { + let url = format!("{META}/{mc_version}"); + Ok(get(&url).call()?.body_mut().read_json()?) +} + +pub fn latest_loader(mc: &str) -> anyhow::Result { + let entries = loaders(mc)?; + entries + .iter() + .find(|e| e.loader.stable) + .or(entries.first()) + .map(|e| e.loader.version.clone()) + .ok_or_else(|| anyhow::anyhow!("no fabric loader for {mc}")) +} + +pub fn check_loader(mc: &str, loader: &str) -> anyhow::Result<()> { + if !loaders(mc)?.iter().any(|e| e.loader.version == loader) { + anyhow::bail!("fabric loader {loader} isn't available for {mc}"); + } + Ok(()) +} +fn maven_to_path(coord: &str) -> anyhow::Result { + let mut parts = coord.split(':'); + let group = parts.next().context("bad coord")?; + let artifact = parts.next().context("bad coord")?; + let version = parts.next().context("bad coord")?; + Ok(format!( + "{}/{artifact}/{version}/{artifact}-{version}.jar", + group.replace('.', "/") + )) +} +pub fn fetch_profile(mc: &str, loader: &str) -> anyhow::Result { + let url = format!("{META}/{mc}/{loader}/profile/json"); + Ok(get(&url).call()?.body_mut().read_json()?) +} +fn coord_key(name: &str) -> &str { + match name.match_indices(':').nth(1) { + Some((i, _)) => &name[..i], + None => name, + } +} +pub fn merge(detail: &mut VersionDetail, profile: Profile) -> anyhow::Result<()> { + let mut libs = Vec::new(); + for fl in &profile.libraries { + let path = maven_to_path(&fl.name)?; + let url = format!("{}{path}", fl.url); + libs.push(Library::unconditional(fl.name.clone(), url, path)); + } + let keys: HashSet<&str> = libs.iter().map(|l| coord_key(&l.name)).collect(); + detail + .libraries + .retain(|l| !keys.contains(coord_key(&l.name))); + libs.append(&mut detail.libraries); + detail.libraries = libs; + detail.main_class = profile.main_class; + Ok(()) +} diff --git a/src/instance.rs b/src/instance.rs new file mode 100644 index 0000000..8fc00fb --- /dev/null +++ b/src/instance.rs @@ -0,0 +1,95 @@ +use anyhow::Ok; +use serde::{Deserialize, Serialize}; +use std::{ + fs::create_dir_all, + path::{Path, PathBuf}, +}; +#[derive(Serialize, Deserialize)] +pub struct Instance { + pub version: String, + #[serde(default)] + pub loader: Option, +} + +#[derive(Serialize, Deserialize)] +pub struct Loader { + pub kind: String, + pub version: String, +} + +pub fn create(instances_dir: &Path, name: &str, version: &str) -> anyhow::Result { + if name.contains('/') { + anyhow::bail!("unusable characters in path."); + } + let directory = instances_dir.join(name); + if directory.join("instance.json").exists() { + anyhow::bail!("instance already exists here!"); + } + create_dir_all(&directory)?; + let cfg = Instance { + version: version.to_string(), + loader: None, + }; + save(&directory, &cfg)?; + Ok(directory) +} +pub fn save(dir: &Path, cfg: &Instance) -> anyhow::Result<()> { + let json = serde_json::to_string_pretty(cfg)?; + std::fs::write(dir.join("instance.json"), json)?; + Ok(()) +} + +pub fn load(root: &Path, name: &str) -> anyhow::Result<(Instance, PathBuf)> { + let dir = root.join(name); + let cfg_path = dir.join("instance.json"); + if !cfg_path.exists() { + anyhow::bail!("no instance named {name}"); + } + let json = std::fs::read_to_string(cfg_path)?; + Ok((serde_json::from_str(&json)?, dir)) +} +pub fn list(root: &Path) -> anyhow::Result> { + if !root.exists() { + return Ok(Vec::new()); + } + let mut out = Vec::new(); + for entry in std::fs::read_dir(root)? { + let entry = entry?; + if entry.path().join("instance.json").exists() { + out.push(entry.file_name().to_string_lossy().to_string()); + } + } + out.sort(); + Ok(out) +} +pub fn remove(instances_dir: &Path, name: &str, yes: bool) -> anyhow::Result<()> { + let dir = instances_dir.join(&name); + if !dir.exists() { + anyhow::bail!("no instance named {name}"); + } + if !yes { + print!("Delete {name} and all its worlds? [y/N] "); + std::io::Write::flush(&mut std::io::stdout())?; + let mut a = String::new(); + std::io::stdin().read_line(&mut a)?; + if !a.trim().eq_ignore_ascii_case("y") { + anyhow::bail!("aborted"); + } + } + std::fs::remove_dir_all(&dir)?; + println!("Removed {name}."); + Ok(()) +} +pub fn sanitize(name: &str) -> String { + name.chars() + .map(|c| { + if c.is_alphanumeric() || " -_.".contains(c) { + c + } else { + '-' + } + }) + .collect::() + .trim_matches(['-', '.', ' ']) + .to_string() +} diff --git a/src/launch.rs b/src/launch.rs new file mode 100644 index 0000000..a383faf --- /dev/null +++ b/src/launch.rs @@ -0,0 +1,104 @@ +use crate::{ + auth::Account, + meta::{Arg, ArgValue, VersionDetail, rules_allow, wanted}, +}; +use std::{collections::HashMap, fs::create_dir_all, path::Path, process::Command}; + +fn flatten(args: &[Arg]) -> Vec { + let mut out = Vec::new(); + for arg in args { + match arg { + Arg::Plain(s) => out.push(s.clone()), + Arg::Conditional { rules, value } => { + if !rules_allow(rules) { + continue; + } + match value { + ArgValue::One(s) => out.push(s.clone()), + ArgValue::Many(v) => out.extend(v.iter().cloned()), + } + } + } + } + out +} +fn substitute(tokens: Vec, vars: &HashMap<&str, String>) -> Vec { + tokens + .into_iter() + .map(|mut t| { + for (k, v) in vars { + t = t.replace(k, v); + } + t + }) + .collect() +} +pub fn run( + detail: &VersionDetail, + game_dir: &Path, + shared_dir: &Path, + account: &Account, + version_type: &str, + version_id: &str, +) -> anyhow::Result<()> { + let client_jar = shared_dir + .join("versions") + .join(version_id) + .join(format!("{version_id}.jar")); + + let mut vars = HashMap::new(); + + let mut classpath: Vec = detail + .libraries + .iter() + .filter(|l| wanted(l)) + .map(|l| { + shared_dir + .join("libraries") + .join(&l.downloads.artifact.path) + .display() + .to_string() + }) + .collect(); + classpath.push(client_jar.display().to_string()); + + vars.insert("${classpath}", classpath.join(":")); + vars.insert( + "${natives_directory}", + shared_dir.join("natives").display().to_string(), + ); + vars.insert("${auth_player_name}", account.name.clone()); + vars.insert("${launcher_name}", "uml".to_string()); + vars.insert("${launcher_version}", "1.0".to_string()); + vars.insert("${version_name}", version_id.to_string()); + vars.insert("${game_directory}", game_dir.display().to_string()); + vars.insert( + "${assets_root}", + shared_dir.join("assets").display().to_string(), + ); + vars.insert("${assets_index_name}", detail.asset_index.id.clone()); + vars.insert("${auth_uuid}", account.uuid.clone()); + vars.insert("${auth_access_token}", account.access_token.clone()); + vars.insert("${clientid}", String::new()); + vars.insert("${auth_xuid}", account.xuid.clone()); + vars.insert("${version_type}", version_type.to_string()); + + let jvm_args = substitute(flatten(&detail.arguments.jvm), &vars); + let game_args = substitute(flatten(&detail.arguments.game), &vars); + + for sub in ["java", "jna", "lwjgl", "netty"] { + create_dir_all(shared_dir.join("natives").join(sub))?; + } + + let status = Command::new("java") // This is what makes UML, UML! the heart of the program. + .current_dir(game_dir) + .args(&jvm_args) + .arg(&detail.main_class) + .args(&game_args) + .status()?; + if !status.success() { + anyhow::bail!("minecraft exited with {status}"); + } + + Ok(()) +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..16fc62d --- /dev/null +++ b/src/main.rs @@ -0,0 +1,196 @@ +mod auth; // this is painful, ai helped a bit btw (i try to use ai as little as possible, but this part's just ANNOYING) +mod download; +mod fabric; +mod instance; +mod launch; +mod meta; +mod mrpack; +mod prism; +use crate::{launch::run, meta::fetch_version}; +use clap::{Parser, Subcommand}; +use std::path::{Path, PathBuf}; + +/// Untitled Minecraft Launcher +#[derive(Parser)] +#[command(name = "uml")] +struct Cli { + #[command(subcommand)] + command: Command, +} +#[derive(Clone, clap::ValueEnum)] +enum LoaderKind { + Fabric, +} +#[derive(Subcommand)] +enum Command { + /// Launch an instance + #[command(alias = "l")] + Launch { + #[arg(trailing_var_arg = true)] + name: Vec, + // disabled until i redo the account system + // #[arg(long)] + // offline: bool, + }, + /// Manage instances + Instances { + #[command(subcommand)] + action: InstanceCmd, + }, +} + +#[derive(Subcommand)] +enum InstanceCmd { + /// Create a new instance + New { + name: String, + #[arg(long)] + version: String, + }, + /// Import a Modrinth modpack + Import { + pack: PathBuf, + #[arg(long)] + name: Option, + #[arg(short = 'y', long)] + yes: bool, + }, + /// Import a Prism Launcher instance + ImportPrism { + path: PathBuf, + #[arg(long)] + name: Option, + }, + /// Install a mod loader on an instance + Mod { + name: String, + #[arg(long, value_enum, default_value_t = LoaderKind::Fabric)] + loader: LoaderKind, + #[arg(long)] + loader_version: Option, + }, + /// Unmod an instance + Unmod { name: String }, + /// Remove an instance + Remove { + name: String, + #[arg(short = 'y', long)] + yes: bool, + }, + /// List instances + List, +} +fn data_dir() -> anyhow::Result { + if let Ok(xdg) = std::env::var("XDG_DATA_HOME") { + if !xdg.is_empty() { + return Ok(Path::new(&xdg).join("uml")); + } + } + let home = std::env::var("HOME")?; + Ok(Path::new(&home).join(".local").join("share").join("uml")) +} + +fn main() -> anyhow::Result<()> { + let uml_dir = data_dir()?; + let instances_dir = uml_dir.join("instances"); + let shared_dir = uml_dir.join("shared"); + + let cli = Cli::parse(); + match cli.command { + Command::Instances { action } => match action { + InstanceCmd::New { name, version } => { + if !meta::version_exists(&version)? { + anyhow::bail!("no such Minecraft version: {version}"); + } + instance::create(&instances_dir, &name, &version)?; + } + InstanceCmd::Import { pack, name, yes } => { + mrpack::import(&pack, &instances_dir, name.as_deref(), yes)?; + } + InstanceCmd::ImportPrism { path, name } => { + prism::import(&path, &instances_dir, name.as_deref())?; + } + InstanceCmd::Remove { name, yes } => { + instance::remove(&instances_dir, &name, yes)?; + } + InstanceCmd::List => { + for n in instance::list(&instances_dir)? { + println!("{n}"); + } + } + InstanceCmd::Unmod { name } => { + let (mut cfg, dir) = instance::load(&instances_dir, &name)?; + if cfg.loader.is_none() { + anyhow::bail!("{name} has no loader"); + } + cfg.loader = None; + instance::save(&dir, &cfg)?; + println!("Removed loader from {name}."); + } + InstanceCmd::Mod { + name, + loader, + loader_version, + } => { + let (mut cfg, dir) = instance::load(&instances_dir, &name)?; + + let (kind, version) = match loader { + LoaderKind::Fabric => { + let v = match loader_version { + Some(v) => { + fabric::check_loader(&cfg.version, &v)?; + v + } + None => fabric::latest_loader(&cfg.version)?, + }; + ("fabric", v) + } + }; + + cfg.loader = Some(instance::Loader { + kind: kind.to_string(), + version: version.clone(), + }); + instance::save(&dir, &cfg)?; + std::fs::create_dir_all(dir.join("mods"))?; + println!("Installed {kind} {version} on {name}."); + } + }, + Command::Launch { name } => { + //, offline } => { + let name = name.join(" "); + let (cfg, game_dir) = instance::load(&instances_dir, &name)?; + let game_version = cfg.version; + let (mut detail, version_type) = fetch_version(&game_version)?; + + // let account = if !offline { + let account = auth::login()?; + // } else { + // auth::gen_offline("TESTING-USER") + // }; + + if let Some(loader) = &cfg.loader { + let profile = match loader.kind.as_str() { + "fabric" => fabric::fetch_profile(&game_version, &loader.version)?, + other => anyhow::bail!("unknown loader: {other}"), + }; + fabric::merge(&mut detail, profile)?; + } + + download::client(&detail, &shared_dir, &game_version)?; + download::libraries(&detail, &shared_dir)?; + download::assets(&detail, &shared_dir)?; + + // Congrats! you found the main part of the program! + run( + &detail, + &game_dir, + &shared_dir, + &account, + &version_type, + &game_version, + )?; + } + } + Ok(()) +} diff --git a/src/meta.rs b/src/meta.rs new file mode 100644 index 0000000..eb46010 --- /dev/null +++ b/src/meta.rs @@ -0,0 +1,179 @@ +use serde::Deserialize; +use std::collections::HashMap; +use ureq::get; + +const MANIFEST_URL: &str = "https://piston-meta.mojang.com/mc/game/version_manifest_v2.json"; + +#[derive(Deserialize)] +pub struct Manifest { + pub versions: Vec, +} + +#[derive(Deserialize)] +#[serde(rename_all = "camelCase")] +#[allow(dead_code)] +pub struct Version { + pub id: String, + #[serde(rename = "type")] + pub kind: String, + pub url: String, + pub time: String, + pub release_time: String, + pub sha1: String, + pub compliance_level: u32, +} + +#[derive(Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct ClientDetails { + pub url: String, +} + +#[derive(Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct MainDownloads { + pub client: ClientDetails, +} +#[derive(Deserialize)] +pub struct Library { + pub name: String, + pub downloads: LibraryDownloads, + #[serde(default)] + rules: Vec, +} + +#[derive(Deserialize)] +pub struct LibraryDownloads { + pub artifact: Artifact, +} + +#[derive(Deserialize)] +#[allow(dead_code)] +pub struct Artifact { + pub url: String, + pub sha1: Option, + pub path: String, +} + +#[derive(Deserialize)] +pub struct Rule { + action: String, + #[serde(default)] + os: Option, + #[serde(default)] + features: Option>, +} + +#[derive(Deserialize)] +struct Os { + #[serde(default)] + name: Option, + #[serde(default)] + arch: Option, +} +#[derive(Deserialize)] +pub struct AssetIndex { + pub id: String, + pub url: String, +} +#[derive(Deserialize)] +pub struct AssetObjects { + pub objects: HashMap, +} + +#[derive(Deserialize)] +pub struct AssetObject { + pub hash: String, +} + +#[derive(Deserialize)] +pub struct Arguments { + #[serde(default)] + pub game: Vec, + #[serde(default)] + pub jvm: Vec, +} + +#[derive(Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct VersionDetail { + pub downloads: MainDownloads, + pub libraries: Vec, + pub asset_index: AssetIndex, + pub arguments: Arguments, + pub main_class: String, +} + +impl Library { + pub fn unconditional(name: String, url: String, path: String) -> Self { + Library { + downloads: LibraryDownloads { + artifact: Artifact { + url, + path, + sha1: None, + }, + }, + rules: Vec::new(), + name: name, + } + } +} + +#[derive(Deserialize)] +#[serde(untagged)] +pub enum Arg { + Plain(String), + Conditional { rules: Vec, value: ArgValue }, +} + +#[derive(Deserialize)] +#[serde(untagged)] +pub enum ArgValue { + One(String), + Many(Vec), +} + +fn os_applies(os: &Os) -> bool { + if let Some(name) = &os.name { + if name != "linux" { + return false; + } + } + if let Some(arch) = &os.arch { + if arch != "x86_64" { + return false; + } + } + true +} + +pub fn rules_allow(rules: &[Rule]) -> bool { + let mut allowed = rules.is_empty(); + for r in rules { + let applies = r.features.is_none() && r.os.as_ref().map_or(true, os_applies); + if applies { + allowed = r.action == "allow"; + } + } + allowed +} + +pub fn wanted(lib: &Library) -> bool { + rules_allow(&lib.rules) +} + +pub fn fetch_version(version_id: &str) -> anyhow::Result<(VersionDetail, String)> { + let manifest: Manifest = get(MANIFEST_URL).call()?.body_mut().read_json()?; + let version = manifest + .versions + .iter() + .find(|v| v.id == version_id) + .ok_or_else(|| anyhow::anyhow!("version {version_id} not found"))?; + let detail: VersionDetail = get(&version.url).call()?.body_mut().read_json()?; + Ok((detail, version.kind.clone())) +} +pub fn version_exists(version_id: &str) -> anyhow::Result { + let manifest: Manifest = get(MANIFEST_URL).call()?.body_mut().read_json()?; + Ok(manifest.versions.iter().any(|v| v.id == version_id)) +} diff --git a/src/mrpack.rs b/src/mrpack.rs new file mode 100644 index 0000000..46e8a06 --- /dev/null +++ b/src/mrpack.rs @@ -0,0 +1,172 @@ +use crate::{ + download::download, + download::verify_sha512, + instance::{Loader, create, load, save}, +}; +use indicatif::{ProgressBar, ProgressStyle}; +use serde::Deserialize; +use std::{collections::HashMap, fs::File, io::Write, path::Path}; +use zip::ZipArchive; +#[derive(Deserialize)] +#[serde(rename_all = "camelCase")] +#[allow(dead_code)] +struct Index { + format_version: u32, + game: String, // now what is modrinth up to? + version_id: String, + name: String, + files: Vec, + dependencies: HashMap, +} +#[derive(Deserialize)] +struct PackFile { + path: String, + hashes: Hashes, + downloads: Vec, + #[serde(default)] + env: Option, +} +#[derive(Deserialize)] +struct Hashes { + sha512: String, +} + +#[derive(Deserialize)] +struct Env { + client: String, +} + +fn extract_overrides( + archive: &mut ZipArchive, + prefix: &str, + instance_dir: &Path, +) -> anyhow::Result<()> { + for i in 0..archive.len() { + let mut entry = archive.by_index(i)?; + let name = entry.name().to_string(); + + let Some(rel) = name.strip_prefix(prefix) else { + continue; + }; + if rel.is_empty() || entry.is_dir() { + continue; + } + if rel.contains("..") || rel.starts_with('/') { + anyhow::bail!("suspicious path in pack: {name}"); + } + + let dest = instance_dir.join(rel); + if let Some(parent) = dest.parent() { + std::fs::create_dir_all(parent)?; + } + let mut out = File::create(&dest)?; + std::io::copy(&mut entry, &mut out)?; + } + Ok(()) +} + +pub fn import( + pack: &Path, + instances_dir: &Path, + name: Option<&str>, + yes: bool, +) -> anyhow::Result<()> { + let mut archive = ZipArchive::new(File::open(pack)?)?; + let index_file = archive.by_name("modrinth.index.json")?; + let index: Index = serde_json::from_reader(index_file)?; + if index.format_version != 1 { + anyhow::bail!("unsupported mrpack format version {}", index.format_version); + } + + let instance_name = match name { + Some(n) => n.to_string(), + None => crate::instance::sanitize(&index.name), + }; + let mc = index + .dependencies + .get("minecraft") + .ok_or_else(|| anyhow::anyhow!("pack has no minecraft version"))?; + + let loader = if let Some(v) = index.dependencies.get("fabric-loader") { + Some(Loader { + kind: "fabric".to_string(), + version: v.clone(), + }) + } else if index.dependencies.contains_key("forge") + || index.dependencies.contains_key("neoforge") + { + anyhow::bail!("Forge modpacks are not currently supported."); + } else if index.dependencies.contains_key("quilt-loader") { + anyhow::bail!("Quilt modpacks are not currently supported."); + } else { + println!( + "This modpack either doesn't have a modloader, or uses one that is unsupported. This is fine, but any mods won't load." + ); + None + }; + + let as_name = match name { + Some(n) => format!(" as {n}"), + None => String::new(), + }; + + let wanted: Vec<_> = index + .files + .iter() + .filter(|f| f.env.as_ref().map_or(true, |e| e.client != "unsupported")) + .collect(); + + let loader_bit = match &loader { + Some(l) => format!(", which will use {} with {} mods", l.kind, wanted.len()), + None => String::new(), + }; + + println!( + "You are importing the modpack {}{}, this modpack will use minecraft version {}{}.", + index.name, as_name, mc, loader_bit + ); + if !yes { + print!("Continue? [y/N] "); + std::io::stdout().flush()?; + + let mut answer = String::new(); + std::io::stdin().read_line(&mut answer)?; + + if !answer.trim().eq_ignore_ascii_case("y") { + anyhow::bail!("aborted"); + } + } + println!("Creating instance..."); + let instance_dir = create(instances_dir, &instance_name, mc)?; + let (mut cfg, _) = load(instances_dir, &instance_name)?; + cfg.loader = loader; + save(&instance_dir, &cfg)?; + println!("Downloading files..."); + let pb = ProgressBar::new(wanted.len() as u64); + pb.set_style(ProgressStyle::with_template("{bar:40} {pos}/{len} {msg}").unwrap()); + + for f in &wanted { + if f.path.contains("..") || f.path.starts_with('/') { + anyhow::bail!("suspicious path in pack: {}", f.path); + } + pb.set_message(f.path.clone()); + let dest = instance_dir.join(&f.path); + if !dest.exists() || !verify_sha512(&dest, &f.hashes.sha512)? { + let url = f + .downloads + .first() + .ok_or_else(|| anyhow::anyhow!("no download url for {}", f.path))?; + download(url, &dest)?; + if !verify_sha512(&dest, &f.hashes.sha512)? { + anyhow::bail!("hash mismatch after download: {}", f.path); + } + } + pb.inc(1); + } + pb.finish_and_clear(); + println!("Copying overrides..."); + extract_overrides(&mut archive, "overrides/", &instance_dir)?; + extract_overrides(&mut archive, "client-overrides/", &instance_dir)?; + println!("The modpack has (probably) been installed successfully!"); + Ok(()) +} diff --git a/src/prism.rs b/src/prism.rs new file mode 100644 index 0000000..2ff42d6 --- /dev/null +++ b/src/prism.rs @@ -0,0 +1,81 @@ +use crate::instance::{Loader, create, load, save}; +use serde::Deserialize; +use std::path::Path; +#[derive(Deserialize)] +struct MmcPack { + components: Vec, +} + +#[derive(Deserialize)] +struct Component { + uid: String, + #[serde(default)] + version: Option, +} + +fn find<'a>(pack: &'a MmcPack, uid: &str) -> Option<&'a str> { + pack.components + .iter() + .find(|c| c.uid == uid) + .and_then(|c| c.version.as_deref()) +} + +fn copy_dir(src: &Path, dst: &Path) -> anyhow::Result<()> { + for entry in std::fs::read_dir(src)? { + let entry = entry?; + let from = entry.path(); + let to = dst.join(entry.file_name()); + if entry.file_type()?.is_dir() { + std::fs::create_dir_all(&to)?; + copy_dir(&from, &to)?; // recurse into subdirectories + } else { + std::fs::copy(&from, &to)?; // std's single-file copy + } + } + Ok(()) +} + +pub fn import(prism_dir: &Path, instances_dir: &Path, name: Option<&str>) -> anyhow::Result<()> { + let json = std::fs::read_to_string(prism_dir.join("mmc-pack.json"))?; + let pack: MmcPack = serde_json::from_str(&json)?; + + let mc = + find(&pack, "net.minecraft").ok_or_else(|| anyhow::anyhow!("no minecraft component"))?; + + let loader = if let Some(v) = find(&pack, "net.fabricmc.fabric-loader") { + Some(Loader { + kind: "fabric".into(), + version: v.to_string(), + }) + } else if find(&pack, "net.minecraftforge").is_some() || find(&pack, "net.neoforged").is_some() + { + anyhow::bail!("Forge instances aren't supported yet"); + } else if find(&pack, "org.quiltmc.quilt-loader").is_some() { + anyhow::bail!("Quilt instances aren't supported yet"); + } else { + None + }; + + let instance_name = match name { + Some(n) => n.to_string(), + None => prism_dir + .file_name() + .and_then(|s| s.to_str()) + .map(crate::instance::sanitize) + .ok_or_else(|| anyhow::anyhow!("bad prism path"))?, + }; + + let dir = create(instances_dir, &instance_name, mc)?; + let (mut cfg, _) = load(instances_dir, &instance_name)?; + cfg.loader = loader; + save(&dir, &cfg)?; + + let src = prism_dir.join("minecraft"); + if !src.exists() { + anyhow::bail!("no minecraft in {}", prism_dir.display()); + } + copy_dir(&src, &dir)?; + + println!("Imported {instance_name} (minecraft {mc})"); + Ok(()) +}